From 6bcf8c5bbfa3d671fc1b160bddd026a28e93b06f Mon Sep 17 00:00:00 2001 From: Patrick Felixberger Date: Wed, 29 Jan 2020 21:07:53 +0100 Subject: [PATCH 1/4] Added option to clear edges on PathMillFace Changed debug level --- src/Mod/Path/PathScripts/PathMillFace.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathMillFace.py b/src/Mod/Path/PathScripts/PathMillFace.py index 347d2fd4a2..cbb7e0d624 100644 --- a/src/Mod/Path/PathScripts/PathMillFace.py +++ b/src/Mod/Path/PathScripts/PathMillFace.py @@ -59,6 +59,7 @@ class ObjectFace(PathPocketBase.ObjectPocket): '''initPocketOp(obj) ... create facing specific properties''' obj.addProperty("App::PropertyEnumeration", "BoundaryShape", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Shape to use for calculating Boundary")) obj.BoundaryShape = ['Perimeter', 'Boundbox', 'Stock'] + obj.addProperty("App::PropertyBool", "ClearEdges", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Clear edges")) if not hasattr(obj, 'ExcludeRaisedAreas'): obj.addProperty("App::PropertyBool", "ExcludeRaisedAreas", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Exclude milling raised areas inside the face.")) @@ -98,7 +99,7 @@ class ObjectFace(PathPocketBase.ObjectPocket): '''areaOpShapes(obj) ... return top face''' # Facing is done either against base objects holeShape = None - + if obj.Base: PathLog.debug("obj.Base: {}".format(obj.Base)) faces = [] @@ -146,6 +147,17 @@ class ObjectFace(PathPocketBase.ObjectPocket): # Find the correct shape depending on Boundary shape. PathLog.debug("Boundary Shape: {}".format(obj.BoundaryShape)) bb = planeshape.BoundBox + + # Apply offset for clearing edges + offset = 0; + if obj.ClearEdges == True: + offset = self.radius + 0.1 + + bb.XMin = bb.XMin - offset + bb.YMin = bb.YMin - offset + bb.XMax = bb.XMax + offset + bb.YMax = bb.YMax + offset + if obj.BoundaryShape == 'Boundbox': bbperim = Part.makeBox(bb.XLength, bb.YLength, 1, FreeCAD.Vector(bb.XMin, bb.YMin, bb.ZMin), FreeCAD.Vector(0, 0, 1)) env = PathUtils.getEnvelope(partshape=bbperim, depthparams=self.depthparams) @@ -158,6 +170,7 @@ class ObjectFace(PathPocketBase.ObjectPocket): elif obj.BoundaryShape == 'Stock': stock = PathUtils.findParentJob(obj).Stock.Shape env = stock + if obj.ExcludeRaisedAreas is True and oneBase[1] is True: includedFaces = self.getAllIncludedFaces(oneBase[0], stock, faceZ=minHeight) if len(includedFaces) > 0: @@ -181,6 +194,7 @@ class ObjectFace(PathPocketBase.ObjectPocket): obj.StepOver = 50 obj.ZigZagAngle = 45.0 obj.ExcludeRaisedAreas = False + obj.ClearEdges = False # need to overwrite the default depth calculations for facing if job and len(job.Model.Group) > 0: @@ -209,6 +223,7 @@ class ObjectFace(PathPocketBase.ObjectPocket): def getAllIncludedFaces(self, base, env, faceZ): included = [] + eXMin = env.BoundBox.XMin eXMax = env.BoundBox.XMax eYMin = env.BoundBox.YMin @@ -239,6 +254,7 @@ class ObjectFace(PathPocketBase.ObjectPocket): fYMax = face.BoundBox.YMax # fZMin = face.BoundBox.ZMin fZMax = face.BoundBox.ZMax + if fZMax > eZMin: if isOverlap(fXMin, fXMax, eXMin, eXMax) is True: if isOverlap(fYMin, fYMax, eYMin, eYMax) is True: @@ -252,6 +268,8 @@ def SetupProperties(): setup = PathPocketBase.SetupProperties() setup.append("BoundaryShape") setup.append("ExcludeRaisedAreas") + setup.append("ClearEdges") + return setup @@ -260,4 +278,5 @@ def Create(name, obj=None): if obj is None: obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name) obj.Proxy = ObjectFace(obj, name) + return obj From fa2b0e9c3e3797b13a58faccd9e32415581f6aa2 Mon Sep 17 00:00:00 2001 From: J-Dunn Date: Sat, 8 Feb 2020 21:10:50 +0000 Subject: [PATCH 2/4] fix missing HorizFeed in boundaryDressup fix missing HorizFeed in boundaryDressup see bug #4260 --- src/Mod/Path/PathScripts/PathDressupPathBoundary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathDressupPathBoundary.py b/src/Mod/Path/PathScripts/PathDressupPathBoundary.py index 34029fede8..808778f2d7 100644 --- a/src/Mod/Path/PathScripts/PathDressupPathBoundary.py +++ b/src/Mod/Path/PathScripts/PathDressupPathBoundary.py @@ -150,7 +150,7 @@ class DressupPathBoundary(object): commands.extend(self.boundaryCommands(obj, lastExit, pos, tc.VertFeed.Value)) lastExit = None PathLog.track(e, flip) - commands.extend(PathGeom.cmdsForEdge(e, flip, False)) + commands.extend(PathGeom.cmdsForEdge(e, flip, False,50,tc.HorizFeed.Value,tc.VertFeed.Value)) # add missing HorizFeed to G2 paths inside.remove(e) pos = newPos lastExit = newPos From b11909185cb3a589f86cfeef36ea1dbaf09aba53 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 9 Feb 2020 10:33:06 +0100 Subject: [PATCH 3/4] Sketcher: [skip ci] fix -Wunused-private-field --- src/Mod/Sketcher/Gui/SketcherSettings.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.h b/src/Mod/Sketcher/Gui/SketcherSettings.h index 6887f217f9..4d94156920 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.h +++ b/src/Mod/Sketcher/Gui/SketcherSettings.h @@ -77,7 +77,6 @@ private Q_SLOTS: private: Ui_SketcherSettingsDisplay* ui; - SketcherGeneralWidget* form; }; /** From e1b3ec41b6edfa569184b2f6d08ede21911c8c9e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 9 Feb 2020 13:52:09 +0100 Subject: [PATCH 4/4] Sketcher: add option to disable leaving sketch with Esc button --- src/Gui/TaskView/TaskDialog.cpp | 2 +- src/Gui/TaskView/TaskDialog.h | 9 +++++++++ src/Gui/TaskView/TaskView.cpp | 2 +- src/Mod/Sketcher/Gui/SketcherSettings.cpp | 2 ++ src/Mod/Sketcher/Gui/SketcherSettings.ui | 21 ++++++++++++++++++++- src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp | 1 + src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 8 ++++++++ 7 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/Gui/TaskView/TaskDialog.cpp b/src/Gui/TaskView/TaskDialog.cpp index 5c784c602e..75643b1837 100644 --- a/src/Gui/TaskView/TaskDialog.cpp +++ b/src/Gui/TaskView/TaskDialog.cpp @@ -38,7 +38,7 @@ using namespace Gui::TaskView; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TaskDialog::TaskDialog() - : QObject(0), pos(North) + : QObject(0), pos(North), escapeButton(true) { } diff --git a/src/Gui/TaskView/TaskDialog.h b/src/Gui/TaskView/TaskDialog.h index 39cafc0f6a..e26bbc8fb8 100644 --- a/src/Gui/TaskView/TaskDialog.h +++ b/src/Gui/TaskView/TaskDialog.h @@ -67,6 +67,14 @@ public: virtual void modifyStandardButtons(QDialogButtonBox*) {} + /// Defines whether a task dialog can be rejected by pressing Esc + void setEscapeButtonEnabled(bool on) { + escapeButton = on; + } + bool isEscapeButtonEnabled() const { + return escapeButton; + } + const std::string& getDocumentName() const { return documentName; } void setDocumentName(const std::string& doc) @@ -118,6 +126,7 @@ protected: private: std::string documentName; + bool escapeButton; }; } //namespace TaskView diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index 09c00650e6..8d9904bdf4 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -477,7 +477,7 @@ void TaskView::keyPressEvent(QKeyEvent* ke) } } } - else if (ke->key() == Qt::Key_Escape) { + else if (ke->key() == Qt::Key_Escape && ActiveDialog->isEscapeButtonEnabled()) { // get only the buttons of the button box QDialogButtonBox* box = ActiveCtrl->standardButtons(); QList list = box->buttons(); diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index 2b9bae2c83..eb742b5fec 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -70,6 +70,7 @@ void SketcherSettings::saveSettings() // Sketch editing ui->checkBoxAdvancedSolverTaskBox->onSave(); ui->checkBoxRecalculateInitialSolutionWhileDragging->onSave(); + ui->checkBoxEnableEscape->onSave(); ui->checkBoxNotifyConstraintSubstitutions->onSave(); form->saveSettings(); } @@ -79,6 +80,7 @@ void SketcherSettings::loadSettings() // Sketch editing ui->checkBoxAdvancedSolverTaskBox->onRestore(); ui->checkBoxRecalculateInitialSolutionWhileDragging->onRestore(); + ui->checkBoxEnableEscape->onRestore(); ui->checkBoxNotifyConstraintSubstitutions->onRestore(); form->loadSettings(); } diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.ui b/src/Mod/Sketcher/Gui/SketcherSettings.ui index 0247f18a4c..f08bbf8319 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.ui +++ b/src/Mod/Sketcher/Gui/SketcherSettings.ui @@ -106,9 +106,28 @@ Requires to re-enter edit mode to take effect. - Notifications + General + + + + Allow to leave sketch edit mode when pressing Esc button + + + Esc can leave sketch edit mode + + + true + + + LeaveSketchWithEscape + + + Mod/Sketcher + + + diff --git a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp index abfa954a2b..06d0cb3c99 100644 --- a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp +++ b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp @@ -50,6 +50,7 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView) SolverAdvanced = new TaskSketcherSolverAdvanced(sketchView); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + setEscapeButtonEnabled(hGrp->GetBool("LeaveSketchWithEscape", true)); Content.push_back(Messages); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index a09b0c2df3..7f6c17c0ac 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -204,6 +204,7 @@ struct EditData { DrawSketchHandler *sketchHandler; bool editDatumDialog; bool buttonPress; + bool handleEscapeButton; // dragged point int DragPoint; @@ -486,6 +487,10 @@ bool ViewProviderSketch::keyPressed(bool pressed, int key) if (!pressed && !edit->buttonPress) return true; edit->buttonPress = pressed; + + // More control over Sketcher edit mode Esc key behavior + // https://forum.freecadweb.org/viewtopic.php?f=3&t=42207 + return edit->handleEscapeButton; } return false; } @@ -5651,6 +5656,9 @@ bool ViewProviderSketch::setEdit(int ModNum) ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); edit->MarkerSize = hGrp->GetInt("MarkerSize", 7); + ParameterGrp::handle hSketch = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + edit->handleEscapeButton = !hSketch->GetBool("LeaveSketchWithEscape", true); + createEditInventorNodes(); auto editDoc = Gui::Application::Instance->editDocument();