From 536adcfda735830e74d2c842ab3051e9d30c22d5 Mon Sep 17 00:00:00 2001 From: Patrick Felixberger Date: Wed, 23 Dec 2020 12:05:49 +0100 Subject: [PATCH 1/5] Added gui support for lead in/out dressup --- src/Mod/Path/Gui/Resources/Path.qrc | 1 + .../Resources/panels/DressUpLeadInOutEdit.ui | 340 ++++++++++++++++++ .../Path/PathScripts/PathDressupDogbone.py | 1 + .../Path/PathScripts/PathDressupLeadInOut.py | 84 ++++- 4 files changed, 425 insertions(+), 1 deletion(-) create mode 100644 src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc index c1383eb7a5..c99246c667 100644 --- a/src/Mod/Path/Gui/Resources/Path.qrc +++ b/src/Mod/Path/Gui/Resources/Path.qrc @@ -97,6 +97,7 @@ panels/DogboneEdit.ui panels/DressupPathBoundary.ui panels/DragKnifeEdit.ui + panels/DressUpLeadInOutEdit.ui panels/HoldingTagsEdit.ui panels/PageBaseGeometryEdit.ui panels/PageBaseHoleGeometryEdit.ui diff --git a/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui b/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui new file mode 100644 index 0000000000..e7d1e9329f --- /dev/null +++ b/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui @@ -0,0 +1,340 @@ + + + TaskPanel + + + + 0 + 0 + 372 + 518 + + + + LeadInOut + + + + + + + 0 + 400 + + + + QFrame::NoFrame + + + 0 + + + 6 + + + + + 0 + 0 + 354 + 470 + + + + Dressup + + + + + 0 + 0 + 351 + 391 + + + + + 6 + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + + <html><head/><body><p>Apply Lead In/Out on all layers</p></body></html> + + + Include Layers + + + + + + + Use Machine CRC + + + + + + + + + + + Extend In: + + + + + + + + 80 + 0 + + + + + + + + Qt::Vertical + + + + + + + Extend Out: + + + + + + + + 80 + 0 + + + + + + + + + + + + Enable LeadIn + + + + + + + Qt::Vertical + + + + + + + Enable LeadOut + + + + + + + + + + + Length / Radius: + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + + + + + + + + Style In: + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + Arc + + + + + Tangent + + + + + Perpendicular + + + + + + + + Qt::Vertical + + + + + + + Style Out: + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + Arc + + + + + Tangent + + + + + Perpendicular + + + + + + + + + + + + Keep Tool Down + + + + + + + Rapid Plunge + + + + + + + + + + + Radius / Center: + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + Radius + + + + + Center + + + + + + + + + + + + + + + + diff --git a/src/Mod/Path/PathScripts/PathDressupDogbone.py b/src/Mod/Path/PathScripts/PathDressupDogbone.py index 25d0fdabc7..ce134a23c3 100644 --- a/src/Mod/Path/PathScripts/PathDressupDogbone.py +++ b/src/Mod/Path/PathScripts/PathDressupDogbone.py @@ -1108,6 +1108,7 @@ class CommandDressupDogbone: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + if FreeCAD.GuiUp: import FreeCADGui from PySide import QtGui diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 6f7c161db1..261531835c 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -463,6 +463,81 @@ class ObjectDressup: commands = newpath return Path.Path(commands) + +class TaskPanel: + def __init__(self, obj): + self.obj = obj + self.form = FreeCADGui.PySideUic.loadUi(":/panels/DressUpLeadInOutEdit.ui") + + FreeCAD.ActiveDocument.openTransaction(translate("Path_DressupLeadInOut", "Edit LeadInOut Dress-up")) + + def reject(self): + FreeCAD.ActiveDocument.abortTransaction() + FreeCADGui.Control.closeDialog() + FreeCAD.ActiveDocument.recompute() + + def accept(self): + self.getFields() + FreeCAD.ActiveDocument.commitTransaction() + FreeCADGui.ActiveDocument.resetEdit() + FreeCADGui.Control.closeDialog() + FreeCAD.ActiveDocument.recompute() + + def getFields(self): + self.obj.LeadIn = self.form.chkLeadIn.isChecked() + self.obj.LeadOut = self.form.chkLeadOut.isChecked() + self.obj.Length = self.form.dsbLen.value() + self.obj.ExtendLeadIn = self.form.dsbExtendIn.value() + self.obj.ExtendLeadOut = self.form.dsbExtendOut.value() + self.obj.StyleOn = str(self.form.cboStyleIn.currentText()) + self.obj.StyleOff = str(self.form.cboStyleOut.currentText()) + self.obj.RadiusCenter = str(self.form.cboRadius.currentText()) + self.obj.RapidPlunge = self.form.chkRapidPlunge.isChecked() + self.obj.IncludeLayers = self.form.chkLayers.isChecked() + self.obj.KeepToolDown = self.form.chkKeepToolDown.isChecked() + self.obj.UseMachineCRC = self.form.chkUseCRC.isChecked() + + self.updateUI() + self.obj.Proxy.execute(self.obj) + + def updateUI(self): + self.form.chkLeadIn.setChecked(self.obj.LeadIn) + self.form.chkLeadOut.setChecked(self.obj.LeadOut) + self.form.chkRapidPlunge.setChecked(self.obj.RapidPlunge) + self.form.chkLayers.setChecked(self.obj.IncludeLayers) + self.form.chkKeepToolDown.setChecked(self.obj.KeepToolDown) + self.form.chkUseCRC.setChecked(self.obj.UseMachineCRC) + + self.form.dsbLen.setValue(self.obj.Length) + + self.form.dsbExtendIn.setValue(self.obj.ExtendLeadIn) + #self.form.dsbExtendIn.setEnabled(self.obj.LeadIn) + + self.form.dsbExtendOut.setValue(self.obj.ExtendLeadOut) + #self.form.dsbExtendOut.setEnabled(self.obj.LeadOut) + + self.form.cboStyleIn.setCurrentIndex(self.form.cboStyleIn.findText(self.obj.StyleOn)) + #self.form.cboStyleIn.setEnabled(self.obj.LeadIn) + + self.form.cboStyleOut.setCurrentIndex(self.form.cboStyleIn.findText(self.obj.StyleOff)) + #self.form.cboStyleOut.setEnabled(self.obj.LeadOut) + + self.form.cboRadius.setCurrentIndex(self.form.cboRadius.findText(self.obj.RadiusCenter)) + + def updateModel(self): + self.getFields() + FreeCAD.ActiveDocument.recompute() + + def setFields(self): + self.updateUI() + + def open(self): + pass + + def setupUi(self): + self.setFields() + + class ViewProviderDressup: def __init__(self, vobj): @@ -484,6 +559,14 @@ class ViewProviderDressup: # FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False return [self.obj.Base] + def setEdit(self, vobj, mode=0): + # pylint: disable=unused-argument + FreeCADGui.Control.closeDialog() + panel = TaskPanel(vobj.Object) + FreeCADGui.Control.showDialog(panel) + panel.setupUi() + return True + def onDelete(self, arg1=None, arg2=None): '''this makes sure that the base operation is added back to the project and visible''' # pylint: disable=unused-argument @@ -519,7 +602,6 @@ class CommandPathDressupLeadInOut: return False def Activated(self): - # check that the selection contains exactly what we want selection = FreeCADGui.Selection.getSelection() if len(selection) != 1: From eed3b8218ab49273f00c2d641e8f60f04902350c Mon Sep 17 00:00:00 2001 From: Patrick Felixberger Date: Wed, 23 Dec 2020 14:18:28 +0100 Subject: [PATCH 2/5] Layout changes --- .../Resources/panels/DressUpLeadInOutEdit.ui | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui b/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui index e7d1e9329f..3f0b091e37 100644 --- a/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui @@ -7,7 +7,7 @@ 0 0 372 - 518 + 466 @@ -37,7 +37,7 @@ 0 0 354 - 470 + 418 @@ -108,13 +108,6 @@ - - - - Qt::Vertical - - - @@ -143,13 +136,6 @@ - - - - Qt::Vertical - - - @@ -226,13 +212,6 @@ - - - - Qt::Vertical - - - From c67800365242f2e449f59586a9e23dacf91569cd Mon Sep 17 00:00:00 2001 From: Patrick F Date: Sat, 26 Dec 2020 21:11:27 +0100 Subject: [PATCH 3/5] Panel Start at creation --- .../Path/PathScripts/PathDressupLeadInOut.py | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 261531835c..f74bc9e809 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -24,7 +24,9 @@ from __future__ import print_function import FreeCAD +import FreeCADGui import Path +#import PathScripts.PathDressupLeadInOut as PathDressupLeadInOut import PathScripts.PathDressup as PathDressup import PathScripts.PathGeom as PathGeom import PathScripts.PathLog as PathLog @@ -32,7 +34,7 @@ import PathScripts.PathUtils as PathUtils import math import copy -from PySide import QtCore +from PySide import QtCore, QtGui __doc__ = """LeadInOut Dressup MASHIN-CRC USE ROLL-ON ROLL-OFF to profile""" @@ -468,8 +470,29 @@ class TaskPanel: def __init__(self, obj): self.obj = obj self.form = FreeCADGui.PySideUic.loadUi(":/panels/DressUpLeadInOutEdit.ui") + self.setupUi() FreeCAD.ActiveDocument.openTransaction(translate("Path_DressupLeadInOut", "Edit LeadInOut Dress-up")) + + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) + + def modifyStandardButtons(self, buttonBox): + self.buttonBox = buttonBox + + def setDirty(self): + self.isDirty = True + self.buttonBox.button(QtGui.QDialogButtonBox.Apply).setEnabled(True) + + def setClean(self): + self.isDirty = False + self.buttonBox.button(QtGui.QDialogButtonBox.Apply).setEnabled(False) + + def clicked(self, button): + # callback for standard buttons + if button == QtGui.QDialogButtonBox.Apply: + self.updateModel() + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCAD.ActiveDocument.abortTransaction() @@ -539,9 +562,9 @@ class TaskPanel: class ViewProviderDressup: - def __init__(self, vobj): self.obj = vobj.Object + self.setEdit(vobj) def attach(self, vobj): self.obj = vobj.Object @@ -625,9 +648,9 @@ class CommandPathDressupLeadInOut: FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)') FreeCADGui.doCommand('obj.Base = base') FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)') + FreeCADGui.doCommand('dbo.setup(obj)') FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupLeadInOut.ViewProviderDressup(obj.ViewObject)') FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False') - FreeCADGui.doCommand('dbo.setup(obj)') FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() From b12bf375bcb92ed6d0481c2024b9623b57a982b8 Mon Sep 17 00:00:00 2001 From: Patrick F Date: Sat, 26 Dec 2020 22:03:40 +0100 Subject: [PATCH 4/5] Updated layout --- .../Resources/panels/DressUpLeadInOutEdit.ui | 516 ++++++++++-------- .../Path/PathScripts/PathDressupLeadInOut.py | 1 - 2 files changed, 289 insertions(+), 228 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui b/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui index 3f0b091e37..53710a2ad7 100644 --- a/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/DressUpLeadInOutEdit.ui @@ -6,8 +6,8 @@ 0 0 - 372 - 466 + 381 + 452 @@ -36,8 +36,8 @@ 0 0 - 354 - 418 + 363 + 403 @@ -48,262 +48,324 @@ 0 0 - 351 - 391 + 361 + 401 - - - 6 - - - 6 - - - 6 - - - 6 - - - 6 - - - - - - - <html><head/><body><p>Apply Lead In/Out on all layers</p></body></html> - - - Include Layers - - - - - - - Use Machine CRC - - - - - - - - - - - Extend In: - - - - - - - - 80 - 0 - - - - - - - - Extend Out: - - - - - - - - 80 - 0 - - - - - - - + + + + QLayout::SetDefaultConstraint + - - - Enable LeadIn + + + + 0 + 0 + - - - - - - Enable LeadOut - - - - - - - - - - - Length / Radius: - - - - - - 80 + 0 0 - 80 - 16777215 + 180 + 190 + + LeadIn + + + + + 10 + 30 + 161 + 151 + + + + + + + Enable LeadIn + + + + + + + + + Extend In: + + + + + + + + 60 + 0 + + + + + + + + + + + + Style In: + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + Arc + + + + + Tangent + + + + + Perpendicular + + + + + + + + + + + + + + + 180 + 190 + + + + LeadOut + + + + + 10 + 30 + 161 + 151 + + + + + + + Enable LeadOut + + + + + + + + + Extend Out: + + + + + + + + 60 + 0 + + + + + + + + + + + + Style Out: + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + Arc + + + + + Tangent + + + + + Perpendicular + + + + + + + + - - + + - - - Style In: - - + + + + + Length / Radius: + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + - - - - 80 - 0 - - - - - 80 - 16777215 - - + - - Arc - + + + Radius / Center: + + - - Tangent - + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + Radius + + + + + Center + + + - - - Perpendicular - - - + - - - Style Out: - - - - - - - - 80 - 0 - - - - - 80 - 16777215 - - + - - Arc - + + + Keep Tool Down + + - - Tangent - + + + Rapid Plunge + + + + + + + + + + + <html><head/><body><p>Apply Lead In/Out on all layers</p></body></html> + + + Include Layers + + - - Perpendicular - + + + Use Machine CRC + + - - - - - - - - - - Keep Tool Down - - - - - - - Rapid Plunge - - - - - - - - - - - Radius / Center: - - - - - - - - 80 - 0 - - - - - 80 - 16777215 - - - - - Radius - - - - - Center - - - + diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index f74bc9e809..f18c6851dd 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -26,7 +26,6 @@ from __future__ import print_function import FreeCAD import FreeCADGui import Path -#import PathScripts.PathDressupLeadInOut as PathDressupLeadInOut import PathScripts.PathDressup as PathDressup import PathScripts.PathGeom as PathGeom import PathScripts.PathLog as PathLog From c504860e1d7dd08d93a315a04fd94e79d2c81290 Mon Sep 17 00:00:00 2001 From: Patrick F Date: Sat, 2 Jan 2021 01:34:53 +0100 Subject: [PATCH 5/5] Abort changes --- .../Path/PathScripts/PathDressupLeadInOut.py | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index f18c6851dd..64fc18e1ac 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -466,8 +466,9 @@ class ObjectDressup: class TaskPanel: - def __init__(self, obj): + def __init__(self, obj, view): self.obj = obj + self.viewProvider = view self.form = FreeCADGui.PySideUic.loadUi(":/panels/DressUpLeadInOutEdit.ui") self.setupUi() @@ -492,6 +493,12 @@ class TaskPanel: if button == QtGui.QDialogButtonBox.Apply: self.updateModel() FreeCAD.ActiveDocument.recompute() + if button == QtGui.QDialogButtonBox.Cancel: + self.abort() + + def abort(self): + FreeCAD.ActiveDocument.abortTransaction() + self.cleanup(True) def reject(self): FreeCAD.ActiveDocument.abortTransaction() @@ -504,6 +511,13 @@ class TaskPanel: FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() FreeCAD.ActiveDocument.recompute() + + def cleanup(self, gui): + self.viewProvider.clearTaskPanel() + if gui: + #FreeCADGui.ActiveDocument.resetEdit() + FreeCADGui.Control.closeDialog() + FreeCAD.ActiveDocument.recompute() def getFields(self): self.obj.LeadIn = self.form.chkLeadIn.isChecked() @@ -567,6 +581,7 @@ class ViewProviderDressup: def attach(self, vobj): self.obj = vobj.Object + self.panel = None def claimChildren(self): if hasattr(self.obj.Base, "InList"): @@ -584,10 +599,14 @@ class ViewProviderDressup: def setEdit(self, vobj, mode=0): # pylint: disable=unused-argument FreeCADGui.Control.closeDialog() - panel = TaskPanel(vobj.Object) + panel = TaskPanel(vobj.Object, self) FreeCADGui.Control.showDialog(panel) panel.setupUi() return True + + def unsetEdit(self, vobj, mode=0): + if self.panel: + self.panel.abort() def onDelete(self, arg1=None, arg2=None): '''this makes sure that the base operation is added back to the project and visible''' @@ -607,6 +626,9 @@ class ViewProviderDressup: def __setstate__(self, state): # pylint: disable=unused-argument return None + + def clearTaskPanel(self): + self.panel = None class CommandPathDressupLeadInOut: