Loading...
Searching...
No Matches
qwt_spline_curve_fitter.cpp
/******************************************************************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include "qwt_spline_curve_fitter.h"
#include "qwt_spline_local.h"
#include "qwt_spline_parametrization.h"
#include <qpolygon.h>
#include <qpainterpath.h>
QwtSplineCurveFitter::QwtSplineCurveFitter()
: QwtCurveFitter( QwtCurveFitter::Path )
{
m_spline = new QwtSplineLocal( QwtSplineLocal::Cardinal );
m_spline->setParametrization( QwtSplineParametrization::ParameterUniform );
}
QwtSplineCurveFitter::~QwtSplineCurveFitter()
{
delete m_spline;
}
void QwtSplineCurveFitter::setSpline( QwtSpline* spline )
{
if ( m_spline == spline )
return;
delete m_spline;
m_spline = spline;
}
const QwtSpline* QwtSplineCurveFitter::spline() const
{
return m_spline;
}
QwtSpline* QwtSplineCurveFitter::spline()
{
return m_spline;
}
QPolygonF QwtSplineCurveFitter::fitCurve( const QPolygonF& points ) const
{
const QPainterPath path = fitCurvePath( points );
const QList< QPolygonF > subPaths = path.toSubpathPolygons();
if ( subPaths.size() == 1 )
return subPaths.first();
return QPolygonF();
}
QPainterPath QwtSplineCurveFitter::fitCurvePath( const QPolygonF& points ) const
{
QPainterPath path;
if ( m_spline )
path = m_spline->painterPath( points );
return path;
}
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