Results 1 to 5 of 5

Thread: QwtRasterData increase quality

  1. #1
    Join Date
    Dec 2017
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default QwtRasterData increase quality

    Hello everybody,
    I'm working on a project where I have to plot many points on a spectrogram (I'm plotting level curves of a 3d function), and so far I've implemented all the features I need for this program, but when I want to use the feature "Print" to print the plot to pdf or any other format and try to zoom in far enough I get a loss in quality of the type you can see on the following picture. I've tried to change the resolution of the QwtPlotRenderer object in dpi to big numbers (like 1200 or so) but it doesn't really change the "smoothness" of the curves and I always seem to get those "spikes" on the curves.
    My question is, is there any way I can "postpone" this behaviour, that is, since this is a plot I know I will end up having those "spikes", but can I increase the number of safe zooms on this plot?

    Capturar.jpgCapturar.jpg

    Also, I implemented the QwtRasterData as in the Spectrogram exemple that comes with qwt:

    Qt Code:
    1. class SpectrogramData: public QwtRasterData
    2. {
    3. const double u;
    4. public:
    5. SpectrogramData(double externalValue, double cCenter, double cInterval) :
    6. u(externalValue)
    7. {
    8. setInterval( Qt::XAxis, QwtInterval(-1.5, 1.5) );
    9. setInterval( Qt::YAxis, QwtInterval(-1.5, 1.5) );
    10. setInterval( Qt::ZAxis, QwtInterval(cCenter-cInterval/2, cCenter+cInterval/2) );
    11. }
    12.  
    13. virtual double value( double x, double y ) const
    14. {
    15. const double v1 = -0.5*(x*x+y*y);
    16. const double v2 = -(1-u)/(qSqrt((x-u)*(x-u)+y*y));
    17. const double v3 = -u/(qSqrt((x+1-u)*(x+1-u)+y*y));
    18. return v1+v2+v3;
    19. }
    20. };
    To copy to clipboard, switch view to plain text mode 

    And I have read something about
    Qt Code:
    1. setRenderThreadCount(0);
    To copy to clipboard, switch view to plain text mode 
    but it doesn't seem to change anything so far...
    Thank you,
    Hope it wasn't too confusing

  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: QwtRasterData increase quality

    When printing to PDF or SVG all vector data stays as vector data and you can zoom in/out in a viewer without a loss of quality. Any other image formats will never do what you want.
    Of course this is not the case for raster data. It is possible to introduce interpolation algos to make things smoother ( like done in QwtMatrixData::BilinearInterpolation ), but the only way to solve it in a fundamental way is to vectorize your data.

    Increasing the resolution of the output device has an effect, as long as your data supports the required resolution. But using a resolution like 100000x100000 will create a huge output and the result might also not look good when being displayed as 1024x1024.

    Uwe

  3. #3
    Join Date
    Dec 2017
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtRasterData increase quality

    I have been studying vector VS raster data and what you say makes sense, but unfortunately I'm newbie enough so that I can't find any class on qwt that allows me to insert my data as vector data (also because I chose the easy way first which was to get inspiration from the source code for the qwt spectrogram example)... Will I be able to just transform my spectrogram class without having to make big changes in the remaining code? Also, I don't like at all to ask for code because it makes it look as if I want other people to do the work for me, but do you happen to have any sample on how to insert data in vector form?
    Thank you!

  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: QwtRasterData increase quality

    Quote Originally Posted by airflow View Post
    I can't find any class on qwt that allows me to insert my data as vector data
    Qwt doesn't offer a vectorizer, but converting raster to vector data is a common subject of investigations and you should find more info in the net.

    Will I be able to just transform my spectrogram class without having to make big changes in the remaining code?
    No - the corresponding representation as vector data is something you would probably convert into a QPainterPath - or a sequence of QPainterPaths. This could then be the displayed with QwtPlotShapeItems.

    Uwe

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

    airflow (10th January 2018)

  6. #5
    Join Date
    Dec 2017
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtRasterData increase quality

    Alright so it goes beyond the scope of my program and that solves the question I guess, thank you for your time!

Similar Threads

  1. Replies: 1
    Last Post: 7th September 2017, 18:35
  2. Replies: 1
    Last Post: 9th October 2015, 12:44
  3. QwtPlotSpectrogram and QwtRasterData
    By jesse_mark in forum Qwt
    Replies: 10
    Last Post: 5th February 2013, 15:59
  4. QwtRasterData and values
    By DKL1972 in forum Qwt
    Replies: 12
    Last Post: 10th March 2010, 10:53
  5. Convert QwtRasterData to QwtSeriesData
    By bigjoeystud in forum Qwt
    Replies: 3
    Last Post: 25th August 2009, 16:06

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.