GlistEngine
Loading...
Searching...
No Matches
gGUIBoxPlot.h
Go to the documentation of this file.
1/*
2 * gGUIBoxPlot.h
3 *
4 * Created on: Ap 27, 2026
5 * Author: ahmet celal
6 */
7
8#ifndef UI_GGUIBOXPLOT_H_
9#define UI_GGUIBOXPLOT_H_
10
11#include "gGUIControl.h"
12#include <vector>
13#include <string>
14
15class gGUIBoxPlot : public gGUIControl {
16public:
18 virtual ~gGUIBoxPlot();
19
20 // Standard GUI lifecycle
22 gBaseGUIObject* topParentGUIObject,
23 gBaseGUIObject* parentGUIObject,
24 int parentSlotLineNo,
25 int parentSlotColumnNo,
26 int x, int y, int w, int h) override;
27
28 void draw() override;
29 void update() override;
30
31 // Data
32 void setData(const std::vector<float>& values);
33 void clearData();
34
35 // Options
36 void setShowOutliers(bool show);
37 bool getShowOutliers() const;
38
39 void setTitle(const std::string& t);
40 const std::string& getTitle() const;
41
42 // Styling (optional)
43 void setBoxWidth(int w);
44 void setMarkerSize(int px);
45
46private:
47 // Stats
48 bool computeStats(); // returns false if not enough data
49 static float medianSorted(const std::vector<float>& sorted, int l, int rExclusive);
50
51 // Drawing helpers
52 int yToPix(float y) const;
53 void rebuildYScale();
54 void drawOutlierMarker(int x, int y) const;
55
56private:
57 std::vector<float> raw;
58 std::vector<float> sorted;
59 std::vector<float> outliers;
60
61 bool showOutliers = true;
62 std::string title = "Box Plot";
63
64 // computed
65 bool hasStats = false;
66 float q1 = 0.0f, med = 0.0f, q3 = 0.0f;
67 float iqr = 0.0f;
68 float whiskLow = 0.0f, whiskHigh = 0.0f;
69 float minY = 0.0f, maxY = 1.0f;
70
71 // layout
72 int padLeft = 60;
73 int padRight = 40;
74 int padTop = 60;
75 int padBottom = 60;
76
77 int boxWidth = 160;
78 int markerSize = 6;
79
80 // cache
81 int chartX = 0, chartY = 0, chartW = 0, chartH = 0;
82};
83
84#endif /* UI_GGUIBOXPLOT_H_ */
Definition gBaseApp.h:16
Definition gBaseGUIObject.h:18
gBaseApp * root
Definition gBaseGUIObject.h:147
Definition gGUIBoxPlot.h:15
void setTitle(const std::string &t)
void setData(const std::vector< float > &values)
void update() override
const std::string & getTitle() const
void setMarkerSize(int px)
void set(gBaseApp *root, gBaseGUIObject *topParentGUIObject, gBaseGUIObject *parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h) override
void clearData()
void setBoxWidth(int w)
virtual ~gGUIBoxPlot()
void draw() override
bool getShowOutliers() const
void setShowOutliers(bool show)
Definition gGUIControl.h:29