dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
configvehicletypewidget.h
Go to the documentation of this file.
1 
12 /*
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.
17  *
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.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 #ifndef CONFIGVEHICLETYPEWIDGET_H
27 #define CONFIGVEHICLETYPEWIDGET_H
28 
29 #include "ui_airframe.h"
30 #include "../uavobjectwidgetutils/configtaskwidget.h"
33 #include "uavobjects/uavobject.h"
35 
41 
42 #include <QWidget>
43 #include <QList>
44 #include <QItemDelegate>
45 
46 class Ui_Widget;
47 
49 {
50  Q_OBJECT
51 private:
52  enum {
53  AIRFRAME_FIXED_WING,
54  AIRFRAME_MULTIROTOR,
55  AIRFRAME_HELICOPTER,
56  AIRFRAME_GROUND,
57  AIRFRAME_CUSTOM
58  };
59 
60 public:
61  ConfigVehicleTypeWidget(QWidget *parent = nullptr);
63 
64  static QStringList getChannelDescriptions();
65 
66 private:
67  Ui_AircraftWidget *m_aircraft;
68 
69  ConfigCcpmWidget *m_heli;
70  ConfigFixedWingWidget *m_fixedwing;
71  ConfigMultiRotorWidget *m_multirotor;
72  ConfigGroundVehicleWidget *m_groundvehicle;
73 
74  void updateCustomAirframeUI();
75  void addToDirtyMonitor();
76  void resetField(UAVObjectField *field);
77 
78  // void setMixerChannel(int channelNumber, bool channelIsMotor, QList<double> vector);
79 
80  QStringList channelNames;
81  QStringList mixerTypes;
82  QStringList mixerVectors;
83 
84  QGraphicsSvgItem *quad;
85  UAVObject::Metadata accInitialData;
86  SystemSettings::AirframeTypeOptions frameType;
87 
88 private slots:
89 
90  virtual void refreshWidgetsValues(UAVObject *o = NULL);
91  virtual void updateObjectsFromWidgets();
92 
93  void setComboCurrentIndex(QComboBox *box, int index);
94 
95  void doSetupAirframeUI(int frameType);
96  void setupAirframeUI(SystemSettings::AirframeTypeOptions frameType);
97 
98  void toggleAileron2(int index);
99  void toggleElevator2(int index);
100  void toggleRudder2(int index);
101  void switchAirframeType(int index);
102 
103  void reverseMultirotorMotor();
104 
105  void bnLevelTrim_clicked();
106  void bnServoTrim_clicked();
107 
108 protected:
109  void showEvent(QShowEvent *event);
110  void resizeEvent(QResizeEvent *event);
111 };
112 
113 class SpinBoxDelegate : public QItemDelegate
114 {
115  Q_OBJECT
116 
117 public:
118  SpinBoxDelegate(QObject *parent = nullptr);
119 
120  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
121  const QModelIndex &index) const;
122 
123  void setEditorData(QWidget *editor, const QModelIndex &index) const;
124  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
125 
126  void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
127  const QModelIndex &index) const;
128 };
129 
130 #endif // CONFIGVEHICLETYPEWIDGET_H
ConfigVehicleTypeWidget(QWidget *parent=nullptr)
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
SpinBoxDelegate(QObject *parent=nullptr)
void showEvent(QShowEvent *event)
void setEditorData(QWidget *editor, const QModelIndex &index) const
void resizeEvent(QResizeEvent *event)
static QStringList getChannelDescriptions()
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const