From 899f3e26eafb177767eb84c3715dd555978e863f Mon Sep 17 00:00:00 2001 From: SparkyCola Date: Wed, 4 Oct 2017 21:43:45 +0200 Subject: [PATCH] Implemented arc of circle in touch mode, same issue with precision as in circle and ellipse --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 46 ++++++++++++--------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 9f15c4a613..af8b6905e3 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -2133,39 +2133,24 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s & pnt2 = proj(pnt2); bool pnt0Inside = polygon.Contains(Base::Vector2d(pnt0.x, pnt0.y)); - if (pnt0Inside) { - std::stringstream ss; - ss << "Vertex" << VertexId - 1; - Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str()); - } - bool pnt1Inside = polygon.Contains(Base::Vector2d(pnt1.x, pnt1.y)); - if (pnt1Inside) { - std::stringstream ss; - ss << "Vertex" << VertexId; - Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str()); - } + bool bpolyInside = true; - if (polygon.Contains(Base::Vector2d(pnt2.x, pnt2.y))) { - std::stringstream ss; - ss << "Vertex" << VertexId + 1; - Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str()); - } - - if (pnt0Inside && pnt1Inside) { + if ((pnt0Inside && pnt1Inside) || touchMode) { double startangle, endangle; aoc->getRange(startangle, endangle, /*emulateCCW=*/true); + if (startangle > endangle) // if arc is reversed std::swap(startangle, endangle); double range = endangle-startangle; int countSegments = std::max(2, int(12.0 * range / (2 * M_PI))); + if(touchMode)countSegments=countSegments*2.5; float segment = float(range) / countSegments; // circumscribed polygon radius float radius = float(aoc->getRadius()) / cos(segment/2); - bool bpolyInside = true; pnt0 = aoc->getCenter(); float angle = float(startangle) + segment/2; for (int i = 0; i < countSegments; ++i, angle += segment) { @@ -2176,6 +2161,9 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s & pnt = proj(pnt); if (!polygon.Contains(Base::Vector2d(pnt.x, pnt.y))) { bpolyInside = false; + if(!touchMode)break; + } else if(touchMode){ + bpolyInside = true; break; } } @@ -2186,6 +2174,24 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s & Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str()); } } + + if (pnt0Inside || (bpolyInside && touchMode)) { + std::stringstream ss; + ss << "Vertex" << VertexId - 1; + Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str()); + } + + if (pnt1Inside || (bpolyInside && touchMode)) { + std::stringstream ss; + ss << "Vertex" << VertexId; + Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str()); + } + + if (polygon.Contains(Base::Vector2d(pnt2.x, pnt2.y)) || (bpolyInside && touchMode)) { + std::stringstream ss; + ss << "Vertex" << VertexId + 1; + Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str()); + } } else if ((*it)->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { // Check if arc lies inside box selection const Part::GeomArcOfEllipse *aoe = static_cast(*it); @@ -2235,7 +2241,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s & double segment = (range) / countSegments; - // circumscribed polygon radius + // circumscribed polygon radius double a = (aoe->getMajorRadius()) / cos(segment/2); double b = (aoe->getMinorRadius()) / cos(segment/2); Base::Vector3d majdir = aoe->getMajorAxisDir();