当前位置:文档之家› CAA用户界面开发——实例说明(CATIA二次开发)

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

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

用户界面开发——实例说明

——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 headers 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

provided:

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 two

submenus below the existing ones.

2.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 class CAAAfrGeoCreationWkbFactory Factory class for the workbench class CAAIAfrGeoCreationWkbFactory Factory interface implemented by CAAAfrGeoCreationWkbFactory TIE_CAAIAfrGeoCreationWkbFactory TIE class for the factory interface

CAAIAfrGeoCreationWkbAddin Add-in interface exposed by the workbench and that all its add-ins must implement

TIE_CAAIAfrGeoCreationWkbAddin 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 module 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 framework's ProtectedInterfaces directory

CAAIAfrGeoCreationWkbAddin.h The header file of the workbench exposed interface

to enable clients to create add-ins In the CAAAfrGeoCreationWbench.m\LocalInterfaces directory

CAAIAfrGeoCreationWkbFactory.h The header file of the workbench factory interface CAAAfrGeoCreationWkbFactory.h The header file of the workbench factory class

CAAAfrGeoCreationWkb.h The header file of the workbench description class In the CAAAfrGeoCreationWbench.m\src directory

CAAIAfrGeoCreationWkbAddin.cpp The source file of the workbench exposed interface

to enable clients to create add-ins CAAIAfrGeoCreationWkbFactory.cpp The source file of the workbench factory interface CAAAfrGeoCreationWkbFactory.cpp The source file of the workbench factory class

CAAAfrGeoCreationWkb.cpp The source file of the workbench description class TIE_CAAIAfrGeoCreationWkbAddin.tsrc The file to create the TIE for

CAAIAfrGeometryWksAddin

TIE_CAAIAfrGeoCreationWkbFactory.tsrc The file to create the TIE for

CAAIAfrGeometryWksFactory

In the dictionary, that is the CNext\code\dictionary directory, referenced at run time using the

CATDictionaryPath environment variable, create or update

https://www.doczj.com/doc/7e3215964.html,.dico The interface dictionary

https://www.doczj.com/doc/7e3215964.html,.fact The factory dictionary

In the CNext\resources\msgcatalog directory, referenced at run time using the

CATMsgCatalogPath environment variable

CAAAfrGeoCreationWkb.CATNls The workbench message file

The command header resource files CAAAfrGeoCreationWkbHeader.CATNls and

CAAAfrGeoCreationWkbHeader.CATRsc

3.1.2 开发步骤

# Step Where

1 Create the workbench factory interface LocalInterfaces and src

2 Create the workbench factory LocalInterfaces and src

3 Create the workbench description class LocalInterfaces and src

4 Create the command headers CreateCommands method

5 Create the workbench and arrange the commands CreateWorkbench method

6 Provide the resources and insert the workbench into the Start menu Resource files

7 Create the workbench exposed interface ProtectedInterfaces and src 3.2 建立Workbench 的Factory Interface

(Creating the Workbench Factory Interface)

3.2.1 命名

CAAIAfrGeoCreationWkb Factory

3.2.2 头文件(the header file )

CAAIAfrGeoCreationWkbFactory.h

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 the CATDeclareInterface macro that declares that this abstract class is an interface. No additional

method than those of CATIGenericFactory is necessary. Don't forget the public keyword required by the TIE compiler.(???)

3.2.3 源文件(The source file )

CAAIAfrGeoCreationWkbFactory.cpp

#include

