Results 1 to 5 of 5

Thread: About QwtPlotPickerMachine

  1. #1
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default About QwtPlotPickerMachine

    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:
    Qt Code:
    1. 8 QList<QwtPickerMachine::Command> MyPointPickMoveMachine::transition(const QwtEventPattern &eventPattern, const QEvent *e)
    2. 9 {
    3. 10 QList<QwtPickerMachine::Command> cmdList;
    4. 11
    5. 12 switch(e->type())
    6. 13 {
    7. 14 case QEvent::MouseButtonDblClick:
    8. 15 {
    9. 16 QMouseEvent *me = ( QMouseEvent * )e;
    10. 17 if( me -> button() == Qt::LeftButton )
    11. 18 {
    12. 19 if( state() == 1 )
    13. 20 {
    14. 21 cmdList += End;
    15. 22 setState(0);
    16. 23 }
    17. 24 }
    18. 25 break;
    19. 26 }
    20. 27 case QEvent::MouseButtonPress:
    21. 28 {
    22. 29 QMouseEvent *me = ( QMouseEvent * )e;
    23. 30 if( me -> button() == Qt::LeftButton )
    24. 31 {
    25. 32 if ( state() == 0 )
    26. 33 {
    27. 34 cmdList += Begin;
    28. 35 cmdList += Append;
    29. 36 cmdList += Append;
    30. 37 setState(1);
    31. 38 }
    32. 39 else
    33. 40 {
    34. 41 cmdList += End;
    35. 42 setState(0);
    36. 43 }
    37. 44 }
    38. 45 else if( me -> button() == Qt::MidButton )
    39. 46 {
    40. 47 if( state() != 0 )
    41. 48 {
    42. 49 cmdList += Remove;
    43. 50 cmdList += End;
    44. 51 setState(0);
    45. 52 }
    46. 53 }
    47. 54 break;
    48. 55 }
    49. 56 case QEvent::MouseMove:
    50. 57 case QEvent::Wheel:
    51. 58 {
    52. 59 if ( state() != 0 )
    53. 60 cmdList += Move;
    54. 61 break;
    55. 62 }
    56. 63 }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About QwtPlotPickerMachine

    As far as I can see your state machine also terminates the selection with a second single click of the left button ( lines 39-43 in the blue numbering ).

    Uwe

  3. #3
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: About QwtPlotPickerMachine

    Quote Originally Posted by Uwe View Post
    As far as I can see your state machine also terminates the selection with a second single click of the left button ( lines 39-43 in the blue numbering ).

    Uwe
    Uwe,
    what I want is like what you mentioned : first single click to select the point , then move it, and the second click to terminate the selection and set the point to the mouse position . But for each time when I created the picker , first single click , just only one single click , not click the second time, then the point will be selected and then be set to the position where it is right there before . no chance to move it during that. so that for each first round
    I can not get what I want. But next, I go on click, the point is selected, and can move it, and click again, the point is set to the mouse position.
    I guess the first click will be translated into two APPEND commands, will these two APPENDs be used as a double click or the first APPEND is correct but the second APPEND is used as the second single click?maybe the problem is related to this, but I am not sure and if it is TRUE, I can not interpret this situation and I dont know how to fix it.

    Nicho
    Last edited by Nicho; 7th August 2013 at 12:47.

  4. #4
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: About QwtPlotPickerMachine

    Uwe,
    or the first APPEND is correct but the second APPEND is used as the second single click?so when i just click once , the selection is terminated ?

    Nicho

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About QwtPlotPickerMachine

    No the selection terminates on "End". Start the debugger and set a breakpoint in QwtPicker::end() to see how it is called.

    Uwe

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.