直齿花键C语言程序源代码.docx
《直齿花键C语言程序源代码.docx》由会员分享,可在线阅读,更多相关《直齿花键C语言程序源代码.docx(26页珍藏版)》请在冰豆网上搜索。
直齿花键C语言程序源代码
直齿花键C语言程序源代码
需要使用UGUISTYLER建立对话框和建立一个花键模板零件下面分别是主要程序代码
/*=============================================================================
WARNING!
!
ThisfileisoverwrittenbytheUIStylereachtimetheStyler
fileissaved.
Filename:
spline_dialog_template.c
ThisfilewasgeneratedbytheNXUserInterfaceStyler
Createdby:
Hao
Version:
NX4
Date:
06-04-11
Time:
22:
26
ThistemplatefileisoverwritteneachtimetheUIStylerdialogis
saved.Anymodificationstothisfilewillbelost.
==============================================================================*/
/*==============================================================================
Purpose:
ThisTEMPLATEfilecontainsCsourceandstaticstructuresto
guideyouintheconstructionofyourNXOpenapplicationdialog.
Thegenerationofyourdialogfile(.dlgextension)isthefirststeptowards
dialogconstructionwithinUnigraphics.YoumustnowcreateaUGOpen
applicationthatutilizesthisfile(.dlg).
Theinformationinthisfileprovidesyouwiththefollowing:
1.Helpontheuseofthefunctions,UF_MB_add_styler_actionsand
UF_STYLER_create_dialoginyourNXOpenapplication.Thesefunctions
willloadanddisplayyourUIStylerdialoginUnigraphics.
Anexampleofthefunction,UF_MB_add_styler_actionstoassociateyour
dialogtothemenubarisshownbelow(SearchonExample1).
Anexampleofainvokingadialogfromacallbackutilizing
UF_STYLER_create_dialogisalsoshownbelow(SearchforExample2).
AnexampleofauserexitutilizingUF_STYLER_create_dialogisalso
shownbelow(SearchforExample3).
2.Thecallbackstructure:
---CHANGE_cbs---
ThisstructureisVERYimportantifyouhavecallbacksassociatedwith
yourdialog.Itcorrelatesthedialogitemsinyourdialogwiththe
callbackfunctionsyoumustsupply.Youshouldnotmodifythis
structuresinceitMUSTmatchuptotheinformationstoredinyour
dialogfile(.dlg).Anyattempttodosowillcauseanerrorwhile
constructingyourdialog.Ifyouwishtomodifytheassociationof
yourcallbackstoyourdialog,pleasereloadyourdialogfile(.dlg)into
theUIStylerandregenerateyourfiles.
Youdonotneedtobeconcernedaboutthisstructure,simplypassitas
anargumenttothefunction,UF_STYLER_create_dialogalongwithyour
dialogfile(.dlg).
Example1displaystheactualcallyoumaymakeforthisparticular
dialog.
3.Theemptycallbackfunctions(stubs)associatedwithyourdialogitems
havealsobeenplacedinthisfile.Theseemptyfunctionshavebeen
createdsimplytostartyoualongwithyourcodingrequirements.
Thefunctionname,argumentlistandpossiblereturnvalueshavealready
beenprovidedforyou.
NOTE:
EachcallbackmustbewrapperedwiththefunctionsUF_initialize()
andUF_terminate().
==============================================================================*/
/*Theseincludefilesareneededforthefollowingtemplatecode.*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include"spline_dialog.h"
/*Thefollowingdefinitiondefinesthenumberofcallbackentries*/
/*inthecallbackstructure:
*/
/*UF_STYLER_callback_info_tCHANGE_cbs*/
#defineSPLINE_CB_COUNT(4+1)/*Add1fortheterminator*/
/*--------------------------------------------------------------------------
Thefollowingstructuredefinesthecallbackentriesusedbythe
stylerfile.ThisstructureMUSTbepassedintotheuserfunction,
UF_STYLER_create_dialogalongwithCHANGE_CB_COUNT.
--------------------------------------------------------------------------*/
staticUF_STYLER_callback_info_tSPLINE_cbs[SPLINE_CB_COUNT]=
{
{UF_STYLER_DIALOG_INDEX,UF_STYLER_CONSTRUCTOR_CB,0,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_NULL_OBJECT,UF_STYLER_NO_CB,0,0}
};
/*--------------------------------------------------------------------------
UF_MB_styler_actions_tcontains4fields.Thesearedefinedasfollows:
Field1:
thenameofyourdialogthatyouwishtodisplay.
Field2:
anyclientdatayouwishtopasstoyourcallbacks.
Field3:
yourcallbackstructure.
Field4:
flagtoinformmenubarofyourdialoglocation.ThisflagMUST
matchtheresourcesetinyourdialog!
DoNOTASSUMEthatchanging
thisfieldwillupdatethelocationofyourdialog.Pleaseusethe
UIStylertoindicatethepositionofyourdialog.
--------------------------------------------------------------------------*/
staticUF_MB_styler_actions_tactions[]={
{"spline_dialog.dlg",NULL,SPLINE_cbs,UF_MB_STYLER_IS_NOT_TOP},
{NULL,NULL,NULL,0}/*ThisisaNULLterminatedlist*/
};
/*----------------MENUBARHOOKUPHELPExample-------------------
TolaunchthisdialogfromaUnigraphicsmenubar,youmustfollow
thestepsbelow.
1)AddthefollowinglinestoyourMenuScriptfileinorderto
associateamenubarbuttonwithyourdialog.Inthis
example,acascademenuwillbecreatedandwillbe
locatedjustbeforetheHelpbuttononthemainmenubar.
Thebutton,SPLINE_DIALOG_BTNissetuptolaunchyourdialogand
willbepositionedasthefirstbuttononyourpulldownmenu.
Ifyouwishtoaddthebuttontoanexistingcascade,simply
addthe3linesbetweenMENULAUNCH_CASCADEandEND_OF_MENU
toyourmenuscriptfile.
TheMenuScriptfilerequiresanextensionof".men".
Makesurethatyouaddtheextensiontothefileandplace
thefileinyourstartupdirectory:
$UGII_USER_DIR/startupor
$UGII_SITE_DIR/startupor
$UGII_VENDOR_DIR/startupdirectory
MovethecontentsbetweenthedashedlinestoyourMenuscriptfile.
!
----------------------------------------------------------------
VERSION120
EDITUG_GATEWAY_MAIN_MENUBAR
BEFOREUG_HELP
CASCADE_BUTTONUISTYLER_DLG_CASCADE_BTN
LABELDialogLauncher
END_OF_BEFORE
MENUUISTYLER_DLG_CASCADE_BTN
BUTTONSPLINE_DIALOG_BTN
LABELDisplayspline_dialogdialog
ACTIONSspline_dialog.dlg
END_OF_MENU
!
---------------------------------------------------------------
2)Issueacalltothefunction,UF_MB_add_styler_actionsfromtheufsta
userexitasshownbelow.Tousethiscall,removetheconditional
definitions:
#ifdefMENUBAR_COMMENTED_OUT
#endifMENUBAR_COMMENTED_OUT
Thestaticstructure,actions,willallowyoutoassociateALLofyour
dialogsandcallbackfunctionstothemenubaratonce.Forexample,ifyou
wishtohave10dialogsassociatedto10differentbuttonsonthemenubar,
youmayentereachdialogandcallbacklistintotheactionsstructure.Make
surethatyouhavecreatedacorrespondingbuttoninyourMenuScriptfile.
Youmayalsohaveseparatesharedlibraries,eachwithaufstauserexit
foreachindividualdialog.
3)Placeyourcompiledandlinkedufstauserfunctionin
$UGII_USER_DIR/startupor
$UGII_SITE_DIR/startupor
$UGII_VENDOR_DIR/startupdirectory.
NOTE:
Theuserfunctionmustcontaintheproperextension.so,.slor.dll
tomakeensurethatitisrecognizedbytheMenuScript.Ifitdoesnot
havetheproperextension,itwillNOTberecognizedbyMenuScript.
TheactionnameyouhaveprovidedinyourMenuScriptmustcorrespondto
tothedialognameprovidedintheactionstructure.ThisMUSTmatchinorder
tobindyourdlgfiletoyourMenuScriptbutton.
4)CopyyourUIStylerdialogfiletotheproperdirectory.
Alldialogfiles(.dlg)mustbelocatedin
$UGII_USER_DIR/applicationor
$UGII_SITE_DIR/applicationor
$UGII_VENDOR_DIR/applicationdirectory
------------------------------------------------------------*/
//#ifdefMENUBAR_COMMENTED_OUT
externvoidufsta(char*param,int*retcode,intrlen)
{
interror_code;
if((UF_initialize())!
=0)
return;
if((error_code=UF_MB_add_styler_actions(actions))!
=0)
{
charfail_message[133];
UF_get_fail_message(error_code,fail_message);
printf("%s\n",fail_message);
}
UF_terminate();
return;
}
//#endif/*MENUBAR_COMMENTED_OUT*/
/*-------DIALOGCREATIONFROMACALLBACKHELPExample----------
Ifyouwishtohavethisdialogdisplayedfromthecallbackof
anotherUIStylerdialog,youshould:
1)MakesurethatthecallbackofyourUIStylerdialogis
designatedasadialogbuildingcallback.
2)Removetheconditionaldefinitions:
#ifdefDISPLAY_FROM_CALLBACK
#endifDISPLAY_FROM_CALLBACK
3)Yourcallbackshouldissueacalltothisfunction.
4)Youshouldalsoaddthefuncitonalprototypetoyourheaderfile
(spline_dialog.h)andensurethatthefileisproperlyincluded.
Alldialogfilesmustbelocatedin
$UGII_USER_DIR/applicationor
$UGII_SITE_DIR/applicationor
$UGII_VENDOR_DIR/applicationdirectory
--------------------------------------------------------------*/
#ifdefDISPLAY_FROM_CALLBACK
externint(int*response)
{
interror_code=0;
if((error_code=UF_initialize())!
=0)
return(0);
if((error_code=UF_STYLER_create_dialog("spline_dialog.dlg",
CHANGE_cbs,/*Callbacksfromdialog*/
CHANGE_CB_COUNT,/*numberofcallbacks*/
NULL,/*Thisisyourclientdata*/
response))!
=0)
{
charfail_message[133];
/*Gettheuserfunctionfailmessagebasedonthefailcode.*/
UF_get_fail_message(error_code,fail_message);