diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.cpp new file mode 100644 index 000000000..9b128efbf --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.cpp @@ -0,0 +1,190 @@ +/** + ****************************************************************************** + * + * @file multipage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup MultiPage + * @{ + * @brief + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "subvehiclepage.h" +#include "ui_subvehiclepage.h" +#include "setupwizard.h" + +SubVehiclePage::SubVehiclePage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), + ui(new Ui::SubVehiclePage) +{ + ui->setupUi(this); + + m_renderer = new QSvgRenderer(); + m_renderer->load(QString(":/configgadget/images/multirotor-shapes.svg")); + m_multiPic = new QGraphicsSvgItem(); + m_multiPic->setSharedRenderer(m_renderer); + QGraphicsScene *scene = new QGraphicsScene(this); + scene->addItem(m_multiPic); + ui->typeGraphicsView->setScene(scene); + + setupMultiTypesCombo(); + + // Default to Quad X since it is the most common setup + ui->typeCombo->setCurrentIndex(1); + connect(ui->typeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateImageAndDescription())); + ui->typeGraphicsView->setSceneRect(m_multiPic->boundingRect()); + ui->typeGraphicsView->fitInView(m_multiPic, Qt::KeepAspectRatio); +} + +SubVehiclePage::~SubVehiclePage() +{ + delete ui; +} + +void SubVehiclePage::initializePage() +{ + updateAvailableTypes(); + updateImageAndDescription(); +} + +bool SubVehiclePage::validatePage() +{ + SetupWizard::VEHICLE_SUB_TYPE type = (SetupWizard::VEHICLE_SUB_TYPE)ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt(); + + getWizard()->setVehicleSubType(type); + return true; +} + +void SubVehiclePage::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + if (m_multiPic) { + ui->typeGraphicsView->setSceneRect(m_multiPic->boundingRect()); + ui->typeGraphicsView->fitInView(m_multiPic, Qt::KeepAspectRatio); + } +} + +void SubVehiclePage::setupMultiTypesCombo() +{ + ui->typeCombo->addItem(tr("Tricopter"), SetupWizard::MULTI_ROTOR_TRI_Y); + m_descriptions << tr("The Tricopter uses three motors and one servo. The servo is used to give yaw authority to the rear motor. " + "The front motors are rotating in opposite directions. The Tricopter is known for its sweeping yaw movement and " + "it is very well suited for FPV since the front rotors are spread wide apart."); + + ui->typeCombo->addItem(tr("Quadcopter X"), SetupWizard::MULTI_ROTOR_QUAD_X); + m_descriptions << tr("The X Quadcopter uses four motors and is the most common multi rotor configuration. Two of the motors rotate clockwise " + "and two counter clockwise. The motors positioned diagonal to each other rotate in the same direction. " + "This setup is perfect for sport flying and is also commonly used for FPV platforms."); + + ui->typeCombo->addItem(tr("Quadcopter +"), SetupWizard::MULTI_ROTOR_QUAD_PLUS); + m_descriptions << tr("The Plus(+) Quadcopter uses four motors and is similar to the X Quadcopter but the forward direction is offset by 45 degrees. " + "The motors front and rear rotate in clockwise and the motors right and left rotate counter-clockwise. " + "This setup was one of the first to be used and is still used for sport flying. This configuration is not that well suited " + "for FPV since the fore rotor tend to be in the way of the camera."); + + ui->typeCombo->addItem(tr("Hexacopter"), SetupWizard::MULTI_ROTOR_HEXA); + m_descriptions << tr("Hexacopter"); + + ui->typeCombo->addItem(tr("Hexacopter X"), SetupWizard::MULTI_ROTOR_HEXA_X); + m_descriptions << tr("Hexacopter X"); + + ui->typeCombo->addItem(tr("Hexacopter H"), SetupWizard::MULTI_ROTOR_HEXA_H); + m_descriptions << tr("Hexacopter H"); + + ui->typeCombo->addItem(tr("Hexacopter Coax (Y6)"), SetupWizard::MULTI_ROTOR_HEXA_COAX_Y); + m_descriptions << tr("Hexacopter Coax (Y6)"); + + + // Fredrik Arvidsson(m_thread) 2012-08-26 Disable Octos until further notice + /* + ui->typeCombo->addItem(tr("Octocopter"), SetupWizard::MULTI_ROTOR_OCTO); + m_descriptions << tr("Octocopter"); + + ui->typeCombo->addItem(tr("Octocopter Coax X"), SetupWizard::MULTI_ROTOR_OCTO_COAX_X); + m_descriptions << tr("Octocopter Coax X"); + + ui->typeCombo->addItem(tr("Octocopter Coax +"), SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS); + m_descriptions << tr("Octocopter Coax +"); + + ui->typeCombo->addItem(tr("Octocopter V"), SetupWizard::MULTI_ROTOR_OCTO_V); + m_descriptions << tr("Octocopter V"); + */ +} + +void SubVehiclePage::updateAvailableTypes() +{ + /* + QVariant enable = (getWizard()->getInputType() == SetupWizard::INPUT_PWM) ? QVariant(0) : QVariant(1 | 32); + ui->typeCombo->model()->setData(ui->typeCombo->model()->index(6, 0), enable, Qt::UserRole - 1); + ui->typeCombo->model()->setData(ui->typeCombo->model()->index(7, 0), enable, Qt::UserRole - 1); + ui->typeCombo->model()->setData(ui->typeCombo->model()->index(8, 0), enable, Qt::UserRole - 1); + ui->typeCombo->model()->setData(ui->typeCombo->model()->index(9, 0), enable, Qt::UserRole - 1); + */ +} + +void SubVehiclePage::updateImageAndDescription() +{ + SetupWizard::VEHICLE_SUB_TYPE type = (SetupWizard::VEHICLE_SUB_TYPE)ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt(); + QString elementId = ""; + QString description = m_descriptions.at(ui->typeCombo->currentIndex()); + + switch (type) { + case SetupWizard::MULTI_ROTOR_TRI_Y: + elementId = "tri"; + break; + case SetupWizard::MULTI_ROTOR_QUAD_X: + elementId = "quad-x"; + break; + case SetupWizard::MULTI_ROTOR_QUAD_PLUS: + elementId = "quad-plus"; + break; + case SetupWizard::MULTI_ROTOR_HEXA: + elementId = "quad-hexa"; + break; + case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y: + elementId = "hexa-coax"; + break; + case SetupWizard::MULTI_ROTOR_HEXA_H: + elementId = "quad-hexa-H"; + break; + case SetupWizard::MULTI_ROTOR_HEXA_X: + elementId = "quad-hexa-X"; + break; + case SetupWizard::MULTI_ROTOR_OCTO: + elementId = "quad-octo"; + break; + case SetupWizard::MULTI_ROTOR_OCTO_COAX_X: + elementId = "octo-coax-X"; + break; + case SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS: + elementId = "octo-coax-P"; + break; + case SetupWizard::MULTI_ROTOR_OCTO_V: + elementId = "quad-octo-v"; + break; + default: + elementId = ""; + break; + } + m_multiPic->setElementId(elementId); + ui->typeGraphicsView->setSceneRect(m_multiPic->boundingRect()); + ui->typeGraphicsView->fitInView(m_multiPic, Qt::KeepAspectRatio); + + ui->typeDescription->setText(description); +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.h new file mode 100644 index 000000000..3ee42766a --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.h @@ -0,0 +1,66 @@ +/** + ****************************************************************************** + * + * @file subvehiclepage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014. + * @addtogroup + * @{ + * @addtogroup SubVehiclePage + * @{ + * @brief + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SUBVEHICLEPAGEPAGE_H +#define SUBVEHICLEPAGEPAGE_H + +#include +#include +#include + +#include "abstractwizardpage.h" + +namespace Ui { +class SubVehiclePage; +} + +class SubVehiclePage : public AbstractWizardPage { + Q_OBJECT + +public: + explicit SubVehiclePage(SetupWizard *wizard, QWidget *parent = 0); + ~SubVehiclePage(); + + void initializePage(); + bool validatePage(); + +protected: + void resizeEvent(QResizeEvent *event); + +private: + Ui::SubVehiclePage *ui; + void setupMultiTypesCombo(); + QSvgRenderer* m_renderer; + QGraphicsSvgItem *m_multiPic; + void updateAvailableTypes(); + QList m_descriptions; + +private slots: + void updateImageAndDescription(); +}; + +#endif // SUBVEHICLEPAGEPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.ui new file mode 100644 index 000000000..9f6ea3219 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/subvehiclepage.ui @@ -0,0 +1,164 @@ + + + SubVehiclePage + + + + 0 + 0 + 600 + 400 + + + + WizardPage + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">OpenPilot Multirotor Configuration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">This part of the wizard will set up the OpenPilot controller for use with a flying platform utilizing multiple rotors. The wizard supports the most common types of multirotors. Other variants of multirotors can be configured by using custom configuration options in the Configuration plugin in the GCS.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Please select the type of multirotor you want to create a configuration for below:</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + 4 + + + + + + + 4 + + + + + + 125 + 36 + + + + + 10 + 50 + false + + + + Multirotor type: + + + + + + + + 125 + 20 + + + + + + + + + + + 0 + 0 + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + 0 + 0 + + + + + 200 + 200 + + + + true + + + QFrame::NoFrame + + + 0 + + + 0 + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + false + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index d415c374a..0dc55fe77 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -37,7 +37,8 @@ HEADERS += setupwizardplugin.h \ pages/biascalibrationpage.h \ pages/airframestabfixedwingpage.h \ pages/escpage.h \ - pages/servopage.h + pages/servopage.h \ + pages/subvehiclepage.h SOURCES += setupwizardplugin.cpp \ setupwizard.cpp \ @@ -66,7 +67,8 @@ SOURCES += setupwizardplugin.cpp \ pages/biascalibrationpage.cpp \ pages/airframestabfixedwingpage.cpp \ pages/escpage.cpp \ - pages/servopage.cpp + pages/servopage.cpp \ + pages/subvehiclepage.cpp OTHER_FILES += SetupWizard.pluginspec @@ -91,7 +93,8 @@ FORMS += \ pages/biascalibrationpage.ui \ pages/airframestabfixedwingpage.ui \ pages/escpage.ui \ - pages/servopage.ui + pages/servopage.ui \ + pages/subvehiclepage.ui RESOURCES += \ wizardResources.qrc