From 8a2ea9727644b8a49cf661b7710da2a095bd134d Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 15 Dec 2021 16:25:06 +0100 Subject: [PATCH] PD: support of wires in ReferenceHighlighter --- .../PartDesign/Gui/ReferenceHighlighter.cpp | 22 +++++++++++++++++++ src/Mod/PartDesign/Gui/ReferenceHighlighter.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/Mod/PartDesign/Gui/ReferenceHighlighter.cpp b/src/Mod/PartDesign/Gui/ReferenceHighlighter.cpp index cf777f4c20..a3893cb53b 100644 --- a/src/Mod/PartDesign/Gui/ReferenceHighlighter.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceHighlighter.cpp @@ -40,6 +40,7 @@ ReferenceHighlighter::ReferenceHighlighter(const TopoDS_Shape& shape, const App: , objectColor(0.6f,0.0f,1.0f) // purple { TopExp::MapShapes(shape, TopAbs_EDGE, eMap); + TopExp::MapShapes(shape, TopAbs_WIRE, wMap); TopExp::MapShapes(shape, TopAbs_FACE, fMap); } @@ -52,6 +53,24 @@ void ReferenceHighlighter::getEdgeColor(const std::string& element, std::vector< colors[pos] = elementColor; } +void ReferenceHighlighter::getEdgeColorsOfWire(const std::string& element, std::vector& colors) const +{ + int idx = std::stoi(element.substr(4)); + assert ( idx > 0 ); + // get the edges of the wire + TopoDS_Shape wire = wMap.FindKey(idx); + for (TopExp_Explorer xp(wire, TopAbs_EDGE); xp.More(); xp.Next()) { + int edgeIndex = eMap.FindIndex(xp.Current()); + + // Edge found? + if (edgeIndex > 0) { + std::size_t pos = std::size_t(edgeIndex - 1); + if (pos < colors.size()) + colors[pos] = elementColor; + } + } +} + void ReferenceHighlighter::getEdgeColorsOfFace(const std::string& element, std::vector& colors) const { int idx = std::stoi(element.substr(4)); @@ -80,6 +99,9 @@ void ReferenceHighlighter::getEdgeColors(const std::vector& element if (boost::starts_with(e, "Edge")) { getEdgeColor(e, colors); } + else if (boost::starts_with(e, "Wire")) { + getEdgeColorsOfWire(e, colors); + } else if (boost::starts_with(e, "Face")) { getEdgeColorsOfFace(e, colors); } diff --git a/src/Mod/PartDesign/Gui/ReferenceHighlighter.h b/src/Mod/PartDesign/Gui/ReferenceHighlighter.h index dd42989486..bc0a8f8b8b 100644 --- a/src/Mod/PartDesign/Gui/ReferenceHighlighter.h +++ b/src/Mod/PartDesign/Gui/ReferenceHighlighter.h @@ -72,6 +72,7 @@ public: private: void getEdgeColor(const std::string& element, std::vector& colors) const; + void getEdgeColorsOfWire(const std::string& element, std::vector& colors) const; void getEdgeColorsOfFace(const std::string& element, std::vector& colors) const; void getFaceColor(const std::string& element, std::vector& colors) const; @@ -80,6 +81,7 @@ private: App::Color elementColor; App::Color objectColor; TopTools_IndexedMapOfShape eMap; + TopTools_IndexedMapOfShape wMap; TopTools_IndexedMapOfShape fMap; };