示例#1
0
void    GLUI_RadioGroup::draw_group( int translate )
{
  GLUI_DRAWINGSENTINAL_IDIOM
  GLUI_RadioButton *button;
  this->int_val = int_val;

  glMatrixMode(GL_MODELVIEW );

  button = (GLUI_RadioButton*) first_child();
  while( button != NULL ) {
    glPushMatrix();
    if (translate) {
      button->translate_to_origin();
    }
    else {
      glTranslatef(button->x_abs-x_abs,
                   button->y_abs-y_abs,0.0);
    }

    if ( button->int_val ) 
      button->draw_checked();
    else 
      button->draw_unchecked();
    
    glPopMatrix();

    button = (GLUI_RadioButton*) button->next();
  }
}
示例#2
0
void    GLUI_RadioGroup::draw()
{
  if ( NOT can_draw() )
    return;
  GLUI_DRAWINGSENTINAL_IDIOM
  GLUI_RadioButton *button;
  this->int_val = int_val;

  glMatrixMode(GL_MODELVIEW );

  button = (GLUI_RadioButton*) first_child();
  while( button != NULL ) {
    if ( button->int_val )
      button->draw_checked();
    else
      button->draw_unchecked();
    button = (GLUI_RadioButton*) button->next();
  }

}
void    GLUI_RadioGroup::draw_group( int translate )
{
  GLUI_RadioButton *button;
  int               state, orig;

  if ( NOT can_draw() )
    return;

  orig = set_to_glut_window();

  if ( translate )
    state = glui->set_front_draw_buffer();

  this->int_val = int_val;

  glMatrixMode(GL_MODELVIEW );

  button = (GLUI_RadioButton*) first_child();
  while( button != NULL ) {
    
    if ( translate ) {
      glPushMatrix();
      button->translate_to_origin();
    }

    if ( button->int_val ) 
      button->draw_checked();
    else 
      button->draw_unchecked();
    
    if ( translate )
      glPopMatrix();

    button = (GLUI_RadioButton*) button->next();
  }

  if ( translate )
    glui->restore_draw_buffer(state);

  restore_window(orig);
}
示例#4
0
void    GLUI_RadioGroup::set_selected( int int_val )
{
  GLUI_RadioButton *button;

  this->int_val = int_val;

  button = (GLUI_RadioButton*) first_child();
  while( button != NULL ) {
    if ( int_val == -1 ) {       /*** All buttons in group are deselected ***/
      button->set_int_val(0);
    }
    else if ( int_val == button->user_id ) { /*** This is selected button ***/
      button->set_int_val(1);
    }
    else {                               /*** This is NOT selected button ***/
      button->set_int_val(0);

    }
    button = (GLUI_RadioButton*) button->next();
  }
  glutPostRedisplay();
}
示例#5
0
GLUI_RadioButton *GLUI::add_radiobutton_to_group(  GLUI_RadioGroup *group,
						   char *name )
{
  GLUI_RadioButton *control;

  if ( group->type != GLUI_CONTROL_RADIOGROUP ) {
    /*fprintf( stderr, "ERROR: Trying to add radiobutton to non-radiogroup\n" );              */
    /*fflush( stderr );              */
    return NULL;
  }

  control = new GLUI_RadioButton;

  if ( control ) {
    control->set_int_val( 0 );
    /*int_val = 0;              */

    /** A radio button's user id is always its ordinal number (zero-indexed)
      within the group */
    control->user_id    = group->num_buttons;
    group->num_buttons++;   /* Increments radiogroup's button count */
    control->set_name( name );
    control->group = group;

    add_control( group, control );

    /*** Now update button states ***/
    group->set_int_val( group->int_val ); /* This tells the group to
					     reset itself to its
					     current value, thereby
					     updating all its buttons */

    return control;
  }
  else {
    return NULL;
  }

}