dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
mixercurvepoint.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 MIXERCURVEPOINT_H
29 #define MIXERCURVEPOINT_H
30 
32 
33 #include <QGraphicsItem>
34 #include <QColor>
35 #include <QList>
36 #include <QFont>
37 
38 class Edge;
39 class MixerCurveWidget;
40 QT_BEGIN_NAMESPACE
41 class QGraphicsSceneMouseEvent;
42 QT_END_NAMESPACE
43 
44 class UAVOBJECTWIDGETUTILS_EXPORT MixerNode : public QObject, public QGraphicsItem
45 {
46  Q_OBJECT
47  Q_INTERFACES(QGraphicsItem)
48 public:
49  MixerNode(MixerCurveWidget *graphWidget);
50  void addEdge(Edge *edge);
51  QList<Edge *> edges() const;
52 
53  enum { Type = UserType + 10 };
54  int type() const { return Type; }
55 
56  void setName(QString name) { cmdName = name; }
57  const QString &getName() { return cmdName; }
58 
59  void verticalMove(bool flag);
60  void commandNode(bool enable);
61  void commandText(QString text);
62  int getCommandIndex() { return index; }
63  void setCommandIndex(int idx) { index = idx; }
64 
65  bool getCommandActive() { return cmdActive; }
66  void setCommandActive(bool enable) { cmdActive = enable; }
67  void setToggle(bool enable) { cmdToggle = enable; }
68  bool getToggle() { return cmdToggle; }
69 
70  void setPositiveColor(QString color0 = "#00ff00", QString color1 = "#00ff00")
71  {
72  posColor0 = color0;
73  posColor1 = color1;
74  }
75  void setNegativeColor(QString color0 = "#ff0000", QString color1 = "#ff0000")
76  {
77  negColor0 = color0;
78  negColor1 = color1;
79  }
80  void setImage(QImage img) { image = img; }
81  void setDrawNode(bool draw) { drawNode = draw; }
82  void setDrawText(bool draw) { drawText = draw; }
83 
84  QRectF boundingRect() const;
85  QPainterPath shape() const;
86  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
87 
88  double value();
89 
90 signals:
91  void commandActivated(QString text);
92 
93 protected:
94  QVariant itemChange(GraphicsItemChange change, const QVariant &val);
95 
96  void mousePressEvent(QGraphicsSceneMouseEvent *event);
97  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
98 
99 private:
100  QList<Edge *> edgeList;
101  QPointF newPos;
102  MixerCurveWidget *graph;
103  QString posColor0;
104  QString posColor1;
105  QString negColor0;
106  QString negColor1;
107  QImage image;
108 
109  bool vertical;
110  QString cmdName;
111  bool cmdActive;
112  bool cmdNode;
113  bool cmdToggle;
114  QString cmdText;
115  bool drawNode;
116  bool drawText;
117  int index;
118 };
119 
120 #endif // MIXERCURVEPOINT_H