diff --git a/src/ui/HSIDisplay.cc b/src/ui/HSIDisplay.cc index b024584a8ae74516a7032388709ce070ffd34b0a..d3a2a9d2a3ec2a0c749ec06a99a47d36eec66f42 100644 --- a/src/ui/HSIDisplay.cc +++ b/src/ui/HSIDisplay.cc @@ -183,6 +183,9 @@ HSIDisplay::HSIDisplay(QWidget *parent) : setActiveUAS(UASManager::instance()->getActiveUAS()); } + connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), + this, SLOT(setActiveUAS(UASInterface*))); + connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); diff --git a/src/ui/QGCVehicleConfig.cc b/src/ui/QGCVehicleConfig.cc index 81ffb140d43d12c72bfdf153020f88bce25cccbd..9e04dd48641ebdbdd99314cfb8da775c9c456cf6 100644 --- a/src/ui/QGCVehicleConfig.cc +++ b/src/ui/QGCVehicleConfig.cc @@ -256,19 +256,21 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) //TODO: Throw an error here too, no autopilot specific configuration qWarning() << "Invalid vehicle dir, no vehicle specific configuration will be loaded."; } + + // Generate widgets for the General tab. QGCToolWidget *tool; bool left = true; foreach (QString file,generaldir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { if (file.toLower().endsWith(".qgw")) { - tool = new QGCToolWidget("", this); + QWidget* parent = left?ui->generalLeftContents:ui->generalRightContents; + tool = new QGCToolWidget("", parent); if (tool->loadSettings(generaldir.absoluteFilePath(file), false)) { toolWidgets.append(tool); - //ui->sensorLayout->addWidget(tool); - QGroupBox *box = new QGroupBox(this); + QGroupBox *box = new QGroupBox(parent); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); if (left) { @@ -285,18 +287,20 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) } } } + + // Generate widgets for the Advanced tab. left = true; foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { if (file.toLower().endsWith(".qgw")) { - tool = new QGCToolWidget("", this); + QWidget* parent = left?ui->advancedLeftContents:ui->advancedRightContents; + tool = new QGCToolWidget("", parent); if (tool->loadSettings(vehicledir.absoluteFilePath(file), false)) { toolWidgets.append(tool); - //ui->sensorLayout->addWidget(tool); - QGroupBox *box = new QGroupBox(this); + QGroupBox *box = new QGroupBox(parent); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); if (left) { @@ -314,7 +318,7 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) } } - //Load tabs for general configuration + // Load tabs for general configuration foreach (QString dir,generaldir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { QPushButton *button = new QPushButton(ui->scrollAreaWidgetContents_3); @@ -331,10 +335,10 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) buttonToWidgetMap[button] = tab; tab->setLayout(new QVBoxLayout()); tab->show(); - QScrollArea *area = new QScrollArea(); + QScrollArea *area = new QScrollArea(tab); tab->layout()->addWidget(area); - QWidget *scrollArea = new QWidget(); - scrollArea->setLayout(new QVBoxLayout()); + QWidget *scrollArea = new QWidget(tab); + scrollArea->setLayout(new QVBoxLayout(tab)); area->setWidget(scrollArea); area->setWidgetResizable(true); area->show(); @@ -343,14 +347,14 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) foreach (QString file,newdir.entryList(QDir::Files| QDir::NoDotAndDotDot)) { if (file.toLower().endsWith(".qgw")) { - tool = new QGCToolWidget("", this); + tool = new QGCToolWidget("", tab); if (tool->loadSettings(newdir.absoluteFilePath(file), false)) { toolWidgets.append(tool); //ui->sensorLayout->addWidget(tool); - QGroupBox *box = new QGroupBox(this); + QGroupBox *box = new QGroupBox(tab); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(tab)); box->layout()->addWidget(tool); scrollArea->layout()->addWidget(box); } else { @@ -360,7 +364,7 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) } } - //Load tabs for vehicle specific configuration + // Load additional tabs for vehicle specific configuration foreach (QString dir,vehicledir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { //QWidget *tab = new QWidget(ui->tabWidget); @@ -379,10 +383,10 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) button->setText(dir); tab->setLayout(new QVBoxLayout()); tab->show(); - QScrollArea *area = new QScrollArea(); + QScrollArea *area = new QScrollArea(tab); tab->layout()->addWidget(area); - QWidget *scrollArea = new QWidget(); - scrollArea->setLayout(new QVBoxLayout()); + QWidget *scrollArea = new QWidget(tab); + scrollArea->setLayout(new QVBoxLayout(tab)); area->setWidget(scrollArea); area->setWidgetResizable(true); area->show(); @@ -392,15 +396,15 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) foreach (QString file,newdir.entryList(QDir::Files| QDir::NoDotAndDotDot)) { if (file.toLower().endsWith(".qgw")) { - tool = new QGCToolWidget("", this); + tool = new QGCToolWidget("", tab); tool->addUAS(mav); if (tool->loadSettings(newdir.absoluteFilePath(file), false)) { toolWidgets.append(tool); //ui->sensorLayout->addWidget(tool); - QGroupBox *box = new QGroupBox(); + QGroupBox *box = new QGroupBox(tab); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); scrollArea->layout()->addWidget(box); box->show(); @@ -412,30 +416,31 @@ void QGCVehicleConfig::loadQgcConfig(bool primary) } } - // Load calibration + // Load general calibration for autopilot //TODO: Handle this more gracefully, maybe have it scan the directory for multiple calibration entries? - tool = new QGCToolWidget("", this); + tool = new QGCToolWidget("", ui->sensorContents); tool->addUAS(mav); if (tool->loadSettings(autopilotdir.absolutePath() + "/general/calibration/calibration.qgw", false)) { toolWidgets.append(tool); - QGroupBox *box = new QGroupBox(this); + QGroupBox *box = new QGroupBox(ui->sensorContents); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); ui->sensorLayout->addWidget(box); } else { delete tool; } - tool = new QGCToolWidget("", this); + // Load vehicle-specific autopilot configuration + tool = new QGCToolWidget("", ui->sensorContents); tool->addUAS(mav); if (tool->loadSettings(autopilotdir.absolutePath() + "/" + mav->getSystemTypeName().toLower() + "/calibration/calibration.qgw", false)) { toolWidgets.append(tool); - QGroupBox *box = new QGroupBox(this); + QGroupBox *box = new QGroupBox(ui->sensorContents); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); ui->sensorLayout->addWidget(box); } else { @@ -494,7 +499,7 @@ void QGCVehicleConfig::loadConfig() QXmlStreamReader xml(xmlfile.readAll()); xmlfile.close(); - //TODO: Testing to ensure that incorrectly formated XML won't break this. + //TODO: Testing to ensure that incorrectly formatted XML won't break this. while (!xml.atEnd()) { if (xml.isStartElement() && xml.name() == "paramfile") @@ -674,7 +679,16 @@ void QGCVehicleConfig::loadConfig() } if (genarraycount > 0) { - tool = new QGCToolWidget("", this); + QWidget* parent = this; + if (valuetype == "vehicles") + { + parent = ui->generalLeftContents; + } + else if (valuetype == "libraries") + { + parent = ui->generalRightContents; + } + tool = new QGCToolWidget("", parent); tool->addUAS(mav); tool->setTitle(parametersname); tool->setObjectName(parametersname); @@ -702,9 +716,9 @@ void QGCVehicleConfig::loadConfig() } toolWidgets.append(tool); - QGroupBox *box = new QGroupBox(this); + QGroupBox *box = new QGroupBox(parent); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); if (valuetype == "vehicles") { @@ -719,7 +733,16 @@ void QGCVehicleConfig::loadConfig() } if (advarraycount > 0) { - tool = new QGCToolWidget("", this); + QWidget* parent = this; + if (valuetype == "vehicles") + { + parent = ui->generalLeftContents; + } + else if (valuetype == "libraries") + { + parent = ui->generalRightContents; + } + tool = new QGCToolWidget("", parent); tool->addUAS(mav); tool->setTitle(parametersname); tool->setObjectName(parametersname); @@ -747,31 +770,25 @@ void QGCVehicleConfig::loadConfig() } toolWidgets.append(tool); - QGroupBox *box = new QGroupBox(this); + QGroupBox *box = new QGroupBox(parent); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); if (valuetype == "vehicles") { - ui->leftAdvancedLayout->addWidget(box); + ui->leftGeneralLayout->addWidget(box); } else if (valuetype == "libraries") { - ui->rightAdvancedLayout->addWidget(box); + ui->rightGeneralLayout->addWidget(box); } box->hide(); toolToBoxMap[tool] = box; } - - - - } xml.readNext(); } - } - xml.readNext(); } } @@ -785,7 +802,7 @@ void QGCVehicleConfig::loadConfig() void QGCVehicleConfig::setActiveUAS(UASInterface* active) { - // Do nothing if system is the same or NULL + // Do nothing if system is the same if (mav == active) return; if (mav) @@ -796,11 +813,41 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active) disconnect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, SLOT(parameterChanged(int,int,QString,QVariant))); - foreach (QGCToolWidget* tool, toolWidgets) + // Delete all children from all fixed tabs. + foreach(QWidget* child, ui->generalLeftContents->findChildren()) + { + child->deleteLater(); + } + foreach(QWidget* child, ui->generalRightContents->findChildren()) + { + child->deleteLater(); + } + foreach(QWidget* child, ui->advancedLeftContents->findChildren()) + { + child->deleteLater(); + } + foreach(QWidget* child, ui->advancedRightContents->findChildren()) + { + child->deleteLater(); + } + foreach(QWidget* child, ui->sensorContents->findChildren()) + { + child->deleteLater(); + } + + // And then delete any custom tabs + foreach(QWidget* child, additionalTabs) { - delete tool; + child->deleteLater(); } + additionalTabs.clear(); + toolWidgets.clear(); + paramToWidgetMap = NULL; + libParamToWidgetMap.clear(); + systemTypeToParamMap.clear(); + toolToBoxMap.clear(); + paramTooltips.clear(); } // Reset current state @@ -811,7 +858,7 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active) // Connect new system mav = active; if (mav) - { + { connect(active, SIGNAL(remoteControlChannelRawChanged(int,float)), this, SLOT(remoteControlChannelRawChanged(int,float))); connect(active, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, @@ -819,13 +866,13 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active) if (systemTypeToParamMap.contains(mav->getSystemTypeName())) { - paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()]; + paramToWidgetMap = &systemTypeToParamMap[mav->getSystemTypeName()]; } else { //Indication that we have no meta data for this system type. qDebug() << "No parameters defined for system type:" << mav->getSystemTypeName(); - paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()]; + paramToWidgetMap = &systemTypeToParamMap[mav->getSystemTypeName()]; } if (!paramTooltips.isEmpty()) @@ -842,7 +889,7 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active) updateStatus(QString("Reading from system %1").arg(mav->getUASName())); // Since a system is now connected, enable the VehicleConfig UI. - //ui->tabWidget->setEnabled(true); + ui->tabWidget->setEnabled(true); ui->setButton->setEnabled(true); ui->refreshButton->setEnabled(true); ui->readButton->setEnabled(true); @@ -1139,7 +1186,18 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete if (!found) { //New param type, create a QGroupBox for it. - QGCToolWidget *tool = new QGCToolWidget("", this); + QWidget* parent; + if (ui->leftAdvancedLayout->count() > ui->rightAdvancedLayout->count()) + { + parent = ui->advancedRightContents; + } + else + { + parent = ui->advancedLeftContents; + } + + // Create the tool, attaching it to the QGroupBox + QGCToolWidget *tool = new QGCToolWidget("", parent); QString tooltitle = parameterName; if (parameterName.split("_").size() > 1) { @@ -1148,14 +1206,17 @@ void QGCVehicleConfig::parameterChanged(int uas, int component, QString paramete tool->setTitle(tooltitle); tool->setObjectName(tooltitle); //tool->setSettings(set); - tool->addParam(uas,component,parameterName,value); libParamToWidgetMap.insert(parameterName,tool); toolWidgets.append(tool); - QGroupBox *box = new QGroupBox(this); + tool->addParam(uas, component, parameterName, value); + QGroupBox *box = new QGroupBox(parent); box->setTitle(tool->objectName()); - box->setLayout(new QVBoxLayout()); + box->setLayout(new QVBoxLayout(box)); box->layout()->addWidget(tool); + libParamToWidgetMap.insert(parameterName,tool); + toolWidgets.append(tool); + //Make sure we have similar number of widgets on each side. if (ui->leftAdvancedLayout->count() > ui->rightAdvancedLayout->count()) diff --git a/src/ui/QGCVehicleConfig.ui b/src/ui/QGCVehicleConfig.ui index 9bbc7af163ffb056189af2021cad08898a2665a4..24e9e663d755ed46ff6c16e6e30e67a7068f3420 100644 --- a/src/ui/QGCVehicleConfig.ui +++ b/src/ui/QGCVehicleConfig.ui @@ -34,8 +34,13 @@ 16777215 +<<<<<<< HEAD true +======= + + 0 +>>>>>>> 975f41067229245752f23de45b80ca4a7e28642d @@ -1070,9 +1075,20 @@ p, li { white-space: pre-wrap; } Configuration +<<<<<<< HEAD 0 +======= + + + + 0 + 0 + 362 + 489 + +>>>>>>> 975f41067229245752f23de45b80ca4a7e28642d @@ -1193,11 +1209,104 @@ p, li { white-space: pre-wrap; } false +<<<<<<< HEAD Copy parameters from permanent memory to non-permanent current memory of aircraft. DOES NOT update the parameters in this view, click refresh after copying them to get them. +======= + + + 0 + + + + + true + + + + + 0 + 0 + 356 + 438 + + + + + 0 + + + + + + + + + + + + + + + Configuration + + + + 0 + + + + + true + + + + + 0 + 0 + 356 + 438 + + + + + 0 + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Advanced Config + + + + + + + + Qt::Horizontal +>>>>>>> 975f41067229245752f23de45b80ca4a7e28642d @@ -1247,12 +1356,106 @@ p, li { white-space: pre-wrap; } Save parameters in this view to a file on this computer. +<<<<<<< HEAD +======= + + + QLayout::SetNoConstraint + + + 0 + + + + + true + + + + + 0 + 0 + 356 + 438 + + + + + 0 + 0 + + + + + 0 + + + + + 0 + + + + + + + + + + + + + + + 0 + 0 + +>>>>>>> 975f41067229245752f23de45b80ca4a7e28642d Save (File) +<<<<<<< HEAD +======= + + + 0 + + + + + true + + + + + 0 + 0 + 356 + 438 + + + + + 0 + 0 + + + + + 0 + + + + + + + + + +>>>>>>> 975f41067229245752f23de45b80ca4a7e28642d diff --git a/src/ui/uas/UASControlWidget.cc b/src/ui/uas/UASControlWidget.cc index 8effb85e438affb9fceedb9593f4620ff79cab41..5c43eddce76117967531fcb66b702e81c1b15cbf 100644 --- a/src/ui/uas/UASControlWidget.cc +++ b/src/ui/uas/UASControlWidget.cc @@ -70,7 +70,7 @@ UASControlWidget::UASControlWidget(QWidget *parent) : QWidget(parent), void UASControlWidget::setUAS(UASInterface* uas) { - if (this->uas) + if (this->uas) { UASInterface* oldUAS = UASManager::instance()->getUASForId(this->uas); disconnect(ui.controlButton, SIGNAL(clicked()), oldUAS, SLOT(armSystem())); diff --git a/src/ui/uas/UASQuickView.cc b/src/ui/uas/UASQuickView.cc index a5d81e23c00293ebab13666256d93dcf2964881f..7465b200643565c3407c7a410f34d2f0921a4220 100644 --- a/src/ui/uas/UASQuickView.cc +++ b/src/ui/uas/UASQuickView.cc @@ -69,6 +69,17 @@ void UASQuickView::saveSettings() settings.setArrayIndex(count++); settings.setValue("name",i.key()); settings.setValue("type","text"); +======= + QAction *action = new QAction(tr("longitude"),this); + action->setCheckable(true); + action->setChecked(true); + connect(action,SIGNAL(toggled(bool)),this,SLOT(actionTriggered(bool))); + this->addAction(action); + UASQuickViewItem *item = new UASQuickViewItem(this); + item->setTitle(tr("longitude")); + this->layout()->addWidget(item); + uasPropertyToLabelMap["longitude"] = item; +>>>>>>> 975f41067229245752f23de45b80ca4a7e28642d } settings.endArray(); settings.sync(); @@ -80,6 +91,7 @@ void UASQuickView::loadSettings() int size = settings.beginReadArray("UAS_QUICK_VIEW_ITEMS"); for (int i=0;iuas) { uasPropertyValueMap.clear(); @@ -259,6 +272,9 @@ void UASQuickView::valueChanged(const int uasId, const QString& name, const QStr { quickViewSelectDialog->addItem(name); } + + // And periodically update the view. + updateTimer->start(1000); } uasPropertyValueMap[name] = value; }