2019-01-10 04:23:24 +08:00
/*
2019-01-12 23:01:55 +08:00
Copyright ( c ) 2008 - 2019 Jan W . Krieger ( < jan @ jkrieger . de > )
2019-01-10 04:23:24 +08:00
This software is free software : you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License ( LGPL ) as published by
the Free Software Foundation , either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Lesser General Public License ( LGPL ) for more details .
You should have received a copy of the GNU Lesser General Public License ( LGPL )
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# include <QString>
# include <QPainter>
# include <QPair>
# include "jkqtplotter/jkqtpgraphs.h"
# include "jkqtplottertools/jkqtp_imexport.h"
# include <functional>
# ifndef jkqtpgraphsevaluatedfunction_H
# define jkqtpgraphsevaluatedfunction_H
/*! \brief type of functions that may be plottet
2019-01-19 16:40:52 +08:00
\ ingroup jkqtplotter_functiongraphs
2019-01-10 04:23:24 +08:00
2019-01-20 17:49:29 +08:00
This is the type of functions \ f $ y = f ( x , \ vec { p } ) \ f $ that may be plottet by JKQTPXFunctionLineGraph
and JKQTPYFunctionLineGraph . It is possible to supply parameters \ f $ \ vec { p } \ f $ to the function that
2019-01-10 04:23:24 +08:00
influence its result . Parameters are given as a pointer to some memory location . The function has to
know on its own how to interpret these .
*/
typedef std : : function < double ( double , void * ) > jkqtpPlotFunctionType ;
/*! \brief simplified type of functions (without parameters) that may be plottet
2019-01-19 16:40:52 +08:00
\ ingroup jkqtplotter_functiongraphs
2019-01-10 04:23:24 +08:00
2019-01-20 17:49:29 +08:00
This is the type of functions \ f $ y = f ( x ) \ f $ that may be plottet by JKQTPXFunctionLineGraph
and JKQTPYFunctionLineGraph .
2019-01-10 04:23:24 +08:00
*/
typedef std : : function < double ( double ) > jkqtpSimplePlotFunctionType ;
/*! \brief This implements line plots where the data is taken from a user supplied function \f$ y=f(x) \f$
2019-01-19 16:40:52 +08:00
\ ingroup jkqtplotter_functiongraphs
2019-01-10 04:23:24 +08:00
This class implements an intelligent plotting algorithm for functions . It starts by sampling
the function at minSamples positions . Then each function interval is bisected recursively if
necessary . To do so the function is evaluated at the mid point and the slopes \ f $ \ alpha_ { \ mbox { left } } \ f $
and \ f $ \ alpha_ { \ mbox { right } } \ f $ of the two linear segments are compared . the midpoint is added
to the graph if \ f [ \ left | \ alpha_ { \ mbox { right } } - \ alpha_ { \ mbox { left } } \ right | > \ mbox { slopeTolerance } \ f ]
In addition all sampling points except minimum and maximum are beeing shifted by a random fraction their
distance to the other points . This helps to prevent beats when sampling periodic functions .
the following image
\ image html plot_functionplots . png
*/
2019-02-03 21:04:48 +08:00
class JKQTP_LIB_EXPORT JKQTPXFunctionLineGraph : public JKQTPGraph {
2019-01-10 04:23:24 +08:00
Q_OBJECT
public :
enum SpecialFunction {
Polynomial , /*!< \brief a polynomial \f$ f(x)=p_0+p_1x+p_2x^2+p_3x^3+... \f$ The parameters \a params have to be point to a QVector<double> and contain the parameters \f$ p_0, p_1, ... \f$ */
Line = Polynomial , /*!< \brief a polynomial \f$ f(x)=p_0+p_1x \f$ The parameters \a params have to be point to a QVector<double> and contain the parameters \f$ p_0, p_1, ... \f$ */
Exponential , /*!< \brief an exponential function \f$ f(x)=p_0+p_1\cdot\exp(x/p_2) \f$ or \f$ f(x)=p_0\cdot\exp(x/p_1) \f$ (depending on the number of parameters). The parameters \a params have to be point to a QVector<double> and contain the parameters \f$ p_0, p_1, ... \f$ */
PowerLaw , /*!< \brief an exponential function \f$ f(x)=p_0+p_1\cdot x^{p_3} \f$ or \f$ f(x)=p_0\cdot x^{p_1} \f$ or \f$ f(x)= x^{p_0} \f$ (depending on the number of parameters) The parameters \a params have to be point to a QVector<double> and contain the parameters \f$ p_0, p_1, ... \f$ */
UserFunction , /*!< \brief no special function but the function is provided by the user */
} ;
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTPXFunctionLineGraph ( JKQTBasePlotter * parent = nullptr ) ;
2019-01-10 04:23:24 +08:00
/** \brief class constructor */
2019-01-20 23:15:10 +08:00
JKQTPXFunctionLineGraph ( JKQTPlotter * parent ) ;
2019-01-10 04:23:24 +08:00
/** \brief class destructor */
2019-01-20 17:49:29 +08:00
virtual ~ JKQTPXFunctionLineGraph ( ) ;
2019-01-10 04:23:24 +08:00
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
/** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker ( JKQTPEnhancedPainter & painter , QRectF & rect ) override ;
/** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor ( ) override ;
/** \brief get the maximum and minimum x-value of the graph
*
* This functions returns 0 for both parameters , so that the plotter uses the predefined
* min and max values .
*/
virtual bool getXMinMax ( double & minx , double & maxx , double & smallestGreaterZero ) override ;
/** \brief get the maximum and minimum y-value of the graph
*/
virtual bool getYMinMax ( double & miny , double & maxy , double & smallestGreaterZero ) override ;
/** \brief clear the data sampled from the function. */
void clearData ( ) ;
2019-01-26 20:00:40 +08:00
/*! \brief sets the property color ( \copybrief color ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter color is : < BLOCKQUOTE > \ copydoc color < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see color for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setColor ( const QColor & __value )
2019-01-10 04:23:24 +08:00
{
this - > color = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property color ( \copybrief color ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter color is : < BLOCKQUOTE > \ copydoc color < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see color for more information */
2019-01-26 20:00:40 +08:00
inline virtual QColor getColor ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > color ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property fillColor ( \copybrief fillColor ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter fillColor is : < BLOCKQUOTE > \ copydoc fillColor < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see fillColor for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setFillColor ( const QColor & __value )
2019-01-10 04:23:24 +08:00
{
this - > fillColor = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property fillColor ( \copybrief fillColor ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter fillColor is : < BLOCKQUOTE > \ copydoc fillColor < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see fillColor for more information */
2019-01-26 20:00:40 +08:00
inline virtual QColor getFillColor ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > fillColor ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property fillStyle ( \copybrief fillStyle ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter fillStyle is : < BLOCKQUOTE > \ copydoc fillStyle < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see fillStyle for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setFillStyle ( const Qt : : BrushStyle & __value )
2019-01-10 04:23:24 +08:00
{
this - > fillStyle = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property fillStyle ( \copybrief fillStyle ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter fillStyle is : < BLOCKQUOTE > \ copydoc fillStyle < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see fillStyle for more information */
2019-01-26 20:00:40 +08:00
inline virtual Qt : : BrushStyle getFillStyle ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > fillStyle ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property style ( \copybrief style ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter style is : < BLOCKQUOTE > \ copydoc style < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see style for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setStyle ( const Qt : : PenStyle & __value )
2019-01-10 04:23:24 +08:00
{
this - > style = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property style ( \copybrief style ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter style is : < BLOCKQUOTE > \ copydoc style < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see style for more information */
2019-01-26 20:00:40 +08:00
inline virtual Qt : : PenStyle getStyle ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > style ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property lineWidth ( \copybrief lineWidth ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter lineWidth is : < BLOCKQUOTE > \ copydoc lineWidth < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see lineWidth for more information */
2019-01-26 03:16:04 +08:00
inline virtual void setLineWidth ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > lineWidth = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property lineWidth ( \copybrief lineWidth ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter lineWidth is : < BLOCKQUOTE > \ copydoc lineWidth < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see lineWidth for more information */
2019-01-26 03:16:04 +08:00
inline virtual double getLineWidth ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > lineWidth ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property drawLine ( \copybrief drawLine ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter drawLine is : < BLOCKQUOTE > \ copydoc drawLine < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see drawLine for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setDrawLine ( bool __value )
2019-01-10 04:23:24 +08:00
{
this - > drawLine = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property drawLine ( \copybrief drawLine ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter drawLine is : < BLOCKQUOTE > \ copydoc drawLine < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see drawLine for more information */
2019-01-26 20:00:40 +08:00
inline virtual bool getDrawLine ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > drawLine ;
}
2019-01-26 20:00:40 +08:00
/** \brief sets the property plotFunction ( \copybrief plotFunction ) to the specified \a __value.
2019-01-10 04:23:24 +08:00
*
2019-01-26 20:00:40 +08:00
* \ details Description of the parameter plotFunction is : < BLOCKQUOTE > \ copydoc plotFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
* \ see plotFunction for more information */
2019-01-26 03:16:04 +08:00
virtual void setPlotFunction ( jkqtpPlotFunctionType & & __value ) ;
2019-01-26 20:00:40 +08:00
/** \brief sets the property plotFunction ( \copybrief plotFunction ) to the specified \a __value.
2019-01-10 04:23:24 +08:00
*
2019-01-26 20:00:40 +08:00
* \ details Description of the parameter plotFunction is : < BLOCKQUOTE > \ copydoc plotFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
* \ see plotFunction for more information */
2019-01-26 03:16:04 +08:00
virtual void setPlotFunction ( const jkqtpPlotFunctionType & __value ) ;
2019-01-26 20:00:40 +08:00
/** \brief sets the property plotFunction ( \copybrief plotFunction ) to the specified \a __value.
2019-01-10 04:23:24 +08:00
*
2019-01-25 05:49:10 +08:00
* \ details Description of the parameter plotFunction is : < BLOCKQUOTE > \ copydoc plotFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
* \ see plotFunction for more information */
2019-01-26 03:16:04 +08:00
virtual void setPlotFunction ( jkqtpSimplePlotFunctionType & & __value ) ;
2019-01-26 20:00:40 +08:00
/** \brief sets the property plotFunction ( \copybrief plotFunction ) to the specified \a __value.
2019-01-10 04:23:24 +08:00
*
2019-01-25 05:49:10 +08:00
* \ details Description of the parameter plotFunction is : < BLOCKQUOTE > \ copydoc plotFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
* \ see plotFunction for more information */
2019-01-26 03:16:04 +08:00
virtual void setPlotFunction ( const jkqtpSimplePlotFunctionType & __value ) ;
2019-01-26 20:00:40 +08:00
/*! \brief returns the property plotFunction ( \copybrief plotFunction ). \see plotFunction for more information */ \
2019-01-26 03:16:04 +08:00
virtual jkqtpPlotFunctionType getPlotFunction ( ) const ;
2019-01-26 20:00:40 +08:00
/*! \brief returns the property simplePlotFunction ( \copybrief simplePlotFunction ). \see simplePlotFunction for more information */ \
virtual jkqtpSimplePlotFunctionType getSimplePlotFunction ( ) const ;
2019-01-10 04:23:24 +08:00
2019-01-26 20:00:40 +08:00
/*! \brief sets the property params ( \copybrief params ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter params is : < BLOCKQUOTE > \ copydoc params < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see params for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setParams ( void * __value )
2019-01-10 04:23:24 +08:00
{
if ( this - > params ! = __value ) {
this - > params = __value ;
clearData ( ) ;
}
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property params ( \copybrief params ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter params is : < BLOCKQUOTE > \ copydoc params < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see params for more information */
2019-01-26 20:00:40 +08:00
inline virtual void * getParams ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > params ;
}
/** \brief sets the params as a pointer to an internal COPY of the given vector (not the data of the vector, as then the size would be unknown!!!) */
2019-01-26 20:00:40 +08:00
void setParams ( const QVector < double > & params ) ;
2019-01-10 04:23:24 +08:00
/** \brief sets the params from a copy of the given array of length \a N */
2019-01-26 20:00:40 +08:00
void setCopiedParams ( const double * params , int N ) ;
2019-01-10 04:23:24 +08:00
/** \brief set an internal parameter vector as function parameters, initialized with {p1} */
2019-01-26 20:00:40 +08:00
void setParamsV ( double p1 ) ;
2019-01-10 04:23:24 +08:00
/** \brief set an internal parameter vector as function parameters, initialized with {p1,p2} */
2019-01-26 20:00:40 +08:00
void setParamsV ( double p1 , double p2 ) ;
2019-01-10 04:23:24 +08:00
/** \brief set an internal parameter vector as function parameters, initialized with {p1,p2,p3} */
2019-01-26 20:00:40 +08:00
void setParamsV ( double p1 , double p2 , double p3 ) ;
2019-01-10 04:23:24 +08:00
/** \brief set an internal parameter vector as function parameters, initialized with {p1,p2,p3,p4} */
2019-01-26 20:00:40 +08:00
void setParamsV ( double p1 , double p2 , double p3 , double p4 ) ;
2019-01-10 04:23:24 +08:00
/** \brief set an internal parameter vector as function parameters, initialized with {p1,p2,p3,p4,p5} */
2019-01-26 20:00:40 +08:00
void setParamsV ( double p1 , double p2 , double p3 , double p4 , double p5 ) ;
2019-01-10 04:23:24 +08:00
/** \brief returns the currently set internal parameter vector */
2019-01-26 20:00:40 +08:00
QVector < double > getInternalParams ( ) const ;
2019-01-10 04:23:24 +08:00
/** \brief returns the currently set internal parameter vector */
2019-01-26 20:00:40 +08:00
QVector < double > getInternalErrorParams ( ) const ;
/*! \brief sets the property minSamples ( \copybrief minSamples ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter minSamples is : < BLOCKQUOTE > \ copydoc minSamples < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see minSamples for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setMinSamples ( const unsigned int & __value )
2019-01-10 04:23:24 +08:00
{
this - > minSamples = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property minSamples ( \copybrief minSamples ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter minSamples is : < BLOCKQUOTE > \ copydoc minSamples < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see minSamples for more information */
2019-01-26 20:00:40 +08:00
inline virtual unsigned int getMinSamples ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > minSamples ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property maxRefinementDegree ( \copybrief maxRefinementDegree ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter maxRefinementDegree is : < BLOCKQUOTE > \ copydoc maxRefinementDegree < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see maxRefinementDegree for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setMaxRefinementDegree ( const unsigned int & __value )
2019-01-10 04:23:24 +08:00
{
this - > maxRefinementDegree = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property maxRefinementDegree ( \copybrief maxRefinementDegree ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter maxRefinementDegree is : < BLOCKQUOTE > \ copydoc maxRefinementDegree < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see maxRefinementDegree for more information */
2019-01-26 20:00:40 +08:00
inline virtual unsigned int getMaxRefinementDegree ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > maxRefinementDegree ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property slopeTolerance ( \copybrief slopeTolerance ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter slopeTolerance is : < BLOCKQUOTE > \ copydoc slopeTolerance < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see slopeTolerance for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setSlopeTolerance ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > slopeTolerance = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property slopeTolerance ( \copybrief slopeTolerance ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter slopeTolerance is : < BLOCKQUOTE > \ copydoc slopeTolerance < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see slopeTolerance for more information */
2019-01-26 20:00:40 +08:00
inline virtual double getSlopeTolerance ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > slopeTolerance ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property minPixelPerSample ( \copybrief minPixelPerSample ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter minPixelPerSample is : < BLOCKQUOTE > \ copydoc minPixelPerSample < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see minPixelPerSample for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setMinPixelPerSample ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > minPixelPerSample = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property minPixelPerSample ( \copybrief minPixelPerSample ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter minPixelPerSample is : < BLOCKQUOTE > \ copydoc minPixelPerSample < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see minPixelPerSample for more information */
2019-01-26 20:00:40 +08:00
inline virtual double getMinPixelPerSample ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > minPixelPerSample ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property plotRefinement ( \copybrief plotRefinement ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter plotRefinement is : < BLOCKQUOTE > \ copydoc plotRefinement < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see plotRefinement for more information */
2019-01-26 03:16:04 +08:00
inline virtual void setPlotRefinement ( bool __value )
2019-01-10 04:23:24 +08:00
{
this - > plotRefinement = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property plotRefinement ( \copybrief plotRefinement ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter plotRefinement is : < BLOCKQUOTE > \ copydoc plotRefinement < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see plotRefinement for more information */
2019-01-26 03:16:04 +08:00
inline virtual bool getPlotRefinement ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > plotRefinement ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property displaySamplePoints ( \copybrief displaySamplePoints ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter displaySamplePoints is : < BLOCKQUOTE > \ copydoc displaySamplePoints < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see displaySamplePoints for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setDisplaySamplePoints ( bool __value )
2019-01-10 04:23:24 +08:00
{
this - > displaySamplePoints = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property displaySamplePoints ( \copybrief displaySamplePoints ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter displaySamplePoints is : < BLOCKQUOTE > \ copydoc displaySamplePoints < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see displaySamplePoints for more information */
2019-01-26 20:00:40 +08:00
inline virtual bool getDisplaySamplePoints ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > displaySamplePoints ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property drawErrorPolygons ( \copybrief drawErrorPolygons ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter drawErrorPolygons is : < BLOCKQUOTE > \ copydoc drawErrorPolygons < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see drawErrorPolygons for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setDrawErrorPolygons ( bool __value )
2019-01-10 04:23:24 +08:00
{
this - > drawErrorPolygons = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property drawErrorPolygons ( \copybrief drawErrorPolygons ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter drawErrorPolygons is : < BLOCKQUOTE > \ copydoc drawErrorPolygons < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see drawErrorPolygons for more information */
2019-01-26 20:00:40 +08:00
inline virtual bool getDrawErrorPolygons ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > drawErrorPolygons ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property drawErrorLines ( \copybrief drawErrorLines ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter drawErrorLines is : < BLOCKQUOTE > \ copydoc drawErrorLines < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see drawErrorLines for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setDrawErrorLines ( bool __value )
2019-01-10 04:23:24 +08:00
{
this - > drawErrorLines = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property drawErrorLines ( \copybrief drawErrorLines ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter drawErrorLines is : < BLOCKQUOTE > \ copydoc drawErrorLines < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see drawErrorLines for more information */
2019-01-26 20:00:40 +08:00
inline virtual bool getDrawErrorLines ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > drawErrorLines ;
}
2019-01-26 20:00:40 +08:00
/** \brief sets the property errorPlotFunction ( \copybrief errorPlotFunction ) to the specified \a __value.
2019-01-10 04:23:24 +08:00
*
2019-01-26 20:00:40 +08:00
* \ details Description of the parameter errorPlotFunction is : < BLOCKQUOTE > \ copydoc errorPlotFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
* \ see errorPlotFunction for more information */
2019-01-26 20:00:40 +08:00
virtual void setErrorPlotFunction ( jkqtpPlotFunctionType & & __value ) ;
/** \brief sets the property errorPlotFunction ( \copybrief errorPlotFunction ) to the specified \a __value.
2019-01-10 04:23:24 +08:00
*
2019-01-26 20:00:40 +08:00
* \ details Description of the parameter errorPlotFunction is : < BLOCKQUOTE > \ copydoc errorPlotFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
* \ see errorPlotFunction for more information */
2019-01-26 20:00:40 +08:00
virtual void setErrorPlotFunction ( const jkqtpPlotFunctionType & __value ) ;
/*! \brief returns the property errorPlotFunction ( \copybrief errorPlotFunction ). \see errorPlotFunction for more information */ \
virtual jkqtpPlotFunctionType getErrorPlotFunction ( ) const ;
/** \brief sets the property errorPlotFunction ( \copybrief errorPlotFunction ) to the specified \a __value.
2019-01-10 04:23:24 +08:00
*
2019-01-26 20:00:40 +08:00
* \ details Description of the parameter errorPlotFunction is : < BLOCKQUOTE > \ copydoc errorPlotFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
* \ see errorPlotFunction for more information */
2019-01-26 20:00:40 +08:00
virtual void setErrorPlotFunction ( jkqtpSimplePlotFunctionType & & __value ) ;
/** \brief sets the property errorPlotFunction ( \copybrief errorPlotFunction ) to the specified \a __value.
2019-01-10 04:23:24 +08:00
*
2019-01-26 20:00:40 +08:00
* \ details Description of the parameter errorPlotFunction is : < BLOCKQUOTE > \ copydoc errorPlotFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
* \ see errorPlotFunction for more information */
2019-01-26 20:00:40 +08:00
virtual void setErrorPlotFunction ( const jkqtpSimplePlotFunctionType & __value ) ;
/*! \brief returns the property errorSimplePlotFunction ( \copybrief errorSimplePlotFunction ). \see errorSimplePlotFunction for more information */ \
virtual jkqtpSimplePlotFunctionType getErrorSimplePlotFunction ( ) const ;
/*! \brief sets the property errorParams ( \copybrief errorParams ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorParams is : < BLOCKQUOTE > \ copydoc errorParams < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorParams for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setErrorParams ( void * __value )
2019-01-10 04:23:24 +08:00
{
this - > errorParams = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property errorParams ( \copybrief errorParams ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorParams is : < BLOCKQUOTE > \ copydoc errorParams < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorParams for more information */
2019-01-26 20:00:40 +08:00
inline virtual void * getErrorParams ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > errorParams ;
}
/** \brief sets the error params as a pointer to an internal COPY of the given vector (not the data of the vector, as then the size would be unknown!!!) */
2019-01-26 20:00:40 +08:00
void setErrorParams ( const QVector < double > & errorParams ) ;
2019-01-10 04:23:24 +08:00
2019-01-26 20:00:40 +08:00
/*! \brief sets the property parameterColumn ( \copybrief parameterColumn ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter parameterColumn is : < BLOCKQUOTE > \ copydoc parameterColumn < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see parameterColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setParameterColumn ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > parameterColumn = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property parameterColumn ( \copybrief parameterColumn ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter parameterColumn is : < BLOCKQUOTE > \ copydoc parameterColumn < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see parameterColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual int getParameterColumn ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > parameterColumn ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property parameterColumn ( \copybrief parameterColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter parameterColumn is : < BLOCKQUOTE > \ copydoc parameterColumn < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see parameterColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setParameterColumn ( size_t __value ) { this - > parameterColumn = static_cast < int > ( __value ) ; }
/*! \brief sets the property errorParameterColumn ( \copybrief errorParameterColumn ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorParameterColumn is : < BLOCKQUOTE > \ copydoc errorParameterColumn < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorParameterColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setErrorParameterColumn ( int __value )
2019-01-10 04:23:24 +08:00
{
this - > errorParameterColumn = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property errorParameterColumn ( \copybrief errorParameterColumn ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorParameterColumn is : < BLOCKQUOTE > \ copydoc errorParameterColumn < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorParameterColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual int getErrorParameterColumn ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > errorParameterColumn ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property errorParameterColumn ( \copybrief errorParameterColumn ) to the specified \a __value, where __value is static_cast'ed from size_t to int.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorParameterColumn is : < BLOCKQUOTE > \ copydoc errorParameterColumn < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorParameterColumn for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setErrorParameterColumn ( size_t __value ) { this - > errorParameterColumn = static_cast < int > ( __value ) ; }
2019-01-10 04:23:24 +08:00
2019-01-26 20:00:40 +08:00
/*! \brief sets the property errorColor ( \copybrief errorColor ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorColor is : < BLOCKQUOTE > \ copydoc errorColor < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorColor for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setErrorColor ( const QColor & __value )
2019-01-10 04:23:24 +08:00
{
this - > errorColor = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property errorColor ( \copybrief errorColor ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorColor is : < BLOCKQUOTE > \ copydoc errorColor < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorColor for more information */
2019-01-26 20:00:40 +08:00
inline virtual QColor getErrorColor ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > errorColor ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property errorFillColor ( \copybrief errorFillColor ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorFillColor is : < BLOCKQUOTE > \ copydoc errorFillColor < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorFillColor for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setErrorFillColor ( const QColor & __value )
2019-01-10 04:23:24 +08:00
{
this - > errorFillColor = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property errorFillColor ( \copybrief errorFillColor ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorFillColor is : < BLOCKQUOTE > \ copydoc errorFillColor < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorFillColor for more information */
2019-01-26 20:00:40 +08:00
inline virtual QColor getErrorFillColor ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > errorFillColor ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property errorFillStyle ( \copybrief errorFillStyle ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorFillStyle is : < BLOCKQUOTE > \ copydoc errorFillStyle < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorFillStyle for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setErrorFillStyle ( const Qt : : BrushStyle & __value )
2019-01-10 04:23:24 +08:00
{
this - > errorFillStyle = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property errorFillStyle ( \copybrief errorFillStyle ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorFillStyle is : < BLOCKQUOTE > \ copydoc errorFillStyle < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorFillStyle for more information */
2019-01-26 20:00:40 +08:00
inline virtual Qt : : BrushStyle getErrorFillStyle ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > errorFillStyle ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property errorStyle ( \copybrief errorStyle ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorStyle is : < BLOCKQUOTE > \ copydoc errorStyle < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorStyle for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setErrorStyle ( const Qt : : PenStyle & __value )
2019-01-10 04:23:24 +08:00
{
this - > errorStyle = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property errorStyle ( \copybrief errorStyle ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorStyle is : < BLOCKQUOTE > \ copydoc errorStyle < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorStyle for more information */
2019-01-26 20:00:40 +08:00
inline virtual Qt : : PenStyle getErrorStyle ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > errorStyle ;
}
2019-01-26 20:00:40 +08:00
/*! \brief sets the property errorLineWidth ( \copybrief errorLineWidth ) to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorLineWidth is : < BLOCKQUOTE > \ copydoc errorLineWidth < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorLineWidth for more information */
2019-01-26 20:00:40 +08:00
inline virtual void setErrorLineWidth ( double __value )
2019-01-10 04:23:24 +08:00
{
this - > errorLineWidth = __value ;
}
2019-01-26 20:00:40 +08:00
/*! \brief returns the property errorLineWidth ( \copybrief errorLineWidth ).
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorLineWidth is : < BLOCKQUOTE > \ copydoc errorLineWidth < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorLineWidth for more information */
2019-01-26 20:00:40 +08:00
inline virtual double getErrorLineWidth ( ) const
2019-01-10 04:23:24 +08:00
{
return this - > errorLineWidth ;
}
2019-01-20 17:49:29 +08:00
/** \copydoc JKQTPGraph::usesColumn() */
2019-01-10 04:23:24 +08:00
virtual bool usesColumn ( int c ) const override ;
/** \brief sets function to the given special function */
void setSpecialFunction ( SpecialFunction function ) ;
/** \brief returns, which special function is set (or if any is set) */
SpecialFunction getFunctionType ( ) const ;
protected :
2019-01-26 03:16:04 +08:00
/** \brief which plot style to use from the parent plotter (via JKQTBasePlotter::getPlotStyle() and JKQTBasePlotter::getNextStyle() ) */
2019-01-10 04:23:24 +08:00
int parentPlotStyle ;
struct doublePair {
double x ;
double f ;
doublePair * next ;
} ;
/** \brief a linked list holding the datapoints \f$ \left(x, y=f(x, \vec{p})\right) \f$ to be plotted */
doublePair * data ;
/** \brief fill the data array with data from the function plotFunction */
virtual void createPlotData ( bool collectParams = true ) ;
virtual void collectParameters ( ) ;
/** \brief refine datapoints on the function graph between two evaluations \a a and \a b */
void refine ( doublePair * a , doublePair * b , unsigned int degree = 0 ) ;
/** \brief if set, the values from this datatsore column are used for the parameters \c p1 , \c p2 , \c p3 , ... of the plot function */
int parameterColumn ;
/** \brief if set, the values from this datatsore column are used for the parameters \c p1 , \c p2 , \c p3 , ... of the error plot function */
int errorParameterColumn ;
/** \brief color of the graph */
QColor color ;
/** \brief color of the graph fill */
QColor fillColor ;
/** \brief linestyle of the graph lines */
Qt : : PenStyle style ;
/** \brief width (pixels) of the graph */
double lineWidth ;
/** \brief fill style, if the curve should be filled */
Qt : : BrushStyle fillStyle ;
/** \brief indicates whether to draw a line or not */
bool drawLine ;
/** \brief indicates whether to fill the space between the curve and the x-axis */
bool fillCurve ;
/** \brief the function to be plotted */
jkqtpPlotFunctionType plotFunction ;
/** \brief a simple function to be plotted, simplified form without parameters */
jkqtpSimplePlotFunctionType simplePlotFunction ;
/** \brief indicates whether a special function is set (and if so, which one), or a user-supplied function */
SpecialFunction functionType ;
/** \brief pointer to the parameters supplied to the plotting funtion */
void * params ;
/** \brief the minimum number of points to evaluate the function at */
unsigned int minSamples ;
/** \brief the maximum number of recursive refinement steps
*
* each step bisects the interval \ f $ [ a , b ] \ f $ into two halfes . So the maximum number
* of points plotted at all are thus :
* \ f [ \ mbox { minSamples } \ cdot 2 ^ { \ mbox { maxRefinementDegree } } \ f ]
*/
unsigned int maxRefinementDegree ;
/** \brief the tolerance for the difference of two subsequent slopes */
double slopeTolerance ;
/** \brief create one sample at least every \a minPixelPerSample pixels */
double minPixelPerSample ;
/** \brief switch on or off [default: on] the plot refinement algorithm */
bool plotRefinement ;
/** \brief if true [default: off] display the points where the function has been sampled */
bool displaySamplePoints ;
/** \brief indicates whether an error polygon should be drawn */
bool drawErrorPolygons ;
/** \brief indicates whether error lines should be drawn */
bool drawErrorLines ;
/** \brief this function calculates the error at a given position */
jkqtpPlotFunctionType errorPlotFunction ;
/** \brief this function calculates the error at a given position, simplified form without parameters */
jkqtpSimplePlotFunctionType errorSimplePlotFunction ;
/** \brief parameters for errorFunction */
void * errorParams ;
/** \brief color of the error graph */
QColor errorColor ;
/** \brief color of the error graph fill */
QColor errorFillColor ;
/** \brief linestyle of the error graph lines */
Qt : : PenStyle errorStyle ;
/** \brief width (pixels) of the error graph */
double errorLineWidth ;
/** \brief fill style, if the error curve should be filled */
Qt : : BrushStyle errorFillStyle ;
QBrush getBrush ( JKQTPEnhancedPainter & painter ) const ;
QPen getLinePen ( JKQTPEnhancedPainter & painter ) const ;
QBrush getErrorBrush ( JKQTPEnhancedPainter & painter ) const ;
QPen getErrorLinePen ( JKQTPEnhancedPainter & painter ) const ;
QVector < double > iparams , ierrorparams ;
} ;
/*! \brief This implements line plots where the data is taken from a user supplied function \f$ x=f(y) \f$
2019-01-19 16:40:52 +08:00
\ ingroup jkqtplotter_functiongraphs
2019-01-10 04:23:24 +08:00
*/
2019-02-03 21:04:48 +08:00
class JKQTP_LIB_EXPORT JKQTPYFunctionLineGraph : public JKQTPXFunctionLineGraph {
2019-01-10 04:23:24 +08:00
Q_OBJECT
public :
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTPYFunctionLineGraph ( JKQTBasePlotter * parent = nullptr ) ;
2019-01-10 04:23:24 +08:00
/** \brief class constructor */
2019-01-20 23:15:10 +08:00
JKQTPYFunctionLineGraph ( JKQTPlotter * parent ) ;
2019-01-10 04:23:24 +08:00
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw ( JKQTPEnhancedPainter & painter ) override ;
protected :
/** \brief fill the data array with data from the function plotFunction */
virtual void createPlotData ( bool collectParams = true ) override ;
} ;
# endif // jkqtpgraphsevaluatedfunction_H