{
Q_OBJECT
public:
QwtTest
(QWidget *parent
= 0, Qt
::WFlags flags
= 0);
~QwtTest();
protected:
private:
Ui::QwtTestClass ui;
double * xData_;
double * yData_;
int dataSize_;
int currXPos_;
int sinPos_;
int scaleFac;
static const double pi;
};
const double QwtTest::pi = 3.14159265358979323846264338327950;
QwtTest
::QwtTest(QWidget *parent, Qt
::WFlags flags
) currXPos_(0),
sinPos_(0),
scaleFac(1)
{
ui.setupUi(this);
ui.
qwtPlot->setAxisAutoScale
(QwtPlot::yLeft);
dataSize_ = 200;
xData_ = new double[dataSize_];
yData_ = new double[dataSize_];
for(int i = 0; i < dataSize_; ++i)
{
xData_[i] = double(i);
yData_[i] = sin(2*pi*i/dataSize_);
}
curve_.setRawSamples(xData_, yData_, dataSize_);
ui.qwtPlot->replot();
}
QwtTest::~QwtTest()
{
delete[] xData_;
delete[] yData_;
}
{
for(int i = 0; i < 5; ++i)
{
yData_[currXPos_] = scaleFac*sin(2*pi*sinPos_/(0.169*dataSize_));
++sinPos_;
currXPos_ = (currXPos_ + 1) % dataSize_;
}
++scaleFac;
//ui.qwtPlot->setAxisScale(QwtPlot::yLeft, -1000, 1000);
ui.qwtPlot->replot();
}
class QwtTest : public QMainWindow
{
Q_OBJECT
public:
QwtTest(QWidget *parent = 0, Qt::WFlags flags = 0);
~QwtTest();
protected:
void timerEvent(QTimerEvent * event);
private:
Ui::QwtTestClass ui;
double * xData_;
double * yData_;
int dataSize_;
int currXPos_;
int sinPos_;
int scaleFac;
QwtPlotCurve curve_;
static const double pi;
};
const double QwtTest::pi = 3.14159265358979323846264338327950;
QwtTest::QwtTest(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags),
currXPos_(0),
sinPos_(0),
scaleFac(1)
{
ui.setupUi(this);
ui.qwtPlot->setAxisAutoScale(QwtPlot::yLeft);
dataSize_ = 200;
xData_ = new double[dataSize_];
yData_ = new double[dataSize_];
for(int i = 0; i < dataSize_; ++i)
{
xData_[i] = double(i);
yData_[i] = sin(2*pi*i/dataSize_);
}
curve_.setRawSamples(xData_, yData_, dataSize_);
curve_.attach(ui.qwtPlot);
ui.qwtPlot->replot();
QObject::startTimer(1000/60);
}
QwtTest::~QwtTest()
{
delete[] xData_;
delete[] yData_;
}
void QwtTest::timerEvent(QTimerEvent * event)
{
for(int i = 0; i < 5; ++i)
{
yData_[currXPos_] = scaleFac*sin(2*pi*sinPos_/(0.169*dataSize_));
++sinPos_;
currXPos_ = (currXPos_ + 1) % dataSize_;
}
++scaleFac;
//ui.qwtPlot->setAxisScale(QwtPlot::yLeft, -1000, 1000);
ui.qwtPlot->replot();
}
To copy to clipboard, switch view to plain text mode
Bookmarks