Hi, Uwe
I made a subclass A from QwtPlotPicker and also a subclass B from QwtPickerMachine.
And I call setStateMachine() to link them.
What I want to achieve is like this:
For a curve, at first, click on any point of the curve, then the point is selected.
And next, move the mouse around, the point will go with the mouse, and there will be a rubber band between this selected point and the point before it or after it on the curve.
And at the end, double-click at any position, the point will be set there.
By this way, the curve is changed or edited.
But now, my problem is:
Whenever I click at the first time, it seems the commad is translated to be a single-click and then soon a double-click. So, the point could be seen as being selected and moved a little and be placed very near to its old position when I just click one time. But after that, all is OK: click on one point again, move it around and set the point as I like.At each time , when I new the picker on the canvas and set it to be enabled, the first click is always like the above.
Why and How to fix it?
Hope for your advice.
Thanks in advance.
Nicho
Below is the source codes of my machine's transition:
8 QList<QwtPickerMachine
::Command> MyPointPickMoveMachine
::transition(const QwtEventPattern &eventPattern,
const QEvent *e
) 9 {
10 QList<QwtPickerMachine::Command> cmdList;
11
12 switch(e->type())
13 {
14 case QEvent::MouseButtonDblClick: 15 {
17 if( me -> button() == Qt::LeftButton )
18 {
19 if( state() == 1 )
20 {
21 cmdList += End;
22 setState(0);
23 }
24 }
25 break;
26 }
27 case QEvent::MouseButtonPress: 28 {
30 if( me -> button() == Qt::LeftButton )
31 {
32 if ( state() == 0 )
33 {
34 cmdList += Begin;
35 cmdList += Append;
36 cmdList += Append;
37 setState(1);
38 }
39 else
40 {
41 cmdList += End;
42 setState(0);
43 }
44 }
45 else if( me -> button() == Qt::MidButton )
46 {
47 if( state() != 0 )
48 {
49 cmdList += Remove;
50 cmdList += End;
51 setState(0);
52 }
53 }
54 break;
55 }
58 {
59 if ( state() != 0 )
60 cmdList += Move;
61 break;
62 }
63 }
8 QList<QwtPickerMachine::Command> MyPointPickMoveMachine::transition(const QwtEventPattern &eventPattern, const QEvent *e)
9 {
10 QList<QwtPickerMachine::Command> cmdList;
11
12 switch(e->type())
13 {
14 case QEvent::MouseButtonDblClick:
15 {
16 QMouseEvent *me = ( QMouseEvent * )e;
17 if( me -> button() == Qt::LeftButton )
18 {
19 if( state() == 1 )
20 {
21 cmdList += End;
22 setState(0);
23 }
24 }
25 break;
26 }
27 case QEvent::MouseButtonPress:
28 {
29 QMouseEvent *me = ( QMouseEvent * )e;
30 if( me -> button() == Qt::LeftButton )
31 {
32 if ( state() == 0 )
33 {
34 cmdList += Begin;
35 cmdList += Append;
36 cmdList += Append;
37 setState(1);
38 }
39 else
40 {
41 cmdList += End;
42 setState(0);
43 }
44 }
45 else if( me -> button() == Qt::MidButton )
46 {
47 if( state() != 0 )
48 {
49 cmdList += Remove;
50 cmdList += End;
51 setState(0);
52 }
53 }
54 break;
55 }
56 case QEvent::MouseMove:
57 case QEvent::Wheel:
58 {
59 if ( state() != 0 )
60 cmdList += Move;
61 break;
62 }
63 }
To copy to clipboard, switch view to plain text mode
Bookmarks