static void delete_display_lists(ModelStruct* model) { int i, j; Scene* scene = get_first_scene_containing_model(model); if (scene && scene->window_glut_id != -1) { int savedID = glutGetWindow(); glutSetWindow(scene->window_glut_id); // Delete the muscle display lists. glDeleteLists(model->dis.muscle_cylinder_id, 1); glDeleteLists(model->dis.muscle_point_id, 1); // Delete the bone, springfloor, contact object, and force matte display lists. for (i=0; i<model->numsegments; i++) { if (model->segment[i].defined == yes) { for (j=0; j<model->segment[i].numBones; j++) delete_polyhedron_display_list(&model->segment[i].bone[j], NULL); for (j=0; j<model->segment[i].numContactObjects; j++) delete_polyhedron_display_list(model->segment[i].contactObject[j].poly, NULL); if (model->segment[i].springFloor) delete_polyhedron_display_list(model->segment[i].springFloor->poly, NULL); if (model->segment[i].forceMatte) delete_polyhedron_display_list(model->segment[i].forceMatte->poly, NULL); } } // Delete the wrap object display lists. for (i=0; i<model->num_wrap_objects; i++) glDeleteLists(model->wrapobj[i]->display_list, 1); // Delete the world object display lists. for (i=0; i<model->numworldobjects; i++) delete_polyhedron_display_list(model->worldobj[i].wobj, NULL); // Delete the constraint object display lists. for (i=0; i<model->num_constraint_objects; i++) glDeleteLists(model->constraintobj[i].display_list, 1); // Delete the materials. for (i=0; i<model->dis.mat.num_materials; i++) { if (model->dis.mat.materials[i].normal_list) glDeleteLists(model->dis.mat.materials[i].normal_list,1); if (model->dis.mat.materials[i].highlighted_list) glDeleteLists(model->dis.mat.materials[i].highlighted_list,1); FREE_IFNOTNULL(model->dis.mat.materials[i].name); } FREE_IFNOTNULL(model->dis.mat.materials); glutSetWindow(savedID); } }
void delete_scene(Scene* scene) { int i; // TODO_SCENE delete_model(scene->model[0]); FREE_IFNOTNULL(scene->model); FREE_IFNOTNULL(scene->snapshot_file_suffix); FREE_IFNOTNULL(scene->movie_file); free(scene); for (i=0; i<SCENEBUFFER; i++) { if (gScene[i] == scene) { gScene[i] = NULL; break; } } adjust_main_menu(); }
void make_message_port(void) { IntBox bbox; HelpStruct* hp; int windex; WindowParams mwin; WinUnion wun; SBoolean iconified; hp = &root.messages; hp->lines_per_page = 10; hp->window_width = 750; hp->window_height = 10*HELP_WINDOW_TEXT_Y_SPACING + 4; hp->line = (TextLine*)simm_malloc(100*sizeof(TextLine)); if (hp->line == NULL) error(exit_program,tool_message); hp->num_lines_malloced = 100; hp->num_lines = 0; hp->starting_line = 0; hp->background_color = HELP_WINDOW_BACKGROUND; bbox.x2 = hp->window_width; bbox.x1 = bbox.x2 - 20; bbox.y2 = hp->window_height; bbox.y1 = 0; make_slider(&hp->sl,vertical_slider,bbox,0,(double)(hp->num_lines)*20.0, (double)(hp->lines_per_page)*20.0,(double)(hp->num_lines)*20.0,4.0,NULL,NULL); glueSetWindowPlacement(GLUT_NORMAL_WINDOW, GLUE_SOUTHWEST, hp->window_width, hp->window_height, 0, 0, NULL); #if defined WIN32 && SIMM_DEMO_VERSION iconified = is_in_demo_mode(); #else iconified = no; #endif mwin.id = hp->window_id = glueOpenWindow("simmmess",iconified,GLUE_TOOL_WINDOW); glueSetWindowMinSize(500,100); mstrcpy(&mwin.name,"SIMM Messages"); glutSetIconTitle("Messages"); glutSetWindowTitle(mwin.name); wun.tool = NULL; windex = add_window(&mwin,&wun,NOTYPE,ZERO,no,draw_message_window, update_message_window,messages_input); if (windex == -1) error(exit_program,tool_message); glutSetWindowData(mwin.id, windex); if (expirationMessage) { error(none, expirationMessage); FREE_IFNOTNULL(expirationMessage); } }
/* 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); }