FunctionCurve.h
Go to the documentation of this file.
/***************************************************************************
File : FunctionCurve.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : Function curve class
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef FUNCTIONCURVE_H
#define FUNCTIONCURVE_H
#include "PlotCurve.h"
class Graph;
// Function curve class
class FunctionCurve: public PlotCurve
{
public:
enum FunctionType{Normal = 0, Parametric = 1, Polar = 2};
FunctionCurve(const FunctionType& t, const QString& name = QString());
FunctionCurve(const QString& name = QString());
double startRange(){return d_from;};
double endRange(){return d_to;};
void setRange(double from, double to);
QStringList formulas(){return d_formulas;};
void setFormulas(const QStringList& lst){d_formulas = lst;};
void setFormula(const QString& s){d_formulas = QStringList() << s;};
QString variable(){return d_variable;};
void setVariable(const QString& s){d_variable = s;};
FunctionType functionType(){return d_function_type;};
void setFunctionType(const FunctionType& t){d_function_type = t;};
void copy(FunctionCurve *f);
QString saveToString();
static void restore(Graph *g, const QStringList& lst);
QString legend();
bool loadData(int points = 0, bool xLog10Scale = false);
int parametersCount(){return d_constants.count();};
QString parameterName(int index);
double parameterValue(int index);
double parameterValue(const QString& name);
QMap<QString, double> constants(){return d_constants;};
void setConstants(const QMap<QString, double>& map){d_constants = map;};
void setConstant(const QString& parName, double val){d_constants.insert(parName, val);};
void removeConstant(const QString& parName){d_constants.remove(parName);};
void removeConstants(){d_constants.clear();};
private:
FunctionType d_function_type;
QString d_variable;
QStringList d_formulas;
double d_from, d_to;
QMap<QString, double> d_constants;
};
#endif
FunctionCurve::loadData
bool loadData(int points=0, bool xLog10Scale=false)
Definition: FunctionCurve.cpp:181
FunctionCurve::setConstants
void setConstants(const QMap< QString, double > &map)
Definition: FunctionCurve.h:83
FunctionCurve::removeConstants
void removeConstants()
Definition: FunctionCurve.h:86
FunctionCurve::removeConstant
void removeConstant(const QString &parName)
Definition: FunctionCurve.h:85
FunctionCurve::endRange
double endRange()
Definition: FunctionCurve.h:46
Graph
A 2D-plotting widget.
Definition: Graph.h:123
FunctionCurve::parameterValue
double parameterValue(int index)
Returns the value of the parameter of rang index.
Definition: FunctionCurve.cpp:346
FunctionCurve::d_formulas
QStringList d_formulas
Definition: FunctionCurve.h:91
FunctionCurve::d_to
double d_to
Definition: FunctionCurve.h:92
FunctionCurve::FunctionType
FunctionType
Definition: FunctionCurve.h:40
FunctionCurve::parametersCount
int parametersCount()
Returns the number of parameters in your function formula.
Definition: FunctionCurve.h:74
FunctionCurve::constants
QMap< QString, double > constants()
Definition: FunctionCurve.h:82
FunctionCurve::d_function_type
FunctionType d_function_type
Definition: FunctionCurve.h:86
PlotCurve.h
FunctionCurve::Polar
Definition: FunctionCurve.h:40
FunctionCurve::saveToString
QString saveToString()
Returns a string used when saving to a project file.
Definition: FunctionCurve.cpp:73
FunctionCurve::setFunctionType
void setFunctionType(const FunctionType &t)
Definition: FunctionCurve.h:59
FunctionCurve::formulas
QStringList formulas()
Definition: FunctionCurve.h:49
FunctionCurve::setVariable
void setVariable(const QString &s)
Definition: FunctionCurve.h:56
FunctionCurve::functionType
FunctionType functionType()
Definition: FunctionCurve.h:58
FunctionCurve::d_variable
QString d_variable
Definition: FunctionCurve.h:90
FunctionCurve::FunctionCurve
FunctionCurve(const FunctionType &t, const QString &name=QString())
Definition: FunctionCurve.cpp:48
FunctionCurve::setFormulas
void setFormulas(const QStringList &lst)
Definition: FunctionCurve.h:50
FunctionCurve
Definition: FunctionCurve.h:37
FunctionCurve::startRange
double startRange()
Definition: FunctionCurve.h:45
FunctionCurve::setConstant
void setConstant(const QString &parName, double val)
Definition: FunctionCurve.h:84
FunctionCurve::d_constants
QMap< QString, double > d_constants
Definition: FunctionCurve.h:93
FunctionCurve::parameterName
QString parameterName(int index)
Returns the name of the parameter of rang index.
Definition: FunctionCurve.cpp:329
FunctionCurve::setFormula
void setFormula(const QString &s)
Provided for convenience when dealing with normal functions.
Definition: FunctionCurve.h:53
FunctionCurve::variable
QString variable()
Definition: FunctionCurve.h:55
FunctionCurve::legend
QString legend()
Returns a string that can be displayed in a plot legend.
Definition: FunctionCurve.cpp:163
FunctionCurve::Normal
Definition: FunctionCurve.h:40
PlotCurve
Abstract 2D plot curve class.
Definition: PlotCurve.h:41
FunctionCurve::Parametric
Definition: FunctionCurve.h:40
FunctionCurve::d_from
double d_from
Definition: FunctionCurve.h:92
FunctionCurve::copy
void copy(FunctionCurve *f)
Definition: FunctionCurve.cpp:63
FunctionCurve::setRange
void setRange(double from, double to)
Definition: FunctionCurve.cpp:57
FunctionCurve::restore
static void restore(Graph *g, const QStringList &lst)
Used when reading from a project file.
Definition: FunctionCurve.cpp:99