0030949: Foundation Classes - Dump improvement for OCCT classes
[occt.git] / src / PrsMgr / PrsMgr_PresentableObject.hxx
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 <Aspect_TypeOfFacingModel.hxx>
21 #include <gp_GTrsf.hxx>
22 #include <Graphic3d_ClipPlane.hxx>
23 #include <Graphic3d_SequenceOfHClipPlane.hxx>
24 #include <Graphic3d_TransformPers.hxx>
25 #include <Graphic3d_TransModeFlags.hxx>
26 #include <Graphic3d_ZLayerId.hxx>
27 #include <Prs3d_Drawer.hxx>
28 #include <PrsMgr_ListOfPresentableObjects.hxx>
29 #include <PrsMgr_Presentation.hxx>
30 #include <PrsMgr_Presentations.hxx>
31 #include <PrsMgr_TypeOfPresentation3d.hxx>
32 #include <TColStd_ListOfInteger.hxx>
33
34 class PrsMgr_PresentationManager;
35 typedef PrsMgr_PresentationManager PrsMgr_PresentationManager3d;
36
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.
50 class PrsMgr_PresentableObject : public Standard_Transient
51 {
52   DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient)
53   friend class PrsMgr_Presentation;
54   friend class PrsMgr_PresentationManager;
55 public:
56
57   //! Return presentations.
58   PrsMgr_Presentations& Presentations() { return myPresentations; }
59
60   //! Get ID of Z layer for main presentation.
61   Graphic3d_ZLayerId ZLayer() const { return myDrawer->ZLayer(); }
62
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);
66
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; }
70
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)
87   {
88     if (AcceptDisplayMode (theMode))
89     {
90       myDrawer->SetDisplayMode (theMode);
91     }
92   }
93
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()
110   {
111     if (!myHilightDrawer.IsNull())
112     {
113       myHilightDrawer->SetDisplayMode (-1);
114     }
115     if (!myDynHilightDrawer.IsNull())
116     {
117       myDynHilightDrawer->SetDisplayMode (-1);
118     }
119   }
120
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; }
136
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
145   //! flags all the Presentations to be Updated.
146   void SetToUpdate() { SetToUpdate (-1); }
147
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);
208   
209   //! Return the local transformation.
210   //! Note that the local transformation of the object having Transformation Persistence
211   //! is applied within Local Coordinate system defined by this Persistence.
212   const Handle(Geom_Transformation)& LocalTransformationGeom() const { return myLocalTransformation; }
213
214   //! Sets local transformation to theTransformation.
215   //! Note that the local transformation of the object having Transformation Persistence
216   //! is applied within Local Coordinate system defined by this Persistence.
217   void SetLocalTransformation (const gp_Trsf& theTrsf) { setLocalTransformation (new Geom_Transformation (theTrsf)); }
218
219   //! Sets local transformation to theTransformation.
220   //! Note that the local transformation of the object having Transformation Persistence
221   //! is applied within Local Coordinate system defined by this Persistence.
222   void SetLocalTransformation (const Handle(Geom_Transformation)& theTrsf) { setLocalTransformation (theTrsf); }
223
224   //! Returns true if object has a transformation that is different from the identity.
225   Standard_Boolean HasTransformation() const { return !myTransformation.IsNull() && myTransformation->Form() != gp_Identity; }
226
227   //! Return the transformation taking into account transformation of parent object(s).
228   //! Note that the local transformation of the object having Transformation Persistence
229   //! is applied within Local Coordinate system defined by this Persistence.
230   const Handle(Geom_Transformation)& TransformationGeom() const { return myTransformation; }
231
232   //! Return the local transformation.
233   //! Note that the local transformation of the object having Transformation Persistence
234   //! is applied within Local Coordinate system defined by this Persistence.
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).
240   //! Note that the local transformation of the object having Transformation Persistence
241   //! is applied within Local Coordinate system defined by this Persistence.
242   const gp_Trsf& Transformation() const { return !myTransformation.IsNull()
243                                                 ? myTransformation->Trsf()
244                                                 : getIdentityTrsf(); }
245
246   //! Return inversed transformation.
247   const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
248
249   //! Return combined parent transformation.
250   const Handle(Geom_Transformation)& CombinedParentTransformation() const { return myCombinedParentTransform; }
251
252   //! resets local transformation to identity.
253   Standard_EXPORT virtual void ResetTransformation();
254
255   //! Updates final transformation (parent + local) of presentable object and its presentations.
256   Standard_EXPORT virtual void UpdateTransformation();
257
258 public: //! @name clipping planes
259   
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
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
278   //! is shown: the number of these planes should be subtracted from limit
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);
282
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);
286
287 public: //! @name parent/children properties
288
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; }
294
295   //! Makes theObject child of current object in scene hierarchy.
296   Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
297
298   //! Makes theObject child of current object in scene hierarchy with keeping the current global transformation
299   //! So the object keeps the same position/orientation in the global CS.
300   Standard_EXPORT void AddChildWithCurrentTransformation(const Handle(PrsMgr_PresentableObject)& theObject);
301
302   //! Removes theObject from children of current object in scene hierarchy.
303   Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
304
305   //! Removes theObject from children of current object in scene hierarchy with keeping the current global transformation.
306   //! So the object keeps the same position/orientation in the global CS.
307   Standard_EXPORT void RemoveChildWithRestoreTransformation(const Handle(PrsMgr_PresentableObject)& theObject);
308
309   //! Returns true if object should have own presentations.
310   Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; }
311
312   //! Returns bounding box of object correspondingly to its current display mode.
313   //! This method requires presentation to be already computed, since it relies on bounding box of presentation structures,
314   //! which are supposed to be same/close amongst different display modes of this object.
315   Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox);
316
317 protected: //! @name interface methods
318
319   //! Protected empty constructor.
320   Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
321
322   //! Destructor.
323   Standard_EXPORT virtual ~PrsMgr_PresentableObject();
324
325   //! Fills the given 3D view presentation for specified display mode using Compute() method.
326   //! In addition, configures other properties of presentation (transformation, clipping planes).
327   //! @param thePrsMgr presentation manager where presentation has been created
328   //! @param thePrs    presentation to fill
329   //! @param theMode   display mode to compute; can be any number accepted by AcceptDisplayMode() method
330   Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
331                                      const Handle(PrsMgr_Presentation)& thePrs,
332                                      const Standard_Integer theMode);
333
334   //! Calculates the 3D view presentation for specified display mode.
335   //! This is a key interface for implementing Presentable Object interface.
336   //! @param thePrsMgr presentation manager where presentation has been created
337   //! @param thePrs    presentation to fill
338   //! @param theMode   display mode to compute; can be any number accepted by AcceptDisplayMode() method
339   //! @sa AcceptDisplayMode()
340   Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
341                                         const Handle(Prs3d_Presentation)& thePrs,
342                                         const Standard_Integer theMode) = 0;
343
344   //! Calculates the 3D view presentation.
345   //! Each of the views in the viewer and every modification such as rotation, for example, entails recalculation.
346   //! It must be redefined to implement hidden line removal for the object. The user never calls this method himself.
347   //! This is done via the InteractiveContext object and is dependent on the point of view from which the object is displayed.
348   Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
349                                         const Handle(Prs3d_Presentation)& thePrs);
350
351   //! Calculates the 3D view presentation.
352   //! A point of view is provided by the projector, and the geometric transformation which has transformed associated presentable objects is specified by transformation.
353   //! This function is to be used in case where a hidden line removal display cannot be calculated automatically.
354   //! This occurs when associated presentable objects have been transformed geometrically, but not translated.
355   //! Warning! The transformation must be applied to the object before computation.
356   Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
357                                         const Handle(Geom_Transformation)& theTrsf,
358                                         const Handle(Prs3d_Presentation)& thePrs);
359
360   //! Recomputes invalidated presentations of the object.
361   //! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated
362   //! @return TRUE if some presentations were recomputed
363   Standard_EXPORT Standard_Boolean UpdatePresentations (Standard_Boolean theToIncludeHidden = Standard_False);
364
365   //! General virtual method for internal update of presentation state
366   //! when some modifications on list of clip planes occurs. Base
367   //! implementation propagate clip planes to every presentation.
368   Standard_EXPORT virtual void UpdateClipping();
369
370   //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
371   //! from parent node and able to derive its own.
372   Standard_EXPORT virtual void SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf);
373
374   //! Sets local transformation to theTransformation.
375   Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTransformation);
376
377   //! Return the identity transformation.
378   Standard_EXPORT static const gp_Trsf& getIdentityTrsf();
379
380   //! Recompute computed (HLR) presentations (when view is in computed mode).
381   Standard_EXPORT void recomputeComputed() const;
382
383   //! Replace aspects of existing (computed) presentation groups,
384   //! so that the new aspects can be applied without recomputing presentation.
385   //! It is NOT recommended approach, because user has to fill such map and then search for each occurrence in computed groups.
386   //! The recommended approach is computing presentation with necessary customized aspects,
387   //! and then modify them directly followed by SynchronizeAspects() call.
388   Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap);
389
390 public: //! @name simplified presentation properties API
391
392   //! Enables or disables on-triangulation build of isolines according to the flag given.
393   void SetIsoOnTriangulation (const Standard_Boolean theIsEnabled) { myDrawer->SetIsoOnTriangulation (theIsEnabled); }
394
395   //! Returns the current facing model which is in effect.
396   Aspect_TypeOfFacingModel CurrentFacingModel() const { return myCurrentFacingModel; }
397
398   //! change the current facing model apply on polygons for SetColor(), SetTransparency(), SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE.
399   //! This mean that attributes is applying both on the front and back face.
400   void SetCurrentFacingModel (const Aspect_TypeOfFacingModel theModel = Aspect_TOFM_BOTH_SIDE) { myCurrentFacingModel = theModel; }
401
402   //! Returns true if the Interactive Object has color.
403   Standard_Boolean HasColor() const { return hasOwnColor; }
404
405   //! Returns the color setting of the Interactive Object.
406   virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); }
407
408   //! Only the interactive object knowns which Drawer attribute is affected by the color, if any
409   //! (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).
410   //! WARNING : Do not forget to set the corresponding fields here (hasOwnColor and myDrawer->SetColor())
411   virtual void SetColor (const Quantity_Color& theColor)
412   {
413     myDrawer->SetColor (theColor);
414     hasOwnColor = Standard_True;
415   }
416
417   //! Removes color settings. Only the Interactive Object
418   //! knows which Drawer attribute is   affected by the color
419   //! setting. For a wire, for example, wire aspect is the
420   //! attribute affected. For a vertex, however, only point
421   //! aspect is affected by the color setting.
422   virtual void UnsetColor() { hasOwnColor = Standard_False; }
423
424   //! Returns true if the Interactive Object has width.
425   Standard_Boolean HasWidth() const { return myOwnWidth != 0.0f; }
426
427   //! Returns the width setting of the Interactive Object.
428   Standard_Real Width() const { return myOwnWidth; }
429
430   //! Allows you to provide the setting aValue for width.
431   //! Only the Interactive Object knows which Drawer attribute is affected by the width setting.
432   virtual void SetWidth (const Standard_Real theWidth) { myOwnWidth = (Standard_ShortReal )theWidth; }
433
434   //! Reset width to default value.
435   virtual void UnsetWidth() { myOwnWidth = 0.0f; }
436
437   //! Returns true if the Interactive Object has a setting for material.
438   Standard_Boolean HasMaterial() const { return hasOwnMaterial; }
439
440   //! Returns the current material setting as enumeration value.
441   Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const;
442
443   //! Sets the material aMat defining this display attribute
444   //! for the interactive object.
445   //! Material aspect determines shading aspect, color and
446   //! transparency of visible entities.
447   Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName);
448
449   //! Removes the setting for material.
450   Standard_EXPORT virtual void UnsetMaterial();
451
452   //! Returns true if there is a transparency setting.
453   Standard_Boolean IsTransparent() const { return myDrawer->Transparency() > 0.005f; }
454
455   //! Returns the transparency setting.
456   //! This will be between 0.0 and 1.0.
457   //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
458   virtual Standard_Real Transparency() const { return (myDrawer->Transparency() <= 0.005f ? 0.0 : myDrawer->Transparency()); }
459
460   //! Attributes a setting aValue for transparency.
461   //! The transparency value should be between 0.0 and 1.0.
462   //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
463   //! Warning At a value of 1.0, there may be nothing visible.
464   Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6);
465
466   //! Removes the transparency setting. The object is opaque by default.
467   Standard_EXPORT virtual void UnsetTransparency();
468
469   //! Returns Standard_True if <myDrawer> has non-null shading aspect
470   Standard_EXPORT virtual Standard_Boolean HasPolygonOffsets() const;
471
472   //! Retrieves current polygon offsets settings from <myDrawer>.
473   Standard_EXPORT virtual void PolygonOffsets (Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const;
474
475   //! Sets up polygon offsets for this object.
476   //! @sa Graphic3d_Aspects::SetPolygonOffsets()
477   Standard_EXPORT virtual void SetPolygonOffsets (const Standard_Integer aMode, const Standard_ShortReal aFactor = 1.0, const Standard_ShortReal aUnits = 0.0);
478
479   //! Clears settings provided by the drawing tool aDrawer.
480   Standard_EXPORT virtual void UnsetAttributes();
481
482   //! Dumps the content of me into the stream
483   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
484
485 public: //! @name deprecated methods
486
487   //! gives the list of modes which are flagged "to be updated".
488   Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead")
489   Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
490
491   Standard_DEPRECATED("This method is deprecated - overload taking Handle should be used instead")
492   void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
493   {
494     Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane (thePlanes);
495     SetClipPlanes (aPlanes);
496   }
497
498   //! Sets up Transform Persistence Mode for this object.
499   //! This function used to lock in object position, rotation and / or zooming relative to camera position.
500   //! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag
501   //! - see description later). theMode should be:
502   //! -   Graphic3d_TMF_None - no persistence attributes (reset);
503   //! -   Graphic3d_TMF_ZoomPers - object doesn't resize;
504   //! -   Graphic3d_TMF_RotatePers - object doesn't rotate;
505   //! -   Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate;
506   //! -   Graphic3d_TMF_RotatePers - object doesn't rotate;
507   //! -   Graphic3d_TMF_TriedronPers - object behaves like trihedron.
508   //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means:
509   //! -   X = 0.0, Y = 0.0 - center of view window;
510   //! -   X > 0.0, Y > 0.0 - right upper corner of view window;
511   //! -   X > 0.0, Y < 0.0 - right lower corner of view window;
512   //! -   X < 0.0, Y > 0.0 - left  upper corner of view window;
513   //! -   X < 0.0, Y < 0.0 - left  lower corner of view window.
514   //! And Z coordinate defines the gap from border of view window (except center position).
515   Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
516   void SetTransformPersistence (const Graphic3d_TransModeFlags theMode, const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
517   {
518     SetTransformPersistence (Graphic3d_TransformPers::FromDeprecatedParams (theMode, thePoint));
519   }
520
521   //! Gets  Transform  Persistence Mode  for  this  object
522   Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
523   Graphic3d_TransModeFlags GetTransformPersistenceMode() const
524   {
525     return myTransformPersistence.IsNull()
526          ? Graphic3d_TMF_None
527          : myTransformPersistence->Mode();
528   }
529
530   //! Gets  point  of  transform  persistence for  this  object
531   Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
532   Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
533
534   //! Get value of the flag "propagate visual state"
535   //! It means that the display/erase/color visual state is propagated automatically to all children;
536   //! by default, the flag is true 
537   Standard_Boolean ToPropagateVisualState() const { return myToPropagateVisualState; }
538
539   //! Change the value of the flag "propagate visual state"
540   void SetPropagateVisualState(const Standard_Boolean theFlag) { myToPropagateVisualState = theFlag; }
541
542 protected:
543
544   //! Recomputes all presentations of the object.
545   Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
546   void Update (Standard_Boolean theToIncludeHidden = Standard_False)
547   {
548     SetToUpdate();
549     UpdatePresentations (theToIncludeHidden);
550   }
551
552   //! Recomputes the presentation in the given mode.
553   //! @param theMode presentation (display mode) to recompute
554   //! @param theToClearOther when TRUE, other presentations (display modes) will be removed
555   Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
556   Standard_EXPORT void Update (Standard_Integer theMode, Standard_Boolean theToClearOther);
557
558 protected:
559
560   PrsMgr_PresentableObject*              myParent;                  //!< pointer to the parent object
561   PrsMgr_Presentations                   myPresentations;           //!< list of presentations
562   Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;              //!< sequence of object-specific clipping planes
563   Handle(Prs3d_Drawer)                   myDrawer;                  //!< main presentation attributes
564   Handle(Prs3d_Drawer)                   myHilightDrawer;           //!< (optional) custom presentation attributes for highlighting selected object
565   Handle(Prs3d_Drawer)                   myDynHilightDrawer;        //!< (optional) custom presentation attributes for highlighting detected object
566   Handle(Graphic3d_TransformPers)        myTransformPersistence;    //!< transformation persistence
567   Handle(Geom_Transformation)            myLocalTransformation;     //!< local transformation relative to parent object
568   Handle(Geom_Transformation)            myTransformation;          //!< absolute transformation of this object (combined parents + local transformations)
569   Handle(Geom_Transformation)            myCombinedParentTransform; //!< transformation of parent object (combined for all parents)
570   PrsMgr_ListOfPresentableObjects        myChildren;                //!< list of children
571   gp_GTrsf                               myInvTransformation;       //!< inversion of absolute transformation (combined parents + local transformations)
572   PrsMgr_TypeOfPresentation3d            myTypeOfPresentation3d;    //!< presentation type
573
574   Aspect_TypeOfFacingModel               myCurrentFacingModel;      //!< current facing model
575   Standard_ShortReal                     myOwnWidth;                //!< custom width value
576   Standard_Boolean                       hasOwnColor;               //!< own color flag
577   Standard_Boolean                       hasOwnMaterial;            //!< own material flag
578
579   Standard_Boolean                       myInfiniteState;           //!< infinite flag
580   Standard_Boolean                       myIsMutable;               //!< mutable flag
581   Standard_Boolean                       myHasOwnPresentations;     //!< flag indicating if object should have own presentations
582
583   Standard_Boolean                       myToPropagateVisualState;  //!< flag indicating if visual state (display/erase/color) should be propagated to all children
584 };
585
586 DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, Standard_Transient)
587
588 #endif // _PrsMgr_PresentableObject_HeaderFile