Results 1 to 7 of 7

Thread: setRenderThreadCount with Curves and SpectroCurve ??

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default setRenderThreadCount with Curves and SpectroCurve ??

    Hello,

    I am trying to use QwtPoltCurve and QwtSpectroCurve for a large number of points, over 2M. But there a slow when replot the curves. Specially when Zooing or panning.

    from a previous post, Uwe recommended me to use "setRenderThreadCount" with the curve and that was an added implementation for SVN trunk before qt6.1 was released.

    Now i am using qt6.1 downloaded from this website.

    but this method is not available at least with the version i just downloaded.
    any suggestion or recommendation how to improve the speed of zooming and panning (reploting) of the curves ?? with different PenSize.

    Thank you so much.
    Last edited by jesse_mark; 20th February 2013 at 17:13.

  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: setRenderThreadCount with Curves and SpectroCurve ??

    ...but this method is not available at least with the version i just downloaded.
    You find it in its base class, QwtPlotItem::setRenderThreadCount().

    Multithreading is used by QwtPlotCurve in a special combination, where the curve is rendered to a QImage before painting ( see the scatterplot example ).Together with avoiding the overhead of QPainter this is indeed a drastic performance improvement. The same could be done in QwtPlotSpectroCurve - probably 1-2 h of work

    This special mode is implemented for pens with a pen size <= 1 as this means setting an RGB value at a position in an image only. For a larger pen width some algo for rendering a circle to a QImage without using QPainter would be necessary .

    Another optimization I can imagine is to introduce a cache for the translated colors. The value -> color translation doesn't need to be done again and again for every replot.

    When you have a good idea for a Qwt example using QwtPlotSpectroCurve ( with synthetic data ) I would have a look at this class.

    Uwe

  3. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setRenderThreadCount with Curves and SpectroCurve ??

    by trying both qwt versions, which svn for qwt6.0 and the new release qwt6.1, for the qwtPoltCurve there was a big performance improvement for the replot with > 2M points.
    this even without using the Multithreading and with using qwtSymbols with size >1 (exactly size=3), i still see a performance improvement when using the Curve.I was able to pan and zoom much more smoothly.

    but with SpectroCurve it is still the same, slow to pan and zoom.

    The same could be done in QwtPlotSpectroCurve - probably 1-2 h of work
    Man, this is probably for you just 1-2h, with me and my basic level its probably 1-2 weeks .

    So, to have this performance improvement with SpectroCurve, what do i need to do ?? can you explain more for me please?
    do you think, this improvement will be soon available with next updates of SVN trunk ??


    When you have a good idea for a Qwt example using QwtPlotSpectroCurve ( with synthetic data ) I would have a look at this class.
    Well, as a good use of SpectroCurve, in my case now, i have a lot of points and each point has a different (weight/value), I filter these points using their weight. Now, I am using just a curve with symbol for each point.

    To have a different color for each point to indicate its weight, will make the filtering more efficient, and will give lot more information about the represented points.

    synthetic data, I really do not have one, but i can make a file with random values for 2M points, but that may look so random.

    Thanks for all your help and support.
    Last edited by jesse_mark; 21st February 2013 at 17:27.

  4. #4
    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: setRenderThreadCount with Curves and SpectroCurve ??

    by trying both qwt versions, which svn for qwt6.0 and the new release qwt6.1, for the qwtPoltCurve there was a big performance improvement for the replot with > 2M points.
    this even without using the Multithreading and with using qwtSymbols with size >1 (exactly size=3), i still see a performance improvement when using the Curve.I was able to pan and zoom much more smoothly..
    Multithreading is only implemented for QwtPlotCurve::Dots with a pen width <= 1 in combination with QwtPlotCurve::ImageBuffer.

    When using symbols I expect 2 reasons for the performance improvement:


    • Qwt 6.1 tries to autodetect if it is faster to render the symbol to a QPixmap once and using this pixmap later. With Qwt 6.0 this has to be enabled explicitly by setting the QwtPlotCurve::CacheSymbols flag.
    • As Qwt 6.1 reintroduced using integer coordinates for paint devices with integer based coordinate systems it is possible to filter out points that are mapped to the same position ( QwtPlotCurve::FilterPoints ).


    So, to have this performance improvement with SpectroCurve, what do i need to do ??
    You can't have the same performance as the situation is different, all what could be done easily is:


    • calculating the colors in advance
    • rendering multithreaded to a QImage for a pen width <= 1


    There might be more optimizations, when using a simple color map with a couple of colors only.

    Uwe

  5. #5
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setRenderThreadCount with Curves and SpectroCurve ??

    With Qwt 6.0 this has to be enabled explicitly by setting the QwtPlotCurve::CacheSymbols flag.
    tried to set the PaintAttribute to CacheSymbols, but u can not find this flag, the flags i could found were only :
    ClipPolygons
    FilterPoints
    MinimizeMemory
    ImageBuffer

    so how should i set this flag??

    You can't have the same performance as the situation is different, all what could be done easily is:

    * calculating the colors in advance
    how can I calculate it ?? do i have to overloaded some function ? or set specific flag/s ??
    * rendering multithreaded to a QImage for a pen width <= 1
    is it the the same way with the curve ??



    btw: how to find which version the library is and if it a an SVN or final release?

    Thank you so much.
    Last edited by jesse_mark; 25th February 2013 at 15:39.

  6. #6
    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: setRenderThreadCount with Curves and SpectroCurve ??

    Quote Originally Posted by jesse_mark View Post
    tried to set the PaintAttribute to CacheSymbols, but u can not find this flag, the flags i could found were only :
    ClipPolygons
    FilterPoints
    MinimizeMemory
    ImageBuffer
    These are the flags you find in Qwt 6.1, where you have QwtSymbol::setCachePolicy(). But as the default setting is to autodetect the best choice for the situation you don't need to take care of it anymore.
    btw: how to find which version the library is and if it a an SVN or final release?.
    Downloading from SVN trunk is always the current development branch ( at the moment 6.1 ), all other SVN branches are maintenance branches for a previous release. So f.e in the qwt-6.0 branch you find the latest 6.0 release with binary compatible bug fixes.

    All packages can be found here: http://sourceforge.net/projects/qwt/files. Alle packages in qwt are final releases, all packages in qwt-beta not.

    Concerning the optimizations I wrote about what could be done in theory - but QwtPlotSpectroCurve is not prepared to offer them. But it is is a very simple class ( the draw method has only 51 lines of code ) and you should be able to overload it and implement something tailored for your situation.

    Check the implementation and you will agree.

    Uwe

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

    jesse_mark (26th February 2013)

  8. #7
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setRenderThreadCount with Curves and SpectroCurve ??

    These are the flags you find in Qwt 6.1
    so this means i am using two different versions of qwt6.1, probably qwt6.1 old SVN version and the last release qwt6.1-rc3 , as The two have the same PaintAttribute, one simple different was the older qwt6.1 use

    grid->setMajPen() while the other use grid->setMajorPen(). and they differ in performance when reploting the curve with lot of points.


    Thanks, I'll have a look at the spectroCurve implementation and see if I can do your suggestions.


    Added after 1 57 minutes:


    Well, I was trying to overload the drawDots method,

    .h
    Qt Code:
    1. #ifndef SPECTROCURVE_H
    2. #define SPECTROCURVE_H
    3. #include <qwt_plot_spectrocurve.h>
    4.  
    5. class SpectroCurve : public QwtPlotSpectroCurve
    6. {
    7.  
    8. public:
    9. SpectroCurve(QWidget * = NULL);
    10.  
    11. protected:
    12. virtual void drawDots( QPainter *,
    13. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    14. const QRectF &canvasRect, int from, int to ) const;
    15.  
    16. };
    17.  
    18. #endif // SPECTROCURVE_H
    To copy to clipboard, switch view to plain text mode 

    .cpp

    Qt Code:
    1. #include "spectrocurve.h"
    2. #include "qwt_plot_spectrocurve.h"
    3. #include "qwt_color_map.h"
    4. #include "qwt_scale_map.h"
    5. #include "qwt_painter.h"
    6. #include <qpainter.h>
    7.  
    8. SpectroCurve::SpectroCurve( QWidget *parent ):
    9. QwtPlotSpectroCurve()
    10. {
    11.  
    12. }
    13.  
    14. void QwtPlotSpectroCurve::drawDots( QPainter *painter,
    15. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    16. const QRectF &canvasRect, int from, int to ) const
    17. {
    18. // if ( !d_data->colorRange.isValid() )
    19. // return;
    20.  
    21. // const bool doAlign = QwtPainter::roundingAlignment( painter );
    22.  
    23. // const QwtColorMap::Format format = d_data->colorMap->format();
    24. // if ( format == QwtColorMap::Indexed )
    25. // d_data->colorTable = d_data->colorMap->colorTable( d_data->colorRange );
    26.  
    27. // const QwtSeriesData<QwtPoint3D> *series = data();
    28.  
    29. // for ( int i = from; i <= to; i++ )
    30. // {
    31. // const QwtPoint3D sample = series->sample( i );
    32.  
    33. // double xi = xMap.transform( sample.x() );
    34. // double yi = yMap.transform( sample.y() );
    35. // if ( doAlign )
    36. // {
    37. // xi = qRound( xi );
    38. // yi = qRound( yi );
    39. // }
    40.  
    41. // if ( d_data->paintAttributes & QwtPlotSpectroCurve::ClipPoints )
    42. // {
    43. // if ( !canvasRect.contains( xi, yi ) )
    44. // continue;
    45. // }
    46.  
    47. // if ( format == QwtColorMap::RGB )
    48. // {
    49. // const QRgb rgb = d_data->colorMap->rgb(
    50. // d_data->colorRange, sample.z() );
    51.  
    52. // painter->setPen( QPen( QColor( rgb ), d_data->penWidth ) );
    53. // }
    54. // else
    55. // {
    56. // const unsigned char index = d_data->colorMap->colorIndex(
    57. // d_data->colorRange, sample.z() );
    58.  
    59. // painter->setPen( QPen( QColor( d_data->colorTable[index] ),
    60. // d_data->penWidth ) );
    61. // }
    62.  
    63. // QwtPainter::drawPoint( painter, QPointF( xi, yi ) );
    64. // }
    65.  
    66. // d_data->colorTable.clear();
    67. }
    To copy to clipboard, switch view to plain text mode 

    I keep getting error when i try to compile it.

    error: undefined reference to `VTT for SpectroCurve'
    error: undefined reference to `vtable for SpectroCurve'


    I wonder if i can use the same code the drawDots method has, so i can play around to understand the code, but
    these errors are thrown.

    error: invalid use of incomplete type 'struct QwtPlotSpectroCurve::PrivateData'
    error: forward declaration of 'struct QwtPlotSpectroCurve::PrivateData'


    thanks
    Last edited by jesse_mark; 26th February 2013 at 17:01.

Similar Threads

  1. Replies: 2
    Last Post: 20th February 2013, 09:10
  2. qwt several curves at a plot
    By freude3 in forum Qwt
    Replies: 4
    Last Post: 4th January 2011, 07:45
  3. qwt display curves
    By sergio486 in forum Qt Programming
    Replies: 0
    Last Post: 11th December 2010, 21:27
  4. Information about curves
    By den in forum Qwt
    Replies: 1
    Last Post: 27th April 2010, 19:02
  5. Multiple curves on top of each other
    By jmsbc in forum Qwt
    Replies: 2
    Last Post: 15th July 2009, 19:46

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.