Exemplo n.º 1
0
GLUI_RadioGroup::GLUI_RadioGroup(GLUI_Node *parent,
                                 int *value_ptr,
                                 int id, GLUI_CB cb)
{
  common_init();
  GLUI_String      buf;

  set_ptr_val( value_ptr );
  if ( value_ptr ) {
    int_val = *value_ptr;  /** Can't call set_int_val(), b/c that 
                               function will try to call the 
                               callback, etc */
    /** Actually, maybe not **/
    last_live_int = *value_ptr;
  }

  user_id    = id;
  glui_format_str( buf, "RadioGroup: %p", this );
  set_name( buf.c_str() );
  callback   = cb;

  parent->add_control( this );

  init_live();
}
Exemplo n.º 2
0
void   GLUI_EditText::dump( FILE *out, const GLUI_String &name )
{
  const GLUI_String buffer = tfm::format(
    "%s (edittext@%p):  ins_pt:%d  subs:%d/%d  sel:%d/%d   len:%d\n",
    name, this,
    insertion_pt,
    substring_start,
    substring_end,
    sel_start,
    sel_end,
    text.length());
  fprintf(out, "%s", buffer.c_str());
}
Exemplo n.º 3
0
static void load_psf_texture_glui(int sel){
	char current[LENGTHBUF];
	char file_name[LENGTHBUF];
	char file_head[LENGTHBUF];
	char img_ext[LENGTHBUF];
	int ext_fmt;
	
	getcwd(current, sizeof(current));
	
	strcpy(file_name, current);
	strcat(file_name, "/");
	strcat(file_name, text_fname.c_str());
	
	get_ext_from_file_name(file_name, file_head, img_ext);
	ext_fmt = set_image_file_format_id(img_ext);
	
	if(ext_fmt == SAVE_PNG || ext_fmt == SAVE_BMP){
		set_texture_current_psf(ext_fmt, file_head);
		set_current_psf_patch_color_mode(TEXTURED_SURFACE);
	};
	
	draw_mesh_w_menu();
	
	GLUI_Master.close_all();
	return;
};
static void load_viewmatrix_glui(int sel){
	char current[LENGTHBUF];
	char file_name[LENGTHBUF];
	char file_head[LENGTHBUF];
	char img_ext[LENGTHBUF];
	int ext_fmt;
	
	getcwd(current, sizeof(current));
	
	strcpy(file_name, current);
	strcat(file_name, "/");
	strcat(file_name, text_fname.c_str());
	
	kemoview_load_modelview_file(file_name);
	
	draw_mesh_w_menu();
	
	GLUI_Master.close_all();
	return;
};
Exemplo n.º 5
0
static void init_kemoview_data_glui(int val){
	char current[LENGTHBUF];
	char file_name[LENGTHBUF];
	char file_head[LENGTHBUF];
	char file_ext[LENGTHBUF];
	int iflag_datatype;
	
	getcwd(current, sizeof(current));
	
	strcpy(file_name, current);
	strcat(file_name, "/");
	strcat(file_name, text_fname.c_str());
	
	get_ext_from_file_name(file_name, file_head, file_ext);
	printf("file name: %s\n", file_name);
	printf("file_head %s\n", file_head);
	printf("file_ext %s\n", file_ext);
	
	iflag_datatype = kemoview_open_data_glut(file_name);
	
	GLUI_Master.close_all();
	draw_mesh_w_menu();
	return;
};
Exemplo n.º 6
0
void GLUI_FileBrowser::fbreaddir(const char *d) {
  GLUI_String item;
  int i = 0;

	if (!d)
    return;

#ifdef _WIN32

  WIN32_FIND_DATA FN;
  HANDLE hFind;
  //char search_arg[MAX_PATH], new_file_path[MAX_PATH];
  //sprintf(search_arg, "%s\\*.*", path_name);

  hFind = FindFirstFile("*.*", &FN);
  if (list) {
    list->delete_all();
    if (hFind != INVALID_HANDLE_VALUE) {
      do {
        int len = strlen(FN.cFileName);
        if (FN.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
          item = '\\';
          item += FN.cFileName;
        } else {
          item = FN.cFileName;
        }
        list->add_item(i,item.c_str());
        i++;
      } while (FindNextFile(hFind, &FN) != 0);

      if (GetLastError() == ERROR_NO_MORE_FILES)
        FindClose(hFind);
      else
        perror("fbreaddir");
    }
  }

#elif defined(__GNUC__)

  DIR *dir;
  struct dirent *dirp;
  struct stat dr;

  if (list) {
    list->delete_all();
    if ((dir = opendir(d)) == NULL)
      perror("fbreaddir:");
    else {
      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("/");
        else
          item = dirp->d_name;

        list->add_item(i,item.c_str());
        i++;
      }
      closedir(dir);
    }
  }
#endif
}
Exemplo n.º 7
0
void control_cb(int control) {
  int item;
  GLUI_String text;
  std::string file_name;
  FILE  *file;
  char c;
  int i;
  int format;
  glutPostRedisplay();
  item = hah->get_current_item();

  if (control == 7) {
    i = 0;
    file_name = "";
    file_name = fb->get_file();
    file = fopen(file_name.c_str(),"r");
    if (file == NULL)
      printf("Error opening file\n");
    else {
      do {
        c = getc(file);
        text += c;
        i++;
      } while (c != EOF);
      fclose(file);
    }

    moo->set_text(text.c_str());
  }


  if ( control == 1 ) {
    tree->hide();
    if (item==0) {
      moo->set_text(general);
    }
    if (item==1) {
      moo->set_text(text_box);
    }
    if (item==2) {
      moo->set_text(scroll);
    }
    if (item==3) {
      moo->set_text(gstring);
    }
    if (item==4) {
      moo->set_text(commandline);
    }
    if (item==5) {
      tree->show();
      moo->set_text(tree_txt);
    }
    if (item==6) {
      moo->set_text(list);
    }
    if (item==7) {
      moo->set_text(filebrowser);
    }
  }
  if ( control == 2) {
    tp->ab("foo");
  }
  if ( control == 3) {
      tp->db();
  }
  if ( control == 4) {
    tp->fb();
  }
  if ( control == 5) {
      tp->resetToRoot();
  }
  if ( control == 6) {
      tp->descendBranch();
  }
  if ( control == 8) {
      tp->next();
  }
  if ( control == 9) {
      tp->expand_all();
  }
  if ( control == 10) {
      tp->collapse_all();
  }
  if ( control == 11) {
    format = 0;
    format = GLUI_TREEPANEL_ALTERNATE_COLOR |
      GLUI_TREEPANEL_CONNECT_CHILDREN_ONLY;

    if (num_display)
      format = format | GLUI_TREEPANEL_DISPLAY_HIERARCHY;
    if (num_format)
      format = format | GLUI_TREEPANEL_HIERARCHY_NUMERICDOT;
    else
      format = format | GLUI_TREEPANEL_HIERARCHY_LEVEL_ONLY;
    tp->set_format(format);
    tp->update_all();
  }
  if (control == 12) {
    if (enable_textbox) {
      moo->enable();
    } else {
      moo->disable();
    }
  }
}