Plotter::Plotter( QWidget *parent ): QwtPlot( parent ) { // Assign a title setTitle( "WAVE DATA" ); QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); canvas->setLineWidth( 1 ); canvas->setPalette( Qt::white ); setCanvas( canvas ); alignScales(); // Insert grid d_grid = new QwtPlotGrid(); d_grid->attach( this ); // Axis setAxisTitle( QwtPlot::xBottom, "Time" ); // setAxisScale( QwtPlot::xBottom, -d_interval, 0.0 ); setAxisTitle( QwtPlot::yLeft, "Amplitude" ); // setAxisScale( QwtPlot::yLeft, -1.0, 1.0 ); resize(600, 350); }
BarChart::BarChart( QWidget *parent ): QwtPlot( parent ) { const struct { const char *distro; const int hits; QColor color; } pageHits[] = { { "Arch", 1114, QColor( "DodgerBlue" ) }, { "Debian", 1373, QColor( "#d70751" ) }, { "Fedora", 1638, QColor( "SteelBlue" ) }, { "Mageia", 1395, QColor( "Indigo" ) }, { "Mint", 3874, QColor( 183, 255, 183 ) }, { "openSuSE", 1532, QColor( 115, 186, 37 ) }, { "Puppy", 1059, QColor( "LightSkyBlue" ) }, { "Ubuntu", 2391, QColor( "FireBrick" ) } }; setAutoFillBackground( true ); setPalette( QColor( "Linen" ) ); QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setLineWidth( 2 ); canvas->setFrameStyle( QFrame::Box | QFrame::Sunken ); canvas->setBorderRadius( 10 ); QPalette canvasPalette( QColor( "Plum" ) ); canvasPalette.setColor( QPalette::Foreground, QColor( "Indigo" ) ); canvas->setPalette( canvasPalette ); setCanvas( canvas ); setTitle( "DistroWatch Page Hit Ranking, April 2012" ); d_barChartItem = new DistroChartItem(); QVector< double > samples; for ( uint i = 0; i < sizeof( pageHits ) / sizeof( pageHits[ 0 ] ); i++ ) { d_distros += pageHits[ i ].distro; samples += pageHits[ i ].hits; d_barChartItem->addDistro( pageHits[ i ].distro, pageHits[ i ].color ); } d_barChartItem->setSamples( samples ); d_barChartItem->attach( this ); insertLegend( new QwtLegend() ); setOrientation( 0 ); setAutoReplot( false ); }
Plot( QWidget *parent = NULL ): QwtPlot( parent ) { QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setLineWidth( 1 ); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); setCanvas( canvas ); }
FrameNumberVisualizator::FrameNumberVisualizator(int duree,int dataFreq,int min, int max, QWidget *parent): QWidget(parent), duree_de_visualisation(duree), frequency(dataFreq) { QHBoxLayout * mainLayout = new QHBoxLayout; this->setLayout(mainLayout); plot = new QwtPlot(); mainLayout->addWidget(plot,5); //Axis plot->enableAxis(QwtPlot::xBottom,false); plot->setAxisScale( QwtPlot::xBottom, 0.0, duree_de_visualisation ); plot->setAxisScale( QwtPlot::yLeft, 0, 1000 ); // canvas QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setLineWidth( 1 ); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); canvas->setBorderRadius( 15 ); QPalette canvasPalette( Qt::white ); canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); canvas->setPalette( canvasPalette ); plot->setCanvas( canvas ); curve = new QwtPlotCurve("frame"); curve->setRenderHint( QwtPlotItem::RenderAntialiased ); curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); curve->setPen( Qt::red ); curve->attach( plot ); timerReplot = new QTimer; timerReplot->setInterval(50); connect(timerReplot,SIGNAL(timeout()),plot,SLOT(replot())); timerRescale = new QTimer; timerRescale->setInterval(1000); connect(timerRescale,SIGNAL(timeout()),SLOT(rescale())); }
Plot::Plot(QWidget *parent): QwtPlot( parent ) { setAutoFillBackground( true ); setPalette( QPalette( QColor( 165, 193, 228 ) ) ); updateGradient(); setTitle( "График аппроксимации" ); insertLegend( new QwtLegend(), QwtPlot::RightLegend ); // axes setAxisTitle( xBottom, "" ); setAxisScale( xBottom, 0.0, 60.0 ); setAxisTitle( yLeft, "Функция принадлежности -->" ); setAxisScale( yLeft, -0.1, 1.1 ); // canvas QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setLineWidth( 1 ); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); canvas->setBorderRadius( 15 ); QPalette canvasPalette( Qt::white ); canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); canvas->setPalette( canvasPalette ); setCanvas( canvas ); // panning with the left mouse button //( void ) new QwtPlotPanner( canvas ); // zoom in/out with the wheel ( void ) new QwtPlotMagnifier( canvas ); zoom = new QwtPlotZoomer(canvas); zoom->setRubberBandPen(QPen(Qt::red)); clear(); // ...a horizontal line at y = 0... <<<<<<< HEAD
CallLogPlot::CallLogPlot(QwtPlot* plot, QObject* parent) :QObject(parent) , m_plot(plot) , m_barScaleDrawX(NULL) , m_barCount(0) { Q_ASSERT(m_plot); m_plot->setAutoReplot(false); // 设置图表颜色 m_plot->setAutoFillBackground(true); m_plot->setPalette(QColor("Linen")); // 设置图表画布 QwtPlotCanvas* canvas = new QwtPlotCanvas(); canvas->setLineWidth(2); canvas->setFrameStyle(QFrame::Box | QFrame::Sunken); QPalette canvasPalette(QColor("Plum")); canvasPalette.setColor(QPalette::Foreground, QColor("Indigo")); canvas->setPalette(canvasPalette); m_plot->setCanvas(canvas); // 创建柱状图表 m_barChart = new BarChart(); m_barChart->attach(m_plot); m_barChart->setOrientation(Qt::Vertical); // 设置X坐标轴 m_barScaleDrawX = new BarScaleDrawX(); m_plot->setAxisMaxMajor(QwtPlot::xBottom, 0); m_plot->setAxisScaleDraw(QwtPlot::xBottom, m_barScaleDrawX); // 设置Y坐标轴 m_barScaleDrawY = new BarScaleDrawY(); m_plot->setAxisMaxMinor(QwtPlot::yLeft, 3); m_plot->setAxisScaleDraw(QwtPlot::yLeft, m_barScaleDrawY); // 设置布局 m_plot->plotLayout()->setCanvasMargin(0); m_plot->replot(); }
Psd::Psd(QWidget *parent) : QWidget(parent), ui(new Ui::Psd) { ui->setupUi(this); ui->plot->setTitle("原信号:cos(2*PI*40*i)+3*cos(2*PI*100*i)+w(n)"); ui->plot->setAutoFillBackground( true ); ui->plot->insertLegend( new QwtLegend(), QwtPlot::RightLegend ); ui->plot->setAutoReplot( false ); QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setLineWidth( 1 ); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); canvas->setBorderRadius( 15 ); QPalette canvasPalette( Qt::white ); canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); canvas->setPalette( canvasPalette ); ui->plot->setCanvas( canvas ); ( void ) new QwtPlotPanner( canvas ); ( void ) new QwtPlotMagnifier( canvas ); cSin->setRenderHint( QwtPlotItem::RenderAntialiased ); cSin->setLegendAttribute( QwtPlotCurve::LegendShowLine, false ); cSin->setPen( Qt::red ); cSin->attach( ui->plot ); QwtPlotMarker *mY = new QwtPlotMarker(); mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop ); mY->setLineStyle( QwtPlotMarker::HLine ); mY->setYValue( 0.0 ); mY->attach( ui->plot ); init(); pf(); populate(); }
Plot::Plot( QWidget *parent ): QwtPlot( parent ), d_interval( 10.0 ), // seconds d_timerId( -1 ) { // Assign a title setTitle( "Testing Refresh Rates" ); QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); canvas->setLineWidth( 1 ); canvas->setPalette( Qt::white ); setCanvas( canvas ); alignScales(); // Insert grid d_grid = new QwtPlotGrid(); d_grid->attach( this ); // Insert curve d_curve = new QwtPlotCurve( "Data Moving Right" ); d_curve->setPen( Qt::black ); d_curve->setData( new CircularBuffer( d_interval, 10 ) ); d_curve->attach( this ); // Axis setAxisTitle( QwtPlot::xBottom, "Seconds" ); setAxisScale( QwtPlot::xBottom, -d_interval, 0.0 ); setAxisTitle( QwtPlot::yLeft, "Values" ); setAxisScale( QwtPlot::yLeft, -1.0, 1.0 ); d_clock.start(); setSettings( d_settings ); }
Plot::Plot(QWidget *parent, const char *name) : QwtPlot(parent) { marker_key = 0; curve_key = 0; minTickLength = 5; majTickLength = 9; movedGraph=FALSE; graphToResize=FALSE; ShiftButton=FALSE; setGeometry(QRect(0,0,500,400)); setAxisTitle(QwtPlot::yLeft, tr("Y Axis Title")); setAxisTitle(QwtPlot::xBottom, tr("X Axis Title")); // grid d_grid = new Grid; d_grid->enableX(false); d_grid->enableY(false); d_grid->setMajPen(QPen(Qt::blue, 0, Qt::SolidLine)); d_grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); 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); ScaleDraw *sd = new ScaleDraw(); sd->setTickLength (QwtScaleDiv::MinorTick, minTickLength); sd->setTickLength (QwtScaleDiv::MediumTick, minTickLength); sd->setTickLength (QwtScaleDiv::MajorTick, majTickLength); setAxisScaleDraw (i, sd); } } QwtPlotLayout *pLayout=plotLayout(); pLayout->setCanvasMargin(0); QwtPlotCanvas* plCanvas = canvas(); plCanvas->setFocusPolicy(QWidget::StrongFocus); plCanvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator); plCanvas->setFocus(); plCanvas->setFrameShadow(QwtPlot::Plain); plCanvas->setCursor(Qt::arrowCursor); plCanvas->setLineWidth(0); setFocusPolicy(QWidget::StrongFocus); setFocusProxy(plCanvas); setFrameShape (QFrame::Box); setLineWidth(0); }
//--------------------------------------------------------------------------- Plot::Plot( size_t streamPos, size_t Type, size_t Group, QWidget *parent ) : QwtPlot( parent ), m_streamPos( streamPos ), m_type( Type ), m_group( Group ) { setAutoReplot( false ); QwtPlotCanvas* canvas = dynamic_cast<QwtPlotCanvas*>( this->canvas() ); if ( canvas ) { canvas->setFrameStyle( QFrame::Plain | QFrame::Panel ); canvas->setLineWidth( 1 ); #if 1 canvas->setPalette( QColor("Cornsilk") ); #endif } setAxisMaxMajor( QwtPlot::yLeft, 0 ); setAxisMaxMinor( QwtPlot::yLeft, 0 ); setAxisScaleDraw( QwtPlot::yLeft, new PlotScaleDrawY() ); enableAxis( QwtPlot::xBottom, false ); // something invalid setAxisScale( QwtPlot::xBottom, -1, 0 ); setAxisScale( QwtPlot::yLeft, -1, 0 ); // Plot grid QwtPlotGrid *grid = new QwtPlotGrid(); grid->enableXMin( true ); grid->enableYMin( true ); grid->setMajorPen( Qt::darkGray, 0, Qt::DotLine ); grid->setMinorPen( Qt::gray, 0 , Qt::DotLine ); grid->attach( this ); m_cursor = new PlotCursor( canvas ); m_cursor->setPosition( 0 ); // curves for( unsigned j = 0; j < PerStreamType[m_type].PerGroup[m_group].Count; ++j ) { QwtPlotCurve* curve = new QwtPlotCurve( PerStreamType[m_type].PerItem[PerStreamType[m_type].PerGroup[m_group].Start + j].Name ); curve->setPen( curveColor( j ) ); curve->setRenderHint( QwtPlotItem::RenderAntialiased ); curve->setZ( curve->z() - j ); //Invert data order (e.g. MAX before MIN) curve->attach( this ); m_curves += curve; } // visual helpers if ( m_type == Type_Video ) switch (m_group) { case Group_Y : Plot_AddHLine( this, 16, 61, 89, 171); Plot_AddHLine( this, 235, 220, 20, 60); break; case Group_U : case Group_V : Plot_AddHLine( this, 16, 61, 89, 171); Plot_AddHLine( this, 240, 220, 20, 60); break; case Group_Sat : Plot_AddHLine( this, 88, 255, 0, 255); Plot_AddHLine( this, 118, 220, 20, 60); break; default : ; } PlotPicker* picker = new PlotPicker( canvas, &PerStreamType[m_type], m_group, &m_curves ); connect( picker, SIGNAL( moved( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) ); connect( picker, SIGNAL( selected( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) ); connect( axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ), SLOT( onXScaleChanged() ) ); // legend m_legend = new PlotLegend(); connect( this, SIGNAL( legendDataChanged( const QVariant &, const QList<QwtLegendData> & ) ), m_legend, SLOT( updateLegend( const QVariant &, const QList<QwtLegendData> & ) ) ); updateLegend(); }
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); }
Plot::Plot(QWidget *parent): QwtPlot( parent ) { setAutoFillBackground( true ); setPalette( QPalette( QColor( 165, 193, 228 ) ) ); updateGradient(); setTitle( "График аппроксимации" ); insertLegend( new QwtLegend(), QwtPlot::RightLegend ); // axes setAxisTitle( xBottom, "" ); setAxisScale( xBottom, 0.0, 10.0 ); setAxisTitle( yLeft, "Функция принадлежности -->" ); setAxisScale( yLeft, 0, 2 ); // canvas QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setLineWidth( 1 ); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); canvas->setBorderRadius( 15 ); QPalette canvasPalette( Qt::white ); canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); canvas->setPalette( canvasPalette ); setCanvas( canvas ); // panning with the left mouse button ( void ) new QwtPlotPanner( canvas ); // zoom in/out with the wheel ( void ) new QwtPlotMagnifier( canvas ); // ...a horizontal line at y = 0... QwtPlotMarker *mY = new QwtPlotMarker(); mY->setLabel( QString::fromLatin1( "y = 0" ) ); mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop ); mY->setLineStyle( QwtPlotMarker::HLine ); mY->setYValue( 0.0 ); mY->attach( this ); // ...a horizontal line at y = 1... QwtPlotMarker *mY1 = new QwtPlotMarker(); mY1->setLabel( QString::fromLatin1( "y = 1" ) ); mY1->setLabelAlignment( Qt::AlignRight | Qt::AlignTop ); mY1->setLineStyle( QwtPlotMarker::HLine ); mY1->setYValue( 1.0 ); mY1->setLinePen(Qt::black, 1, Qt::DashLine); mY1->attach( this ); // ...a vertical line at x = 0 QwtPlotMarker *mX = new QwtPlotMarker(); mX->setLabel( QString::fromLatin1( "x = 0" ) ); mX->setLabelAlignment( Qt::AlignLeft | Qt::AlignBottom ); mX->setLabelOrientation( Qt::Vertical ); mX->setLineStyle( QwtPlotMarker::VLine ); mX->setLinePen( Qt::black, 0, Qt::DashDotLine ); mX->setXValue( 0 ); mX->attach( this ); // curvePoints = new QwtPlotCurve(); // curvePoints->setStyle( QwtPlotCurve::Dots ); // curvePoints->attach( this ); }
ThreeAxisDataVisualizator::ThreeAxisDataVisualizator(int duree,int dataFreq,int min, int max, int _type, QWidget *parent): QWidget(parent), duree_de_visualisation(duree), frequency(dataFreq), type(_type), min(0), max(0) { curves = QList<QString>(); QString typeStr; if(type==DataType::acc){ typeStr = "accelerometre"; }else if(type==DataType::gyro){ typeStr = "gyroscope"; }else if(type==DataType::euler){ typeStr = "euler"; }else if(type==DataType::qua){ typeStr = "quaternion"; } curves.append(typeStr+" x"); curves.append(typeStr+" y"); curves.append(typeStr+" z"); QHBoxLayout * mainLayout = new QHBoxLayout; this->setLayout(mainLayout); plot = new QwtPlot(); mainLayout->addWidget(plot,5); QWidget * checkBoxGroup = new QWidget(this); mainLayout->addWidget(checkBoxGroup,1); QVBoxLayout * checkBoxGroupLayout = new QVBoxLayout; checkBoxGroup->setLayout(checkBoxGroupLayout); QPushButton * resetScaleButton = new QPushButton; resetScaleButton->setText("reset y scale"); setStyleSheet("QPushButton{" "font-family: Futura;" "color:#4C6BCF;" "font-size: 14px;" "border:2px solid ;" "border-color: #4C6BCF;" "border-radius:5px;" "min-height:60;}"); checkBoxGroupLayout->addWidget(resetScaleButton); checkBoxX = new QCheckBox(curves.at(0),checkBoxGroup); checkBoxGroupLayout->addWidget(checkBoxX); checkBoxY = new QCheckBox(curves.at(1),checkBoxGroup); checkBoxGroupLayout->addWidget(checkBoxY); checkBoxZ = new QCheckBox(curves.at(2),checkBoxGroup); checkBoxGroupLayout->addWidget(checkBoxZ); timeSlider = new QSlider(Qt::Horizontal,checkBoxGroup); checkBoxGroupLayout->addWidget(timeSlider); checkBoxX->setChecked(true); checkBoxY->setChecked(true); checkBoxZ->setChecked(true); QSignalMapper * mapper = new QSignalMapper; mapper->setMapping(checkBoxX,0); mapper->setMapping(checkBoxY,1); mapper->setMapping(checkBoxZ,2); connect(checkBoxX,SIGNAL(stateChanged(int)),mapper,SLOT(map())); connect(checkBoxY,SIGNAL(stateChanged(int)),mapper,SLOT(map())); connect(checkBoxZ,SIGNAL(stateChanged(int)),mapper,SLOT(map())); connect(mapper,SIGNAL(mapped(int)),SLOT(handleCheckBox(int))); // canvas QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setLineWidth( 1 ); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); canvas->setBorderRadius( 15 ); QPalette canvasPalette( Qt::white ); canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); canvas->setPalette( canvasPalette ); plot->setCanvas( canvas ); QwtPlotScaleItem *it1 = new QwtPlotScaleItem(QwtScaleDraw::BottomScale ,0.0); it1->attach(plot); plot->enableAxis(QwtPlot::xBottom,false); plot->setAxisScale( QwtPlot::xBottom, 0.0, duree_de_visualisation ); plot->setAxisScale( QwtPlot::yLeft, min, max ); xCurve = new QwtPlotCurve( curves.at(0)); xCurve->setRenderHint( QwtPlotItem::RenderAntialiased ); xCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); xCurve->setPen( Qt::red ); xCurve->attach( plot ); yCurve = new QwtPlotCurve(curves.at(1)); yCurve->setRenderHint( QwtPlotItem::RenderAntialiased ); yCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); yCurve->setPen( Qt::blue ); yCurve->attach( plot ); zCurve = new QwtPlotCurve( curves.at(2)); zCurve->setRenderHint( QwtPlotItem::RenderAntialiased ); zCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); zCurve->setPen( Qt::green ); zCurve->attach( plot ); timerReplot = new QTimer; timerReplot->setInterval(50); connect(timerReplot,SIGNAL(timeout()),plot,SLOT(replot())); connect(timeSlider,SIGNAL(sliderMoved(int)),SLOT(updateVizualizatorTimeWindow(int))); timerRescale = new QTimer; timerRescale->setInterval(1000); connect(timerRescale,SIGNAL(timeout()),SLOT(rescale())); connect(resetScaleButton,SIGNAL(clicked(bool)),SLOT(resetScale())); setEnabled(false); }
void Plot::setSettings( const Settings &s ) { if ( d_timerId >= 0 ) killTimer( d_timerId ); d_timerId = startTimer( s.updateInterval ); d_grid->setPen( s.grid.pen ); d_grid->setVisible( s.grid.pen.style() != Qt::NoPen ); CircularBuffer *buffer = static_cast<CircularBuffer *>( d_curve->data() ); if ( s.curve.numPoints != buffer->size() || s.curve.functionType != d_settings.curve.functionType ) { switch( s.curve.functionType ) { case Settings::Wave: buffer->setFunction( wave ); break; case Settings::Noise: buffer->setFunction( noise ); break; default: buffer->setFunction( NULL ); } buffer->fill( d_interval, s.curve.numPoints ); } d_curve->setPen( s.curve.pen ); d_curve->setBrush( s.curve.brush ); d_curve->setPaintAttribute( QwtPlotCurve::ClipPolygons, s.curve.paintAttributes & QwtPlotCurve::ClipPolygons ); d_curve->setPaintAttribute( QwtPlotCurve::FilterPoints, s.curve.paintAttributes & QwtPlotCurve::FilterPoints ); d_curve->setRenderHint( QwtPlotItem::RenderAntialiased, s.curve.renderHint & QwtPlotItem::RenderAntialiased ); #ifndef QWT_NO_OPENGL if ( s.canvas.openGL ) { QwtPlotGLCanvas *plotCanvas = qobject_cast<QwtPlotGLCanvas *>( canvas() ); if ( plotCanvas == NULL ) { plotCanvas = new GLCanvas(); plotCanvas->setPalette( QColor( "khaki" ) ); setCanvas( plotCanvas ); } } else #endif { QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>( canvas() ); if ( plotCanvas == NULL ) { plotCanvas = new QwtPlotCanvas(); plotCanvas->setFrameStyle( QFrame::Box | QFrame::Plain ); plotCanvas->setLineWidth( 1 ); plotCanvas->setPalette( Qt::white ); setCanvas( plotCanvas ); } plotCanvas->setAttribute( Qt::WA_PaintOnScreen, s.canvas.paintOnScreen ); plotCanvas->setPaintAttribute( QwtPlotCanvas::BackingStore, s.canvas.useBackingStore ); plotCanvas->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, s.canvas.immediatePaint ); } QwtPainter::setPolylineSplitting( s.curve.lineSplitting ); d_settings = s; }
Plot::Plot( QWidget *parent ): QwtPlot( parent ) { //setAutoFillBackground( true ); //setPalette( QPalette( QColor( 165, 193, 228 ) ) ); //updateGradient(); //setTitle( "A Simple QwtPlot Demonstration" ); //insertLegend( new QwtLegend(), QwtPlot::BottomLegend ); // axes setAxisTitle( xBottom, "x -->" ); setAxisScale( xBottom, 0.0, 360.0 ); setAxisTitle( yLeft, "y -->" ); setAxisScale( yLeft, -10.0, 10.0 ); // canvas QwtPlotCanvas *canvas = new QwtPlotCanvas(); //canvas->setLineWidth( 1 ); canvas->setFrameStyle( QFrame::StyledPanel ); //canvas->setBorderRadius( 15 ); QwtPlotGrid* grid = new QwtPlotGrid(); grid->setPen(Qt::black, 0.1, Qt::DashLine); grid->attach(this); QPalette canvasPalette( Qt::white ); canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); canvas->setPalette( canvasPalette ); setCanvas( canvas ); // panning with the left mouse button QwtPlotPanner* panner = new QwtPlotPanner( canvas ); panner->setMouseButton(Qt::LeftButton, Qt::ControlModifier); // zoom in/out with the wheel QwtPlotMagnifier* magnifier = new QwtPlotMagnifier( canvas ); magnifier->setAxisEnabled(xBottom, false); QwtPlotZoomer* zoomer = new QwtPlotZoomer(canvas); zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier ); zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier ); zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home ); zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier); zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ShiftModifier); canvas->setFocusPolicy(Qt::StrongFocus); canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator); canvas->setFocus(); //canvas->setFrameShadow(QwtPlot::Plain); //canvas->setCursor(Qt::arrowCursor); canvas->setLineWidth(0); //canvas->setPaintAttribute(QwtPlotCanvas::PaintCached, false); //canvas->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); //populate(); }