Catia的二次开发.docx

上传人:b****4 文档编号:5465238 上传时间:2022-12-16 格式:DOCX 页数:12 大小:21.58KB
下载 相关 举报
Catia的二次开发.docx_第1页
第1页 / 共12页
Catia的二次开发.docx_第2页
第2页 / 共12页
Catia的二次开发.docx_第3页
第3页 / 共12页
Catia的二次开发.docx_第4页
第4页 / 共12页
Catia的二次开发.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

Catia的二次开发.docx

《Catia的二次开发.docx》由会员分享,可在线阅读,更多相关《Catia的二次开发.docx(12页珍藏版)》请在冰豆网上搜索。

Catia的二次开发.docx

Catia的二次开发

3.1.2开发步骤

#2Createtheworkbenchfactory3Createtheworkbenchdescriptionclass4Createthecommandheaders5Createtheworkbenchandarrangethecommands6ProvidetheresourcesandinserttheworkbenchintotheStartmenu7CreatetheworkbenchexposedinterfaceStepWhereLocalInterfacesandsrcLocalInterfacesandsrcLocalInterfacesandsrc

CreateCommandsmethodCreateWorkbenchmethod

1Createtheworkbenchfactoryinterface

ResourcefilesProtectedInterfacesandsrc

3.2建立Workbench的FactoryInterface

(CreatingtheWorkbenchFactoryInterface)

3.2.1命名

CAAIAfrGeoCreationWkbFactory

3.2.2头文件(theheaderfile)

CAAIAfrGeoCreationWkbFactory.h

#includeexternIIDIID_CAAIAfrGeoCreationWkbFactory;classCAAIAfrGeoCreationWkbFactory:

publicCATIGenericFactory{CATDeclareInterface;public:

};

AfactoryinterfaceisaCAAinterface,thatis,anabstractclassthatderivesfromCATIGenericFactory.Asanyinterface,ithasanIIDdeclaredasIID_followedbytheinterfacename,andincludesthe

CATDeclareInterfacemacrothatdeclaresthatthisabstractclassisaninterface.Noadditional3

methodthanthoseofCATIGenericFactoryisnecessary.Don'tforgetthepublickeywordrequiredbytheTIEcompiler.(?

3.2.3源文件(Thesourcefile)

CAAIAfrGeoCreationWkbFactory.cpp

#includeIIDIID_CAAIAfrGeoCreationWkbFactory={0xb32eed10,0xd4c1,0x11d3,{0xb7,0xf5,0x00,0x08,0xc7,0x4f,0xe8,0xdd}};CATImplementInterface(CAAIAfrGeoCreationWkbFactory,CATIGenericFactory);

TheCATImplementInterfacemacroisusedinconjunctionwithCATDeclareInterfaceintheheaderfiletomakeaninterfacefromthisabstractclassandtodeclarethatitOM-derivesfromCATIGenericfactory.

3.2.4TIE文件(TheTIEtsrcfile)

TIE_CAAIAfrGeoCreationWkbFactory.tsrc

#include"CAAIAfrGeoCreationWkbFactory.h"

TheMulti-WorkspaceApplicationBuilder(mkmk)willgeneratetheTIEforthisinterfaceforyou,thatis,theTIE_CAAIAfrGeoCreationWkbFactory.hfileintheProtectedGenerateddirectory.

3.3建立Workbench的Factory

(CreatingtheWorkbenchFactory)

3.3.1注意事项

Thefactoryclassthatcreatesworkbenchinstancesmustconcatenatethenameoftheclasstoinstantiate,thatis,theworkbenchdescriptionclassCAAAfrGeoCreationWkb,withthestringFactory.ThisgivesCAAAfrGeoCreationWkbFactory.

3.3.2头文件

CAAAfrGeoCreationWkbFactory.h

#include"CATWorkshopConfigurationFactory.h"CATDeclareConfigurationFactory(CAAAfrGeoCreationWkb);

TheCATDeclareConfigurationFactorymacroargumentisthenameoftheworkbenchdescriptionclass.

4

3.3.3源文件

CAAAfrGeoCreationWkbFactory.cpp

#include#include#includeCATImplementConfigurationFactory(CAAAfrGeoCreationWkb,CAAIAfrGeoCreationWkbFactory);

