ug open api 关于UIStyler中控件的初始值问题【对你们来说应该是基础问题】
功能 启动命令 弹出 显示输入长方体的对话框
输入长宽高后按下确定 创建长方体
我创建一个uf 程序后 按下命令 启动对话框里的参数 都是 0
按下 确定创建了 一个 "10","20","30" 长方体 【但长宽高不是我输入的值】
【我输入多少创建的都是同一个长方体 】
//问题1、如何设置 初始值【一开始默认值是0】
//问题2、如何道德对话框里的值 【用它创建长方体】
//看了视频后会基础的简单操作但不大会用 UIStyler中的控件
double corner_pt[3]={10,10,10}; //定位点默认不变
char * edge_len[3]={"10","20","30"}; //改成对话框里的值怎么改
tag_t blk_tag;
UF_MODL_create_block1(UF_NULLSIGN,corner_pt,
edge_len,&blk_tag); //调用API创建方体
以下 全部 程序文件
程序文件 赖的下的 可以看看 以下 C++ API 源代码 在这里先说声谢谢 希望你们能告诉我
/* These include files are needed for the following template code. */
#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_styler.h>
#include <uf_mb.h>
#include <F:\MGNX_C++\UG_CFT\UG_CFT\UG_CFT.h>
#include <uf_modl.h>
/* The following definition defines the number of callback entries */
/* in the callback structure: */
/* UF_STYLER_callback_info_t CHANGE_cbs */
#define CHANGE_CB_COUNT ( 7 + 1 ) /* Add 1 for the terminator */
static UF_STYLER_callback_info_t CHANGE_cbs[CHANGE_CB_COUNT] =
{
{UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB , 0, CHANGE_apply_cb_gz},
{UF_STYLER_DIALOG_INDEX, UF_STYLER_DESTRUCTOR_CB , 0, CHANGE_apply_cb_hh},
{UF_STYLER_DIALOG_INDEX, UF_STYLER_OK_CB , 0, CHANGE_apply_cb_ok},
{UF_STYLER_DIALOG_INDEX, UF_STYLER_CANCEL_CB , 0, CHANGE_apply_cb_qx},
{CHANGE_REAL_0 , UF_STYLER_ACTIVATE_CB , 0, CHANGE_apply_cb_x},
{CHANGE_REAL_1 , UF_STYLER_ACTIVATE_CB , 0, CHANGE_apply_cb_y},
{CHANGE_REAL_2 , UF_STYLER_ACTIVATE_CB , 0, CHANGE_apply_cb_z},
{UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }
};
static UF_MB_styler_actions_t actions[] = {
{ "UG_CFT.dlg", NULL, CHANGE_cbs, UF_MB_STYLER_IS_NOT_TOP },
{ NULL, NULL, NULL, 0 } /* This is a NULL terminated list */
};
extern void ufsta (char *param, int *retcode, int rlen)
{
int error_code,resonse;
if ( (UF_initialize()) != 0)
return;
/* 在调用UIStyler对话框之前操作 如加入密码*/
/* 在调用UIStyler对话框 */
if ( error_code = UF_STYLER_create_dialog ("UG_CFT.dlg",
CHANGE_cbs,CHANGE_CB_COUNT,NULL,&resonse) != 0 )//user 与UIStyler前缀名 有关注意大小写
{
char fail_message[133];
UF_get_fail_message(error_code, fail_message);
printf ( "%s\n", fail_message );
}
/* 在调用UIStyler对话框之后操作 */
UF_terminate();
return;
}
#ifdef DISPLAY_FROM_CALLBACK
extern int <enter the name of your function> ( int *response )
{
int error_code = 0;
if ( ( error_code = UF_initialize() ) != 0 )
return (0) ;
if ( ( error_code = UF_STYLER_create_dialog ( "UG_CFT.dlg",
CHANGE_cbs, /* Callbacks from dialog */
CHANGE_CB_COUNT, /* number of callbacks*/
NULL, /* This is your client data */
response ) ) != 0 )
{
char fail_message[133];
/* Get the user function fail message based on the fail code.*/
UF_get_fail_message(error_code, fail_message);
UF_UI_set_status (fail_message);
printf ( "%s\n", fail_message );
}
UF_terminate();
return (error_code);
}
#endif /* DISPLAY_FROM_CALLBACK */
#ifdef DISPLAY_FROM_USER_EXIT
extern void <enter a valid user exit here> (char *param, int *retcode, int rlen)
{
int response = 0;
int error_code = 0;
if ( ( UF_initialize() ) != 0 )
return;
if ( ( error_code = UF_STYLER_create_dialog ( "UG_CFT.dlg",
CHANGE_cbs, /* Callbacks from dialog */
CHANGE_CB_COUNT, /* number of callbacks*/
NULL, /* This is your client data */
&response ) ) != 0 )
{
char fail_message[133];
/* Get the user function fail message based on the fail code.*/
UF_get_fail_message(error_code, fail_message);
UF_UI_set_status (fail_message);
printf ( "%s\n", fail_message );
}
UF_terminate();
return;
}
extern int ufusr_ask_unload (void)
{
/* unload immediately after application exits*/
return ( UF_UNLOAD_IMMEDIATELY );
/*via the unload selection dialog... */
/*return ( UF_UNLOAD_SEL_DIALOG ); */
/*when UG terminates... */
/*return ( UF_UNLOAD_UG_TERMINATE ); */
}
extern void ufusr_cleanup (void)
{
return;
}
#endif /* DISPLAY_FROM_USER_EXIT */
int CHANGE_apply_cb_gz ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
/* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */
/* for this callback type. You must continue dialog construction.*/
}
int CHANGE_apply_cb_hh ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
UF_terminate ();
/* Callback acknowledged, do not terminate dialog. */
/* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */
/* for this callback type. You must continue dialog destruction*/
return (UF_UI_CB_CONTINUE_DIALOG);
}
int CHANGE_apply_cb_ok ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
double corner_pt[3]={10,10,10}; //定位点
char * edge_len[3]={"10","20","30"}; //大小
tag_t blk_tag;
UF_MODL_create_block1(UF_NULLSIGN,corner_pt,
edge_len,&blk_tag); //调用API创建方体
UF_terminate ();
/* Callback acknowledged, terminate dialog */
/* It is STRONGLY recommended that you exit your */
/* callback with UF_UI_CB_EXIT_DIALOG in a ok callback.*/
/* return ( UF_UI_CB_EXIT_DIALOG ); */
return (UF_UI_CB_EXIT_DIALOG);
}
int CHANGE_apply_cb_qx ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
UF_terminate ();
/* Callback acknowledged, terminate dialog */
/* It is STRONGLY recommended that you exit your */
/* callback with UF_UI_CB_EXIT_DIALOG in a cancel call */
/* back rather than UF_UI_CB_CONTINUE_DIALOG. */
return ( UF_UI_CB_EXIT_DIALOG );
}
int CHANGE_apply_cb_x ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
/* or Callback acknowledged, terminate dialog. */
/* return ( UF_UI_CB_EXIT_DIALOG ); */
}
int CHANGE_apply_cb_y ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
/* or Callback acknowledged, terminate dialog. */
/* return ( UF_UI_CB_EXIT_DIALOG ); */
}
int CHANGE_apply_cb_z ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
/* or Callback acknowledged, terminate dialog. */
/* return ( UF_UI_CB_EXIT_DIALOG ); */
}
|