Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-11 09:18:56

0001 // Created on: 1995-01-25
0002 // Created by: Jean-Louis Frenkel
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _PrsMgr_PresentableObject_HeaderFile
0018 #define _PrsMgr_PresentableObject_HeaderFile
0019 
0020 #include <Aspect_TypeOfFacingModel.hxx>
0021 #include <gp_GTrsf.hxx>
0022 #include <Graphic3d_ClipPlane.hxx>
0023 #include <Prs3d_Drawer.hxx>
0024 #include <PrsMgr_ListOfPresentableObjects.hxx>
0025 #include <PrsMgr_Presentation.hxx>
0026 #include <NCollection_Sequence.hxx>
0027 #include <PrsMgr_DisplayStatus.hxx>
0028 #include <PrsMgr_TypeOfPresentation3d.hxx>
0029 #include <Standard_Integer.hxx>
0030 #include <NCollection_List.hxx>
0031 class PrsMgr_Presentation;
0032 
0033 class PrsMgr_PresentationManager;
0034 
0035 //! A framework to supply the Graphic3d structure of the object to be presented.
0036 //! On the first display request, this structure is created by calling the appropriate algorithm and
0037 //! retaining this framework for further display. This abstract framework is inherited in
0038 //! Application Interactive Services (AIS), notably by AIS_InteractiveObject. Consequently, 3D
0039 //! presentation should be handled by the relevant daughter classes and their member functions in
0040 //! AIS. This is particularly true in the creation of new interactive objects.
0041 //!
0042 //! Key interface methods to be implemented by every Selectable Object:
0043 //! - AcceptDisplayMode() accepting display modes implemented by this object;
0044 //! - Compute() computing presentation for the given display mode index.
0045 //!
0046 //! Warning! Methods managing standard attributes (SetColor(), SetWidth(), SetMaterial()) have
0047 //! different meaning for objects of different type (or no meaning at all). Sub-classes might
0048 //! override these methods to modify Prs3d_Drawer or class properties providing a convenient
0049 //! short-cut depending on application needs. For more sophisticated configuring, Prs3d_Drawer
0050 //! should be modified directly, while short-cuts might be left unimplemented.
0051 class PrsMgr_PresentableObject : public Standard_Transient
0052 {
0053   DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient)
0054   friend class PrsMgr_Presentation;
0055   friend class PrsMgr_PresentationManager;
0056 
0057 public:
0058   //! Return presentations.
0059   NCollection_Sequence<occ::handle<PrsMgr_Presentation>>& Presentations()
0060   {
0061     return myPresentations;
0062   }
0063 
0064   //! Get ID of Z layer for main presentation.
0065   Graphic3d_ZLayerId ZLayer() const { return myDrawer->ZLayer(); }
0066 
0067   //! Set Z layer ID and update all presentations of the presentable object.
0068   //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower
0069   //! layers.
0070   Standard_EXPORT virtual void SetZLayer(const Graphic3d_ZLayerId theLayerId);
0071 
0072   //! Returns true if object has mutable nature (content or location are be changed regularly).
0073   //! Mutable object will be managed in different way than static onces (another optimizations).
0074   bool IsMutable() const { return myIsMutable; }
0075 
0076   //! Sets if the object has mutable nature (content or location will be changed regularly).
0077   //! This method should be called before object displaying to take effect.
0078   Standard_EXPORT virtual void SetMutable(const bool theIsMutable);
0079 
0080   //! Return view affinity mask.
0081   const occ::handle<Graphic3d_ViewAffinity>& ViewAffinity() const { return myViewAffinity; }
0082 
0083   //! Returns true if the Interactive Object has display mode setting overriding global setting
0084   //! (within Interactive Context).
0085   bool HasDisplayMode() const { return myDrawer->DisplayMode() != -1; }
0086 
0087   //! Returns the display mode setting of the Interactive Object.
0088   //! The range of supported display mode indexes should be specified within object definition and
0089   //! filtered by AccepDisplayMode().
0090   //! @sa AcceptDisplayMode()
0091   int DisplayMode() const { return myDrawer->DisplayMode(); }
0092 
0093   //! Sets the display mode for the interactive object.
0094   //! An object can have its own temporary display mode, which is different from that proposed by
0095   //! the interactive context.
0096   //! @sa AcceptDisplayMode()
0097   void SetDisplayMode(const int theMode)
0098   {
0099     if (AcceptDisplayMode(theMode))
0100     {
0101       myDrawer->SetDisplayMode(theMode);
0102     }
0103   }
0104 
0105   //! Removes display mode settings from the interactive object.
0106   void UnsetDisplayMode() { myDrawer->SetDisplayMode(-1); }
0107 
0108   //! Returns true if the Interactive Object is in highlight mode.
0109   //! @sa HilightAttributes()
0110   bool HasHilightMode() const
0111   {
0112     return !myHilightDrawer.IsNull() && myHilightDrawer->DisplayMode() != -1;
0113   }
0114 
0115   //! Returns highlight display mode.
0116   //! This is obsolete method for backward compatibility - use ::HilightAttributes() and
0117   //! ::DynamicHilightAttributes() instead.
0118   //! @sa HilightAttributes()
0119   int HilightMode() const
0120   {
0121     return !myHilightDrawer.IsNull() ? myHilightDrawer->DisplayMode() : -1;
0122   }
0123 
0124   //! Sets highlight display mode.
0125   //! This is obsolete method for backward compatibility - use ::HilightAttributes() and
0126   //! ::DynamicHilightAttributes() instead.
0127   //! @sa HilightAttributes()
0128   Standard_EXPORT void SetHilightMode(const int theMode);
0129 
0130   //! Unsets highlight display mode.
0131   //! @sa HilightAttributes()
0132   void UnsetHilightMode()
0133   {
0134     if (!myHilightDrawer.IsNull())
0135     {
0136       myHilightDrawer->SetDisplayMode(-1);
0137     }
0138     if (!myDynHilightDrawer.IsNull())
0139     {
0140       myDynHilightDrawer->SetDisplayMode(-1);
0141     }
0142   }
0143 
0144   //! Returns true if the class of objects accepts specified display mode index.
0145   //! The interactive context can have a default mode of representation for the set of Interactive
0146   //! Objects. This mode may not be accepted by a given class of objects. Consequently, this virtual
0147   //! method allowing us to get information about the class in question must be implemented. At
0148   //! least one display mode index should be accepted by this method. Although subclass can leave
0149   //! default implementation, it is highly desired defining exact list of supported modes instead,
0150   //! which is usually an enumeration for one object or objects class sharing similar list of
0151   //! display modes.
0152   virtual bool AcceptDisplayMode(const int theMode) const
0153   {
0154     (void)theMode;
0155     return true;
0156   }
0157 
0158   //! Returns the default display mode.
0159   virtual int DefaultDisplayMode() const { return 0; }
0160 
0161   //! Returns TRUE if any active presentation has invalidation flag.
0162   //! @param theToIncludeHidden when TRUE, also checks hidden presentations
0163   Standard_EXPORT bool ToBeUpdated(bool theToIncludeHidden = false) const;
0164 
0165   //! Flags presentation to be updated; UpdatePresentations() will recompute these presentations.
0166   //! @param theMode presentation (display mode) to invalidate, or -1 to invalidate them all
0167   Standard_EXPORT void SetToUpdate(int theMode);
0168 
0169   //! flags all the Presentations to be Updated.
0170   void SetToUpdate() { SetToUpdate(-1); }
0171 
0172   //! Returns true if the interactive object is infinite; FALSE by default.
0173   //! This flag affects various operations operating on bounding box of graphic presentations of
0174   //! this object. For instance, infinite objects are not taken in account for View FitAll. This
0175   //! does not necessarily means that object is actually infinite, auxiliary objects might be also
0176   //! marked with this flag to achieve desired behavior.
0177   bool IsInfinite() const { return myInfiniteState; }
0178 
0179   //! Sets if object should be considered as infinite.
0180   Standard_EXPORT void SetInfiniteState(const bool theFlag = true);
0181 
0182   //! Returns information on whether the object accepts display in HLR mode or not.
0183   PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; }
0184 
0185   //! Set type of presentation.
0186   Standard_EXPORT void SetTypeOfPresentation(const PrsMgr_TypeOfPresentation3d theType);
0187 
0188   //! Return presentation display status; PrsMgr_DisplayStatus_None by default.
0189   PrsMgr_DisplayStatus DisplayStatus() const { return myDisplayStatus; }
0190 
0191 public: //! @name presentation attributes
0192   //! Returns the attributes settings.
0193   const occ::handle<Prs3d_Drawer>& Attributes() const { return myDrawer; }
0194 
0195   //! Initializes the drawing tool theDrawer.
0196   virtual void SetAttributes(const occ::handle<Prs3d_Drawer>& theDrawer) { myDrawer = theDrawer; }
0197 
0198   //! Returns the hilight attributes settings.
0199   //! When not NULL, overrides both Prs3d_TypeOfHighlight_LocalSelected and
0200   //! Prs3d_TypeOfHighlight_Selected defined within AIS_InteractiveContext::HighlightStyle().
0201   //! @sa AIS_InteractiveContext::HighlightStyle()
0202   const occ::handle<Prs3d_Drawer>& HilightAttributes() const { return myHilightDrawer; }
0203 
0204   //! Initializes the hilight drawing tool theDrawer.
0205   virtual void SetHilightAttributes(const occ::handle<Prs3d_Drawer>& theDrawer)
0206   {
0207     myHilightDrawer = theDrawer;
0208   }
0209 
0210   //! Returns the hilight attributes settings.
0211   //! When not NULL, overrides both Prs3d_TypeOfHighlight_LocalDynamic and
0212   //! Prs3d_TypeOfHighlight_Dynamic defined within AIS_InteractiveContext::HighlightStyle().
0213   //! @sa AIS_InteractiveContext::HighlightStyle()
0214   const occ::handle<Prs3d_Drawer>& DynamicHilightAttributes() const { return myDynHilightDrawer; }
0215 
0216   //! Initializes the dynamic hilight drawing tool.
0217   virtual void SetDynamicHilightAttributes(const occ::handle<Prs3d_Drawer>& theDrawer)
0218   {
0219     myDynHilightDrawer = theDrawer;
0220   }
0221 
0222   //! Clears settings provided by the hilight drawing tool theDrawer.
0223   virtual void UnsetHilightAttributes() { myHilightDrawer.Nullify(); }
0224 
0225   //! Synchronize presentation aspects after their modification.
0226   //!
0227   //! This method should be called after modifying primitive aspect properties (material, texture,
0228   //! shader) so that modifications will take effect on already computed presentation groups (thus
0229   //! avoiding re-displaying the object).
0230   Standard_EXPORT void SynchronizeAspects();
0231 
0232 public: //! @name object transformation
0233   //! Returns Transformation Persistence defining a special Local Coordinate system where this
0234   //! presentable object is located or NULL handle if not defined. Position of the object having
0235   //! Transformation Persistence is mutable and depends on camera position. The same applies to a
0236   //! bounding box of the object.
0237   //! @sa Graphic3d_TransformPers class description
0238   const occ::handle<Graphic3d_TransformPers>& TransformPersistence() const
0239   {
0240     return myTransformPersistence;
0241   }
0242 
0243   //! Sets up Transform Persistence defining a special Local Coordinate system where this object
0244   //! should be located. Note that management of Transform Persistence object is more expensive than
0245   //! of the normal one, because it requires its position being recomputed basing on camera position
0246   //! within each draw call / traverse.
0247   //! @sa Graphic3d_TransformPers class description
0248   Standard_EXPORT virtual void SetTransformPersistence(
0249     const occ::handle<Graphic3d_TransformPers>& theTrsfPers);
0250 
0251   //! Return the local transformation.
0252   //! Note that the local transformation of the object having Transformation Persistence
0253   //! is applied within Local Coordinate system defined by this Persistence.
0254   const occ::handle<TopLoc_Datum3D>& LocalTransformationGeom() const
0255   {
0256     return myLocalTransformation;
0257   }
0258 
0259   //! Sets local transformation to theTransformation.
0260   //! Note that the local transformation of the object having Transformation Persistence
0261   //! is applied within Local Coordinate system defined by this Persistence.
0262   void SetLocalTransformation(const gp_Trsf& theTrsf)
0263   {
0264     setLocalTransformation(new TopLoc_Datum3D(theTrsf));
0265   }
0266 
0267   //! Sets local transformation to theTransformation.
0268   //! Note that the local transformation of the object having Transformation Persistence
0269   //! is applied within Local Coordinate system defined by this Persistence.
0270   void SetLocalTransformation(const occ::handle<TopLoc_Datum3D>& theTrsf)
0271   {
0272     setLocalTransformation(theTrsf);
0273   }
0274 
0275   //! Returns true if object has a transformation that is different from the identity.
0276   bool HasTransformation() const
0277   {
0278     return !myTransformation.IsNull() && myTransformation->Form() != gp_Identity;
0279   }
0280 
0281   //! Return the transformation taking into account transformation of parent object(s).
0282   //! Note that the local transformation of the object having Transformation Persistence
0283   //! is applied within Local Coordinate system defined by this Persistence.
0284   const occ::handle<TopLoc_Datum3D>& TransformationGeom() const { return myTransformation; }
0285 
0286   //! Return the local transformation.
0287   //! Note that the local transformation of the object having Transformation Persistence
0288   //! is applied within Local Coordinate system defined by this Persistence.
0289   const gp_Trsf& LocalTransformation() const
0290   {
0291     return !myLocalTransformation.IsNull() ? myLocalTransformation->Trsf() : getIdentityTrsf();
0292   }
0293 
0294   //! Return the transformation taking into account transformation of parent object(s).
0295   //! Note that the local transformation of the object having Transformation Persistence
0296   //! is applied within Local Coordinate system defined by this Persistence.
0297   const gp_Trsf& Transformation() const
0298   {
0299     return !myTransformation.IsNull() ? myTransformation->Trsf() : getIdentityTrsf();
0300   }
0301 
0302   //! Return inversed transformation.
0303   const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
0304 
0305   //! Return combined parent transformation.
0306   const occ::handle<TopLoc_Datum3D>& CombinedParentTransformation() const
0307   {
0308     return myCombinedParentTransform;
0309   }
0310 
0311   //! resets local transformation to identity.
0312   Standard_EXPORT virtual void ResetTransformation();
0313 
0314   //! Updates final transformation (parent + local) of presentable object and its presentations.
0315   Standard_EXPORT virtual void UpdateTransformation();
0316 
0317   //! Calculates object presentation for specific camera position.
0318   //! Each of the views in the viewer and every modification such as rotation, for example, entails
0319   //! recalculation.
0320   //! @param theProjector [in] view orientation
0321   virtual void RecomputeTransformation(const occ::handle<Graphic3d_Camera>& theProjector)
0322   {
0323     (void)theProjector;
0324   }
0325 
0326 public: //! @name clipping planes
0327   //! Get clip planes.
0328   //! @return set of previously added clip planes for all display mode presentations.
0329   const occ::handle<Graphic3d_SequenceOfHClipPlane>& ClipPlanes() const { return myClipPlanes; }
0330 
0331   //! Set clip planes for graphical clipping for all display mode presentations.
0332   //! The composition of clip planes truncates the rendering space to convex volume.
0333   //! Please be aware that number of supported clip plane is limited.
0334   //! The planes which exceed the limit are ignored.
0335   //! Besides of this, some planes can be already set in view where the object is shown:
0336   //! the number of these planes should be subtracted from limit to predict the maximum
0337   //! possible number of object clipping planes.
0338   Standard_EXPORT virtual void SetClipPlanes(
0339     const occ::handle<Graphic3d_SequenceOfHClipPlane>& thePlanes);
0340 
0341   //! Adds clip plane for graphical clipping for all display mode
0342   //! presentations. The composition of clip planes truncates the rendering
0343   //! space to convex volume. Please be aware that number of supported
0344   //! clip plane is limited. The planes which exceed the limit are ignored.
0345   //! Besides of this, some planes can be already set in view where the object
0346   //! is shown: the number of these planes should be subtracted from limit
0347   //! to predict the maximum possible number of object clipping planes.
0348   //! @param[in] thePlane  the clip plane to be appended to map of clip planes.
0349   Standard_EXPORT virtual void AddClipPlane(const occ::handle<Graphic3d_ClipPlane>& thePlane);
0350 
0351   //! Removes previously added clip plane.
0352   //! @param[in] thePlane  the clip plane to be removed from map of clip planes.
0353   Standard_EXPORT virtual void RemoveClipPlane(const occ::handle<Graphic3d_ClipPlane>& thePlane);
0354 
0355 public: //! @name parent/children properties
0356   //! Returns parent of current object in scene hierarchy.
0357   PrsMgr_PresentableObject* Parent() const { return myParent; }
0358 
0359   //! Returns children of the current object.
0360   const NCollection_List<occ::handle<PrsMgr_PresentableObject>>& Children() const
0361   {
0362     return myChildren;
0363   }
0364 
0365   //! Makes theObject child of current object in scene hierarchy.
0366   Standard_EXPORT virtual void AddChild(const occ::handle<PrsMgr_PresentableObject>& theObject);
0367 
0368   //! Makes theObject child of current object in scene hierarchy with keeping the current global
0369   //! transformation So the object keeps the same position/orientation in the global CS.
0370   Standard_EXPORT void AddChildWithCurrentTransformation(
0371     const occ::handle<PrsMgr_PresentableObject>& theObject);
0372 
0373   //! Removes theObject from children of current object in scene hierarchy.
0374   Standard_EXPORT virtual void RemoveChild(const occ::handle<PrsMgr_PresentableObject>& theObject);
0375 
0376   //! Removes theObject from children of current object in scene hierarchy with keeping the current
0377   //! global transformation. So the object keeps the same position/orientation in the global CS.
0378   Standard_EXPORT void RemoveChildWithRestoreTransformation(
0379     const occ::handle<PrsMgr_PresentableObject>& theObject);
0380 
0381   //! Returns true if object should have own presentations.
0382   bool HasOwnPresentations() const { return myHasOwnPresentations; }
0383 
0384   //! Returns bounding box of object correspondingly to its current display mode.
0385   //! This method requires presentation to be already computed, since it relies on bounding box of
0386   //! presentation structures, which are supposed to be same/close amongst different display modes
0387   //! of this object.
0388   Standard_EXPORT virtual void BoundingBox(Bnd_Box& theBndBox);
0389 
0390 protected: //! @name interface methods
0391   //! Protected empty constructor.
0392   Standard_EXPORT PrsMgr_PresentableObject(
0393     const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
0394 
0395   //! Destructor.
0396   Standard_EXPORT ~PrsMgr_PresentableObject() override;
0397 
0398   //! Fills the given 3D view presentation for specified display mode using Compute() method.
0399   //! In addition, configures other properties of presentation (transformation, clipping planes).
0400   //! @param thePrsMgr presentation manager where presentation has been created
0401   //! @param thePrs    presentation to fill
0402   //! @param theMode   display mode to compute; can be any number accepted by AcceptDisplayMode()
0403   //! method
0404   Standard_EXPORT virtual void Fill(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0405                                     const occ::handle<PrsMgr_Presentation>&        thePrs,
0406                                     const int                                      theMode);
0407 
0408   //! Calculates the 3D view presentation for specified display mode.
0409   //! This is a key interface for implementing Presentable Object interface.
0410   //! @param thePrsMgr presentation manager where presentation has been created
0411   //! @param thePrs    presentation to fill
0412   //! @param theMode   display mode to compute; can be any number accepted by AcceptDisplayMode()
0413   //! method
0414   //! @sa AcceptDisplayMode()
0415   Standard_EXPORT virtual void Compute(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0416                                        const occ::handle<Prs3d_Presentation>&         thePrs,
0417                                        const int                                      theMode) = 0;
0418 
0419   //! Calculates hidden line removal presentation for specific camera position.
0420   //! Each of the views in the viewer and every modification such as rotation, for example, entails
0421   //! recalculation. Default implementation throws Standard_NotImplemented exception Warning! The
0422   //! transformation must be applied to the object before computation.
0423   //! @param[in] theProjector  view orientation
0424   //! @param[in] theTrsf  additional transformation, or NULL if undefined
0425   //! @param[in] thePrs   presentation to fill
0426   Standard_EXPORT virtual void computeHLR(const occ::handle<Graphic3d_Camera>&   theProjector,
0427                                           const occ::handle<TopLoc_Datum3D>&     theTrsf,
0428                                           const occ::handle<Prs3d_Presentation>& thePrs);
0429 
0430   //! Recomputes invalidated presentations of the object.
0431   //! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated
0432   //! @return TRUE if some presentations were recomputed
0433   Standard_EXPORT bool UpdatePresentations(bool theToIncludeHidden = false);
0434 
0435   //! General virtual method for internal update of presentation state
0436   //! when some modifications on list of clip planes occurs. Base
0437   //! implementation propagate clip planes to every presentation.
0438   Standard_EXPORT virtual void UpdateClipping();
0439 
0440   //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
0441   //! from parent node and able to derive its own.
0442   Standard_EXPORT virtual void SetCombinedParentTransform(
0443     const occ::handle<TopLoc_Datum3D>& theTrsf);
0444 
0445   //! Sets local transformation to theTransformation.
0446   Standard_EXPORT virtual void setLocalTransformation(
0447     const occ::handle<TopLoc_Datum3D>& theTransformation);
0448 
0449   //! Return the identity transformation.
0450   Standard_EXPORT static const gp_Trsf& getIdentityTrsf();
0451 
0452   //! Recompute computed (HLR) presentations (when view is in computed mode).
0453   Standard_EXPORT void recomputeComputed() const;
0454 
0455   //! Replace aspects of existing (computed) presentation groups,
0456   //! so that the new aspects can be applied without recomputing presentation.
0457   //! It is NOT recommended approach, because user has to fill such map and then search for each
0458   //! occurrence in computed groups. The recommended approach is computing presentation with
0459   //! necessary customized aspects, and then modify them directly followed by SynchronizeAspects()
0460   //! call.
0461   Standard_EXPORT void replaceAspects(
0462     const NCollection_DataMap<occ::handle<Graphic3d_Aspects>, occ::handle<Graphic3d_Aspects>>&
0463       theMap);
0464 
0465 public: //! @name simplified presentation properties API
0466   //! Enables or disables on-triangulation build of isolines according to the flag given.
0467   void SetIsoOnTriangulation(const bool theIsEnabled)
0468   {
0469     myDrawer->SetIsoOnTriangulation(theIsEnabled);
0470   }
0471 
0472   //! Returns the current facing model which is in effect.
0473   Aspect_TypeOfFacingModel CurrentFacingModel() const { return myCurrentFacingModel; }
0474 
0475   //! change the current facing model apply on polygons for SetColor(), SetTransparency(),
0476   //! SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE. This mean that attributes
0477   //! is applying both on the front and back face.
0478   void SetCurrentFacingModel(const Aspect_TypeOfFacingModel theModel = Aspect_TOFM_BOTH_SIDE)
0479   {
0480     myCurrentFacingModel = theModel;
0481   }
0482 
0483   //! Returns true if the Interactive Object has color.
0484   bool HasColor() const { return hasOwnColor; }
0485 
0486   //! Returns the color setting of the Interactive Object.
0487   virtual void Color(Quantity_Color& theColor) const { theColor = myDrawer->Color(); }
0488 
0489   //! Only the interactive object knowns which Drawer attribute is affected by the color, if any
0490   //! (ex: for a wire,it's the wireaspect field of the drawer, but for a vertex, only the point
0491   //! aspect field is affected by the color). WARNING : Do not forget to set the corresponding
0492   //! fields here (hasOwnColor and myDrawer->SetColor())
0493   virtual void SetColor(const Quantity_Color& theColor)
0494   {
0495     myDrawer->SetColor(theColor);
0496     hasOwnColor = true;
0497   }
0498 
0499   //! Removes color settings. Only the Interactive Object
0500   //! knows which Drawer attribute is affected by the color
0501   //! setting. For a wire, for example, wire aspect is the
0502   //! attribute affected. For a vertex, however, only point
0503   //! aspect is affected by the color setting.
0504   virtual void UnsetColor() { hasOwnColor = false; }
0505 
0506   //! Returns true if the Interactive Object has width.
0507   bool HasWidth() const { return myOwnWidth != 0.0f; }
0508 
0509   //! Returns the width setting of the Interactive Object.
0510   double Width() const { return myOwnWidth; }
0511 
0512   //! Allows you to provide the setting aValue for width.
0513   //! Only the Interactive Object knows which Drawer attribute is affected by the width setting.
0514   virtual void SetWidth(const double theWidth) { myOwnWidth = (float)theWidth; }
0515 
0516   //! Reset width to default value.
0517   virtual void UnsetWidth() { myOwnWidth = 0.0f; }
0518 
0519   //! Returns true if the Interactive Object has a setting for material.
0520   bool HasMaterial() const { return hasOwnMaterial; }
0521 
0522   //! Returns the current material setting as enumeration value.
0523   Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const;
0524 
0525   //! Sets the material aMat defining this display attribute
0526   //! for the interactive object.
0527   //! Material aspect determines shading aspect, color and
0528   //! transparency of visible entities.
0529   Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& aName);
0530 
0531   //! Removes the setting for material.
0532   Standard_EXPORT virtual void UnsetMaterial();
0533 
0534   //! Returns true if there is a transparency setting.
0535   bool IsTransparent() const { return myDrawer->Transparency() > 0.005f; }
0536 
0537   //! Returns the transparency setting.
0538   //! This will be between 0.0 and 1.0.
0539   //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
0540   virtual double Transparency() const
0541   {
0542     return (myDrawer->Transparency() <= 0.005f ? 0.0 : myDrawer->Transparency());
0543   }
0544 
0545   //! Attributes a setting aValue for transparency.
0546   //! The transparency value should be between 0.0 and 1.0.
0547   //! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
0548   //! Warning At a value of 1.0, there may be nothing visible.
0549   Standard_EXPORT virtual void SetTransparency(const double aValue = 0.6);
0550 
0551   //! Removes the transparency setting. The object is opaque by default.
0552   Standard_EXPORT virtual void UnsetTransparency();
0553 
0554   //! Returns true if <myDrawer> has non-null shading aspect
0555   Standard_EXPORT virtual bool HasPolygonOffsets() const;
0556 
0557   //! Retrieves current polygon offsets settings from <myDrawer>.
0558   Standard_EXPORT virtual void PolygonOffsets(int& aMode, float& aFactor, float& aUnits) const;
0559 
0560   //! Sets up polygon offsets for this object.
0561   //! @sa Graphic3d_Aspects::SetPolygonOffsets()
0562   Standard_EXPORT virtual void SetPolygonOffsets(const int   aMode,
0563                                                  const float aFactor = 1.0,
0564                                                  const float aUnits  = 0.0);
0565 
0566   //! Clears settings provided by the drawing tool aDrawer.
0567   Standard_EXPORT virtual void UnsetAttributes();
0568 
0569   //! Dumps the content of me into the stream
0570   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0571 
0572 public: //! @name deprecated methods
0573   //! gives the list of modes which are flagged "to be updated".
0574   Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead")
0575   Standard_EXPORT void ToBeUpdated(NCollection_List<int>& ListOfMode) const;
0576 
0577   //! Get value of the flag "propagate visual state"
0578   //! It means that the display/erase/color visual state is propagated automatically to all
0579   //! children; by default, the flag is true
0580   bool ToPropagateVisualState() const { return myToPropagateVisualState; }
0581 
0582   //! Change the value of the flag "propagate visual state"
0583   void SetPropagateVisualState(const bool theFlag) { myToPropagateVisualState = theFlag; }
0584 
0585 protected:
0586   //! Recomputes all presentations of the object.
0587   Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be "
0588                       "called instead")
0589   void Update(bool theToIncludeHidden = false)
0590   {
0591     SetToUpdate();
0592     UpdatePresentations(theToIncludeHidden);
0593   }
0594 
0595   //! Recomputes the presentation in the given mode.
0596   //! @param theMode presentation (display mode) to recompute
0597   //! @param theToClearOther when TRUE, other presentations (display modes) will be removed
0598   Standard_DEPRECATED(
0599     "This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead")
0600   Standard_EXPORT void Update(int theMode, bool theToClearOther);
0601 
0602 protected:
0603   // clang-format off
0604   PrsMgr_PresentableObject*              myParent;                  //!< pointer to the parent object
0605   NCollection_Sequence<occ::handle<PrsMgr_Presentation>>                   myPresentations;           //!< list of presentations
0606   occ::handle<Graphic3d_ViewAffinity>         myViewAffinity;            //!< view affinity mask
0607   occ::handle<Graphic3d_SequenceOfHClipPlane> myClipPlanes;              //!< sequence of object-specific clipping planes
0608   occ::handle<Prs3d_Drawer>                   myDrawer;                  //!< main presentation attributes
0609   occ::handle<Prs3d_Drawer>                   myHilightDrawer;           //!< (optional) custom presentation attributes for highlighting selected object
0610   occ::handle<Prs3d_Drawer>                   myDynHilightDrawer;        //!< (optional) custom presentation attributes for highlighting detected object
0611   occ::handle<Graphic3d_TransformPers>        myTransformPersistence;    //!< transformation persistence
0612   occ::handle<TopLoc_Datum3D>                 myLocalTransformation;     //!< local transformation relative to parent object
0613   occ::handle<TopLoc_Datum3D>                 myTransformation;          //!< absolute transformation of this object (combined parents + local transformations)
0614   occ::handle<TopLoc_Datum3D>                 myCombinedParentTransform; //!< transformation of parent object (combined for all parents)
0615   NCollection_List<occ::handle<PrsMgr_PresentableObject>>        myChildren;                //!< list of children
0616   gp_GTrsf                               myInvTransformation;       //!< inversion of absolute transformation (combined parents + local transformations)
0617   PrsMgr_TypeOfPresentation3d            myTypeOfPresentation3d;    //!< presentation type
0618   PrsMgr_DisplayStatus                   myDisplayStatus;           //!< presentation display status
0619 
0620   Aspect_TypeOfFacingModel               myCurrentFacingModel;      //!< current facing model
0621   float                     myOwnWidth;                //!< custom width value
0622   bool                       hasOwnColor;               //!< own color flag
0623   bool                       hasOwnMaterial;            //!< own material flag
0624 
0625   bool                       myInfiniteState;           //!< infinite flag
0626   bool                       myIsMutable;               //!< mutable flag
0627   bool                       myHasOwnPresentations;     //!< flag indicating if object should have own presentations
0628 
0629   bool                       myToPropagateVisualState;  //!< flag indicating if visual state (display/erase/color) should be propagated to all children
0630   // clang-format on
0631 };
0632 
0633 #endif // _PrsMgr_PresentableObject_HeaderFile