LP-56 - Better txpid option namings, fix tabs-spaces, tooltips. headers, variable...
[librepilot.git] / ground / openpilotgcs / src / plugins / uavobjectwidgetutils / mixercurvewidget.h
blob24ff448a78a1a1e8886074a8225db60b2a899c4e
1 /**
2 ******************************************************************************
4 * @file mixercurvewidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup UAVObjectWidgetUtils Plugin
9 * @{
10 * @brief Utility plugin for UAVObject to Widget relation management
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef MIXERCURVEWIDGET_H_
29 #define MIXERCURVEWIDGET_H_
31 #include <QObject>
32 #include <QGraphicsView>
33 #include <QtSvg/QSvgRenderer>
34 #include <QtSvg/QGraphicsSvgItem>
35 #include <QtCore/QPointer>
36 #include "mixercurvepoint.h"
37 #include "mixercurveline.h"
38 #include "uavobjectwidgetutils_global.h"
40 class UAVOBJECTWIDGETUTILS_EXPORT MixerCurveWidget : public QGraphicsView {
41 Q_OBJECT
43 public:
44 static const int NODE_NUMELEM = 5;
46 MixerCurveWidget(QWidget *parent = 0);
47 ~MixerCurveWidget();
49 friend class MixerCurve;
51 void itemMoved(double itemValue); // Callback when a point is moved, to be updated
52 void initCurve(const QList<double> *points);
53 QList<double> getCurve();
54 void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0);
55 void setCurve(const QList<double> *points);
56 void setMin(double value);
57 double getMin();
58 void setMax(double value);
59 double getMax();
60 double setRange(double min, double max);
62 public slots:
63 void setXAxisLabel(QString label);
64 void setYAxisLabel(QString label);
66 signals:
67 void curveUpdated();
68 void curveMinChanged(double value);
69 void curveMaxChanged(double value);
71 protected:
72 void showEvent(QShowEvent *event);
73 void resizeEvent(QResizeEvent *event);
74 void changeEvent(QEvent *event);
76 private slots:
77 void positionAxisLabels();
79 private:
80 QGraphicsSvgItem *m_plot;
81 QGraphicsTextItem *m_xAxisTextItem;
82 QGraphicsTextItem *m_yAxisTextItem;
84 QList<Edge *> m_edgeList;
85 QList<MixerNode *> m_nodeList;
87 QString m_xAxisString;
88 QString m_yAxisString;
90 double m_curveMin;
91 double m_curveMax;
92 bool m_curveUpdating;
94 void initNodes(int numPoints);
95 void setupXAxisLabel();
96 void setupYAxisLabel();
97 void setPositiveColor(QString color);
98 void setNegativeColor(QString color);
100 void resizeCommands();
102 #endif /* MIXERCURVEWIDGET_H_ */