版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、直齿花键C语言程序源代码需要使用UGUISTYLER建立对话框和建立一个花键模板零件下面分别是主要程序代码/*=WARNING! This file is overwritten by the UlStyler each time the Stylerfile is saved.Filename: spline_dialog_template .cThis file was generated by the NX User Interface StylerCreated by: HaoVersion: NX 4Date: 06-04-11Time: 22:26This template fil
2、e is overwritten each time the UIStyler dialog issaved. Any modifications to this file will be lost.=*/*=Purpose: This TEMPLATE file contains C source and static structures toguide you in the construction of your NX Open application dialog.The generation of your dialog file (.dlg extension) is the f
3、irst step towardsdialog construction within Unigraphics. You must now create a UGOpenapplication that utilizes this file (. dlg).The information in this file provides youwith the following:1. Help on the use of the functions, UF MB add styler actions andUF_STYLER_create_dialog in your NX Open applic
4、ation. These functionswill load and display your UIStyler dialog in Unigraphics.An example of the function, UF_MB_add_styler_actions to associate your dialog to the menubar is shown below (Search on Example 1).An example of a invoking a dialog from a callback utilizingUF_STYLER_create_dialog is also
5、 shown below (Search for Example 2).An example of a user exit utilizing UF_STYLER_create_dialog is alsoshown below (Search for Example 3).2.The callback structure:CHANGE_cbs -This structure is VERY important if you have callbacks associated withyour dialog. It correlates the dialog items in your dia
6、log with thecallback functions you must supply. You should not modify thisstructure since it MUST match up to the information stored in yourdialog file (. dlg). Any attempt to do so will cause an error whileconstructing your dialog. If you wish to modify the association ofyour callbacks to your dial
7、og, please reload your dialog file (. dlg) intothe UIStyler and regenerate your files.You do not need to be concerned about this structure, simply pass it asan argument to the function, UF_STYLER_create_dialog along with yourdialog file (. dig).Example 1 displays the actual call you may make for thi
8、s particulardialog.3. The empty callback functions (stubs) associated with your dialog itemshave also been placed in this file.These empty functions have been created simply to start you along with your coding requirements.The function name, argument list and possible return values have alreadybeen
9、provided for you.NOTE:Each callback must be wrapperedwith the functions UF_i nitialize() and UF_terminate ().=*/* These include files are needed for the following template code.*/#include vstdi o.h>#include <uf.h>#include <uf_defs h>#include <uf_exit h>#include <uf_ui h>#i
10、nclude <uf_styler.h>#include <uf_mb h>#include vstdlib h>#include vuf_modl_expressions h>#include <uf_part h>#include vuf_modl h>#include "spline_dialog h"/* The following definition defines the number of callback entries */* in the callback structure:*/* UF_STYL
11、ER_callback_info_t CHANGE_cbs*/#define SPLINE_CB_COUNT ( 4 + 1 ) /* Add 1for the terminator */*The following structure defines the callback entries used by the styler file. This structure MUST be passed into the user function, UF_STYLER_create_dialog along with CHANGE_CB_COUNT.*/staticUF_STYLER_call
12、back_info_tSPLINE_cbsSPLINE_CB_COUNT=0,UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB SPLINE_constructor,UF_STYLER_DIALOG_INDEX, UF_STYLER_DESTRUCTOR_CB,0,SPLINE_destructor,UF_STYLER_DIALOG_INDEX, UF_STYLER_OK_CB, 0,SPLINE_ok,UF_STYLER_DIALOG_INDEX, UF_STYLER_CANCEL_CB, 0,SPLINE_cancel,UF_STYLER_N
13、ULL_OBJECT, UF_STYLER_NO_CB, 0, 0 ;/*UF MB styler actions t contains 4 fields. These are defined as follows:Field 1 : the name of your dialog that you wish to displa y.Field 2 : any client data you wish to pass to your callbacks.Field 3 : your callback structure.Field 4 : flag to inform menubar of y
14、our dialog location. This flag MUSTmatch the resource set in your dialog!Do NOT ASSUME that changingthis field will update the location of your dialog. Please use theUIStyler to indicate the position of your dialog.*/static UF_MB_styler_actions_t actions = "spline_dialog .dlg",NULL,SPLINE_
15、cbs, UF_MB_STYLER_IS_NOT_TOP , NULL, NULL, NULL, 0 /* This is a NULL terminated list */;/* MENUBAR HOOKUP HELPExampleTo launch this dialog from a Unigraphics menubar, you must follow the steps below.1) Add the following lines to your MenuScript file in order toassociate a menu bar button with your d
16、ialog. In thisexample, a cascade menu will be created and will belocated just before the Help button on the main menubar.The button, SPLINE_DIALOG_BTN is set up to launch your dialog andwill be positioned as the first button on your pulldown men u.If you wish to add the button to an existing cascade
17、, simplyadd the 3 lines between MENU LAUNCH_CASCADE and END_OF_MENUto your menuscript file.The MenuScript file requires an extension of ".men".Make sure that you add the extension to the file and placethe file in your startup directory: $UGII_USER_DIR/startup or $UGII_SITE_DIR/startup or $
18、UGII_VENDOR_DIR/startup directoryMove the contents between the dashed lines to your Menuscript file.VERSION 120EDIT UG_GATEWAY_MAIN_MENUBARBEFORE UG_HELPCASCADE_BUTTON UISTYLER_DLG_CASCADE_BTNLABEL Dialog Launcher END_OF_BEFOREMENUUISTYLER_DLG_CASCADE_BTNBUTTON SPLINE_DIALOG_BTNLABEL Display spline_
19、dialog dialog ACTIONS spline_dialog .dig END_OF_MENU2) Issue a call to the function,UF MB add styler actions from the ufsta user exit as shown below. To use this call, remove the conditional definitions:#ifdefMENUBAR_COMMENTED_OUT#endifMENUBAR_COMMENTED_OUTThe static structure, actions, will allow y
20、ou to associate ALL of yourdialogs and callback functions to the menubar at once. For example, if youwish to have 10 dialogs associated to 10 different buttons on the menubar,you may enter each dialog and callback list into the actions structure. Makesure that you have created a corresponding button
21、 in your MenuScript file.You may also have separate shared libraries, each with a ufsta user exitfor each individual dialog.3) Place your compiled and linked ufsta user function in$UGII_USER_DIR/startup or $UGII_SITE_DIR/startup or $UGII_VENDOR_DIR/startup directory.NOTE: The user function must cont
22、ain the proper extension . so, .si or .dllto make ensure that it is recognizedby the MenuScript. If it does nothave the proper extension, it will NOT be recognized by MenuScript.The action name you have provided in your MenuScript must correspond toto the dialog name provided in the action structure
23、. This MUST match inorderto bind your dlg file to your MenuScript button.4) Copy your UlStyler dialog file to the proper directory.All dialog files (. dlg) must be located in $UGII_USER_DIR/application or $UGII_SITE_DIR/application or $UGII_VENDOR_DIR/application directory*/#ifdef MENUBAR_COMMENTED_
24、OUT extern void ufsta (char *param, int *retcode, int rlen)int error_code;if ( (UF_initialize() != 0)return;if(error_codeUF_MB_add_styler_actions ( actions ) ) != 0 )char fail_message133;UF_get_fail_message(error_code, fail_message);printf ( "%sn", fail_message );UF_terminate();return;#end
25、if /*MENUBAR_COMMENTED_OUT*/DIALOG CREATION FROM ACALLBACK HELP ExampleIf you wish to have this dialog displayed from the callback ofanother UlStyler dialog, you should:1) Make sure that the callback of your UIStyler dialog isdesignated as a dialog building callback.2) Remove the conditional definit
26、ions:#ifdef DISPLAY_FROM_CALLBACK #endif DISPLAY_FROM_CALLBACK3) Your callback should issue a call to this functio n.4) You should also add the funcitonal prototype to your header file(spline_dialog h) and ensure that the file is properly included.All dialog files must be located in $UGII_USER_DIR/a
27、pplication or $UGII_SITE_DIR/application or $UGII_VENDOR_DIR/application directory*/#ifdef DISPLAY_FROM_CALLBACK extern int venter 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("splin
28、e_dialog dlg",CHANGE_cbs,/* Callbacksfrom dialog */CHANGE_CB_COUNT, /* number of callbacks*/NULL,/* This is yourclient data */response ) ) != 0 )char fail_message133;/* Get the user function fail message based on the fail code */UF_get_fail_message(error_code, fail_message);UF_UI_set_status (fa
29、il_message); printf ( "%sn", fail_message );UF_terminate();return (error_code);#endif /* DISPLAY_FROM_CALLBACK */DIALOG CREATION FROM A USEREXIT HELP ExampleTo create this dialog from a user exit, you must invoke acall to the NX Open API, UF_STYLER_create_dialog. An example is shown below.
30、All dialog files must be located in $UGII_USER_DIR/application or $UGII_SITE_DIR/application or $UGII_VENDOR_DIR/application directory1) Remove the conditional definitions:#ifdef DISPLAY_FROM_USER_EXIT #endif DISPLAY_FROM_USER_EXIT2) Add a user exit to the function name below, for example, ufusr.3)
31、Consider how your shared library will be unloaded. Take a lookat the generated function ufusr_ask_unload.*/#ifdef DISPLAY_FROM_USER_EXIT extern void venter 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_c
32、ode =UF_STYLER_create_dialog("spline_dialog dlg",CHANGE_cbs,/* Callbacksfrom dialog */CHANGE_CB_COUNT, /* number of callbacks*/NULL,/* This is yourclient data */&response ) ) != 0 )char fail_message133;/* Get the user function fail message based on the fail code */UF_get_fail_message(e
33、rror_code, fail_message);UF_UI_set_status (fail_message); printf ( "%sn", fail_message );UF_terminate();return;/*This function specifieshow a shared image isunloaded from memory within Unigraphics. This function gives you the capability to unload an internal NX Open application or user exi
34、t from Unigraphics. You can specify any one of the three constants as a return value to determine the type of unload to perform: immediately after user function execution, via an unload selection dialog, or when Unigraphics terminates terminates.If you chooseUF_UNLOAD_SEL_DIALOG, then you have the o
35、ption to unload your image by selecting File->Utilities->Unload Shared Image.NOTE: A program which associates NX Open applications with the menubarMUST NOT use this option since it will UNLOAD your NX Open application imagefrom the menubar.*/extern int ufusr_ask_unload (void)/* unload immediat
36、ely after applicationexits*/return(UF_UNLOAD_IMMEDIATELY );/*via the unload selection dialog */*return ( UF_UNLOAD_SEL_DIALOG );*/*when UG terminates */*return(UF_UNLOAD_UG_TERMINATE ); */*You have the option of coding the cleanup routine to perform any housekeeping chores that may need to be perfor
37、med. If you code the cleanup routine, it is automatically called by Unigraphics.*/extern void ufusr_cleanup (void)return;#endif /* DISPLAY_FROM_USER_EXIT */*/*UlStyler Callback Functions*/*/* Callback Name: CHANGE_constructor* This is a callback function associated with an action taken from a* UISty
38、ler object.* Input: dialogd - The dialog id indicate which dialog this callback* is associated with. The dialog id is a dynamic,* unique id and should not be stored. It is* strictly for the use in the NX Open API:UF_STYLER_ask_value(s)*UF_STYLER_set_value* client_data - Client data is user defined d
39、ata associated* with your dialog. Client data may be bound* to your dialog with UF MB add styler actions* or UF_STYLER_create_dialog.* callback_data - This structure pointer contains information* specific to the UIStyler Object type that* invoked this callback and the callback type.*/int SPLINE_cons
40、tructor ( 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*/char dir100;const char env255="UGII_USER_DIR"char *basedir=NULL
41、;tag_t part;UF PART load status t error status;basedir=getenv(env);strcpy(dir,basedir);strcat(dir,"partspline_part prt");if(UF_PART_open(dir,&part, &error_status)!=0)UF_free_string_array(error_status .n_parts,erro r_status file_names);UF_free(error_status .statuses);return(UF_UI_CB
42、_CONTINUE_DIALOG);UF_free_string_array(error_status .n_parts,erro r_status file_names);UF_free(error_status .statuses); double arExpValue5;UF_MODL_eval_exp("d1",&arExpValue0);UF_MODL_eval_exp("d2",&arExpValue1);UF_MODL_eval_exp("W", &arExpValue2);UF_MODL_eva
43、l_exp("N", &arExpValue3);UF_MODL_eval_exp("L", &arExpValue4);UF_STYLER_item_value_type_t data_set;data set .item attr=UF STYLER VALUE;*data set .item id=SPLINE SPLINE D1; data_set .value real=arExpValue0;UF_STYLER_set_value(dialogd,&data_set); UF_STYLER_free_value(&am
44、p;data_set);data set .item attr=UF STYLER VALUE;*data set .item id=SPLINE SPLINE D2; data_set .value .real=arExpValue1;UF_STYLER_set_value(dialogd,&data_set); UF_STYLER_free_value(&data_set); data set .item attr=UF STYLER VALUE;*data set .item id=SPLINE SPLINE W; data_set .value .real=arExpV
45、alue2;UF_STYLER_set_value(dialogd,&data_set); UF_STYLER_free_value(&data_set);data set .item attr=UF STYLER VALUE;" data set .item id=SPLINE SPLINE N; data_set .value integer=arExpValue3;UF_STYLER_set_value(dialog_id,&data_set); UF_STYLER_free_value(&data_set);data set .item att
46、r=UF STYLER VALUE;*data set .item id=SPLINE SPLINE L; data_set .value .real=arExpValue4;UF_STYLER_set_value(dialog_id,&data_set);UF_STYLER_free_value(&data_set); UF_terminate ();/* Callback acknowledged, do not terminate dialog */return (UF_UI_CB_CONTINUE_DIALOG);/* A return value of UF_UI_C
47、B_EXIT_DIALOG will not be accepted */* for this callback type.You mustcontinue dialog construction .*/* Callback Name: CHANGE_destructor* This is a callback function associated with an action taken from a* UlStyler object.* Input: dialogd- The dialog idindicate which dialog this callback* is associa
48、ted with. The dialog id is a dynamic,* unique id and should not be stored. It is* strictly for the use in the NX Open API:UF_STYLER_ask_value(s)UF_STYLER_set_value* client_data - Client data is user defined data associated* with your dialog. Client data may be bound* to your dialog with UF MB add st
49、yler actions* or UF_STYLER_create_dialog.* callback_data - This structure pointer contains information* specific to the UIStyler Object type that* invoked this callback and the callback type.*/int SPLINE_destructor ( int dialog_id, void * client_data,UF_STYLER_item_value_type_p_t callback_data)/* Ma
50、ke sure User Function is available. */if ( UF_initialize() != 0)return(UF_UI_CB_CONTINUE_DIALOG );/* - Enter your callback code here*/UF_terminate ();/* Callback acknowledged, donotterminate dialog.*/*AreturnvalueofUF_UI_CB_EXIT_DIALOGwill notbeaccepted */* for this callbacktype.Youmustcontinue dial
51、og destruction*/ return(UF_UI_CB_CONTINUE_DIALOG);/* Callback Name: CHANGE_ok* This is a callback function associated with an action taken from a* UlStyler object.* Input: dialogd- The dialog idindicate which dialog this callback* is associated with. The dialog id is a dynamic,* unique id and should
52、 not be stored. It is* strictly for the use in the NX Open API:UF_STYLER_ask_value(s)UF_STYLER_set_value* client_data - Client data is user defined data associated* with your dialog. Client data may be bound* to your dialog with UF MB add styler actions* or UF_STYLER_create_dialog.* callback_data -
53、This structure pointer contains information* specific to the UIStyler Object type that* invoked this callback and the callback type.*/int SPLINE_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)ret
54、urn(UF_UI_CB_CONTINUE_DIALOG );/* - Enter your callback code here*/double d1;double d2;double W;int N;double L;char exps_string520;UF_STYLER_item_value_type_t data5;data0.item_attr=UF_STYLER_V ALUE;data0 .item_id=SPLINE_SPLINE_D1;UF_STYLER_ask_value(dialog_id,&data0);data1.item_attr=UF_STYLER_V
55、ALUE; data1 .item_id=SPLINE_SPLINE_D2;UF_STYLER_ask_value(dialog_id,&data1);data2.item_attr=UF_STYLER_V ALUE; data2 .item_id=SPLINE_SPLINE_W;UF_STYLER_ask_value(dialog_id,&data2);data3.item_attr=UF_STYLER_V ALUE; data3 .item_id=SPLINE_SPLINE_N;UF_STYLER_ask_value(dialog_id,&data3);data4.
56、item_attr=UF_STYLER_V ALUE; data4 . item_id=SPLINE_SPLINE_L;UF_STYLER_ask_value(dialog_id,&data4); d1= data0 .value .real; d2=data1 .value .real;W=data2 .value .real;N=data3 value .integer;L=data4 .value.real;for(int i=0;i<5;i+) UF_STYLER_free_value(&datai); if(d1=0|d2=0|W=0|N=0|L=0) uc1601("对话框中的数值不能为零!",1);return(UF_UI_CB_CONTINUE_DIALOG); if(d1v=d2) uc1601("d1 必须大于 d2!",1);return(UF_UI_CB_CONTINUE_DIALOG); /Modify the value of expression sprintf(exps_string0,"d1=%f&
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年西安工业大学招聘备考题库(14人)含答案详解
- 2026吉林紫金铜业有限公司招聘2人备考题库及答案详解参考
- 2026云南楚雄州双柏县选调由政府安排工作退役士兵6人备考题库完整答案详解
- 2026年涧西区参加洛阳市县区事业单位联考招聘17人备考题库完整答案详解
- 2026湖南怀化市辰溪县锦岩矿业投资有限责任公司招聘6人备考题库及完整答案详解1套
- 2026山东台庄建筑工程质量检测有限公司招聘工作人员1人备考题库及完整答案详解一套
- 2026年知识文化素质能力培养方法
- 2026年餐饮行业面试预测题及高频考点
- 金融证书考试试题及答案
- 2026年新能源工程师面试题
- 2025-2026学年人教版七年级生物下册核心知识点总结归纳
- 国开2026年《新媒体伦理与法规》形成性考核1-5答案
- 2025年军队文职人员统一招聘面试(药学)专项练习含答案
- 2026年老年健康管理服务考试题含答案
- 2026年N1叉车司机考试题库及答案(1000题)
- 2025年中国职场员工健康风险研究报告
- 县域经济发展课件
- 2025重庆水务环境控股集团管网有限公司招聘20人笔试考试备考试题及答案解析
- 理想华莱十大亮点课件
- 成人肠内营养支持护理团队标准
- 痛风的饮食宣教
评论
0/150
提交评论