ScatterPlot::ScatterPlot(Context *context) : context(context) { setAutoDelete(false); // no don't delete on detach ! curve = NULL; curve2 = NULL; hover = NULL; hover2 = NULL; grid = NULL; ride = NULL; static_cast<QwtPlotCanvas*>(canvas())->setFrameStyle(QFrame::NoFrame); setAxisMaxMinor(xBottom, 0); setAxisMaxMinor(yLeft, 0); QwtScaleDraw *sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(QwtPlot::xBottom, sd); sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); setAxisScaleDraw(QwtPlot::yLeft, sd); connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); connect(context, SIGNAL(intervalHover(IntervalItem*)), this, SLOT(intervalHover(IntervalItem*))); // lets watch the mouse move... new mouseTracker(this); configChanged(CONFIG_APPEARANCE | CONFIG_GENERAL); // use latest wheelsize/cranklength and colors }
void HrPwPlot::configChanged(qint32) { // setColors bg setCanvasBackground(GColor(CPLOTBACKGROUND)); QPalette palette; palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND))); palette.setBrush(QPalette::Background, QBrush(GColor(CPLOTBACKGROUND))); palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER)); palette.setColor(QPalette::Text, GColor(CPLOTMARKER)); setPalette(palette); // tick draw QwtScaleDraw *sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->setTickLength(QwtScaleDiv::MinorTick, 0); setAxisScaleDraw(QwtPlot::xBottom, sd); axisWidget(QwtPlot::xBottom)->setPalette(palette); sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); setAxisScaleDraw(QwtPlot::yLeft, sd); axisWidget(QwtPlot::yLeft)->setPalette(palette); QPen gridPen; gridPen.setColor(GColor(CPLOTGRID)); grid->setPen(gridPen); }
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 PlotMatrix::updateLayout() { for ( int row = 0; row < numRows(); row++ ) { for ( int col = 0; col < numColumns(); col++ ) { QwtPlot *p = plot( row, col ); if ( p ) { bool showAxis[QwtPlot::axisCnt]; showAxis[QwtPlot::xBottom] = axisEnabled( QwtPlot::xBottom ) && row == numRows() - 1; showAxis[QwtPlot::xTop] = axisEnabled( QwtPlot::xTop ) && row == 0; showAxis[QwtPlot::yLeft] = axisEnabled( QwtPlot::yLeft ) && col == 0; showAxis[QwtPlot::yRight] = axisEnabled( QwtPlot::yRight ) && col == numColumns() - 1; for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) { if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop ) p->enableAxis( axis, showAxis[axis] ); else { p->enableAxis( axis, true ); QwtScaleDraw *sd = p->axisScaleDraw( axis ); sd->enableComponent( QwtScaleDraw::Backbone, showAxis[axis] ); sd->enableComponent( QwtScaleDraw::Ticks, showAxis[axis] ); sd->enableComponent( QwtScaleDraw::Labels, showAxis[axis] ); } } } } } for ( int col = 0; col < numColumns(); col++ ) { alignVAxes( col, QwtPlot::yLeft ); alignVAxes( col, QwtPlot::yRight ); } for ( int row = 0; row < numRows(); row++ ) { for ( int col = 0; col < numColumns(); col++ ) { QwtPlot *p = plot( row, col ); if ( p ) p->replot(); } } }
void PowerHist::setYMax() { double MaxY = curve->maxYValue(); if (MaxY < curveSelected->maxYValue()) MaxY = curveSelected->maxYValue(); static const double tmin = 1.0/60; setAxisScale(yLeft, (lny ? tmin : 0.0), MaxY * 1.1); QwtScaleDraw *sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); setAxisScaleDraw(QwtPlot::yLeft, sd); }
static void enablePlotAxis( QwtPlot *plot, int axis, bool on ) { // when false we still enable the axis to have an effect // of the minimal extent active. Instead we hide all visible // parts and margins/spacings. plot->enableAxis( axis, true ); QwtScaleDraw *sd = plot->axisScaleDraw( axis ); sd->enableComponent( QwtScaleDraw::Backbone, on ); sd->enableComponent( QwtScaleDraw::Ticks, on ); sd->enableComponent( QwtScaleDraw::Labels, on ); QwtScaleWidget* sw = plot->axisWidget( axis ); sw->setMargin( on ? 4 : 0 ); sw->setSpacing( on ? 20 : 0 ); }
ScatterPlot::ScatterPlot(Context *context) : context(context) { all = NULL; grid = NULL; static_cast<QwtPlotCanvas*>(canvas())->setFrameStyle(QFrame::NoFrame); setAxisMaxMinor(xBottom, 0); setAxisMaxMinor(yLeft, 0); QwtScaleDraw *sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(QwtPlot::xBottom, sd); sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); setAxisScaleDraw(QwtPlot::yLeft, sd); connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); configChanged(); // use latest colors etc }
VectorPlot::VectorPlot(QWidget *parent, const QString &title, SetLegend * externalLegend) : QWidget(parent), legend(externalLegend) { this->setMinimumHeight(200); QwtText titleText(title); QFont titleTextFont(titleText.font()); titleTextFont.setPointSize(10); titleText.setFont(titleTextFont); plot = new QwtPlot(titleText, this); plot->setCanvasBackground(Qt::white); //plot->setGeometry(ui.widget_plot->geometry()); plot->setAxisScale(QwtPlot::xBottom, 0, 0.01); plot->setAxisScale(QwtPlot::yLeft, 0, 0.01); for ( int i = 0; i < QwtPlot::axisCnt; i++ ) { plot->setAxisAutoScale(i); QwtScaleWidget *scaleWidget = (QwtScaleWidget *)plot->axisWidget(i); if ( scaleWidget ) scaleWidget->setMargin(0); QwtScaleDraw *scaleDraw = (QwtScaleDraw *)plot->axisScaleDraw(i); if ( scaleDraw ) scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); } plot->canvas()->setFrameStyle(QFrame::Box|QFrame::Plain); plot->setAutoReplot(true); //plot->setMinimumSize(QSize(200, 200)); //this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); plot->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); QPen pen(QColor(255, 0, 0)); marker1 = new QwtPlotMarker(); marker1->setLineStyle(QwtPlotMarker::VLine); marker1->setLinePen(pen); marker1->setXValue(0); marker2 = new QwtPlotMarker(); marker2->setLineStyle(QwtPlotMarker::VLine); marker2->setLinePen(pen); marker2->setXValue(0); zoomer = 0; }
// // Set a plain canvas frame and align the scales to it // void DataPlot::alignScales() { canvas()->setFrameStyle(QFrame::Box | QFrame::Plain ); canvas()->setLineWidth(1); for ( int i = 0; i < QwtPlot::axisCnt; i++ ) { QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i); if ( scaleWidget ) scaleWidget->setMargin(0); QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i); if ( scaleDraw ) scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); } }
void XYZPlot::alignScales() { // The code below shows how to align the scales to // the canvas frame, but is also a good example demonstrating // why the spreaded API needs polishing. canvas()->setFrameStyle(QFrame::Box | QFrame::Plain); canvas()->setLineWidth(1); for (int i = 0; i < QwtPlot::axisCnt; i++) { QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i); if (scaleWidget) scaleWidget->setMargin(0); QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i); if (scaleDraw) scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); } }
// // Set a plain canvas frame and align the scales to it // void Plotter::alignScales() { // The code below shows how to align the scales to // the canvas frame, but is also a good example demonstrating // why the spreaded API needs polishing. for ( int i = 0; i < QwtPlot::axisCnt; i++ ) { QwtScaleWidget *scaleWidget = axisWidget( i ); if ( scaleWidget ) scaleWidget->setMargin( 0 ); QwtScaleDraw *scaleDraw = axisScaleDraw( i ); if ( scaleDraw ) scaleDraw->enableComponent( QwtAbstractScaleDraw::Backbone, false ); } plotLayout()->setAlignCanvasToScales( true ); }
MUPlot::MUPlot(MUWidget *muw, CriticalPowerWindow *parent, Context *context) : QwtPlot(parent), QwtSyntheticPointData(MUN), context(context), muw(muw), parent(parent), modelCurve(NULL), slowCurve(NULL), fastCurve(NULL), mmpCurve(NULL) { // initalise all the model stufff // probably abstract this out later muSet = NULL; slowHandle = NULL; slowLine = NULL; slowDrag = false; fastHandle = NULL; fastLine = NULL; fastDrag = false; setAutoDelete(false); setAutoFillBackground(true); static_cast<QwtPlotCanvas*>(canvas())->setFrameStyle(QFrame::NoFrame); // left yAxis scale prettify 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("w(x)")); setAxisMaxMinor(yLeft, 0); plotLayout()->setAlignCanvasToScales(true); // 0.5 increments on bottom axis QwtValueList ytick[QwtScaleDiv::NTickTypes]; for (double i=0.0f; i<=10.0f; i+= 1.0) ytick[QwtScaleDiv::MajorTick]<<i; setAxisScaleDiv(yLeft,QwtScaleDiv(0.0f,10.0f,ytick)); // bottom xAxis scale prettify sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); setAxisScaleDraw(xBottom, sd); setAxisTitle(xBottom, tr("Motor Unit, x")); setAxisMaxMinor(xBottom, 0); // 0.2 increments on bottom axis QwtValueList xtick[QwtScaleDiv::NTickTypes]; for (double i=0.0f; i<=1.0f; i+= 0.2) xtick[QwtScaleDiv::MajorTick]<<i; setAxisScaleDiv(xBottom,QwtScaleDiv(0.0f,1.0f,xtick)); // now color everything we created configChanged(CONFIG_APPEARANCE); // set to a 2 Normal Model setModel(2); // set mouse tracker parent->setMouseTracking(true); installEventFilter(parent); new muMouseTracker(this); }
PfPvPlot::PfPvPlot(Context *context) : rideItem (NULL), context(context), hover(NULL), cp_ (0), cad_ (85), cl_ (0.175), shade_zones(true) { static_cast<QwtPlotCanvas*>(canvas())->setFrameStyle(QFrame::NoFrame); setAutoFillBackground(true); setAxisTitle(yLeft, tr("Average Effective Pedal Force (N)")); setAxisScale(yLeft, 0, 600); setAxisTitle(xBottom, tr("Circumferential Pedal Velocity (m/s)")); setAxisScale(xBottom, 0, 3); setAxisMaxMinor(yLeft, 0); setAxisMaxMinor(xBottom, 0); QwtScaleDraw *sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(xBottom, sd); sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); setAxisScaleDraw(yLeft, sd); mX = new QwtPlotMarker(); mX->setLineStyle(QwtPlotMarker::VLine); mX->attach(this); mY = new QwtPlotMarker(); mY->setLineStyle(QwtPlotMarker::HLine); mY->attach(this); cpCurve = new QwtPlotCurve(); cpCurve->setRenderHint(QwtPlotItem::RenderAntialiased); cpCurve->attach(this); curve = new QwtPlotCurve(); curve->attach(this); cl_ = appsettings->value(this, GC_CRANKLENGTH).toDouble() / 1000.0; // markup timeInQuadrant tiqMarker[0] = new QwtPlotMarker(); tiqMarker[0]->attach(this); tiqMarker[0]->setXValue(2.9); tiqMarker[0]->setYValue(580); tiqMarker[1] = new QwtPlotMarker(); tiqMarker[1]->attach(this); tiqMarker[1]->setXValue(0.1); tiqMarker[1]->setYValue(580); tiqMarker[2] = new QwtPlotMarker(); tiqMarker[2]->attach(this); tiqMarker[2]->setXValue(0.1); tiqMarker[2]->setYValue(10); tiqMarker[3] = new QwtPlotMarker(); tiqMarker[3]->attach(this); tiqMarker[3]->setXValue(2.9); tiqMarker[3]->setYValue(10); merge_intervals = false; frame_intervals = true; // only default on first time through, after this the user may have adjusted if (appsettings->value(this, GC_SHADEZONES, true).toBool()==false) shade_zones = false; else shade_zones = true; configChanged(); recalc(); }
void SaxsviewImage::setYTickLabelsVisible(bool on) { QwtScaleDraw *scale = axisScaleDraw(QwtPlot::yLeft); scale->enableComponent(QwtAbstractScaleDraw::Labels, on); updateLayout(); }