0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / Prs3d / Prs3d_Drawer.hxx
index 19ba6aa..87030cc 100644 (file)
 
 #include <Standard_Integer.hxx>
 #include <Standard_Boolean.hxx>
-#include <Quantity_Length.hxx>
 #include <Aspect_TypeOfDeflection.hxx>
+#include <Graphic3d_GroupAspect.hxx>
+#include <Graphic3d_PresentationAttributes.hxx>
+#include <Graphic3d_ShaderProgram.hxx>
 #include <Standard_Real.hxx>
 #include <Prs3d_VertexDrawMode.hxx>
 #include <Prs3d_DimensionUnits.hxx>
 #include <Prs3d_TypeOfHLR.hxx>
-#include <MMgt_TShared.hxx>
+#include <Standard_Transient.hxx>
+#include <GeomAbs_Shape.hxx>
 
 class Prs3d_IsoAspect;
 class Prs3d_LineAspect;
@@ -39,15 +42,14 @@ class Prs3d_DatumAspect;
 class Prs3d_DimensionAspect;
 class TCollection_AsciiString;
 
-class Prs3d_Drawer;
-DEFINE_STANDARD_HANDLE(Prs3d_Drawer, MMgt_TShared)
+DEFINE_STANDARD_HANDLE(Prs3d_Drawer, Graphic3d_PresentationAttributes)
 
 //! A graphic attribute manager which governs how
 //! objects such as color, width, line thickness and deflection are displayed.
 //! A drawer includes an instance of the Aspect classes with particular default values.
-class Prs3d_Drawer : public MMgt_TShared
+class Prs3d_Drawer : public Graphic3d_PresentationAttributes
 {
-
+  DEFINE_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes)
 public:
 
   //! Default constructor.
@@ -74,11 +76,11 @@ public:
   //!   Prs3d_DeflectionCurve
   //!   Prs3d_WFDeflectionSurface
   //!   Prs3d_WFDeflectionRestrictedFace
-  Standard_EXPORT void SetMaximalChordialDeviation (const Quantity_Length theChordialDeviation);
+  Standard_EXPORT void SetMaximalChordialDeviation (const Standard_Real theChordialDeviation);
 
   //! Returns the maximal chordal deviation. The default value is 0.1.
   //! Drawings of curves or patches are made with respect to an absolute maximal chordal deviation.
-  Quantity_Length MaximalChordialDeviation() const
+  Standard_Real MaximalChordialDeviation() const
   {
     return HasOwnMaximalChordialDeviation() || myLink.IsNull()
          ? myChordialDeviation
@@ -128,6 +130,20 @@ public:
   //! Returns true if the drawer has IsoOnPlane setting active.
   Standard_Boolean HasOwnIsoOnPlane() const { return myHasOwnIsoOnPlane; }
 
+  //! Returns True if the drawing of isos on triangulation is enabled.
+  Standard_Boolean IsoOnTriangulation() const
+  {
+    return HasOwnIsoOnTriangulation() || myLink.IsNull()
+         ? myIsoOnTriangulation
+         : myLink->IsoOnTriangulation();
+  }
+
+  //! Returns true if the drawer has IsoOnTriangulation setting active.
+  Standard_Boolean HasOwnIsoOnTriangulation() const { return myHasOwnIsoOnTriangulation; }
+
+  //! Enables or disables isolines on triangulation by setting the parameter theIsEnabled to true or false.
+  Standard_EXPORT void SetIsoOnTriangulation (const Standard_Boolean theToEnable);
+
   //! Sets the discretisation parameter theValue.
   Standard_EXPORT void SetDiscretisation (const Standard_Integer theValue);
 
@@ -188,6 +204,15 @@ public:
          : 0.0;
   }
 
+  //! Updates the previous value used for the chordal deviation coefficient to the current state.
+  void UpdatePreviousDeviationCoefficient()
+  {
+    if (myHasOwnDeviationCoefficient)
+    {
+      myPreviousDeviationCoefficient = DeviationCoefficient();
+    }
+  }
+
   //! Sets the deviation coefficient aCoefficient for removal
   //! of hidden lines created by different viewpoints in
   //! different presentations. The Default value is 0.02.
@@ -268,6 +293,15 @@ public:
          : 0.0;
   }
 
+  //! Updates the previous deviation angle to the current value
+  void UpdatePreviousDeviationAngle()
+  {
+    if (myHasOwnDeviationAngle)
+    {
+      myPreviousDeviationAngle = DeviationAngle();
+    }
+  }
+
   //! Sets anAngle, the angle of maximum chordal deviation for removal of hidden lines created by
   //! different viewpoints in different presentations.
   //! The default value is 20 * M_PI / 180.
