⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gear_cutter_application.cpp

📁 C# 教学示例程序
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////////////
//
//  gear_cutter_application.cpp
//
//  Description:
//      Contains Unigraphics entry points for the application.
//
//////////////////////////////////////////////////////////////////////////////

//  Include files
#include <stdlib.h>
#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_mb.h>
#include <windows.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 "gear_cutter_application.h"
static void print_error( char *fun, int status );
extern DllExport int standard_hob_func( int *response );
extern "C" DllExport void cutter_database_func();
extern DllExport int tiqian_tutai_hob_func( int *response );
extern DllExport int tiqian_no_tutai_hob_func( int *response );
//----------------------------------------------------------------------------
//  Activation Methods
//----------------------------------------------------------------------------
static UF_MB_cb_status_t standard_hob_act(
	UF_MB_widget_t widget,
    UF_MB_data_t client_data,
    UF_MB_activated_button_p_t call_button );

static UF_MB_cb_status_t tiqian_tutai_hob_act(
    UF_MB_widget_t             widget,
    UF_MB_data_t               client_data,
    UF_MB_activated_button_p_t call_button );

static UF_MB_cb_status_t tiqian_no_tutai_hob_act(
    UF_MB_widget_t             widget,
    UF_MB_data_t               client_data,
    UF_MB_activated_button_p_t call_button );

static UF_MB_cb_status_t cutter_database_act(
    UF_MB_widget_t             widget,
    UF_MB_data_t               client_data,
    UF_MB_activated_button_p_t call_button );

static UF_MB_cb_status_t help_chm_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[] =
{
 {"standard_hob_act", standard_hob_act, NULL},
 {"tiqian_tutai_hob_act",tiqian_tutai_hob_act},
 {"tiqian_no_tutai_hob_act",tiqian_no_tutai_hob_act},
 {"cutter_database_act",cutter_database_act},
 {"help_chm_act",help_chm_act},
 { 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
//----------------------------------------------------------------------------

// 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();
    }
}

/*----------------------------------------------------------------------------*
 *  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 standard_hob_act(
	UF_MB_widget_t widget,
    UF_MB_data_t client_data,
    UF_MB_activated_button_p_t call_button )
{
int respond;
standard_hob_func(&respond);
return(UF_MB_CB_CONTINUE);
}

static UF_MB_cb_status_t tiqian_tutai_hob_act(
    UF_MB_widget_t             widget,
    UF_MB_data_t               client_data,
    UF_MB_activated_button_p_t call_button )
{
int respond;
tiqian_tutai_hob_func(&respond);
return(UF_MB_CB_CONTINUE);
}

static UF_MB_cb_status_t tiqian_no_tutai_hob_act(
    UF_MB_widget_t             widget,
    UF_MB_data_t               client_data,
    UF_MB_activated_button_p_t call_button )
{
int respond;
tiqian_no_tutai_hob_func(&respond);
return(UF_MB_CB_CONTINUE);
}

static UF_MB_cb_status_t cutter_database_act(
    UF_MB_widget_t             widget,
    UF_MB_data_t               client_data,
    UF_MB_activated_button_p_t call_button )
{
cutter_database_func();
return(UF_MB_CB_CONTINUE);
}

static UF_MB_cb_status_t help_chm_act(
    UF_MB_widget_t             widget,
    UF_MB_data_t               client_data,
    UF_MB_activated_button_p_t call_button )
{
uc1601("有什么问题可以与作者联系!",1);
return(UF_MB_CB_CONTINUE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -