收藏 分享(赏)

CAA用户界面开发——实例说明(CATIA二次开发).doc

上传人:j35w19 文档编号:6622165 上传时间:2019-04-18 格式:DOC 页数:18 大小:323KB
下载 相关 举报
CAA用户界面开发——实例说明(CATIA二次开发).doc_第1页
第1页 / 共18页
CAA用户界面开发——实例说明(CATIA二次开发).doc_第2页
第2页 / 共18页
CAA用户界面开发——实例说明(CATIA二次开发).doc_第3页
第3页 / 共18页
CAA用户界面开发——实例说明(CATIA二次开发).doc_第4页
第4页 / 共18页
CAA用户界面开发——实例说明(CATIA二次开发).doc_第5页
第5页 / 共18页
点击查看更多>>
资源描述

1、1用户界面开发实例说明Creating a Workbench一、目标1.1 目标Showing how to create a workbench to be added to a given workshop. 1.2 显示界面(workbench )Like the workshop, the workbench is an object that gathers the commands to work on the document and arrange them in toolbars and menus. 1.3 命令标签(command header)Command head

2、ers are used to make the link between the workbench and the commands.二、CAAAfrGeoCreationWbench 实例说明2.1 功能The CAAAfrGeoCreationWbench use case creates a workbench named CAA Geometrical Creation for the CAAGeometry document. Its specifications cover most of the cases you will meet. Two toolbars are pr

3、ovided:The Solids toolbar. It includes five new commands: Cuboid, Sphere, Torus, and Cylinder 1 and 2.The Surfaces toolbar. It includes three new commands: Revolution Surface, Nurbs Surface, and Offset Surface.The only change in the menu bar is the addition of these commands in the Insert menu using

4、 two submenus below the existing ones.22.2 运行运行 CATIA 系统,并依次选择 Start-Infrastructure-CAA V5: Geometrical Creation: This creates a new CAAGeometry document with the CAA V5: Geometrical Creation workbench active. 2.3 框架组成CAAAfrGeoCreationWkb Workbench description classCAAAfrGeoCreationWkbFactory Factor

5、y class for the workbench classCAAIAfrGeoCreationWkbFactory Factory interface implemented by CAAAfrGeoCreationWkbFactoryTIE_CAAIAfrGeoCreationWkbFactoryTIE class for the factory interfaceCAAIAfrGeoCreationWkbAddin Add-in interface exposed by the workbench and that all its add-ins must implementTIE_C

6、AAIAfrGeoCreationWkbAddin TIE class for the add-in interface三、程序结构(Step-by-Step)3.1 编程准备3.1.1 确认 Make sure that the workshop to which it is dedicated exposes the CATIxxxConfiguration interface, where xxx is the workshop identifier, in a PublicInterfaces or ProtectedInterfaces directory. Create the m

7、odule directory to store the workbench code along with its two subdirectories LocalInterfaces and src. Then you will need to create the following files. In the frameworks ProtectedInterfaces directoryCAAIAfrGeoCreationWkbAddin.h The header file of the workbench exposed interface to enable clients to

8、 create add-insIn the CAAAfrGeoCreationWbench.mLocalInterfaces directoryCAAIAfrGeoCreationWkbFactory.h The header file of the workbench factory interfaceCAAAfrGeoCreationWkbFactory.h The header file of the workbench factory classCAAAfrGeoCreationWkb.h The header file of the workbench description cla

9、ssIn the CAAAfrGeoCreationWbench.msrc directoryCAAIAfrGeoCreationWkbAddin.cpp The source file of the workbench exposed interface to enable clients to create add-insCAAIAfrGeoCreationWkbFactory.cpp The source file of the workbench factory interfaceCAAAfrGeoCreationWkbFactory.cpp The source file of th

10、e workbench factory classCAAAfrGeoCreationWkb.cpp The source file of the workbench description classTIE_CAAIAfrGeoCreationWkbAddin.tsrc The file to create the TIE for CAAIAfrGeometryWksAddinTIE_CAAIAfrGeoCreationWkbFactory.tsrc The file to create the TIE for 3CAAIAfrGeometryWksFactoryIn the dictiona

11、ry, that is the CNextcodedictionary directory, referenced at run time using the CATDictionaryPath environment variable, create or updateCAAApplicationFrame.edu.dico The interface dictionaryCAAApplicationFrame.edu.fact The factory dictionaryIn the CNextresourcesmsgcatalog directory, referenced at run

