LP-56 - Better txpid option namings, fix tabs-spaces, tooltips. headers, variable...
[librepilot.git] / ground / openpilotgcs / src / plugins / config / configstabilizationwidget.h
blob1698af188ad68b1e846e37fd72d259a6a9abb09e
1 /**
2 ******************************************************************************
4 * @file configstabilizationwidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup ConfigPlugin Config Plugin
9 * @{
10 * @brief Stabilization configuration panel
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
27 #ifndef CONFIGSTABILIZATIONWIDGET_H
28 #define CONFIGSTABILIZATIONWIDGET_H
30 #include "ui_stabilization.h"
31 #include "../uavobjectwidgetutils/configtaskwidget.h"
32 #include "extensionsystem/pluginmanager.h"
33 #include "uavobjectmanager.h"
34 #include "uavobject.h"
35 #include "stabilizationsettings.h"
36 #include <QWidget>
37 #include <QTimer>
38 #include <QSignalMapper>
39 #include "qwt/src/qwt_plot_curve.h"
40 #include "qwt/src/qwt_plot_grid.h"
42 class ConfigStabilizationWidget : public ConfigTaskWidget {
43 Q_OBJECT
45 public:
46 ConfigStabilizationWidget(QWidget *parent = 0);
47 ~ConfigStabilizationWidget();
48 bool shouldObjectBeSaved(UAVObject *object);
50 private:
51 Ui_StabilizationWidget *ui;
52 QTimer *realtimeUpdates;
53 QList<QTabBar *> m_stabTabBars;
54 QString m_stabilizationObjectsString;
56 // Milliseconds between automatic 'Instant Updates'
57 static const int AUTOMATIC_UPDATE_RATE = 500;
59 static const int EXPO_CURVE_POINTS_COUNT = 100;
60 static const double EXPO_CURVE_CONSTANT = 1.00695;
62 int boardModel;
63 int m_stabSettingsBankCount;
64 int m_currentStabSettingsBank;
66 QwtPlotCurve m_expoPlotCurveRoll;
67 QwtPlotCurve m_expoPlotCurvePitch;
68 QwtPlotCurve m_expoPlotCurveYaw;
69 QwtPlotGrid m_plotGrid;
70 QSignalMapper m_stabSettingsCopyFromSignalMapper;
71 QSignalMapper m_stabSettingsCopyToSignalMapper;
72 QSignalMapper m_stabSettingsSwapSignalMapper;
74 UAVObject *getStabBankObject(int bank);
76 void updateThrottleCurveFromObject();
77 void updateObjectFromThrottleCurve();
78 void setupExpoPlot();
79 void setupStabBanksGUI();
80 void resetStabBank(int bank);
81 void restoreStabBank(int bank);
83 protected:
84 QString mapObjectName(const QString objectName);
86 protected slots:
87 void refreshWidgetsValues(UAVObject *o = NULL);
88 void updateObjectsFromWidgets();
90 private slots:
91 void realtimeUpdatesSlot(bool value);
92 void linkCheckBoxes(bool value);
93 void processLinkedWidgets(QWidget *);
94 void onBoardConnected();
95 void stabBankChanged(int index);
96 void resetThrottleCurveToDefault();
97 void throttleCurveUpdated();
98 void replotExpo(int value, QwtPlotCurve &curve);
99 void replotExpoRoll(int value);
100 void replotExpoPitch(int value);
101 void replotExpoYaw(int value);
103 void restoreAllStabBanks();
104 void resetAllStabBanks();
105 void restoreCurrentAction();
106 void resetCurrentStabBank();
107 void copyCurrentStabBank();
109 void copyFromBankToBank(int fromBank, int toBank);
110 void copyFromBankToCurrent(int bank);
111 void copyToBankFromCurrent(int bank);
112 void swapBankAndCurrent(int bank);
114 #endif // ConfigStabilizationWidget_H