Ejemplo n.º 1
0
struct Interactive_tool *CREATE(Interactive_tool)(const char *name,const char *display_name,
	const char *tool_type_name,
	Interactive_event_handler *interactive_event_handler,
	Interactive_tool_bring_up_dialog_function *bring_up_dialog_function,
	Interactive_tool_reset_function *reset_function,
	Interactive_tool_destroy_tool_data_function *destroy_tool_data_function,
	Interactive_tool_copy_function *copy_function,
	void *tool_data)
/*******************************************************************************
LAST MODIFIED : 25 February 2008

DESCRIPTION :
Creates an Interactive_tool with the given <name> and <icon>. If an
<interactive_event_handler> is supplied it is called to pass on any input
events to the interactive_tool, with the <tool_data> passed as the third
parameter.  The <tool_type_name> is used to identify what object type the tool
is and each type of tool should pass a pointer to a static string naming that
type.
==============================================================================*/
{
	struct Interactive_tool *interactive_tool;

	ENTER(CREATE(Interactive_tool));
	if (name&&display_name)
	{
		if (ALLOCATE(interactive_tool,struct Interactive_tool,1)&&
			(interactive_tool->name=duplicate_string(name))&&
			(interactive_tool->display_name=duplicate_string(display_name)))
		{
			/* We don't duplicate this string as it is the pointer to the
				string which identifies its type */
			interactive_tool->tool_type_name=tool_type_name;
			interactive_tool->bring_up_dialog_function=bring_up_dialog_function;
			interactive_tool->reset_function=reset_function;
			interactive_tool->interactive_event_handler=interactive_event_handler;
			interactive_tool->destroy_tool_data_function=destroy_tool_data_function;
			interactive_tool->tool_data=tool_data;
			interactive_tool->copy_function=copy_function;
			interactive_tool->manager = (struct MANAGER(Interactive_tool) *)NULL;
			interactive_tool->manager_change_status = MANAGER_CHANGE_NONE(Interactive_tool);
			interactive_tool->access_count=0;
		}
		else
		{
			display_message(ERROR_MESSAGE,
				"CREATE(Interactive_tool).  Not enough memory");
			if (interactive_tool)
			{
				if (interactive_tool->name)
				{
					DEALLOCATE(interactive_tool->name);
				}
				DEALLOCATE(interactive_tool);
			}
		}
	}
Ejemplo n.º 2
0
/*
Global functions
----------------
*/
struct Environment_map *CREATE(Environment_map)(const char *name)
/*******************************************************************************
LAST MODIFIED : 1 September 1996

DESCRIPTION :
Allocates memory and assigns fields for a environment map.  Adds the environment
map to the list of all environment maps.
==============================================================================*/
{
	int i;
	struct Environment_map *environment_map;
	char *temp_name

	ENTER(CREATE(Environment_map));
	/* allocate memory for structure */
	if (ALLOCATE(environment_map,struct Environment_map,1))
	{
		if (name)
		{
			if (ALLOCATE(temp_name,char,strlen(name)+1))
			{
				strcpy(temp_name,name);
				environment_map->name = temp_name;
			}
		}
		else
		{
			if (ALLOCATE(temp_name,char,1))
			{
				*(temp_name)='\0';
				environment_map->name = temp_name;
			}
		}
		if (environment_map->name)
		{
			environment_map->access_count=0;
			environment_map->manager = (struct MANAGER(Environment_map) *)NULL;
			environment_map->manager_change_status = MANAGER_CHANGE_NONE(Environment_map);
			for (i=5;i>=0;i--)
			{
				(environment_map->face_material)[i]=
					(struct Graphical_material *)NULL;
			}
		}