class CustomData
{
public:
CustomData();
void append(double *x, double *y, int count);
int count() const;
int size() const;
const double *x() const;
const double *y() const;
private:
int d_count;
QwtArray<double> d_x;
QwtArray<double> d_y;
};
//class CustomQwtPlot:public QwtPlot
void CustomQwtPlot
::appendDataShow(double *x,
double *y,
int size,
const QPen &curvePen
) {
......
if ( d_data == NULL )
d_data = new CustomData;
if(cur == NULL)
{
d_data->append(x, y, size);
cur->setRawData(d_data->x(), d_data->y(), d_data->count());
cur->setPen(curvePen);
cur->attach(this);
}
......
}
//CustomQwtPlot *energyplot;
void plot
::updateEnergyplot(QList<QStringList> data,
QStringList header
) {
......
if (energyplot == NULL)
{
......
energyplot = new CustomQwtPlot;
double *xData = new double[count];
double *yData = new double[count];
for (int i = 0; i < count; i++)
{
xData[i] = (double)i;
yData[i] = data.at(0).at(i).toDouble(&ok);
}
energyplot->appendDataShow(xData, yData, count, c);
......
delete []xData;
delete []yData;
......
}
}
class CustomData
{
public:
CustomData();
void append(double *x, double *y, int count);
int count() const;
int size() const;
const double *x() const;
const double *y() const;
private:
int d_count;
QwtArray<double> d_x;
QwtArray<double> d_y;
};
//class CustomQwtPlot:public QwtPlot
void CustomQwtPlot::appendDataShow(double *x, double *y, int size, const QPen &curvePen)
{
......
if ( d_data == NULL )
d_data = new CustomData;
if(cur == NULL)
{
cur = new QwtPlotCurve("curve");
cur->setPaintAttribute(QwtPlotCurve::PaintFiltered);
cur->setRenderHint(QwtPlotItem::RenderAntialiased);
d_data->append(x, y, size);
cur->setRawData(d_data->x(), d_data->y(), d_data->count());
cur->setPen(curvePen);
cur->attach(this);
}
......
}
//CustomQwtPlot *energyplot;
void plot::updateEnergyplot(QList<QStringList> data, QStringList header)
{
......
if (energyplot == NULL)
{
......
energyplot = new CustomQwtPlot;
double *xData = new double[count];
double *yData = new double[count];
for (int i = 0; i < count; i++)
{
xData[i] = (double)i;
yData[i] = data.at(0).at(i).toDouble(&ok);
}
energyplot->appendDataShow(xData, yData, count, c);
......
delete []xData;
delete []yData;
......
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks