diff --git a/Qt/sim-test.cpp b/Qt/sim-test.cpp index 0e311ba..24cad9a 100644 --- a/Qt/sim-test.cpp +++ b/Qt/sim-test.cpp @@ -10,7 +10,13 @@ Test_Sim::Test_Sim(Web_socket_wrapper* web_socket, QWidget* parent) : {button_lookup_e::button, ui->button} }; slider_lookup = { - {slider_lookup_e::slider, ui->Slider} + {slider_lookup_e::slider, ui->slider} + }; + dial_lookup = { + {dial_lookup_e::dial, ui->dial} + }; + thermo_lookup = { + {thermo_lookup_e::thermo, ui->thermo} }; led_lookup = { {led_lookup_e::led, ui->led} @@ -26,6 +32,7 @@ Test_Sim::Test_Sim(Web_socket_wrapper* web_socket, QWidget* parent) : setup_buttons(); setup_comboboxes(); setup_sliders(); + setup_dials(); } Test_Sim::~Test_Sim() { @@ -74,6 +81,14 @@ void Test_Sim::setup_comboboxes(void) } } +void Test_Sim::setup_dials(void) +{ + for (Iterable lookup; lookup < dial_lookup_e::end; lookup++) + { + create_dial_needle(dial_lookup[lookup]); + } +} + void Test_Sim::button_update(button_lookup_e lookup) { m_web_socket->send_event(Web_socket_wrapper::Event::clicked, QString(magic_enum::enum_name(lookup).data())); @@ -135,7 +150,7 @@ QwtSlider* Test_Sim::id_to_slider(QString name) slider_lookup_e lookup = magic_enum::enum_cast(name.toStdString()).value_or(slider_lookup_e::end); if (lookup == slider_lookup_e::end) { - QD << "thermo lookup == end, instead of " << name; + QD << "slider lookup == end, instead of " << name; emit quit(); return nullptr; } @@ -160,6 +175,32 @@ QString Test_Sim::format_slider_value(QString name, double val) return ""; } +QwtDial* Test_Sim::id_to_dial(QString name) +{ + dial_lookup_e lookup = magic_enum::enum_cast(name.toStdString()).value_or(dial_lookup_e::end); + if (lookup == dial_lookup_e::end) + { + QD << "dial lookup == end, instead of " << name; + emit quit(); + return nullptr; + } + + return dial_lookup[lookup]; +} + +QwtThermo* Test_Sim::id_to_thermo(QString name) +{ + thermo_lookup_e lookup = magic_enum::enum_cast(name.toStdString()).value_or(thermo_lookup_e::end); + if (lookup == thermo_lookup_e::end) + { + QD << "thermo lookup == end, instead of " << name; + emit quit(); + return nullptr; + } + + return thermo_lookup[lookup]; +} + QComboBox* Test_Sim::id_to_combobox(QString name) { combobox_lookup_e lookup = magic_enum::enum_cast(name.toStdString()).value_or(combobox_lookup_e::end); diff --git a/Qt/sim-test.h b/Qt/sim-test.h index 4644b1c..8baf079 100644 --- a/Qt/sim-test.h +++ b/Qt/sim-test.h @@ -25,6 +25,12 @@ class Test_Sim : public SimulatorBase { ITERABLE_ENUM_BEGIN(slider_lookup_e) slider ITERABLE_ENUM_END; + ITERABLE_ENUM_BEGIN(dial_lookup_e) + dial + ITERABLE_ENUM_END; + ITERABLE_ENUM_BEGIN(thermo_lookup_e) + thermo + ITERABLE_ENUM_END; ITERABLE_ENUM_BEGIN(combobox_lookup_e) combobox ITERABLE_ENUM_END; @@ -35,6 +41,7 @@ class Test_Sim : public SimulatorBase { void setup_buttons(void); void setup_sliders(void); void setup_comboboxes(void); + void setup_dials(void); void button_update(button_lookup_e lookup); void slider_update(slider_lookup_e lookup); @@ -46,6 +53,8 @@ class Test_Sim : public SimulatorBase { QwtSlider* id_to_slider(QString name); QLabel* id_to_slider_label(QString name); QString format_slider_value(QString name, double val); + QwtDial* id_to_dial(QString name); + QwtThermo* id_to_thermo(QString name); QComboBox* id_to_combobox(QString name); private: @@ -53,6 +62,8 @@ class Test_Sim : public SimulatorBase { std::unordered_map button_lookup; std::unordered_map slider_lock; std::unordered_map slider_lookup; + std::unordered_map dial_lookup; + std::unordered_map thermo_lookup; std::unordered_map led_lookup; std::unordered_map combobox_lookup; std::unordered_map label_lookup; diff --git a/Qt/sim-test.ui b/Qt/sim-test.ui index 83019f8..653438f 100644 --- a/Qt/sim-test.ui +++ b/Qt/sim-test.ui @@ -15,9 +15,6 @@ - - - @@ -36,12 +33,29 @@ + + + 4 + + + + TextLabel + + + + + + + + + + @@ -57,11 +71,21 @@ + + QwtDial + QWidget +
qwt_dial.h
+
QwtSlider QWidget
qwt_slider.h
+ + QwtThermo + QWidget +
qwt_thermo.h
+