From 9e10b726e9c5095ae279bcd7af34bdb2b0de25d9 Mon Sep 17 00:00:00 2001 From: Michael Carpenter Date: Wed, 10 Jul 2013 18:50:03 -0400 Subject: [PATCH] Implementation of Advanced Parameter List, with descriptions and names from the XML file --- qgroundcontrol.pro | 9 ++-- src/ui/configuration/AdvParameterList.cc | 55 +++++++++++++++++++++++ src/ui/configuration/AdvParameterList.h | 25 +++++++++++ src/ui/configuration/AdvParameterList.ui | 31 +++++++++++++ src/ui/configuration/ApmSoftwareConfig.cc | 7 +++ src/ui/configuration/ApmSoftwareConfig.h | 3 +- 6 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 src/ui/configuration/AdvParameterList.cc create mode 100644 src/ui/configuration/AdvParameterList.h create mode 100644 src/ui/configuration/AdvParameterList.ui diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 903223229..be5811b24 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -259,7 +259,8 @@ FORMS += src/ui/MainWindow.ui \ src/ui/configuration/ArduCopterPidConfig.ui \ src/ui/configuration/ApmPlaneLevel.ui \ src/ui/configuration/ParamWidget.ui \ - src/ui/configuration/ArduPlanePidConfig.ui + src/ui/configuration/ArduPlanePidConfig.ui \ + src/ui/configuration/AdvParameterList.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -443,7 +444,8 @@ HEADERS += src/MG.h \ src/ui/configuration/ArduCopterPidConfig.h \ src/ui/configuration/ApmPlaneLevel.h \ src/ui/configuration/ParamWidget.h \ - src/ui/configuration/ArduPlanePidConfig.h + src/ui/configuration/ArduPlanePidConfig.h \ + src/ui/configuration/AdvParameterList.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -645,7 +647,8 @@ SOURCES += src/main.cc \ src/ui/configuration/ArduCopterPidConfig.cc \ src/ui/configuration/ApmPlaneLevel.cc \ src/ui/configuration/ParamWidget.cc \ - src/ui/configuration/ArduPlanePidConfig.cc + src/ui/configuration/ArduPlanePidConfig.cc \ + src/ui/configuration/AdvParameterList.cc # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc diff --git a/src/ui/configuration/AdvParameterList.cc b/src/ui/configuration/AdvParameterList.cc new file mode 100644 index 000000000..5dccd0707 --- /dev/null +++ b/src/ui/configuration/AdvParameterList.cc @@ -0,0 +1,55 @@ +#include "AdvParameterList.h" + + +AdvParameterList::AdvParameterList(QWidget *parent) : AP2ConfigWidget(parent) +{ + ui.setupUi(this); + ui.tableWidget->setColumnCount(4); + ui.tableWidget->horizontalHeader()->hide(); + ui.tableWidget->verticalHeader()->hide(); + //ui.tableWidget->setHorizontalHeader(0); + //ui.tableWidget->setVerticalHeader(0); + ui.tableWidget->setColumnWidth(0,200); + ui.tableWidget->setColumnWidth(1,100); + ui.tableWidget->setColumnWidth(2,200); + ui.tableWidget->setColumnWidth(3,800); + +} + +AdvParameterList::~AdvParameterList() +{ +} +void AdvParameterList::setParameterMetaData(QString name,QString humanname,QString description) +{ + paramToNameMap[name] = humanname; + paramToDescriptionMap[name] = description; +} + +void AdvParameterList::parameterChanged(int uas, int component, QString parameterName, QVariant value) +{ + + if (!paramValueMap.contains(parameterName)) + { + ui.tableWidget->setRowCount(ui.tableWidget->rowCount()+1); + if (paramToNameMap.contains(parameterName)) + { + ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,0,new QTableWidgetItem(paramToNameMap[parameterName])); + } + else + { + ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,0,new QTableWidgetItem("Unknown")); + } + ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,1,new QTableWidgetItem(QString::number(value.toFloat(),'g',2))); + ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,2,new QTableWidgetItem(parameterName)); + if (paramToDescriptionMap.contains(parameterName)) + { + ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,3,new QTableWidgetItem(paramToDescriptionMap[parameterName])); + } + else + { + ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,3,new QTableWidgetItem("Unknown")); + } + paramValueMap[parameterName] = ui.tableWidget->item(ui.tableWidget->rowCount()-1,1); + } + paramValueMap[parameterName]->setText(QString::number(value.toFloat(),'g',2)); +} diff --git a/src/ui/configuration/AdvParameterList.h b/src/ui/configuration/AdvParameterList.h new file mode 100644 index 000000000..6a530f9f1 --- /dev/null +++ b/src/ui/configuration/AdvParameterList.h @@ -0,0 +1,25 @@ +#ifndef ADVPARAMETERLIST_H +#define ADVPARAMETERLIST_H + +#include +#include "ui_AdvParameterList.h" +#include "AP2ConfigWidget.h" + +class AdvParameterList : public AP2ConfigWidget +{ + Q_OBJECT + +public: + explicit AdvParameterList(QWidget *parent = 0); + void setParameterMetaData(QString name,QString humanname,QString description); + ~AdvParameterList(); +private slots: + void parameterChanged(int uas, int component, QString parameterName, QVariant value); +private: + QMap paramValueMap; + QMap paramToNameMap; + QMap paramToDescriptionMap; + Ui::AdvParameterList ui; +}; + +#endif // ADVPARAMETERLIST_H diff --git a/src/ui/configuration/AdvParameterList.ui b/src/ui/configuration/AdvParameterList.ui new file mode 100644 index 000000000..9b9d40849 --- /dev/null +++ b/src/ui/configuration/AdvParameterList.ui @@ -0,0 +1,31 @@ + + + AdvParameterList + + + + 0 + 0 + 666 + 497 + + + + Form + + + + + + <h2>Advanced Parameter List</h2> + + + + + + + + + + + diff --git a/src/ui/configuration/ApmSoftwareConfig.cc b/src/ui/configuration/ApmSoftwareConfig.cc index a12719cf7..c8e1261b6 100644 --- a/src/ui/configuration/ApmSoftwareConfig.cc +++ b/src/ui/configuration/ApmSoftwareConfig.cc @@ -47,6 +47,11 @@ ApmSoftwareConfig::ApmSoftwareConfig(QWidget *parent) : QWidget(parent) buttonToConfigWidgetMap[ui.advancedParamButton] = advancedParamConfig; connect(ui.advancedParamButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget())); + advParameterList = new AdvParameterList(this); + ui.stackedWidget->addWidget(advParameterList); + buttonToConfigWidgetMap[ui.advParamListButton] = advParameterList; + connect(ui.advParamListButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget())); + arduCopterPidConfig = new ArduCopterPidConfig(this); ui.stackedWidget->addWidget(arduCopterPidConfig); buttonToConfigWidgetMap[ui.arduCopterPidButton] = arduCopterPidConfig; @@ -312,6 +317,7 @@ void ApmSoftwareConfig::activeUASSet(UASInterface *uas) { advancedParamConfig->addCombo(humanname,docs,name,valuelist); } + advParameterList->setParameterMetaData(name,humanname,docs); } else if (fieldmap.size() > 0) { @@ -341,6 +347,7 @@ void ApmSoftwareConfig::activeUASSet(UASInterface *uas) { advancedParamConfig->addRange(humanname,docs,name,max,min); } + advParameterList->setParameterMetaData(name,humanname,docs); } } diff --git a/src/ui/configuration/ApmSoftwareConfig.h b/src/ui/configuration/ApmSoftwareConfig.h index d314450e2..700a82067 100644 --- a/src/ui/configuration/ApmSoftwareConfig.h +++ b/src/ui/configuration/ApmSoftwareConfig.h @@ -11,7 +11,7 @@ #include "AdvancedParamConfig.h" #include "ArduCopterPidConfig.h" #include "ArduPlanePidConfig.h" - +#include "AdvParameterList.h" #include "UASInterface.h" #include "UASManager.h" @@ -35,6 +35,7 @@ private: AdvancedParamConfig *advancedParamConfig; ArduCopterPidConfig *arduCopterPidConfig; ArduPlanePidConfig *arduPlanePidConfig; + AdvParameterList *advParameterList; QMap buttonToConfigWidgetMap; }; -- 2.22.0