0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / Prs3d / Prs3d_Drawer.hxx
index f8541df..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_HighlightStyle.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;
@@ -42,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.
@@ -77,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
@@ -441,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
@@ -459,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
@@ -489,6 +500,10 @@ public:
   //! shading aspect that overrides the one in the link.
   Standard_Boolean HasOwnShadingAspect() const { return myHasOwnShadingAspect; }
 
+  //! 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:
   //!   Color: Quantity_NOC_YELLOW
@@ -724,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.
@@ -742,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();
 
@@ -824,36 +862,6 @@ public:
   //! that overrides the one in the link.
   Standard_Boolean HasOwnDimAngleDisplayUnits() const { return myHasOwnDimAngleDisplayUnits; }
 
-  //! Returns true if the drawer has its own style of dynamic highlighting
-  //! that overrides the one in the link
-  Standard_Boolean HasOwnHighlightStyle() const { return myHasOwnHighlightStyle; }
-
-  //! Returns own dynamic highlight style or corresponding style of the link. If no one of
-  //! them is defined, invalid handle will be returned.
-  const Handle(Graphic3d_HighlightStyle)& HighlightStyle() const
-  {
-    return HasOwnHighlightStyle() || myLink.IsNull()
-      ? myHighlightStyle : myLink->HighlightStyle();
-  }
-
-  //! Allows to set own dynamic highlight style.
-  Standard_EXPORT void SetHighlightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle);
-
-  //! Returns true if the drawer has its own style of selection highlighting
-  //! that overrides the one in the link
-  Standard_Boolean HasOwnSelectionStyle() const { return myHasOwnSelectionStyle; }
-
-  //! Returns own selection highlight style or corresponding style of the link. If no one of
-  //! them is defined, invalid handle will be returned.
-  const Handle(Graphic3d_HighlightStyle)& SelectionStyle() const
-  {
-    return HasOwnSelectionStyle() || myLink.IsNull()
-      ? mySelectionStyle : myLink->SelectionStyle();
-  }
-
-  //! Allows to set own selection highlight style.
-  Standard_EXPORT void SetSelectionStyle (const Handle(Graphic3d_HighlightStyle)& theStyle);
-
   //! Returns the drawer to which the current object references.
   const Handle(Prs3d_Drawer)& Link() { return myLink; }
 
@@ -861,10 +869,10 @@ 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();
@@ -874,10 +882,18 @@ public:
   //! @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
-  Standard_EXPORT void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
+  //! @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;
@@ -886,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;
@@ -955,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;
@@ -967,16 +984,9 @@ protected:
   Prs3d_DimensionUnits          myDimensionDisplayUnits;
   Standard_Boolean              myHasOwnDimLengthDisplayUnits;
   Standard_Boolean              myHasOwnDimAngleDisplayUnits;
-
-  Handle(Graphic3d_HighlightStyle) myHighlightStyle;
-  Standard_Boolean                 myHasOwnHighlightStyle;
-  Handle(Graphic3d_HighlightStyle) mySelectionStyle;
-  Standard_Boolean                 myHasOwnSelectionStyle;
-
-public:
-
-  DEFINE_STANDARD_RTTIEXT(Prs3d_Drawer,MMgt_TShared)
-
 };
 
+Standard_DEPRECATED("Class name is deprecated - use Prs3d_Drawer instead")
+typedef Prs3d_Drawer Graphic3d_HighlightStyle;
+
 #endif // _Prs3d_Drawer_HeaderFile