mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
server plot ui
This commit is contained in:
+2
-23
@@ -14,32 +14,11 @@ target_compile_options(UI PRIVATE $<$<CONFIG:Debug>:
|
||||
>)
|
||||
|
||||
file(GLOB_RECURSE CUSTOM_UI_SOURCES "custom/*.?pp")
|
||||
file(GLOB_RECURSE UI_SOURCES "*.?pp")
|
||||
|
||||
target_sources(UI
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_item.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_item.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_button.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_button.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_checkbox.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_checkbox.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_combobox.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_combobox.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_dial.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_dial.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_label.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_label.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_led.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_led.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_slider.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_slider.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_textbox.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_textbox.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_thermo.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_thermo.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_x_boxes.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_x_boxes.hpp
|
||||
|
||||
${UI_SOURCES}
|
||||
${CUSTOM_UI_SOURCES}
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#include "UI_plot.hpp"
|
||||
|
||||
UI_plot::UI_plot(QObject* parent)
|
||||
: UI_item{UI_PLOT_TYPE, parent}
|
||||
{
|
||||
}
|
||||
|
||||
UI_plot::UI_plot(std::string text, std::string x_label, std::string y_label, QObject *parent)
|
||||
: UI_item(UI_PLOT_TYPE, parent) , m_x_label(x_label), m_y_label(y_label)
|
||||
{
|
||||
set_text(text);
|
||||
}
|
||||
|
||||
UI_plot::UI_plot(const json &j, QObject *parent)
|
||||
: UI_item{UI_PLOT_TYPE, parent}
|
||||
{
|
||||
from_json(j);
|
||||
}
|
||||
\
|
||||
void UI_plot::set_x_label(std::string name)
|
||||
{
|
||||
m_x_label = name;
|
||||
}
|
||||
|
||||
std::string UI_plot::x_label() const
|
||||
{
|
||||
return m_x_label;
|
||||
}
|
||||
|
||||
void UI_plot::set_y_label(std::string name)
|
||||
{
|
||||
m_y_label = name;
|
||||
}
|
||||
|
||||
std::string UI_plot::y_label() const
|
||||
{
|
||||
return m_y_label;
|
||||
}
|
||||
|
||||
void UI_plot::add_value(double x, double y)
|
||||
{
|
||||
m_x_vals.push_back(x);
|
||||
m_y_vals.push_back(y);
|
||||
}
|
||||
|
||||
void UI_plot::clean_vals()
|
||||
{
|
||||
m_x_vals.clear();
|
||||
m_y_vals.clear();
|
||||
}
|
||||
|
||||
void UI_plot::from_json(const json &j)
|
||||
{
|
||||
UI_item::from_json(j);
|
||||
this->m_x_label = j.at("x_label");
|
||||
this->m_y_label = j.at("y_label");
|
||||
this->m_x_vals = (std::vector<double>)j.at("x_vals");
|
||||
this->m_y_vals = (std::vector<double>)j.at("y_vals");
|
||||
}
|
||||
|
||||
json UI_plot::to_json(size_t id) const
|
||||
{
|
||||
json j = UI_item::to_json(id);
|
||||
j["x_label"] = m_x_label;
|
||||
j["y_label"] = m_y_label;
|
||||
j["x_vals"] = m_x_vals;
|
||||
j["y_vals"] = m_y_vals;
|
||||
return j;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef UI_PLOT_H
|
||||
#define UI_PLOT_H
|
||||
|
||||
#include "UI_item.hpp"
|
||||
#define UI_PLOT_TYPE std::string("UI_plot")
|
||||
|
||||
class UI_plot : public UI_item {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UI_plot(QObject* parent = nullptr);
|
||||
UI_plot(std::string text, std::string x_label, std::string y_label, QObject *parent = nullptr);
|
||||
UI_plot(const json &j, QObject *parent = nullptr);
|
||||
\
|
||||
void set_x_label(std::string name);
|
||||
std::string x_label() const;
|
||||
void set_y_label(std::string name);
|
||||
std::string y_label() const;
|
||||
void set_x_label_enabled(bool enabled);
|
||||
bool x_label_enabled() const;
|
||||
void set_y_label_enabled(bool enabled);
|
||||
bool y_label_enabled() const;
|
||||
void add_value(double x, double y);
|
||||
void clean_vals();
|
||||
|
||||
void from_json(const json &j) override;
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
private:
|
||||
std::vector<double>m_x_vals;
|
||||
std::vector<double>m_y_vals;
|
||||
std::string m_x_label;
|
||||
std::string m_y_label;
|
||||
bool m_x_label_enabled;
|
||||
bool m_y_label_enabled;
|
||||
};
|
||||
|
||||
#endif // UI_PLOT_H
|
||||
Reference in New Issue
Block a user