📄 app.cpp
字号:
//////////////////////////////////////////////////////////////////////////////
//
// APP.cpp
//
// Description:
// Contains Unigraphics entry points for the application.
//
//////////////////////////////////////////////////////////////////////////////
// Include files
#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_mb.h>
#include <windows.h>
#include <stdlib.h>
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
using std::ostrstream;
using std::endl;
using std::ends;
#else
# include <strstream.h>
#endif
#include <iostream.h>
#include "APP.h"
extern DllExport int BlockFun( int *response );
static void print_error( char *fun, int status );
//----------------------------------------------------------------------------
// Activation Methods
//----------------------------------------------------------------------------
static UF_MB_cb_status_t block_act(
UF_MB_widget_t widget,
UF_MB_data_t client_data,
UF_MB_activated_button_p_t call_button );
static UF_MB_action_t actionTable[] =
{
{ "block_act", block_act, NULL},
{ NULL, NULL, NULL }
};
// Unigraphics Startup
// This entry point activates the application at Unigraphics startup
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
/* TODO: Add your application code here */
int status;
status = UF_MB_add_actions( actionTable );
print_error( "UF_MB_add_actions", status );
/* Terminate the API environment */
errorCode = UF_terminate();
}
/* Print out any error messages */
PrintErrorMessage( errorCode );
}
//----------------------------------------------------------------------------
// Utilities
//----------------------------------------------------------------------------
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 );
}
}
// Unload Handler
// This function specifies when to unload your application from Unigraphics.
// If your application registers a callback (from a MenuScript item or a
// User Defined Object for example), this function MUST return
// "UF_UNLOAD_UG_TERMINATE".
extern "C" int ufusr_ask_unload( void )
{
return( UF_UNLOAD_UG_TERMINATE );
}
/* PrintErrorMessage
**
** Prints error messages to standard error and the Unigraphics status
** line. */
static void PrintErrorMessage( int errorCode )
{
if ( 0 != errorCode )
{
/* Retrieve the associated error message */
char message[133];
UF_get_fail_message( errorCode, message );
/* Print out the message */
UF_UI_set_status( message );
// Construct a buffer to hold the text.
ostrstream error_message;
// Initialize the buffer with the required text.
error_message << endl
<< "Error:" << endl
<< message
<< endl << endl << ends;
// Write the message to standard error
cerr << error_message.str();
}
}
static UF_MB_cb_status_t block_act(
UF_MB_widget_t widget,
UF_MB_data_t client_data,
UF_MB_activated_button_p_t call_button )
{
int respond;
BlockFun(&respond);
return(UF_MB_CB_CONTINUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -