int define_Computed_field_type_time_lookup(struct Parse_state *state, void *field_modify_void,void *computed_field_time_package_void) /******************************************************************************* LAST MODIFIED : 25 August 2006 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_TIME_LOOKUP (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; struct Computed_field **source_fields; Computed_field_modify_data *field_modify; struct Option_table *option_table; struct Set_Computed_field_conditional_data set_source_field_data, set_time_field_data; ENTER(define_Computed_field_type_time_lookup); USE_PARAMETER(computed_field_time_package_void); if (state&&(field_modify=(Computed_field_modify_data *)field_modify_void)) { return_code=1; /* get valid parameters for projection field */ source_fields = (struct Computed_field **)NULL; if (ALLOCATE(source_fields, struct Computed_field *, 2)) { source_fields[0] = (struct Computed_field *)NULL; source_fields[1] = (struct Computed_field *)NULL; if ((NULL != field_modify->get_field()) && (computed_field_time_lookup_type_string == Computed_field_get_type_string(field_modify->get_field()))) { return_code=Computed_field_get_type_time_lookup(field_modify->get_field(), source_fields, source_fields + 1); } if (return_code) { /* must access objects for set functions */ if (source_fields[0]) { ACCESS(Computed_field)(source_fields[0]); } if (source_fields[1]) { ACCESS(Computed_field)(source_fields[1]); } option_table = CREATE(Option_table)(); /* fields */ set_source_field_data.computed_field_manager= field_modify->get_field_manager(); set_source_field_data.conditional_function=Computed_field_has_numerical_components; set_source_field_data.conditional_function_user_data=(void *)NULL; Option_table_add_entry(option_table,"field",&source_fields[0], &set_source_field_data,set_Computed_field_conditional); set_time_field_data.computed_field_manager= field_modify->get_field_manager(); set_time_field_data.conditional_function=Computed_field_is_scalar; set_time_field_data.conditional_function_user_data=(void *)NULL; Option_table_add_entry(option_table,"time_field",&source_fields[1], &set_time_field_data,set_Computed_field_conditional); return_code=Option_table_multi_parse(option_table,state); /* no errors,not asking for help */ if (return_code) { return_code = field_modify->update_field_and_deaccess( Cmiss_field_module_create_time_lookup(field_modify->get_field_module(), source_fields[0], source_fields[1])); } if (!return_code) { if ((!state->current_token)|| (strcmp(PARSER_HELP_STRING,state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING,state->current_token))) { /* error */ display_message(ERROR_MESSAGE, "define_Computed_field_type_time_lookup. Failed"); } } if (source_fields[0]) { DEACCESS(Computed_field)(&source_fields[0]); } if (source_fields[1]) { DEACCESS(Computed_field)(&source_fields[1]); } DESTROY(Option_table)(&option_table); } DEALLOCATE(source_fields); } else {
int gfx_modify_rendition_graphic(struct Parse_state *state, enum Cmiss_graphic_type graphic_type, const char *help_text, struct Modify_rendition_data *modify_rendition_data, struct Rendition_command_data *rendition_command_data) { if (!(state && rendition_command_data && modify_rendition_data)) { display_message(ERROR_MESSAGE, "gfx_modify_rendition_graphic. Invalid argument(s)"); return 0; } Cmiss_graphic *graphic = 0; if (modify_rendition_data->modify_this_graphic) { graphic = Cmiss_graphic_access(modify_rendition_data->graphic); graphic_type = Cmiss_graphic_get_graphic_type(graphic); } else { graphic = get_graphic_for_gfx_modify(rendition_command_data->rendition, graphic_type, modify_rendition_data->graphic); if (modify_rendition_data->group && (!graphic->subgroup_field)) { graphic->subgroup_field = Cmiss_field_access(Cmiss_field_group_base_cast(modify_rendition_data->group)); } } if (!graphic) { display_message(ERROR_MESSAGE, "gfx_modify_rendition_graphic. Could not create graphic"); return 0; } REACCESS(Cmiss_graphic)(&(modify_rendition_data->graphic), graphic); int return_code = 1; Cmiss_graphics_coordinate_system coordinate_system = Cmiss_graphic_get_coordinate_system(graphic); char *font_name = (char *)NULL; Cmiss_field_id orientation_scale_field = 0; Cmiss_field_id variable_scale_field = 0; Cmiss_field_id xi_point_density_field = 0; GT_object *glyph = 0; Triple glyph_offset, glyph_scale_factors, glyph_size; enum Graphic_glyph_scaling_mode glyph_scaling_mode = GRAPHIC_GLYPH_SCALING_GENERAL; const char *glyph_scaling_mode_string = 0; if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_GLYPH)) { Cmiss_graphic_get_glyph_parameters(graphic, &glyph, &glyph_scaling_mode, glyph_offset, glyph_size, &orientation_scale_field, glyph_scale_factors, &variable_scale_field); if (glyph) ACCESS(GT_object)(glyph); if (orientation_scale_field) { ACCESS(Computed_field)(orientation_scale_field); } if (variable_scale_field) { ACCESS(Computed_field)(variable_scale_field); } glyph_scaling_mode_string = ENUMERATOR_STRING(Graphic_glyph_scaling_mode)(glyph_scaling_mode); } enum Use_element_type use_element_type; const char *use_element_type_string = 0; if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_USE_ELEMENT_TYPE)) { use_element_type = graphic->use_element_type; use_element_type_string = ENUMERATOR_STRING(Use_element_type)(use_element_type); } enum Xi_discretization_mode xi_discretization_mode; const char *xi_discretization_mode_string = 0; if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_XI_DISCRETIZATION_MODE)) { Cmiss_graphic_get_xi_discretization(graphic, &xi_discretization_mode, &xi_point_density_field); if (xi_point_density_field) { ACCESS(Computed_field)(xi_point_density_field); } xi_discretization_mode_string = ENUMERATOR_STRING(Xi_discretization_mode)(xi_discretization_mode); } int number_of_components = 3; int visibility = graphic->visibility_flag; int number_of_valid_strings; const char **valid_strings; enum Cmiss_graphics_render_type render_type = graphic->render_type; const char *render_type_string = ENUMERATOR_STRING(Cmiss_graphics_render_type)(render_type); /* The value stored in the graphic is an integer rather than a char */ char reverse_track = (graphic->reverse_track) ? 1 : 0; char *seed_nodeset_name = 0; if (graphic->seed_nodeset) { seed_nodeset_name = Cmiss_nodeset_get_name(graphic->seed_nodeset); } Option_table *option_table = CREATE(Option_table)(); if (help_text) { Option_table_add_help(option_table, help_text); } /* as */ Option_table_add_entry(option_table,"as",&(graphic->name), (void *)1,set_name); /* cell_centres/cell_corners/cell_density/exact_xi */ if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_XI_DISCRETIZATION_MODE)) { valid_strings = ENUMERATOR_GET_VALID_STRINGS(Xi_discretization_mode)( &number_of_valid_strings, (ENUMERATOR_CONDITIONAL_FUNCTION(Xi_discretization_mode) *)NULL, (void *)NULL); Option_table_add_enumerator(option_table,number_of_valid_strings, valid_strings,&xi_discretization_mode_string); DEALLOCATE(valid_strings); } /* centre */ if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_GLYPH)) { Option_table_add_entry(option_table,"centre",glyph_offset, &(number_of_components),set_reversed_float_vector); } /* circle_discretization */ if (graphic_type == CMISS_GRAPHIC_CYLINDERS) { Option_table_add_entry(option_table, "circle_discretization", (void *)&(graphic->circle_discretization), (void *)NULL, set_Circle_discretization); } /* constant_radius */ if (graphic_type == CMISS_GRAPHIC_CYLINDERS) { Option_table_add_entry(option_table,"constant_radius", &(graphic->constant_radius),NULL,set_float); } /* coordinate */ Set_Computed_field_conditional_data set_coordinate_field_data; set_coordinate_field_data.computed_field_manager = rendition_command_data->computed_field_manager; set_coordinate_field_data.conditional_function = Computed_field_has_up_to_3_numerical_components; set_coordinate_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_Computed_field_conditional_entry(option_table, "coordinate", &(graphic->coordinate_field), &set_coordinate_field_data); /* coordinate system */ const char *coordinate_system_string = ENUMERATOR_STRING(Cmiss_graphics_coordinate_system)(coordinate_system); valid_strings = ENUMERATOR_GET_VALID_STRINGS(Cmiss_graphics_coordinate_system)( &number_of_valid_strings, (ENUMERATOR_CONDITIONAL_FUNCTION(Cmiss_graphics_coordinate_system) *)NULL, (void *)NULL); Option_table_add_enumerator(option_table, number_of_valid_strings, valid_strings, &coordinate_system_string); DEALLOCATE(valid_strings); /* data */ Set_Computed_field_conditional_data set_data_field_data; set_data_field_data.computed_field_manager = rendition_command_data->computed_field_manager; set_data_field_data.conditional_function = Computed_field_has_numerical_components; set_data_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_Computed_field_conditional_entry(option_table, "data", &(graphic->data_field), &set_data_field_data); /* decimation_threshold */ if (graphic_type == CMISS_GRAPHIC_ISO_SURFACES) { Option_table_add_double_entry(option_table, "decimation_threshold", &(graphic->decimation_threshold)); } /* delete */ Option_table_add_entry(option_table,"delete", &(modify_rendition_data->delete_flag),NULL,set_char_flag); /* density */ Set_Computed_field_conditional_data set_xi_point_density_field_data; set_xi_point_density_field_data.computed_field_manager = rendition_command_data->computed_field_manager; set_xi_point_density_field_data.conditional_function = Computed_field_is_scalar; set_xi_point_density_field_data.conditional_function_user_data = (void *)NULL; if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_XI_DISCRETIZATION_MODE)) { Option_table_add_Computed_field_conditional_entry(option_table, "density", &xi_point_density_field, &set_xi_point_density_field_data); } /* discretization */ if (Cmiss_graphic_type_uses_attribute(graphic_type, CMISS_GRAPHIC_ATTRIBUTE_DISCRETIZATION)) { Option_table_add_entry(option_table,"discretization", &(graphic->discretization),NULL, set_Element_discretization); } /* ellipse/line/rectangle/ribbon */ Streamline_type streamline_type = STREAM_LINE; const char *streamline_type_string = ENUMERATOR_STRING(Streamline_type)(streamline_type); if (graphic_type == CMISS_GRAPHIC_STREAMLINES) { valid_strings = ENUMERATOR_GET_VALID_STRINGS(Streamline_type)( &number_of_valid_strings, (ENUMERATOR_CONDITIONAL_FUNCTION(Streamline_type) *)NULL, (void *)NULL); Option_table_add_enumerator(option_table,number_of_valid_strings, valid_strings,&streamline_type_string); DEALLOCATE(valid_strings); }
static void Element_tool_interactive_event_handler(void *device_id, struct Interactive_event *event,void *element_tool_void, struct Graphics_buffer *graphics_buffer) /******************************************************************************* LAST MODIFIED 18 November 2005 DESCRIPTION : Input handler for input from devices. <device_id> is a unique address enabling the editor to handle input from more than one device at a time. The <event> describes the type of event, button numbers and key modifiers, and the volume of space affected by the interaction. Main events are button press, movement and release. ==============================================================================*/ { enum Interactive_event_type event_type; FE_value time, xi[MAXIMUM_ELEMENT_XI_DIMENSIONS]; int clear_selection, element_dimension, i, input_modifier, number_of_xi_points, shift_pressed; int number_in_xi[MAXIMUM_ELEMENT_XI_DIMENSIONS]; struct FE_element *picked_element; struct FE_element_shape *element_shape; struct Element_tool *element_tool; struct Interaction_volume *interaction_volume,*temp_interaction_volume; struct LIST(Scene_picked_object) *scene_picked_object_list; struct Scene *scene; struct Cmiss_rendition *rendition = NULL; FE_value_triple *xi_points; ENTER(Element_tool_interactive_event_handler); if (device_id&&event&&(element_tool= (struct Element_tool *)element_tool_void)) { Cmiss_region_begin_hierarchical_change(element_tool->region); interaction_volume=Interactive_event_get_interaction_volume(event); scene=Interactive_event_get_scene(event); if (scene != 0) { event_type=Interactive_event_get_type(event); input_modifier=Interactive_event_get_input_modifier(event); shift_pressed=(INTERACTIVE_EVENT_MODIFIER_SHIFT & input_modifier); switch (event_type) { case INTERACTIVE_EVENT_BUTTON_PRESS: { /* interaction only works with first mouse button */ if (1==Interactive_event_get_button_number(event)) { scene_picked_object_list= Scene_pick_objects(scene,interaction_volume,graphics_buffer); if (scene_picked_object_list != 0) { element_tool->picked_element_was_unselected=1; if (0 != (picked_element=Scene_picked_object_list_get_nearest_element( scene_picked_object_list,(struct Cmiss_region *)NULL, element_tool->select_elements_enabled, element_tool->select_faces_enabled, element_tool->select_lines_enabled, (struct Scene_picked_object **)NULL, &rendition, (struct Cmiss_graphic **)NULL))) { /* Open command_field of picked_element in browser */ if (element_tool->command_field) { if (element_tool->time_keeper) { time = Time_keeper_get_time(element_tool->time_keeper); } else { time = 0; } /* since we don't really have fields constant over an element, evaluate at its centre */ element_dimension = get_FE_element_dimension(picked_element); for (i = 0; i < element_dimension; i++) { number_in_xi[i] = 1; } get_FE_element_shape(picked_element, &element_shape); if (FE_element_shape_get_xi_points_cell_centres( element_shape, number_in_xi, &number_of_xi_points, &xi_points)) { /*???debug*/printf("element_tool: xi ="); for (i = 0; i < element_dimension; i++) { xi[i] = xi_points[0][i]; /*???debug*/printf(" %g",xi[i]); } /*???debug*/printf("\n"); Cmiss_field_module_id field_module = Cmiss_field_get_field_module(element_tool->command_field); Cmiss_field_cache_id field_cache = Cmiss_field_module_create_cache(field_module); Cmiss_field_cache_set_time(field_cache, time); Cmiss_field_cache_set_mesh_location(field_cache, picked_element, element_dimension, xi); char *command_string = Cmiss_field_evaluate_string(element_tool->command_field, field_cache); if (command_string) { Execute_command_execute_string(element_tool->execute_command, command_string); DEALLOCATE(command_string); } Cmiss_field_cache_destroy(&field_cache); Cmiss_field_module_destroy(&field_module); DEALLOCATE(xi_points); } } Cmiss_field_group_id group = Cmiss_rendition_get_selection_group(rendition); if (group) { Cmiss_region_id temp_region = Cmiss_rendition_get_region(rendition); Cmiss_field_module_id field_module = Cmiss_region_get_field_module(temp_region); int dimension = Cmiss_element_get_dimension(picked_element); Cmiss_mesh_id master_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(group, master_mesh); Cmiss_mesh_destroy(&master_mesh); if (element_group) { Cmiss_mesh_group_id mesh_group = Cmiss_field_element_group_get_mesh(element_group); element_tool->picked_element_was_unselected = !Cmiss_mesh_contains_element(Cmiss_mesh_group_base_cast(mesh_group), picked_element); Cmiss_mesh_group_destroy(&mesh_group); Cmiss_field_element_group_destroy(&element_group); } Cmiss_field_group_destroy(&group); Cmiss_field_module_destroy(&field_module); } } REACCESS(FE_element)(&(element_tool->last_picked_element), picked_element); /*(if ((clear_selection = !shift_pressed) &&((!picked_element)|| (element_tool->picked_element_was_unselected)))*/ clear_selection = !shift_pressed; if (clear_selection) { if (element_tool->region) { Cmiss_rendition *root_rendition = Cmiss_region_get_rendition_internal(element_tool->region); Cmiss_field_group_id root_group = Cmiss_rendition_get_selection_group(root_rendition); if (root_group) { Cmiss_field_group_clear_region_tree_element(root_group); Cmiss_field_group_destroy(&root_group); } Cmiss_rendition_destroy(&root_rendition); } } if (picked_element) { REACCESS(Cmiss_rendition)(&(element_tool->rendition), rendition); Cmiss_region *sub_region = NULL; Cmiss_field_group_id sub_group = NULL; Cmiss_mesh_group_id mesh_group = 0; if (element_tool->rendition) { sub_region = Cmiss_rendition_get_region(element_tool->rendition); sub_group = Cmiss_rendition_get_or_create_selection_group(element_tool->rendition); if (sub_group) { int dimension = Cmiss_element_get_dimension(picked_element); Cmiss_field_module_id field_module = Cmiss_region_get_field_module(sub_region); Cmiss_mesh_id temp_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(sub_group, temp_mesh); if (!element_group) element_group = Cmiss_field_group_create_element_group(sub_group, temp_mesh); mesh_group = Cmiss_field_element_group_get_mesh(element_group); Cmiss_field_element_group_destroy(&element_group); Cmiss_mesh_destroy(&temp_mesh); Cmiss_field_module_destroy(&field_module); } } if (mesh_group) { Cmiss_mesh_group_add_element(mesh_group, picked_element); Cmiss_mesh_group_destroy(&mesh_group); } if (sub_group) { Cmiss_field_group_destroy(&sub_group); } } DESTROY(LIST(Scene_picked_object))(&(scene_picked_object_list)); } element_tool->motion_detected=0; REACCESS(Interaction_volume)( &(element_tool->last_interaction_volume),interaction_volume); } } break; case INTERACTIVE_EVENT_MOTION_NOTIFY: case INTERACTIVE_EVENT_BUTTON_RELEASE: { if (element_tool->last_interaction_volume&& ((INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) || (1==Interactive_event_get_button_number(event)))) { if (INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) { element_tool->motion_detected=1; } if (element_tool->last_picked_element) { /* unselect last_picked_element if not just added */ if ((INTERACTIVE_EVENT_BUTTON_RELEASE==event_type)&& shift_pressed&&(!(element_tool->picked_element_was_unselected))) { struct LIST(FE_element) *temp_element_list = CREATE(LIST(FE_element))(); ADD_OBJECT_TO_LIST(FE_element)(element_tool->last_picked_element, temp_element_list); Cmiss_rendition_remove_selection_from_element_list_of_dimension(element_tool->rendition, temp_element_list, Cmiss_element_get_dimension(element_tool->last_picked_element)); DESTROY(LIST(FE_element))(&temp_element_list); } } else if (element_tool->motion_detected) { /* rubber band select */ temp_interaction_volume= create_Interaction_volume_bounding_box( element_tool->last_interaction_volume,interaction_volume); if (temp_interaction_volume != 0) { if (INTERACTIVE_EVENT_MOTION_NOTIFY==event_type) { if (!element_tool->rubber_band) { /* create rubber_band object and put in scene */ element_tool->rubber_band=CREATE(GT_object)( "element_tool_rubber_band",g_POLYLINE, element_tool->rubber_band_material); ACCESS(GT_object)(element_tool->rubber_band); } Interaction_volume_make_polyline_extents( temp_interaction_volume,element_tool->rubber_band); } else { #if defined (USE_SCENE_OBJECT) Scene_remove_graphics_object(scene,element_tool->rubber_band); #endif DEACCESS(GT_object)(&(element_tool->rubber_band)); } if (INTERACTIVE_EVENT_BUTTON_RELEASE==event_type) { scene_picked_object_list= Scene_pick_objects(scene,temp_interaction_volume, graphics_buffer); if (scene_picked_object_list != 0) { Region_element_map *element_map = (Region_element_map *)Scene_picked_object_list_get_picked_region_sorted_elements( scene_picked_object_list, element_tool->select_elements_enabled, element_tool->select_faces_enabled, element_tool->select_lines_enabled); if (element_map) { Cmiss_region *sub_region = NULL; Cmiss_field_group_id sub_group = NULL; Cmiss_rendition *region_rendition = NULL; Cmiss_mesh_group_id mesh_group[MAXIMUM_ELEMENT_XI_DIMENSIONS]; int iter = 0; for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { mesh_group[iter] = 0; } Region_element_map::iterator pos; for (pos = element_map->begin(); pos != element_map->end(); ++pos) { if (pos->first != sub_region) { if (sub_group) { Cmiss_field_group_destroy(&sub_group); } for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { if (mesh_group[iter]) { Cmiss_mesh_group_destroy(&(mesh_group[iter])); } } if (region_rendition) { Cmiss_rendition_destroy(®ion_rendition); } sub_region = pos->first; if (sub_region) { region_rendition= Cmiss_region_get_rendition_internal(sub_region); sub_group = Cmiss_rendition_get_or_create_selection_group(region_rendition); } } if (sub_region && sub_group) { Cmiss_field_module_id field_module = Cmiss_region_get_field_module(sub_region); int dimension = Cmiss_element_get_dimension(pos->second); if (dimension <= MAXIMUM_ELEMENT_XI_DIMENSIONS) { if (!mesh_group[dimension - 1]) { Cmiss_mesh_id temp_mesh = Cmiss_field_module_find_mesh_by_dimension(field_module, dimension); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(sub_group, temp_mesh); if (!element_group) { element_group = Cmiss_field_group_create_element_group(sub_group, temp_mesh); } mesh_group[dimension - 1] = Cmiss_field_element_group_get_mesh(element_group); Cmiss_field_element_group_destroy(&element_group); Cmiss_mesh_destroy(&temp_mesh); } Cmiss_mesh_group_add_element(mesh_group[dimension - 1], pos->second); } Cmiss_field_module_destroy(&field_module); } } if (sub_group) { Cmiss_field_group_destroy(&sub_group); } for (iter = 0; iter < MAXIMUM_ELEMENT_XI_DIMENSIONS; iter++) { if (mesh_group[iter]) { Cmiss_mesh_group_destroy(&(mesh_group[iter])); } } if (region_rendition) { Cmiss_rendition_destroy(®ion_rendition); } delete element_map; } DESTROY(LIST(Scene_picked_object))( &(scene_picked_object_list)); } } DESTROY(Interaction_volume)(&temp_interaction_volume); } } if (INTERACTIVE_EVENT_BUTTON_RELEASE==event_type) { Element_tool_reset((void *)element_tool); } } } break; default: { display_message(ERROR_MESSAGE, "Element_tool_interactive_event_handler. Unknown event type"); } break; }
/* Global functions ---------------- */ #if defined (WX_USER_INTERFACE) bool wxCmguiApp::OnInit() { return (true); } wxAppTraits * wxCmguiApp::CreateTraits() { return new wxGUIAppTraits; } void wxCmguiApp::OnIdle(wxIdleEvent& event) { if (event_dispatcher) { if (Event_dispatcher_process_idle_event(event_dispatcher)) { event.RequestMore(); } } } void wxCmguiApp::SetEventDispatcher(Event_dispatcher *event_dispatcher_in) { event_dispatcher = event_dispatcher_in; } BEGIN_EVENT_TABLE(wxCmguiApp, wxApp) EVT_IDLE(wxCmguiApp::OnIdle) END_EVENT_TABLE() IMPLEMENT_APP_NO_MAIN(wxCmguiApp) #endif /*defined (WX_USER_INTERFACE)*/ #if !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER) int main(int argc,const char *argv[]) #else /* !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)*/ int WINAPI WinMain(HINSTANCE current_instance,HINSTANCE previous_instance, LPSTR command_line,int initial_main_window_state) /* using WinMain as the entry point tells Windows that it is a gui and to use the graphics device interface functions for I/O */ /*???DB. WINDOWS a zero return code if WinMain does get into the message loop. Other application interfaces may expect something else. Should this failure code be #define'd ? */ /*???DB. Win32 SDK says that don't have to call it WinMain */ #endif /* !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)*/ /******************************************************************************* LAST MODIFIED : 7 January 2003 DESCRIPTION : Main program for the CMISS Graphical User Interface ==============================================================================*/ { int return_code = 0; #if defined (WIN32_USER_INTERFACE) || defined (_MSC_VER) int argc = 1, i; const char **argv; char *p, *q; #endif /* defined (WIN32_USER_INTERFACE) */ struct Cmiss_context_app *context = NULL; struct User_interface_module *UI_module = NULL; struct Cmiss_command_data *command_data; #if !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER) ENTER(main); #else /* !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)*/ ENTER(WinMain); //_CrtSetBreakAlloc(28336); for (p = command_line; p != NULL && *p != 0;) { p = strchr(p, ' '); if (p != NULL) p++; argc++; } argv = (const char **)malloc(sizeof(*argv) * argc); argv[0] = "cmgui"; for (i = 1, p = command_line; p != NULL && *p != 0;) { q = strchr(p, ' '); if (q != NULL) *q++ = 0; if (p != NULL) argv[i++] = p; p = q; } #endif /* !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)*/ /* display the version */ display_message(INFORMATION_MESSAGE, "%s version %s\n%s\n" "Build information: %s %s\n", CMISS_NAME_STRING, CMISS_VERSION_STRING, CMISS_COPYRIGHT_STRING, CMISS_BUILD_STRING, CMISS_SVN_REVISION_STRING); #if defined (CARBON_USER_INTERFACE) || (defined (WX_USER_INTERFACE) && defined (DARWIN)) ProcessSerialNumber PSN; GetCurrentProcess(&PSN); TransformProcessType(&PSN,kProcessTransformToForegroundApplication); #endif context = Cmiss_context_app_create("default"); #if defined (WX_USER_INTERFACE) int wx_entry_started = 0; #endif if (context) { #if defined (WX_USER_INTERFACE) || (!defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)) UI_module = Cmiss_context_create_user_interface(context, argc, argv, NULL); #else /* !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)*/ UI_module = Cmiss_context_create_user_interface(context, argc, argv, current_instance, previous_instance, command_line, initial_main_window_state, NULL); #endif /* !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)*/ if (UI_module) { #if defined (WX_USER_INTERFACE) if (UI_module->user_interface) { char **temp_argv = NULL, **cleanup_argv = NULL; int temp_argc = argc, cleanup_argc = argc; if (cleanup_argc > 0) { ALLOCATE(temp_argv, char *, cleanup_argc); ALLOCATE(cleanup_argv, char *, cleanup_argc); for (int i = 0; i < cleanup_argc; i++) { cleanup_argv[i] = temp_argv[i] = duplicate_string(argv[i]); } } if (wxEntryStart(temp_argc, temp_argv)) { wx_entry_started = 1; wxXmlResource::Get()->InitAllHandlers(); wxCmguiApp &app = wxGetApp(); if (&app) { app.SetEventDispatcher(UI_module->event_dispatcher); } else { display_message(ERROR_MESSAGE, "initialiseWxApp. wxCmguiApp not initialised."); } } else { display_message(ERROR_MESSAGE, "initialiseWxApp. Invalid arguments."); } if (cleanup_argv) { for (int i = 0; i < cleanup_argc; i++) { DEALLOCATE(cleanup_argv[i]); } DEALLOCATE(temp_argv); DEALLOCATE(cleanup_argv); } } #endif Cmiss_graphics_module_id graphics_module = NULL; if (NULL != (graphics_module = Cmiss_context_get_default_graphics_module(Cmiss_context_app_get_core_context(context)))) { Cmiss_graphics_module_define_standard_materials(graphics_module); Cmiss_graphics_module_destroy(&graphics_module); } if (NULL != (command_data = Cmiss_context_get_default_command_interpreter(context))) { Cmiss_command_data_set_cmgui_string(command_data, CMISS_NAME_STRING, CMISS_VERSION_STRING, "CMISS_DATE_STRING", CMISS_COPYRIGHT_STRING, CMISS_BUILD_STRING, CMISS_SVN_REVISION_STRING); Cmiss_command_data_main_loop(command_data); Cmiss_command_data_destroy(&command_data); return_code = 0; } else { return_code = 1; } User_interface_module_destroy(&UI_module); } else { return_code = 1; } Cmiss_context_app_destroy(&context); Context_internal_cleanup(); #if defined (WX_USER_INTERFACE) if (wx_entry_started) wxEntryCleanup(); #endif /* FieldML does not cleanup the global varaibles xmlParser, xmlSchematypes and * xmlCatalog at this moment, so we clean it up here instead*/ xmlCatalogCleanup(); xmlSchemaCleanupTypes(); xmlCleanupParser(); } else { return_code = 1; } #if defined (WIN32_USER_INTERFACE) || defined (_MSC_VER) free(argv) #endif LEAVE; return (return_code); } /* main */
virtual ~StringFieldValueCache() { DEALLOCATE(stringValue); }
GfxFont::~GfxFont() { DEALLOCATE(_fontData); }
int define_Computed_field_type_quaternion_SLERP(struct Parse_state *state, void *field_modify_void, void *computed_field_lookup_package_void) /******************************************************************************* LAST MODIFIED : 25 August 2006 DESCRIPTION : Converts <field> into type 'quaterions' (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; Computed_field_lookup_package *computed_field_lookup_package; Computed_field_modify_data *field_modify; ENTER(define_Computed_field_type_quaternion_SLERP); if (state&&(field_modify=(Computed_field_modify_data *)field_modify_void) && (computed_field_lookup_package= (Computed_field_lookup_package *) computed_field_lookup_package_void)) { return_code = 1; Cmiss_field_id source_field = 0; char *nodeset_name = duplicate_string("cmiss_nodes"); char node_flag = 0; int node_identifier = 0; if ((NULL != field_modify->get_field()) && (computed_field_quaternion_SLERP_type_string == Computed_field_get_type_string(field_modify->get_field()))) { Cmiss_node_id lookup_node = 0; return_code = Computed_field_get_type_quaternion_SLERP(field_modify->get_field(), &source_field, &lookup_node); if (source_field) { ACCESS(Computed_field)(source_field); } if (lookup_node) { node_identifier = get_FE_node_identifier(lookup_node); FE_region *fe_region = FE_node_get_FE_region(lookup_node); if (!FE_region_contains_FE_node(fe_region, lookup_node)) { DEALLOCATE(nodeset_name); nodeset_name = duplicate_string("cmiss_data"); } node_flag = 1; } } Option_table *option_table = CREATE(Option_table)(); Option_table_add_help(option_table, "A 4 components quaternion field. The components of " "the quaternion field are expected to be the w, x, y, z components" "of a quaternion (4 components in total). The quaternion field is" "evaluated and interpolated using SLERP at a normalised time between two" "quaternions (read in from the exnode generally). This quaternion field" "can be convert to a matrix with quaternion_to_matrix field, the resulting" "matrix can be used to create a smooth time dependent rotation for an object" "using the quaternion_to_matrix field. This field must be define directly from" "exnode file or from a matrix_to_quaternion field"); Set_Computed_field_conditional_data set_source_field_data; set_source_field_data.computed_field_manager = field_modify->get_field_manager(); set_source_field_data.conditional_function = Computed_field_has_4_components; set_source_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "field", &source_field, &set_source_field_data, set_Computed_field_conditional); /* identifier of the node to lookup */ Option_table_add_entry(option_table, "node", &node_identifier, &node_flag, set_int_and_char_flag); /* the nodeset the node is from */ Option_table_add_string_entry(option_table, "nodeset", &nodeset_name, " NODE_GROUP_FIELD_NAME|[GROUP_NAME.]cmiss_nodes|cmiss_data[cmiss_nodes]"); return_code = Option_table_multi_parse(option_table, state); DESTROY(Option_table)(&option_table); if (return_code && node_flag) { Cmiss_nodeset_id nodeset = Cmiss_field_module_find_nodeset_by_name(field_modify->get_field_module(), nodeset_name); Cmiss_node_id node = Cmiss_nodeset_find_node_by_identifier(nodeset, node_identifier); if (node) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_quaternion_SLERP(field_modify->get_field_module(), source_field, node)); } else { display_message(ERROR_MESSAGE, "define field quaternion_SLERP. Invalid node %d", node_identifier); return_code = 0; } Cmiss_node_destroy(&node); Cmiss_nodeset_destroy(&nodeset); } else { if ((!state->current_token)|| (strcmp(PARSER_HELP_STRING,state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING,state->current_token))) { display_message(ERROR_MESSAGE, "define_Computed_field_type_quaternion_SLERP. Failed"); } } DEALLOCATE(nodeset_name); REACCESS(Computed_field)(&source_field, NULL); } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_quaternion_SLERP. Invalid argument(s)"); return_code = 0; } LEAVE; return (return_code); } /* define_Computed_field_type_quaternion_SLERP */
int Cmiss_context_destroy(struct Context **context_address) { int return_code = 0; struct Context *context = NULL; if (context_address && NULL != (context = *context_address)) { context->access_count--; if (0 == context->access_count) { if (context->id) DEALLOCATE(context->id); //-- if (context->UI_module) //-- { //-- User_interface_module_destroy(&context->UI_module); //-- } if (context->graphics_module) Cmiss_graphics_module_destroy(&context->graphics_module); if (context->root_region) { /* need the following due to circular references where field owned by region references region itself; * when following removed also remove #include "region/cmiss_region_private.h". Also rendition * has a computed_field manager callback so it must be deleted before detaching fields hierarchical */ Cmiss_region_detach_fields_hierarchical(context->root_region); DEACCESS(Cmiss_region)(&context->root_region); } if (context->scene_viewer_package) { Cmiss_scene_viewer_package_destroy(&context->scene_viewer_package); } if (context->any_object_selection) { DESTROY(Any_object_selection)(&context->any_object_selection); } if (context->element_point_ranges_selection) { DESTROY(Element_point_ranges_selection)(&context->element_point_ranges_selection); } if (context->curve_manager) { DESTROY(MANAGER(Curve))(&context->curve_manager); } if (context->io_stream_package) { DESTROY(IO_stream_package)(&context->io_stream_package); } //-- if (context->event_dispatcher) //-- { //-- DESTROY(Event_dispatcher)(&context->event_dispatcher); //-- } DEALLOCATE(*context_address); } *context_address = NULL; return_code = 1; } else { display_message(ERROR_MESSAGE, "Cmiss_context_destroy. Missing context address"); return_code = 0; } /* Write out any memory blocks still ALLOCATED when MEMORY_CHECKING is on. When MEMORY_CHECKING is off this function does nothing */ list_memory(/*count_number*/0, /*show_pointers*/0, /*increment_counter*/0, /*show_structures*/1); return return_code; }
int define_Computed_field_type_if(struct Parse_state *state, void *field_modify_void,void *computed_field_conditional_package_void) /******************************************************************************* LAST MODIFIED : 27 July 2007 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_IF (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; struct Computed_field **source_fields; Computed_field_modify_data *field_modify; struct Option_table *option_table; struct Set_Computed_field_array_data set_source_field_array_data; struct Set_Computed_field_conditional_data set_source_field_data; ENTER(define_Computed_field_type_if); USE_PARAMETER(computed_field_conditional_package_void); if (state && (field_modify=(Computed_field_modify_data *)field_modify_void)) { return_code=1; /* get valid parameters for projection field */ source_fields = (struct Computed_field **)NULL; if (ALLOCATE(source_fields, struct Computed_field *, 3)) { source_fields[0] = (struct Computed_field *)NULL; source_fields[1] = (struct Computed_field *)NULL; source_fields[2] = (struct Computed_field *)NULL; if ((NULL != field_modify->get_field()) && (computed_field_if_type_string == Computed_field_get_type_string(field_modify->get_field()))) { return_code=Computed_field_get_type_if(field_modify->get_field(), source_fields, source_fields + 1, source_fields + 2); } if (return_code) { /* must access objects for set functions */ if (source_fields[0]) { ACCESS(Computed_field)(source_fields[0]); } if (source_fields[1]) { ACCESS(Computed_field)(source_fields[1]); } if (source_fields[2]) { ACCESS(Computed_field)(source_fields[2]); } option_table = CREATE(Option_table)(); Option_table_add_help(option_table, "The if field uses three input fields. " "The first field is evaluated and for each component " "if the value of the component is not zero (== true) then " "the value for that component is copied from the second field. " "Otherwise (the first field value was zero == false) " "the value for that component is copied from the third field"); /* fields */ set_source_field_data.computed_field_manager= field_modify->get_field_manager(); set_source_field_data.conditional_function= Computed_field_has_numerical_components; set_source_field_data.conditional_function_user_data=(void *)NULL; set_source_field_array_data.number_of_fields=3; set_source_field_array_data.conditional_data= &set_source_field_data; Option_table_add_entry(option_table,"fields",source_fields, &set_source_field_array_data,set_Computed_field_array); return_code=Option_table_multi_parse(option_table,state); /* no errors,not asking for help */ if (return_code) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_if(field_modify->get_field_module(), source_fields[0], source_fields[1], source_fields[2])); } if (!return_code) { if ((!state->current_token)|| (strcmp(PARSER_HELP_STRING,state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING,state->current_token))) { /* error */ display_message(ERROR_MESSAGE, "define_Computed_field_type_if. Failed"); } } if (source_fields[0]) { DEACCESS(Computed_field)(&source_fields[0]); } if (source_fields[1]) { DEACCESS(Computed_field)(&source_fields[1]); } if (source_fields[2]) { DEACCESS(Computed_field)(&source_fields[2]); } DESTROY(Option_table)(&option_table); } DEALLOCATE(source_fields); } else {
int Interaction_volume_make_polyline_extents( struct Interaction_volume *interaction_volume, struct GT_object *graphics_object) /******************************************************************************* LAST MODIFIED : 10 July 2000 DESCRIPTION : Fills <graphics_object> - of type g_POLYLINE with lines marking the box enclosing the <interaction volume>, used for rubber-banding. Lines are put at time 0 in the graphics object; any other primitives at that time are cleared. ==============================================================================*/ { ZnReal model_vertex[8][3]; /* use 0.999999 to avoid clipping problems for frustums */ static ZnReal normalised_vertex[8][3]= { {-0.9999,-0.9999,-0.9999}, {-0.9999,-0.9999, 0.9999}, {-0.9999, 0.9999,-0.9999}, {-0.9999, 0.9999, 0.9999}, { 0.9999,-0.9999,-0.9999}, { 0.9999,-0.9999, 0.9999}, { 0.9999, 0.9999,-0.9999}, { 0.9999, 0.9999, 0.9999} }; ZnReal time; int i,return_code; struct GT_polyline *polyline; Triple *point,*points; ENTER(Interaction_volume_make_polyline_extents); if (interaction_volume&&graphics_object&& (g_POLYLINE==GT_object_get_type(graphics_object))) { return_code=1; /* get the 8 vertices of the interaction_volume frustum */ for (i=0;(i<8)&&return_code;i++) { return_code=Interaction_volume_normalised_to_model_coordinates( interaction_volume,normalised_vertex[i],model_vertex[i]); } if (return_code) { /* make a polyline big enough for the 12 line segment edges of the box */ if (ALLOCATE(points,Triple,24)&& (polyline=CREATE(GT_polyline)(g_PLAIN_DISCONTINUOUS,/*line_width=default*/0, 12,points,/*normalpoints*/NULL,0,(GLfloat *)NULL))) { point=points; /* lines spanning axis 1 */ for (i=0;i<4;i++) { (*point)[0]=(GLfloat)model_vertex[i][0]; (*point)[1]=(GLfloat)model_vertex[i][1]; (*point)[2]=(GLfloat)model_vertex[i][2]; point++; (*point)[0]=(GLfloat)model_vertex[i+4][0]; (*point)[1]=(GLfloat)model_vertex[i+4][1]; (*point)[2]=(GLfloat)model_vertex[i+4][2]; point++; } /* lines spanning axis 2 */ for (i=0;i<2;i++) { (*point)[0]=(GLfloat)model_vertex[i*4][0]; (*point)[1]=(GLfloat)model_vertex[i*4][1]; (*point)[2]=(GLfloat)model_vertex[i*4][2]; point++; (*point)[0]=(GLfloat)model_vertex[i*4+2][0]; (*point)[1]=(GLfloat)model_vertex[i*4+2][1]; (*point)[2]=(GLfloat)model_vertex[i*4+2][2]; point++; (*point)[0]=(GLfloat)model_vertex[i*4+1][0]; (*point)[1]=(GLfloat)model_vertex[i*4+1][1]; (*point)[2]=(GLfloat)model_vertex[i*4+1][2]; point++; (*point)[0]=(GLfloat)model_vertex[i*4+3][0]; (*point)[1]=(GLfloat)model_vertex[i*4+3][1]; (*point)[2]=(GLfloat)model_vertex[i*4+3][2]; point++; } /* lines spanning axis 3 */ for (i=0;i<8;i++) { (*point)[0]=(GLfloat)model_vertex[i][0]; (*point)[1]=(GLfloat)model_vertex[i][1]; (*point)[2]=(GLfloat)model_vertex[i][2]; point++; } /* put all graphics in at time 0 */ time=0.0; if (GT_object_has_time(graphics_object,time)) { GT_object_remove_primitives_at_time(graphics_object,time, (GT_object_primitive_object_name_conditional_function *)NULL, NULL); } if (!GT_OBJECT_ADD(GT_polyline)(graphics_object,time,polyline)) { display_message(ERROR_MESSAGE, "Interaction_volume_make_polyline_extents. " "Could not add primitive"); return_code=0; DESTROY(GT_polyline)(&polyline); } } else { display_message(ERROR_MESSAGE, "Interaction_volume_make_polyline_extents. Not enough memory)"); DEALLOCATE(points); return_code=0; } } else { display_message(ERROR_MESSAGE, "Interaction_volume_make_polyline_extents. Invalid volume"); } } else { display_message(ERROR_MESSAGE, "Interaction_volume_make_polyline_extents. Invalid argument(s)"); return_code=0; } LEAVE; return (return_code); } /* Interaction_volume_make_polyline_extents */
int define_Computed_field_type_integration(Parse_state *state, void *field_modify_void,void *computed_field_integration_package_void) /******************************************************************************* LAST MODIFIED : 24 August 2006 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_INTEGRATION (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code = 1; ENTER(define_Computed_field_type_integration); Computed_field_modify_data *field_modify = reinterpret_cast<Computed_field_modify_data *>(field_modify_void); USE_PARAMETER(computed_field_integration_package_void); if (state && field_modify) { cmzn_region_id region = field_modify->get_region(); cmzn_mesh_id mesh = 0; cmzn_field_id coordinate_field = 0; cmzn_field_id integrand = 0; int magnitude_coordinates_flag = 0; int seed_element_identifier = 0; float time_update = 0; if ((NULL != field_modify->get_field()) && Computed_field_is_type_integration(field_modify->get_field())) { cmzn_element_id seed_element; return_code = Computed_field_get_type_integration(field_modify->get_field(), &mesh, &seed_element, &integrand, &magnitude_coordinates_flag, &coordinate_field); if (seed_element) { seed_element_identifier = cmzn_element_get_identifier(seed_element); cmzn_element_destroy(&seed_element); } } if (coordinate_field) { ACCESS(Computed_field)(coordinate_field); } if (integrand) { ACCESS(Computed_field)(integrand); } else { /* Make a default integrand of one */ double value = 1.0; // use temporary field module to supply different defaults cmzn_fieldmodule *temp_field_module = cmzn_region_get_fieldmodule(region); cmzn_fieldmodule_set_field_name(temp_field_module, "constant_1.0"); integrand = Computed_field_create_constant(temp_field_module, /*number_of_components*/1, &value); if (NULL == integrand) { display_message(ERROR_MESSAGE, "define_Computed_field_type_integration. Unable to create constant integrand"); return_code = 0; } cmzn_fieldmodule_destroy(&temp_field_module); } char *group_name = 0; Option_table *option_table = CREATE(Option_table)(); /* coordinate */ Set_Computed_field_conditional_data set_coordinate_field_data; set_coordinate_field_data.computed_field_manager = field_modify->get_field_manager(); set_coordinate_field_data.conditional_function = Computed_field_has_up_to_3_numerical_components; set_coordinate_field_data.conditional_function_user_data = 0; Option_table_add_Computed_field_conditional_entry(option_table, "coordinate", &coordinate_field, &set_coordinate_field_data); /* integrand */ Set_Computed_field_conditional_data set_integrand_field_data; set_integrand_field_data.computed_field_manager = field_modify->get_field_manager(); set_integrand_field_data.conditional_function = Computed_field_is_scalar; set_integrand_field_data.conditional_function_user_data = 0; Option_table_add_Computed_field_conditional_entry(option_table, "integrand", &integrand, &set_integrand_field_data); /* magnitude_coordinates|no_magnitude_coordinates */ Option_table_add_switch(option_table, "magnitude_coordinates", "no_magnitude_coordinates", &magnitude_coordinates_flag); // mesh Option_table_add_mesh_entry(option_table, "mesh", region, &mesh); /* region - legacy group name */ Option_table_add_string_entry(option_table, "region", &group_name, " GROUP_NAME(DEPRECATED)"); /* seed_element */ Option_table_add_int_non_negative_entry(option_table, "seed_element", &seed_element_identifier); /* update_time_integration */ Option_table_add_entry(option_table,"update_time_integration", &time_update, NULL, set_float); return_code = Option_table_multi_parse(option_table,state); DESTROY(Option_table)(&option_table); if (return_code && !mesh) { int dimension = FE_region_get_highest_dimension(cmzn_region_get_FE_region(region)); mesh = cmzn_fieldmodule_find_mesh_by_dimension(field_modify->get_field_module(), dimension); if (group_name) { cmzn_field_id group_field = cmzn_fieldmodule_find_field_by_name(field_modify->get_field_module(), group_name); cmzn_field_group_id group = cmzn_field_cast_group(group_field); cmzn_field_element_group_id element_group = cmzn_field_group_get_field_element_group(group, mesh); cmzn_mesh_destroy(&mesh); mesh = cmzn_mesh_group_base_cast(cmzn_field_element_group_get_mesh_group(element_group)); cmzn_field_element_group_destroy(&element_group); cmzn_field_group_destroy(&group); cmzn_field_destroy(&group_field); } } if (return_code && !mesh) { display_message(ERROR_MESSAGE, "You must specify a mesh."); return_code = 0; } if (return_code && !coordinate_field) { display_message(ERROR_MESSAGE, "You must specify a coordinate field."); return_code = 0; } if (return_code && !integrand) { display_message(ERROR_MESSAGE, "You must specify an integrand field."); return_code = 0; } cmzn_element_id seed_element = 0; if (return_code) { seed_element = cmzn_mesh_find_element_by_identifier(mesh, seed_element_identifier); if (!seed_element) { display_message(ERROR_MESSAGE, "Could not find seed_element %d in mesh.", seed_element_identifier); return_code = 0; } } if (return_code) { if (time_update && (NULL != field_modify->get_field()) && Computed_field_is_type_integration(field_modify->get_field())) { display_message(ERROR_MESSAGE, "The update_time_integration code has not been updated" "with the latest changes."); return_code=0; } else { return_code = field_modify->update_field_and_deaccess( Computed_field_create_integration(field_modify->get_field_module(), mesh, seed_element, integrand, magnitude_coordinates_flag, coordinate_field)); } } if (group_name) { DEALLOCATE(group_name); } cmzn_element_destroy(&seed_element); cmzn_mesh_destroy(&mesh); cmzn_field_destroy(&coordinate_field); cmzn_field_destroy(&integrand); } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_integration. Invalid argument(s)"); return_code=0; } LEAVE; return (return_code); }
int define_Computed_field_type_xi_texture_coordinates(Parse_state *state, void *field_modify_void,void *computed_field_integration_package_void) /******************************************************************************* LAST MODIFIED : 24 August 2006 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_XI_TEXTURE_COORDINATES (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code = 1; ENTER(define_Computed_field_type_xi_texture_coordinates); Computed_field_modify_data *field_modify = reinterpret_cast<Computed_field_modify_data *>(field_modify_void); USE_PARAMETER(computed_field_integration_package_void); if (state && field_modify) { cmzn_region_id region = field_modify->get_region(); cmzn_mesh_id mesh = 0; int seed_element_identifier = 0; char *group_name = 0; Option_table *option_table = CREATE(Option_table)(); // mesh Option_table_add_mesh_entry(option_table, "mesh", region, &mesh); /* region - legacy group name */ Option_table_add_string_entry(option_table, "region", &group_name, " GROUP_NAME(OBSOLETE)"); /* seed_element */ Option_table_add_int_non_negative_entry(option_table, "seed_element", &seed_element_identifier); return_code = Option_table_multi_parse(option_table,state); DESTROY(Option_table)(&option_table); if (return_code && !mesh) { int dimension = FE_region_get_highest_dimension(cmzn_region_get_FE_region(region)); mesh = cmzn_fieldmodule_find_mesh_by_dimension(field_modify->get_field_module(), dimension); if (group_name) { cmzn_field_id group_field = cmzn_fieldmodule_find_field_by_name(field_modify->get_field_module(), group_name); cmzn_field_group_id group = cmzn_field_cast_group(group_field); cmzn_field_element_group_id element_group = cmzn_field_group_get_field_element_group(group, mesh); cmzn_mesh_destroy(&mesh); mesh = cmzn_mesh_group_base_cast(cmzn_field_element_group_get_mesh_group(element_group)); cmzn_field_element_group_destroy(&element_group); cmzn_field_group_destroy(&group); cmzn_field_destroy(&group_field); } } if (return_code && !mesh) { display_message(ERROR_MESSAGE, "Must specify mesh."); return_code = 0; } cmzn_element_id seed_element = 0; if (return_code) { seed_element = cmzn_mesh_find_element_by_identifier(mesh, seed_element_identifier); if (!seed_element) { display_message(ERROR_MESSAGE, "Could not find seed_element %d in mesh.", seed_element_identifier); return_code = 0; } } // use temporary field module to supply different defaults cmzn_field_id coordinate_field = FIRST_OBJECT_IN_MANAGER_THAT(Computed_field)( Computed_field_is_type_xi_coordinates, (void *)NULL, field_modify->get_field_manager()); if (coordinate_field) { ACCESS(Computed_field)(coordinate_field); } else { if ((!state->current_token) || (strcmp(PARSER_HELP_STRING, state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING, state->current_token))) { display_message(ERROR_MESSAGE, "define_Computed_field_type_xi_texture_coordinates. xi field not found"); } return_code = 0; } double value = 1.0; cmzn_fieldmodule *temp_field_module = cmzn_region_get_fieldmodule(region); cmzn_fieldmodule_set_field_name(temp_field_module, "constant_1.0"); Computed_field *integrand = Computed_field_create_constant(temp_field_module, /*number_of_components*/1, &value); cmzn_fieldmodule_destroy(&temp_field_module); if (NULL == integrand) { display_message(ERROR_MESSAGE, "define_Computed_field_type_xi_texture_coordinates. Unable to create constant field"); return_code = 0; } if (return_code) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_integration(field_modify->get_field_module(), mesh, seed_element, integrand, /*magnitude_coordinates*/0, coordinate_field)); } if (group_name) { DEALLOCATE(group_name); } cmzn_element_destroy(&seed_element); cmzn_mesh_destroy(&mesh); cmzn_field_destroy(&coordinate_field); cmzn_field_destroy(&integrand); } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_xi_texture_coordinates. Invalid argument(s)"); return_code=0; } LEAVE; return (return_code); }
int define_Computed_field_type_format_output(struct Parse_state *state, void *field_modify_void,void *computed_field_arithmetic_operators_package_void) /******************************************************************************* LAST MODIFIED : 15 May 2008 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_FORMAT_OUTPUT (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; char *format_string; struct Computed_field *source_field; Computed_field_modify_data *field_modify; struct Option_table *option_table; struct Set_Computed_field_conditional_data set_source_field_data; ENTER(define_Computed_field_type_format_output); USE_PARAMETER(computed_field_arithmetic_operators_package_void); if (state&&(field_modify=(Computed_field_modify_data *)field_modify_void)) { return_code=1; source_field = (struct Computed_field *)NULL; format_string = NULL; if ((NULL != field_modify->get_field()) && (computed_field_format_output_type_string == Computed_field_get_type_string(field_modify->get_field()))) { return_code=Computed_field_get_type_format_output(field_modify->get_field(), &source_field, &format_string); } if (return_code) { /* must access objects for set functions */ if (source_field) { ACCESS(Computed_field)(source_field); } option_table = CREATE(Option_table)(); /* fields */ set_source_field_data.computed_field_manager= field_modify->get_field_manager(); set_source_field_data.conditional_function= Computed_field_has_numerical_components; set_source_field_data.conditional_function_user_data=(void *)NULL; Option_table_add_Computed_field_conditional_entry(option_table,"field", &source_field, &set_source_field_data); Option_table_add_string_entry(option_table, "format_string", &format_string, "C style formatting string"); return_code=Option_table_multi_parse(option_table,state); /* no errors,not asking for help */ if (return_code) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_format_output(field_modify->get_field_module(), source_field, format_string)); } if (!return_code) { if ((!state->current_token)|| (strcmp(PARSER_HELP_STRING,state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING,state->current_token))) { /* error */ display_message(ERROR_MESSAGE, "define_Computed_field_type_format_output. Failed"); } } if (source_field) { DEACCESS(Computed_field)(&source_field); } if (format_string) DEALLOCATE(format_string); DESTROY(Option_table)(&option_table); } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_format_output. Not enough memory"); return_code = 0; } } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_format_output. Invalid argument(s)"); return_code = 0; } LEAVE; return (return_code); } /* define_Computed_field_type_format_output */
void Script::_load() { removeContent(); Str source; try { File sourceFile(getFilename().getData(), "r"); char *data = (char *)ALLOCATE(sourceFile.getSize()); sourceFile.read(sourceFile.getSize(), data); source = Str(sourceFile.getSize(), data); DEALLOCATE(data); } catch (const FileException& e) { THROW(ResourceIOException, "script", getFilename(), e.getString()); } scripting::ASTNode *ast; try { ast = scripting::parse(source); } catch (const scripting::ParseException& e) { THROW(ResourceIOException, "script", getFilename(), Str::format("%d:%d: %s", e.scriptLine, e.scriptColumn, e.message)); } //printAST(0, ast); scripting::Bytecode code; try { code = scripting::generateBytecode(ast); } catch (const scripting::ByteCodeGenException& e) { THROW(ResourceIOException, "script", getFilename(), e.message); } DELETE(ast); //Str disasm = scripting::disasm(code); //std::cout << disasm.getData() << std::endl; { context = NEW(scripting::Context, scriptEngine); try { class_ = context->run(code, List<scripting::Value>()); } catch (scripting::UnhandledExcException& e) { scripting::Value exc = e.getException(); if (exc.type == scripting::ValueType::Exception) { THROW(ResourceIOException, "script", getFilename(), ((scripting::ExceptionData *)exc.p)->error.getData()); } else { THROW(ResourceIOException, "script", getFilename(), "Unhandled exception"); } } } }
int define_Computed_field_type_nodal_lookup(struct Parse_state *state, void *field_modify_void, void *computed_field_lookup_package_void) /******************************************************************************* LAST MODIFIED : 25 August 2006 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_NODAL_LOOKUP (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; Computed_field_lookup_package *computed_field_lookup_package; Computed_field_modify_data *field_modify; if (state&&(field_modify=(Computed_field_modify_data *)field_modify_void) && (computed_field_lookup_package= (Computed_field_lookup_package *) computed_field_lookup_package_void)) { return_code = 1; Cmiss_field_id source_field = 0; char *nodeset_name = duplicate_string("cmiss_nodes"); char node_flag = 0; int node_identifier = 0; if ((NULL != field_modify->get_field()) && (computed_field_nodal_lookup_type_string == Computed_field_get_type_string(field_modify->get_field()))) { Cmiss_node_id lookup_node = 0; return_code = Computed_field_get_type_nodal_lookup(field_modify->get_field(), &source_field, &lookup_node); if (source_field) { ACCESS(Computed_field)(source_field); } if (lookup_node) { node_identifier = get_FE_node_identifier(lookup_node); FE_region *fe_region = FE_node_get_FE_region(lookup_node); if (!FE_region_contains_FE_node(fe_region, lookup_node)) { DEALLOCATE(nodeset_name); nodeset_name = duplicate_string("cmiss_data"); } node_flag = 1; } } Option_table *option_table = CREATE(Option_table)(); /* source field */ Set_Computed_field_conditional_data set_source_field_data; set_source_field_data.computed_field_manager = field_modify->get_field_manager(); set_source_field_data.conditional_function = Computed_field_has_numerical_components; set_source_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table,"field", &source_field, &set_source_field_data,set_Computed_field_conditional); /* the node to nodal_lookup */ Option_table_add_entry(option_table, "node", &node_identifier, &node_flag, set_int_and_char_flag); /* the nodeset the node is from */ Option_table_add_string_entry(option_table, "nodeset", &nodeset_name, " NODE_GROUP_FIELD_NAME|[GROUP_NAME.]cmiss_nodes|cmiss_data[cmiss_nodes]"); return_code = Option_table_multi_parse(option_table,state); DESTROY(Option_table)(&option_table); if (return_code && node_flag) { Cmiss_nodeset_id nodeset = Cmiss_field_module_find_nodeset_by_name(field_modify->get_field_module(), nodeset_name); Cmiss_node_id node = Cmiss_nodeset_find_node_by_identifier(nodeset, node_identifier); if (node) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_nodal_lookup(field_modify->get_field_module(), source_field, node)); } else { display_message(ERROR_MESSAGE, "define field nodal lookup. Invalid node %d", node_identifier); return_code = 0; } Cmiss_node_destroy(&node); Cmiss_nodeset_destroy(&nodeset); } else { if ((!state->current_token)|| (strcmp(PARSER_HELP_STRING,state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING,state->current_token))) { display_message(ERROR_MESSAGE, "define_Computed_field_type_time_nodal_lookup. Failed"); } } DEALLOCATE(nodeset_name); REACCESS(Computed_field)(&source_field, NULL); } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_nodal_lookup. Invalid argument(s)"); return_code = 0; } return (return_code); }
void NavPathWaypt_Destroy(navpathwaypt_t* waypt) { DEALLOCATE(navpathwaypt_t, (char*)waypt); }
int set_Cmiss_region_path(struct Parse_state *state, void *path_address_void, void *root_region_void) /******************************************************************************* LAST MODIFIED : 13 January 2003 DESCRIPTION : Modifier function for entering a path to a Cmiss_region, starting at <root_region>. ==============================================================================*/ { const char *current_token; char **path_address; int return_code; struct Cmiss_region *region, *root_region; ENTER(set_Cmiss_region_path); if (state && (root_region = (struct Cmiss_region *)root_region_void)) { if ((current_token = state->current_token)) { if (!Parse_state_help_mode(state)) { region = Cmiss_region_find_subregion_at_path( root_region, current_token); if (region) { if ((path_address = (char **)path_address_void)) { if (*path_address) { DEALLOCATE(*path_address); } if ((*path_address = duplicate_string(current_token))) { return_code = shift_Parse_state(state, 1); } else { display_message(ERROR_MESSAGE, "set_Cmiss_region_path. Could not allocate memory for path"); return_code = 0; } } else { display_message(ERROR_MESSAGE, "set_Cmiss_region_path. Missing path_address"); return_code = 0; } DEACCESS(Cmiss_region)(®ion); } else { display_message(ERROR_MESSAGE, "Invalid region path: %s", current_token); display_parse_state_location(state); return_code = 0; } } else { display_message(INFORMATION_MESSAGE," PATH_TO_REGION"); if ((path_address = (char **)path_address_void) && (*path_address)) { display_message(INFORMATION_MESSAGE, "[%s]", *path_address); } return_code = 1; } } else { display_message(ERROR_MESSAGE, "Missing region path"); display_parse_state_location(state); return_code = 0; } } else { display_message(ERROR_MESSAGE, "set_Cmiss_region_path. Missing state"); return_code = 0; } LEAVE; return (return_code); } /* set_Cmiss_region_path */
void BitSet::clear(){ DEALLOCATE(m_bits); m_bits =0; m_bits_holder_count =0; }
int define_Computed_field_type_histogram_image_filter(struct Parse_state *state, void *field_modify_void, void *computed_field_simple_package_void) /******************************************************************************* LAST MODIFIED : 18 October 2006 DESCRIPTION : Converts <field> into type DISCRETEGAUSSIAN (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int i, original_number_of_components, previous_state_index, return_code; int *numberOfBins; double marginalScale, *histogramMinimum, *histogramMaximum; struct Computed_field *source_field; Computed_field_modify_data *field_modify; struct Option_table *option_table; struct Set_Computed_field_conditional_data set_source_field_data; ENTER(define_Computed_field_type_histogram_image_filter); USE_PARAMETER(computed_field_simple_package_void); if (state && (field_modify=(Computed_field_modify_data *)field_modify_void)) { return_code = 1; /* get valid parameters for projection field */ source_field = (struct Computed_field *)NULL; numberOfBins = (int *)NULL; histogramMinimum = (double *)NULL; histogramMaximum = (double *)NULL; marginalScale = 10.0; original_number_of_components = 0; if ((NULL != field_modify->get_field()) && (computed_field_histogram_image_filter_type_string == Computed_field_get_type_string(field_modify->get_field()))) { return_code = Cmiss_field_get_type_histogram_image_filter(field_modify->get_field(), &source_field, &numberOfBins, &marginalScale, &histogramMinimum, &histogramMaximum); original_number_of_components = source_field->number_of_components; } if (return_code) { /* must access objects for set functions */ if (source_field) { ACCESS(Computed_field)(source_field); } if (state->current_token && (!(strcmp(PARSER_HELP_STRING, state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING, state->current_token)))) { /* Handle help separately */ option_table = CREATE(Option_table)(); Option_table_add_help(option_table, "The histogram_filter field uses the itk::ImageToHistogramGenerator code to generate binned values representing the relative frequency of the various pixel intensities. There should be a number_of_bins for each component direction, and so the total number of bins will be a product of these, so that for a 3 component image you would get a volume histogram. " "If you wanted a histogram for a single component then set the number_of_bins for the other components to 1. " "If you do not set the optional histogram_minimums or histogram_maximums (which is a vector of values, 1 for each source component) then the histogram will automatically range the values to the minimum and maximum values in the source image."); /* field */ set_source_field_data.computed_field_manager = field_modify->get_field_manager(); set_source_field_data.conditional_function = Computed_field_has_numerical_components; set_source_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "field", &source_field, &set_source_field_data, set_Computed_field_conditional); /* histogramMinimum */ double dummyHistogramMinimum = 0.0; Option_table_add_double_entry(option_table, "histogram_minimums", &dummyHistogramMinimum); /* histogramMinimum */ double dummyHistogramMaximum = 1.0; Option_table_add_double_entry(option_table, "histogram_maximums", &dummyHistogramMaximum); /* numberOfBins */ int dummyNumberOfBins = 64; Option_table_add_int_positive_entry(option_table, "number_of_bins", &dummyNumberOfBins); /* marginalScale */ Option_table_add_double_entry(option_table, "marginal_scale", &marginalScale); return_code = Option_table_multi_parse(option_table, state); DESTROY(Option_table)(&option_table); } if (return_code) { // store previous state so that we can return to it previous_state_index = state->current_index; /* parse the source field so we know the dimension. */ option_table = CREATE(Option_table)(); /* field */ set_source_field_data.computed_field_manager = field_modify->get_field_manager(); set_source_field_data.conditional_function = Computed_field_has_numerical_components; set_source_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "field", &source_field, &set_source_field_data, set_Computed_field_conditional); /* Ignore all the other entries */ Option_table_ignore_all_unmatched_entries(option_table); return_code = Option_table_multi_parse(option_table, state); DESTROY(Option_table)(&option_table); /* Return back to where we were */ shift_Parse_state(state, previous_state_index - state->current_index); if (!source_field) { display_message(ERROR_MESSAGE, "define_Computed_field_type_histogram_image_filter. " "Missing source field"); return_code = 0; } } if (return_code) { if (source_field->number_of_components != original_number_of_components) { REALLOCATE(numberOfBins, numberOfBins, int, source_field->number_of_components); for (i = 0 ; i < source_field->number_of_components ; i++) { numberOfBins[i] = 64; } } option_table = CREATE(Option_table)(); /* field, ignore as we have already got it */ int field_expected_parameters = 1; Option_table_add_ignore_token_entry( option_table, "field", &field_expected_parameters); /* histogramMinimum */ int histogramMinimumLength = 0; if (histogramMinimum) histogramMinimumLength = original_number_of_components; Option_table_add_variable_length_double_vector_entry(option_table, "histogram_minimums", &histogramMinimumLength, &histogramMinimum); /* histogramMaximum */ int histogramMaximumLength = 0; if (histogramMaximum) histogramMaximumLength = original_number_of_components; Option_table_add_variable_length_double_vector_entry(option_table, "histogram_maximums", &histogramMaximumLength, &histogramMaximum); /* numberOfBins */ Option_table_add_int_vector_entry(option_table, "number_of_bins", numberOfBins, &source_field->number_of_components); /* marginalScale */ Option_table_add_double_entry(option_table, "marginal_scale", &marginalScale); return_code = Option_table_multi_parse(option_table, state); DESTROY(Option_table)(&option_table); if (histogramMinimum && histogramMinimumLength != source_field->number_of_components) { display_message(ERROR_MESSAGE, "define_Computed_field_type_histogram_image_filter. Length of histogram_minimums vector does not match source field compontents"); return_code = 0; } if (histogramMaximum && histogramMaximumLength != source_field->number_of_components) { display_message(ERROR_MESSAGE, "define_Computed_field_type_histogram_image_filter. Length of histogram_Maximums vector does not match source field compontents"); return_code = 0; } if (return_code) { return_code = field_modify->update_field_and_deaccess( Cmiss_field_module_create_histogram_image_filter( field_modify->get_field_module(), source_field, numberOfBins, marginalScale, histogramMinimum, histogramMaximum)); } if (!return_code) { /* error */ display_message(ERROR_MESSAGE, "define_Computed_field_type_histogram_image_filter. Failed"); } } if (source_field) { DEACCESS(Computed_field)(&source_field); } if (numberOfBins) { DEALLOCATE(numberOfBins); } }
void Scene::loadSceneData(int sceneNum) { _activeScreenNumber = sceneNum; if (g_vm->getGameID() == GType_Ringworld2) { // Most scenes in Ringworld 2 don't have a scene size resource, but rather just have // a standard 320x200 size. Only read the scene size data for the specific few scenes switch (sceneNum) { case 700: case 1020: case 1100: case 1700: case 2600: case 2950: case 3100: case 3101: case 3275: case 3600: { // Get the basic scene size from the resource byte *data = g_resourceManager->getResource(RES_BITMAP, sceneNum, 9999); _backgroundBounds = Rect(0, 0, READ_LE_UINT16(data), READ_LE_UINT16(data + 2)); DEALLOCATE(data); break; } default: // For all other scenes, use a standard screen size _backgroundBounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); break; } } else { // Get the basic scene size byte *data = g_resourceManager->getResource(RES_BITMAP, sceneNum, 9999); _backgroundBounds = Rect(0, 0, READ_LE_UINT16(data), READ_LE_UINT16(data + 2)); DEALLOCATE(data); } g_globals->_sceneManager._scene->_sceneBounds.contain(_backgroundBounds); // Set up a surface for storing the scene background SceneManager::setBackSurface(); // Load the data lists for the scene g_globals->_walkRegions.load(sceneNum); // Load the item regions of the scene g_globals->_sceneRegions.load(sceneNum); // Load the priority regions _priorities.load(sceneNum); // Initialize the section enabled list Common::fill(&_enabledSections[0], &_enabledSections[16 * 16], 0xffff); g_globals->_sceneOffset.x = (_sceneBounds.left / 160) * 160; g_globals->_sceneOffset.y = (_sceneBounds.top / 100) * 100; g_globals->_paneRefreshFlag[0] = 1; g_globals->_paneRefreshFlag[1] = 1; g_globals->_sceneManager._loadMode = 1; g_globals->_sceneManager._sceneLoadCount = 0; g_globals->_sceneManager._sceneBgOffset = Common::Point(0, 0); // Load the background for the scene loadBackground(0, 0); }
wxComfileWindow(Comfile_window *comfile_window): comfile_window(comfile_window) { wxXmlInit_comfile_window_wx(); comfile_window->wx_comfile_window = (wxComfileWindow *)NULL; wxXmlResource::Get()->LoadFrame(this, (wxWindow *)NULL, _T("CmguiComfileWindow")); this->SetIcon(cmiss_icon_xpm); comfile_listbox = XRCCTRL(*this, "ComfileListBox", wxListBox); this_frame = XRCCTRL(*this, "CmguiComfileWindow", wxFrame); char **command,*line, *temp_string, *command_string; struct IO_stream *comfile; int i,number_of_commands; wxString blank = wxT(""); if ((comfile_window->file_name)&& (comfile=CREATE(IO_stream)(comfile_window->io_stream_package))&& IO_stream_open_for_read(comfile, comfile_window->file_name)) { number_of_commands=0; while ((EOF!=IO_stream_scan(comfile," "))&&!IO_stream_end_of_stream(comfile)&& IO_stream_read_string(comfile,"[^\n]",&line)) { command_string=trim_string(line); if (command_string != NULL) { number = comfile_listbox->GetCount(); if (number == 0) comfile_listbox->InsertItems(1, &blank,number); number = comfile_listbox->GetCount(); wxString string(command_string, wxConvUTF8); comfile_listbox->InsertItems(1,&string, number-1); number_of_commands++; DEALLOCATE(command_string); } DEALLOCATE(line); } if (!IO_stream_end_of_stream(comfile)) { display_message(ERROR_MESSAGE, "identify_command_list. Error reading comfile"); } if (number_of_commands>0) { if (ALLOCATE(command,char *,number_of_commands)) { comfile_window->number_of_commands=number_of_commands; comfile_window->commands=command; for (i=number_of_commands;i>0;i--) { *command=(char *)NULL; command++; } temp_string = NULL; if (ALLOCATE(temp_string,char,(strlen(comfile_window->name) + 10))) { strcpy(temp_string, "comfile: "); strcat(temp_string, comfile_window->name); temp_string[(strlen(comfile_window->name) + 9)]='\0'; this_frame->SetTitle(wxString::FromAscii(temp_string)); if (temp_string) { DEALLOCATE(temp_string); } } } else {
int gfx_define_font(struct Parse_state *state, void *dummy_to_be_modified,void *graphics_module_void) /******************************************************************************* LAST MODIFIED : 12 March 2008 DESCRIPTION : Executes a GFX DEFINE FONT command. ==============================================================================*/ { const char *current_token, *font_name; int return_code; Cmiss_graphics_module_id graphics_module = 0; if (state && (graphics_module = (Cmiss_graphics_module_id)graphics_module_void)) { if (NULL != (current_token = state->current_token)) { if (strcmp(PARSER_HELP_STRING,current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING,current_token)) { font_name = current_token; if (shift_Parse_state(state,1)&& (current_token=state->current_token)) { Cmiss_graphics_font_id font = Cmiss_graphics_module_find_font_by_name( graphics_module, font_name); if (!font) { font = Cmiss_graphics_module_create_font(graphics_module); Cmiss_graphics_font_set_name(font, font_name); } Cmiss_graphics_font_type font_type = Cmiss_graphics_font_get_type(font); Cmiss_graphics_font_true_type true_type = Cmiss_graphics_font_get_true_type(font); char *font_type_string = 0; char *true_type_string = 0; int number_of_valid_strings_font_type = 0; int number_of_valid_strings_true_type = 0; const char **valid_font_type_strings = ENUMERATOR_GET_VALID_STRINGS(Cmiss_graphics_font_type)( &number_of_valid_strings_font_type, (ENUMERATOR_CONDITIONAL_FUNCTION(Cmiss_graphics_font_type) *)NULL, (void *)NULL); std::string all_font_types = " "; for (int i = 0; i < number_of_valid_strings_font_type; i++) { if (i) all_font_types += "|"; all_font_types += valid_font_type_strings[i]; } const char *all_font_types_help = all_font_types.c_str(); const char **valid_font_true_type_strings = ENUMERATOR_GET_VALID_STRINGS(Cmiss_graphics_font_true_type)( &number_of_valid_strings_true_type, (ENUMERATOR_CONDITIONAL_FUNCTION(Cmiss_graphics_font_true_type) *)NULL, (void *)NULL); std::string all_font_true_types = " "; for (int i = 0; i < number_of_valid_strings_true_type; i++) { if (i) all_font_true_types += "|"; all_font_true_types += valid_font_true_type_strings[i]; } const char *all_font_true_types_help = all_font_true_types.c_str(); struct Option_table *option_table = CREATE(Option_table)(); int bold_flag = 0; int italic_flag = 0; float depth = (float)Cmiss_graphics_font_get_depth(font); int size = Cmiss_graphics_font_get_size(font); /* bold */ Option_table_add_entry(option_table, "bold", (void *)&bold_flag, NULL, set_char_flag); Option_table_add_entry(option_table, "italic", (void *)&italic_flag, NULL, set_char_flag); Option_table_add_entry(option_table,"depth", &(depth),NULL,set_float); Option_table_add_entry(option_table,"size", &(size),NULL,set_int_non_negative); Option_table_add_string_entry(option_table, "font_type", &font_type_string, all_font_types_help); Option_table_add_string_entry(option_table, "true_type", &true_type_string, all_font_true_types_help); return_code = Option_table_multi_parse(option_table, state); if (return_code) { if (font_type_string) { STRING_TO_ENUMERATOR(Cmiss_graphics_font_type)(font_type_string, &font_type); if (CMISS_GRAPHICS_FONT_TYPE_INVALID == font_type) { display_message(ERROR_MESSAGE, "gfx_define_font: Invalid font type %s", font_type_string); return_code = 0; } } else { display_message(ERROR_MESSAGE, "gfx_define_font: Missing font_type argument"); return_code = 0; } if (true_type_string) { STRING_TO_ENUMERATOR(Cmiss_graphics_font_true_type)(true_type_string, &true_type); if (CMISS_GRAPHICS_FONT_TRUE_TYPE_INVALID == true_type) { display_message(ERROR_MESSAGE, "gfx_define_font: Invalid true type %s", true_type_string); return_code = 0; } } else { display_message(ERROR_MESSAGE, "gfx_define_font: Missing true_type argument"); return_code = 0; } if (font) { Cmiss_graphics_font_set_bold(font, bold_flag); Cmiss_graphics_font_set_italic(font, italic_flag); Cmiss_graphics_font_set_depth(font, depth); Cmiss_graphics_font_set_size(font, size); Cmiss_graphics_font_set_true_type(font, true_type); Cmiss_graphics_font_set_type(font, font_type); } } Cmiss_graphics_font_destroy(&font); DEALLOCATE(font_type_string); DEALLOCATE(true_type_string); DESTROY(Option_table)(&option_table); } else { display_message(WARNING_MESSAGE,"Missing font string."); display_parse_state_location(state); return_code=0; } }
int define_Computed_field_type_compose(struct Parse_state *state, void *field_modify_void, void *computed_field_compose_package_void) /******************************************************************************* LAST MODIFIED : 24 August 2006 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_COMPOSE (if it is not already) and allows its contents to be modified. ==============================================================================*/ { int return_code; Computed_field_compose_package *computed_field_compose_package; Computed_field_modify_data *field_modify; struct Option_table *find_option_table, *option_table, *out_of_bounds_option_table; struct Set_Computed_field_conditional_data set_calculate_values_field_data, set_find_element_xi_field_data, set_texture_coordinates_field_data; ENTER(define_Computed_field_type_compose); if (state && (field_modify=(Computed_field_modify_data *)field_modify_void) && (computed_field_compose_package = (Computed_field_compose_package *) computed_field_compose_package_void)) { return_code = 1; Cmiss_mesh_id mesh = 0; char *search_group_name = 0; Cmiss_field_id calculate_values_field = 0; Cmiss_field_id find_element_xi_field = 0; Cmiss_field_id texture_coordinates_field = 0; char find_nearest_flag = 0; char find_exact_flag = 0; char use_point_five_when_out_of_bounds_flag = 0; char fail_when_out_of_bounds_flag = 0; int use_point_five_when_out_of_bounds = 0; int element_dimension = 0; /* Maintain the existing behaviour as the default */ int find_nearest = 0; /* get valid parameters for composite field */ if (field_modify->get_field()) { Computed_field_compose* compose_core = dynamic_cast<Computed_field_compose*>(field_modify->get_field()->core); if (compose_core) { return_code = compose_core->get_type( &calculate_values_field, &find_element_xi_field, &texture_coordinates_field, &mesh, &find_nearest, &use_point_five_when_out_of_bounds); if (mesh) { Cmiss_mesh_access(mesh); element_dimension = Cmiss_mesh_get_dimension(mesh); } } } if (return_code) { /* must access objects for set functions */ if (calculate_values_field) { ACCESS(Computed_field)(calculate_values_field); } if (find_element_xi_field) { ACCESS(Computed_field)(find_element_xi_field); } if (texture_coordinates_field) { ACCESS(Computed_field)(texture_coordinates_field); } option_table = CREATE(Option_table)(); Option_table_add_help(option_table, "The value of a compose field is found by evaluating the <texture_coordinates_field>, " "then searching for matching values of the <find_element_xi_field> in the elements of " "the <mesh> (alternatively specified by <group> and <element_dimension>) and then " "finally evaluating the <calculate_values_field> at this found location. You can " "specify the outcome if the matching values cannot be found in the mesh with " "<use_point_five_when_out_of_bounds> or <fail_when_out_of_bounds>. See examples " "a/resample_texture or a/create_slices where the compose field is used to find the " "equivalent coordinate in another element to evaluate a texture."); /* calculate_values_field */ set_calculate_values_field_data.computed_field_manager = field_modify->get_field_manager(); set_calculate_values_field_data.conditional_function = Computed_field_has_numerical_components; set_calculate_values_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "calculate_values_field", &calculate_values_field, &set_calculate_values_field_data, set_Computed_field_conditional); Option_table_add_int_positive_entry(option_table,"element_dimension", &element_dimension); /* find_element_xi_field */ set_find_element_xi_field_data.computed_field_manager = field_modify->get_field_manager(); set_find_element_xi_field_data.conditional_function = Computed_field_has_numerical_components; set_find_element_xi_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "find_element_xi_field", &find_element_xi_field, &set_find_element_xi_field_data, set_Computed_field_conditional); find_option_table=CREATE(Option_table)(); Option_table_add_char_flag_entry(find_option_table,"find_nearest", &find_nearest_flag); Option_table_add_char_flag_entry(find_option_table,"find_exact", &find_exact_flag); Option_table_add_suboption_table(option_table, find_option_table); /* group */ Option_table_add_string_entry(option_table, "group", &search_group_name, " GROUP_NAME"); // mesh Option_table_add_mesh_entry(option_table, "mesh", field_modify->get_region(), &mesh); /* texture_coordinates_field */ set_texture_coordinates_field_data.computed_field_manager = field_modify->get_field_manager(); set_texture_coordinates_field_data.conditional_function = Computed_field_has_numerical_components; set_texture_coordinates_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "texture_coordinates_field", &texture_coordinates_field, &set_texture_coordinates_field_data, set_Computed_field_conditional); out_of_bounds_option_table=CREATE(Option_table)(); /* use_point_five_when_out_of_bounds */ Option_table_add_char_flag_entry(out_of_bounds_option_table, "use_point_five_when_out_of_bounds", &use_point_five_when_out_of_bounds_flag); Option_table_add_char_flag_entry(out_of_bounds_option_table, "fail_when_out_of_bounds", &fail_when_out_of_bounds_flag); Option_table_add_suboption_table(option_table, out_of_bounds_option_table); return_code = Option_table_multi_parse(option_table, state); if (return_code && !mesh) { mesh = Cmiss_field_module_find_mesh_by_dimension( field_modify->get_field_module(), element_dimension); if (search_group_name) { Cmiss_field_id group_field = Cmiss_field_module_find_field_by_name(field_modify->get_field_module(), search_group_name); Cmiss_field_group_id group = Cmiss_field_cast_group(group_field); Cmiss_field_element_group_id element_group = Cmiss_field_group_get_element_group(group, mesh); Cmiss_mesh_destroy(&mesh); mesh = Cmiss_mesh_group_base_cast(Cmiss_field_element_group_get_mesh(element_group)); Cmiss_field_element_group_destroy(&element_group); Cmiss_field_group_destroy(&group); Cmiss_field_destroy(&group_field); } } if (return_code && !mesh) { display_message(ERROR_MESSAGE, "You must specify a mesh (or element_dimension and optional group)."); return_code = 0; } if (return_code) { if (find_nearest_flag && find_exact_flag) { display_message(ERROR_MESSAGE, "Specify only one of find_nearest and find_exact"); return_code = 0; } if (find_nearest_flag) { find_nearest = 1; } else if (find_exact_flag) { find_nearest = 0; } if (use_point_five_when_out_of_bounds_flag && fail_when_out_of_bounds_flag) { display_message(ERROR_MESSAGE, "Specify only one of use_point_five_when_out_of_bounds " "and fail_when_out_of_bounds"); return_code = 0; } if (use_point_five_when_out_of_bounds_flag) { use_point_five_when_out_of_bounds = 1; } else if (fail_when_out_of_bounds_flag) { use_point_five_when_out_of_bounds = 0; } } if (return_code) { return_code = field_modify->update_field_and_deaccess( Computed_field_create_compose(field_modify->get_field_module(), texture_coordinates_field, find_element_xi_field, calculate_values_field, mesh, find_nearest, use_point_five_when_out_of_bounds)); } if (!return_code) { if ((!state->current_token) || (strcmp(PARSER_HELP_STRING, state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING, state->current_token))) { /* error */ display_message(ERROR_MESSAGE, "define_Computed_field_type_compose. Failed"); } } Cmiss_mesh_destroy(&mesh); if (calculate_values_field) { DEACCESS(Computed_field)(&calculate_values_field); } if (find_element_xi_field) { DEACCESS(Computed_field)(&find_element_xi_field); } if (search_group_name) { DEALLOCATE(search_group_name); } if (texture_coordinates_field) { DEACCESS(Computed_field)(&texture_coordinates_field); } DESTROY(Option_table)(&option_table); } } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_compose. Invalid argument(s)"); return_code = 0; } LEAVE; return (return_code); } /* define_Computed_field_type_compose */
/** * Sets the specified cursor * * @cursorType Specified cursor number */ void EventsClass::setCursor(CursorType cursorType) { if (cursorType == _lastCursor) return; _lastCursor = cursorType; g_globals->clearFlag(122); CursorMan.showMouse(true); const byte *cursor; bool delFlag = true; uint size; bool questionEnabled = false; switch (cursorType) { case CURSOR_NONE: // No cursor g_globals->setFlag(122); if ((g_vm->getGameID() != GType_Ringworld) || ((g_vm->getGameID() == GType_Ringworld) && (g_vm->getFeatures() & GF_DEMO))) { CursorMan.showMouse(false); return; } cursor = g_resourceManager->getSubResource(4, 1, 6, &size); break; case CURSOR_LOOK: // Look cursor if (g_vm->getGameID() == GType_BlueForce) { cursor = g_resourceManager->getSubResource(1, 5, 3, &size); } else if (g_vm->getGameID() == GType_Ringworld2) { cursor = g_resourceManager->getSubResource(5, 1, 5, &size); } else { cursor = g_resourceManager->getSubResource(4, 1, 5, &size); } _currentCursor = CURSOR_LOOK; break; case CURSOR_USE: // Use cursor if (g_vm->getGameID() == GType_BlueForce) { cursor = g_resourceManager->getSubResource(1, 5, 2, &size); } else if (g_vm->getGameID() == GType_Ringworld2) { cursor = g_resourceManager->getSubResource(5, 1, 4, &size); } else { cursor = g_resourceManager->getSubResource(4, 1, 4, &size); } _currentCursor = CURSOR_USE; break; case CURSOR_TALK: // Talk cursor if (g_vm->getGameID() == GType_BlueForce) { cursor = g_resourceManager->getSubResource(1, 5, 4, &size); } else if (g_vm->getGameID() == GType_Ringworld2) { cursor = g_resourceManager->getSubResource(5, 1, 6, &size); } else { cursor = g_resourceManager->getSubResource(4, 1, 3, &size); } _currentCursor = CURSOR_TALK; break; case CURSOR_EXIT: // Exit cursor (Blue Force) assert(g_vm->getGameID() == GType_BlueForce); cursor = g_resourceManager->getSubResource(1, 5, 7, &size); _currentCursor = CURSOR_EXIT; break; case CURSOR_PRINTER: // Printer cursor (Blue Force) assert(g_vm->getGameID() == GType_BlueForce); cursor = g_resourceManager->getSubResource(1, 7, 6, &size); _currentCursor = CURSOR_PRINTER; break; case CURSOR_ARROW: // Arrow cursor cursor = CURSOR_ARROW_DATA; delFlag = false; break; case CURSOR_WALK: default: switch (g_vm->getGameID()) { case GType_BlueForce: if (cursorType == CURSOR_WALK) { cursor = g_resourceManager->getSubResource(1, 5, 1, &size); } else { // Inventory icon cursor = g_resourceManager->getSubResource(10, ((int)cursorType - 1) / 20 + 1, ((int)cursorType - 1) % 20 + 1, &size); questionEnabled = true; } _currentCursor = cursorType; break; case GType_Ringworld2: if (cursorType == CURSOR_WALK) { cursor = CURSOR_WALK_DATA; delFlag = false; } else { // Inventory icon InvObject *invObject = g_globals->_inventory->getItem((int)cursorType); cursor = g_resourceManager->getSubResource(6, invObject->_strip, invObject->_frame, &size); questionEnabled = true; } _currentCursor = cursorType; break; default: // For Ringworld, always treat as the walk cursor cursor = CURSOR_WALK_DATA; _currentCursor = CURSOR_WALK; delFlag = false; break; } break; // Ringworld 2 specific cursors case EXITCURSOR_N: case EXITCURSOR_S: case EXITCURSOR_W: case EXITCURSOR_E: case EXITCURSOR_LEFT_HAND: case CURSOR_INVALID: case EXITCURSOR_NE: case EXITCURSOR_SE: case EXITCURSOR_SW: case EXITCURSOR_NW: case SHADECURSOR_UP: case SHADECURSOR_DOWN: case SHADECURSOR_HAND: _currentCursor = cursorType; cursor = g_resourceManager->getSubResource(5, 1, cursorType - R2CURSORS_START, &size); break; case R2_CURSOR_ROPE: _currentCursor = cursorType; cursor = g_resourceManager->getSubResource(5, 4, 1, &size); break; } // Decode the cursor GfxSurface s = surfaceFromRes(cursor); Graphics::Surface surface = s.lockSurface(); const byte *cursorData = (const byte *)surface.getPixels(); CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor); s.unlockSurface(); if (delFlag) DEALLOCATE(cursor); // For Blue Force and Return to Ringworld, enable the question button when an inventory icon is selected if (g_vm->getGameID() != GType_Ringworld) T2_GLOBALS._uiElements._question.setEnabled(questionEnabled); }
void StringFieldValueCache::setString(const char *string_in) { if (stringValue) DEALLOCATE(stringValue); stringValue = duplicate_string(string_in); }
/** * Executes a GFX DEFINE GLYPH command. */ int gfx_define_glyph(struct Parse_state *state, void *glyph_name_void, void *define_glyph_data_void) { int return_code = 1; Define_glyph_data *define_glyph_data = static_cast<Define_glyph_data *>(define_glyph_data_void); if ((state) && (define_glyph_data)) { if (state->current_token) { const char *glyph_name = static_cast<char *>(glyph_name_void); bool process = false; if (glyph_name) { process = true; } else { if (Parse_state_help_mode(state)) { glyph_name = "GLYPH_NAME"; Option_table *option_table = CREATE(Option_table)(); Option_table_add_entry(option_table, "GLYPH_NAME", (void *)glyph_name, define_glyph_data_void, gfx_define_glyph); return_code = Option_table_parse(option_table, state); DESTROY(Option_table)(&option_table); } else { glyph_name = state->current_token; shift_Parse_state(state, 1); process = true; } } if (process) { char *scene_path_name = 0; struct Option_table *option_table = CREATE(Option_table)(); Option_table_add_help(option_table, "The 'scene' option defines a static glyph from the named graphics " "at the region/scene path."); /* scene (graphics) */ Option_table_add_string_entry(option_table, "scene", &scene_path_name, " [/REGION_PATH.]GRAPHICS_NAME"); return_code = Option_table_multi_parse(option_table, state); if (return_code) { cmzn_graphics* graphics = 0; const char *scene_name = 0; const char *graphics_name = 0; if (scene_path_name) export_object_name_parser(scene_path_name, &scene_name, &graphics_name); cmzn_region *input_region = cmzn_region_find_subregion_at_path(define_glyph_data->root_region, scene_name); if (input_region && graphics_name) { cmzn_scene_id scene = cmzn_region_get_scene(input_region); graphics = cmzn_scene_find_graphics_by_name(scene, graphics_name); cmzn_scene_destroy(&scene); } if (!graphics) { display_message(ERROR_MESSAGE, "gfx_define_glyph. Invalid scene region path or graphics name"); return_code = 0; } else { cmzn_glyphmodule_begin_change(define_glyph_data->glyphmodule); cmzn_glyph_id glyph = cmzn_glyphmodule_find_glyph_by_name(define_glyph_data->glyphmodule, glyph_name); if (glyph) { struct GT_object *graphics_object = cmzn_graphics_copy_graphics_object( graphics); if (!cmzn_glyph_set_graphics_object(glyph, graphics_object)) { display_message(ERROR_MESSAGE, "gfx_define_glyph. Unable to change glyph"); return_code = 0; } DEACCESS(GT_object)(&graphics_object); } else { glyph = cmzn_glyphmodule_create_static_glyph_from_graphics(define_glyph_data->glyphmodule, graphics); if ((CMZN_OK != cmzn_glyph_set_name(glyph, glyph_name)) || (CMZN_OK != cmzn_glyph_set_managed(glyph, true))) { display_message(ERROR_MESSAGE, "gfx_define_glyph. Failed"); return_code = 0; } } cmzn_glyph_destroy(&glyph); cmzn_glyphmodule_end_change(define_glyph_data->glyphmodule); } cmzn_graphics_destroy(&graphics); cmzn_region_destroy(&input_region); if (scene_name) DEALLOCATE(scene_name); if (graphics_name) DEALLOCATE(graphics_name); } if (scene_path_name) DEALLOCATE(scene_path_name); DESTROY(Option_table)(&option_table); } } else { display_message(ERROR_MESSAGE, "Missing glyph name"); display_parse_state_location(state); return_code=0; } } else { display_message(ERROR_MESSAGE, "gfx_define_glyph. Invalid argument(s)"); return_code = 0; } return (return_code); }
int define_Computed_field_type_fast_marching_image_filter(struct Parse_state *state, void *field_modify_void, void *computed_field_simple_package_void) /******************************************************************************* LAST MODIFIED : 30 August 2006 DESCRIPTION : Converts <field> into type COMPUTED_FIELD_FAST_MARCHING_IMAGE_FILTER (if it is not already) and allows its contents to be modified. ==============================================================================*/ { double stopping_value; int num_seed_points; int dimension; double *seed_points; double *seed_values; int *output_size; int length_seed_points; int return_code; int previous_state_index; int i; struct Computed_field *source_field; Computed_field_modify_data *field_modify; struct Option_table *option_table; struct Set_Computed_field_conditional_data set_source_field_data; ENTER(define_Computed_field_type_fast_marching_image_filter); USE_PARAMETER(computed_field_simple_package_void); if (state && (field_modify=(Computed_field_modify_data *)field_modify_void)) { return_code = 1; source_field = (struct Computed_field *)NULL; stopping_value = 100; num_seed_points = 1; dimension = 2; length_seed_points = num_seed_points * dimension; seed_points = (double *)NULL; seed_values = (double *)NULL; output_size = (int *)NULL; ALLOCATE(seed_points, double, length_seed_points); ALLOCATE(seed_values, double, num_seed_points); ALLOCATE(output_size, int, dimension); // should probably default to having 1 seed seed_points[0] = 0.5; // pjb: is this ok? seed_points[1] = 0.5; seed_values[0] = 0.0; output_size[0] = 128; output_size[1] = 128; /* get valid parameters for projection field */ if ((NULL != field_modify->get_field()) && (computed_field_fast_marching_image_filter_type_string == Computed_field_get_type_string(field_modify->get_field()))) { return_code = cmzn_field_get_type_fast_marching_image_filter(field_modify->get_field(), &source_field, &stopping_value, &num_seed_points, &dimension, &seed_points, &seed_values, &output_size); } if (return_code) { if (source_field) { ACCESS(Computed_field)(source_field); } if (state->current_token && (!(strcmp(PARSER_HELP_STRING, state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING, state->current_token)))) { /* Handle help separately */ option_table = CREATE(Option_table)(); Option_table_add_help(option_table, "The fast_marching_filter field uses the itk::FastMarchingImageFilter code to segment a field. The segmentation is based on a level set algorithm. The <field> it operates on is used as a speed term, to govern where the level set curve grows quickly. The speed term is usually some function (eg a sigmoid) of an image gradient field. The output field is a time crossing map, where the value at is each pixel is the time take to reach that location from the specified seed points. Values typically range from 0 through to extremely large (10 to the 38). To convert the time cross map into a segmented region use a binary threshold filter. To specify the seed points first set the <num_seed_points> and the <dimension> of the image. The <seed_points> are a list of the coordinates for the first and any subsequent seed points. It is also possible to specify non-zero initial <seed_values> if desired and to set the <output_size> of the time crossing map. See a/segmentation for an example of using this field. For more information see the itk software guide."); /* field */ set_source_field_data.computed_field_manager = field_modify->get_field_manager(); set_source_field_data.conditional_function = Computed_field_is_scalar; set_source_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "field", &source_field, &set_source_field_data, set_Computed_field_conditional); /* stopping_value */ Option_table_add_double_entry(option_table, "stopping_value", &stopping_value); /* num_seed_points */ Option_table_add_int_positive_entry(option_table, "num_seed_points", &num_seed_points); /* dimension */ Option_table_add_int_positive_entry(option_table, "dimension", &dimension); /* seed_points */ Option_table_add_double_vector_entry(option_table, "seed_points", seed_points, &length_seed_points); /* seed_values */ Option_table_add_double_vector_entry(option_table, "seed_values", seed_values, &num_seed_points); /* output_size */ Option_table_add_int_vector_entry(option_table, "output_size", output_size, &dimension); return_code = Option_table_multi_parse(option_table, state); DESTROY(Option_table)(&option_table); } if (return_code) { // store previous state so that we can return to it previous_state_index = state->current_index; /* parse the two options which determine the number of seed values and hence the size of the array that must be created to read in the number of seed values. */ option_table = CREATE(Option_table)(); /* num_seed_points */ Option_table_add_int_positive_entry(option_table, "num_seed_points", &num_seed_points); /* dimension */ Option_table_add_int_positive_entry(option_table, "dimension", &dimension); /* Ignore all the other entries */ Option_table_ignore_all_unmatched_entries(option_table); return_code = Option_table_multi_parse(option_table, state); DESTROY(Option_table)(&option_table); /* Return back to where we were */ shift_Parse_state(state, previous_state_index - state->current_index); } /* parse the rest of the table */ if (return_code) { length_seed_points = num_seed_points * dimension; /* reallocate memory for arrays */ REALLOCATE(seed_points, seed_points, double, length_seed_points); REALLOCATE(seed_values, seed_values, double, num_seed_points); REALLOCATE(output_size, output_size, int, dimension); /* set default values, in case options are not specified in field definition. */ for (i=0; i < length_seed_points ;i++) { seed_points[i] = 0; } for (i=0; i < num_seed_points ;i++) { seed_values[i] = 0; } for (i=0; i < dimension ;i++) { output_size[i] = 128; } option_table = CREATE(Option_table)(); /* field */ set_source_field_data.computed_field_manager = field_modify->get_field_manager(); set_source_field_data.conditional_function = Computed_field_is_scalar; set_source_field_data.conditional_function_user_data = (void *)NULL; Option_table_add_entry(option_table, "field", &source_field, &set_source_field_data, set_Computed_field_conditional); /* stopping_value */ Option_table_add_double_entry(option_table, "stopping_value", &stopping_value); int num_seed_points_expected_parameters = 1; Option_table_add_ignore_token_entry(option_table, "num_seed_points", &num_seed_points_expected_parameters); int dimension_expected_parameters = 1; Option_table_add_ignore_token_entry(option_table, "dimension", &dimension_expected_parameters); Option_table_add_double_vector_entry(option_table, "seed_points", seed_points, &length_seed_points); Option_table_add_double_vector_entry(option_table, "seed_values", seed_values, &num_seed_points); Option_table_add_int_vector_entry(option_table, "output_size", output_size, &dimension); return_code=Option_table_multi_parse(option_table,state); DESTROY(Option_table)(&option_table); } /* no errors,not asking for help */ if (return_code) { if (!source_field) { display_message(ERROR_MESSAGE, "define_Computed_field_type_fast_marching_image_filter. " "Missing source field"); return_code = 0; } } if (return_code) { return_code = field_modify->update_field_and_deaccess( cmzn_fieldmodule_create_field_imagefilter_fast_marching( field_modify->get_field_module(), source_field, stopping_value, num_seed_points, dimension, seed_points, seed_values, output_size)); } if (!return_code) { if ((!state->current_token) || (strcmp(PARSER_HELP_STRING, state->current_token)&& strcmp(PARSER_RECURSIVE_HELP_STRING, state->current_token))) { /* error */ display_message(ERROR_MESSAGE, "define_Computed_field_type_fast_marching_image_filter. Failed"); } } if (source_field) { DEACCESS(Computed_field)(&source_field); } if (seed_points) { DEALLOCATE(seed_points); } if (seed_values) { DEALLOCATE(seed_values); } if (output_size) { DEALLOCATE(output_size); } } } else { display_message(ERROR_MESSAGE, "define_Computed_field_type_fast_marching_image_filter. Invalid argument(s)"); return_code = 0; } LEAVE; return (return_code); } /* define_Computed_field_type_fast_marching_image_filter */
/** * Sets the specified cursor * * @cursorType Specified cursor number */ void EventsClass::setCursor(CursorType cursorType) { if (cursorType == _lastCursor) return; _lastCursor = cursorType; _globals->clearFlag(122); CursorMan.showMouse(true); const byte *cursor; bool delFlag = true; uint size; switch (cursorType) { case CURSOR_NONE: // No cursor _globals->setFlag(122); if (_vm->getFeatures() & GF_DEMO) { CursorMan.showMouse(false); return; } cursor = _resourceManager->getSubResource(4, 1, 6, &size); break; case CURSOR_LOOK: // Look cursor cursor = _resourceManager->getSubResource(4, 1, 5, &size); _currentCursor = CURSOR_LOOK; break; case CURSOR_USE: // Use cursor cursor = _resourceManager->getSubResource(4, 1, 4, &size); _currentCursor = CURSOR_USE; break; case CURSOR_TALK: // Talk cursor cursor = _resourceManager->getSubResource(4, 1, 3, &size); _currentCursor = CURSOR_TALK; break; case CURSOR_ARROW: // Arrow cursor cursor = CURSOR_ARROW_DATA; delFlag = false; break; case CURSOR_WALK: default: // Walk cursor cursor = CURSOR_WALK_DATA; _currentCursor = CURSOR_WALK; delFlag = false; break; } // Decode the cursor GfxSurface s = surfaceFromRes(cursor); Graphics::Surface surface = s.lockSurface(); const byte *cursorData = (const byte *)surface.getBasePtr(0, 0); CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor); s.unlockSurface(); if (delFlag) DEALLOCATE(cursor); }
String::~String(){ if(m_data) DEALLOCATE(m_data); }