diff --git a/src/OpenGl/OpenGl_LayerList.cxx b/src/OpenGl/OpenGl_LayerList.cxx index 2d908581e9..93896580b7 100644 --- a/src/OpenGl/OpenGl_LayerList.cxx +++ b/src/OpenGl/OpenGl_LayerList.cxx @@ -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; } } diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 7248b4bb17..427d134352 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -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 index 0000000000..82ea56ddf7 --- /dev/null +++ b/tests/bugs/vis/bug25400 @@ -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