]> OCCT Git - occt-copy.git/commitdiff
0025400: Visualization, TKOpenGl - Structure disappears if assigned a non-default...
authorsan <san@opencascade.com>
Thu, 30 Oct 2014 08:57:09 +0000 (11:57 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 30 Oct 2014 08:58:22 +0000 (11:58 +0300)
- BVH tree in the target Z layer was not updated when OpenGl_Structure
was moved to another Z layer.
- vpriority DRAW command added to test how BVH tree is updated when
display priority is changed
- Test case for Z layers and display priorities added

Handle -noupdate argument within vpriority command

src/OpenGl/OpenGl_LayerList.cxx
src/ViewerTest/ViewerTest_ObjectCommands.cxx
tests/bugs/vis/bug25400 [new file with mode: 0644]

index 2d908581e9a9cd3804e61e8a3852f03790f51384..93896580b7e9f5777a1121b410cd19f7336a213c 100644 (file)
@@ -257,7 +257,9 @@ void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure *theStructure,
   if ((aPriority = aList.Remove (theStructure, Standard_True)) >= 0)
   {
     myNbStructures--;
-    AddStructure (theStructure, theNewLayerId, aPriority, Standard_True);
+    // isForChangePriority should be Standard_False below, because we want
+    // the BVH tree in the target layer to be updated with theStructure
+    AddStructure (theStructure, theNewLayerId, aPriority);
   }
   else
   {
@@ -273,7 +275,9 @@ void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure *theStructure,
       if ((aPriority = aList.Remove (theStructure, Standard_True)) >= 0)
       {
         myNbStructures--;
-        AddStructure (theStructure, theNewLayerId, aPriority, Standard_True);
+        // isForChangePriority should be Standard_False below, because we want
+        // the BVH tree in the target layer to be updated with theStructure
+        AddStructure (theStructure, theNewLayerId, aPriority);
         break;
       }
     }
index 7248b4bb17bad09e6789f5db271d8880bd55e3a4..427d134352884315cc3a722488a71f67aeb26775 100644 (file)
@@ -5765,6 +5765,81 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
   return 0;
 }
 
+//=======================================================================
+//function : VPriority
+//purpose  : Prints or sets the display priority for an object
+//=======================================================================
+
+static int VPriority (Draw_Interpretor& theDI,
+                      Standard_Integer  theArgNum,
+                      const char**      theArgs)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
+  if (aContext.IsNull())
+  {
+    std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
+    return 1;
+  }
+
+  TCollection_AsciiString aLastArg (theArgs[theArgNum - 1]);
+  Standard_Integer aPriority = -1;
+  Standard_Integer aNbArgs   = theArgNum;
+  if (aLastArg.IsIntegerValue())
+  {
+    aPriority = aLastArg.IntegerValue();
+    --aNbArgs;
+    if (aPriority < 0 || aPriority > 10)
+    {
+      std::cout << "Error: the specified display priority value '" << aLastArg
+                << "' is outside the valid range [0..10]" << std::endl;
+      return 1;
+    }
+  }
+  else
+  {
+    anUpdateTool.Invalidate();
+  }
+
+  if (aNbArgs < 2)
+  {
+    std::cout << "Error: wrong number of arguments! See usage:\n";
+    theDI.PrintHelp (theArgs[0]);
+    return 1;
+  }
+
+  for (Standard_Integer anArgIter = 1; anArgIter < aNbArgs; ++anArgIter)
+  {
+    if (anUpdateTool.parseRedrawMode (theArgs[anArgIter]))
+    {
+      continue;
+    }
+
+    TCollection_AsciiString aName (theArgs[anArgIter]);
+    Handle(AIS_InteractiveObject) anIObj;
+    if (GetMapOfAIS().IsBound2 (aName))
+    {
+      anIObj = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
+    }
+
+    if (anIObj.IsNull())
+    {
+      std::cout << "Error: the object '" << theArgs[1] << "' is not displayed" << std::endl;
+      return 1;
+    }
+
+    if (aPriority < 1)
+    {
+      theDI << aContext->DisplayPriority (anIObj) << " ";
+    }
+    else
+    {
+      aContext->SetDisplayPriority (anIObj, aPriority);
+    }
+  }
+  return 0;
+}
+
 //=======================================================================
 //function : ObjectsCommands
 //purpose  :
@@ -6008,4 +6083,9 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     "vlocscale name x y z scale\n\t\t  applies scale to local transformation",
     __FILE__,
     LocalTransformPresentation, group);
+
+  theCommands.Add("vpriority",
+    "vpriority [-noupdate|-update] name [value]\n\t\t  prints or sets the display priority for an object",
+    __FILE__,
+    VPriority, group);
 }
diff --git a/tests/bugs/vis/bug25400 b/tests/bugs/vis/bug25400
new file mode 100644 (file)
index 0000000..82ea56d
--- /dev/null
@@ -0,0 +1,43 @@
+puts "========"
+puts "OCC25400"
+puts "========"
+puts ""
+###################################################################################################
+#  Visualization, TKOpenGl - Structure disappears if assigned a non-default Z layer
+###################################################################################################
+
+box b 1 2 3
+vinit
+vdisplay b
+vfrustumculling 1
+vfit
+
+vdump $imagedir/${casename}_default_layer.png
+
+# 1. Test a non-default Z layer:
+# the object should not disappear from the screen
+# due to wrong frustum culling operation
+
+vzlayer add
+vobjzlayer set b 1
+# vfit is used to redraw the view, the box disappeared after this due to the issue 25400
+vfit
+
+vdump $imagedir/${casename}_new_layer.png
+
+vzlayer del 1
+# vfit is used to redraw the view, the textured box appeared again after this
+vfit
+
+vdump $imagedir/${casename}_after_delete_layer.png
+
+# 2. Test a non-default display priority value:
+# the object should not disappear from the screen
+# due to wrong frustum culling operation
+
+vpriority b
+vpriority b 6
+
+vdump $imagedir/${casename}_new_priority.png
+
+set only_screen 1