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); }
/*! \brief Assign a scale division The scale division determines where to set the tick marks. \param transformation Transformation, needed to translate between scale and pixal values \param scaleDiv Scale Division \sa For more information about scale divisions, see QwtScaleDiv. */ void QwtScaleWidget::setScaleDiv( QwtScaleTransformation *transformation, const QwtScaleDiv &scaleDiv ) { QwtScaleDraw *sd = d_data->scaleDraw; if ( sd->scaleDiv() != scaleDiv || sd->scaleMap().transformation()->type() != transformation->type() ) { sd->setTransformation( transformation ); sd->setScaleDiv( scaleDiv ); layoutScale(); Q_EMIT scaleDivChanged(); } else { /* The transformation doesn't anything different as the previous one. So we better throw it silently away instead of initiating heavy updates */ delete transformation; } }
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 PlotMatrix::alignVAxes( int col, int axis ) { if ( axis != QwtPlot::yLeft && axis != QwtPlot::yRight ) return; double maxExtent = 0; for ( int row = 0; row < numRows(); row++ ) { QwtPlot *p = plot( row, col ); if ( p ) { QwtScaleWidget *scaleWidget = p->axisWidget( axis ); QwtScaleDraw *sd = scaleWidget->scaleDraw(); sd->setMinimumExtent( 0.0 ); const double extent = sd->extent( scaleWidget->font() ); if ( extent > maxExtent ) maxExtent = extent; } } for ( int row = 0; row < numRows(); row++ ) { QwtPlot *p = plot( row, col ); if ( p ) { QwtScaleWidget *scaleWidget = p->axisWidget( axis ); scaleWidget->scaleDraw()->setMinimumExtent( maxExtent ); } } }
PerfPlot::PerfPlot() : STScurve(NULL), LTScurve(NULL), SBcurve(NULL), DAYcurve(NULL) { xsd = new PPTimeScaleDraw(QDateTime()); xsd->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(QwtPlot::xBottom, xsd); insertLegend(new QwtLegend(), QwtPlot::BottomLegend); setAxisTitle(yLeft, tr("Exponentially Weighted Average Stress")); setAxisTitle(xBottom, tr("Time (days)")); setAxisTitle(yRight, tr("Daily Stress")); enableAxis(yRight, true); static_cast<QwtPlotCanvas*>(canvas())->setFrameStyle(QFrame::NoFrame); setAxisMaxMinor(xBottom, 0); setAxisMaxMinor(yLeft, 0); setAxisMaxMinor(yRight, 0); QwtScaleDraw *sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(QwtPlot::yLeft, sd); sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(QwtPlot::yRight, sd); grid = new QwtPlotGrid(); grid->attach(this); configUpdate(); }
bool SaxsviewImage::minorTicksVisible() const { // // All axis are in sync, just pick one. // QwtScaleDraw *draw = p->scales[QwtPlot::xBottom]->scaleDraw(); return draw->tickLength(QwtScaleDiv::MinorTick) > 0; }
void BarChart::setOrientation( int o ) { const Qt::Orientation orientation = ( o == 0 ) ? Qt::Vertical : Qt::Horizontal; int axis1 = QwtPlot::xBottom; int axis2 = QwtPlot::yLeft; if ( orientation == Qt::Horizontal ) qSwap( axis1, axis2 ); d_barChartItem->setOrientation( orientation ); setAxisTitle( axis1, "Distros" ); setAxisMaxMinor( axis1, 3 ); setAxisScaleDraw( axis1, new DistroScaleDraw( orientation, d_distros ) ); setAxisTitle( axis2, "Hits per day ( HPD )" ); setAxisMaxMinor( axis2, 3 ); QwtScaleDraw *scaleDraw = new QwtScaleDraw(); scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 4 ); setAxisScaleDraw( axis2, scaleDraw ); plotLayout()->setCanvasMargin( 0 ); replot(); }
DataPlot::DataPlot(QWidget *parent, TelemetryStateReceiver* collector, OdometryStateReceiver* odometryReceiver,QMap<QString, QStringList> *list) : QwtPlot(parent), d_interval(0), d_timerId(-1) { node=collector; odom_receiver=odometryReceiver; connect_status=false; QObject::connect( node, SIGNAL( parameterReceived( )), this, SLOT( onParameterReceived( ))); data_count=0; posicionBuffer=PLOT_SIZE; colors_list <<"red"<<"blue"<<"green"<<"black"<<"yellow"<<"magenta"<<"cyan"<<"gray"<<"darkCyan"<<"darkMagenta"<<"darkYellow"<<"darkGray"<<"darkRed"<<"darkBlue"<<"darkGreen"<<"lightGray" <<"red"<<"blue"<<"green"<<"black"<<"yellow"<<"magenta"<<"cyan"<<"gray"<<"darkCyan"<<"darkMagenta"<<"darkYellow"<<"darkGray"<<"darkRed"<<"darkBlue"<<"darkGreen"<<"lightGray" <<"red"<<"blue"<<"green"<<"black"<<"yellow"<<"magenta"<<"cyan"<<"gray"<<"darkCyan"<<"darkMagenta"<<"darkYellow"<<"darkGray"<<"darkRed"<<"darkBlue"<<"darkGreen"<<"lightGray" <<"red"<<"blue"<<"green"<<"black"<<"yellow"<<"magenta"<<"cyan"<<"gray"<<"darkCyan"<<"darkMagenta"<<"darkYellow"<<"darkGray"<<"darkRed"<<"darkBlue"<<"darkGreen"<<"lightGray"; iterator_colors=0; is_stop_pressed=false; alignScales(); setAutoReplot(false); parameters_list = setCurveLabels(*list); current_min_limit=0; current_max_limit=0; QwtPlotZoomer* zoomer = new MyZoomer(canvas()); QwtPlotPanner *panner = new QwtPlotPanner(canvas()); panner->setAxisEnabled(QwtPlot::yRight, true); panner->setMouseButton(Qt::MidButton); // 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); setGridPlot(); initTimeData(); #if 0 // Insert zero line at y = 0 QwtPlotMarker *mY = new QwtPlotMarker(); mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); mY->setLineStyle(QwtPlotMarker::HLine); mY->setYValue(0.0); mY->attach(this); #endif initAxisX(); initAxisY(); initCurves(); setTimerInterval(1000);// 1 second = 1000 }
void SaxsviewImage::setMajorTicksVisible(bool on) { for (int i = QwtPlot::yLeft; i < QwtPlot::axisCnt; ++i) { QwtScaleDraw *draw = p->scales[i]->scaleDraw(); draw->setTickLength(QwtScaleDiv::MajorTick, on ? 8 : 0); } replot(); }
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; }
/*! Change the alignment of the scale The alignment sets the orientation of the scale and the position of the ticks: - QwtScaleDraw::BottomScale: horizontal, ticks below - QwtScaleDraw::TopScale: horizontal, ticks above - QwtScaleDraw::LeftScale: vertical, ticks left - QwtScaleDraw::RightScale: vertical, ticks right For horizontal scales the position corresponds to QwtPlotItem::yAxis(), otherwise to QwtPlotItem::xAxis(). \sa scaleDraw(), QwtScaleDraw::alignment(), setPosition() */ void QwtPlotScaleItem::setAlignment( QwtScaleDraw::Alignment alignment ) { QwtScaleDraw *sd = d_data->scaleDraw; if ( sd->alignment() != alignment ) { sd->setAlignment( alignment ); itemChanged(); } }
Plot::Plot( QWidget *parent ): QwtPlot( parent ), d_formatType( 0 ), d_alpha(255) { d_spectrogram = new QwtPlotSpectrogram(); d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count d_spectrogram->setCachePolicy( QwtPlotRasterItem::PaintCache ); QList<double> contourLevels; for ( double level = 0.5; level < 10.0; level += 1.0 ) contourLevels += level; d_spectrogram->setContourLevels( contourLevels ); d_spectrogram->setData( new SpectrogramData() ); d_spectrogram->attach( this ); const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); // A color bar on the right axis QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight ); rightAxis->setTitle( "Intensity" ); rightAxis->setColorBarEnabled( true ); setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() ); enableAxis( QwtPlot::yRight ); plotLayout()->setAlignCanvasToScales( true ); setColorMap( Plot::RGBMap ); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size QwtPlotZoomer* zoomer = new MyZoomer( canvas() ); zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); panner->setAxisEnabled( QwtPlot::yRight, false ); panner->setMouseButton( Qt::MidButton ); // 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 ); }
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 QwtPlotScaleItem::updateScaleDiv(const QwtScaleDiv& xScaleDiv, const QwtScaleDiv& yScaleDiv) { QwtScaleDraw *sd = d_data->scaleDraw; if ( d_data->scaleDivFromAxis && sd ) { sd->setScaleDiv( sd->orientation() == Qt::Horizontal ? xScaleDiv : yScaleDiv); updateBorders(); } }
/*! \brief Assign a scale division The scale division determines where to set the tick marks. \param scaleDiv Scale Division \sa For more information about scale divisions, see QwtScaleDiv. */ void QwtScaleWidget::setScaleDiv( const QwtScaleDiv &scaleDiv ) { QwtScaleDraw *sd = d_data->scaleDraw; if ( sd->scaleDiv() != scaleDiv ) { sd->setScaleDiv( scaleDiv ); layoutScale(); Q_EMIT scaleDivChanged(); } }
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); setAxisScaleDraw(QwtPlot::yLeft, sd); }
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); }
SectionWindow::SectionWindow(QWidget *parent): QMainWindow(parent) { m_data = new RasterData(); m_plot = new QwtPlot(parent); m_spect = new QwtPlotSpectrogram(); m_spect->setColorMap(QwtLinearColorMap(Qt::darkCyan, Qt::red)); m_spect->setData(*m_data); m_spect->attach(m_plot); m_plot->axisWidget(QwtPlot::xBottom)->setTitle("Band (index)"); m_plot->axisWidget(QwtPlot::yLeft)->setTitle("Arclength (pixel)"); m_plot->setMargin(5); // A color bar on the right axis QwtScaleWidget *rightAxis = m_plot->axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity"); rightAxis->setColorBarEnabled(true); m_plot->enableAxis(QwtPlot::yRight); m_plot->plotLayout()->setAlignCanvasToScales(true); m_plot->replot(); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size m_zoomer = new MyZoomer(this, m_plot->canvas()); m_zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); m_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); const QColor c(Qt::darkBlue); m_zoomer->setRubberBandPen(c); m_zoomer->setTrackerPen(c); QwtPlotPanner *panner = new QwtPlotPanner(m_plot->canvas()); panner->setAxisEnabled(QwtPlot::yRight, false); panner->setMouseButton(Qt::MidButton); // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically const QFontMetrics fm(m_plot->axisWidget(QwtPlot::yLeft)->font()); QwtScaleDraw *sd = m_plot->axisScaleDraw(QwtPlot::yLeft); sd->setMinimumExtent( fm.width("100.00") ); setCentralWidget(m_plot); }
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; }
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 }
/*! \brief Assign a scale division The scale division determines where to set the tick marks. \param transformation Transformation, needed to translate between scale and pixal values \param scaleDiv Scale Division \sa For more information about scale divisions, see QwtScaleDiv. */ void QwtScaleWidget::setScaleDiv( const QwtScaleTransformation& transformation, const QwtScaleDiv &scaleDiv) { QwtScaleDraw *sd = d_data->scaleDraw; if (sd->scaleDiv() != scaleDiv || sd->map().transformation().xForm != transformation.xForm ) { sd->setTransformation(transformation); sd->setScaleDiv(scaleDiv); layoutScale(); emit scaleDivChanged(); } }
void QwtPlotPropertySetDialog::updateAxisValue(QwtPlot::Axis axis) { QwtInterval inv= m_plot->axisInterval(axis); //QwtScaleWidget* scaleWidget = m_plot->axisWidget(axis); QwtScaleDraw *scaleDraw = m_plot->axisScaleDraw(axis); QwtDateScaleDraw* dateScale = dynamic_cast<QwtDateScaleDraw*>(scaleDraw); m_property_id.setVarPropertyData(axisPropertyID(axis,4) ,QPointF(inv.minValue(),inv.maxValue())); m_property_id.setVarPropertyData(axisPropertyID(axis,1) ,m_plot->axisTitle(axis).text()); ScaleDraw sd = NormalScale; sd = ((dateScale == nullptr) ? NormalScale : DateScale); m_property_id.setVarPropertyData(axisPropertyID(axis,2),int(sd)); m_property_id.setVarPropertyData(axisPropertyID(axis,5),scaleDraw->labelRotation()); }
void SaxsviewImage::setMinorTicksVisible(bool on) { // // There is a ScaleDraw component "Ticks", like the "Labels" used // for the visibility of the labels, but "Ticks" shows/hides // all ticks, not selected ones. Here we "disable" tick marks by // setting their size to 0 if disabled, and their default value // when enabled. // for (int i = QwtPlot::yLeft; i < QwtPlot::axisCnt; ++i) { QwtScaleDraw *draw = p->scales[i]->scaleDraw(); draw->setTickLength(QwtScaleDiv::MinorTick, on ? 4 : 0); draw->setTickLength(QwtScaleDiv::MediumTick, on ? 6 : 0); } replot(); }
/*! \brief Assign a scale division The scale division determines where to set the tick marks. \param transformation Transformation, needed to translate between scale and pixal values \param scaleDiv Scale Division \sa For more information about scale divisions, see QwtScaleDiv. */ void QwtScaleWidget::setScaleDiv( QwtScaleTransformation *transformation, const QwtScaleDiv &scaleDiv) { QwtScaleDraw *sd = d_data->scaleDraw; if (sd->scaleDiv() != scaleDiv || sd->map().transformation()->type() != transformation->type() ) { sd->setTransformation(transformation); sd->setScaleDiv(scaleDiv); layoutScale(); emit scaleDivChanged(); } else delete transformation; }
// // 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); } }
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 ); }
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 ); }
ScatterPlot::ScatterPlot(Context *context) : context(context) { setInstanceName("2D Plot"); all = NULL; grid = NULL; 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); setAxisScaleDraw(QwtPlot::yLeft, sd); connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); configChanged(); // use latest colors etc }
virtual void rescale() { QwtScaleWidget *scaleWidget = plot()->axisWidget(yAxis()); QwtScaleDraw *sd = scaleWidget->scaleDraw(); int minExtent = 0; if ( zoomRectIndex() > 0 ) { // When scrolling in vertical direction // the plot is jumping in horizontal direction // because of the different widths of the labels // So we better use a fixed extent. minExtent = sd->spacing() + sd->maxTickLength() + 1; minExtent += sd->labelSize( scaleWidget->font(), c_rangeMax).width(); } sd->setMinimumExtent(minExtent); ScrollZoomer::rescale(); }