3D PLM Enterprise Architecture

User Interface - Frame

Creating a Property Page for Application Properties

Customizing the Tools Options dialog box
Use Case

Abstract

This article shows how to add a property page to a property sheet for a given workshop or workbench displayed in the Tools Options dialog box.


What You Will Learn With This Use Case

This use case is intended to show how to create a property page for a given workshop or workbench [1]. It is important to refer to the technical article "Application Property Access" before reading this article [2].

Each property page contains options managed as setting attributes [3] which are stored on disk in a setting file and in a memory in a CATSettingRepositoty class instance. The Tools Options command, such as other commands, must not directly handle the setting repository but it's setting controller [4].

[Top]

The CAACafEltToolsOptions Use Case

CAACafEltToolsOptions is a use case of the CAACATIAApplicationFrm.edu framework that illustrates the CATIAApplicationFrame framework capabilities.

[Top]

What Does CAACafEltToolsOptions Do

CAACafEltToolsOptions creates the Elements property page that contains three frames: Identifier, Max Points/Curve, and Implicit Points. This property page is associated with the "CAA V5: Geometrical Creation" workbench of the Infrastructure submenu of the Start menu [1]. The dialog box is as follows:

The left part of the dialog box is dedicated to workshop or workbench selection in a tree. The right part displays the property sheet for the selected workshop or workbench. It is automatically generated at run time using the available workshops and workbenches. The property sheet for the "CAA V5: Geometrical Creation" workbench is made of a single property page named "Elements". It includes three frames:

  1. The "Identifier" frame manages the visibility of the identifiers of the elements for which the workbench supplies creation commands. The element identifiers can be permanently:
  2. The "Max Points/Curve" frame manages the maximum number of points in a curve. This property can be set thanks to a slider whose value can range from 2 to 100
  3. The "Implicit Points" frame manages whether implicit points should be shown or hidden. This property can be set thanks to two radio buttons.

These three options are saved in a setting file named CAACafGeometryEltSetting.CATSetting and managed by a setting controller. This controller is a component named CAACafGeometryEltSettingCtrl [5]. This component implements the following interfaces:

[Top]

How to Launch CAACafEltToolsOptions

See the section entitled "How to Launch the CAAGeometry Use Case" in the "The CAAGeometry Sample" use case for a detailed description of how this use case should be launched. 

But just before launching the execution, edit the CAACATIAApplicationFrm.edu.dico interface dictionary file located in the dictionary directory of the CAACATIAApplicationFrm.edu framework:

Windows InstallRootDirectory\CAACATIAApplicationFrm.edu\CNext\code\dictionary\
UNIX InstallRootDirectory/CAACATIAApplicationFrm.edu/CNext/code/dictionary/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

In this file, remove the "#" character before the two following lines, and then run mkCreateRuntimeView.

# CAACafElementPropertyPageEdt CATIUserSettings libCAACafEltToolsOptions
# CAACafViewPropertyPageEdt    CATIUserSettings libCAACafViewToolsOptions

The second line deals with the View property page created by the non-described CAACafViewToolsOptions use case located in the CAACafViewToolsOptions.m module.

Then, in the window where you run the mkrun command, do not type the module name on the command line, but type CNEXT instead. When the application is ready, do the following:

[Top]

Where to Find the CAACafEltToolsOptions Code

The CAACafEltToolsOptions use case is made of classes and interfaces located in the CAACafEltToolsOptions.m module and in the ProtectedInterfaces directory of the CAACATIAApplicationFrm.edu framework:

Windows InstallRootDirectory\CAACATIAApplicationFrm.edu\CAACafEltToolsOptions.m\
Unix InstallRootDirectory/CAACATIAApplicationFrm.edu/CAACafEltToolsOptions.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

These classes and interfaces are:

CAACafElementPropertyPageEdt Property page editor class
CAACafElementPropertyPageEdtFactory Factory class for the property page editor class
CAAICafElementPropertyPageEdtFactory Factory interface implemented by CAACafElementPropertyPageEdtFactory
TIE_CAAICafElementPropertyPageEdtFactory TIE class for the factory interface
CAACafElementPropertyPageDlg Dialog box class associated with the property page

[Top]

Step-by-Step

To create a property page, there are seven main steps:

  1. Creating the property page editor factory interface
  2. Creating the property page editor factory
  3. Creating the property page editor
  4. Setting the resources for the property page editor
  5. Creating the property page dialog
  6. Setting the resources for the property page Dialog
  7. Testing in administrator mode

[Top]

Creating the Property Page Editor Factory Interface

This factory interface is named CAAICafElementPropertyPageEdtFactory. To create this interface, create:

  1. The header file
  2. The source file
  3. The TIE tsrc file.

