0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / PrsMgr / PrsMgr_PresentableObject.hxx
CommitLineData
42cf5bc1 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _PrsMgr_PresentableObject_HeaderFile
18#define _PrsMgr_PresentableObject_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <PrsMgr_Presentations.hxx>
24#include <PrsMgr_TypeOfPresentation3d.hxx>
25#include <Graphic3d_SequenceOfHClipPlane.hxx>
26#include <Graphic3d_CTransPersStruct.hxx>
27#include <Standard_Boolean.hxx>
28#include <Graphic3d_ZLayerId.hxx>
29#include <PrsMgr_PresentableObjectPointer.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_TransModeFlags.hxx>
37#include <TColStd_ListOfInteger.hxx>
38#include <Graphic3d_ClipPlane.hxx>
39class Standard_NotImplemented;
40class PrsMgr_Presentation;
41class PrsMgr_PresentationManager;
42class Graphic3d_Structure;
43class Graphic3d_DataStructureManager;
44class Geom_Transformation;
45class Prs3d_Presentation;
46class Prs3d_Projector;
47class gp_Pnt;
48class gp_Trsf;
49
50
51class PrsMgr_PresentableObject;
52DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, MMgt_TShared)
53
54//! A framework to supply the Graphic3d
55//! structure of the object to be presented. On the first
56//! display request, this structure is created by calling the
57//! appropriate algorithm and retaining this frameworkfor
58//! further display.
59//! This abstract framework is inherited in Application
60//! Interactive Services (AIS), notably in:
61//! - AIS_InteractiveObject
62//! - AIS_ConnectedInteractive
63//! - AIS_MultipleConnectedInteractive
64//! - AIS_Shape
65//! Consequently, 3D presentation should be handled by
66//! the relevant daughter classes and their member
67//! functions in AIS. This is particularly true in the
68//! creation of new interactive objects.
69class PrsMgr_PresentableObject : public MMgt_TShared
70{
71
72public:
73
74
75 Standard_EXPORT PrsMgr_Presentations& Presentations();
76
77 //! Returns information on whether the object accepts display in HLR mode or not.
78 Standard_EXPORT PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const;
79
80 //! Sets up Transform Persistence Mode for this object.
81 //! This function used to lock in object position, rotation and / or zooming relative to camera position.
82 //! Object will be drawn in the origin setted by APoint parameter (except Graphic3d_TMF_TriedronPers flag
83 //! - see description later). aFlag should be:
84 //! - Graphic3d_TMF_None - no persistence attributes (reset);
85 //! - Graphic3d_TMF_PanPers - object doesn't move;
86 //! - Graphic3d_TMF_ZoomPers - object doesn't resize;
87 //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
88 //! - Graphic3d_TMF_FullPers - pan, zoom and rotate transform persistence;
89 //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron;
90 //! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_ZoomPers);
91 //! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_RotatePers);
92 //! - combination (Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers).
93 //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected APoint coordinates X and Y means:
94 //! - X = 0.0, Y = 0.0 - center of view window;
95 //! - X > 0.0, Y > 0.0 - right upper corner of view window;
96 //! - X > 0.0, Y < 0.0 - right lower corner of view window;
97 //! - X < 0.0, Y > 0.0 - left upper corner of view window;
98 //! - X < 0.0, Y < 0.0 - left lower corner of view window.
99 //! And Z coordinate defines the gap from border of view window (except center position).
100 Standard_EXPORT virtual void SetTransformPersistence (const Graphic3d_TransModeFlags& aFlag, const gp_Pnt& APoint);
101
102 //! Calls previous method with point (0,0,0)
103 Standard_EXPORT void SetTransformPersistence (const Graphic3d_TransModeFlags& aFlag);
104
105 //! Gets Transform Persistence Mode for this object
106 Standard_EXPORT Graphic3d_TransModeFlags GetTransformPersistenceMode() const;
107
108 //! Gets point of transform persistence for this object
109 Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
110
111 Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
112
113 //! flags the Prs of mode <AMode> to be Updated.
114 //! the Update will be done when needed.
115 Standard_EXPORT void SetToUpdate (const Standard_Integer aMode);
116
117 //! flags all the Presentations to be Updated.
118 Standard_EXPORT void SetToUpdate();
119
120 //! gives the list of modes which are flagged "to be updated".
121 Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
122
123 //! Sets local transformation to theTransformation.
124 Standard_EXPORT virtual void SetLocalTransformation (const gp_Trsf& theTransformation);
125
126 //! Returns true if object has a transformation that is different from the identity.
127 Standard_EXPORT Standard_Boolean HasTransformation() const;
128
129 const gp_Trsf& LocalTransformation() const;
130
131 const gp_Trsf& Transformation() const;
132
133 const gp_Trsf& InversedTransformation() const;
134
135 //! resets local transformation to identity.
136 Standard_EXPORT virtual void ResetTransformation();
137
138 Standard_EXPORT virtual void UpdateTransformation();
139
140 Standard_EXPORT virtual void UpdateTransformation (const Handle(Prs3d_Presentation)& P);
141
142 //! Set Z layer ID and update all presentations of the presentable object.
143 //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
144 Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
145
146 //! Get ID of Z layer.
147 Standard_EXPORT Graphic3d_ZLayerId ZLayer() const;
148
149 //! Adds clip plane for graphical clipping for all display mode
150 //! presentations. The composition of clip planes truncates the rendering
151 //! space to convex volume. Please be aware that number of supported
152 //! clip plane is limited. The planes which exceed the limit are ignored.
153 //! Besides of this, some planes can be already set in view where the object
154 //! is shown: the number of these planes should be substracted from limit
155 //! to predict the maximum possible number of object clipping planes.
156 //! @param thePlane [in] the clip plane to be appended to map of clip planes.
157 Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
158
159 //! Removes previously added clip plane.
160 //! @param thePlane [in] the clip plane to be removed from map of clip planes.
161 Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
162
163 //! Set clip planes for graphical clipping for all display mode presentations.
164 //! The composition of clip planes truncates the rendering space to convex
165 //! volume. Please be aware that number of supported clip plane is limited.
166 //! The planes which exceed the limit are ignored. Besides of this, some
167 //! planes can be already set in view where the object is shown: the number
168 //! of these planes should be substracted from limit to predict the maximum
169 //! possible number of object clipping planes.
170 Standard_EXPORT virtual void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes);
171
172 //! Get clip planes.
173 //! @return set of previously added clip planes for all display mode presentations.
174 const Graphic3d_SequenceOfHClipPlane& GetClipPlanes() const;
175
176 //! Sets if the object has mutable nature (content or location will be changed regularly).
177 //! This method should be called before object displaying to take effect.
178 Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
179
180 //! Returns true if object has mutable nature (content or location are be changed regularly).
181 //! Mutable object will be managed in different way than static onces (another optimizations).
182 Standard_EXPORT const Standard_Boolean IsMutable() const;
183
184 //! Makes theObject child of current object in scene hierarchy.
185 Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
186
187 //! Removes theObject from children of current object in scene hierarchy.
188 Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
189
190 //! Returns children of the current object.
191 Standard_EXPORT const PrsMgr_ListOfPresentableObjects& Children() const;
192
193 //! Returns true if object should have own presentations.
194 Standard_EXPORT const Standard_Boolean HasOwnPresentations() const;
195
196 //! Returns parent of current object in scene hierarchy.
197 Standard_EXPORT const PrsMgr_PresentableObjectPointer Parent() const;
198
199
200friend class PrsMgr_Presentation;
201friend class PrsMgr_PresentationManager;
202friend
203 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector);
204friend
205 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Graphic3d_Structure)& theGivenStruct);
206friend
207 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf);
208friend
209 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Graphic3d_Structure)& theGivenStruct);
210
211
212 DEFINE_STANDARD_RTTI(PrsMgr_PresentableObject,MMgt_TShared)
213
214protected:
215
216
217 Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
218Standard_EXPORT virtual ~PrsMgr_PresentableObject();
219
220 //! Calculates the 3D view aPresentation and its
221 //! updates. The latter are managed by aPresentationManager.
222 //! aPresentableObject has the display mode aMode;
223 //! this has the default value of 0, that is, the wireframe display mode.
224 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0);
225
226 //! Calculates the 3D view aPresentation and its
227 //! updates. The latter are managed by
228 //! aPresentationManager. Each of the views in the
229 //! viewer and every modification such as rotation, for
230 //! example, entails recalculation.
231 //! It must be redefined to implement hidden line removal
232 //! for the object. The user never calls this method
233 //! himself. This is done via the InteractiveContext object
234 //! and is dependent on the point of view from which the
235 //! object is displayed.
236 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation);
237
238 //! Calculates the 3D view aPresentation and its
239 //! updates. The latter are managed by
240 //! aPresentationManager. A point of view is provided
241 //! by the projector aProjector, and the geometric
242 //! transformation which has transformed associated
243 //! presentable objects is specified by aTrsf.
244 //! This function is to be used in case where a hidden
245 //! line removal display cannot be calculated
246 //! automatically. This occurs when associated
247 //! presentable objects have been transformed
248 //! geometrically, but not translated.
249 //! Warning
250 //! The transformation aTrsf must be applied to the
251 //! object before computation.
252 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation);
253
254 //! recomputes all presentations of the object.
255 Standard_EXPORT void Update (const Standard_Boolean AllModes = Standard_False);
256
257 //! Recomputes the presentation in the given mode.
258 //! If ClearOther is true, other presentation will be cleared.
259 Standard_EXPORT void Update (const Standard_Integer aMode, const Standard_Boolean ClearOther);
260
261 //! High-level interface for controlling polygon offsets
262 Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode = 0);
263
264 //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
265 //! from parent node and able to derive its own.
266 Standard_EXPORT virtual void SetCombinedParentTransform (const gp_Trsf& theTransformation);
267
268 //! General virtual method for internal update of presentation state
269 //! when some modifications on list of clip planes occurs. Base
270 //! implementation propagate clip planes to every presentation.
271 Standard_EXPORT virtual void UpdateClipping();
272
273 PrsMgr_Presentations myPresentations;
274 PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d;
275 Graphic3d_SequenceOfHClipPlane myClipPlanes;
276 Standard_Boolean myIsMutable;
277 Graphic3d_ZLayerId myZLayer;
278 Standard_Boolean myHasOwnPresentations;
279
280
281private:
282
283
284 Graphic3d_CTransPersStruct myTransformPersistence;
285 PrsMgr_PresentableObjectPointer myParent;
286 gp_Trsf myLocalTransformation;
287 gp_Trsf myTransformation;
288 gp_Trsf myInvTransformation;
289 gp_Trsf myCombinedParentTransform;
290 PrsMgr_ListOfPresentableObjects myChildren;
291
292
293};
294
295
296#include <PrsMgr_PresentableObject.lxx>
297
298
299
300
301
302#endif // _PrsMgr_PresentableObject_HeaderFile