/****************************************************************************** Copyright (c) 1999 Unigraphics Solutions, Inc. Unpublished - All Rights Reserved *******************************************************************************/ /* Shown below is a sample program, available in the UG/Open sample directory, which demonstrates how to use UF_ROUTE functions to create a UG/Routing custom application. The sample file is named ufd_route_custom.c. This is an example of adding a custom UG/Routing application to Unigraphics. In addition to this source file, the two menu files: add_custom_route.men, and custom_route.men are needed. Please see the MenuScript chapter of the UG/Open Programmer's Guide for a detailed description of this example, the required MenuScript environment variables and directories, and the correct placement of the shared library and menu files. These files are intended to provide a template that can be modified by renaming the files, and renaming the variables and routines contained in this C file to allow you create your own application. Additional information on MenuScript can be found in: - the UG/Open MenuScript User Guide - the UG/Open API Reference Manual - the UG/Open API Programmer's Manual - the UG/Open MenuScript Quick Reference Card - the UG/Open MenuScript Menu File Reference Card */ #include #include #include #include #include #include #include #include static void RTCUST_APP__enter( void ); static void RTCUST_APP__init( void ); static void RTCUST_APP__exit( void ); static void print_error( char *fun, int status ); static UF_MB_cb_status_t RTCUST_APP__action1( UF_MB_widget_t widget, UF_MB_data_t client_data, UF_MB_activated_button_p_t call_button ); static int app_id = 0; static UF_MB_action_t actionTable[] = { { "RTCUST_APP__action1", RTCUST_APP__action1, NULL }, { NULL, NULL, NULL } }; extern void ufsta( char *param, int *retcod, int param_len ) { UF_MB_application_t appData; char name[] = "ROUTE_CUSTOM_APP_1"; int status; UF_initialize(); /* Initialize User Function */ status = UF_MB_add_actions( actionTable ); print_error( "UF_MB_add_actions", status ); /* Initialize application data */ appData.name = name; appData.id = 0; appData.init_proc = RTCUST_APP__init; appData.exit_proc = RTCUST_APP__exit; appData.enter_proc = RTCUST_APP__enter; /* Initialize application support flags */ appData.drawings_supported = FALSE; appData.design_in_context_supported = TRUE; /* Register the application with UG */ status = UF_MB_register_application( &appData ); print_error( "UF_MB_register_application", status ); /* Register the application as a UG/Routing custom app */ status = UF_ROUTE_register_custom_app( appData.id ); print_error( "UF_ROUTE_register_application", status ); app_id = appData.id; } /*----------------------------------------------------------------- -----------* * print_error * * Print the error message corresponding to the status code specified if * the status is non-zero. *------------------------------------------------------------------ ----------*/ static void print_error( char *fun, int status ) { if ( status != 0 ) { char msg[133]; UF_get_fail_message( status, msg ); printf( "%s failed with error = %d\n %s\n", fun, status, msg ); } } static UF_MB_cb_status_t RTCUST_APP__action1( UF_MB_widget_t widget, UF_MB_data_t client_data, UF_MB_activated_button_p_t call_button ) { int curr_app_id = *((int *) client_data); printf( "Application ID = %d\n", curr_app_id ); return( UF_MB_CB_CONTINUE ); } UF_ROUTE_application_view_p_t RTCUST_APP__app_view; /*----------------------------------------------------------------- -----------* * RTCUST_APP__enter * * Enter the application *------------------------------------------------------------------ ----------*/ static void RTCUST_APP__enter( void) { static loaded = FALSE; int error; printf( "Entering application\n" ); /* Place code to enter application here */ if ( ! loaded ) { error = UF_ROUTE_load_app_view( "piping.apv", &RTCUST_APP__app_view ); if ( error == 0 ) { UF_ROUTE_set_current_app_view( RTCUST_APP__app_view ); loaded = TRUE; } } UF_ROUTE_enter_custom_app( ); } /*----------------------------------------------------------------- -----------* * RTCUST_APP__init * * Initialize the application *------------------------------------------------------------------ ----------*/ static void RTCUST_APP__init( void ) { printf( "Initializing application\n" ); UF_ROUTE_init_custom_app( ); /* Place code to initialize application here */ } /*----------------------------------------------------------------- -----------* * RTCUST_APP__exit * * Exit the application *------------------------------------------------------------------ ----------*/ static void RTCUST_APP__exit( void ) { printf( "Exiting application\n" ); UF_ROUTE_exit_custom_app( ); /* Place code to cleanup for application and exit here */ } /* Sample menu file - custom_route.men Shown below is a sample UG/Menuscript file used by the UG/Routing custom application sample program, ufd_route_custom.c. VERSION 120 EDIT UG_GATEWAY_MAIN_MENUBAR AFTER UG_APP_ROUTE SEPARATOR APPLICATION_BUTTON ROUTE_CUSTOM_APP_1 LABEL Custom... LIBRARIES libcustom MENU_FILES add_route_custom.men END_OF_AFTER */