From 44fd9342e9eda0092e58fd84bbc77eb02429ed4b Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Wed, 6 Jun 2018 23:47:54 +0200 Subject: [PATCH] Material: editor, move in ui hardcoded properties into the editor module in a tuple --- src/Mod/Material/MaterialEditor.py | 43 +- src/Mod/Material/materials-editor.ui | 757 +-------------------------- 2 files changed, 43 insertions(+), 757 deletions(-) diff --git a/src/Mod/Material/MaterialEditor.py b/src/Mod/Material/MaterialEditor.py index 95d167fff0..d7ee606fcb 100644 --- a/src/Mod/Material/MaterialEditor.py +++ b/src/Mod/Material/MaterialEditor.py @@ -64,6 +64,12 @@ class MaterialEditor: QtCore.QObject.connect(self.widget.Editor, QtCore.SIGNAL("currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)"), self.checkDeletable) QtCore.QObject.connect(self.widget.ButtonOpen, QtCore.SIGNAL("clicked()"), self.openfile) QtCore.QObject.connect(self.widget.ButtonSave, QtCore.SIGNAL("clicked()"), self.savefile) + + # add material properies (the keys) to the editor + for group in material_properties: + # print(group) + self.addPropertiesToGroup(group) + # update the editor with the contents of the property, if we have one d = None if self.prop and self.obj: @@ -74,6 +80,28 @@ class MaterialEditor: self.updateContents(d) + def addPropertiesToGroup(self, propertygroup=None): + "Adds property to a known group in Tree widges" + if propertygroup: + groupname = propertygroup[0] + groupproperties = propertygroup[1] + else: + return + + # parent + self.widget.Editor.addTopLevelItem(QtGui.QTreeWidgetItem([groupname, ])) + # how to expand it ? + + # childs + for key in groupproperties: + if not self.widget.Editor.findItems(key,QtCore.Qt.MatchRecursive,0): + top = self.widget.Editor.findItems(translate("Material", groupname),QtCore.Qt.MatchExactly,0) + if top: + i = QtGui.QTreeWidgetItem(top[0]) + i.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEditable|QtCore.Qt.ItemIsDragEnabled|QtCore.Qt.ItemIsUserCheckable|QtCore.Qt.ItemIsEnabled) + i.setText(0,key) + + def getMaterialResources(self): self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Material/Resources") use_built_in_materials = self.fem_prefs.GetBool("UseBuiltInMaterials", True) @@ -125,7 +153,7 @@ class MaterialEditor: self.clearEditor() for k,i in data.items(): k = self.expandKey(k) - # most material dict keys are hard coded in ui file, not known keys are added to user defined group + # most material dict keys are added with addPropertiesToGroup, see tuple with all these properties at module end slot = self.widget.Editor.findItems(k,QtCore.Qt.MatchRecursive,0) if len(slot) == 1: slot = slot[0] @@ -354,3 +382,16 @@ def editMaterial(material): else: return material + +# material properties +# are there any more resources in FreeCAD source code where known material properties are defined exept the material cards itself? +material_properties = ( + ('Meta information', ['Card Name', 'Author And License', 'Source']), + ('General', ['Name', 'Father', 'Description', 'Denisty', 'Vendor', 'ProductURL', 'SpecificPrice']), + ('Mechanical', ['Youngs Modulus', 'Ultimate Tensile Strength', 'Compressive Strength', 'Elasticity', 'Fracture Toughness']), + ('FEM', ['Poisson Ratio']), + ('Architectural', ['Execution Instructions', 'Fire Resistance Class', 'Standard Code', 'Thermal Conductivity', 'Sound Transmission Class', 'Color', 'Finish', 'Units Per Quantity', 'Environmental Efficiency Class']), + ('Rendering', ['Diffuse Color', 'Ambient Color', 'Specular Color', 'Shininess', 'Emissive Color', 'Transparency', 'Vertex Shader', 'Fragment Shader', 'Texture Path', 'Texture Scaling']), + ('Vector rendering', ['View Color', 'Father', 'View Linewidth', 'Section Color', 'Section Fill Pattern', 'Section Linewidth']), + ('User defined', []) + ) diff --git a/src/Mod/Material/materials-editor.ui b/src/Mod/Material/materials-editor.ui index add1da1aff..4ef6dde150 100644 --- a/src/Mod/Material/materials-editor.ui +++ b/src/Mod/Material/materials-editor.ui @@ -7,7 +7,7 @@ 0 0 441 - 604 + 626 @@ -181,761 +181,6 @@ Value - - - Meta information - - - Additional information that will be written in the material card. - - - - 75 - true - - - - - Card Name - - - This is a description of your material, for ex. "Standard Steel Material" - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Author And License - - - Your name and license info, for ex. "John Smith, CC-BY 3.0" - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Source - - - An optional description of where the information included in this card comes from - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - - General - - - General properties of this material - - - - 75 - false - true - - - - - - 200 - 200 - 200 - - - - - - - - - - 200 - 200 - 200 - - - - - - Name - - - A uniquely identificable name, for ex. "Steel". This should match the name of the card. - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Father - - - An optional father material. Missing properties here will be taken from the father. For ex. "Metal" - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Description - - - A longer and more precise description of your material - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Density - - - Density of this material, in kg/m³. For ex. 7800 - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Vendor - - - The name of the vendor of this material - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Product URL - - - A URL where information about this material can be found - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Specific Price - - - A price for this material, including the unit, for ex. 1.5 EUR/kg - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - - Mechanical - - - Mechanical properties of this material - - - - 75 - true - - - - - - 200 - 200 - 200 - - - - - - - - - - 200 - 200 - 200 - - - - - - Youngs Modulus - - - Also called tensile modulus or elastic modulus, a measure of the stiffness of a material, in kPa - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Ultimate Tensile Strength - - - The maximum stress that a material can withstand while being stretched or pulled before failing or breaking, in MPa - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Compressive Strength - - - The capacity of a material or structure to withstand loads tending to reduce size - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Elasticity - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Fracture Toughness - - - The ability of a material containing a crack to resist fracture - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - - FEM - - - FEM-related properties - - - - 75 - true - - - - - Poisson Ratio - - - The Poisson ratio is the negative ratio of transverse to axial strain. - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - - Architectural - - - Architectural properties - - - - 75 - true - - - - - - 200 - 200 - 200 - - - - - - - - - - 200 - 200 - 200 - - - - - - Model - - - The specific model of a certain product - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Execution Instructions - - - Specific execution or installation instructions - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Fire Resistance Class - - - Fire resistance standard and class, for ex. RF 1h or UL 350-2 - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Standard Code - - - The standard and code this material is described in, for ex. MasterFormat 03-1113.310 - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Thermal Conductivity - - - The property of a material to conduct heat, in W/mK. - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Sound Transmission Class - - - A standard and rating indicating how well a material attenuates airborne sound. For ex. STC 44 - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Color - - - A specific color for this product - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Finish - - - A special finish specification for this product - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Units Per Quantity - - - In case this product is made of small units, this property describes how many units fit into a certain volume or area, for ex. 50 units/m³ - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Environmental Efficiency Class - - - A standard and rating of this material regarding sustainability and environmental design - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - - Rendering - - - Properties used by the FreeCAD 3D view, but also by external renderers - - - - 75 - true - - - - - - 200 - 200 - 200 - - - - - - - - - - 200 - 200 - 200 - - - - - - - 123 - 123 - 123 - - - - - - Diffuse Color - - - A diffuse color, expressed with 3 comma-separated float values, for ex. 0.5,0.5,0.5 - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Ambient Color - - - An ambient color, expressed with 3 comma-separated float values, for ex. 0.5,0.5,0.5 - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Specular Color - - - A specular color, expressed with 3 comma-separated float values, for ex. 0.5,0.5,0.5 - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Shininess - - - An intensity value for shininess/specularity, expressed as a float value between 0 and 1.0 - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Emissive Color - - - An emission color, expressed with 3 comma-separated float values, for ex. 0.5,0.5,0.5 - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Transparency - - - A transparency value, expressed as a float value between 0 (opaque) and 1.0 (fully transparent) - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Vertex Shader - - - An optional vertex shader to be used by renderers that support it - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Fragment Shader - - - An optional fragment shader to be used by renderers that support it - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Texture Path - - - A path to a texture image, to be used by the renderers that support it - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Texture Scaling - - - A scaling value for the texture, might be used differently by different renderes - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - - Vector rendering - - - Properties applicable in vector renderings - - - - 75 - true - - - - - - 200 - 200 - 200 - - - - - - - - - - 200 - 200 - 200 - - - - - - View Color - - - A base color for viewed faces, expressed with 3 comma-separated float values, for ex. 0.5,0.5,0.5 - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - View Fill Pattern - - - An SVG pattern to apply on viewed faces, expressed as either a name of an existing pattern (such as "simple") or a complete <pattern>...</pattern> SVG element - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - View Linewidth - - - An optional linewidth factor for viewed faces - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Section Color - - - A base color for sectionned faces, expressed with 3 comma-separated float values, for ex. 0.5,0.5,0.5 - - - - - Section Fill Pattern - - - An SVG pattern to apply on cut faces, expressed as either a name of an existing pattern (such as "simple") or a complete <pattern>...</pattern> SVG element - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - Section Linewidth - - - An optional linewidth factor for cut faces - - - - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - - User defined - - - Additional properties defined by the user - - - - 75 - true - - -