void initialize(void) { int i; const char* p; add_preprocessor_option(yes, "-I%s", get_preference("RESOURCES_FOLDER")); root.numwindows = 0; root.messages.line = NULL; root.gldesc.max_screen_x = glutGet(GLUT_SCREEN_WIDTH); if (root.gldesc.max_screen_x <= 0) root.gldesc.max_screen_x = 1024; root.gldesc.max_screen_y = glutGet(GLUT_SCREEN_HEIGHT); if (root.gldesc.max_screen_y <= 0) root.gldesc.max_screen_y = 768; root.gldesc.max_screen_x -= 10; root.gldesc.max_screen_y -= 30; if (is_preference_on(get_preference("MULTIPLE_SCREENS")) == no) glueSetConstrainedWindows(yes); else glueSetConstrainedWindows(no); if (is_preference_on(get_preference("MULTIPLE_SCREENS")) == no) open_main_window(); init_global_lighting(); if (make_selectors() == code_bad) error(exit_program,tool_message); /* Initialize some root structure variables */ root.nummodels = 0; root.numplots = 0; root.numtools = 0; root.currentwindow = NO_WINDOW; root.modelcount = 0; root.confirm_window_open = no; root.gfont.defaultfont = SIMM_DEFAULT_FONT; root.gfont.largefont = SIMM_LARGE_FONT; root.gfont.smallfont = SIMM_SMALL_FONT; root.gfont.italics = SIMM_ITALIC_FONT; root.gfont.bold = SIMM_BOLD_FONT; /* Set all the plot pointers to NULL */ for (i=0; i<PLOTBUFFER; i++) gPlot[i] = NULL; /* Set all the model pointers to NULL */ for (i=0; i<MODELBUFFER; i++) gModel[i] = NULL; /* Set all the tool structures to unused */ for (i=0; i<TOOLBUFFER; i++) { tool[i].used = no; tool[i].name = NULL; } /* Make the [initially empty] model menu */ root.modelmenu = -1; root.plotmenu = -1; root.gravityMenu = glueCreateMenu("Gravity"); glueAddMenuEntryWithValue(root.gravityMenu, " +X", smX); glueAddMenuEntryWithValue(root.gravityMenu, " -X", smNegX); glueAddMenuEntryWithValue(root.gravityMenu, " +Y", smY); glueAddMenuEntryWithValue(root.gravityMenu, " -Y", smNegY); glueAddMenuEntryWithValue(root.gravityMenu, " +Z", smZ); glueAddMenuEntryWithValue(root.gravityMenu, " -Z", smNegZ); glueAddMenuEntryWithValue(root.gravityMenu, "none", smNoAlign); /* Init the command list */ root.num_commands = 0; for (i=0; i<COMMAND_BUFFER; i++) root.command[i] = NULL; updatemodelmenu(); /* Call routines to make the color map */ init_color_database(); /* Make the confirm-action menu */ make_confirm_menu(); /* Malloc the SIMM event queue */ root.simm_event_queue = (SimmEvent*)simm_malloc(EVENT_QUEUE_SIZE*sizeof(SimmEvent)); if (root.simm_event_queue == NULL) error(exit_program,tool_message); root.event_queue_length = EVENT_QUEUE_SIZE; root.events_in_queue = 0; }
/* DELETE_MODEL: this routine deletes a model from the system. It closes the * model window, frees the model structures, deletes the model window from * the window list, updates the pop-up model menu, and checks to make sure * no tools are currently set to the model. */ void delete_model(ModelStruct* ms) { int i, j; char buf[1024]; MotionModelOptions* mmo; Scene* scene = get_first_scene_containing_model(ms); if (is_model_realtime(ms) == rtMocap) { #if INCLUDE_EVA_REALTIME stop_realtime_mocap_stream(); #endif } else if (is_model_realtime(ms) == rtSimulation) { #if ! SIMM_VIEWER // DPTODO #endif } glutDeleteMutex(ms->modelLock); glutSetWindow(scene->window_glut_id); /* Post the MODEL_DELETED event before deleting the motions * (which will post MOTION_DELETED events for each one). This * requires more checking by each tool when handling a * MOTION_DELETED event (to see if the model still exists or * not), but is more efficient because the tool will not * update itself for each motion deleted and then update itself * again when the whole model is deleted. * The model pointer is included in the MODEL_DELETED event so * that the tools can check to see if they are currently set to * the deleted model. But the modelnum is also needed to index * into the array of tool/model options (e.g., meop, pmop). */ make_and_queue_simm_event(MODEL_DELETED, ms->modelnum, ms, NULL, ZERO, ZERO); for (i = 0; i < ms->motion_array_size; i++) { if (ms->motion[i]) { delete_motion(ms, ms->motion[i], no); FREE_IFNOTNULL(ms->motion[i]); } } destroy_model_menus(ms); // In order to delete the window from the GUI as quickly as possible, // only the tasks that must be done before the window is // removed are done before calling delete_window(). This // means that deleting the bone display lists, which used // to be done inside free_model(), is done separately, here. // These display lists can only be deleted when the window // in which they were created is current. delete_display_lists(ms); delete_window(scene->window_glut_id); sprintf(buf, "Deleted model %s.", ms->name); purge_simm_events_for_struct(scene, SCENE_INPUT_EVENT); purge_simm_events_for_model(ms->modelnum, MODEL_ADDED); free_model(ms->modelnum); root.nummodels--; updatemodelmenu(); message(buf, 0, DEFAULT_MESSAGE_X_OFFSET); }