Material: editor, get rid of duplicate unit definition
- in mat editor xml file and in FreeCAD unit system - remove it from material editor xml file and get it from FreeCAD unit system
This commit is contained in:
@@ -23,44 +23,44 @@
|
||||
</Group>
|
||||
|
||||
<Group Name="Mechanical">
|
||||
<Property Name="Density" Type="Quantity" Units="(-3, 1, 0, 0, 0, 0, 0, 0)">
|
||||
<Property Name="Density" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Density</Reference>
|
||||
</Property>
|
||||
<Property Name="YoungsModulus" Type="Quantity" Units="(-1, 1, -2, 0, 0, 0, 0, 0)">
|
||||
<Property Name="YoungsModulus" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Young%27s_modulus</Reference>
|
||||
</Property>
|
||||
<Property Name="PoissonRatio" Type="Float">
|
||||
<Reference>https://en.wikipedia.org/wiki/Poisson%27s_ratio</Reference>
|
||||
</Property>
|
||||
<Property Name="UltimateTensileStrength" Type="Quantity" Units="(-1, 1, -2, 0, 0, 0, 0, 0)">
|
||||
<Property Name="UltimateTensileStrength" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Ultimate_tensile_strength</Reference>
|
||||
</Property>
|
||||
<Property Name="CompressiveStrength" Type="Quantity" Units="(-1, 1, -2, 0, 0, 0, 0, 0)">
|
||||
<Property Name="CompressiveStrength" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Compressive_strength</Reference>
|
||||
</Property>
|
||||
<Property Name="YieldStrength" Type="Quantity" Units="(-1, 1, -2, 0, 0, 0, 0, 0)">
|
||||
<Property Name="YieldStrength" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Yield_Strength</Reference>
|
||||
</Property>
|
||||
<Property Name="UltimateStrain" Type="Float">
|
||||
<Reference>https://en.wikipedia.org/wiki/Deformation_(mechanics)</Reference>
|
||||
</Property>
|
||||
<Property Name="FractureToughness" Type="Quantity" Units="(-1, 1, -2, 0, 0, 0, 0, 0)">
|
||||
<Property Name="FractureToughness" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Fracture_toughness</Reference>
|
||||
</Property>
|
||||
<Property Name="AngleOfFriction" Type="Quantity" Units="(0, 0, 0, 0, 0, 0, 0, 1)">
|
||||
<Property Name="AngleOfFriction" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Friction#Angle_of_friction</Reference>
|
||||
<Reference>https://en.m.wikipedia.org/wiki/Mohr%E2%80%93Coulomb_theory</Reference>
|
||||
</Property>
|
||||
</Group>
|
||||
|
||||
<Group Name="Thermal">
|
||||
<Property Name="ThermalConductivity" Type="Quantity" Units="(1, 1, -3, 0, -1, 0, 0, 0)">
|
||||
<Property Name="ThermalConductivity" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Thermal_conductivity</Reference>
|
||||
</Property>
|
||||
<Property Name="ThermalExpansionCoefficient" Type="Quantity" Units="(0, 0, 0, 0, -1, 0, 0, 0)">
|
||||
<Property Name="ThermalExpansionCoefficient" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Volumetric_thermal_expansion_coefficient</Reference>
|
||||
</Property>
|
||||
<Property Name="SpecificHeat" Type="Quantity" Units="(2, 0, -2, 0, -1, 0, 0, 0)">
|
||||
<Property Name="SpecificHeat" Type="Quantity">
|
||||
<Reference>https://en.wikipedia.org/wiki/Heat_capacity</Reference>
|
||||
</Property>
|
||||
</Group>
|
||||
|
||||
@@ -112,13 +112,11 @@ class MaterialEditor:
|
||||
widget = self.widget
|
||||
treeView = widget.treeView
|
||||
model = treeView.model()
|
||||
model.setHorizontalHeaderLabels(["Property", "Value",
|
||||
"Type", "Units"])
|
||||
model.setHorizontalHeaderLabels(["Property", "Value", "Type"])
|
||||
|
||||
treeView.setColumnWidth(0, 250)
|
||||
treeView.setColumnWidth(1, 250)
|
||||
treeView.setColumnHidden(2, True)
|
||||
treeView.setColumnHidden(3, True)
|
||||
|
||||
tree = getMaterialAttributeStructure(True)
|
||||
MatPropDict = tree.getroot()
|
||||
@@ -141,13 +139,7 @@ class MaterialEditor:
|
||||
tt = properDict['Type']
|
||||
itType = QtGui.QStandardItem(tt)
|
||||
|
||||
try:
|
||||
uu = properDict['Units']
|
||||
itUnit = QtGui.QStandardItem(uu)
|
||||
except KeyError:
|
||||
itUnit = QtGui.QStandardItem()
|
||||
|
||||
top.appendRow([item, it, itType, itUnit])
|
||||
top.appendRow([item, it, itType])
|
||||
|
||||
top.sortChildren(0)
|
||||
|
||||
@@ -486,24 +478,22 @@ class MaterialsDelegate(QtGui.QStyledItemDelegate):
|
||||
if column == 1:
|
||||
|
||||
row = index.row()
|
||||
|
||||
PP = group.child(row, 0)
|
||||
matproperty = PP.text().replace(" ", "") # remove spaces
|
||||
|
||||
TT = group.child(row, 2)
|
||||
|
||||
if TT:
|
||||
Type = TT.text()
|
||||
UU = group.child(row, 3)
|
||||
if UU:
|
||||
Units = UU.text()
|
||||
else:
|
||||
Units = None
|
||||
|
||||
else:
|
||||
Type = "String"
|
||||
Units = None
|
||||
|
||||
VV = group.child(row, 1)
|
||||
Value = VV.text()
|
||||
|
||||
editor = matProperWidget(parent, Type, Units, Value)
|
||||
editor = matProperWidget(parent, matproperty, Type, Value)
|
||||
|
||||
elif column == 0:
|
||||
|
||||
@@ -546,7 +536,7 @@ class MaterialsDelegate(QtGui.QStyledItemDelegate):
|
||||
ui = FreeCADGui.UiLoader()
|
||||
|
||||
|
||||
def matProperWidget(parent=None, Type="String", Units=None, Value=None,
|
||||
def matProperWidget(parent=None, matproperty=None, Type="String", Value=None,
|
||||
minimum=None, maximum=None, stepsize=None, precision=None):
|
||||
|
||||
'''customs widgets for the material stuff.'''
|
||||
@@ -569,13 +559,12 @@ def matProperWidget(parent=None, Type="String", Units=None, Value=None,
|
||||
elif Type == "Quantity":
|
||||
|
||||
widget = ui.createWidget("Gui::InputField")
|
||||
if Units:
|
||||
vv = string2tuple(Units)
|
||||
unit = FreeCAD.Units.Unit(
|
||||
vv[0], vv[1], vv[2], vv[3], vv[4], vv[5], vv[6], vv[7]
|
||||
)
|
||||
if hasattr(FreeCAD.Units, matproperty):
|
||||
unit = getattr(FreeCAD.Units, matproperty)
|
||||
quantity = FreeCAD.Units.Quantity(1, unit)
|
||||
widget.setProperty('unit', quantity.getUserPreferred()[2])
|
||||
else:
|
||||
FreeCAD.Console.PrintError('Not known unit for property: ' + matproperty + '\n')
|
||||
|
||||
elif Type == "Integer":
|
||||
|
||||
|
||||
Reference in New Issue
Block a user