1 /****************************************************************************
2 **  Copyright (c) 2019, Adel Kara Slimane <adel.ks@zegrapher.com>
3 **
4 **  This file is part of ZeGrapher's source code.
5 **
6 **  ZeGrapher is free software: you may copy, redistribute and/or modify it
7 **  under the terms of the GNU General Public License as published by the
8 **  Free Software Foundation, either version 3 of the License, or (at your
9 **  option) any later version.
10 **
11 **  This file is distributed in the hope that it will be useful, but
12 **  WITHOUT ANY WARRANTY; without even the implied warranty of
13 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 **  General Public License for more details.
15 **
16 **  You should have received a copy of the GNU General Public License
17 **  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 **
19 ****************************************************************************/
20 
21 #ifndef GRAPHDRAW_H
22 #define GRAPHDRAW_H
23 
24 #include <QWidget>
25 
26 #include "structures.h"
27 #include "Calculus/funccalculator.h"
28 #include "Widgets/tangentwidget.h"
29 #include "Widgets/straightlinewidget.h"
30 #include "Widgets/pareqwidget.h"
31 #include "information.h"
32 #include "Calculus/funcvaluessaver.h"
33 #include "Calculus/regressionvaluessaver.h"
34 #include "GraphDraw/viewmapper.h"
35 
36 
37 class MathObjectDraw : public QWidget // Base class from math objects drawing
38 {
39     Q_OBJECT
40 public:
41     explicit MathObjectDraw(Information *info);
42     ~MathObjectDraw();
43 
44 protected slots:
45     void addRegSaver(Regression *reg);
46     void delRegSaver(Regression *reg);
47     void updateSettingsVals();
48 
49 protected:
50 
51     inline void drawRhombus(QPointF pt,double w);
52     inline void drawDisc(QPointF pt, double w);
53     inline void drawSquare(QPointF pt, double w);
54     inline void drawTriangle(QPointF pt, double w);
55     inline void drawCross(QPointF pt, double w);
56 
57     void drawOneSequence(int id, int width);
58     void drawDataSet(int id, int width);
59     void drawCurve(int width, QColor color, const QPolygonF &curve);
60     void drawCurve(int width, QColor color, const QList<QPolygonF> &curves);
61     void drawOneTangent(int id);
62 
63     void drawFunctions();
64     void drawRegressions();
65     void drawData();
66     void drawSequences();
67     void drawTangents(); //except the one pointed by tangentDrawException
68     void drawStraightLines();
69     void drawStaticParEq();
70 
71     void recalculateRegVals();
72 
73     Information *information;
74     FuncValuesSaver *funcValuesSaver;
75     QList<RegressionValuesSaver> regValuesSavers;
76     QPainter painter;
77     ZeViewSettings viewSettings;
78 
79     QPolygonF polygon;
80     QPen pen;
81     QBrush brush;
82     Point centre;
83     ZeViewMapper viewMapper;
84 
85     double coef;
86 
87     double uniteX, uniteY;
88     bool moving, recalculate, recalculateRegs;
89     int tangentDrawException;
90 
91     QList<FuncCalculator*> funcs;
92     QList<SeqCalculator*> seqs;
93     QList<StraightLineWidget*> *straightLines;
94     QList<TangentWidget*> *tangents;
95     QList<ParEqWidget*> *parEqs;
96     QList< QList<double> > *regVals;
97 
98     QFont font;
99 };
100 
101 #endif // GRAPHDRAW_H
102