Implemented interface functions in base classes.

This commit is contained in:
Markus Lampert
2017-09-24 16:03:31 -07:00
committed by Yorik van Havre
parent 18a3fc0580
commit 567f592d84
5 changed files with 46 additions and 0 deletions

View File

@@ -60,6 +60,11 @@ class ObjectOp(PathOp.ObjectOp):
Do not overwrite, implement areaOpFeatures(obj) instead.'''
return PathOp.FeatureTool | PathOp.FeatureDepths | PathOp.FeatureStepDown | PathOp.FeatureHeights | PathOp.FeatureStartPoint | self.areaOpFeatures(obj)
def areaOpFeatures(self, obj):
'''areaOpFeatures(obj) ... overwrite to add operation specific features.
Can safely be overwritten by subclasses.'''
return 0
def initOperation(self, obj):
'''initOperation(obj) ... sets up standard Path.Area properties and calls initAreaOp().
Do not overwrite, overwrite initAreaOp(obj) instead.'''
@@ -75,6 +80,11 @@ class ObjectOp(PathOp.ObjectOp):
self.initAreaOp(obj)
def initAreaOp(self, obj):
'''initAreaOp(obj) ... overwrite if the receiver class needs initialisation.
Can safely be overwritten by subclasses.'''
pass
def areaOpShapeForDepths(self, obj):
'''areaOpShapeForDepths(obj) ... returns the shape used to make an initial calculation for the depths being used.
The default implementation returns the job's Base.Shape'''

View File

@@ -57,12 +57,22 @@ class ObjectOp(PathOp.ObjectOp):
Do not overwrite, implement circularHoleFeatures(obj) instead'''
return PathOp.FeatureTool | PathOp.FeatureDepths | PathOp.FeatureHeights | PathOp.FeatureBaseFaces | self.circularHoleFeatures(obj)
def circularHoleFeatures(self, obj):
'''circularHoleFeatures(obj) ... overwrite to add operations specific features.
Can safely be overwritten by subclasses.'''
return 0
def initOperation(self, obj):
'''initOperation(obj) ... adds Disabled properties and calls initCircularHoleOperation(obj).
Do not overwrite, implement initCircularHoleOperation(obj) instead.'''
obj.addProperty("App::PropertyStringList", "Disabled", "Base", QtCore.QT_TRANSLATE_NOOP("Path", "List of disabled features"))
self.initCircularHoleOperation(obj)
def initCircularHoleOperation(self, obj):
'''initCircularHoleOperation(obj) ... overwrite if the subclass nees initialisation.
Can safely be overwritten by subclasses.'''
pass
def baseIsArchPanel(self, obj, base):
'''baseIsArchPanel(obj, base) ... return true if op deals with an Arch.Panel.'''
return hasattr(base, "Proxy") and isinstance(base.Proxy, ArchPanel.PanelSheet)

View File

@@ -171,6 +171,8 @@ class ViewProvider:
self.obj.Stock.ViewObject.Proxy.onEdit(_OpenCloseResourceEditor)
class StockEdit(object):
Index = -1
StockType = PathStock.StockType.Unknown
def __init__(self, obj, form):
self.obj = obj
@@ -207,6 +209,14 @@ class StockEdit(object):
def setLengthField(self, widget, prop):
widget.setText(FreeCAD.Units.Quantity(prop.Value, FreeCAD.Units.Length).UserString)
# the following members must be overwritten by subclasses
def editorFrame(self):
return None
def setFields(self, obj):
pass
def setupUi(self, obj):
pass
class StockFromBaseBoundBoxEdit(StockEdit):
Index = 2
StockType = PathStock.StockType.FromBase

View File

@@ -183,6 +183,12 @@ class ObjectOp(object):
Can safely be overwritten by subclasses.'''
pass
def opExecute(self, obj):
'''opExecute(obj) ... called whenever the receiver needs to be recalculated.
See documentation of execute() for a list of base functionality provided.
Should be overwritten by subclasses.'''
pass
def onChanged(self, obj, prop):
'''onChanged(obj, prop) ... base implementation of the FC notification framework.
Do not overwrite, overwrite opOnChanged() instead.'''

View File

@@ -53,6 +53,16 @@ class ObjectPocket(PathAreaOp.ObjectOp):
def pocketOpFeatures(self, obj):
return 0
def initPocketOp(self, obj):
'''initPocketOp(obj) ... overwrite to initialize subclass.
Can safely be overwritten by subclass.'''
pass
def pocketInvertExtraOffset(self):
'''pocketInvertExtraOffset() ... return True if ExtraOffset's direction is inward.
Can safely be overwritten by subclass.'''
return False
def initAreaOp(self, obj):
'''initAreaOp(obj) ... create pocket specific properties.
Do not overwrite, implement initPocketOp(obj) instead.'''