mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
simbase
allow dials and thermos
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include <qwt_plot_curve.h>
|
#include <qwt_plot_curve.h>
|
||||||
#include <qwt_slider.h>
|
#include <qwt_slider.h>
|
||||||
#include <qwt_series_data.h>
|
#include <qwt_series_data.h>
|
||||||
|
#include <qwt_thermo.h>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
void create_dial_needle(QwtDial* dial);
|
void create_dial_needle(QwtDial* dial);
|
||||||
|
|||||||
@@ -81,6 +81,16 @@ void SimulatorBase::UI_item_parser(json& input)
|
|||||||
process_ui_slider(uiItem);
|
process_ui_slider(uiItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (uiItem["type"] == "UI_dial")
|
||||||
|
{
|
||||||
|
process_ui_dial(uiItem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (uiItem["type"] == "UI_thermo")
|
||||||
|
{
|
||||||
|
process_ui_thermo(uiItem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (uiItem["type"] == "UI_textbox")
|
if (uiItem["type"] == "UI_textbox")
|
||||||
{
|
{
|
||||||
process_ui_textbox(uiItem);
|
process_ui_textbox(uiItem);
|
||||||
@@ -157,6 +167,66 @@ void SimulatorBase::process_ui_slider(json& uiItem)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimulatorBase::process_ui_dial(json& uiItem)
|
||||||
|
{
|
||||||
|
QwtDial* dial = id_to_dial(QString::fromStdString(uiItem["id"]));
|
||||||
|
QLabel* label = id_to_dial_label(QString::fromStdString(uiItem["id"]));
|
||||||
|
if (dial == nullptr)
|
||||||
|
{
|
||||||
|
QD << "id_to_dial returned null on " << QString::fromStdString(uiItem["id"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double value = uiItem["value"];
|
||||||
|
bool visible = uiItem["visible"];
|
||||||
|
|
||||||
|
if (dial->value() != value)
|
||||||
|
{
|
||||||
|
if (label != nullptr)
|
||||||
|
{
|
||||||
|
label->setText(format_slider_value(QString::fromStdString(uiItem["id"]), value));
|
||||||
|
}
|
||||||
|
dial->setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (dial->isVisible() != visible)
|
||||||
|
{
|
||||||
|
dial->setVisible(visible);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimulatorBase::process_ui_thermo(json& uiItem)
|
||||||
|
{
|
||||||
|
QwtThermo* thermo = id_to_thermo(QString::fromStdString(uiItem["id"]));
|
||||||
|
QLabel* label = id_to_thermo_label(QString::fromStdString(uiItem["id"]));
|
||||||
|
if (thermo == nullptr)
|
||||||
|
{
|
||||||
|
QD << "id_to_dial returned null on " << QString::fromStdString(uiItem["id"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double value = uiItem["value"];
|
||||||
|
bool visible = uiItem["visible"];
|
||||||
|
|
||||||
|
if (thermo->value() != value)
|
||||||
|
{
|
||||||
|
if (label != nullptr)
|
||||||
|
{
|
||||||
|
label->setText(format_slider_value(QString::fromStdString(uiItem["id"]), value));
|
||||||
|
}
|
||||||
|
thermo->setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (thermo->isVisible() != visible)
|
||||||
|
{
|
||||||
|
thermo->setVisible(visible);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void SimulatorBase::process_ui_textbox(json& uiItem)
|
void SimulatorBase::process_ui_textbox(json& uiItem)
|
||||||
{
|
{
|
||||||
QD << "Not implemented";
|
QD << "Not implemented";
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ class SimulatorBase : public QMainWindow {
|
|||||||
virtual QwtDial* id_to_dial(QString name) {return nullptr;}
|
virtual QwtDial* id_to_dial(QString name) {return nullptr;}
|
||||||
virtual QLabel* id_to_dial_label(QString name) {return nullptr;}
|
virtual QLabel* id_to_dial_label(QString name) {return nullptr;}
|
||||||
virtual QString format_dial_value(QString name, double val) {return QString();}
|
virtual QString format_dial_value(QString name, double val) {return QString();}
|
||||||
|
virtual QwtThermo* id_to_thermo(QString name) {return nullptr;}
|
||||||
|
virtual QLabel* id_to_thermo_label(QString name) {return nullptr;}
|
||||||
|
virtual QString format_thermo_label(QString name) {return QString();}
|
||||||
virtual QComboBox* id_to_combobox(QString name) {return nullptr;}
|
virtual QComboBox* id_to_combobox(QString name) {return nullptr;}
|
||||||
virtual QTextEdit* id_to_textbox(QString name) {return nullptr;}
|
virtual QTextEdit* id_to_textbox(QString name) {return nullptr;}
|
||||||
|
|
||||||
@@ -40,6 +43,8 @@ class SimulatorBase : public QMainWindow {
|
|||||||
void UI_item_parser(json& input);
|
void UI_item_parser(json& input);
|
||||||
virtual void process_ui_label(json& uiItem);
|
virtual void process_ui_label(json& uiItem);
|
||||||
virtual void process_ui_slider(json& uiItem);
|
virtual void process_ui_slider(json& uiItem);
|
||||||
|
virtual void process_ui_dial(json& uiItem);
|
||||||
|
virtual void process_ui_thermo(json& uiItem);
|
||||||
virtual void process_ui_textbox(json& uiItem);
|
virtual void process_ui_textbox(json& uiItem);
|
||||||
virtual void process_ui_combobox(json& uiItem);
|
virtual void process_ui_combobox(json& uiItem);
|
||||||
virtual void process_ui_radiobutton(json& uiItem);
|
virtual void process_ui_radiobutton(json& uiItem);
|
||||||
|
|||||||
Reference in New Issue
Block a user