Browse Source

Added auto-grouping of parameters by first underscore

QGC4.4
lm 15 years ago
parent
commit
c3cf5b7c2d
  1. 4
      src/QGC.h
  2. 6
      src/ui/HSIDisplay.cc
  3. 58
      src/ui/QGCParamWidget.cc

4
src/QGC.h

@ -6,7 +6,9 @@
namespace QGC namespace QGC
{ {
const QColor ColorCyan(55, 154, 195); const QColor colorCyan(55, 154, 195);
const QColor colorRed(154, 20, 20);
const QColor colorGreen(20, 200, 20);
/** @brief Get the current ground time in microseconds */ /** @brief Get the current ground time in microseconds */
quint64 groundTimeUsecs(); quint64 groundTimeUsecs();

6
src/ui/HSIDisplay.cc

@ -149,7 +149,7 @@ void HSIDisplay::paintDisplay()
lockStatusColor = QColor(255, 20, 20); lockStatusColor = QColor(255, 20, 20);
} }
paintText(tr("POS"), QGC::ColorCyan, 1.8f, 2.0f, 2.5f, &painter); paintText(tr("POS"), QGC::colorCyan, 1.8f, 2.0f, 2.5f, &painter);
painter.setBrush(lockStatusColor); painter.setBrush(lockStatusColor);
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.drawRect(QRect(refToScreenX(9.5f), refToScreenY(2.0f), refToScreenX(7.0f), refToScreenY(4.0f))); painter.drawRect(QRect(refToScreenX(9.5f), refToScreenY(2.0f), refToScreenX(7.0f), refToScreenY(4.0f)));
@ -204,14 +204,14 @@ void HSIDisplay::paintDisplay()
if (bodyXSetCoordinate != 0 || bodyYSetCoordinate != 0) if (bodyXSetCoordinate != 0 || bodyYSetCoordinate != 0)
{ {
// Draw setpoint // Draw setpoint
drawSetpointXY(bodyXSetCoordinate, bodyYSetCoordinate, bodyYawSet, QGC::ColorCyan, painter); drawSetpointXY(bodyXSetCoordinate, bodyYSetCoordinate, bodyYawSet, QGC::colorCyan, painter);
// Draw travel direction line // Draw travel direction line
QPointF m(bodyXSetCoordinate, bodyYSetCoordinate); QPointF m(bodyXSetCoordinate, bodyYSetCoordinate);
// Transform from body to world coordinates // Transform from body to world coordinates
m = metricWorldToBody(m); m = metricWorldToBody(m);
// Scale from metric body to screen reference units // Scale from metric body to screen reference units
QPointF s = metricBodyToRef(m); QPointF s = metricBodyToRef(m);
drawLine(s.x(), s.y(), xCenterPos, yCenterPos, 1.5f, QGC::ColorCyan, &painter); drawLine(s.x(), s.y(), xCenterPos, yCenterPos, 1.5f, QGC::colorCyan, &painter);
} }
// Labels on outer part and bottom // Labels on outer part and bottom

58
src/ui/QGCParamWidget.cc

@ -35,6 +35,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCParamWidget.h" #include "QGCParamWidget.h"
#include "UASInterface.h" #include "UASInterface.h"
#include <QDebug> #include <QDebug>
#include "QGC.h"
/** /**
* @param uas MAV to set the parameters on * @param uas MAV to set the parameters on
@ -137,11 +138,8 @@ void QGCParamWidget::addComponent(int uas, int component, QString componentName)
void QGCParamWidget::addParameter(int uas, int component, QString parameterName, float value) void QGCParamWidget::addParameter(int uas, int component, QString parameterName, float value)
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
// Insert parameter into map // Reference to item in tree
QStringList plist; QTreeWidgetItem* parameterItem;
plist.append(parameterName);
plist.append(QString::number(value));
QTreeWidgetItem* item = new QTreeWidgetItem(plist);
// Get component // Get component
if (!components->contains(component)) if (!components->contains(component))
@ -164,6 +162,34 @@ void QGCParamWidget::addParameter(int uas, int component, QString parameterName,
compParamGroups->insert(parent, item); compParamGroups->insert(parent, item);
components->value(component)->addChild(item); components->value(component)->addChild(item);
} }
// Append child to group
bool found = false;
QTreeWidgetItem* parentItem = compParamGroups->value(parent);
for (int i = 0; i < parentItem->childCount(); i++)
{
QTreeWidgetItem* child = parentItem->child(i);
QString key = child->data(0, Qt::DisplayRole).toString();
if (key == parameterName)
{
//qDebug() << "UPDATED CHILD";
parameterItem = child;
parameterItem->setData(1, Qt::DisplayRole, value);
found = true;
}
}
if (!found)
{
// Insert parameter into map
QStringList plist;
plist.append(parameterName);
plist.append(QString::number(value));
parameterItem = new QTreeWidgetItem(plist);
compParamGroups->value(parent)->addChild(parameterItem);
parameterItem>setFlags(item->flags() | Qt::ItemIsEditable);
}
} }
else else
{ {
@ -176,19 +202,28 @@ void QGCParamWidget::addParameter(int uas, int component, QString parameterName,
if (key == parameterName) if (key == parameterName)
{ {
//qDebug() << "UPDATED CHILD"; //qDebug() << "UPDATED CHILD";
child->setData(1, Qt::DisplayRole, value); parameterItem = child;
parameterItem->setData(1, Qt::DisplayRole, value);
found = true; found = true;
} }
} }
if (!found) if (!found)
{ {
components->value(component)->addChild(item); // Insert parameter into map
item->setFlags(item->flags() | Qt::ItemIsEditable); QStringList plist;
plist.append(parameterName);
plist.append(QString::number(value));
parameterItem = new QTreeWidgetItem(plist);
compParamGroups->value(parent)->addChild(parameterItem);
parameterItem>setFlags(item->flags() | Qt::ItemIsEditable);
} }
//connect(item, SIGNAL()) //tree->expandAll();
tree->expandAll();
} }
// Reset background color
current->setBackground(0, QBrush(QColor(QGC::colorGreen)));
current->setBackground(1, QBrush(QColor(QGC::colorGreen)));
tree->update(); tree->update();
} }
@ -231,7 +266,8 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* current, int column)
{ {
qDebug() << "PARAM CHANGED: COMP:" << key << "KEY:" << str << "VALUE:" << value; qDebug() << "PARAM CHANGED: COMP:" << key << "KEY:" << str << "VALUE:" << value;
map->insert(str, value); map->insert(str, value);
// FIXME CHANGE COLOR OF CHANGED PARAM current->setBackground(0, QBrush(QColor(QGC::colorGreen)));
current->setBackground(1, QBrush(QColor(QGC::colorGreen)));
} }
} }
} }

Loading…
Cancel
Save