-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_area.hpp
171 lines (125 loc) · 3.52 KB
/
render_area.hpp
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#ifndef RENDER_AREA_HPP
#define RENDER_AREA_HPP
#include "ui_mainwindow.h"
#include <QWidget>
#include <QTimer>
#include <QTime>
#include <QPainter>
#include <QMouseEvent>
#include <QLabel>
#include <QStyle>
#include <QCursor>
#include <QThread>
#include <list>
#include <iostream>
#include <vector>
#include <string>
#include <windows.h>
#include <stdlib.h>
#include <iostream>
#include <QPlainTextEdit>
#include <QString>
#include "./Tree/tree.hpp"
#include "structure/structure_tree_choice.hpp"
#include "vec2.hpp"
#include "3D/vec3.hpp"
#include "3D/mat3.hpp"
#include "3D/obj_generator.hpp"
using std::vector;
using std::string;
//forward declaration of QLabel
class QLabel;
//The main class wher all the human/machine interaction are managed
class render_area : public QWidget
{
Q_OBJECT
public:
//constructor
render_area(QPlainTextEdit *,QPlainTextEdit *,QPlainTextEdit *, Ui::MainWindow *,QWidget *parent = 0);
~render_area();
void init_fig();
void giveDescriptionText(QPlainTextEdit *);
void give_TextEdit(QPlainTextEdit *text);
QString description_rule();
QString description_alphabet();
QString description_axiom();
void displayRule();
void changeAlphabet(string);
void changeRules(string);
void changeAxiom(string);
void resetRule();
void update_tree_name(string);
void update_tree_radius(float r_start,float r_end);
tree get_tree();
protected:
/** Actual drawing function */
void paintEvent(QPaintEvent *event);
/** Function called when the mouse is pressed */
void mousePressEvent(QMouseEvent *event);
/** Function called when the mouse is moved */
void mouseMoveEvent(QMouseEvent *event);
/** Function called when the mouse is released */
void mouseReleaseEvent(QMouseEvent *event);
/** Function called in render_area */
void paint_segment(QPainter *painter,vec3 p1,vec3 p2);
void draw_tree();
/** Function to get the cell wher the mouse is*/
void paint();
private slots:
// functions called by the GUI
void update_brush_size(int );
void update_tree_size(int );
void update_segment_size(int );
void update_alpha(int );
void update_alpha_random(int );
void update_beta(int );
void update_beta_random(int );
void update_gamma(int );
void update_gamma_random(int );
void update_ratio(int );
void update_algo_select(int );
void update_algo_speed(int );
void update_rotation_y(int );
void update_rotation_x(int );
void update_startColor(int);
void update_endColor(int);
void reset_grid();
void launch_algo();
private: //attributes
int width;
int height;
void cleanGrid();
float brush_size;
float rotation_theta_y;
float rotation_theta_x;
float scale;
float scale_prec;
int algo_select;
int algo_iter;
int algo_delay;
bool running;
float dx;
float dy;
float dx_prec;
float dy_prec;
int clickpos_x;
int clickpos_y;
/** The current position of the click of the mouse */
vec2 mouse_point;
mat3 mat_rotation_y;
mat3 mat_rotation_x;
/** Indicates if the mouse is currently clicked or not */
bool is_left_clicked;
bool is_right_clicked;
bool slow_draw;
int slow_draw_iter;
QPlainTextEdit *ruleText;
QPlainTextEdit *axiomText;
QPlainTextEdit *alphabetText;
Ui::MainWindow *ui;
tree render_tree;
structure_tree_choice treeStructure;
vector<vector<int>> lst_color;
vector<int> color_selected;
};
#endif // RENDER_AREA_HPP