File indexing completed on 2022-09-20 12:13:55

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 #include "functiongraph.h"
0021 
0022 #include "private/abstractfunctiongraph.h"
0023 #include "private/functiongraphfactory.h"
0024 
0025 using namespace Analitza;
0026 
0027 FunctionGraph::FunctionGraph(AbstractFunctionGraph *g)
0028     : PlotItem(QStringLiteral("123123213123"), Qt::black)
0029     , m_functionGraph(g)
0030 {
0031     Q_ASSERT(m_functionGraph);
0032 }
0033 
0034 FunctionGraph::~FunctionGraph()
0035 {
0036     delete m_functionGraph;
0037 }
0038 
0039 QString FunctionGraph::typeName() const
0040 {
0041     Q_ASSERT(m_functionGraph);
0042     return m_functionGraph->typeName();
0043 }
0044 
0045 QString FunctionGraph::display() const
0046 {
0047     return m_display;
0048 }
0049 
0050 void FunctionGraph::setDisplay(const QString& display)
0051 {
0052     m_display = display;
0053 }
0054 
0055 const Analitza::Expression& FunctionGraph::expression() const
0056 {
0057     Q_ASSERT(m_functionGraph);
0058     
0059     return m_functionGraph->expression();
0060 }
0061 
0062 Analitza::Variables* FunctionGraph::variables() const
0063 {
0064     Q_ASSERT(m_functionGraph);
0065     
0066     return m_functionGraph->variables();
0067 }
0068 
0069 QString FunctionGraph::iconName() const
0070 {
0071     Q_ASSERT(m_functionGraph);
0072     
0073     return m_functionGraph->iconName();
0074 }
0075 
0076 Dimension FunctionGraph::spaceDimension() const
0077 {
0078     Q_ASSERT(m_functionGraph);
0079     
0080     return m_functionGraph->spaceDimension();
0081 }
0082 
0083 CoordinateSystem FunctionGraph::coordinateSystem() const
0084 {
0085     Q_ASSERT(m_functionGraph);
0086     
0087     return m_functionGraph->coordinateSystem();
0088 }
0089 
0090 QStringList FunctionGraph::errors() const
0091 {
0092     Q_ASSERT(m_functionGraph);
0093     
0094     QStringList err(m_errors);
0095     err += m_functionGraph->errors();
0096     return err;
0097 }
0098 
0099 bool FunctionGraph::isCorrect() const
0100 {
0101     Q_ASSERT(m_functionGraph);
0102 
0103     return m_errors.isEmpty() && m_functionGraph && m_functionGraph->isCorrect();
0104 }
0105 
0106 QPair<Analitza::Expression, Analitza::Expression> FunctionGraph::interval(const QString &argname, bool evaluate) const
0107 {
0108     Q_ASSERT(m_functionGraph);
0109     
0110     return m_functionGraph->interval(argname, evaluate);
0111 }
0112 
0113 bool FunctionGraph::setInterval(const QString &argname, const Analitza::Expression &min, const Analitza::Expression &max)
0114 {
0115     Q_ASSERT(m_functionGraph);
0116     
0117     bool ret = m_functionGraph->setInterval(argname, min, max);
0118     
0119     if (ret)
0120         emitDataChanged();
0121     
0122     return ret;
0123 }
0124 
0125 QPair<double, double> FunctionGraph::interval(const QString &argname) const
0126 {
0127     Q_ASSERT(m_functionGraph);
0128 
0129     return m_functionGraph->interval(argname);
0130 }
0131 
0132 bool FunctionGraph::setInterval(const QString &argname, double min, double max)
0133 {
0134     Q_ASSERT(m_functionGraph);
0135     
0136     bool ret = m_functionGraph->setInterval(argname, min, max);
0137 
0138     if (ret)
0139         emitDataChanged();
0140     
0141     return ret;
0142 }
0143 
0144 void FunctionGraph::clearIntervals()
0145 {
0146     m_functionGraph->clearIntervals();
0147 }
0148 
0149 bool FunctionGraph::hasIntervals() const
0150 {
0151     return m_functionGraph->hasIntervals();
0152 }
0153 
0154 QStringList FunctionGraph::parameters() const
0155 {
0156     Q_ASSERT(m_functionGraph);
0157     return m_functionGraph->parameters();
0158 }
0159 
0160 void FunctionGraph::setResolution(int resolution)
0161 {
0162     Q_ASSERT(m_functionGraph);
0163     return m_functionGraph->setResolution(resolution);
0164 }