-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraphwindow.h
More file actions
119 lines (89 loc) · 2.49 KB
/
Copy pathgraphwindow.h
File metadata and controls
119 lines (89 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma once
#include <GLFW/glfw3.h>
#include "widget.h"
#include "helper_types.h"
#include "textedit.h"
struct OldRenderState {
int t_x = -1;
int t_y = -1;
int t_w = -1;
int t_h = -1;
int b_h = -1;
int b_y = -1;
};
struct Drawable {
double x; // in scale
double y; // in scale
Color* c;
virtual ~Drawable() = default;
};
struct DrawCircle : Drawable {}; // don't actually need more data. Just want it anyways.
struct DrawLine : Drawable {
double endX;
double endY;
};
struct DataType {
bool scatter = false;
std::vector<double> x = {};
std::vector<double> y = {};
Button* scatterButton = nullptr;
Button* removeButton = nullptr;
int id;
std::vector<double> modified_x = {};
std::vector<double> modified_y = {};
Color* c;
virtual ~DataType() = default;
bool file = false;
// for files
icu::UnicodeString filename;
std::string filepath;
// for non files
TextEdit* x_edit = nullptr;
TextEdit* y_edit = nullptr;
};
class GraphWindow : public Widget {
public:
GraphWindow(Widget* parent);
void render() override;
bool on_mouse_button_event(int button, int action, int mods) override;
bool on_mouse_move_event() override;
bool on_scroll_event(double xchange, double ychange) override;
bool on_key_event(int key, int scancode, int action, int mods) override;
void position(int x, int y, int w, int h) override;
void executeAction(WidgetActionType typ) override;
private:
std::vector<Color*> colorsList;
std::vector<std::unique_ptr<Drawable>> drawables = {};
std::vector<DataType> allData = {};
OldRenderState OLDSTATE = {};
bool rerender = true;
void setColors();
void addThing(bool isfile, std::string filepath="");
void updateInfoFor(int id);
void recalculateDrawables(bool changeMinsMax=true);
void recalculateDisplayedValues();
std::vector<double> getVals(icu::UnicodeString text, bool& allgood);
std::vector<std::filesystem::path> get_files_in_directory(const std::filesystem::path& dir_path);
std::pair<int,int> fromScaledToPixels(double x, double y);
std::pair<double,double> fromPixelsToScaled(int x, int y);
double xmin = 0;
double ymin = 0;
double xmax = 10;
double ymax = 10;
Button* reset;
Button* addCords;
Button* addFile;
Button* addFolder;
TextEdit* averageText;
int screenHeight = 0;
int screenStart = 0;
int id_glob = 0;
int EXISTING_VAL = 0;
int TOTAL_ITEM_HEIGHT = 0;
double scroll = 0;
bool selectingSquare = false;
bool canSelect = false;
int squareStartX = 0;
int squareStartY = 0;
bool moving = false;
};