3D PLM Enterprise Architecture

User Interface - Frame

Center Specification Tree Nodes

How to center specification tree nodes ?
Use Case

Abstract

This article shows how to center nodes of the specification tree.


What You Will Learn With This Use Case

This use case is intended to show you how to use the CATCafCenterGraph class that is used to center the node of a specification tree.

Top]

The CAACafCenterGraph Use Case

CAACafCenterGraph is a use case of the CAACATIAApplicationFrame.edu framework that illustrates CATIAApplicationFrame and ObjectModelerBase framework capabilities.

[Top]

What Does CAACafCenterGraph Do

CAACafCenterGraph contains a command that illustrates usage of the CATCafCenterGraph class. Once launched the command waits for a selection in the geometry, then makes use of the CATCafCenterGraph class to find and center the node associated to the selection in the geometry. The process can be repeated as long as the command is active.

Fig.1: In this example "Pad.1" is centered in the window as a result of pad selection

[Top]

How to Launch CAACafCenterGraph

To launch CAACafCenterGraph, you will need to set up the build time environment, then compile CAACafCenterGraph along with its prerequisites, set up the run time environment, and then execute the use case [4]. 

But just before launching the execution, edit the CAAApplicationFrame.edu.dico interface dictionary file located in the dictionary directory of the CAAApplicationFrame.edu framework:

Windows InstallRootDirectory\CAADoc\CAAApplicationFrame.edu\CNext\code\dictionary\
UNIX InstallRootDirectory/CAADoc/CAAApplicationFrame.edu/CNext/code/dictionary/

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

In this file, remove the "#" character before the two following lines, and then run mkCreateRuntimeView.

...
#CAAAfrGeneralWksAddin          CATIWorkbenchAddin              libCAAAfrGeneralWksAddin
#CAAAfrGeneralWksAddin          CATIAfrGeneralWksAddin          libCAAAfrGeneralWksAddin
...

The two lines deal with the General workshop add-in described in the CAAAfrGeneralWksAddin use case [3] located in the CAAAfrGeneralWksAddin.m module (CAAApplicationFrame.edu framework)

Then, in the window where you run the mkrun command, do not type the module name on the command line, but type CNEXT instead. When the application is ready, do the following:

  1. On the File menu, click New
  2. File New Dialog box click Part  and click OK
  3. Create Point, Line, Pad, ....
  4. On the power input type "c:Center Graph Demonstrator"
  5. Select objects in 3D, see the effect in specification tree
  6. On the Start menu, click Exit

[Top]

Where to Find the CAACafCenterGraph Code

The CAACafCenterGraph use case is made of two classes:

[Top]

Step-by-Step

There are two logical steps in CAACafCenterGraph :

  1. Implementing the BuildGraph method
  2. Centering the graph on the Selected Object

[Top]

Implementing the BuildGraph Method

As usual the BuildGraph method is divided in three parts:

  1. Creating the agents
  2. Creating the states
  3. Creating the transitions between states according to the agents.
...
   _daObjectToCenterNode = new CATPathElementAgent("SelObjectToCenterNodeId");
   _daObjectToCenterNode->AddElementType(IID_CATINavigateObject);
   _daObjectToCenterNode->SetBehavior(CATDlgEngRepeat | CATDlgEngNewHSOManager | CATDlgEngWithPSOHSO );

   CATDialogState *stGetObjState = GetInitialState("stGetObjStateId");
   stGetObjState->AddDialogAgent(_daObjectToCenterNode);

   CATDialogTransition *pTransition = AddTransition
   (
       stGetObjState,
       stGetObjState,
       IsLastModifiedAgentCondition(_daObjectToCenterNode) , 
       Action((ActionMethod) & CAACafCenterGraphCmd::CenterGraphOnObject)
   ); 

...

_daObjectToCenterNode is an acquisition agent to select an object in the specification tree or in 3D. After the selection, the object is highlighted (specify by the CATDlgEngWithPSOHSO behavior). The CATDlgEngRepeat behavior enables you to re-use the agent without reinitializing it. The CATDlgEngNewHSOManager empties the HSO before each selection.

This state command has only one state, stGetObjState , whose name is stGetObjStateId

When the end user selects a valid element, the unique transition is triggered and the CenterGraphOnObject method is called. 

[Top]

Centering the graph on the Selected Object

The first part of the CenterGraphOnObject method consists in retrieving the CATNavigBox instance corresponding to the tree you want to center. In the case of this sample it is the specification tree of the window.

...
 // Retrieves the current window 
CATFrmLayout * pLayout = CATFrmLayout::GetCurrentLayout();
if ( NULL == pLayout ) return TRUE;

CATFrmWindow * pCurrentWindow = pLayout->GetCurrentWindow();
if ( NULL == pCurrentWindow ) return TRUE;

// If it is a CATFrmNavigGraphicWindow, it is possible to
// retrieve a CATNavigBox pointer
//
if ( 1 != pCurrentWindow->IsAKindOf("CATFrmNavigGraphicWindow") ) return TRUE;

CATFrmNavigGraphicWindow * pFrmNavigGraphicWindow = 
(CATFrmNavigGraphicWindow*) pCurrentWindow ;

CATNavigBox * pNavigBox = NULL ;
pNavigBox = pFrmNavigGraphicWindow->GetNavigBox();

...

Then the actual job is done by instanciating a CATCafCenterGraph class and calling the CenterGraph method on it.

...
CATCafCenterGraph CenterGraphObj;
CenterGraphObj.CenterGraph("OnHSO",pNavigBox);

...

The first argument is "OnHSO" because we want to center the tree on the highlighted object. The second argument is the pointer to the CATNavigBox instance that was retrieved in the first part of the method.

For information, please note that actual code run by the "CenterGraph" method is the same as the one run by the interactive command "Center Graph" that can be found in V5 in object contextual menu.

[Top]


In Short

This use case explains how to find and center an element of the specification tree in the window.  

[Top]


References

[1] The Object Navigator
[2] Getting Started with State Dialog Commands
[3] Making Your Document Independent Command Available in All Workbenches
[4] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [March 2006] Document created
[Top]

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