Public Member Functions

QwtCPointerData Class Reference

Data class containing two pointers to memory blocks of doubles. More...

#include <qwt_data.h>

Inheritance diagram for QwtCPointerData:
Inheritance graph
[legend]
Collaboration diagram for QwtCPointerData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 QwtCPointerData (const double *x, const double *y, vcl_size_t size)
QwtCPointerDataoperator= (const QwtCPointerData &)
 Assignment.
virtual QwtDatacopy () const
virtual vcl_size_t size () const
virtual double x (vcl_size_t i) const
virtual double y (vcl_size_t i) const
const double * xData () const
const double * yData () const
virtual QwtDoubleRect boundingRect () const

Detailed Description

Data class containing two pointers to memory blocks of doubles.

Definition at line 144 of file qwt_data.h.


Constructor & Destructor Documentation

QwtCPointerData::QwtCPointerData ( const double *  x,
const double *  y,
vcl_size_t  size 
)

Constructor

Parameters:
xArray of x values
yArray of y values
sizeSize of the x and y arrays
Warning:
The programmer must assure that the memory blocks referenced by the pointers remain valid during the lifetime of the QwtPlotCPointer object.
See also:
QwtPlotCurve::setData(), QwtPlotCurve::setRawData()

Definition at line 282 of file qwt_data.cpp.

Referenced by copy().

                                                  :
    d_x(x), 
    d_y(y), 
    d_size(size)
{
}

Member Function Documentation

QwtDoubleRect QwtCPointerData::boundingRect (  ) const [virtual]

Returns the bounding rectangle of the data. If there is no bounding rect, like for empty data the rectangle is invalid: QwtDoubleRect::isValid() == false

Reimplemented from QwtData.

Definition at line 355 of file qwt_data.cpp.

References size().

{
    const size_t sz = size();

    if ( sz <= 0 )
        return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid

    double minX, maxX, minY, maxY;
    const double *xIt = d_x;
    const double *yIt = d_y;
    const double *end = d_x + sz;
    minX = maxX = *xIt++;
    minY = maxY = *yIt++;

    while ( xIt < end )
    {
        const double xv = *xIt++;
        if ( xv < minX )
            minX = xv;
        if ( xv > maxX )
            maxX = xv;

        const double yv = *yIt++;
        if ( yv < minY )
            minY = yv;
        if ( yv > maxY )
            maxY = yv;
    }
    return QwtDoubleRect(minX, minY, maxX - minX, maxY - minY);
}
QwtData * QwtCPointerData::copy (  ) const [virtual]
Returns:
Pointer to a copy (virtual copy constructor)

Implements QwtData.

Definition at line 345 of file qwt_data.cpp.

References QwtCPointerData().

{
    return new QwtCPointerData(d_x, d_y, d_size);
}
QwtCPointerData & QwtCPointerData::operator= ( const QwtCPointerData data )

Assignment.

Definition at line 291 of file qwt_data.cpp.

{
    if (this != &data)
    {
        d_x = data.d_x;
        d_y = data.d_y;
        d_size = data.d_size;
    }
    return *this;
}
vcl_size_t QwtCPointerData::size (  ) const [virtual]
Returns:
Size of the data set

Implements QwtData.

Definition at line 303 of file qwt_data.cpp.

Referenced by boundingRect().

{   
    return d_size; 
}
double QwtCPointerData::x ( vcl_size_t  i ) const [virtual]

Return the x value of data point i

Parameters:
iIndex
Returns:
x X value of data point i

Implements QwtData.

Definition at line 314 of file qwt_data.cpp.

References int().

{ 
    return d_x[int(i)]; 
}
const double * QwtCPointerData::xData (  ) const
Returns:
Array of the x-values

Definition at line 331 of file qwt_data.cpp.

{
    return d_x;
}
double QwtCPointerData::y ( vcl_size_t  i ) const [virtual]

Return the y value of data point i

Parameters:
iIndex
Returns:
y Y value of data point i

Implements QwtData.

Definition at line 325 of file qwt_data.cpp.

References int().

{ 
    return d_y[int(i)]; 
}
const double * QwtCPointerData::yData (  ) const
Returns:
Array of the y-values

Definition at line 337 of file qwt_data.cpp.

{
    return d_y;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines