PDA

View Full Version : QwtPlotSpectrogram and contour lines



toffkriss
7th March 2010, 13:03
Hi,

I am plotting some values with a QwtPlotSpectrogram:


QPixmap plotImage = QPixmap(plotSize);
plotImage.fill(QColor(Qt::white));
QPainter painter(&plotImage);
QwtScaleMap map;
map.setPaintInterval(0, 1);
map.setScaleInterval(0, 1);
plotSpectogram.draw(&painter, map, map, QRect(QPoint(0, 0), plotSize));

That works fine. But if if switch the ContourMode on, somehow the contour lines are mirrored vertically (see attached image). 4373
I derive QwtRasterData and implemented all the necessary functions.
This looks like the typical coordinate system problem, at which the origin of the spectrum is bottom left, but the origin of the image is top left. Since I guess, the QwtRasterData::value() method is used for both the image and the contour lines, I dont see, what I did wrong. Do I have to modify the QwtScaleMaps somehow? Or is this origin thing only considered inside QwtPlotSpectrogam while plotting the spectrogram, but not while plotting the contour lines?
I am using Qt 4.6 and Qwt 5.2.

Thanks,
Christoph

toffkriss
8th March 2010, 06:35
I did some further research. If I attach the QwtPlotSpectrogram I use to create the image to a regular QwtPlot, it turns out fine (see attached Image).
4384
Seems to me, that the different origins of a QwtPlot and a QPixmap (or image in general) are not taken into consideration in the method QwtPlotSpectrogram::draw().

Uwe
8th March 2010, 07:23
Better try to understand, what the maps are about !


QPixmap plotImage = QPixmap(plotSize);
plotImage.fill(QColor(Qt::white));
QPainter painter(&plotImage);

QwtScaleMap xMap;
xMap.setPaintInterval(0, plotSize.width());
xMap.setScaleInterval(...);

QwtScaleMap yMap;
yMap.setPaintInterval(plotSize.height(), 0); // inverted !!!
yMap.setScaleInterval(...);

plotSpectogram.draw(&painter, xMap, yMap, QRect(QPoint(0, 0), plotSize));

Uwe

toffkriss
8th March 2010, 10:49
Thanks, that solved the problem.