00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef GLUI_GLUI_H
00033 #define GLUI_GLUI_H
00034
00035 #if defined(GLUI_FREEGLUT)
00036
00037
00038
00039
00040 #include <GL/freeglut.h>
00041
00042 #elif defined(GLUI_OPENGLUT)
00043
00044
00045
00046
00047 #include <GL/openglut.h>
00048
00049 #else
00050
00051 #ifdef __APPLE__
00052 #include <GLUT/glut.h>
00053 #else
00054 #include <GL/glut.h>
00055 #endif
00056
00057 #endif
00058
00059 #include <cstdlib>
00060 #include <cstdio>
00061 #include <cstring>
00062 #include <string>
00063 #include <vector>
00064
00065 #define GLUI_VERSION 2.3f
00066
00067 #if defined(_WIN32)
00068 #if !defined(GLUI_NO_LIB_PRAGMA)
00069 #pragma comment(lib, "glui32.lib") // Link automatically with GLUI library
00070 #endif
00071 #endif
00072
00073
00074
00075 #ifndef Byte
00076 #define Byte unsigned char
00077 #endif
00078
00079 #ifndef _RGBC_
00080 class RGBc {
00081 public:
00082 Byte r, g, b;
00083
00084 void set(Byte r,Byte g,Byte b) {this->r=r;this->g=g;this->b=b;}
00085
00086 RGBc( void ) {}
00087 RGBc( Byte r, Byte g, Byte b ) { set( r, g, b ); }
00088 };
00089 #define _RGBC_
00090 #endif
00091
00092
00093
00094 enum GLUI_Glut_CB_Types
00095 {
00096 GLUI_GLUT_RESHAPE,
00097 GLUI_GLUT_KEYBOARD,
00098 GLUI_GLUT_DISPLAY,
00099 GLUI_GLUT_MOUSE,
00100 GLUI_GLUT_MOTION,
00101 GLUI_GLUT_SPECIAL,
00102 GLUI_GLUT_PASSIVE_MOTION,
00103 GLUI_GLUT_ENTRY,
00104 GLUI_GLUT_VISIBILITY
00105 };
00106
00107
00108
00109 #define GLUI_XOFF 6
00110 #define GLUI_YOFF 6
00111 #define GLUI_ITEMSPACING 3
00112 #define GLUI_CHECKBOX_SIZE 13
00113 #define GLUI_RADIOBUTTON_SIZE 13
00114 #define GLUI_BUTTON_SIZE 20
00115 #define GLUI_STATICTEXT_SIZE 13
00116 #define GLUI_SEPARATOR_HEIGHT 8
00117 #define GLUI_DEFAULT_CONTROL_WIDTH 100
00118 #define GLUI_DEFAULT_CONTROL_HEIGHT 13
00119 #define GLUI_EDITTEXT_BOXINNERMARGINX 3
00120 #define GLUI_EDITTEXT_HEIGHT 20
00121 #define GLUI_EDITTEXT_WIDTH 130
00122 #define GLUI_EDITTEXT_MIN_INT_WIDTH 35
00123 #define GLUI_EDITTEXT_MIN_TEXT_WIDTH 50
00124 #define GLUI_PANEL_NAME_DROP 8
00125 #define GLUI_PANEL_EMBOSS_TOP 4
00126
00127
00128 #define GLUI_ROTATION_WIDTH 50
00129 #define GLUI_ROTATION_HEIGHT (GLUI_ROTATION_WIDTH+18)
00130 #define GLUI_MOUSE_INTERACTION_WIDTH 50
00131 #define GLUI_MOUSE_INTERACTION_HEIGHT (GLUI_MOUSE_INTERACTION_WIDTH)+18
00132
00134 #define GLUI_PANEL_NONE 0
00135 #define GLUI_PANEL_EMBOSSED 1
00136 #define GLUI_PANEL_RAISED 2
00137
00139 #define GLUI_DEF_MAX_ARRAY 30
00140
00141
00142 #define GLUI_CONTROL_ACTIVE_MOUSEDOWN 1
00143 #define GLUI_CONTROL_ACTIVE_PERMANENT 2
00144
00145
00146 #define GLUI_ALIGN_CENTER 1
00147 #define GLUI_ALIGN_RIGHT 2
00148 #define GLUI_ALIGN_LEFT 3
00149
00150
00151 #define GLUI_LIMIT_NONE 0
00152 #define GLUI_LIMIT_CLAMP 1
00153 #define GLUI_LIMIT_WRAP 2
00154
00155
00156 #define GLUI_TRANSLATION_XY 0
00157 #define GLUI_TRANSLATION_Z 1
00158 #define GLUI_TRANSLATION_X 2
00159 #define GLUI_TRANSLATION_Y 3
00160
00161 #define GLUI_TRANSLATION_LOCK_NONE 0
00162 #define GLUI_TRANSLATION_LOCK_X 1
00163 #define GLUI_TRANSLATION_LOCK_Y 2
00164
00165
00166 #define GLUI_ACTIVATE_MOUSE 1
00167 #define GLUI_ACTIVATE_TAB 2
00168
00169
00170 #define GLUI_LIVE_NONE 0
00171 #define GLUI_LIVE_INT 1
00172 #define GLUI_LIVE_FLOAT 2
00173 #define GLUI_LIVE_TEXT 3
00174 #define GLUI_LIVE_STRING 6
00175 #define GLUI_LIVE_DOUBLE 4
00176 #define GLUI_LIVE_FLOAT_ARRAY 5
00177
00178
00179 #define GLUI_TEXTBOX_HEIGHT 130
00180 #define GLUI_TEXTBOX_WIDTH 130
00181 #define GLUI_LIST_HEIGHT 130
00182 #define GLUI_LIST_WIDTH 130
00183 #define GLUI_DOUBLE_CLICK 1
00184 #define GLUI_SINGLE_CLICK 0
00185 #define GLUI_TAB_WIDTH 50
00186 #define GLUI_TEXTBOX_BOXINNERMARGINX 3
00187 #define GLUI_TEXTBOX_MIN_TEXT_WIDTH 50
00188 #define GLUI_LIST_BOXINNERMARGINX 3
00189 #define GLUI_LIST_MIN_TEXT_WIDTH 50
00190
00191
00192 #define GLUI_TREEPANEL_DEFAULTS 0 // bar, standard bar color
00193 #define GLUI_TREEPANEL_ALTERNATE_COLOR 1 // Alternate between 8 different bar colors
00194 #define GLUI_TREEPANEL_ENABLE_BAR 2 // enable the bar
00195 #define GLUI_TREEPANEL_DISABLE_BAR 4 // disable the bar
00196 #define GLUI_TREEPANEL_DISABLE_DEEPEST_BAR 8 // disable only the deepest bar
00197 #define GLUI_TREEPANEL_CONNECT_CHILDREN_ONLY 16 // disable only the bar of the last child of each root
00198 #define GLUI_TREEPANEL_DISPLAY_HIERARCHY 32 // display some sort of hierachy in the tree node title
00199 #define GLUI_TREEPANEL_HIERARCHY_NUMERICDOT 64 // display hierarchy in 1.3.2 (etc... ) format
00200 #define GLUI_TREEPANEL_HIERARCHY_LEVEL_ONLY 128 // display hierarchy as only the level depth
00201
00202
00203 #define GLUI_SCROLL_ARROW_WIDTH 16
00204 #define GLUI_SCROLL_ARROW_HEIGHT 16
00205 #define GLUI_SCROLL_BOX_MIN_HEIGHT 5
00206 #define GLUI_SCROLL_BOX_STD_HEIGHT 16
00207 #define GLUI_SCROLL_STATE_NONE 0
00208 #define GLUI_SCROLL_STATE_UP 1
00209 #define GLUI_SCROLL_STATE_DOWN 2
00210 #define GLUI_SCROLL_STATE_BOTH 3
00211 #define GLUI_SCROLL_STATE_SCROLL 4
00212 #define GLUI_SCROLL_DEFAULT_GROWTH_EXP 1.05f
00213 #define GLUI_SCROLL_VERTICAL 0
00214 #define GLUI_SCROLL_HORIZONTAL 1
00215
00216
00221 #define CHAR_WIDTH_HASH_SIZE 128
00222
00223
00224
00225 enum TranslationCodes
00226 {
00227 GLUI_TRANSLATION_MOUSE_NONE = 0,
00228 GLUI_TRANSLATION_MOUSE_UP,
00229 GLUI_TRANSLATION_MOUSE_DOWN,
00230 GLUI_TRANSLATION_MOUSE_LEFT,
00231 GLUI_TRANSLATION_MOUSE_RIGHT,
00232 GLUI_TRANSLATION_MOUSE_UP_LEFT,
00233 GLUI_TRANSLATION_MOUSE_UP_RIGHT,
00234 GLUI_TRANSLATION_MOUSE_DOWN_LEFT,
00235 GLUI_TRANSLATION_MOUSE_DOWN_RIGHT
00236 };
00237
00238
00239
00240 typedef std::string GLUI_String;
00241 GLUI_String& glui_format_str(GLUI_String &str, const char* fmt, ...);
00242
00243
00244
00245 class GLUI;
00246 class GLUI_Control;
00247 class GLUI_Listbox;
00248 class GLUI_StaticText;
00249 class GLUI_EditText;
00250 class GLUI_Panel;
00251 class GLUI_Spinner;
00252 class GLUI_RadioButton;
00253 class GLUI_RadioGroup;
00254 class GLUI_Glut_Window;
00255 class GLUI_TreePanel;
00256 class GLUI_Scrollbar;
00257 class GLUI_List;
00258
00259 class Arcball;
00260
00261
00262 #define GLUI_SUBWINDOW ((long)(1<<1))
00263 #define GLUI_SUBWINDOW_TOP ((long)(1<<2))
00264 #define GLUI_SUBWINDOW_BOTTOM ((long)(1<<3))
00265 #define GLUI_SUBWINDOW_LEFT ((long)(1<<4))
00266 #define GLUI_SUBWINDOW_RIGHT ((long)(1<<5))
00267
00268
00269 #define GLUI_EDITTEXT_TEXT 1
00270 #define GLUI_EDITTEXT_INT 2
00271 #define GLUI_EDITTEXT_FLOAT 3
00272 #define GLUI_SPINNER_INT GLUI_EDITTEXT_INT
00273 #define GLUI_SPINNER_FLOAT GLUI_EDITTEXT_FLOAT
00274 #define GLUI_SCROLL_INT GLUI_EDITTEXT_INT
00275 #define GLUI_SCROLL_FLOAT GLUI_EDITTEXT_FLOAT
00276
00277 #define GLUI_EDITTEXT_STRING 4
00278
00279
00280 typedef void (*GLUI_Update_CB) (int obj_id);
00281 typedef void (*GLUI_Control_CB)(GLUI_Control *);
00282 typedef void (*Int1_CB) (int);
00283 typedef void (*Int2_CB) (int, int);
00284 typedef void (*Int3_CB) (int, int, int);
00285 typedef void (*Int4_CB) (int, int, int, int);
00286
00287
00294 class GLUI_CB
00295 {
00296 public:
00297 GLUI_CB() : idCB(0),objCB(0) {}
00298 GLUI_CB(GLUI_Update_CB cb) : idCB(cb),objCB(0) {}
00299 GLUI_CB(GLUI_Control_CB cb) : idCB(0),objCB(cb) {}
00300
00301
00303 void operator()(GLUI_Control *ctrl) const;
00304 bool operator!() const { return !idCB && !objCB; }
00305 operator bool() const { return !(!(*this)); }
00306 private:
00307 GLUI_Update_CB idCB;
00308 GLUI_Control_CB objCB;
00309 };
00310
00311
00312
00313
00314
00315
00316
00317 class GLUI_Control;
00318
00327 class GLUI_Node
00328 {
00329 friend class GLUI_Tree;
00330 friend class GLUI_Rollout;
00331 friend class GLUI_Main;
00332
00333 public:
00334 GLUI_Node();
00335 virtual ~GLUI_Node() {}
00336
00337 GLUI_Node *first_sibling();
00338 GLUI_Node *last_sibling();
00339 GLUI_Node *prev();
00340 GLUI_Node *next();
00341
00342 GLUI_Node *first_child() { return child_head; }
00343 GLUI_Node *last_child() { return child_tail; }
00344 GLUI_Node *parent() { return parent_node; }
00345
00347 virtual int add_control( GLUI_Control *control );
00348
00349 void link_this_to_parent_last (GLUI_Node *parent );
00350 void link_this_to_parent_first(GLUI_Node *parent );
00351 void link_this_to_sibling_next(GLUI_Node *sibling );
00352 void link_this_to_sibling_prev(GLUI_Node *sibling );
00353 void unlink();
00354
00355 void dump( FILE *out, const char *name );
00356
00357 protected:
00358 static void add_child_to_control(GLUI_Node *parent,GLUI_Control *child);
00359 GLUI_Node *parent_node;
00360 GLUI_Node *child_head;
00361 GLUI_Node *child_tail;
00362 GLUI_Node *next_sibling;
00363 GLUI_Node *prev_sibling;
00364 };
00365
00366
00367
00368
00369
00370
00371
00372
00373 enum GLUI_StdBitmaps_Codes
00374 {
00375 GLUI_STDBITMAP_CHECKBOX_OFF = 0,
00376 GLUI_STDBITMAP_CHECKBOX_ON,
00377 GLUI_STDBITMAP_RADIOBUTTON_OFF,
00378 GLUI_STDBITMAP_RADIOBUTTON_ON,
00379 GLUI_STDBITMAP_UP_ARROW,
00380 GLUI_STDBITMAP_DOWN_ARROW,
00381 GLUI_STDBITMAP_LEFT_ARROW,
00382 GLUI_STDBITMAP_RIGHT_ARROW,
00383 GLUI_STDBITMAP_SPINNER_UP_OFF,
00384 GLUI_STDBITMAP_SPINNER_UP_ON,
00385 GLUI_STDBITMAP_SPINNER_DOWN_OFF,
00386 GLUI_STDBITMAP_SPINNER_DOWN_ON,
00387 GLUI_STDBITMAP_CHECKBOX_OFF_DIS,
00388 GLUI_STDBITMAP_CHECKBOX_ON_DIS,
00389 GLUI_STDBITMAP_RADIOBUTTON_OFF_DIS,
00390 GLUI_STDBITMAP_RADIOBUTTON_ON_DIS,
00391 GLUI_STDBITMAP_SPINNER_UP_DIS,
00392 GLUI_STDBITMAP_SPINNER_DOWN_DIS,
00393 GLUI_STDBITMAP_LISTBOX_UP,
00394 GLUI_STDBITMAP_LISTBOX_DOWN,
00395 GLUI_STDBITMAP_LISTBOX_UP_DIS,
00396 GLUI_STDBITMAP_NUM_ITEMS
00397 };
00398
00399
00400
00401
00402
00403
00404
00410 class GLUI_Bitmap
00411 {
00412 friend class GLUI_StdBitmaps;
00413
00414 public:
00415 GLUI_Bitmap();
00416 ~GLUI_Bitmap();
00417
00419 void init_grey(unsigned char *array);
00420
00422 void init(int *array);
00423
00424 private:
00426 unsigned char *pixels;
00427 int w, h;
00428 };
00429
00430
00431
00432
00433
00434
00435
00436
00441 class GLUI_StdBitmaps
00442 {
00443 public:
00444 GLUI_StdBitmaps();
00445 ~GLUI_StdBitmaps();
00446
00448 int width (int n) const;
00450 int height(int n) const;
00451
00455 void draw(int n, int x, int y) const;
00456
00457 private:
00458 GLUI_Bitmap bitmaps[GLUI_STDBITMAP_NUM_ITEMS];
00459 };
00460
00461
00462
00463
00464
00465
00466
00471 class GLUI_Master_Object
00472 {
00473
00474 friend void glui_idle_func();
00475
00476 public:
00477
00478 GLUI_Master_Object();
00479 ~GLUI_Master_Object();
00480
00481 GLUI_Node gluis;
00482 GLUI_Control *active_control, *curr_left_button_glut_menu;
00483 GLUI *active_control_glui;
00484 int glui_id_counter;
00485
00486 GLUI_Glut_Window *find_glut_window( int window_id );
00487
00488 void set_glutIdleFunc(void (*f)(void));
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503 void set_left_button_glut_menu_control( GLUI_Control *control );
00504
00505
00506
00507
00508 void set_glutReshapeFunc (void (*f)(int width, int height));
00509 void set_glutKeyboardFunc(void (*f)(unsigned char key, int x, int y));
00510 void set_glutSpecialFunc (void (*f)(int key, int x, int y));
00511 void set_glutMouseFunc (void (*f)(int, int, int, int ));
00512
00513 void set_glutDisplayFunc(void (*f)(void)) {glutDisplayFunc(f);}
00514 void set_glutTimerFunc(unsigned int millis, void (*f)(int value), int value)
00515 { ::glutTimerFunc(millis,f,value);}
00516 void set_glutOverlayDisplayFunc(void(*f)(void)){glutOverlayDisplayFunc(f);}
00517 void set_glutSpaceballMotionFunc(Int3_CB f) {glutSpaceballMotionFunc(f);}
00518 void set_glutSpaceballRotateFunc(Int3_CB f) {glutSpaceballRotateFunc(f);}
00519 void set_glutSpaceballButtonFunc(Int2_CB f) {glutSpaceballButtonFunc(f);}
00520 void set_glutTabletMotionFunc(Int2_CB f) {glutTabletMotionFunc(f);}
00521 void set_glutTabletButtonFunc(Int4_CB f) {glutTabletButtonFunc(f);}
00522
00523 void set_glutMenuStatusFunc(Int3_CB f) {glutMenuStatusFunc(f);}
00524 void set_glutMenuStateFunc(Int1_CB f) {glutMenuStateFunc(f);}
00525 void set_glutButtonBoxFunc(Int2_CB f) {glutButtonBoxFunc(f);}
00526 void set_glutDialsFunc(Int2_CB f) {glutDialsFunc(f);}
00527
00528
00529 GLUI *create_glui( const char *name, long flags=0, int x=-1, int y=-1 );
00530 GLUI *create_glui_subwindow( int parent_window, long flags=0 );
00531 GLUI *find_glui_by_window_id( int window_id );
00532 void get_viewport_area( int *x, int *y, int *w, int *h );
00533 void auto_set_viewport();
00534 void close_all();
00535 void sync_live_all();
00536
00537 void reshape();
00538
00539 float get_version() { return GLUI_VERSION; }
00540
00541 void glui_setIdleFuncIfNecessary(void);
00542
00543 private:
00544 GLUI_Node glut_windows;
00545 void (*glut_idle_CB)(void);
00546
00547 void add_cb_to_glut_window(int window,int cb_type,void *cb);
00548 };
00549
00553 extern GLUI_Master_Object GLUI_Master;
00554
00555
00556
00557
00558
00559
00560
00569 class GLUI_Glut_Window : public GLUI_Node
00570 {
00571 public:
00572 GLUI_Glut_Window();
00573
00574 int glut_window_id;
00575
00576
00577 void (*glut_keyboard_CB)(unsigned char, int, int);
00578 void (*glut_special_CB)(int, int, int);
00579 void (*glut_reshape_CB)(int, int);
00580 void (*glut_passive_motion_CB)(int,int);
00581 void (*glut_mouse_CB)(int,int,int,int);
00582 void (*glut_visibility_CB)(int);
00583 void (*glut_motion_CB)(int,int);
00584 void (*glut_display_CB)(void);
00585 void (*glut_entry_CB)(int);
00586 };
00587
00588
00589
00590
00591
00592
00593
00607 class GLUI_Main : public GLUI_Node
00608 {
00609
00610
00611 friend class GLUI_Control;
00612 friend class GLUI_Rotation;
00613 friend class GLUI_Translation;
00614 friend class GLUI;
00615 friend class GLUI_Master_Object;
00616
00617
00618
00619 friend void glui_mouse_func(int button, int state, int x, int y);
00620 friend void glui_keyboard_func(unsigned char key, int x, int y);
00621 friend void glui_special_func(int key, int x, int y);
00622 friend void glui_passive_motion_func(int x, int y);
00623 friend void glui_reshape_func( int w, int h );
00624 friend void glui_visibility_func(int state);
00625 friend void glui_motion_func(int x, int y);
00626 friend void glui_entry_func(int state);
00627 friend void glui_display_func( void );
00628 friend void glui_idle_func(void);
00629
00630 friend void glui_parent_window_reshape_func( int w, int h );
00631 friend void glui_parent_window_keyboard_func( unsigned char, int, int );
00632 friend void glui_parent_window_special_func( int, int, int );
00633 friend void glui_parent_window_mouse_func( int, int, int, int );
00634
00635 protected:
00636
00637 int main_gfx_window_id;
00638 int mouse_button_down;
00639 int glut_window_id;
00640 int top_level_glut_window_id;
00641 GLUI_Control *active_control;
00642 GLUI_Control *mouse_over_control;
00643 GLUI_Panel *main_panel;
00644 enum buffer_mode_t {
00645 buffer_front=1,
00646 buffer_back=2
00647 };
00648 buffer_mode_t buffer_mode;
00649 int curr_cursor;
00650 int w, h;
00651 long flags;
00652 bool closing;
00653 int parent_window;
00654 int glui_id;
00655
00656
00657
00658 GLUI_Control *find_control( int x, int y );
00659 GLUI_Control *find_next_control( GLUI_Control *control );
00660 GLUI_Control *find_next_control_rec( GLUI_Control *control );
00661 GLUI_Control *find_next_control_( GLUI_Control *control );
00662 GLUI_Control *find_prev_control( GLUI_Control *control );
00663 void create_standalone_window( const char *name, int x=-1, int y=-1 );
00664 void create_subwindow( int parent,int window_alignment );
00665 void setup_default_glut_callbacks( void );
00666
00667 void mouse(int button, int state, int x, int y);
00668 void keyboard(unsigned char key, int x, int y);
00669 void special(int key, int x, int y);
00670 void passive_motion(int x, int y);
00671 void reshape( int w, int h );
00672 void visibility(int state);
00673 void motion(int x, int y);
00674 void entry(int state);
00675 void display( void );
00676 void idle(void);
00677 int needs_idle(void);
00678
00679 void (*glut_mouse_CB)(int, int, int, int);
00680 void (*glut_keyboard_CB)(unsigned char, int, int);
00681 void (*glut_special_CB)(int, int, int);
00682 void (*glut_reshape_CB)(int, int);
00683
00684
00685
00686
00687 virtual int add_control( GLUI_Node *parent, GLUI_Control *control );
00688
00689
00690
00691
00692 GLUI_Main( void );
00693
00694 public:
00695 GLUI_StdBitmaps std_bitmaps;
00696 GLUI_String window_name;
00697 RGBc bkgd_color;
00698 float bkgd_color_f[3];
00699
00700 void *font;
00701 int curr_modifiers;
00702
00703 void adjust_glut_xy( int &x, int &y ) { y = h-y; }
00704 void activate_control( GLUI_Control *control, int how );
00705 void align_controls( GLUI_Control *control );
00706 void deactivate_current_control( void );
00707
00709 void draw_raised_box( int x, int y, int w, int h );
00711 void draw_lowered_box( int x, int y, int w, int h );
00712
00716 bool should_redraw_now(GLUI_Control *ctl);
00717
00722 int set_current_draw_buffer();
00724 void restore_draw_buffer( int buffer_state );
00725
00727 void refresh();
00728
00730 void post_update_main_gfx();
00731
00733 void pack_controls();
00734
00735 void close_internal();
00736 void check_subwindow_position();
00737 void set_ortho_projection();
00738 void set_viewport();
00739 int get_glut_window_id( void ) { return glut_window_id; }
00740 };
00741
00742
00743
00744
00745
00746
00747
00759 class GLUI_Control : public GLUI_Node
00760 {
00761 public:
00762
00764 int w, h;
00765 int x_abs, y_abs;
00766 int x_off, y_off_top, y_off_bot;
00767
00768 int contain_x, contain_y;
00769 int contain_w, contain_h;
00770
00771
00772
00773
00775 int active_type;
00776 bool active;
00777 bool can_activate;
00778 bool spacebar_mouse_click;
00779
00781 long user_id;
00782 GLUI_CB callback;
00783
00785 float float_val;
00786 int int_val;
00787 float float_array_val[GLUI_DEF_MAX_ARRAY];
00788 int float_array_size;
00789 GLUI_String text;
00792 void *ptr_val;
00793 int live_type;
00794 bool live_inited;
00795
00796 int last_live_int;
00797 float last_live_float;
00798 GLUI_String last_live_text;
00799 float last_live_float_array[GLUI_DEF_MAX_ARRAY];
00800
00802 GLUI *glui;
00803 bool is_container;
00804 int alignment;
00805 bool enabled;
00806 GLUI_String name;
00807 void *font;
00808 bool collapsible, is_open;
00809 GLUI_Node collapsed_node;
00810 bool hidden;
00811 int char_widths[CHAR_WIDTH_HASH_SIZE][2];
00812
00813 public:
00814
00815 virtual void set_name( const char *string );
00816 virtual void set_int_val( int new_int ) { int_val = new_int; output_live(true); }
00817 virtual void set_float_val( float new_float ) { float_val = new_float; output_live(true); }
00818 virtual void set_ptr_val( void *new_ptr ) { ptr_val = new_ptr; output_live(true); }
00819 virtual void set_float_array_val( float *array_ptr );
00820
00821 virtual float get_float_val( void ) { return float_val; }
00822 virtual int get_int_val( void ) { return int_val; }
00823 virtual void get_float_array_val( float *array_ptr );
00824 virtual int get_id( void ) const { return user_id; }
00825 virtual void set_id( int obj_id ) { user_id=obj_id; }
00826
00827 virtual int mouse_down_handler( int local_x, int local_y ) { return false; }
00828 virtual int mouse_up_handler( int local_x, int local_y, bool inside ) { return false; }
00829 virtual int mouse_held_down_handler( int local_x, int local_y, bool inside) { return false; }
00830 virtual int key_handler( unsigned char key, int modifiers ) { return false; }
00831 virtual int special_handler( int key,int modifiers ) { return false; }
00832
00833 virtual void update_size( void ) { }
00834 virtual void idle( void ) { }
00835 virtual int mouse_over( int state, int x, int y ) { return false; }
00836
00837 virtual void enable( void );
00838 virtual void disable( void );
00839 virtual void activate( int how ) { active = true; }
00840 virtual void deactivate( void ) { active = false; }
00841
00843 void hide_internal( int recurse );
00844 void unhide_internal( int recurse );
00845
00847 int can_draw( void ) { return (glui != NULL && hidden == false); }
00848
00855 void redraw(void);
00856
00858 void redraw_window(void);
00859
00860 virtual void align( void );
00861 void pack( int x, int y );
00862 void pack_old( int x, int y );
00863 void draw_recursive( int x, int y );
00864 int set_to_glut_window( void );
00865 void restore_window( int orig );
00866 void translate_and_draw_front( void );
00867 void translate_to_origin( void )
00868 {glTranslatef((float)x_abs+.5,(float)y_abs+.5,0.0);}
00869 virtual void draw( int x, int y )=0;
00870 void set_font( void *new_font );
00871 void *get_font( void );
00872 int string_width( const char *text );
00873 int string_width( const GLUI_String &str )
00874 { return string_width(str.c_str()); }
00875 int char_width( char c );
00876
00877 void draw_name( int x, int y );
00878 void draw_box_inwards_outline( int x_min, int x_max,
00879 int y_min, int y_max );
00880 void draw_box( int x_min, int x_max, int y_min, int y_max,
00881 float r, float g, float b );
00882 void draw_bkgd_box( int x_min, int x_max, int y_min, int y_max );
00883 void draw_emboss_box( int x_min, int x_max,int y_min,int y_max);
00884 void draw_string( const char *text );
00885 void draw_string( const GLUI_String &s )
00886 { draw_string(s.c_str()); }
00887 void draw_char( char c );
00888 void draw_active_box( int x_min, int x_max, int y_min, int y_max );
00889 void set_to_bkgd_color( void );
00890
00891 void set_w( int new_w );
00892 void set_h( int new_w );
00893 void set_alignment( int new_align );
00894 void sync_live( int recurse, int draw );
00895 void init_live( void );
00896 void output_live( int update_main_gfx );
00897 virtual void set_text( const char *t ) {}
00898 void execute_callback( void );
00899 void get_this_column_dims( int *col_x, int *col_y,
00900 int *col_w, int *col_h,
00901 int *col_x_off, int *col_y_off );
00902 virtual bool needs_idle( void ) const;
00903 virtual bool wants_tabs() const { return false; }
00904
00905 GLUI_Control(void)
00906 {
00907 x_off = GLUI_XOFF;
00908 y_off_top = GLUI_YOFF;
00909 y_off_bot = GLUI_YOFF;
00910 x_abs = GLUI_XOFF;
00911 y_abs = GLUI_YOFF;
00912 active = false;
00913 enabled = true;
00914 int_val = 0;
00915 last_live_int = 0;
00916 float_array_size = 0;
00917 glui_format_str(name, "Control: %p", this);
00918 float_val = 0.0;
00919 last_live_float = 0.0;
00920 ptr_val = NULL;
00921 glui = NULL;
00922 w = GLUI_DEFAULT_CONTROL_WIDTH;
00923 h = GLUI_DEFAULT_CONTROL_HEIGHT;
00924 font = NULL;
00925 active_type = GLUI_CONTROL_ACTIVE_MOUSEDOWN;
00926 alignment = GLUI_ALIGN_LEFT;
00927 is_container = false;
00928 can_activate = true;
00929 spacebar_mouse_click = true;
00930 live_type = GLUI_LIVE_NONE;
00931 text = "";
00932 last_live_text == "";
00933 live_inited = false;
00934 collapsible = false;
00935 is_open = true;
00936 hidden = false;
00937 memset(char_widths, -1, sizeof(char_widths));
00938 int i;
00939 for( i=0; i<GLUI_DEF_MAX_ARRAY; i++ )
00940 float_array_val[i] = last_live_float_array[i] = 0.0;
00941 }
00942
00943 virtual ~GLUI_Control();
00944 };
00945
00946
00947
00948
00949
00950
00956 class GLUI_Button : public GLUI_Control
00957 {
00958 public:
00959 bool currently_inside;
00960
00961 int mouse_down_handler( int local_x, int local_y );
00962 int mouse_up_handler( int local_x, int local_y, bool inside );
00963 int mouse_held_down_handler( int local_x, int local_y, bool inside );
00964 int key_handler( unsigned char key,int modifiers );
00965
00966 void draw( int x, int y );
00967 void draw_pressed( void );
00968 void draw_text( int sunken );
00969
00970 void update_size( void );
00971
00980 GLUI_Button( GLUI_Node *parent, const char *name,
00981 int obj_id=-1, GLUI_CB cb=GLUI_CB() );
00982 GLUI_Button( void ) { common_init(); };
00983
00984 protected:
00985 void common_init(void) {
00986 glui_format_str(name, "Button: %p", this );
00987 h = GLUI_BUTTON_SIZE;
00988 w = 100;
00989 alignment = GLUI_ALIGN_CENTER;
00990 can_activate = true;
00991 }
00992 };
00993
00994
00995
00996
00997
00998
00999
01000
01005 class GLUI_Checkbox : public GLUI_Control
01006 {
01007 public:
01008 int orig_value;
01009 bool currently_inside;
01010 int text_x_offset;
01011
01012 int mouse_down_handler( int local_x, int local_y );
01013 int mouse_up_handler( int local_x, int local_y, bool inside );
01014 int mouse_held_down_handler( int local_x, int local_y, bool inside );
01015 int key_handler( unsigned char key,int modifiers );
01016
01017 void update_size( void );
01018
01019 void draw( int x, int y );
01020
01021 void draw_active_area( void );
01022 void draw_empty_box( void );
01023 void set_int_val( int new_val );
01024
01035 GLUI_Checkbox(GLUI_Node *parent, const char *name, int *value_ptr=NULL,
01036 int obj_id=-1, GLUI_CB callback=GLUI_CB());
01037 GLUI_Checkbox( void ) { common_init(); }
01038
01039 protected:
01040 void common_init(void) {
01041 glui_format_str( name, "Checkbox: %p", this );
01042 w = 100;
01043 h = GLUI_CHECKBOX_SIZE;
01044 orig_value = -1;
01045 text_x_offset = 18;
01046 can_activate = true;
01047 live_type = GLUI_LIVE_INT;
01048 }
01049 };
01050
01051
01052
01053
01054
01055
01056
01061 class GLUI_Column : public GLUI_Control
01062 {
01063 public:
01064 void draw( int x, int y );
01065
01073 GLUI_Column( GLUI_Node *parent, int draw_bar = true );
01074 GLUI_Column( void ) { common_init(); }
01075
01076 protected:
01077 void common_init() {
01078 w = 0;
01079 h = 0;
01080 int_val = 0;
01081 can_activate = false;
01082 }
01083 };
01084
01085
01086
01087
01088
01089
01090
01091
01095 class GLUI_Panel : public GLUI_Control
01096 {
01097 public:
01098
01108 GLUI_Panel( GLUI_Node *parent, const char *name,
01109 int type=GLUI_PANEL_EMBOSSED );
01110 GLUI_Panel() { common_init(); }
01111
01112 void draw( int x, int y );
01113 void set_name( const char *text );
01114 void set_type( int new_type );
01115
01116 void update_size( void );
01117
01118 protected:
01119 void common_init( void ) {
01120 w = 300;
01121 h = GLUI_DEFAULT_CONTROL_HEIGHT + 7;
01122 int_val = GLUI_PANEL_EMBOSSED;
01123 alignment = GLUI_ALIGN_CENTER;
01124 is_container = true;
01125 can_activate = false;
01126 name="";
01127 };
01128 };
01129
01130
01131
01132
01133
01134
01135
01139 class GLUI_FileBrowser : public GLUI_Panel
01140 {
01141 public:
01153 GLUI_FileBrowser( GLUI_Node *parent,
01154 const char *name,
01155 int frame_type = GLUI_PANEL_EMBOSSED,
01156 int user_id = -1,
01157 GLUI_CB callback = GLUI_CB());
01158
01159 GLUI_List *list;
01160 GLUI_String current_dir;
01161
01162 void fbreaddir(const char *);
01163 static void dir_list_callback(GLUI_Control*);
01164
01165 void set_w(int w);
01166 void set_h(int h);
01167 const char* get_file() { return file.c_str(); }
01168 void set_allow_change_dir(int c) { allow_change_dir = c; }
01169
01170 protected:
01171 void common_init()
01172 {
01173 w = GLUI_DEFAULT_CONTROL_WIDTH;
01174 h = GLUI_DEFAULT_CONTROL_HEIGHT;
01175 int_val = GLUI_PANEL_EMBOSSED;
01176 alignment = GLUI_ALIGN_CENTER;
01177 is_container = true;
01178 can_activate = false;
01179 allow_change_dir = true;
01180 last_item = -1;
01181 user_id = -1;
01182 name = "";
01183 current_dir = ".";
01184 file = "";
01185 };
01186
01187 private:
01188 int last_item;
01189 GLUI_String file;
01190 int allow_change_dir;
01191
01192 };
01193
01194
01195
01196
01197
01198
01203 class GLUI_Rollout : public GLUI_Panel
01204 {
01205 public:
01206
01219 GLUI_Rollout( GLUI_Node *parent, const char *name, int open=true,
01220 int type=GLUI_PANEL_EMBOSSED );
01221 GLUI_Rollout( void ) { common_init(); }
01222
01223
01224 bool currently_inside, initially_inside;
01225 GLUI_Button button;
01226
01227 void draw( int x, int y );
01228 void draw_pressed( void );
01229 int mouse_down_handler( int local_x, int local_y );
01230 int mouse_up_handler( int local_x, int local_y, bool inside );
01231 int mouse_held_down_handler( int local_x, int local_y, bool inside );
01232
01233 void open( void );
01234 void close( void );
01235
01236 void update_size( void );
01237
01238 protected:
01239 void common_init() {
01240 currently_inside = false;
01241 initially_inside = false;
01242 can_activate = true;
01243 is_container = true;
01244 h = GLUI_DEFAULT_CONTROL_HEIGHT + 7;
01245 w = GLUI_DEFAULT_CONTROL_WIDTH;
01246 y_off_top = 21;
01247 collapsible = true;
01248 name = "";
01249 }
01250 };
01251
01252
01253
01254
01255
01256
01257
01261 class GLUI_Tree : public GLUI_Panel
01262 {
01263 public:
01264 GLUI_Tree(GLUI_Node *parent, const char *name,
01265 int open=false, int inset=0);
01266
01267 private:
01268 int level;
01269 float red;
01270 float green;
01271 float blue;
01272 float lred;
01273 float lgreen;
01274 float lblue;
01275 int obj_id;
01276 GLUI_Column *column;
01277 int is_current;
01278
01279 int child_number;
01280 int format;
01281
01282 public:
01283 bool currently_inside, initially_inside;
01284 GLUI_Button button;
01285 GLUI_String level_name;
01286 GLUI_TreePanel *panel;
01287
01288 void draw( int x, int y );
01289 void draw_pressed( void );
01290 int mouse_down_handler( int local_x, int local_y );
01291 int mouse_up_handler( int local_x, int local_y, bool inside );
01292 int mouse_held_down_handler( int local_x, int local_y, bool inside );
01293 void set_column(GLUI_Column *c) { column = c; }
01294 void open( void );
01295 void close( void );
01296
01297
01298 void update_size( void );
01299 void set_level(int l) { level = l; }
01300 void set_id(int i) { obj_id = i; }
01301 void set_format(int f) { format = f; }
01302 void set_current(int c) { is_current = c; }
01303 int get_id() { return obj_id; }
01304 int get_level() { return level; }
01305 int get_child_number() { return child_number; }
01306 void enable_bar() { if (column) { column->int_val = 1; set_color(red, green, blue); } }
01307 void disable_bar() { if (column) { column->int_val = 0; } }
01308 void set_child_number(int c) { child_number = c; }
01309 void set_level_color(float r, float g, float b) {
01310 lred = r;
01311 lgreen = g;
01312 lblue = b;
01313 }
01314 void set_color(float r, float g, float b) {
01315 red = r;
01316 green = g;
01317 blue = b;
01318 }
01319 protected:
01320 void common_init()
01321 {
01322 currently_inside = false;
01323 initially_inside = false;
01324 can_activate = true;
01325 is_container = true;
01326 h = GLUI_DEFAULT_CONTROL_HEIGHT + 7;
01327 w = GLUI_DEFAULT_CONTROL_WIDTH;
01328 y_off_top = 21;
01329 collapsible = true;
01330 red = .5;
01331 green = .5;
01332 blue = .5;
01333 lred = 0;
01334 lgreen = 0;
01335 lblue = 0;
01336 column = NULL;
01337 is_current = 0;
01338 child_number = 0;
01339 format = 0;
01340 panel = NULL;
01341 name = "";
01342 level_name = "";
01343 level = 0;
01344
01345 };
01346 };
01347
01348
01349
01350
01351
01352
01353
01354
01361 class GLUI_TreePanel : public GLUI_Panel
01362 {
01363 public:
01364 GLUI_TreePanel(GLUI_Node *parent, const char *name,
01365 bool open=false, int inset=0);
01366
01367 int max_levels;
01368 int next_id;
01369 int format;
01370 float red;
01371 float green;
01372 float blue;
01373 float lred;
01374 float lgreen;
01375 float lblue;
01376 int root_children;
01377
01378
01379
01380
01381 GLUI_Tree *curr_branch;
01382 GLUI_Panel *curr_root;
01383
01384 public:
01385 void set_color(float r, float g, float b);
01386 void set_level_color(float r, float g, float b);
01387 void set_format(int f) { format = f; }
01388
01389
01390 GLUI_Tree * ab(const char *name, GLUI_Tree *root = NULL);
01391
01392 void fb(GLUI_Tree *branch= NULL);
01393
01394 void db(GLUI_Tree *branch = NULL);
01395
01396 void descendBranch(GLUI_Panel *root = NULL);
01397
01398 void resetToRoot(GLUI_Panel *new_root = NULL);
01399 void next( void );
01400 void refresh( void );
01401 void expand_all( void );
01402 void collapse_all( void );
01403 void update_all( void );
01404 void initNode(GLUI_Tree *temp);
01405 void formatNode(GLUI_Tree *temp);
01406
01407 protected:
01408 int uniqueID( void ) { next_id++; return next_id - 1; }
01409 void common_init()
01410 {
01411 GLUI_Panel();
01412 next_id = 0;
01413 curr_root = this;
01414 curr_branch = NULL;
01415 red = .5;
01416 green = .5;
01417 blue = .5;
01418 root_children = 0;
01419 }
01420 };
01421
01422
01423
01424
01425
01426
01427
01428 class GLUI_Rotation;
01429 class GLUI_Translation;
01430
01435 class GLUI : public GLUI_Main
01436 {
01437 public:
01439 int add_control( GLUI_Control *control ) { return main_panel->add_control(control); }
01440
01441 void add_column( int draw_bar = true );
01442 void add_column_to_panel( GLUI_Panel *panel, int draw_bar = true );
01443
01444 void add_separator( void );
01445 void add_separator_to_panel( GLUI_Panel *panel );
01446
01447 GLUI_RadioGroup
01448 *add_radiogroup( int *live_var=NULL,
01449 int user_id=-1,GLUI_CB callback=GLUI_CB());
01450
01451 GLUI_RadioGroup
01452 *add_radiogroup_to_panel( GLUI_Panel *panel,
01453 int *live_var=NULL,
01454 int user_id=-1, GLUI_CB callback=GLUI_CB() );
01455 GLUI_RadioButton
01456 *add_radiobutton_to_group( GLUI_RadioGroup *group,
01457 const char *name );
01458
01459 GLUI_Listbox *add_listbox( const char *name, int *live_var=NULL,
01460 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01461 GLUI_Listbox *add_listbox_to_panel( GLUI_Panel *panel,
01462 const char *name, int *live_var=NULL,
01463 int obj_id=-1, GLUI_CB callback=GLUI_CB());
01464
01465 GLUI_Rotation *add_rotation( const char *name, float *live_var=NULL,
01466 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01467 GLUI_Rotation *add_rotation_to_panel( GLUI_Panel *panel,
01468 const char *name, float *live_var=NULL,
01469 int obj_id=-1, GLUI_CB callback=GLUI_CB());
01470
01471 GLUI_Translation *add_translation( const char *name,
01472 int trans_type, float *live_var=NULL,
01473 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01474 GLUI_Translation *add_translation_to_panel(
01475 GLUI_Panel *panel, const char *name,
01476 int trans_type, float *live_var=NULL,
01477 int obj_id=-1, GLUI_CB callback=GLUI_CB());
01478
01479 GLUI_Checkbox *add_checkbox( const char *name,
01480 int *live_var=NULL,
01481 int obj_id=-1, GLUI_CB callback=GLUI_CB());
01482 GLUI_Checkbox *add_checkbox_to_panel( GLUI_Panel *panel, const char *name,
01483 int *live_var=NULL, int obj_id=-1,
01484 GLUI_CB callback=GLUI_CB());
01485
01486 GLUI_Button *add_button( const char *name, int obj_id=-1,
01487 GLUI_CB callback=GLUI_CB());
01488 GLUI_Button *add_button_to_panel( GLUI_Panel *panel, const char *name,
01489 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01490
01491 GLUI_StaticText *add_statictext( const char *name );
01492 GLUI_StaticText *add_statictext_to_panel( GLUI_Panel *panel, const char *name );
01493
01494 GLUI_EditText *add_edittext( const char *name,
01495 int data_type=GLUI_EDITTEXT_TEXT,
01496 void*live_var=NULL,
01497 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01498 GLUI_EditText *add_edittext_to_panel( GLUI_Panel *panel,
01499 const char *name,
01500 int data_type=GLUI_EDITTEXT_TEXT,
01501 void *live_var=NULL, int obj_id=-1,
01502 GLUI_CB callback=GLUI_CB() );
01503 GLUI_EditText *add_edittext( const char *name, GLUI_String& live_var,
01504 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01505 GLUI_EditText *add_edittext_to_panel( GLUI_Panel *panel, const char *name,
01506 GLUI_String& live_var, int obj_id=-1,
01507 GLUI_CB callback=GLUI_CB() );
01508
01509 GLUI_Spinner *add_spinner( const char *name,
01510 int data_type=GLUI_SPINNER_INT,
01511 void *live_var=NULL,
01512 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01513 GLUI_Spinner *add_spinner_to_panel( GLUI_Panel *panel,
01514 const char *name,
01515 int data_type=GLUI_SPINNER_INT,
01516 void *live_var=NULL,
01517 int obj_id=-1,
01518 GLUI_CB callback=GLUI_CB() );
01519
01520 GLUI_Panel *add_panel( const char *name, int type=GLUI_PANEL_EMBOSSED );
01521 GLUI_Panel *add_panel_to_panel( GLUI_Panel *panel, const char *name,
01522 int type=GLUI_PANEL_EMBOSSED );
01523
01524
01525 GLUI_Rollout *add_rollout( const char *name, int open=true,
01526 int type=GLUI_PANEL_EMBOSSED);
01527 GLUI_Rollout *add_rollout_to_panel( GLUI_Panel *panel, const char *name,
01528 int open=true,
01529 int type=GLUI_PANEL_EMBOSSED);
01530
01531
01533 void set_main_gfx_window( int window_id );
01534 int get_glut_window_id( void ) { return glut_window_id; }
01535
01536 void enable( void ) { main_panel->enable(); }
01537 void disable( void );
01538
01539 void sync_live( void );
01540
01541 void close( void );
01542
01543 void show( void );
01544 void hide( void );
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566 int init( const char *name, long flags, int x, int y, int parent_window );
01567 protected:
01568 virtual int add_control( GLUI_Node *parent, GLUI_Control *control ) {
01569 return GLUI_Main::add_control( parent, control );
01570 }
01571 };
01572
01573
01574
01575
01576
01577
01578
01579 class GLUI_EditText : public GLUI_Control
01580 {
01581 public:
01582 int has_limits;
01583 int data_type;
01584 GLUI_String orig_text;
01585 int insertion_pt;
01586 int title_x_offset;
01587 int text_x_offset;
01588 int substring_start;
01589 int substring_end;
01590 int sel_start, sel_end;
01591 int num_periods;
01592 int last_insertion_pt;
01593 float float_low, float_high;
01594 int int_low, int_high;
01595 GLUI_Spinner *spinner;
01596 int debug;
01597 int draw_text_only;
01598
01599
01600 int mouse_down_handler( int local_x, int local_y );
01601 int mouse_up_handler( int local_x, int local_y, bool inside );
01602 int mouse_held_down_handler( int local_x, int local_y, bool inside );
01603 int key_handler( unsigned char key,int modifiers );
01604 int special_handler( int key, int modifiers );
01605
01606 void activate( int how );
01607 void deactivate( void );
01608
01609 void draw( int x, int y );
01610
01611 int mouse_over( int state, int x, int y );
01612
01613 int find_word_break( int start, int direction );
01614 int substring_width( int start, int end );
01615 void clear_substring( int start, int end );
01616 int find_insertion_pt( int x, int y );
01617 int update_substring_bounds( void );
01618 void update_and_draw_text( void );
01619 void draw_text( int x, int y );
01620 void draw_insertion_pt( void );
01621 void set_numeric_text( void );
01622 void update_x_offsets( void );
01623 void update_size( void );
01624
01625 void set_float_limits( float low,float high,int limit_type=GLUI_LIMIT_CLAMP);
01626 void set_int_limits( int low, int high, int limit_type=GLUI_LIMIT_CLAMP );
01627 void set_float_val( float new_val );
01628 void set_int_val( int new_val );
01629 void set_text( const char *text );
01630 void set_text( const GLUI_String &s) { set_text(s.c_str()); }
01631 const char *get_text() { return text.c_str(); }
01632
01633 void dump( FILE *out, const char *text );
01634
01635
01636 GLUI_EditText( GLUI_Node *parent, const char *name,
01637 int text_type=GLUI_EDITTEXT_TEXT,
01638 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01639
01640 GLUI_EditText( GLUI_Node *parent, const char *name,
01641 int *live_var,
01642 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01643
01644 GLUI_EditText( GLUI_Node *parent, const char *name,
01645 float *live_var,
01646 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01647
01648 GLUI_EditText( GLUI_Node *parent, const char *name,
01649 char *live_var,
01650 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01651
01652 GLUI_EditText( GLUI_Node *parent, const char *name,
01653 std::string &live_var,
01654 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01655
01656
01657 GLUI_EditText( GLUI_Node *parent, const char *name,
01658 int text_type, void *live_var,
01659 int obj_id, GLUI_CB callback );
01660
01661 GLUI_EditText( void ) { common_init(); }
01662
01663 protected:
01664 void common_init( void ) {
01665 h = GLUI_EDITTEXT_HEIGHT;
01666 w = GLUI_EDITTEXT_WIDTH;
01667 title_x_offset = 0;
01668 text_x_offset = 55;
01669 insertion_pt = -1;
01670 last_insertion_pt = -1;
01671 name = "";
01672 substring_start = 0;
01673 data_type = GLUI_EDITTEXT_TEXT;
01674 substring_end = 2;
01675 num_periods = 0;
01676 has_limits = GLUI_LIMIT_NONE;
01677 sel_start = 0;
01678 sel_end = 0;
01679 active_type = GLUI_CONTROL_ACTIVE_PERMANENT;
01680 can_activate = true;
01681 spacebar_mouse_click = false;
01682 spinner = NULL;
01683 debug = false;
01684 draw_text_only = false;
01685 }
01686 void common_construct( GLUI_Node *parent, const char *name,
01687 int data_type, int live_type, void *live_var,
01688 int obj_id, GLUI_CB callback );
01689 };
01690
01691
01692
01693
01694
01695
01696
01697 class GLUI_CommandLine : public GLUI_EditText
01698 {
01699 public:
01700 typedef GLUI_EditText Super;
01701
01702 enum { HIST_SIZE = 100 };
01703 std::vector<GLUI_String> hist_list;
01704 int curr_hist;
01705 int oldest_hist;
01706 int newest_hist;
01707 bool commit_flag;
01708
01709 public:
01710 int key_handler( unsigned char key,int modifiers );
01711 int special_handler( int key,int modifiers );
01712 void deactivate( void );
01713
01714 virtual const char *get_history( int command_number ) const
01715 { return hist_list[command_number - oldest_hist].c_str(); }
01716 virtual GLUI_String& get_history_str( int command_number )
01717 { return hist_list[command_number - oldest_hist]; }
01718 virtual const GLUI_String& get_history_str( int command_number ) const
01719 { return hist_list[command_number - oldest_hist]; }
01720 virtual void recall_history( int history_number );
01721 virtual void scroll_history( int direction );
01722 virtual void add_to_history( const char *text );
01723 virtual void reset_history( void );
01724
01725 void dump( FILE *out, const char *text );
01726
01727
01728 GLUI_CommandLine( GLUI_Node *parent, const char *name, void *live_var=NULL,
01729 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01730 GLUI_CommandLine( void ) { common_init(); }
01731 protected:
01732 void common_init() {
01733 hist_list.resize(HIST_SIZE);
01734 curr_hist = 0;
01735 oldest_hist = 0;
01736 newest_hist = 0;
01737 commit_flag = false;
01738 }
01739 };
01740
01741
01742
01743
01744
01745
01746
01747 class GLUI_RadioGroup : public GLUI_Control
01748 {
01749 public:
01750 int num_buttons;
01751
01752 void draw( int x, int y );
01753 void set_name( const char *text );
01754 void set_int_val( int int_val );
01755 void set_selected( int int_val );
01756
01757 void draw_group( int translate );
01758
01759 GLUI_RadioGroup( GLUI_Node *parent, int *live_var=NULL,
01760 int user_id=-1,GLUI_CB callback=GLUI_CB() );
01761 GLUI_RadioGroup( void ) { common_init(); }
01762
01763 protected:
01764 void common_init( void ) {
01765 x_off = 0;
01766 y_off_top = 0;
01767 y_off_bot = 0;
01768 is_container = true;
01769 w = 300;
01770 h = 300;
01771 num_buttons = 0;
01772 name = "";
01773 can_activate = false;
01774 live_type = GLUI_LIVE_INT;
01775 }
01776 };
01777
01778
01779
01780
01781
01782
01783
01784 class GLUI_RadioButton : public GLUI_Control
01785 {
01786 public:
01787 int orig_value;
01788 bool currently_inside;
01789 int text_x_offset;
01790
01791 int mouse_down_handler( int local_x, int local_y );
01792 int mouse_up_handler( int local_x, int local_y, bool inside );
01793 int mouse_held_down_handler( int local_x, int local_y, bool inside );
01794
01795 void draw( int x, int y );
01796 void update_size( void );
01797
01798 void draw_active_area( void );
01799 void draw_checked( void );
01800 void draw_unchecked( void );
01801 void draw_O( void );
01802
01803 GLUI_RadioButton( GLUI_RadioGroup *group, const char *name );
01804 GLUI_RadioGroup *group;
01805
01806 protected:
01807 void common_init()
01808 {
01809 glui_format_str( name, "RadioButton: %p", (void *) this );
01810 h = GLUI_RADIOBUTTON_SIZE;
01811 group = NULL;
01812 orig_value = -1;
01813 text_x_offset = 18;
01814 can_activate = true;
01815 }
01816 };
01817
01818
01819
01820
01821
01822
01823
01824
01825 class GLUI_Separator : public GLUI_Control
01826 {
01827 public:
01828 void draw( int x, int y );
01829
01830 GLUI_Separator( GLUI_Node *parent );
01831 GLUI_Separator( void ) { common_init(); }
01832
01833 protected:
01834 void common_init() {
01835 w = 100;
01836 h = GLUI_SEPARATOR_HEIGHT;
01837 can_activate = false;
01838 }
01839 };
01840
01841 #define GLUI_SPINNER_ARROW_WIDTH 12
01842 #define GLUI_SPINNER_ARROW_HEIGHT 8
01843 #define GLUI_SPINNER_ARROW_Y 2
01844
01845 #define GLUI_SPINNER_STATE_NONE 0
01846 #define GLUI_SPINNER_STATE_UP 1
01847 #define GLUI_SPINNER_STATE_DOWN 2
01848 #define GLUI_SPINNER_STATE_BOTH 3
01849
01850 #define GLUI_SPINNER_DEFAULT_GROWTH_EXP 1.05f
01851
01852
01853
01854
01855
01856
01857
01858 class GLUI_Spinner : public GLUI_Control
01859 {
01860 public:
01861
01862 GLUI_Spinner( GLUI_Node* parent, const char *name,
01863 int data_type=GLUI_SPINNER_INT, int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01864
01865 GLUI_Spinner( GLUI_Node* parent, const char *name,
01866 int *live_var, int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01867
01868 GLUI_Spinner( GLUI_Node* parent, const char *name,
01869 float *live_var, int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01870
01871 GLUI_Spinner( GLUI_Node* parent, const char *name,
01872 int data_type,
01873 void *live_var,
01874 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01875
01876 GLUI_Spinner( void ) { common_init(); }
01877
01878 bool currently_inside;
01879 int state;
01880 float growth, growth_exp;
01881 int last_x, last_y;
01882 int data_type;
01883 int callback_count;
01884 int last_int_val;
01885 float last_float_val;
01886 int first_callback;
01887 float user_speed;
01888
01889 GLUI_EditText *edittext;
01890
01891 int mouse_down_handler( int local_x, int local_y );
01892 int mouse_up_handler( int local_x, int local_y, bool inside );
01893 int mouse_held_down_handler( int local_x, int local_y, bool inside );
01894 int key_handler( unsigned char key,int modifiers );
01895 int special_handler( int key,int modifiers );
01896
01897 void draw( int x, int y );
01898 void draw_pressed( void );
01899 void draw_unpressed( void );
01900 void draw_text( int sunken );
01901
01902 void update_size( void );
01903
01904 void set_float_limits( float low,float high,int limit_type=GLUI_LIMIT_CLAMP);
01905 void set_int_limits( int low, int high,int limit_type=GLUI_LIMIT_CLAMP);
01906 int find_arrow( int local_x, int local_y );
01907 void do_drag( int x, int y );
01908 void do_callbacks( void );
01909 void do_click( void );
01910 void idle( void );
01911 bool needs_idle( void ) const;
01912
01913 const char *get_text( void );
01914
01915 void set_float_val( float new_val );
01916 void set_int_val( int new_val );
01917 float get_float_val( void );
01918 int get_int_val( void );
01919 void increase_growth( void );
01920 void reset_growth( void );
01921
01922 void set_speed( float speed ) { user_speed = speed; }
01923
01924 protected:
01925 void common_init() {
01926 glui_format_str( name, "Spinner: %p", this );
01927 h = GLUI_EDITTEXT_HEIGHT;
01928 w = GLUI_EDITTEXT_WIDTH;
01929 x_off = 0;
01930 y_off_top = 0;
01931 y_off_bot = 0;
01932 can_activate = true;
01933 state = GLUI_SPINNER_STATE_NONE;
01934 edittext = NULL;
01935 growth_exp = GLUI_SPINNER_DEFAULT_GROWTH_EXP;
01936 callback_count = 0;
01937 first_callback = true;
01938 user_speed = 1.0;
01939 }
01940 void common_construct( GLUI_Node* parent, const char *name,
01941 int data_type, void *live_var,
01942 int obj_id, GLUI_CB callback );
01943 };
01944
01945
01946
01947
01948
01949
01950
01951 class GLUI_StaticText : public GLUI_Control
01952 {
01953 public:
01954 void set_text( const char *text );
01955 void draw( int x, int y );
01956 void draw_text( void );
01957 void update_size( void );
01958 void erase_text( void );
01959
01960 GLUI_StaticText(GLUI_Node *parent, const char *name);
01961 GLUI_StaticText( void ) { common_init(); }
01962
01963 protected:
01964 void common_init() {
01965 h = GLUI_STATICTEXT_SIZE;
01966 name = "";
01967 can_activate = false;
01968 }
01969 };
01970
01971
01972
01973
01974
01975
01976
01977 class GLUI_TextBox : public GLUI_Control
01978 {
01979 public:
01980
01981 GLUI_TextBox(GLUI_Node *parent, GLUI_String &live_var,
01982 bool scroll = false, int obj_id=-1, GLUI_CB callback=GLUI_CB() );
01983 GLUI_TextBox( GLUI_Node *parent,
01984 bool scroll = false, int obj_id=-1,
01985 GLUI_CB callback=GLUI_CB() );
01986
01987 GLUI_String orig_text;
01988 int insertion_pt;
01989 int substring_start;
01990 int substring_end;
01991 int sel_start, sel_end;
01992 int last_insertion_pt;
01993 int debug;
01994 int draw_text_only;
01995 int tab_width;
01996 int start_line;
01997 int num_lines;
01998 int curr_line;
01999 int visible_lines;
02000 int insert_x;
02001 int insert_y;
02002 int keygoal_x;
02003 GLUI_Scrollbar *scrollbar;
02004
02005 int mouse_down_handler( int local_x, int local_y );
02006 int mouse_up_handler( int local_x, int local_y, bool inside );
02007 int mouse_held_down_handler( int local_x, int local_y, bool inside );
02008 int key_handler( unsigned char key,int modifiers );
02009 int special_handler( int key,int modifiers );
02010
02011 void activate( int how );
02012 void deactivate( void );
02013
02014 void enable( void );
02015 void disable( void );
02016
02017 void draw( int x, int y );
02018
02019 int mouse_over( int state, int x, int y );
02020
02021 int get_box_width();
02022 int find_word_break( int start, int direction );
02023 int substring_width( int start, int end, int initial_width=0 );
02024 void clear_substring( int start, int end );
02025 int find_insertion_pt( int x, int y );
02026 int update_substring_bounds( void );
02027 void update_and_draw_text( void );
02028 void draw_text( int x, int y );
02029 void draw_insertion_pt( void );
02030 void update_x_offsets( void );
02031 void update_size( void );
02032
02033 void set_text( const char *text );
02034 const char *get_text( void ) { return text.c_str(); }
02035
02036 void dump( FILE *out, char *text );
02037 void set_tab_w(int w) { tab_width = w; }
02038 void set_start_line(int l) { start_line = l; }
02039 static void scrollbar_callback(GLUI_Control*);
02040
02041 bool wants_tabs( void ) const { return true; }
02042
02043 protected:
02044 void common_init()
02045 {
02046 h = GLUI_TEXTBOX_HEIGHT;
02047 w = GLUI_TEXTBOX_WIDTH;
02048 tab_width = GLUI_TAB_WIDTH;
02049 num_lines = 0;
02050 visible_lines = 0;
02051 start_line = 0;
02052 curr_line = 0;
02053 insert_y = -1;
02054 insert_x = -1;
02055 insertion_pt = -1;
02056 last_insertion_pt = -1;
02057 name[0] = '\0';
02058 substring_start = 0;
02059 substring_end = 2;
02060 sel_start = 0;
02061 sel_end = 0;
02062 active_type = GLUI_CONTROL_ACTIVE_PERMANENT;
02063 can_activate = true;
02064 spacebar_mouse_click = false;
02065 scrollbar = NULL;
02066 debug = false;
02067 draw_text_only = false;
02068 }
02069 void common_construct(
02070 GLUI_Node *parent, GLUI_String *live_var,
02071 bool scroll, int obj_id, GLUI_CB callback);
02072 };
02073
02074
02075
02076
02077
02078
02079
02080 class GLUI_List_Item : public GLUI_Node
02081 {
02082 public:
02083 GLUI_String text;
02084 int obj_id;
02085 };
02086
02087
02088
02089
02090
02091
02092
02093 class GLUI_List : public GLUI_Control
02094 {
02095 public:
02096
02097 GLUI_List( GLUI_Node *parent, bool scroll = false,
02098 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
02099
02100
02101
02102 GLUI_List( GLUI_Node *parent,
02103 GLUI_String& live_var, bool scroll = false,
02104 int obj_id=-1,
02105 GLUI_CB callback=GLUI_CB()
02106
02107 );
02108
02109
02110 GLUI_String orig_text;
02111 int debug;
02112 int draw_text_only;
02113 int start_line;
02114 int num_lines;
02115 int curr_line;
02116 int visible_lines;
02117 GLUI_Scrollbar *scrollbar;
02118 GLUI_List_Item items_list;
02119 GLUI_Control *associated_object;
02120 GLUI_CB obj_cb;
02121 int cb_click_type;
02122 int last_line;
02123 int last_click_time;
02124
02125 int mouse_down_handler( int local_x, int local_y );
02126 int mouse_up_handler( int local_x, int local_y, bool inside );
02127 int mouse_held_down_handler( int local_x, int local_y, bool inside );
02128 int key_handler( unsigned char key,int modifiers );
02129 int special_handler( int key,int modifiers );
02130
02131 void activate( int how );
02132 void deactivate( void );
02133
02134 void draw( int x, int y );
02135
02136 int mouse_over( int state, int x, int y );
02137
02138 int get_box_width();
02139 int find_word_break( int start, int direction );
02140 int substring_width( const char *t, int start, int end );
02141 int find_line( int x, int y );
02142 void update_and_draw_text( void );
02143 void draw_text( const char *t, int selected, int x, int y );
02144 void update_size( void );
02145
02146
02147 int add_item( int obj_id, char *text );
02148 int delete_item( const char *text );
02149 int delete_item( int obj_id );
02150 int delete_all();
02151
02152 GLUI_List_Item *get_item_ptr( const char *text );
02153 GLUI_List_Item *get_item_ptr( int obj_id );
02154
02155 void dump( FILE *out, const char *text );
02156 void set_start_line(int l) { start_line = l; }
02157 static void scrollbar_callback(GLUI_Control*);
02158 int get_current_item() { return curr_line; }
02159 void set_click_type(int d) {
02160 cb_click_type = d; }
02161 void set_object_callback(GLUI_CB cb=GLUI_CB(), GLUI_Control*obj=NULL)
02162 { obj_cb=cb; associated_object=obj; }
02163
02164 protected:
02165 void common_init()
02166 {
02167 h = GLUI_LIST_HEIGHT;
02168 w = GLUI_LIST_WIDTH;
02169 num_lines = 0;
02170 visible_lines = 0;
02171 start_line = 0;
02172 curr_line = 0;
02173 name[0] = '\0';
02174 active_type = GLUI_CONTROL_ACTIVE_PERMANENT;
02175 can_activate = true;
02176 spacebar_mouse_click = false;
02177 scrollbar = NULL;
02178 debug = false;
02179 draw_text_only = false;
02180 cb_click_type = GLUI_SINGLE_CLICK;
02181 last_line = -1;
02182 last_click_time = 0;
02183 associated_object = NULL;
02184 };
02185 void common_construct(
02186 GLUI_Node *parent,
02187 GLUI_String* live_var, bool scroll,
02188 int obj_id,
02189 GLUI_CB callback
02190
02191 );
02192 };
02193
02194
02195
02196
02197
02198
02199
02200 class GLUI_Scrollbar : public GLUI_Control
02201 {
02202 public:
02203
02204 GLUI_Scrollbar( GLUI_Node *parent,
02205 const char *name,
02206 int horz_vert=GLUI_SCROLL_HORIZONTAL,
02207 int data_type=GLUI_SCROLL_INT,
02208 int obj_id=-1, GLUI_CB callback=GLUI_CB()
02209
02210
02211 );
02212
02213
02214 GLUI_Scrollbar( GLUI_Node *parent, const char *name, int horz_vert,
02215 int *live_var,
02216 int obj_id=-1, GLUI_CB callback=GLUI_CB()
02217
02218
02219 );
02220
02221
02222 GLUI_Scrollbar( GLUI_Node *parent, const char *name, int horz_vert,
02223 float *live_var,
02224 int obj_id=-1, GLUI_CB callback=GLUI_CB()
02225
02226
02227 );
02228
02229 bool currently_inside;
02230 int state;
02231 float growth, growth_exp;
02232 int last_x, last_y;
02233 int data_type;
02234 int callback_count;
02235 int last_int_val;
02236 float last_float_val;
02237 int first_callback;
02238 float user_speed;
02239 float float_min, float_max;
02240 int int_min, int_max;
02241 int horizontal;
02242 double last_update_time;
02243 double velocity_limit;
02244 int box_length;
02245 int box_start_position;
02246 int box_end_position;
02247 int track_length;
02248
02249
02250
02251
02252
02253
02254
02255
02256 void * associated_object;
02257 GLUI_CB object_cb;
02258
02259 int mouse_down_handler( int local_x, int local_y );
02260 int mouse_up_handler( int local_x, int local_y, bool inside );
02261 int mouse_held_down_handler( int local_x, int local_y, bool inside );
02262 int key_handler( unsigned char key,int modifiers );
02263 int special_handler( int key,int modifiers );
02264
02265 void draw( int x, int y );
02266 void draw_pressed( void );
02267 void draw_unpressed( void );
02268 void draw_text( int sunken );
02269
02270 void update_size( void );
02271
02272 void set_int_limits( int low, int high,int limit_type=GLUI_LIMIT_CLAMP);
02273 void set_float_limits( float low,float high,int limit_type=GLUI_LIMIT_CLAMP);
02274 int find_arrow( int local_x, int local_y );
02275 void do_drag( int x, int y );
02276 void do_callbacks( void );
02277 void draw_scroll( void );
02278 void do_click( void );
02279 void idle( void );
02280 bool needs_idle( void ) const;
02281 void set_int_val( int new_val );
02282 void set_float_val( float new_val );
02283 void increase_growth( void );
02284 void reset_growth( void );
02285
02286 void set_speed( float speed ) { user_speed = speed; };
02287 void update_scroll_parameters();
02288 void set_object_callback(GLUI_CB cb=GLUI_CB(), GLUI_Control*obj=NULL)
02289 { object_cb=cb; associated_object=obj; }
02290
02291 protected:
02292 void common_init ( void );
02293 void common_construct(
02294 GLUI_Node *parent,
02295 const char *name,
02296 int horz_vert,
02297 int data_type, void* live_var,
02298 int obj_id, GLUI_CB callback
02299
02300
02301 );
02302
02303 virtual void draw_scroll_arrow(int arrowtype, int x, int y);
02304 virtual void draw_scroll_box(int x, int y, int w, int h);
02305 };
02306
02307
02308
02309
02310
02311
02312
02313 class GLUI_Listbox_Item : public GLUI_Node
02314 {
02315 public:
02316 GLUI_String text;
02317 int obj_id;
02318 };
02319
02320 class GLUI_Listbox : public GLUI_Control
02321 {
02322 public:
02323 GLUI_String curr_text;
02324 GLUI_Listbox_Item items_list;
02325 int depressed;
02326
02327 int orig_value;
02328 bool currently_inside;
02329 int text_x_offset, title_x_offset;
02330 int glut_menu_id;
02331
02332 int mouse_down_handler( int local_x, int local_y );
02333 int mouse_up_handler( int local_x, int local_y, bool inside );
02334 int mouse_held_down_handler( int local_x, int local_y, bool inside );
02335 int key_handler( unsigned char key,int modifiers );
02336 int special_handler( int key,int modifiers );
02337
02338 void update_size( void );
02339 void draw( int x, int y );
02340 int mouse_over( int state, int x, int y );
02341
02342 void set_int_val( int new_val );
02343 void dump( FILE *output );
02344
02345
02346 int add_item( int obj_id, char *text );
02347 int delete_item( const char *text );
02348 int delete_item( int obj_id );
02349 int sort_items( void );
02350
02351 int do_selection( int item );
02352
02353 GLUI_Listbox_Item *get_item_ptr( const char *text );
02354 GLUI_Listbox_Item *get_item_ptr( int obj_id );
02355
02356
02357 GLUI_Listbox( GLUI_Node *parent,
02358 const char *name, int *live_var=NULL,
02359 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
02360 GLUI_Listbox( void ) { common_init(); }
02361
02362 protected:
02364 bool recalculate_item_width( void );
02365 void common_init() {
02366 glui_format_str( name, "Listbox: %p", this );
02367 w = GLUI_EDITTEXT_WIDTH;
02368 h = GLUI_EDITTEXT_HEIGHT;
02369 orig_value = -1;
02370 title_x_offset = 0;
02371 text_x_offset = 55;
02372 can_activate = true;
02373 curr_text = "";
02374 live_type = GLUI_LIVE_INT;
02375 depressed = false;
02376 glut_menu_id = -1;
02377 }
02378
02379 ~GLUI_Listbox();
02380 };
02381
02382
02383
02384
02385
02386
02387
02391 class GLUI_Mouse_Interaction : public GLUI_Control
02392 {
02393 public:
02394
02395 int draw_active_area_only;
02396
02397 int mouse_down_handler( int local_x, int local_y );
02398 int mouse_up_handler( int local_x, int local_y, bool inside );
02399 int mouse_held_down_handler( int local_x, int local_y, bool inside );
02400 int special_handler( int key, int modifiers );
02401 void update_size( void );
02402 void draw( int x, int y );
02403 void draw_active_area( void );
02404
02405
02406
02407 virtual int iaction_mouse_down_handler( int local_x, int local_y ) = 0;
02408 virtual int iaction_mouse_up_handler( int local_x, int local_y, bool inside )=0;
02409 virtual int iaction_mouse_held_down_handler( int local_x, int local_y, bool inside )=0;
02410 virtual int iaction_special_handler( int key, int modifiers )=0;
02411 virtual void iaction_draw_active_area_persp( void )=0;
02412 virtual void iaction_draw_active_area_ortho( void )=0;
02413 virtual void iaction_dump( FILE *output )=0;
02414 virtual void iaction_init( void ) = 0;
02415
02416 GLUI_Mouse_Interaction( void ) {
02417 glui_format_str( name, "Mouse_Interaction: %p", this );
02418 w = GLUI_MOUSE_INTERACTION_WIDTH;
02419 h = GLUI_MOUSE_INTERACTION_HEIGHT;
02420 can_activate = true;
02421 live_type = GLUI_LIVE_NONE;
02422 alignment = GLUI_ALIGN_CENTER;
02423 draw_active_area_only = false;
02424 }
02425 };
02426
02427
02428
02429
02430
02431
02432
02437 class GLUI_Rotation : public GLUI_Mouse_Interaction
02438 {
02439 public:
02440 Arcball *ball;
02441 GLUquadricObj *quadObj;
02442 bool can_spin, spinning;
02443 float damping;
02444
02445 int iaction_mouse_down_handler( int local_x, int local_y );
02446 int iaction_mouse_up_handler( int local_x, int local_y, bool inside );
02447 int iaction_mouse_held_down_handler( int local_x, int local_y, bool inside );
02448 int iaction_special_handler( int key, int modifiers );
02449 void iaction_init( void ) { init_ball(); }
02450 void iaction_draw_active_area_persp( void );
02451 void iaction_draw_active_area_ortho( void );
02452 void iaction_dump( FILE *output );
02453
02454
02455
02456
02457
02458 void setup_texture( void );
02459 void setup_lights( void );
02460 void draw_ball( float radius );
02461
02462 void init_ball( void );
02463
02464 void reset( void );
02465
02466 bool needs_idle( void ) const;
02467 void idle( void );
02468
02469 void copy_float_array_to_ball( void );
02470 void copy_ball_to_float_array( void );
02471
02472 void set_spin( float damp_factor );
02473
02474 GLUI_Rotation( GLUI_Node *parent, const char *name, float *live_var=NULL,
02475 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
02476 GLUI_Rotation(void) { common_init(); }
02477
02478 protected:
02479 void common_init();
02480 };
02481
02482
02483
02484
02485
02486
02487
02492 class GLUI_Translation : public GLUI_Mouse_Interaction
02493 {
02494 public:
02495 int trans_type;
02496 int down_x, down_y;
02497 float scale_factor;
02498 GLUquadricObj *quadObj;
02499 int trans_mouse_code;
02500 float orig_x, orig_y, orig_z;
02501 int locked;
02502
02503 int iaction_mouse_down_handler( int local_x, int local_y );
02504 int iaction_mouse_up_handler( int local_x, int local_y, bool inside );
02505 int iaction_mouse_held_down_handler( int local_x, int local_y, bool inside );
02506 int iaction_special_handler( int key, int modifiers );
02507 void iaction_init( void ) { }
02508 void iaction_draw_active_area_persp( void );
02509 void iaction_draw_active_area_ortho( void );
02510 void iaction_dump( FILE *output );
02511
02512 void set_speed( float s ) { scale_factor = s; }
02513
02514 void setup_texture( void );
02515 void setup_lights( void );
02516 void draw_2d_arrow( int radius, int filled, int orientation );
02517 void draw_2d_x_arrows( int radius );
02518 void draw_2d_y_arrows( int radius );
02519 void draw_2d_z_arrows( int radius );
02520 void draw_2d_xy_arrows( int radius );
02521
02522 int get_mouse_code( int x, int y );
02523
02524
02525
02526
02527 float get_z( void ) { return float_array_val[0]; }
02528 float get_x( void ) { return float_array_val[0]; }
02529 float get_y( void ) {
02530 if ( trans_type == GLUI_TRANSLATION_XY ) return float_array_val[1];
02531 else return float_array_val[0];
02532 }
02533
02534 void set_z( float val );
02535 void set_x( float val );
02536 void set_y( float val );
02537 void set_one_val( float val, int index );
02538
02539 GLUI_Translation( GLUI_Node *parent, const char *name,
02540 int trans_type, float *live_var=NULL,
02541 int obj_id=-1, GLUI_CB callback=GLUI_CB() );
02542 GLUI_Translation( void ) { common_init(); }
02543
02544 protected:
02545 void common_init() {
02546 locked = GLUI_TRANSLATION_LOCK_NONE;
02547 glui_format_str( name, "Translation: %p", this );
02548 w = GLUI_MOUSE_INTERACTION_WIDTH;
02549 h = GLUI_MOUSE_INTERACTION_HEIGHT;
02550 can_activate = true;
02551 live_type = GLUI_LIVE_FLOAT_ARRAY;
02552 float_array_size = 0;
02553 alignment = GLUI_ALIGN_CENTER;
02554 trans_type = GLUI_TRANSLATION_XY;
02555 scale_factor = 1.0;
02556 quadObj = NULL;
02557 trans_mouse_code = GLUI_TRANSLATION_MOUSE_NONE;
02558 }
02559 };
02560
02561
02562 int _glutBitmapWidthString( void *font, const char *s );
02563 void _glutBitmapString( void *font, const char *s );
02564
02565
02566
02567
02568
02569
02570
02571 void glui_display_func( void );
02572 void glui_reshape_func( int w, int h );
02573 void glui_keyboard_func(unsigned char key, int x, int y);
02574 void glui_special_func(int key, int x, int y);
02575 void glui_mouse_func(int button, int state, int x, int y);
02576 void glui_motion_func(int x, int y);
02577 void glui_passive_motion_func(int x, int y);
02578 void glui_entry_func(int state);
02579 void glui_visibility_func(int state);
02580 void glui_idle_func(void);
02581
02582 void glui_parent_window_reshape_func( int w, int h );
02583 void glui_parent_window_keyboard_func(unsigned char key, int x, int y);
02584 void glui_parent_window_mouse_func(int, int, int, int );
02585 void glui_parent_window_special_func(int key, int x, int y);
02586
02587 #endif