1 // Created on: 1995-01-25
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _PrsMgr_PresentableObject_HeaderFile
18 #define _PrsMgr_PresentableObject_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <PrsMgr_Presentations.hxx>
24 #include <PrsMgr_TypeOfPresentation3d.hxx>
25 #include <Graphic3d_SequenceOfHClipPlane.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Graphic3d_ZLayerId.hxx>
28 #include <PrsMgr_PresentableObjectPointer.hxx>
29 #include <gp_GTrsf.hxx>
30 #include <gp_Trsf.hxx>
31 #include <PrsMgr_ListOfPresentableObjects.hxx>
32 #include <MMgt_TShared.hxx>
33 #include <PrsMgr_Presentation.hxx>
34 #include <PrsMgr_PresentationManager3d.hxx>
35 #include <Standard_Integer.hxx>
36 #include <Graphic3d_TransformPers.hxx>
37 #include <Graphic3d_TransModeFlags.hxx>
38 #include <TColStd_ListOfInteger.hxx>
39 #include <Graphic3d_ClipPlane.hxx>
40 class Standard_NotImplemented;
41 class PrsMgr_Presentation;
42 class PrsMgr_PresentationManager;
43 class Graphic3d_Structure;
44 class Graphic3d_DataStructureManager;
45 class Geom_Transformation;
46 class Prs3d_Presentation;
47 class Prs3d_Projector;
52 class PrsMgr_PresentableObject;
53 DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, MMgt_TShared)
55 //! A framework to supply the Graphic3d
56 //! structure of the object to be presented. On the first
57 //! display request, this structure is created by calling the
58 //! appropriate algorithm and retaining this frameworkfor
60 //! This abstract framework is inherited in Application
61 //! Interactive Services (AIS), notably in:
62 //! - AIS_InteractiveObject
63 //! - AIS_ConnectedInteractive
64 //! - AIS_MultipleConnectedInteractive
66 //! Consequently, 3D presentation should be handled by
67 //! the relevant daughter classes and their member
68 //! functions in AIS. This is particularly true in the
69 //! creation of new interactive objects.
70 class PrsMgr_PresentableObject : public MMgt_TShared
76 Standard_EXPORT PrsMgr_Presentations& Presentations();
78 //! Returns information on whether the object accepts display in HLR mode or not.
79 PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; }
81 //! @return transform persistence of the presentable object.
82 const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTransformPersistence; }
84 //! Sets up Transform Persistence for this object.
85 Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
87 //! Sets up Transform Persistence Mode for this object.
88 //! This function used to lock in object position, rotation and / or zooming relative to camera position.
89 //! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag
90 //! - see description later). theMode should be:
91 //! - Graphic3d_TMF_None - no persistence attributes (reset);
92 //! - Graphic3d_TMF_ZoomPers - object doesn't resize;
93 //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
94 //! - Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate;
95 //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
96 //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron.
97 //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means:
98 //! - X = 0.0, Y = 0.0 - center of view window;
99 //! - X > 0.0, Y > 0.0 - right upper corner of view window;
100 //! - X > 0.0, Y < 0.0 - right lower corner of view window;
101 //! - X < 0.0, Y > 0.0 - left upper corner of view window;
102 //! - X < 0.0, Y < 0.0 - left lower corner of view window.
103 //! And Z coordinate defines the gap from border of view window (except center position).
104 Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
105 void SetTransformPersistence (const Graphic3d_TransModeFlags theMode, const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
107 SetTransformPersistence (Graphic3d_TransformPers::FromDeprecatedParams (theMode, thePoint));
110 //! Gets Transform Persistence Mode for this object
111 Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
112 Graphic3d_TransModeFlags GetTransformPersistenceMode() const
114 return myTransformPersistence.IsNull()
116 : myTransformPersistence->Mode();
119 //! Gets point of transform persistence for this object
120 Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
121 Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
123 Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
125 //! flags the Prs of mode <AMode> to be Updated.
126 //! the Update will be done when needed.
127 Standard_EXPORT void SetToUpdate (const Standard_Integer aMode);
129 //! flags all the Presentations to be Updated.
130 Standard_EXPORT void SetToUpdate();
132 //! gives the list of modes which are flagged "to be updated".
133 Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
135 //! Sets local transformation to theTransformation.
136 Standard_EXPORT virtual void SetLocalTransformation (const gp_Trsf& theTransformation);
138 //! Returns true if object has a transformation that is different from the identity.
139 Standard_EXPORT Standard_Boolean HasTransformation() const;
141 const gp_Trsf& LocalTransformation() const { return myLocalTransformation; }
143 const gp_Trsf& Transformation() const { return myTransformation; }
145 const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
147 //! resets local transformation to identity.
148 Standard_EXPORT virtual void ResetTransformation();
150 Standard_EXPORT virtual void UpdateTransformation();
152 Standard_EXPORT virtual void UpdateTransformation (const Handle(Prs3d_Presentation)& P);
154 //! Set Z layer ID and update all presentations of the presentable object.
155 //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
156 Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
158 //! Get ID of Z layer.
159 Standard_EXPORT Graphic3d_ZLayerId ZLayer() const;
161 //! Adds clip plane for graphical clipping for all display mode
162 //! presentations. The composition of clip planes truncates the rendering
163 //! space to convex volume. Please be aware that number of supported
164 //! clip plane is limited. The planes which exceed the limit are ignored.
165 //! Besides of this, some planes can be already set in view where the object
166 //! is shown: the number of these planes should be substracted from limit
167 //! to predict the maximum possible number of object clipping planes.
168 //! @param thePlane [in] the clip plane to be appended to map of clip planes.
169 Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
171 //! Removes previously added clip plane.
172 //! @param thePlane [in] the clip plane to be removed from map of clip planes.
173 Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
175 //! Set clip planes for graphical clipping for all display mode presentations.
176 //! The composition of clip planes truncates the rendering space to convex volume.
177 //! Please be aware that number of supported clip plane is limited.
178 //! The planes which exceed the limit are ignored.
179 //! Besides of this, some planes can be already set in view where the object is shown:
180 //! the number of these planes should be subtracted from limit to predict the maximum
181 //! possible number of object clipping planes.
182 Standard_EXPORT virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes);
184 Standard_DEPRECATED("This method is deprecated - overload taking Handle should be used instead")
185 void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
187 Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane (thePlanes);
188 SetClipPlanes (aPlanes);
192 //! @return set of previously added clip planes for all display mode presentations.
193 const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myClipPlanes; }
195 //! Sets if the object has mutable nature (content or location will be changed regularly).
196 //! This method should be called before object displaying to take effect.
197 Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
199 //! Returns true if object has mutable nature (content or location are be changed regularly).
200 //! Mutable object will be managed in different way than static onces (another optimizations).
201 Standard_Boolean IsMutable() const { return myIsMutable; }
203 //! Makes theObject child of current object in scene hierarchy.
204 Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
206 //! Removes theObject from children of current object in scene hierarchy.
207 Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
209 //! Returns children of the current object.
210 const PrsMgr_ListOfPresentableObjects& Children() const { return myChildren; }
212 //! Returns true if object should have own presentations.
213 Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; }
215 //! Returns parent of current object in scene hierarchy.
216 PrsMgr_PresentableObjectPointer Parent() const { return myParent; }
219 friend class PrsMgr_Presentation;
220 friend class PrsMgr_PresentationManager;
222 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector);
224 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Graphic3d_Structure)& theGivenStruct);
226 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf);
228 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Graphic3d_Structure)& theGivenStruct);
231 DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject,MMgt_TShared)
236 Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
237 Standard_EXPORT virtual ~PrsMgr_PresentableObject();
239 //! Calculates the 3D view aPresentation and its
240 //! updates. The latter are managed by aPresentationManager.
241 //! aPresentableObject has the display mode aMode;
242 //! this has the default value of 0, that is, the wireframe display mode.
243 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode);
245 //! Calculates the 3D view aPresentation and its
246 //! updates. The latter are managed by
247 //! aPresentationManager. Each of the views in the
248 //! viewer and every modification such as rotation, for
249 //! example, entails recalculation.
250 //! It must be redefined to implement hidden line removal
251 //! for the object. The user never calls this method
252 //! himself. This is done via the InteractiveContext object
253 //! and is dependent on the point of view from which the
254 //! object is displayed.
255 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation);
257 //! Calculates the 3D view aPresentation and its
258 //! updates. The latter are managed by
259 //! aPresentationManager. A point of view is provided
260 //! by the projector aProjector, and the geometric
261 //! transformation which has transformed associated
262 //! presentable objects is specified by aTrsf.
263 //! This function is to be used in case where a hidden
264 //! line removal display cannot be calculated
265 //! automatically. This occurs when associated
266 //! presentable objects have been transformed
267 //! geometrically, but not translated.
269 //! The transformation aTrsf must be applied to the
270 //! object before computation.
271 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation);
273 //! recomputes all presentations of the object.
274 Standard_EXPORT void Update (const Standard_Boolean AllModes = Standard_False);
276 //! Recomputes the presentation in the given mode.
277 //! If ClearOther is true, other presentation will be cleared.
278 Standard_EXPORT void Update (const Standard_Integer aMode, const Standard_Boolean ClearOther);
280 //! High-level interface for controlling polygon offsets
281 Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode);
283 //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
284 //! from parent node and able to derive its own.
285 Standard_EXPORT virtual void SetCombinedParentTransform (const gp_Trsf& theTransformation);
287 //! General virtual method for internal update of presentation state
288 //! when some modifications on list of clip planes occurs. Base
289 //! implementation propagate clip planes to every presentation.
290 Standard_EXPORT virtual void UpdateClipping();
294 PrsMgr_Presentations myPresentations;
295 PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d;
296 Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
297 Standard_Boolean myIsMutable;
298 Graphic3d_ZLayerId myZLayer;
299 Standard_Boolean myHasOwnPresentations;
303 Handle(Graphic3d_TransformPers) myTransformPersistence;
304 PrsMgr_PresentableObjectPointer myParent;
305 gp_Trsf myLocalTransformation;
306 gp_Trsf myTransformation;
307 gp_GTrsf myInvTransformation;
308 gp_Trsf myCombinedParentTransform;
309 PrsMgr_ListOfPresentableObjects myChildren;
313 #endif // _PrsMgr_PresentableObject_HeaderFile