


版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 營養性疾病管理規范-1
- 產業園調研報告數據表
- 寵物門店創業計劃書1000字
- 私人定制旅游服務商業計劃書2025
- 微信平臺支撐服務項目方案共39文檔
- 美的海外市場部電子商務方案書
- 保安員(高級)職業鑒定理論考試題及答案
- 2025年中國脫漆脫塑劑行業市場規模及未來投資方向研究報告
- 2025年中國田徑器材行業市場前景預測及投資價值評估分析報告
- 《證據法學(第三版)》課件 第7-13章 證明責任 -證據的審查判斷
- 三年級下學期音樂復習題
- 農網配電營業工復習題
- 電氣畢業論文-基于-plc自動門控制設計
- 煉鋼廠風險分級管控清單連鑄區域
- 新時期農村初中語文教學中滲透心理健康教育的研究 論文
- 女性中醫保健智慧樹知到答案章節測試2023年暨南大學
- 餐飲員工入職登記表
- GA 1808-2022軍工單位反恐怖防范要求
- -衛生資格-副高-護理學-副高-章節練習-專科護理學-內科疾病患者護理(多選題)(共42題)
- 一帶一路 匠心織竹-計劃書
- Unit 1 Extended reading Eating in China 公開課-高中英語牛津譯林版(2020)選擇性必修第一冊
評論
0/150
提交評論