本文整理汇总了C++中QwtPlotMarker::setYValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotMarker::setYValue方法的具体用法?C++ QwtPlotMarker::setYValue怎么用?C++ QwtPlotMarker::setYValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotMarker
的用法示例。
在下文中一共展示了QwtPlotMarker::setYValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clear
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 );
}
示例2: QDialog
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.
}
示例3: fm
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
}
示例4: Plot_AddHLine
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 );
}
示例5: dodaj_naj
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);
}
示例6: setMarkerYPos
/*!
\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;
}
示例7: addText
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();
}
示例8: setTitle
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);
}
示例9: setInitialTimeDisplay
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();
}
示例10: canvasPalette
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();
}
示例11: 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);
}
示例12: bgColor
//.........这里部分代码省略.........
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);
}
示例13: canvasPalette
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 );
}
示例14: QMainWindow
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);
}
示例15: QwtPlot
//
// 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);
}