0029491: Visualization, AIS_Shape - filter unsupported Display Modes within ::AcceptD...
authorkgv <kgv@opencascade.com>
Thu, 8 Feb 2018 06:30:39 +0000 (09:30 +0300)
committerapn <apn@opencascade.com>
Fri, 9 Feb 2018 13:13:39 +0000 (16:13 +0300)
AIS_Shape::AcceptDisplayMode() now accepts only modes 0,1 and 2.
AIS_ColoredShape::Compute() no more computes presentation for unknown display mode.

src/AIS/AIS_ColoredShape.cxx
src/AIS/AIS_Shape.cxx
src/AIS/AIS_Shape.hxx

index 7119e87..662f7b5 100644 (file)
@@ -345,7 +345,7 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
 //function : Compute
 //purpose  :
 //=======================================================================
-void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
+void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
                                 const Handle(Prs3d_Presentation)&           thePrs,
                                 const Standard_Integer                      theMode)
 {
@@ -359,31 +359,45 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
     thePrs->SetInfiniteState (Standard_True);
   }
 
-  if (theMode == AIS_Shaded)
+  switch (theMode)
   {
-    if (myDrawer->IsAutoTriangulation())
+    case AIS_WireFrame:
     {
-      // compute mesh for entire shape beforehand to ensure consistency and optimizations (parallelization)
       StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
 
       // After this call if type of deflection is relative
       // computed deflection coefficient is stored as absolute.
-      Standard_Boolean wasRecomputed = StdPrs_ToolTriangulatedShape::Tessellate (myshape, myDrawer);
-
-      // Set to update wireframe presentation on triangulation.
-      if (myDrawer->IsoOnTriangulation() && wasRecomputed)
+      Prs3d::GetDeflection (myshape, myDrawer);
+      break;
+    }
+    case AIS_Shaded:
+    {
+      if (myDrawer->IsAutoTriangulation())
       {
-        SetToUpdate (AIS_WireFrame);
+        // compute mesh for entire shape beforehand to ensure consistency and optimizations (parallelization)
+        StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
+
+        // After this call if type of deflection is relative
+        // computed deflection coefficient is stored as absolute.
+        Standard_Boolean wasRecomputed = StdPrs_ToolTriangulatedShape::Tessellate (myshape, myDrawer);
+
+        // Set to update wireframe presentation on triangulation.
+        if (myDrawer->IsoOnTriangulation() && wasRecomputed)
+        {
+          SetToUpdate (AIS_WireFrame);
+        }
       }
+      break;
+    }
+    case 2:
+    {
+      AIS_Shape::Compute (thePrsMgr, thePrs, theMode);
+      return;
+    }
+    default:
+    {
+      return;
     }
-  }
-  else // WireFrame mode
-  {
-    StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
-
-    // After this call if type of deflection is relative
-    // computed deflection coefficient is stored as absolute.
-    Prs3d::GetDeflection (myshape, myDrawer);
   }
 
   // Extract myShapeColors map (KeyshapeColored -> Color) to subshapes map (Subshape -> Color).
index b5ead33..82b805b 100644 (file)
@@ -19,7 +19,6 @@
 #include <AIS_GraphicTool.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <Aspect_TypeOfLine.hxx>
-#include <Bnd_Box.hxx>
 #include <BRep_Builder.hxx>
 #include <BRepBndLib.hxx>
 #include <BRepTools.hxx>
@@ -68,7 +67,6 @@
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS_Iterator.hxx>
-#include <TopoDS_Shape.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
 
@@ -97,28 +95,6 @@ AIS_Shape::AIS_Shape(const TopoDS_Shape& theShape)
   //
 }
 
-//=======================================================================
-//function : Type
-//purpose  : 
-//=======================================================================
-AIS_KindOfInteractive AIS_Shape::Type() const 
-{return AIS_KOI_Shape;}
-
-
-//=======================================================================
-//function : Signature
-//purpose  : 
-//=======================================================================
-Standard_Integer AIS_Shape::Signature() const 
-{return 0;}
-
-//=======================================================================
-//function : AcceptShapeDecomposition
-//purpose  : 
-//=======================================================================
-Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const 
-{return Standard_True;}
-
 //=======================================================================
 //function : Compute
 //purpose  : 
index d9424ee..c6f566f 100644 (file)
 
 #include <AIS_InteractiveObject.hxx>
 #include <Bnd_Box.hxx>
-#include <TopAbs_ShapeEnum.hxx>
 #include <TopoDS_Shape.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_TypeOfHLR.hxx>
 
-class TopoDS_Shape;
-class Bnd_Box;
-
 //! A framework to manage presentation and selection of shapes.
 //! AIS_Shape is the interactive object which is used the
 //! most by   applications. There are standard functions
@@ -68,25 +64,31 @@ public:
   //! Initializes construction of the shape shap from wires,
   //! edges and vertices.
   Standard_EXPORT AIS_Shape(const TopoDS_Shape& shap);
-  
+
   //! Returns index 0. This value refers to SHAPE from TopAbs_ShapeEnum
-  Standard_EXPORT virtual Standard_Integer Signature() const Standard_OVERRIDE;
-  
+  virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
+
   //! Returns Object as the type of Interactive Object.
-  Standard_EXPORT virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE;
-  
+  virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Shape; }
+
   //! Returns true if the Interactive Object accepts shape decomposition.
-  Standard_EXPORT virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE;
-  
+  virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE { return Standard_True; }
+
+  //! Return true if specified display mode is supported.
+  virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode >= 0 && theMode <= 2; }
+
+  //! Returns this shape object.
+  const TopoDS_Shape& Shape() const { return myshape; }
+
   //! Constructs an instance of the shape object theShape.
-  void Set (const TopoDS_Shape& theShape)
+  void SetShape (const TopoDS_Shape& theShape)
   {
     myshape  = theShape;
     myCompBB = Standard_True;
   }
 
-  //! Returns this shape object.
-  const TopoDS_Shape& Shape() const { return myshape; }
+  //! Alias for ::SetShape().
+  void Set (const TopoDS_Shape& theShape) { SetShape (theShape); }
 
   //! Sets a local value for deviation coefficient for this specific shape.
   Standard_EXPORT Standard_Boolean SetOwnDeviationCoefficient();