IID IID_CAAIAfrGeoCreationWkbFactory = {

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 abstract class and to declare that it OM-derives from

CATIGenericfactory.

3.2.4 TIE文件(The TIE tsrc file)

The Multi-Workspace Application Builder (mkmk) will generate the TIE for this interface for you, that is, the TIE_CAAIAfrGeoCreationWkbFactory.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 CAAAfrGeoCreationWkb, with the string Factory. This gives CAAAfrGeoCreationWkbFactory.

3.3.2 头文件

CATDeclareConfigurationFactory

class.

3.3.3 源文件

The CATImplementConfigurationFactory arguments are the name of the workbench description class and the name of the workbench factory interface respectively. The

CATDeclareConfigurationFactory and CATImplementConfigurationFactory macros create the workbench factory implementation class as a data extension of the CATApplicationFrame component

3.3.4 更新字典

3.3.

4.1 The interface dictionary

that is a file whose name is the framework name suffixed 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 means of the extension class created by the macros, whose code is located in the libCAAAfrGeoCreationWbench shared library or DLL:(不太明白)

3.3.

4.2 The factory dictionary

that is a file whose name is the framework name suffixed by fact, 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

class instance:

3.4 定义与实现Workbench 类

(Creating the Workbench Description Class)

3.4.1 说明

The CAAAfrGeoCreationWkb class implements the CATICAAAfrGeometryWksConfiguration interface exposed by the CAAGeometry workshop . It includes the 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

?GetCustomInterface s which returns the names of the interfaces 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 : public CATBaseUnknown

{

CATDeclareClass;

public:

CAAAfrGeoCreationWkb();

virtual ~CAAAfrGeoCreationWkb();

void CreateCommands();

CATCmdWorkbench * CreateWorkbench();

CATClassId GetAddinInterface();

void GetCustomInterfaces(CATListPV * oDefaultIIDList ,

CATListPV * oCustomIIDList) ;

private:

CAAAfrGeoCreationWkb(const CAAAfrGeoCreationWkb &iObjectToCopy);

};

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.

Note 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 源文件

TIE_CATICAAAfrGeometryWksConfiguration(CAAAfrGeoCreationWkb);

CAAAfrGeoCreationWkb::CAAAfrGeoCreationWkb() {}

CAAAfrGeoCreationWkb::~CAAAfrGeoCreationWkb() {}

void CAAAfrGeoCreationWkb::CreateCommands()

{

... // See Creating the Command Headers

}

CATCmdWorkbench * CAAAfrGeoCreationWkb::CreateWorkbench()

{

... // See Creating the Workbench and Arranging the Commands

}

CATClassId CAAAfrGeoCreationWkb::GetAddinInterface()

{

return "CAAIAfrGeoCreationWkbAddin";

}

void CAAAfrGeoCreationWkb::GetCustomInterfaces(CATListPV * oDefaultIIDList,

CATListPV * oCustomIIDList)

{}

3.4.3.1 TIE_CATICAAAfrGeometryWksConfiguration 宏

The CAAAfrGeoCreationWkb class states that it implements the CATICAAAfrGeometryWksConfiguration interface

3.4.3.2 TIE_ CATImplementClass宏

declaring that the CAAAfrGeoCreationWkb class is a component 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 command 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 创建命令标签类

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 instantiate your command headers in the empty CreateCommands method. This method should contain one instantiation statement of the command header class per command. Each statement

其中:

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 with 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 command's code, without 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 action 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 Commands

3.4.3.4.1 创建workbench

NewAccess

pCAAAfrGeoCreationWkb is the variable used to handle the workbench instance pointer, and CAAAfrGeoCreationWkb is 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.CATNls 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 Creating the Solids Toolbar Content

AddToolbarView(pCAAAfrSolidEltTlb,1,Right);

NewAccess(CATCmdContainer,pCAAAfrSurfacicEltTlb,CAAAfrSurfacicEltTlb);

SetAccessNext(pCAAAfrSolidEltTlb,pCAAAfrSurfacicEltTlb);

... // See Creating the Surfaces Toolbar Content

AddToolbarView(pCAAAfrSurfacicEltTlb,-1,Right);

NewAccess(CATCmdContainer,pCAAAfrGeoCreationMbr,CAAAfrGeoCreationMbr);

... // See Creating the Menu Bar Content

SetWorkbenchMenu(pCAAAfrGeoCreationWkb,pCAAAfrGeoCreationMbr);

...

其中:

(1)The Solids toolbar is created as an instance of the CATCmdContainer class using the NewAccess macro. pCAAAfrSolidEltTlb is the variable 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 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 the application window.

(3)The menu bar is also created as an instance of the CATCmdContainer class and is referred to using the pCAAAfrGeoCreationMbr pointer. Its identifier is CAAAfrGeoCreationMbr and is used for its resources. It is set as the workbench's menu bar using the SetWorkbenchMenu macro.

The toolbar resources, and how to provide them, are described in Creating Resources for Workbenches. See also Providing the Resources and Inserting the Workbench into the Start Menu for an overview of all

the resources to create.

1)添加Solids 工具条按钮(Creating the Solids Toolbar Content)

This toolbar contains four commands: Cuboid, Sphere, Torus, and Cylinder. You should, for each command:

(1)Create a command starter using the NewAccess macro

