1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
/****************************************************************************
clic droit project settings, onglet C++ dans le champ libs écrire : -lqwt et includepath : /usr/lib/qt3/include/qwt
*****************************************************************************/
#define MAX 360
#define pi 3.14159265
#include<qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_spline.h>
#include <qlayout.h>
#include <qmenubar.h>
#include <qtimer.h>
#include <qvector.h>
void Form1::init()
{
qwtPlot1->setTitle("Mon premier graph");
//qwtPlot1->setAxisMaxMinor(1,0);
//qwtPlot1->setAxisMaxMajor(1,50);
//curve1->setData(&x, &y1, 100);
// qwtPlot1->setCurveStyle(cRight, QwtCurve::Sticks);
// qwtPlot1->setCurvePen(cRight, QPen(Qt::red));
}
void Form1::destroy() {};
void Form1::TracerCourbe()
{
QwtPlot *qwtPlot1 = new QwtPlot;
QwtPlotCurve *curve1 = new QwtPlotCurve;
long a, b;
double x[MAX], y[MAX], t;
a=spinBox1->value();
b=spinBox2->value();
for( int i=0;i<MAX;i++)
{
t= i*pi/180;
x[i] = sin(t) *a;
y[i] = cos(t) *b;
curve1->setData(&x[i], &y[i], 100);
curve1->attach(qwtPlot1);
qwtPlot1->replot();
}
} |
Partager