Skip to content

Commit

Permalink
PATH:Tooledit:support for units
Browse files Browse the repository at this point in the history
connected units to ToolEdit and listview in the tooltable library
  • Loading branch information
danielfalck committed Dec 24, 2016
1 parent 1d2c392 commit 605d4da
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 28 deletions.
34 changes: 17 additions & 17 deletions src/Mod/Path/Gui/Resources/panels/ContourEdit.ui
Expand Up @@ -31,7 +31,7 @@
<x>0</x>
<y>0</y>
<width>334</width>
<height>318</height>
<height>313</height>
</rect>
</property>
<attribute name="icon">
Expand Down Expand Up @@ -66,19 +66,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QDoubleSpinBox" name="stepDown">
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
Expand All @@ -93,6 +80,19 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QDoubleSpinBox" name="stepDown">
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="Heights">
Expand All @@ -101,7 +101,7 @@
<x>0</x>
<y>0</y>
<width>334</width>
<height>318</height>
<height>313</height>
</rect>
</property>
<attribute name="icon">
Expand Down Expand Up @@ -151,7 +151,7 @@
<x>0</x>
<y>0</y>
<width>334</width>
<height>318</height>
<height>313</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -209,7 +209,7 @@
<x>0</x>
<y>0</y>
<width>334</width>
<height>318</height>
<height>313</height>
</rect>
</property>
<attribute name="icon">
Expand Down
12 changes: 6 additions & 6 deletions src/Mod/Path/Gui/Resources/panels/ToolEdit.ui
Expand Up @@ -212,7 +212,7 @@
<item row="6" column="1">
<widget class="Gui::InputField" name="DiameterField">
<property name="text">
<string>12.7 mm</string>
<string>0 mm</string>
</property>
<property name="singleStep">
<double>0.125000000000000</double>
Expand All @@ -231,7 +231,7 @@
<item row="8" column="1">
<widget class="Gui::InputField" name="LengthOffsetField">
<property name="text">
<string>25.4 mm</string>
<string>0 mm</string>
</property>
<property name="maximum">
<double>100.000000000000000</double>
Expand All @@ -247,7 +247,7 @@
<item row="12" column="1">
<widget class="Gui::InputField" name="FlatRadiusField">
<property name="text">
<string>0.00 mm</string>
<string>0 mm</string>
</property>
<property name="maximum">
<double>100.000000000000000</double>
Expand All @@ -263,7 +263,7 @@
<item row="14" column="1">
<widget class="Gui::InputField" name="CornerRadiusField">
<property name="text">
<string>0.00 mm</string>
<string>0 mm</string>
</property>
<property name="maximum">
<double>100.000000000000000</double>
Expand All @@ -272,14 +272,14 @@
<double>0.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
<string notr="true">mm</string>
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="Gui::InputField" name="CuttingEdgeHeightField">
<property name="text">
<string>25.4 mm</string>
<string>0 mm</string>
</property>
<property name="maximum">
<double>100.000000000000000</double>
Expand Down
37 changes: 32 additions & 5 deletions src/Mod/Path/PathScripts/PathToolLibraryManager.py
Expand Up @@ -190,6 +190,33 @@ def getTools(self, tablename):
headers = ["","Tool Num.","Name","Tool Type","Material","Diameter","Length Offset","Flat Radius","Corner Radius","Cutting Edge Angle","Cutting Edge Height"]
model = QtGui.QStandardItemModel()
model.setHorizontalHeaderLabels(headers)
parms = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units")
digits = parms.GetContents()[1][2] # user's number of digits of precision
if parms.GetContents()[0][2]==0:
suffix = 'mm'
conversion = 1.0
elif parms.GetContents()[0][2]==3:
suffix = 'in'
conversion = 25.4
else:
suffix = ''

def unitconv(ivalue):
parms = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units")
digits = parms.GetContents()[1][2] #get user's number of digits of precision
if parms.GetContents()[0][2]==0:
suffix = 'mm'
conversion = 1.0
elif parms.GetContents()[0][2]==3:
suffix = 'in'
conversion = 25.4
else:
suffix = ''
val = FreeCAD.Units.parseQuantity(str(round(ivalue/conversion,digits))+suffix)
displayed_val = val.UserString #just the displayed value-not the internal one

return displayed_val

if tt:
if len(tt.Tools) == 0:
tooldata.append([])
Expand All @@ -201,12 +228,12 @@ def getTools(self, tablename):
itemName = QtGui.QStandardItem(t.Name)
itemToolType = QtGui.QStandardItem(t.ToolType)
itemMaterial = QtGui.QStandardItem(t.Material)
itemDiameter = QtGui.QStandardItem(str(t.Diameter))
itemLengthOffset = QtGui.QStandardItem(str(t.LengthOffset))
itemFlatRadius = QtGui.QStandardItem(str(t.FlatRadius))
itmCornerRadius = QtGui.QStandardItem(str(t.CornerRadius))
itemDiameter = QtGui.QStandardItem(unitconv(t.Diameter))
itemLengthOffset = QtGui.QStandardItem(unitconv(t.LengthOffset))
itemFlatRadius = QtGui.QStandardItem(unitconv(t.FlatRadius))
itmCornerRadius = QtGui.QStandardItem(unitconv(t.CornerRadius))
itemCuttingEdgeAngle = QtGui.QStandardItem(str(t.CuttingEdgeAngle))
itemCuttingEdgeHeight = QtGui.QStandardItem(str(t.CuttingEdgeHeight))
itemCuttingEdgeHeight = QtGui.QStandardItem(unitconv(t.CuttingEdgeHeight))

row = [itemcheck, itemNumber, itemName, itemToolType, itemMaterial, itemDiameter, itemLengthOffset, itemFlatRadius, itmCornerRadius, itemCuttingEdgeAngle, itemCuttingEdgeHeight]
model.appendRow(row)
Expand Down

0 comments on commit 605d4da

Please sign in to comment.