Mechanical Modeler

Enabling the Build Deactivation

Implementing CATIMechanicalProperties
Use Case

Creating a New Geometrical Feature : The Combined Curve > Enabling the Build Deactivation


Abstract

The main goal of this use case is to describe how to implement the CATIMechanicalProperties. This interface enabling for a geometrical feature to manage its activation or deactivation in the update mechanism [1].


What You Will Learn With This Use Case

This use case describes the implementation of the CATIMechanicalProperties interface. This interface has three methods:

If the first method, used by the implementation of the CATIBuild interface [2], just returns a value, the last two ones modify the status value, and regenerate the visualization of the combined curve. You will learn how to do that.

 

[Top]

The CAAMmrCombCurveMechanicalProperties Use Case

CAAMmrCombCurveMechanicalProperties is a use case of the CAAMechanicalModeler.edu framework that illustrates Mechanical Modeler frameworks capabilities.

[Top]

What Does CAAMmrCombCurveMechanicalProperties Do

Since it is possible to implement the CATIMechanicalProperties interface (V5R15), the contextual sub-menu associated with the combined curve has been updated to enable the end user to choose interactively the status of the feature: Active or not [3].

Fig.1: Contextual Menu

When the end user selects a Combined Curve, and rights click, depending on the current state of the feature's instance, it can either activate or deactivate it. On the above picture,

 

Fig.2: An Active (left) or Deactivate (right) Combined Curve

On left, the feature is active, and on right it is inactive: the mask of the icon is different , and the combined curve is not drawing.

[Top]

How to Launch CAAMmrCombCurveMechanicalProperties

See the section entitled "How to Launch the Combined Curve Use Case" in the "Creating a New Geometrical Feature: The Combined Curve" use case for a detailed description of how this use case should be launched.

Launch CATIA, when the application is ready, follow the scenario described below:

(*) The file is located in the directory CAAMechanicalModeler.edu/InputData

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

[Top]

Where to Find the CAAMmrCombCurveMechanicalProperties Code

The CAAMmrCombCurveMechanicalProperties use case is made of a one class, the CAAEMmrCombinedCurveMechProp class, located in the CAAMmrCombinedCurve.m module of the CAAMechanicalModeler.edu framework:

Windows InstallRootDirectory\CAAMechanicalModeler.edu\CAAMmrCombinedCurve.m\
Unix InstallRootDirectory/CAAMechanicalModeler.edu/CAAMmrCombinedCurve.m/

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

[Top]

Step-by-Step

This use case is divided into two main steps:

[Top]

Defining the CAAEMmrCombinedCurveMechProp Class

#include "CATBaseUnknown.h"  
class CAAEMmrCombinedCurveMechProp: public CATBaseUnknown
{
   CATDeclareClass;

   public:

      CAAEMmrCombinedCurveMechProp ();
      virtual ~CAAEMmrCombinedCurveMechProp ();

      virtual int IsInactive() const ;
      virtual void Activate() ;
      virtual void InActivate() ;

   private:

      CAAEMmrCombinedCurveMechProp (CAAEMmrCombinedCurveMechProp &iObjectToCopy);
      CAAEMmrCombinedCurveMechProp& operator=(CAAEMmrCombinedCurveMechProp &iObjectToCopy);

   private:
      int _status ;
};

The CAAEMmrCombinedCurveMechProp C++ class derives from CATBaseUnknown. The CATDeclareClass macro declares that the CAAEMmrCombinedCurveMechProp class belongs to a component. The copy constructor and the "=" operator are set as private to prevent the compiler from automatically creating as public.

The CATIMechanicalProperties interface contains three methods to override:

In this sample, the status is kept by a data member, _status. But in your own implementation, it is strongly recommended to use a new knowledge parameter associated with an attribute of the combined curve.

The value of the state is the same whatever the implementation code:

[Top]

Implementing the CAAEMmrCombinedCurveMechProp Class

As usual, to implement an interface you first need to use the TIE macro.

CATImplementClass ( CAAEMmrCombinedCurveMechProp ,
                    DataExtension , 
                    CATBaseUnknown ,
                    CombinedCurve );

#include "TIE_CATIMechanicalProperties.h"  
TIE_CATIMechanicalProperties( CAAEMmrCombinedCurveMechProp);

The CAAEMmrCombinedCurveMechProp class states that it implements the CATIMechanicalProperties interface thanks to the TIE_CATIMechanicalProperties macro. This extension class is dedicated to this component, and the CATImplementClass macro declares that the CAAEMmrCombinedCurveMechProp class is data extension class, thanks to the DataExtension keyword, and that it extends the component whose main class is CombinedCurve. The third parameter must always be set to CATBaseUnknown, makes no sense, and is unused for extensions. 

Do not forget to update the interface dictionary. Here it is an extract of the CAAMechanicalModeler.edu.dico file located in the CNext directory of the CAAMechanicalModeler.edu framework.

...
CombinedCurve               CATIMechanicalProperties                libCAAMmrCombinedCurve
...

[Top]

Coding the Inactive Method

...
int CAAEMmrCombinedCurveMechProp::IsInactive() const
{
   return _status ;
}

This method only returns the value of _status, the data member.

[Top]

Coding the Activate Method

void CAAEMmrCombinedCurveMechProp::Activate() 
{

   _status = 0 ;
...

The Activate method sets that the geometrical feature must be taken into account in the update mechanism. So the value of _status, the data member, is set to 0.

...
  CATISpecObject * piSpecObject= NULL; 
  HRESULT rc = QueryInterface(IID_CATISpecObject, (void**)&piSpecObject);
 
  piSpecObject->SetUpToDate(FALSE) ;
...

The second step is only mandatory in this implementation. It enables to "force" the re-construction of the feature. If your status is kept by a knowledge parameter, the modification of the parameter will automatically regenerate the reconstruction of the combined curve. So the call to the SetUpToDate method of the CATISpecObject interface will be useless.

...
  CATIRedrawEvent * piRedrawEvent = NULL; 
  rc = QueryInterface(IID_CATIRedrawEvent, (void**)&piRedrawEvent);
 
  piRedrawEvent->Redraw();

...

The next step enables us to update the specification tree. It enables to modify the icon of the feature. If the feature is deactivated, a mask showing the deactivation is applied to the icon. See Fig.2

...
  CATIModelEvents * piModelEvent = NULL; 
  rc = QueryInterface(IID_CATIModelEvents, (void**)&piModelEvent);

  CATModify notif = this;
  piModelEvent->Dispatch(notif);


...

The last action consists in to update all viewers containing a representation of the combined curve. You should do it to re-visualize the feature after the update.

[Top]

Coding the InActivate Method

void CAAEMmrCombinedCurveMechProp::InActivate() 
{

   _status = 1 ;
...

The InActivate method sets that the geometrical feature must not be taken into account [1] in the update mechanism. So the value of _status, the data member, is set to 1.

It is the only one difference with the Activate method, the other steps are identical: force the update, redraw the specification tree, and update the viewers.

[Top]


In Short

This use case has demonstrated how to implement the CATIMechanicalProperties interface. In the activate or Inactivate methods you should:

  1. Set the value of the status - Use a Knowledge parameter
  2. Update the specification tree to modify the mask of the icon
  3. Update viewers to re-visualize the feature which has been updated

[Top]


References

[1] Integrating a New Geometrical Feature in the Update Mechanism
[2] Building Combined Curve's Result
[3] Adding a Contextual Sub-Menu
[Top]

History

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

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