PDA

View Full Version : qwt_data.h and qwt_data.cpp



kja
25th October 2010, 02:33
Hi,

I installed qwt-6.0.0-rc2.zip and have all the examples working with Visual Studio 2008, but I don't have qwt_data.h or qwt_data.cpp in my source files. does anyone know where I can get these files?
Thanks

Added after 17 minutes:

What I am trying to do is load some double time and double price data into a 2d graph. I want to use setRawData but I don't have the qwt_data files.
Is there another way to do this?

here is some of my code:


class newPlot : public QwtPlot{
public:
newPlot();
~newPlot(){}
};
newPlot::newPlot()
{
setTitle("Sunday Plot");
insertLegend(new QwtLegend(), QwtPlot::RightLegend);

setAxisTitle(xBottom, "Time");
setAxisScale(xBottom, 0.0, 100000.0);

setAxisTitle(yLeft, "Price");
setAxisScale(yLeft, 0.0, 1.0);

QwtPlotCurve *myCurve = new QwtPlotCurve("price over time");
myCurve->setPen(QPen(Qt::red));
myCurve->attach(this);

////some example data
double *tm= new double [1000];
double *pr= new double [1000];
for (int i=0; i<1000; i++){
tm[i] = i;
vvvll[i] = i+1;
}

myCurve->setRawData();

}

int main(int argc, char **argv)
{
QApplication a(argc, argv);

newPlot plot;
plot.resize(1000,400);
plot.show();

return a.exec();
}



I don't know what to do to get some data into myCurve

thanks.

franco.amato
25th October 2010, 17:58
Hi,
please give a look at this routine setCurveData(..)
You can follow this simple tutorial http://www.digitalfanatics.org/projects/qt_tutorial/chapter11.html

Regards

kja
25th October 2010, 19:52
Hi, thanks for your help.

I tried to run that example but I get a bunch of errors, am I forgetting to include something?



#include <qapplication.h>
#include <qwt_plot.h>

class MyPlot : public QwtPlot
{
public:
MyPlot( QWidget *parent=0, char *name=0 ) : QwtPlot( parent, name )
{
setTitle( "This is an Example" );

setAutoLegend( true );
setLegendPos( Qwt::Bottom );

setAxisTitle( xBottom, "x" );
setAxisTitle( yLeft, "y" );

long cSin = insertCurve( "y = sin(x)" );
long cSign = insertCurve( "y = sign(sin(x))" );

const int points = 500;
double x[ points ];
double sn[ points ];
double sg[ points ];

for( int i=0; i<points; i++ )
{
x[i] = (3.0*3.14/double(points))*double(i);

sn[i] = 2.0*sin( x[i] );
sg[i] = (sn[i]>0)?1:((sn[i]<0)?-1:0);
}

setCurveData( cSin, x, sn, points );
setCurveData( cSign, x, sg, points );

setCurvePen( cSin, QPen( blue ) );
setCurvePen( cSign, QPen( green, 3 ) );

replot();
}
};

int main( int argc, char **argv )
{
QApplication a( argc, argv );

MyPlot p;
a.setMainWidget( &p );
p.show();

return a.exec();
}


these are the errors I get:


1>(16) : error C2664: 'QwtPlot::QwtPlot(const QwtText &,QWidget *)' : cannot convert parameter 1 from 'QWidget *' to 'const QwtText &'
1> Reason: cannot convert from 'QWidget *' to 'const QwtText'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>(21) : error C3861: 'setAutoLegend': identifier not found
1>(22) : error C2653: 'Qwt' : is not a class or namespace name
1>(22) : error C2065: 'Bottom' : undeclared identifier
1>(22) : error C3861: 'setLegendPos': identifier not found
1>(29) : error C3861: 'insertCurve': identifier not found
1>(30) : error C3861: 'insertCurve': identifier not found
1>(47) : error C3861: 'setCurveData': identifier not found
1>(48) : error C3861: 'setCurveData': identifier not found
1>(51) : error C2065: 'blue' : undeclared identifier
1>(51) : error C3861: 'setCurvePen': identifier not found
1>(52) : error C2065: 'green' : undeclared identifier
1>(52) : error C3861: 'setCurvePen': identifier not found
1>(64) : error C2039: 'setMainWidget' : is not a member of 'QApplication'
1> (95) : see declaration of 'QApplication'




That setCurveData seems like just what I need..... hmmmmm

franco.amato
25th October 2010, 21:37
Which version are you using? I think that example is refered to an older version. In the past I did something very basic with the version 5*.
Meanwhile I just downloaded the last version ( 6 ) and there is a 'example' folder with lots of examples.
Giving a look at curvdemo1 you can see the call to the setRawSamples method that take the x vector, the y vector and the array size.
To call setRawSamples you have to create a 'QwtPlotCurve' object.

Regards

kja
26th October 2010, 18:55
Thanks a lot! that setRawSamples worked great for me!

Thanks for the help

trygub
30th November 2010, 11:36
I don't have qwt_data.h or qwt_data.cpp in my source files. does anyone know where I can get these files?


These files were deleted in https://qwt.svn.sourceforge.net/svnroot/qwt/trunk/qwt, revision 56 ...
QwtSeriesData<T> is the successor of QwtData.

HTH

--

Semen A. Trygubenko | http://trygub.com