Results 1 to 3 of 3

Thread: How to adddata for qwtspectrogram

  1. #1
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to adddata for qwtspectrogram

    Hi,
    I'm centroid and I'm newbie in qwt. I have to create a plot similar to the qwt example spectrogram, in that example , it defines a class SpectrogramData (codes followed in ps),and it use the data like this,d_spectrogram->setData(SpectrogramData());
    but I want to use the data from files or matrix,how can I do this with Qwt?
    Thank you in advance.

    regards,
    centroid

    ps.
    class SpectrogramData: public QwtRasterData
    {
    public:
    SpectrogramData():
    QwtRasterData(QwtDoubleRect(0.0, 0.0, 3.0, 3.0))
    {
    }

    virtual QwtRasterData *copy() const
    {
    return new SpectrogramData();
    }

    virtual QwtDoubleInterval range() const
    {
    return QwtDoubleInterval(0.0, 10.0);
    }

    virtual double value(double x, double y) const
    {
    const double c = 0.842;

    const double v1 = x * x + (y-c) * (y+c);
    const double v2 = x * (y+c) + x * (y+c);

    return 1.0 / (v1 * v1 + v2 * v2);

    }
    };
    it uses the data like this
    Plot::Plot(QWidget *parent):
    QwtPlot(parent)
    {
    d_spectrogram = new QwtPlotSpectrogram();
    ...
    d_spectrogram->setData(SpectrogramData());
    d_spectrogram->attach(this);
    ...
    }
    Reading the Qwt User's Guide 5.2.1,I find this in QwtRasterData Class Reference:
    void QwtRasterData::initRaster(const QwtDoubleRect & ,const QSize & raster) [virtual]

    Initialize a raster.

    Before the composition of an image QwtPlotSpectrogram calls initRaster, announcing the area and its resolution that will be requested.

    The default implementation does nothing, but for data sets that are stored in files, it might be good idea to reimplement initRaster, where the data is resampled and loaded into memory.

    Parameters:
    rect Area of the raster
    raster Number of horizontal and vertical pixels
    See also:
    initRaster(), value()

    maybe it is useful,but how can I reimplement initRaster?
    Hope for your help.Thank you!

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

    Default Re: How to adddata for qwtspectrogram

    I have explained these questions several times in this forum. Please spend some time with readingfirst and come back with the questions, that are left.

    Uwe

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

    centroid (2nd August 2010)

  4. #3
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to adddata for qwtspectrogram

    Thank you all the same,I will read it first,but I have a question about this ,this maybe a common problem we are confronted,so why Qwt could not offer a better API for data input,like the QwtPlot3D?Maybe Qwt could do it better in this aspect.
    Thank again.

Similar Threads

  1. Replies: 1
    Last Post: 4th March 2010, 18:57
  2. QwtSpectrogram example program
    By cgifford in forum Qwt
    Replies: 3
    Last Post: 2nd July 2008, 07:46

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.