@@ -406,6 +440,10 @@ public:
   //! point aspect that overrides the one in the link.
   Standard_Boolean HasOwnPointAspect() const { return myHasOwnPointAspect; }
 
+  //! Sets own point aspect.
+  //! Returns FALSE if the drawer already has its own attribute for point aspect.
+  Standard_EXPORT Standard_Boolean SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
   //! Returns settings for line aspects.
   //! These settings can be edited. The default values are:
   //!   Color: Quantity_NOC_YELLOW
@@ -424,6 +462,14 @@ public:
   //! line aspect that overrides the one in the link.
   Standard_Boolean HasOwnLineAspect() const { return myHasOwnLineAspect; }
 
+  //! Sets own line aspects.
+  //! Returns FALSE if own line aspect are already set.
+  Standard_EXPORT Standard_Boolean SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
+  //! Sets own line aspects for datums.
+  //! Returns FALSE if own line for datums are already set.
+  Standard_EXPORT Standard_Boolean SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
   //! Returns settings for text aspect.
   //! These settings can be edited. The default value is:
   //! - Color: Quantity_NOC_YELLOW
@@ -454,23 +500,9 @@ public:
   //! shading aspect that overrides the one in the link.
   Standard_Boolean HasOwnShadingAspect() const { return myHasOwnShadingAspect; }
 
-  //! Returns True if the ShadingAspect is applied
-  //! to the whole presentation.
-  Standard_Boolean ShadingAspectGlobal() const
-  {
-    return HasOwnShadingAspectGlobal() || myLink.IsNull()
-         ? myShadingAspectGlobal
-         : myLink->ShadingAspectGlobal();
-  }
-
-  //! Indicates that the ShadingAspect will be apply
-  //! to the whole presentation. This allows to modify
-  //! the aspect without recomputing the content of the presentation.
-  Standard_EXPORT void SetShadingAspectGlobal (const Standard_Boolean theValue);
-
-  //! Returns true if the drawer has its own attribute for
-  //! ShadingAspectGlobal flag that overrides the one in the link.
-  Standard_Boolean HasOwnShadingAspectGlobal() const { return myHasOwnShadingAspectGlobal; }
+  //! Sets own shading aspect.
+  //! Returns FALSE if the drawer already has its own attribute for shading aspect.
+  Standard_EXPORT Standard_Boolean SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
 
   //! Returns settings for seen line aspects.
   //! These settings can be edited. The default values are:
@@ -707,6 +739,10 @@ public:
   //! face boundaries aspect that overrides the one in the link.
   Standard_Boolean HasOwnFaceBoundaryAspect() const { return myHasOwnFaceBoundaryAspect; }
 
+  //! Sets own face boundary aspect.
+  //! Returns FALSE if the drawer already has its own attribute for face boundary aspect.
+  Standard_EXPORT Standard_Boolean SetupOwnFaceBoundaryAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
   //! Enables or disables face boundary drawing for shading presentations. 
   //! The method sets drawing flag owned by the drawer that will be used during
   //! visualization instead of the one set in link.
@@ -725,6 +761,25 @@ public:
   //! "draw face boundaries" flag that overrides the one in the link.
   Standard_Boolean HasOwnFaceBoundaryDraw() const { return myHasOwnFaceBoundaryDraw; }
 
+  //! Returns true if the drawer has its own attribute for face boundaries upper edge continuity class that overrides the one in the link.
+  Standard_Boolean HasOwnFaceBoundaryUpperContinuity() const { return myFaceBoundaryUpperContinuity != -1; }
+
+  //! Get the most edge continuity class; GeomAbs_CN by default (all edges).
+  GeomAbs_Shape FaceBoundaryUpperContinuity() const
+  {
+    return HasOwnFaceBoundaryUpperContinuity()
+         ? (GeomAbs_Shape )myFaceBoundaryUpperContinuity
+         : (!myLink.IsNull()
+           ? myLink->FaceBoundaryUpperContinuity()
+           : GeomAbs_CN);
+  }
+
+  //! Set the most edge continuity class for face boundaries.
+  void SetFaceBoundaryUpperContinuity (GeomAbs_Shape theMostAllowedEdgeClass) { myFaceBoundaryUpperContinuity = theMostAllowedEdgeClass; }
+
+  //! Unset the most edge continuity class for face boundaries.
+  void UnsetFaceBoundaryUpperContinuity() { myFaceBoundaryUpperContinuity = -1; }
+
   //! Returns settings for the appearance of dimensions. 
   Standard_EXPORT const Handle(Prs3d_DimensionAspect)& DimensionAspect();
 
