Qwt User's Guide: qwt_spline_curve_fitter.cpp Source File

Qwt User's Guide 6.2.0

qwt_spline_curve_fitter.cpp
1 /******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10 #include "qwt_spline_curve_fitter.h"
11 #include "qwt_spline_local.h"
12 #include "qwt_spline_parametrization.h"
13
14 #include <qpolygon.h>
15 #include <qpainterpath.h>
16
18 QwtSplineCurveFitter::QwtSplineCurveFitter()
19 : QwtCurveFitter( QwtCurveFitter::Path )
20 {
21 m_spline = new QwtSplineLocal( QwtSplineLocal::Cardinal );
22 m_spline->setParametrization( QwtSplineParametrization::ParameterUniform );
23 }
24
26 QwtSplineCurveFitter::~QwtSplineCurveFitter()
27 {
28 delete m_spline;
29 }
30
40 void QwtSplineCurveFitter::setSpline( QwtSpline* spline )
41 {
42 if ( m_spline == spline )
43 return;
44
45 delete m_spline;
46 m_spline = spline;
47 }
48
53 const QwtSpline* QwtSplineCurveFitter::spline() const
54 {
55 return m_spline;
56 }
57
62 QwtSpline* QwtSplineCurveFitter::spline()
63 {
64 return m_spline;
65 }
66
75 QPolygonF QwtSplineCurveFitter::fitCurve( const QPolygonF& points ) const
76 {
77 const QPainterPath path = fitCurvePath( points );
78
79 const QList< QPolygonF > subPaths = path.toSubpathPolygons();
80 if ( subPaths.size() == 1 )
81 subPaths.first();
82
83 return QPolygonF();
84 }
85
94 QPainterPath QwtSplineCurveFitter::fitCurvePath( const QPolygonF& points ) const
95 {
96 QPainterPath path;
97
98 if ( m_spline )
99 path = m_spline->painterPath( points );
100
101 return path;
102 }
QList
Definition: qwt_abstract_legend.h:17
QwtCurveFitter
Abstract base class for a curve fitter.
Definition: qwt_curve_fitter.h:22
QwtSplineCurveFitter::setSpline
void setSpline(QwtSpline *)
Definition: qwt_spline_curve_fitter.cpp:40
QwtSplineCurveFitter::fitCurvePath
virtual QPainterPath fitCurvePath(const QPolygonF &) const override
Definition: qwt_spline_curve_fitter.cpp:94
QwtSplineCurveFitter::~QwtSplineCurveFitter
virtual ~QwtSplineCurveFitter()
Destructor.
Definition: qwt_spline_curve_fitter.cpp:26
QwtSplineCurveFitter::QwtSplineCurveFitter
QwtSplineCurveFitter()
Constructor.
Definition: qwt_spline_curve_fitter.cpp:18
QwtSplineCurveFitter::spline
const QwtSpline * spline() const
Definition: qwt_spline_curve_fitter.cpp:53
QwtSplineCurveFitter::fitCurve
virtual QPolygonF fitCurve(const QPolygonF &) const override
Definition: qwt_spline_curve_fitter.cpp:75
QwtSpline
Base class for all splines.
Definition: qwt_spline.h:58
QwtSpline::painterPath
virtual QPainterPath painterPath(const QPolygonF &) const =0
QwtSpline::setParametrization
void setParametrization(int type)
Definition: qwt_spline.cpp:576
QwtSplineLocal
A spline with C1 continuity.
Definition: qwt_spline_local.h:25
QwtSplineLocal::Cardinal
@ Cardinal
Definition: qwt_spline_local.h:42
QwtSplineParametrization::ParameterUniform
@ ParameterUniform
Definition: qwt_spline_parametrization.h:72