(2)Associate the command starter, using the SetAccessCommand macro, with the appropriate command header identifier defined in the CreateCommands method

(3)Arrange the command starters in the toolbar using the SetAccessChild and SetAccessNext macros ...

NewAccess(CATCmdStarter,pCAAAfrTSolidEltCuboidStr,CAAAfrTSolidEltCuboidStr);

SetAccessCommand(pCAAAfrTSolidEltCuboidStr,"CAAAfrCuboidHdr");

SetAccessChild(pCAAAfrSolidEltTlb,pCAAAfrTSolidEltCuboidStr);

NewAccess(CATCmdStarter,pCAAAfrTSolidEltSphereStr,CAAAfrTSolidEltSphereStr);

SetAccessCommand(pCAAAfrTSolidEltSphereStr,"CAAAfrSphereHdr");

SetAccessNext(pCAAAfrTSolidEltCuboidStr,pCAAAfrTSolidEltSphereStr);

NewAccess(CATCmdStarter,pCAAAfrTSolidEltTorusStr,CAAAfrTSolidEltTorusStr);

SetAccessCommand(pCAAAfrTSolidEltTorusStr,"CAAAfrTorusHdr");

SetAccessNext(pCAAAfrTSolidEltSphereStr,pCAAAfrTSolidEltTorusStr);

NewAccess(CATCmdStarter,pCAAAfrTSolidEltCylinder1Str,CAAAfrTSolidEltCylinder1Str);

SetAccessCommand(pCAAAfrTSolidEltCylinder1Str,"CAAAfrCylinder1Hdr");

SetAccessNext(pCAAAfrTSolidEltTorusStr,pCAAAfrTSolidEltCylinder1Str);

NewAccess(CATCmdStarter,pCAAAfrTSolidEltCylinder2Str,CAAAfrTSolidEltCylinder2Str);

SetAccessCommand(pCAAAfrTSolidEltCylinder2Str,"CAAAfrCylinder2Hdr");

SetAccessNext(pCAAAfrTSolidEltCylinder1Str,pCAAAfrTSolidEltCylinder2Str);

...

Three macros are required for each command. For example, the Cuboid command is processed as follows:

1) First create the command starter as a CATCmdStarter instance using the NewAccess macro. pCAAAfrTSolidEltCuboidStr is the variable used to handle a pointer to that

instance, and CAAAfrTSolidEltCuboidStr is its identifier.

2) Then associate the Cuboid command header with this command starter using the SetAccessCommand macro. The second parameter is the Cuboid command header

identifier defined as the first parameter of the command header consrtuctor. Refer to

Creating the Command Headers

3) Finally set the Cuboid command starter as the child of the Solids toolbar.

Proceed in the same way for the other commands, except that they are set as next of one another using the SetAccessNext macro.

2)添加Surfaces 工具条按钮(Creating the Surfaces Toolbar Content)

This toolbar contains three commands: Revolution Surface, Nurbs Surface, and Offset Surface. You should, for each command:

(1)Create a command starter using the NewAccess macro

(2)Associate the command starter, using the SetAccessCommand macro, with the appropriate command header identifier defined in the CreateCommands method

(3)Arrange the command starters in the toolbar using the SetAccessChild and SetAccessNext macros ...

NewAccess(CATCmdStarter,pCAAAfrTSurfRevolStr,CAAAfrTSurfRevolStr);

SetAccessCommand(pCAAAfrTSurfRevolStr,"CAAAfrRevolSurfHdr");

SetAccessChild(pCAAAfrSurfacicEltTlb,pCAAAfrTSurfRevolStr);

NewAccess(CATCmdStarter,pCAAAfrTSurfNurbsStr,CAAAfrTSurfNurbsStr);

SetAccessCommand(pCAAAfrTSurfNurbsStr,"CAAAfrNurbsSurfHdr");

SetAccessNext(pCAAAfrTSurfRevolStr,pCAAAfrTSurfNurbsStr);

NewAccess(CATCmdStarter,pCAAAfrTSurfOffsetStr,CAAAfrTSurfOffsetStr);

SetAccessCommand(pCAAAfrTSurfOffsetStr,"CAAAfrOffsetSurfHdr");

SetAccessNext(pCAAAfrTSurfNurbsStr,pCAAAfrTSurfOffsetStr);

...

Three macros are required for each command. For example, the Revolution Surface command is processed as follows:

