Results 1 to 9 of 9

Thread: Speed problem dragging points

  1. #1
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Speed problem dragging points

    In my project I have to draw a line with mouse.
    To do this I have take some code slice from event_filter example in qwt source dir.
    It works quite well if the window is "little", but it become too slow if I maximize the windows.
    This issue is present also in the event_filter example, I have also have a screencast.
    I hope it is not an issue of qwt, and I wonder how to speed up it

    best regards
    Max

  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: Speed problem dragging points

    Quote Originally Posted by mastupristi View Post
    To do this I have take some code slice from event_filter example in qwt source dir.
    In this example you have replots while moving the point, what is o.k. for the example, but for plots with some content this should be avoided. A better approach is to translate the part that needs to be dragged into a QwtWidgetOverlay when being selected and retranslate it to a plot item when being released The itemeditor example shows how to do it - also QwtPlotPicker/QwtPlotZoomer use this a widget overlay for the rubberband.

    Quote Originally Posted by mastupristi View Post
    It works quite well if the window is "little", but it become too slow if I maximize the windows.
    I can't confirm this effect on my system and I don't see any reason why this should happen - at least, when you don't use a remote desktop.
    But without knowing more detail about your environment it is hard to say any useful. But in general, when speaking about remote desktops and X11 I recommend to stay with Qt4 and the X11 paint engine ( what also offers hardware acceleration ).

    But as a first step I recommend to play with the itemeditor example ( dragging the items with the mouse ). When working with remote desktops the mask mode ( see the combo box in the top left corner ) might have an effect.

    Uwe

  3. #3
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Re: Speed problem dragging points

    I have simplified as much as possible the event_filter example.
    ev-filt.tar.gz
    my purpose is to understand how this works, and then apply the overlay.
    I have some questions, also unrelated to this issue.

    but first of all I have to take a look deeply to the itemeditor example, and then I can try to apply overlay this example and the to my project.
    Do you have any suggestion to make me get my goal quickly?

    best regards
    Max
    Last edited by mastupristi; 1st May 2016 at 01:53.

  4. #4
    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: Speed problem dragging points

    Quote Originally Posted by mastupristi View Post
    Do you have any suggestion to make me get my goal quickly?
    First of all you have to find out the reason for the bad performance - your code works without any problems on my box.

    So what Qt version, which operating system, which hardware, is it a remote desktop ...

    Uwe

  5. #5
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Speed problem dragging points

    I use xubuntu 16.04 with official qt pakages: qt 5.5.1, qwt 6.1.2.
    The hw is an Intel i7 970, nVidia 460, 12gb RAM

    Best regards
    Max

  6. #6
    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: Speed problem dragging points

    Sounds like a powerful system - all I can imagine, that might explain the video is when your X11 is totally misconfigured.

    Uwe

  7. #7
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Speed problem dragging points

    My computer is six years old, not a recent one, but it is still quite powerfull.
    I'll take a look to x11 config. Until now I trust ubuntu to configure automagically X.
    Anyway, the itemeditor example is fast enough also in full screen mode, and zoomed to have bigger items.

    Best regards
    Max

  8. #8
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Speed problem dragging points

    I spent some time investigating X11 config, I installed the new nVidia proprietary driver, I have tested the performance with x11perf. Nothing seems wrong. But the event_filter example was still slow.

    So I decide to have a deeper look to itemeditor example to make event_filter use overlay.

    The result is here:
    ev-filt-overlay.tar.gz
    It is definitely improvable, as coding style, as class usage, but it is fast enough also in fullscreen.
    Can I have your opinion about it?

    I also have a question on itemeditor example.

    about eventFilter method in Editor class:
    Qt Code:
    1. bool Editor::eventFilter( QObject* object, QEvent* event )
    2. {
    3. QwtPlot *plot = qobject_cast<QwtPlot *>( parent() );
    4. if ( plot && object == plot->canvas() )
    5. {
    6. switch( event->type() )
    7. {
    8. case QEvent::MouseButtonPress:
    9. {
    10. const QMouseEvent* mouseEvent =
    11. dynamic_cast<QMouseEvent* >( event );
    12.  
    13. if ( d_overlay == NULL &&
    14. mouseEvent->button() == Qt::LeftButton )
    15. {
    16. const bool accepted = pressed( mouseEvent->pos() );
    17. if ( accepted )
    18. {
    19. d_overlay = new Overlay( plot->canvas(), this );
    20.  
    21. d_overlay->updateOverlay();
    22. d_overlay->show();
    23. }
    24. }
    25.  
    26. break;
    27. }
    28. case QEvent::MouseMove:
    29. {
    30. if ( d_overlay )
    31. {
    32. const QMouseEvent* mouseEvent =
    33. dynamic_cast< QMouseEvent* >( event );
    34.  
    35. const bool accepted = moved( mouseEvent->pos() );
    36. if ( accepted )
    37. d_overlay->updateOverlay();
    38. }
    39.  
    40. break;
    41. }
    42. case QEvent::MouseButtonRelease:
    43. {
    44. const QMouseEvent* mouseEvent =
    45. static_cast<QMouseEvent* >( event );
    46.  
    47. if ( d_overlay && mouseEvent->button() == Qt::LeftButton )
    48. {
    49. released( mouseEvent->pos() );
    50.  
    51. delete d_overlay;
    52. d_overlay = NULL;
    53. }
    54.  
    55. break;
    56. }
    57. default:
    58. break;
    59. }
    60.  
    61. return false;
    62. }
    63.  
    64. return QObject::eventFilter( object, event );
    65. }
    To copy to clipboard, switch view to plain text mode 

    For every event in the switch, it return false (line 61). But in the QT documentation about QObject::eventFilter there is:
    In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
    In this case why return false instead of true, since the events are handled?

    best regards
    Max

  9. #9
    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: Speed problem dragging points

    There are 2 differences between what happens in the itemeditor and the event_filter example.

    a) In the itemeditor example the content of the plot remains unchanged. So when the item is dragged the content can be restored from a pixmap cache without having to do a replot.
    b) Depending on the Mask parameter, the pixels written to the graphics stack might be limited to the pixels, that are really changing.

    As the event_filter has almost no content, the effect of a) should be no factor - for heavy plots it would be significant. So in your case I would expect, that b) is what you are suffering from.

    In case of remote desktops it is obvious, that pushing a fullscreen image ( width * height * 4 ) over the network is slower than a smaller one. Here it might be worth to go back to Qt4 ( graphic system native ), what is much faster for vector graphics. But as you are not using a remote desktop it means, that flushing a RGB buffer is a horrible bottleneck - something that will hit you in many other situations as well.

    Uwe

Similar Threads

  1. Replies: 8
    Last Post: 6th December 2019, 18:11
  2. Replies: 4
    Last Post: 8th October 2012, 07:05
  3. QWebkit and dragging problem
    By .:saeed:. in forum Qt Programming
    Replies: 4
    Last Post: 7th October 2012, 14:56
  4. Problem in dragging and move QDockWidget
    By stilgar in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2012, 11:33
  5. QAbstractItemDelegate painting while dragging problem
    By rickbsgu in forum Qt Programming
    Replies: 0
    Last Post: 25th March 2011, 20:35

Tags for this Thread

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.