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