2015-07-11 18:56:02 +08:00
/*
2019-01-12 23:01:55 +08:00
Copyright ( c ) 2008 - 2019 Jan W . Krieger ( < jan @ jkrieger . de > )
2015-07-11 18:56:02 +08:00
2015-07-12 22:34:27 +08:00
2015-07-11 18:56:02 +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/>.
*/
2018-12-19 00:13:18 +08:00
# ifndef jkqtpgraphsparsedfunction_H
# define jkqtpgraphsparsedfunction_H
2015-07-11 18:56:02 +08:00
# include <QString>
# include <QPainter>
# include <QPair>
2018-11-26 03:25:44 +08:00
# include "jkqtplottertools/jkqtptools.h"
# include "jkqtplottertools/jkqtpmathparser.h"
# include "jkqtplottertools/jkqtp_imexport.h"
2018-12-24 03:27:24 +08:00
# include "jkqtplotter/jkqtpgraphsevaluatedfunction.h"
2015-07-11 18:56:02 +08:00
// forward declarations
2019-01-20 17:49:29 +08:00
class JKQTBasePlotter ;
2019-01-20 23:15:10 +08:00
class JKQTPlotter ;
2015-07-11 18:56:02 +08:00
/*! \brief This implements line plots where the data is taken from a user supplied function \f$ y=f(x) \f$ The function is defined as a string and parsed by JKMathParser
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_parsedFgraphs
2015-07-11 18:56:02 +08:00
Additional function parameters may be given in the vector parameters . They are accessible in the function as \ c p1 , \ c p2 , \ c p3 , . . .
Parameters may also be given from a data column . Then first the params from the column and the the parameters from the vector are numbered .
2018-12-24 22:07:14 +08:00
Use the variable \ c x in an equation to refer to the free parameter of the curve .
2015-07-11 18:56:02 +08:00
*/
2019-01-20 17:49:29 +08:00
class LIB_EXPORT JKQTPXParsedFunctionLineGraph : public JKQTPXFunctionLineGraph {
2018-12-24 22:07:14 +08:00
Q_OBJECT
2015-07-11 18:56:02 +08:00
public :
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTPXParsedFunctionLineGraph ( JKQTBasePlotter * parent = nullptr ) ;
2015-08-02 19:36:54 +08:00
/** \brief class constructor */
2019-01-20 23:15:10 +08:00
JKQTPXParsedFunctionLineGraph ( JKQTPlotter * parent ) ;
2015-08-02 19:36:54 +08:00
2015-07-11 18:56:02 +08:00
/** \brief class destructor */
2019-01-20 17:49:29 +08:00
virtual ~ JKQTPXParsedFunctionLineGraph ( ) override ;
2015-07-11 18:56:02 +08:00
2019-01-10 04:23:24 +08:00
/*! \brief sets the property function to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter function is : < BLOCKQUOTE > \ copydoc function < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see function for more information */
inline virtual void set_function ( const QString & __value )
{
this - > function = __value ;
}
/*! \brief returns the property function.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter function is : < BLOCKQUOTE > \ copydoc function < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see function for more information */
inline virtual QString get_function ( ) const
{
return this - > function ;
}
/*! \brief sets the property errorFunction to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorFunction is : < BLOCKQUOTE > \ copydoc errorFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorFunction for more information */
inline virtual void set_errorFunction ( const QString & __value )
{
this - > errorFunction = __value ;
}
/*! \brief returns the property errorFunction.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorFunction is : < BLOCKQUOTE > \ copydoc errorFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorFunction for more information */
inline virtual QString get_errorFunction ( ) const
{
return this - > errorFunction ;
}
2015-07-11 18:56:02 +08:00
2018-12-24 03:27:24 +08:00
/** \brief INTERNAL data structure
* \ internal
*/
2019-01-20 17:49:29 +08:00
struct JKQTPXParsedFunctionLineGraphFunctionData {
2018-12-24 03:27:24 +08:00
JKQTPMathParser * parser ;
JKQTPMathParser : : jkmpNode * node ;
int varcount ;
} ;
2015-07-11 18:56:02 +08:00
2018-12-24 03:27:24 +08:00
protected :
/** \brief the function to be evaluated for the plot. Use \c x as the free variable, e.g. \c "x^2+2" */
2015-07-11 18:56:02 +08:00
QString function ;
2019-01-20 17:49:29 +08:00
JKQTPXParsedFunctionLineGraphFunctionData fdata ;
2015-07-11 18:56:02 +08:00
2018-12-24 03:27:24 +08:00
/** \brief the function to be evaluated to add error indicators to the graph. This function is evaluated to an error for every x. Use \c x as the free variable, e.g. \c "x^2+2". */
2015-07-11 18:56:02 +08:00
QString errorFunction ;
2019-01-20 17:49:29 +08:00
JKQTPXParsedFunctionLineGraphFunctionData efdata ;
2015-07-11 18:56:02 +08:00
2018-12-24 22:07:14 +08:00
// hide functions that should not be used in this class!
2019-01-26 03:16:04 +08:00
using JKQTPXFunctionLineGraph : : setPlotFunction ;
2019-01-20 17:49:29 +08:00
using JKQTPXFunctionLineGraph : : set_params ;
using JKQTPXFunctionLineGraph : : set_errorPlotFunction ;
using JKQTPXFunctionLineGraph : : set_errorParams ;
2018-12-24 22:07:14 +08:00
/** \brief fill the data array with data from the function plotFunction */
2018-12-28 05:52:00 +08:00
virtual void createPlotData ( bool collectParams = true ) override ;
2018-12-24 22:07:14 +08:00
/** \brief implements the actual plot function */
2019-01-20 17:49:29 +08:00
static double JKQTPXParsedFunctionLineGraphFunction ( double x , void * data ) ;
2018-12-24 22:07:14 +08:00
} ;
/*! \brief This implements line plots where the data is taken from a user supplied function \f$ x=f(y) \f$ The function is defined as a string and parsed by JKMathParser
2019-01-13 01:53:16 +08:00
\ ingroup jkqtplotter_parsedFgraphs
2018-12-24 22:07:14 +08:00
Additional function parameters may be given in the vector parameters . They are accessible in the function as \ c p1 , \ c p2 , \ c p3 , . . .
Parameters may also be given from a data column . Then first the params from the column and the the parameters from the vector are numbered .
Use the variable \ c y in an equation to refer to the free parameter of the curve ( \ c is also understood for convenience ) .
*/
2019-01-20 17:49:29 +08:00
class LIB_EXPORT JKQTPYParsedFunctionLineGraph : public JKQTPYFunctionLineGraph {
2018-12-24 22:07:14 +08:00
Q_OBJECT
public :
/** \brief class constructor */
2019-01-20 17:49:29 +08:00
JKQTPYParsedFunctionLineGraph ( JKQTBasePlotter * parent = nullptr ) ;
2018-12-24 22:07:14 +08:00
/** \brief class constructor */
2019-01-20 23:15:10 +08:00
JKQTPYParsedFunctionLineGraph ( JKQTPlotter * parent ) ;
2018-12-24 22:07:14 +08:00
/** \brief class destructor */
2019-01-20 17:49:29 +08:00
virtual ~ JKQTPYParsedFunctionLineGraph ( ) override ;
2018-12-24 22:07:14 +08:00
2019-01-10 04:23:24 +08:00
/*! \brief sets the property function to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter function is : < BLOCKQUOTE > \ copydoc function < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see function for more information */
inline virtual void set_function ( const QString & __value )
{
this - > function = __value ;
}
/*! \brief returns the property function.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter function is : < BLOCKQUOTE > \ copydoc function < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see function for more information */
inline virtual QString get_function ( ) const
{
return this - > function ;
}
/*! \brief sets the property errorFunction to the specified \a __value.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorFunction is : < BLOCKQUOTE > \ copydoc errorFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorFunction for more information */
inline virtual void set_errorFunction ( const QString & __value )
{
this - > errorFunction = __value ;
}
/*! \brief returns the property errorFunction.
2019-01-25 05:49:10 +08:00
\ details Description of the parameter errorFunction is : < BLOCKQUOTE > \ copydoc errorFunction < / BLOCKQUOTE >
2019-01-10 04:23:24 +08:00
\ see errorFunction for more information */
inline virtual QString get_errorFunction ( ) const
{
return this - > errorFunction ;
}
2018-12-24 22:07:14 +08:00
/** \brief INTERNAL data structure
* \ internal
*/
2019-01-20 17:49:29 +08:00
struct JKQTPYParsedFunctionLineGraphFunctionData {
2018-12-24 22:07:14 +08:00
JKQTPMathParser * parser ;
JKQTPMathParser : : jkmpNode * node ;
int varcount ;
} ;
protected :
/** \brief the function to be evaluated for the plot. Use \c x as the free variable, e.g. \c "x^2+2" */
QString function ;
2019-01-20 17:49:29 +08:00
JKQTPYParsedFunctionLineGraphFunctionData fdata ;
2018-12-24 22:07:14 +08:00
/** \brief the function to be evaluated to add error indicators to the graph. This function is evaluated to an error for every x. Use \c x as the free variable, e.g. \c "x^2+2". */
QString errorFunction ;
2019-01-20 17:49:29 +08:00
JKQTPYParsedFunctionLineGraphFunctionData efdata ;
2018-12-24 22:07:14 +08:00
// hide functions that should not be used in this class!
2019-01-26 03:16:04 +08:00
using JKQTPXFunctionLineGraph : : setPlotFunction ;
2019-01-20 17:49:29 +08:00
using JKQTPXFunctionLineGraph : : set_params ;
using JKQTPXFunctionLineGraph : : set_errorPlotFunction ;
using JKQTPXFunctionLineGraph : : set_errorParams ;
2015-07-11 18:56:02 +08:00
/** \brief fill the data array with data from the function plotFunction */
2018-12-28 05:52:00 +08:00
virtual void createPlotData ( bool collectParams = true ) override ;
2018-12-24 22:07:14 +08:00
/** \brief implements the actual plot function */
2019-01-20 17:49:29 +08:00
static double JKQTPYParsedFunctionLineGraphFunction ( double x , void * data ) ;
2015-07-11 18:56:02 +08:00
} ;
2018-12-19 00:13:18 +08:00
# endif // jkqtpgraphsparsedfunction_H