diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 2e1108e35e..bf2fc4f9f5 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -2744,6 +2744,23 @@ bool ViewProviderSketch::selectAll() int VertexId = -1; int GeoId = 0; + auto selectVertex = [this](int &vertexId, int numberOfVertices) { + for (int i = 0; i < numberOfVertices; i++) { + vertexId++; + addSelection2(fmt::format("Vertex{}", vertexId + 1)); + } + }; + + auto selectEdge = [this](int GeoId) { + if (GeoId >= 0) { + addSelection2(fmt::format("Edge{}", GeoId + 1)); + } else { + addSelection2(fmt::format("ExternalEdge{}", GeoEnum::RefExt - GeoId + 1)); + } + }; + + bool hasUnselectedGeometry = false; + for (std::vector::const_iterator it = geomlist.begin(); it != geomlist.end() - 2; // -2 to exclude H_Axis and V_Axis ++it, ++GeoId) { @@ -2753,53 +2770,22 @@ bool ViewProviderSketch::selectAll() } if ((*it)->is()) { - VertexId++; - addSelection2(fmt::format("Vertex{}", VertexId + 1)); + selectVertex(VertexId, 1); } - else if ((*it)->is()) { - VertexId++; // start - addSelection2(fmt::format("Vertex{}", VertexId + 1)); - - VertexId++; // end - addSelection2(fmt::format("Vertex{}", VertexId + 1)); - - if (GeoId >= 0) { - addSelection2(fmt::format("Edge{}", GeoId + 1)); - } else { - addSelection2(fmt::format("ExternalEdge{}", -GeoId - 1)); - } + else if ((*it)->is() || (*it)->is()) { + selectVertex(VertexId, 2); // Start + End + selectEdge(GeoId); } else if ((*it)->isDerivedFrom()) { - VertexId++; - addSelection2(fmt::format("Vertex{}", VertexId + 1)); - - if (GeoId >= 0) { - addSelection2(fmt::format("Edge{}", GeoId + 1)); - } else { - addSelection2(fmt::format("ExternalEdge{}", -GeoId - 1)); - } + selectVertex(VertexId, 1); // Center + selectEdge(GeoId); } - else if ((*it)->isDerivedFrom()) { - if (auto arc = dynamic_cast(*it)) { - VertexId++; // start - addSelection2(fmt::format("Vertex{}", VertexId + 1)); - - VertexId++; // end - addSelection2(fmt::format("Vertex{}", VertexId + 1)); - - VertexId++; // center - addSelection2(fmt::format("Vertex{}", VertexId + 1)); - } else { - // for other curves, select available vertices - VertexId++; - addSelection2(fmt::format("Vertex{}", VertexId + 1)); - } - - if (GeoId >= 0) { - addSelection2(fmt::format("Edge{}", GeoId + 1)); - } else { - addSelection2(fmt::format("ExternalEdge{}", -GeoId - 1)); - } + else if ((*it)->isDerivedFrom()) { + selectVertex(VertexId, 3); // Start + End + Center + selectEdge(GeoId); + } + else { + hasUnselectedGeometry = true; } } @@ -2812,6 +2798,10 @@ bool ViewProviderSketch::selectAll() // get root point if they exist addSelection2("RootPoint"); + if (hasUnselectedGeometry) { + Base::Console().error("Select All: Not all geometry was selected"); + } + return true; }