From 83cf2a17cd2ddb0586c3b73aef8208fde9830d68 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Fri, 31 May 2024 11:48:56 +0200 Subject: [PATCH] Gui: Refactor DressUp VP to use setHighlighted* This refactors DressUp VP a bit so it does no longer store original copy of original faces colors to properly support selection, but uses highlight methods provided by the base class. It simplfies code a bit and ensures coherent behavior. --- .../PartDesign/Gui/ViewProviderDressUp.cpp | 29 +++++++------------ src/Mod/PartDesign/Gui/ViewProviderDressUp.h | 5 ---- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp b/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp index 19b9b757bc..17e8d5287b 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp @@ -63,7 +63,7 @@ std::string ViewProviderDressUp::featureIcon() const bool ViewProviderDressUp::setEdit(int ModNum) { - if (ModNum == ViewProvider::Default ) { + if (ModNum == ViewProvider::Default) { // Here we should prevent edit of a Feature with missing base // Otherwise it could call unhandled exception. PartDesign::DressUp* dressUp = static_cast(getObject()); @@ -84,7 +84,6 @@ bool ViewProviderDressUp::setEdit(int ModNum) { } } - void ViewProviderDressUp::highlightReferences(const bool on) { PartDesign::DressUp* pcDressUp = static_cast(getObject()); @@ -100,31 +99,25 @@ void ViewProviderDressUp::highlightReferences(const bool on) std::vector edges = pcDressUp->Base.getSubValuesStartsWith("Edge"); if (on) { - if (!faces.empty() && originalFaceMaterials.empty()) { - originalFaceMaterials = vp->ShapeAppearance.getValues(); - std::vector materials = originalFaceMaterials; + if (!faces.empty()) { + std::vector materials = vp->ShapeAppearance.getValues(); PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), ShapeAppearance.getDiffuseColor()); highlighter.getFaceMaterials(faces, materials); - vp->ShapeAppearance.setValues(materials); + + vp->setHighlightedFaces(materials); } - if (!edges.empty() && originalLineColors.empty()) { - originalLineColors = vp->LineColorArray.getValues(); - std::vector colors = originalLineColors; + if (!edges.empty()) { + std::vector colors = vp->LineColorArray.getValues(); PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), LineColor.getValue()); highlighter.getEdgeColors(edges, colors); - vp->LineColorArray.setValues(colors); + + vp->setHighlightedEdges(colors); } } else { - if (!faces.empty() && !originalFaceMaterials.empty()) { - vp->ShapeAppearance.setValues(originalFaceMaterials); - originalFaceMaterials.clear(); - } - if (!edges.empty() && !originalLineColors.empty()) { - vp->LineColorArray.setValues(originalLineColors); - originalLineColors.clear(); - } + vp->unsetHighlightedFaces(); + vp->unsetHighlightedEdges(); } } diff --git a/src/Mod/PartDesign/Gui/ViewProviderDressUp.h b/src/Mod/PartDesign/Gui/ViewProviderDressUp.h index 3c5ff435c9..0096d2cc0a 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDressUp.h +++ b/src/Mod/PartDesign/Gui/ViewProviderDressUp.h @@ -58,11 +58,6 @@ public: protected: bool setEdit(int ModNum) override; - -private: - std::vector originalFaceMaterials; - std::vector originalLineColors; - };