Mechanical Modeler |
Enabling the Build DeactivationImplementing CATIMechanicalProperties |
|
Use Case | ||
Creating a New Geometrical Feature : The Combined Curve > Enabling the Build Deactivation |
AbstractThe 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]. |
This use case describes the implementation of the CATIMechanicalProperties interface. This interface has three methods:
IsInactive
: It returns the
status of the feature for the update mechanism. Activate
: It sets that the feature is active for the buildInActivate
: It unsets that the feature is active for the buildIf 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]
CAAMmrCombCurveMechanicalProperties is a use case of the CAAMechanicalModeler.edu framework that illustrates Mechanical Modeler frameworks capabilities.
[Top]
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].
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,
Activate
method of
the CATIMechanicalProperties
interface to rebuild the combined curve and
refresh the visualization. See Fig.2 on left.
InActivate
method of
the CATIMechanicalProperties
interface to force the build of the combined
curve and refresh the visualization. See Fig.2 on right.
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]
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
InstallRootDirectory/CAAMechanicalModeler.edu/InputData
InstallRootDirectory\CAAMechanicalModeler.edu\InputData
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
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]
This use case is divided into two main steps:
[Top]
#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:
IsInactive
: Returns the
status of the featureActivate
: Sets that the feature is active for the buildInActivate
: Unsets that the feature is active for the buildIn 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]
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]
... int CAAEMmrCombinedCurveMechProp::IsInactive() const { return _status ; } |
This method only returns the value of _status
, the data member.
[Top]
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]
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]
This use case has demonstrated how to implement the CATIMechanicalProperties interface. In the activate or Inactivate methods you should:
[Top]
[1] | Integrating a New Geometrical Feature in the Update Mechanism |
[2] | Building Combined Curve's Result |
[3] | Adding a Contextual Sub-Menu |
[Top] |
Version: 1 [Jan 2005] | Document created |
[Top] |
Copyright © 2005, Dassault Systèmes. All rights reserved.