Results 1 to 4 of 4

Thread: Qwt minimize drawing part

  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Qwt minimize drawing part

    Hi all,
    I am concerning about optimization when redrawing of qwt plot.
    A Qwtplot has a QwtPlotItem attached. When there is new data, calling plot.replot() will redraw everything including QwtScale. Is there anyway to call QwtPlotItem to update only when there is new data to avoid the rest to update (because my QwtScale is static all the time). Caching pixmap is one solution but it is a redraw anyway.
    This can be apply to barchart, xy plot, qwtDial, etc.

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt minimize drawing part

    Time it takes to blit cached pixmap to the screen is insignificant when it comes to performance.
    Redrawing the scales shouldn't be a bottleneck either.

    Btw do you know rules of premature optimization?
    Rule 1 : Don't optimize!
    Rule 2 : Don't optimize jet!

    I'm guessing that rule 1 applies here

  3. #3
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qwt minimize drawing part

    hi Spitfire,
    Thank you for your quick reply. I cant see the difference between the two mentioned rules though
    Let me use QwtDial for embedded device as an example.
    I suppose that by default every parts of the dial apart from the needle has been cached right?
    and you mean that the CPU usage spent for redrawing these cache pixmap is insignificant compared with one for redrawing the needle?


    Added after 4 minutes:


    In addition, pixmap of the needle can also be cached then we can rotate the pixmap to display updated value.
    Last edited by lamle; 13th April 2012 at 11:47.

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

    Default Re: Qwt minimize drawing part

    In general it depends on your system if blitting a pixmap is a relevant operation. F.e. when using an unaccelerated framebuffer driver or the graphic board is connected via a slow bus it matters. I've seen such devices where blitting a 800x600 image takes about 70ms, what might be too slow for widgets like speedos. But on usual desktop PCs it shouldn't matter.

    Also Qt Embedded platforms differ - depending on your plugin and how it is implemented. In most implementations I have seen the composition of the screen is done in memory and drawing a pixmap is not more than copying bits in memory. The bottlenecks are usually happening after the screen composition is done: so when you try to optimize something in application code the important thing is usually to reduce the regions to be updated - the parameter you can set in QWidget::update/repaint.

    About Qwt: the situation for a widget like QwtDial is very different to QwtPlot - so better don't mix up both in the same discussion:

    A) QwtDial

    When the value of a QwtDial changes you could limit the update regions to the bounding rectangle of the previous and the new position.

    An extra cache for the background of QwtDial is pointless as drawing the background ( including the scales ) is indeed no operation that takes much time. Caching the needle is no good idea as rotating a pixmap is a very slow operation ( more expensive than drawing a not too complex shape ) and the result is ugly ( artefacts instead of antialiasing ) - this makes no sense at all.

    B) QwtPlot

    QwtPlot/QwtPlotCanvas are optimized in many ways and most ( probably all ) what you wrote is wrong. But if you have questions in this area better come up with a detailed use case - general concerns are not helpful as plots and their requirements differ a lot.

    Uwe

Similar Threads

  1. PyQt4 - part of a QPixmap not drawing correctly
    By emorris in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2012, 15:17
  2. Minimize to Tray
    By QT8seven in forum Qt Programming
    Replies: 3
    Last Post: 5th December 2011, 11:12
  3. Replies: 2
    Last Post: 23rd August 2011, 12:23
  4. Hide on Minimize
    By defunct in forum Qt Programming
    Replies: 9
    Last Post: 26th March 2009, 09:46
  5. Minimize other Window
    By johncharlesb in forum Qt Programming
    Replies: 1
    Last Post: 14th October 2007, 16:22

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.