PDA

View Full Version : Keep PlotPicker rectangle after mouse button released



missoni
6th March 2013, 18:00
Hey!
I have trouble figuring out which behaviour of which class has to be overriden.

I need to draw a rectangle when user presses left mouse button and drags mouse (like QwtPlotZoomer does), but after the button is released, the rectangle should not disappear. The drawn rectangle should remain until user starts drawing another rectangle or presses right mouse button to clear the plot area.

I have tried inheriting from QwtPickerDragRectMachine, but I am not really sure which behavior should be overriden. What do the states mean? Does e.g. setState(0) in QList<QwtPickerMachine::Command> QwtPickerClickRectMachine::transition(const QwtEventPattern &eventPattern, const QEvent *event) reset the rectangle?

I could create a second QwtPlotPicker, which would not be interactive and would only be triggered by a signal coming from the first QwtPlotPicker as soon as the rectangle is finished. I find such a solution not extraordinarily beautiful and if it possible to implement the functionality I am striving for in one class, I'd rather go for that option.

Thanks in advance for any help!

Uwe
8th March 2013, 07:18
Insert a new QwtPlotShapeItem with the coordinates of the rectangle.

Uwe

missoni
11th March 2013, 09:27
Insert a new QwtPlotShapeItem with the coordinates of the rectangle.

Uwe

Hey Uwe,
where do I find a QwtPlotShapeItem? It is not in Qwt 6.0.2, neither in the docs, nor in the sources.

raphael.lencrerot
11th March 2013, 19:07
You have to use 6.1
svn checkout svn://svn.code.sf.net/p/qwt/code/trunk/qwt
I had to upgrade mine also to use this item recently.

Uwe
11th March 2013, 20:32
Another option is to copy the code of the RectItem ( 6.0 only ) you find in the navigation example.

Uwe

missoni
12th March 2013, 15:58
Another option is to copy the code of the RectItem ( 6.0 only ) you find in the navigation example.

Uwe

Awesome, thanks!


You have to use 6.1
svn checkout svn://svn.code.sf.net/p/qwt/code/trunk/qwt
I had to upgrade mine also to use this item recently.

Thanks for your advice. I tried copying only the necessary files, but there have been too many changes since 6.0.2. I will have to upgrade whole Qwt soon.