File indexing completed on 2024-04-14 14:07:53

0001 /*************************************************************************************
0002  *  Copyright (C) 2007-2009 by Aleix Pol <aleixpol@kde.org>                          *
0003  *  Copyright (C) 2010-2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> *
0004  *                                                                                   *
0005  *  This program is free software; you can redistribute it and/or                    *
0006  *  modify it under the terms of the GNU General Public License                      *
0007  *  as published by the Free Software Foundation; either version 2                   *
0008  *  of the License, or (at your option) any later version.                           *
0009  *                                                                                   *
0010  *  This program is distributed in the hope that it will be useful,                  *
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0013  *  GNU General Public License for more details.                                     *
0014  *                                                                                   *
0015  *  You should have received a copy of the GNU General Public License                *
0016  *  along with this program; if not, write to the Free Software                      *
0017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0018  *************************************************************************************/
0019 
0020 #ifndef FUNCTIONGRAPH2_H
0021 #define FUNCTIONGRAPH2_H
0022 
0023 #include "plotitem.h"
0024 #include <QPair>
0025 
0026 namespace Analitza
0027 {
0028 
0029 /**
0030  * \class FunctionGraph
0031  * 
0032  * \ingroup AnalitzaPlotModule
0033  *
0034  * \brief Base class for any object that is a lambda expression.
0035  *
0036  * This class is a common interface for functions objects.
0037  */
0038 
0039 class AbstractFunctionGraph;
0040 
0041 class ANALITZAPLOT_EXPORT FunctionGraph : public PlotItem
0042 {
0043 public:
0044     ~FunctionGraph() override;
0045 
0046     Analitza::Variables *variables() const override;
0047     
0048     //MappingGraph
0049     QString typeName() const override;
0050     const Analitza::Expression &expression() const override;
0051     QString iconName() const override;
0052     Dimension spaceDimension() const override;
0053     CoordinateSystem coordinateSystem() const override;
0054     QStringList errors() const;
0055     bool isCorrect() const;
0056 
0057     //if evaluate true then result of expressiones will be strings of the value
0058     //if evaluate is false then the expressions will not evaluate
0059  
0060     QPair<Analitza::Expression, Analitza::Expression> interval(const QString &argname, bool evaluate) const;
0061     bool setInterval(const QString &argname, const Analitza::Expression &min, const Analitza::Expression &max);
0062 
0063     QPair<double, double> interval(const QString &argname) const;
0064     bool setInterval(const QString &argname, double min, double max);
0065     void clearIntervals();
0066     bool hasIntervals() const;
0067     
0068     /** @returns the parameters that a function expects */
0069     QStringList parameters() const;
0070 
0071     /**
0072      * The display property will store the expression like it's been entered by the user.
0073      * This is useful because sometimes the expression is modified when entered so that
0074      * we can plot it properly, this remembers what the user entered.
0075      */
0076     QString display() const override;
0077     void setDisplay(const QString& display);
0078     
0079     /** 
0080      * This method gives a hint to the backend of how many @p points we want the plots to have.
0081      * This is useful for telling the plot implementations an idea of where is this going to be plotted, so
0082      * we can use lighter computations if we're previewing or if we're in a small device.
0083      */
0084     void setResolution(int points);
0085     
0086 protected:
0087     FunctionGraph(AbstractFunctionGraph* g);
0088     AbstractFunctionGraph *backend() const { return m_functionGraph; }
0089 
0090 private:
0091     FunctionGraph(const FunctionGraph &other);
0092     
0093     AbstractFunctionGraph *m_functionGraph;
0094     QStringList m_errors;
0095     QString m_display;
0096 };
0097 
0098 }
0099 
0100 #endif // FUNCTIONGRAPH2_H