3D PLM PPR Hub Open Gateway

Product Modeler

Creating a Product Workbench

Implementing the CATIPRDWorkshopConfiguration Interface

Use Case

Abstract

This article presents the CAAPuiPRDWorkshopConfig use case which illustrates how to create a Product workbench.


What You Will Learn With This Use Case

By implementing the CATIPRDWorkshopConfiguration, you can implement a complete Product Structure workshop with its toolbar and commands.

[Top]

The CAAPuiPRDWorkshopConfig Use Case

CAAPuiPRDWorkshopConfig is a use case of the CAAProductStructureUI.edu framework that illustrates the ProductStructureUI framework capabilities.

[Top]

What Does CAAPuiPRDWorkshopConfig Do

The goal of CAAPuiPRDWorkshopConfig is to demonstrate how to implement the CATIPRDWorkshopConfiguration interface. It consists of the following parts:

Our workbench which is represented by the CAA Workbench menu entry, is now available in the Infrastructure solutions.

If activated, it behaves like the Product Structure workbench except that we have a new toolbar with a command represented by the icon.

[Top]

How to Launch CAAPuiPRDWorkshopConfig

To launch CAAPuiPRDWorkshopConfig:

  1. Set the current directory to InstallRoot/CAAProductStructureUI.edu
  2. Set up  the build time environment and build the CAAPuiPRDWorkshopConfig.m module (see reference [1])
  3. Edit the  CNext/code/dictionary/CAAProductStructureUI.edu.dico dictionary by uncommenting the line containing CATIPRDWorkshopConfiguration
    #CAAPuiPRDWorkshopConfig use case
    CATApplicationFrame     CAAIPuiPRDWorkshopConfigFactory libCAAPuiPRDWorkshopConfig
    CAAPuiPRDWorkshopConfig CATIPRDWorkshopConfiguration    libCAAPuiPRDWorkshopConfig
  4. Install the dictionary and other resource files by executing mkCreateRuntimeView
  5. Start CATIA by executing mkrun
  6. Start the CAA Workbench:



     
  7. Click on the command and a dialog box will appear:


     

[Top]

Where to Find the CAAPuiPRDWorkshopConfig Code

CAAPuiPRDWorkshopConfig code is located in the CAAPuiPRDWorkshopConfig.m module of the CAAProductStructureUI.edu framework.

[Top]

Step-by-Step

There are three parts in CAAPuiPRDWorkshopConfig:

  1. Workbench, Toolbar Creation and Layout
  2. Command Implementation
  3. User Interface

We will now detail each of those sections:

[Top]

Workbench, Toolbar Creation and Layout

The implementation of CATIPRDWorkshopConfiguration is provided by our CAAPuiPRDWorkshopConfig class. Its purpose is to create the workbench, the toolbar and to do the layout the commands on it. Four methods need be defined:

...
class CAAPuiPRDWorkshopConfig: public CATBaseUnknown
{
        CATDeclareClass;

public:

        // Standard constructors and destructors for an implementation class
        // -----------------------------------------------------------------
        CAAPuiPRDWorkshopConfig ();
        virtual ~CAAPuiPRDWorkshopConfig ();

        /**
         * @see ApplicationFrame.CATIWorkbench#CreateCommands
         */
        void CreateCommands();

        /**
         * @see ApplicationFrame.CATIWorkbench#CreateWorkbench
         */
        CATCmdWorkbench *CreateWorkbench();

        /**
         * @see ApplicationFrame.CATIWorkbench#GetAddinInterface
         */
        CATClassId GetAddinInterface();

        /**
         * @see ApplicationFrame.CATIWorkbench#GetCustomInterfaces
         */
        void GetCustomInterfaces (CATListPV *iDefaultIIDList,
                                  CATListPV *iCustomIIDList);

private:
        // The copy constructor and the equal operator must not be implemented
        // -------------------------------------------------------------------
        CAAPuiPRDWorkshopConfig (CAAPuiPRDWorkshopConfig &);
        CAAPuiPRDWorkshopConfig& operator=(CAAPuiPRDWorkshopConfig&);
};

