void Plot::clear() { this->detachItems(); pointsArr.clear(); // ...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 ); 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 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 ); }
SimDialog::SimDialog( QWidget * parent, Qt::WFlags f) : QDialog(parent, f) { setupUi(this); // setup the plot ... m_plot->setTitle("Comparing Similarity Measures"); m_plot->insertLegend(new QwtLegend(), QwtPlot::BottomLegend); // set up the axes ... m_plot->setAxisTitle(QwtPlot::xBottom, "Variations"); m_plot->setAxisScale(QwtPlot::xBottom, -10, 10); m_plot->setAxisTitle(QwtPlot::yLeft, "Similarity"); m_plot->setAxisScale(QwtPlot::yLeft, -1.5, 1.5); // enable grid ... QwtPlotGrid *grid = new QwtPlotGrid; grid->enableXMin(true); grid->enableYMin(true); grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine)); grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); grid->attach(m_plot); // 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(m_plot); // Insert zero line at x = 0 QwtPlotMarker *mX = new QwtPlotMarker(); mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); mX->setLineStyle(QwtPlotMarker::VLine); mX->setXValue(0.0); mX->attach(m_plot); // Insert new curves cReg = new QwtPlotCurve("Regular Similarity Measure"); cReg->attach(m_plot); cOct = new QwtPlotCurve("Octree based Similarity Measure"); cOct->attach(m_plot); // Set curve styles cReg->setPen(QPen(Qt::red, 2)); cOct->setPen(QPen(Qt::blue, 2)); // Populate the volume combos ... MainWindow* _win = (MainWindow *)this->parent(); viewer3d * _view = (viewer3d *) _win->getViewer(); QList<Volume*> _vols = _view->getVolumes(); // append Volume names to combo boxes ... // Need to modify Volume class so that it stored patient name ... // More importantly modify PatientBrowser so that the data can be directly // loaded. }
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 Plot_AddHLine(QwtPlot* plot, double value , double r , double g, double b) { QwtPlotMarker *marker = new QwtPlotMarker(); marker->setLineStyle ( QwtPlotMarker::HLine ); marker->setLinePen(QPen(QColor(r, g, b, 128), 1, Qt::DashDotLine)); marker->attach( plot ); marker->setYValue( value ); }
void wykres::dodaj_naj(double d) { QwtPlotMarker *mY = new QwtPlotMarker(); mY->setLabel(QString::fromLatin1("Osobnik najlepszy = ")+QString::number(-d)); mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); mY->setLineStyle(QwtPlotMarker::HLine); mY->setYValue(-d); mY->attach(this); }
/*! \brief Specify the Y position of the marker \param key Marker key \param val Y position of the marker \return \c TRUE if the specified marker exists */ bool QwtPlot::setMarkerYPos(long key, double val) { int rv = FALSE; QwtPlotMarker *m; if ((m = d_markers->find(key))) { m->setYValue(val); rv = TRUE; } return rv; }
void caStripPlot::addText(double x, double y, char* text, QColor c, int fontsize) { QwtPlotMarker *mY = new QwtPlotMarker(); QwtText txt; txt.setText(text); txt.setFont(QFont("Helvetica",fontsize, QFont::Bold)); txt.setColor(c); mY->setLabel(txt); mY->setLabelAlignment(Qt::AlignRight | Qt::AlignTop); mY->setXValue(x); mY->setYValue(y); mY->attach(this); replot(); }
Plot::Plot() { setTitle("A Simple QwtPlot Demonstration"); insertLegend(new QwtLegend(), QwtPlot::RightLegend); // Set axis titles setAxisTitle(xBottom, "x -->"); setAxisTitle(yLeft, "y -->"); // Insert new curves QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)"); #if QT_VERSION >= 0x040000 cSin->setRenderHint(QwtPlotItem::RenderAntialiased); #endif cSin->setPen(QPen(Qt::red)); cSin->attach(this); QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)"); #if QT_VERSION >= 0x040000 cCos->setRenderHint(QwtPlotItem::RenderAntialiased); #endif cCos->setPen(QPen(Qt::blue)); cCos->attach(this); // Create sin and cos data const int nPoints = 100; cSin->setData(SimpleData(::sin, nPoints)); cCos->setData(SimpleData(::cos, nPoints)); // Insert markers // ...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 vertical line at x = 2 * pi QwtPlotMarker *mX = new QwtPlotMarker(); mX->setLabel(QString::fromLatin1("x = 2 pi")); mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom); mX->setLabelOrientation(Qt::Vertical); mX->setLineStyle(QwtPlotMarker::VLine); mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine)); mX->setXValue(2.0 * M_PI); mX->attach(this); }
void MainWindow::setInitialTimeDisplay(int start) { std::size_t ncols = _vm["file.ncols"].as<int>(); std::size_t nrows = _vm["file.nrows"].as<int>(); //TODO: move plotting to appropiate method std::size_t numofplottedsamples = _vm["plot.num.samples"].as<int>(); _gridPlot->p->detachItems(); _gridPlot->setoffset(start); double interrowoffset = _vm["inter.row.offset"].as<double>(); for (std::size_t row=0; row<nrows; ++row){ // for (std::size_t row=0; row<1; ++row){ std::vector<double> xs(numofplottedsamples); std::vector<double> ys(numofplottedsamples); std::stringstream strst; std::string strTitle = "Row"; strst << strTitle << "-" << row; strTitle = strst.str(); QwtPlotCurve *tscurve = new QwtPlotCurve((char *)strTitle.c_str()); for (std::size_t x = 0; x < numofplottedsamples; ++x) { if (x+start<ncols){ xs[x] = (x+start)/_gridPlot->gridXpixelsperunit; //position in seconds if (_bf!=NULL) { ys[x] = row*interrowoffset + (*_bf)(row,x+start)/_gridPlot->gridYpixelsperunit; //y value of that sample } else if (_bfsi!=NULL) { ys[x] = row*interrowoffset + (*_bfsi)(row,x+start)/_gridPlot->gridYpixelsperunit; //y value of that sample } } } tscurve->setSamples(&xs[0],&ys[0],xs.size()); tscurve->setPen(QPen(Qt::black)); QwtPlotMarker *rowNameText = new QwtPlotMarker(); rowNameText->setLabel(QString(strTitle.c_str())); rowNameText->setXValue(xs[0]+0.25); rowNameText->setYValue(row*interrowoffset-0.5); rowNameText->attach(_gridPlot->p); tscurve->attach(_gridPlot->p); } _gridPlot->resetzoom(); }
void VectorPlot::addHorizontalLine(double value, QString labelText) { QPen pen(QColor(0, 0, 255)); QwtPlotMarker* horizontalLineMarker = new QwtPlotMarker(); horizontalLineMarker->setLineStyle(QwtPlotMarker::HLine); horizontalLineMarker->setLinePen(pen); horizontalLineMarker->setYValue(value); QwtText label; label.setText(labelText); QFont font = label.font(); font.setPointSize(9); label.setFont(font); horizontalLineMarker->setLabel(label); horizontalLineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignLeft); horizontalLineMarker->attach(plot); }
void VectorPlot::addMarking(const std::vector<int> &marking) { QwtDoubleRect boundingRect(0, 1, marking.size() - 1, 2); setupPlot(boundingRect); // this is gonna be slow... for(unsigned i = 0; i < marking.size(); ++i) { QwtPlotMarker* marker = new QwtPlotMarker(); QwtText text; text.setText(QString::number(marking[i])); marker->setLabel(text); marker->setXValue((double)i); marker->setYValue(0.0); marker->attach(plot); } }
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(); }
void Plot::populate() { // Insert new curves QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)"); cSin->setRenderHint(QwtPlotItem::RenderAntialiased); cSin->setLegendAttribute(QwtPlotCurve::LegendShowLine, true); cSin->setPen(QPen(Qt::red)); cSin->attach(this); QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)"); cCos->setRenderHint(QwtPlotItem::RenderAntialiased); cCos->setLegendAttribute(QwtPlotCurve::LegendShowLine, true); cCos->setPen(QPen(Qt::blue)); cCos->attach(this); // Create sin and cos data cSin->setData(new FunctionData(::sin)); cCos->setData(new FunctionData(::cos)); // Insert markers // ...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 vertical line at x = 2 * pi QwtPlotMarker *mX = new QwtPlotMarker(); mX->setLabel(QString::fromLatin1("x = 2 pi")); mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom); mX->setLabelOrientation(Qt::Vertical); mX->setLineStyle(QwtPlotMarker::VLine); mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine)); mX->setXValue(2.0 * M_PI); mX->attach(this); }
/*! * Initializes the Main Window */ DataPlot::DataPlot(QWidget *parent): QwtPlot(parent), d_interval(0), d_timerId(-1), min(0), max(10) { id = 0; plotAccx = plotAccy = plotMgx = plotMgy = plotTemp = plotMic = plotVl = plotIr = true; auto_scale = false; filter = new dataFilter(); for(int i = 0; i < 8; i++) attached[i] = true; // Disable polygon clipping QwtPainter::setDeviceClipping(false); running = false; // We don't need the cache here canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); #if QT_VERSION >= 0x040000 #ifdef Q_WS_X11 /* Qt::WA_PaintOnScreen is only supported for X11, but leads to substantial bugs with Qt 4.2.x/Windows */ canvas()->setAttribute(Qt::WA_PaintOnScreen, true); #endif #endif alignScales(); // Initialize data for (int i = 0; i< PLOT_SIZE; i++) { d_x[i] = 0.5 * i; // time axis d_mgx[i] = 0; d_mgy[i] = 0; d_accx[i] = 0; d_accy[i] = 0; d_mic[i] = 0; d_ir[i] = 0; d_temp[i] = 0; } // Assign a title setTitle(QString("Sensors for Node %1").arg(id)); insertLegend(new QwtLegend(), QwtPlot::BottomLegend); // Insert new curves mgxPlot = new QwtPlotCurve("MGx"); //mgxFilteredPlot = new QwtPlotCurve("Filtered MGx"); mgyPlot = new QwtPlotCurve("MGy"); //mgyPlot = new QwtPlotCurve("Moving Average"); AccyPlot = new QwtPlotCurve("ACCy"); //AccyPlot = new QwtPlotCurve("e"); AccxPlot = new QwtPlotCurve("ACCx"); tempPlot = new QwtPlotCurve("Temp"); irPlot = new QwtPlotCurve("IR"); micPlot = new QwtPlotCurve("MIC"); vlPlot = new QwtPlotCurve("VL"); AccyPlot->attach(this); AccxPlot->attach(this); mgxPlot->attach(this); //mgxFilteredPlot->attach(this); mgyPlot->attach(this); tempPlot->attach(this); irPlot->attach(this); micPlot->attach(this); vlPlot->attach(this); const QColor bgColor(255,255,255); #if QT_VERSION < 0x040000 setPaletteBackgroundColor(bgColor); #else QPalette p = palette(); p.setColor(backgroundRole(), bgColor); setPalette(p); #endif //! \todo Change line thickness // Set curve styles QPen *pen = new QPen(Qt::darkBlue); pen->setWidth(2); mgxPlot->setPen(*pen); QwtSplineCurveFitter *f = new QwtSplineCurveFitter(); f->setFitMode(QwtSplineCurveFitter::Spline); mgxPlot->setCurveFitter(f); pen->setColor(Qt::darkMagenta); //mgxFilteredPlot->setPen(*pen); pen->setColor(Qt::red); mgyPlot->setPen(*pen); mgyPlot->setCurveFitter(f); pen->setColor(Qt::green); AccyPlot->setPen(*pen); AccyPlot->setCurveFitter(f); pen->setColor(Qt::darkGray); AccxPlot->setPen(*pen); AccxPlot->setCurveFitter(f); pen->setColor(Qt::yellow); tempPlot->setPen(*pen); tempPlot->setCurveFitter(f); pen->setColor(Qt::darkGreen); irPlot->setPen(*pen); irPlot->setCurveFitter(f); pen->setColor(Qt::magenta); micPlot->setPen(*pen); micPlot->setCurveFitter(f); pen->setColor(Qt::darkRed); vlPlot->setPen(*pen); vlPlot->setCurveFitter(f); // Attach (don't copy) data. Both curves use the same x array. mgxPlot->setRawData(d_x, d_mgx, PLOT_SIZE); // mgxFilteredPlot->setRawData(d_x, d_fmgx, PLOT_SIZE); mgyPlot->setRawData(d_x, d_mgy, PLOT_SIZE); AccyPlot->setRawData(d_x, d_accy, PLOT_SIZE); AccxPlot->setRawData(d_x, d_accx, PLOT_SIZE); tempPlot->setRawData(d_x, d_temp, PLOT_SIZE); irPlot->setRawData(d_x, d_ir, PLOT_SIZE); micPlot->setRawData(d_x, d_mic, PLOT_SIZE); vlPlot->setRawData(d_x, d_vl, PLOT_SIZE); #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 // Axis setAxisTitle(QwtPlot::xBottom, "Time/seconds"); setAxisScale(QwtPlot::xBottom, 0, 100); setAxisTitle(QwtPlot::yLeft, "Values"); setAxisScale(QwtPlot::yLeft, 0, 10); setTimerInterval(0.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 ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_accelXPoints(100, QPointF(0, 0)), m_accelYPoints(100, QPointF(0, 0)), m_gyroXPoints(100, QPointF(0, 0)), m_gyroYPoints(100, QPointF(0, 0)), m_counter(0), m_power(0) { ui->setupUi(this); // init scenes xScene = new QGraphicsScene(); yScene = new QGraphicsScene(); xScene->setBackgroundBrush(Qt::white); yScene->setBackgroundBrush(Qt::white); ui->xGraphicsView->setScene(xScene); ui->yGraphicsView->setScene(yScene); m_tcpSocket = new QTcpSocket(this); connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(onTcpRead())); m_controlSocket = new QTcpSocket(this); connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(onControlRead())); // connecting connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectToServer())); connect(ui->disconnectButton, SIGNAL(clicked()), this, SLOT(disconnectFromServer())); // control buttons connect(ui->up2Button, SIGNAL(clicked()), this, SLOT(handleControlButton())); connect(ui->up1Button, SIGNAL(clicked()), this, SLOT(handleControlButton())); connect(ui->zeroButton, SIGNAL(clicked()), this, SLOT(handleControlButton())); connect(ui->down1Button, SIGNAL(clicked()), this, SLOT(handleControlButton())); connect(ui->down2Button, SIGNAL(clicked()), this, SLOT(handleControlButton())); // plotting setup m_accelXData = new QwtPointSeriesData(); m_accelYData = new QwtPointSeriesData(); m_accelXCurve = new QwtPlotCurve("Accel X"); m_accelYCurve = new QwtPlotCurve("Accel Y"); m_accelXCurve->setPen( QPen( Qt::black ) ); m_accelYCurve->setPen( QPen( Qt::red)); m_accelXCurve->attach( ui->plot ); m_accelYCurve->attach(ui->plot); m_gyroXData = new QwtPointSeriesData(); m_gyroYData = new QwtPointSeriesData(); m_gyroXCurve = new QwtPlotCurve("Gyro X"); m_gyroYCurve = new QwtPlotCurve("Gyro Y"); m_gyroXCurve->setPen( QPen( Qt::green ) ); m_gyroYCurve->setPen( QPen( Qt::blue)); m_gyroXCurve->attach( ui->plot ); m_gyroYCurve->attach(ui->plot); ui->plot->setCanvasBackground(Qt::white); // Axes ui->plot->setAxisTitle( QwtPlot::xBottom, "Seconds" ); ui->plot->setAxisTitle( QwtPlot::yLeft, "Degrees" ); ui->plot->setAxisScale( QwtPlot::yLeft, -90, 90 ); // zero line QwtPlotMarker* zeroMarker = new QwtPlotMarker(); zeroMarker->setLineStyle(QwtPlotMarker::HLine); zeroMarker->setLinePen(QPen(Qt::DotLine)); zeroMarker->setSymbol(new QwtSymbol(QwtSymbol::HLine)); zeroMarker->setYValue(0); zeroMarker->attach(ui->plot); updatePlot(0, 0, 0, 0); }
// // Initialize main window // DataPlot::DataPlot(QWidget *parent): QwtPlot(parent), d_interval(0), d_timerId(-1) { // Disable polygon clipping QwtPainter::setDeviceClipping(false); // We don't need the cache here canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); #if QT_VERSION >= 0x040000 #ifdef Q_WS_X11 /* Qt::WA_PaintOnScreen is only supported for X11, but leads to substantial bugs with Qt 4.2.x/Windows */ canvas()->setAttribute(Qt::WA_PaintOnScreen, true); #endif #endif alignScales(); // Initialize data for (int i = 0; i< PLOT_SIZE; i++) { d_x[i] = 0.5 * i; // time axis d_y[i] = 0; d_z[i] = 0; } // Assign a title setTitle("A Test for High Refresh Rates"); insertLegend(new QwtLegend(), QwtPlot::BottomLegend); // Insert new curves QwtPlotCurve *cRight = new QwtPlotCurve("Data Moving Right"); cRight->attach(this); QwtPlotCurve *cLeft = new QwtPlotCurve("Data Moving Left"); cLeft->attach(this); // Set curve styles cRight->setPen(QPen(Qt::red)); cLeft->setPen(QPen(Qt::blue)); // Attach (don't copy) data. Both curves use the same x array. cRight->setRawData(d_x, d_y, PLOT_SIZE); cLeft->setRawData(d_x, d_z, PLOT_SIZE); #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 // Axis setAxisTitle(QwtPlot::xBottom, "Time/seconds"); setAxisScale(QwtPlot::xBottom, 0, 100); setAxisTitle(QwtPlot::yLeft, "Values"); setAxisScale(QwtPlot::yLeft, -1.5, 1.5); setTimerInterval(0.0); }
void Nullcline::MakePlotItems() { #ifdef DEBUG_FUNC ScopeTracker st("Nullcline::MakePlotItems", std::this_thread::get_id()); #endif std::unique_lock<std::mutex> lock( Mutex() ); if (_packets.empty()) return; while (_packets.size()>1) { delete _packets.front(); _packets.pop_front(); } Record* record = _packets.front(); _packets.pop_front(); if (!record) return; lock.unlock(); ClearPlotItems(); const size_t xidx = Spec_toi("xidx"), yidx = Spec_toi("yidx"), resolution2 = NumParserMgrs(), resolution = (int)sqrt(resolution2); const std::vector< std::pair<int,int> >& xcross_h = record->xcross_h, & xcross_v = record->xcross_v, & ycross_h = record->ycross_h, & ycross_v = record->ycross_v; const double* x = record->x, * y = record->y; const double xinc = record->xinc, yinc = record->yinc; const size_t xnum_pts_h = xcross_h.size(), xnum_pts_v = xcross_v.size(), ynum_pts_h = ycross_h.size(), ynum_pts_v = ycross_v.size(); ReservePlotItems(xnum_pts_h + xnum_pts_v + ynum_pts_h + ynum_pts_v); const QColor& xcolor = _colors.at(xidx+1); for (size_t i=0; i<xnum_pts_h; ++i) { QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush(xcolor), QPen(xcolor, 2), QSize(5, 5) ); QwtPlotMarker* marker = new QwtPlotMarker(); marker->setSymbol(symbol); const int idx = xcross_h.at(i).first*resolution + xcross_h.at(i).second; marker->setXValue(x[idx] + xinc/2.0); marker->setYValue(y[idx]); marker->setZ(-1); AddPlotItem(marker); } for (size_t i=0; i<xnum_pts_v; ++i) { QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush(xcolor), QPen(xcolor, 2), QSize(5, 5) ); QwtPlotMarker* marker = new QwtPlotMarker(); marker->setSymbol(symbol); const int idx = xcross_v.at(i).first*resolution + xcross_v.at(i).second; marker->setXValue(x[idx]); marker->setYValue(y[idx] + yinc/2.0); marker->setZ(-1); AddPlotItem(marker); } QColor ycolor = _colors.at(yidx+1); for (size_t i=0; i<ynum_pts_h; ++i) { QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush(ycolor), QPen(ycolor, 2), QSize(5, 5) ); QwtPlotMarker* marker = new QwtPlotMarker(); marker->setSymbol(symbol); const int idx = ycross_h.at(i).first*resolution + ycross_h.at(i).second; marker->setXValue(x[idx] + xinc/2.0); marker->setYValue(y[idx]); marker->setZ(-1); AddPlotItem(marker); } for (size_t i=0; i<ynum_pts_v; ++i) { QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse, QBrush(ycolor), QPen(ycolor, 2), QSize(5, 5) ); QwtPlotMarker* marker = new QwtPlotMarker(); marker->setSymbol(symbol); const int idx = ycross_v.at(i).first*resolution + ycross_v.at(i).second; marker->setXValue(x[idx]); marker->setYValue(y[idx] + yinc/2.0); marker->setZ(-1); AddPlotItem(marker); } DrawBase::Initialize(); //Have to wait on this, since we don't know how many objects there //are until the analysis is complete delete record; }