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