...

The CreateWorkbench method is called to create the workbench, the toolbar(s) and the command(s) of the toolbar(s).

...
CATCmdWorkbench *CAAPuiPRDWorkshopConfig::CreateWorkbench ()
{
        CAAPuiPRDWorkshopConfigTRACE(">> CAAPuiPRDWorkshopConfig::CreateWorkbench()");

        // Definition of the CAAPuiPRDWorkshopConfig workbench Layout 
        NewAccess(CATCmdWorkbench, pWorkbench, CAAPuiPRDWorkshopConfig);

        // Workbench Toolbar 
        NewAccess(CATCmdContainer, pToolbar, CAAPuiPRDWorkshopConfigToolbar);
        SetAccessChild(pWorkbench, pToolbar);

        // Add commands to toolbar
        NewAccess(CATCmdStarter, pStarter, CAAPuiPRDWorkshopConfigStarter);
        SetAccessCommand(pStarter, "CAAPuiPRDWorkshopConfigCmd1");
        SetAccessChild(pToolbar, pStarter);

        // Visible toolbar set in the right side of the application window
        int visibleFlag = 1;
        AddToolbarView(pToolbar, visibleFlag, Right);

        CAAPuiPRDWorkshopConfigTRACE("<< CAAPuiPRDWorkshopConfig::CreateWorkbench()");
        return pWorkbench;
}

...

The purpose of the CreateCommands method is to create all the command headers of our toolbar. Our command header class CAAPuiPRDWorkshopConfigHeader, is defined by way of the MacDeclareHeader macro.

Here a command named CAAPuiPRDWorkshopConfigCmd1 is created. It is located in the CAAPuiPRDWorkshopConfig shared library and its class is CAAPuiPRDWorkshopConfigCmd. The ShowProduct identifier will be used to locate resources related to this command.

...

#include "CATCommandHeader.h"
MacDeclareHeader(CAAPuiPRDWorkshopConfigHeader);

...

void CAAPuiPRDWorkshopConfig::CreateCommands ()
{
        CAAPuiPRDWorkshopConfigTRACE(">> CAAPuiPRDWorkshopConfig::CreateCommands()");

        // Instantiates the command header for the command
        new CAAPuiPRDWorkshopConfigHeader
                ("CAAPuiPRDWorkshopConfigCmd1", // command name
                 "CAAPuiPRDWorkshopConfig", // lib name
                 "CAAPuiPRDWorkshopConfigCmd", // class name
                 (void*) NULL);

        CAAPuiPRDWorkshopConfigTRACE("<< CAAPuiPRDWorkshopConfig::CreateCommands()");
}
...

The purpose of the GetAddinInterface method is to return the interface name to be implemented by all addin toolbar.

...
CATClassId CAAPuiPRDWorkshopConfig::GetAddinInterface ()
{
        // Returns the interface name to implement an Addin to this workbench. 
        return "CAAIPuiPRDWorkshopConfigAddin";
}
...

GetCustomInterfaces is not used but nevertheless be implemented as an empty function.

...
void CAAPuiPRDWorkshopConfig::GetCustomInterfaces (CATListPV *iDefaultIIDList,
                                                   CATListPV *iCustomIIDList)
{
        // should be empty!
}
...

[Top]

Command Implementation

The command that gets executed must be of a class named CAAPuiPRDWorkshopConfigCmd as specified by CAAPuiPRDWorkshopConfig::CreateCommands. This class must also derives from the CATCommand class. The only method we need to override is the Activate method.

...
class CAAPuiPRDWorkshopConfigCmd: public CATCommand {

public:

        CAAPuiPRDWorkshopConfigCmd();
        virtual ~CAAPuiPRDWorkshopConfigCmd();

        /**
         * Activates our command.
         * @param iFromClient 
         * The command that requests to activate the current one.
         * @param iEvtDat
         * The notification sent.
         */
        virtual CATStatusChangeRC Activate(CATCommand * iFromClient,
                                           CATNotification * iEvtDat);
};
...

In the Activate method, we just get the current window and display its title in a dialog box

