/
ifs_gui.h
479 lines (423 loc) · 14.6 KB
/
ifs_gui.h
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
#ifndef __IFS_GUI__
#define __IFS_GUI__
extern "C" {
#include <X11/Xlib.h>
#include <X11/Xutil.h>
}
#include <string>
#include <vector>
#include "ifs.h"
#include "point.h"
struct IFSGui;
struct Widget {
Point2d<int> ul; //the upper left hand corner
int height;
int width;
IFSGui* ifsg; //the gui, so we can call the member functions
Pixmap p;
GC gc;
void (IFSGui::*click_signal)(XEvent*);
virtual void initial_draw() = 0;
virtual void redraw() = 0;
void clear();
bool contains_pixel(int x, int y);
bool intersects_rectangle(const Point2d<int>& p, int w, int h);
Widget() {}
};
struct WidgetDraw : Widget {
WidgetDraw() {}
WidgetDraw(IFSGui* i, int w, int h, void (IFSGui::*f)(XEvent*));
void redraw();
void initial_draw();
};
struct WidgetButton : Widget {
std::string text;
Point2d<int> text_position;
WidgetButton() {}
WidgetButton(IFSGui* i, const std::string& t, int w, int h, void (IFSGui::*f)(XEvent*));
void initial_draw();
void redraw();
};
struct WidgetText : Widget {
std::string text;
Point2d<int> text_position;
WidgetText() {}
WidgetText(IFSGui* i, const std::string& t, int w, int h);
void update_text(const std::string& s);
void redraw();
void initial_draw();
};
struct WidgetCheck : Widget {
std::string text;
bool checked;
Point2d<int> text_position;
WidgetCheck() {}
WidgetCheck(IFSGui* i, const std::string& t, int w, int h, bool c, void (IFSGui::*f)(XEvent*));
void redraw();
void initial_draw();
};
struct WidgetLeftArrow : Widget {
WidgetLeftArrow() {}
WidgetLeftArrow(IFSGui* i, int w, int h, void (IFSGui::*f)(XEvent*));
void initial_draw();
void redraw();
};
struct WidgetRightArrow : Widget {
WidgetRightArrow() {}
WidgetRightArrow(IFSGui* i, int w, int h, void (IFSGui::*f)(XEvent*));
void initial_draw();
void redraw();
};
struct IFSPath {
bool is_valid;
std::vector<cpx> path;
bool closed;
bool has_traps;
std::vector<Ball> traps;
std::vector<int> trap_colors;
bool has_coordinates;
std::vector<std::pair<double, double> > coordinates;
bool has_uv_words;
std::vector<std::pair<Bitword,Bitword> > uv_words;
bool has_half_words;
std::vector<Bitword> half_words;
int half_depth;
int half_start;
int half_end;
int movie_length;
int movie_fps;
bool movie_with_mandelbrot;
IFSPath() {
is_valid = false;
path.resize(0);
closed = has_traps = has_coordinates = has_uv_words = has_half_words = false;
traps.resize(0);
trap_colors.resize(0);
coordinates.resize(0);
uv_words.resize(0);
movie_length = 10;
movie_fps = 30;
movie_with_mandelbrot = false;
half_depth = 10;
half_start = 0;
half_end = 0;
}
};
enum IFSWindowMode { LIMIT, MANDELBROT, BOTH };
struct IFSGui {
//which mode
IFSWindowMode window_mode;
//limit and mandelbrot settings
//limit
ifs IFS;
cpx limit_ll;
cpx limit_ur;
int limit_depth;
bool limit_auto_depth;
bool limit_chunky;
bool limit_colors;
double limit_pixel_width;
bool limit_uv_graph;
int limit_uv_graph_depth;
bool limit_nifs;
bool limit_gifs;
bool limit_2d;
std::vector<cpx> limit_marked_points;
Point2d<int> limit_cpx_to_pixel(const cpx& c);
cpx limit_pixel_to_cpx(const Point2d<int>& p);
//mandelbrot
cpx mand_ll;
cpx mand_ur;
int mand_pixel_group_size;
int mand_num_pixel_groups;
double mand_pixel_group_width;
double mand_pixel_width;
bool mand_connected;
int mand_connected_depth;
bool mand_contains_half;
int mand_contains_half_depth;
bool mand_trap;
int mand_trap_depth;
bool mand_limit_trap;
bool mand_dirichlet;
int mand_dirichlet_depth;
bool mand_set_C;
int mand_set_C_depth;
bool mand_theta;
int mand_theta_depth;
cpx mand_pixel_group_to_cpx(const Point2d<int>& p);
Point2d<int> mand_cpx_to_pixel_group(const cpx& c);
cpx mand_pixel_to_cpx(const Point2d<int>& p);
Point2d<int> mand_cpx_to_pixel(const cpx& c);
int mand_get_color(PointNd<6,int>& p);
int mand_output_picture_size;
//data for mandelbrot
std::vector<std::vector<PointNd<6,int> > > mand_data_grid;
bool mand_grid_connected_valid;
bool mand_grid_contains_half_valid;
bool mand_grid_trap_valid;
bool mand_grid_dirichlet_valid;
bool mand_grid_set_C_valid;
bool mand_grid_theta_valid;
//data about highlighted point
bool point_connected_check;
int point_connected_depth;
bool point_is_connected;
bool point_contains_half_check;
int point_contains_half_depth;
bool point_is_contains_half;
bool point_uv_words_check;
int point_uv_words_depth;
std::vector<std::pair<Bitword,Bitword> > point_uv_words;
bool point_trap_check;
int point_trap_depth;
std::vector<std::pair<Bitword,Bitword> > point_trap_words;
bool point_coordinates_check;
int point_coordinates_depth;
double point_coordinates_theta;
double point_coordinates_lambda;
//data about path
IFSPath path;
bool currently_drawing_path;
void make_path_drawing_buttons();
void make_path_task_buttons(bool created_by_drawing);
void make_path_creation_buttons(bool cancelling);
//computation functions
void draw_limit();
void draw_nifs_limit();
void draw_gifs_limit();
void draw_2d_limit();
void recenter_limit(cpx c);
void draw_mand();
void change_highlighted_ifs(cpx c);
void mand_zoom(double radius_multiplier);
void mand_reset_mesh();
void mand_recenter();
void mand_draw_ball(const Ball& b, int col);
void recompute_point_data();
void find_traps_along_path(int verbose);
void find_coordinates_along_path(int verbose);
//graphics stuff
Display* display;
int screen;
Window main_window;
Colormap col_map;
std::vector<Widget*> widgets;
int get_rgb_color(double r, double g, double b);
//widgets:
WidgetButton W_switch_to_limit;
WidgetButton W_switch_to_mandelbrot;
WidgetButton W_switch_to_combined;
WidgetText W_point_title;
WidgetText W_point_point;
WidgetCheck W_point_connected_check;
WidgetLeftArrow W_point_connected_leftarrow;
WidgetText W_point_connected_depth_label;
WidgetRightArrow W_point_connected_rightarrow;
WidgetText W_point_connected_status;
WidgetCheck W_point_contains_half_check;
WidgetLeftArrow W_point_contains_half_leftarrow;
WidgetText W_point_contains_half_depth_label;
WidgetRightArrow W_point_contains_half_rightarrow;
WidgetText W_point_contains_half_status;
WidgetCheck W_point_trap_check;
WidgetLeftArrow W_point_trap_leftarrow;
WidgetText W_point_trap_depth_label;
WidgetRightArrow W_point_trap_rightarrow;
WidgetText W_point_trap_status;
WidgetCheck W_point_uv_words_check;
WidgetLeftArrow W_point_uv_words_leftarrow;
WidgetText W_point_uv_words_depth_label;
WidgetRightArrow W_point_uv_words_rightarrow;
WidgetText W_point_uv_words_status;
WidgetCheck W_point_coordinates_check;
WidgetLeftArrow W_point_coordinates_leftarrow;
WidgetText W_point_coordinates_depth_label;
WidgetRightArrow W_point_coordinates_rightarrow;
WidgetText W_point_coordinates_status;
WidgetDraw W_limit_plot;
WidgetText W_limit_depth_title;
WidgetLeftArrow W_limit_depth_leftarrow;
WidgetText W_limit_depth_label;
WidgetRightArrow W_limit_depth_rightarrow;
WidgetCheck W_limit_depth_auto;
WidgetCheck W_limit_chunky;
WidgetCheck W_limit_colors;
WidgetText W_limit_zoom_title;
WidgetButton W_limit_zoom_in;
WidgetButton W_limit_zoom_out;
WidgetText W_limit_center_title;
WidgetCheck W_limit_uv_graph;
WidgetText W_limit_uv_graph_depth_title;
WidgetLeftArrow W_limit_uv_graph_depth_leftarrow;
WidgetText W_limit_uv_graph_depth_label;
WidgetRightArrow W_limit_uv_graph_depth_rightarrow;
WidgetCheck W_limit_nifs;
WidgetCheck W_limit_gifs;
WidgetCheck W_limit_2d;
WidgetDraw W_mand_plot;
WidgetText W_mand_options_title;
WidgetButton W_mand_recenter;
WidgetText W_mand_zoom_title;
WidgetButton W_mand_zoom_in;
WidgetButton W_mand_zoom_out;
WidgetText W_mand_mesh_title;
WidgetLeftArrow W_mand_mesh_leftarrow;
WidgetText W_mand_mesh_label;
WidgetRightArrow W_mand_mesh_rightarrow;
WidgetCheck W_mand_connected_check;
WidgetLeftArrow W_mand_connected_depth_leftarrow;
WidgetText W_mand_connected_depth_label;
WidgetRightArrow W_mand_connected_depth_rightarrow;
WidgetCheck W_mand_contains_half_check;
WidgetLeftArrow W_mand_contains_half_depth_leftarrow;
WidgetText W_mand_contains_half_depth_label;
WidgetRightArrow W_mand_contains_half_depth_rightarrow;
WidgetCheck W_mand_trap_check;
WidgetLeftArrow W_mand_trap_depth_leftarrow;
WidgetText W_mand_trap_depth_label;
WidgetRightArrow W_mand_trap_depth_rightarrow;
WidgetCheck W_mand_limit_trap_check;
WidgetCheck W_mand_dirichlet_check;
WidgetLeftArrow W_mand_dirichlet_depth_leftarrow;
WidgetText W_mand_dirichlet_depth_label;
WidgetRightArrow W_mand_dirichlet_depth_rightarrow;
WidgetCheck W_mand_set_C_check;
WidgetLeftArrow W_mand_set_C_depth_leftarrow;
WidgetText W_mand_set_C_depth_label;
WidgetRightArrow W_mand_set_C_depth_rightarrow;
WidgetCheck W_mand_theta_check;
WidgetLeftArrow W_mand_theta_depth_leftarrow;
WidgetText W_mand_theta_depth_label;
WidgetRightArrow W_mand_theta_depth_rightarrow;
WidgetText W_mand_mouse_label;
WidgetText W_mand_mouse_X;
WidgetText W_mand_mouse_Y;
WidgetButton W_mand_output_window;
WidgetButton W_mand_output_picture;
WidgetLeftArrow W_mand_output_picture_size_leftarrow;
WidgetText W_mand_output_picture_size_label;
WidgetRightArrow W_mand_output_picture_size_rightarrow;
WidgetText W_mand_path_drawing_title;
WidgetButton W_mand_path_create_by_drawing_button;
WidgetButton W_mand_path_create_by_boundary_button;
WidgetButton W_mand_path_finish_cancel_button;
WidgetButton W_mand_path_finish_path_button;
WidgetButton W_mand_path_finish_loop_button;
WidgetText W_mand_path_tasks_title;
WidgetButton W_mand_path_delete_button;
WidgetButton W_mand_path_find_traps_button;
WidgetButton W_mand_path_find_coordinates_button;
WidgetButton W_mand_path_create_movie_button;
WidgetText W_mand_path_movie_length_title;
WidgetLeftArrow W_mand_path_movie_decrease_length;
WidgetText W_mand_path_movie_length_label;
WidgetRightArrow W_mand_path_movie_increase_length;
WidgetCheck W_mand_path_movie_with_mandelbrot;
WidgetButton W_mand_path_find_uv_words_button;
WidgetButton W_mand_path_find_half_words_button;
WidgetText W_mand_path_half_depth_title;
WidgetLeftArrow W_mand_path_half_depth_leftarrow;
WidgetText W_mand_path_half_depth_label;
WidgetRightArrow W_mand_path_half_depth_rightarrow;
WidgetText W_mand_path_half_start_stop_title;
WidgetLeftArrow W_mand_path_half_start_leftarrow;
WidgetText W_mand_path_half_start_label;
WidgetRightArrow W_mand_path_half_start_rightarrow;
WidgetLeftArrow W_mand_path_half_end_leftarrow;
WidgetText W_mand_path_half_end_label;
WidgetRightArrow W_mand_path_half_end_rightarrow;
//signal functions
void S_switch_to_limit(XEvent* e);
void S_switch_to_mandelbrot(XEvent* e);
void S_switch_to_combined(XEvent* e);
void S_limit_draw(XEvent* e);
void S_limit_increase_depth(XEvent* e);
void S_limit_decrease_depth(XEvent* e);
void S_limit_auto_depth(XEvent* e);
void S_limit_switch_chunky(XEvent* e);
void S_limit_switch_colors(XEvent* e);
void S_limit_zoom_in(XEvent* e);
void S_limit_zoom_out(XEvent* e);
void S_limit_uv_graph(XEvent* e);
void S_limit_uv_graph_decrease_depth(XEvent* e);
void S_limit_uv_graph_increase_depth(XEvent* e);
void S_limit_nifs(XEvent* e);
void S_limit_gifs(XEvent* e);
void S_limit_2d(XEvent* e);
void S_mand_draw(XEvent* e);
void S_mand_recenter(XEvent* e);
void S_mand_zoom_in(XEvent* e);
void S_mand_zoom_out(XEvent* e);
void S_mand_decrease_mesh(XEvent* e);
void S_mand_increase_mesh(XEvent* e);
void S_mand_connected(XEvent* e);
void S_mand_connected_increase_depth(XEvent* e);
void S_mand_connected_decrease_depth(XEvent* e);
void S_mand_contains_half(XEvent* e);
void S_mand_contains_half_increase_depth(XEvent* e);
void S_mand_contains_half_decrease_depth(XEvent* e);
void S_mand_trap(XEvent* e);
void S_mand_trap_increase_depth(XEvent* e);
void S_mand_trap_decrease_depth(XEvent* e);
void S_mand_limit_trap(XEvent* e);
void S_mand_dirichlet(XEvent* e);
void S_mand_dirichlet_decrease_depth(XEvent* e);
void S_mand_dirichlet_increase_depth(XEvent* e);
void S_mand_set_C(XEvent* e);
void S_mand_set_C_decrease_depth(XEvent* e);
void S_mand_set_C_increase_depth(XEvent* e);
void S_mand_theta(XEvent* e);
void S_mand_theta_decrease_depth(XEvent* e);
void S_mand_theta_increase_depth(XEvent* e);
void S_mand_output_window(XEvent* e);
void S_mand_output_picture(XEvent* e);
void S_mand_output_picture_increase_size(XEvent* e);
void S_mand_output_picture_decrease_size(XEvent* e);
void S_point_connected(XEvent* e);
void S_point_connected_increase_depth(XEvent* e);
void S_point_connected_decrease_depth(XEvent* e);
void S_point_contains_half(XEvent* e);
void S_point_contains_half_increase_depth(XEvent* e);
void S_point_contains_half_decrease_depth(XEvent* e);
void S_point_trap(XEvent* e);
void S_point_trap_increase_depth(XEvent* e);
void S_point_trap_decrease_depth(XEvent* e);
void S_point_uv_words(XEvent* e);
void S_point_uv_words_increase_depth(XEvent* e);
void S_point_uv_words_decrease_depth(XEvent* e);
void S_point_coordinates(XEvent* e);
void S_point_coordinates_increase_depth(XEvent* e);
void S_point_coordinates_decrease_depth(XEvent* e);
void S_mand_path_create_by_drawing_button(XEvent* e);
void S_mand_path_create_by_boundary(XEvent* e);
void S_mand_path_finish_cancel(XEvent* e);
void S_mand_path_finish_path(XEvent* e);
void S_mand_path_finish_loop(XEvent* e);
void S_mand_path_delete(XEvent* e);
void S_mand_path_find_traps(XEvent* e);
void S_mand_path_find_coordinates(XEvent* e);
void S_mand_path_create_movie(XEvent* e);
void S_mand_path_movie_decrease_length(XEvent* e);
void S_mand_path_movie_increase_length(XEvent* e);
void S_mand_path_movie_with_mandelbrot(XEvent* e);
void S_mand_path_find_uv_words(XEvent* e);
void S_mand_path_find_half_words(XEvent* e);
void S_mand_path_half_increase_depth(XEvent* e);
void S_mand_path_half_decrease_depth(XEvent* e);
void S_mand_path_half_increase_start(XEvent* e);
void S_mand_path_half_decrease_start(XEvent* e);
void S_mand_path_half_increase_end(XEvent* e);
void S_mand_path_half_decrease_end(XEvent* e);
bool main_window_initialized;
int main_window_height;
int main_window_width;
int limit_sidebar_size;
int mand_sidebar_size;
void detach_widget(Widget* w);
void pack_widget_upper_right(const Widget* w1, Widget* w2);
void launch(IFSWindowMode m = BOTH, const cpx& c = cpx(0.5,0.5));
void reset_and_pack_window();
void main_loop();
};
#endif