This is shown below.

  1. Header file: CAAICafElementPropertyPageEdtFactory.h is as follows
    #include <CATIGenericFactory.h>
    
    extern IID IID_CAAICafElementPropertyPageEdtFactory;
    
    class CAAICafElementPropertyPageEdtFactory : public CATIGenericFactory
    {
      CATDeclareInterface;
      public :
    };

    A factory interface is an interface, that is, an abstract class that derives from CATIGenericFactory. Like 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.

  2. Source file: CAAICafElementPropertyPageEdtFactory.cpp is as follows.
    #include "CAAICafElementPropertyPageEdtFactory.h"
    
    IID IID_CAAICafElementPropertyPageEdtFactory = {
        0x4ee83c16,
        0xd55d,
        0x11d3,
        {0xb7, 0xf5, 0x00, 0x08, 0xc7, 0x4f, 0xe8, 0xdd}
      };
    
    CATImplementInterface(CAAICafElementPropertyPageEdtFactory, CATIGenericFactory);

    This file includes a GUID [6], shown in bold typeface. The CATDeclareInterface in the header file and the CATImplementInterface macros make an interface from this C++ class. CATImplementInterface states that CAAICafElementPropertyPageEdtFactory OM-derives [7] from CATIGenericFactory.

  3. TIE file: to enable components to implement this interface, create a file named TIE_CAAICafElementPropertyPageEdtFactory.tsrc in the src directory, and containing:
    #include "CAAICafElementPropertyPageEdtFactory.h"

    The Multi-Workspace Application Builder (mkmk) will generate the TIE for this interface, that is the TIE_CAAICafElementPropertyPageEdtFactory.h file for you in the ProtectedGenerated directory.

[Top]

Creating the Property Page Editor Factory

Macros help to create the class. These macros create a class whose name is made of the property page editor class name to which the string Factory is appended. This is the reason why the header file is named CAACafElementPropertyPageEdtFactory.h and the source file is named CAACafElementPropertyPageEdtFactory.cpp.

To create this class, create:

  1. The header file, using the CAT_EDITOR_DECLARE_FACTORY macro
  2. The source file, using the CAT_EDITOR_DEFINE_FACTORY2 macro
  3. Update the interface dictionary and the factory dictionary.

The macros help you to create the class. These macros create a class whose name is made of the property page editor class name to which the string Factory is appended. This is the reason why this class is named CAACafElementPropertyPageEdtFactory.

  1. Header file: CAACafElementPropertyPageEdtFactory.h is as follows.
    #include <CATEditorFactory.h>
    #include <CAACafElementPropertyPageEdt.h>
    
    #define ExportedByNOTHING
    
    CAT_EDITOR_DECLARE_FACTORY(NOTHING,
                               CAACafElementPropertyPageEdt,
                               CAACafElementPropertyPageEdt);

    The CAT_EDITOR_DECLARE_FACTORY macro creates the factory class header file contents. It is important to set the same string wherever NOTHING is used in this example. ExportedByNOTHING sets a non existing shared library or DLL to the class. Setting a valid one is useless, since the created class in an extension of CATUserSettingManager, and its instantiation is made when CATUserSettingManager is asked for a pointer to CAAICafElementPropertyPageEdtFactory. In this case, the shared library or DLL is known using the interface dictionary. The second parameter is the name of the property page editor class. This name is used to create the factory class name by appending Factory, that is, CAACafElementPropertyPageEdtFactory in this example. The third parameter is a type assigned to the class to create that could be retrieved using the CATIGenericFactory::Support method, but that is unused here, and simply set as the property page editor class name.

  2. Source file: CAACafElementPropertyPageEdtFactory.cpp is as follows.
    #include <CAACafElementPropertyPageEdtFactory.h>
    
    CAT_EDITOR_DEFINE_FACTORY2(CAACafElementPropertyPageEdt,
                               CAACafElementPropertyPageEdt);
    
    #include <TIE_CAAICafElementPropertyPageEdtFactory.h>
    TIE_CAAICafElementPropertyPageEdtFactory(CAACafElementPropertyPageEdtFactory);

    The CAT_EDITOR_DEFINE_FACTORY2 macro creates the property page editor factory implementation class contents as a data extension of the CATUserSettingManager component. CATUserSettingManager manages all the property page editor factories for Tools Options. Then the TIE macro declares that this extension class implements the CAAICafElementPropertyPageEdtFactory interface.

  3. Dictionary files: you should now update

    At run time, the pathname of the directory that contains these files is concatenated in the CATDictionaryPath environment variable.

[Top]

Creating the Property Page Editor

