0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / AIS / AIS_ColoredShape.cxx
index c53bddb..22b5873 100644 (file)
@@ -124,8 +124,7 @@ Handle(AIS_ColoredDrawer) AIS_ColoredShape::CustomAspects (const TopoDS_Shape& t
   {
     aDrawer = new AIS_ColoredDrawer (myDrawer);
     myShapeColors.Bind (theShape, aDrawer);
-    LoadRecomputable (AIS_WireFrame);
-    LoadRecomputable (AIS_Shaded);
+    SetToUpdate();
   }
   return aDrawer;
 }
@@ -141,8 +140,7 @@ void AIS_ColoredShape::ClearCustomAspects()
     return;
   }
   myShapeColors.Clear();
-  LoadRecomputable (AIS_WireFrame);
-  LoadRecomputable (AIS_Shaded);
+  SetToUpdate();
 }
 
 //=======================================================================
@@ -157,8 +155,7 @@ void AIS_ColoredShape::UnsetCustomAspects (const TopoDS_Shape&    theShape,
     return;
   }
 
-  LoadRecomputable (AIS_WireFrame);
-  LoadRecomputable (AIS_Shaded);
+  SetToUpdate();
   if (theToUnregister)
   {
     myShapeColors.UnBind (theShape);
@@ -183,8 +180,6 @@ void AIS_ColoredShape::SetCustomColor (const TopoDS_Shape&   theShape,
   const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
   setColor (aDrawer, theColor);
   aDrawer->SetOwnColor (theColor);
-  LoadRecomputable (AIS_WireFrame);
-  LoadRecomputable (AIS_Shaded);
 }
 
 //=======================================================================
@@ -202,8 +197,6 @@ void AIS_ColoredShape::SetCustomTransparency (const TopoDS_Shape& theShape,
   const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
   setTransparency (aDrawer, theTransparency);
   aDrawer->SetOwnTransparency (theTransparency);
-  LoadRecomputable (AIS_WireFrame);
-  LoadRecomputable (AIS_Shaded);
 }
 
 //=======================================================================
@@ -221,8 +214,6 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape,
   const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
   setWidth (aDrawer, theLineWidth);
   aDrawer->SetOwnWidth (theLineWidth);
-  LoadRecomputable (AIS_WireFrame);
-  LoadRecomputable (AIS_Shaded);
 }
 
 //=======================================================================
@@ -232,11 +223,6 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape,
 
 void AIS_ColoredShape::SetColor (const Quantity_Color&  theColor)
 {
-  setColor (myDrawer, theColor);
-  myDrawer->SetColor (theColor);
-  hasOwnColor = Standard_True;
-  LoadRecomputable (AIS_WireFrame);
-  LoadRecomputable (AIS_Shaded);
   for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
   {
     const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
@@ -262,6 +248,7 @@ void AIS_ColoredShape::SetColor (const Quantity_Color&  theColor)
       aDrawer->FaceBoundaryAspect()->SetColor (theColor);
     }
   }
+  AIS_Shape::SetColor (theColor);
 }
 
 //=======================================================================
@@ -271,10 +258,6 @@ void AIS_ColoredShape::SetColor (const Quantity_Color&  theColor)
 
 void AIS_ColoredShape::SetWidth (const Standard_Real    theLineWidth)
 {
-  setWidth (myDrawer, theLineWidth);
-  myOwnWidth = theLineWidth;
-  LoadRecomputable (AIS_WireFrame);
-  LoadRecomputable (AIS_Shaded);
   for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
   {
     const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
@@ -296,6 +279,16 @@ void AIS_ColoredShape::SetWidth (const Standard_Real    theLineWidth)
       aDrawer->FaceBoundaryAspect()->SetWidth (theLineWidth);
     }
   }
