Results 1 to 2 of 2

Thread: How to redraw everything while panning the canvas?

  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to redraw everything while panning the canvas?

    Hi there. I'm evaluating the Qwt library, and so far it has impressed me in several aspects.

    But I've encountered two important issues regarding panning. I've added a QwtPlotPanner to the canvas, and the grid moves while I pan. There are however some additional items I want to have redrawn for each move event. for to make a nice and smooth plot.

    Issue 1: The axes are only redrawn when I release the mouse button. I want the axes/ruler to be drawn while moving (with the grid) to make it a smooth experience for the user.
    Issue 2: The grid is moved, but this is only the pixmap created before the move started. Hence new lines in the grid is not created outside of the initial area.


    I did partly solve issue 1 by replacing
    Qt Code:
    1. emit moved(d_data->pos.x() - d_data->initialPos.x(),
    2. d_data->pos.y() - d_data->initialPos.y());
    To copy to clipboard, switch view to plain text mode 
    in the widgetMouseMoveEvent in qwt.panner.cpp to
    Qt Code:
    1. emit panned(d_data->pos.x() - d_data->initialPos.x(),
    2. d_data->pos.y() - d_data->initialPos.y());
    3. d_data->initialPos = d_data->pos;
    To copy to clipboard, switch view to plain text mode 
    The moved signal doesn't seem to be connected to anything anyway. This fix will introduce a bug with the grid moving; the grid flickers because of the setting of the initialPos in the middle of move events.

    How can these two issues be solved?

    Thanks in advance,
    Stig

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

    Default Re: How to redraw everything while panning the canvas?

    QwtPanner grabs the content of the canvas into a pixmap and moves the pixmap only. This is done for performance reasons, because rendering the plot items might be too slow for mouse movements. If you don't want this - don't use the panner.

    Instead catch all mouse events of the plot canvas using an event filter. Translate the mouse movements into coordinates of the plot using the canvas maps ( QwtPlot::canvasMap ) and adjust the scales.

Similar Threads

  1. QGraphicsView and panning performance
    By prashant in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2009, 19:40
  2. Panning QGraphicsScene
    By prashant in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2009, 20:41
  3. How can I redraw the QTreeWidgetITem?
    By cspp in forum Qt Programming
    Replies: 13
    Last Post: 14th May 2009, 11:50
  4. Panning
    By linuxdev in forum The GraphicsView Framework
    Replies: 3
    Last Post: 30th December 2008, 06:40
  5. Graphics View Panning ,zooming
    By linuxdev in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2008, 07:17

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.