You'll now create the class for the property page editor. This class should implement the CATIUserSettings interface, derive from the CATEditor class, and override methods that are either pure virtual or empty in their CATEditor implementation. You should provide their body to make them play the following roles.

BuildEditor Instantiates the associated dialog class
SetUserSettingValue Sets the values in the property page from the setting controller
ResetUserSettingValue Restores the values set by the administrator, or if any, restores the default values set in the code
CancelModification Cancels the modifications made to values in the property page and restore the previous ones
CommitModification Saves the modifications in the setting file.

The property page editor class header file is shown below.

#ifndef CAACafElementPropertyPageEdt_H
#define CAACafElementPropertyPageEdt_H

// CATIAApplicationFrame framework
#include "CATEditor.h"                // Needed to derive from CATEditor
class CATIIniSettingManagment ;       // Interface to handle the setting controller

// Local framework
class CAACafElementPropertyPageDlg;   // Property page dialog  

// System framework
class CATSettingRepository;

class CAACafElementPropertyPageEdt : public CATEditor
{
  CATDeclareClass;

  public :

    CAACafElementPropertyPageEdt();
    virtual ~CAACafElementPropertyPageEdt();

    void             BuildEditor           (CATEditorPage * iTabPage);
    void             SetUserSettingsValue  (CATSettingRepository * iUselessFileRep);
    void             ResetUserSettingsValue();
    void             CancelModification    (CATSettingRepository * iUselessFileRep);
    void             CommitModification    (CATSettingRepository * iUselessFileRep);

 private:

   CAACafElementPropertyPageEdt(const CAACafElementPropertyPageEdt &iObjectToCopy);
   CAACafElementPropertyPageEdt & operator = (const CAACafElementPropertyPageEdt &iObjectToCopy);

  private : 

    CAACafElementPropertyPageDlg  *  _pDialogPage;
    CATIIniSettingManagment       *  _pISettingManagmentForCtrl ;
};
#endif

The CAACafElementProperetyPageEdt class C++ derives from CATEditor. The CATDeclareClass macro declares that the class CAACafElementProperetyPageEdt belongs to a component. Note that the copy constructor and the assignment operator are set as private, and are not implemented in the source file. This prevents the compiler from creating them as public without you know. We'll examine the implementation of each method individually.

_pDialogPage is the pointer to property page dialog created in the BuildEditor method.

_pISettingManagmentForCtrl is a pointer of the CATIIniSettingManagment interface. In the constructor class, this interface pointer is initialized and in the ResetUserSettingsValue, CancelModification and CommitModification methods it is used. This interface manages the Save, Rollback, ResetToAdminValues, Commit on the setting repository encapsulated by the setting controller.

The property page editor class source file is shown below.

[Top]

Setting the Resources for the Property Page Editor

The resources for the property page editor are its title and the property sheet linked to your workshop or workbench into which your property page should be displayed.

The title of the property page, is in the CAACafElementPropertyPageEdt.CATNls file in the CNext\resources\msgcatalog directory of the CAACATIAApplicationFrm.edu framework.

TabPage.Title = "Elements" ;

where:
TabPage A required keyword for property pages
Title The keyword for titles

The property page is set in the property sheet of the "CAA V5 Geometrical Creation" workbench of the Infrastructure solution. This information is set in the CAACafElementPropertyPageEdt.CATRsc file in the CNext\resources\msgcatalog directory of the CAACATIAApplicationFrm.edu framework.

TabPage.SolutionName = "Infrastructure" ;
TabPage.WorkbenchName = "CAAAfrGeoCreationWkb" ;

where:
TabPage A required keyword for property pages
SolutionName The submenu of the Start menu where your workshop or workbench appears. This name is defined in the CATRsc file of your workshop or workbench within the keyword Category.
WorkbenchName The identifier of your workshop or workbench, set using the NewAccess macro in the CreateWorkshop or CreateWorkbench method [1]

In this same resource file you retrieve the URL for the contextual help:

TabPage.LongHelpId = "ToolsOptions.Infrastructure.CAAV5GeometricalCreation.Elements";

where:

TabPage A required keyword for property pages
LongHelpId A required keyword for URL
ToolsOptions A mandatory string
Infrastructure The name of the solution (in fact the category)
CAAV5GeometricalCreation The identifier of your workshop or workbench, set using the NewAccess macro in the CreateWorkshop or CreateWorkbench method [1]
Elements English name of the property page

[Top]

Creating the Property Page Dialog

This dialog class represents the contents of the property page, that is, the right part of the dialog box. The header file is as follows.

#ifndef CAACafElementPropertyPageDlg_H
#define CAACafElementPropertyPageDlg_H

