Results 1 to 2 of 2

Thread: DirectPainter and z order

  1. #1
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default DirectPainter and z order

    This is another about updating a QwtPlotCurve as new data arrives from a time-sensitive source. Refer to the oscilloscope example but create a sweep effect instead of clearing on each restart.

    Using Qt 4.8 and qwt-6.0.1, currently developing on Windows and the app will also be on Linux.

    Bursts of data arrive, say 50 at a time, up to 100000, then repeat. To update an existing section, first set a QwtPlotDirectPainter pen to black, slightly wider than the actual curve, and redraw the 50 old points. Second I have an overloaded hook to QwtSeriesData->replace(), so update the 50 points. Finally change the DirectPainter pen to normal and draw the new section.

    The problem - DirectPainter black pen erases QwtPlotGrid where they overlap. The z value is 10 for grid and 20 for plot curve. Changing these during initialization or before painting makes no difference.

    As a guess, does DirectPainter ignore this and assume that its curves are always supposed to be on top?

    Several workarounds come to mind but all require a replot. The idea of clip regions is a bit fuzzy, not sure if this means a rectangle or other shape is the only part replotted. I have not run across examples that fit here.

    Am I missing something or any suggestions to get the grid points back, or replot only a region?
    Thanks,
    Scott

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

    Default Re: DirectPainter and z order

    Quote Originally Posted by ScottBell View Post
    The problem - DirectPainter black pen erases QwtPlotGrid where they overlap. The z value is 10 for grid and 20 for plot curve.
    Plot items are painted in order of increasing z values. So in your setting the curve will always be on top of the grid !

    As a guess, does DirectPainter ignore this and assume that its curves are always supposed to be on top?
    Yes, the direct painter always paints on top of the existing content - z values are of no meaning when using it.

    Am I missing something or any suggestions to get the grid points back, or replot only a region?
    You could repaint the grid lines after you have added a new section of your curve.

    With the X11 paint engine it is easy, as you can paint outside of paint events. If not you have to do the same what the direct painter does:


    1. install en event filter for the plot canvas
    2. call canvas()-repaint
    3. uninstall the event filter


    Inside of the event filter check for paint events and draw the lines that were crossed by the new section of the curve

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    ScottBell (7th February 2013)

Similar Threads

  1. Replies: 3
    Last Post: 28th September 2012, 14:01
  2. tab order in QTabWidget
    By ugluk in forum Qt Programming
    Replies: 2
    Last Post: 23rd July 2012, 13:25
  3. Execution order
    By Ishtar in forum Newbie
    Replies: 2
    Last Post: 26th April 2010, 20:36
  4. Setting Tab order
    By Rakesh_Kumar in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2009, 04:58
  5. about tab order
    By hesummar in forum Qt Programming
    Replies: 7
    Last Post: 16th November 2006, 05:45

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.