Public Member Functions

PlotDataModel Class Reference

A model which operates on top of BaseQueryModel and is used by a plot a source of data points. More...

#include <grapher.h>

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

List of all members.

Public Member Functions

 PlotDataModel (QAbstractItemModel *model, int xColumn, int yColumn)
void initialize ()
size_t size () const
double x (size_t i) const
double y (size_t i) const
QwtDatacopy () const

Detailed Description

A model which operates on top of BaseQueryModel and is used by a plot a source of data points.


Constructor & Destructor Documentation

PlotDataModel::PlotDataModel ( QAbstractItemModel model,
int  xColumn,
int  yColumn 
)

Referenced by copy().

{
    setModel(model, xColumn, yColumn);
}


Member Function Documentation

QwtData * PlotDataModel::copy (  )  const

Reimplemented from QwtData.

{
    qDebug() << "Copy of PlotDataModel requested: why?????";
    return new PlotDataModel(model(), xColumn, yColumn);
}

void PlotDataModel::initialize (  ) 

{
    xColumn = 0;
    yColumn = 0;
}

size_t PlotDataModel::size (  )  const

Reimplemented from QwtData.

{
    return model()->rowCount();
}

double PlotDataModel::x ( size_t  i  )  const

Reimplemented from QwtData.

{ //600ms voor 50k
    QVariant data =  model()->index(i, xColumn).data(Qt::DisplayRole);
    Q_ASSERT(!data.isNull());
#ifdef DEBUG_WITHOUTDB
    bool ok;
    double x = data.toDouble(&ok);
    Q_ASSERT(ok);
#endif //DEBUG_WITHOUTDB
#ifndef DEBUG_WITHOUTDB
    double x = data.toDateTime().toTime_t();
    //qDebug() << x << data;
#endif //DEBUG_WITHOUTDB
    //qDebug() << "asking for x = " << QString::number(x, 'f', 15) << data.toDateTime().toTime_t() << data << " on position " << i;
    return x;
}

double PlotDataModel::y ( size_t  i  )  const

Reimplemented from QwtData.

{ //100ms voor 50k
    QVariant data = model()->index(i, yColumn).data(Qt::DisplayRole);
    if (data.isNull()) return std::numeric_limits<double>::quiet_NaN();
    else {
        bool ok;
        double y = data.toDouble(&ok);
        Q_ASSERT(ok);
        //qDebug() << "asking for y = " << y << " on position " << i;
        return y;
    }
}


The documentation for this class was generated from the following files: