29 namespace visualization {
32 unsigned int position_x_,
unsigned int position_y_,
33 unsigned int width_ ,
unsigned int height_) :
34 Window(name_, position_x_, position_y_, width_, height_)
47 LOG(LTRACE) <<
"WindowMazeOfDigits::Display handler of window " << glutGetWindow();
50 APP_DATA_SYNCHRONIZATION_SCOPED_LOCK();
53 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
54 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
62 size_t w_window = glutGet(GLUT_WINDOW_WIDTH);
63 size_t h_window = glutGet(GLUT_WINDOW_HEIGHT);
66 float w_scale = (float) w_window / w_tensor;
67 float h_scale = (float) h_window / h_tensor;
68 float scale_min = (w_scale < h_scale) ? w_scale : h_scale;
76 for (
size_t y = 0; y < h_tensor; y++) {
77 for (
size_t x = 0; x < w_tensor; x++) {
84 r = 0.0; g = 0.0; b = 0.0;
88 case 0: r = 0.0; g = 0.0; b = 0.3;
break;
89 case 1: r = 0.0; g = 0.0; b = 0.6;
break;
90 case 2: r = 0.0; g = 0.0; b = 0.9;
break;
91 case 3: r = 0.0; g = 0.3; b = 1.0;
break;
92 case 4: r = 0.0; g = 0.6; b = 0.6;
break;
93 case 5: r = 0.0; g = 0.9; b = 0.3;
break;
94 case 6: r = 1.0; g = 0.75; b = 0.0;
break;
95 case 7: r = 1.0; g = 0.5; b = 0.0;
break;
96 case 8: r = 1.0; g = 0.25; b = 0.0;
break;
97 case 9: r = 1.0; g = 1.0; b = 1.0;
break;
102 draw_filled_rectangle(
float(x) * w_scale,
float(y) * h_scale, h_scale, w_scale, r,g, b, (
float)1.0f);
107 r = 0.0; g = 0.0; b = 0.0;
108 draw_cross((
float(x) + 0.5)* w_scale, (
float(y) + 0.5)* h_scale, scale_min/4, 4.0, r, g, b, (
float)1.0f);
109 r = 1.0; g = 0.0; b = 0.0;
110 draw_cross((
float(x) + 0.5)* w_scale, (
float(y) + 0.5)* h_scale, scale_min/4, 2.0, r, g, b, (
float)1.0f);
116 r = 0.0; g = 0.0; b = 0.0;
117 draw_circle((
float(x) + 0.5)* w_scale, (
float(y) + 0.5)* h_scale, scale_min/4, 4.0, r, g, b, (
float)1.0f);
118 r = 1.0; g = 1.0; b = 1.0;
119 draw_circle((
float(x) + 0.5)* w_scale, (
float(y) + 0.5)* h_scale, scale_min/4, 2.0, r, g, b, (
float)1.0f);
127 draw_grid(0.5f, 0.3f, 0.3f, 0.3f, w_tensor, h_tensor);
137 Position2D prev = (*saccadic_path)[i-1];
138 Position2D next = (*saccadic_path)[i];
141 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
144 glVertex2i((
float(prev.x) + 0.5) * w_scale, (
float(prev.y) + 0.5) * h_scale);
145 glVertex2i((
float(next.x) + 0.5) * w_scale, (
float(next.y) + 0.5) * h_scale);
149 draw_circle((
float(next.x) + 0.5)* w_scale, (
float(next.y) + 0.5)* h_scale, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0);
158 Position2D prev = (*saccadic_path)[i-1];
159 Position2D next = (*saccadic_path)[i];
163 glColor4f(0.0f, g, 0.0f, 1.0f);
164 glVertex2i((
float(prev.x) + 0.5) * w_scale, (
float(prev.y) + 0.5) * h_scale);
165 glVertex2i((
float(next.x) + 0.5) * w_scale, (
float(next.y) + 0.5) * h_scale);
185 APP_DATA_SYNCHRONIZATION_SCOPED_LOCK();
193 APP_DATA_SYNCHRONIZATION_SCOPED_LOCK();
void draw_circle(float x, float y, float size, float line_width, float r, float g, float b, float a)
WindowMazeOfDigits(std::string name_="MazeOfDigits", unsigned int position_x_=0, unsigned int position_y_=0, unsigned int width_=512, unsigned int height_=512)
void setMazePointer(mic::types::TensorXfPtr displayed_maze_)
void draw_filled_rectangle(float x, float y, float h, float w, float r, float g, float b, float a)
void displayHandler(void)
Channel storing the agent position.
mic::types::TensorXfPtr displayed_maze
std::shared_ptr< std::vector< mic::types::Position2D > > saccadic_path
Saccadic path to be displayed - a sequence of consecutive agent positions.
Parent class of all OpenGL-based windows (abstract).
void draw_cross(float x, float y, float size, float line_width, float r, float g, float b, float a)
virtual ~WindowMazeOfDigits()
void setPathPointer(std::shared_ptr< std::vector< mic::types::Position2D > > saccadic_path_)
void draw_grid(float r, float g, float b, float a, float cells_h, float cells_v, float line_width_=1.0)
Declaration of WindowManager class along with a bunch of helpful types and macros.