TheCATImplementConfigurationFactoryargumentsarethenameoftheworkbenchdescriptionclassandthenameoftheworkbenchfactoryinterfacerespectively.The

CATDeclareConfigurationFactoryandCATImplementConfigurationFactorymacroscreatethe

workbenchfactoryimplementationclassasadataextensionoftheCATApplicationFramecomponent

3.3.4更新字典

3.3.4.1Theinterfacedictionarythatisafilewhosenameistheframeworknamesuffixedbydico,suchasCAAApplicationFrame.dico,andthatyoushouldcreateorupdateintheframeworkCNext/code/dictionarydirectory.TheinterfacedictionarycontainsthefollowingdeclarationtostatethattheCATApplicationFramecomponentimplementstheCAAIAfrGeoCreationWkbFactoryinterface,bymeansoftheextensionclasscreatedbythemacros,whosecodeislocatedinthelibCAAAfrGeoCreationWbenchsharedlibraryorDLL:

(不太明白)

CATApplicationFrameCAAIAfrGeoCreationWkbFactorylibCAAAfrGeoCreationWbench

3.3.4.2Thefactorydictionarythatisafilewhosenameistheframeworknamesuffixedbyfact,suchasCAAApplicationFrame.fact,andthatyoushouldcreateorupdateintheframeworkCNext/code/dictionarydirectory.ThefactorydictionarycontainsthefollowingdeclarationtostatethattheCAAIAfrGeoCreationWkbFactoryinterfaceisaninterfacetoafactorywhoseimplementationcreatesaCAAAfrGeoCreationWkbclassinstance:

CAAAfrGeoCreationWkbCAAIAfrGeoCreationWkbFactory

3.4定义与实现Workbench类

(CreatingtheWorkbenchDescriptionClass)

3.4.1说明

TheCAAAfrGeoCreationWkbclassimplementstheCATICAAAfrGeometryWksConfigurationinterfaceexposedbytheCAAGeometryworkshop.Itincludesthefollowingmethods:

?

?

?

CreateCommandstoinstantiatethecommandheadersforthecommandsoftheworkbenchCreateWorkbenchtocreatethecontainersfortheworkbench,themenus,andthetoolbars,and

arrangethecommandsinthemenusandtoolbars

GetCustomInterfaceswhichreturnsthenamesoftheinterfacesexposedbytheworkbenchto

enableitscustomization

5

?

GetAddinInterfacewhichreturnsthenameoftheinterfaceexposedbytheworkbenchtocreate

add-ins.

3.4.2头文件

CAAAfrGeoCreationWkb.h

#include"CATBaseUnknown.h"#include"CATListPV.h"classCATCmdWorkbench;classCAAAfrGeoCreationWkb:

publicCATBaseUnknown{CATDeclareClass;public:

CAAAfrGeoCreationWkb();virtual~CAAAfrGeoCreationWkb();voidCATClassIdvoidprivate:

CAAAfrGeoCreationWkb(constCAAAfrGeoCreationWkb&iObjectToCopy);};CreateCommands();GetAddinInterface();GetCustomInterfaces(CATListPV*oDefaultIIDList,CATListPV*oCustomIIDList);

CATCmdWorkbench*CreateWorkbench();

TheCAAAfrGeoCreationWkbclassC++-derivesfromCATBaseUnknown.TheCATDeclareClassmacrodeclaresthattheclassCAAAfrGeoCreationWkbbelongstoacomponent.Theclasshasaconstructor,adestructor,thefourmethodsoftheCATIWorkbenchinterface,andacopyconstructor.Notethatthecopyconstructorissetasprivate.Thispreventsthecompilerfromcreatingthecopyconstructoraspublicwithoutyouknow.Thiscopyconstructorisnotimplementedinthesourcefile.

3.4.3源文件

CAAAfrGeoCreationWkb.cpp

#include

#include//SeeCreatingtheCommandHeadersMacDeclareHeader(CAAAfrGeoCreationWkbHeader);#includeCATImplementClass(CAAAfrGeoCreationWkb,Implementation,CATBaseUnknown,CATNull);#include6

TIE_CATICAAAfrGeometryWksConfiguration(CAAAfrGeoCreationWkb);CAAAfrGeoCreationWkb:

:

CAAAfrGeoCreationWkb(){}CAAAfrGeoCreationWkb:

