1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-16 08:29:15 +01:00

Create airspeed page

This commit is contained in:
Fredrik Larson 2014-08-25 06:31:52 +10:00
parent 6bcc6f32ed
commit 7f0901cdda
3 changed files with 368 additions and 0 deletions

View File

@ -0,0 +1,136 @@
/**
******************************************************************************
*
* @file fixedwingpage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup
* @{
* @addtogroup FixedWingPage
* @{
* @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 "airspeedpage.h"
#include "ui_airspeed.h"
#include "setupwizard.h"
AirSpeedPage::AirSpeedPage(SetupWizard *wizard, QWidget *parent) :
AbstractWizardPage(wizard, parent),
ui(new Ui::AirSpeedPage)
{
ui->setupUi(this);
QSvgRenderer *renderer = new QSvgRenderer();
renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg"));
m_airspeedPic = new QGraphicsSvgItem();
m_airspeedPic->setSharedRenderer(renderer);
QGraphicsScene *scene = new QGraphicsScene(this);
scene->addItem(m_airspeedPic);
ui->typeGraphicsView->setScene(scene);
setupAirSpeedPageTypesCombo();
// Default to Software Estimation
connect(ui->typeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateImageAndDescription()));
ui->typeCombo->setCurrentIndex(0);
}
AirSpeedPage::~AirSpeedPage()
{
delete ui;
}
void AirSpeedPage::initializePage()
{
updateAvailableTypes();
updateImageAndDescription();
}
//TODO
bool AirSpeedPage::validatePage()
{
SetupWizard::VEHICLE_SUB_TYPE type = (SetupWizard::VEHICLE_SUB_TYPE)ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt();
getWizard()->setVehicleSubType(type);
return true;
}
void AirSpeedPage::fitInView()
{
if (m_airspeedPic) {
ui->typeGraphicsView->setSceneRect(m_airspeedPic->boundingRect());
ui->typeGraphicsView->fitInView(m_airspeedPic, Qt::KeepAspectRatio);
}
}
void AirSpeedPage::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
fitInView();
}
void AirSpeedPage::showEvent(QShowEvent *event)
{
Q_UNUSED(event);
fitInView();
}
//TODO
void AirSpeedPage::setupAirSpeedPageTypesCombo()
{
ui->typeCombo->addItem(tr("Aileron Dual Servos"), SetupWizard::FIXED_WING_DUAL_AILERON);
m_descriptions << tr("This setup expects a traditional airframe using two independent aileron servos on their own channel (not connected by Y adapter) plus an elevator and a rudder. ");
ui->typeCombo->addItem(tr("Aileron Single Servo"), SetupWizard::FIXED_WING_AILERON);
m_descriptions << tr("This setup expects a traditional airframe using a single alieron servo or two servos connected by a Y adapter plus an elevator and a rudder. ");
ui->typeCombo->addItem(tr("Elevon"), SetupWizard::FIXED_WING_ELEVON);
m_descriptions << tr("This setup currently expects a flying-wing setup, an elevon plus rudder setup is not yet supported. Setup should include only two elevons, and should explicitly not include a rudder.");
}
void AirSpeedPage::updateAvailableTypes()
{
}
//TODO
void AirSpeedPage::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::FIXED_WING_DUAL_AILERON:
elementId = "aileron";
break;
case SetupWizard::FIXED_WING_AILERON:
elementId = "aileron-single";
break;
case SetupWizard::FIXED_WING_ELEVON:
elementId = "elevon";
break;
default:
elementId = "";
break;
}
m_airspeedPic->setElementId(elementId);
ui->typeGraphicsView->setSceneRect(m_airspeedPic->boundingRect());
ui->typeGraphicsView->fitInView(m_airspeedPic, Qt::KeepAspectRatio);
ui->typeDescription->setText(description);
}

View File

@ -0,0 +1,68 @@
/**
******************************************************************************
*
* @file fixedwingpage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup
* @{
* @addtogroup FixedWingPage
* @{
* @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 AIRSPEEDPAGE_H
#define AIRSPEEDPAGE_H
#include <QtSvg/QGraphicsSvgItem>
#include <QtSvg/QSvgRenderer>
#include <QList>
#include "abstractwizardpage.h"
namespace Ui {
class AirSpeedPage;
}
class AirSpeedPage : public AbstractWizardPage {
Q_OBJECT
public:
explicit AirSpeedPage(SetupWizard *wizard, QWidget *parent = 0);
~AirSpeedPage();
void initializePage();
bool validatePage();
void fitInView();
protected:
void resizeEvent(QResizeEvent *event);
void showEvent(QShowEvent *event);
private:
Ui::AirSpeedPage *ui;
void setupAirSpeedPageTypesCombo();
QGraphicsSvgItem *m_fixedwingPic;
void updateAvailableTypes();
QList<QString> m_descriptions;
private slots:
void updateImageAndDescription();
};
#endif // AIRSPEEDPAGE_H

View File

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FixedWingPage</class>
<widget class="QWizardPage" name="FixedWingPage">
<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>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;OpenPilot Airspeed Sensor Configuration&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;This part of the wizard will set up the OpenPilot controller for use with an airspeed sensor also commonly called a Pitot tube. The OpenPilot Platform supports multiple types of hardware airspeed sensors as well as an advanced software based wind speed estimation algorthym which requires no additional hardware although this is slightly less accurate than using a dedicated hardware sensor. &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Please select the type of airspeed sensor you wish to use below:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>Airspeed 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>