mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-1222 Added base page for selection kind of action.
This commit is contained in:
parent
c39424d50a
commit
4695a60df6
@ -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);
|
||||
}
|
@ -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 <QtSvg/QGraphicsSvgItem>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QList>
|
||||
|
||||
#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<QString> m_descriptions;
|
||||
|
||||
private slots:
|
||||
void updateImageAndDescription();
|
||||
};
|
||||
|
||||
#endif // SUBVEHICLEPAGEPAGE_H
|
@ -0,0 +1,164 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SubVehiclePage</class>
|
||||
<widget class="QWizardPage" name="SubVehiclePage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>WizardPage</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><!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></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>125</width>
|
||||
<height>36</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Multirotor type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="typeCombo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>125</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="typeDescription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGraphicsView" name="typeGraphicsView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="backgroundBrush">
|
||||
<brush brushstyle="NoBrush">
|
||||
<color alpha="0">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</property>
|
||||
<property name="foregroundBrush">
|
||||
<brush brushstyle="NoBrush">
|
||||
<color alpha="0">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</property>
|
||||
<property name="interactive">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user