Add job as parameter to opSetDefaultValues

This commit is contained in:
Markus Lampert
2018-08-19 13:34:29 -07:00
parent b93d39f701
commit 070d17e4e4
14 changed files with 33 additions and 37 deletions

View File

@@ -140,8 +140,8 @@ class ObjectOp(PathOp.ObjectOp):
'''opSetDefaultValues(obj) ... base implementation, do not overwrite.
The base implementation sets the depths and heights based on the
areaOpShapeForDepths() return value.
Do not overwrite, overwrite areaOpSetDefaultValues(obj) instead.'''
PathLog.debug("opSetDefaultValues(%s)" % (obj.Label))
Do not overwrite, overwrite areaOpSetDefaultValues(obj, job) instead.'''
PathLog.debug("opSetDefaultValues(%s, %s)" % (obj.Label, job.Label))
if PathOp.FeatureDepths & self.opFeatures(obj):
try:
shape = self.areaOpShapeForDepths(obj)
@@ -156,10 +156,10 @@ class ObjectOp(PathOp.ObjectOp):
obj.OpStartDepth = 1.0
obj.OpFinalDepth = 0.0
self.areaOpSetDefaultValues(obj)
self.areaOpSetDefaultValues(obj, job)
def areaOpSetDefaultValues(self, obj):
'''areaOpSetDefaultValues(obj) ... overwrite to set initial values of operation specific properties.
def areaOpSetDefaultValues(self, obj, job):
'''areaOpSetDefaultValues(obj, job) ... overwrite to set initial values of operation specific properties.
Can safely be overwritten by subclasses.'''
pass

View File

@@ -113,8 +113,8 @@ class ObjectChamfer(PathEngraveBase.ObjectOp):
'''The chamfer op can only deal with features of the base model, all others are rejected.'''
return base != self.baseobject
def opSetDefaultValues(self, obj):
PathLog.track(obj.Label)
def opSetDefaultValues(self, obj, job):
PathLog.track(obj.Label, job.Label)
obj.Width = '1 mm'
obj.ExtraDepth = '0.1 mm'
obj.Join = 'Round'

View File

@@ -116,8 +116,8 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp):
self.commandlist.append(Path.Command('G80'))
def opSetDefaultValues(self, obj):
'''opSetDefaultValues(obj) ... set default value for RetractHeight'''
def opSetDefaultValues(self, obj, job):
'''opSetDefaultValues(obj, job) ... set default value for RetractHeight'''
obj.RetractHeight = 10
def Create(name):

View File

@@ -147,7 +147,8 @@ class ObjectEngrave(PathEngraveBase.ObjectOp):
def opUpdateDepths(self, obj, ignoreErrors=False):
'''updateDepths(obj) ... engraving is always done at the top most z-value'''
self.opSetDefaultValues(obj)
job = PathUtils.findParentJob(obj)
self.opSetDefaultValues(obj, job)
def Create(name):
'''Create(name) ... Creates and returns an Engrave operation.'''

View File

@@ -150,10 +150,9 @@ class ObjectOp(PathOp.ObjectOp):
params.update({'Z': z, 'F': self.horizFeed})
self.commandlist.append(Path.Command(cmd.Name, params))
def opSetDefaultValues(self, obj):
'''opSetDefaultValues(obj) ... set depths for engraving'''
def opSetDefaultValues(self, obj, job):
'''opSetDefaultValues(obj, job) ... set depths for engraving'''
if PathOp.FeatureDepths & self.opFeatures(obj):
job = PathUtils.findParentJob(obj)
if job and job.Base:
bb = job.Base.Shape.BoundBox
obj.OpStartDepth = bb.ZMax

View File

@@ -187,7 +187,7 @@ class ObjectHelix(PathCircularHoleBase.ObjectOp):
return out
def opSetDefaultValues(self, obj):
def opSetDefaultValues(self, obj, job):
obj.Direction = "CW"
obj.StartSide = "Inside"
obj.StepOver = 100

View File

@@ -124,13 +124,11 @@ class ObjectFace(PathPocketBase.ObjectPocket):
return [(env, False)]
def areaOpSetDefaultValues(self, obj):
'''areaOpSetDefaultValues(obj) ... initialize mill facing properties'''
def areaOpSetDefaultValues(self, obj, job):
'''areaOpSetDefaultValues(obj, job) ... initialize mill facing properties'''
obj.StepOver = 50
obj.ZigZagAngle = 45.0
job = PathUtils.findParentJob(obj)
# need to overwrite the default depth calculations for facing
if job and job.Base:
obj.OpStartDepth = job.Stock.Shape.BoundBox.ZMax

