Re: QwtPlotItem::setZ() isn't working correctly
Hi everybody, hi Uwe.
I'm using a QwtPlot (based on the oscilloscope example) to show live data with one or more QwtPlotCurve. Optionally there are markers (QwtPlotMarker) and one QwtPlotTextLabel shown in the plot.
The z-order (QwtPlotItem::setZ()) for the curves is 1, for the QwtPlotMarker z is 2 and 3 for the QwtPlotTextLabel.
The z-order for the marker and the label is working correctly (the label is always on top of the marker), but the curves are sometimes on top of everything and sometimes everything is shown in the right order. The curves are updated using QwtPlotDirectPainter::drawSeries().
Code for the plot: https://github.com/knarfS/smuview/bl.../plot/plot.cpp
Is this a bug or am I doing something wrong?
Thanks,
Frank
Added after 55 minutes:
Sorry but I totally forgot:
When I activate replot() in Plot::update_curves() (https://github.com/knarfS/smuview/bl.../plot.cpp#L686), the z-order is working, but the curves starts to flicker when there are ~500 samples shown...
Re: QwtPlotItem::setZ() isn't working correctly
Quote:
Originally Posted by
knarfS
The curves are updated using QwtPlotDirectPainter::drawSeries().
This is a specific hack that allows to draw incrementally on top of the existing content without having to repaint the rest.
So yes this will break the z-order and there is no way to get around it.
Uwe
Re: QwtPlotItem::setZ() isn't working correctly
Hi Uwe.
Ok, that makes sense.
Is there another possibility to live plot a large number of data points with some sort of a z-order?
Frank
Re: QwtPlotItem::setZ() isn't working correctly
One approach would be to draw your curve to a pixmap and overload QwtPlot::drawItems to bring the pixmap into the game.
But I would check first if it is possible to speed up rendering itself:
- try to run on a hardware accelerated graphics backend.
- don't use antialiasing or pens with a width > 1
- maybe QwtPlotCurve::FilterPointsAggressive ( Qwt >= 6.2 ) can be used
- ...
I would also decouple sample and replot rates. Usually it doesn't make much sense to replot more than a few times per second.
Uwe
Re: QwtPlotItem::setZ() isn't working correctly
Quote:
Originally Posted by
Uwe
This is a specific hack that allows to draw incrementally on top of the existing content without having to repaint the rest.
So yes this will break the z-order and there is no way to get around it.
Uwe
Oh no! Uwe, is this also the case when using a QwtPlotCurve? I'm having the same issue of QwtPlotItems being below the plot regardless of the QwtPlotItem::setZ().
(However, I'm following your itemeditor example, so when I move the QwtPlotItem I create a temporary QwtWidgetOverlay and this places the moving item ABOVE the plot, as I want.)
So, with QwtPlotCurve does one still need to render to a custom pixmap to fix the z-order, or are there other workarounds, such as with QwtWidgetOverlay or something else?
EDIT: Aha! I got it to work by using QwtPlotCurve::setZ(0). Setting QwtPlotItem::setZ() seems to have no effect in relation to the z height of the curve.
Re: QwtPlotItem::setZ() isn't working correctly
There is no specific QwtPlotCurve::setZ() - it is exactly the same call as QwtPlotItem::setZ().
Uwe