From 82e2c5cf924613c654a97579bfd3f483d956df37 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Mon, 16 Dec 2013 14:29:04 -0500 Subject: [PATCH] Move some code around to accomidate multiple svg images in the output calibration screen. Need to fix the SVG to allow for zooming in on specific channel components as we do with the multi rotor screen. This has some sloppy comments in if for my own debugging purposes. --- .../configfixedwingwidget.cpp | 1 + .../pages/outputcalibrationpage.cpp | 55 ++++++++++++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 57a204a10..af76c818d 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -92,6 +92,7 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : QString type = "aileron"; // This needs fixed. Need to be able to obtain the aircraft type. + qDebug() << "Current Aircraft type: " << m_aircraft->fixedWingType->currentText(); // not sure why m_aircraft->fixedWingType->currentText() is not working here! fix it if (type == "vtail") { diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index 2741e1b7b..1bbd4b4cc 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -39,14 +39,10 @@ OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *paren qDebug() << "calling output calibration page"; m_vehicleRenderer = new QSvgRenderer(); -// need to determine multi rotor or fixed wing. and pick the right svg + // move the code that was here to setupVehicle() so we can determine which image to use. + m_vehicleScene = new QGraphicsScene(this); + ui->vehicleView->setScene(m_vehicleScene); - if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && - m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && - m_vehicleRenderer->isValid()) { - m_vehicleScene = new QGraphicsScene(this); - ui->vehicleView->setScene(m_vehicleScene); - } } OutputCalibrationPage::~OutputCalibrationPage() @@ -67,8 +63,18 @@ void OutputCalibrationPage::setupVehicle() m_channelIndex.clear(); m_currentWizardIndex = 0; m_vehicleScene->clear(); + +// KF moved code from OutputCalibrationPage() here so it can be used to detect the current vehicle +// needs to be slimmed down and not repeated. + switch (getWizard()->getVehicleSubType()) { case SetupWizard::MULTI_ROTOR_TRI_Y: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } + m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; m_vehicleElementIds << "tri" << "tri-frame" << "tri-m1" << "tri-m2" << "tri-m3" << "tri-s1"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 4 << 4; @@ -79,30 +85,55 @@ void OutputCalibrationPage::setupVehicle() getWizard()->setActuatorSettings(m_actuatorSettings); break; case SetupWizard::MULTI_ROTOR_QUAD_X: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1; m_vehicleElementIds << "quad-x" << "quad-x-frame" << "quad-x-m1" << "quad-x-m2" << "quad-x-m3" << "quad-x-m4"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4; m_channelIndex << 0 << 0 << 1 << 2 << 3; break; case SetupWizard::MULTI_ROTOR_QUAD_PLUS: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1; m_vehicleElementIds << "quad-p" << "quad-p-frame" << "quad-p-m1" << "quad-p-m2" << "quad-p-m3" << "quad-p-m4"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4; m_channelIndex << 0 << 0 << 1 << 2 << 3; break; case SetupWizard::MULTI_ROTOR_HEXA: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "hexa" << "hexa-frame" << "hexa-m1" << "hexa-m2" << "hexa-m3" << "hexa-m4" << "hexa-m5" << "hexa-m6"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; break; case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "hexa-y6" << "hexa-y6-frame" << "hexa-y6-m2" << "hexa-y6-m1" << "hexa-y6-m4" << "hexa-y6-m3" << "hexa-y6-m6" << "hexa-y6-m5"; m_vehicleHighlightElementIndexes << 0 << 2 << 1 << 4 << 3 << 6 << 5; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; break; case SetupWizard::MULTI_ROTOR_HEXA_H: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "hexa-h" << "hexa-h-frame" << "hexa-h-m1" << "hexa-h-m2" << "hexa-h-m3" << "hexa-h-m4" << "hexa-h-m5" << "hexa-h-m6"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6; @@ -110,6 +141,11 @@ void OutputCalibrationPage::setupVehicle() break; // KF hack case SetupWizard::FIXED_WING_AILERON: + if (QFile::exists(QString(":/setupwizard/resources/fixedwing-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/fixedwing-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } qDebug() << "no clue what a wizard index is!"; // m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; @@ -119,6 +155,11 @@ void OutputCalibrationPage::setupVehicle() getWizard()->setActuatorSettings(m_actuatorSettings); break; case SetupWizard::FIXED_WING_VTAIL: + if (QFile::exists(QString(":/setupwizard/resources/fixedwing-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/fixedwing-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } qDebug() << "no clue what a wizard index is!"; // m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4;