From 7f62f27fdcb59934d15e991a4a8329ffd92b4e19 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 4 Mar 2019 15:49:59 +0100 Subject: [PATCH] Add the possibility to associate a color to a status --- src/Info/ParamInfo.hh | 3 ++- src/Info/StatusDefNode.cc | 11 ++++++++++- src/Info/StatusInfo.hh | 23 ++++++++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Info/ParamInfo.hh b/src/Info/ParamInfo.hh index 1194707..5ec08ec 100644 --- a/src/Info/ParamInfo.hh +++ b/src/Info/ParamInfo.hh @@ -294,10 +294,11 @@ public: /* * @brief Add parameter status for a given min/max values */ - void addStatus(double minVal, double maxVal, std::string name) { + void addStatus(double minVal, double maxVal, std::string name, std::string color = "") { StatusInfo info; info.setRange(minVal,maxVal); info.setName(name); + info.setColor(color); _statusDef.push_back(info); } diff --git a/src/Info/StatusDefNode.cc b/src/Info/StatusDefNode.cc index f2c0b77..651d948 100644 --- a/src/Info/StatusDefNode.cc +++ b/src/Info/StatusDefNode.cc @@ -59,7 +59,16 @@ public: xmlFree(value); } - pParamInfo->addStatus(minVal,maxVal,name); + //Get color + value = xmlGetProp(pNode, (const xmlChar *) "color"); + std::string color = ""; + if (value != NULL) + { + color = std::string((const char*)value); + xmlFree(value); + } + + pParamInfo->addStatus(minVal,maxVal,name, color); } }; diff --git a/src/Info/StatusInfo.hh b/src/Info/StatusInfo.hh index e8400b4..df28224 100644 --- a/src/Info/StatusInfo.hh +++ b/src/Info/StatusInfo.hh @@ -19,7 +19,7 @@ namespace Info { class StatusInfo { public: - StatusInfo() : _minValue(0.0), _maxValue(0.0), _name("") + StatusInfo() : _minValue(0.0), _maxValue(0.0), _name(""), _color("") { } @@ -68,6 +68,22 @@ public: return _name; } + /* + * @brief Set color + */ + void setColor(std::string color) + { + _color = color; + } + + /* + * @brief Get color name + */ + const std::string& getColor() const + { + return _color; + } + private: /* * @brief min value for the range of this status @@ -83,6 +99,11 @@ private: * @brief status name */ std::string _name; + + /* + * @brief status color. Format: [R,G,B]. Empty if not defined + */ + std::string _color; }; } -- libgit2 0.21.2