Results 1 to 4 of 4

Thread: Map NaN values to white instead of "black" (0u) in QwtPlotSpectrogram?

  1. #1
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Map NaN values to white instead of "black" (0u) in QwtPlotSpectrogram?

    Hi

    I wonder if there is a way to change so that "invalid" (in my case, qQNaN()) values in QwtRasterData is mapped to white instead of "black" (0u?) value in a QwtPlotSpectrogram? If this is very complicated, I think I could come around it by just changing all NaN values to some value which is outside the range of relevant data/values that I want to display, adjust the colorStops in the color map I use so that the values of "uninteresting"/invalid data always is between two white color stops, and set the axis scale of the colormap axis to only the relevant range. But, it feels like it would be a much better solution if I could just change how NaN values are mapped.

    Any good advice out there?

  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: Map NaN values to white instead of "black" (0u) in QwtPlotSpectrogram?

    Quote Originally Posted by dobedidoo View Post
    I wonder if there is a way to change so that "invalid" (in my case, qQNaN()) values in QwtRasterData is mapped to white instead of "black" (0u?)
    It is transparent not black - the alpha value is 0 and you should see the background color of the canvas at those positions.

    Uwe

  3. #3
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    34
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Map NaN values to white instead of "black" (0u) in QwtPlotSpectrogram?

    Hm, I just see black where I would then hope for "transparent". In tried setting the canvas backgound to white (and even tried yellow) with setCanvasBackground(), and in the Spectrogram example (which I modified to return qQNaN() for raster data values < 1.0), I just see black in those areas. If I lower the opacity I see that the canvas background is in fact white (or yellow), so why do I just see the black color instead of "transparent"? Strange...

  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: Map NaN values to white instead of "black" (0u) in QwtPlotSpectrogram?

    I added the following code to the example:
    Qt Code:
    1. setCanvasBackground( Qt::darkBlue );
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. virtual double SpectrogramData::value( double x, double y ) const
    2. {
    3. if ( x > -1 && x < -0.6 && y > -1 && y < -0.6 )
    4. return qQNaN();
    5.  
    6. ....
    7. }
    To copy to clipboard, switch view to plain text mode 
    With Qwt from SVN trunk you also need to remove the line:
    Qt Code:
    1. setAttribute( QwtRasterData::WithoutGaps, true );
    To copy to clipboard, switch view to plain text mode 
    The result is a blue gap in the specified area.

    Uwe

    spectrogram.png

Similar Threads

  1. Replies: 14
    Last Post: 16th May 2017, 04:51
  2. Replies: 1
    Last Post: 20th November 2015, 11:02
  3. Replies: 3
    Last Post: 16th March 2015, 08:31
  4. Filtering Events on "black-box" objects
    By sebastian.f in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2009, 09:35
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05

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.