Machining

NC Review

Implementing User Data Feature Editor

Implementing the CATIMfgUserDataFeature interface
Use Case

Abstract

This article discusses the CAAMaiUserDataFeature use case and explains how to implement the CATIMfgUserDataFeature manufacturing interface.


What You Will Learn With This Use Case

This use case is intended to help you customize the editor of a user data feature by implementing the CATIMfgUserDataFeature manufacturing interface. This involves the following: 

[Top]

The CAAMaiUserDataFeature Use Case

CAAMaiUserDataFeature is a use case of the CAAManufacturingItf.edu framework that illustrates ManufacturingInterfaces framework capabilities.

[Top]

What Does CAAMaiUserDataFeature Do

CAAMaiUserDataFeature runs with the Process document shown on Fig.1 that contains a Manufacturing Setup linked to a user data feature (through the interface CATIMfgUserDataAccess) and a Manufacturing Program linked to another user data feature.

The use case builds the editor of this user data feature whose modelization is the following:

 

Fig. 1: The CAAMaiUserDataFeature.CATProcess model

[Top]

How to Launch CAAMaiUserDataFeature

To launch CAAMaiUserDataFeature, you will need to:

[Top]

Where to Find the CAAMaiUserDataFeature Code

The CAAMaiUserDataFeature use case is made of a class named CAAEMaiUserDataFeature located in the CAAMaiUserDataFeature.m module of the CAAManufacturingItf.edu framework:

Windows InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CAAMaiUserDataFeature.m
Unix InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/CAAMaiUserDataFeature.m

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

[Top]

Step-by-Step

There are three logical steps in CAAMaiUserDataFeature:

  1. Creating an Extension Class to Implement CATIMfgUserDataFeature for a  feature of type MyUserDataFeature
  2. Implementing the GetEditor method
  3. Implementing the GetNLSDescription method

We now comment each of those sections by looking at the code.

[Top]

Creating an Extension Class to Implement CATIMfgUserDataFeature for a feature of type MyUserDataFeature

The extension class that will implement CATIMfgUserDataFeature is named CAAEMaiUserDataFeature. Creating this class is done is three sub steps:

  1. Create the CAAEMaiUserDataFeature class header file:
    // System
    #include "CATBaseUnknown.h"
    // Dialog
    #include "CATDlgInclude.h"
    
    class CAAEMaiUserDataFeature : public CATBaseUnknown
    {
      // Used in conjonction with CATImplementClass in the .cpp file
    	CATDeclareClass;
      
    public:
    // Constructor and destructor
        CAAEMaiUserDataFeature();
        virtual ~CAAEMaiUserDataFeature();
     
    // Implementation of the CATIMfgUserDataFeature interface
        HRESULT GetEditor (CATDialog *iFather, CATDlgFrame *&oEditor);
        HRESULT GetNLSDescription (CATUnicodeString &oNLSDescription);
      private:
    
        // Copy constructor, not implemented
        // Set as private to prevent from compiler automatic creation as public.
        CAAEMaiUserDataFeature
    		(const CAAEMaiUserDataFeature&iObjectToCopy);
     
        // Assignment operator, not implemented
        // Set as private to prevent from compiler automatic creation as public.
        CAAEMaiUserDataFeature& operator  = 
    		(const CAAEMaiUserDataFeature&iObjectToCopy);
     
    };

    The CAAEMaiUserDataFeature class C++-derives from CATBaseUnknown. The CATDeclareClass macro declares that the class CAAEMaiUserDataFeature belongs to a component. The class has a constructor, a destructor, the GetEditor and GetNLSDescription  methods of  CATIMfgUserDataFeature, and a copy constructor. Note that the copy constructor is set as private. This is very important for extensions. Since extensions must never be directly instantiated by client applications, this prevents the compiler from creating the copy constructor as public without you know. This copy constructor is not implemented in the source file.

  2. Create the CAAEMaiUserDataFeature class source file. It begins as follows:
    ...
    #include "TIE_CATIMfgUserDataFeature.h"
    TIE_CATIMfgUserDataFeature(CAAEMaiUserDataFeature);
    CATImplementClass(CAAEMaiUserDataFeature,
                      DataExtension,
                      CATBaseUnknown,
                      MyUserDataFeature);
    ...
    HRESULT CAAEMaiUserDataFeature::GetEditor(CATDialog *iFather, CATDlgFrame * &oEditor)
    {
      HRESULT RC = S_OK;
      ...

    The CAAEMaiUserDataFeature class states that it implements the CATIMfgUserDataFeature interface thanks to the TIE_CATIMfgUserDataFeature macro. The CATImplementClass macro declares that the CAAEMaiUserDataFeature class is data extension class, thanks to the DataExtension keyword, and that it extends the feature whose type is MyUserDataFeature. The third parameter must always be set to CATBaseUnknown, makes no sense, and is unused for extensions.

  3. Have a look on the dictionary

    The dictionary, that is a file named, for example in this case, CAAManufacturingItf.edu.dico, whose directory's pathname is concatenated at run time in the CATDictionaryPath environment variable, and containing the following declaration to state that the MyUserDataFeaturefeature implements the CATIMfgUserDataFeature interface, and whose code is located in the libCAAMaiUserDataFeature shared library or DLL. 

    MyUserDataFeature CATIMfgUserDataFeature libCAAMaiUserDataFeature

    The CAAManufacturingItf.edu.dico file is located in:
    Windows InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CNext\code\dictionary\
    Unix InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/Cnext/code/dictionary/

[Top]

Implementing the GetEditor method

The aim of this method is to create a frame and fill it with the editor of the feature. It creates a Frame, then looks for the attribute 'MyAttribute' thanks to the Object Specs Modeler interfaces, then  reads the object that modelizes it (in this case a Literal Feature) and gets its editor thanks to the Literal Features interfaces.

  ...
// Creates a Frame
oEditor = new CATDlgFrame (iFather,CATString("Parameter 1"));
  ...

[Top]

Implementing the GetNLSDescription method

The aim of this method is to give the NLS string that will appear as name of the menu item (see figure above) and as name of the editor. In this use case, the string is hardcoded with 'Standards...'.

...

// Builds the string that will appear in the menu item

  oNLSDescription = CATUnicodeString("Standards...");

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[2] Process Modeler Home Page
[Top]

History

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

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