dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
multipage.cpp
Go to the documentation of this file.
1 
13 /*
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.
18  *
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.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #include "multipage.h"
29 #include "ui_multipage.h"
30 #include "setupwizard.h"
31 
32 MultiPage::MultiPage(SetupWizard *wizard, QWidget *parent)
33  : AbstractWizardPage(wizard, parent)
34  , ui(new Ui::MultiPage)
35 {
36  ui->setupUi(this);
37 
38  QSvgRenderer *renderer = new QSvgRenderer();
39  renderer->load(QString(":/configgadget/images/multirotor-shapes.svg"));
40  m_multiPic = new QGraphicsSvgItem();
41  m_multiPic->setSharedRenderer(renderer);
42  QGraphicsScene *scene = new QGraphicsScene(this);
43  scene->addItem(m_multiPic);
44  ui->typeGraphicsView->setScene(scene);
45 
46  setupMultiTypesCombo();
47 
48  // Default to Quad X since it is the most common setup
49  ui->typeCombo->setCurrentIndex(1);
50  connect(ui->typeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
51  &MultiPage::updateImageAndDescription);
52  ui->typeGraphicsView->setSceneRect(m_multiPic->boundingRect());
53  ui->typeGraphicsView->fitInView(m_multiPic, Qt::KeepAspectRatio);
54 }
55 
57 {
58  delete ui;
59 }
60 
62 {
63  updateAvailableTypes();
64  updateImageAndDescription();
65 }
66 
68 {
70  (SetupWizard::VEHICLE_SUB_TYPE)ui->typeCombo->itemData(ui->typeCombo->currentIndex())
71  .toInt();
72 
74  return true;
75 }
76 
77 void MultiPage::resizeEvent(QResizeEvent *event)
78 {
79  Q_UNUSED(event);
80  if (m_multiPic) {
81  ui->typeGraphicsView->setSceneRect(m_multiPic->boundingRect());
82  ui->typeGraphicsView->fitInView(m_multiPic, Qt::KeepAspectRatio);
83  }
84 }
85 
86 void MultiPage::setupMultiTypesCombo()
87 {
88  ui->typeCombo->addItem(tr("Tricopter"), SetupWizard::MULTI_ROTOR_TRI_Y);
89  m_descriptions << tr(
90  "The Tricopter uses three motors and one servo. The servo is used to give yaw authority to "
91  "the rear motor. "
92  "The front motors are rotating in opposite directions. The Tricopter is known for its "
93  "sweeping yaw movement and "
94  "it is very well suited for FPV since the front rotors are spread wide apart.");
95 
96  ui->typeCombo->addItem(tr("Quadcopter X"), SetupWizard::MULTI_ROTOR_QUAD_X);
97  m_descriptions << tr(
98  "The X Quadcopter uses four motors and is the most common multi rotor configuration. Two "
99  "of the motors rotate clockwise "
100  "and two counter clockwise. The motors positioned diagonal to each other rotate in the "
101  "same direction. "
102  "This setup is perfect for sport flying and is also commonly used for FPV platforms.");
103 
104  ui->typeCombo->addItem(tr("Quadcopter +"), SetupWizard::MULTI_ROTOR_QUAD_PLUS);
105  m_descriptions << tr("The Plus(+) Quadcopter uses four motors and is similar to the X "
106  "Quadcopter but the forward direction is offset by 45 degrees. "
107  "The motors front and rear rotate in clockwise and the motors right and "
108  "left rotate counter-clockwise. "
109  "This setup was one of the first to be used and is still used for sport "
110  "flying. This configuration is not that well suited "
111  "for FPV since the fore rotor tend to be in the way of the camera.");
112 
113  ui->typeCombo->addItem(tr("Hexacopter"), SetupWizard::MULTI_ROTOR_HEXA);
114  m_descriptions << tr("Hexacopter");
115 
116  ui->typeCombo->addItem(tr("Hexacopter Coax (Y6)"), SetupWizard::MULTI_ROTOR_HEXA_COAX_Y);
117  m_descriptions << tr("Hexacopter Coax (Y6)");
118 
119  ui->typeCombo->addItem(tr("Hexacopter X"), SetupWizard::MULTI_ROTOR_HEXA_H);
120  m_descriptions << tr("Hexacopter H");
121 
122  // Fredrik Arvidsson(m_thread) 2012-08-26 Disable Octos until further notice
123  /*
124  ui->typeCombo->addItem(tr("Octocopter"), SetupWizard::MULTI_ROTOR_OCTO);
125  m_descriptions << tr("Octocopter");
126 
127  ui->typeCombo->addItem(tr("Octocopter Coax X"), SetupWizard::MULTI_ROTOR_OCTO_COAX_X);
128  m_descriptions << tr("Octocopter Coax X");
129 
130  ui->typeCombo->addItem(tr("Octocopter Coax +"), SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS);
131  m_descriptions << tr("Octocopter Coax +");
132 
133  ui->typeCombo->addItem(tr("Octocopter V"), SetupWizard::MULTI_ROTOR_OCTO_V);
134  m_descriptions << tr("Octocopter V");
135  */
136 }
137 
138 void MultiPage::updateAvailableTypes()
139 {
140  /*
141  QVariant enable = (getWizard()->getInputType() == SetupWizard::INPUT_PWM) ? QVariant(0) :
142  QVariant(1 | 32);
143  ui->typeCombo->model()->setData(ui->typeCombo->model()->index(6, 0), enable, Qt::UserRole -
144  1);
145  ui->typeCombo->model()->setData(ui->typeCombo->model()->index(7, 0), enable, Qt::UserRole -
146  1);
147  ui->typeCombo->model()->setData(ui->typeCombo->model()->index(8, 0), enable, Qt::UserRole -
148  1);
149  ui->typeCombo->model()->setData(ui->typeCombo->model()->index(9, 0), enable, Qt::UserRole -
150  1);
151  */
152 }
153 
154 void MultiPage::updateImageAndDescription()
155 {
157  (SetupWizard::VEHICLE_SUB_TYPE)ui->typeCombo->itemData(ui->typeCombo->currentIndex())
158  .toInt();
159  QString elementId = "";
160  QString description = m_descriptions.at(ui->typeCombo->currentIndex());
161 
162  switch (type) {
164  elementId = "tri";
165  break;
167  elementId = "quad-x";
168  break;
170  elementId = "quad-plus";
171  break;
173  elementId = "quad-hexa";
174  break;
176  elementId = "hexa-coax";
177  break;
179  elementId = "quad-hexa-H";
180  break;
182  elementId = "quad-octo";
183  break;
185  elementId = "octo-coax-X";
186  break;
188  elementId = "octo-coax-P";
189  break;
191  elementId = "quad-octo-v";
192  break;
193  default:
194  elementId = "";
195  break;
196  }
197  m_multiPic->setElementId(elementId);
198  ui->typeGraphicsView->setSceneRect(m_multiPic->boundingRect());
199  ui->typeGraphicsView->fitInView(m_multiPic, Qt::KeepAspectRatio);
200 
201  ui->typeDescription->setText(description);
202 }
The SetupWizard class is the main interface to the setup wizard. It provides selects the sequence of ...
Definition: setupwizard.h:47
void resizeEvent(QResizeEvent *event)
Definition: multipage.cpp:77
MultiPage(SetupWizard *wizard, QWidget *parent=nullptr)
Definition: multipage.cpp:32
SetupWizard * getWizard() const
void setVehicleSubType(SetupWizard::VEHICLE_SUB_TYPE type)
Definition: setupwizard.h:61
bool validatePage()
Definition: multipage.cpp:67
void initializePage()
Definition: multipage.cpp:61