:

~CAAAfrGeoCreationWkb(){}voidCAAAfrGeoCreationWkb:

:

CreateCommands(){...//SeeCreatingtheCommandHeaders}CATCmdWorkbench*CAAAfrGeoCreationWkb:

:

CreateWorkbench(){...//SeeCreatingtheWorkbenchandArrangingtheCommands}CATClassIdCAAAfrGeoCreationWkb:

:

GetAddinInterface(){return"CAAIAfrGeoCreationWkbAddin";}voidCAAAfrGeoCreationWkb:

:

GetCustomInterfaces(CATListPV*oDefaultIIDList,CATListPV*oCustomIIDList){}

3.4.3.1TIE_CATICAAAfrGeometryWksConfiguration宏TheCAAAfrGeoCreationWkbclassstatesthatitimplementstheCATICAAAfrGeometryWksConfigurationinterface3.4.3.2TIE_CATImplementClass宏declaringthattheCAAAfrGeoCreationWkbclassisacomponentmainclass[2],thankstothe

Implementationkeyword,andthatitOM-derivesfromCATBaseUnknown[2].Thefourthparametermust

alwaysbesettoCATNullforcomponentmainclasses.3.4.3.3创建命令标签(CreatingtheCommandHeaders)(见《命令标签》)3.4.3.3.1命令标签Eachcommandavailableinyourworkbenchmusthaveacommandheader.Acommandheaderisaninstanceofacommandheaderclass,anddifferentcommandscansharethesamecommandheaderclasstocreatetheircommandheader.3.4.3.3.2创建命令标签类CAAAfrGeoCreationWkbHeadercommandheaderclassiscareatedinCAAAfrGeoCreationWkb.cpp:

#includeMacDeclareHeader(CAAAfrGeoCreationWkbHeader);

7

TheMacDeclareHeadermacrocreatestheheaderfileandthesourcefilefortheCAAAfrGeoCreationWkbHeaderclass,andassociateswiththisclasstheresourcefilesCAAAfrGeoCreationWkbHeader.CATNlsandCAAAfrGeoCreationWkbHeader.CATRsc.3.4.3.3.3定义命令标签CreatethecodetoinstantiateyourcommandheadersintheemptyCreateCommandsmethod.Thismethodshouldcontainoneinstantiationstatementofthecommandheaderclasspercommand.Eachstatementhasthefollowingform,forexamplefortheCuboidcommand.

voidCAAAfrGeoCreationWkb:

:

CreateCommands(){...newCAAAfrGeoCreationWkbHeader("CAAAfrCuboidHdr","CAADegGeoCommands","CAADegCreateCuboidCmd",(void*)NULL);...}

其中:

1)CAAAfruboidHdristheidentifieryouneedtoassigntothecommandheader.Itwillbeused

afterwards:

(1)Toassociatethecommandstartersyouwilldefinetoputthecommandinamenuandintoolbarswiththecommandheader.

(2)Tobuildthevariablesthatdefinethecommandheaderresources,suchasthenameseenbytheenduserinhis/herownlanguageinthemenu,ortheicontodisplayinatoolbar.

2)CAADegGeoCommandsisthenameofthesharedlibraryorDLLcontainingtheCuboidcommand's

code,withouttheprefixlib,andwithoutthesuffixdependingontheoperatingsystem.

3)CAADegCreateCuboidCmdisthenameoftheCuboidcommandclass

4)thelastargumentisthepossiblepointertotheobjecttopasstothecommandwhenexecutingit.Itisoftenacharacterstringthatindicatestheactiontocarryoutwhenthesamecommandcanperformseveralactionsdependingontheactivedocumentanddata,suchas"update"or"updateall",or"cut"or"copy".3.4.3.4CreatingtheWorkbenchandArrangingtheCommands3.4.3.4.1创建workbenchusingtheNewAccessmacro:

CATCmdWorkbench*CAAAfrGeoCreationWkb:

:

CreateWorkbench(){NewAccess(CATCmdWorkbench,pCAAAfrGeoCreationWkb,CAAAfrGeoCreationWkb);...//SeeCreatingtheContainersfortheToolbarsandtheMenuBarreturnpCAAAfrGeoCreationWkb;}pCAAAfrGeoCreationWkbisthevariableusedtohandlethewo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 实习总结

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1