12、 time using the CATMsgCatalogPath environment variableCAAAfrGeoCreationWkb.CATNls The workbench message fileCAAAfrGeoCreationWkbHeader.CATNls andCAAAfrGeoCreationWkbHeader.CATRscThe command header resource files3.1.2 开发步骤# Step Where1 Create the workbench factory interface LocalInterfaces and src2 C

13、reate the workbench factory LocalInterfaces and src3 Create the workbench description class LocalInterfaces and src4 Create the command headers CreateCommands method5 Create the workbench and arrange the commands CreateWorkbench method6 Provide the resources and insert the workbench into the Start m

14、enu Resource files7 Create the workbench exposed interface ProtectedInterfaces and src3.2 建立 Workbench 的 Factory Interface (Creating the Workbench Factory Interface)3.2.1 命名CAAIAfrGeoCreationWkbFactory3.2.2 头文件(the header file )CAAIAfrGeoCreationWkbFactory.h#include extern IID IID_CAAIAfrGeoCreation

15、WkbFactory;class CAAIAfrGeoCreationWkbFactory : public CATIGenericFactoryCATDeclareInterface;public :;A factory interface is a CAA interface, that is, an abstract class that derives from CATIGenericFactory. As any interface, it has an IID declared as IID_ followed by the interface name, and includes

16、 the CATDeclareInterface macro that declares that this abstract class is an interface. No additional 4method than those of CATIGenericFactory is necessary. Dont forget the public keyword required by the TIE compiler.(?)3.2.3 源文件(The source file )CAAIAfrGeoCreationWkbFactory.cpp#include IID IID_CAAIA

17、frGeoCreationWkbFactory = 0xb32eed10,0xd4c1,0x11d3,0xb7, 0xf5, 0x00, 0x08, 0xc7, 0x4f, 0xe8, 0xdd;CATImplementInterface(CAAIAfrGeoCreationWkbFactory, CATIGenericFactory);The CATImplementInterface macro is used in conjunction with CATDeclareInterface in the header file to make an interface from this

18、abstract class and to declare that it OM-derives from CATIGenericfactory.3.2.4 TIE 文件(The TIE tsrc file )TIE_CAAIAfrGeoCreationWkbFactory.tsrc #include “CAAIAfrGeoCreationWkbFactory.h“The Multi-Workspace Application Builder (mkmk) will generate the TIE for this interface for you, that is, the TIE_CA

19、AIAfrGeoCreationWkbFactory.h file in the ProtectedGenerated directory.3.3 建立 Workbench 的 Factory (Creating the Workbench Factory)3.3.1 注意事项The factory class that creates workbench instances must concatenate the name of the class to instantiate, that is, the workbench description class CAAAfrGeoCreat

20、ionWkb, with the string Factory. This gives CAAAfrGeoCreationWkbFactory.3.3.2 头文件CAAAfrGeoCreationWkbFactory.h #include “CATWorkshopConfigurationFactory.h“ CATDeclareConfigurationFactory(CAAAfrGeoCreationWkb);The CATDeclareConfigurationFactory macro argument is the name of the workbench description

21、class. 53.3.3 源文件CAAAfrGeoCreationWkbFactory.cpp #include #include #include CATImplementConfigurationFactory(CAAAfrGeoCreationWkb,CAAIAfrGeoCreationWkbFactory);The CATImplementConfigurationFactory arguments are the name of the workbench description class and the name of the workbench factory interfa

22、ce respectively. The CATDeclareConfigurationFactory and CATImplementConfigurationFactory macros create the workbench factory implementation class as a data extension of the CATApplicationFrame component3.3.4 更新字典3.3.4.1 The interface dictionarythat is a file whose name is the framework name suffixed

23、 by dico, such as CAAApplicationFrame.dico, and that you should create or update in the framework CNext/code/dictionary directory. The interface dictionary contains the following declaration to state that the CATApplicationFrame component implements the CAAIAfrGeoCreationWkbFactory interface, by mea

24、ns of the extension class created by the macros, whose code is located in the libCAAAfrGeoCreationWbench shared library or DLL:(不太明白)CATApplicationFrame CAAIAfrGeoCreationWkbFactory libCAAAfrGeoCreationWbench3.3.4.2 The factory dictionarythat is a file whose name is the framework name suffixed by fa

