diff --git a/src/UI/UI_dial.cpp b/src/UI/UI_dial.cpp index ac209dd..2d911ce 100644 --- a/src/UI/UI_dial.cpp +++ b/src/UI/UI_dial.cpp @@ -1,12 +1,20 @@ #include "UI_dial.hpp" -UI_dial::UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value, +UI_dial::UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, QObject *parrent) - : UI_item(UI_DIAL_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value) + : UI_item(UI_DIAL_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit) { } -UI_dial::UI_dial(const json &j, QObject *parrent) : UI_item(UI_DIAL_TYPE, parrent) +UI_dial::UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, + double value, QObject *parrent) + : UI_dial(text, "", fg_color, bg_color, min, max, value, parrent) +{ + +} + +UI_dial::UI_dial(const json &j, QObject *parrent) + : UI_item(UI_DIAL_TYPE, parrent) { from_json(j); } @@ -44,6 +52,7 @@ void UI_dial::from_json(const json &j) this->m_min = j.at("min"); this->m_max = j.at("max"); this->m_value = j.at("value"); + this->m_unit = j.at("unit"); } json UI_dial::to_json(size_t id) const @@ -52,5 +61,6 @@ json UI_dial::to_json(size_t id) const j["min"] = this->m_min; j["max"] = this->m_max; j["value"] = this->m_value; + j["unit"] = this->m_unit; return j; } diff --git a/src/UI/UI_dial.hpp b/src/UI/UI_dial.hpp index 52d0ed0..3ed072c 100644 --- a/src/UI/UI_dial.hpp +++ b/src/UI/UI_dial.hpp @@ -7,6 +7,8 @@ class UI_dial : public UI_item { Q_OBJECT public: + UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, + QObject *parrent = nullptr); UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value, QObject *parrent = nullptr); UI_dial(const json &j, QObject *parrent = nullptr); @@ -24,4 +26,5 @@ class UI_dial : public UI_item double m_min; double m_max; double m_value; + std::string m_unit; }; diff --git a/src/UI/UI_slider.cpp b/src/UI/UI_slider.cpp index c76d3e3..b6ce3f1 100644 --- a/src/UI/UI_slider.cpp +++ b/src/UI/UI_slider.cpp @@ -1,11 +1,18 @@ #include "UI_slider.hpp" -UI_slider::UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, +UI_slider::UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, QObject *parrent) - : UI_item(UI_SLIDER_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value) + : UI_item(UI_SLIDER_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit) { } +UI_slider::UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value, + QObject *parrent) + : UI_slider(text, "", fg_color, bg_color, min, max, value, parrent) +{ + +} + UI_slider::UI_slider(const json &j, QObject *parrent) : UI_item(UI_SLIDER_TYPE, parrent) { from_json(j); @@ -45,6 +52,7 @@ void UI_slider::from_json(const json &j) this->m_min = j.at("min"); this->m_max = j.at("max"); this->m_value = j.at("value"); + this->m_unit = j.at("unit"); } json UI_slider::to_json(size_t id) const @@ -53,5 +61,6 @@ json UI_slider::to_json(size_t id) const j["min"] = this->m_min; j["max"] = this->m_max; j["value"] = this->m_value; + j["unit"] = this->m_unit; return j; } diff --git a/src/UI/UI_slider.hpp b/src/UI/UI_slider.hpp index 80a0ee4..428a717 100644 --- a/src/UI/UI_slider.hpp +++ b/src/UI/UI_slider.hpp @@ -7,6 +7,8 @@ class UI_slider : public UI_item { Q_OBJECT public: + UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, + QObject *parrent = nullptr); UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value, QObject *parrent = nullptr); UI_slider(const json &j, QObject *parrent = nullptr); @@ -26,4 +28,5 @@ class UI_slider : public UI_item double m_min; double m_max; double m_value; + std::string m_unit; }; diff --git a/src/UI/UI_thermo.cpp b/src/UI/UI_thermo.cpp index 579b265..784fc3e 100644 --- a/src/UI/UI_thermo.cpp +++ b/src/UI/UI_thermo.cpp @@ -1,8 +1,14 @@ #include "UI_thermo.hpp" -UI_thermo::UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, +UI_thermo::UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, QObject *parrent) - : UI_item(UI_THERMO_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value) + : UI_item(UI_THERMO_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit) +{ +} + +UI_thermo::UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value, + QObject *parrent) + : UI_thermo(text, "", fg_color, bg_color, min, max, value, parrent) { } @@ -94,6 +100,7 @@ void UI_thermo::from_json(const json &j) this->m_min = j.at("min"); this->m_max = j.at("max"); this->m_value = j.at("value"); + this->m_unit = j.at("unit"); this->m_color_map.clear(); for (auto &i : j["color_map"]) { @@ -109,6 +116,7 @@ json UI_thermo::to_json(size_t id) const j["min"] = this->m_min; j["max"] = this->m_max; j["value"] = this->m_value; + j["unit"] = this->m_unit; j["color_map"] = json::array(); for (auto &[key, value] : this->m_color_map) { diff --git a/src/UI/UI_thermo.hpp b/src/UI/UI_thermo.hpp index 05081e3..50dcbe0 100644 --- a/src/UI/UI_thermo.hpp +++ b/src/UI/UI_thermo.hpp @@ -8,6 +8,8 @@ class UI_thermo : public UI_item { Q_OBJECT public: + UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value, + QObject *parrent = nullptr); UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value, QObject *parrent = nullptr); UI_thermo(const json &j, QObject *parrent = nullptr); @@ -32,5 +34,6 @@ class UI_thermo : public UI_item double m_min; double m_max; double m_value; + std::string m_unit; std::unordered_map m_color_map; };