CATIA CAA应用开发的过程与方法.docx
《CATIA CAA应用开发的过程与方法.docx》由会员分享,可在线阅读,更多相关《CATIA CAA应用开发的过程与方法.docx(25页珍藏版)》请在冰豆网上搜索。
CATIACAA应用开发的过程与方法
应用开发的过程与方法
命名方法详见《应用开发中的命名规则》
一、系统安装与环境配置
1.1系统安装
1.1.1VC++
1.1.2CATIA
1.1.3组建应用接口(CAA)
1.1.4快速应用开发环境(RADE)
1.2应用开发环境配置
二、目录结构的建立
2.1创建工作空间(Workspace)
InMicrosoftDeveloperStudioopenmenu"File"andselect"OpenCAAV5Workspace",thefollowingwindowappearsinwhichyoucanselecttoopenyourworkspacewiththe"mkmk"functionalities.
EithermodewillgiveyouaccesstotheCodeGeneratorfeatures.
Onceyouhavefilledintheworkspaceinformation,clickon"OK".Alogwindowappearswhileyourenvironmentisupdatedandtheworkspaceopened.WhenthiswindowhasdisappearedDeveloperStudioloadstheprojectfilesitstoredinyourworkspaceandyouarereadytowork.
ThecommandsavailableintheCodeGeneratorareasetofwizardswhereinyouspecifyaseriesofparametersanditwillgeneratecodeforyou.Beforecreatingthecode,areportwindowappearssothatyoumayverifythatthecodegeneratedisasyouexpectit.
Youmayfindthatsomeofthegeneratedsourcefilescontaincommentedoutstatementssuchas"DONOTEDIT:
:
THECAA2WIZARDSWILLINSERTCODEHERE".Donotmodifywhatyoufindbetweenthesecommentedlinesorthewizardswillnolongerbeabletoinsertcodeinthesourcefile.
2.2定义组件框架(CAAV5Framework/ImplementationFramework)
InMicrosoftDeveloperStudio,openmenu"Project"andselect"NewFramework…"
Thewizardwillthencreatethefollowingdirectorystructure:
Educationtypeframeworksaresuffixed".edu"andTestframeworksaresuffixed".tst".Thewizardappendsthesesuffixestothenameoftheframework.
2.3定义接口空间(InterfaceFramework)
Aninterfaceframeworkisaframeworkthatcontains(mainly)interfacesinbothC++orIDLlanguage.Thestructureofthisinterfaceisveryspecific.V5namingconventionsrequiresthattheseinterfacesbedistinguishablethroughan"Interfaces"suffix.Thereforeifyoutypein"Bird"intheframeworkname,thegeneratedframeworkwillbecalled"BirdInterfaces".Thegeneratedstructureisthefollowing:
Afterthefilestructurehasbeencreated,theC++InteractiveDashboardupdatesyourDeveloperStudioprojecttotakeintoaccountthenewfilesanddirectories.IntheJavaInteractiveDashboard,youwillseethenewframeworkintheworkspacetreeview.Notethattheframeworkissetasthecurrentlyactiveproject.
2.4定义模块(Module)
InMicrosoftDeveloperStudio,openmenu"Project"andselect"NewModule…"
Whenyouclickon"OK"areportwindowisdisplayedtoshowyouthefilesanddirectoriesthatwillbecreated.Ifyouaccept,thefollowingfilestructurewillbecreated:
Notethatthenewlycreatedmoduleissetasthecurrentlyactivemodule
三、类定义
CodeGeneratorwizardsenableyoutocreatespecificV5objectsthatimplementcustomaryV5patterns.Thesecurrentlyinclude:
∙Objectmodelerinterfaces(bothC++andIDL)
∙Objectmodelerimplementations
∙V5documents
∙V5features.
InMicrosoftDeveloperStudio,sourcecodeisgeneratedinthecurrentlyactivemodule.Iftheactiveprojectisnotamodule,thefollowingwarningboxwillaskyoutoselectanactivemodule.InMicrosoftDeveloperStudio,thisisdonebyactivatingthecontextualmenuonthedesiredMicrosoftproject("Setasactiveproject").
WhenyougeneratesourcecodeusingtheCodeGenerator,yourworkspaceisupdatedtotakeintoaccountthefilesnewlycreated.InDeveloperStudioonly,thisoftenresultsinthefollowingwarning:
Thisisanexpectedbehaviouranditissafetoreloadyourproject.
3.1CAAV5C++类
InMicrosoftDeveloperStudio,openmenu"Insert"andselect"CAAV5Class...".
ItisrecommendedtousethiscommandratherthanusingMsDev'sownclasscreatorbecauseittakesintoaccounttheCAAV5FileTree,aswellasthestandardmacrosincludedintheCAAclasses.
Thewizardwillcreateaheaderandasourcefilecomprisingastandardconstructoranddestructor,aswellasanequaloperatorandacopyconstructor.Thefollowingfilesarecreated.
3.2元件接口类(ObjectModelerinterfaces)
InterfacescanbedefinedinC++orinIDL(interfacedefinitionlanguage).InMicrosoftDeveloperStudio,openmenu"Insert"andselect"Interface...".
3.2.1C++接口
V5namingconventionsrequirethatyourinterfacehavea3letterprefix,followedbytheletter'I'inuppercase,followedbyanythingelse,asinCATINavigateObject.
3.2.2IDL接口
IDLinterfacescanonlybegeneratedinsideanInterfaceframework.TheIDLradiobuttonwillbegreyedoutinanyothertypeofframework.
V5namingconventionsrequirethatautomationinterfacehavea3letterprefix,followedbythelettersIAinuppercase,followedbyanythingelse.TheautomationaliaswillbegeneratedbyextractingtheXXXIAprefixfromtheinterfacename.
Whenyouclickon"OK"areportwindowisdisplayedtoshowyouthefilesthatwillbecreated.Ifyouaccept,thefollowingfileswillbecreated(oraffected):
3.3元件实现类(ObjectModelerImplementations)
3.3.1定义新元件
ComponentimplementationsarewritteninC++.Theycannotbeincludedininterfaceframeworks...InMicrosoftDeveloperStudio,openmenu"Insert"andselect"Component..."
EventhoughyoumaycreateanimplementationfromeitheraC++oranIDLinterface,thewizardwillnotfunctiononanuncompiledIDLheader.
Ifyoudirectlytypeinthenameoftheinterfaceyouwishtoimplement,thecommandwillpromptyoutospecifytheheaderfilethatcontainsthedefinitionoftheinterface.Youmayalsoaskthewizardtolistalloftheavailableinterfacesinyourworkspace,orinyourprerequisiteworkspaces(thismaytakesometimeasitparsesalltheinterfacesintheworkspace).
Whenyouclickon"OK"areportwindowisdisplayedtoshowyouthefilesthatwillbecreated.Ifyouaccept,thefollowingfileswillbecreated:
3.3.2扩展现有元件
Thepreviouscommandalsoallowsyoutoaddnewextensionstoalreadyexistingimplementations.Youdothisbycheckingtheitem"Extends"andbyspecifyingwhichobjectyouareextending.
Thegeneratedobjectsforextensionsarethesameasforimplementations.
3.3.3利用元件实现类构造工具(ImplementationWizard)
Whenyoudevelopanewimplementationorextension,youmayderivefromanotherC++classthatalreadyimplementssomeofthefunctionsoftheinterfaceyouareimplementing.Assuch,youhaveachoicebetweenoverloadingthosefunctionalitesornotredefiningthemandusingthemastheyhavebeendefinedinthebaseclass.Bydefault,theimplementationbuilderwillmakeyouwriteallthemethodsoftheinterface.Byusingthewizard,youcanchoosebetweenredefiningthosemethodsornot.(Ofcourse,ifthebaseclassimplementsnomethodfromtheinterface,usingthewizardwillnotbeofanyuse).
ThewizardpushbuttonisavailableassoonasyoutypeinabaseclassdifferentfromCATBaseUnknownorCATIABaseObject.Thewizardwillthenscanthebaseclasstofindifitimplementsanymethodsoftheinterfaceandwilldisplaytheminalist
3.4命令类(command)
Youmaycreateseveraldifferenttypesofnewcommandsthatyoucanaddinyourworkshops:
InMicrosoftDeveloperStudio,openmenu"Insert"andselect"CATIAResource/Command..."
Whenspecifyingthenameofaworkshop(orworkbench),thewizardwilllocatethecodeforthatworkshopandgenerateacommandheaderforyou.Ifnocommandheaderisfound,anewtypeofheaderwillbegenerated.
Eventhoughyouhaveselectedthe"Includeinworkshop:
"check,youwillstillneedtousethe"Customize"functionalityofCATIAtoaccessthecommandfromyourpalette.
3.5对话框类(DialogObject)
YoumaycreateinteractivelyanewdialogelementbasedontheDialogframework:
InMicrosoftDeveloperStudio,openmenu"Insert"andselect"CATIAResource/Dialog..."
Notethatifyouwanttocreateadialog-basedcommand,youshouldusethe"Command..."itemofthe"CATIAResource"submenuofthe"Insert"menu.
Whenyouselectthiscommand,anewpageisinsertedinyourMsDevenvironmentwithanewandemptydialog.Referto"Dialogbuilderfeatures"forfulldocumentation.此处不明白!
!
!
3.6测试实例(V5Test-case)
Youmaycreateinteractivelyanewtestcasescriptinsideatest-dedicatedframeworkbyusing:
InMicrosoftDeveloperStudio,openmenu"Insert"andselect"Test-Case…"
Whenyouselectthiscommand,anewtestcasescriptiscreatedinyourframework.Thistestcasecanberunusingthe"ReplayTest-Cases"commandfoundinthe"Build"menu.
3.7交互界面(Workshop/Workbench)类
ThecomponentbuildercurrentlyonlyallowsyoutogenerateonetypeofV5pattern:
Workshops(orworkbenches)
InMicrosoftDeveloperStudio,openmenu"Insert"andselect"CATIAResource/CATIAPattern..."
Youmustfirstselectthetypeofcomponentyouwishtocreate:
3.7.1工具导航条
Thewizardleadsyouthroughaseriesofpanelswhereinyouarepromptedforthecaracteristicsoftheobjectyouwishtocreate.Afterfillingineachpanel,youcanmoveontothenextpanelusingthewizardnavigationbar.Whenallthestepshavebeencompleted,youclickon"Finish"togeneratethecomponent.
3.7.2定义交互界面类
ThesearethestepstocreateaV5workshop:
四、源代码编制
4.1插件
详见《插件的开发方法》
4.2命令
详见《命令的开发方法》
4.3接口
详见《接口的开发方法》
4.4对话框
详见《对话框的开发方法》
4.5交互界面
详见《交互界面开发》
五、支撑框架设置(IdentiyCard.h)
5.1作用
Asalmostallcomponents(frameworks)arebuiltuponotherscomponents,itisnecessary
∙Toincludeatcompiletimethecorrespondingheaderfiles
∙Toreferenceatlinktimethecorrespondinglibraries.
Howeverthesourcefilesofagivencomponentmayincludealotofheaderfilesand,withouttheIdentityCardfile,wemustbrowseallthefilestoknowthenamesofincludedheaderfilesandthenfindthenamesofthecorrespondingcomponents.
TheIdentityCardfilesynthesizesthoserelations