25、ct, such as CAAApplicationFrame.fact, and that you should create or update in the framework CNext/code/dictionary directory. The factory dictionary contains the following declaration to state that the CAAIAfrGeoCreationWkbFactory interface is an interface to a factory whose implementation creates a

26、CAAAfrGeoCreationWkb class instance: CAAAfrGeoCreationWkb CAAIAfrGeoCreationWkbFactory3.4 定义与实现 Workbench 类(Creating the Workbench Description Class)3.4.1 说明The CAAAfrGeoCreationWkb class implements the CATICAAAfrGeometryWksConfiguration interface exposed by the CAAGeometry workshop . It includes th

27、e following methods: CreateCommands to instantiate the command headers for the commands of the workbench CreateWorkbench to create the containers for the workbench, the menus, and the toolbars, and arrange the commands in the menus and toolbars 6 GetCustomInterfaces which returns the names of the in

28、terfaces exposed by the workbench to enable its customization GetAddinInterface which returns the name of the interface exposed by the workbench to create add-ins. 3.4.2 头文件CAAAfrGeoCreationWkb.h#include “CATBaseUnknown.h“#include “CATListPV.h“class CATCmdWorkbench;class CAAAfrGeoCreationWkb : publi

29、c CATBaseUnknownCATDeclareClass;public:CAAAfrGeoCreationWkb();virtual CAAAfrGeoCreationWkb();void CreateCommands();CATCmdWorkbench * CreateWorkbench();CATClassId GetAddinInterface();void GetCustomInterfaces(CATListPV * oDefaultIIDList , CATListPV * oCustomIIDList) ;private:CAAAfrGeoCreationWkb(const

30、 CAAAfrGeoCreationWkb ;The CAAAfrGeoCreationWkb class C+-derives from CATBaseUnknown. The CATDeclareClass macro declares that the class CAAAfrGeoCreationWkb belongs to a component. The class has a constructor, a destructor, the four methods of the CATIWorkbench interface, and a copy constructor. Not

31、e that the copy constructor is set as private. This prevents the compiler from creating the copy constructor as public without you know. This copy constructor is not implemented in the source file.3.4.3 源文件CAAAfrGeoCreationWkb.cpp #include #include / See Creating the Command HeadersMacDeclareHeader(

32、CAAAfrGeoCreationWkbHeader);#include CATImplementClass(CAAAfrGeoCreationWkb, Implementation, CATBaseUnknown, 7CATNull);#include TIE_CATICAAAfrGeometryWksConfiguration(CAAAfrGeoCreationWkb);CAAAfrGeoCreationWkb:CAAAfrGeoCreationWkb() CAAAfrGeoCreationWkb:CAAAfrGeoCreationWkb() void CAAAfrGeoCreationW

33、kb:CreateCommands(). / See Creating the Command HeadersCATCmdWorkbench * CAAAfrGeoCreationWkb:CreateWorkbench(). / See Creating the Workbench and Arranging the CommandsCATClassId CAAAfrGeoCreationWkb:GetAddinInterface()return “CAAIAfrGeoCreationWkbAddin“;void CAAAfrGeoCreationWkb:GetCustomInterfaces

34、(CATListPV * oDefaultIIDList,CATListPV * oCustomIIDList)3.4.3.1 TIE_CATICAAAfrGeometryWksConfiguration 宏The CAAAfrGeoCreationWkb class states that it implements the CATICAAAfrGeometryWksConfiguration interface3.4.3.2 TIE_ CATImplementClass 宏declaring that the CAAAfrGeoCreationWkb class is a componen

35、t main class 2, thanks to the Implementation keyword, and that it OM-derives from CATBaseUnknown 2. The fourth parameter must always be set to CATNull for component main classes.3.4.3.3 创建命令标签(Creating the Command Headers)(见命令标签)3.4.3.3.1 命令标签Each command available in your workbench must have a comm

36、and header. A command header is an instance of a command header class, and different commands can share the same command header class to create their command header. 3.4.3.3.2 创建命令标签类CAAAfrGeoCreationWkbHeader command header class is careated in CAAAfrGeoCreationWkb.cpp: 8#include MacDeclareHeader(C

