From e4a52991b66203188448fecb197a72b5b9827e0a Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Thu, 2 Nov 2017 19:52:26 +0100 Subject: [PATCH] Sketcher: Restore inter-body expression engine links in Carbon Copy --- src/Mod/Sketcher/App/SketchObject.cpp | 5 +++-- src/Mod/Sketcher/App/SketchObject.h | 11 +++++++++++ src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index f7757ca99b..e8abc3d5dd 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -99,6 +99,7 @@ SketchObject::SketchObject() ADD_PROPERTY_TYPE(Constraints, (0) ,"Sketch",(App::PropertyType)(App::Prop_None),"Sketch constraints"); ADD_PROPERTY_TYPE(ExternalGeometry,(0,0),"Sketch",(App::PropertyType)(App::Prop_None),"Sketch external geometry"); + allowOtherBody = true; allowUnaligned = true; for (std::vector::iterator it=ExternalGeo.begin(); it != ExternalGeo.end(); ++it) @@ -2090,14 +2091,14 @@ bool SketchObject::isCarbonCopyAllowed(App::Document *pDoc, App::DocumentObject App::Part* part_obj = App::Part::getPartOfObject(pObj); if (part_this == part_obj){ //either in the same part, or in the root of document if (body_this != NULL) { - if (body_this != body_obj) { + if ((body_this != body_obj) && !this->allowOtherBody) { if (rsn) *rsn = rlOtherBody; return false; } } } else { - // cross-part link. Disallow, should be done via shapebinders only + // cross-part relation. Disallow, should be done via shapebinders only if (rsn) *rsn = rlOtherPart; return false; diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 99fd79ef44..4ceceff49c 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -305,6 +305,14 @@ public: /// gets the solved sketch as a reference inline Sketch &getSolvedSketch(void) {return solvedSketch;} + /// Flag to allow external geometry from other bodies than the one this sketch belongs to + bool isAllowedOtherBody() const { + return allowOtherBody; + } + void setAllowOtherBody(bool on) { + allowOtherBody = on; + } + /// Flag to allow carbon copy from misaligned geometry bool isAllowedUnaligned() const { return allowUnaligned; @@ -349,6 +357,9 @@ protected: std::vector supportedGeometry(const std::vector &geoList) const; private: + /// Flag to allow external geometry from other bodies than the one this sketch belongs to + bool allowOtherBody; + /// Flag to allow carbon copy from misaligned geometry bool allowUnaligned; diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 25af80fa76..e1df861c5d 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -6535,6 +6535,7 @@ namespace SketcherGui { Q_UNUSED(sSubName); Sketcher::SketchObject *sketch = static_cast(object); + sketch->setAllowOtherBody(QApplication::keyboardModifiers() == Qt::ControlModifier || QApplication::keyboardModifiers() == (Qt::ControlModifier | Qt::AltModifier)); sketch->setAllowUnaligned(QApplication::keyboardModifiers() == (Qt::ControlModifier | Qt::AltModifier)); this->notAllowedReason = ""; @@ -6550,7 +6551,7 @@ namespace SketcherGui { this->notAllowedReason = QT_TR_NOOP("This object is in another document."); break; case Sketcher::SketchObject::rlOtherBody: - this->notAllowedReason = QT_TR_NOOP("This object belongs to another body."); + this->notAllowedReason = QT_TR_NOOP("This object belongs to another body. Hold Ctrl to allow crossreferences."); break; case Sketcher::SketchObject::rlOtherPart: this->notAllowedReason = QT_TR_NOOP("This object belongs to another part.");