From dbf47de2faee842bcf35536911e6395f47802a3f Mon Sep 17 00:00:00 2001 From: sshutina Date: Wed, 5 Nov 2025 12:35:16 +0000 Subject: [PATCH] Fix default group z layer --- src/Graphic3d/Graphic3d_Group.cxx | 5 +++++ src/OpenGl/OpenGl_Structure.cxx | 1 + src/ViewerTest/ViewerTest_ObjectCommands.cxx | 15 +++++++-------- tests/v3d/materials/bug33504 | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Graphic3d/Graphic3d_Group.cxx b/src/Graphic3d/Graphic3d_Group.cxx index 59f144cb16..14ba3624f6 100644 --- a/src/Graphic3d/Graphic3d_Group.cxx +++ b/src/Graphic3d/Graphic3d_Group.cxx @@ -315,6 +315,11 @@ void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint, //======================================================================= void Graphic3d_Group::SetZLayer (const Graphic3d_ZLayerId theLayerId, Standard_Boolean theToUpdate) { + if (theLayerId == myZLayerId) + { + return; + } + myZLayerId = theLayerId; myStructure->myCStructure->SetGroupZLayer (Standard_True); if (theToUpdate) diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 29db041180..0cedbf1b9e 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -305,6 +305,7 @@ void OpenGl_Structure::Disconnect (Graphic3d_CStructure& theStructure) Handle(Graphic3d_Group) OpenGl_Structure::NewGroup (const Handle(Graphic3d_Structure)& theStruct) { Handle(OpenGl_Group) aGroup = new OpenGl_Group (theStruct); + aGroup->SetZLayer (ZLayer()); myGroups.Append (aGroup); return aGroup; } diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index b31597675a..4e5221550e 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -6877,7 +6877,7 @@ static int vAddGroup (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs, c } // Check for zlayer and color parameters. Quantity_Color aColor(Quantity_NOC_INDIANRED); - Graphic3d_ZLayerId aLayerID = anObj->ZLayer(); + Graphic3d_ZLayerId aLayerID = Graphic3d_ZLayerId_UNKNOWN; for (Standard_Integer anIter = anArgIter; anIter < theNbArgs; ++anIter) { const TCollection_AsciiString anArg(theArgVec[anIter]); @@ -6888,11 +6888,6 @@ static int vAddGroup (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs, c Message::SendFail() << "Specified zlayer does not exist."; return 1; } - if (aLayerID == Graphic3d_ZLayerId_UNKNOWN) - { - std::cout << "Warning: you set this group with unknown zlayer."; - aLayerID = anObj->ZLayer(); - } } else if (anArg == "-color") { @@ -6934,7 +6929,9 @@ static int vAddGroup (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs, c Standard_Real aDy = Draw::Atof (theArgVec[anArgIter++]); Standard_Real aZ = Draw::Atof (theArgVec[anArgIter++]); - aNewGroup->SetZLayer (aLayerID, Standard_True); + if (aLayerID != Graphic3d_ZLayerId_UNKNOWN) + aNewGroup->SetZLayer (aLayerID, Standard_True); + Handle(Prs3d_LineAspect) anAspectQuadTop = new Prs3d_LineAspect(aColor, (Aspect_TypeOfLine)0, 2.0); aNewGroup->SetGroupPrimitivesAspect (anAspectQuadTop->Aspect()); Handle(Graphic3d_ArrayOfTriangles) aPrim = new Graphic3d_ArrayOfTriangles(4, 6, Graphic3d_ArrayFlags_None); @@ -6966,7 +6963,9 @@ static int vAddGroup (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs, c Standard_Real aPz = Draw::Atof (theArgVec[anArgIter++]); Standard_Real aHeight = Draw::Atof (theArgVec[anArgIter++]); - aNewGroup->SetZLayer (aLayerID, Standard_True); + if (aLayerID != Graphic3d_ZLayerId_UNKNOWN) + aNewGroup->SetZLayer(aLayerID, Standard_True); + Handle(Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d (aColor, Font_NOF_MONOSPACE, 1.0, 0.0); aNewGroup->SetGroupPrimitivesAspect (aTextAspect); Graphic3d_Vertex aMarker (aPx, aPy, aPz); diff --git a/tests/v3d/materials/bug33504 b/tests/v3d/materials/bug33504 index 55437e6294..9b4111dff5 100644 --- a/tests/v3d/materials/bug33504 +++ b/tests/v3d/materials/bug33504 @@ -15,7 +15,7 @@ vfit #add groups with different zlayer settings vaddgroup b1 quad 5 5 1 1 3 -zlayer 0 -color 0.0 0.0 1.0 vaddgroup b1 quad 5 5 1 1 5 -zlayer -3 -color 0.0 1.0 0.0 -vaddgroup b1 quad 5 5 1 1 7 -zlayer -2 -color 1.0 0.0 0.0 +vaddgroup b1 quad 5 5 1 1 7 -color 1.0 0.0 0.0 vaddgroup b1 text myKindOfText 5 5 10 20 -zlayer -4 -color 1.0 0.0 1.0 #general perspective -- 2.39.5