2015-07-11 18:56:02 +08:00
/*
2018-11-25 21:53:26 +08:00
Copyright ( c ) 2008 - 2018 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
class JKQtBasePlotter ;
2015-08-02 19:36:54 +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
\ ingroup jkqtplotter_plots
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 .
*/
class LIB_EXPORT JKQTPxParsedFunctionLineGraph : public JKQTPxFunctionLineGraph {
Q_OBJECT
public :
/** \brief class constructor */
2018-11-18 18:59:30 +08:00
JKQTPxParsedFunctionLineGraph ( JKQtBasePlotter * parent = nullptr ) ;
2015-08-02 19:36:54 +08:00
/** \brief class constructor */
JKQTPxParsedFunctionLineGraph ( JKQtPlotter * parent ) ;
2015-07-11 18:56:02 +08:00
/** \brief class destructor */
2015-08-02 19:36:54 +08:00
virtual ~ JKQTPxParsedFunctionLineGraph ( ) ;
2015-07-11 18:56:02 +08:00
JKQTPGET_SET_MACRO ( QList < double > , parameters )
JKQTPGET_SET_MACRO ( QString , function )
JKQTPGET_SET_MACRO ( QList < double > , errorParameters )
JKQTPGET_SET_MACRO ( QString , errorFunction )
2018-12-24 03:27:24 +08:00
/** \brief INTERNAL data structure
* \ internal
*/
struct JKQTPxParsedFunctionLineGraphFunctionData {
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 ;
2018-12-24 03:27:24 +08:00
/** \brief values of the parameters \c p1 , \c p2 , \c p3 , ... */
2015-07-11 18:56:02 +08:00
QList < double > parameters ;
JKQTPxParsedFunctionLineGraphFunctionData fdata ;
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 ;
2018-12-24 03:27:24 +08:00
/** \brief values of the parameters \c p1 , \c p2 , \c p3 , ... for the error function*/
2015-07-11 18:56:02 +08:00
QList < double > errorParameters ;
JKQTPxParsedFunctionLineGraphFunctionData efdata ;
2018-12-24 03:27:24 +08:00
virtual void set_plotFunction ( jkqtpPlotFunctionType & & f ) ;
virtual void set_plotFunction ( const jkqtpPlotFunctionType & f ) ;
2015-07-11 18:56:02 +08:00
JKQTPGET_SET_MACRO_I ( void * , params , clearData ( ) )
JKQTPGET_SET_MACRO ( jkqtpPlotFunctionType , errorPlotFunction )
JKQTPGET_SET_MACRO ( void * , errorParams )
/** \brief fill the data array with data from the function plotFunction */
virtual void createPlotData ( bool collectParams = true ) ;
} ;
2018-12-19 00:13:18 +08:00
# endif // jkqtpgraphsparsedfunction_H