diff --git a/src/Mod/Path/Gui/Resources/panels/EngraveEdit.ui b/src/Mod/Path/Gui/Resources/panels/EngraveEdit.ui index f701bf8776..8d776ef3ba 100644 --- a/src/Mod/Path/Gui/Resources/panels/EngraveEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/EngraveEdit.ui @@ -31,7 +31,7 @@ 0 0 303 - 82 + 85 @@ -78,7 +78,7 @@ 0 0 303 - 82 + 85 @@ -173,40 +173,6 @@ - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - Algorithm - - - - - - - - OCC Native Outline - - - - - - - diff --git a/src/Mod/Path/PathScripts/PathContour.py b/src/Mod/Path/PathScripts/PathContour.py index 774c1b8dbb..9f457441df 100644 --- a/src/Mod/Path/PathScripts/PathContour.py +++ b/src/Mod/Path/PathScripts/PathContour.py @@ -40,7 +40,7 @@ FreeCAD.setLogLevel('Path.Area', 0) if FreeCAD.GuiUp: import FreeCADGui - from PySide import QtGui + # from PySide import QtGui # Qt tanslation handling @@ -85,6 +85,9 @@ class ObjectContour: obj.addProperty("App::PropertyString", "AreaParams", "Debug", QtCore.QT_TRANSLATE_NOOP("App::Property", "parameters used by PathArea")) obj.setEditorMode('AreaParams', 2) # hide + if FreeCAD.GuiUp: + _ViewProviderContour(obj.ViewObject) + obj.Proxy = self self.endVector = None @@ -285,12 +288,17 @@ class _ViewProviderContour: self.Object = vobj.Object return + def deleteObjectsOnReject(self): + return hasattr(self, 'deleteOnReject') and self.deleteOnReject + def setEdit(self, vobj, mode=0): FreeCADGui.Control.closeDialog() - taskd = TaskPanel() + taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject()) taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) taskd.setupUi() + self.deleteOnReject = False + return True def getIcon(self): @@ -344,7 +352,7 @@ class CommandPathContour: FreeCADGui.addModule("PathScripts.PathContour") FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Contour")') FreeCADGui.doCommand('PathScripts.PathContour.ObjectContour(obj)') - FreeCADGui.doCommand('PathScripts.PathContour._ViewProviderContour(obj.ViewObject)') + #FreeCADGui.doCommand('PathScripts.PathContour._ViewProviderContour(obj.ViewObject)') FreeCADGui.doCommand('obj.Active = True') @@ -357,8 +365,9 @@ class CommandPathContour: FreeCADGui.doCommand('obj.OffsetExtra = 0.0') FreeCADGui.doCommand('obj.Direction = "CW"') FreeCADGui.doCommand('obj.UseComp = True') - FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') + FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') + FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('PathScripts.PathContour.ObjectContour.setDepths(obj.Proxy, obj)') FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') @@ -368,22 +377,31 @@ class CommandPathContour: class TaskPanel: - def __init__(self): + def __init__(self, obj, deleteOnReject): + FreeCAD.ActiveDocument.openTransaction(translate("Path_Contour", "Contour Operation")) self.form = FreeCADGui.PySideUic.loadUi(":/panels/ContourEdit.ui") # self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ContourEdit.ui") + self.deleteOnReject = deleteOnReject self.updating = False def accept(self): self.getFields() - FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.abortTransaction() FreeCADGui.Selection.removeObserver(self.s) + if self.deleteOnReject: + FreeCAD.ActiveDocument.openTransaction(translate("Path_Contour", "Uncreate Contour Operation")) + FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() def getFields(self): @@ -454,8 +472,8 @@ class TaskPanel: # install the function mode resident FreeCADGui.Selection.addObserver(self.s) - def getStandardButtons(self): - return int(QtGui.QDialogButtonBox.Ok) + # def getStandardButtons(self): + # return int(QtGui.QDialogButtonBox.Ok) def setupUi(self): PathLog.track() diff --git a/src/Mod/Path/PathScripts/PathDrilling.py b/src/Mod/Path/PathScripts/PathDrilling.py index 7418784233..0e09797e7c 100644 --- a/src/Mod/Path/PathScripts/PathDrilling.py +++ b/src/Mod/Path/PathScripts/PathDrilling.py @@ -82,6 +82,9 @@ class ObjectDrilling: # Tool Properties obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path")) + if FreeCAD.GuiUp: + _ViewProviderDrill(obj.ViewObject) + obj.Proxy = self self.vertFeed = 0.0 self.horizFeed = 0.0 @@ -290,12 +293,16 @@ class _ViewProviderDrill: # this is executed when a property of the APP OBJECT changes pass + def deleteObjectsOnReject(self): + return hasattr(self, 'deleteOnReject') and self.deleteOnReject + def setEdit(self, vobj, mode=0): FreeCADGui.Control.closeDialog() - taskd = TaskPanel() + taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject()) taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) taskd.setupUi() + self.deleteOnReject = False return True def unsetEdit(self, vobj, mode): @@ -326,7 +333,8 @@ class CommandPathDrilling: FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Drilling")') FreeCADGui.doCommand('PathScripts.PathDrilling.ObjectDrilling(obj)') FreeCADGui.doCommand('obj.Active = True') - FreeCADGui.doCommand('PathScripts.PathDrilling._ViewProviderDrill(obj.ViewObject)') + #FreeCADGui.doCommand('PathScripts.PathDrilling._ViewProviderDrill(obj.ViewObject)') + FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') ztop = 10.0 zbottom = 0.0 @@ -335,26 +343,34 @@ class CommandPathDrilling: FreeCADGui.doCommand('obj.FinalDepth=' + str(zbottom)) FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') + FreeCADGui.doCommand('obj.ViewObject.startEditing()') FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() - FreeCADGui.doCommand('obj.ViewObject.startEditing()') class TaskPanel: - def __init__(self): + def __init__(self, obj, deleteOnReject): + FreeCAD.ActiveDocument.openTransaction(translate("Path_Drilling", "Drilling Operation")) self.form = FreeCADGui.PySideUic.loadUi(":/panels/DrillingEdit.ui") + self.deleteOnReject = deleteOnReject + self.obj = obj def accept(self): - FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() - # FreeCADGui.Selection.removeObserver(self.s) def reject(self): FreeCADGui.Control.closeDialog() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.abortTransaction() + if self.deleteOnReject: + FreeCAD.ActiveDocument.openTransaction(translate("Path_Drilling", "Uncreate Drilling Operation")) + FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() - # FreeCADGui.Selection.removeObserver(self.s) def getFields(self): PathLog.track() @@ -571,9 +587,6 @@ class TaskPanel: FreeCAD.ActiveDocument.recompute() - def getStandardButtons(self): - return int(QtGui.QDialogButtonBox.Ok) - def setupUi(self): PathLog.track() diff --git a/src/Mod/Path/PathScripts/PathEngrave.py b/src/Mod/Path/PathScripts/PathEngrave.py index d0d3fac146..1829226630 100644 --- a/src/Mod/Path/PathScripts/PathEngrave.py +++ b/src/Mod/Path/PathScripts/PathEngrave.py @@ -30,7 +30,7 @@ import Part import ArchPanel import PathScripts.PathLog as PathLog -from PySide import QtCore, QtGui +from PySide import QtCore from PathScripts import PathUtils """Path Engrave object and FreeCAD command""" @@ -51,9 +51,6 @@ class ObjectPathEngrave: obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "An optional comment for this profile")) obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "User Assigned Label")) - obj.addProperty("App::PropertyEnumeration", "Algorithm", "Algorithm", QtCore.QT_TRANSLATE_NOOP("App::Property", "The library or Algorithm used to generate the path")) - obj.Algorithm = ['OCC Native'] - # Tool Properties obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path")) @@ -121,8 +118,7 @@ class ObjectPathEngrave: tempedges = PathUtils.cleanedges(w.Edges, 0.5) wires.append(Part.Wire(tempedges)) - if obj.Algorithm == "OCC Native": - output += self.buildpathocc(obj, wires) + output += self.buildpathocc(obj, wires) elif isinstance(baseobject.Proxy, ArchPanel.PanelSheet): # process the sheet @@ -132,8 +128,7 @@ class ObjectPathEngrave: for w in shape.Wires: tempedges = PathUtils.cleanedges(w.Edges, 0.5) wires.append(Part.Wire(tempedges)) - if obj.Algorithm == "OCC Native": - output += self.buildpathocc(obj, wires) + output += self.buildpathocc(obj, wires) else: raise ValueError('Unknown baseobject type for engraving') @@ -216,12 +211,17 @@ class _ViewProviderEngrave: self.Object = vobj.Object return + def deleteObjectsOnReject(self): + return hasattr(self, 'deleteOnReject') and self.deleteOnReject + def setEdit(self, vobj, mode=0): FreeCADGui.Control.closeDialog() - taskd = TaskPanel() + taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject()) taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) taskd.setupUi() + self.deleteOnReject = False + return True def getIcon(self): @@ -264,18 +264,22 @@ class CommandPathEngrave: FreeCADGui.doCommand('obj.FinalDepth= -0.1') FreeCADGui.doCommand('obj.SafeHeight= 5.0') FreeCADGui.doCommand('obj.Active = True') + FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') + FreeCADGui.doCommand('obj.ViewObject.startEditing()') FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() - FreeCADGui.doCommand('obj.ViewObject.startEditing()') class TaskPanel: - def __init__(self): + def __init__(self, obj, deleteOnReject): + FreeCAD.ActiveDocument.openTransaction(translate("Path_Engrave", "Engraving Operation")) self.form = FreeCADGui.PySideUic.loadUi(":/panels/EngraveEdit.ui") + self.deleteOnReject = deleteOnReject + self.obj = obj def __del__(self): FreeCADGui.Selection.removeObserver(self.s) @@ -283,15 +287,23 @@ class TaskPanel: def accept(self): self.getFields() - FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.abortTransaction() FreeCADGui.Selection.removeObserver(self.s) + if self.deleteOnReject: + FreeCAD.ActiveDocument.openTransaction(translate("Path_Engrave", "Uncreate Engrave Operation")) + FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.commitTransaction() + FreeCAD.ActiveDocument.recompute() + def getFields(self): if self.obj: @@ -336,8 +348,8 @@ class TaskPanel: # install the function mode resident FreeCADGui.Selection.addObserver(self.s) - def getStandardButtons(self): - return int(QtGui.QDialogButtonBox.Ok) + # def getStandardButtons(self): + # return int(QtGui.QDialogButtonBox.Ok) def setupUi(self): diff --git a/src/Mod/Path/PathScripts/PathMillFace.py b/src/Mod/Path/PathScripts/PathMillFace.py index 6bf02ea673..b27b4a25ce 100644 --- a/src/Mod/Path/PathScripts/PathMillFace.py +++ b/src/Mod/Path/PathScripts/PathMillFace.py @@ -25,7 +25,7 @@ from __future__ import print_function import FreeCAD import Path -from PySide import QtCore, QtGui +from PySide import QtCore from PathScripts import PathUtils import Part from FreeCAD import Vector @@ -93,6 +93,9 @@ class ObjectFace: obj.addProperty("App::PropertyString", "AreaParams", "Debug", QtCore.QT_TRANSLATE_NOOP("App::Property", "parameters used by PathArea")) obj.setEditorMode('AreaParams', 2) # hide + if FreeCAD.GuiUp: + ViewProviderFace(obj.ViewObject) + obj.Proxy = self def onChanged(self, obj, prop): @@ -340,12 +343,16 @@ class ViewProviderFace: self.Object = vobj.Object return + def deleteObjectsOnReject(self): + return hasattr(self, 'deleteOnReject') and self.deleteOnReject + def setEdit(self, vobj, mode=0): FreeCADGui.Control.closeDialog() - taskd = TaskPanel() + taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject()) taskd.obj = vobj.Object taskd.setupUi() FreeCADGui.Control.showDialog(taskd) + self.deleteOnReject = False return True def getIcon(self): @@ -383,7 +390,7 @@ class CommandPathMillFace: FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Face")') FreeCADGui.doCommand('PathScripts.PathMillFace.ObjectFace(obj)') FreeCADGui.doCommand('obj.Active = True') - FreeCADGui.doCommand('PathScripts.PathMillFace.ViewProviderFace(obj.ViewObject)') + #FreeCADGui.doCommand('PathScripts.PathMillFace.ViewProviderFace(obj.ViewObject)') FreeCADGui.doCommand('from PathScripts import PathUtils') FreeCADGui.doCommand('obj.StepOver = 50') FreeCADGui.doCommand('obj.ClearanceHeight = 10') # + str(bb.ZMax + 2.0)) @@ -391,6 +398,8 @@ class CommandPathMillFace: FreeCADGui.doCommand('obj.StartDepth = ' + str(ztop + 1)) FreeCADGui.doCommand('obj.FinalDepth =' + str(ztop)) FreeCADGui.doCommand('obj.ZigZagAngle = 45.0') + FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') + FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') snippet = ''' @@ -406,31 +415,40 @@ else: obj.FinalDepth = str(baseobject.Shape.BoundBox.ZMax) ''' FreeCADGui.doCommand(snippet) + FreeCADGui.doCommand('obj.ViewObject.startEditing()') FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() - FreeCADGui.doCommand('obj.ViewObject.startEditing()') class TaskPanel: - def __init__(self): + def __init__(self, obj, deleteOnReject): + FreeCAD.ActiveDocument.openTransaction(translate("Path_MillFace", "Mill Facing Operation")) # self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/MillFaceEdit.ui") self.form = FreeCADGui.PySideUic.loadUi(":/panels/MillFaceEdit.ui") + self.deleteOnReject = deleteOnReject + self.obj = obj self.updating = False def accept(self): self.getFields() - FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.abortTransaction() FreeCADGui.Selection.removeObserver(self.s) + if self.deleteOnReject: + FreeCAD.ActiveDocument.openTransaction(translate("Path_MillFace", "Uncreate Mill Face Operation")) + FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.commitTransaction() + FreeCAD.ActiveDocument.recompute() def getFields(self): if self.obj: @@ -597,8 +615,8 @@ class TaskPanel: FreeCAD.ActiveDocument.recompute() - def getStandardButtons(self): - return int(QtGui.QDialogButtonBox.Ok) + # def getStandardButtons(self): + # return int(QtGui.QDialogButtonBox.Ok) def edit(self, item, column): if not self.updating: diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index eea9e7c8a6..2fb46b306a 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -39,7 +39,7 @@ FreeCAD.setLogLevel('Path.Area', 0) if FreeCAD.GuiUp: import FreeCADGui - from PySide import QtCore, QtGui + from PySide import QtCore # Qt tanslation handling def translate(context, text, disambig=None): @@ -89,6 +89,9 @@ class ObjectProfile: obj.addProperty("App::PropertyString", "AreaParams", "Debug", QtCore.QT_TRANSLATE_NOOP("App::Property", "parameters used by PathArea")) obj.setEditorMode('AreaParams', 2) # hide + if FreeCAD.GuiUp: + _ViewProviderProfile(obj.ViewObject) + obj.Proxy = self def __getstate__(self): @@ -333,12 +336,16 @@ class _ViewProviderProfile: self.Object = vobj.Object return + def deleteObjectsOnReject(self): + return hasattr(self, 'deleteOnReject') and self.deleteOnReject + def setEdit(self, vobj, mode=0): FreeCADGui.Control.closeDialog() - taskd = TaskPanel() + taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject()) taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) taskd.setupUi() + self.deleteOnReject = False return True def getIcon(self): @@ -407,7 +414,8 @@ class CommandPathProfile: FreeCADGui.doCommand('obj.UseComp = True') FreeCADGui.doCommand('obj.processHoles = False') FreeCADGui.doCommand('obj.processPerimeter = True') - FreeCADGui.doCommand('PathScripts.PathProfile._ViewProviderProfile(obj.ViewObject)') + #FreeCADGui.doCommand('PathScripts.PathProfile._ViewProviderProfile(obj.ViewObject)') + FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') @@ -417,22 +425,32 @@ class CommandPathProfile: class TaskPanel: - def __init__(self): + def __init__(self, obj, deleteOnReject): + FreeCAD.ActiveDocument.openTransaction(translate("Path_Profile", "Profile Operation")) self.form = FreeCADGui.PySideUic.loadUi(":/panels/ProfileEdit.ui") self.updating = False + self.deleteOnReject = deleteOnReject + self.obj = obj def accept(self): self.getFields() - FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.abortTransaction() FreeCADGui.Selection.removeObserver(self.s) + if self.deleteOnReject: + FreeCAD.ActiveDocument.openTransaction(translate("Path_Profile", "Uncreate Profile Operation")) + FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.commitTransaction() + FreeCAD.ActiveDocument.recompute() def getFields(self): if self.obj: @@ -591,9 +609,6 @@ class TaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() - def getStandardButtons(self): - return int(QtGui.QDialogButtonBox.Ok) - def setupUi(self): # Connect Signals and Slots diff --git a/src/Mod/Path/PathScripts/PathProfileEdges.py b/src/Mod/Path/PathScripts/PathProfileEdges.py index dc054ed30d..64d8a0e787 100644 --- a/src/Mod/Path/PathScripts/PathProfileEdges.py +++ b/src/Mod/Path/PathScripts/PathProfileEdges.py @@ -40,7 +40,7 @@ PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE) if FreeCAD.GuiUp: import FreeCADGui - from PySide import QtCore, QtGui + from PySide import QtCore # Qt tanslation handling def translate(context, text, disambig=None): @@ -88,6 +88,9 @@ class ObjectProfile: obj.addProperty("App::PropertyString", "AreaParams", "Debug", QtCore.QT_TRANSLATE_NOOP("App::Property", "parameters used by PathArea")) obj.setEditorMode('AreaParams', 2) # hide + if FreeCAD.GuiUp: + _ViewProviderProfile(obj.ViewObject) + obj.Proxy = self def __getstate__(self): @@ -200,23 +203,23 @@ class ObjectProfile: PathLog.debug("Generating Path with params: {}".format(params)) PathLog.debug(pp) - if True: - from PathScripts.PathUtils import CollisionTester - parentJob = PathUtils.findParentJob(obj) - if parentJob is None: - pass - base = parentJob.Base - if base is None: - pass + # if True: + # from PathScripts.PathUtils import CollisionTester + # parentJob = PathUtils.findParentJob(obj) + # if parentJob is None: + # pass + # base = parentJob.Base + # if base is None: + # pass - profileparams['Thicken'] = True #{'Fill':0, 'Coplanar':0, 'Project':True, 'SectionMode':2, 'Thicken':True} - profileparams['ToolRadius']= self.radius - self.radius *.005 - profile.setParams(**profileparams) - sec = profile.makeSections(heights=[0.0])[0].getShape() - cutPath = sec.extrude(FreeCAD.Vector(0,0,baseobject.BoundBox.ZMax)) - c = CollisionTester() - c.getCollisionSim(base.Shape, cutPath) - return pp + # profileparams['Thicken'] = True #{'Fill':0, 'Coplanar':0, 'Project':True, 'SectionMode':2, 'Thicken':True} + # profileparams['ToolRadius']= self.radius - self.radius *.005 + # profile.setParams(**profileparams) + # sec = profile.makeSections(heights=[0.0])[0].getShape() + # cutPath = sec.extrude(FreeCAD.Vector(0,0,baseobject.BoundBox.ZMax)) + # c = CollisionTester() + # c.getCollisionSim(base.Shape, cutPath) + # return pp def execute(self, obj): @@ -302,12 +305,16 @@ class _ViewProviderProfile: self.Object = vobj.Object return + def deleteObjectsOnReject(self): + return hasattr(self, 'deleteOnReject') and self.deleteOnReject + def setEdit(self, vobj, mode=0): FreeCADGui.Control.closeDialog() - taskd = TaskPanel() + taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject()) taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) taskd.setupUi() + self.deleteOnReject = False return True def getIcon(self): @@ -380,7 +387,8 @@ class CommandPathProfileEdges: FreeCADGui.addModule("PathScripts.PathProfile") FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Edge Profile")') FreeCADGui.doCommand('PathScripts.PathProfileEdges.ObjectProfile(obj)') - FreeCADGui.doCommand('PathScripts.PathProfileEdges._ViewProviderProfile(obj.ViewObject)') + #FreeCADGui.doCommand('PathScripts.PathProfileEdges._ViewProviderProfile(obj.ViewObject)') + FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') FreeCADGui.doCommand('obj.Active = True') @@ -404,24 +412,33 @@ class CommandPathProfileEdges: class TaskPanel: - def __init__(self): + def __init__(self, obj, deleteOnReject): + FreeCAD.ActiveDocument.openTransaction(translate("Path_ProfileEdges", "ProfileEdges Operation")) self.form = FreeCADGui.PySideUic.loadUi(":/panels/ProfileEdgesEdit.ui") # self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ProfileEdgesEdit.ui") - + self.deleteOnReject = deleteOnReject + self.obj = obj self.updating = False def accept(self): self.getFields() - FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.abortTransaction() FreeCADGui.Selection.removeObserver(self.s) + if self.deleteOnReject: + FreeCAD.ActiveDocument.openTransaction(translate("Path_ProfileEdges", "Uncreate ProfileEdges Operation")) + FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.commitTransaction() + FreeCAD.ActiveDocument.recompute() def getFields(self): if self.obj: @@ -570,9 +587,6 @@ class TaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() - def getStandardButtons(self): - return int(QtGui.QDialogButtonBox.Ok) - def setupUi(self): # Connect Signals and Slots diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index e2a5d7e498..48120ef3cb 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -36,11 +36,11 @@ if sys.version_info.major >= 3: LOG_MODULE = 'PathSurface' PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) -#PathLog.trackModule('PathSurface') +# PathLog.trackModule('PathSurface') if FreeCAD.GuiUp: import FreeCADGui - from PySide import QtCore, QtGui + from PySide import QtCore __title__ = "Path Surface Operation" __author__ = "sliptonic (Brad Collette)" @@ -48,10 +48,12 @@ __url__ = "http://www.freecadweb.org" """Path surface object and FreeCAD command""" + # Qt tanslation handling def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) + class ObjectSurface: def __init__(self, obj): @@ -85,6 +87,9 @@ class ObjectSurface: self.horizRapid = 0.0 self.radius = 0.0 + if FreeCAD.GuiUp: + ViewProviderSurface(obj.ViewObject) + obj.Proxy = self def addsurfacebase(self, obj, ss, sub=""): @@ -311,7 +316,7 @@ class ObjectSurface: from PathScripts.PathPreferences import PathPreferences deflection = PathPreferences.defaultGeometryTolerance() - mesh = MeshPart.meshFromShape(mesh.Shape, Deflection = deflection) + mesh = MeshPart.meshFromShape(mesh.Shape, Deflection=deflection) bb = mesh.BoundBox @@ -352,6 +357,9 @@ class ViewProviderSurface: def __setstate__(self, state): # mandatory return None + def deleteObjectsOnReject(self): + return hasattr(self, 'deleteOnReject') and self.deleteOnReject + def getIcon(self): # optional return ":/icons/Path-Surfacing.svg" @@ -365,10 +373,12 @@ class ViewProviderSurface: def setEdit(self, vobj, mode=0): FreeCADGui.Control.closeDialog() - taskd = TaskPanel() + taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject()) + taskd.obj = vobj.Object FreeCADGui.Control.showDialog(taskd) taskd.setupUi() + self.deleteOnReject = False return True def unsetEdit(self, vobj, mode): # optional @@ -403,42 +413,53 @@ class CommandPathSurfacing: 'obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Surface")') FreeCADGui.doCommand('PathScripts.PathSurface.ObjectSurface(obj)') FreeCADGui.doCommand('obj.Active = True') - FreeCADGui.doCommand( - 'PathScripts.PathSurface.ViewProviderSurface(obj.ViewObject)') + # FreeCADGui.doCommand( + # 'PathScripts.PathSurface.ViewProviderSurface(obj.ViewObject)') FreeCADGui.doCommand('from PathScripts import PathUtils') FreeCADGui.doCommand('obj.ClearanceHeight = ' + str(ztop + 2)) FreeCADGui.doCommand('obj.StartDepth = ' + str(ztop)) FreeCADGui.doCommand('obj.SafeHeight = ' + str(ztop + 2)) FreeCADGui.doCommand('obj.StepDown = ' + str((ztop - zbottom) / 8)) FreeCADGui.doCommand('obj.SampleInterval = 0.4') + FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') FreeCADGui.doCommand('obj.FinalDepth=' + str(zbottom)) FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') + FreeCADGui.doCommand('obj.ViewObject.startEditing()') FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() - FreeCADGui.doCommand('obj.ViewObject.startEditing()') class TaskPanel: - def __init__(self): + def __init__(self, obj, deleteOnReject): # self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/SurfaceEdit.ui") + FreeCAD.ActiveDocument.openTransaction(translate("Path_Surface", "Surfacing Operation")) self.form = FreeCADGui.PySideUic.loadUi(":/panels/SurfaceEdit.ui") FreeCAD.Console.PrintWarning("Surface calculations can be slow. Don't Panic.\n") + self.deleteOnReject = deleteOnReject + self.obj = obj def accept(self): self.getFields() - FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.resetEdit() + FreeCAD.ActiveDocument.abortTransaction() FreeCADGui.Selection.removeObserver(self.s) + if self.deleteOnReject: + FreeCAD.ActiveDocument.openTransaction(translate("Path_Surface", "Uncreate Surface")) + FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.commitTransaction() + FreeCAD.ActiveDocument.recompute() def getFields(self): if self.obj: @@ -571,8 +592,8 @@ class TaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() - def getStandardButtons(self): - return int(QtGui.QDialogButtonBox.Ok) + # def getStandardButtons(self): + # return int(QtGui.QDialogButtonBox.Ok) def setupUi(self): # Base Geometry