Weather App
 
Loading...
Searching...
No Matches
PanelSensor.h
Go to the documentation of this file.
1
5
6 #pragma once
7 #include "Panel.h"
8 #include "HttpFetcher.h"
9 #include "LocalDB.h"
10 #include <wx/app.h>
11 #include <wx/charts/wxcharts.h>
12 #include <wx/slider.h>
13 #include <wx/richtext/richtextctrl.h>
14
22 class PanelSensor : public Panel {
23 public:
33 PanelSensor(Panel* origin, std::string sensorId, std::string chartName);
34
41
44 std::string sensorId;
45 std::string chartName;
47
50 const int styleObjectSpacingX = 10;
51 const int styleObjectSpacingY = 10;
53
56
61 void FetchData();
62
71 void OnDataFetched(wxThreadEvent& event);
72
75
78
82 void UpdateGUI();
83
89 void OnWindowResized(wxSizeEvent& event);
90
96 void OnWindowMaximized(wxMaximizeEvent& event);
97
103 void OnFullScreen(wxFullScreenEvent& event);
105
108 wxStaticText* textTop;
109
112 wxSlider* slider;
113 void OnSliderChanged(wxCommandEvent& event);
114
115 const int sliderMinValue = 0;
116 const int sliderMaxValue = 1000;
117 const int startingValueCount = 24;
119
122 wxRichTextCtrl* summery1;
123 wxRichTextCtrl* summery2;
124
129
135
138 nlohmann::json data;
139
140 wxLineChartCtrl* chart = nullptr;
141
146
152
156 float chartSum;
157 size_t chartMinIndex = 0;
158 size_t chartMaxIndex = 0;
160
167
170 wxButton* button_back;
171
178 void ButtonBack_OnButtonClick(wxCommandEvent& event);
180 };
181
Defines the HttpFetcher class for performing HTTP GET requests asynchronously.
Manages local storage and retrieval of JSON data for stations and sensors.
Defines the Panel class for managing wxWidgets panels.
Handles asynchronous HTTP GET requests.
Definition HttpFetcher.h:34
Panel(Panel *origin)
Constructs a new Panel and hides the previous one if provided.
float chartStandardDeviationSum
Sum of squared deviations for standard deviation calculation.
Definition PanelSensor.h:159
~PanelSensor()
Destructor for PanelSensor.
const int startingValueCount
Default number of data points displayed.
Definition PanelSensor.h:117
int chartLocalValidCount
Number of valid points in the currently viewed range.
Definition PanelSensor.h:161
const int styleObjectSpacingX
Horizontal spacing between UI elements.
Definition PanelSensor.h:50
void UpdateSummery1Text()
Updates the text in the summary box.
wxRichTextCtrl * summery1
Rich text box displaying summary statistics.
Definition PanelSensor.h:122
void OnWindowResized(wxSizeEvent &event)
Handles window resize events.
const int styleObjectSpacingY
Vertical spacing between UI elements.
Definition PanelSensor.h:51
wxLineChartCtrl * chart
Pointer to the line chart control.
Definition PanelSensor.h:140
void UpdateGUI()
Updates the graphical user interface. Resizes UI elements based on the current window size.
void UpdateChartSize()
Adjusts the chart size based on the window size.
void OnFullScreen(wxFullScreenEvent &event)
Handles full-screen events.
size_t chartMinIndex
Index of the minimum value in the dataset.
Definition PanelSensor.h:157
float chartSum
Sum of all data points.
Definition PanelSensor.h:156
nlohmann::json data
JSON object holding sensor data.
Definition PanelSensor.h:138
float chartLocalStandardDeviationSum
Sum of squared deviations for local standard deviation calculation.
Definition PanelSensor.h:165
void FetchData()
Initiates fetching of sensor data.
void OnDataFetched(wxThreadEvent &event)
Event handler for processing fetched sensor data.
size_t chartMaxIndex
Index of the maximum value in the dataset.
Definition PanelSensor.h:158
const int sliderMaxValue
Maximum value of the slider.
Definition PanelSensor.h:116
void UpdateSummeryTransofrm()
Applies transformations and updates the second summary box.
std::string chartName
Name displayed on the chart.
Definition PanelSensor.h:45
void OnSliderChanged(wxCommandEvent &event)
Handles slider change events.
void UpdateChart()
Updates the chart with the latest data.
int chartValidCount
Total number of valid data points.
Definition PanelSensor.h:155
wxButton * button_back
Button for navigating back to the previous panel.
Definition PanelSensor.h:170
wxStaticText * textTop
Static text displaying the sensor selection message.
Definition PanelSensor.h:108
const int sliderMinValue
Minimum value of the slider.
Definition PanelSensor.h:115
void ButtonBack_OnButtonClick(wxCommandEvent &event)
Handles click events on the "Back" button. Closes the panel and returns to the previous screen.
wxRichTextCtrl * summery2
Rich text box displaying transformed statistics.
Definition PanelSensor.h:123
wxSlider * slider
Slider for adjusting displayed data range.
Definition PanelSensor.h:112
float chartLocalSum
Sum of data points in the viewed range.
Definition PanelSensor.h:162
void OnWindowMaximized(wxMaximizeEvent &event)
Handles window maximization events.
size_t chartLocalMinIndex
Index of the minimum value in the viewed range.
Definition PanelSensor.h:163
std::string sensorId
Unique ID of the selected sensor.
Definition PanelSensor.h:44
HttpFetcher * httpFetcher
Pointer to an HTTP fetcher instance.
Definition PanelSensor.h:73
PanelSensor(Panel *origin, std::string sensorId, std::string chartName)
Constructor for PanelSensor.
size_t chartLocalMaxIndex
Index of the maximum value in the viewed range.
Definition PanelSensor.h:164