File indexing completed on 2024-12-08 06:27:11

0001 /*************************************************************************************
0002 *  Copyright (C) 2012 by Aleix Pol <aleixpol@kde.org>                               *
0003 *                                                                                   *
0004 *  This program is free software; you can redistribute it and/or                    *
0005 *  modify it under the terms of the GNU General Public License                      *
0006 *  as published by the Free Software Foundation; either version 2                   *
0007 *  of the License, or (at your option) any later version.                           *
0008 *                                                                                   *
0009 *  This program is distributed in the hope that it will be useful,                  *
0010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0012 *  GNU General Public License for more details.                                     *
0013 *                                                                                   *
0014 *  You should have received a copy of the GNU General Public License                *
0015 *  along with this program; if not, write to the Free Software                      *
0016 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0017 *************************************************************************************/
0018 
0019 #ifndef PLOTSFACTORY_H
0020 #define PLOTSFACTORY_H
0021 
0022 #include "plottingenums.h"
0023 #include "analitzaplotexport.h"
0024 #include <analitza/expression.h>
0025 
0026 class QColor;
0027 
0028 namespace Analitza {
0029 class Variables;
0030 class FunctionGraph;
0031 
0032 class ANALITZAPLOT_EXPORT PlotBuilder
0033 {
0034     friend class PlotsFactory;
0035     public:
0036         QStringList errors() const { return m_errors; }
0037         bool canDraw() const;
0038         FunctionGraph* create(const QColor& color, const QString& name) const;
0039         Analitza::Expression expression() const;
0040         QString display() const;
0041         QSharedPointer<Variables> m_vars;
0042 
0043     protected:
0044         PlotBuilder();
0045         
0046         QString m_id;
0047         QStringList m_errors;
0048         Analitza::Expression m_expression;
0049         QString m_display;
0050 };
0051 
0052 class ANALITZAPLOT_EXPORT PlotsFactory
0053 {
0054     public:
0055         PlotsFactory();
0056         virtual ~PlotsFactory();
0057         
0058         static PlotsFactory* self();
0059         PlotBuilder requestPlot(const Analitza::Expression& expresssion, Dimension dim, const QSharedPointer<Variables> &vars = {}) const;
0060         QStringList examples(Dimensions s) const;
0061 
0062     private:
0063         QSharedPointer<Variables> m_vars;
0064 };
0065 
0066 }
0067 
0068 #endif // PLOTSFACTORY_H