Removed depths lock - obsolete through usage of expressions.

This commit is contained in:
Markus Lampert
2017-10-08 10:33:45 -07:00
parent fb22e23981
commit 8d79228dce
4 changed files with 29 additions and 91 deletions

View File

@@ -14,7 +14,7 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="startDepth">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Start Depth of the operation. The highest point in Z-axis the operation needs to process.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@@ -30,7 +30,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="finalDepth">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The depth of the operation which corresponds to the lowest value in Z-axis the operation needs to process.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@@ -53,7 +53,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="finishDepth">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Depth of the final cut of the operation. Can be used to produce a cleaner finish.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@@ -69,7 +69,7 @@
</property>
</widget>
</item>
<item row="0" column="3">
<item row="0" column="2">
<widget class="QToolButton" name="startDepthSet">
<property name="text">
<string>...</string>
@@ -80,7 +80,7 @@
</property>
</widget>
</item>
<item row="1" column="3">
<item row="1" column="2">
<widget class="QToolButton" name="finalDepthSet">
<property name="text">
<string>...</string>
@@ -98,7 +98,7 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="4">
<item row="5" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -111,7 +111,7 @@
</property>
</spacer>
</item>
<item row="3" column="2">
<item row="3" column="1">
<widget class="Gui::QuantitySpinBox" name="stepDown">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The depth in Z-axis the operation moves downwards between layers.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;This value depends on the tool being used, the material to be cut, available cooling and many other factors. Please consult the tool manufacturers data sheets for the proper value.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@@ -141,33 +141,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="startDepthLock">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Lock Start Depth to specified value, prevent automatic recalculation.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="finalDepthLock">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Lock Start Depth to specified value, prevent automatic recalculation.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="2">
<item row="4" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -196,8 +170,6 @@
<tabstop>stepDown</tabstop>
<tabstop>startDepthSet</tabstop>
<tabstop>finalDepthSet</tabstop>
<tabstop>startDepthLock</tabstop>
<tabstop>finalDepthLock</tabstop>
</tabstops>
<resources>
<include location="../../../../../Gui/Icons/resource.qrc"/>

View File

@@ -72,6 +72,11 @@ class QuantitySpinBox:
else:
self.valid = False
def expression(self):
if self.valid:
return self.widget.property('expression')
return False
def updateSpinBox(self, quantity=None):
if self.valid:
if quantity is None:

View File

