d_interval(0, 30),
d_paintedPoints(0),
d_timerId(-1)
{
d_directPainter = new QwtPlotDirectPainter();
setAutoReplot(false);
// We don't need the cache here
//canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
#if defined(Q_WS_X11)
// Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent
// works on X11. This has a nice effect on the performance.
canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
plotLayout()->setAlignCanvasToScales(true);
setAxisTitle
(QwtPlot::xBottom,
"Time [s]");
setAxisTitle
(QwtPlot::yLeft,
"Temperature");
setAxisScale
(QwtPlot::xBottom, d_interval.
minValue(), d_interval.
maxValue());
setAxisScale
(QwtPlot::yLeft,
-20,
20);
grid
->setPen
(QPen(Qt
::gray,
0.0, Qt
::DotLine));
grid->enableX(true);
grid->enableXMin(true);
grid->enableY(true);
grid->enableYMin(false);
grid->attach(this);
/*
// Mark middle
d_origin = new QwtPlotMarker();
d_origin->setLineStyle(QwtPlotMarker::Cross);
// In future calculate middle
d_origin->setValue(5, 0.0);
d_origin->setLinePen(QPen(Qt::gray, 0.0, Qt::DashLine));
d_origin->attach(this);
*/
d_curve
->setPen
(QPen(Qt
::green));
#if 1
d_curve
->setRenderHint
(QwtPlotItem::RenderAntialiased,
true);
#endif
#if 1
d_curve
->setPaintAttribute
(QwtPlotCurve::ClipPolygons,
false);
#endif
d_curve->setData(new CurveData());
d_curve->attach(this);
d_zoomer = new Zoomer(canvas());
d_zoomer
->setRubberBandPen
(QPen(Qt
::red,
2, Qt
::DotLine));
d_zoomer
->setTrackerPen
(QPen(Qt
::red));
}
MyPlot::MyPlot(QWidget *parent):
QwtPlot(parent),
d_interval(0, 30),
d_paintedPoints(0),
d_timerId(-1)
{
d_directPainter = new QwtPlotDirectPainter();
setAutoReplot(false);
// We don't need the cache here
canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
//canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
#if defined(Q_WS_X11)
// Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent
// works on X11. This has a nice effect on the performance.
canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
plotLayout()->setAlignCanvasToScales(true);
setAxisTitle(QwtPlot::xBottom, "Time [s]");
setAxisTitle(QwtPlot::yLeft, "Temperature");
setAxisScale(QwtPlot::xBottom, d_interval.minValue(), d_interval.maxValue());
setAxisScale(QwtPlot::yLeft, -20, 20);
QwtPlotGrid *grid = new QwtPlotGrid();
grid->setPen(QPen(Qt::gray, 0.0, Qt::DotLine));
grid->enableX(true);
grid->enableXMin(true);
grid->enableY(true);
grid->enableYMin(false);
grid->attach(this);
/*
// Mark middle
d_origin = new QwtPlotMarker();
d_origin->setLineStyle(QwtPlotMarker::Cross);
// In future calculate middle
d_origin->setValue(5, 0.0);
d_origin->setLinePen(QPen(Qt::gray, 0.0, Qt::DashLine));
d_origin->attach(this);
*/
d_curve = new QwtPlotCurve();
d_curve->setStyle(QwtPlotCurve::Lines);
d_curve->setPen(QPen(Qt::green));
#if 1
d_curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
#endif
#if 1
d_curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, false);
#endif
d_curve->setData(new CurveData());
d_curve->attach(this);
d_zoomer = new Zoomer(canvas());
d_zoomer->setRubberBandPen(QPen(Qt::red, 2, Qt::DotLine));
d_zoomer->setTrackerPen(QPen(Qt::red));
}
To copy to clipboard, switch view to plain text mode
// (my y-axis range is -20 to 20)
QRectF newRect
(1,
-20,
30,
40);
m_Plot->setZoomRect(newRect); // This calls: d_zoomer->zoom(newRect);
// (my y-axis range is -20 to 20)
QRectF newRect(1, -20, 30, 40);
m_Plot->setZoomRect(newRect); // This calls: d_zoomer->zoom(newRect);
To copy to clipboard, switch view to plain text mode
Bookmarks