AbstractThis article discusses the CAAVisManager use case. This use case explains how to create and implement a specific visualization interface for geometric components, how to make the visualization manager aware of this interface to display these components, and how to catch the visualization notification to manage the PSO and HSO contents. This article focuses on the specific visualization interface implementation. |
Geometric components usually implement the visualization interfaces supplied by the Visualization framework, namely CATI3DGeoVisu and CATI2DGeoVisu [1]. This use case is intended to show how to create and implement a visualization interface of your own to make a geometric component displayable in a 3D viewer, and how to make the visualization manager aware of this interface to display this component. Companion articles of this use case deal with the use of the visualization manager [2], and with catching visualization notifications [3].
[Top]
CAAVisManager is a set of use cases of the CAAVisualization.edu framework that illustrates CATIA Visualization framework capabilities.
[Top]
CAAVisManager contains a series of modules that make up a small application. This article focuses on the CAAIVis2DGraphVisu interface, and shows how to create it, and how to implement it for a base geometric component from which derived geometric components, such as a sphere, a cuboid, and a component set, will inherit. It also shows how to implement CATIModelEvents for this base component.
CAAIVis2DGraphVisu provides methods for 3D components that already implement CATI3DGeoVisu to also have a 2D graphic representation used to display each object as a labeled box to build a 2D graph in the 3D window. (CATI2GeoVisu could be used instead of creating a new interface.) CAAIVis2DGraphVisu derives from the CATIVisu interface. This is to make the visualization manager aware of your own interface in addition to CATI3DGeoVisu or CATI2DGeoVisu. For this reason, never derive your visualization interfaces from CATI3DGeoVisu or CATI2DGeoVisu.
[Top]
To launch CAAVisManager, you will need to set up the build time environment, then compile the four CAAVisManager modules along with their prerequisites, set up the run time environment, and then execute the use case [4]. You cannot launch CAAVisManager itself. CAAVisManager is simply used by the CAAVisManagerAppli use case. Type CAAVisManagerAppli instead of CAAVisManager to display the interactive application along with a viewer that displays the CAAVisManagerDefaultDocument.
[Top]
CAAVisManager code is located in the CAAVisualization.edu framework:
Windows | InstallRootDirectory\CAAVisualization.edu\ |
Unix | InstallRootDirectory/CAAVisualization.edu/ |
where InstallRootDirectory
is the root directory of your CAA V5
installation.
CAAVisManager includes the following modules:
CAAVisManagerAppli.m | Contains the interactive application, the windows and the documents |
CAAVisManagerComp.m | Contains the geometric components to display |
CAAVisManagerImpl.m | Contains the extension classes required to make the geometric components displayable |
CAAVisManagerInt.m | Contains the interfaces implemented by the geometric components, especially the visualization interface. Their header files are located in the PrivateInterfaces directory |
CAAVisManager includes the following files to create and implement a customized visualization interface:
PrivateInterfaces directory | |
CAAIVis2DGraphVisu.h | Header file for the customized visualization interface CAAIVis2DGraphVisu |
In CAAVisManagerInt.m
src directory | |
CAAIVis2DGraphVisu.cpp | Source file for the customized visualization interface CAAIVis2DGraphVisu |
In CAAVisManagerImpl.m
LocalInterfaces directory | |
CAAEVis2DGraphVisuForObject.h | Header file for the extension class that implements CAAIVis2DGraphVisu |
CAAEVisModelEventsuForObject.h | Header file for the extension class that implements CATIModelEvents |
CAAVisManagerImpl.m/src directory | |
CAAEVis2DGraphVisuForObject.cpp | Source file for the extension class that implements CAAIVis2DGraphVisu |
CAAEVisModelEventsuForObject.cpp | Source file for the extension class that implements CATIModelEvents |
[Top]
To implement CATI3DGeoVisu and CATIModelEvents, there are four main steps:
[Top]
The CAAIVis2DGraphVisu interface is intended to display the set, cuboid, and sphere components in a tree showing the document tree structure. Each component is displayed as a colored box with its type written in the box.
#include "CATIVisu.h" #include "CAT3x3Matrix.h" #include "CAAVisManagerInt.h" extern ExportedByCAAVisManagerInt IID IID_CAAIVis2DGraphVisu; class ExportedByCAAVisManagerInt CAAIVis2DGraphVisu : public CATIVisu { CATDeclareInterface; public: virtual CAT3x3Matrix & GetPositioningMatrix()=0; virtual void IncrementPositioningMatrix()=0; }; |
CAAIVis2DGraphVisu derives from the CATIVisu interface. As
for any interface, its header file includes the CATDeclareInterface
macro. Its methods are:
BuildRep |
Inherited from CATIVisu, it builds and returns the representation associated with the geometric component to display in a viewer |
GetPositioningMatrix |
Returns the representation positioning matrix |
IncrementPositioningMatrix |
Computes the representation positioning matrix |
#include "CAAIVis2DGraphVisu.h" IID IID_CAAIVis2DGraphVisu = { 0x2ccd5540, 0xd884, 0x11d3, {0x9e, 0xd6, 0x00, 0x50, 0x8b, 0x12, 0x96, 0xfa} }; CATImplementInterface(CAAIVis2DGraphVisu, CATBaseUnknown); |
The source file contains the interface IID [5],
and the CATImplementInterface
macro to state that CAAIVis2DGraphVisu
OM-derives [6] from CATBaseUnknown.
![]() |
Note that even if CAAIVis2DGraphVisu C++-derives from CATIVisu, it's useless to make it also OM-derive from CATIVisu, and much safer to OM-derive it from CATBaseUnknown. This satisfies the Determinism principle in case of your component OM-derives from another one, or if your component implements several visualization interfaces that all must C++-derive from CATIVisu. |
[Top]
The CAAEVis2DGraphVisuForObject header file is as follows.
#include "CAAVis2DGraphVisuAdapter.h" class CAAEVis2DGraphVisuForObject : public CAAVis2DGraphVisuAdapter { CATDeclareClass; public : CAAEVis2DGraphVisuForObject(); virtual ~CAAEVis2DGraphVisuForObject(); CATRep * BuildRep(); private: CAAEVis2DGraphVisuForObject(const CAAEVis2DGraphVisuForObject &iObjectToCopy); }; |
CAAEVis2DGraphVisuForObject derives from CAAVis2DGraphVisuAdapter,
that provides the code for the non described GetPositioningMatrix
and IncrementPositioningMatrix
methods. CAAVis2DGraphVisuAdapter
derives from the CATExtIVisu class that provides the methods of CATIVisu
that don't need to be redefined. The BuildRep
method is the method
for making object displayable. As any class that makes up a component, its
header file includes the CATDeclareClass
macro. Note that the copy
constructor is declared as private, and is not implemented. This prevents the
compiler from creating a public one without you know. This is to prevent clients
from creating instances from an existing one, that they normally should not
handle, except using interface pointers.
The CAAEVis2DGraphVisuForObject source file is as follows.
... #include "TIE_CAAIVis2DGraphVisu.h" TIE_CAAIVis2DGraphVisu(CAAEVis2DGraphVisuForObject); CATImplementClass(CAAEVis2DGraphVisuForObject, DataExtension, CATBaseUnknown, CAAVisModelObject); CAAEVis2DGraphVisuForObject::CAAEVis2DGraphVisuForObject() {} CAAEVis2DGraphVisuForObject::~CAAEVis2DGraphVisuForObject() {} CATRep * CAAEVis2DGraphVisuForObject::BuildRep() { ... } |
The main points of this source file are:
TIE_CAAIVis2DGraphVisu
macroCATImplementClass
macroBuildRep
method is the only redefined method of CATIVisu.
It should return a pointer to the component representation, that is, a
pointer to a CAT2DRep in this case.[Top]
The BuildRep
method is implemented using three sub steps.
CATRep * CAAEVis2DGraphVisuForObject::BuildRep() { CAT2DBagRep * pCurrentObjectBagRep = NULL; ... |
The CAT2DBagRep class can contain any kind of 2D representation.
... CAAIVisModelObject *PtrVMO=NULL; HRESULT rc = QueryInterface(IID_CAAIVisModelObject,(void **)&PtrVMO); if ( SUCCEEDED(rc) ) { char * Type = NULL; PtrVMO->GetType(&Type); pCurrentObjectBagRep = new CAAVis2DGraphBoxRep(Type); delete [] Type; ... |
The box displays the component type. To retrieve this type, a pointer to
the CAAIVisModelObject interface is needed, with which we can call
the GetType
method that returns this type as a character
string. A specific representation, the CAAVis2DGraphBoxRep, is
instantiated.
This code is specific to the example. It is not described here and uses the methods of the adapter.
[Top]
CAAVisModelEventsForObject implements the CATIModelEvents interface by deriving from the CATExtIModelEvents adapter.
#include "CATExtIModelEvents.h" class CAAEVisModelEventsForObject : public CATExtIModelEvents { CATDeclareClass; public : CAAEVisModelEventsForObject(); virtual ~CAAEVisModelEventsForObject(); private : CAAEVisModelEventsForObject(const CAAEVisModelEventsForObject &iObjectToCopy); }; |
As any class that makes up a component, its header file includes the CATDeclareClass
macro. None of the CATIModelEvents methods needs to be redefined.
Note that the copy constructor is declared as private, and is not
implemented. This prevents the compiler from creating a public one without
you know. This is to prevent clients from creating instances from an
existing one, that they normally should not handle, except using interface
pointers.
#include "CAAEVisModelEventsForObject.h" #include "TIE_CATIModelEvents.h" TIE_CATIModelEvents(CAAEVisModelEventsForObject); CATImplementClass(CAAEVisModelEventsForObject, DataExtension, CATBaseUnknown, CAAVisModelObject); CAAEVisModelEventsForObject::CAAEVisModelEventsForObject() {} CAAEVisModelEventsForObject::~CAAEVisModelEventsForObject() {} |
The main points of this source file are:
TIE_CATIModelEvents
macroCATImplementClass
macro[Top]
This use case shows how to implement an visualization interface of your own,
named CAAIVis2DGraphVisu. It is intended to display a geometric component
as a labeled box in an object tree. CAAIVis2DGraphVisu is
implemented by an extension class of the base graphic component and so applies
to all derived graphic component, since the representations differ only by the
type printed in the box. The BuildRep
method creates and returns
the 2D representation that stands for the geometric component in the component
tree. The geometric component also implements CATI3DGeoVisu to display in
the 3D viewer.
To enable the representation of the geometric component to be refreshed when the component is modified, the component should implement the CATIModelEvents interface. This is done also using an extension class of the base geometric component, and any derived geometric component inherits the implementation of this interfaces. Usually, deriving from the CATExtIModelEvents adapter is enough, and no method needs to be redefined.
[Top]
Version: 1 [May 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.