Placement preferences for stock.

This commit is contained in:
Markus Lampert
2017-09-29 19:06:25 -07:00
committed by wmayer
parent d436239785
commit 9f9eb42b78
3 changed files with 129 additions and 5 deletions

View File

@@ -41,7 +41,6 @@ if False:
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
"""Path Job object and FreeCAD command"""

View File

@@ -85,6 +85,17 @@ class JobPreferencesPage:
attrs['ypos'] = FreeCAD.Units.Quantity(self.form.stockExtYpos.text()).UserString
attrs['zneg'] = FreeCAD.Units.Quantity(self.form.stockExtZneg.text()).UserString
attrs['zpos'] = FreeCAD.Units.Quantity(self.form.stockExtZpos.text()).UserString
if self.form.stockPlacementGroup.isChecked():
angle = FreeCAD.Units.Quantity(self.form.stockAngle.text()).Value
axis = FreeCAD.Vector(self.form.stockAxisX.value(), self.form.stockAxisY.value(), self.form.stockAxisZ.value())
rot = FreeCAD.Rotation(axis, angle)
attrs['rotX'] = rot.Q[0]
attrs['rotY'] = rot.Q[1]
attrs['rotZ'] = rot.Q[2]
attrs['rotW'] = rot.Q[3]
attrs['posX'] = FreeCAD.Units.Quantity(self.form.stockPositionX.text()).Value
attrs['posY'] = FreeCAD.Units.Quantity(self.form.stockPositionY.text()).Value
attrs['posZ'] = FreeCAD.Units.Quantity(self.form.stockPositionZ.text()).Value
PathPreferences.setDefaultStockTemplate(json.dumps(attrs))
else:
PathPreferences.setDefaultStockTemplate('')
@@ -184,6 +195,30 @@ class JobPreferencesPage:
self.form.stockCylinderRadius.setText(attrs.get('radius', '5 mm'))
self.form.stockCylinderHeight.setText(attrs.get('height', '10 mm'))
posX = attrs.get('posX')
posY = attrs.get('posY')
posZ = attrs.get('posZ')
rotX = attrs.get('rotX')
rotY = attrs.get('rotY')
rotZ = attrs.get('rotZ')
rotW = attrs.get('rotW')
if posX is not None and posY is not None and posZ is not None and rotX is not None and rotY is not None and rotZ is not None and rotW is not None:
pos = FreeCAD.Vector(float(posX), float(posY), float(posZ))
rot = FreeCAD.Rotation(float(rotX), float(rotY), float(rotZ), float(rotW))
placement = FreeCAD.Placement(pos, rot)
self.form.stockPlacementGroup.setChecked(True)
else:
placement = FreeCAD.Placement()
self.form.stockPlacementGroup.setChecked(False)
self.form.stockAngle.setText(FreeCAD.Units.Quantity("%f rad" % placement.Rotation.Angle).UserString)
self.form.stockAxisX.setValue(placement.Rotation.Axis.x)
self.form.stockAxisY.setValue(placement.Rotation.Axis.y)
self.form.stockAxisZ.setValue(placement.Rotation.Axis.z)
self.form.stockPositionX.setText(FreeCAD.Units.Quantity(placement.Base.x, FreeCAD.Units.Length).UserString)
self.form.stockPositionY.setText(FreeCAD.Units.Quantity(placement.Base.y, FreeCAD.Units.Length).UserString)
self.form.stockPositionZ.setText(FreeCAD.Units.Quantity(placement.Base.z, FreeCAD.Units.Length).UserString)
self.setupStock(index)
self.form.stock.currentIndexChanged.connect(self.setupStock)