Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / config / configstabilizationwidget.h
blob525f66c3967f17f427278cd72d265c077641c1e2
1 /**
2 ******************************************************************************
4 * @file configstabilizationwidget.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup ConfigPlugin Config Plugin
10 * @{
11 * @brief Stabilization configuration panel
12 *****************************************************************************/
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.
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.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef CONFIGSTABILIZATIONWIDGET_H
29 #define CONFIGSTABILIZATIONWIDGET_H
31 #include "../uavobjectwidgetutils/configtaskwidget.h"
33 #include "uavobject.h"
35 #include "qwt/src/qwt_plot_curve.h"
36 #include "qwt/src/qwt_plot_grid.h"
38 #include <QTimer>
39 #include <QSignalMapper>
41 class Ui_StabilizationWidget;
43 class QWidget;
44 class QTabBar;
46 class ConfigStabilizationWidget : public ConfigTaskWidget {
47 Q_OBJECT
49 public:
50 ConfigStabilizationWidget(QWidget *parent = 0);
51 ~ConfigStabilizationWidget();
53 bool shouldObjectBeSaved(UAVObject *object);
55 protected:
56 QString mapObjectName(const QString objectName);
58 virtual void refreshWidgetsValuesImpl(UAVObject *obj);
59 virtual void updateObjectsFromWidgetsImpl();
61 private:
62 Ui_StabilizationWidget *ui;
63 QTimer *realtimeUpdates;
64 QList<QTabBar *> m_stabTabBars;
65 QString m_stabilizationObjectsString;
67 // Milliseconds between automatic 'Instant Updates'
68 static const int AUTOMATIC_UPDATE_RATE = 500;
70 static const int EXPO_CURVE_POINTS_COUNT = 100;
71 constexpr static const double EXPO_CURVE_CONSTANT = 1.01395948;
73 int m_stabSettingsBankCount;
74 int m_currentStabSettingsBank;
76 QwtPlotCurve m_expoPlotCurveRoll;
77 QwtPlotCurve m_expoPlotCurvePitch;
78 QwtPlotCurve m_expoPlotCurveYaw;
79 QwtPlotGrid m_plotGrid;
81 QSignalMapper m_bankActionSignalMapper;
83 UAVObject *getStabBankObject(int bank);
85 void updateThrottleCurveFromObject();
86 void updateObjectFromThrottleCurve();
87 void setupExpoPlot();
88 void setupStabBanksGUI();
89 void resetBank(int bank);
90 void restoreBank(int bank);
91 void copyBank(int fromBank, int toBank);
92 void swapBank(int fromBank, int toBank);
94 private slots:
95 void enableControlsChanged(bool enable);
97 void realtimeUpdatesSlot(bool value);
98 void linkCheckBoxes(bool value);
99 void processLinkedWidgets(QWidget *);
100 void stabBankChanged(int index);
101 void resetThrottleCurveToDefault();
102 void throttleCurveUpdated();
103 void replotExpo(int value, QwtPlotCurve &curve);
104 void replotExpoRoll(int value);
105 void replotExpoPitch(int value);
106 void replotExpoYaw(int value);
108 void bankAction(const QString &mapping);
110 #endif // ConfigStabilizationWidget_H