Catia的二次开发Word文档格式.docx
《Catia的二次开发Word文档格式.docx》由会员分享,可在线阅读,更多相关《Catia的二次开发Word文档格式.docx(12页珍藏版)》请在冰点文库上搜索。
![Catia的二次开发Word文档格式.docx](https://file1.bingdoc.com/fileroot1/2023-5/11/4283ce13-c10d-4228-9609-06511dd221b2/4283ce13-c10d-4228-9609-06511dd221b21.gif)
externIIDIID_CAAIAfrGeoCreationWkbFactory;
classCAAIAfrGeoCreationWkbFactory:
publicCATIGenericFactory{CATDeclareInterface;
public:
};
AfactoryinterfaceisaCAAinterface,thatis,anabstractclassthatderivesfromCATIGenericFactory.Asanyinterface,ithasanIIDdeclaredasIID_followedbytheinterfacename,andincludesthe
CATDeclareInterfacemacrothatdeclaresthatthisabstractclassisaninterface.Noadditional3
methodthanthoseofCATIGenericFactoryisnecessary.Don'
tforgetthepublickeywordrequiredbytheTIEcompiler.(?
?
)
3.2.3源文件(Thesourcefile)
CAAIAfrGeoCreationWkbFactory.cpp
CAAIAfrGeoCreationWkbFactory.h>
IIDIID_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
CATWorkshopConfigurationFactory.h"
CATDeclareConfigurationFactory(CAAAfrGeoCreationWkb);
TheCATDeclareConfigurationFactorymacroargumentisthenameoftheworkbenchdescriptionclass.
4
3.3.3源文件
CAAAfrGeoCreationWkbFactory.cpp
CAAAfrGeoCreationWkb.h>
#include<
CAAAfrGeoCreationWkbFactory.h>
TIE_CAAIAfrGeoCreationWkbFactory.h>
CATImplementConfigurationFactory(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
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
CATCommandHeader.h>
//SeeCreatingtheCommandHeadersMacDeclareHeader(CAAAfrGeoCreationWkbHeader);
CATCreateWorkshop.h>
CATImplementClass(CAAAfrGeoCreationWkb,Implementation,CATBaseUnknown,CATNull);
TIE_CATICAAAfrGeometryWksConfiguration.h>
6
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:
MacDeclareHeader(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"
copy"
.3.4.3.4CreatingtheWorkbenchandArrangingtheCommands3.4.3.4.1创建workbenchusingtheNewAccessmacro:
CATCmdWorkbench*CAAAfrGeoCreationWkb:
CreateWorkbench(){NewAccess(CATCmdWorkbench,pCAAAfrGeoCreationWkb,CAAAfrGeoCreationWkb);
...//SeeCreatingtheContainersfortheToolbarsandtheMenuBarreturnpCAAAfrGeoCreationWkb;
}pCAAAfrGeoCreationWkbisthevariableusedtohandlethewo