{
tab_x[0] = 0; tab_x[1] = 200; tab_x[2] = 400; tab_x[3] = 600; tab_x[4] = 1600; tab_x[5] = 2000;
tab_x[6] = 2400; tab_x[7] = 2800; tab_x[8] = 3200; tab_x[9] = 3600; tab_x[10] =
tab_y[0] = mygamma(tab_x[0],4096,1023,0.5);
tab_y[1] = mygamma(tab_x[1],4096,1023,0.5);
tab_y[2] = mygamma(tab_x[2],4096,1023,0.5);
tab_y[3] = mygamma(tab_x[3],4096,1023,0.5);
tab_y[4] = mygamma(tab_x[4],4096,1023,0.5);
tab_y[5] = mygamma(tab_x[5],4096,1023,0.
tab_y[6] = mygamma(tab_x[6],4096,1023,0.5);
tab_y[7] = mygamma(tab_x[7],4096,1023,0.5);
tab_y[8] = mygamma(tab_x[8],4096,1023,0.5);
tab_y[9] = mygamma(tab_x[9],4096,1023,0.5);
tab_y[10] = mygamma(tab_x[10],4096,1023,0.5);
int nb_points = sizeof(tab_x) / sizeof(tab_x[0]);
for ( int i = 0; i < nb_points ; i++ )
{
points
+= QPointF(tab_x
[i
], tab_y
[i
]);
}
m_Curve
->setCurveAttribute
(QwtPlotCurve::Fitted,
true);
// Otherwise I have got Lines and not smooth curve the fitted curve is better for me
m_CurveFitter->setFitMode(m_CurveFitter->ParametricSpline);
m_CurveFitter->setSplineSize(4096); // from my orignal 10 points I want 4096 points
m_Curve->setCurveFitter(m_CurveFitter);
m_Curve->setData(tab_x, tab_y, sizeof(tab_x) / sizeof(tab_x[0]));
m_Curve->attach(this);
}
{
m_Curve;
m_CurveFitter
for ( int i = 0; i < m_Curve->dataSize(); i++ )
{
points
+= QPointF(m_Curve
->x
(i
), m_Curve
->y
(i
));
}
InterpolatedPoints = curveFitter->fitCurve(points);
return InterpolatedPoints;
}
double mygamma(double in,int nbpoints_in,int nbpoints_out,double gma)
{
double x = in / nbpoints_in;
return (pow(x,gma) * nbpoints_out );
}
Plot::Plot(QWidget *parent):
QwtPlot(parent)
{
tab_x[0] = 0; tab_x[1] = 200; tab_x[2] = 400; tab_x[3] = 600; tab_x[4] = 1600; tab_x[5] = 2000;
tab_x[6] = 2400; tab_x[7] = 2800; tab_x[8] = 3200; tab_x[9] = 3600; tab_x[10] =
tab_y[0] = mygamma(tab_x[0],4096,1023,0.5);
tab_y[1] = mygamma(tab_x[1],4096,1023,0.5);
tab_y[2] = mygamma(tab_x[2],4096,1023,0.5);
tab_y[3] = mygamma(tab_x[3],4096,1023,0.5);
tab_y[4] = mygamma(tab_x[4],4096,1023,0.5);
tab_y[5] = mygamma(tab_x[5],4096,1023,0.
tab_y[6] = mygamma(tab_x[6],4096,1023,0.5);
tab_y[7] = mygamma(tab_x[7],4096,1023,0.5);
tab_y[8] = mygamma(tab_x[8],4096,1023,0.5);
tab_y[9] = mygamma(tab_x[9],4096,1023,0.5);
tab_y[10] = mygamma(tab_x[10],4096,1023,0.5);
int nb_points = sizeof(tab_x) / sizeof(tab_x[0]);
QPolygonF points,points2;
for ( int i = 0; i < nb_points ; i++ )
{
points += QPointF(tab_x[i], tab_y[i]);
}
m_Curve = new QwtPlotCurve();
m_CurveFitter = new QwtSplineCurveFitter();
m_Curve->setCurveAttribute(QwtPlotCurve::Fitted, true); // Otherwise I have got Lines and not smooth curve the fitted curve is better for me
m_Curve->setStyle(QwtPlotCurve::Lines);
m_CurveFitter->setFitMode(m_CurveFitter->ParametricSpline);
m_CurveFitter->setSplineSize(4096); // from my orignal 10 points I want 4096 points
m_Curve->setCurveFitter(m_CurveFitter);
m_Curve->setData(tab_x, tab_y, sizeof(tab_x) / sizeof(tab_x[0]));
m_Curve->attach(this);
}
QPolygonF Plot::getPoints(int nCurve)
{
QPolygonF points,InterpolatedPoints;
m_Curve;
m_CurveFitter
for ( int i = 0; i < m_Curve->dataSize(); i++ )
{
points += QPointF(m_Curve->x(i), m_Curve->y(i));
}
InterpolatedPoints = curveFitter->fitCurve(points);
return InterpolatedPoints;
}
double mygamma(double in,int nbpoints_in,int nbpoints_out,double gma)
{
double x = in / nbpoints_in;
return (pow(x,gma) * nbpoints_out );
}
To copy to clipboard, switch view to plain text mode
Bookmarks