#include "CATDlgFrame.h"          // Needed to derive from CATDlgFrame

// Dialog Framework
class CATDlgRadioButton;
class CATDlgSlider;

// System Framework
class CAAICafGeometryEltSettingAtt;

class CAACafElementPropertyPageDlg : public CATDlgFrame
{
  public :
    DeclareResource(CAACafElementPropertyPageDlg, CATDlgFrame);

    CAACafElementPropertyPageDlg(CATDialog * ipParent);
    virtual ~CAACafElementPropertyPageDlg();

    void Build();
    void ValueSettings();

  private :
    CAACafElementPropertyPageDlg ();
    CAACafElementPropertyPageDlg(const CAACafElementPropertyPageDlg &iObjectToCopy);
    CAACafElementPropertyPageDlg & operator = (const CAACafElementPropertyPageDlg &iObjectToCopy);
      
    void IdHideCB            (CATCommand         * iPublishingCommand,
                              CATNotification    * iNotification,
                              CATCommandClientData iUsefulData);
    void IdShowCB            (CATCommand         * iPublishingCommand,
                              CATNotification    * iNotification,
                              CATCommandClientData iUsefulData);
    void IdPreSelectShowCB   (CATCommand         * iPublishingCommand,
                              CATNotification    * iNotification,
                              
    void MaxPointCB          (CATCommand         * iPublishingCommand,
                              CATNotification    * iNotification,
                              CATCommandClientData iUsefulData);
                              
    void ImplPointHideCB     (CATCommand         * iPublishingCommand,
                              CATNotification    * iNotification,
                              CATCommandClientData iUsefulData);
    void ImplPointShowCB     (CATCommand         * iPublishingCommand,
                              CATNotification    * iNotification,
                              CATCommandClientData iUsefulData);
    
  private :
    CATDlgRadioButton    * _pIdHide;
    CATDlgRadioButton    * _pIdShow;
    CATDlgRadioButton    * _pIdPreSelectShow;
    
    CATDlgRadioButton    * _pImplPointShow;
    CATDlgRadioButton    * _pImplPointHide;    
    
    CATDlgSlider         * _pMaxPoint;
    
    CAAICafGeometryEltSettingAtt * _pISettingAttForCtrl;
};

A property page dialog must derive from CATDlgFrame. The DeclareResource macro declares that the messages and resources are to be searched for in the CAACafElementPropertyPageDlg.CATNls and CAACafElementPropertyPageDlg.CATRsc files respectively. These files are delivered in the CNext\resources\msgcatalog directory of CAACATIAApplicationFrm.edu framework. The class has a constructor with a single argument to get its parent, and a destructor. The constructor only initializes the data members, while the Build method creates and arranges the controls, and sets the callbacks onto these controls. The ValueSettings method reads the setting attribute values to set those of the controls that represent the setting attributes in the property page. A default constructor and a copy constructor are set as private, and are not implemented in the source file. This prevents the compiler from creating them as public without you know.

The controls declared as data member are used in callback methods: radio buttons, slider.

_pISettingAttForCtrlis a pointer of the CAAICafGeometryEltSettingAtt interface. In the constructor class, the pointer is initialized and in ValueSettings and in all the callback methods it is used. This interface reads/writes the attributes values on the setting repository encapsulated by the setting controller.

We'll examine each method or group of methods individually.

Setting the Resources for the Property Page Dialog

In the CAACafElementPropertyPageDlg.CATNls, defined in the CNext/resources/msgcatalog, you set the NLS for each dialog object created in the property page dialog.

[Top]

Testing in Administrator Mode

To test your new property page, you must it run using the administrator mode. This mode can be accessed by setting the CATReferenceSettingPath environment variable. First test the case where you are an administrator in passing the -admin parameter to the CNEXT command and next when you benefit of the administrator files in relaunching CNEXT without argument.

where MySettingPath is the pathname of your setting file directory. Caution: MySettingPath must already exist.

[Top]


In Short

Creating a property page for the Tools Options menu implies to create a property page editor factory, a property page editor class instantiated by this factory, and to supply a property page dialog class gathering the controls to access the parameters and values you let the end user access and modify.

The property page uses a setting controller that manages the access to the setting repositories and files to read and save these parameters and values.

[Top]


References

[1] Creating a Workbench
[2] Application Property Access
[3] Setting Repositories and Attributes
[4] The Setting Controller
[5] Creating a Setting Controller
[6] About Globally Unique IDentifiers
[7] Object Modeler Component and Implementation Inheritances
[Top]

History

Version: 1 [Jan 2000] Document created
[Top]

Copyright © 2000, Dassault Systèmes. All rights reserved.