Results 1 to 3 of 3

Thread: QwtPlotSpectrogram rows and columns problem

  1. #1
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  3. The following user says thank you to Uwe for this useful post:

    raulchernobyl (23rd November 2012)

  4. #3
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!

Similar Threads

  1. table view (how to insert rows and columns)
    By narlapavan in forum Qt Programming
    Replies: 1
    Last Post: 14th February 2012, 10:50
  2. Replies: 1
    Last Post: 28th August 2011, 06:36
  3. Static/Fixed rows and columns in a QTreeView
    By code_talker in forum Qt Programming
    Replies: 0
    Last Post: 27th April 2011, 13:00
  4. Weird problem resizing rows and columns in qtableview
    By Tiansen in forum Qt Programming
    Replies: 1
    Last Post: 27th December 2010, 14:26
  5. QTableWidget: Disable 'snapping' to rows and columns?
    By PolyVox in forum Qt Programming
    Replies: 2
    Last Post: 8th October 2008, 20:04

Tags for this Thread

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.