Commit 9e10b726 authored by Michael Carpenter's avatar Michael Carpenter

Implementation of Advanced Parameter List, with descriptions and names from the XML file

parent 1bf19f54
......@@ -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
......
#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));
}
#ifndef ADVPARAMETERLIST_H
#define ADVPARAMETERLIST_H
#include <QWidget>
#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<QString,QTableWidgetItem*> paramValueMap;
QMap<QString,QString> paramToNameMap;
QMap<QString,QString> paramToDescriptionMap;
Ui::AdvParameterList ui;
};
#endif // ADVPARAMETERLIST_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AdvParameterList</class>
<widget class="QWidget" name="AdvParameterList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>666</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;h2&gt;Advanced Parameter List&lt;/h2&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -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);
}
}
......
......@@ -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<QObject*,QWidget*> buttonToConfigWidgetMap;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment