Plot::Plot( QWidget *parent ): QwtPlot( parent ) { setPalette( QColor( 60, 60, 60 ) ); canvas()->setPalette( Qt::white ); // panning with the left mouse button ( void ) new QwtPlotPanner( canvas() ); // zoom in/out with the wheel ( void ) new QwtPlotMagnifier( canvas() ); setTitle( "Shapes" ); insertLegend( new QwtLegend(), QwtPlot::RightLegend ); // axes setAxisTitle( QwtAxis::xBottom, "x -->" ); setAxisTitle( QwtAxis::yLeft, "y -->" ); #if 0 setAxisScaleEngine( QwtAxis::xBottom, new QwtLog10ScaleEngine ); setAxisScaleEngine( QwtAxis::yLeft, new QwtLog10ScaleEngine ); #endif populate(); }
void Plot::setLogScaling (bool d) { if (d == true) setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine); else setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine); }
void Plot::setLogScaling (bool d) { if (d == TRUE) setAxisScaleEngine(QwtPlot::yRight, new QwtLog10ScaleEngine); else setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine); // replot(); }
Spectrogramplot::Spectrogramplot(int numDataPoints, int numRows, QWidget *parent) :QwtPlot(parent) ,nData_(numDataPoints) ,nRows_(numRows) { spectrogram_ = new QwtPlotSpectrogram(); spectrogram_->setRenderThreadCount(0); // set system specific thread count data_ = new WaterfallData(nData_, nRows_); spectrogram_->attach(this); setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true); axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true); spectrogram_->setColorMap(new ColorMap()); spectrogram_->setData(data_); setXAxisRange(0, nData_); setYAxisRange(0, nRows_); setZAxisScale(-1,1); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size zoomer_ = new MyZoomer(qobject_cast<QwtPlotCanvas*>(canvas())); zoomer_->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton); zoomer_->setMousePattern(QwtEventPattern::MouseSelect2, Qt::LeftButton, Qt::ControlModifier); panner_ = new QwtPlotPanner(canvas()); panner_->setAxisEnabled(QwtPlot::yRight, false); panner_->setMouseButton(Qt::RightButton); magnifier_ = new QwtPlotMagnifier(canvas()); magnifier_->setMouseButton(Qt::NoButton); // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); sd->setMinimumExtent( fm.width("100.00") ); const QColor c(Qt::darkBlue); zoomer_->setRubberBandPen(c); zoomer_->setTrackerPen(c); }
Lineplot::Lineplot(QWidget *parent) :QwtPlot(parent) ,xMin_(0) ,xMax_(0) { counter_ = 0; numPoints_ = 1; indexPoints_ = new double[numPoints_]; dataPoints_ = new double[numPoints_]; setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QPalette palette; palette.setColor(canvas()->backgroundRole(), QColor("white")); canvas()->setPalette(palette); curve_ = new QwtPlotCurve("Curve"); curve_->setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); curve_->setStyle(QwtPlotCurve::Lines); curve_->setRawSamples(indexPoints_, dataPoints_, numPoints_); curve_->setYAxis(QwtPlot::yLeft); curve_->attach(this); memset(dataPoints_, 0x0, numPoints_*sizeof(double)); for(int i=0;i<numPoints_;i++) indexPoints_[i] = i; enableAxis(QwtPlot::yRight); QwtScaleWidget *leftAxis = axisWidget(QwtPlot::yLeft); connect(leftAxis, SIGNAL(scaleDivChanged()), this, SLOT(linkScales())); setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine); axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true); axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true); axisScaleEngine(QwtPlot::yRight)->setAttribute(QwtScaleEngine::Floating,true); zoomer_ = new MyZoomer(canvas()); zoomer_->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton); zoomer_->setMousePattern(QwtEventPattern::MouseSelect2, Qt::LeftButton, Qt::ControlModifier); panner_ = new QwtPlotPanner(canvas()); panner_->setMouseButton(Qt::RightButton); magnifier_ = new QwtPlotMagnifier(canvas()); magnifier_->setMouseButton(Qt::NoButton); }
void QcepPlot::setLogAxis(int axis, int isLog) { if (axis >= 0 && axis < QwtPlot::axisCnt) { m_IsLog[axis] = isLog; if (isLog) { setAxisScaleEngine(axis, new QwtLogScaleEngine); } else { setAxisScaleEngine(axis, new QwtLinearScaleEngine); } replot(); } }
void Plot::setLogX(bool on){ if(!on){ setAxisScaleEngine( QwtPlot::xBottom, new QwtLinearScaleEngine ); setAxisAutoScale(QwtPlot::xBottom); } else{ setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine ); setAxisScale(QwtPlot::xBottom,0.01,d_curve1->maxXValue()*2); } }
HistoricPlot::HistoricPlot(QWidget *parent) :QwtPlot(parent) { //Fondo del canvas negro canvas()->setPalette(Qt::black); //Auto repintar las curvas setAutoReplot(true); setTitle("Historian Variable Plot"); // Grid m_grid = new QwtPlotGrid; m_grid->enableXMin( true ); m_grid->setMajorPen( Qt::gray, 0, Qt::DotLine ); m_grid->setMinorPen( Qt::darkGray, 0, Qt::DotLine ); m_grid->attach( this ); //Scale m_scaleDraw = new QwtDateScaleDraw( Qt::UTC ); m_scaleDraw->setDateFormat( QwtDate::Millisecond, "hh:mm:ss:zzz\nddd dd MMM yyyy" ); m_scaleDraw->setDateFormat( QwtDate::Second, "hh:mm:ss\nddd dd MMM yyyy" ); m_scaleDraw->setDateFormat( QwtDate::Minute, "hh:mm\nddd dd MMM yyyy" ); m_scaleDraw->setDateFormat( QwtDate::Hour, "hh:mm\nddd dd MMM yyyy" ); m_scaleDraw->setDateFormat( QwtDate::Day, "ddd dd MMM yyyy" ); m_scaleDraw->setDateFormat( QwtDate::Week, "Www yyyy" ); m_scaleDraw->setDateFormat( QwtDate::Month, "MMM yyyy" ); m_scaleDraw->setDateFormat( QwtDate::Year, "yyyy"); m_scaleEngine = new QwtDateScaleEngine( Qt::UTC ); //Axis setAxisTitle( QwtPlot::xBottom, QString( "Time" ) ); setAxisScaleDraw( QwtPlot::xBottom, m_scaleDraw ); setAxisScaleEngine( QwtPlot::xBottom, m_scaleEngine ); setAxisLabelRotation( QwtPlot::xBottom, -50.0 ); setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom ); setAxisTitle( QwtPlot::yLeft, QString( "Value" ) ); //Legend m_legend = new QwtLegend; insertLegend(m_legend); //Zoomer m_zoomer = new Zoomer( canvas() ); m_zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); m_zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); //Panner m_panner = new QwtPlotPanner( canvas() ); m_panner->setMouseButton( Qt::MidButton ); resize(800,600); }
CpintPlot::CpintPlot(Context *context, QString p, const Zones *zones, bool rangemode) : path(p), thisCurve(NULL), CPCurve(NULL), allCurve(NULL), zones(zones), series(RideFile::watts), context(context), current(NULL), bests(NULL), isFiltered(false), shadeMode(2), rangemode(rangemode) { setAutoFillBackground(true); setAxisTitle(xBottom, tr("Interval Length")); LogTimeScaleDraw *ld = new LogTimeScaleDraw; ld->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(xBottom, ld); setAxisScaleEngine(xBottom, new QwtLogScaleEngine); QwtScaleDiv div( (double)0.017, (double)60 ); div.setTicks(QwtScaleDiv::MajorTick, LogTimeScaleDraw::ticks); setAxisScaleDiv(QwtPlot::xBottom, div); QwtScaleDraw *sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); setAxisScaleDraw(yLeft, sd); setAxisTitle(yLeft, tr("Average Power (watts)")); setAxisMaxMinor(yLeft, 0); plotLayout()->setAlignCanvasToScales(true); //grid = new QwtPlotGrid(); //grid->enableX(true); //grid->attach(this); curveTitle.attach(this); curveTitle.setXValue(5); curveTitle.setYValue(60); curveTitle.setLabel(QwtText("", QwtText::PlainText)); // default to no title zoomer = new penTooltip(static_cast<QwtPlotCanvas*>(this->canvas())); zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier); canvasPicker = new LTMCanvasPicker(this); static_cast<QwtPlotCanvas*>(canvas())->setFrameStyle(QFrame::NoFrame); connect(canvasPicker, SIGNAL(pointHover(QwtPlotCurve*, int)), this, SLOT(pointHover(QwtPlotCurve*, int))); configChanged(); // apply colors ecp = new ExtendedCriticalPower(context); extendedCPCurve4 = NULL; extendedCurveTitle2 = NULL; }
void Plot::setLogY(bool on){ /* * Amplification means voltage ratio V2 / V1 = Vout / Vin, and voltage gain in dB = 20 × log (V2 / V1). * */ if(!on){ setAxisScaleEngine( QwtPlot::yLeft, new QwtLinearScaleEngine ); setAxisAutoScale(QwtPlot::yLeft); } else{ setAxisScaleEngine( QwtPlot::yLeft, new QwtLogScaleEngine ); setAxisScale(QwtPlot::yLeft,d_average->minYValue(),d_average->maxYValue()*2); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RiuSummaryQwtPlot::useDateBasedTimeAxis() { QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC); scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy")); QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC); setAxisScaleEngine(QwtPlot::xBottom, scaleEngine); setAxisScaleDraw(QwtPlot::xBottom, scaleDraw); }
/** * Set the log scale on the y axis */ void OneCurvePlot::setYLogScale() { const QwtScaleDiv *div = axisScaleDiv(QwtPlot::yLeft); double from = div->lBound(); double to = div->hBound(); QwtLog10ScaleEngine* logEngine = new QwtLog10ScaleEngine(); setAxisScaleEngine(yLeft,logEngine); setYScale(from,to); recalcYAxisDivs(); replot(); }
CpintPlot::CpintPlot(Context *context, QString p, const Zones *zones) : path(p), thisCurve(NULL), CPCurve(NULL), allCurve(NULL), zones(zones), series(RideFile::watts), context(context), current(NULL), bests(NULL), isFiltered(false), shadeMode(2) { setInstanceName("CP Plot"); assert(!USE_T0_IN_CP_MODEL); // doesn't work with energyMode=true setAxisTitle(xBottom, tr("Interval Length")); LogTimeScaleDraw *ld = new LogTimeScaleDraw; ld->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(xBottom, ld); setAxisScaleEngine(xBottom, new LogTimeScaleEngine); setAxisScale(xBottom, (double)0.017, (double)60); QwtScaleDraw *sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(yLeft, sd); setAxisTitle(yLeft, tr("Average Power (watts)")); setAxisMaxMinor(yLeft, 0); plotLayout()->setAlignCanvasToScales(true); grid = new QwtPlotGrid(); grid->enableX(true); grid->attach(this); curveTitle.attach(this); curveTitle.setXValue(5); curveTitle.setYValue(20); curveTitle.setLabel(QwtText("", QwtText::PlainText)); // default to no title zoomer = new penTooltip(this->canvas()); zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier); canvasPicker = new LTMCanvasPicker(this); canvas()->setFrameStyle(QFrame::NoFrame); connect(canvasPicker, SIGNAL(pointHover(QwtPlotCurve*, int)), this, SLOT(pointHover(QwtPlotCurve*, int))); configChanged(); // apply colors }
Plot::Plot( QWidget *parent ): QwtPlot( parent ) { setTitle( "Trading Chart" ); QwtDateScaleDraw *scaleDraw = new DateScaleDraw( Qt::UTC ); QwtDateScaleEngine *scaleEngine = new QwtDateScaleEngine( Qt::UTC ); setAxisTitle( QwtPlot::xBottom, QString( "2010" ) ); setAxisScaleDraw( QwtPlot::xBottom, scaleDraw ); setAxisScaleEngine( QwtPlot::xBottom, scaleEngine ); setAxisLabelRotation( QwtPlot::xBottom, -50.0 ); setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom ); setAxisTitle( QwtPlot::yLeft, QString( "Price [EUR]" ) ); #if 0 QwtLegend *legend = new QwtLegend; legend->setDefaultItemMode( QwtLegendData::Checkable ); insertLegend( legend, QwtPlot::RightLegend ); #else Legend *legend = new Legend; insertLegend( legend, QwtPlot::RightLegend ); #endif populate(); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size Zoomer* zoomer = new Zoomer( canvas() ); zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); panner->setMouseButton( Qt::MidButton ); connect( legend, SIGNAL( checked( QwtPlotItem *, bool, int ) ), SLOT( showItem( QwtPlotItem *, bool ) ) ); }
void Plot::initAxis( int axis, const QString& title, Qt::TimeSpec timeSpec ) { setAxisTitle( axis, title ); QwtDateScaleDraw *scaleDraw = new QwtDateScaleDraw( timeSpec ); QwtDateScaleEngine *scaleEngine = new QwtDateScaleEngine( timeSpec ); #if 0 if ( timeSpec == Qt::LocalTime ) { scaleDraw->setTimeSpec( Qt::OffsetFromUTC ); scaleDraw->setUtcOffset( 10 ); scaleEngine->setTimeSpec( Qt::OffsetFromUTC ); scaleEngine->setUtcOffset( 10 ); } #endif setAxisScaleDraw( axis, scaleDraw ); setAxisScaleEngine( axis, scaleEngine ); }
void Plot::setTransformation( QwtTransform *transform ) { QwtLinearScaleEngine *scaleEngine = new QwtLinearScaleEngine(); scaleEngine->setTransformation( transform ); setAxisScaleEngine( QwtAxis::xBottom, scaleEngine ); // we have to reassign the axis settinge, because they are // invalidated, when the scale engine has changed QwtScaleDiv scaleDiv = axisScaleEngine( QwtAxis::xBottom )->divideScale( 10.0, 1000.0, 8, 10 ); QList<double> ticks; ticks += 10.0; ticks += scaleDiv.ticks( QwtScaleDiv::MajorTick ); scaleDiv.setTicks( QwtScaleDiv::MajorTick, ticks ); setAxisScaleDiv( QwtAxis::xBottom, scaleDiv ); replot(); }
/** * Set the linear scale on the y axis */ void OneCurvePlot::setYLinearScale() { QwtLinearScaleEngine* engine = new QwtLinearScaleEngine(); setAxisScaleEngine(yLeft,engine); replot(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RiuSummaryQwtPlot::useTimeBasedTimeAxis() { setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine()); setAxisScaleDraw(QwtPlot::xBottom, new QwtScaleDraw()); }
bool CopasiPlot::initFromSpec(const CPlotSpecification* plotspec) { mIgnoreUpdate = true; mpPlotSpecification = plotspec; if (mpZoomer) mpZoomer->setEnabled(false); // size_t k, kmax = mpPlotSpecification->getItems().size(); setTitle(FROM_UTF8(mpPlotSpecification->getTitle())); mCurves.resize(mpPlotSpecification->getItems().size()); mCurves = NULL; std::map< std::string, C2DPlotCurve * >::iterator found; CCopasiVector< CPlotItem >::const_iterator itPlotItem = mpPlotSpecification->getItems().begin(); CCopasiVector< CPlotItem >::const_iterator endPlotItem = mpPlotSpecification->getItems().end(); CVector< bool > Visible(mpPlotSpecification->getItems().size()); Visible = true; bool * pVisible = Visible.array(); for (; itPlotItem != endPlotItem; ++itPlotItem, ++pVisible) { // Qwt does not like it to reuse the curve as this may lead to access // violation. We therefore delete the curves but remember their visibility. if ((found = mCurveMap.find((*itPlotItem)->CCopasiParameter::getKey())) != mCurveMap.end()) { *pVisible = found->second->isVisible(); } } // Remove unused curves if definition has changed std::map< std::string, C2DPlotCurve * >::iterator it = mCurveMap.begin(); std::map< std::string, C2DPlotCurve * >::iterator end = mCurveMap.end(); for (; it != end; ++it) pdelete(it->second); mCurveMap.clear(); itPlotItem = mpPlotSpecification->getItems().begin(); pVisible = Visible.array(); C2DPlotCurve ** ppCurve = mCurves.array(); unsigned long int k = 0; bool needLeft = false; bool needRight = false; for (; itPlotItem != endPlotItem; ++itPlotItem, ++pVisible, ++ppCurve, ++k) { // set up the curve C2DPlotCurve * pCurve = new C2DPlotCurve(&mMutex, (*itPlotItem)->getType(), (*itPlotItem)->getActivity(), FROM_UTF8((*itPlotItem)->getTitle())); *ppCurve = pCurve; mCurveMap[(*itPlotItem)->CCopasiParameter::getKey()] = pCurve; //color handling should be similar for different curve types QColor color; if (pCurve->getType() == CPlotItem::curve2d || pCurve->getType() == CPlotItem::histoItem1d || pCurve->getType() == CPlotItem::bandedGraph) { std::string colorstr = *(*itPlotItem)->getValue("Color").pSTRING; color = CQPlotColors::getColor(colorstr, k); } pCurve->setPen(color); pCurve->attach(this); showCurve(pCurve, *pVisible); if (pCurve->getType() == CPlotItem::curve2d || pCurve->getType() == CPlotItem::bandedGraph) { needLeft = true; pCurve->setRenderHint(QwtPlotItem::RenderAntialiased); unsigned C_INT32 linetype = *(*itPlotItem)->getValue("Line type").pUINT; if (linetype == 0 //line || linetype == 3) //line+symbols { pCurve->setStyle(QwtPlotCurve::Lines); unsigned C_INT32 linesubtype = *(*itPlotItem)->getValue("Line subtype").pUINT; C_FLOAT64 width = *(*itPlotItem)->getValue("Line width").pUDOUBLE; switch (linesubtype) //symbol type { case 1: pCurve->setPen(QPen(QBrush(color), width, Qt::DotLine, Qt::FlatCap)); break; case 2: pCurve->setPen(QPen(QBrush(color), width, Qt::DashLine)); break; case 3: pCurve->setPen(QPen(QBrush(color), width, Qt::DashDotLine)); break; case 4: pCurve->setPen(QPen(QBrush(color), width, Qt::DashDotDotLine)); break; case 0: default: pCurve->setPen(QPen(QBrush(color), width, Qt::SolidLine)); break; } } if (linetype == 1) //points { C_FLOAT64 width = *(*itPlotItem)->getValue("Line width").pUDOUBLE; pCurve->setPen(QPen(color, width, Qt::SolidLine, Qt::RoundCap)); pCurve->setStyle(QwtPlotCurve::Dots); } if (linetype == 2) //only symbols { pCurve->setStyle(QwtPlotCurve::NoCurve); } if (linetype == 2 //symbols || linetype == 3) //line+symbols { unsigned C_INT32 symbolsubtype = *(*itPlotItem)->getValue("Symbol subtype").pUINT; switch (symbolsubtype) //symbol type { case 1: pCurve->setSymbol(QwtSymbol(QwtSymbol::Cross, QBrush(), QPen(QBrush(color), 2), QSize(7, 7))); break; case 2: pCurve->setSymbol(QwtSymbol(QwtSymbol::Ellipse, QBrush(), QPen(QBrush(color), 1), QSize(8, 8))); break; case 0: default: pCurve->setSymbol(QwtSymbol(QwtSymbol::Cross, QBrush(color), QPen(QBrush(color), 1), QSize(5, 5))); break; } } } //2d curves and banded graphs if (pCurve->getType() == CPlotItem::bandedGraph) { //set fill color QColor c = color; c.setAlpha(64); pCurve->setBrush(c); } if (pCurve->getType() == CPlotItem::histoItem1d) { pCurve->setIncrement(*(*itPlotItem)->getValue("increment").pDOUBLE); pCurve->setStyle(QwtPlotCurve::Steps); pCurve->setYAxis(QwtPlot::yRight); pCurve->setCurveAttribute(QwtPlotCurve::Inverted); needRight = true; } } if (plotspec->isLogX()) setAxisScaleEngine(xBottom, new QwtLog10ScaleEngine()); else setAxisScaleEngine(xBottom, new QwtLinearScaleEngine()); setAxisAutoScale(xBottom); if (plotspec->isLogY()) setAxisScaleEngine(yLeft, new QwtLog10ScaleEngine()); else setAxisScaleEngine(yLeft, new QwtLinearScaleEngine()); setAxisAutoScale(yLeft); enableAxis(yLeft, needLeft); if (needRight) { setAxisScaleEngine(yRight, new QwtLinearScaleEngine()); setAxisTitle(yRight, "Percent %"); enableAxis(yRight); } mIgnoreUpdate = false; return true; //TODO really check! }
void CpintPlot::setSeries(RideFile::SeriesType x) { series = x; // Log scale for all bar Energy setAxisScaleEngine(xBottom, new LogTimeScaleEngine); setAxisScaleDraw(xBottom, new LogTimeScaleDraw); setAxisTitle(xBottom, tr("Interval Length")); switch (series) { case RideFile::none: setAxisTitle(yLeft, tr("Total work (kJ)")); setAxisScaleEngine(xBottom, new QwtLinearScaleEngine); setAxisScaleDraw(xBottom, new QwtScaleDraw); setAxisTitle(xBottom, tr("Interval Length (minutes)")); break; case RideFile::cad: setAxisTitle(yLeft, tr("Average Cadence (rpm)")); break; case RideFile::hr: setAxisTitle(yLeft, tr("Average Heartrate (bpm)")); break; case RideFile::kph: setAxisTitle(yLeft, tr("Average Speed (kph)")); break; case RideFile::nm: setAxisTitle(yLeft, tr("Average Pedal Force (nm)")); break; case RideFile::NP: setAxisTitle(yLeft, tr("Normalized Power (watts)")); break; case RideFile::xPower: setAxisTitle(yLeft, tr("Skiba xPower (watts)")); break; case RideFile::wattsKg: if (mainWindow->useMetricUnits) setAxisTitle(yLeft, tr("Watts per kilo (watts/kg)")); else setAxisTitle(yLeft, tr("Watts per lb (watts/lb)")); break; case RideFile::vam: setAxisTitle(yLeft, tr("VAM (meters per hour)")); break; default: case RideFile::watts: setAxisTitle(yLeft, tr("Average Power (watts)")); break; } delete CPCurve; CPCurve = NULL; clear_CP_Curves(); if (allCurve) { delete allCurve; allCurve = NULL; } }
Plot::Plot( QWidget *parent ): QwtPlot( parent ) { setAutoReplot( false ); setTitle( "Frequency Response of a Second-Order System" ); QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setBorderRadius( 10 ); setCanvas( canvas ); setCanvasBackground( QColor( "MidnightBlue" ) ); // legend QwtLegend *legend = new QwtLegend; insertLegend( legend, QwtPlot::BottomLegend ); // grid QwtPlotGrid *grid = new QwtPlotGrid; grid->enableXMin( true ); grid->setMajorPen( Qt::white, 0, Qt::DotLine ); grid->setMinorPen( Qt::gray, 0 , Qt::DotLine ); grid->attach( this ); // axes enableAxis( QwtPlot::yRight ); setAxisTitle( QwtPlot::xBottom, "Normalized Frequency" ); setAxisTitle( QwtPlot::yLeft, "Amplitude [dB]" ); setAxisTitle( QwtPlot::yRight, "Phase [deg]" ); setAxisMaxMajor( QwtPlot::xBottom, 6 ); setAxisMaxMinor( QwtPlot::xBottom, 9 ); setAxisScaleEngine( QwtPlot::xBottom, new QwtLogScaleEngine ); // curves d_curve1 = new QwtPlotCurve( "Amplitude" ); d_curve1->setRenderHint( QwtPlotItem::RenderAntialiased ); d_curve1->setPen( Qt::yellow ); d_curve1->setLegendAttribute( QwtPlotCurve::LegendShowLine ); d_curve1->setYAxis( QwtPlot::yLeft ); d_curve1->attach( this ); d_curve2 = new QwtPlotCurve( "Phase" ); d_curve2->setRenderHint( QwtPlotItem::RenderAntialiased ); d_curve2->setPen( Qt::cyan ); d_curve2->setLegendAttribute( QwtPlotCurve::LegendShowLine ); d_curve2->setYAxis( QwtPlot::yRight ); d_curve2->attach( this ); // marker d_marker1 = new QwtPlotMarker(); d_marker1->setValue( 0.0, 0.0 ); d_marker1->setLineStyle( QwtPlotMarker::VLine ); d_marker1->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom ); d_marker1->setLinePen( Qt::green, 0, Qt::DashDotLine ); d_marker1->attach( this ); d_marker2 = new QwtPlotMarker(); d_marker2->setLineStyle( QwtPlotMarker::HLine ); d_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom ); d_marker2->setLinePen( QColor( 200, 150, 0 ), 0, Qt::DashDotLine ); d_marker2->setSymbol( new QwtSymbol( QwtSymbol::Diamond, QColor( Qt::yellow ), QColor( Qt::green ), QSize( 8, 8 ) ) ); d_marker2->attach( this ); setDamp( 0.0 ); setAutoReplot( true ); }
Plot::Plot(int width, int height, QWidget *parent, const char *) : QwtPlot(parent) { setAutoReplot (false); marker_key = 0; curve_key = 0; minTickLength = 5; majTickLength = 9; setGeometry(QRect(0, 0, width, height)); setAxisTitle(QwtPlot::yLeft, tr("Y Axis Title")); setAxisTitle(QwtPlot::xBottom, tr("X Axis Title")); //due to the plot layout updates, we must always have a non empty title setAxisTitle(QwtPlot::yRight, tr(" ")); setAxisTitle(QwtPlot::xTop, tr(" ")); // grid d_grid = new Grid(); d_grid->attach(this); //custom scale for (int i= 0; i<QwtPlot::axisCnt; i++) { QwtScaleWidget *scale = (QwtScaleWidget *) axisWidget(i); if (scale) { scale->setMargin(0); //the axis title color must be initialized... QwtText title = scale->title(); title.setColor(Qt::black); scale->setTitle(title); //...same for axis color QPalette pal = scale->palette(); pal.setColor(QPalette::Foreground, QColor(Qt::black)); scale->setPalette(pal); ScaleDraw *sd = new ScaleDraw(this); sd->setTickLength(QwtScaleDiv::MinorTick, minTickLength); sd->setTickLength(QwtScaleDiv::MediumTick, minTickLength); sd->setTickLength(QwtScaleDiv::MajorTick, majTickLength); setAxisScaleDraw (i, sd); setAxisScaleEngine (i, new ScaleEngine()); } } QwtPlotLayout *pLayout = plotLayout(); pLayout->setCanvasMargin(0); pLayout->setAlignCanvasToScales (true); QwtPlotCanvas* plCanvas = canvas(); plCanvas->setFocusPolicy(Qt::StrongFocus); plCanvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator); //plCanvas->setFocus(); plCanvas->setFrameShadow(QwtPlot::Plain); plCanvas->setCursor(Qt::arrowCursor); plCanvas->setLineWidth(0); plCanvas->setPaintAttribute(QwtPlotCanvas::PaintCached, false); plCanvas->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); QColor background = QColor(Qt::white); background.setAlpha(255); QPalette palette; palette.setColor(QPalette::Window, background); setPalette(palette); setCanvasBackground (background); setFocusPolicy(Qt::StrongFocus); //setFocusProxy(plCanvas); setFrameShape(QFrame::Box); setLineWidth(0); }