AbstractThis article discusses the CAATpiRetrieveAnnotation use case. This use case explains how to retrieve all 3D annotations applied to a selected geometry and how to highlight them. |
This use case is intended to help you to use Technological Product Specifications (TPS) interfaces [1]. The use case demonstrates CATITPSRetrieveServices interface usage to retrieve the 3D annotations linked on a selected geometry. It also illustrates how to highlight the retrieved annotations by using CATIBuildPath interface.
[Top]
CAATpiRetrieveAnnotation is a use case of the CAATPSInterfaces.edu framework that illustrates CATTPSInterfaces framework capabilities.
[Top]
The use case is an interactive command that prompt the user to select a geometrical element and then retrieve annotations which are applied to the selection. The retrieved 3D annotations are highlighted and their names are displayed in a panel.
[Top]
The use case command is available in the toolbar "CAA Sample" of the workbench Functionnal & Tolerancing & Annotation.
To launch CAATpiRetrieveAnnotation, you will need to set up the build time environment, then compile CAATPSInterfaces.edu framework along with its prerequisites, set up the run time environment, and then execute the use case [2].
Do not type the module name on the command line, but type CNEXT instead. When the application is ready, do the following:
Notice that the toolbar CAA Sample is also available in other workbenches :
[Top]
The CAATpiRetrieveAnnotation use case is located in the CAATpiRetrieveAnnotation.m module of the CAATPSInterfaces.edu framework:
Windows | InstallRootDirectory\CAATPSInterfaces.edu\CAATpiRetrieveAnnotation.m\ |
Unix | InstallRootDirectory/CAATPSInterfaces.edu/CAATpiRetrieveAnnotation.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There are seven logical steps in CAATpiRetrieveAnnotation:
We will now comment each of these sections by looking at the code.
[Top]
The use case is the class CAATpiRetrieveAnnotationCmd which is a CATStateCommand that implement the following statechart diagram.
The Buildgraph method of the command implements this statechart diagram.
There are 2 agents associated to the state SelectState
. SelectionAgent
is a CATPathElementAgent that accept all kinds of objects, when valuated
the transition method SomethingSelected
is called. ClosePanelAgent
is a CATDialogAgent that listen the Close button of the panel to
terminate the command.
[Top]
boolean CAATpiRetrieveAnnotationCmd::SomethingSelected (void * ipData) { ... // Retrieve the selection CATPathElement * pPathSelected = _pSelectionAgent -> GetValue (); if ( pPathSelected ) { // Retrieve CATITPSRetrieveServices interfaces CATITPSRetrieveServices * piRetServ = NULL; rc = CATTPSInstantiateComponent (DfTPS_ItfRetrieveServices, (void**) & piRetServ); if ( SUCCEEDED(rc) ) { // Retrieve the list of TPS (3D Annotations) linked on selected Path CATITPSList * piTPSList = NULL; rc = piRetServ -> RetrieveTPSsFromPath (pPathSelected, NULL, &piTPSList); if ( SUCCEEDED(rc) ) { ... piTPSList -> Release(); piTPSList = NULL; } piRetServ -> Release(); piRetServ = NULL; } pPathSelected = NULL; } ... |
When selection agent is valuated the transition method SomethingSelected
is called. The CATPathElement selected pPathSelected
is
retrieved by calling GetValue
on the selection agent. CATITPSRetrieveServices
interface is obtained from the global service CATTPSInstantiateComponent
.
The method RetrieveTPSsFromPath
is called with pPathSelected
as input argument. The retrieved 3D annotations are returned as a CATITPSList
pointer piTPSList
.
[Top]
CATListValCATUnicodeString AliasList; ... unsigned int Count = 0; piTPSList -> Count(&Count); if ( Count ) { ... CATITPSComponent * piItem = NULL; CATIAlias * piAlias = NULL; CATUnicodeString Alias; ... // Iterate on the list of 3D annotations for ( unsigned int Idx = 0 ; Idx < Count ; Idx ++) { rc = piTPSList -> Item (Idx, &piItem); if ( SUCCEEDED(rc) ) { // Append it's alias to the list of Alias rc = piItem -> QueryInterface (IID_CATIAlias, (void**)&piAlias); if ( SUCCEEDED(rc) ) { Alias = piAlias -> GetAlias(); AliasList.Append(Alias); piAlias -> Release(); piAlias = NULL; } piItem -> Release(); piItem = NULL; } } ... } ... // Send AliasList to the panel for Display _pPanel -> SetAliasList (AliasList); ... |
The AliasList
that contains the names of retrieved 3D
Annotations is constructed by iterating on piTPSList
with Count
and Item
methods. The name of each 3D Annotations is obtained by CATIAlias::GetAlias
method. And last, the SetAliasList
method is used to inform the
panel of the new AliasList
.
[Top]
// Retrieve HSO from editor and Empty it CATFrmEditor * pEdt = GetEditor(); if ( pEdt ) { CATHSO * pHSO = pEdt -> GetHSO(); if ( pHSO ) { pHSO -> Empty(); // Add selected PathElement in the HSO, it will be highlighted pHSO -> AddElements (pPathSelected); |
In a CATStateCommand, the editor can be retrieved thanks to GetEditor
method. That allows to retrieved the HSO which manage highlight. HSO is reseted
by Empty
method. The selected path pPathSelected
is
placed in HSO with AddElements
method.
[Top]
CATIBuildPath * piBuildPath = NULL; CATPathElement * pPath = NULL; ... // Highlight the retrieved TPS by placing its PathElement // in the HSO. rc = piItem -> QueryInterface (IID_CATIBuildPath, (void**)&piBuildPath); if ( SUCCEEDED(rc) ) { rc = piBuildPath -> ExtractPathElement(pPathSelected, &pPath); if ( SUCCEEDED(rc) ) { pHSO -> AddElements (pPath); pPath -> Release(); pPath = NULL; } piBuildPath -> Release(); piBuildPath = NULL; ... |
For each 3D annotation (piItem
) CATIBuildPath interface
is used to generated the CATPathElement pPath
. ExtractPathElement
method must be called with a context path which is used in product environment
to known which instance of the product containing the Annotation must be
highlighted. Here the selected path pPathSelected
is used as
context.
The HSO is filled with the generated path by calling AddElements
.
[Top]
// No more elements to Add in the HSO, notification is send // and HSO content can be highlighted. pHSO -> EndAddElements (); ... |
The EndAddElements
method is used to inform the HSO that it can
display and highlight it's content.
[Top]
The use case finishes when the command ended by pressing the close button in the panel.
[Top]
This use case has demonstrated how to retrieve 3D Annotations linked to a geometry and how to highlight them.
[Top]
[1] | Technological Product Specification Overview |
[2] | Building and Launching a CAA V5 Use Case |
[Top]
History | |
Version: 1 [Feb 2002] | Document created |
[Top] |
Copyright © 2002, Dassault Systèmes. All rights reserved.