View File

@@ -236,8 +236,8 @@ class ObjectOp(object):
Can safely be overwritten by subclasses.'''
pass
def opSetDefaultValues(self, obj):
'''opSetDefaultValues(obj) ... overwrite to set initial default values.
def opSetDefaultValues(self, obj, job):
'''opSetDefaultValues(obj, job) ... overwrite to set initial default values.
Called after the receiver has been fully created with all properties.
Can safely be overwritten by subclasses.'''
pass
@@ -319,7 +319,7 @@ class ObjectOp(object):
if FeatureStartPoint & features:
obj.UseStartPoint = False
self.opSetDefaultValues(obj)
self.opSetDefaultValues(obj, job)
obj.recompute()
return True

View File

@@ -88,8 +88,8 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
removalshapes = [(obj.removalshape, False)]
return removalshapes
def areaOpSetDefaultValues(self, obj):
'''areaOpSetDefaultValues(obj) ... set default values'''
def areaOpSetDefaultValues(self, obj, job):
'''areaOpSetDefaultValues(obj, job) ... set default values'''
obj.StepOver = 100
obj.ZigZagAngle = 45

View File

@@ -147,11 +147,10 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
obj.removalshape = self.removalshapes[0][0]
return self.removalshapes
def areaOpSetDefaultValues(self, obj):
'''areaOpSetDefaultValues(obj) ... set default values'''
def areaOpSetDefaultValues(self, obj, job):
'''areaOpSetDefaultValues(obj, job) ... set default values'''
obj.StepOver = 100
obj.ZigZagAngle = 45
job = PathUtils.findParentJob(obj)
if job and job.Stock:
bb = job.Stock.Shape.BoundBox
obj.OpFinalDepth = bb.ZMin

View File

@@ -135,8 +135,8 @@ class ObjectProfile(PathAreaOp.ObjectOp):
'''areaOpUseProjection(obj) ... returns True'''
return True
def areaOpSetDefaultValues(self, obj):
'''areaOpSetDefaultValues(obj) ... sets default values.
def areaOpSetDefaultValues(self, obj, job):
'''areaOpSetDefaultValues(obj, job) ... sets default values.
Do not overwrite.'''
obj.Side = "Outside"
obj.OffsetExtra = 0.0

View File

@@ -73,9 +73,9 @@ class ObjectContour(PathProfileBase.ObjectProfile):
def areaOpOnDocumentRestored(self, obj):
obj.setEditorMode('Side', 2) # it's always outside
def areaOpSetDefaultValues(self, obj):
'''areaOpSetDefaultValues(obj) ... call super's implementation and set Side="Outside".'''
self.baseObject().areaOpSetDefaultValues(obj)
def areaOpSetDefaultValues(self, obj, job):
'''areaOpSetDefaultValues(obj, job) ... call super's implementation and set Side="Outside".'''
self.baseObject().areaOpSetDefaultValues(obj, job)
obj.Side = 'Outside'
def areaOpShapes(self, obj):

View File

@@ -130,9 +130,9 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
PathLog.debug("%d shapes" % len(shapes))
return shapes
def areaOpSetDefaultValues(self, obj):
'''areaOpSetDefaultValues(obj) ... sets default values for hole, circle and perimeter processing.'''
self.baseObject().areaOpSetDefaultValues(obj)
def areaOpSetDefaultValues(self, obj, job):
'''areaOpSetDefaultValues(obj, job) ... sets default values for hole, circle and perimeter processing.'''
self.baseObject().areaOpSetDefaultValues(obj, job)
obj.processHoles = False
obj.processCircles = False

View File

@@ -308,13 +308,12 @@ class ObjectSurface(PathOp.ObjectOp):
def pocketInvertExtraOffset(self):
return True
def opSetDefaultValues(self, obj):
'''opSetDefaultValues(obj) ... initialize defauts'''
def opSetDefaultValues(self, obj, job):
'''opSetDefaultValues(obj, job) ... initialize defauts'''
# obj.ZigZagAngle = 45.0
obj.StepOver = 50
# need to overwrite the default depth calculations for facing
job = PathUtils.findParentJob(obj)
if job and job.Base:
d = PathUtils.guessDepths(job.Base.Shape, None)
obj.OpStartDepth = d.start_depth