From 64bb126e20ec2d5240f96b2b2ba7ed40cd7d0638 Mon Sep 17 00:00:00 2001 From: tstellanova Date: Tue, 30 Jul 2013 12:52:38 -0700 Subject: [PATCH] Start adjusting config UI Start move to single column layout for advanced parameters; Fix crashing bug in PrimaryFlightDisplay when uas is removed and then re-added; workaround compiler warning in GeneralBlockPanelKernel, --- .../Core/products/GeneralBlockPanelKernel.h | 5 +- src/ui/PrimaryFlightDisplay.cc | 3 + src/ui/QGCConfigView.cc | 48 ++++++++------- src/ui/QGCPX4VehicleConfig.cc | 60 +++++++------------ src/ui/QGCPX4VehicleConfig.ui | 55 +++++------------ 5 files changed, 66 insertions(+), 105 deletions(-) diff --git a/libs/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/libs/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h index 2116dcc74..e0344e62a 100644 --- a/libs/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +++ b/libs/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h @@ -88,7 +88,7 @@ void computeProductBlockingSizes(std::ptrdiff_t& k, std::ptrdiff_t& m, std::ptrd // at the register level. For vectorization purpose, these small vertical panels are unpacked, // e.g., each coefficient is replicated to fit a packet. This small vertical panel has to // stay in L1 cache. - std::ptrdiff_t l1, l2; + std::ptrdiff_t l1, l2, initial_n; typedef gebp_traits Traits; enum { @@ -98,11 +98,12 @@ void computeProductBlockingSizes(std::ptrdiff_t& k, std::ptrdiff_t& m, std::ptrd mr_mask = (0xffffffff/mr)*mr }; + initial_n = n; manage_caching_sizes(GetAction, &l1, &l2); k = std::min(k, l1/kdiv); std::ptrdiff_t _m = k>0 ? l2/(4 * sizeof(LhsScalar) * k) : 0; if(_m diff --git a/src/ui/PrimaryFlightDisplay.cc b/src/ui/PrimaryFlightDisplay.cc index a68acdf54..d0070d229 100644 --- a/src/ui/PrimaryFlightDisplay.cc +++ b/src/ui/PrimaryFlightDisplay.cc @@ -293,6 +293,9 @@ void PrimaryFlightDisplay::forgetUAS(UASInterface* uas) */ void PrimaryFlightDisplay::setActiveUAS(UASInterface* uas) { + if (uas == this->uas) + return; //no need to rewire + // Disconnect the previous one (if any) forgetUAS(this->uas); diff --git a/src/ui/QGCConfigView.cc b/src/ui/QGCConfigView.cc index b33e6e664..ff88f313a 100644 --- a/src/ui/QGCConfigView.cc +++ b/src/ui/QGCConfigView.cc @@ -14,12 +14,9 @@ QGCConfigView::QGCConfigView(QWidget *parent) : connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(activeUASChanged(UASInterface*))); - if (ui->waitingLabel) { - ui->gridLayout->removeWidget(ui->waitingLabel); - delete ui->waitingLabel; - ui->waitingLabel = NULL; - } - ui->gridLayout->addWidget(new QGCPX4VehicleConfig()); + //don't show a configuration widget if no vehicle is connected + //show a placeholder informational widget instead + } QGCConfigView::~QGCConfigView() @@ -32,26 +29,31 @@ void QGCConfigView::activeUASChanged(UASInterface* uas) if (currUAS == uas) return; - if (ui->waitingLabel) { - ui->gridLayout->removeWidget(ui->waitingLabel); - delete ui->waitingLabel; - ui->waitingLabel = NULL; - } - - if (currUAS && currUAS->getAutopilotType() != uas->getAutopilotType()) { - foreach (QObject* obj, ui->gridLayout->children()) { - QWidget* w = dynamic_cast(obj); - if (w) { - ui->gridLayout->removeWidget(w); + //remove all child widgets since they could contain stale data + //for example, when we switch from one PX4 UAS to another UAS + foreach (QObject* obj, ui->gridLayout->children()) { + QWidget* w = dynamic_cast(obj); + if (w) { + ui->gridLayout->removeWidget(w); + if (obj != ui->waitingLabel) delete obj; - } } } - switch (uas->getAutopilotType()) { - case MAV_AUTOPILOT_PX4: - ui->gridLayout->addWidget(new QGCPX4VehicleConfig()); - default: - ui->gridLayout->addWidget(new QGCVehicleConfig()); + if (NULL != uas) { + ui->gridLayout->removeWidget(ui->waitingLabel); + + switch (uas->getAutopilotType()) { + case MAV_AUTOPILOT_PX4: + ui->gridLayout->addWidget(new QGCPX4VehicleConfig()); + break; + default: + ui->gridLayout->addWidget(new QGCVehicleConfig()); + } } + else { + //restore waiting label if we no longer have a connection + ui->gridLayout->addWidget(ui->waitingLabel); + } + } diff --git a/src/ui/QGCPX4VehicleConfig.cc b/src/ui/QGCPX4VehicleConfig.cc index a0c01d0f5..b61a81a15 100644 --- a/src/ui/QGCPX4VehicleConfig.cc +++ b/src/ui/QGCPX4VehicleConfig.cc @@ -18,6 +18,12 @@ #include "QGCToolWidget.h" #include "ui_QGCPX4VehicleConfig.h" + +#define WIDGET_INDEX_RC 0 +#define WIDGET_INDEX_SENSOR_CAL 1 +#define WIDGET_INDEX_GENERAL_CONFIG 2 +#define WIDGET_INDEX_ADV_CONFIG 3 + QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : QWidget(parent), mav(NULL), @@ -107,22 +113,23 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : } void QGCPX4VehicleConfig::rcMenuButtonClicked() { - ui->stackedWidget->setCurrentIndex(0); + //TODO eg ui->stackedWidget->findChild("rcConfig"); + ui->stackedWidget->setCurrentIndex(WIDGET_INDEX_RC); } void QGCPX4VehicleConfig::sensorMenuButtonClicked() { - ui->stackedWidget->setCurrentIndex(1); + ui->stackedWidget->setCurrentIndex(WIDGET_INDEX_SENSOR_CAL); } void QGCPX4VehicleConfig::generalMenuButtonClicked() { - ui->stackedWidget->setCurrentIndex(ui->stackedWidget->count()-2); + ui->stackedWidget->setCurrentIndex(WIDGET_INDEX_GENERAL_CONFIG); } void QGCPX4VehicleConfig::advancedMenuButtonClicked() { - ui->stackedWidget->setCurrentIndex(ui->stackedWidget->count()-1); + ui->stackedWidget->setCurrentIndex(WIDGET_INDEX_ADV_CONFIG); } QGCPX4VehicleConfig::~QGCPX4VehicleConfig() @@ -288,7 +295,7 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary) foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { if (file.toLower().endsWith(".qgw")) { - QWidget* parent = left?ui->advancedLeftContents:ui->advancedRightContents; + QWidget* parent = ui->advanceColumnContents; tool = new QGCToolWidget("", parent); if (tool->loadSettings(vehicledir.absoluteFilePath(file), false)) { @@ -297,16 +304,8 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary) box->setTitle(tool->objectName()); box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); - if (left) - { - left = false; - ui->advancedLeftLayout->addWidget(box); - } - else - { - left = true; - ui->advancedRightLayout->addWidget(box); - } + ui->advancedColumnLayout->addWidget(box); + } else { delete tool; } @@ -808,8 +807,9 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) } - // Do nothing if system is the same - if (mav == active) return; + // Do nothing if UAS is already visible + if (mav == active) + return; if (mav) { @@ -829,11 +829,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) { child->deleteLater(); } - foreach(QWidget* child, ui->advancedLeftContents->findChildren()) - { - child->deleteLater(); - } - foreach(QWidget* child, ui->advancedRightContents->findChildren()) + foreach(QWidget* child, ui->advanceColumnContents->findChildren()) { child->deleteLater(); } @@ -1184,15 +1180,7 @@ void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString param if (!found) { //New param type, create a QGroupBox for it. - QWidget* parent; - if (ui->advancedLeftLayout->count() > ui->advancedRightLayout->count()) - { - parent = ui->advancedRightContents; - } - else - { - parent = ui->advancedLeftContents; - } + QWidget* parent = ui->advanceColumnContents; // Create the tool, attaching it to the QGroupBox QGCToolWidget *tool = new QGCToolWidget("", parent); @@ -1214,16 +1202,8 @@ void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString param libParamToWidgetMap.insert(parameterName,tool); toolWidgets.append(tool); + ui->advancedColumnLayout->addWidget(box); - // Make sure we have similar number of widgets on each side. - if (ui->advancedLeftLayout->count() > ui->advancedRightLayout->count()) - { - ui->advancedRightLayout->addWidget(box); - } - else - { - ui->advancedLeftLayout->addWidget(box); - } toolToBoxMap[tool] = box; } } diff --git a/src/ui/QGCPX4VehicleConfig.ui b/src/ui/QGCPX4VehicleConfig.ui index 883dfd72f..6535f127c 100644 --- a/src/ui/QGCPX4VehicleConfig.ui +++ b/src/ui/QGCPX4VehicleConfig.ui @@ -7,7 +7,7 @@ 0 0 1256 - 711 + 783 @@ -43,7 +43,7 @@ 0 0 133 - 691 + 757 @@ -889,7 +889,7 @@ Config <!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:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> <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-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></body></html> @@ -906,8 +906,8 @@ p, li { white-space: pre-wrap; } 0 0 - 530 - 574 + 26 + 26 @@ -981,8 +981,8 @@ p, li { white-space: pre-wrap; } 0 0 - 525 - 523 + 16 + 16 @@ -1018,8 +1018,8 @@ p, li { white-space: pre-wrap; } 0 0 - 524 - 523 + 16 + 16 @@ -1065,10 +1065,10 @@ p, li { white-space: pre-wrap; } - + - + Load Platform Defaults @@ -1092,13 +1092,13 @@ p, li { white-space: pre-wrap; } true - + 0 0 - 525 - 523 + 928 + 562 @@ -1106,7 +1106,7 @@ p, li { white-space: pre-wrap; } 0 - + @@ -1124,31 +1124,6 @@ p, li { white-space: pre-wrap; } 0 - - - - true - - - - - 0 - 0 - 524 - 523 - - - - - 0 - - - - - - - - -- 2.22.0