]> OCCT Git - occt.git/commitdiff
Fix default group z layer
authorsshutina <svetlana.shutina@opencascade.com>
Wed, 5 Nov 2025 12:35:16 +0000 (12:35 +0000)
committersshutina <svetlana.shutina@opencascade.com>
Wed, 5 Nov 2025 13:25:41 +0000 (13:25 +0000)
src/Graphic3d/Graphic3d_Group.cxx
src/OpenGl/OpenGl_Structure.cxx
src/ViewerTest/ViewerTest_ObjectCommands.cxx
tests/v3d/materials/bug33504

index 59f144cb16bed5f2c03d90527ebca6d77f0a6164..14ba3624f6f324b63c1c39ce5b9fb5b00e886512 100644 (file)
@@ -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)
index 29db04118090a5b6ba5fb7a704b3bce5b6157d30..0cedbf1b9e5ec49ba3aacc5bfe24deb37b84e778 100644 (file)
@@ -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;
 }
index b31597675aed3c24a5a272fb4208dda586496c14..4e5221550efa8856f40914ae0b25332e5b67d172 100644 (file)
@@ -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);
index 55437e629461eebed1200bf5ab1ea402d3ff27e5..9b4111dff50213d06841f80fcbf6d3ee8d3d758e 100644 (file)
@@ -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