emigrand
6th December 2011, 22:21
Hi,
first post, so please don't be too strict with me.
I'm biologist, not programmer, and it took me a while to get to this point. Now I'm stuck with a problem which I think is easy for a qwt-advanced. One of my final goals is to visualize data from an ad-converter with qwt. For getting accustomed with matters I tried to produce a simple plot with code I found somewhere (in a header?), but when I compile it, I find strange lines besides the curves I would expect:
class vtPlot : public QwtPlot
{
Q_OBJECT
static int const NPOINTS = 150;
double x[NPOINTS], ysin[NPOINTS], ycos[NPOINTS];
public:
explicit vtPlot(QObject *parent = 0);
void *myData();
QwtPointArrayData *myArray[2];
};
vtPlot::vtPlot(QObject *parent)
{
}
void *vtPlot::myData()
{
for(int i = 0; i < NPOINTS; i++)
{
x[i] = 0.1*i;
ysin[i] = sin(x[i]);
ycos[i] = cos(x[i]);
}
myArray[0] = new QwtPointArrayData(x,ysin,(sizeof(x)+sizeof(ysin))) ; // actually not sure if the third argument is correct
myArray[1] = new QwtPointArrayData(x,ycos,(sizeof(x)+sizeof(ycos))) ;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
vtPlot *myPlot = new vtPlot(&w);
QwtPlotCurve *curve1 = new QwtPlotCurve("sinus");
QwtPlotCurve *curve2 = new QwtPlotCurve("cosinus");
myPlot->myData();
curve1->setData(myPlot->myArray[0]);
curve1->attach(myPlot);
curve2->setData(myPlot->myArray[1]);
curve2->attach(myPlot);
myPlot->setTitle("Voltage [mV] - Time [s]");
myPlot->setAxisTitle(myPlot->yLeft,"Voltage [mV]");
myPlot->setAxisTitle(myPlot->xBottom,"Time [s]");
w.setCentralWidget(myPlot);
w.show();
return a.exec();
}
Gives me this:
7153
Of course I ensure having searched the forum and the www for help, but I wasn't successful.
Any hint would be appreciated.
Thanks a lot,
Emi
first post, so please don't be too strict with me.
I'm biologist, not programmer, and it took me a while to get to this point. Now I'm stuck with a problem which I think is easy for a qwt-advanced. One of my final goals is to visualize data from an ad-converter with qwt. For getting accustomed with matters I tried to produce a simple plot with code I found somewhere (in a header?), but when I compile it, I find strange lines besides the curves I would expect:
class vtPlot : public QwtPlot
{
Q_OBJECT
static int const NPOINTS = 150;
double x[NPOINTS], ysin[NPOINTS], ycos[NPOINTS];
public:
explicit vtPlot(QObject *parent = 0);
void *myData();
QwtPointArrayData *myArray[2];
};
vtPlot::vtPlot(QObject *parent)
{
}
void *vtPlot::myData()
{
for(int i = 0; i < NPOINTS; i++)
{
x[i] = 0.1*i;
ysin[i] = sin(x[i]);
ycos[i] = cos(x[i]);
}
myArray[0] = new QwtPointArrayData(x,ysin,(sizeof(x)+sizeof(ysin))) ; // actually not sure if the third argument is correct
myArray[1] = new QwtPointArrayData(x,ycos,(sizeof(x)+sizeof(ycos))) ;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
vtPlot *myPlot = new vtPlot(&w);
QwtPlotCurve *curve1 = new QwtPlotCurve("sinus");
QwtPlotCurve *curve2 = new QwtPlotCurve("cosinus");
myPlot->myData();
curve1->setData(myPlot->myArray[0]);
curve1->attach(myPlot);
curve2->setData(myPlot->myArray[1]);
curve2->attach(myPlot);
myPlot->setTitle("Voltage [mV] - Time [s]");
myPlot->setAxisTitle(myPlot->yLeft,"Voltage [mV]");
myPlot->setAxisTitle(myPlot->xBottom,"Time [s]");
w.setCentralWidget(myPlot);
w.show();
return a.exec();
}
Gives me this:
7153
Of course I ensure having searched the forum and the www for help, but I wasn't successful.
Any hint would be appreciated.
Thanks a lot,
Emi