#include <QtGui>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_curve.h>
#include <qwt_legend.h>
#include <qwt_series_data.h>
#include <qwt_text.h>
#include <math.h>
{
public:
Plot();
};
Plot::Plot()
{
double x[100];
double y1[100];
double y2[100];
for(int i=0;i<100;i++){
x[i]=i;
y1[i]=i*i;
y2[i]=i;
}
setTitle("Vitesse et angle de braquage en fonction du temps");
// Set axes
setAxisTitle(xBottom, "Temps");
setAxisScale(xBottom, 0.0, 100);
setAxisTitle(yLeft, "");
setAxisScale(yLeft, 0.0, 100);
// add curves
curve1
->setPen
(QPen(Qt
::green));
curve1->attach(this);
curve1->setData(x, y1, 100);
curve2
->setPen
(QPen(Qt
::red));
curve2->attach(this);
curve2->setData(x, y2, 100);
// ...a horizontal line ...
mY
->setLabel
(QString::fromLatin1("t ( ms )"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->attach(this);
// ...a vertical line ...
mX
->setLabel
(QString::fromLatin1("V ( m/s ) ,Ang ( rad/s )"));
mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mX->attach(this);
}
int main(int argc, char **argv)
{
Plot *myPlot = new Plot();
myPlot->autoRefresh();
myPlot->resize(600,400);
myPlot->show();
return a.exec();
}
#include <QtGui>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_curve.h>
#include <qwt_legend.h>
#include <qwt_series_data.h>
#include <qwt_text.h>
#include <math.h>
class Plot : public QwtPlot
{
public:
Plot();
};
Plot::Plot()
{
double x[100];
double y1[100];
double y2[100];
for(int i=0;i<100;i++){
x[i]=i;
y1[i]=i*i;
y2[i]=i;
}
setTitle("Vitesse et angle de braquage en fonction du temps");
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
// Set axes
setAxisTitle(xBottom, "Temps");
setAxisScale(xBottom, 0.0, 100);
setAxisTitle(yLeft, "");
setAxisScale(yLeft, 0.0, 100);
// add curves
QwtPlotCurve *curve1 = new QwtPlotCurve("Vitesse");
curve1->setPen(QPen(Qt::green));
curve1->attach(this);
curve1->setData(x, y1, 100);
QwtPlotCurve *curve2 = new QwtPlotCurve("Angle de Braquage");
curve2->setPen(QPen(Qt::red));
curve2->attach(this);
curve2->setData(x, y2, 100);
// ...a horizontal line ...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel(QString::fromLatin1("t ( ms )"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->attach(this);
// ...a vertical line ...
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel(QString::fromLatin1("V ( m/s ) ,Ang ( rad/s )"));
mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->attach(this);
}
int main(int argc, char **argv)
{
QApplication a(argc, argv);
Plot *myPlot = new Plot();
myPlot->autoRefresh();
myPlot->resize(600,400);
myPlot->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks