Mechanical Modeler

Editing Combined Curves

Implementing CATIEdit through a dialog box and a state dialog command
Use Case

Creating a New Geometrical Feature : The Combined Curve > Editing Combined Curves


Abstract

The main goal of this use case is to describe how to edit Combined Curves interactively. 


What You Will Learn With This Use Case

This use case explains how to edit Combined Curves interactively. You will learn to:

Moreover, the state command can be also used to create new instances. Consequently, this article gives you also explanations to create a command to instantiate Combined Curves interactively. However, to light the article, the piece of code which makes the instantiation has been off-set in the referenced article [1].

The use case intent is to help you make your first step in the interactive edition world. Some more sophisticated examples are provided with Dialog and DialogEngine frameworks. The point of this use case is to show an example of an edition command taking full advantage of services provided by Mechanical Modeler Frameworks.

[Top]

The CAAMmrCombinedCurveUI Use Case

CAAMmrCombinedCurveUI is a use case of the CAAMechanicalModeler.edu framework that illustrates MechanicalModeler framework capabilities.

[Top]

What Does CAAMmrCombinedCurveUI Do

The CAAMmrCombinedCurveUI use case enables you to edit an existing combined curve through a state command and a dialog box. Here is a picture showing the edition of the combined curve included in the CAACombinedCurve.CATPart document. This file is located in the InputData directory of the CAAMechanicalModeler.edu framework.

Fig.1 The Combined Curve Edition

The next figure summarizes the architecture of the Combined Curve edition pattern.

[Top]

V5R13 Modifications to Take the Ordered Set Into Account

The CAAMmrCombCrvPanelStCmd command class has been modified in V5R13 to take the ordered set [2][3] into account. There are three main modifications:

  1. Current feature management

    The  specifications are the following:

    (*) In the CAAMmrCombCrvPanelStCmd command the new feature is created at the end of the command, but generally the creation is done at the beginning. In the first case, the feature is set current at the end of the command, otherwise it stays current at the end. 

    On this above picture CombinedCurve.2 is into an ordered set (an Ordered Geometrical Set). When it is being edited, you can see that it is the current feature since it is underlined.

    The management of the current feature has been processed by the Overriding Activate, Deactivate and Cancel methods to Manage Current Feature section.

  2. Aggregation management
  3. When aggregating a feature into an ordered set you should take care of the position of the current feature. The new feature is located after the current feature. This management, specific to the creation mode, is detailed in the referenced article [1] which deals with the instantiation of the combined curve. 

  4. Absorption management   
  5. When a geometrical feature [4] is inserted into an ordered set, or when a surfacic feature [4] is modified into a such set, you must call the Insert method of the CATMmrLinearBodyServices class. This call has been integrated just after the update of the combined curve, in the OkAction method.

[Top]

How to Launch CAAMmrCombinedCurveUI

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.

[Top]

Where to Find the CAAMmrCombinedCurveUI Code

The CAAMmrCombinedCurveUI use case is made of a several classes located in the CAAMmrCombinedCurveUI.m module of the CAAMechanicalModeler.edu framework:

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

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

The code for this use case is made of the following classes:

[Top]

Step-by-Step

The CAAMmrCombinedCurveUI is divided into the following steps:

  1. Implementing CATIEdit [5]
  2. How to launch the Creation Command through an Header of Command
  3. Creating the Combined Curve edition state dialog command. This command manages the edition dialog. It may be called to edit an existing Combined Curve Feature ( "edition mode", thanks to CATIEdit implementation ) or to create a new one ( "creation mode", thanks to an icon provided in a toolbar using an add-in [6]).
  4. Creating the Combined Curve edition dialog box

[Top]

Declaring CATIEdit Implementation

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

CATImplementClass ( CAAEMmrCombinedCurveEdit ,
                    DataExtension ,
                    CATIEdit ,
                    CombinedCurve );

CATImplementBOA(CATIEdit, CAAEMmrCombinedCurveEdit);

The CATImplementClass macro is used in conjunction with the CATDeclareClass macro in the class header file to express that the class is part of a CAA V5 Object Modeler component. Its argument read as follows:

  1. CAAEMmrCombCrvInputDescription: the class name
  2. DataExtension: the CAA V5 Object Modeler class type. 
  3. CATIEdit: The name of implemented interface
  4. CombinedCurve: the name of the extended component

The CATImplementBOA macro replaces the TIE_CATIEdit macro. Its arguments are the BOA-implemented interface and the extension class name respectively.

[Top]

Coding the Activate Method to Launch the Combined Curve Edition Command

The method Activate of the interface CATIEdit is called whenever the user shows his willingness to edit a feature, for example when double clicking on a feature node in the feature tree. It returns a pointer on a CATCommand. This CATCommand (here called CAAMmrCombCrvPanelStCmd) is the feature edition command.

...
CATCommand * CAAEMmrCombinedCurveEdit::Activate(CATPathElement *ipPath)
{
  // Gets a pointer on CAAIMmrCombinedCurve in edition
  CAAIMmrCombinedCurve* piCombinedCurve = NULL;
  HRESULT rc = QueryInterface(IID_CAAIMmrCombinedCurve,
                              (void**) &piCombinedCurve);
  if ( FAILED(rc) )
    return NULL;

  // Creates the edition command
  CATCommand *pCommand = new CAAMmrCombCrvPanelStCmd(piCombinedCurve);

  // Releases useless pointer
  piCombinedCurve->Release();
  piCombinedCurve = NULL ;

  return pCommand;
}

[Top]

How to launch the Creation Command through an Header Command ?

#include "CATCreateExternalObject.h" 
CATCreateClass(CAAMmrCombCrvPanelStCmd);

These two lines enables the frame to launch the command thanks to an header of command.

[Top]

Constructing the Command

The Combined Curve edition/creation state dialog command constructor:

[Top]

Coding the BuildGraph Method

The BuildGraph method describes how the command works.

[Top]

Coding the OkAction Method

This method is called when users press on the OK button of the Combined Curve edition dialog box. Transitions to this OK state are provided by parent Command CATMMUIPanelStateCmd.

In case this edition command is used to modify a Combined Curve, it just modifies the Combined Curve’s input Curves and Direction.

// edition mode

// Updates the combine with its new curves inputs.
HRESULT rc;

rc = _piCombinedCurve -> SetCurve     ( 1 , _piSpecOnCurve1 );
if ( FAILED(rc) ) 
  return FALSE;

rc = _piCombinedCurve -> SetDirection ( 1 , _piSpecOnDir1   );
if ( FAILED(rc) ) 
  return FALSE;

rc = _piCombinedCurve -> SetCurve     ( 2 , _piSpecOnCurve2 );
if ( FAILED(rc) ) 
  return FALSE;

rc = _piCombinedCurve -> SetDirection ( 2 , _piSpecOnDir2   );
if ( FAILED(rc) ) 
  return FALSE;

When this command is used to create a new Combined Curve (creation mode), first it retrieves a geometrical features set, and then aggregates the new feature  inside the set. The explanations of these two steps have been off-set in the referenced use case [1]. 

Whatever the command mode (creation or edition), the OKaction method updates the Combined Curve. To do so, it creates a new update command of type CATPrtUpdateCom. This command updates only the combined curve (in manual update mode) or the whole part (automatic update mode). This command  encapsulates interactive error management ( edit / delete, etc...).

...
CATPrtUpdateCom *pUpdateCommand =  new CATPrtUpdateCom ( 
                        piSpecOnCombinedCurve ,  // the feature to update, translated into part->update 
                                                 // in	 case of automatic update setting
                        1                     ,  // respects update interactive setting 
                                                 // ( manual / automatic )
                        GetMode()            );  // creation or modification. Prevents the user from 
                                                 // creating a feature in error 

After the update step, if the feature is inside an ordered set, whatever the command mode (creation or edition), you must call the Insert method of the CATMmrLinearBodyServices class.  

CATBaseUnknown_var spBUOnCC = piSpecOnCombinedCurve ;
rc = CATMmrLinearBodyServices::Insert(spBUOnCC);

The last step consists in to modify the graphic properties of the new combined curve. The graphic properties are changed by this way:

CATIVisProperties *piGraphPropOnCombinedCurve = NULL;
rc = piSpecOnCombinedCurve->QueryInterface( IID_CATIVisProperties, 
                                                        (void**)& piGraphPropOnCombinedCurve);
 
CATVisPropertiesValues Attribut;
Attribut.SetColor(255, 255, 0); // yellow
Attribut.SetWidth(4);           // medium thickness
piGraphPropOnCombinedCurve->SetPropertiesAtt(Attribut, CATVPAllPropertyType, CATVPLine);

[Top]

Coding the CancelAction Method

CATBoolean CAAMmrCombCrvPanelStCmd::CancelAction(void *)
{
    if (_editor) _editor -> UnsetRepeatedCommand();
    return TRUE ; 
} 

This code enables you to unset the repeat mode when the Cancel or Close icon are pushed by the end user. 

[Top]

Overriding Activate, Deactivate and Cancel methods to Manage Current Feature

The management of the current feature, a specificity of an ordered set, has been implemented through the Activate, Deactivate, and Cancel methods of the CATCommand class [8]. 

In the three methods, the IsCombCrvInsideOrderedBody local method has been used to check if the combined curve is inside an ordered set. 

CATISpecObject * pSpecObjectOnCombCrv = NULL ;
rc = _piCombinedCurve->QueryInterface(IID_CATISpecObject,
                                                  (void**) &pSpecObjectOnCombCrv);
if ( SUCCEEDED(rc) )
{ 
   CATISpecObject * pFatherCC = NULL ;
   pFatherCC = pSpecObjectOnCombCrv->GetFather();
   if ( NULL != pFatherCC )
   {
      CATIGSMTool *piGSMToolFatherCC = NULL;
      rc = pFatherCC->QueryInterface ( IID_CATIGSMTool, (void**) &piGSMToolFatherCC);
      if ( SUCCEEDED(rc) )
      {
         int IsAnOrderedBody = -1 ;
         piGSMToolFatherCC->GetType(IsAnOrderedBody) ;
         if ( 1 == IsAnOrderedBody )
         {
            oIsInsideOrderedBody = TRUE ;
         } 

First you retrieve the feature aggregating the combined curve. It is possible thanks CATISpecObject and its GetFather method. Then you check the type of the aggregating feature. The CATIGSMTool interface is implemented on the GSMTool and HybridBody StartUp, and finally GetType gives you the type (1=ordered set, 0= non ordered set). 

[Top]

Overriding Methods from the Parent Command CATMMUIPanelStateCmd

To take full advantage of the services provided by deriving from CATMMUIPanelStateCmd, three very simple methods must be overridden.

[Top]

Other Places of Interest: Highlighting Geometry and Enabling OK Button Sensitivity

Highlighting geometry is very useful when editing a feature. This part of code is called when the dialog box focus switches from one a field to another. It highlights the corresponding geometric element.

if ( piSpecOnGeomElem != NULL )
{
  // uses this pointer to build a path element
 
  CATIBuildPath *piBuildPath = NULL;
  HRESULT rc = piSpecOnGeomElem->QueryInterface( IID_CATIBuildPath, 
                                                 (void**) &piBuildPath );
  if ( SUCCEEDED(rc) )
  {
    CATPathElement Context = _editor->GetUIActiveObject();
    CATPathElement *pPathElement = NULL ;

    rc = piBuildPath->ExtractPathElement(&Context,&pPathElement);
    if (pPathElement != NULL)
    {
       _HSO->AddElement(pPathElement); // the geometrical element corresponding to the 
                                    // active field is now highlighted
        pPathElement->Release(); pPathElement = NULL ;                  
    }
    piBuildPath->Release(); // do not forget to release useless pointers
    piBuildPath = NULL ;
  }
}

The OK button must not be pressed if all of the four input curves and directions are not set. The OK button sensitivity can be managed as follows:

void CAAMmrCombCrvPanelStCmd::CheckOKSensitivity()
{
  if ( _piSpecOnCurve1 != NULL &&
       _piSpecOnDir1   != NULL &&
       _piSpecOnCurve2 != NULL &&
       _piSpecOnDir2   != NULL )
    _panel->SetOKSensitivity(CATDlgEnable);
  else
    _panel->SetOKSensitivity(CATDlgDisable);
  return;
}

[Top]

Creating the Combined Curve Edition Dialog Box

This edition dialog box is very basic. It is a not resizable and provides an OK button and a Cancel button.

CAAMmrCombinedCurveDlg::CAAMmrCombinedCurveDlg()
               : CATDlgDialog( (CATApplicationFrame::GetApplicationFrame())->GetMainWindow(),
                 "CombinedCurve",
                 CATDlgGridLayout | CATDlgWndOK | CATDlgWndCANCEL | CATDlgWndNoResize )

Note: this dialog box could be used by another command, since it does not know the Combined Curve edition state dialog command.

Thanks to its grid layout, it is easy to add some CATDlgLabel and CATDlgSelectionList:

This figure shows the Combined Curve edition dialog box.

Two types of objects are used:

  1. CATDlgLabel for the texts
  2. CATDlgSelectorList for the input fields.

Rows and Columns are numbered starting from 0.

Here is the code corresponding to the top row:

// Creates the CATDlgLabel for the input field's names.

_label_curve1 = new CATDlgLabel( this , CATString("labelc1") );
CATUnicodeString Promptc1 = "First Curve :";
_label_curve1 ->SetTitle(Promptc1);
...
// Creates the four input fields.
CATUnicodeString Prompt_nosel = "no selection";
_sel_curve1 = new CATDlgSelectorList(this,
                                     CATString("selc1"),
                                     CATDlgDataModify);
_sel_curve1->SetVisibleTextHeight(1);
_sel_curve1->SetLine(Prompt_nosel,0,CATDlgDataModify);
...
// first column: labels.
cst.Column=0;
cst.Row=0; _label_curve1 -> SetGridConstraints(cst);
// second column: input fields.
cst.Column=1;
cst.Row=0; _sel_curve1 -> SetGridConstraints(cst);
...

[Top]


In Short

This use case has demonstrated how to manage Combined Curve interactive.

It first shows how to implement the CATIEdit interface to activate Combined Curve edition.

Then, it creates a Combined Curve edition state dialog command, whose main points are to:

Finally, this use case briefly presents a basic Combined Curve edition dialog box.

[Top]


References

[1] Instantiating Combined Curves
[2] The Contents of the Specification Container- Geometrical Features Sets
[3] Order and Absorption Concepts
[4] The Contents of the Specification Container- Geometrical Features
[5] Editing Objects     
[6] Creating an Add-in in the Shape Design Workbench 
[7] Creating Combined Curve's Interface of Type
[8] The CAA Command Model
[Top]

History

Version: 1 [Mar 2000] Document created
Version: 2 [Oct 2003] Document Updated- Ordered Geometrical Set integration
Version: 3 [Jan 2005] CATImplementBOA usage instead TIE_CATIEdit
[Top]

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