From d8e1d849f5d285cba3516c54b19376b2c49b306b Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Tue, 21 Jan 2014 23:08:13 +0100 Subject: [PATCH 1/5] OP-1183 UAVObjectBrowser now displays and allows editing of integers in hex format (when unit is set to hex) +review OPReview --- .../plugins/uavobjectbrowser/fieldtreeitem.h | 137 +++++++++++++++++- .../uavobjectbrowser/uavobjecttreemodel.cpp | 9 +- 2 files changed, 136 insertions(+), 10 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h index 31cf9ecb3..64e639eea 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h @@ -51,18 +51,23 @@ class FieldTreeItem : public TreeItem { Q_OBJECT public: + FieldTreeItem(int index, const QList &data, TreeItem *parent = 0) : TreeItem(data, parent), m_index(index) {} + FieldTreeItem(int index, const QVariant &data, TreeItem *parent = 0) : TreeItem(data, parent), m_index(index) {} + bool isEditable() { return true; } + virtual QWidget *createEditor(QWidget *parent) = 0; virtual QVariant getEditorValue(QWidget *editor) = 0; virtual void setEditorValue(QWidget *editor, QVariant value) = 0; virtual void apply() {} + protected: int m_index; }; @@ -70,12 +75,12 @@ protected: class EnumFieldTreeItem : public FieldTreeItem { Q_OBJECT public: - EnumFieldTreeItem(UAVObjectField *field, int index, const QList &data, - TreeItem *parent = 0) : + EnumFieldTreeItem(UAVObjectField *field, int index, const QList &data, TreeItem *parent = 0) : FieldTreeItem(index, data, parent), m_enumOptions(field->getOptions()), m_field(field) {} - EnumFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, - TreeItem *parent = 0) : + + EnumFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) : FieldTreeItem(index, data, parent), m_enumOptions(field->getOptions()), m_field(field) {} + void setData(QVariant value, int column) { QStringList options = m_field->getOptions(); @@ -85,6 +90,7 @@ public: setChanged(tmpValIndex != value); TreeItem::setData(value, column); } + QString enumOptions(int index) { if ((index < 0) || (index >= m_enumOptions.length())) { @@ -92,6 +98,7 @@ public: } return m_enumOptions.at(index); } + void apply() { int value = data(dataColumn).toInt(); @@ -100,6 +107,7 @@ public: m_field->setValue(options[value], m_index); setChanged(false); } + void update() { QStringList options = m_field->getOptions(); @@ -111,14 +119,16 @@ public: setHighlight(true); } } + QWidget *createEditor(QWidget *parent) { QComboBox *editor = new QComboBox(parent); // Setting ClickFocus lets the ComboBox stay open on Mac OSX. editor->setFocusPolicy(Qt::ClickFocus); - foreach(QString option, m_enumOptions) - editor->addItem(option); + foreach(QString option, m_enumOptions) { + editor->addItem(option); + } return editor; } @@ -135,6 +145,7 @@ public: comboBox->setCurrentIndex(value.toInt()); } + private: QStringList m_enumOptions; UAVObjectField *m_field; @@ -148,6 +159,7 @@ public: { setMinMaxValues(); } + IntFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) : FieldTreeItem(index, data, parent), m_field(field) { @@ -210,16 +222,19 @@ public: spinBox->setValue(value.toInt()); } + void setData(QVariant value, int column) { setChanged(m_field->getValue(m_index) != value); TreeItem::setData(value, column); } + void apply() { m_field->setValue(data(dataColumn).toInt(), m_index); setChanged(false); } + void update() { int value = m_field->getValue(m_index).toInt(); @@ -241,18 +256,22 @@ class FloatFieldTreeItem : public FieldTreeItem { public: FloatFieldTreeItem(UAVObjectField *field, int index, const QList &data, bool scientific = false, TreeItem *parent = 0) : FieldTreeItem(index, data, parent), m_field(field), m_useScientificNotation(scientific) {} + FloatFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, bool scientific = false, TreeItem *parent = 0) : FieldTreeItem(index, data, parent), m_field(field), m_useScientificNotation(scientific) {} + void setData(QVariant value, int column) { setChanged(m_field->getValue(m_index) != value); TreeItem::setData(value, column); } + void apply() { m_field->setValue(data(dataColumn).toDouble(), m_index); setChanged(false); } + void update() { double value = m_field->getValue(m_index).toDouble(); @@ -303,9 +322,115 @@ public: spinBox->setValue(value.toDouble()); } } + private: UAVObjectField *m_field; bool m_useScientificNotation; }; +class HexFieldTreeItem : public FieldTreeItem { + Q_OBJECT +public: + HexFieldTreeItem(UAVObjectField *field, int index, const QList &data, TreeItem *parent = 0) : + FieldTreeItem(index, data, parent), m_field(field) + {} + + HexFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) : + FieldTreeItem(index, data, parent), m_field(field) + {} + + QWidget *createEditor(QWidget *parent) + { + QLineEdit *lineEdit = new QLineEdit(parent); + + lineEdit->setInputMask(QString(maxLength(), 'H')); + + return lineEdit; + } + + QVariant getEditorValue(QWidget *editor) + { + QLineEdit *lineEdit = static_cast(editor); + + return lineEdit->text(); + } + + void setEditorValue(QWidget *editor, QVariant value) + { + QLineEdit *lineEdit = static_cast(editor); + + lineEdit->setText(value.toString()); + } + + void setData(QVariant value, int column) + { + setChanged(m_field->getValue(m_index) != value); + TreeItem::setData(value, column); + } + + void apply() + { + m_field->setValue(toUInt(data(dataColumn)), m_index); + setChanged(false); + } + + void update() + { + QVariant value = toHexString(m_field->getValue(m_index)); + + if (data() != value || changed()) { + TreeItem::setData(value); + setHighlight(true); + } + } + +private: + UAVObjectField *m_field; + + QVariant toHexString(QVariant value) + { + QString str; + bool ok; + + return str.setNum(value.toUInt(&ok), 16).toUpper(); + } + + QVariant toUInt(QVariant str) + { + bool ok; + + return str.toString().toUInt(&ok, 16); + } + + int maxLength() + { + int maxLength = 0; + + switch (m_field->getType()) { + case UAVObjectField::INT8: + maxLength = 2; + break; + case UAVObjectField::INT16: + maxLength = 4; + break; + case UAVObjectField::INT32: + maxLength = 8; + break; + case UAVObjectField::UINT8: + maxLength = 2; + break; + case UAVObjectField::UINT16: + maxLength = 4; + break; + case UAVObjectField::UINT32: + maxLength = 8; + break; + default: + Q_ASSERT(false); + break; + } + return maxLength; + } +}; + #endif // FIELDTREEITEM_H diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp index 1845f2c35..f1665bd59 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp @@ -228,7 +228,11 @@ void UAVObjectTreeModel::addSingleField(int index, UAVObjectField *field, TreeIt case UAVObjectField::UINT32: data.append(field->getValue(index)); data.append(field->getUnits()); - item = new IntFieldTreeItem(field, index, data); + if (field->getUnits().toLower() == "hex") { + item = new HexFieldTreeItem(field, index, data); + } else { + item = new IntFieldTreeItem(field, index, data); + } break; case UAVObjectField::FLOAT32: data.append(field->getValue(index)); @@ -351,9 +355,6 @@ QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const return item->data(index.column()); } -// if (role == Qt::DecorationRole) -// return QIcon(":/core/images/openpilot_logo_128.png"); - if (role == Qt::ToolTipRole) { TreeItem *item = static_cast(index.internalPointer()); return item->description(); From ae3d2f41b8816b468f4f903f0f1e861b92856797 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 22 Jan 2014 21:35:06 +0100 Subject: [PATCH 2/5] OP-1183 UAVObjectBrowser - fixed issue in newly added hex string editor --- .../src/plugins/uavobjectbrowser/fieldtreeitem.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h index 64e639eea..6f150e96a 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/fieldtreeitem.h @@ -101,7 +101,7 @@ public: void apply() { - int value = data(dataColumn).toInt(); + int value = data().toInt(); QStringList options = m_field->getOptions(); m_field->setValue(options[value], m_index); @@ -231,7 +231,7 @@ public: void apply() { - m_field->setValue(data(dataColumn).toInt(), m_index); + m_field->setValue(data().toInt(), m_index); setChanged(false); } @@ -268,7 +268,7 @@ public: void apply() { - m_field->setValue(data(dataColumn).toDouble(), m_index); + m_field->setValue(data().toDouble(), m_index); setChanged(false); } @@ -364,13 +364,13 @@ public: void setData(QVariant value, int column) { - setChanged(m_field->getValue(m_index) != value); + setChanged(m_field->getValue(m_index) != toUInt(value)); TreeItem::setData(value, column); } void apply() { - m_field->setValue(toUInt(data(dataColumn)), m_index); + m_field->setValue(toUInt(data()), m_index); setChanged(false); } From b58620c9815bba46bbab1ee6482e081630df7f35 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 24 Jan 2014 00:17:47 +0100 Subject: [PATCH 3/5] OP-1184 removed obsolete plots from the stack scope monitor gadget did same in TaskInfo uav object --- .../default_configurations/OpenPilotGCS.xml | 84 ++++++---- shared/uavobjectdefinition/taskinfo.xml | 155 +++++++++--------- 2 files changed, 124 insertions(+), 115 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml index 827ea2a1c..2ed464a0d 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml @@ -2285,7 +2285,8 @@ 1000 240 - 4294945280 + 4294901760 + true None StackRemaining-System TaskInfo @@ -2296,38 +2297,20 @@ 4294945280 + true None - StackRemaining-Actuator + StackRemaining-CallbackScheduler0 TaskInfo 0 1 0 0 - - 4294945280 - None - StackRemaining-Guidance - TaskInfo - 0 - 1 - 0 - 0 - - - 4294945280 - None - StackRemaining-Watchdog - TaskInfo - 0 - 1 - 0 - 0 - - 4294945280 + 4278190335 + true None - StackRemaining-TelemetryTx + StackRemaining-CallbackScheduler1 TaskInfo 0 1 @@ -2335,9 +2318,10 @@ 0 - 4294945280 + 4294967040 + true None - StackRemaining-TelemetryTxPri + StackRemaining-ManualControl TaskInfo 0 1 @@ -2345,9 +2329,10 @@ 0 - 4294945280 + 4278255615 + true None - StackRemaining-TelemetryRx + StackRemaining-Stabilization TaskInfo 0 1 @@ -2355,9 +2340,10 @@ 0 - 4294945280 + 4294923775 + true None - StackRemaining-GPS + StackRemaining-Actuator TaskInfo 0 1 @@ -2365,9 +2351,10 @@ 0 - 4294945280 + 4289331327 + true None - StackRemaining-ManualControl + StackRemaining-Sensors TaskInfo 0 1 @@ -2376,6 +2363,7 @@ 4294945280 + true None StackRemaining-Altitude TaskInfo @@ -2385,9 +2373,10 @@ 0 - 4294945280 + 4283760767 + true None - StackRemaining-AHRSComms + StackRemaining-TelemetryTx TaskInfo 0 1 @@ -2395,15 +2384,38 @@ 0 - 4294945280 + 4289331327 + true None - StackRemaining-Stabilization + StackRemaining-TelemetryTxPri TaskInfo 0 1 0 0 + + 4294901760 + true + None + StackRemaining-TelemetryRx + TaskInfo + 0 + 1 + 0 + 0 + + + 4283782527 + true + None + StackRemaining-RadioRx + TaskInfo + 0 + 1 + 0 + 0 + 12 1 1000 diff --git a/shared/uavobjectdefinition/taskinfo.xml b/shared/uavobjectdefinition/taskinfo.xml index 7dc843c0a..c5ddc5058 100644 --- a/shared/uavobjectdefinition/taskinfo.xml +++ b/shared/uavobjectdefinition/taskinfo.xml @@ -3,72 +3,70 @@ Task information + System - Actuator - Attitude - Sensors - TelemetryTx - TelemetryTxPri - TelemetryRx - RadioRx - GPS - ManualControl - Altitude - Airspeed - Stabilization - AltitudeHold - PathPlanner - PathFollower - FlightPlan - Com2UsbBridge - Usb2ComBridge - OveroSync - ModemRx - ModemTx - ModemStat - Autotune - EventDispatcher - MagBaro - OSDGen CallbackScheduler0 CallbackScheduler1 CallbackScheduler2 CallbackScheduler3 + + ManualControl + Stabilization + Actuator + Sensors + Attitude + Altitude + Airspeed + MagBaro + + PathFollower + FlightPlan + + TelemetryTx + TelemetryTxPri + TelemetryRx + + RadioRx + Com2UsbBridge + Usb2ComBridge + + GPS + OSDGen + Autotune + System - Actuator - Attitude - Sensors - TelemetryTx - TelemetryTxPri - TelemetryRx - RadioRx - GPS - ManualControl - Altitude - Airspeed - Stabilization - AltitudeHold - PathPlanner - PathFollower - FlightPlan - Com2UsbBridge - Usb2ComBridge - OveroSync - ModemRx - ModemTx - ModemStat - Autotune - EventDispatcher - MagBaro - OSDGen CallbackScheduler0 CallbackScheduler1 CallbackScheduler2 CallbackScheduler3 + + ManualControl + Stabilization + Actuator + Sensors + Attitude + Altitude + Airspeed + MagBaro + + PathFollower + FlightPlan + + TelemetryTx + TelemetryTxPri + TelemetryRx + + RadioRx + Com2UsbBridge + Usb2ComBridge + + GPS + OSDGen + Autotune @@ -77,40 +75,39 @@ + System - Actuator - Attitude - Sensors - TelemetryTx - TelemetryTxPri - TelemetryRx - RadioRx - GPS - ManualControl - Altitude - Airspeed - Stabilization - AltitudeHold - PathPlanner - PathFollower - FlightPlan - Com2UsbBridge - Usb2ComBridge - OveroSync - ModemRx - ModemTx - ModemStat - Autotune - EventDispatcher - MagBaro - OSDGen CallbackScheduler0 CallbackScheduler1 CallbackScheduler2 CallbackScheduler3 + + ManualControl + Stabilization + Actuator + Sensors + Attitude + Altitude + Airspeed + MagBaro + + PathFollower + FlightPlan + + TelemetryTx + TelemetryTxPri + TelemetryRx + + RadioRx + Com2UsbBridge + Usb2ComBridge + + GPS + OSDGen + Autotune - + From 16ff328bfb67e83fa521a97b1eeda68f3eca8f75 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 24 Jan 2014 19:53:13 +0100 Subject: [PATCH 4/5] OP-1184 removed spurious drawAntialiased setting from stack scope config +review OPReview-632 --- .../default_configurations/OpenPilotGCS.xml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml index 2ed464a0d..decf3135b 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml @@ -2286,7 +2286,6 @@ 240 4294901760 - true None StackRemaining-System TaskInfo @@ -2297,7 +2296,6 @@ 4294945280 - true None StackRemaining-CallbackScheduler0 TaskInfo @@ -2308,7 +2306,6 @@ 4278190335 - true None StackRemaining-CallbackScheduler1 TaskInfo @@ -2319,7 +2316,6 @@ 4294967040 - true None StackRemaining-ManualControl TaskInfo @@ -2330,7 +2326,6 @@ 4278255615 - true None StackRemaining-Stabilization TaskInfo @@ -2341,7 +2336,6 @@ 4294923775 - true None StackRemaining-Actuator TaskInfo @@ -2352,7 +2346,6 @@ 4289331327 - true None StackRemaining-Sensors TaskInfo @@ -2363,7 +2356,6 @@ 4294945280 - true None StackRemaining-Altitude TaskInfo @@ -2374,7 +2366,6 @@ 4283760767 - true None StackRemaining-TelemetryTx TaskInfo @@ -2385,7 +2376,6 @@ 4289331327 - true None StackRemaining-TelemetryTxPri TaskInfo @@ -2396,7 +2386,6 @@ 4294901760 - true None StackRemaining-TelemetryRx TaskInfo @@ -2407,7 +2396,6 @@ 4283782527 - true None StackRemaining-RadioRx TaskInfo From a234f52b6d5db59c0b70c4395479ab7a153c04ad Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 24 Jan 2014 20:50:13 +0100 Subject: [PATCH 5/5] OP-1182 minor tweak of telemetry monitor widget margin for better centering --- .../openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index e83891d06..d19ad9e2c 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -60,8 +60,7 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow) : // put everything together QHBoxLayout *layout = new QHBoxLayout; layout->setSpacing(6); - // cheat a bit with the margin to "nicely" center things vertically - layout->setContentsMargins(6, 0, 4, 2); + layout->setContentsMargins(5, 2, 5, 2); setLayout(layout); layout->addWidget(new QLabel(tr("Connections:")), 0, Qt::AlignVCenter);