From 2c377232177609217b951cd19ec0dfdb453f5ee7 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 2 Sep 2013 16:18:19 +0200 Subject: [PATCH] Fixed bug in external geometry selection of sketcher --- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 35 ++++++++++++++--------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index b60ef85f99..c859ab92ed 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -4474,22 +4474,31 @@ namespace SketcherGui { bool allow(App::Document *pDoc, App::DocumentObject *pObj, const char *sSubName) { + // Selection outside of the Document is NOT allowed Sketcher::SketchObject *sketch = static_cast(object); + if (sketch->getDocument() != pDoc) + return false; + App::DocumentObject *support = sketch->Support.getValue(); + Part::BodyBase* body = Part::BodyBase::findBodyOf(support); + if (body != NULL) { + if (Part::BodyBase::findBodyOf(pObj) == body) { + // Don't allow selection after the Tip feature in the same body + if (body->isAfterTip(pObj)) + return false; + } else { + // Selection outside of body not allowed if flag is not set + if (!sketch->allowOtherBody) + return false; + } - // for the moment we allow external constraints only from the support and datum features - if(pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) || - pObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) - return true; - - if (pObj != support) { - // Selection outside of support not allowed - if (!sketch->allowOtherBody) - return false; - - // Selection outside of support allowed if from other body - // TODO: There is still a possibility of creating cyclic references here - if (Part::BodyBase::findBodyOf(pObj) == Part::BodyBase::findBodyOf(support)) + // Datum features are always allowed + if(pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) || + pObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) + return true; + } else { + // Legacy parts - don't allow selection outside of the support + if (pObj != support) return false; }