37、AAAfrGeoCreationWkbHeader);The MacDeclareHeader macro creates the header file and the source file for the CAAAfrGeoCreationWkbHeader class, and associates with this class the resource files CAAAfrGeoCreationWkbHeader.CATNls and CAAAfrGeoCreationWkbHeader.CATRsc. 3.4.3.3.3 定义命令标签Create the code to in

38、stantiate your command headers in the empty CreateCommands method. This method should contain one instantiation statement of the command header class per command. Each statement has the following form, for example for the Cuboid command. void CAAAfrGeoCreationWkb:CreateCommands().new CAAAfrGeoCreati

39、onWkbHeader(“CAAAfrCuboidHdr“,“CAADegGeoCommands“,“CAADegCreateCuboidCmd“,(void *) NULL);. 其中:1)CAAAfruboidHdr is the identifier you need to assign to the command header. It will be used afterwards: (1)To associate the command starters you will define to put the command in a menu and in toolbars wit

40、h the command header.(2)To build the variables that define the command header resources, such as the name seen by the end user in his/her own language in the menu, or the icon to display in a toolbar. 2)CAADegGeoCommands is the name of the shared library or DLL containing the Cuboid commands code, w

41、ithout the prefix lib, and without the suffix depending on the operating system. 3)CAADegCreateCuboidCmd is the name of the Cuboid command class 4)the last argument is the possible pointer to the object to pass to the command when executing it. It is often a character string that indicates the actio

42、n to carry out when the same command can perform several actions depending on the active document and data, such as “update“ or “update all“, or “cut“ or “copy“. 3.4.3.4 Creating the Workbench and Arranging the Commands3.4.3.4.1 创建 workbench using the NewAccess macro:CATCmdWorkbench * CAAAfrGeoCreat

43、ionWkb:CreateWorkbench()NewAccess(CATCmdWorkbench,pCAAAfrGeoCreationWkb,CAAAfrGeoCreationWkb);. / See Creating the Containers for the Toolbars and the Menu Barreturn pCAAAfrGeoCreationWkb;9pCAAAfrGeoCreationWkb is the variable used to handle the workbench instance pointer, and CAAAfrGeoCreationWkb i

44、s the workbench identifier. Note that the workbench class name and the workbench identifier must be identical to take into account the workbench resources in the Start menu. They appear both in bold typeface. This identifier is also used to name the workbench resource files CAAAfrGeoCreationWkb.CATN

45、ls and CAAAfrGeoCreationWkb.CATRsc. The workbench resources, and how to provide them, are described in Creating Resources for Workbenches. 3.4.3.4.2 创建 containers .NewAccess(CATCmdContainer,pCAAAfrSolidEltTlb,CAAAfrSolidEltTlb);SetAccessChild(pCAAAfrGeoCreationWkb, pCAAAfrSolidEltTlb);. / See Creati

46、ng the Solids Toolbar ContentAddToolbarView(pCAAAfrSolidEltTlb,1,Right);NewAccess(CATCmdContainer,pCAAAfrSurfacicEltTlb,CAAAfrSurfacicEltTlb);SetAccessNext(pCAAAfrSolidEltTlb,pCAAAfrSurfacicEltTlb);. / See Creating the Surfaces Toolbar ContentAddToolbarView(pCAAAfrSurfacicEltTlb,-1,Right);NewAccess(

47、CATCmdContainer,pCAAAfrGeoCreationMbr,CAAAfrGeoCreationMbr);. / See Creating the Menu Bar ContentSetWorkbenchMenu(pCAAAfrGeoCreationWkb,pCAAAfrGeoCreationMbr);.其中:(1)The Solids toolbar is created as an instance of the CATCmdContainer class using the NewAccess macro. pCAAAfrSolidEltTlb is the variabl

48、e used to handle the Solids toolbar command container instance pointer, and CAAAfrSolidEltTlb is the identifier used to refer to it in the workbench resource files. This identifier must be unique among all the toolbar identifiers that can be found within the application. The Solids toolbar is set as

49、 the child of the workbench using the SetAccessChild macro, and its default location is defined using the AddToolbarView macro, where 1 means that the Solids toolbar is visible by default (-1 means invisible), and Right means that the toolbar is docked at the right side of the application window. (2)The Surfaces toolbar is created in the same way, but it is set next to the Solids toolbar using the SetAccessNext macro. It is invisible (-1 means invisible) by default, and is also docked at the right side of t

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

当前位置:首页 > 实用文档 > 说明文书

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报