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 | |
2b886265 |
20 | #include <Aspect_TypeOfFacingModel.hxx> |
1f7f5a90 |
21 | #include <gp_GTrsf.hxx> |
22 | #include <Graphic3d_ClipPlane.hxx> |
42cf5bc1 |
23 | #include <Graphic3d_SequenceOfHClipPlane.hxx> |
1f7f5a90 |
24 | #include <Graphic3d_TransformPers.hxx> |
25 | #include <Graphic3d_TransModeFlags.hxx> |
42cf5bc1 |
26 | #include <Graphic3d_ZLayerId.hxx> |
b5cce1ab |
27 | #include <Prs3d_Drawer.hxx> |
42cf5bc1 |
28 | #include <PrsMgr_ListOfPresentableObjects.hxx> |
42cf5bc1 |
29 | #include <PrsMgr_Presentation.hxx> |
1f7f5a90 |
30 | #include <PrsMgr_Presentations.hxx> |
1f7f5a90 |
31 | #include <PrsMgr_TypeOfPresentation3d.hxx> |
42cf5bc1 |
32 | #include <TColStd_ListOfInteger.hxx> |
42cf5bc1 |
33 | |
7dd7c146 |
34 | class PrsMgr_PresentationManager; |
35 | typedef PrsMgr_PresentationManager PrsMgr_PresentationManager3d; |
36 | |
2b886265 |
37 | //! A framework to supply the Graphic3d structure of the object to be presented. |
38 | //! On the first display request, this structure is created by calling the appropriate algorithm and retaining this framework for further display. |
39 | //! This abstract framework is inherited in Application Interactive Services (AIS), notably by AIS_InteractiveObject. |
40 | //! Consequently, 3D presentation should be handled by the relevant daughter classes and their member functions in AIS. |
41 | //! This is particularly true in the creation of new interactive objects. |
42 | //! |
43 | //! Key interface methods to be implemented by every Selectable Object: |
44 | //! - AcceptDisplayMode() accepting display modes implemented by this object; |
45 | //! - Compute() computing presentation for the given display mode index. |
46 | //! |
47 | //! Warning! Methods managing standard attributes (SetColor(), SetWidth(), SetMaterial()) have different meaning for objects of different type (or no meaning at all). |
48 | //! Sub-classes might override these methods to modify Prs3d_Drawer or class properties providing a convenient short-cut depending on application needs. |
49 | //! For more sophisticated configuring, Prs3d_Drawer should be modified directly, while short-cuts might be left unimplemented. |
f838dac4 |
50 | class PrsMgr_PresentableObject : public Standard_Transient |
42cf5bc1 |
51 | { |
f838dac4 |
52 | DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient) |
53 | friend class PrsMgr_Presentation; |
54 | friend class PrsMgr_PresentationManager; |
42cf5bc1 |
55 | public: |
56 | |
2b886265 |
57 | //! Return presentations. |
1f7f5a90 |
58 | PrsMgr_Presentations& Presentations() { return myPresentations; } |
be5c3602 |
59 | |
2b886265 |
60 | //! Get ID of Z layer for main presentation. |
61 | Graphic3d_ZLayerId ZLayer() const { return myDrawer->ZLayer(); } |
be5c3602 |
62 | |
2b886265 |
63 | //! Set Z layer ID and update all presentations of the presentable object. |
64 | //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers. |
65 | Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId); |
778cd667 |
66 | |
2b886265 |
67 | //! Returns true if object has mutable nature (content or location are be changed regularly). |
68 | //! Mutable object will be managed in different way than static onces (another optimizations). |
69 | Standard_Boolean IsMutable() const { return myIsMutable; } |
778cd667 |
70 | |
2b886265 |
71 | //! Sets if the object has mutable nature (content or location will be changed regularly). |
72 | //! This method should be called before object displaying to take effect. |
73 | Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable); |
74 | |
75 | //! Returns true if the Interactive Object has display mode setting overriding global setting (within Interactive Context). |
76 | Standard_Boolean HasDisplayMode() const { return myDrawer->DisplayMode() != -1; } |
77 | |
78 | //! Returns the display mode setting of the Interactive Object. |
79 | //! The range of supported display mode indexes should be specified within object definition and filtered by AccepDisplayMode(). |
80 | //! @sa AcceptDisplayMode() |
81 | Standard_Integer DisplayMode() const { return myDrawer->DisplayMode(); } |
82 | |
83 | //! Sets the display mode for the interactive object. |
84 | //! An object can have its own temporary display mode, which is different from that proposed by the interactive context. |
85 | //! @sa AcceptDisplayMode() |
86 | void SetDisplayMode (const Standard_Integer theMode) |
778cd667 |
87 | { |
2b886265 |
88 | if (AcceptDisplayMode (theMode)) |
89 | { |
90 | myDrawer->SetDisplayMode (theMode); |
91 | } |
778cd667 |
92 | } |
1d92133e |
93 | |
2b886265 |
94 | //! Removes display mode settings from the interactive object. |
95 | void UnsetDisplayMode() { myDrawer->SetDisplayMode (-1); } |
96 | |
97 | //! Returns true if the Interactive Object is in highlight mode. |
98 | Standard_Boolean HasHilightMode() const { return !myHilightDrawer.IsNull() && myHilightDrawer->DisplayMode() != -1; } |
99 | |
100 | //! Returns highlight display mode. |
101 | //! This is obsolete method for backward compatibility - use ::HilightAttributes() and ::DynamicHilightAttributes() instead. |
102 | Standard_Integer HilightMode() const { return !myHilightDrawer.IsNull() ? myHilightDrawer->DisplayMode() : -1; } |
103 | |
104 | //! Sets highlight display mode. |
105 | //! This is obsolete method for backward compatibility - use ::HilightAttributes() and ::DynamicHilightAttributes() instead. |
106 | Standard_EXPORT void SetHilightMode (const Standard_Integer theMode); |
107 | |
108 | //! Unsets highlight display mode. |
109 | void UnsetHilightMode() |
778cd667 |
110 | { |
2b886265 |
111 | if (!myHilightDrawer.IsNull()) |
112 | { |
113 | myHilightDrawer->SetDisplayMode (-1); |
114 | } |
115 | if (!myDynHilightDrawer.IsNull()) |
116 | { |
117 | myDynHilightDrawer->SetDisplayMode (-1); |
118 | } |
778cd667 |
119 | } |
120 | |
2b886265 |
121 | //! Returns true if the class of objects accepts specified display mode index. |
122 | //! The interactive context can have a default mode of representation for the set of Interactive Objects. |
123 | //! This mode may not be accepted by a given class of objects. |
124 | //! Consequently, this virtual method allowing us to get information about the class in question must be implemented. |
125 | //! At least one display mode index should be accepted by this method. |
126 | //! Although subclass can leave default implementation, it is highly desired defining exact list of supported modes instead, |
127 | //! which is usually an enumeration for one object or objects class sharing similar list of display modes. |
128 | virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const |
129 | { |
130 | (void )theMode; |
131 | return Standard_True; |
132 | } |
133 | |
134 | //! Returns the default display mode. |
135 | virtual Standard_Integer DefaultDisplayMode() const { return 0; } |
825aa485 |
136 | |
226fce20 |
137 | //! Returns TRUE if any active presentation has invalidation flag. |
138 | //! @param theToIncludeHidden when TRUE, also checks hidden presentations |
139 | Standard_EXPORT Standard_Boolean ToBeUpdated (Standard_Boolean theToIncludeHidden = Standard_False) const; |
140 | |
141 | //! Flags presentation to be updated; UpdatePresentations() will recompute these presentations. |
142 | //! @param theMode presentation (display mode) to invalidate, or -1 to invalidate them all |
143 | Standard_EXPORT void SetToUpdate (Standard_Integer theMode); |
144 | |
42cf5bc1 |
145 | //! flags all the Presentations to be Updated. |
226fce20 |
146 | void SetToUpdate() { SetToUpdate (-1); } |
147 | |
2b886265 |
148 | //! Returns true if the interactive object is infinite; FALSE by default. |
149 | //! This flag affects various operations operating on bounding box of graphic presentations of this object. |
150 | //! For instance, infinite objects are not taken in account for View FitAll. |
151 | //! This does not necessarily means that object is actually infinite, |
152 | //! auxiliary objects might be also marked with this flag to achieve desired behavior. |
153 | Standard_Boolean IsInfinite() const { return myInfiniteState; } |
154 | |
155 | //! Sets if object should be considered as infinite. |
156 | Standard_EXPORT void SetInfiniteState (const Standard_Boolean theFlag = Standard_True); |
157 | |
158 | //! Returns information on whether the object accepts display in HLR mode or not. |
159 | PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; } |
160 | |
161 | //! Set type of presentation. |
162 | Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d theType); |
163 | |
164 | public: //! @name presentation attributes |
165 | |
166 | //! Returns the attributes settings. |
167 | const Handle(Prs3d_Drawer)& Attributes() const { return myDrawer; } |
168 | |
169 | //! Initializes the drawing tool theDrawer. |
170 | virtual void SetAttributes(const Handle(Prs3d_Drawer)& theDrawer) { myDrawer = theDrawer; } |
171 | |
172 | //! Returns the hilight attributes settings. |
173 | //! When not NULL, overrides both Prs3d_TypeOfHighlight_LocalSelected and Prs3d_TypeOfHighlight_Selected defined within AIS_InteractiveContext. |
174 | const Handle(Prs3d_Drawer)& HilightAttributes() const { return myHilightDrawer; } |
175 | |
176 | //! Initializes the hilight drawing tool theDrawer. |
177 | virtual void SetHilightAttributes(const Handle(Prs3d_Drawer)& theDrawer) { myHilightDrawer = theDrawer; } |
178 | |
179 | //! Returns the hilight attributes settings. |
180 | //! When not NULL, overrides both Prs3d_TypeOfHighlight_LocalDynamic and Prs3d_TypeOfHighlight_Dynamic defined within AIS_InteractiveContext. |
181 | const Handle(Prs3d_Drawer)& DynamicHilightAttributes() const { return myDynHilightDrawer; } |
182 | |
183 | //! Initializes the dynamic hilight drawing tool. |
184 | virtual void SetDynamicHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer) { myDynHilightDrawer = theDrawer; } |
185 | |
186 | //! Clears settings provided by the hilight drawing tool theDrawer. |
187 | virtual void UnsetHilightAttributes() { myHilightDrawer.Nullify(); } |
188 | |
189 | //! Synchronize presentation aspects after their modification. |
190 | //! |
191 | //! This method should be called after modifying primitive aspect properties (material, texture, shader) |
192 | //! so that modifications will take effect on already computed presentation groups (thus avoiding re-displaying the object). |
193 | Standard_EXPORT void SynchronizeAspects(); |
194 | |
195 | public: //! @name object transformation |
196 | |
197 | //! Returns Transformation Persistence defining a special Local Coordinate system where this presentable object is located or NULL handle if not defined. |
198 | //! Position of the object having Transformation Persistence is mutable and depends on camera position. |
199 | //! The same applies to a bounding box of the object. |
200 | //! @sa Graphic3d_TransformPers class description |
201 | const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTransformPersistence; } |
202 | |
203 | //! Sets up Transform Persistence defining a special Local Coordinate system where this object should be located. |
204 | //! Note that management of Transform Persistence object is more expensive than of the normal one, |
205 | //! because it requires its position being recomputed basing on camera position within each draw call / traverse. |
206 | //! @sa Graphic3d_TransformPers class description |
207 | Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers); |
42cf5bc1 |
208 | |
1f7f5a90 |
209 | //! Return the local transformation. |
67160f4e |
210 | //! Note that the local transformation of the object having Transformation Persistence |
211 | //! is applied within Local Coordinate system defined by this Persistence. |
1f7f5a90 |
212 | const Handle(Geom_Transformation)& LocalTransformationGeom() const { return myLocalTransformation; } |
213 | |
42cf5bc1 |
214 | //! Sets local transformation to theTransformation. |
67160f4e |
215 | //! Note that the local transformation of the object having Transformation Persistence |
216 | //! is applied within Local Coordinate system defined by this Persistence. |
1f7f5a90 |
217 | void SetLocalTransformation (const gp_Trsf& theTrsf) { setLocalTransformation (new Geom_Transformation (theTrsf)); } |
218 | |
219 | //! Sets local transformation to theTransformation. |
67160f4e |
220 | //! Note that the local transformation of the object having Transformation Persistence |
221 | //! is applied within Local Coordinate system defined by this Persistence. |
1f7f5a90 |
222 | void SetLocalTransformation (const Handle(Geom_Transformation)& theTrsf) { setLocalTransformation (theTrsf); } |
223 | |
42cf5bc1 |
224 | //! Returns true if object has a transformation that is different from the identity. |
1f7f5a90 |
225 | Standard_Boolean HasTransformation() const { return !myTransformation.IsNull() && myTransformation->Form() != gp_Identity; } |
3202bf1e |
226 | |
1f7f5a90 |
227 | //! Return the transformation taking into account transformation of parent object(s). |
67160f4e |
228 | //! Note that the local transformation of the object having Transformation Persistence |
229 | //! is applied within Local Coordinate system defined by this Persistence. |
1f7f5a90 |
230 | const Handle(Geom_Transformation)& TransformationGeom() const { return myTransformation; } |
3202bf1e |
231 | |
1f7f5a90 |
232 | //! Return the local transformation. |
67160f4e |
233 | //! Note that the local transformation of the object having Transformation Persistence |
234 | //! is applied within Local Coordinate system defined by this Persistence. |
1f7f5a90 |
235 | const gp_Trsf& LocalTransformation() const { return !myLocalTransformation.IsNull() |
236 | ? myLocalTransformation->Trsf() |
237 | : getIdentityTrsf(); } |
238 | |
239 | //! Return the transformation taking into account transformation of parent object(s). |
67160f4e |
240 | //! Note that the local transformation of the object having Transformation Persistence |
241 | //! is applied within Local Coordinate system defined by this Persistence. |
1f7f5a90 |
242 | const gp_Trsf& Transformation() const { return !myTransformation.IsNull() |
243 | ? myTransformation->Trsf() |
244 | : getIdentityTrsf(); } |
3202bf1e |
245 | |
2b886265 |
246 | //! Return inversed transformation. |
3202bf1e |
247 | const gp_GTrsf& InversedTransformation() const { return myInvTransformation; } |
1b63268e |
248 | |
2b886265 |
249 | //! Return combined parent transformation. |
250 | const Handle(Geom_Transformation)& CombinedParentTransformation() const { return myCombinedParentTransform; } |
251 | |
42cf5bc1 |
252 | //! resets local transformation to identity. |
253 | Standard_EXPORT virtual void ResetTransformation(); |
1b63268e |
254 | |
255 | //! Updates final transformation (parent + local) of presentable object and its presentations. |
42cf5bc1 |
256 | Standard_EXPORT virtual void UpdateTransformation(); |
1b63268e |
257 | |
2b886265 |
258 | public: //! @name clipping planes |
42cf5bc1 |
259 | |
2b886265 |
260 | //! Get clip planes. |
261 | //! @return set of previously added clip planes for all display mode presentations. |
262 | const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myClipPlanes; } |
263 | |
264 | //! Set clip planes for graphical clipping for all display mode presentations. |
265 | //! The composition of clip planes truncates the rendering space to convex volume. |
266 | //! Please be aware that number of supported clip plane is limited. |
267 | //! The planes which exceed the limit are ignored. |
268 | //! Besides of this, some planes can be already set in view where the object is shown: |
269 | //! the number of these planes should be subtracted from limit to predict the maximum |
270 | //! possible number of object clipping planes. |
271 | Standard_EXPORT virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes); |
272 | |
42cf5bc1 |
273 | //! Adds clip plane for graphical clipping for all display mode |
274 | //! presentations. The composition of clip planes truncates the rendering |
275 | //! space to convex volume. Please be aware that number of supported |
276 | //! clip plane is limited. The planes which exceed the limit are ignored. |
277 | //! Besides of this, some planes can be already set in view where the object |
2b886265 |
278 | //! is shown: the number of these planes should be subtracted from limit |
42cf5bc1 |
279 | //! to predict the maximum possible number of object clipping planes. |
280 | //! @param thePlane [in] the clip plane to be appended to map of clip planes. |
281 | Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane); |
2b886265 |
282 | |
42cf5bc1 |
283 | //! Removes previously added clip plane. |
284 | //! @param thePlane [in] the clip plane to be removed from map of clip planes. |
285 | Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane); |
3202bf1e |
286 | |
2b886265 |
287 | public: //! @name parent/children properties |
3202bf1e |
288 | |
2b886265 |
289 | //! Returns parent of current object in scene hierarchy. |
290 | PrsMgr_PresentableObject* Parent() const { return myParent; } |
291 | |
292 | //! Returns children of the current object. |
293 | const PrsMgr_ListOfPresentableObjects& Children() const { return myChildren; } |
3202bf1e |
294 | |
42cf5bc1 |
295 | //! Makes theObject child of current object in scene hierarchy. |
296 | Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject); |
2b886265 |
297 | |
42cf5bc1 |
298 | //! Removes theObject from children of current object in scene hierarchy. |
299 | Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject); |
be5c3602 |
300 | |
42cf5bc1 |
301 | //! Returns true if object should have own presentations. |
3202bf1e |
302 | Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; } |
be5c3602 |
303 | |
2b886265 |
304 | //! Returns bounding box of object correspondingly to its current display mode. |
305 | //! This method requires presentation to be already computed, since it relies on bounding box of presentation structures, |
306 | //! which are supposed to be same/close amongst different display modes of this object. |
307 | Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox); |
42cf5bc1 |
308 | |
2b886265 |
309 | protected: //! @name interface methods |
42cf5bc1 |
310 | |
2b886265 |
311 | //! Protected empty constructor. |
312 | Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); |
313 | |
314 | //! Destructor. |
315 | Standard_EXPORT virtual ~PrsMgr_PresentableObject(); |
316 | |
317 | //! Fills the given 3D view presentation for specified display mode using Compute() method. |
318 | //! In addition, configures other properties of presentation (transformation, clipping planes). |
319 | //! @param thePrsMgr presentation manager where presentation has been created |
320 | //! @param thePrs presentation to fill |
321 | //! @param theMode display mode to compute; can be any number accepted by AcceptDisplayMode() method |
322 | Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& thePrsMgr, |
323 | const Handle(PrsMgr_Presentation)& thePrs, |
324 | const Standard_Integer theMode); |
325 | |
326 | //! Calculates the 3D view presentation for specified display mode. |
327 | //! This is a key interface for implementing Presentable Object interface. |
328 | //! @param thePrsMgr presentation manager where presentation has been created |
329 | //! @param thePrs presentation to fill |
330 | //! @param theMode display mode to compute; can be any number accepted by AcceptDisplayMode() method |
331 | //! @sa AcceptDisplayMode() |
332 | Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, |
333 | const Handle(Prs3d_Presentation)& thePrs, |
334 | const Standard_Integer theMode) = 0; |
335 | |
336 | //! Calculates the 3D view presentation. |
337 | //! Each of the views in the viewer and every modification such as rotation, for example, entails recalculation. |
338 | //! It must be redefined to implement hidden line removal for the object. The user never calls this method himself. |
339 | //! This is done via the InteractiveContext object and is dependent on the point of view from which the object is displayed. |
340 | Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector, |
341 | const Handle(Prs3d_Presentation)& thePrs); |
342 | |
343 | //! Calculates the 3D view presentation. |
344 | //! A point of view is provided by the projector, and the geometric transformation which has transformed associated presentable objects is specified by transformation. |
345 | //! This function is to be used in case where a hidden line removal display cannot be calculated automatically. |
346 | //! This occurs when associated presentable objects have been transformed geometrically, but not translated. |
347 | //! Warning! The transformation must be applied to the object before computation. |
348 | Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector, |
349 | const Handle(Geom_Transformation)& theTrsf, |
350 | const Handle(Prs3d_Presentation)& thePrs); |
351 | |
352 | //! Recomputes invalidated presentations of the object. |
353 | //! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated |
354 | //! @return TRUE if some presentations were recomputed |
355 | Standard_EXPORT Standard_Boolean UpdatePresentations (Standard_Boolean theToIncludeHidden = Standard_False); |
356 | |
357 | //! General virtual method for internal update of presentation state |
358 | //! when some modifications on list of clip planes occurs. Base |
359 | //! implementation propagate clip planes to every presentation. |
360 | Standard_EXPORT virtual void UpdateClipping(); |
361 | |
362 | //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation |
363 | //! from parent node and able to derive its own. |
364 | Standard_EXPORT virtual void SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf); |
365 | |
366 | //! Sets local transformation to theTransformation. |
367 | Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTransformation); |
368 | |
369 | //! Return the identity transformation. |
370 | Standard_EXPORT static const gp_Trsf& getIdentityTrsf(); |
371 | |
372 | //! Recompute computed (HLR) presentations (when view is in computed mode). |
373 | Standard_EXPORT void recomputeComputed() const; |
374 | |
375 | //! Replace aspects of existing (computed) presentation groups, |
376 | //! so that the new aspects can be applied without recomputing presentation. |
377 | //! It is NOT recommended approach, because user has to fill such map and then search for each occurrence in computed groups. |
378 | //! The recommended approach is computing presentation with necessary customized aspects, |
379 | //! and then modify them directly followed by SynchronizeAspects() call. |
380 | Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap); |
381 | |
382 | public: //! @name simplified presentation properties API |
383 | |
384 | //! Enables or disables on-triangulation build of isolines according to the flag given. |
385 | void SetIsoOnTriangulation (const Standard_Boolean theIsEnabled) { myDrawer->SetIsoOnTriangulation (theIsEnabled); } |
386 | |
387 | //! Returns the current facing model which is in effect. |
388 | Aspect_TypeOfFacingModel CurrentFacingModel() const { return myCurrentFacingModel; } |
389 | |
390 | //! change the current facing model apply on polygons for SetColor(), SetTransparency(), SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE. |
391 | //! This mean that attributes is applying both on the front and back face. |
392 | void SetCurrentFacingModel (const Aspect_TypeOfFacingModel theModel = Aspect_TOFM_BOTH_SIDE) { myCurrentFacingModel = theModel; } |
393 | |
394 | //! Returns true if the Interactive Object has color. |
395 | Standard_Boolean HasColor() const { return hasOwnColor; } |
396 | |
397 | //! Returns the color setting of the Interactive Object. |
398 | virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); } |
399 | |
400 | //! Only the interactive object knowns which Drawer attribute is affected by the color, if any |
401 | //! (ex: for a wire,it's the wireaspect field of the drawer, but for a vertex, only the point aspect field is affected by the color). |
402 | //! WARNING : Do not forget to set the corresponding fields here (hasOwnColor and myDrawer->SetColor()) |
403 | virtual void SetColor (const Quantity_Color& theColor) |
f838dac4 |
404 | { |
2b886265 |
405 | myDrawer->SetColor (theColor); |
406 | hasOwnColor = Standard_True; |
f838dac4 |
407 | } |
408 | |
2b886265 |
409 | //! Removes color settings. Only the Interactive Object |
410 | //! knows which Drawer attribute is affected by the color |
411 | //! setting. For a wire, for example, wire aspect is the |
412 | //! attribute affected. For a vertex, however, only point |
413 | //! aspect is affected by the color setting. |
414 | virtual void UnsetColor() { hasOwnColor = Standard_False; } |
415 | |
416 | //! Returns true if the Interactive Object has width. |
417 | Standard_Boolean HasWidth() const { return myOwnWidth != 0.0f; } |
418 | |
419 | //! Returns the width setting of the Interactive Object. |
420 | Standard_Real Width() const { return myOwnWidth; } |
421 | |
422 | //! Allows you to provide the setting aValue for width. |
423 | //! Only the Interactive Object knows which Drawer attribute is affected by the width setting. |
424 | virtual void SetWidth (const Standard_Real theWidth) { myOwnWidth = (Standard_ShortReal )theWidth; } |
425 | |
426 | //! Reset width to default value. |
427 | virtual void UnsetWidth() { myOwnWidth = 0.0f; } |
428 | |
429 | //! Returns true if the Interactive Object has a setting for material. |
430 | Standard_Boolean HasMaterial() const { return hasOwnMaterial; } |
431 | |
432 | //! Returns the current material setting as enumeration value. |
433 | Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const; |
434 | |
435 | //! Sets the material aMat defining this display attribute |
436 | //! for the interactive object. |
437 | //! Material aspect determines shading aspect, color and |
438 | //! transparency of visible entities. |
439 | Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName); |
440 | |
441 | //! Removes the setting for material. |
442 | Standard_EXPORT virtual void UnsetMaterial(); |
443 | |
444 | //! Returns true if there is a transparency setting. |
445 | Standard_Boolean IsTransparent() const { return myDrawer->Transparency() > 0.005f; } |
446 | |
447 | //! Returns the transparency setting. |
448 | //! This will be between 0.0 and 1.0. |
449 | //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent. |
450 | virtual Standard_Real Transparency() const { return (myDrawer->Transparency() <= 0.005f ? 0.0 : myDrawer->Transparency()); } |
451 | |
452 | //! Attributes a setting aValue for transparency. |
453 | //! The transparency value should be between 0.0 and 1.0. |
454 | //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent. |
455 | //! Warning At a value of 1.0, there may be nothing visible. |
456 | Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6); |
457 | |
458 | //! Removes the transparency setting. The object is opaque by default. |
459 | Standard_EXPORT virtual void UnsetTransparency(); |
460 | |
461 | //! Returns Standard_True if <myDrawer> has non-null shading aspect |
462 | Standard_EXPORT virtual Standard_Boolean HasPolygonOffsets() const; |
463 | |
464 | //! Retrieves current polygon offsets settings from <myDrawer>. |
465 | Standard_EXPORT virtual void PolygonOffsets (Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const; |
466 | |
467 | //! Sets up polygon offsets for this object. |
468 | //! @sa Graphic3d_Aspects::SetPolygonOffsets() |
469 | Standard_EXPORT virtual void SetPolygonOffsets (const Standard_Integer aMode, const Standard_ShortReal aFactor = 1.0, const Standard_ShortReal aUnits = 0.0); |
470 | |
471 | //! Clears settings provided by the drawing tool aDrawer. |
f838dac4 |
472 | Standard_EXPORT virtual void UnsetAttributes(); |
473 | |
2b886265 |
474 | public: //! @name deprecated methods |
f838dac4 |
475 | |
2b886265 |
476 | //! gives the list of modes which are flagged "to be updated". |
477 | Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead") |
478 | Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const; |
f838dac4 |
479 | |
2b886265 |
480 | Standard_DEPRECATED("This method is deprecated - overload taking Handle should be used instead") |
481 | void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes) |
482 | { |
483 | Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane (thePlanes); |
484 | SetClipPlanes (aPlanes); |
485 | } |
f838dac4 |
486 | |
2b886265 |
487 | //! Sets up Transform Persistence Mode for this object. |
488 | //! This function used to lock in object position, rotation and / or zooming relative to camera position. |
489 | //! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag |
490 | //! - see description later). theMode should be: |
491 | //! - Graphic3d_TMF_None - no persistence attributes (reset); |
492 | //! - Graphic3d_TMF_ZoomPers - object doesn't resize; |
493 | //! - Graphic3d_TMF_RotatePers - object doesn't rotate; |
494 | //! - Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate; |
495 | //! - Graphic3d_TMF_RotatePers - object doesn't rotate; |
496 | //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron. |
497 | //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means: |
498 | //! - X = 0.0, Y = 0.0 - center of view window; |
499 | //! - X > 0.0, Y > 0.0 - right upper corner of view window; |
500 | //! - X > 0.0, Y < 0.0 - right lower corner of view window; |
501 | //! - X < 0.0, Y > 0.0 - left upper corner of view window; |
502 | //! - X < 0.0, Y < 0.0 - left lower corner of view window. |
503 | //! And Z coordinate defines the gap from border of view window (except center position). |
504 | Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead") |
505 | void SetTransformPersistence (const Graphic3d_TransModeFlags theMode, const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0)) |
506 | { |
507 | SetTransformPersistence (Graphic3d_TransformPers::FromDeprecatedParams (theMode, thePoint)); |
508 | } |
f838dac4 |
509 | |
2b886265 |
510 | //! Gets Transform Persistence Mode for this object |
511 | Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead") |
512 | Graphic3d_TransModeFlags GetTransformPersistenceMode() const |
513 | { |
514 | return myTransformPersistence.IsNull() |
515 | ? Graphic3d_TMF_None |
516 | : myTransformPersistence->Mode(); |
517 | } |
42cf5bc1 |
518 | |
2b886265 |
519 | //! Gets point of transform persistence for this object |
520 | Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead") |
521 | Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const; |
42cf5bc1 |
522 | |
2b886265 |
523 | protected: |
226fce20 |
524 | |
525 | //! Recomputes all presentations of the object. |
526 | Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead") |
527 | void Update (Standard_Boolean theToIncludeHidden = Standard_False) |
528 | { |
529 | SetToUpdate(); |
530 | UpdatePresentations (theToIncludeHidden); |
531 | } |
532 | |
42cf5bc1 |
533 | //! Recomputes the presentation in the given mode. |
226fce20 |
534 | //! @param theMode presentation (display mode) to recompute |
535 | //! @param theToClearOther when TRUE, other presentations (display modes) will be removed |
536 | Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead") |
537 | Standard_EXPORT void Update (Standard_Integer theMode, Standard_Boolean theToClearOther); |
1f7f5a90 |
538 | |
3202bf1e |
539 | protected: |
540 | |
2b886265 |
541 | PrsMgr_PresentableObject* myParent; //!< pointer to the parent object |
542 | PrsMgr_Presentations myPresentations; //!< list of presentations |
543 | Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; //!< sequence of object-specific clipping planes |
544 | Handle(Prs3d_Drawer) myDrawer; //!< main presentation attributes |
545 | Handle(Prs3d_Drawer) myHilightDrawer; //!< (optional) custom presentation attributes for highlighting selected object |
546 | Handle(Prs3d_Drawer) myDynHilightDrawer; //!< (optional) custom presentation attributes for highlighting detected object |
547 | Handle(Graphic3d_TransformPers) myTransformPersistence; //!< transformation persistence |
548 | Handle(Geom_Transformation) myLocalTransformation; //!< local transformation relative to parent object |
549 | Handle(Geom_Transformation) myTransformation; //!< absolute transformation of this object (combined parents + local transformations) |
550 | Handle(Geom_Transformation) myCombinedParentTransform; //!< transformation of parent object (combined for all parents) |
551 | PrsMgr_ListOfPresentableObjects myChildren; //!< list of children |
552 | gp_GTrsf myInvTransformation; //!< inversion of absolute transformation (combined parents + local transformations) |
553 | PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; //!< presentation type |
554 | |
555 | Aspect_TypeOfFacingModel myCurrentFacingModel; //!< current facing model |
556 | Standard_ShortReal myOwnWidth; //!< custom width value |
557 | Standard_Boolean hasOwnColor; //!< own color flag |
558 | Standard_Boolean hasOwnMaterial; //!< own material flag |
559 | |
560 | Standard_Boolean myInfiniteState; //!< infinite flag |
561 | Standard_Boolean myIsMutable; //!< mutable flag |
562 | Standard_Boolean myHasOwnPresentations; //!< flag indicating if object should have own presentations |
42cf5bc1 |
563 | |
42cf5bc1 |
564 | }; |
565 | |
f838dac4 |
566 | DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, Standard_Transient) |
1f7f5a90 |
567 | |
42cf5bc1 |
568 | #endif // _PrsMgr_PresentableObject_HeaderFile |