dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
mixercurvewidget.h
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #ifndef MIXERCURVEWIDGET_H_
29 #define MIXERCURVEWIDGET_H_
30 
32 
33 #include <QObject>
34 #include <QGraphicsView>
35 #include <QSvgRenderer>
36 #include <QGraphicsSvgItem>
37 #include <QPointer>
38 
39 class Edge;
40 class MixerNode;
41 
42 class UAVOBJECTWIDGETUTILS_EXPORT MixerCurveWidget : public QGraphicsView
43 {
44  Q_OBJECT
45 
46 public:
47  MixerCurveWidget(QWidget *parent = nullptr);
49 
50  friend class MixerCurve;
51 
52  void itemMoved(double itemValue); // Callback when a point is moved, to be updated
53  void initCurve(const QList<double> *points);
55  void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0);
56  void setCurve(const QList<double> *points);
57  void setMin(double value);
58  double getMin();
59  void setMax(double value);
60  double getMax();
61  double setRange(double min, double max);
62 
63  void cmdActivated(MixerNode *node);
64  void activateCommand(const QString &name);
65  bool isCommandActive(const QString &name);
66  void showCommand(const QString &name, bool show);
67  void showCommands(bool show);
68  MixerNode *getCmdNode(const QString &name);
69  void setCommandText(const QString &name, const QString &text);
70 
71  static const int NODE_NUMELEM = 5;
72 
73 signals:
74  void curveUpdated();
75  void curveMinChanged(double value);
76  void curveMaxChanged(double value);
77  void commandActivated(MixerNode *node);
78 
79 private slots:
80 
81 private:
82  QGraphicsSvgItem *plot;
83 
84  QList<MixerNode *> nodePool;
85  QList<MixerNode *> cmdNodePool;
86  QList<Edge *> edgePool;
87  QList<MixerNode *> nodeList;
88 
89  double curveMin;
90  double curveMax;
91  bool curveUpdating;
92 
93  QString posColor0;
94  QString posColor1;
95  QString negColor0;
96  QString negColor1;
97 
98  void initNodes(int numPoints);
99  MixerNode *getNode(int index);
100  MixerNode *getCommandNode(int index);
101  Edge *getEdge(int index, MixerNode *sourceNode, MixerNode *destNode);
102  void setPositiveColor(QString color0 = "#00ff00", QString color1 = "#00ff00");
103  void setNegativeColor(QString color0 = "#ff0000", QString color1 = "#ff0000");
104 
105  void resizeCommands();
106 
107 protected:
108  void showEvent(QShowEvent *event);
109  void resizeEvent(QResizeEvent *event);
110 };
111 #endif /* MIXERCURVEWIDGET_H_ */
void setMin(double value)
Definition: mixercurve.cpp:301
void initLinearCurve(int numPoints, double maxValue=1, double minValue=0)
Definition: mixercurve.cpp:286
void setMax(double value)
Definition: mixercurve.cpp:310
void showEvent(QShowEvent *event)
Definition: mixercurve.cpp:431
double getMax()
Definition: mixercurve.cpp:315
double getMin()
Definition: mixercurve.cpp:306
void initCurve(const QList< double > *points)
Definition: mixercurve.cpp:277
void setCurve(const QList< double > *points)
Definition: mixercurve.cpp:296
double setRange(double min, double max)
Definition: mixercurve.cpp:319
void resizeEvent(QResizeEvent *event)
Definition: mixercurve.cpp:446
QList< double > getCurve()
Definition: mixercurve.cpp:282
plot(TimeVA, VA(1,:), TimeVA, VA(2,:), TimeGPSPos, Vgps(1,:), TimeGPSPos, Vgps(2,:))