QwtPlotSpectrogram rows and columns problem
Hi, I'm using QwtPlotSpectrogram along with QwtMatrixRasterData in order to plot a set of captured data from an oscilloscope. As far as I understand, I have to use a QVector to store the data, and then use setValueMatrix in order to send the data to the Spectrogram (specifying the vector and the number of columns). I want to send column by column (each column contains 1k points or rows), so the Spectrogram updates towards the right of the plot (plotting first a column of 1k points, then the next column of another 1k points and so on); however, instead of updating towards the right, it updates towards the top: it plots first a column of 1k points, then a column of 2k points (or rows), and so on...
Here's the piece of my code that deals with the Spectrogram:
QwtPlotSpectrogram *Spectrogram1 = new QwtPlotSpectrogram;
QwtMatrixRasterData *OSCRasterData = new QwtMatrixRasterData;
QVector<double> OSCvector;
Tektronix3052B *OSC;
double OSCvalue;
...
Spectrogram1->attach(this->ui->graph);
Spectrogram1->setColorMap(colorMap);
OSCvector.clear();
...
NumberOfPointsFrequency = 0;
for (numFreq = InitialFrequency;numFreq<FinalFrequency;numFreq+=S tepFrequency) {
// captures data from Oscilloscope, 1k points separated by commas
OSC->ReadData(DataFromOscilloscope);
StringOfData = strtok (DataFromOscilloscope,"\n");
OSCDataToParseString.sprintf("%s",StringOfData);
OSCDataToParseList = OSCDataToParseString.split(",");
for (varOSC=0;varOSC<OSCDataToParseList.length();varOS C++) {
OSCvalue = OSCDataToParseList.at(varOSC).toFloat();
OSCvector.append(OSCvalue);
}
// this variable keeps the number of oscilloscope's sweeps done so far, equal to the number of columns
NumberOfPointsFrequency++;
OSCRasterData->setInterval(Qt::XAxis,QwtInterval::QwtInterval(mi nX,maxX,QwtInterval::IncludeBorders));
OSCRasterData->setInterval(Qt::YAxis,QwtInterval::QwtInterval(mi nY,maxY,QwtInterval::IncludeBorders));
OSCRasterData->setInterval(Qt::ZAxis,QwtInterval::QwtInterval(mi nV,maxV,QwtInterval::IncludeBorders));
OSCRasterData->setValueMatrix(OSCvector,NumberOfPointsFrequency) ;
Spectrogram1->setData(OSCRasterData);
this->ui->graph->replot();
}
Thanks a lot!
Re: QwtPlotSpectrogram rows and columns problem
Qimage is organized in rows not in columns and out of performance considerations it doesn't make sense to do something different for QwtPlotMatrixData.
Better load your samples to your own type of data structure and derive a class from QwtRasterData returning values from there.
Uwe
Re: QwtPlotSpectrogram rows and columns problem
Thanks for your reply Uwe.. I ended up solving the problem transposing the matrix using another vector, it might not be the best solution or the most optimum, but it did the job!