mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
This commit is based on https://github.com/GoldenCheetah/GoldenCheetah/pull/3956 with the following additions / changes: * Upgraded to the latest version of the multiaxes-branch, thus eliminating crashes of GoldenCheetah on startup * Disabled the emitting of Layout Requests on geometry changes of QwtScaleWidget - without this, CPU utilization was up to 100% on one core * Added the class SplineLookup, reusing small portions of code from Qwt 6.1 * Re-added the splines in WPrime and RideFile (resampling), using the new interface of QwtSpline * Appveyor: qwt in cache-section now depends on qwt/qwtconfig.prin.in for refresh on version change
102 lines
2.4 KiB
C++
102 lines
2.4 KiB
C++
/*****************************************************************************
|
|
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
|
* This file may be used under the terms of the 3-clause BSD License
|
|
*****************************************************************************/
|
|
|
|
#include <QwtSplinePleasing>
|
|
#include <QwtSplineLocal>
|
|
#include <QwtSplineCubic>
|
|
#include <QwtSplineParametrization>
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
#include <QPolygon>
|
|
#include <QLine>
|
|
#include <QDebug>
|
|
|
|
static void testSpline( const char* name, QwtSplineInterpolating* spline,
|
|
int type, const QPolygonF& points )
|
|
{
|
|
spline->setParametrization( type );
|
|
|
|
QElapsedTimer timer;
|
|
timer.start();
|
|
|
|
const QVector< QLineF > lines = spline->bezierControlLines( points );
|
|
|
|
qDebug() << name << ":" << timer.elapsed();
|
|
}
|
|
|
|
static void testSplines( int paramType, const QPolygonF& points )
|
|
{
|
|
#if 0
|
|
QwtSplinePleasing splinePleasing;
|
|
testSpline( "Pleasing", &splinePleasing, paramType, points );
|
|
#endif
|
|
|
|
#if 1
|
|
QwtSplineLocal splineCardinal( QwtSplineLocal::Cardinal );
|
|
testSpline( "Cardinal", &splineCardinal, paramType, points );
|
|
#endif
|
|
|
|
#if 1
|
|
QwtSplineLocal splinePC( QwtSplineLocal::PChip );
|
|
testSpline( "PChip", &splinePC, paramType, points );
|
|
#endif
|
|
|
|
#if 1
|
|
QwtSplineLocal splineAkima( QwtSplineLocal::Akima );
|
|
testSpline( "Akima", &splineAkima, paramType, points );
|
|
#endif
|
|
|
|
#if 1
|
|
QwtSplineLocal splinePB( QwtSplineLocal::ParabolicBlending );
|
|
testSpline( "Parabolic Blending", &splinePB, paramType, points );
|
|
#endif
|
|
|
|
#if 1
|
|
QwtSplineCubic splineC2;
|
|
testSpline( "Cubic", &splineC2, paramType, points );
|
|
#endif
|
|
}
|
|
|
|
int main()
|
|
{
|
|
QPolygonF points;
|
|
|
|
for ( int i = 0; i < 10e6; i++ )
|
|
points += QPointF( i, std::sin( i ) );
|
|
|
|
#if 1
|
|
qDebug() << "=== X";
|
|
testSplines( QwtSplineParametrization::ParameterX, points );
|
|
#endif
|
|
|
|
#if 1
|
|
qDebug() << "=== Y";
|
|
testSplines( QwtSplineParametrization::ParameterY, points );
|
|
#endif
|
|
|
|
#if 1
|
|
qDebug() << "=== Uniform";
|
|
testSplines( QwtSplineParametrization::ParameterUniform, points );
|
|
#endif
|
|
|
|
#if 1
|
|
qDebug() << "=== Manhattan";
|
|
testSplines( QwtSplineParametrization::ParameterManhattan, points );
|
|
#endif
|
|
|
|
#if 1
|
|
qDebug() << "=== Chordal";
|
|
testSplines( QwtSplineParametrization::ParameterChordal, points );
|
|
#endif
|
|
|
|
#if 1
|
|
qDebug() << "=== Centripetral";
|
|
testSplines( QwtSplineParametrization::ParameterCentripetal, points );
|
|
#endif
|
|
|
|
return 0;
|
|
}
|