0031431: Visualization, PrsMgr_PresentableObject - simplify HLR computing interface
[occt.git] / src / PrsMgr / PrsMgr_PresentableObject.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-01-25
2// Created by: Jean-Louis Frenkel
3// Copyright (c) 1995-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _PrsMgr_PresentableObject_HeaderFile
18#define _PrsMgr_PresentableObject_HeaderFile
19
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 34class PrsMgr_PresentationManager;
35typedef 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 50class 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 55public:
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
164public: //! @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
195public: //! @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 258public: //! @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 287public: //! @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
52c38ce1 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
42cf5bc1 302 //! Removes theObject from children of current object in scene hierarchy.
303 Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
be5c3602 304
52c38ce1 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
42cf5bc1 309 //! Returns true if object should have own presentations.
3202bf1e 310 Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; }
be5c3602 311
2b886265 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);
42cf5bc1 316
2b886265 317protected: //! @name interface methods
42cf5bc1 318
2b886265 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
b5163d2f 344 //! Calculates hidden line removal presentation for specific camera position.
2b886265 345 //! Each of the views in the viewer and every modification such as rotation, for example, entails recalculation.
b5163d2f 346 //! Default implementation throws Standard_NotImplemented exception
2b886265 347 //! Warning! The transformation must be applied to the object before computation.
b5163d2f 348 //! @param theProjector [in] view orientation
349 //! @param theTrsf [in] additional transformation, or NULL if undefined
350 //! @param thePrs [in] presentation to fill
351 Standard_EXPORT virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
352 const Handle(Geom_Transformation)& theTrsf,
353 const Handle(Prs3d_Presentation)& thePrs);
2b886265 354
355 //! Recomputes invalidated presentations of the object.
356 //! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated
357 //! @return TRUE if some presentations were recomputed
358 Standard_EXPORT Standard_Boolean UpdatePresentations (Standard_Boolean theToIncludeHidden = Standard_False);
359
360 //! General virtual method for internal update of presentation state
361 //! when some modifications on list of clip planes occurs. Base
362 //! implementation propagate clip planes to every presentation.
363 Standard_EXPORT virtual void UpdateClipping();
364
365 //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
366 //! from parent node and able to derive its own.
367 Standard_EXPORT virtual void SetCombinedParentTransform (const Handle(Geom_Transformation)& theTrsf);
368
369 //! Sets local transformation to theTransformation.
370 Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTransformation);
371
372 //! Return the identity transformation.
373 Standard_EXPORT static const gp_Trsf& getIdentityTrsf();
374
375 //! Recompute computed (HLR) presentations (when view is in computed mode).
376 Standard_EXPORT void recomputeComputed() const;
377
378 //! Replace aspects of existing (computed) presentation groups,
379 //! so that the new aspects can be applied without recomputing presentation.
380 //! It is NOT recommended approach, because user has to fill such map and then search for each occurrence in computed groups.
381 //! The recommended approach is computing presentation with necessary customized aspects,
382 //! and then modify them directly followed by SynchronizeAspects() call.
383 Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap);
384
385public: //! @name simplified presentation properties API
386
387 //! Enables or disables on-triangulation build of isolines according to the flag given.
388 void SetIsoOnTriangulation (const Standard_Boolean theIsEnabled) { myDrawer->SetIsoOnTriangulation (theIsEnabled); }
389
390 //! Returns the current facing model which is in effect.
391 Aspect_TypeOfFacingModel CurrentFacingModel() const { return myCurrentFacingModel; }
392
393 //! change the current facing model apply on polygons for SetColor(), SetTransparency(), SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE.
394 //! This mean that attributes is applying both on the front and back face.
395 void SetCurrentFacingModel (const Aspect_TypeOfFacingModel theModel = Aspect_TOFM_BOTH_SIDE) { myCurrentFacingModel = theModel; }
396
397 //! Returns true if the Interactive Object has color.
398 Standard_Boolean HasColor() const { return hasOwnColor; }
399
400 //! Returns the color setting of the Interactive Object.
401 virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); }
402
403 //! Only the interactive object knowns which Drawer attribute is affected by the color, if any
404 //! (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).
405 //! WARNING : Do not forget to set the corresponding fields here (hasOwnColor and myDrawer->SetColor())
406 virtual void SetColor (const Quantity_Color& theColor)
f838dac4 407 {
2b886265 408 myDrawer->SetColor (theColor);
409 hasOwnColor = Standard_True;
f838dac4 410 }
411
2b886265 412 //! Removes color settings. Only the Interactive Object
413 //! knows which Drawer attribute is affected by the color
414 //! setting. For a wire, for example, wire aspect is the
415 //! attribute affected. For a vertex, however, only point
416 //! aspect is affected by the color setting.
417 virtual void UnsetColor() { hasOwnColor = Standard_False; }
418
419 //! Returns true if the Interactive Object has width.
420 Standard_Boolean HasWidth() const { return myOwnWidth != 0.0f; }
421
422 //! Returns the width setting of the Interactive Object.
423 Standard_Real Width() const { return myOwnWidth; }
424
425 //! Allows you to provide the setting aValue for width.
426 //! Only the Interactive Object knows which Drawer attribute is affected by the width setting.
427 virtual void SetWidth (const Standard_Real theWidth) { myOwnWidth = (Standard_ShortReal )theWidth; }
428
429 //! Reset width to default value.
430 virtual void UnsetWidth() { myOwnWidth = 0.0f; }
431
432 //! Returns true if the Interactive Object has a setting for material.
433 Standard_Boolean HasMaterial() const { return hasOwnMaterial; }
434
435 //! Returns the current material setting as enumeration value.
436 Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const;
437
438 //! Sets the material aMat defining this display attribute
439 //! for the interactive object.
440 //! Material aspect determines shading aspect, color and
441 //! transparency of visible entities.
442 Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName);
443
444 //! Removes the setting for material.
445 Standard_EXPORT virtual void UnsetMaterial();
446
447 //! Returns true if there is a transparency setting.
448 Standard_Boolean IsTransparent() const { return myDrawer->Transparency() > 0.005f; }
449
450 //! Returns the transparency setting.
451 //! This will be between 0.0 and 1.0.
452 //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
453 virtual Standard_Real Transparency() const { return (myDrawer->Transparency() <= 0.005f ? 0.0 : myDrawer->Transparency()); }
454
455 //! Attributes a setting aValue for transparency.
456 //! The transparency value should be between 0.0 and 1.0.
457 //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
458 //! Warning At a value of 1.0, there may be nothing visible.
459 Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6);
460
461 //! Removes the transparency setting. The object is opaque by default.
462 Standard_EXPORT virtual void UnsetTransparency();
463
464 //! Returns Standard_True if <myDrawer> has non-null shading aspect
465 Standard_EXPORT virtual Standard_Boolean HasPolygonOffsets() const;
466
467 //! Retrieves current polygon offsets settings from <myDrawer>.
468 Standard_EXPORT virtual void PolygonOffsets (Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const;
469
470 //! Sets up polygon offsets for this object.
471 //! @sa Graphic3d_Aspects::SetPolygonOffsets()
472 Standard_EXPORT virtual void SetPolygonOffsets (const Standard_Integer aMode, const Standard_ShortReal aFactor = 1.0, const Standard_ShortReal aUnits = 0.0);
473
474 //! Clears settings provided by the drawing tool aDrawer.
f838dac4 475 Standard_EXPORT virtual void UnsetAttributes();
476
0904aa63 477 //! Dumps the content of me into the stream
bc73b006 478 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0904aa63 479
2b886265 480public: //! @name deprecated methods
f838dac4 481
2b886265 482 //! gives the list of modes which are flagged "to be updated".
483 Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead")
484 Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
f838dac4 485
2b886265 486 Standard_DEPRECATED("This method is deprecated - overload taking Handle should be used instead")
487 void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
488 {
489 Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane (thePlanes);
490 SetClipPlanes (aPlanes);
491 }
f838dac4 492
2b886265 493 //! Sets up Transform Persistence Mode for this object.
494 //! This function used to lock in object position, rotation and / or zooming relative to camera position.
495 //! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag
496 //! - see description later). theMode should be:
497 //! - Graphic3d_TMF_None - no persistence attributes (reset);
498 //! - Graphic3d_TMF_ZoomPers - object doesn't resize;
499 //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
500 //! - Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate;
501 //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
502 //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron.
503 //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means:
504 //! - X = 0.0, Y = 0.0 - center of view window;
505 //! - X > 0.0, Y > 0.0 - right upper corner of view window;
506 //! - X > 0.0, Y < 0.0 - right lower corner of view window;
507 //! - X < 0.0, Y > 0.0 - left upper corner of view window;
508 //! - X < 0.0, Y < 0.0 - left lower corner of view window.
509 //! And Z coordinate defines the gap from border of view window (except center position).
510 Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
511 void SetTransformPersistence (const Graphic3d_TransModeFlags theMode, const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
512 {
513 SetTransformPersistence (Graphic3d_TransformPers::FromDeprecatedParams (theMode, thePoint));
514 }
f838dac4 515
2b886265 516 //! Gets Transform Persistence Mode for this object
517 Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
518 Graphic3d_TransModeFlags GetTransformPersistenceMode() const
519 {
520 return myTransformPersistence.IsNull()
521 ? Graphic3d_TMF_None
522 : myTransformPersistence->Mode();
523 }
42cf5bc1 524
2b886265 525 //! Gets point of transform persistence for this object
526 Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
527 Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
42cf5bc1 528
0d56f743 529 //! Get value of the flag "propagate visual state"
530 //! It means that the display/erase/color visual state is propagated automatically to all children;
531 //! by default, the flag is true
532 Standard_Boolean ToPropagateVisualState() const { return myToPropagateVisualState; }
533
534 //! Change the value of the flag "propagate visual state"
535 void SetPropagateVisualState(const Standard_Boolean theFlag) { myToPropagateVisualState = theFlag; }
536
2b886265 537protected:
226fce20 538
539 //! Recomputes all presentations of the object.
540 Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
541 void Update (Standard_Boolean theToIncludeHidden = Standard_False)
542 {
543 SetToUpdate();
544 UpdatePresentations (theToIncludeHidden);
545 }
546
42cf5bc1 547 //! Recomputes the presentation in the given mode.
226fce20 548 //! @param theMode presentation (display mode) to recompute
549 //! @param theToClearOther when TRUE, other presentations (display modes) will be removed
550 Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
551 Standard_EXPORT void Update (Standard_Integer theMode, Standard_Boolean theToClearOther);
1f7f5a90 552
3202bf1e 553protected:
554
2b886265 555 PrsMgr_PresentableObject* myParent; //!< pointer to the parent object
556 PrsMgr_Presentations myPresentations; //!< list of presentations
557 Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; //!< sequence of object-specific clipping planes
558 Handle(Prs3d_Drawer) myDrawer; //!< main presentation attributes
559 Handle(Prs3d_Drawer) myHilightDrawer; //!< (optional) custom presentation attributes for highlighting selected object
560 Handle(Prs3d_Drawer) myDynHilightDrawer; //!< (optional) custom presentation attributes for highlighting detected object
561 Handle(Graphic3d_TransformPers) myTransformPersistence; //!< transformation persistence
562 Handle(Geom_Transformation) myLocalTransformation; //!< local transformation relative to parent object
563 Handle(Geom_Transformation) myTransformation; //!< absolute transformation of this object (combined parents + local transformations)
564 Handle(Geom_Transformation) myCombinedParentTransform; //!< transformation of parent object (combined for all parents)
565 PrsMgr_ListOfPresentableObjects myChildren; //!< list of children
566 gp_GTrsf myInvTransformation; //!< inversion of absolute transformation (combined parents + local transformations)
567 PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; //!< presentation type
568
569 Aspect_TypeOfFacingModel myCurrentFacingModel; //!< current facing model
570 Standard_ShortReal myOwnWidth; //!< custom width value
571 Standard_Boolean hasOwnColor; //!< own color flag
572 Standard_Boolean hasOwnMaterial; //!< own material flag
573
574 Standard_Boolean myInfiniteState; //!< infinite flag
575 Standard_Boolean myIsMutable; //!< mutable flag
576 Standard_Boolean myHasOwnPresentations; //!< flag indicating if object should have own presentations
42cf5bc1 577
0d56f743 578 Standard_Boolean myToPropagateVisualState; //!< flag indicating if visual state (display/erase/color) should be propagated to all children
42cf5bc1 579};
580
f838dac4 581DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, Standard_Transient)
1f7f5a90 582
42cf5bc1 583#endif // _PrsMgr_PresentableObject_HeaderFile