0026163: Visualization - AIS_Shape::SetWidth() should not overwrite the free boundary...
authorapl <apl@opencascade.com>
Mon, 18 May 2015 17:11:22 +0000 (20:11 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 21 May 2015 10:53:58 +0000 (13:53 +0300)
src/AIS/AIS_Shape.cxx
tests/bugs/vis/bug26163 [new file with mode: 0644]

index b8bfede..cda29b3 100644 (file)
@@ -474,10 +474,30 @@ void AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
       *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
     }
   }
-  // disable dedicated line aspects
-  theDrawer->SetFreeBoundaryAspect  (theDrawer->LineAspect());
-  theDrawer->SetUnFreeBoundaryAspect(theDrawer->LineAspect());
-  theDrawer->SetSeenLineAspect      (theDrawer->LineAspect());
+  if (!theDrawer->HasOwnFreeBoundaryAspect())
+  {
+    theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+    if (theDrawer->HasLink())
+    {
+      *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
+    }
+  }
+  if (!theDrawer->HasOwnUnFreeBoundaryAspect())
+  {
+    theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+    if (theDrawer->HasLink())
+    {
+      *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
+    }
+  }
+  if (!theDrawer->HasOwnSeenLineAspect())
+  {
+    theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+    if (theDrawer->HasLink())
+    {
+      *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
+    }
+  }
 
   // override color
   theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
@@ -485,6 +505,9 @@ void AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
   theDrawer->LineAspect()->SetColor (theColor);
   theDrawer->WireAspect()->SetColor (theColor);
   theDrawer->PointAspect()->SetColor (theColor);
+  theDrawer->FreeBoundaryAspect()->SetColor (theColor);
+  theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
+  theDrawer->SeenLineAspect()->SetColor (theColor);
 }
 
 //=======================================================================
@@ -695,14 +718,37 @@ void AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
       *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
     }
   }
-  // disable dedicated line aspects
-  theDrawer->SetFreeBoundaryAspect  (theDrawer->LineAspect());
-  theDrawer->SetUnFreeBoundaryAspect(theDrawer->LineAspect());
-  theDrawer->SetSeenLineAspect      (theDrawer->LineAspect());
+  if (!theDrawer->HasOwnFreeBoundaryAspect())
+  {
+    theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+    if (theDrawer->HasLink())
+    {
+      *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
+    }
+  }
+  if (!theDrawer->HasOwnUnFreeBoundaryAspect())
+  {
+    theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+    if (theDrawer->HasLink())
+    {
+      *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
+    }
+  }
+  if (!theDrawer->HasOwnSeenLineAspect())
+  {
+    theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+    if (theDrawer->HasLink())
+    {
+      *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
+    }
+  }
 
   // override width
   theDrawer->LineAspect()->SetWidth (theLineWidth);
   theDrawer->WireAspect()->SetWidth (theLineWidth);
+  theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
+  theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
+  theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
 }
 
 //=======================================================================
diff --git a/tests/bugs/vis/bug26163 b/tests/bugs/vis/bug26163
new file mode 100644 (file)
index 0000000..9051b8f
--- /dev/null
@@ -0,0 +1,29 @@
+puts "============"
+puts "CR26163"
+puts "============"
+puts ""
+
+##########################################################################################
+puts "Visualization - AIS_Shape::SetWidth() should not overwrite the free boundary color"
+##########################################################################################
+
+set check_x 252
+set check_y 170
+
+pload VISUALIZATION MODELING
+
+vinit View1 w=400 h=400
+vclear
+vaxo
+
+restore [locate_data_file bug26163.brep] s 
+vdisplay s
+vfit
+vsetwidth s 4
+
+# check that free boundary color is kept
+if { [checkcolor $check_x $check_y 0.0 1.0 0.0] != 1 } {
+  puts "Error: free boundary aspect unexpectedly changed."
+}
+
+vdump ${imagedir}/${casename}.png