...
CATStatusChangeRC CAAPuiPRDWorkshopConfigCmd::Activate(CATCommand *iFromClient, 
                                                       CATNotification *iEvtDat)
{
        CAAPuiPRDWorkshopConfigTRACE (">> CAAPuiPRDWorkshopConfigCmd::Activate");

        CATApplicationFrame *pApplication = CATApplicationFrame::GetFrame(); 
        if (NULL != pApplication) { 
                CATDlgWindow * pMainWindow = pApplication->GetMainWindow();
                CATDlgNotify *pNotifyDlg = new CATDlgNotify
                        (pMainWindow, "CAAPuiPRDWorkshopConfig", CATDlgNfyOK);
                if (NULL != pNotifyDlg) {
                        pNotifyDlg->DisplayBlocked
                                ("Hello World!",
                                 "CAAPuiPRDWorkshopConfig UseCase");
                        pNotifyDlg->RequestDelayedDestruction(); 
                }
        }
        RequestDelayedDestruction();

        CAAPuiPRDWorkshopConfigTRACE ("<< CAAPuiPRDWorkshopConfigCmd::Activate");
        return CATStatusChangeRCCompleted;
}
...

Now that we have completed the code implementation, we need to take care of the user interface with the help of resource files.

[Top]

User Interface

There are three visible objects: the workbench, the toolbar and its command.

All files are located in the install_root/CAAProductStructureUI.edu/CNext/resources/msgcatalog/ directory, except the bitmaps for the icons which are in install_root/CAAProductStructureUI.edu/CNext/resources/graphic/icons/normal

The workbench:

The title of the CAAPuiPRDWorkshopConfig workbench is defined by the CAAPuiPRDWorkshopConfig.CATNls file:

CAAPuiPRDWorkshopConfig.Title = "CAA Workbench";
CAAPuiPRDWorkshopConfig.Help = "CAA Workbench (CAAPuiPRDWorkshopConfig use case)";
CAAPuiPRDWorkshopConfig.ShortHelp = "CAA Workbench";
...

Its position in the start menu and icon file name are defined by the CAAPuiPRDWorkshopConfig.CATRsc file:

CAAPuiPRDWorkshopConfig.Category = "Infrastructure"; 
CAAPuiPRDWorkshopConfig.Icon.NormalRep = "CAAPuiPRDWorkshopConfig_I";
CAAPuiPRDWorkshopConfig_I.gif represents the workbench icon:
The toolbar:

The title of the toolbar named CAAPuiPRDWorkshopConfigToolbar is also defined by the CAAPuiPRDWorkshopConfig.CATNls file:

CAAPuiPRDWorkshopConfigToolbar.Title = "CAA Toolbar 3";

The command:

The command CAAPuiPRDWorkshopConfigCmd1 are defined by three files:

  1. CAAPuiPRDWorkshopConfigHeader.CATNls defines the screen tip, the documentation line and the command prompt input:

    CAAPuiPRDWorkshopConfigHeader.CAAPuiPRDWorkshopConfigCmd1.Title = "cmd3";
    CAAPuiPRDWorkshopConfigHeader.CAAPuiPRDWorkshopConfigCmd1.Help = "cmd3 long help text";
    CAAPuiPRDWorkshopConfigHeader.CAAPuiPRDWorkshopConfigCmd1.ShortHelp = "cmd3 info";



     

  2. CAAPuiPRDWorkshopConfigHeader.CATRsc defines the icon file name for the command:

    CAAPuiPRDWorkshopConfigHeader.CAAPuiPRDWorkshopConfigCmd1.Icon.Normal="CAAPuiPRDWorkshopConfigCmd_I";

     

  3. CAAPuiPRDWorkshopConfig_I.gif defines the icon:

     

[Top]


In Short

This use case has demonstrated how to create a toolbar with a command:

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[2] Application Frame Overview
[3] The CAA Command Model
[4] Creating a Workbench
[5] Creating an Add-in
[Top]

History

Version: 1 [Aug 2004] Document revised
Version: 1 [Oct 2003] Document created
[Top]

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