From 3c754af4842becb23e74175e416cb5abb2419b93 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Wed, 20 Jun 2012 01:27:19 +0200 Subject: [PATCH] OP-642 Added element which is a string in uavo object type definition to be used in uavo browser to categorise uavo:s visually into subtrees. Category value is assigned in generated code and accessible via getter method. OP-644 Fixed option for uavo browser to enable disable hilights for objects which values wasn't really changed to indicate stream activity in uavo object tree. --- .../uavobjectbrowser/uavobjectbrowser.cpp | 1 + .../uavobjectbrowserconfiguration.cpp | 7 ++++- .../uavobjectbrowserconfiguration.h | 4 +++ .../uavobjectbrowseroptionspage.cpp | 2 ++ .../uavobjectbrowseroptionspage.ui | 9 +++++- .../uavobjectbrowser/uavobjectbrowserwidget.h | 2 ++ .../uavobjectbrowser/uavobjecttreemodel.cpp | 11 +++++-- .../uavobjectbrowser/uavobjecttreemodel.h | 2 ++ .../src/plugins/uavobjects/uavmetaobject.cpp | 2 +- .../src/plugins/uavobjects/uavobject.cpp | 16 ++++++++++ .../src/plugins/uavobjects/uavobject.h | 3 ++ .../plugins/uavobjects/uavobjecttemplate.cpp | 30 +++++++++++-------- .../plugins/uavobjects/uavobjecttemplate.h | 1 + .../generators/generator_common.cpp | 2 ++ ground/uavobjgenerator/uavobjectparser.cpp | 15 ++++++++++ ground/uavobjgenerator/uavobjectparser.h | 2 ++ shared/uavobjectdefinition/gyros.xml | 1 + 17 files changed, 91 insertions(+), 19 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.cpp index cf343ec5c..46142340c 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowser.cpp @@ -45,5 +45,6 @@ void UAVObjectBrowser::loadConfiguration(IUAVGadgetConfiguration* config) m_widget->setRecentlyUpdatedColor(m->recentlyUpdatedColor()); m_widget->setManuallyChangedColor(m->manuallyChangedColor()); m_widget->setRecentlyUpdatedTimeout(m->recentlyUpdatedTimeout()); + m_widget->setOnlyHilightChangedValues(m->onlyHighlightChangedValues()); } diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.cpp index e534542c6..cce3bee89 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.cpp @@ -31,17 +31,20 @@ UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, QS IUAVGadgetConfiguration(classId, parent), m_recentlyUpdatedColor(QColor(255, 230, 230)), m_manuallyChangedColor(QColor(230, 230, 255)), - m_recentlyUpdatedTimeout(500) + m_recentlyUpdatedTimeout(500), + m_onlyHilightChangedValues(false) { //if a saved configuration exists load it if(qSettings != 0) { QColor recent = qSettings->value("recentlyUpdatedColor").value(); QColor manual = qSettings->value("manuallyChangedColor").value(); int timeout = qSettings->value("recentlyUpdatedTimeout").toInt(); + bool hilight = qSettings->value("onlyHilightChangedValues").toBool(); m_recentlyUpdatedColor = recent; m_manuallyChangedColor = manual; m_recentlyUpdatedTimeout = timeout; + m_onlyHilightChangedValues = hilight; } } @@ -51,6 +54,7 @@ IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone() m->m_recentlyUpdatedColor = m_recentlyUpdatedColor; m->m_manuallyChangedColor = m_manuallyChangedColor; m->m_recentlyUpdatedTimeout = m_recentlyUpdatedTimeout; + m->m_onlyHilightChangedValues = m_onlyHilightChangedValues; return m; } @@ -62,4 +66,5 @@ void UAVObjectBrowserConfiguration::saveConfig(QSettings* qSettings) const { qSettings->setValue("recentlyUpdatedColor", m_recentlyUpdatedColor); qSettings->setValue("manuallyChangedColor", m_manuallyChangedColor); qSettings->setValue("recentlyUpdatedTimeout", m_recentlyUpdatedTimeout); + qSettings->setValue("onlyHilightChangedValues", m_onlyHilightChangedValues); } diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.h index 941428f83..8e31c18dc 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserconfiguration.h @@ -39,6 +39,7 @@ Q_OBJECT Q_PROPERTY(QColor m_recentlyUpdatedColor READ recentlyUpdatedColor WRITE setRecentlyUpdatedColor) Q_PROPERTY(QColor m_manuallyChangedColor READ manuallyChangedColor WRITE setManuallyChangedColor) Q_PROPERTY(int m_recentlyUpdatedTimeout READ recentlyUpdatedTimeout WRITE setRecentlyUpdatedTimeout) +Q_PROPERTY(bool m_onlyHilightChangedValues READ onlyHighlightChangedValues WRITE setOnlyHighlightChangedValues) public: explicit UAVObjectBrowserConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0); @@ -48,6 +49,7 @@ public: QColor recentlyUpdatedColor() const { return m_recentlyUpdatedColor; } QColor manuallyChangedColor() const { return m_manuallyChangedColor; } int recentlyUpdatedTimeout() const { return m_recentlyUpdatedTimeout; } + bool onlyHighlightChangedValues() const {return m_onlyHilightChangedValues;} signals: @@ -55,11 +57,13 @@ public slots: void setRecentlyUpdatedColor(QColor color) { m_recentlyUpdatedColor = color; } void setManuallyChangedColor(QColor color) { m_manuallyChangedColor = color; } void setRecentlyUpdatedTimeout(int timeout) { m_recentlyUpdatedTimeout = timeout; } + void setOnlyHighlightChangedValues(bool hilight) { m_onlyHilightChangedValues = hilight; } private: QColor m_recentlyUpdatedColor; QColor m_manuallyChangedColor; int m_recentlyUpdatedTimeout; + bool m_onlyHilightChangedValues; }; #endif // UAVOBJECTBROWSERCONFIGURATION_H diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.cpp index fe0a13290..b9561e471 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.cpp @@ -52,6 +52,7 @@ QWidget *UAVObjectBrowserOptionsPage::createPage(QWidget *parent) m_page->recentlyUpdatedButton->setColor(m_config->recentlyUpdatedColor()); m_page->manuallyChangedButton->setColor(m_config->manuallyChangedColor()); m_page->recentlyUpdatedTimeoutSpinBox->setValue(m_config->recentlyUpdatedTimeout()); + m_page->hilightBox->setChecked(m_config->onlyHighlightChangedValues()); return w; @@ -62,6 +63,7 @@ void UAVObjectBrowserOptionsPage::apply() m_config->setRecentlyUpdatedColor(m_page->recentlyUpdatedButton->color()); m_config->setManuallyChangedColor(m_page->manuallyChangedButton->color()); m_config->setRecentlyUpdatedTimeout(m_page->recentlyUpdatedTimeoutSpinBox->value()); + m_config->setOnlyHighlightChangedValues(m_page->hilightBox->isChecked()); } void UAVObjectBrowserOptionsPage::finish() diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.ui b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.ui index 474e26dc6..350fc440b 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.ui +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowseroptionspage.ui @@ -48,7 +48,7 @@ - + Qt::Vertical @@ -115,6 +115,13 @@ + + + + Only hilight nodes when value actually changes + + + diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h index b047d37f0..f3bf04185 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjectbrowserwidget.h @@ -48,6 +48,8 @@ public: void setRecentlyUpdatedColor(QColor color) { m_model->setRecentlyUpdatedColor(color); } void setManuallyChangedColor(QColor color) { m_model->setManuallyChangedColor(color); } void setRecentlyUpdatedTimeout(int timeout) { m_model->setRecentlyUpdatedTimeout(timeout); } + void setOnlyHilightChangedValues(bool hilight) { m_model->setOnlyHilightChangedValues(hilight); } + public slots: void showMetaData(bool show); diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp index 9bd8b20b4..5f8de21b4 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.cpp @@ -363,10 +363,15 @@ void UAVObjectTreeModel::highlightUpdatedObject(UAVObject *obj) Q_ASSERT(obj); ObjectTreeItem *item = findObjectTreeItem(obj); Q_ASSERT(item); + if(!m_onlyHilightChangedValues){ + item->setHighlight(true); + } item->update(); - QModelIndex itemIndex = index(item); - Q_ASSERT(itemIndex != QModelIndex()); - emit dataChanged(itemIndex, itemIndex); + if(!m_onlyHilightChangedValues){ + QModelIndex itemIndex = index(item); + Q_ASSERT(itemIndex != QModelIndex()); + emit dataChanged(itemIndex, itemIndex); + } } ObjectTreeItem *UAVObjectTreeModel::findObjectTreeItem(UAVObject *object) diff --git a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h index d9787e3a7..78f3166c9 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h +++ b/ground/openpilotgcs/src/plugins/uavobjectbrowser/uavobjecttreemodel.h @@ -68,6 +68,7 @@ public: m_recentlyUpdatedTimeout = timeout; TreeItem::setHighlightTime(timeout); } + void setOnlyHilightChangedValues(bool hilight) {m_onlyHilightChangedValues = hilight; } signals: @@ -97,6 +98,7 @@ private: int m_recentlyUpdatedTimeout; QColor m_recentlyUpdatedColor; QColor m_manuallyChangedColor; + bool m_onlyHilightChangedValues; // Highlight manager to handle highlighting of tree items. HighLightManager *m_highlightManager; diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp index bb45495f5..e3fd7fdbb 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavmetaobject.cpp @@ -31,7 +31,7 @@ /** * Constructor */ -UAVMetaObject::UAVMetaObject(quint32 objID, const QString& name, UAVObject* parent): +UAVMetaObject::UAVMetaObject(quint32 objID, const QString& name, UAVObject *parent): UAVObject(objID, true, name) { this->parent = parent; diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp index 47960b060..d01caba21 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp @@ -145,6 +145,22 @@ void UAVObject::setDescription(const QString& description) this->description = description; } +/** + * Get the category of the object + */ +QString UAVObject::getCategory() +{ + return category; +} + +/** + * Set the category of the object + */ +void UAVObject::setCategory(const QString& category) +{ + this->category = category; +} + /** * Get the total number of bytes of the object's data diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h index 945672c61..56e74152e 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h @@ -103,6 +103,7 @@ public: quint32 getInstID(); bool isSingleInstance(); QString getName(); + QString getCategory(); QString getDescription(); quint32 getNumBytes(); qint32 pack(quint8* dataOut); @@ -163,6 +164,7 @@ protected: bool isSingleInst; QString name; QString description; + QString category; quint32 numBytes; QMutex* mutex; quint8* data; @@ -170,6 +172,7 @@ protected: void initializeFields(QList& fields, quint8* data, quint32 numBytes); void setDescription(const QString& description); + void setCategory(const QString& category); }; #endif // UAVOBJECT_H diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp index 58aa84ead..f08f5e434 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp @@ -8,26 +8,26 @@ * @{ * @addtogroup UAVObjectsPlugin UAVObjects Plugin * @{ - * - * @note Object definition file: $(XMLFILE). + * + * @note Object definition file: $(XMLFILE). * This is an automatically generated file. * DO NOT modify manually. * * @brief The UAVUObjects GCS plugin *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "$(NAMELC).h" @@ -35,6 +35,7 @@ const QString $(NAME)::NAME = QString("$(NAME)"); const QString $(NAME)::DESCRIPTION = QString("$(DESCRIPTION)"); +const QString $(NAME)::CATEGORY = QString("$(CATEGORY)"); /** * Constructor @@ -51,6 +52,9 @@ $(FIELDSINIT) // Set the object description setDescription(DESCRIPTION); + // Set the Category of this object type + setCategory(CATEGORY); + connect(this, SIGNAL(objectUpdated(UAVObject*)), SLOT(emitNotifications())); } diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h index 9b5a766ee..f68eebe49 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h @@ -54,6 +54,7 @@ $(DATAFIELDINFO) static const quint32 OBJID = $(OBJIDHEX); static const QString NAME; static const QString DESCRIPTION; + static const QString CATEGORY; static const bool ISSINGLEINST = $(ISSINGLEINST); static const bool ISSETTINGS = $(ISSETTINGS); static const quint32 NUMBYTES = sizeof(DataFields); diff --git a/ground/uavobjgenerator/generators/generator_common.cpp b/ground/uavobjgenerator/generators/generator_common.cpp index 34f097e44..5ba513dc6 100644 --- a/ground/uavobjgenerator/generators/generator_common.cpp +++ b/ground/uavobjgenerator/generators/generator_common.cpp @@ -55,6 +55,8 @@ void replaceCommonTags(QString& out, ObjectInfo* info) out.replace(QString("$(NAMELC)"), info->namelc); // Replace $(DESCRIPTION) tag out.replace(QString("$(DESCRIPTION)"), info->description); + // Replace $(CATEGORY) tag + out.replace(QString("$(CATEGORY)"), info->category); // Replace $(NAMEUC) tag out.replace(QString("$(NAMEUC)"), info->name.toUpper()); // Replace $(OBJID) tag diff --git a/ground/uavobjgenerator/uavobjectparser.cpp b/ground/uavobjgenerator/uavobjectparser.cpp index a11a53e82..4d70e8116 100644 --- a/ground/uavobjgenerator/uavobjectparser.cpp +++ b/ground/uavobjgenerator/uavobjectparser.cpp @@ -198,6 +198,12 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename) descriptionFound = true; } + else if ( childNode.nodeName().compare(QString("category")) == 0 ) { + QString status = processObjectCategory(childNode, &info->category); + + if (!status.isNull()) + return status; + } else if (!childNode.isComment()) { return QString("Unknown object element"); } @@ -540,3 +546,12 @@ QString UAVObjectParser::processObjectDescription(QDomNode& childNode, QString * description->append(childNode.firstChild().nodeValue()); return QString(); } + +/** + * Process the category field from the XML file + */ +QString UAVObjectParser::processObjectCategory(QDomNode& childNode, QString * category) +{ + category->append(childNode.firstChild().nodeValue()); + return QString(); +} diff --git a/ground/uavobjgenerator/uavobjectparser.h b/ground/uavobjgenerator/uavobjectparser.h index f41c3ce30..5babfbc40 100644 --- a/ground/uavobjgenerator/uavobjectparser.h +++ b/ground/uavobjgenerator/uavobjectparser.h @@ -96,6 +96,7 @@ typedef struct { int loggingUpdatePeriod; /** Update period used by the logging module (only if logging mode is PERIODIC) */ QList fields; /** The data fields for the object **/ QString description; /** Description used for Doxygen **/ + QString category; /** Description used for Doxygen **/ } ObjectInfo; class UAVObjectParser @@ -127,6 +128,7 @@ private: QString processObjectFields(QDomNode& childNode, ObjectInfo* info); QString processObjectAccess(QDomNode& childNode, ObjectInfo* info); QString processObjectDescription(QDomNode& childNode, QString * description); + QString processObjectCategory(QDomNode& childNode, QString * category); QString processObjectMetadata(QDomNode& childNode, UpdateMode* mode, int* period, bool* acked); void calculateID(ObjectInfo* info); quint32 updateHash(quint32 value, quint32 hash); diff --git a/shared/uavobjectdefinition/gyros.xml b/shared/uavobjectdefinition/gyros.xml index 8240d2a68..a6ad37e0e 100644 --- a/shared/uavobjectdefinition/gyros.xml +++ b/shared/uavobjectdefinition/gyros.xml @@ -1,5 +1,6 @@ + Sensors The gyro data.