@@ -814,14 +869,31 @@ public:
   Standard_Boolean HasLink() const { return !myLink.IsNull(); }
 
   //! Sets theDrawer as a link to which the current object references.
-  void Link (const Handle(Prs3d_Drawer)& theDrawer)
-  {
-    myLink = theDrawer;
-  }
+  void Link (const Handle(Prs3d_Drawer)& theDrawer) { SetLink (theDrawer); }
+
+  //! Sets theDrawer as a link to which the current object references.
+  void SetLink (const Handle(Prs3d_Drawer)& theDrawer) { myLink = theDrawer; }
 
   //! Removes local attributes. 
   Standard_EXPORT void ClearLocalAttributes();
 
+  //! Assign shader program for specified type of primitives.
+  //! @param theProgram new program to set (might be NULL)
+  //! @param theAspect  the type of primitives
+  //! @param theToOverrideDefaults if true then non-overridden attributes using defaults will be allocated and copied from the Link;
+  //!                              otherwise, only already customized attributes will be changed
+  //! @return TRUE if presentation should be recomputed after creating aspects not previously customized (if theToOverrideDefaults is also TRUE)
+  Standard_EXPORT bool SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
+                                         const Graphic3d_GroupAspect            theAspect,
+                                         const bool                             theToOverrideDefaults = false);
+
+  //! Sets Shading Model type for the shading aspect.
+  Standard_EXPORT bool SetShadingModel (Graphic3d_TypeOfShadingModel theModel,
+                                        bool theToOverrideDefaults = false);
+
+  //! Dumps the content of me into the stream
+  Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
 protected:
 
   Handle(Prs3d_Drawer)          myLink;
@@ -830,7 +902,7 @@ protected:
   Standard_Boolean              myHasOwnNbPoints;
   Standard_Real                 myMaximalParameterValue;
   Standard_Boolean              myHasOwnMaximalParameterValue;
-  Quantity_Length               myChordialDeviation;
+  Standard_Real                 myChordialDeviation;
   Standard_Boolean              myHasOwnChordialDeviation;
   Aspect_TypeOfDeflection       myTypeOfDeflection;
   Standard_Boolean              myHasOwnTypeOfDeflection;
@@ -849,6 +921,8 @@ protected:
   Standard_Real                 myPreviousHLRDeviationAngle;
   Standard_Boolean              myIsoOnPlane;
   Standard_Boolean              myHasOwnIsoOnPlane;
+  Standard_Boolean              myIsoOnTriangulation;
+  Standard_Boolean              myHasOwnIsoOnTriangulation;
   Standard_Boolean              myIsAutoTriangulated;
   Standard_Boolean              myHasOwnIsAutoTriangulated;
 
@@ -868,8 +942,6 @@ protected:
   Standard_Boolean              myHasOwnTextAspect;
   Handle(Prs3d_ShadingAspect)   myShadingAspect;
   Standard_Boolean              myHasOwnShadingAspect;
-  Standard_Boolean              myShadingAspectGlobal;
-  Standard_Boolean              myHasOwnShadingAspectGlobal;
   Handle(Prs3d_PlaneAspect)     myPlaneAspect;
   Standard_Boolean              myHasOwnPlaneAspect;
   Handle(Prs3d_LineAspect)      mySeenLineAspect;
@@ -899,6 +971,7 @@ protected:
   Standard_Boolean              myUnFreeBoundaryDraw;
   Standard_Boolean              myHasOwnUnFreeBoundaryDraw;
   Handle(Prs3d_LineAspect)      myFaceBoundaryAspect;
+  Standard_Integer              myFaceBoundaryUpperContinuity; //!< the most edge continuity class (GeomAbs_Shape) to be included to face boundaries presentation, or -1 if undefined
   Standard_Boolean              myHasOwnFaceBoundaryAspect;
   Standard_Boolean              myFaceBoundaryDraw;
   Standard_Boolean              myHasOwnFaceBoundaryDraw;
@@ -911,11 +984,9 @@ protected:
   Prs3d_DimensionUnits          myDimensionDisplayUnits;
   Standard_Boolean              myHasOwnDimLengthDisplayUnits;
   Standard_Boolean              myHasOwnDimAngleDisplayUnits;
-
-public:
-
-  DEFINE_STANDARD_RTTI(Prs3d_Drawer, MMgt_TShared)
-
 };
 
+Standard_DEPRECATED("Class name is deprecated - use Prs3d_Drawer instead")
+typedef Prs3d_Drawer Graphic3d_HighlightStyle;
+
 #endif // _Prs3d_Drawer_HeaderFile