Results 1 to 12 of 12

Thread: Changing data in spectogram

  1. #1
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Changing data in spectogram

    Hi!

    I'm trying to modify spectogram example to plot interpolated function z(x,y) based on 2D array Z and 1D arrays X and Y. I made interpolation algorithm and function
    Qt Code:
    1. double value(double x, double y)
    To copy to clipboard, switch view to plain text mode 
    , but i have a problem to implement those arrays.
    I tried with pointers to arrays in SpectrogramData, but I cant get it work.

    What's the easiest way to provide those arrays to value function?
    Second step is to change values of arrays and replot...

    Thanks!

    P.S.
    Qt Code:
    1. class SpectrogramData: public QwtRasterData
    To copy to clipboard, switch view to plain text mode 

  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: Changing data in spectogram

    Quote Originally Posted by stefan View Post
    What's the easiest way to provide those arrays to value function?
    Use QwtMatrixRasterData ( it implements next next neighbour and bilinear interpolation ).

    Quote Originally Posted by stefan View Post
    Second step is to change values of arrays and replot...
    The spectrogram caches the rendered image, that needs to be invalidated before you replot. The spectrogram class implicitely invalidates this image, when you use its public API. When you want to change the array behind the back of the class you have to call spectrogram->invalidateCache() manually.

    Uwe

  3. The following 2 users say thank you to Uwe for this useful post:

    Onanymous (19th July 2011), stefan (21st July 2011)

  4. #3
    Join Date
    May 2010
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing data in spectogram

    Quote Originally Posted by Uwe View Post
    The spectrogram class implicitely invalidates this image, when you use its public API. When you want to change the array behind the back of the class you have to call spectrogram->invalidateCache() manually.
    Uwe
    Thanks a lot for that note. This should be written in big letters somewhere in the documentation of spectrogram.

  5. #4
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing data in spectogram

    Thanks, it's working!

  6. #5
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing data in spectogram

    Hi,
    I have another issue regarding spectogram example, thus I'll continue on this post.

    When I change intervals
    Qt Code:
    1. setInterval( Qt::XAxis, QwtInterval( -1.5, 1.56 ) );
    To copy to clipboard, switch view to plain text mode 
    The plot is actually drawn from -1.5 to 2.0
    It probably rounds limits.. But I dont want that.
    How can I prevent that? How can I crop a plot? I dont mind if the last value on the axis is 1.5

    Thank you

  7. #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: Changing data in spectogram

    To avoid, that tick labels close to the borders extend the canvas you have to set:
    Qt Code:
    1. plot->plotLayout()->setAlignCanvasToScales(true);
    To copy to clipboard, switch view to plain text mode 

    Next you have to decide if you want to use auto scaling or not. If not you can assign the axes scales manually.

    Qt Code:
    1. plot->setAxisScale( QwtPlot::xBottom, ... );
    2. plot->setAxisScale( QwtPlot::yLeft, ... );
    3. ...
    To copy to clipboard, switch view to plain text mode 

    If you want to have autoscaling, but you want to exclude your spectrogram from participating:

    Qt Code:
    1. spectrogram->setItemAtribute( QwtPlotItem::AutoScale, false );
    To copy to clipboard, switch view to plain text mode 

    Or if you want to have autoscaling for your spectrogram , but you don't want the autoscaler to align the borders of the scales:

    Qt Code:
    1. plot->axisScaleEngine( QwtPlot::xBottom )->setAttribute(
    2. QwtScaleEngine::Floating, true );
    3. plot->axisScaleEngine( QwtPlot::yLeft )->setAttribute(
    4. QwtScaleEngine::Floating, true );
    5. ...
    To copy to clipboard, switch view to plain text mode 

    HTH,
    Uwe

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

    stefan (25th July 2011)

  9. #7
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing data in spectogram

    Yes, that's exactly what I'm looking for!
    Qt Code:
    1. plotLayout()->setAlignCanvasToScales(true);
    2. setAxisScale( QwtPlot::xBottom,X->first(),X->last());
    3. setAxisScale( QwtPlot::yLeft,Y->first(),Y->last());
    4. colorAxis->setColorMap(QwtDoubleInterval(zMin, zMax),d_spectrogram->colorMap());
    5. setAxisScale(QwtPlot::yRight,zMin,zMax);
    To copy to clipboard, switch view to plain text mode 

    Uwe, you are a true QwtMaster Thanks!

  10. #8
    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: Changing data in spectogram

    No, obviously you want autoscaling. Then this is your code ( of course with the same result ):

    Qt Code:
    1. plotLayout()->setAlignCanvasToScales(true);
    2. axisScaleEngine( QwtPlot::xBottom )->setAttribute(
    3. QwtScaleEngine::Floating, true );
    4. axisScaleEngine( QwtPlot::yLeft )->setAttribute(
    5. QwtScaleEngine::Floating, true );
    6. colorAxis->setColorMap(QwtDoubleInterval(
    7. zMin, zMax), d_spectrogram->colorMap());
    8. setAxisScale(QwtPlot::yRight, zMin, zMax);
    To copy to clipboard, switch view to plain text mode 
    Uwe

  11. #9
    Join Date
    Apr 2011
    Posts
    58
    Thanks
    1

    Default Re: Changing data in spectogram

    Hi.
    Following on this topic. I'm trying to use the spectrogram to plot and visualize some elevation data...
    I've only the intensity values (height of the mountains) at certain points in the x,y coordinates. Total about 20 heights.
    How do I input the raster data so that I could see the spectrogram being interpolated inbetween the mountain heights?
    The entire area map is about 400x400 in length and width.
    Thank you for any advise.

  12. #10
    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: Changing data in spectogram

    Quote Originally Posted by marc2050 View Post
    Following on this topic.
    This question doesn't follow - please start a new thread for a unrelated posting,

    Uwe

  13. #11
    Join Date
    Sep 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Changing data in spectogram

    This doesn't work for me

  14. #12
    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: Changing data in spectogram

    Quote Originally Posted by dzemomona12 View Post
    This doesn't work for me
    You failed with starting a new thread for unrelated postings ?

    Uwe

Similar Threads

  1. Replies: 0
    Last Post: 23rd February 2011, 00:07
  2. Printing complex page with changing data
    By marcvanriet in forum Qt Programming
    Replies: 4
    Last Post: 22nd December 2010, 01:15
  3. QSortFilterProxyModel with changing data
    By kemp in forum Qt Programming
    Replies: 4
    Last Post: 13th September 2010, 07:27
  4. Replies: 8
    Last Post: 25th April 2010, 21:19
  5. Spectogram related
    By KosyakOFF in forum Qwt
    Replies: 6
    Last Post: 30th April 2009, 06:59

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.