25 #include "../global.h"
26 #include "vectorizer.h"
27 #include "orderizer.h"
37 #define H2D_DEFAULT_X_POS -1
38 #define H2D_DEFAULT_Y_POS -1
39 #define H2D_DEFAULT_WIDTH 600
40 #define H2D_DEFAULT_HEIGHT 400
41 #define H2DV_SCALE_LOG_BASE 1.005
55 WinGeom(
int x,
int y,
int width,
int height) {
59 this->height = height;
84 class HERMES_API
View :
public Hermes::Mixins::TimeMeasurable,
public Hermes::Mixins::Loggable
98 void set_title(
const char* title);
100 void set_min_max_range(
double min,
double max);
101 void auto_min_max_range();
102 void get_min_max_range(
double& min,
double& max);
104 void show_scale(
bool show =
true);
105 void set_scale_position(
int horz,
int vert);
106 void set_scale_size(
int width,
int height,
int numticks);
107 void set_scale_format(
const char* fmt);
108 void fix_scale_width(
int width = 80);
112 void save_screenshot(
const char* bmpname,
bool high_quality =
false);
115 void save_numbered_screenshot(
const char* format,
int number,
bool high_quality =
false);
118 void set_num_palette_steps(
int num);
119 void set_palette_filter(
bool linear);
121 void wait_for_keypress(
const char* text = NULL);
122 void wait_for_close();
123 void wait_for_draw();
125 static void wait(
const char* text);
128 virtual void reset_view(
bool force_reset);
131 #define FPS_FRAME_SIZE 5
132 double rendering_frames[FPS_FRAME_SIZE];
135 static double get_tick_count();
140 double scale, log_scale, trans_x, trans_y;
141 double center_x, center_y;
142 int margin, lspace, rspace;
143 int mouse_x, mouse_y;
146 bool dragging, scaling;
148 virtual void on_create(
int output_id);
149 virtual void on_display() {};
150 virtual void on_reshape(
int width,
int height);
151 virtual void on_mouse_move(
int x,
int y);
152 virtual void on_left_mouse_down(
int x,
int y);
153 virtual void on_left_mouse_up(
int x,
int y);
154 virtual void on_left_mouse_double_click(
int x,
int y) {}
155 virtual void on_right_mouse_down(
int x,
int y);
156 virtual void on_right_mouse_up(
int x,
int y);
157 virtual void on_right_mouse_double_click(
int x,
int y) {}
158 virtual void on_middle_mouse_down(
int x,
int y) {}
159 virtual void on_middle_mouse_up(
int x,
int y) {}
160 virtual void on_middle_mouse_double_click(
int x,
int y) {}
161 virtual void on_key_down(
unsigned char key,
int x,
int y);
162 virtual void on_special_key(
int key,
int x,
int y);
163 virtual void on_entry(
int state) {}
164 virtual void on_close();
166 virtual void update_layout();
171 int output_x, output_y, output_width, output_height;
172 float jitter_x, jitter_y;
173 bool hq_frame, frame_ready;
176 int pal_steps, pal_filter;
177 double tex_scale, tex_shift;
179 double range_min, range_max;
181 bool b_scale, b_help;
182 bool scale_focused, scale_dragging;
183 int pos_horz, pos_vert;
184 int scale_x, scale_y;
185 int scale_width, scale_height, labels_width;
186 int scale_numticks, scale_box_height, scale_box_skip;
188 int scale_fixed_width;
190 bool want_screenshot;
191 static int screenshot_no;
197 void create_gl_palette();
198 virtual void get_palette_color(
double x,
float* gl_color);
201 inline double transform_x(
double x) {
return (x * scale + trans_x) + center_x; }
202 inline double transform_y(
double y) {
return center_y - (y * scale + trans_y); }
203 inline double untransform_x(
double x) {
return (x - center_x - trans_x) / scale; }
204 inline double untransform_y(
double y) {
return (center_y - y - trans_y) / scale; }
206 virtual void clear_background();
208 void display_antialiased();
210 void set_ortho_projection(
bool no_jitter =
false);
211 void set_3d_projection(
int fov,
double znear,
double zfar);
213 void draw_text(
double x,
double y,
const char* text,
int align = -1);
214 int get_text_width(
const char* text);
216 char *get_screenshot_file_name();
217 void save_screenshot_internal(
const char* filename);
219 virtual void scale_dispatch();
220 virtual int measure_scale_labels();
221 void draw_continuous_scale(
char* title,
bool righttext);
222 void draw_discrete_scale(
int numboxes,
const char* boxnames[],
const float boxcolors[][3]);
224 void update_tex_adjust();
226 virtual const char* get_help_text()
const = 0;
228 friend void on_display_stub(
void);
229 friend void on_reshape_stub(
int,
int);
230 friend void on_mouse_move_stub(
int,
int);
231 friend void on_mouse_click_stub(
int,
int,
int,
int);
232 friend void on_key_down_stub(
unsigned char,
int,
int);
233 friend void on_special_key_stub(
int,
int,
int);
234 friend void on_entry_stub(
int);
235 friend void on_idle_stub();
236 friend void on_close_stub();
239 friend void on_create(
int);
242 class HERMES_API View
246 void init() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
247 View() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
248 View(
const char* title, WinGeom* wg = NULL) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
249 View(
char* title, WinGeom* wg = NULL) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
251 int create() {
throw Hermes::Exceptions::Exception(
"GLUT disabled.");
return -1; }
252 void close() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
253 void refresh() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
256 void set_title(
const char* title) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
258 void set_min_max_range(
double min,
double max) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
259 void auto_min_max_range() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
260 void get_min_max_range(
double& min,
double& max) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
262 void show_scale(
bool show =
true) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
263 void set_scale_position(
int horz,
int vert) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
264 void set_scale_size(
int width,
int height,
int numticks) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
265 void set_scale_format(
const char* fmt) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
266 void fix_scale_width(
int width = 80) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
270 void save_screenshot(
const char* bmpname,
bool high_quality =
false) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
273 void save_numbered_screenshot(
const char* format,
int number,
bool high_quality =
false) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
275 void set_palette(
ViewPaletteType type) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
276 void set_num_palette_steps(
int num) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
277 void set_palette_filter(
bool linear) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
279 void wait_for_keypress(
const char* text = NULL) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
280 void wait_for_close() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
281 void wait_for_draw() {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
283 static void wait(
const char* text) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }
284 static void wait(
ViewWaitEvent wait_event =
HERMES_WAIT_CLOSE,
const char* text = NULL) {
throw Hermes::Exceptions::Exception(
"GLUT disabled."); }