From fdf040f5b7ea3b01be17d1970d26db6dbddc4263 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 9 Apr 2017 15:25:34 +0200 Subject: [PATCH] Sketcher: Carbon Copy ===================== Carbon copy checks for parallel planes, translated origin and rotated axes, so that it can provide flipping detection when using reverse mappings. This commit enables you to press CTRL will activating the tool in order to bypass this checks. Without the checks you will get a sketch exactly as the one you want to copy, there are no corrections at all. This enables you to copy a profile on a new plane at a different direction for example for lofting purposes. --- src/Mod/Sketcher/App/SketchObject.cpp | 11 ++++++----- src/Mod/Sketcher/App/SketchObject.h | 2 ++ src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 7 ++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index abba314882..c154cd9751 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -99,6 +99,7 @@ SketchObject::SketchObject() 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) if (*it) delete *it; @@ -2083,14 +2084,14 @@ bool SketchObject::isCarbonCopyAllowed(App::Document *pDoc, App::DocumentObject double doty = sy * ly; // the planes of the sketches must be parallel - if(dot != 1.0 && dot != -1.0) { + if(!allowUnaligned && dot != 1.0 && dot != -1.0) { if (rsn) *rsn = rlNonParallel; return false; } // the axis must be aligned - if( (dotx != 1.0 && dotx != -1.0) || (doty != 1.0 && doty != -1.0)) { + if(!allowUnaligned && ((dotx != 1.0 && dotx != -1.0) || (doty != 1.0 && doty != -1.0))) { if (rsn) *rsn = rlAxesMisaligned; return false; @@ -2102,14 +2103,14 @@ bool SketchObject::isCarbonCopyAllowed(App::Document *pDoc, App::DocumentObject double alignment = ddir * lnormal; - if( (alignment != 1.0 && alignment != -1.0) && (psObj->Placement.getValue().getPosition() != this->Placement.getValue().getPosition()) ){ + if(!allowUnaligned && (alignment != 1.0 && alignment != -1.0) && (psObj->Placement.getValue().getPosition() != this->Placement.getValue().getPosition()) ){ if (rsn) *rsn = rlOriginsMisaligned; return false; } - xinv = (dotx == 1.0); - yinv = (doty == 1.0); + xinv = allowUnaligned?false:(dotx == 1.0); + yinv = allowUnaligned?false:(doty == 1.0); return true; } diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 33e4c63c65..177790109e 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -302,6 +302,8 @@ public: /// 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; enum eReasonList{ rlAllowed, diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index c49565e47a..e967b7ce48 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -6199,6 +6199,7 @@ namespace SketcherGui { Sketcher::SketchObject *sketch = static_cast(object); sketch->allowOtherBody = false; + sketch->allowUnaligned = (QApplication::keyboardModifiers() == Qt::ControlModifier); this->notAllowedReason = ""; Sketcher::SketchObject::eReasonList msg; @@ -6219,13 +6220,13 @@ namespace SketcherGui { this->notAllowedReason = QT_TR_NOOP("This object belongs to another part."); break; case Sketcher::SketchObject::rlNonParallel: - this->notAllowedReason = QT_TR_NOOP("The selected sketch is not parallel to this sketch."); + this->notAllowedReason = QT_TR_NOOP("The selected sketch is not parallel to this sketch. Hold Ctrl to allow non-parallel sketchs."); break; case Sketcher::SketchObject::rlAxesMisaligned: - this->notAllowedReason = QT_TR_NOOP("The XY axes of the selected sketch do not have the same direction as this sketch."); + this->notAllowedReason = QT_TR_NOOP("The XY axes of the selected sketch do not have the same direction as this sketch. Hold Ctrl to disregard it."); break; case Sketcher::SketchObject::rlOriginsMisaligned: - this->notAllowedReason = QT_TR_NOOP("The origin of the selected sketch is not aligned with the origin of this sketch."); + this->notAllowedReason = QT_TR_NOOP("The origin of the selected sketch is not aligned with the origin of this sketch. Hold Ctrl to disregard it."); break; default: break;