(1)First create the command starter as a CATCmdStarter instance using the NewAccess macro. pCAAAfrTSurfRevolStr is the variable used to handle a pointer to that instance, and CAAAfrTSurfRevolStr is its identifier.

(2)Then associate the Revolution Surface command header with this command starter using the SetAccessCommand macro. The second parameter is the Revolution Surface command header identifier defined as the first parameter of the command header consrtuctor. Refer to Creating the Command Headers

(3)Finally set the Revolution Surface command starter as the child of the Surfaces toolbar.

Proceed in the same way for the other commands, except that they are set as next of one another using the SetAccessNext macro.

3)添加菜单项(Creating the Menu Bar Content)

Menus and submenus are created as CATCmdContainer instances, and menu items as CATCmdStarter instances. The menu bar you create will be merged when the workbench is loaded or activated at run time with the workshop menu bar, itself resulting in the merge of the default menu bar, that is, the one that exists when no document is active, with the one defined for the workshop. You can neither remove a menu from the default menu bar or from the menu bar defined for the workshop, nor change the menu order. You can add submenus to menus. You can also add submenus to your own submenus, but not to existing submenus.

You should:

(1)Create a command container for each menu and submenu using the NewAccess macro

(2)Create a command starter for each command using the NewAccess macro

(3)Associate each command starter, using the SetAccessCommand macro, with the appropriate command header identifier defined in the CreateCommands method

(4)Arrange the command starters in the menu using the SetAccessChild, and SetAccessNext macros ——Insert Menu - Solids Submenu

SetAccessNext(pCAAAfrGeoCreationInsertSep,pCAAAfrSolidEltSnu);

NewAccess(CATCmdStarter,pCAAAfrMSolidCuboidStr,CAAAfrMSolidCuboidStr);

SetAccessChild(pCAAAfrSolidEltSnu,pCAAAfrMSolidCuboidStr);

SetAccessCommand(pCAAAfrMSolidCuboidStr,"CAAAfrCuboidHdr");

NewAccess(CATCmdStarter,pCAAAfrMSolidSphereStr,CAAAfrMSolidSphereStr);

SetAccessNext(pCAAAfrMSolidCuboidStr,pCAAAfrMSolidSphereStr);

SetAccessCommand(pCAAAfrMSolidSphereStr,"CAAAfrSphereHdr");

NewAccess(CATCmdStarter,pCAAAfrMSolidTorusStr,CAAAfrMSolidTorusStr);

SetAccessNext(pCAAAfrMSolidSphereStr,pCAAAfrMSolidTorusStr);

SetAccessCommand(pCAAAfrMSolidTorusStr,"CAAAfrTorusHdr");

NewAccess(CATCmdStarter,pCAAAfrMSolidCylinder1Str,CAAAfrMSolidCylinder1Str);

SetAccessNext(pCAAAfrMSolidTorusStr,pCAAAfrMSolidCylinder1Str);

SetAccessCommand(pCAAAfrMSolidCylinder1Str,"CAAAfrCylinder1Hdr");

NewAccess(CATCmdStarter,pCAAAfrMSolidCylinder2Str,CAAAfrMSolidCylinder2Str);

SetAccessNext(pCAAAfrMSolidCylinder1Str,pCAAAfrMSolidCylinder2Str);

SetAccessCommand(pCAAAfrMSolidCylinder2Str,"CAAAfrCylinder2Hdr");

...

The Insert menu command container is created, even if it already exists. Then the Solids submenu command container is created and set as the child of the Insert menu command container. Since no other positioning information is given, it should lay below the last submenu or command of the workshop menu bar, that is the Plane command. Then the Cuboid command starter is created and set as the child of the Solids submenu command container, and the others are cretaed and set next of one another.

——Insert Menu - Surfaces Submenu

...

NewAccess(CATCmdContainer,pCAAAfrSurfacicEltSnu,CAAAfrSurfacicEltSnu) ;

SetAccessNext(pCAAAfrSolidEltSnu,pCAAAfrSurfacicEltSnu);

NewAccess(CATCmdStarter,pCAAAfrMSurfRevolStr,CAAAfrMSurfRevolStr);

SetAccessChild(pCAAAfrSurfacicEltSnu,pCAAAfrMSurfRevolStr);

SetAccessCommand(pCAAAfrMSurfRevolStr,"CAAAfrRevolSurfHdr");

NewAccess(CATCmdStarter,pCAAAfrMSurfNurbsStr,CAAAfrMSurfNurbsStr);

