Matthias Pospiech | 16 Apr 18:09

Re: Help with understanding QwtRasterData needed

I now created my own SpectrogramData version. But in the end I found out 
that SpectrogramData fails to use my own values in the value function.
m_RangeX.min, m_RangeY.min are all unkown within
    virtual double value(double x, double y) const
(see definition below)

This problem is out of the scope of my c++ knowledge...

Matthias

--------------
class SpectrogramData: public QwtRasterData
{
private:
    double * m_Array;
    double m_minValue;
    double m_maxValue;
    struct structMinMax{
        double min;
        double max;
    };
    structMinMax m_RangeX;
    structMinMax m_RangeY;
    struct structXY{
        double x;
        double y;
    };
    structXY m_DataSize;
    structXY m_RealToArray;

public:
    // Constructor giving back the QwtRasterData Constructor
    SpectrogramData(): QwtRasterData()
    {
        m_Array = NULL;
    }

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

    virtual QwtDoubleInterval range() const
    {
        return QwtDoubleInterval(m_minValue, m_maxValue);
    }

    virtual double value(double x, double y) const
    {
        double value = m_Array[ArrPos(
            (int)((x - m_RangeX.min) * m_RealToArray.x),
            (int)((y - m_RangeY.min) * m_RealToArray.y)
            )];
        return value;
    }

    void setData(double * Array, int sizex, int sizey)
    {
        m_DataSize.x = sizex;
        m_DataSize.y = sizey;
        int size = sizex * sizey;
        MinMaxArrayValue(Array, size, &m_minValue, &m_maxValue);
        if (m_Array != NULL)
            delete [] m_Array;
        m_Array = new double [size];
        memcpy(m_Array, Array, size * sizeof(double));
    }

    void setRangeX(const double min, const double max)
    {
        m_RangeX.min = min;
        m_RangeX.max = max;
        m_RealToArray.x = (m_RangeX.max - m_RangeX.min) / m_DataSize.x;
    }

    void setRangeY(const double min, const double max)
    {
        m_RangeY.min = min;
        m_RangeY.max = max;
        m_RealToArray.y = (m_RangeY.max - m_RangeY.min) / m_DataSize.y;
    }

    int ArrPos(const int x, const int y) const
    {
        return y + m_DataSize.y * x;
    }

};

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Gmane