20 #include "../global.h"
21 #include "orderizer.h"
31 #define H2D_DEFAULT_X_POS -1
32 #define H2D_DEFAULT_Y_POS -1
33 #define H2D_DEFAULT_WIDTH 600
34 #define H2D_DEFAULT_HEIGHT 400
35 #define H2DV_SCALE_LOG_BASE 1.005
37 #define transform_x(x) ((x * scale + trans_x) + center_x)
38 #define transform_y(y) (center_y - (y * scale + trans_y))
52 WinGeom(
int x,
int y,
int width,
int height) {
56 this->height = height;
80 class HERMES_API
View :
public Hermes::Mixins::TimeMeasurable,
public Hermes::Mixins::Loggable
95 const char* get_title()
const;
97 void set_title(
const char* msg, ...);
99 void set_min_max_range(
double min,
double max);
100 void auto_min_max_range();
101 void get_min_max_range(
double& min,
double& max);
103 void show_scale(
bool show =
true);
104 void set_scale_position(
int horz,
int vert);
105 void set_scale_size(
int width,
int height,
int numticks);
106 void set_scale_format(
const char* fmt);
107 void fix_scale_width(
int width = 80);
111 void save_screenshot(
const char* bmpname,
bool high_quality =
false);
114 void save_numbered_screenshot(
const char* format,
int number,
bool high_quality =
false);
117 void set_num_palette_steps(
int num);
118 void set_palette_filter(
bool linear);
121 static void wait_for_keypress(
const char* text =
nullptr);
122 void wait_for_close();
123 void wait_for_draw();
126 static void wait(
const char* text);
131 virtual void reset_view(
bool force_reset);
134 #define FPS_FRAME_SIZE 5
135 double rendering_frames[FPS_FRAME_SIZE];
142 static double get_tick_count();
149 double scale, log_scale, trans_x, trans_y;
150 double center_x, center_y;
151 int margin, lspace, rspace;
152 int mouse_x, mouse_y;
155 bool dragging, scaling;
157 virtual void on_create(
int output_id);
158 virtual void on_display() {};
159 virtual void on_reshape(
int width,
int height);
160 virtual void on_mouse_move(
int x,
int y);
161 virtual void on_left_mouse_down(
int x,
int y);
162 virtual void on_left_mouse_up(
int x,
int y);
163 virtual void on_left_mouse_double_click(
int x,
int y) {}
164 virtual void on_right_mouse_down(
int x,
int y);
165 virtual void on_right_mouse_up(
int x,
int y);
166 virtual void on_right_mouse_double_click(
int x,
int y) {}
167 virtual void on_middle_mouse_down(
int x,
int y) {}
168 virtual void on_middle_mouse_up(
int x,
int y) {}
169 virtual void on_middle_mouse_double_click(
int x,
int y) {}
170 virtual void on_key_down(
unsigned char key,
int x,
int y);
171 virtual void on_special_key(
int key,
int x,
int y);
172 virtual void on_entry(
int state) {}
173 virtual void on_close();
176 virtual void update_layout();
181 int output_x, output_y, output_width, output_height;
182 float jitter_x, jitter_y;
183 bool hq_frame, frame_ready;
186 int pal_steps, pal_filter;
187 double tex_scale, tex_shift;
189 double range_min, range_max;
191 bool b_scale, b_help;
192 bool scale_focused, scale_dragging;
193 int pos_horz, pos_vert;
194 int scale_x, scale_y;
195 int scale_width, scale_height, labels_width;
196 int scale_numticks, scale_box_height, scale_box_skip;
198 int scale_fixed_width;
200 bool want_screenshot;
201 static int screenshot_no;
209 void create_gl_palette();
211 virtual void get_palette_color(
double x,
float* gl_color);
214 inline double untransform_x(
double x) {
return (x - center_x - trans_x) / scale; }
215 inline double untransform_y(
double y) {
return (center_y - y - trans_y) / scale; }
218 virtual void clear_background();
220 void display_antialiased();
222 void set_ortho_projection(
bool no_jitter =
false);
223 void set_3d_projection(
int fov,
double znear,
double zfar);
225 void draw_text(
double x,
double y,
const char* text,
int align = -1);
226 int get_text_width(
const char* text);
228 char *get_screenshot_file_name();
229 void save_screenshot_internal(
const char* filename);
231 virtual void scale_dispatch();
232 virtual int measure_scale_labels();
233 void draw_continuous_scale(
char* title,
bool righttext);
234 void draw_discrete_scale(
int numboxes,
const char* boxnames[],
const float boxcolors[][3]);
236 void update_tex_adjust();
238 virtual const char* get_help_text()
const = 0;
240 friend void on_display_stub(
void);
241 friend void on_reshape_stub(
int,
int);
242 friend void on_mouse_move_stub(
int,
int);
243 friend void on_mouse_click_stub(
int,
int,
int,
int);
244 friend void on_key_down_stub(
unsigned char,
int,
int);
245 friend void on_special_key_stub(
int,
int,
int);
246 friend void on_entry_stub(
int);
247 friend void on_idle_stub();
248 friend void on_close_stub();
249 friend int add_view_in_thread(
void*);
250 friend int remove_view_in_thread(
void*);
251 friend void on_create(
int);
254 class HERMES_API View
258 void init() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
260 View(
const char* title, WinGeom* wg =
nullptr) {}
261 View(
char* title, WinGeom* wg =
nullptr) {}
263 int create() {
throw Hermes::Exceptions::Exception(
"GLUT disabled.");
return -1; }
264 void close() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
265 void refresh() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
268 void set_title(
const char* msg, ...) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
270 void set_min_max_range(
double min,
double max) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
271 void auto_min_max_range() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
272 void get_min_max_range(
double& min,
double& max) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
274 void show_scale(
bool show =
true) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
275 void set_scale_position(
int horz,
int vert) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
276 void set_scale_size(
int width,
int height,
int numticks) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
277 void set_scale_format(
const char* fmt) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
278 void fix_scale_width(
int width = 80) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
282 void save_screenshot(
const char* bmpname,
bool high_quality =
false) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
285 void save_numbered_screenshot(
const char* format,
int number,
bool high_quality =
false) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
287 void set_palette(
ViewPaletteType type) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
288 void set_num_palette_steps(
int num) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
289 void set_palette_filter(
bool linear) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
291 static void wait_for_keypress(
const char* text =
nullptr) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
292 void wait_for_close() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
293 void wait_for_draw() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
295 static void wait(
const char* text) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
296 static void wait(
ViewWaitEvent wait_event =
HERMES_WAIT_CLOSE,
const char* text =
nullptr) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
unsigned int gl_pallete_tex_id
OpenGL texture object ID.
Represents a simple visualization window.
Wait for all windows to close.
ViewWaitEvent
Wait events.
::xsd::cxx::tree::type type
C++ type corresponding to the anyType XML Schema built-in type.
bool view_not_reset
True if the view was not reset and therefore it has to be.
ViewPaletteType
View palette type.
Maximum ID of view palette type.
int rendering_frames_top
the new_ location of the next FPS
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Wait for any unprocessed keypress to happen.
A palette based on hue scale.
double vertices_min_x
AABB of shown mesh.