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 ); }
void ConfigStabilizationWidget::setupExpoPlot() { ui->expoPlot->setMouseTracking(false); ui->expoPlot->setAxisScale(QwtPlot::xBottom, 0, 100, 25); QwtText title; title.setText(tr("Input %")); title.setFont(ui->expoPlot->axisFont(QwtPlot::xBottom)); ui->expoPlot->setAxisTitle(QwtPlot::xBottom, title); ui->expoPlot->setAxisScale(QwtPlot::yLeft, 0, 100, 25); title.setText(tr("Output %")); title.setFont(ui->expoPlot->axisFont(QwtPlot::yLeft)); ui->expoPlot->setAxisTitle(QwtPlot::yLeft, title); QwtPlotCanvas *plotCanvas = dynamic_cast<QwtPlotCanvas *>(ui->expoPlot->canvas()); if (plotCanvas) { plotCanvas->setFrameStyle(QFrame::NoFrame); } ui->expoPlot->canvas()->setCursor(QCursor()); m_plotGrid.setMajorPen(QColor(Qt::gray)); m_plotGrid.setMinorPen(QColor(Qt::lightGray)); m_plotGrid.enableXMin(false); m_plotGrid.enableYMin(false); m_plotGrid.attach(ui->expoPlot); m_expoPlotCurveRoll.setRenderHint(QwtPlotCurve::RenderAntialiased); QColor rollColor(Qt::red); rollColor.setAlpha(180); m_expoPlotCurveRoll.setPen(QPen(rollColor, 2)); m_expoPlotCurveRoll.attach(ui->expoPlot); replotExpoRoll(ui->expoSpinnerRoll->value()); m_expoPlotCurveRoll.show(); QColor pitchColor(Qt::green); pitchColor.setAlpha(180); m_expoPlotCurvePitch.setRenderHint(QwtPlotCurve::RenderAntialiased); m_expoPlotCurvePitch.setPen(QPen(pitchColor, 2)); m_expoPlotCurvePitch.attach(ui->expoPlot); replotExpoPitch(ui->expoSpinnerPitch->value()); m_expoPlotCurvePitch.show(); QColor yawColor(Qt::blue); yawColor.setAlpha(180); m_expoPlotCurveYaw.setRenderHint(QwtPlotCurve::RenderAntialiased); m_expoPlotCurveYaw.setPen(QPen(yawColor, 2)); m_expoPlotCurveYaw.attach(ui->expoPlot); replotExpoYaw(ui->expoSpinnerYaw->value()); m_expoPlotCurveYaw.show(); }
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
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void StatsGenMDFWidget::initQwtPlot(QString xAxisName, QString yAxisName, QwtPlot* plot) { QPalette pal; pal.setColor(QPalette::Text, Qt::white); pal.setColor(QPalette::Foreground, Qt::white); pal.setColor(QPalette::Window, Qt::black); plot->setPalette( pal ); plot->plotLayout()->setAlignCanvasToScales( true ); for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) { plot->axisWidget( axis )->setMargin( 0 ); plot->axisWidget(axis)->setPalette(pal); } QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setAutoFillBackground( false ); canvas->setFrameStyle( QFrame::NoFrame ); canvas->setPalette(pal); plot->setCanvas( canvas ); QFont font; font.setBold(true); QwtText xAxis(xAxisName); xAxis.setColor(Qt::white); xAxis.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop ); xAxis.setFont(font); QwtText yAxis(yAxisName); yAxis.setColor(Qt::white); yAxis.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop ); yAxis.setFont(font); const int margin = 5; plot->setContentsMargins( margin, margin, margin, margin ); plot->setAxisTitle(QwtPlot::xBottom, xAxis); plot->setAxisTitle(QwtPlot::yLeft, yAxis); }
PlotZoz::PlotZoz(QWidget *) { // Прозрачность полотна QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setFrameStyle(QFrame::NoFrame); canvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false); canvas->setPaintAttribute(QwtPlotCanvas::Opaque, false); canvas->setAttribute(Qt::WA_OpaquePaintEvent, false); canvas->setAutoFillBackground( false ); setCanvas(canvas); plotLayout()->setAlignCanvasToScales(true); // Отключаем щкалы деления for (int i=0; i<QwtPlot::axisCnt; i++) { axisScaleDraw(i)->enableComponent(QwtScaleDraw::Ticks, false); axisScaleDraw(i)->enableComponent(QwtScaleDraw::Backbone, false); } pltSpectrogram = new PlotSpectr(); pltRasterData = new PlotRasterData(); pltGrid = new QwtPlotGrid; pltGrid->enableXMin(true); // разрешаем отображение линий сетки, соответствующих вспомогательным делениям нижней шкалы pltGrid->enableYMin(true); // разрешаем отображение линий сетки, соответствующих вспомогательным делениям нижней шкалы pltGrid->setMajorPen(QPen(Qt::gray,0,Qt::DotLine)); // черный для основных делений pltGrid->setMinorPen(QPen(Qt::gray,0,Qt::DotLine)); // серый для вспомогательных pltGrid->attach(this); setAxisMaxMajor(0,20); setAxisMaxMinor(0,0); setAxisMaxMajor(1,20); setAxisMaxMinor(1,0); setAxisMaxMajor(2,20); setAxisMaxMinor(2,0); setAxisMaxMajor(3,20); setAxisMaxMinor(3,0); canvas->setCursor(Qt::ArrowCursor); setMouseTracking(true); for (int i=0; i<QwtPlot::axisCnt; i++) axisWidget(i)->setMouseTracking(true); }
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 ): 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(); }
Plot::Plot( QWidget *parent ): QwtPlot( parent) { setPalette( Qt::black ); // we want to have the axis scales like a frame around the // canvas plotLayout()->setAlignCanvasToScales( true ); for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) axisWidget( axis )->setMargin( 0 ); QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setAutoFillBackground( false ); canvas->setFrameStyle( QFrame::NoFrame ); setCanvas( canvas ); setAxisScale( QwtPlot::yLeft, 0.0, 10.0 ); // a title QwtText title( "Picker Demo" ); title.setColor( Qt::white ); title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop ); QFont font; font.setBold( true ); title.setFont( font ); QwtPlotTextLabel *titleItem = new QwtPlotTextLabel(); titleItem->setText( title ); titleItem->attach( this ); #if 1 // section //QColor c( "PaleVioletRed" ); QwtPlotZoneItem* zone = new QwtPlotZoneItem(); zone->setPen( Qt::darkGray ); zone->setBrush( QColor( "#834358" ) ); zone->setOrientation( Qt::Horizontal ); zone->setInterval( 3.8, 5.7 ); zone->attach( this ); #else // grid QwtPlotGrid *grid = new QwtPlotGrid(); grid->setMajorPen( Qt::white, 0, Qt::DotLine ); grid->setMinorPen( Qt::gray, 0 , Qt::DotLine ); grid->attach( this ); #endif // curves QPolygonF points1; points1 << QPointF( 0.2, 4.4 ) << QPointF( 1.2, 3.0 ) << QPointF( 2.7, 4.5 ) << QPointF( 3.5, 6.8 ) << QPointF( 4.7, 7.9 ) << QPointF( 5.8, 7.1 ); insertCurve( "Curve 1", "DarkOrange", points1 ); QPolygonF points2; points2 << QPointF( 0.4, 8.7 ) << QPointF( 1.4, 7.8 ) << QPointF( 2.3, 5.5 ) << QPointF( 3.3, 4.1 ) << QPointF( 4.4, 5.2 ) << QPointF( 5.6, 5.7 ); insertCurve( "Curve 2", "DodgerBlue", points2 ); CurveTracker* tracker = new CurveTracker( this->canvas() ); // for the demo we want the tracker to be active without // having to click on the canvas tracker->setStateMachine( new QwtPickerTrackerMachine() ); tracker->setRubberBandPen( QPen( "MediumOrchid" ) ); }
//--------------------------------------------------------------------------- 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(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 ); }
EigenPlotDlg::EigenPlotDlg(QWidget* parent) : QDialog(parent), mpPlot(NULL), mpCurve(NULL), mpComponentsSpin(NULL) { // Eigen plot mpPlot = new QwtPlot(this); mpPlot->installEventFilter(this); mpPlot->setAutoFillBackground(true); QFont ftAxis = QApplication::font(); ftAxis.setBold(true); ftAxis.setPointSize(10); QwtText bottomText("Number of Components"); bottomText.setFont(ftAxis); mpPlot->setAxisTitle(QwtPlot::xBottom, bottomText); QwtText leftText("Eigen Values"); leftText.setFont(ftAxis); mpPlot->setAxisTitle(QwtPlot::yLeft, leftText); QwtScaleEngine* pLinearScale = mpPlot->axisScaleEngine(QwtPlot::xBottom); pLinearScale->setAttribute(QwtScaleEngine::Floating); QwtLog10ScaleEngine* pLogScale = new QwtLog10ScaleEngine(); pLogScale->setAttribute(QwtScaleEngine::Floating); mpPlot->setAxisScaleEngine(QwtPlot::yLeft, pLogScale); QPalette plotPalette = mpPlot->palette(); plotPalette.setColor(QPalette::Window, Qt::white); mpPlot->setPalette(plotPalette); QwtPlotCanvas* pPlotCanvas = mpPlot->canvas(); pPlotCanvas->setFrameStyle(QFrame::NoFrame); QwtPlotLayout* pPlotLayout = mpPlot->plotLayout(); pPlotLayout->setMargin(5); QwtPlotGrid* pPlotGrid = new QwtPlotGrid(); pPlotGrid->setPen(QPen(Qt::DotLine)); pPlotGrid->attach(mpPlot); mpPlot->replot(); // Number of components QLabel* pComponentsLabel = new QLabel("Number of Components:", this); mpComponentsSpin = new QSpinBox(this); mpComponentsSpin->setFixedWidth(50); mpComponentsSpin->setMinimum(1); QLabel* pDescriptionLabel = new QLabel("To set, left click in the plot or enter a value.", this); pDescriptionLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); pDescriptionLabel->setWordWrap(true); QFont descriptionFont(pDescriptionLabel->font()); descriptionFont.setItalic(true); pDescriptionLabel->setFont(descriptionFont); QHBoxLayout* pComponentsLayout = new QHBoxLayout(); pComponentsLayout->setMargin(0); pComponentsLayout->setSpacing(5); pComponentsLayout->addWidget(pComponentsLabel); pComponentsLayout->addWidget(mpComponentsSpin); pComponentsLayout->addWidget(pDescriptionLabel, 10); // Horizontal line QFrame* pLine = new QFrame(this); pLine->setFrameStyle(QFrame::HLine | QFrame::Sunken); // Buttons QPushButton* pOk = new QPushButton("&OK", this); QPushButton* pCancel = new QPushButton("&Cancel", this); connect(pOk, SIGNAL(clicked()), this, SLOT(accept())); connect(pCancel, SIGNAL(clicked()), this, SLOT(reject())); QHBoxLayout* pButtonLayout = new QHBoxLayout(); pButtonLayout->setMargin(0); pButtonLayout->setSpacing(5); pButtonLayout->addStretch(10); pButtonLayout->addWidget(pOk); pButtonLayout->addWidget(pCancel); // Layout QGridLayout* pGrid = new QGridLayout(this); pGrid->setMargin(10); pGrid->setSpacing(10); pGrid->addWidget(mpPlot, 0, 0); pGrid->addLayout(pComponentsLayout, 1, 0); pGrid->addWidget(pLine, 2, 0); pGrid->addLayout(pButtonLayout, 3, 0); pGrid->setRowStretch(0, 10); // Initialization setWindowTitle("PCA Components"); setModal(true); resize(440, 300); }
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; }