1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-12 20:08:48 +01:00

Add the fixed wing plane art to the channel config screen (in progress)

Begin adding plane art to Output config screen in wizard.
This commit is contained in:
Kevin Finisterre 2013-12-15 21:37:19 -05:00
parent a042ffd843
commit 632ffed707
3 changed files with 104 additions and 13 deletions

View File

@ -40,6 +40,8 @@
#include <math.h> #include <math.h>
#include <QMessageBox> #include <QMessageBox>
const QString ConfigFixedWingWidget::CHANNELBOXNAME = QString("fixedWingChannelBox");
QStringList ConfigFixedWingWidget::getChannelDescriptions() QStringList ConfigFixedWingWidget::getChannelDescriptions()
{ {
// init a channel_numelem list of channel desc defaults // init a channel_numelem list of channel desc defaults
@ -83,6 +85,32 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
populateChannelComboBoxes(); populateChannelComboBoxes();
QSvgRenderer *renderer = new QSvgRenderer();
renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg"));
plane = new QGraphicsSvgItem();
plane->setSharedRenderer(renderer);
QString type = "aileron"; // This needs fixed. Need to be able to obtain the aircraft type.
// not sure why m_aircraft->fixedWingType->currentText() is not working here! fix it
if (type == "vtail")
{
plane->setElementId("vtail");
}
else if (type == "aileron")
{
plane->setElementId("aileron");
}
else
{
plane->setElementId("unknown");
}
QGraphicsScene *scene = new QGraphicsScene();
scene->addItem(plane);
scene->setSceneRect(plane->boundingRect());
m_aircraft->planeShape->setScene(scene);
QStringList fixedWingTypes; QStringList fixedWingTypes;
fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
m_aircraft->fixedWingType->addItems(fixedWingTypes); m_aircraft->fixedWingType->addItems(fixedWingTypes);
@ -90,6 +118,7 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
// Set default model to "Elevator aileron rudder" // Set default model to "Elevator aileron rudder"
connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
setupUI(m_aircraft->fixedWingType->currentText()); setupUI(m_aircraft->fixedWingType->currentText());
} }
@ -158,6 +187,26 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
} }
} }
void ConfigFixedWingWidget::setupEnabledControls(QString frameType)
{
// disable all motor channel boxes
for (int i = 1; i <= 8; i++) {
// do it manually so we can turn off any error decorations
QComboBox *combobox = this->findChild<QComboBox *>("fixedWingChannelBox" + QString::number(i));
if (combobox) {
combobox->setEnabled(false);
combobox->setItemData(0, 0, Qt::DecorationRole);
}
}
if (frameType == "Vtail" || frameType == "Elevon") {
enableComboBoxes(this, CHANNELBOXNAME, 3, true);
} else if (frameType == "aileron" || frameType == "Elevator aileron rudder") {
enableComboBoxes(this, CHANNELBOXNAME, 4, true);
}
}
void ConfigFixedWingWidget::registerWidgets(ConfigTaskWidget &parent) void ConfigFixedWingWidget::registerWidgets(ConfigTaskWidget &parent)
{ {
parent.addWidget(m_aircraft->fixedWingThrottle->getCurveWidget()); parent.addWidget(m_aircraft->fixedWingThrottle->getCurveWidget());
@ -278,6 +327,16 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets()
return airframeType; return airframeType;
} }
void ConfigFixedWingWidget::updateAirframe(QString frameType)
{
qDebug() << "ConfigFixedWingWidget::updateAirframe - frame type" << frameType;
// this is not doing anything right now
m_aircraft->planeShape->setSceneRect(plane->boundingRect());
m_aircraft->planeShape->fitInView(plane, Qt::KeepAspectRatio);
}
/** /**
Setup Elevator/Aileron/Rudder airframe. Setup Elevator/Aileron/Rudder airframe.
@ -502,15 +561,6 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
return true; return true;
} }
void ConfigFixedWingWidget::enableControls(bool enable)
{
ConfigTaskWidget::enableControls(enable);
if (enable) {
setupUI(m_aircraft->fixedWingType->currentText());
}
}
/** /**
This function displays text and color formatting in order to help the user understand what channels have not yet been configured. This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
*/ */
@ -600,3 +650,34 @@ bool ConfigFixedWingWidget::throwConfigError(QString airframeType)
return error; return error;
} }
/**
WHAT DOES THIS DO???
*/
void ConfigFixedWingWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
// Thit fitInView method should only be called now, once the
// widget is shown, otherwise it cannot compute its values and
// the result is usually a ahrsbargraph that is way too small.
m_aircraft->planeShape->fitInView(plane, Qt::KeepAspectRatio);
}
/**
Resize the GUI contents when the user changes the window size
*/
void ConfigFixedWingWidget::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
m_aircraft->planeShape->fitInView(plane, Qt::KeepAspectRatio);
}
void ConfigFixedWingWidget::enableControls(bool enable)
{
ConfigTaskWidget::enableControls(enable);
if (enable) {
setupEnabledControls(m_aircraft->fixedWingType->currentText());
}
}

View File

@ -34,8 +34,9 @@
#include "uavobjectmanager.h" #include "uavobjectmanager.h"
#include "uavobject.h" #include "uavobject.h"
#include "uavtalk/telemetrymanager.h" #include "uavtalk/telemetrymanager.h"
#include <QtCore/QList>
#include <QWidget> #include <QWidget>
#include <QList>
#include <QItemDelegate> #include <QItemDelegate>
class Ui_Widget; class Ui_Widget;
@ -44,6 +45,7 @@ class ConfigFixedWingWidget : public VehicleConfig {
Q_OBJECT Q_OBJECT
public: public:
static const QString CHANNELBOXNAME;
static QStringList getChannelDescriptions(); static QStringList getChannelDescriptions();
ConfigFixedWingWidget(QWidget *parent = 0); ConfigFixedWingWidget(QWidget *parent = 0);
@ -52,8 +54,14 @@ public:
virtual void refreshWidgetsValues(QString frameType); virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets(); virtual QString updateConfigObjectsFromWidgets();
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
void enableControls(bool enable);
private: private:
Ui_FixedWingConfigWidget *m_aircraft; Ui_FixedWingConfigWidget *m_aircraft;
QGraphicsSvgItem *plane;
virtual void registerWidgets(ConfigTaskWidget &parent); virtual void registerWidgets(ConfigTaskWidget &parent);
virtual void resetActuators(GUIConfigDataUnion *configData); virtual void resetActuators(GUIConfigDataUnion *configData);
@ -62,9 +70,8 @@ private:
bool setupFrameElevon(QString airframeType); bool setupFrameElevon(QString airframeType);
bool setupFrameVtail(QString airframeType); bool setupFrameVtail(QString airframeType);
protected: void updateAirframe(QString multiRotorType);
void enableControls(bool enable); void setupEnabledControls(QString airframeType);
private slots: private slots:
virtual void setupUI(QString airframeType); virtual void setupUI(QString airframeType);
virtual bool throwConfigError(QString airframeType); virtual bool throwConfigError(QString airframeType);

View File

@ -38,6 +38,9 @@ OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *paren
qDebug() << "calling output calibration page"; qDebug() << "calling output calibration page";
m_vehicleRenderer = new QSvgRenderer(); m_vehicleRenderer = new QSvgRenderer();
// need to determine multi rotor or fixed wing. and pick the right svg
if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) &&
m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) &&
m_vehicleRenderer->isValid()) { m_vehicleRenderer->isValid()) {