Results 1 to 7 of 7

Thread: Spectogram related

  1. #1
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Spectogram related

    Hi everyone.

    I have plot with curves and Spectogram on it. Then I replot this plot (in order to apply changes in curves data) spectogram goes something like blank or it's rasterdata values are all equal to zero.

    I have found only one way - to setData to spectogram for every replot. Can I use more advance solution?

    VERY big thanks for your answers beforehand.

  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: Spectogram related

    Without showing more informations you can't expect any useful answer. At least you have to post the implementation of your raster data object.

    Uwe

  3. #3
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Spectogram related

    Impl:

    class SpectrogramData: public QwtRasterData
    {
    public:

    double min,max,width,height,pixWidth,pixHeight;
    ap::real_2d_array* grid;
    mPoints mainStringBeg;
    mPoints mainStringEnd;
    double xMast,yMast;
    double currX,x0,x1,y0,y1,x,y,tmpEn0,tmpEn1;

    SpectrogramData(double tmax, double tmin, double twidth, double theight,double tpixWidth, double tpixHeight, ap::real_2d_array* a)
    : QwtRasterData(QwtDoubleRect(0, 0,twidth,theight))
    {
    max=tmax;
    min=tmin;
    width=twidth;
    height=theight;
    //this->setBoundingRect(QwtDoubleRect(0,0,width,height) );
    grid=a;
    pixWidth=tpixWidth;
    pixHeight=tpixHeight;
    xMast=width/pixWidth;
    yMast=height/pixHeight;
    SETMAINSTRINGS(0);
    }

    void setParams(double tmin,double tmax,int twidth,int theight)
    {
    min=tmin; max=tmax;
    width=twidth; height=theight;
    this->setBoundingRect(QwtDoubleRect(0,0,width,height) );
    }
    void setGrid( ap::real_2d_array* a /*vector <tmpPoint> *a*/)
    {
    grid=a;
    }

    virtual QwtRasterData *copy() const
    {
    return new SpectrogramData(max,min,width,height,pixWidth,pixH eight,grid);
    }

    virtual QwtDoubleInterval range() const
    {
    if (min==-1 && max==-1)
    return QwtDoubleInterval(0.0, 10.0);

    return QwtDoubleInterval(0, max);

    }

    virtual double value(double tx, double ty) const
    {

    if (int(tx)<width && int(tx)>=0 && int(ty)<height-1 && int(ty)>=0)
    {
    if (min!=-1 || max!=-1)
    {
    if (ty<mainStringBeg.y)
    return 0;
    if ( ty>mainStringEnd.y)
    {
    if (int(mainStringEnd.y)+1<height)
    SETMAINSTRINGS( int(mainStringEnd.y) );
    else return 0;
    }
    if (ty==mainStringBeg.y)
    {
    SEARCHVALUEONLINE(mainStringBeg,tx)
    return y;
    }
    if(ty>mainStringBeg.y && ty<mainStringEnd.y)
    {
    SEARCHVALUE(tx,ty)
    return y;
    }
    if (ty==mainStringEnd.y)
    {
    SEARCHVALUEONLINE(mainStringEnd,tx)
    return y;
    }
    else
    return 0;
    }
    }
    return 0;

    }
    };


    macros like SEARCHVALUE are used to perform an interpolation.

  4. #4
    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: Spectogram related

    Your raster data object has a pointer to the values (grid) only. Did you check what's going on with this array later ?

    Uwe

  5. #5
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Spectogram related

    Well i performed such test: in place of setData() function I set cerr<< value of some random grid cells and they are correct, so my app don't clear grids before reploting. But if I cerr<< rasterData.value() on some random values they are all zero.

    I don't know internal work of rasterData class. Maybe I should observe Implementation of rasterData copy() function.

    Maybe in some situations it gets wrong parameters (width,hight,resolution) so value() function will return zero on every pixel (My value impl. return zero in case if value() can't calculate real value).

    Then I setData to spectogram I use temp. QwtRasterData like: d_spectogram->setData(SpectogramData(<data constructor>));

    Maybe I should create pointer to spectogramData, allocate memory and create new spectogramData and then set it to spectogram?

    As far as I discovered setData() function makes copy of rasterData as we give her as a parameter. So there is no point too put huge grids in rasterData, it is better to store pointers to this grid. But I stiil don't know why spectogram turns blank.

    I've tested another thing - if I use setData, then replot the spectrPlot ones it's drawing right picture. but if will replot twice spectroGram will turn blank =|
    Last edited by KosyakOFF; 29th April 2009 at 13:51.

  6. #6
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Spectogram related

    I think I've got it.

    Then Spectogram copies user defined spectogram data (child class of basic QwtRasterData) it convert this data to basic QwtRasterData with prededined value() method.

    This must be a problem. So maybe I should overload spectogram Private data?

  7. #7
    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: Spectogram related

    The spectrogram item clones your raster data object using your virtual copy method - the one you have posted looks o.k. to me.
    But note, that you might need to reassign your data object ( create a new clone ) whenever you change its attributes.

    F.e. calling setGrid for your object will have no effect until you reassign it.

    Uwe

Similar Threads

  1. Replies: 2
    Last Post: 12th December 2008, 15:38
  2. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  3. Related To QGraphicsItemGroup
    By ashishsaryar in forum Qt Programming
    Replies: 0
    Last Post: 29th April 2008, 14:55
  4. Question related to Q3DataTable
    By mitesh_modi in forum Qt Programming
    Replies: 0
    Last Post: 29th November 2006, 08:49
  5. Qt related questions and thoughts about getting job
    By AlexKiriukha in forum General Discussion
    Replies: 4
    Last Post: 26th January 2006, 12:25

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.