PDA

View Full Version : QwtPolarSpectrogram: Plotting just the upper half circle



QTim
22nd April 2015, 13:20
Hi Uwe, and everybody,

I'm using a QwtPolarSpectrogram as a RADAR or SONAR PPI,it works faily well and is a great tool, thanks for this, btw.!! :)

The thing is: I only need the "upper half" of the widged (0-180° of the polar circle). Is i t possiblie to only show the upper half? Any Ideas about this?


Thank you!

QTim

Uwe
23rd April 2015, 07:21
class YourData: public QwtRasterData
{
public:
virtual double value( double azimuth, double radius ) const
{
if ( azimuth > M_PI )
return 0.0; // some value indicating invalid

....
}
};
Then the rest is to use a color map where 0.0 is mapped to 0 ( = an rgb with an alpha of 0 )

Uwe

QTim
23rd April 2015, 11:25
Thanks for your answer, Uwe, and sorry for bothering you again, but i really tried setting the value 0 to a certain color, but it didn't wok at all!
(see one try below)

Can you help me a little further?




PlotPolarSpectrogramColorMap::PlotPolarSpectrogram ColorMap():
QwtLinearColorMap( Qt::darkBlue, Qt::darkRed )
{
addColorStop( 0.2, Qt::blue );
addColorStop( 0.4, Qt::cyan );
addColorStop( 0.6, Qt::yellow );
addColorStop( 0.8, Qt::red );

rgb(QwtInterval(-0.01, 0.01), 200); // Just to try!

}



Thanks
QTim

Uwe
24th April 2015, 07:42
An even easier solution would be to return Q_SNAN as NaN values are mapped to an RGB value of 0u. Then you don't need to change your color map.

Uwe

QTim
24th April 2015, 11:22
NaN values are mapped to an RGB value of 0u. Then you don't need to change your color map.



But how do I map the NaN values? It doesn't seem to work. :/

Thanks
QTim

Uwe
24th April 2015, 11:29
But how do I map the NaN values?
You don't - it is implemented in QwtLinearColorMap ( when using Qwt 6.1 ).

Uwe

QTim
24th April 2015, 14:15
Hi Uwe,

okay, the only thing I changed now is the value function:

class YourData: public QwtRasterData
{
public:
virtual double value( double azimuth, double radius ) const
{
if ( azimuth > M_PI )
return Q_SNAN;

....
}
};

but there is no transparency at all. It still looks like a standard polar spectrogram. :confused:
I am on QWT 6.1.

Thank you!!

QTim

Uwe
24th April 2015, 14:23
Add the same to the spectrogram example. If it works there compare what is different to your application.

Uwe

QTim
24th April 2015, 14:53
Add the same to the spectrogram example. If it works there compare what is different to your application.

Uwe

Uwe, please have a look at the picture. As you can se, I use the plain spectrogram example, exept the
if ( azimuth > M_PI )
return Q_SNAN;
in the value function.
http://www.bilder-upload.eu/thumb/f20105-1429883889.png (http://www.bilder-upload.eu/show.php?file=f20105-1429883889.png)

It doesn't work. :(

Uwe
24th April 2015, 15:39
I can see a picture, where the spectrogram covers the upper half - the lower half is empty ( the background of the canvas ).
So maybe I misunderstood your question - you want to hide the lower half of the complete plot - not the spectrogram inside the plot ?

This is not supported by QwtPolarPlot and you would have to solve it by giving the plot a geometry, where the lower half is below the bottom of its parent widget.

Uwe