1 Attachment(s)
Looking for a simple QwtWidgetOverlay implementation example
Hi,
I'm facing a small problem. My application plots a 3D cube (f.e. XYZ data). I have 3 plots using QwtPlotSpectrogram, one for ZX, one for ZY and one for XY.
Each plot emit moved signal through a derived QwtPlotPicker using a QwtPickerTrackerMachine machine state. the signal emitted from a plot is used to display a marker on the other plots to show the corresponding projected position (see figure attached). In this example the mouse lies in the plot below with the green rubber, then the markers (small red rectangles) will be plotted on the above plots.
The problem is, it slows down a lot my picker rubber when I move the mouse in a plot. This is probably due to replot mechanism that replot the entire plot widget on the other 2 plots to update the small marker position.
When I disable the code related to the update of red markers position wrt mouse position, there is no lag.
I tried to seek a solution on google to understanding this lag problem, it seems that I can solve this by using QwtWidgetOverlay instead of QwtPlotMarker (previous thread here)
I also dig down to qwt code and understood that QwtPlotPicker rubber and so on use QwtWidgetOverlay that explain why they don't lag with the mouse move in general.
My development skill is limited since I am a physicist and I couldn't easily understand from qwt code how to use QwtWidgetOverlay.
So my question is simple, can I find a simple example to implement a QwtWidgetOverlay to avoid slow down effects.
Thanks by advance.
Attachment 10148
Re: Looking for a simple QwtWidgetOverlay implementation example
What you need is something like this ( untested ):
Code:
class Overlay: public QwtWidgetOverlay
{
public:
QwtWidgetOverlay( canvas )
{
}
void setPosition( const QPointF& pos )
[
m_pos = pos;
updateOverlay();
}
virtual void drawOverlay
( QPainter *painter
) const {
const QwtPlot* plot
= dynamic_cast<const
QwtPlot*>
( parent
()->parent
() );
painter->setPen( Qt::yellow );
painter->drawLine( pos.x(), 0, pos.x(), height() );
painter->drawLine( 0, pos.y(), 0, width() );
}
}
HTH, Uwe
Re: Looking for a simple QwtWidgetOverlay implementation example
Magic!
no lag anymore.
Just remove QPainter local declaration and use the one passed through parameters.
Thank you very much.