@@ -128,12 +128,9 @@ class ObjectOp(object):
if FeatureDepths & features:
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Starting Depth of Tool- first cut depth in Z"))
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Final Depth of Tool- lowest value in Z"))
obj.addProperty("App::PropertyBool", "StartDepthLock", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "If enabled Start Depth will not be automatically updated when geometry changes"))
obj.addProperty("App::PropertyBool", "FinalDepthLock", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "If enabled Final Depth will not be automatically updated when geometry changes"))
values = ['start']
if FeatureNoFinalDepth & features:
obj.setEditorMode('FinalDepth', 2) # hide
obj.setEditorMode('FinalDepthLock', 2) # hide
else:
values.append('final')
self.addOpValues(obj, values)
@@ -168,24 +165,18 @@ class ObjectOp(object):
obj.touch()
obj.Document.recompute()
if FeatureDepths & self.opFeatures(obj):
if not hasattr(obj, 'StartDepthLock'):
obj.addProperty("App::PropertyBool", "StartDepthLock", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "If enabled Start Depth will not be automatically updated when geometry changes"))
obj.StartDepthLock = False
if not hasattr(obj, 'FinalDepthLock'):
obj.addProperty("App::PropertyBool", "FinalDepthLock", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "If enabled Final Depth will not be automatically updated when geometry changes"))
obj.FinalDepthLock = False
if not hasattr(obj, 'OpStartDepth'):
self.addOpValues(obj, ['start', 'final'])
if not obj.StartDepthLock:
if not hasattr(obj, 'StartDepthLock') or not obj.StartDepthLock:
obj.setExpression('StartDepth', 'OpStartDepth')
if FeatureNoFinalDepth & features:
if FeatureNoFinalDepth & self.opFeatures(obj):
obj.setEditorMode('OpFinalDepth', 2)
elif not obj.FinalDepthLock:
elif not hasattr(obj, 'FinalDepthLock') or not obj.FinalDepthLock:
obj.setExpression('FinalDepth', 'OpFinalDepth')
if PatGeom.isRoughly(obj.StepDown.Value, 1):
if PathGeom.isRoughly(obj.StepDown.Value, 1):
obj.setExpression('StepDown', 'OpToolDiameter')
if FeatureStepDown & self.opFeatures(obj) and not hasattr(obj, 'OpToolDiameter'):
self.addOpValues(['tooldia'])
self.addOpValues(obj, ['tooldia'])
def __getstate__(self):
'''__getstat__(self) ... called when receiver is saved.
@@ -237,7 +228,7 @@ class ObjectOp(object):
'''onChanged(obj, prop) ... base implementation of the FC notification framework.
Do not overwrite, overwrite opOnChanged() instead.'''
if not 'Restore' in obj.State and prop in ['Base', 'StartDepth', 'StartDepthLock', 'FinalDepth', 'FinalDepthLock']:
if not 'Restore' in obj.State and prop in ['Base', 'StartDepth', 'FinalDepth']:
self.updateDepths(obj, True)
self.opOnChanged(obj, prop)
@@ -258,9 +249,7 @@ class ObjectOp(object):
obj.setExpression('StartDepth', 'OpStartDepth')
obj.setExpression('FinalDepth', 'OpFinalDepth')
obj.OpStartDepth = 1.0
obj.StartDepthLock = False
obj.OpFinalDepth = 0.0
obj.FinalDepthLock = False
if FeatureStepDown & features:
obj.OpToolDiameter = 1.0
@@ -331,15 +320,10 @@ class ObjectOp(object):
# clearing with stock boundaries
pass
safeDepths = True
if FeatureDepths & self.opFeatures(obj):
# first set update final depth, it's value is not negotiable
if not PathGeom.isRoughly(obj.OpFinalDepth.Value, zmin):
if not hasattr(obj, 'FinalDepthLock') or not obj.FinalDepthLock:
obj.OpFinalDepth = zmin
else:
if obj.OpFinalDepth.Value < zmin:
safeDepths = False
obj.OpFinalDepth = zmin
zmin = obj.OpFinalDepth.Value
def minZmax(z):
@@ -354,15 +338,7 @@ class ObjectOp(object):
# update start depth if requested and required
if not PathGeom.isRoughly(obj.OpStartDepth.Value, zmax):
if not hasattr(obj, 'StartDepthLock') or not obj.StartDepthLock:
obj.OpStartDepth = zmax
elif (obj.OpStartDepth.Value - 0.0001) <= obj.OpFinalDepth.Value:
obj.OpStartDepth = minZmax(obj.OpFinalDepth.Value)
else:
if obj.OpStartDepth.Value < zmax:
safeDepths = False
return safeDepths
obj.OpStartDepth = zmax
@waiting_effects
def execute(self, obj):

View File

@@ -569,7 +569,6 @@ class TaskPanelDepthsPage(TaskPanelPage):
if PathOp.FeatureNoFinalDepth & self.features:
self.form.finalDepth.hide()
self.form.finalDepthLabel.hide()
self.form.finalDepthLock.hide()
self.form.finalDepthSet.hide()
if not PathOp.FeatureStepDown & self.features:
@@ -580,27 +579,15 @@ class TaskPanelDepthsPage(TaskPanelPage):
self.form.finishDepth.hide()
self.form.finishDepthLabel.hide()
self.startDepth = PathGui.QuantitySpinBox(self.form.startDepth, obj, 'StartDepth', self.lockStartDepth)
self.finalDepth = PathGui.QuantitySpinBox(self.form.finalDepth, obj, 'FinalDepth', self.lockFinalDepth)
self.startDepth = PathGui.QuantitySpinBox(self.form.startDepth, obj, 'StartDepth')
self.finalDepth = PathGui.QuantitySpinBox(self.form.finalDepth, obj, 'FinalDepth')
self.finishDepth = PathGui.QuantitySpinBox(self.form.finishDepth, obj, 'FinishDepth')
self.stepDown = PathGui.QuantitySpinBox(self.form.stepDown, obj, 'StepDown')
def getTitle(self, obj):
return translate("PathOp", "Depths")
def lockStartDepth(self, obj):
if not obj.StartDepthLock:
obj.StartDepthLock = True
def lockFinalDepth(self, obj):
if not obj.FinalDepthLock:
obj.FinalDepthLock = True
def getFields(self, obj):
if obj.StartDepthLock != self.form.startDepthLock.isChecked():
obj.StartDepthLock = self.form.startDepthLock.isChecked()
if obj.FinalDepthLock != self.form.finalDepthLock.isChecked():
obj.FinalDepthLock = self.form.finalDepthLock.isChecked()
self.startDepth.updateProperty()
if not PathOp.FeatureNoFinalDepth & self.features:
self.finalDepth.updateProperty()
@@ -611,10 +598,8 @@ class TaskPanelDepthsPage(TaskPanelPage):
def setFields(self, obj):
self.startDepth.updateSpinBox()
self.form.startDepthLock.setChecked(obj.StartDepthLock)
if not PathOp.FeatureNoFinalDepth & self.features:
self.finalDepth.updateSpinBox()
self.form.finalDepthLock.setChecked(obj.FinalDepthLock)
if PathOp.FeatureStepDown & self.features:
self.stepDown.updateSpinBox()
if PathOp.FeatureFinishDepth & self.features:
@@ -624,10 +609,8 @@ class TaskPanelDepthsPage(TaskPanelPage):
def getSignalsForUpdate(self, obj):
signals = []
signals.append(self.form.startDepth.editingFinished)
signals.append(self.form.startDepthLock.clicked)
if not PathOp.FeatureNoFinalDepth & self.features:
signals.append(self.form.finalDepth.editingFinished)
signals.append(self.form.finalDepthLock.clicked)
if PathOp.FeatureStepDown & self.features:
signals.append(self.form.stepDown.editingFinished)
if PathOp.FeatureFinishDepth & self.features:
@@ -635,18 +618,20 @@ class TaskPanelDepthsPage(TaskPanelPage):
return signals
def registerSignalHandlers(self, obj):
self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.startDepth))
self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.startDepth, 'StartDepth'))
if not PathOp.FeatureNoFinalDepth & self.features:
self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.finalDepth))
self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.finalDepth, 'FinaleDepth'))
def pageUpdateData(self, obj, prop):
if prop in ['StartDepth', 'FinalDepth', 'StepDown', 'FinishDepth', 'FinalDepthLock', 'StartDepthLock']:
if prop in ['StartDepth', 'FinalDepth', 'StepDown', 'FinishDepth']:
self.setFields(obj)
def depthSet(self, obj, spinbox):
def depthSet(self, obj, spinbox, prop):
z = self.selectionZLevel(FreeCADGui.Selection.getSelectionEx())
if z is not None:
PathLog.debug("depthSet(%.2f)" % z)
if spinbox.expression():
obj.setExpression(prop, None)
spinbox.updateSpinBox(FreeCAD.Units.Quantity(z, FreeCAD.Units.Length))
spinbox.updateProperty()
else: