I will continue it and create a debug trace system that can be activated by ENV variable
diff --git a/src/LICENSE.txt b/src/LICENSE.txt
old mode 100644
new mode 100755
diff --git a/src/algebra3.cpp b/src/algebra3.cpp
index 143c43f..f39c939 100755
--- a/src/algebra3.cpp
+++ b/src/algebra3.cpp
@@ -1172,16 +1172,16 @@ void mat3::print(FILE *file, const char *name) const
{
int i, j;
- fprintf( stderr, "%s:\n", name );
+ //debug("%s:\n", name );
for( i = 0; i < 3; i++ )
{
- fprintf( stderr, " " );
+ //debug( " " );
for( j = 0; j < 3; j++ )
{
- fprintf( stderr, "%f ", v[i][j] );
+ //debug( "%f ", v[i][j] );
}
- fprintf( stderr, "\n" );
+ //debug("\n" );
}
}
@@ -1352,16 +1352,16 @@ void mat4::print(FILE *file, const char *name) const
{
int i, j;
- fprintf( stderr, "%s:\n", name );
+ //debug("%s:\n", name );
for( i = 0; i < 4; i++ )
{
- fprintf( stderr, " " );
+ //debug(" " );
for( j = 0; j < 4; j++ )
{
- fprintf( stderr, "%f ", v[i][j] );
+ //debug( "%f ", v[i][j] );
}
- fprintf( stderr, "\n" );
+ //debug( "\n" );
}
}
diff --git a/src/doc/doxygen.cfg b/src/doc/doxygen.cfg
old mode 100644
new mode 100755
diff --git a/src/doc/glui_manual.doc b/src/doc/glui_manual.doc
old mode 100644
new mode 100755
diff --git a/src/doc/glui_manual.pdf b/src/doc/glui_manual.pdf
old mode 100644
new mode 100755
diff --git a/src/example/example1.cpp b/src/example/example1.cpp
old mode 100644
new mode 100755
index 70985d3..1c356e4
--- a/src/example/example1.cpp
+++ b/src/example/example1.cpp
@@ -31,6 +31,7 @@ void myGlutIdle( void )
glutSetWindow(main_window);
glutPostRedisplay();
+ usleep(100);
}
diff --git a/src/example/example2.cpp b/src/example/example2.cpp
old mode 100644
new mode 100755
diff --git a/src/example/example3.cpp b/src/example/example3.cpp
old mode 100644
new mode 100755
index 459cfad..52652c4
--- a/src/example/example3.cpp
+++ b/src/example/example3.cpp
@@ -215,6 +215,7 @@ void myGlutIdle( void )
counter++;
glui->sync_live();
+ usleep(100);
}
diff --git a/src/example/example4.cpp b/src/example/example4.cpp
old mode 100644
new mode 100755
index 7b58735..5f5af2c
--- a/src/example/example4.cpp
+++ b/src/example/example4.cpp
@@ -288,7 +288,7 @@ int main(int argc, char* argv[])
x, and y */
/*** Add invisible panel to hold rest of controls ***/
- GLUI_Panel *panel1 = new GLUI_Panel(glui, "", GLUI_PANEL_NONE );
+ GLUI_Panel *panel1 = new GLUI_Panel(glui, "panel1", GLUI_PANEL_NONE );
obj_panel = new GLUI_Panel( panel1, "Objects" );
@@ -305,7 +305,7 @@ int main(int argc, char* argv[])
scale_spinner->set_float_limits( .2f, 4.0 );
scale_spinner->set_alignment( GLUI_ALIGN_RIGHT );
- GLUI_Panel *panel2 = new GLUI_Panel( obj_panel, "", GLUI_PANEL_NONE );
+ GLUI_Panel *panel2 = new GLUI_Panel( obj_panel, "panel2", GLUI_PANEL_NONE );
new GLUI_Checkbox( panel2, "Sphere", &show_sphere );
new GLUI_Column( panel2 );
new GLUI_Checkbox( panel2, "Torus", &show_torus );
diff --git a/src/example/example5.cpp b/src/example/example5.cpp
old mode 100644
new mode 100755
index 5b52b4e..65e4072
--- a/src/example/example5.cpp
+++ b/src/example/example5.cpp
@@ -172,6 +172,7 @@ void myGlutIdle( void )
application */
glutPostRedisplay();
+ usleep(100);
}
/***************************************** myGlutMouse() **********/
diff --git a/src/example/example6.cpp b/src/example/example6.cpp
old mode 100644
new mode 100755
index 6111f1f..1233096
--- a/src/example/example6.cpp
+++ b/src/example/example6.cpp
@@ -67,18 +67,18 @@ const char commandline[] =
"users can recall previous commands.\n";
const char gstring[] =
- "GLUI_String\n"
+ "std::string\n"
"\n"
"The GLUI string class used to be wrapper class around \n"
"a fixed 300 char buffer.\n"
- "Now GLUI_String is just a typedef for std::string.\n"
+ "Now std::string is just a typedef for std::string.\n"
"\n"
"One new function has been introduced, which is a sprintf() equivalent\n"
- "for std::string/GLUI_String.\n"
+ "for std::string/std::string.\n"
"\n"
- " glui_format_str(GLUI_String& str, const char *format_str, ...);\n"
+ " glui_format_str(std::string& str, const char *format_str, ...);\n"
"\n"
- "Other than the fact that it takes a GLUI_String as the first argument,\n"
+ "Other than the fact that it takes a std::string as the first argument,\n"
"it works just like sprintf().\n";
const char list[] =
@@ -157,7 +157,7 @@ const char text_box[] =
void control_cb(int control) {
int item;
- GLUI_String text;
+ std::string text;
std::string file_name;
FILE *file;
char c;
@@ -278,11 +278,11 @@ int main(int argc, char* argv[])
main_window = edit->get_glut_window_id();
GLUI_Panel *ep = new GLUI_Panel(edit,"",true);
new GLUI_StaticText(ep,"Widget Information:");
- hah = new GLUI_List(ep,true,1,control_cb);
+ hah = new GLUI_List(ep,"hah", true,1,control_cb);
hah->add_item(0,"GLUI 2.3");
hah->add_item(1,"TextBox");
hah->add_item(2,"Scrollbar");
- hah->add_item(3,"GLUI_String");
+ hah->add_item(3,"std::string");
hah->add_item(4,"CommandLine");
hah->add_item(5,"Tree");
hah->add_item(6,"List");
@@ -293,7 +293,7 @@ int main(int argc, char* argv[])
hah->set_h(180);
new GLUI_Column(ep,false);
- moo = new GLUI_TextBox(ep,true,1,textbox_cb);
+ moo = new GLUI_TextBox(ep, "moo", true,1,textbox_cb);
moo->set_text(general);
moo->set_h(400);
moo->set_w(410);
diff --git a/src/glui.cpp b/src/glui.cpp
index 7b9bf47..729ff5d 100755
--- a/src/glui.cpp
+++ b/src/glui.cpp
@@ -220,7 +220,7 @@ void glui_display_func(void)
{
GLUI *glui;
- /* printf( "display func\n" ); */
+ debug( "display func\n" );
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
@@ -242,7 +242,7 @@ void glui_reshape_func(int w,int h )
GLUI_Glut_Window *glut_window;
int current_window;
- /*printf( "glui_reshape_func(): %d w/h: %d/%d\n", glutGetWindow(), w, h ); */
+ debug( "glui_reshape_func(): %d w/h: %d/%d\n", glutGetWindow(), w, h );
current_window = glutGetWindow();
@@ -285,7 +285,7 @@ void glui_keyboard_func(unsigned char key, int x, int y)
current_window = glutGetWindow();
glut_window = GLUI_Master.find_glut_window( current_window );
- /*printf( "key: %d\n", current_window ); */
+ debug( "key: %d\n", current_window );
if ( glut_window ) { /** Was event in a GLUT window? **/
if ( GLUI_Master.active_control_glui AND GLUI_Master.active_control ) {
@@ -433,7 +433,7 @@ void glui_visibility_func(int state)
{
GLUI *glui;
- /* printf( "IN GLUI VISIBILITY()\n" ); */
+ debug( "IN GLUI VISIBILITY()\n" );
/* fflush( stdout ); */
glui = GLUI_Master.find_glui_by_window_id( glutGetWindow() );
@@ -486,8 +486,10 @@ void glui_idle_func(void)
/*********************************** GLUI_Master_Object::GLUI_Master_Object() ******/
GLUI_Master_Object::GLUI_Master_Object()
-: glui_id_counter(1),
- glut_idle_CB(NULL)
+ : glui_id_counter(1)
+ , glut_idle_CB(NULL)
+ , gluis("gluis")
+ , glut_windows("glut_windows")
{
}
@@ -512,7 +514,7 @@ GLUI *GLUI_Master_Object::create_glui_subwindow( int parent_window,
long flags )
{
GLUI *new_glui = new GLUI;
- GLUI_String new_name;
+ std::string new_name;
glui_format_str( new_name, "subwin_%p", this );
new_glui->init( new_name.c_str(), flags | GLUI_SUBWINDOW, 0,0,
@@ -685,7 +687,7 @@ void GLUI_Main::reshape( int reshape_w, int reshape_h )
glViewport( 0, 0, new_w, new_h );
- /* printf( "%d: %d\n", glutGetWindow(), this->flags ); */
+ debug( "%d: %d\n", glutGetWindow(), this->flags );
glutPostRedisplay();
}
@@ -710,9 +712,9 @@ void GLUI_Main::keyboard(unsigned char key, int x, int y)
new_control = find_next_control( active_control );
}
- /* if ( new_control )
- printf( "new_control: %s\n", new_control->name );
- */
+ if ( new_control ) {
+ debug( "new_control: %s\n", new_control->NodeName );
+ }
deactivate_current_control();
activate_control( new_control, GLUI_ACTIVATE_TAB );
@@ -753,7 +755,7 @@ void GLUI_Main::mouse(int button, int state, int x, int y)
int callthrough;
GLUI_Control *control;
- /* printf( "MOUSE: %d %d\n", button, state ); */
+ debug( "MOUSE: %d %d\n", button, state );
callthrough = true;
@@ -762,10 +764,12 @@ void GLUI_Main::mouse(int button, int state, int x, int y)
if ( button == GLUT_LEFT ) {
control = find_control( x, y );
- /*if ( control ) printf( "control: %s\n", control->name.c_str() ); */
-
+ if ( control ) {
+ debug( "control: %s\n", control->NodeName );
+ }
+
if ( mouse_button_down AND active_control != NULL AND
- state == GLUT_UP )
+ state == GLUT_UP )
{
/** We just released the mouse, which was depressed at some control **/
@@ -824,7 +828,7 @@ void GLUI_Main::motion(int x, int y)
int callthrough;
GLUI_Control *control;
- /* printf( "MOTION: %d %d\n", x, y ); */
+ debug( "MOTION: %d %d\n", x, y );
callthrough = true;
@@ -854,7 +858,7 @@ void GLUI_Main::passive_motion(int x, int y)
control = find_control( x, y );
- /* printf( "%p %p\n", control, mouse_over_control ); */
+ debug( "%p %p\n", control, mouse_over_control );
if ( control != mouse_over_control ) {
if ( mouse_over_control ) {
@@ -899,7 +903,7 @@ void GLUI_Main::idle(void)
{
/*** Pass the idle event onto the active control, if any ***/
- /* printf( "IDLE \t" ); */
+ debug( "IDLE \t" );
if ( active_control != NULL ) {
/* First we check if the control actually needs the idle right now.
@@ -925,60 +929,60 @@ int GLUI_Main::needs_idle( void )
/******************************************* GLUI_Main::find_control() ******/
-
-GLUI_Control *GLUI_Main::find_control( int x, int y )
+GLUI_Control *GLUI_Main::find_control( int x, int y, GLUI_Control * parent )
{
- GLUI_Control *node, *last_container;
+ GLUI_Control *node, *found, *child;
- last_container = NULL;
+ found = NULL;
- node = main_panel;
- while( node != NULL ) {
- if ( !dynamic_cast<GLUI_Column*>(node) AND
- PT_IN_BOX( x, y,
- node->x_abs, node->x_abs + node->w,
- node->y_abs, node->y_abs + node->h )
- )
+ if( parent == NULL ) {
+ node = main_panel;
+ }
+ else
{
- /*** Point is inside current node ***/
-
- if ( node->first_child() == NULL ) {
- /*** SPECIAL CASE: for edittext boxes, we make sure click is
- in box, and not on name string. This should be generalized
- for all controls later... ***/
- if ( dynamic_cast<GLUI_EditText*>(node) ) {
- if ( x < node->x_abs + ((GLUI_EditText*)node)->text_x_offset )
- return (GLUI_Control*) node->parent();
+ node = parent;
+ }
+ if ( PT_IN_BOX( x, y,
+ node->x_abs, node->x_abs + node->w,
+ node->y_abs, node->y_abs + node->h ) )
+ {
+ //debug ( "ctrl fits: '%s'\n", node->NodeName );
+ child = dynamic_cast<GLUI_Control *>(node->first_child());
+ if ( child != NULL )
+ {
+ //debug ( "ctrl '%s' has childs\n", node->NodeName );
+ do
+ {
+ found = find_control ( x, y, child);
+ if (NULL == found) child = dynamic_cast<GLUI_Control *>(child->next());
+ }
+ while ( found == NULL && child != NULL );
}
-
- return node; /* point is inside this node, and node has no children,
- so return this node as the selected node */
- }
- else {
- /*** This is a container class ***/
- last_container = node;
- node = (GLUI_Control*) node->first_child(); /* Descend into child */
- }
-
+ if ( found == NULL ) found = node;
+
+ // SPECIAL CASE: for edittext boxes, we make sure click is
+ // in box, and not on name string. This should be generalized
+ // for all controls later...
+ if ( dynamic_cast<GLUI_EditText*>(node) )
+ {
+ if ( x < node->x_abs + ((GLUI_EditText*)node)->text_x_offset )
+ {
+ return (GLUI_Control*) node->parent();
+ }
+ }
+ if( parent == NULL ) {
+ debug ( "found ctrl: '%s'\n",
+ dynamic_cast<GLUI_Node*>(found)->whole_tree() );
+ }
+ return found;
}
- else {
- node = (GLUI_Control*) node->next();
+ else
+ {
+ debug (" not in %s.... skipping the whole tree \n", node->NodeName);
+ return NULL;
}
- }
-
- /** No leaf-level nodes found to accept the mouse click, so
- return the last container control found which DOES accept the click **/
-
- if ( last_container ) {
- /* printf( "ctrl: '%s'\n", last_container->name ); */
-
- return last_container;
- }
- else {
- return NULL;
- }
-}
+}
/************************************* GLUI_Main::pack_controls() ***********/
@@ -1001,21 +1005,21 @@ void GLUI_Main::pack_controls( void )
glutSetWindow( orig_window );
- /* printf( "%d %d\n", parent_h, parent_w ); */
+ debug( "%d %d\n", parent_h, parent_w );
if ( 1 ) {
- if ( TEST_AND(this->flags,GLUI_SUBWINDOW_TOP )) {
- main_panel->w = MAX( main_panel->w, parent_w );
- }
- else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_LEFT )) {
- main_panel->h = MAX( main_panel->h, parent_h );
- }
- else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_BOTTOM )) {
- main_panel->w = MAX( main_panel->w, parent_w );
- }
- else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_RIGHT )) {
- main_panel->h = MAX( main_panel->h, parent_h );
- }
+ if ( TEST_AND(this->flags,GLUI_SUBWINDOW_TOP )) {
+ main_panel->w = MAX( main_panel->w, parent_w );
+ }
+ else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_LEFT )) {
+ main_panel->h = MAX( main_panel->h, parent_h );
+ }
+ else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_BOTTOM )) {
+ main_panel->w = MAX( main_panel->w, parent_w );
+ }
+ else if ( TEST_AND(this->flags,GLUI_SUBWINDOW_RIGHT )) {
+ main_panel->h = MAX( main_panel->h, parent_h );
+ }
}
}
@@ -1139,7 +1143,7 @@ GLUI_Main::GLUI_Main( void )
bkgd_color_f[2] = b / 255.0f;
/*** Create the main panel ***/
- main_panel = new GLUI_Panel;
+ main_panel = new GLUI_Panel("root panel");
main_panel->set_int_val( GLUI_PANEL_NONE );
main_panel->glui = (GLUI*) this;
main_panel->name = "\0";
@@ -1232,7 +1236,7 @@ void GLUI_Main::activate_control( GLUI_Control *control, int how )
active_control = NULL;
}
- /* printf( "activate: %d\n", glutGetWindow() ); */
+ debug( "activate: %d\n", glutGetWindow() );
GLUI_Master.active_control = active_control;
GLUI_Master.active_control_glui = (GLUI*) this;
}
@@ -1263,7 +1267,7 @@ void GLUI_Main::deactivate_current_control( void )
active_control = NULL;
}
- /* printf( "deactivate: %d\n", glutGetWindow() ); */
+ debug( "deactivate: %d\n", glutGetWindow() );
GLUI_Master.active_control = NULL;
GLUI_Master.active_control_glui = NULL;
}
@@ -1696,7 +1700,7 @@ void glui_parent_window_reshape_func( int w, int h )
GLUI *glui;
int first = true;
- /* printf( "glui_parent_window_reshape_func: %d\n", glutGetWindow() ); */
+ debug( "glui_parent_window_reshape_func: %d\n", glutGetWindow() );
current_window = glutGetWindow();
@@ -1724,7 +1728,7 @@ void glui_parent_window_reshape_func( int w, int h )
void glui_parent_window_keyboard_func(unsigned char key, int x, int y)
{
- /* printf( "glui_parent_window_keyboard_func: %d\n", glutGetWindow() ); */
+ debug( "glui_parent_window_keyboard_func: %d\n", glutGetWindow() );
int current_window;
GLUI *glui;
@@ -1759,7 +1763,7 @@ void glui_parent_window_keyboard_func(unsigned char key, int x, int y)
void glui_parent_window_special_func(int key, int x, int y)
{
- /*printf( "glui_parent_window_special_func: %d\n", glutGetWindow() ); */
+ debug( "glui_parent_window_special_func: %d\n", glutGetWindow() );
int current_window;
GLUI *glui;
@@ -1994,8 +1998,9 @@ void GLUI_Master_Object::get_viewport_area( int *x, int *y,
if ( TEST_AND( curr_glui->flags, GLUI_SUBWINDOW) AND
curr_glui->parent_window == curr_window ) {
- /* printf( "%s -> %d %d %d\n", curr_glui->window_name.c_str(), curr_glui->flags,
- curr_glui->w, curr_glui->h );*/
+// this debug line cause obscure segfaulting.... the NodeName seems to be corrupted
+// debug( "%s -> %d %d %d\n", curr_glui->NodeName, curr_glui->flags,
+// curr_glui->w, curr_glui->h );
if ( TEST_AND( curr_glui->flags,GLUI_SUBWINDOW_LEFT ) ) {
curr_x += curr_glui->w;
diff --git a/src/glui_add_controls.cpp b/src/glui_add_controls.cpp
index ecf72b9..68474b8 100755
--- a/src/glui_add_controls.cpp
+++ b/src/glui_add_controls.cpp
@@ -78,21 +78,23 @@ GLUI_Panel *GLUI::add_panel_to_panel( GLUI_Panel *parent_panel,
/***************************** GLUI::add_radiogroup() ***************/
GLUI_RadioGroup *GLUI::add_radiogroup( int *value_ptr,
- int user_id, GLUI_CB callback)
+ int user_id, GLUI_CB callback,
+ const char* name )
{
return add_radiogroup_to_panel( main_panel, value_ptr,
- user_id, callback );
+ user_id, callback, name );
}
/***************************** GLUI::add_radiogroup_to_panel() ***************/
-GLUI_RadioGroup *GLUI::add_radiogroup_to_panel(
+GLUI_RadioGroup *GLUI::add_radiogroup_to_panel(
GLUI_Panel *panel, int *value_ptr,
- int user_id, GLUI_CB callback
+ int user_id, GLUI_CB callback,
+ const char* name
)
{
- return new GLUI_RadioGroup( panel, value_ptr, user_id, callback );
+ return new GLUI_RadioGroup( panel, value_ptr, user_id, callback, name );
}
@@ -181,7 +183,7 @@ GLUI_EditText *GLUI::add_edittext_to_panel( GLUI_Panel *panel,
/********************************** GLUI::add_edittext() ************/
GLUI_EditText *GLUI::add_edittext( const char *name,
- GLUI_String & data,
+ std::string & data,
int id, GLUI_CB callback)
{
return add_edittext_to_panel( main_panel, name, data, id, callback );
@@ -192,7 +194,7 @@ GLUI_EditText *GLUI::add_edittext( const char *name,
GLUI_EditText*
GLUI::add_edittext_to_panel( GLUI_Panel *panel, const char *name,
- GLUI_String& data,
+ std::string& data,
int id, GLUI_CB callback)
{
return new GLUI_EditText( panel, name, GLUI_EDITTEXT_STRING, &data, id, callback );
diff --git a/src/glui_button.cpp b/src/glui_button.cpp
index a414cd8..ef0ca26 100755
--- a/src/glui_button.cpp
+++ b/src/glui_button.cpp
@@ -33,12 +33,14 @@
/****************************** GLUI_Button::GLUI_Button() **********/
GLUI_Button::GLUI_Button( GLUI_Node *parent, const char *name,
- int id, GLUI_CB cb )
+ int id, GLUI_CB cb ):
+ GLUI_Control(name)
+
{
common_init();
user_id = id;
callback = cb;
- set_name( name );
+ set_name( const_cast<char*>(name) );
currently_inside = false;
parent->add_control( this );
diff --git a/src/glui_checkbox.cpp b/src/glui_checkbox.cpp
index 12d619e..6911f4d 100755
--- a/src/glui_checkbox.cpp
+++ b/src/glui_checkbox.cpp
@@ -39,12 +39,12 @@
GLUI_Checkbox::GLUI_Checkbox( GLUI_Node *parent,
const char *name, int *value_ptr,
int id,
- GLUI_CB cb )
+ GLUI_CB cb ): GLUI_Control(name)
{
common_init();
set_ptr_val( value_ptr );
- set_name( name );
+ set_name( const_cast<char*>(name) );
user_id = id;
callback = cb;
diff --git a/src/glui_column.cpp b/src/glui_column.cpp
index 8932fed..88a1110 100755
--- a/src/glui_column.cpp
+++ b/src/glui_column.cpp
@@ -35,6 +35,7 @@
/******************************** GLUI_Column::GLUI_Column() ************/
GLUI_Column::GLUI_Column( GLUI_Node *parent, int draw_bar )
+ : GLUI_Control ("Column")
{
common_init();
int_val = draw_bar; /* Whether to draw vertical bar or not */
diff --git a/src/glui_commandline.cpp b/src/glui_commandline.cpp
index 1237fcb..5b10570 100755
--- a/src/glui_commandline.cpp
+++ b/src/glui_commandline.cpp
@@ -36,9 +36,10 @@
/****************************** GLUI_CommandLine::GLUI_CommandLine() **********/
GLUI_CommandLine::GLUI_CommandLine( GLUI_Node *parent, const char *name,
void *data, int id, GLUI_CB cb )
+ : GLUI_EditText (name)
{
common_init();
- set_name( name );
+ set_name( const_cast<char*>(name) );
data_type = GLUI_EDITTEXT_TEXT;
ptr_val = data;
diff --git a/src/glui_control.cpp b/src/glui_control.cpp
index 0542fdb..85030d4 100755
--- a/src/glui_control.cpp
+++ b/src/glui_control.cpp
@@ -194,11 +194,13 @@ void GLUI_Control::draw_recursive( int x, int y )
{
GLUI_Control *node;
- /* printf( "%s %d\n", this->name.c_str(), this->hidden );*/
+ debug ( "%s %s hidden(%d)\n",__func__,
+ dynamic_cast<GLUI_Node*>(this)->whole_tree(),
+ this->hidden );
if ( NOT can_draw() )
return;
- /*if ( 1 ) { -- Debugging to check control width
+ /*if ( 1 ) { -- Debugging to check control width
glColor3f( 1.0, 0.0, 0.0 );
glBegin( GL_LINES );
glVertex2i( x_abs, y_abs );00
@@ -210,20 +212,20 @@ void GLUI_Control::draw_recursive( int x, int y )
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
- glTranslatef( (float) this->x_abs + .5,
- (float) this->y_abs + .5,
- 0.0 );
+ glTranslatef( (float) this->x_abs + .5,
+ (float) this->y_abs + .5,
+ 0.0 );
if ( NOT _glui_draw_border_only ) {
if ( NOT strcmp( name.c_str(), "Rollout" ) ) {
}
this->draw( this->x_off, this->y_off_top );
- }
- else
+ }
+ else
{
if ( dynamic_cast<GLUI_Column*>(this) ) {
- /* printf( "%s w/h: %d/%d\n", (char*) name, w, h ); */
+ debug ( "%s w/h: %d/%d\n", name.c_str(), w, h );
/*w = 2; */
}
@@ -235,7 +237,7 @@ void GLUI_Control::draw_recursive( int x, int y )
glEnd();
}
glPopMatrix();
-
+
node = (GLUI_Control*) first_child();
while( node ) {
node->draw_recursive( node->x_abs, node->y_abs );
@@ -782,7 +784,7 @@ void GLUI_Control::sync_live(int recurse, int draw_it)
callbacks ***/
if ( 0 ) { /* THIS CODE BELOW SHOULD NOT BE EXECUTED */
if ( glui->mouse_button_down ) {
- /* printf( "Can't sync\n" ); */
+ debug( "Can't sync\n" );
return;
}
}
@@ -1030,8 +1032,9 @@ void GLUI_Control::get_float_array_val( float *array_ptr )
/**** GLUI_Control::set_name() ********************/
-void GLUI_Control::set_name( const char *str )
+void GLUI_Control::set_name( char *str )
{
+ name.clear();
name = str;
redraw();
}
@@ -1183,13 +1186,13 @@ void GLUI_Control::unhide_internal( int recurse )
node = (GLUI_Node *) this;
while( node != NULL ) {
- /* printf( "unhide: %s [%d]\n", ((GLUI_Control*)node)->name.c_str(),
- ((GLUI_Control*)node)->hidden );*/
+ debug( "unhide: %s [%d]\n", ((GLUI_Control*)node)->name.c_str(),
+ ((GLUI_Control*)node)->hidden );
((GLUI_Control*)node)->hidden = false;
- if ( recurse AND node->first_child() != NULL )
+ if ( recurse AND node->first_child() != NULL )
((GLUI_Control*) node->first_child())->unhide_internal(true);
-
+
node = node->next();
}
@@ -1197,9 +1200,9 @@ void GLUI_Control::unhide_internal( int recurse )
while( node != NULL ) {
((GLUI_Control*)node)->hidden = false;
- if ( recurse AND node->first_child() != NULL )
+ if ( recurse AND node->first_child() != NULL )
((GLUI_Control*) node->first_child())->unhide_internal(true);
-
+
node = node->next();
}
}
diff --git a/src/glui_edittext.cpp b/src/glui_edittext.cpp
index 3f2865c..a4a0fce 100755
--- a/src/glui_edittext.cpp
+++ b/src/glui_edittext.cpp
@@ -38,7 +38,8 @@
GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
int data_type, void *live_var,
- int id, GLUI_CB callback )
+ int id, GLUI_CB callback ) :
+ GLUI_Control(name)
{
if (data_type == GLUI_EDITTEXT_TEXT) {
live_type = GLUI_LIVE_TEXT;
@@ -61,7 +62,9 @@ GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
/****************************** GLUI_EditText::GLUI_EditText() **********/
GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
- int text_type, int id, GLUI_CB callback )
+ int text_type, int id, GLUI_CB callback ):
+ GLUI_Control(name)
+
{
common_construct( parent, name, text_type, GLUI_LIVE_NONE, 0, id, callback);
}
@@ -70,7 +73,9 @@ GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
int *live_var,
- int id, GLUI_CB callback )
+ int id, GLUI_CB callback ):
+ GLUI_Control(name)
+
{
common_construct( parent, name, GLUI_EDITTEXT_INT, GLUI_LIVE_INT, live_var, id, callback);
}
@@ -79,7 +84,9 @@ GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
float *live_var,
- int id, GLUI_CB callback )
+ int id, GLUI_CB callback ):
+ GLUI_Control(name)
+
{
common_construct( parent, name, GLUI_EDITTEXT_FLOAT, GLUI_LIVE_FLOAT, live_var, id, callback);
}
@@ -88,7 +95,9 @@ GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
char *live_var,
- int id, GLUI_CB callback )
+ int id, GLUI_CB callback ):
+ GLUI_Control(name)
+
{
common_construct( parent, name, GLUI_EDITTEXT_TEXT, GLUI_LIVE_TEXT, live_var, id, callback);
}
@@ -97,7 +106,9 @@ GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
GLUI_EditText::GLUI_EditText( GLUI_Node *parent, const char *name,
std::string &live_var,
- int id, GLUI_CB callback )
+ int id, GLUI_CB callback ):
+ GLUI_Control(name)
+
{
common_construct( parent, name, GLUI_EDITTEXT_TEXT, GLUI_LIVE_STRING, &live_var, id, callback);
}
@@ -109,7 +120,7 @@ void GLUI_EditText::common_construct( GLUI_Node *parent, const char *name,
GLUI_CB cb )
{
common_init();
- set_name( name );
+ set_name( const_cast<char*>(name) );
live_type = live_t;
data_type = data_t;
@@ -308,7 +319,7 @@ int GLUI_EditText::key_handler( unsigned char key,int modifiers )
}
else if ( key == CTRL('k') ) { /* KILL TO END OF LINE */
sel_start = sel_end = insertion_pt;
- text.erase(insertion_pt,GLUI_String::npos);
+ text.erase(insertion_pt,std::string::npos);
}
}
else if ( modifiers == GLUT_ACTIVE_ALT ) /* ALT ONLY */
@@ -349,7 +360,7 @@ int GLUI_EditText::key_handler( unsigned char key,int modifiers )
}
if ( key == '.' ) {
- /*printf( "PERIOD: %d\n", num_periods ); */
+ debug( "PERIOD: %d\n", num_periods );
if ( num_periods > 0 ) {
/** We're trying to type a period, but the text already contains
@@ -359,7 +370,7 @@ int GLUI_EditText::key_handler( unsigned char key,int modifiers )
int period_found = false;
if ( sel_start != sel_end ) {
for( i=MIN(sel_end,sel_start); i<MAX(sel_start,sel_end); i++ ) {
- /* printf( "%c ", text[i] ); */
+ debug( "%c ", text[i] );
if ( text[i] == '.' ) {
period_found = true;
break;
@@ -367,7 +378,7 @@ int GLUI_EditText::key_handler( unsigned char key,int modifiers )
}
}
- /* printf( "found: %d num: %d\n", period_found, num_periods ); */
+ debug( "found: %d num: %d\n", period_found, num_periods );
if ( NOT period_found )
return true;
@@ -670,10 +681,10 @@ void GLUI_EditText::draw_text( int x, int y )
text_x = text_x_offset + 2 + GLUI_EDITTEXT_BOXINNERMARGINX;
- /*printf( "text_x: %d substr_width: %d start/end: %d/%d\n",
+ debug( "text_x: %d substr_width: %d start/end: %d/%d\n",
text_x, substring_width( substring_start, substring_end ),
substring_start, substring_end );
- */
+
/** Find lower and upper selection bounds **/
sel_lo = MIN(sel_start, sel_end );
sel_hi = MAX(sel_start, sel_end );
@@ -767,7 +778,7 @@ int GLUI_EditText::find_insertion_pt( int x, int y )
curr_x -= char_width( text[i] );
if ( x > curr_x ) {
- /* printf( "-> %d\n", i ); */
+ debug( "-> %d\n", i );
return i+1;
}
@@ -805,7 +816,7 @@ void GLUI_EditText::draw_insertion_pt( void )
return; /* Don't draw insertion point if there is a current selection */
}
- /* printf( "insertion pt: %d\n", insertion_pt ); */
+ debug( "insertion pt: %d\n", insertion_pt );
curr_x = this->x_abs + text_x_offset
+ substring_width( substring_start, substring_end )
@@ -860,7 +871,7 @@ void GLUI_EditText::update_and_draw_text( void )
return;
update_substring_bounds();
- /* printf( "ss: %d/%d\n", substring_start, substring_end ); */
+ debug( "ss: %d/%d\n", substring_start, substring_end );
redraw();
}
@@ -872,11 +883,10 @@ int GLUI_EditText::special_handler( int key,int modifiers )
{
if ( NOT glui )
return false;
-
- if ( debug )
- printf( "SPECIAL:%d - mod:%d subs:%d/%d ins:%d sel:%d/%d\n",
+
+ debug( "SPECIAL:%d - mod:%d subs:%d/%d ins:%d sel:%d/%d\n",
key, modifiers, substring_start, substring_end,insertion_pt,
- sel_start, sel_end );
+ sel_start, sel_end );
if ( key == GLUT_KEY_LEFT ) {
if ( (modifiers & GLUT_ACTIVE_CTRL) != 0 ) {
@@ -1192,7 +1202,7 @@ int GLUI_EditText::mouse_over( int state, int x, int y )
glutSetCursor( GLUT_CURSOR_TEXT );
}
else {
- /* printf( "OUT\n" ); */
+ debug ( "OUT\n" );
glutSetCursor( GLUT_CURSOR_LEFT_ARROW );
}
diff --git a/src/glui_filebrowser.cpp b/src/glui_filebrowser.cpp
index 20980e3..6cab110 100755
--- a/src/glui_filebrowser.cpp
+++ b/src/glui_filebrowser.cpp
@@ -48,17 +48,18 @@ GLUI_FileBrowser::GLUI_FileBrowser( GLUI_Node *parent,
const char *name,
int type,
int id,
- GLUI_CB cb)
+ GLUI_CB cb) :
+ GLUI_Panel(name)
{
common_init();
- set_name( name );
+ set_name( const_cast<char*>(name) );
user_id = id;
int_val = type;
callback = cb;
parent->add_control( this );
- list = new GLUI_List(this, true, 1);
+ list = new GLUI_List(this, "FileBrowser list", true, 1);
list->set_object_callback( GLUI_FileBrowser::dir_list_callback, this );
list->set_click_type(GLUI_DOUBLE_CLICK);
this->fbreaddir(this->current_dir.c_str());
@@ -98,7 +99,7 @@ void GLUI_FileBrowser::dir_list_callback(GLUI_Control *glui_object) {
void GLUI_FileBrowser::fbreaddir(const char *d) {
- GLUI_String item;
+ std::string item;
int i = 0;
if (!d)
@@ -148,7 +149,7 @@ void GLUI_FileBrowser::fbreaddir(const char *d) {
while ((dirp = readdir(dir)) != NULL) /* open directory */
{
if (!lstat(dirp->d_name,&dr) && S_ISDIR(dr.st_mode)) /* dir is directory */
- item = dirp->d_name + GLUI_String("/");
+ item = dirp->d_name + std::string("/");
else
item = dirp->d_name;
diff --git a/src/glui_internal.h b/src/glui_internal.h
old mode 100644
new mode 100755
diff --git a/src/glui_internal_control.h b/src/glui_internal_control.h
old mode 100644
new mode 100755
diff --git a/src/glui_list.cpp b/src/glui_list.cpp
index 15b5501..29950e9 100755
--- a/src/glui_list.cpp
+++ b/src/glui_list.cpp
@@ -34,10 +34,11 @@
/****************************** GLUI_List::GLUI_List() **********/
-GLUI_List::GLUI_List( GLUI_Node *parent, bool scroll,
+GLUI_List::GLUI_List( GLUI_Node *parent, const char* name, bool scroll,
int id, GLUI_CB callback
/*,GLUI_Control *object
GLUI_InterObject_CB obj_cb*/)
+ : GLUI_Control (name)
{
common_construct(parent, NULL, scroll, id, callback/*, object, obj_cb*/);
}
@@ -45,11 +46,13 @@ GLUI_List::GLUI_List( GLUI_Node *parent, bool scroll,
/****************************** GLUI_List::GLUI_List() **********/
GLUI_List::GLUI_List( GLUI_Node *parent,
- GLUI_String& live_var, bool scroll,
- int id,
- GLUI_CB callback
+ const char* name,
+ std::string& live_var, bool scroll,
+ int id,
+ GLUI_CB callback
/* ,GLUI_Control *object
,GLUI_InterObject_CB obj_cb*/ )
+ : GLUI_Control (name)
{
common_construct(parent, &live_var, scroll, id, callback/*, object, obj_cb*/);
}
@@ -58,8 +61,8 @@ GLUI_List::GLUI_List( GLUI_Node *parent,
void GLUI_List::common_construct(
GLUI_Node *parent,
- GLUI_String* data, bool scroll,
- int id,
+ std::string* data, bool scroll,
+ int id,
GLUI_CB callback
/*,GLUI_Control *object
, GLUI_InterObject_CB obj_cb*/)
diff --git a/src/glui_listbox.cpp b/src/glui_listbox.cpp
index 36ca881..73c771e 100755
--- a/src/glui_listbox.cpp
+++ b/src/glui_listbox.cpp
@@ -38,11 +38,12 @@ GLUI_Listbox::GLUI_Listbox( GLUI_Node *parent,
const char *name, int *value_ptr,
int id,
GLUI_CB cb)
+ : GLUI_Control(name)
{
common_init();
set_ptr_val( value_ptr );
user_id = id;
- set_name( name );
+ set_name( const_cast<char*>(name) );
callback = cb;
parent->add_control( this );
@@ -229,7 +230,7 @@ void GLUI_Listbox::dump( FILE *output )
{
GLUI_Listbox_Item *item;
- /* printf( "%p\n", (char*) name ); */
+ debug( "%p\n", name.c_str() );
fprintf( output, "Listbox: %s\n", name.c_str() );
@@ -305,12 +306,12 @@ int GLUI_Listbox::mouse_over( int state, int x, int y )
{
GLUI_Listbox_Item *item;
- /* printf( "x/y: %d/%d\n", x, y ); */
+ debug( "x/y: %d/%d\n", x, y );
if ( state AND enabled AND x > x_abs + text_x_offset) {
/**** Build a GLUT menu for this listbox ***/
- /* printf( "%d %d\n", x, y ); */
+ debug( "%d %d\n", x, y );
glut_menu_id = glutCreateMenu(listbox_callback);
@@ -325,7 +326,7 @@ int GLUI_Listbox::mouse_over( int state, int x, int y )
GLUI_Master.set_left_button_glut_menu_control( this );
}
else if ( glut_menu_id != -1 ) {
- /* printf( "OUT\n" ); */
+ debug( "OUT\n" );
glutDetachMenu( GLUT_LEFT_BUTTON );
glutDestroyMenu( glut_menu_id );
glut_menu_id = -1;
@@ -359,7 +360,7 @@ int GLUI_Listbox::do_selection( int item_num )
if ( NOT sel_item )
return false;
- /* printf( "-> %s\n", (char*) sel_item->text ); */
+ debug( "-> %s\n", sel_item->text.c_str() );
int_val = item_num;
curr_text = sel_item->text;
diff --git a/src/glui_node.cpp b/src/glui_node.cpp
index a701026..9bac335 100755
--- a/src/glui_node.cpp
+++ b/src/glui_node.cpp
@@ -46,6 +46,16 @@ GLUI_Node::GLUI_Node()
{
}
+GLUI_Node::GLUI_Node(const char* name)
+{
+ NodeName = name;
+ parent_node = NULL;
+ child_head = NULL;
+ child_tail = NULL;
+ next_sibling = NULL;
+ prev_sibling = NULL;
+}
+
/********************************************* GLUI_Node::first() *******/
/* Returns first sibling in 'this' node's sibling list */
@@ -203,12 +213,30 @@ void GLUI_Node::unlink( void )
void GLUI_Node::dump( FILE *out, const char *name )
{
- fprintf( out, "GLUI_node: %s\n", name );
- fprintf( out, " parent: %p child_head: %p child_tail: %p\n",
+ debug( "GLUI_node: %s\n", name );
+ debug( " parent: %p child_head: %p child_tail: %p\n",
(void *) parent_node,
(void *) child_head,
(void *) child_tail );
- fprintf( out, " next: %p prev: %p\n",
+ debug( " next: %p prev: %p\n",
(void *) next_sibling,
(void *) prev_sibling );
}
+
+const char* GLUI_Node::whole_tree(int start)
+{
+ static std::string tree;
+ if (start) {
+ tree.clear();
+ tree += "\"";
+ }
+ if (parent_node != NULL) {
+ parent_node->whole_tree(0);
+ tree += ".";
+ }
+ tree += NodeName;
+ if (start) {
+ tree += "\"";
+ }
+ return tree.c_str();
+}
diff --git a/src/glui_panel.cpp b/src/glui_panel.cpp
index 5c3b116..e0a0def 100755
--- a/src/glui_panel.cpp
+++ b/src/glui_panel.cpp
@@ -33,10 +33,10 @@
#include "glui_internal_control.h"
-GLUI_Panel::GLUI_Panel( GLUI_Node *parent, const char *name, int type )
+GLUI_Panel::GLUI_Panel( GLUI_Node *parent, const char *name, int type ): GLUI_Control(name)
{
common_init();
- set_name( name );
+ set_name( const_cast<char*>(name) );
user_id = -1;
int_val = type;
@@ -142,9 +142,10 @@ void GLUI_Panel::draw( int x, int y )
/****************************** GLUI_Panel::set_name() **********/
-void GLUI_Panel::set_name( const char *new_name )
+void GLUI_Panel::set_name( char *new_name )
{
- name = new_name ? new_name : "";
+ name.clear();
+ name=new_name;
update_size();
diff --git a/src/glui_radio.cpp b/src/glui_radio.cpp
index 4b81f3f..3a07170 100755
--- a/src/glui_radio.cpp
+++ b/src/glui_radio.cpp
@@ -38,10 +38,13 @@
GLUI_RadioGroup::GLUI_RadioGroup(GLUI_Node *parent,
int *value_ptr,
- int id, GLUI_CB cb)
+ int id, GLUI_CB cb,
+ const char* name ):
+ GLUI_Control(name)
+
{
common_init();
- GLUI_String buf;
+ std::string buf;
set_ptr_val( value_ptr );
if ( value_ptr ) {
@@ -54,7 +57,7 @@ GLUI_RadioGroup::GLUI_RadioGroup(GLUI_Node *parent,
user_id = id;
glui_format_str( buf, "RadioGroup: %p", this );
- set_name( buf.c_str() );
+ set_name( const_cast<char*>(buf.c_str()) );
callback = cb;
parent->add_control( this );
@@ -109,7 +112,7 @@ void GLUI_RadioGroup::draw_group( int translate )
/****************************** GLUI_RadioGroup::set_name() **********/
-void GLUI_RadioGroup::set_name( const char *text )
+void GLUI_RadioGroup::set_name( char *text )
{
name = text;
@@ -146,7 +149,8 @@ void GLUI_RadioGroup::set_selected( int int_val )
/************************ GLUI_RadioButton::GLUI_RadioButton() **********/
-GLUI_RadioButton::GLUI_RadioButton( GLUI_RadioGroup *grp, const char *name )
+GLUI_RadioButton::GLUI_RadioButton( GLUI_RadioGroup *grp, const char *name ) :
+ GLUI_Control(name)
{
common_init();
@@ -155,7 +159,7 @@ GLUI_RadioButton::GLUI_RadioButton( GLUI_RadioGroup *grp, const char *name )
/** A radio button's user id is always its ordinal number (zero-indexed)
within the group */
user_id = grp->num_buttons;
- set_name( name );
+ set_name( const_cast<char*>(name) );
group = grp;
group->num_buttons++; /* Increments radiogroup's button count */
diff --git a/src/glui_rollout.cpp b/src/glui_rollout.cpp
index 559d2bf..cdf5292 100755
--- a/src/glui_rollout.cpp
+++ b/src/glui_rollout.cpp
@@ -38,10 +38,12 @@ enum {rollout_height_pixels=GLUI_DEFAULT_CONTROL_HEIGHT + 7};
/****************************** GLUI_Rollout::GLUI_Rollout() **********/
GLUI_Rollout::GLUI_Rollout( GLUI_Node *parent, const char *name,
- int open, int type )
+ int open, int type ) :
+ GLUI_Panel(name),
+ button("")
{
common_init();
- set_name( name );
+ set_name( const_cast<char*>(name) );
user_id = -1;
int_val = type;
diff --git a/src/glui_rotation.cpp b/src/glui_rotation.cpp
index b367ac8..b0ba1e1 100755
--- a/src/glui_rotation.cpp
+++ b/src/glui_rotation.cpp
@@ -47,7 +47,7 @@ int GLUI_Rotation::iaction_mouse_down_handler( int local_x, int local_y )
ball->mouse_down( local_x, local_y );
- /* printf( "%d %d - %f %f\n", local_x, local_y, ball->center[0], ball->center[1] ); */
+ debug( "%d %d - %f %f\n", local_x, local_y, ball->center[0], ball->center[1] );
copy_ball_to_float_array();
@@ -82,7 +82,7 @@ int GLUI_Rotation::iaction_mouse_held_down_handler( int local_x, int local_y,
local_y = (int) floor(2.0 * ball->center[1] - local_y);
- /* printf( "%d %d\n", local_x, local_y ); */
+ debug( "%d %d\n", local_x, local_y );
ball->mouse_motion( local_x, local_y, 0,
(glui->curr_modifiers & GLUT_ACTIVE_ALT) != 0,
@@ -186,7 +186,8 @@ int GLUI_Rotation::iaction_special_handler( int key,int modifiers )
void GLUI_Rotation::init_ball( void )
{
- /*printf( "%f %f %f", float( MIN(w/2,h/2)), (float) w/2, (float) h/2 ); */
+ debug( "GLUI_Rotation::init_ball %f %f %f\n",
+ float( MIN(w/2,h/2)), (float) w/2, (float) h/2 );
ball->set_params( vec2( (float)(w/2), (float)((h-18)/2)),
(float) 2.0*(h-18) );
@@ -420,11 +421,12 @@ GLUI_Rotation::GLUI_Rotation( GLUI_Node *parent,
const char *name, float *value_ptr,
int id,
GLUI_CB cb )
+ : GLUI_Mouse_Interaction (name)
{
common_init();
set_ptr_val( value_ptr );
user_id = id;
- set_name( name );
+ set_name( const_cast<char*>( name ));
callback = cb;
parent->add_control( this );
init_live();
diff --git a/src/glui_scrollbar.cpp b/src/glui_scrollbar.cpp
index 1a0e6a2..2a49ad5 100755
--- a/src/glui_scrollbar.cpp
+++ b/src/glui_scrollbar.cpp
@@ -55,6 +55,7 @@ GLUI_Scrollbar::GLUI_Scrollbar( GLUI_Node *parent,
/*,GLUI_Control *object
,GLUI_InterObject_CB obj_cb*/
)
+ : GLUI_Control (name)
{
common_construct(parent, name, horz_vert, data_type, NULL, id, callback/*, object, obj_cb*/);
}
@@ -68,6 +69,7 @@ GLUI_Scrollbar::GLUI_Scrollbar( GLUI_Node *parent, const char *name,
/*,GLUI_Control *object
,GLUI_InterObject_CB obj_cb*/
)
+ : GLUI_Control (name)
{
common_construct(parent, name, horz_vert, GLUI_SCROLL_INT, live_var, id, callback/*, object, obj_cb*/);
}
@@ -81,6 +83,7 @@ GLUI_Scrollbar::GLUI_Scrollbar( GLUI_Node *parent, const char *name,
/*,GLUI_Control *object
,GLUI_InterObject_CB obj_cb*/
)
+ : GLUI_Control (name)
{
common_construct(parent, name, horz_vert, GLUI_SCROLL_FLOAT, live_var, id, callback/*, object, obj_cb*/);
}
@@ -152,7 +155,7 @@ void GLUI_Scrollbar::common_construct(
}
this->data_type = data_type;
this->set_ptr_val( data );
- this->set_name(name);
+ this->set_name( const_cast<char*>(name));
this->user_id = id;
this->callback = callback;
//this->associated_object = object;
@@ -177,9 +180,9 @@ int GLUI_Scrollbar::mouse_down_handler( int local_x, int local_y )
this->state = find_arrow( local_x, local_y );
GLUI_Master.glui_setIdleFuncIfNecessary();
- /* printf( "spinner: mouse down : %d/%d arrow:%d\n", local_x, local_y,
+ debug( "spinner: mouse down : %d/%d arrow:%d\n", local_x, local_y,
find_arrow( local_x, local_y ));
- */
+
if ( state != GLUI_SCROLL_STATE_UP AND state != GLUI_SCROLL_STATE_DOWN)
return true;
@@ -222,7 +225,7 @@ int GLUI_Scrollbar::mouse_up_handler( int local_x, int local_y, bool inside )
state = GLUI_SCROLL_STATE_NONE;
GLUI_Master.glui_setIdleFuncIfNecessary();
- /* printf("spinner: mouse up : %d/%d inside: %d\n",local_x,local_y,inside); */
+ debug("spinner: mouse up : %d/%d inside: %d\n",local_x,local_y,inside);
/*glutSetCursor( GLUT_CURSOR_INHERIT ); */
glutSetCursor( GLUT_CURSOR_LEFT_ARROW );
@@ -246,9 +249,8 @@ int GLUI_Scrollbar::mouse_held_down_handler( int local_x, int local_y,
if ( state == GLUI_SCROLL_STATE_NONE )
return false;
- /* printf("spinner: mouse held: %d/%d inside: %d\n",local_x,local_y,
+ debug("spinner: mouse held: %d/%d inside: %d\n",local_x,local_y,
new_inside);
- */
if ( state == GLUI_SCROLL_STATE_SCROLL) { /* dragging? */
do_drag( local_x-x_abs, local_y-y_abs );
@@ -619,7 +621,7 @@ void GLUI_Scrollbar::do_click( void )
new_val += direction * incr;
if (1 || data_type==GLUI_SCROLL_FLOAT) set_float_val(new_val);
if (0 && data_type==GLUI_SCROLL_INT) set_int_val((int)new_val);
- //printf("do_click: incr %f val=%f float_val=%f\n",incr,new_val,float_val);
+ debug("do_click: incr %f val=%f float_val=%f\n",incr,new_val,float_val);
/*** Now update live variable and do callback. We don't want
to do the callback on each iteration of this function, just on every
diff --git a/src/glui_separator.cpp b/src/glui_separator.cpp
index 9a1c1ed..c873f42 100755
--- a/src/glui_separator.cpp
+++ b/src/glui_separator.cpp
@@ -36,6 +36,8 @@
/****************************** GLUI_Separator::GLUI_Separator() **********/
GLUI_Separator::GLUI_Separator( GLUI_Node *parent )
+ : GLUI_Control("separator")
+
{
common_init();
parent->add_control( this );
diff --git a/src/glui_spinner.cpp b/src/glui_spinner.cpp
index 2b51917..6320386 100755
--- a/src/glui_spinner.cpp
+++ b/src/glui_spinner.cpp
@@ -47,7 +47,6 @@ FIXME: there's a heck of a lot of duplication between this and glui_scrollbar.cp
#include <cmath>
#include <cassert>
-/*static int __debug=0; */
#define GLUI_SPINNER_GROWTH_STEPS 800
#define GLUI_SPINNER_MIN_GROWTH_STEPS 100
@@ -56,33 +55,40 @@ FIXME: there's a heck of a lot of duplication between this and glui_scrollbar.cp
/****************************** GLUI_Spinner::GLUI_Spinner() ****************/
-GLUI_Spinner::GLUI_Spinner( GLUI_Node* parent, const char *name,
- int data_type, int id, GLUI_CB callback )
+GLUI_Spinner::GLUI_Spinner( GLUI_Node* parent, const char *name,
+ int data_type, int id, GLUI_CB callback ) :
+ GLUI_Control(name)
{
common_construct(parent, name, data_type, NULL, id, callback);
}
/****************************** GLUI_Spinner::GLUI_Spinner() ****************/
-GLUI_Spinner::GLUI_Spinner( GLUI_Node* parent, const char *name,
- int *live_var, int id, GLUI_CB callback )
+GLUI_Spinner::GLUI_Spinner( GLUI_Node* parent, const char *name,
+ int *live_var, int id, GLUI_CB callback ) :
+ GLUI_Control(name)
+
{
common_construct(parent, name, GLUI_SPINNER_INT, live_var, id, callback);
}
/****************************** GLUI_Spinner::GLUI_Spinner() ****************/
-GLUI_Spinner::GLUI_Spinner( GLUI_Node* parent, const char *name,
- float *live_var, int id, GLUI_CB callback )
+GLUI_Spinner::GLUI_Spinner( GLUI_Node* parent, const char *name,
+ float *live_var, int id, GLUI_CB callback ) :
+ GLUI_Control(name)
+
{
common_construct(parent, name, GLUI_SPINNER_FLOAT, live_var, id, callback);
}
/****************************** GLUI_Spinner::GLUI_Spinner() ****************/
-GLUI_Spinner::GLUI_Spinner( GLUI_Node *parent, const char *name,
+GLUI_Spinner::GLUI_Spinner( GLUI_Node *parent, const char *name,
int data_t, void *live_var,
- int id, GLUI_CB callback )
+ int id, GLUI_CB callback ) :
+ GLUI_Control(name)
+
{
common_construct(parent, name, data_t, live_var, id, callback);
}
@@ -112,7 +118,7 @@ void GLUI_Spinner::common_construct( GLUI_Node* parent, const char *name,
user_id = id;
data_type = data_t;
callback = cb;
- set_name( name );
+ set_name( const_cast<char*>(name) );
//glui = parent->get_glui();
parent->add_control( this );
@@ -134,9 +140,8 @@ int GLUI_Spinner::mouse_down_handler( int local_x, int local_y )
this->state = find_arrow( local_x, local_y );
GLUI_Master.glui_setIdleFuncIfNecessary();
- /* printf( "spinner: mouse down : %d/%d arrow:%d\n", local_x, local_y,
+ debug( "spinner: mouse down : %d/%d arrow:%d\n", local_x, local_y,
find_arrow( local_x, local_y ));
- */
if ( state != GLUI_SPINNER_STATE_UP AND state != GLUI_SPINNER_STATE_DOWN )
return true;
@@ -168,7 +173,7 @@ int GLUI_Spinner::mouse_up_handler( int local_x, int local_y, bool inside )
state = GLUI_SPINNER_STATE_NONE;
GLUI_Master.glui_setIdleFuncIfNecessary();
- /* printf("spinner: mouse up : %d/%d inside: %d\n",local_x,local_y,inside); */
+ debug("spinner: mouse up : %d/%d inside: %d\n",local_x,local_y,inside);
/*glutSetCursor( GLUT_CURSOR_INHERIT ); */
glutSetCursor( GLUT_CURSOR_LEFT_ARROW );
@@ -192,9 +197,8 @@ int GLUI_Spinner::mouse_held_down_handler( int local_x, int local_y,
if ( state == GLUI_SPINNER_STATE_NONE )
return false;
- /* printf("spinner: mouse held: %d/%d inside: %d\n",local_x,local_y,
+ debug("spinner: mouse held: %d/%d inside: %d\n",local_x,local_y,
new_inside);
- */
if ( state == GLUI_SPINNER_STATE_BOTH ) { /* dragging? */
do_drag( local_x, local_y );
@@ -591,7 +595,7 @@ void GLUI_Spinner::increase_growth( void )
if ( growth < (hi-lo) / GLUI_SPINNER_MIN_GROWTH_STEPS )
growth *= growth_exp;
- /* printf( "growth: %f\n", growth ); */
+ debug( "growth: %f\n", growth );
}
diff --git a/src/glui_statictext.cpp b/src/glui_statictext.cpp
index 8d6bebe..fe71bf2 100755
--- a/src/glui_statictext.cpp
+++ b/src/glui_statictext.cpp
@@ -35,9 +35,11 @@
/****************************** GLUI_StaticText::GLUI_StaticText() **********/
GLUI_StaticText::GLUI_StaticText( GLUI_Node *parent, const char *name )
+ : GLUI_Control("separator")
+
{
common_init();
- set_name( name );
+ set_name( const_cast<char*>(name) );
parent->add_control( this );
}
@@ -53,7 +55,7 @@ void GLUI_StaticText::draw( int x, int y )
/****************************** GLUI_StaticText::set_text() **********/
-void GLUI_StaticText::set_text( const char *text )
+void GLUI_StaticText::set_text( char *text )
{
set_name( text );
redraw();
diff --git a/src/glui_string.cpp b/src/glui_string.cpp
index 4e59007..da3c924 100755
--- a/src/glui_string.cpp
+++ b/src/glui_string.cpp
@@ -35,7 +35,7 @@
#define vsnprintf _vsnprintf
#endif
-GLUI_String& glui_format_str(GLUI_String& str, const char* fmt, ...)
+ std::string& glui_format_str( std::string& str, const char* fmt, ...)
{
const size_t ISIZE = 128;
char stackbuf[ISIZE];
diff --git a/src/glui_textbox.cpp b/src/glui_textbox.cpp
index 70f8d9a..7f431d2 100755
--- a/src/glui_textbox.cpp
+++ b/src/glui_textbox.cpp
@@ -39,23 +39,26 @@ static const int LINE_HEIGHT = 15;
/****************************** GLUI_TextBox::GLUI_TextBox() **********/
-GLUI_TextBox::GLUI_TextBox(GLUI_Node *parent, GLUI_String &live_var,
+GLUI_TextBox::GLUI_TextBox(GLUI_Node *parent, const char* name, std::string &live_var,
bool scroll, int id, GLUI_CB callback )
+ : GLUI_Control (name)
+
{
common_construct(parent, &live_var, scroll, id, callback);
}
/****************************** GLUI_TextBox::GLUI_TextBox() **********/
-GLUI_TextBox::GLUI_TextBox( GLUI_Node *parent, bool scroll, int id,
+GLUI_TextBox::GLUI_TextBox( GLUI_Node *parent, const char* name, bool scroll, int id,
GLUI_CB callback )
+ : GLUI_Control (name)
{
common_construct(parent, NULL, scroll, id, callback);
}
/****************************** GLUI_TextBox::common_construct() **********/
void GLUI_TextBox::common_construct(
- GLUI_Node *parent, GLUI_String *data,
+ GLUI_Node *parent, std::string *data,
bool scroll, int id, GLUI_CB callback)
{
common_init();
@@ -250,7 +253,7 @@ int GLUI_TextBox::key_handler( unsigned char key,int modifiers )
}
else if ( key == CTRL('k') ) { /* KILL TO END OF LINE */
sel_start = sel_end = insertion_pt;
- text.erase(insertion_pt,GLUI_String::npos);
+ text.erase(insertion_pt,std::string::npos);
}
}
else if ( modifiers == GLUT_ACTIVE_ALT ) /* ALT ONLY */
@@ -778,7 +781,7 @@ void GLUI_TextBox::draw_insertion_pt( void )
if ( debug ) dump( stdout, "-> DRAW_INS_PT" );
- /* printf( "insertion pt: %d\n", insertion_pt ); */
+ debug( "insertion pt: %d\n", insertion_pt );
box_width = get_box_width();
@@ -881,7 +884,7 @@ int GLUI_TextBox::substring_width( int start, int end, int initial_width )
void GLUI_TextBox::update_and_draw_text( void )
{
//update_substring_bounds();
- /* printf( "ss: %d/%d\n", substring_start, substring_end ); */
+ debug( "ss: %d/%d\n", substring_start, substring_end );
redraw();
}
@@ -895,10 +898,9 @@ int GLUI_TextBox::special_handler( int key,int modifiers )
if ( NOT glui )
return false;
- if ( debug )
- printf( "SPECIAL:%d - mod:%d subs:%d/%d ins:%d sel:%d/%d\n",
+ debug( "SPECIAL:%d - mod:%d subs:%d/%d ins:%d sel:%d/%d\n",
key, modifiers, substring_start, substring_end,insertion_pt,
- sel_start, sel_end );
+ sel_start, sel_end );
if ( key == GLUT_KEY_DOWN ) {
if (insert_x == -1 || insert_y == -1)
@@ -912,7 +914,7 @@ int GLUI_TextBox::special_handler( int key,int modifiers )
sel_start = sel_end;
}
if ( can_draw())
- update_and_draw_text();
+ update_and_draw_text();
} else if ( key == GLUT_KEY_UP ) {
if (insert_x == -1 || insert_y == -1)
return false;
@@ -925,7 +927,7 @@ int GLUI_TextBox::special_handler( int key,int modifiers )
sel_start = sel_end;
}
if ( can_draw())
- update_and_draw_text();
+ update_and_draw_text();
} else if ( key == GLUT_KEY_LEFT ) {
if ( (modifiers & GLUT_ACTIVE_CTRL) != 0 ) {
insertion_pt = find_word_break( insertion_pt, -1 );
@@ -956,9 +958,9 @@ int GLUI_TextBox::special_handler( int key,int modifiers )
/*** Update selection if shift key is down ***/
if ( (modifiers & GLUT_ACTIVE_SHIFT ) != 0 )
sel_end = insertion_pt;
- else
+ else
sel_start = sel_end = insertion_pt;
-
+
CLAMP( insertion_pt, 0, text.length()); /* Make sure insertion_pt
is in bounds */
@@ -1069,7 +1071,7 @@ void GLUI_TextBox::set_text( const char *new_text )
void GLUI_TextBox::dump( FILE *out, char *name )
{
- fprintf( out,
+ debug(
"%s (edittext@%p): line:%d ins_pt:%d subs:%d/%d sel:%d/%d len:%d\n",
name, this, curr_line,
insertion_pt, substring_start, substring_end, sel_start, sel_end,
@@ -1086,7 +1088,7 @@ int GLUI_TextBox::mouse_over( int state, int x, int y )
glutSetCursor( GLUT_CURSOR_TEXT );
}
else {
- /* printf( "OUT\n" ); */
+ debug( "OUT\n" );
glutSetCursor( GLUT_CURSOR_LEFT_ARROW );
}
diff --git a/src/glui_translation.cpp b/src/glui_translation.cpp
index f262809..c66bac2 100755
--- a/src/glui_translation.cpp
+++ b/src/glui_translation.cpp
@@ -41,12 +41,13 @@ GLUI_Translation::GLUI_Translation(
GLUI_Node *parent, const char *name,
int trans_t, float *value_ptr,
int id, GLUI_CB cb )
+ : GLUI_Mouse_Interaction (name)
{
common_init();
set_ptr_val( value_ptr );
user_id = id;
- set_name( name );
+ set_name( const_cast<char*>( name ) );
callback = cb;
parent->add_control( this );
//init_live();
diff --git a/src/glui_tree.cpp b/src/glui_tree.cpp
index 75735b7..6d16f22 100755
--- a/src/glui_tree.cpp
+++ b/src/glui_tree.cpp
@@ -31,13 +31,16 @@
/****************************** GLUI_Tree::GLUI_Tree() **********/
GLUI_Tree::GLUI_Tree(GLUI_Node *parent, const char *name,
- int open, int inset)
+ int open, int inset):
+ GLUI_Panel(name),
+ button("")
+
{
common_init();
GLUI_StaticText *inset_label;
GLUI_Column *col;
- this->set_name( name );
+ this->set_name( const_cast<char*>( name ));
this->user_id = -1;
if ( NOT open ) {
diff --git a/src/glui_treepanel.cpp b/src/glui_treepanel.cpp
index 4cbf8c1..945c50d 100755
--- a/src/glui_treepanel.cpp
+++ b/src/glui_treepanel.cpp
@@ -23,11 +23,12 @@
/****************************** GLUI_TreePanel::GLUI_TreePanel() *********/
GLUI_TreePanel::GLUI_TreePanel(GLUI_Node *parent, const char *name,
- bool open, int inset)
+ bool open, int inset) :
+ GLUI_Panel(name)
{
common_init();
- set_name( name );
+ set_name( const_cast<char*>(name) );
user_id = -1;
if ( !open ) {
@@ -182,8 +183,8 @@ void GLUI_TreePanel::formatNode(GLUI_Tree *temp)
return;
int level = temp->get_level();
int child_number = temp->get_child_number();
- GLUI_String level_name="";
- GLUI_String full_name="";
+ std::string level_name="";
+ std::string full_name="";
temp->level_name == "";
diff --git a/src/glui_window.cpp b/src/glui_window.cpp
old mode 100644
new mode 100755
diff --git a/src/include/GL/glui.h b/src/include/GL/glui.h
old mode 100644
new mode 100755
index 01a5c75..1f6b8fe
--- a/src/include/GL/glui.h
+++ b/src/include/GL/glui.h
@@ -38,6 +38,12 @@
// that come from old GLUT headers.
#include <cstdlib>
+#if defined(DEBUG)
+#define debug(message, ...) fprintf( stderr, __FILE__ ":%d:" message, __LINE__, ## __VA_ARGS__ )
+#else
+#define debug(message, ...)
+#endif
+
#if defined(GLUI_FREEGLUT)
// FreeGLUT does not yet work perfectly with GLUI
@@ -249,8 +255,7 @@ enum TranslationCodes
/************ A string type for us to use **********/
-typedef std::string GLUI_String;
-GLUIAPI GLUI_String& glui_format_str(GLUI_String &str, const char* fmt, ...);
+GLUIAPI std::string& glui_format_str(std::string &str, const char* fmt, ...);
/********* Pre-declare classes as needed *********/
@@ -336,14 +341,15 @@ class GLUI_Control;
Everything onscreen is a GLUI_Node--windows, buttons, etc.
The nodes are traversed for event processing, sizing, redraws, etc.
*/
-class GLUIAPI GLUI_Node
+class GLUIAPI GLUI_Node
{
friend class GLUI_Tree; /* JVK */
friend class GLUI_Rollout;
friend class GLUI_Main;
public:
- GLUI_Node();
+ GLUI_Node(const char* name);
+
virtual ~GLUI_Node() {}
GLUI_Node *first_sibling();
@@ -365,8 +371,12 @@ public:
void unlink();
void dump( FILE *out, const char *name );
+ const char* whole_tree(int start=1);
+ const char* NodeName;
+
protected:
+ GLUI_Node();
static void add_child_to_control(GLUI_Node *parent,GLUI_Control *child);
GLUI_Node *parent_node;
GLUI_Node *child_head;
@@ -667,7 +677,7 @@ protected:
/********** Misc functions *************/
- GLUI_Control *find_control( int x, int y );
+ GLUI_Control *find_control( int x, int y, GLUI_Control * parent=NULL );
GLUI_Control *find_next_control( GLUI_Control *control );
GLUI_Control *find_next_control_rec( GLUI_Control *control );
GLUI_Control *find_next_control_( GLUI_Control *control );
@@ -705,7 +715,7 @@ protected:
public:
GLUI_StdBitmaps std_bitmaps;
- GLUI_String window_name;
+ std::string window_name;
unsigned char bkgd_color[3];
float bkgd_color_f[3];
@@ -762,13 +772,13 @@ public:
checkboxes, labels, edit boxes, scrollbars, etc.
Most of the work of this class is in routing events,
like keystrokes, mouseclicks, redraws, and sizing events.
-
+
Yes, this is a huge and hideous class. It needs to be
split up into simpler subobjects. None of the data members
should be directly accessed by users (they should be protected,
not public); only subclasses.
*/
-class GLUIAPI GLUI_Control : public GLUI_Node
+class GLUIAPI GLUI_Control : public GLUI_Node
{
public:
@@ -777,9 +787,9 @@ public:
int x_abs, y_abs;
int x_off, y_off_top, y_off_bot; /* INNER margins, by which child
controls are indented */
- int contain_x, contain_y;
+ int contain_x, contain_y;
int contain_w, contain_h;
- /* if this is a container control (e.g.,
+ /* if this is a container control (e.g.,
radiogroup or panel) this indicated dimensions
of inner area in which controls reside */
@@ -788,7 +798,7 @@ public:
bool active; ///< If true, we've got the focus
bool can_activate; ///< If false, remove from tab order.
bool spacebar_mouse_click; ///< Spacebar simulates click.
-
+
/** Callbacks */
long user_id; ///< Integer to pass to callback function.
GLUI_CB callback; ///< User callback function, or NULL.
@@ -798,24 +808,24 @@ public:
int int_val; /**< Our integer value */
float float_array_val[GLUI_DEF_MAX_ARRAY];
int float_array_size;
- GLUI_String text; /**< The text inside this control */
-
+ std::string text; /**< The text inside this control */
+
/** "Live variable" updating */
void *ptr_val; /**< A pointer to the user's live variable value */
int live_type;
bool live_inited;
/* These variables store the last value that live variable was known to have. */
- int last_live_int;
+ int last_live_int;
float last_live_float;
- GLUI_String last_live_text;
+ std::string last_live_text;
float last_live_float_array[GLUI_DEF_MAX_ARRAY];
-
-/** Properties of our control */
+
+/** Properties of our control */
GLUI *glui; /**< Our containing event handler (NEVER NULL during event processing!) */
bool is_container; /**< Is this a container class (e.g., panel) */
int alignment;
bool enabled; /**< Is this control grayed out? */
- GLUI_String name; /**< The name of this control */
+ std::string name; /**< The name of this control */
void *font; /**< Our glutbitmap font */
bool collapsible, is_open;
GLUI_Node collapsed_node;
@@ -824,7 +834,7 @@ public:
public:
/*** Get/Set values ***/
- virtual void set_name( const char *string );
+ virtual void set_name( char *string );
virtual void set_int_val( int new_int ) { int_val = new_int; output_live(true); }
virtual void set_float_val( float new_float ) { float_val = new_float; output_live(true); }
virtual void set_ptr_val( void *new_ptr ) { ptr_val = new_ptr; output_live(true); }
@@ -846,7 +856,7 @@ public:
virtual void idle( void ) { }
virtual int mouse_over( int state, int x, int y ) { return false; }
- virtual void enable( void );
+ virtual void enable( void );
virtual void disable( void );
virtual void activate( int how ) { active = true; }
virtual void deactivate( void ) { active = false; }
@@ -871,30 +881,30 @@ public:
virtual void align( void );
void pack( int x, int y ); /* Recalculate positions and offsets */
- void pack_old( int x, int y );
+ void pack_old( int x, int y );
void draw_recursive( int x, int y );
int set_to_glut_window( void );
void restore_window( int orig );
void translate_and_draw_front( void );
- void translate_to_origin( void )
+ void translate_to_origin( void )
{glTranslatef((float)x_abs+.5,(float)y_abs+.5,0.0);}
virtual void draw( int x, int y )=0;
void set_font( void *new_font );
void *get_font( void );
int string_width( const char *text );
- int string_width( const GLUI_String &str )
+ int string_width( const std::string &str )
{ return string_width(str.c_str()); }
int char_width( char c );
void draw_name( int x, int y );
- void draw_box_inwards_outline( int x_min, int x_max,
+ void draw_box_inwards_outline( int x_min, int x_max,
int y_min, int y_max );
void draw_box( int x_min, int x_max, int y_min, int y_max,
float r, float g, float b );
void draw_bkgd_box( int x_min, int x_max, int y_min, int y_max );
void draw_emboss_box( int x_min, int x_max,int y_min,int y_max);
void draw_string( const char *text );
- void draw_string( const GLUI_String &s )
+ void draw_string( const std::string &s )
{ draw_string(s.c_str()); }
void draw_char( char c );
void draw_active_box( int x_min, int x_max, int y_min, int y_max );
@@ -908,13 +918,15 @@ public:
void output_live( int update_main_gfx ); /** Writes live variable **/
virtual void set_text( const char *t ) {}
void execute_callback( void );
- void get_this_column_dims( int *col_x, int *col_y,
- int *col_w, int *col_h,
+ void get_this_column_dims( int *col_x, int *col_y,
+ int *col_w, int *col_h,
int *col_x_off, int *col_y_off );
virtual bool needs_idle( void ) const;
virtual bool wants_tabs() const { return false; }
- GLUI_Control(void)
+ GLUI_Control(const char* name)
+ : GLUI_Node(name)
+ , collapsed_node("collapsed_node")
{
x_off = GLUI_XOFF;
y_off_top = GLUI_YOFF;
@@ -926,7 +938,6 @@ public:
int_val = 0;
last_live_int = 0;
float_array_size = 0;
- glui_format_str(name, "Control: %p", this);
float_val = 0.0;
last_live_float = 0.0;
ptr_val = NULL;
@@ -948,11 +959,15 @@ public:
hidden = false;
memset(char_widths, -1, sizeof(char_widths)); /* JVK */
int i;
+ set_name(const_cast<char*>(name));
for( i=0; i<GLUI_DEF_MAX_ARRAY; i++ )
float_array_val[i] = last_live_float_array[i] = 0.0;
}
virtual ~GLUI_Control();
+
+protected:
+ GLUI_Control();
};
/************************************************************/
@@ -991,7 +1006,7 @@ public:
*/
GLUI_Button( GLUI_Node *parent, const char *name,
int id=-1, GLUI_CB cb=GLUI_CB() );
- GLUI_Button( void ) { common_init(); };
+ GLUI_Button( const char* name ) : GLUI_Control(name) { common_init(); };
protected:
void common_init(void) {
@@ -1046,7 +1061,7 @@ public:
*/
GLUI_Checkbox(GLUI_Node *parent, const char *name, int *value_ptr=NULL,
int id=-1, GLUI_CB callback=GLUI_CB());
- GLUI_Checkbox( void ) { common_init(); }
+ GLUI_Checkbox( const char* name ) :GLUI_Control(name) { common_init(); }
protected:
void common_init(void) {
@@ -1083,7 +1098,7 @@ public:
@param draw_bar If true, draw a visible bar between new and old controls.
*/
GLUI_Column( GLUI_Node *parent, int draw_bar = true );
- GLUI_Column( void ) { common_init(); }
+ GLUI_Column( const char* name ): GLUI_Control(name) { common_init(); }
protected:
void common_init() {
@@ -1119,10 +1134,10 @@ public:
*/
GLUI_Panel( GLUI_Node *parent, const char *name,
int type=GLUI_PANEL_EMBOSSED );
- GLUI_Panel() { common_init(); }
+ GLUI_Panel(const char *name): GLUI_Control(name) { set_name( const_cast<char*>(name) ); common_init(); }
void draw( int x, int y );
- void set_name( const char *text );
+ void set_name( char *text );
void set_type( int new_type );
void update_size( void );
@@ -1169,7 +1184,7 @@ public:
GLUI_CB callback = GLUI_CB());
GLUI_List *list;
- GLUI_String current_dir;
+ std::string current_dir;
void fbreaddir(const char *);
static void dir_list_callback(GLUI_Control*);
@@ -1198,7 +1213,7 @@ protected:
private:
int last_item;
- GLUI_String file;
+ std::string file;
int allow_change_dir;
};
@@ -1230,7 +1245,7 @@ public:
*/
GLUI_Rollout( GLUI_Node *parent, const char *name, int open=true,
int type=GLUI_PANEL_EMBOSSED );
- GLUI_Rollout( void ) { common_init(); }
+ GLUI_Rollout( const char* name ): GLUI_Panel(name), button(name) { common_init(); }
bool currently_inside, initially_inside;
@@ -1294,7 +1309,7 @@ private:
public:
bool currently_inside, initially_inside;
GLUI_Button button;
- GLUI_String level_name; // level name, eg: 1.1.2, III, or 3
+ std::string level_name; // level name, eg: 1.1.2, III, or 3
GLUI_TreePanel *panel;
void draw( int x, int y );
@@ -1306,7 +1321,7 @@ public:
void open( void );
void close( void );
- /* void set_name( const char *text ) { panel.set_name( text ); }; */
+ /* void set_name( char *text ) { panel.set_name( text ); }; */
void update_size( void );
void set_id(int i) { id = i; }
void set_level(int l) { level = l; }
@@ -1420,7 +1435,7 @@ protected:
int uniqueID( void ) { next_id++; return next_id - 1; }
void common_init()
{
- GLUI_Panel();
+ GLUI_Panel("");
next_id = 0;
curr_root = this;
curr_branch = NULL;
@@ -1458,12 +1473,14 @@ public:
GLUI_RadioGroup
*add_radiogroup( int *live_var=NULL,
- int user_id=-1,GLUI_CB callback=GLUI_CB());
+ int user_id=-1,GLUI_CB callback=GLUI_CB(),
+ const char *name="Radio" );
GLUI_RadioGroup
*add_radiogroup_to_panel( GLUI_Panel *panel,
int *live_var=NULL,
- int user_id=-1, GLUI_CB callback=GLUI_CB() );
+ int user_id=-1, GLUI_CB callback=GLUI_CB(),
+ const char *name="Radio" );
GLUI_RadioButton
*add_radiobutton_to_group( GLUI_RadioGroup *group,
const char *name );
@@ -1488,41 +1505,41 @@ public:
int trans_type, float *live_var=NULL,
int id=-1, GLUI_CB callback=GLUI_CB());
- GLUI_Checkbox *add_checkbox( const char *name,
+ GLUI_Checkbox *add_checkbox( const char *name,
int *live_var=NULL,
int id=-1, GLUI_CB callback=GLUI_CB());
- GLUI_Checkbox *add_checkbox_to_panel( GLUI_Panel *panel, const char *name,
- int *live_var=NULL, int id=-1,
+ GLUI_Checkbox *add_checkbox_to_panel( GLUI_Panel *panel, const char *name,
+ int *live_var=NULL, int id=-1,
GLUI_CB callback=GLUI_CB());
- GLUI_Button *add_button( const char *name, int id=-1,
+ GLUI_Button *add_button( const char *name, int id=-1,
GLUI_CB callback=GLUI_CB());
- GLUI_Button *add_button_to_panel( GLUI_Panel *panel, const char *name,
+ GLUI_Button *add_button_to_panel( GLUI_Panel *panel, const char *name,
int id=-1, GLUI_CB callback=GLUI_CB() );
GLUI_StaticText *add_statictext( const char *name );
GLUI_StaticText *add_statictext_to_panel( GLUI_Panel *panel, const char *name );
- GLUI_EditText *add_edittext( const char *name,
+ GLUI_EditText *add_edittext( const char *name,
int data_type=GLUI_EDITTEXT_TEXT,
void*live_var=NULL,
int id=-1, GLUI_CB callback=GLUI_CB() );
- GLUI_EditText *add_edittext_to_panel( GLUI_Panel *panel,
+ GLUI_EditText *add_edittext_to_panel( GLUI_Panel *panel,
const char *name,
int data_type=GLUI_EDITTEXT_TEXT,
- void *live_var=NULL, int id=-1,
+ void *live_var=NULL, int id=-1,
GLUI_CB callback=GLUI_CB() );
- GLUI_EditText *add_edittext( const char *name, GLUI_String& live_var,
+ GLUI_EditText *add_edittext( const char *name, std::string& live_var,
int id=-1, GLUI_CB callback=GLUI_CB() );
- GLUI_EditText *add_edittext_to_panel( GLUI_Panel *panel, const char *name,
- GLUI_String& live_var, int id=-1,
+ GLUI_EditText *add_edittext_to_panel( GLUI_Panel *panel, const char *name,
+ std::string& live_var, int id=-1,
GLUI_CB callback=GLUI_CB() );
- GLUI_Spinner *add_spinner( const char *name,
+ GLUI_Spinner *add_spinner( const char *name,
int data_type=GLUI_SPINNER_INT,
void *live_var=NULL,
int id=-1, GLUI_CB callback=GLUI_CB() );
- GLUI_Spinner *add_spinner_to_panel( GLUI_Panel *panel,
+ GLUI_Spinner *add_spinner_to_panel( GLUI_Panel *panel,
const char *name,
int data_type=GLUI_SPINNER_INT,
void *live_var=NULL,
@@ -1530,13 +1547,13 @@ public:
GLUI_CB callback=GLUI_CB() );
GLUI_Panel *add_panel( const char *name, int type=GLUI_PANEL_EMBOSSED );
- GLUI_Panel *add_panel_to_panel( GLUI_Panel *panel, const char *name,
+ GLUI_Panel *add_panel_to_panel( GLUI_Panel *panel, const char *name,
int type=GLUI_PANEL_EMBOSSED );
GLUI_Rollout *add_rollout( const char *name, int open=true,
int type=GLUI_PANEL_EMBOSSED);
- GLUI_Rollout *add_rollout_to_panel( GLUI_Panel *panel, const char *name,
+ GLUI_Rollout *add_rollout_to_panel( GLUI_Panel *panel, const char *name,
int open=true,
int type=GLUI_PANEL_EMBOSSED);
@@ -1593,7 +1610,7 @@ class GLUIAPI GLUI_EditText : public GLUI_Control
public:
int has_limits;
int data_type;
- GLUI_String orig_text;
+ std::string orig_text;
int insertion_pt;
int title_x_offset;
int text_x_offset;
@@ -1639,7 +1656,7 @@ public:
void set_float_val( float new_val );
void set_int_val( int new_val );
void set_text( const char *text );
- void set_text( const GLUI_String &s) { set_text(s.c_str()); }
+ void set_text( const std::string &s) { set_text(s.c_str()); }
const char *get_text() { return text.c_str(); }
void dump( FILE *out, const char *text );
@@ -1670,7 +1687,7 @@ public:
int text_type, void *live_var,
int id, GLUI_CB callback );
// Deprecated constructor, only called internally
- GLUI_EditText( void ) { common_init(); }
+ GLUI_EditText( const char* name ) : GLUI_Control(name) { common_init(); }
protected:
void common_init( void ) {
@@ -1715,11 +1732,11 @@ public:
#ifdef _MSC_VER
// Explicit template instantiation needed for dll
- template class GLUIAPI std::allocator<GLUI_String>;
- template class GLUIAPI std::vector<GLUI_String, std::allocator<GLUI_String> >;
+ template class GLUIAPI std::allocator<std::string>;
+ template class GLUIAPI std::vector<std::string, std::allocator<std::string> >;
#endif
- std::vector<GLUI_String> hist_list;
+ std::vector<std::string> hist_list;
int curr_hist;
int oldest_hist;
int newest_hist;
@@ -1732,9 +1749,9 @@ public:
virtual const char *get_history( int command_number ) const
{ return hist_list[command_number - oldest_hist].c_str(); }
- virtual GLUI_String& get_history_str( int command_number )
+ virtual std::string& get_history_str( int command_number )
{ return hist_list[command_number - oldest_hist]; }
- virtual const GLUI_String& get_history_str( int command_number ) const
+ virtual const std::string& get_history_str( int command_number ) const
{ return hist_list[command_number - oldest_hist]; }
virtual void recall_history( int history_number );
virtual void scroll_history( int direction );
@@ -1746,7 +1763,7 @@ public:
GLUI_CommandLine( GLUI_Node *parent, const char *name, void *live_var=NULL,
int id=-1, GLUI_CB callback=GLUI_CB() );
- GLUI_CommandLine( void ) { common_init(); }
+ GLUI_CommandLine( const char* name ) : GLUI_EditText (name) { common_init(); }
protected:
void common_init() {
hist_list.resize(HIST_SIZE);
@@ -1770,15 +1787,16 @@ public:
int num_buttons;
void draw( int x, int y );
- void set_name( const char *text );
+ void set_name( char *text );
void set_int_val( int int_val );
void set_selected( int int_val );
void draw_group( int translate );
GLUI_RadioGroup( GLUI_Node *parent, int *live_var=NULL,
- int user_id=-1,GLUI_CB callback=GLUI_CB() );
- GLUI_RadioGroup( void ) { common_init(); }
+ int user_id=-1,GLUI_CB callback=GLUI_CB(),
+ const char* name="radioG" );
+ GLUI_RadioGroup( const char* name ): GLUI_Control(name) { common_init(); }
protected:
void common_init( void ) {
@@ -1848,7 +1866,7 @@ public:
void draw( int x, int y );
GLUI_Separator( GLUI_Node *parent );
- GLUI_Separator( void ) { common_init(); }
+ GLUI_Separator( const char* name ): GLUI_Control(name) { common_init(); }
protected:
void common_init() {
@@ -1893,7 +1911,7 @@ public:
void *live_var,
int id=-1, GLUI_CB callback=GLUI_CB() );
// Deprecated constructor
- GLUI_Spinner( void ) { common_init(); }
+ GLUI_Spinner( const char* name ): GLUI_Control(name) { common_init(); }
bool currently_inside;
int state;
@@ -1971,14 +1989,14 @@ protected:
class GLUIAPI GLUI_StaticText : public GLUI_Control
{
public:
- void set_text( const char *text );
+ void set_text( char *text );
void draw( int x, int y );
void draw_text( void );
void update_size( void );
void erase_text( void );
GLUI_StaticText(GLUI_Node *parent, const char *name);
- GLUI_StaticText( void ) { common_init(); }
+ GLUI_StaticText( const char* name ): GLUI_Control(name) { common_init(); }
protected:
void common_init() {
@@ -1998,13 +2016,14 @@ class GLUIAPI GLUI_TextBox : public GLUI_Control
{
public:
/* GLUI Textbox - JVK */
- GLUI_TextBox(GLUI_Node *parent, GLUI_String &live_var,
+ GLUI_TextBox( GLUI_Node *parent, const char* name, std::string &live_var,
bool scroll = false, int id=-1, GLUI_CB callback=GLUI_CB() );
GLUI_TextBox( GLUI_Node *parent,
+ const char* name,
bool scroll = false, int id=-1,
GLUI_CB callback=GLUI_CB() );
- GLUI_String orig_text;
+ std::string orig_text;
int insertion_pt;
int substring_start; /*substring that gets displayed in box*/
int substring_end;
@@ -2061,6 +2080,7 @@ public:
bool wants_tabs( void ) const { return true; }
protected:
+
void common_init()
{
h = GLUI_TEXTBOX_HEIGHT;
@@ -2087,8 +2107,8 @@ protected:
draw_text_only = false;
}
void common_construct(
- GLUI_Node *parent, GLUI_String *live_var,
- bool scroll, int id, GLUI_CB callback);
+ GLUI_Node *parent, std::string *live_var,
+ bool scroll, int id, GLUI_CB callback);
};
/************************************************************/
@@ -2097,10 +2117,10 @@ protected:
/* */
/************************************************************/
-class GLUIAPI GLUI_List_Item : public GLUI_Node
+class GLUIAPI GLUI_List_Item : public GLUI_Node
{
public:
- GLUI_String text;
+ std::string text;
int id;
};
@@ -2114,20 +2134,21 @@ class GLUIAPI GLUI_List : public GLUI_Control
{
public:
/* GLUI List - JVK */
- GLUI_List( GLUI_Node *parent, bool scroll = false,
+ GLUI_List( GLUI_Node *parent, const char* name, bool scroll = false,
int id=-1, GLUI_CB callback=GLUI_CB() );
- /*, GLUI_Control *object = NULL
+ /*, GLUI_Control *object = NULL
,GLUI_InterObject_CB obj_cb = NULL);*/
GLUI_List( GLUI_Node *parent,
- GLUI_String& live_var, bool scroll = false,
- int id=-1,
+ const char* name,
+ std::string& live_var, bool scroll = false,
+ int id=-1,
GLUI_CB callback=GLUI_CB()
/*,GLUI_Control *object = NULL */
/*,GLUI_InterObject_CB obj_cb = NULL*/);
- GLUI_String orig_text;
+ std::string orig_text;
int debug;
int draw_text_only;
int start_line;
@@ -2204,7 +2225,7 @@ protected:
};
void common_construct(
GLUI_Node *parent,
- GLUI_String* live_var, bool scroll,
+ std::string* live_var, bool scroll,
int id,
GLUI_CB callback
/*,GLUI_Control *object*/
@@ -2333,14 +2354,14 @@ protected:
class GLUIAPI GLUI_Listbox_Item : public GLUI_Node
{
public:
- GLUI_String text;
+ std::string text;
int id;
};
class GLUIAPI GLUI_Listbox : public GLUI_Control
{
public:
- GLUI_String curr_text;
+ std::string curr_text;
GLUI_Listbox_Item items_list;
int depressed;
@@ -2376,7 +2397,7 @@ public:
GLUI_Listbox( GLUI_Node *parent,
const char *name, int *live_var=NULL,
int id=-1, GLUI_CB callback=GLUI_CB() );
- GLUI_Listbox( void ) { common_init(); }
+ GLUI_Listbox( const char* name ):GLUI_Control(name) { common_init(); }
protected:
/** Change w and return true if we need to be widened to fit the current item. */
@@ -2432,8 +2453,7 @@ public:
virtual void iaction_dump( FILE *output )=0;
virtual void iaction_init( void ) = 0;
- GLUI_Mouse_Interaction( void ) {
- glui_format_str( name, "Mouse_Interaction: %p", this );
+ GLUI_Mouse_Interaction( const char* name ) : GLUI_Control(name) {
w = GLUI_MOUSE_INTERACTION_WIDTH;
h = GLUI_MOUSE_INTERACTION_HEIGHT;
can_activate = true;
@@ -2492,7 +2512,7 @@ public:
GLUI_Rotation( GLUI_Node *parent, const char *name, float *live_var=NULL,
int id=-1, GLUI_CB callback=GLUI_CB() );
- GLUI_Rotation(void) { common_init(); }
+ GLUI_Rotation(const char* name): GLUI_Mouse_Interaction(name) { common_init(); }
protected:
void common_init();
@@ -2558,7 +2578,7 @@ public:
GLUI_Translation( GLUI_Node *parent, const char *name,
int trans_type, float *live_var=NULL,
int id=-1, GLUI_CB callback=GLUI_CB() );
- GLUI_Translation( void ) { common_init(); }
+ GLUI_Translation( const char* name ) : GLUI_Mouse_Interaction(name) { common_init(); }
protected:
void common_init() {
diff --git a/src/makefile b/src/makefile
index eb22251..69ec239 100755
--- a/src/makefile
+++ b/src/makefile
@@ -5,9 +5,10 @@
#CC=gcc
# Compiler options
-OPTS=-g
-OPTS=-O0
-#OPTS=-O2
+OPTS+=-g
+OPTS+=-O0
+#OPTS+=-O2
+OPTS+=-DDEBUG
UNAME = $(shell uname)
@@ -18,7 +19,7 @@ endif
#######################################
-CPPFLAGS += -I./ -I./include
+CPPFLAGS += -I./ -I./include $(OPTS)
LIBGLUI = -L./lib -lglui
LIBGL = -lGLU -lGL
diff --git a/src/msvc/README.txt b/src/msvc/README.txt
old mode 100644
new mode 100755
diff --git a/src/msvc/gluidll.vcproj b/src/msvc/gluidll.vcproj
old mode 100644
new mode 100755
diff --git a/src/tools/ppm.cpp b/src/tools/ppm.cpp
old mode 100644
new mode 100755
diff --git a/src/tools/ppm.h b/src/tools/ppm.h
old mode 100644
new mode 100755
diff --git a/src/tools/ppm2array.cpp b/src/tools/ppm2array.cpp
old mode 100644
new mode 100755
diff --git a/src/viewmodel.cpp b/src/viewmodel.cpp
old mode 100644
new mode 100755
diff --git a/www/image1.png b/www/image1.png
old mode 100644
new mode 100755
diff --git a/www/index.html b/www/index.html
old mode 100644
new mode 100755
diff --git a/www/screen2.png b/www/screen2.png
old mode 100644
new mode 100755
diff --git a/www/screen3.png b/www/screen3.png
old mode 100644
new mode 100755
diff --git a/www/screen4.png b/www/screen4.png
old mode 100644
new mode 100755
diff --git a/www/title.jpg b/www/title.jpg
old mode 100644
new mode 100755
diff --git a/www/valid-html401.png b/www/valid-html401.png
old mode 100644
new mode 100755