PDA

View Full Version : I do not understand QwtEventPattern. Can someone explain?



sadastronaut
5th August 2014, 19:53
What does make sense to me:


QwtPlotMagnifier * magnifier;
magnifier->setMouseButton(Qt::MiddleButton);
This makes sense. I assign the middle button to the magnifying function.

What doesn't make sense:

QwtPlotPicker * picker;
picker->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton);
I simply don't understand the event patterns. I want to assign the right mouse button to the picker, but I don't know where the QwtEventPattern::MouseSelect2 fits in.

I see the header that, for instance QwtEventPattern::MouseSelect2
is

/*!
The default setting for 1, 2 and 3 button mice is:

- Qt::LeftButton + Qt::ControlModifier
- Qt::RightButton
- Qt::RightButton
*/
but I simply don't know what this means, and how it relates to the buttons I want to assign. (I mean, I know what each individual component is, like Qt::RightButton, but I don't know what the 3 mean collectively).

Uwe
6th August 2014, 10:25
QwtPickerMachine is a mealy machine ( http://en.wikipedia.org/wiki/Mealy_machine ), where QwtEventPattern::MousePatternCode/KeyPatternCode defines the input and QwtPickerMachine::Command the output alphabet.

So what you can do on application side is:



Change the type of machine - mapping an inputs to a command sequence
change the mapping of mouse/keyboard events to the input alphabet
implement what to do on the commands ( f.e by overloading QwtPicker::move() )


Not sure if this makes it more understandable when you are unfamiliar with the concept of state machines, but my experience is, that application requirements how to select things on a plot canvas is so different, that a simpler API like for QwtPlotMagnifier would not be enough.

Uwe