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> |
42cf5bc1 |
26 | #include <Standard_Boolean.hxx> |
27 | #include <Graphic3d_ZLayerId.hxx> |
28 | #include <PrsMgr_PresentableObjectPointer.hxx> |
29 | #include <gp_Trsf.hxx> |
30 | #include <PrsMgr_ListOfPresentableObjects.hxx> |
31 | #include <MMgt_TShared.hxx> |
32 | #include <PrsMgr_Presentation.hxx> |
33 | #include <PrsMgr_PresentationManager3d.hxx> |
34 | #include <Standard_Integer.hxx> |
825aa485 |
35 | #include <Graphic3d_TransformPers.hxx> |
42cf5bc1 |
36 | #include <Graphic3d_TransModeFlags.hxx> |
37 | #include <TColStd_ListOfInteger.hxx> |
38 | #include <Graphic3d_ClipPlane.hxx> |
39 | class Standard_NotImplemented; |
40 | class PrsMgr_Presentation; |
41 | class PrsMgr_PresentationManager; |
42 | class Graphic3d_Structure; |
43 | class Graphic3d_DataStructureManager; |
44 | class Geom_Transformation; |
45 | class Prs3d_Presentation; |
46 | class Prs3d_Projector; |
47 | class gp_Pnt; |
48 | class gp_Trsf; |
49 | |
50 | |
51 | class PrsMgr_PresentableObject; |
52 | DEFINE_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. |
69 | class PrsMgr_PresentableObject : public MMgt_TShared |
70 | { |
71 | |
72 | public: |
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; |
825aa485 |
110 | |
111 | //! @return transform persistence of the presentable object. |
112 | const Graphic3d_TransformPers& TransformPersistence() const; |
113 | |
42cf5bc1 |
114 | Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType); |
115 | |
116 | //! flags the Prs of mode <AMode> to be Updated. |
117 | //! the Update will be done when needed. |
118 | Standard_EXPORT void SetToUpdate (const Standard_Integer aMode); |
119 | |
120 | //! flags all the Presentations to be Updated. |
121 | Standard_EXPORT void SetToUpdate(); |
122 | |
123 | //! gives the list of modes which are flagged "to be updated". |
124 | Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const; |
125 | |
126 | //! Sets local transformation to theTransformation. |
127 | Standard_EXPORT virtual void SetLocalTransformation (const gp_Trsf& theTransformation); |
128 | |
129 | //! Returns true if object has a transformation that is different from the identity. |
130 | Standard_EXPORT Standard_Boolean HasTransformation() const; |
131 | |
132 | const gp_Trsf& LocalTransformation() const; |
133 | |
134 | const gp_Trsf& Transformation() const; |
135 | |
136 | const gp_Trsf& InversedTransformation() const; |
137 | |
138 | //! resets local transformation to identity. |
139 | Standard_EXPORT virtual void ResetTransformation(); |
140 | |
141 | Standard_EXPORT virtual void UpdateTransformation(); |
142 | |
143 | Standard_EXPORT virtual void UpdateTransformation (const Handle(Prs3d_Presentation)& P); |
144 | |
145 | //! Set Z layer ID and update all presentations of the presentable object. |
146 | //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers. |
147 | Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId); |
148 | |
149 | //! Get ID of Z layer. |
150 | Standard_EXPORT Graphic3d_ZLayerId ZLayer() const; |
151 | |
152 | //! Adds clip plane for graphical clipping for all display mode |
153 | //! presentations. The composition of clip planes truncates the rendering |
154 | //! space to convex volume. Please be aware that number of supported |
155 | //! clip plane is limited. The planes which exceed the limit are ignored. |
156 | //! Besides of this, some planes can be already set in view where the object |
157 | //! is shown: the number of these planes should be substracted from limit |
158 | //! to predict the maximum possible number of object clipping planes. |
159 | //! @param thePlane [in] the clip plane to be appended to map of clip planes. |
160 | Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane); |
161 | |
162 | //! Removes previously added clip plane. |
163 | //! @param thePlane [in] the clip plane to be removed from map of clip planes. |
164 | Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane); |
165 | |
166 | //! Set clip planes for graphical clipping for all display mode presentations. |
167 | //! The composition of clip planes truncates the rendering space to convex |
168 | //! volume. Please be aware that number of supported clip plane is limited. |
169 | //! The planes which exceed the limit are ignored. Besides of this, some |
170 | //! planes can be already set in view where the object is shown: the number |
171 | //! of these planes should be substracted from limit to predict the maximum |
172 | //! possible number of object clipping planes. |
173 | Standard_EXPORT virtual void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes); |
174 | |
175 | //! Get clip planes. |
176 | //! @return set of previously added clip planes for all display mode presentations. |
177 | const Graphic3d_SequenceOfHClipPlane& GetClipPlanes() const; |
178 | |
179 | //! Sets if the object has mutable nature (content or location will be changed regularly). |
180 | //! This method should be called before object displaying to take effect. |
181 | Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable); |
182 | |
183 | //! Returns true if object has mutable nature (content or location are be changed regularly). |
184 | //! Mutable object will be managed in different way than static onces (another optimizations). |
487bf1ce |
185 | Standard_EXPORT Standard_Boolean IsMutable() const; |
42cf5bc1 |
186 | |
187 | //! Makes theObject child of current object in scene hierarchy. |
188 | Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject); |
189 | |
190 | //! Removes theObject from children of current object in scene hierarchy. |
191 | Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject); |
192 | |
193 | //! Returns children of the current object. |
194 | Standard_EXPORT const PrsMgr_ListOfPresentableObjects& Children() const; |
195 | |
196 | //! Returns true if object should have own presentations. |
487bf1ce |
197 | Standard_EXPORT Standard_Boolean HasOwnPresentations() const; |
42cf5bc1 |
198 | |
199 | //! Returns parent of current object in scene hierarchy. |
487bf1ce |
200 | Standard_EXPORT PrsMgr_PresentableObjectPointer Parent() const; |
42cf5bc1 |
201 | |
202 | |
203 | friend class PrsMgr_Presentation; |
204 | friend class PrsMgr_PresentationManager; |
205 | friend |
206 | Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector); |
207 | friend |
208 | Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Graphic3d_Structure)& theGivenStruct); |
209 | friend |
210 | Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf); |
211 | friend |
212 | Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Graphic3d_Structure)& theGivenStruct); |
213 | |
214 | |
215 | DEFINE_STANDARD_RTTI(PrsMgr_PresentableObject,MMgt_TShared) |
216 | |
217 | protected: |
218 | |
219 | |
220 | Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); |
221 | Standard_EXPORT virtual ~PrsMgr_PresentableObject(); |
222 | |
223 | //! Calculates the 3D view aPresentation and its |
224 | //! updates. The latter are managed by aPresentationManager. |
225 | //! aPresentableObject has the display mode aMode; |
226 | //! this has the default value of 0, that is, the wireframe display mode. |
227 | Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0); |
228 | |
229 | //! Calculates the 3D view aPresentation and its |
230 | //! updates. The latter are managed by |
231 | //! aPresentationManager. Each of the views in the |
232 | //! viewer and every modification such as rotation, for |
233 | //! example, entails recalculation. |
234 | //! It must be redefined to implement hidden line removal |
235 | //! for the object. The user never calls this method |
236 | //! himself. This is done via the InteractiveContext object |
237 | //! and is dependent on the point of view from which the |
238 | //! object is displayed. |
239 | Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation); |
240 | |
241 | //! Calculates the 3D view aPresentation and its |
242 | //! updates. The latter are managed by |
243 | //! aPresentationManager. A point of view is provided |
244 | //! by the projector aProjector, and the geometric |
245 | //! transformation which has transformed associated |
246 | //! presentable objects is specified by aTrsf. |
247 | //! This function is to be used in case where a hidden |
248 | //! line removal display cannot be calculated |
249 | //! automatically. This occurs when associated |
250 | //! presentable objects have been transformed |
251 | //! geometrically, but not translated. |
252 | //! Warning |
253 | //! The transformation aTrsf must be applied to the |
254 | //! object before computation. |
255 | Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation); |
256 | |
257 | //! recomputes all presentations of the object. |
258 | Standard_EXPORT void Update (const Standard_Boolean AllModes = Standard_False); |
259 | |
260 | //! Recomputes the presentation in the given mode. |
261 | //! If ClearOther is true, other presentation will be cleared. |
262 | Standard_EXPORT void Update (const Standard_Integer aMode, const Standard_Boolean ClearOther); |
263 | |
264 | //! High-level interface for controlling polygon offsets |
265 | Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode = 0); |
266 | |
267 | //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation |
268 | //! from parent node and able to derive its own. |
269 | Standard_EXPORT virtual void SetCombinedParentTransform (const gp_Trsf& theTransformation); |
270 | |
271 | //! General virtual method for internal update of presentation state |
272 | //! when some modifications on list of clip planes occurs. Base |
273 | //! implementation propagate clip planes to every presentation. |
274 | Standard_EXPORT virtual void UpdateClipping(); |
275 | |
276 | PrsMgr_Presentations myPresentations; |
277 | PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; |
278 | Graphic3d_SequenceOfHClipPlane myClipPlanes; |
279 | Standard_Boolean myIsMutable; |
280 | Graphic3d_ZLayerId myZLayer; |
281 | Standard_Boolean myHasOwnPresentations; |
282 | |
283 | |
284 | private: |
285 | |
286 | |
825aa485 |
287 | Graphic3d_TransformPers myTransformPersistence; |
42cf5bc1 |
288 | PrsMgr_PresentableObjectPointer myParent; |
289 | gp_Trsf myLocalTransformation; |
290 | gp_Trsf myTransformation; |
291 | gp_Trsf myInvTransformation; |
292 | gp_Trsf myCombinedParentTransform; |
293 | PrsMgr_ListOfPresentableObjects myChildren; |
294 | |
295 | |
296 | }; |
297 | |
298 | |
299 | #include <PrsMgr_PresentableObject.lxx> |
300 | |
301 | |
302 | |
303 | |
304 | |
305 | #endif // _PrsMgr_PresentableObject_HeaderFile |