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
9 * @addtogroup ConfigPlugin Config Plugin
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
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"
39 #include <QSignalMapper>
41 class Ui_StabilizationWidget
;
46 class ConfigStabilizationWidget
: public ConfigTaskWidget
{
50 ConfigStabilizationWidget(QWidget
*parent
= 0);
51 ~ConfigStabilizationWidget();
53 bool shouldObjectBeSaved(UAVObject
*object
);
56 QString
mapObjectName(const QString objectName
);
58 virtual void refreshWidgetsValuesImpl(UAVObject
*obj
);
59 virtual void updateObjectsFromWidgetsImpl();
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();
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
);
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