void GLUI_Control::draw_box( int x_min, int x_max, int y_min, int y_max, float r, float g, float b) { if ( r == 1.0 AND g == 1.0 AND b == 1.0 AND NOT enabled AND glui ) { draw_bkgd_box( x_min, x_max, y_min, y_max ); return; } glColor3f( r, g, b ); glBegin( GL_QUADS ); glVertex2i( x_min, y_min ); glVertex2i( x_max, y_min ); glVertex2i( x_max, y_max ); glVertex2i( x_min, y_max ); glEnd(); }
void GLUI_Slider::draw( int x, int y ) { int orig; if ( NOT glui ) return; orig = set_to_glut_window(); draw_emboss_box( 0, w, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - 1 - GLUI_SLIDER_FONT_MID_HEIGHT, h ); draw_bkgd_box( GLUI_SLIDER_NAME_INDENT-1, GLUI_SLIDER_NAME_INDENT + string_width(name.string) + 2*GLUI_SLIDER_NAME_SIDE_BORDER - 1, 0, 0 + GLUI_SLIDER_FONT_FULL_HEIGHT + GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_NAME_BOTTOM_BORDER); draw_name( GLUI_SLIDER_NAME_INDENT + GLUI_SLIDER_NAME_SIDE_BORDER, GLUI_SLIDER_FONT_HEIGHT-1 + GLUI_SLIDER_NAME_TOP_BORDER); draw_active_area(); restore_window(orig); draw_active_box( GLUI_SLIDER_NAME_INDENT, GLUI_SLIDER_NAME_INDENT + string_width(name.string) + 2*GLUI_SLIDER_NAME_SIDE_BORDER - 1, 0, GLUI_SLIDER_FONT_FULL_HEIGHT + GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_NAME_BOTTOM_BORDER - 1); }
void GLUI_Graph::draw( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM; draw_emboss_box( 0, w, GLUI_GRAPH_NAME_TOP_BORDER + GLUI_GRAPH_FONT_HEIGHT - 1 - GLUI_GRAPH_FONT_MID_HEIGHT, h ); draw_bkgd_box( GLUI_GRAPH_NAME_INDENT-1, GLUI_GRAPH_NAME_INDENT + string_width(name) + 2*GLUI_GRAPH_NAME_SIDE_BORDER - 1, 0, 0 + GLUI_GRAPH_FONT_FULL_HEIGHT + GLUI_GRAPH_NAME_TOP_BORDER + GLUI_GRAPH_NAME_BOTTOM_BORDER); draw_name( GLUI_GRAPH_NAME_INDENT + GLUI_GRAPH_NAME_SIDE_BORDER, GLUI_GRAPH_FONT_HEIGHT-1 + GLUI_GRAPH_NAME_TOP_BORDER); draw_active_area(); draw_active_box( GLUI_GRAPH_NAME_INDENT, GLUI_GRAPH_NAME_INDENT + string_width(name) + 2*GLUI_GRAPH_NAME_SIDE_BORDER - 1, 0, GLUI_GRAPH_FONT_FULL_HEIGHT + GLUI_GRAPH_NAME_TOP_BORDER + GLUI_GRAPH_NAME_BOTTOM_BORDER - 1); }
void GLUI_Slider::draw_slider( void ) { int min_x; int max_x; int wid_x; float min_val; float max_val; float val; int x_pos; draw_bkgd_box( 2 + GLUI_SLIDER_KNOB_SIDE_BORDER - 1, w-2 - GLUI_SLIDER_KNOB_SIDE_BORDER, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - GLUI_SLIDER_FONT_MID_HEIGHT + GLUI_SLIDER_VAL_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT + GLUI_SLIDER_KNOB_TOP_BORDER+1, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - GLUI_SLIDER_FONT_MID_HEIGHT + GLUI_SLIDER_VAL_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT + GLUI_SLIDER_KNOB_TOP_BORDER + 1+ 2*GLUI_SLIDER_KNOB_HALF_HEIGHT + 1); draw_emboss_box( 2 + GLUI_SLIDER_KNOB_SIDE_BORDER + GLUI_SLIDER_KNOB_HALF_WIDTH, w - 2 - GLUI_SLIDER_KNOB_HALF_WIDTH - GLUI_SLIDER_KNOB_SIDE_BORDER, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - GLUI_SLIDER_FONT_MID_HEIGHT + GLUI_SLIDER_VAL_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT + GLUI_SLIDER_KNOB_TOP_BORDER + GLUI_SLIDER_KNOB_HALF_HEIGHT, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - GLUI_SLIDER_FONT_MID_HEIGHT + GLUI_SLIDER_VAL_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT + GLUI_SLIDER_KNOB_TOP_BORDER + GLUI_SLIDER_KNOB_HALF_HEIGHT + 3); min_x = 2 + GLUI_SLIDER_KNOB_SIDE_BORDER + GLUI_SLIDER_KNOB_HALF_WIDTH; max_x = w - 2 - GLUI_SLIDER_KNOB_HALF_WIDTH - GLUI_SLIDER_KNOB_SIDE_BORDER; wid_x = max_x - min_x + 1; switch (data_type) { case GLUI_SLIDER_INT: min_val = (float)int_low; max_val = (float)int_high; val = (float)int_val; break; case GLUI_SLIDER_FLOAT: min_val = float_low; max_val = float_high; val = float_val; break; default: fprintf(stderr,"GLUI_Slider::draw_val - Impossible data type!\n"); abort(); break; } if (max_val == min_val) x_pos = min_x; else { if (val == max_val) x_pos = max_x; else x_pos = (int) (min_x + wid_x*((val-min_val)/(max_val-min_val))); } draw_knob(x_pos,0,0,0,0,glui->bkgd_color[0], glui->bkgd_color[1], glui->bkgd_color[2]); draw_knob(x_pos,1,0,1,0, GLUI_SLIDER_KNOB_BLACK, GLUI_SLIDER_KNOB_BLACK, GLUI_SLIDER_KNOB_BLACK); draw_knob(x_pos,0,1,0,1, GLUI_SLIDER_KNOB_WHITE, GLUI_SLIDER_KNOB_WHITE, GLUI_SLIDER_KNOB_WHITE); if (pressed) draw_knob(x_pos,1,1,1,1, GLUI_SLIDER_KNOB_GREY, GLUI_SLIDER_KNOB_GREY, GLUI_SLIDER_KNOB_GREY); else draw_knob(x_pos,1,1,1,1,glui->bkgd_color[0], glui->bkgd_color[1], glui->bkgd_color[2]); draw_knob(x_pos,2,1,2,1, GLUI_SLIDER_KNOB_D_GREY, GLUI_SLIDER_KNOB_D_GREY, GLUI_SLIDER_KNOB_D_GREY); if (pressed) draw_knob(x_pos,2,2,2,2, GLUI_SLIDER_KNOB_L_GREY, GLUI_SLIDER_KNOB_L_GREY, GLUI_SLIDER_KNOB_L_GREY); else draw_knob(x_pos,2,2,2,2, GLUI_SLIDER_KNOB_GREY, GLUI_SLIDER_KNOB_GREY, GLUI_SLIDER_KNOB_GREY); }
void GLUI_Slider::draw_val( void ) { int max_w, i; char buf[GLUI_SLIDER_MAX_VAL_STRING_SIZE]; switch (data_type) { case GLUI_SLIDER_INT: sprintf(buf,"%d", int_val); break; case GLUI_SLIDER_FLOAT: sprintf(buf,"%.7g", float_val); break; default: fprintf(stderr,"GLUI_Slider::draw_val - Impossible data type!\n"); abort(); } max_w = w +1 - (GLUI_SLIDER_NAME_INDENT + string_width(name) + 2*GLUI_SLIDER_NAME_SIDE_BORDER + 2*GLUI_SLIDER_VAL_SIDE_BORDER + 2); if (max_w < string_width(GLUI_SLIDER_TRUNCATE_STRING)) { fprintf(stderr,"GLUI_Slider::draw_val - Impossible max_w!!!!\n"); abort(); } if (string_width(buf) > max_w) { max_w -= string_width(GLUI_SLIDER_TRUNCATE_STRING); i = strlen(buf)-1; while ((string_width(buf) > max_w) && (i>=0)) { buf[i--] = 0; } sprintf(&buf[i+1],"%s",GLUI_SLIDER_TRUNCATE_STRING); } draw_bkgd_box( GLUI_SLIDER_NAME_INDENT + string_width(name) + 2*GLUI_SLIDER_NAME_SIDE_BORDER + GLUI_SLIDER_VAL_SIDE_BORDER - 1, w-1 - GLUI_SLIDER_VAL_SIDE_BORDER, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - GLUI_SLIDER_FONT_MID_HEIGHT + GLUI_SLIDER_VAL_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT + 1, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - GLUI_SLIDER_FONT_MID_HEIGHT + GLUI_SLIDER_VAL_TOP_BORDER + 1 ); glColor3b( 0, 0, 0 ); glRasterPos2i( w - string_width(buf) - GLUI_SLIDER_VAL_SIDE_BORDER, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - GLUI_SLIDER_FONT_MID_HEIGHT + GLUI_SLIDER_VAL_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT); draw_string(buf); }