SetAccessNext(pCAAAfrMSurfRevolStr,pCAAAfrMSurfNurbsStr);

SetAccessCommand(pCAAAfrMSurfNurbsStr,"CAAAfrNurbsSurfHdr");

The Surfaces submenu command container is created and set next to the Solids submenu command container. Then the Revolution Surface command starter is created and set as the child of the Surfaces submenu command container, and the others are cretaed and set next of one another.

The menu and submenu resources, and how to provide them, are described in Creating Resources for Workbenches. See also Providing the Resources and Inserting the Workbench into the Start Menu for an overview of all the resources to create.

3.4.3.5 GetCustomInterfaces方法

The GetCustomInterfaces method must be empty. The names of the interface exposed by the workbench to enable clients to create add-ins is returned by the GetAddinInterface method.

3.4.4 修改字典(Updating the Dictionary)

Update the interface dictionary, that is a file named, for example, CAAApplicationFrame.dico, whose directory's pathname is concatenated at run time in the CATDictionaryPath environment variable, and containing the following declaration to state that the CAAAfrGeoCreationWkb class implements the CATICAAAfrGeometryWksConfiguration interface, and whose code is located in the libCAAAfrGeoCreationWbench shared library or DLL. The update is in bold typeface:

3.5 创建资源及嵌入Workbench

(Providing the Resources and Inserting the Workbench into the Start Menu)

3.5.1 workbench资源(The workbench and command container resources)

3.5.1.1 文本资源

The resource file containing the title and help messages in the English language, and that can be translated into other languages. It is suffixed using CATNls The resource files must have the workbench identifier as file name, that is CAAAfrGeoCreationWkb. This identifier is declared in the CreateWorkbench method of the workbench description class, as the third parameter of the NewAccess macro that creates the

The workbench resource files are then CAAAfrGeoCreationWkb.CATNls and CAAAfrGeoCreationWkb.CATRsc. These files are located in the CNext\resources\msgcatalog directory of the framework containing the workbench module. This directory includes subdirectories, one for each language into which the title and messages of the CAAAfrGeoCreationWkb.CATNls file can be translated. The resource files contain:

o Workbench: the title, messages, and icons to be displayed in the Start menu

o Toolbars: their titles

o Menus and submenus: their titles, icons, and mnemonics

o Icon boxes: their titles.

Each resource is provided using a key and a text, or a file name without suffix, separated by the equal sign. The key is built as a concatenation of the object identifier you defined as the third parameter of the NewAccess macro, a dot, and a keyword designating the appropriate resource. The message is enclosed using double quotes and ended using a semicolon. For example, the CAAAfrGeoCreationWkb workbench

The CAAAfrGeoCreationWkb.CATNls file contains:

?The resources for the workbench itself: the title used in the Start menu, its

associated help message, the short help displayed when the mouse is over the

workbench icon, and the long help

?The titles of the toolbars and icon boxes

?The titles and mnemonics of the menus and submenus.

//----------------------------------------------------------------------------

// WORKBENCH

//----------------------------------------------------------------------------

CAAAfrGeoCreationWkb.Title = "CAA V5: Geometrical Creation";

CAAAfrGeoCreationWkb.ShortHelp = "Workbench to create Geometrical Elements";

CAAAfrGeoCreationWkb.Help = "Workbench to create Geometrical, Solid and Surfacic Elements";

CAAAfrGeoCreationWkb.LongHelp = "This is the CAA V5: Geometrical Creation Workbench.

It is used to demonstrate workbenches.

It contains two toolsbars:

- One for some Solid Elements

- The other for some Surfacic Elements";

//----------------------------------------------------------------------------

// TOOLBAR

//----------------------------------------------------------------------------

CAAAfrSolidEltTlb.Title = "Solids" ;

CAAAfrSurfacicEltTlb.Title = "Surfaces" ;

//----------------------------------------------------------------------------

// SUB - MENU

//----------------------------------------------------------------------------

CAAAfrSolidEltSnu.Title = "Solids" ;

CAAAfrSolidEltSnu.Mnemonic = "S";

CAAAfrSurfacicEltSnu.Title = "Surfaces" ;

CAAAfrSurfacicEltSnu.Mnemonic = "u";

3.5.1.2 位图资源CAAAfrGeoCreationWkb.CATRsc

This file contains the category, that is the submenu of the Start menu where the workbench should appear, and the names of the icons to be associated with the workbench for the Start menu.

