From 527f18adcdbfb642adebc6b995d02a102fc334f1 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Fri, 5 Sep 2025 02:28:59 +0200 Subject: [PATCH] Tests: Correct testcases after scene graph reordering in Clarify Select --- src/Mod/Import/TestImportGui.py | 4 ++-- src/Mod/Part/Gui/SoBrepEdgeSet.cpp | 9 +++++---- src/Mod/Part/Gui/SoBrepFaceSet.cpp | 7 ++++--- src/Mod/Part/Gui/SoBrepPointSet.cpp | 12 ++++++++---- src/Mod/Part/parttests/ColorPerFaceTest.py | 16 ++++++++-------- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/Mod/Import/TestImportGui.py b/src/Mod/Import/TestImportGui.py index 9f2d6eb25a..8a0cfdb707 100644 --- a/src/Mod/Import/TestImportGui.py +++ b/src/Mod/Import/TestImportGui.py @@ -77,7 +77,7 @@ class ExportImportTest(unittest.TestCase): sa.apply(feature.ViewObject.RootNode) paths = sa.getPaths() - bind = paths.get(2).getTail() + bind = paths.get(1).getTail() self.assertEqual(bind.value.getValue(), bind.PER_PART) sa = coin.SoSearchAction() @@ -87,5 +87,5 @@ class ExportImportTest(unittest.TestCase): sa.apply(feature.ViewObject.RootNode) paths = sa.getPaths() - mat = paths.get(2).getTail() + mat = paths.get(1).getTail() self.assertEqual(mat.diffuseColor.getNum(), 6) diff --git a/src/Mod/Part/Gui/SoBrepEdgeSet.cpp b/src/Mod/Part/Gui/SoBrepEdgeSet.cpp index 88e1fedf23..14da9ed8e9 100644 --- a/src/Mod/Part/Gui/SoBrepEdgeSet.cpp +++ b/src/Mod/Part/Gui/SoBrepEdgeSet.cpp @@ -90,7 +90,7 @@ void SoBrepEdgeSet::GLRender(SoGLRenderAction *action) bool hasContextHighlight = ctx && !ctx->hl.empty(); - bool hasFaceHighlight = viewProvider->isFaceHighlightActive(); + bool hasFaceHighlight = viewProvider && viewProvider->isFaceHighlightActive(); bool hasAnyHighlight = hasContextHighlight || hasFaceHighlight; if (Gui::Selection().isClarifySelectionActive() @@ -98,7 +98,9 @@ void SoBrepEdgeSet::GLRender(SoGLRenderAction *action) && hasAnyHighlight) { // if we are using clarifyselection - add this to delayed paths with priority // as we want to get this rendered on top of everything - viewProvider->setFaceHighlightActive(true); + if (viewProvider) { + viewProvider->setFaceHighlightActive(true); + } Gui::SoDelayedAnnotationsElement::addDelayedPath(action->getState(), action->getCurPath()->copy(), 200); @@ -159,8 +161,7 @@ void SoBrepEdgeSet::GLRender(SoGLRenderAction *action) if(ctx2 && !ctx2->selectionIndex.empty()) renderSelection(action,ctx2,false); else if (Gui::Selection().isClarifySelectionActive() - && ((ctx && !ctx->hl.empty()) || viewProvider->isFaceHighlightActive()) - && Gui::SoDelayedAnnotationsElement::isProcessingDelayedPaths) { + && !Gui::SoDelayedAnnotationsElement::isProcessingDelayedPaths && hasAnyHighlight) { state->push(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/Mod/Part/Gui/SoBrepFaceSet.cpp b/src/Mod/Part/Gui/SoBrepFaceSet.cpp index 449bd9439a..8ef68c572a 100644 --- a/src/Mod/Part/Gui/SoBrepFaceSet.cpp +++ b/src/Mod/Part/Gui/SoBrepFaceSet.cpp @@ -532,10 +532,11 @@ void SoBrepFaceSet::GLRender(SoGLRenderAction *action) auto state = action->getState(); selCounter.checkRenderCache(state); + bool hasContextHighlight = ctx && ctx->isHighlighted() && !ctx->isHighlightAll() + && ctx->highlightIndex >= 0 && ctx->highlightIndex < partIndex.getNum(); + // for the tool add this node to delayed paths as we want to render it on top of the scene - if (Gui::Selection().isClarifySelectionActive() && ctx && ctx->isHighlighted() - && !ctx->isHighlightAll() && ctx->highlightIndex >= 0 - && ctx->highlightIndex < partIndex.getNum()) { + if (Gui::Selection().isClarifySelectionActive() && hasContextHighlight) { if (!Gui::SoDelayedAnnotationsElement::isProcessingDelayedPaths) { if (viewProvider) { diff --git a/src/Mod/Part/Gui/SoBrepPointSet.cpp b/src/Mod/Part/Gui/SoBrepPointSet.cpp index bfb028e8c9..8d8b8d6009 100644 --- a/src/Mod/Part/Gui/SoBrepPointSet.cpp +++ b/src/Mod/Part/Gui/SoBrepPointSet.cpp @@ -83,13 +83,17 @@ void SoBrepPointSet::GLRender(SoGLRenderAction *action) return; if(selContext2->checkGlobal(ctx)) ctx = selContext2; - + + + bool hasContextHighlight = + ctx && ctx->isHighlighted() && !ctx->isHighlightAll() && ctx->highlightIndex >= 0; // for clarifyselection, add this node to delayed path if it is highlighted and render it on // top of everything else (highest priority) - if (Gui::Selection().isClarifySelectionActive() && ctx && ctx->isHighlighted() - && !ctx->isHighlightAll() && ctx->highlightIndex >= 0 + if (Gui::Selection().isClarifySelectionActive() && hasContextHighlight && !Gui::SoDelayedAnnotationsElement::isProcessingDelayedPaths) { - viewProvider->setFaceHighlightActive(true); + if (viewProvider) { + viewProvider->setFaceHighlightActive(true); + } Gui::SoDelayedAnnotationsElement::addDelayedPath(action->getState(), action->getCurPath()->copy(), 300); diff --git a/src/Mod/Part/parttests/ColorPerFaceTest.py b/src/Mod/Part/parttests/ColorPerFaceTest.py index 3086efa738..85cdf8a858 100644 --- a/src/Mod/Part/parttests/ColorPerFaceTest.py +++ b/src/Mod/Part/parttests/ColorPerFaceTest.py @@ -49,7 +49,7 @@ class ColorPerFaceTest(unittest.TestCase): sa.apply(box.ViewObject.RootNode) paths = sa.getPaths() - mat = paths.get(2).getTail() + mat = paths.get(1).getTail() self.assertEqual(mat.diffuseColor.getNum(), 6) def testBoxAndLink(self): @@ -83,7 +83,7 @@ class ColorPerFaceTest(unittest.TestCase): sa.apply(box.ViewObject.RootNode) paths = sa.getPaths() - mat = paths.get(2).getTail() + mat = paths.get(1).getTail() self.assertEqual(mat.diffuseColor.getNum(), 6) def testTransparency(self): @@ -110,7 +110,7 @@ class ColorPerFaceTest(unittest.TestCase): sa.apply(box.ViewObject.RootNode) paths = sa.getPaths() - bind = paths.get(2).getTail() + bind = paths.get(1).getTail() self.assertEqual(bind.value.getValue(), bind.PER_PART) sa = coin.SoSearchAction() @@ -120,7 +120,7 @@ class ColorPerFaceTest(unittest.TestCase): sa.apply(box.ViewObject.RootNode) paths = sa.getPaths() - mat = paths.get(2).getTail() + mat = paths.get(1).getTail() self.assertEqual(mat.diffuseColor.getNum(), 6) def testMultiFuse(self): @@ -146,7 +146,7 @@ class ColorPerFaceTest(unittest.TestCase): sa.apply(fuse.ViewObject.RootNode) paths = sa.getPaths() - bind = paths.get(2).getTail() + bind = paths.get(1).getTail() self.assertEqual(bind.value.getValue(), bind.PER_PART) sa = coin.SoSearchAction() @@ -156,7 +156,7 @@ class ColorPerFaceTest(unittest.TestCase): sa.apply(fuse.ViewObject.RootNode) paths = sa.getPaths() - mat = paths.get(2).getTail() + mat = paths.get(1).getTail() self.assertEqual(mat.diffuseColor.getNum(), 11) self.assertEqual(len(fuse.Shape.Faces), 11) @@ -195,7 +195,7 @@ class ColorPerFaceTest(unittest.TestCase): sa.apply(fuse.ViewObject.RootNode) paths = sa.getPaths() - bind = paths.get(2).getTail() + bind = paths.get(1).getTail() self.assertEqual(bind.value.getValue(), bind.PER_PART) sa = coin.SoSearchAction() @@ -205,5 +205,5 @@ class ColorPerFaceTest(unittest.TestCase): sa.apply(fuse.ViewObject.RootNode) paths = sa.getPaths() - mat = paths.get(2).getTail() + mat = paths.get(1).getTail() self.assertEqual(mat.diffuseColor.getNum(), 11)