+  AIS_Shape::SetWidth (theLineWidth);
+}
+
+//=======================================================================
+//function : UnsetWidth
+//purpose  :
+//=======================================================================
+void AIS_ColoredShape::UnsetWidth()
+{
+  SetWidth (1.0f);
 }
 
 //=======================================================================
@@ -305,10 +298,6 @@ void AIS_ColoredShape::SetWidth (const Standard_Real    theLineWidth)
 
 void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
 {
-  setTransparency (myDrawer, theValue);
-  myDrawer->SetTransparency ((Standard_ShortReal )theValue);
-  LoadRecomputable (AIS_WireFrame);
-  LoadRecomputable (AIS_Shaded);
   for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
   {
     const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
@@ -322,6 +311,7 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
       aDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
     }
   }
+  AIS_Shape::SetTransparency (theValue);
 }
 
 //=======================================================================
@@ -330,27 +320,7 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
 //=======================================================================
 void AIS_ColoredShape::UnsetTransparency()
 {
-  myDrawer->SetTransparency (0.0f);
-  if (myDrawer->HasOwnShadingAspect())
-  {
-    myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
-    if (!HasColor()
-     && !HasMaterial()
-     && !myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
-    {
-      myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
-    }
-  }
-
-  for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
-  {
-    const Handle(Prs3d_Drawer)& aDrawer = anIter.Value();
-    if (aDrawer->HasOwnShadingAspect())
-    {
-      aDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
-    }
-  }
-  SynchronizeAspects();
+  SetTransparency (0.0f);
 }
 
 //=======================================================================
@@ -360,19 +330,20 @@ void AIS_ColoredShape::UnsetTransparency()
 
 void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
 {
-  setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
-  //myOwnMaterial = theMaterial;
-  hasOwnMaterial = Standard_True;
-  LoadRecomputable (AIS_Shaded);
   for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
   {
     const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
-    //if (aDrawer->HasOwnMaterial()) continue;
+    if (aDrawer->HasOwnMaterial())
+    {
+      continue;
+    }
+
     if (aDrawer->HasOwnShadingAspect())
     {
       setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());
     }
   }
+  AIS_Shape::SetMaterial (theMaterial);
 }
 
 //=======================================================================
@@ -401,7 +372,7 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& theP
 
       // After this call if type of deflection is relative
       // computed deflection coefficient is stored as absolute.
-      Prs3d::GetDeflection (myshape, myDrawer);
+      StdPrs_ToolTriangulatedShape::GetDeflection (myshape, myDrawer);
       break;
     }
     case AIS_Shaded:
@@ -519,8 +490,8 @@ void AIS_ColoredShape::ComputeSelection (const Handle(SelectMgr_Selection)& theS
   }
 
   const TopAbs_ShapeEnum aTypOfSel   = AIS_Shape::SelectionType (theMode);
-  const Standard_Real    aDeflection = Prs3d::GetDeflection (myshape, myDrawer);
-  const Standard_Real    aDeviationAngle = myDrawer->HLRAngle();
+  const Standard_Real    aDeflection = StdPrs_ToolTriangulatedShape::GetDeflection (myshape, myDrawer);
+  const Standard_Real    aDeviationAngle = myDrawer->DeviationAngle();
   const Standard_Integer aPriority   = StdSelect_BRepSelectionTool::GetStandardPriority (myshape, aTypOfSel);
   if (myDrawer->IsAutoTriangulation()
   && !BRepTools::Triangulation (myshape, Precision::Infinite()))
@@ -545,8 +516,8 @@ void AIS_ColoredShape::ComputeSelection (const Handle(SelectMgr_Selection)& theS
   Handle(SelectMgr_SelectableObject) aThis (this);
   for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
   {
-    Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelEntIter.Value()->BaseSensitive()->OwnerId());
-    anOwner->Set (aThis);
+    const Handle(SelectMgr_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
+    anOwner->SetSelectable (aThis);
   }
 
   StdSelect_BRepSelectionTool::PreBuildBVH (theSelection);