CAAAfrGeoCreationWkb.Category = "Infrastructure" ;

// Icons for the Welcome window 64x64

CAAAfrGeoCreationWkb.Icon.NormalPnl = "I_WkAsCAAAfrGeoCreationWkb";

CAAAfrGeoCreationWkb.Icon.PressedlPnl = "IP_WkAsCAAAfrGeoCreationWkb";

CAAAfrGeoCreationWkb.Icon.FocusedlPnl = "IF_WkAsCAAAfrGeoCreationWkb";

// Icons for the Start menu 32x32

CAAAfrGeoCreationWkb.Icon.NormalCtx = "I_WkNvCAAAfrGeoCreationWkb";

CAAAfrGeoCreationWkb.Icon.PressedlCtx = "IP_WkNvCAAAfrGeoCreationWkb";

CAAAfrGeoCreationWkb.Icon.FocusedlCtx = "IF_WkNvCAAAfrGeoCreationWkb";

// Icons for the workbench toolbar 24x24

CAAAfrGeoCreationWkb.Icon.NormalRep = "I_WkCAAAfrGeoCreationWkb";

CAAAfrGeoCreationWkb.Icon.PressedlRep = "IP_WkCAAAfrGeoCreationWkb";

CAAAfrGeoCreationWkb.Icon.FocusedlRep = "IF_WkCAAAfrGeoCreationWkb";

It is in this file that you declare if the workbench is warm start compliant [3]. The CAAGeometry document is not warm start compliant, so its workbenches are not compliant too.

3.5.2 command header资源

The command header resources in the command header resource files: titles, messages, icons, and the accelerators associated with the commands. The resource files searched for at run time should have the same name than you command header class, that is CAAAfrGeoCreationWkbHeader.

3.5.2.1 文本资源CAAAfrGeoCreationWkbHeader.CATNls

The CAAAfrGeoCreationWkbHeader.CATNls file contains the following for the Cuboid commands

For each command, the title, short help, help, and long help are declared.

3.5.2.2 位图资源CAAAfrGeoCreationWkbHeader. CATRsc

The CAAAfrGeoCreationWkbHeader.CATRsc file includes the following for the Cuboid command

This icon name is provided to display in the Solids toolbar where the Cuboid command is included. The icon is also displayed in front of the menu item in the menu.

The command starter resources are the mnemonics associated with the commands. They are automatically set at run time.

3.6 创建应用插件(Creating the Workbench Exposed Interface)

3.6.1 头文件

To enable client applications of your workbench to customize it with add-ins, you should provide the CAAIAfrGeoCreationWkbAddin interface the client application will implement. This enables the client application to add its own commands in one or several new toolbars.

The header file of this interface should be inserted in the ProtectedInterfaces or PublicInterfaces directory of your framework to make it available to client applications. To create the CAAIAfrGeoCreationWkbAddin interface:

Create the CAAIAfrGeoCreationWkbAddin.h file as follows.

#include // Needed to derive from CATIWorkbenchAddin #include "CAAAfrGeoCreationWbench.h" // Needed to export the IID

extern IID ExportedByCAAAfrGeoCreationWbench IID_CAAIAfrGeoCreationWkbAddin;

class ExportedByCAAAfrGeoCreationWbench CAAIAfrGeoCreationWkbAddin : public

CATIWorkbenchAddin

{

CATDeclareInterface;

public :

};

The CAAIAfrGeoCreationWkbAddin.h file contains the ExportedByCAAAfrGeoCreationWbench definition that manages the DLL interface for Windows, and is set to blank for UNIX. Don't forget the public keyword required by the TIE compiler.

3.6.2 源文件

The CATDeclareInterface and CATImplementInterface macros make an interface from this C++ class.

四、问题(Troubleshooting)

A Command Doesn't Display in the Menu Bar or Toolbar

I create a command starter for a command, and I arrange it in the menu bar or in a toolbar, but the

command doesn't display in the menu bar or toolbar where I place it.

The command starter is not associated with a command header, and is thus not displayed, since the command cannot be launched without command header.

Check your CreateWorkbench method. The command starter must be associated with a command header for the command you want to display thanks to the SetAccessCommand macro.

相关资料(References)

[1] About Globally Unique IDentifiers

[2] Object Modeler Component and Implementation Inheritances

[3] Warm Start Incremental Backup

相关主题
文本预览
相关文档 最新文档