Path: Allow parent job assignment

Modifications focus on allowing the creation of operations to include direct provision of parent job.
Path: Remove `useGui` implementation
This commit is contained in:
Russell Johnson
2021-08-12 22:26:57 -05:00
parent a5fcb3b225
commit 4c1951aedc
22 changed files with 53 additions and 49 deletions

View File

@@ -737,9 +737,9 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Adaptive operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = PathAdaptive(obj, name)
obj.Proxy = PathAdaptive(obj, name, parentJob)
return obj

View File

@@ -70,9 +70,9 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Custom operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectCustom(obj, name)
obj.Proxy = ObjectCustom(obj, name, parentJob)
return obj

View File

@@ -291,10 +291,9 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Deburr operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectDeburr(obj, name)
obj.Proxy = ObjectDeburr(obj, name, parentJob)
return obj

View File

@@ -159,12 +159,13 @@ def SetupProperties():
setup.append("RetractHeight")
return setup
def Create(name, obj = None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Drilling operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectDrilling(obj, name)
obj.Proxy = ObjectDrilling(obj, name, parentJob)
if obj.Proxy:
obj.Proxy.findAllHoles(obj)

View File

@@ -48,8 +48,8 @@ def translate(context, text, disambig=None):
class ObjectEngrave(PathEngraveBase.ObjectOp):
'''Proxy class for Engrave operation.'''
def __init__(self, obj, name):
super(ObjectEngrave, self).__init__(obj, name)
def __init__(self, obj, name, parentJob):
super(ObjectEngrave, self).__init__(obj, name, parentJob)
self.wires = []
def opFeatures(self, obj):
@@ -144,9 +144,9 @@ def SetupProperties():
return ["StartVertex"]
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns an Engrave operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectEngrave(obj, name)
obj.Proxy = ObjectEngrave(obj, name, parentJob)
return obj

View File

@@ -214,11 +214,11 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Helix operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectHelix(obj, name)
obj.Proxy = ObjectHelix(obj, name, parentJob)
if obj.Proxy:
obj.Proxy.findAllHoles(obj)
return obj

View File

@@ -175,8 +175,8 @@ class ViewProvider:
FreeCADGui.Control.closeDialog()
FreeCADGui.Control.showDialog(self.taskPanel)
self.taskPanel.setupUi(activate)
self.deleteOnReject = False
self.showOriginAxis(True)
self.deleteOnReject = False
def resetTaskPanel(self):
self.showOriginAxis(False)

View File

@@ -304,9 +304,9 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Mill Facing operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectFace(obj, name)
obj.Proxy = ObjectFace(obj, name, parentJob)
return obj

View File

@@ -119,7 +119,7 @@ class ObjectOp(object):
obj.addProperty("App::PropertyDistance", "OpStockZMin", "Op Values", QtCore.QT_TRANSLATE_NOOP("PathOp", "Holds the min Z value of Stock"))
obj.setEditorMode('OpStockZMin', 1) # read-only
def __init__(self, obj, name):
def __init__(self, obj, name, parentJob=None):
PathLog.track()
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("PathOp", "Make False, to prevent operation from generating code"))
@@ -190,6 +190,8 @@ class ObjectOp(object):
self.initOperation(obj)
if not hasattr(obj, 'DoNotSetDefaultValues') or not obj.DoNotSetDefaultValues:
if parentJob:
self.job = PathUtils.addToJob(obj, jobname=parentJob.Name)
job = self.setDefaultValues(obj)
if job:
job.SetupSheet.Proxy.setOperationProperties(obj, name)
@@ -322,7 +324,10 @@ class ObjectOp(object):
def setDefaultValues(self, obj):
'''setDefaultValues(obj) ... base implementation.
Do not overwrite, overwrite opSetDefaultValues() instead.'''
job = PathUtils.addToJob(obj)
if self.job:
job = self.job
else:
job = PathUtils.addToJob(obj)
obj.Active = True
@@ -622,5 +627,3 @@ class ObjectOp(object):
This function can safely be overwritten by subclasses.'''
return True

View File

@@ -1280,12 +1280,12 @@ def Create(res):
this function directly, but calls the Activated() function of the Command object
that is created in each operations Gui implementation.'''
FreeCAD.ActiveDocument.openTransaction("Create %s" % res.name)
obj = res.objFactory(res.name)
obj = res.objFactory(res.name, obj=None, parentJob=res.job)
if obj.Proxy:
obj.ViewObject.Proxy = ViewProvider(obj.ViewObject, res)
obj.ViewObject.Visibility = False
FreeCAD.ActiveDocument.commitTransaction()
obj.ViewObject.Document.setEdit(obj.ViewObject, 0)
return obj
FreeCAD.ActiveDocument.abortTransaction()
@@ -1329,6 +1329,7 @@ class CommandResources:
self.menuText = menuText
self.accelKey = accelKey
self.toolTip = toolTip
self.job = None
def SetupOperation(name,

View File

@@ -717,9 +717,9 @@ def SetupProperties():
return PathPocketBase.SetupProperties() + ["HandleMultipleFeatures"]
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Pocket operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectPocket(obj, name)
obj.Proxy = ObjectPocket(obj, name, parentJob)
return obj

View File

@@ -242,11 +242,11 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Pocket operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject('Path::FeaturePython', name)
obj.Proxy = ObjectPocket(obj, name)
obj.Proxy = ObjectPocket(obj, name, parentJob)
return obj
return obj

View File

@@ -97,9 +97,9 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Probing operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectProbing(obj, name)
proxy = ObjectProbing(obj, name, parentJob)
return obj

View File

@@ -1301,9 +1301,9 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Profile based on faces operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectProfile(obj, name)
obj.Proxy = ObjectProfile(obj, name, parentJob)
return obj

View File

@@ -42,9 +42,9 @@ def SetupProperties():
return PathProfile.SetupProperties()
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Profile operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectContour(obj, name)
obj.Proxy = ObjectContour(obj, name, parentJob)
return obj

View File

@@ -43,9 +43,9 @@ def SetupProperties():
return PathProfile.SetupProperties()
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Profile operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectProfile(obj, name)
obj.Proxy = ObjectProfile(obj, name, parentJob)
return obj

View File

@@ -44,9 +44,9 @@ def SetupProperties():
return PathProfile.SetupProperties()
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Profile operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectProfile(obj, name)
obj.Proxy = ObjectProfile(obj, name, parentJob)
return obj

View File

@@ -1767,9 +1767,9 @@ def SetupProperties():
return [tup[1] for tup in ObjectSlot.opPropertyDefinitions(False)]
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Slot operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectSlot(obj, name)
obj.Proxy = ObjectSlot(obj, name, parentJob)
return obj

View File

@@ -2124,9 +2124,9 @@ def SetupProperties():
return [tup[1] for tup in ObjectSurface.opPropertyDefinitions(False)]
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Surface operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectSurface(obj, name)
obj.Proxy = ObjectSurface(obj, name, parentJob)
return obj

View File

@@ -327,11 +327,11 @@ def SetupProperties():
return setup
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a thread milling operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectThreadMilling(obj, name)
obj.Proxy = ObjectThreadMilling(obj, name, parentJob)
if obj.Proxy:
obj.Proxy.findAllHoles(obj)
return obj

View File

@@ -363,9 +363,9 @@ def SetupProperties():
return ["Discretize"]
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Vcarve operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
ObjectVcarve(obj, name)
obj.Proxy = ObjectVcarve(obj, name, parentJob)
return obj

View File

@@ -1814,9 +1814,9 @@ def SetupProperties():
return [tup[1] for tup in ObjectWaterline.opPropertyDefinitions(False)]
def Create(name, obj=None):
def Create(name, obj=None, parentJob=None):
'''Create(name) ... Creates and returns a Waterline operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectWaterline(obj, name)
obj.Proxy = ObjectWaterline(obj, name, parentJob)
return obj