dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
configfixedwingwidget.cpp
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 #include "actuatorcommand.h"
27 #include "configfixedwingwidget.h"
29 #include "mixersettings.h"
30 
31 #include <QDebug>
32 #include <QStringList>
33 #include <QWidget>
34 #include <QTextEdit>
35 #include <QVBoxLayout>
36 #include <QPushButton>
37 #include <QBrush>
38 #include <math.h>
39 
43 ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_AircraftWidget *aircraft, QWidget *parent)
44  : VehicleConfig(parent)
45 {
46  m_aircraft = aircraft;
47 }
48 
53 {
54  // Do nothing
55 }
56 
60 void ConfigFixedWingWidget::setupUI(SystemSettings::AirframeTypeOptions frameType)
61 {
62  Q_ASSERT(m_aircraft);
63 
64  if (frameType == SystemSettings::AIRFRAMETYPE_FIXEDWING) {
65  // Setup the UI
66  setComboCurrentIndex(m_aircraft->aircraftType,
67  m_aircraft->aircraftType->findText("Fixed Wing"));
68  setComboCurrentIndex(m_aircraft->fixedWingType,
69  m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
70  m_aircraft->fwRudder1ChannelBox->setEnabled(true);
71  m_aircraft->fwRudder1Label->setEnabled(true);
72  m_aircraft->fwRudder2ChannelBox->setEnabled(true);
73  m_aircraft->fwRudder2Label->setEnabled(true);
74  m_aircraft->fwElevator1ChannelBox->setEnabled(true);
75  m_aircraft->fwElevator1Label->setEnabled(true);
76  m_aircraft->fwElevator2ChannelBox->setEnabled(true);
77  m_aircraft->fwElevator2Label->setEnabled(true);
78  m_aircraft->fwAileron1ChannelBox->setEnabled(true);
79  m_aircraft->fwAileron1Label->setEnabled(true);
80  m_aircraft->fwAileron2ChannelBox->setEnabled(true);
81  m_aircraft->fwAileron2Label->setEnabled(true);
82 
83  m_aircraft->fwAileron1Label->setText("Aileron 1");
84  m_aircraft->fwAileron2Label->setText("Aileron 2");
85  m_aircraft->fwElevator1Label->setText("Elevator 1");
86  m_aircraft->fwElevator2Label->setText("Elevator 2");
87  m_aircraft->elevonMixBox->setHidden(true);
88 
89  } else if (frameType == SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON) {
90  setComboCurrentIndex(m_aircraft->aircraftType,
91  m_aircraft->aircraftType->findText("Fixed Wing"));
92  setComboCurrentIndex(m_aircraft->fixedWingType,
93  m_aircraft->fixedWingType->findText("Elevon"));
94  m_aircraft->fwAileron1Label->setText("Elevon 1");
95  m_aircraft->fwAileron2Label->setText("Elevon 2");
96  m_aircraft->fwElevator1ChannelBox->setEnabled(false);
97  m_aircraft->fwElevator1Label->setEnabled(false);
98  m_aircraft->fwElevator2ChannelBox->setEnabled(false);
99  m_aircraft->fwElevator2Label->setEnabled(false);
100  m_aircraft->fwRudder1ChannelBox->setEnabled(true);
101  m_aircraft->fwRudder1Label->setEnabled(true);
102  m_aircraft->fwRudder2ChannelBox->setEnabled(true);
103  m_aircraft->fwRudder2Label->setEnabled(true);
104  m_aircraft->fwElevator1Label->setText("Elevator 1");
105  m_aircraft->fwElevator2Label->setText("Elevator 2");
106  m_aircraft->elevonMixBox->setHidden(false);
107  m_aircraft->elevonLabel1->setText("Roll");
108  m_aircraft->elevonLabel2->setText("Pitch");
109 
110  } else if (frameType == SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL) {
111  setComboCurrentIndex(m_aircraft->aircraftType,
112  m_aircraft->aircraftType->findText("Fixed Wing"));
113  setComboCurrentIndex(m_aircraft->fixedWingType,
114  m_aircraft->fixedWingType->findText("Vtail"));
115  m_aircraft->fwRudder1ChannelBox->setEnabled(false);
116  m_aircraft->fwRudder1Label->setEnabled(false);
117  m_aircraft->fwRudder2ChannelBox->setEnabled(false);
118  m_aircraft->fwRudder2Label->setEnabled(false);
119  m_aircraft->fwElevator1ChannelBox->setEnabled(true);
120  m_aircraft->fwElevator1Label->setEnabled(true);
121  m_aircraft->fwElevator1Label->setText("Vtail 1");
122  m_aircraft->fwElevator2Label->setText("Vtail 2");
123  m_aircraft->elevonMixBox->setHidden(false);
124  m_aircraft->fwElevator2ChannelBox->setEnabled(true);
125  m_aircraft->fwElevator2Label->setEnabled(true);
126  m_aircraft->fwAileron1Label->setText("Aileron 1");
127  m_aircraft->fwAileron2Label->setText("Aileron 2");
128  m_aircraft->elevonLabel1->setText("Rudder");
129  m_aircraft->elevonLabel2->setText("Pitch");
130  }
131 }
132 
133 void ConfigFixedWingWidget::ResetActuators(GUIConfigDataUnion *configData)
134 {
135  configData->fixedwing.FixedWingPitch1 = 0;
136  configData->fixedwing.FixedWingPitch2 = 0;
137  configData->fixedwing.FixedWingRoll1 = 0;
138  configData->fixedwing.FixedWingRoll2 = 0;
139  configData->fixedwing.FixedWingYaw1 = 0;
140  configData->fixedwing.FixedWingYaw2 = 0;
141  configData->fixedwing.FixedWingThrottle = 0;
142 }
143 
144 QStringList ConfigFixedWingWidget::getChannelDescriptions()
145 {
146  int i;
147  QStringList channelDesc;
148 
149  // init a channel_numelem list of channel desc defaults
150  for (i = 0; i < (int)(ActuatorCommand::CHANNEL_NUMELEM); i++) {
151  channelDesc.append(QString("-"));
152  }
153 
154  // get the gui config data
155  GUIConfigDataUnion configData = GetConfigData();
156 
157  if (configData.fixedwing.FixedWingPitch1 > 0)
158  channelDesc[configData.fixedwing.FixedWingPitch1 - 1] = QString("FixedWingPitch1");
159  if (configData.fixedwing.FixedWingPitch2 > 0)
160  channelDesc[configData.fixedwing.FixedWingPitch2 - 1] = QString("FixedWingPitch2");
161  if (configData.fixedwing.FixedWingRoll1 > 0)
162  channelDesc[configData.fixedwing.FixedWingRoll1 - 1] = QString("FixedWingRoll1");
163  if (configData.fixedwing.FixedWingRoll2 > 0)
164  channelDesc[configData.fixedwing.FixedWingRoll2 - 1] = QString("FixedWingRoll2");
165  if (configData.fixedwing.FixedWingYaw1 > 0)
166  channelDesc[configData.fixedwing.FixedWingYaw1 - 1] = QString("FixedWingYaw1");
167  if (configData.fixedwing.FixedWingYaw2 > 0)
168  channelDesc[configData.fixedwing.FixedWingYaw2 - 1] = QString("FixedWingYaw2");
169  if (configData.fixedwing.FixedWingThrottle > 0)
170  channelDesc[configData.fixedwing.FixedWingThrottle - 1] = QString("FixedWingThrottle");
171 
172  return channelDesc;
173 }
174 
179 SystemSettings::AirframeTypeOptions ConfigFixedWingWidget::updateConfigObjectsFromWidgets()
180 {
181  MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
182  Q_ASSERT(mixerSettings);
183 
184  // Default fixed-wing type is classic airplane
185  SystemSettings::AirframeTypeOptions airframeType = SystemSettings::AIRFRAMETYPE_FIXEDWING;
186 
187  // Setup the appropriate aircraft type
188  if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder") {
189  airframeType = SystemSettings::AIRFRAMETYPE_FIXEDWING;
190  setupFrameFixedWing(airframeType);
191  } else if (m_aircraft->fixedWingType->currentText() == "Elevon") {
192  airframeType = SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON;
193  setupFrameElevon(airframeType);
194  } else { // "Vtail"
195  airframeType = SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL;
196  setupFrameVtail(airframeType);
197  }
198 
199  return airframeType;
200 }
201 
205 void ConfigFixedWingWidget::refreshAirframeWidgetsValues(
206  SystemSettings::AirframeTypeOptions frameType)
207 {
208  Q_ASSERT(m_aircraft);
209 
211  fixedGUISettingsStruct fixed = config.fixedwing;
212 
213  // Then retrieve how channels are setup
214  setComboCurrentIndex(m_aircraft->fwEngineChannelBox, fixed.FixedWingThrottle);
215  setComboCurrentIndex(m_aircraft->fwAileron1ChannelBox, fixed.FixedWingRoll1);
216  setComboCurrentIndex(m_aircraft->fwAileron2ChannelBox, fixed.FixedWingRoll2);
217  setComboCurrentIndex(m_aircraft->fwElevator1ChannelBox, fixed.FixedWingPitch1);
218  setComboCurrentIndex(m_aircraft->fwElevator2ChannelBox, fixed.FixedWingPitch2);
219  setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1);
220  setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
221 
222  MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
223  Q_ASSERT(mixerSettings);
224 
225  int channel;
226  if (frameType == SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON) {
227  // If the airframe is elevon, restore the slider setting
228  // Find the channel number for Elevon1 (FixedWingRoll1)
229  channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
230  if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here,
231  // hence the check.
232  m_aircraft->elevonSlider1->setValue(
233  getMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL)
234  * 100);
235  m_aircraft->elevonSlider2->setValue(
236  getMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH)
237  * 100);
238  }
239  }
240  if (frameType == SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL) {
241  channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1;
242  if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here,
243  // hence the check.
244  m_aircraft->elevonSlider1->setValue(
245  getMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW) * 100);
246  m_aircraft->elevonSlider2->setValue(
247  getMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH)
248  * 100);
249  }
250  }
251 }
252 
260 bool ConfigFixedWingWidget::setupFrameFixedWing(SystemSettings::AirframeTypeOptions airframeType)
261 {
262  // Check coherence:
263  // Show any config errors in GUI
264  if (throwConfigError(airframeType)) {
265  return false;
266  }
267 
268  // Now setup the channels:
269 
271  ResetActuators(&config);
272 
273  config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
274  config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
275  config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
276  config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
277  config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex();
278  config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
279 
280  SetConfigData(config, SystemSettings::AIRFRAMETYPE_FIXEDWING);
281 
282  MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
283  Q_ASSERT(mixerSettings);
284  resetMixers(mixerSettings);
285 
286  // ... and compute the matrix:
287  // In order to make code a bit nicer, we assume:
288  // - Channel dropdowns start with 'None', then 0 to 7
289 
290  // 1. Assign the servo/motor/none for each channel
291 
292  // motor
293  int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1;
294  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_MOTOR);
295  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_THROTTLECURVE1,
296  mixerScale);
297 
298  // rudder
299  channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1;
300  if (channel > -1) {
301  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
302  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW, mixerScale);
303 
304  channel = m_aircraft->fwRudder2ChannelBox->currentIndex() - 1;
305  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
306  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW, mixerScale);
307  }
308 
309  // ailerons
310  channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
311  if (channel > -1) {
312  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
313  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL, mixerScale);
314 
315  channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1;
316  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
317  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL, mixerScale);
318  }
319 
320  // elevators
321  channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1;
322  if (channel > -1) {
323  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
324  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH, mixerScale);
325 
326  channel = m_aircraft->fwElevator2ChannelBox->currentIndex() - 1;
327  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
328  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH, mixerScale);
329  }
330 
331  m_aircraft->fwStatusLabel->setText("Mixer generated");
332 
333  return true;
334 }
335 
339 bool ConfigFixedWingWidget::setupFrameElevon(SystemSettings::AirframeTypeOptions airframeType)
340 {
341  // Check coherence:
342  // Show any config errors in GUI
343  if (throwConfigError(airframeType)) {
344  return false;
345  }
346 
348  ResetActuators(&config);
349 
350  config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
351  config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
352  config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex();
353  config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex();
354  config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
355 
356  SetConfigData(config, SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON);
357 
358  MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
359  Q_ASSERT(mixerSettings);
360  resetMixers(mixerSettings);
361 
362  // Save the curve:
363  // ... and compute the matrix:
364  // In order to make code a bit nicer, we assume:
365  // - Channel dropdowns start with 'None', then 0 to 7
366 
367  // 1. Assign the servo/motor/none for each channel
368 
369  double value;
370 
371  // motor
372  int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1;
373  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_MOTOR);
374  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_THROTTLECURVE1,
375  mixerScale);
376 
377  // rudders
378  channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1;
379  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
380  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW, mixerScale);
381 
382  channel = m_aircraft->fwRudder2ChannelBox->currentIndex() - 1;
383  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
384  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW, -mixerScale);
385 
386  // ailerons
387  channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
388  if (channel > -1) {
389  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
390  value = (double)(m_aircraft->elevonSlider2->value() * (mixerScale / 100.0));
391  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH, value);
392  value = (double)(m_aircraft->elevonSlider1->value() * (mixerScale / 100.0));
393  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL, value);
394 
395  channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1;
396  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
397  value = (double)(m_aircraft->elevonSlider2->value() * (mixerScale / 100.0));
398  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH, value);
399  value = (double)(m_aircraft->elevonSlider1->value() * (mixerScale / 100.0));
400  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL, -value);
401  }
402 
403  m_aircraft->fwStatusLabel->setText("Mixer generated");
404  return true;
405 }
406 
410 bool ConfigFixedWingWidget::setupFrameVtail(SystemSettings::AirframeTypeOptions airframeType)
411 {
412  // Check coherence:
413  // Show any config errors in GUI
414  if (throwConfigError(airframeType)) {
415  return false;
416  }
417 
419  ResetActuators(&config);
420 
421  config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
422  config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
423  config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
424  config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
425  config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
426 
427  SetConfigData(config, SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL);
428 
429  MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
430  Q_ASSERT(mixerSettings);
431  resetMixers(mixerSettings);
432 
433  // Save the curve:
434  // ... and compute the matrix:
435  // In order to make code a bit nicer, we assume:
436  // - Channel dropdowns start with 'None', then 0 to 7
437 
438  // 1. Assign the servo/motor/none for each channel
439 
440  double value;
441 
442  // motor
443  int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1;
444  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_MOTOR);
445  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_THROTTLECURVE1,
446  mixerScale);
447 
448  // rudders
449  channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1;
450  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
451  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW, mixerScale);
452 
453  channel = m_aircraft->fwRudder2ChannelBox->currentIndex() - 1;
454  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
455  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW, -mixerScale);
456 
457  // ailerons
458  channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
459  if (channel > -1) {
460  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
461  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL, mixerScale);
462 
463  channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1;
464  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
465  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL, -mixerScale);
466  }
467 
468  // vtail
469  channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1;
470  if (channel > -1) {
471  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
472  value = (double)(m_aircraft->elevonSlider2->value() * (mixerScale / 100.0));
473  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH, value);
474  value = (double)(m_aircraft->elevonSlider1->value() * (mixerScale / 100.0));
475  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW, value);
476 
477  channel = m_aircraft->fwElevator2ChannelBox->currentIndex() - 1;
478  setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
479  value = (double)(m_aircraft->elevonSlider2->value() * (mixerScale / 100.0));
480  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH, value);
481  value = (double)(m_aircraft->elevonSlider1->value() * (mixerScale / 100.0));
482  setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW, -value);
483  }
484 
485  m_aircraft->fwStatusLabel->setText("Mixer generated");
486  return true;
487 }
488 
493 bool ConfigFixedWingWidget::throwConfigError(SystemSettings::AirframeTypeOptions airframeType)
494 {
495  // Initialize configuration error flag
496  bool error = false;
497 
498  // Create a red block. All combo boxes are the same size, so any one should do as a model
499  int size = m_aircraft->fwEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize);
500  QPixmap pixmap(size, size);
501  pixmap.fill(QColor("red"));
502 
503  if (airframeType == SystemSettings::AIRFRAMETYPE_FIXEDWING) {
504  if (m_aircraft->fwEngineChannelBox->currentText() == "None") {
505  m_aircraft->fwEngineChannelBox->setItemData(0, pixmap,
506  Qt::DecorationRole); // Set color palettes
507  error = true;
508  } else {
509  m_aircraft->fwEngineChannelBox->setItemData(0, 0,
510  Qt::DecorationRole); // Reset color palettes
511  }
512 
513  if (m_aircraft->fwElevator1ChannelBox->currentText() == "None") {
514  m_aircraft->fwElevator1ChannelBox->setItemData(
515  0, pixmap, Qt::DecorationRole); // Set color palettes
516  error = true;
517  } else {
518  m_aircraft->fwElevator1ChannelBox->setItemData(
519  0, 0, Qt::DecorationRole); // Reset color palettes
520  }
521 
522  if ((m_aircraft->fwAileron1ChannelBox->currentText() == "None")
523  && (m_aircraft->fwRudder1ChannelBox->currentText() == "None")) {
524  pixmap.fill(QColor("green"));
525  m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap,
526  Qt::DecorationRole); // Set color palettes
527  m_aircraft->fwRudder1ChannelBox->setItemData(0, pixmap,
528  Qt::DecorationRole); // Set color palettes
529  error = true;
530  } else {
531  m_aircraft->fwAileron1ChannelBox->setItemData(
532  0, 0, Qt::DecorationRole); // Reset color palettes
533  m_aircraft->fwRudder1ChannelBox->setItemData(
534  0, 0, Qt::DecorationRole); // Reset color palettes
535  }
536  } else if (airframeType == SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON) {
537  if (m_aircraft->fwEngineChannelBox->currentText() == "None") {
538  m_aircraft->fwEngineChannelBox->setItemData(0, pixmap,
539  Qt::DecorationRole); // Set color palettes
540  error = true;
541  } else {
542  m_aircraft->fwEngineChannelBox->setItemData(0, 0,
543  Qt::DecorationRole); // Reset color palettes
544  }
545 
546  if (m_aircraft->fwAileron1ChannelBox->currentText() == "None") {
547  m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap,
548  Qt::DecorationRole); // Set color palettes
549  error = true;
550  } else {
551  m_aircraft->fwAileron1ChannelBox->setItemData(
552  0, 0, Qt::DecorationRole); // Reset color palettes
553  }
554 
555  if (m_aircraft->fwAileron2ChannelBox->currentText() == "None") {
556  m_aircraft->fwAileron2ChannelBox->setItemData(0, pixmap,
557  Qt::DecorationRole); // Set color palettes
558  error = true;
559  } else {
560  m_aircraft->fwAileron2ChannelBox->setItemData(
561  0, 0, Qt::DecorationRole); // Reset color palettes
562  }
563 
564  } else if (airframeType == SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL) {
565  if (m_aircraft->fwEngineChannelBox->currentText() == "None") {
566  m_aircraft->fwEngineChannelBox->setItemData(0, pixmap,
567  Qt::DecorationRole); // Set color palettes
568  error = true;
569  } else {
570  m_aircraft->fwEngineChannelBox->setItemData(0, 0,
571  Qt::DecorationRole); // Reset color palettes
572  }
573 
574  if (m_aircraft->fwElevator1ChannelBox->currentText() == "None") {
575  m_aircraft->fwElevator1ChannelBox->setItemData(
576  0, pixmap, Qt::DecorationRole); // Set color palettes
577  error = true;
578  } else {
579  m_aircraft->fwElevator1ChannelBox->setItemData(
580  0, 0, Qt::DecorationRole); // Reset color palettes
581  }
582 
583  if (m_aircraft->fwElevator2ChannelBox->currentText() == "None") {
584  m_aircraft->fwElevator2ChannelBox->setItemData(
585  0, pixmap, Qt::DecorationRole); // Set color palettes
586  error = true;
587  } else {
588  m_aircraft->fwElevator2ChannelBox->setItemData(
589  0, 0, Qt::DecorationRole); // Reset color palettes
590  }
591  }
592 
593  if (error) {
594  m_aircraft->fwStatusLabel->setText(
595  QString("<font color='red'>ERROR: Assign all necessary channels</font>"));
596  }
597 
598  return error;
599 }
static void SetConfigData(GUIConfigDataUnion configData, SystemSettings::AirframeTypeOptions vehicle)
static GUIConfigDataUnion GetConfigData()
for i
Definition: OPPlots.m:140
double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerSettings::Mixer1VectorElem elementName)
ConfigFixedWingWidget(Ui_AircraftWidget *aircraft=nullptr, QWidget *parent=nullptr)
fixedGUISettingsStruct fixedwing
void resetMixers(UAVDataObject *mixer)
void setMixerType(UAVDataObject *mixer, int channel, MixerSettings::Mixer1TypeOptions mixerType)
void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerSettings::Mixer1VectorElem elementName, double value)
else error('Your technical computing program does not support file choosers.Please input the file name in the argument. ') end elseif nargin >0 logfile
UAVObjectManager * getObjectManager()
ConfigTaskWidget::getObjectManager Utility function to get a pointer to the object manager...
static const double mixerScale
static void setComboCurrentIndex(QComboBox *box, int index)