qt_gotcha
26th January 2013, 12:36
Sorry, I have asked this before but still don't get it! :o
I have a two layer GIS type application, with a QwtPlot and 2 Spectrograms:
the bottom one is a grey scale shaded relief map, opaque, the top shows water flow. In the top spectrogram the value 0 needs to be transparent, anything > 0 needs to get a blue color. The color map is:
class colorMapWater: public QwtLinearColorMap
{
public:
colorMapWater():
QwtLinearColorMap( QColor(BGc), Qt::darkBlue )
{
addColorStop( 0.0, qRgba(0, 0, 0, 0));// or Qt::transparent);
addColorStop( 0.1, QColor("#FFFF55") );
addColorStop( 0.4, QColor("#8080FF") );
addColorStop( 0.9, Qt::blue );
}
};
the function to show the top (water) map is as follows.
// fill QwtMatrixRasterData RD with matrix data from Map and find the new max value
// also sets interval for x and y axis
double MaxV = fillDrawMapData(Map, RD);
// set the interval to the new max value
maxAxis2 = qMax(maxAxis2, MaxV);
RD->setInterval( Qt::ZAxis, QwtInterval( 0, maxAxis2));
//drawMap is a QwtPlotSpectrogram
drawMap->setData(RD);
drawMap->setColorMap(new colorMapWater());
// set the right axis legend to the new interval
rightAxis->setColorMap( drawMap->data()->interval( Qt::ZAxis ), new colorMapWater());
MPlot->setAxisScale( MPlot->yRight, 0, maxAxis2);
MPlot->setAxisScaleEngine( MPlot->yRight, new QwtLinearScaleEngine() );
MPlot->replot();
In my thinking this should produce a plot where all values in RD that are zero should be transparent. I can also setAlpha and that works, the bottom layers is visible. However this producs differences in hue of the water layer that are interpreted wrongly (e.g. darker blue can be a dark bottom layer or deeper water) which is not what I want.
Thanks!
I have a two layer GIS type application, with a QwtPlot and 2 Spectrograms:
the bottom one is a grey scale shaded relief map, opaque, the top shows water flow. In the top spectrogram the value 0 needs to be transparent, anything > 0 needs to get a blue color. The color map is:
class colorMapWater: public QwtLinearColorMap
{
public:
colorMapWater():
QwtLinearColorMap( QColor(BGc), Qt::darkBlue )
{
addColorStop( 0.0, qRgba(0, 0, 0, 0));// or Qt::transparent);
addColorStop( 0.1, QColor("#FFFF55") );
addColorStop( 0.4, QColor("#8080FF") );
addColorStop( 0.9, Qt::blue );
}
};
the function to show the top (water) map is as follows.
// fill QwtMatrixRasterData RD with matrix data from Map and find the new max value
// also sets interval for x and y axis
double MaxV = fillDrawMapData(Map, RD);
// set the interval to the new max value
maxAxis2 = qMax(maxAxis2, MaxV);
RD->setInterval( Qt::ZAxis, QwtInterval( 0, maxAxis2));
//drawMap is a QwtPlotSpectrogram
drawMap->setData(RD);
drawMap->setColorMap(new colorMapWater());
// set the right axis legend to the new interval
rightAxis->setColorMap( drawMap->data()->interval( Qt::ZAxis ), new colorMapWater());
MPlot->setAxisScale( MPlot->yRight, 0, maxAxis2);
MPlot->setAxisScaleEngine( MPlot->yRight, new QwtLinearScaleEngine() );
MPlot->replot();
In my thinking this should produce a plot where all values in RD that are zero should be transparent. I can also setAlpha and that works, the bottom layers is visible. However this producs differences in hue of the water layer that are interpreted wrongly (e.g. darker blue can be a dark bottom layer or deeper water) which is not what I want.
Thanks!