From 8b62680fe747c68eea170aa0535cc2eed1239134 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Fri, 7 Aug 2015 15:21:37 +0300 Subject: [PATCH] Sketcher: minor enhance in sketch interaction with body --- src/Mod/Sketcher/App/SketchObject.cpp | 10 ++-------- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 4 +++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index f55bf567d..737a54a7c 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1712,16 +1712,10 @@ bool SketchObject::isExternalAllowed(App::Document *pDoc, App::DocumentObject *p App::DocumentObject *support = this->Support.getValue(); Part::BodyBase* body = Part::BodyBase::findBodyOf(this); if (body != NULL) { - if (Part::BodyBase::findBodyOf(pObj) != body) { + if ( ! body->hasFeature (pObj) && !this->allowOtherBody ) { // Selection outside of body not allowed if flag is not set - if (!this->allowOtherBody) - return false; + return false; } - - // 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) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index a78f61547..d1de0af5a 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -4480,8 +4480,10 @@ namespace SketcherGui { // Note: its better to search the support of the sketch in case the sketch support is a base plane Part::BodyBase* body = Part::BodyBase::findBodyOf(sketch); - if ((body != NULL) && (Part::BodyBase::findBodyOf(pObj) == body) && body->isAfter(pObj, sketch)) { + if ( body && body->hasFeature ( pObj ) && body->isAfter ( pObj, sketch ) ) { // Don't allow selection after the sketch in the same body + // NOTE: allowness of features in other bodies is handled by SketchObject::isExternalAllowed() + // TODO may be this should be in SketchObject::isExternalAllowed() (2015-08-07, Fat-Zer) return false; }