From 448e9d77313b5062a32e211b8473eb19aa2f0131 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Thu, 5 Sep 2019 22:02:56 +0200 Subject: [PATCH] FEM: gui objs, use single quotes instead of double ones --- .../Fem/femguiobjects/FemSelectionWidgets.py | 70 ++-- .../ViewProviderFemConstraint.py | 4 +- ...iderFemConstraintElectrostaticPotential.py | 6 +- .../_ViewProviderFemConstraintSelfWeight.py | 4 +- .../_ViewProviderFemElementFluid1D.py | 10 +- .../_ViewProviderFemElementGeometry1D.py | 10 +- .../_ViewProviderFemElementGeometry2D.py | 8 +- .../_ViewProviderFemElementRotation1D.py | 12 +- .../femguiobjects/_ViewProviderFemMaterial.py | 306 +++++++++--------- ...wProviderFemMaterialMechanicalNonlinear.py | 4 +- .../_ViewProviderFemMaterialReinforced.py | 98 +++--- .../_ViewProviderFemMeshBoundaryLayer.py | 8 +- .../femguiobjects/_ViewProviderFemMeshGmsh.py | 90 +++--- .../_ViewProviderFemMeshGroup.py | 8 +- .../_ViewProviderFemMeshRegion.py | 8 +- .../_ViewProviderFemResultMechanical.py | 28 +- .../_ViewProviderFemSolverCalculix.py | 60 ++-- 17 files changed, 367 insertions(+), 367 deletions(-) diff --git a/src/Mod/Fem/femguiobjects/FemSelectionWidgets.py b/src/Mod/Fem/femguiobjects/FemSelectionWidgets.py index 8f5a595a5c..460ae98fe0 100644 --- a/src/Mod/Fem/femguiobjects/FemSelectionWidgets.py +++ b/src/Mod/Fem/femguiobjects/FemSelectionWidgets.py @@ -234,13 +234,13 @@ class GeometryElementsSelection(QtGui.QWidget): def initElemTypes(self, eltypes): self.sel_elem_types = eltypes # FreeCAD.Console.PrintMessage( - # 'Selection of: {} is allowed.\n'.format(self.sel_elem_types) + # "Selection of: {} is allowed.\n".format(self.sel_elem_types) # ) - self.sel_elem_text = '' + self.sel_elem_text = "" for e in self.sel_elem_types: - self.sel_elem_text += (e + ', ') - self.sel_elem_text = self.sel_elem_text.rstrip(', ') - # FreeCAD.Console.PrintMessage('Selection of: ' + self.sel_elem_text + ' is allowed.\n') + self.sel_elem_text += (e + ", ") + self.sel_elem_text = self.sel_elem_text.rstrip(", ") + # FreeCAD.Console.PrintMessage("Selection of: " + self.sel_elem_text + " is allowed.\n") self.selection_mode_std_print_message = ( "Single click on a " + self.sel_elem_text + " will add it to the list" ) @@ -267,7 +267,7 @@ class GeometryElementsSelection(QtGui.QWidget): # radiobutton down the list self.lb_selmod = QtGui.QLabel() self.lb_selmod.setText(self.tr("Selection mode")) - self.rb_standard = QtGui.QRadioButton(self.tr(self.sel_elem_text.lstrip('Solid, '))) + self.rb_standard = QtGui.QRadioButton(self.tr(self.sel_elem_text.lstrip("Solid, "))) self.rb_solid = QtGui.QRadioButton(self.tr("Solid")) self.rb_standard.setChecked(True) self.rb_solid.setChecked(False) @@ -281,7 +281,7 @@ class GeometryElementsSelection(QtGui.QWidget): mainLayout.addWidget(self._helpTextLbl) mainLayout.addWidget(self.pushButton_Add) mainLayout.addWidget(self.list_References) - if 'Solid' in self.sel_elem_types: + if "Solid" in self.sel_elem_types: mainLayout.addLayout(rbtnLayout) self.setLayout(mainLayout) # signals and slots @@ -314,7 +314,7 @@ class GeometryElementsSelection(QtGui.QWidget): self.references.append((ref[0], elem)) def get_item_text(self, ref): - return (ref[0].Name + ':' + ref[1]) + return (ref[0].Name + ":" + ref[1]) def get_allitems_text(self): items = [] @@ -342,14 +342,14 @@ class GeometryElementsSelection(QtGui.QWidget): currentItemName = str(self.list_References.currentItem().text()) for ref in self.references: if self.get_item_text(ref) == currentItemName: - # print('found: shape: ' + ref[0].Name + ' element: ' + ref[1]) + # print("found: shape: " + ref[0].Name + " element: " + ref[1]) if not ref[0].ViewObject.Visibility: self.obj_notvisible.append(ref[0]) ref[0].ViewObject.Visibility = True FreeCADGui.Selection.clearSelection() ref_sh_type = ref[0].Shape.ShapeType - if ref[1].startswith('Solid') \ - and (ref_sh_type == 'Compound' or ref_sh_type == 'CompSolid'): + if ref[1].startswith("Solid") \ + and (ref_sh_type == "Compound" or ref_sh_type == "CompSolid"): # selection of Solids of Compounds or CompSolids is not possible # because a Solid is no Subelement # since only Subelements can be selected @@ -363,7 +363,7 @@ class GeometryElementsSelection(QtGui.QWidget): # find these faces in ref[0] for i, fref in enumerate(ref[0].Shape.Faces): if fs.isSame(fref): - fref_elstring = 'Face' + str(i + 1) + fref_elstring = "Face" + str(i + 1) if fref_elstring not in faces: faces.append(fref_elstring) for f in faces: @@ -373,8 +373,8 @@ class GeometryElementsSelection(QtGui.QWidget): FreeCADGui.Selection.addSelection(ref[0], ref[1]) def setback_listobj_visibility(self): - '''set back Visibility of the list objects - ''' + """set back Visibility of the list objects + """ FreeCADGui.Selection.clearSelection() for obj in self.obj_notvisible: obj.ViewObject.Visibility = False @@ -418,15 +418,15 @@ class GeometryElementsSelection(QtGui.QWidget): def choose_selection_mode_standard(self, state): self.selection_mode_solid = not state if self.sel_server and not self.selection_mode_solid: - FreeCAD.Console.PrintMessage(self.selection_mode_std_print_message + '\n') + FreeCAD.Console.PrintMessage(self.selection_mode_std_print_message + "\n") def choose_selection_mode_solid(self, state): self.selection_mode_solid = state if self.sel_server and self.selection_mode_solid: - FreeCAD.Console.PrintMessage(self.selection_mode_solid_print_message + '\n') + FreeCAD.Console.PrintMessage(self.selection_mode_solid_print_message + "\n") def add_references(self): - '''Called if Button add_reference is triggered''' + """Called if Button add_reference is triggered""" # in constraints EditTaskPanel the selection is active as soon as the taskpanel is open # here the addReference button EditTaskPanel has to be triggered to start selection mode self.setback_listobj_visibility() @@ -443,7 +443,7 @@ class GeometryElementsSelection(QtGui.QWidget): self.sel_server = FemSelectionObserver(self.selectionParser, print_message) def selectionParser(self, selection): - print('selection: {} {} {}'.format( + print("selection: {} {} {}".format( selection[0].Shape.ShapeType, selection[0].Name, selection[1] @@ -451,11 +451,11 @@ class GeometryElementsSelection(QtGui.QWidget): if hasattr(selection[0], "Shape") and selection[1]: elt = selection[0].Shape.getElement(selection[1]) ele_ShapeType = elt.ShapeType - if self.selection_mode_solid and 'Solid' in self.sel_elem_types: + if self.selection_mode_solid and "Solid" in self.sel_elem_types: # in solid selection mode use edges and faces for selection of a solid # adapt selection variable to hold the Solid solid_to_add = None - if ele_ShapeType == 'Edge': + if ele_ShapeType == "Edge": found_edge = False for i, s in enumerate(selection[0].Shape.Solids): for e in s.Edges: @@ -464,11 +464,11 @@ class GeometryElementsSelection(QtGui.QWidget): solid_to_add = str(i + 1) else: FreeCAD.Console.PrintMessage( - 'Edge belongs to more than one solid\n' + "Edge belongs to more than one solid\n" ) solid_to_add = None found_edge = True - elif ele_ShapeType == 'Face': + elif ele_ShapeType == "Face": found_face = False for i, s in enumerate(selection[0].Shape.Solids): for e in s.Faces: @@ -477,21 +477,21 @@ class GeometryElementsSelection(QtGui.QWidget): solid_to_add = str(i + 1) else: FreeCAD.Console.PrintMessage( - 'Face belongs to more than one solid\n' + "Face belongs to more than one solid\n" ) solid_to_add = None found_face = True if solid_to_add: - selection = (selection[0], 'Solid' + solid_to_add) - ele_ShapeType = 'Solid' + selection = (selection[0], "Solid" + solid_to_add) + ele_ShapeType = "Solid" FreeCAD.Console.PrintMessage( - 'selection variable adapted to hold the Solid: {} {} {}\n' + "selection variable adapted to hold the Solid: {} {} {}\n" .format(selection[0].Shape.ShapeType, selection[0].Name, selection[1]) ) else: return if ele_ShapeType in self.sel_elem_types: - if (self.selection_mode_solid and ele_ShapeType == 'Solid') \ + if (self.selection_mode_solid and ele_ShapeType == "Solid") \ or self.selection_mode_solid is False: if selection not in self.references: # only equal shape types are allowed to add @@ -513,7 +513,7 @@ class GeometryElementsSelection(QtGui.QWidget): # selected shape will not added to the list FreeCADGui.Selection.clearSelection() message = ( - '{} is in reference list already!\n' + "{} is in reference list already!\n" .format(self.get_item_text(selection)) ) FreeCAD.Console.PrintMessage(message) @@ -521,27 +521,27 @@ class GeometryElementsSelection(QtGui.QWidget): else: # selected shape will not added to the list FreeCADGui.Selection.clearSelection() - message = ele_ShapeType + ' is not allowed to add to the list!\n' + message = ele_ShapeType + " is not allowed to add to the list!\n" FreeCAD.Console.PrintMessage(message) QtGui.QMessageBox.critical(None, "Wrong shape type", message) - def has_equal_references_shape_types(self, ref_shty=''): + def has_equal_references_shape_types(self, ref_shty=""): for ref in self.references: # the method getElement(element) does not return Solid elements r = FemMeshTools.get_element(ref[0], ref[1]) if not r: FreeCAD.Console.PrintError( - 'Problem in retrieving element: {} \n'.format(ref[1]) + "Problem in retrieving element: {} \n".format(ref[1]) ) continue FreeCAD.Console.PrintLog( - ' ReferenceShape : {}, {}, {} --> {}' + " ReferenceShape : {}, {}, {} --> {}" .format(r.ShapeType, ref[0].Name, ref[0].Label, ref[1]) ) if not ref_shty: ref_shty = r.ShapeType if r.ShapeType != ref_shty: - message = 'Multiple shape types are not allowed in the reference list.\n' + message = "Multiple shape types are not allowed in the reference list.\n" FreeCAD.Console.PrintMessage(message) QtGui.QMessageBox.critical(None, "Multiple ShapeTypes not allowed", message) return False @@ -549,8 +549,8 @@ class GeometryElementsSelection(QtGui.QWidget): class FemSelectionObserver: - '''selection observer especially for the needs of geometry reference selection of FEM''' - def __init__(self, parseSelectionFunction, print_message=''): + """selection observer especially for the needs of geometry reference selection of FEM""" + def __init__(self, parseSelectionFunction, print_message=""): self.parseSelectionFunction = parseSelectionFunction FreeCADGui.Selection.addObserver(self) FreeCAD.Console.PrintMessage(print_message + "!\n") diff --git a/src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py b/src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py index 05c5195582..348032f690 100644 --- a/src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py +++ b/src/Mod/Fem/femguiobjects/ViewProviderFemConstraint.py @@ -73,7 +73,7 @@ class ViewProxy(object): guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintElectrostaticPotential.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintElectrostaticPotential.py index 2bea6b9ea6..43e5dfb576 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintElectrostaticPotential.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintElectrostaticPotential.py @@ -131,9 +131,9 @@ class _TaskPanel(object): quantity = Units.Quantity(self._paramWidget.potentialTxt.text()) except ValueError: FreeCAD.Console.PrintMessage( - 'Wrong input. OK has been triggered without a green hook ' - 'in the input field. Not recognised input: "{}" ' - 'Potential has not been set.\n' + "Wrong input. OK has been triggered without a green hook " + "in the input field. Not recognised input: '{}' " + "Potential has not been set.\n" .format(self._paramWidget.potentialTxt.text()) ) if quantity is not None: diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintSelfWeight.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintSelfWeight.py index e62496fbd6..ad13c98de8 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintSelfWeight.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintSelfWeight.py @@ -66,9 +66,9 @@ class _ViewProviderFemConstraintSelfWeight: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementFluid1D.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementFluid1D.py index 1c42cc8608..c3cfd2e8ef 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementFluid1D.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementFluid1D.py @@ -94,9 +94,9 @@ class _ViewProviderFemElementFluid1D: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -107,7 +107,7 @@ class _ViewProviderFemElementFluid1D: class _TaskPanelFemElementFluid1D: - '''The TaskPanel for editing References property of FemElementFluid1D objects''' + """The TaskPanel for editing References property of FemElementFluid1D objects""" def __init__(self, obj): @@ -295,7 +295,7 @@ class _TaskPanelFemElementFluid1D: # geometry selection widget self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection( - obj.References, ['Edge'] + obj.References, ["Edge"] ) # form made from param and selection widget @@ -390,7 +390,7 @@ class _TaskPanelFemElementFluid1D: self.obj.PumpHeadLoss = self.PumpHeadLoss def updateParameterWidget(self): - 'fills the widgets' + "fills the widgets" index_sectiontype = self.parameterWidget.cb_section_type.findText(self.SectionType) self.parameterWidget.cb_section_type.setCurrentIndex(index_sectiontype) self.parameterWidget.sw_section_type.setCurrentIndex(index_sectiontype) diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementGeometry1D.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementGeometry1D.py index e3f21deea9..2ead71f9b2 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementGeometry1D.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementGeometry1D.py @@ -91,9 +91,9 @@ class _ViewProviderFemElementGeometry1D: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -104,7 +104,7 @@ class _ViewProviderFemElementGeometry1D: class _TaskPanelFemElementGeometry1D: - '''The TaskPanel for editing References property of FemElementGeometry1D objects''' + """The TaskPanel for editing References property of FemElementGeometry1D objects""" def __init__(self, obj): @@ -155,7 +155,7 @@ class _TaskPanelFemElementGeometry1D: # geometry selection widget self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection( obj.References, - ['Edge'] + ["Edge"] ) # form made from param and selection widget @@ -196,7 +196,7 @@ class _TaskPanelFemElementGeometry1D: self.obj.PipeThickness = self.PipeThickness def updateParameterWidget(self): - 'fills the widgets' + "fills the widgets" index_crosssectiontype = self.parameterWidget.cb_crosssectiontype.findText( self.SectionType ) diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementGeometry2D.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementGeometry2D.py index 12b8dfffe7..e84ab93fcb 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementGeometry2D.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementGeometry2D.py @@ -90,9 +90,9 @@ class _ViewProviderFemElementGeometry2D: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -103,7 +103,7 @@ class _ViewProviderFemElementGeometry2D: class _TaskPanelFemElementGeometry2D: - '''The TaskPanel for editing References property of FemElementGeometry2D objects''' + """The TaskPanel for editing References property of FemElementGeometry2D objects""" def __init__(self, obj): @@ -123,7 +123,7 @@ class _TaskPanelFemElementGeometry2D: # geometry selection widget self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection( obj.References, - ['Face'] + ["Face"] ) # form made from param and selection widget diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementRotation1D.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementRotation1D.py index 3750fe4957..4e8dbe422a 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementRotation1D.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementRotation1D.py @@ -66,7 +66,7 @@ class _ViewProviderFemElementRotation1D: def onChanged(self, vobj, prop): return - ''' + """ # do not activate the task panel, since rotation with reference shapes is not yet supported def setEdit(self, vobj, mode=0): # hide all meshes @@ -82,7 +82,7 @@ class _ViewProviderFemElementRotation1D: def unsetEdit(self, vobj, mode=0): FreeCADGui.Control.closeDialog() return True - ''' + """ def setEdit(self, vobj, mode=0): # avoid edit mode by return False @@ -97,9 +97,9 @@ class _ViewProviderFemElementRotation1D: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -110,7 +110,7 @@ class _ViewProviderFemElementRotation1D: class _TaskPanelFemElementRotation1D: - '''The TaskPanel for editing References property of FemElementRotation1D objects''' + """The TaskPanel for editing References property of FemElementRotation1D objects""" def __init__(self, obj): self.obj = obj @@ -130,7 +130,7 @@ class _TaskPanelFemElementRotation1D: # geometry selection widget self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection( obj.References, - ['Edge'] + ["Edge"] ) # form made from param and selection widget diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py index 3804e0efd1..dfebe22f35 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py @@ -89,9 +89,9 @@ class _ViewProviderFemMaterial: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -102,14 +102,14 @@ class _ViewProviderFemMaterial: class _TaskPanelFemMaterial: - '''The editmode TaskPanel for FemMaterial objects''' + """The editmode TaskPanel for FemMaterial objects""" def __init__(self, obj): - FreeCAD.Console.PrintMessage('\n') # empty line on start task panel + FreeCAD.Console.PrintMessage("\n") # empty line on start task panel self.obj = obj self.material = self.obj.Material # FreeCAD material dictionary of current material - self.card_path = '' + self.card_path = "" self.materials = {} # { card_path : FreeCAD material dict, ... } self.cards = {} # { card_path : card_names, ... } self.icons = {} # { card_path : icon_path, ... } @@ -192,7 +192,7 @@ class _TaskPanelFemMaterial: # hide some groupBox according to material category self.parameterWidget.label_category.setText(self.obj.Category) - if self.obj.Category == 'Fluid': + if self.obj.Category == "Fluid": self.parameterWidget.groupBox_mechanical.setVisible(0) self.parameterWidget.label_expansion_coefficient.setVisible(0) self.parameterWidget.input_fd_expansion_coefficient.setVisible(0) @@ -209,7 +209,7 @@ class _TaskPanelFemMaterial: # search for exact this mat_card in all known cards, choose the current material self.card_path = self.get_material_card(self.material) - FreeCAD.Console.PrintLog('card_path: {}'.format(self.card_path)) + FreeCAD.Console.PrintLog("card_path: {}".format(self.card_path)) if not self.card_path: # we have not found our material in self.materials dict :-( # we're going to add a user-defined temporary material: a document material @@ -217,7 +217,7 @@ class _TaskPanelFemMaterial: "Previously used material card can not be found in material directories. " "Add document material.\n" ) - self.card_path = '_document_material' + self.card_path = "_document_material" self.materials[self.card_path] = self.material self.parameterWidget.cb_materials.addItem( QtGui.QIcon(":/icons/help-browser.svg"), @@ -242,7 +242,7 @@ class _TaskPanelFemMaterial: # geometry selection widget self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection( obj.References, - ['Solid', 'Face', 'Edge'], + ["Solid", "Face", "Edge"], False ) # start with Solid in list! @@ -263,8 +263,8 @@ class _TaskPanelFemMaterial: self.obj.References = self.selectionWidget.references else: error_message = ( - 'Due to some wrong material quantity units in the changed ' - 'material data, the task panel changes where not accepted.\n' + "Due to some wrong material quantity units in the changed " + "material data, the task panel changes where not accepted.\n" ) FreeCAD.Console.PrintError(error_message) QtGui.QMessageBox.critical(None, "Material data not changed", error_message) @@ -284,35 +284,35 @@ class _TaskPanelFemMaterial: doc.resetEdit() def do_not_set_thermal_zeros(self): - ''' thermal material parameter are set to 0.0 if not available + """ thermal material parameter are set to 0.0 if not available this leads to wrong material values and to not finding the card on reopen the task pane, thus do not write thermal parameter, if they are 0.0 - ''' - if Units.Quantity(self.material['ThermalConductivity']) == 0.0: - self.material.pop('ThermalConductivity', None) + """ + if Units.Quantity(self.material["ThermalConductivity"]) == 0.0: + self.material.pop("ThermalConductivity", None) FreeCAD.Console.PrintMessage( - 'Zero ThermalConductivity value. ' - 'This parameter is not saved in the material data.\n' + "Zero ThermalConductivity value. " + "This parameter is not saved in the material data.\n" ) - if Units.Quantity(self.material['ThermalExpansionCoefficient']) == 0.0: - self.material.pop('ThermalExpansionCoefficient', None) + if Units.Quantity(self.material["ThermalExpansionCoefficient"]) == 0.0: + self.material.pop("ThermalExpansionCoefficient", None) FreeCAD.Console.PrintMessage( - 'Zero ThermalExpansionCoefficient value. ' - 'This parameter is not saved in the material data.\n' + "Zero ThermalExpansionCoefficient value. " + "This parameter is not saved in the material data.\n" ) - if Units.Quantity(self.material['SpecificHeat']) == 0.0: - self.material.pop('SpecificHeat', None) + if Units.Quantity(self.material["SpecificHeat"]) == 0.0: + self.material.pop("SpecificHeat", None) FreeCAD.Console.PrintMessage( - 'Zero SpecificHeat value. ' - 'This parameter is not saved in the material data.\n' + "Zero SpecificHeat value. " + "This parameter is not saved in the material data.\n" ) # choose material **************************************************************************** def get_material_card(self, material): for a_mat in self.materials: unmatched_items = set(self.materials[a_mat].items()) ^ set(material.items()) - # print(a_mat + ' --> unmatched_items = ' + str(len(unmatched_items))) + # print(a_mat + " --> unmatched_items = " + str(len(unmatched_items))) # if len(unmatched_items) < 4: # print(unmatched_items) if len(unmatched_items) == 0: @@ -324,8 +324,8 @@ class _TaskPanelFemMaterial: return self.card_path = self.parameterWidget.cb_materials.itemData(index) # returns whole path FreeCAD.Console.PrintMessage( - 'choose_material in FEM material task panel:\n' - ' {}\n'.format(self.card_path) + "choose_material in FEM material task panel:\n" + " {}\n".format(self.card_path) ) self.material = self.materials[self.card_path] self.check_material_keys() @@ -333,23 +333,23 @@ class _TaskPanelFemMaterial: self.parameterWidget.cb_materials.setCurrentIndex(index) # set after input fields gen_mat_desc = "" gen_mat_name = "" - if 'Description' in self.material: - gen_mat_desc = self.material['Description'] - if 'Name' in self.material: - gen_mat_name = self.material['Name'] + if "Description" in self.material: + gen_mat_desc = self.material["Description"] + if "Name" in self.material: + gen_mat_name = self.material["Name"] self.parameterWidget.l_mat_description.setText(gen_mat_desc) self.parameterWidget.l_mat_name.setText(gen_mat_name) - # print('choose_material: done') + # print("choose_material: done") def set_transient_material(self): - self.card_path = '_transient_material' + self.card_path = "_transient_material" self.materials[self.card_path] = self.material # = the current input fields data index = self.parameterWidget.cb_materials.findData(self.card_path) self.choose_material(index) def add_transient_material(self): self.has_transient_mat = True - self.card_path = '_transient_material' + self.card_path = "_transient_material" self.parameterWidget.cb_materials.addItem( QtGui.QIcon(":/icons/help-browser.svg"), self.card_path, @@ -363,7 +363,7 @@ class _TaskPanelFemMaterial: import MaterialEditor if self.card_path not in self.cards: FreeCAD.Console.PrintLog( - 'Card path not in cards, material dict will be used to open Material Editor.\n' + "Card path not in cards, material dict will be used to open Material Editor.\n" ) new_material_params = MaterialEditor.editMaterial(material=self.material) else: @@ -371,14 +371,14 @@ class _TaskPanelFemMaterial: # material editor returns the mat_dict only, not a card_path # if the material editor was canceled a empty dict will be returned # do not change the self.material - # check if dict is not empty (do not use 'is True') + # check if dict is not empty (do not use "is True") if new_material_params: # check material quantity units from materialtools.cardutils import check_mat_units as checkunits if checkunits(new_material_params) is True: self.material = new_material_params self.card_path = self.get_material_card(self.material) - # print('card_path: ' + self.card_path) + # print("card_path: " + self.card_path) self.check_material_keys() self.set_mat_params_in_input_fields(self.material) if not self.card_path: @@ -405,14 +405,14 @@ class _TaskPanelFemMaterial: self.choose_material(index) else: error_message = ( - 'Due to some wrong material quantity units in data passed ' - 'by the material editor, the material data was not changed.\n' + "Due to some wrong material quantity units in data passed " + "by the material editor, the material data was not changed.\n" ) FreeCAD.Console.PrintError(error_message) QtGui.QMessageBox.critical(None, "Material data not changed", error_message) else: FreeCAD.Console.PrintLog( - 'No changes where made by the material editor.\n' + "No changes where made by the material editor.\n" ) def toggleInputFieldsReadOnly(self): @@ -439,145 +439,145 @@ class _TaskPanelFemMaterial: def check_material_keys(self): # FreeCAD units definition is at file end of src/Base/Unit.cpp if not self.material: - FreeCAD.Console.PrintMessage('For some reason all material data is empty!\n') - self.material['Name'] = 'Empty' - if 'Density' in self.material: - if 'Density' not in str(Units.Unit(self.material['Density'])): + FreeCAD.Console.PrintMessage("For some reason all material data is empty!\n") + self.material["Name"] = "Empty" + if "Density" in self.material: + if "Density" not in str(Units.Unit(self.material["Density"])): FreeCAD.Console.PrintMessage( - 'Density in material data seems to have no unit ' - 'or a wrong unit (reset the value): {}\n' - .format(self.material['Name']) + "Density in material data seems to have no unit " + "or a wrong unit (reset the value): {}\n" + .format(self.material["Name"]) ) - self.material['Density'] = '0 kg/m^3' + self.material["Density"] = "0 kg/m^3" else: FreeCAD.Console.PrintMessage( - 'Density not found in material data of: {}\n' - .format(self.material['Name']) + "Density not found in material data of: {}\n" + .format(self.material["Name"]) ) - self.material['Density'] = '0 kg/m^3' - if self.obj.Category == 'Solid': + self.material["Density"] = "0 kg/m^3" + if self.obj.Category == "Solid": # mechanical properties - if 'YoungsModulus' in self.material: + if "YoungsModulus" in self.material: # unit type of YoungsModulus is Pressure - if 'Pressure' not in str(Units.Unit(self.material['YoungsModulus'])): + if "Pressure" not in str(Units.Unit(self.material["YoungsModulus"])): FreeCAD.Console.PrintMessage( - 'YoungsModulus in material data seems to have no unit ' - 'or a wrong unit (reset the value): {}\n' - .format(self.material['Name']) + "YoungsModulus in material data seems to have no unit " + "or a wrong unit (reset the value): {}\n" + .format(self.material["Name"]) ) - self.material['YoungsModulus'] = '0 MPa' + self.material["YoungsModulus"] = "0 MPa" else: FreeCAD.Console.PrintMessage( - 'YoungsModulus not found in material data of: {}\n' - .format(self.material['Name']) + "YoungsModulus not found in material data of: {}\n" + .format(self.material["Name"]) ) - self.material['YoungsModulus'] = '0 MPa' - if 'PoissonRatio' in self.material: + self.material["YoungsModulus"] = "0 MPa" + if "PoissonRatio" in self.material: # PoissonRatio does not have a unit, but it is checked it there is no value at all try: - float(self.material['PoissonRatio']) + float(self.material["PoissonRatio"]) except ValueError: FreeCAD.Console.PrintMessage( - 'PoissonRatio has wrong or no data (reset the value): {}\n' - .format(self.material['PoissonRatio']) + "PoissonRatio has wrong or no data (reset the value): {}\n" + .format(self.material["PoissonRatio"]) ) - self.material['PoissonRatio'] = '0' + self.material["PoissonRatio"] = "0" else: FreeCAD.Console.PrintMessage( - 'PoissonRatio not found in material data of: {}\n' - .format(self.material['Name']) + "PoissonRatio not found in material data of: {}\n" + .format(self.material["Name"]) ) - self.material['PoissonRatio'] = '0' - if self.obj.Category == 'Fluid': + self.material["PoissonRatio"] = "0" + if self.obj.Category == "Fluid": # Fluidic properties - if 'KinematicViscosity' in self.material: - ki_vis = self.material['KinematicViscosity'] - if 'KinematicViscosity' not in str(Units.Unit(ki_vis)): + if "KinematicViscosity" in self.material: + ki_vis = self.material["KinematicViscosity"] + if "KinematicViscosity" not in str(Units.Unit(ki_vis)): FreeCAD.Console.PrintMessage( - 'KinematicViscosity in material data seems to have no unit ' - 'or a wrong unit (reset the value): {}\n' - .format(self.material['Name']) + "KinematicViscosity in material data seems to have no unit " + "or a wrong unit (reset the value): {}\n" + .format(self.material["Name"]) ) - self.material['KinematicViscosity'] = '0 m^2/s' + self.material["KinematicViscosity"] = "0 m^2/s" else: FreeCAD.Console.PrintMessage( - 'KinematicViscosity not found in material data of: {}\n' - .format(self.material['Name']) + "KinematicViscosity not found in material data of: {}\n" + .format(self.material["Name"]) ) - self.material['KinematicViscosity'] = '0 m^2/s' - if 'VolumetricThermalExpansionCoefficient' in self.material: + self.material["KinematicViscosity"] = "0 m^2/s" + if "VolumetricThermalExpansionCoefficient" in self.material: # unit type VolumetricThermalExpansionCoefficient is ThermalExpansionCoefficient - vol_ther_ex_co = self.material['VolumetricThermalExpansionCoefficient'] - if 'VolumetricThermalExpansionCoefficient' not in str(Units.Unit(vol_ther_ex_co)): + vol_ther_ex_co = self.material["VolumetricThermalExpansionCoefficient"] + if "VolumetricThermalExpansionCoefficient" not in str(Units.Unit(vol_ther_ex_co)): FreeCAD.Console.PrintMessage( - 'VolumetricThermalExpansionCoefficient in material data ' - 'seems to have no unit or a wrong unit (reset the value): {}\n' - .format(self.material['Name']) + "VolumetricThermalExpansionCoefficient in material data " + "seems to have no unit or a wrong unit (reset the value): {}\n" + .format(self.material["Name"]) ) - self.material['VolumetricThermalExpansionCoefficient'] = '0 m/m/K' + self.material["VolumetricThermalExpansionCoefficient"] = "0 m/m/K" else: FreeCAD.Console.PrintMessage( - 'VolumetricThermalExpansionCoefficient not found in material data of: {}\n' - .format(self.material['Name']) + "VolumetricThermalExpansionCoefficient not found in material data of: {}\n" + .format(self.material["Name"]) ) - self.material['VolumetricThermalExpansionCoefficient'] = '0 m/m/K' + self.material["VolumetricThermalExpansionCoefficient"] = "0 m/m/K" # Thermal properties - if 'ThermalConductivity' in self.material: - if 'ThermalConductivity' not in str(Units.Unit(self.material['ThermalConductivity'])): + if "ThermalConductivity" in self.material: + if "ThermalConductivity" not in str(Units.Unit(self.material["ThermalConductivity"])): FreeCAD.Console.PrintMessage( - 'ThermalConductivity in material data seems to have no unit ' - 'or a wrong unit (reset the value): {}\n' - .format(self.material['Name']) + "ThermalConductivity in material data seems to have no unit " + "or a wrong unit (reset the value): {}\n" + .format(self.material["Name"]) ) - self.material['ThermalConductivity'] = '0 W/m/K' + self.material["ThermalConductivity"] = "0 W/m/K" else: FreeCAD.Console.PrintMessage( - 'ThermalConductivity not found in material data of: {}\n' - .format(self.material['Name']) + "ThermalConductivity not found in material data of: {}\n" + .format(self.material["Name"]) ) - self.material['ThermalConductivity'] = '0 W/m/K' - if 'ThermalExpansionCoefficient' in self.material: - the_ex_co = self.material['ThermalExpansionCoefficient'] - if 'ThermalExpansionCoefficient' not in str(Units.Unit(the_ex_co)): + self.material["ThermalConductivity"] = "0 W/m/K" + if "ThermalExpansionCoefficient" in self.material: + the_ex_co = self.material["ThermalExpansionCoefficient"] + if "ThermalExpansionCoefficient" not in str(Units.Unit(the_ex_co)): FreeCAD.Console.PrintMessage( - 'ThermalExpansionCoefficient in material data seems to have no unit ' - 'or a wrong unit (reset the value): {}\n' - .format(self.material['Name']) + "ThermalExpansionCoefficient in material data seems to have no unit " + "or a wrong unit (reset the value): {}\n" + .format(self.material["Name"]) ) - self.material['ThermalExpansionCoefficient'] = '0 um/m/K' + self.material["ThermalExpansionCoefficient"] = "0 um/m/K" else: FreeCAD.Console.PrintMessage( - 'ThermalExpansionCoefficient not found in material data of: {}\n' - .format(self.material['Name']) + "ThermalExpansionCoefficient not found in material data of: {}\n" + .format(self.material["Name"]) ) - self.material['ThermalExpansionCoefficient'] = '0 um/m/K' - if 'SpecificHeat' in self.material: - if 'SpecificHeat' not in str(Units.Unit(self.material['SpecificHeat'])): + self.material["ThermalExpansionCoefficient"] = "0 um/m/K" + if "SpecificHeat" in self.material: + if "SpecificHeat" not in str(Units.Unit(self.material["SpecificHeat"])): FreeCAD.Console.PrintMessage( - 'SpecificHeat in material data seems to have no unit ' - 'or a wrong unit (reset the value): {}\n' - .format(self.material['Name']) + "SpecificHeat in material data seems to have no unit " + "or a wrong unit (reset the value): {}\n" + .format(self.material["Name"]) ) - self.material['SpecificHeat'] = '0 J/kg/K' + self.material["SpecificHeat"] = "0 J/kg/K" else: FreeCAD.Console.PrintMessage( - 'SpecificHeat not found in material data of: {}\n' - .format(self.material['Name']) + "SpecificHeat not found in material data of: {}\n" + .format(self.material["Name"]) ) - self.material['SpecificHeat'] = '0 J/kg/K' - FreeCAD.Console.PrintMessage('\n') + self.material["SpecificHeat"] = "0 J/kg/K" + FreeCAD.Console.PrintMessage("\n") # mechanical input fields def ym_changed(self): # FreeCADs standard unit for stress is kPa value = self.parameterWidget.input_fd_young_modulus.property("rawValue") - old_ym = Units.Quantity(self.material['YoungsModulus']).getValueAs("kPa") + old_ym = Units.Quantity(self.material["YoungsModulus"]).getValueAs("kPa") variation = 0.001 if value: if not (1 - variation < float(old_ym) / value < 1 + variation): # YoungsModulus has changed material = self.material - material['YoungsModulus'] = unicode(value) + " kPa" + material["YoungsModulus"] = unicode(value) + " kPa" self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -587,7 +587,7 @@ class _TaskPanelFemMaterial: def density_changed(self): # FreeCADs standard unit for density is kg/mm^3 value = self.parameterWidget.input_fd_density.property("rawValue") - old_density = Units.Quantity(self.material['Density']).getValueAs("kg/m^3") + old_density = Units.Quantity(self.material["Density"]).getValueAs("kg/m^3") variation = 0.001 if value: if not (1 - variation < float(old_density) / value < 1 + variation): @@ -595,7 +595,7 @@ class _TaskPanelFemMaterial: material = self.material value_in_kg_per_m3 = value * 1e9 # SvdW:Keep density in SI units for easier readability - material['Density'] = unicode(value_in_kg_per_m3) + " kg/m^3" + material["Density"] = unicode(value_in_kg_per_m3) + " kg/m^3" self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -604,13 +604,13 @@ class _TaskPanelFemMaterial: def pr_changed(self): value = self.parameterWidget.spinBox_poisson_ratio.value() - old_pr = Units.Quantity(self.material['PoissonRatio']) + old_pr = Units.Quantity(self.material["PoissonRatio"]) variation = 0.001 if value: if not (1 - variation < float(old_pr) / value < 1 + variation): # PoissonRatio has changed material = self.material - material['PoissonRatio'] = unicode(value) + material["PoissonRatio"] = unicode(value) self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -619,7 +619,7 @@ class _TaskPanelFemMaterial: elif value == 0: # PoissonRatio was set to 0.0 what is possible material = self.material - material['PoissonRatio'] = unicode(value) + material["PoissonRatio"] = unicode(value) self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -629,14 +629,14 @@ class _TaskPanelFemMaterial: # thermal input fields def tc_changed(self): value = self.parameterWidget.input_fd_thermal_conductivity.property("rawValue") - old_tc = Units.Quantity(self.material['ThermalConductivity']).getValueAs("W/m/K") + old_tc = Units.Quantity(self.material["ThermalConductivity"]).getValueAs("W/m/K") variation = 0.001 if value: if not (1 - variation < float(old_tc) / value < 1 + variation): # ThermalConductivity has changed material = self.material value_in_W_per_mK = value * 1e-3 # To compensate for use of SI units - material['ThermalConductivity'] = unicode(value_in_W_per_mK) + " W/m/K" + material["ThermalConductivity"] = unicode(value_in_W_per_mK) + " W/m/K" self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -646,7 +646,7 @@ class _TaskPanelFemMaterial: def tec_changed(self): value = self.parameterWidget.input_fd_expansion_coefficient.property("rawValue") old_tec = Units.Quantity( - self.material['ThermalExpansionCoefficient'] + self.material["ThermalExpansionCoefficient"] ).getValueAs("um/m/K") variation = 0.001 if value: @@ -654,7 +654,7 @@ class _TaskPanelFemMaterial: # ThermalExpansionCoefficient has changed material = self.material value_in_um_per_mK = value * 1e6 # To compensate for use of SI units - material['ThermalExpansionCoefficient'] = unicode(value_in_um_per_mK) + " um/m/K" + material["ThermalExpansionCoefficient"] = unicode(value_in_um_per_mK) + " um/m/K" self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -663,14 +663,14 @@ class _TaskPanelFemMaterial: def sh_changed(self): value = self.parameterWidget.input_fd_specific_heat.property("rawValue") - old_sh = Units.Quantity(self.material['SpecificHeat']).getValueAs("J/kg/K") + old_sh = Units.Quantity(self.material["SpecificHeat"]).getValueAs("J/kg/K") variation = 0.001 if value: if not (1 - variation < float(old_sh) / value < 1 + variation): # SpecificHeat has changed material = self.material value_in_J_per_kgK = value * 1e-6 # To compensate for use of SI units - material['SpecificHeat'] = unicode(value_in_J_per_kgK) + " J/kg/K" + material["SpecificHeat"] = unicode(value_in_J_per_kgK) + " J/kg/K" self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -681,7 +681,7 @@ class _TaskPanelFemMaterial: def vtec_changed(self): value = self.parameterWidget.input_fd_vol_expansion_coefficient.property("rawValue") old_vtec = Units.Quantity( - self.material['VolumetricThermalExpansionCoefficient'] + self.material["VolumetricThermalExpansionCoefficient"] ).getValueAs("m/m/K") variation = 0.001 if value: @@ -689,7 +689,7 @@ class _TaskPanelFemMaterial: # VolumetricThermalExpansionCoefficient has changed material = self.material value_in_one_per_K = unicode(value) + " m/m/K" - material['VolumetricThermalExpansionCoefficient'] = value_in_one_per_K + material["VolumetricThermalExpansionCoefficient"] = value_in_one_per_K self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -698,14 +698,14 @@ class _TaskPanelFemMaterial: def kinematic_viscosity_changed(self): value = self.parameterWidget.input_fd_kinematic_viscosity.property("rawValue") - old_nu = Units.Quantity(self.material['KinematicViscosity']).getValueAs("m^2/s") + old_nu = Units.Quantity(self.material["KinematicViscosity"]).getValueAs("m^2/s") variation = 0.000001 if value: if not (1 - variation < float(old_nu) / value < 1 + variation): # KinematicViscosity has changed material = self.material value_in_m2_per_second = value - material['KinematicViscosity'] = unicode(value_in_m2_per_second) + " m^2/s" + material["KinematicViscosity"] = unicode(value_in_m2_per_second) + " m^2/s" self.material = material if self.has_transient_mat is False: self.add_transient_material() @@ -713,32 +713,32 @@ class _TaskPanelFemMaterial: self.set_transient_material() def set_mat_params_in_input_fields(self, matmap): - if 'YoungsModulus' in matmap: + if "YoungsModulus" in matmap: ym_new_unit = "MPa" - ym = FreeCAD.Units.Quantity(matmap['YoungsModulus']) + ym = FreeCAD.Units.Quantity(matmap["YoungsModulus"]) ym_with_new_unit = ym.getValueAs(ym_new_unit) q = FreeCAD.Units.Quantity("{} {}".format(ym_with_new_unit, ym_new_unit)) self.parameterWidget.input_fd_young_modulus.setText(q.UserString) - if 'PoissonRatio' in matmap: - self.parameterWidget.spinBox_poisson_ratio.setValue(float(matmap['PoissonRatio'])) + if "PoissonRatio" in matmap: + self.parameterWidget.spinBox_poisson_ratio.setValue(float(matmap["PoissonRatio"])) # Fluidic properties - if 'KinematicViscosity' in matmap: + if "KinematicViscosity" in matmap: nu_new_unit = "m^2/s" - nu = FreeCAD.Units.Quantity(matmap['KinematicViscosity']) + nu = FreeCAD.Units.Quantity(matmap["KinematicViscosity"]) nu_with_new_unit = nu.getValueAs(nu_new_unit) q = FreeCAD.Units.Quantity("{} {}".format(nu_with_new_unit, nu_new_unit)) self.parameterWidget.input_fd_kinematic_viscosity.setText(q.UserString) # For isotropic materials the volumetric thermal expansion coefficient # is three times the linear coefficient: - if 'VolumetricThermalExpansionCoefficient' in matmap: # linear, only for solid + if "VolumetricThermalExpansionCoefficient" in matmap: # linear, only for solid vtec_new_unit = "m/m/K" - vtec = FreeCAD.Units.Quantity(matmap['VolumetricThermalExpansionCoefficient']) + vtec = FreeCAD.Units.Quantity(matmap["VolumetricThermalExpansionCoefficient"]) vtec_with_new_unit = vtec.getValueAs(vtec_new_unit) q = FreeCAD.Units.Quantity("{} {}".format(vtec_with_new_unit, vtec_new_unit)) self.parameterWidget.input_fd_vol_expansion_coefficient.setText(q.UserString) - if 'Density' in matmap: + if "Density" in matmap: density_new_unit = "kg/m^3" - density = FreeCAD.Units.Quantity(matmap['Density']) + density = FreeCAD.Units.Quantity(matmap["Density"]) density_with_new_unit = density.getValueAs(density_new_unit) # self.parameterWidget.input_fd_density.setText( # "{} {}".format(density_with_new_unit, density_new_unit) @@ -746,21 +746,21 @@ class _TaskPanelFemMaterial: q = FreeCAD.Units.Quantity("{} {}".format(density_with_new_unit, density_new_unit)) self.parameterWidget.input_fd_density.setText(q.UserString) # thermal properties - if 'ThermalConductivity' in matmap: + if "ThermalConductivity" in matmap: tc_new_unit = "W/m/K" - tc = FreeCAD.Units.Quantity(matmap['ThermalConductivity']) + tc = FreeCAD.Units.Quantity(matmap["ThermalConductivity"]) tc_with_new_unit = tc.getValueAs(tc_new_unit) q = FreeCAD.Units.Quantity("{} {}".format(tc_with_new_unit, tc_new_unit)) self.parameterWidget.input_fd_thermal_conductivity.setText(q.UserString) - if 'ThermalExpansionCoefficient' in matmap: # linear, only for solid + if "ThermalExpansionCoefficient" in matmap: # linear, only for solid tec_new_unit = "um/m/K" - tec = FreeCAD.Units.Quantity(matmap['ThermalExpansionCoefficient']) + tec = FreeCAD.Units.Quantity(matmap["ThermalExpansionCoefficient"]) tec_with_new_unit = tec.getValueAs(tec_new_unit) q = FreeCAD.Units.Quantity("{} {}".format(tec_with_new_unit, tec_new_unit)) self.parameterWidget.input_fd_expansion_coefficient.setText(q.UserString) - if 'SpecificHeat' in matmap: + if "SpecificHeat" in matmap: sh_new_unit = "J/kg/K" - sh = FreeCAD.Units.Quantity(matmap['SpecificHeat']) + sh = FreeCAD.Units.Quantity(matmap["SpecificHeat"]) sh_with_new_unit = sh.getValueAs(sh_new_unit) q = FreeCAD.Units.Quantity("{} {}".format(sh_with_new_unit, sh_new_unit)) self.parameterWidget.input_fd_specific_heat.setText(q.UserString) diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterialMechanicalNonlinear.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterialMechanicalNonlinear.py index e7acf7b160..e56539e5d7 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterialMechanicalNonlinear.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterialMechanicalNonlinear.py @@ -76,9 +76,9 @@ class _ViewProviderFemMaterialMechanicalNonlinear: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterialReinforced.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterialReinforced.py index 76596d0680..33f10d9094 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterialReinforced.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterialReinforced.py @@ -38,7 +38,7 @@ from PySide import QtCore from PySide import QtGui import sys -False if False else FemGui.__name__ # flake8, dummy FemGui usage, returns 'FemGui' +False if False else FemGui.__name__ # flake8, dummy FemGui usage, returns "FemGui" if sys.version_info.major >= 3: unicode = str @@ -96,11 +96,11 @@ class _ViewProviderFemMaterialReinforced: else: from PySide.QtGui import QMessageBox message = ( - 'Active Task Dialog found! ' - 'Please close this one before opening a new one!' + "Active Task Dialog found! " + "Please close this one before opening a new one!" ) QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -111,22 +111,22 @@ class _ViewProviderFemMaterialReinforced: class _TaskPanelFemMaterialReinforced: - '''The editmode TaskPanel for FemMaterialReinforced objects''' + """The editmode TaskPanel for FemMaterialReinforced objects""" if sys.version_info.major >= 3: unicode = str def __init__(self, obj): - FreeCAD.Console.PrintMessage('\n') # empty line on start task panel + FreeCAD.Console.PrintMessage("\n") # empty line on start task panel self.obj = obj # init matrix and reinforcement material self.material_m = self.obj.Material - self.card_path_m = '' + self.card_path_m = "" self.has_transient_mat_m = False self.material_r = self.obj.Reinforcement - self.card_path_r = '' + self.card_path_r = "" self.has_transient_mat_r = False # mat_card is the FCMat file # card_name is the file name of the mat_card @@ -176,7 +176,7 @@ class _TaskPanelFemMaterialReinforced: # search for exact the mat_card_m and mat_card_r in all known cards # choose the current matrix material self.card_path_m = self.get_material_card(self.material_m) - FreeCAD.Console.PrintLog('card_path: {}'.format(self.card_path_m)) + FreeCAD.Console.PrintLog("card_path: {}".format(self.card_path_m)) if not self.card_path_m: # we have not found our material in self.materials dict :-( # we're going to add a user-defined temporary material: a document material @@ -184,7 +184,7 @@ class _TaskPanelFemMaterialReinforced: "Previously used material card cannot be found in material directories. " "Add document material.\n" ) - self.card_path_m = '_Document_Matrix_Material' + self.card_path_m = "_Document_Matrix_Material" self.materials[self.card_path_m] = self.material_m self.parameterWidget.cb_materials_m.addItem( QtGui.QIcon(":/icons/help-browser.svg"), @@ -207,7 +207,7 @@ class _TaskPanelFemMaterialReinforced: # choose the current reinforcement material self.card_path_r = self.get_material_card(self.material_r) - FreeCAD.Console.PrintLog('card_path: {}'.format(self.card_path_r)) + FreeCAD.Console.PrintLog("card_path: {}".format(self.card_path_r)) if not self.card_path_r: # we have not found our material in self.materials dict :-( # we're going to add a user-defined temporary material: a document material @@ -215,7 +215,7 @@ class _TaskPanelFemMaterialReinforced: "Previously used material card cannot be found in material directories. " "Add document material.\n" ) - self.card_path_r = '_Document_Reinforcement_Material' + self.card_path_r = "_Document_Reinforcement_Material" self.materials[self.card_path_r] = self.material_r self.parameterWidget.cb_materials_r.addItem( QtGui.QIcon(":/icons/help-browser.svg"), @@ -247,8 +247,8 @@ class _TaskPanelFemMaterialReinforced: self.obj.Reinforcement = self.material_r else: error_message = ( - 'Due to some wrong material quantity units in the changed ' - 'material data, the task panel changes where not accepted.\n' + "Due to some wrong material quantity units in the changed " + "material data, the task panel changes where not accepted.\n" ) FreeCAD.Console.PrintError(error_message) QtGui.QMessageBox.critical(None, "Material data not changed", error_message) @@ -268,23 +268,23 @@ class _TaskPanelFemMaterialReinforced: def output_obj_mat_param(self): self.print_mat_dict(self.obj.Material) self.print_mat_dict(self.obj.Reinforcement) - print('\n') + print("\n") def print_mat_dict(self, mat_dict): - if 'Name' in mat_dict: - print('Material: {}'.format(mat_dict['Name'])) + if "Name" in mat_dict: + print("Material: {}".format(mat_dict["Name"])) else: - print('Matrix material: no Name') + print("Matrix material: no Name") for key in mat_dict: - print(' {}: {}'.format(key, mat_dict[key])) + print(" {}: {}".format(key, mat_dict[key])) # choose material card *********************************************************************** def get_material_card(self, material): for a_mat in self.materials: unmatched_items = set(self.materials[a_mat].items()) ^ set(material.items()) - # print(a_mat + ' --> unmatched_items = ' + str(len(unmatched_items))) + # print(a_mat + " --> unmatched_items = " + str(len(unmatched_items))) if len(unmatched_items) < 4: - FreeCAD.Console.PrintLog('{}\n'.format(unmatched_items)) + FreeCAD.Console.PrintLog("{}\n".format(unmatched_items)) if len(unmatched_items) == 0: return a_mat return "" @@ -295,17 +295,17 @@ class _TaskPanelFemMaterialReinforced: # get the whole card path self.card_path_m = self.parameterWidget.cb_materials_m.itemData(index) FreeCAD.Console.PrintMessage( - 'choose_material in FEM material task panel:\n' - ' {}\n'.format(self.card_path_m) + "choose_material in FEM material task panel:\n" + " {}\n".format(self.card_path_m) ) self.material_m = self.materials[self.card_path_m] self.parameterWidget.cb_materials_m.setCurrentIndex(index) gen_mat_desc = "" gen_mat_name = "" - if 'Description' in self.material_m: - gen_mat_desc = self.material_m['Description'] - if 'Name' in self.material_m: - gen_mat_name = self.material_m['Name'] + if "Description" in self.material_m: + gen_mat_desc = self.material_m["Description"] + if "Name" in self.material_m: + gen_mat_name = self.material_m["Name"] self.parameterWidget.l_description_m.setText(gen_mat_desc) self.parameterWidget.l_name_m.setText(gen_mat_name) @@ -315,30 +315,30 @@ class _TaskPanelFemMaterialReinforced: # get the whole card path self.card_path_r = self.parameterWidget.cb_materials_r.itemData(index) FreeCAD.Console.PrintMessage( - 'choose_material in FEM material task panel:\n' - ' {}\n'.format(self.card_path_r) + "choose_material in FEM material task panel:\n" + " {}\n".format(self.card_path_r) ) self.material_r = self.materials[self.card_path_r] self.parameterWidget.cb_materials_r.setCurrentIndex(index) gen_mat_desc = "" gen_mat_name = "" - if 'Description' in self.material_r: - gen_mat_desc = self.material_r['Description'] - if 'Name' in self.material_r: - gen_mat_name = self.material_r['Name'] + if "Description" in self.material_r: + gen_mat_desc = self.material_r["Description"] + if "Name" in self.material_r: + gen_mat_name = self.material_r["Name"] self.parameterWidget.l_description_r.setText(gen_mat_desc) self.parameterWidget.l_name_r.setText(gen_mat_name) # transient material is needed if the user changed mat parameter by the mat editor def set_transient_material_m(self): - self.card_path_m = '_Transient_Matrix_Material' + self.card_path_m = "_Transient_Matrix_Material" self.materials[self.card_path_m] = self.material_m # = the current matrix mat dict index = self.parameterWidget.cb_materials_m.findData(self.card_path_m) self.choose_material_m(index) def add_transient_material_m(self): self.has_transient_mat_m = True - self.card_path_m = '_Transient_Matrix_Material' + self.card_path_m = "_Transient_Matrix_Material" self.parameterWidget.cb_materials_m.addItem( QtGui.QIcon(":/icons/help-browser.svg"), self.card_path_m, @@ -347,14 +347,14 @@ class _TaskPanelFemMaterialReinforced: self.set_transient_material_m() def set_transient_material_r(self): - self.card_path_r = '_Transient_Reinforcement_Material' + self.card_path_r = "_Transient_Reinforcement_Material" self.materials[self.card_path_r] = self.material_r # = the current reinforced mat dict index = self.parameterWidget.cb_materials_r.findData(self.card_path_r) self.choose_material_r(index) def add_transient_material_r(self): self.has_transient_mat_r = True - self.card_path_r = '_Transient_Reinforcement_Material' + self.card_path_r = "_Transient_Reinforcement_Material" self.parameterWidget.cb_materials_r.addItem( QtGui.QIcon(":/icons/help-browser.svg"), self.card_path_r, @@ -371,7 +371,7 @@ class _TaskPanelFemMaterialReinforced: import MaterialEditor if self.card_path_m not in self.cards: FreeCAD.Console.PrintLog( - 'Card path not in cards, material dict will be used to open Material Editor.\n' + "Card path not in cards, material dict will be used to open Material Editor.\n" ) new_material_params = MaterialEditor.editMaterial(material=self.material_m) else: @@ -379,14 +379,14 @@ class _TaskPanelFemMaterialReinforced: # material editor returns the mat_dict only, not a card_path # if the material editor was canceled a empty dict will be returned # do not change the self.material - # check if dict is not empty (do not use 'is True') + # check if dict is not empty (do not use "is True") if new_material_params: # check material quantity units from materialtools.cardutils import check_mat_units as checkunits if checkunits(new_material_params) is True: self.material_m = new_material_params self.card_path_m = self.get_material_card(self.material_m) - FreeCAD.Console.PrintMessage('card_path: {}\n'.format(self.card_path_m)) + FreeCAD.Console.PrintMessage("card_path: {}\n".format(self.card_path_m)) if not self.card_path_m: FreeCAD.Console.PrintMessage( "Material card chosen by the material editor " @@ -411,20 +411,20 @@ class _TaskPanelFemMaterialReinforced: self.choose_material_m(index) else: error_message = ( - 'Due to some wrong material quantity units in data passed ' - 'by the material editor, the material data was not changed.\n' + "Due to some wrong material quantity units in data passed " + "by the material editor, the material data was not changed.\n" ) FreeCAD.Console.PrintError(error_message) QtGui.QMessageBox.critical(None, "Material data not changed", error_message) else: - FreeCAD.Console.PrintMessage('No changes where made by the material editor.\n') + FreeCAD.Console.PrintMessage("No changes where made by the material editor.\n") def edit_material_r(self): # opens the material editor to choose a material or edit material params import MaterialEditor if self.card_path_r not in self.cards: FreeCAD.Console.PrintLog( - 'Card path not in cards, material dict will be used to open Material Editor.\n' + "Card path not in cards, material dict will be used to open Material Editor.\n" ) new_material_params = MaterialEditor.editMaterial(material=self.material_r) else: @@ -432,14 +432,14 @@ class _TaskPanelFemMaterialReinforced: # material editor returns the mat_dict only, not a card_path # if the material editor was canceled a empty dict will be returned # do not change the self.material - # check if dict is not empty (do not use 'is True') + # check if dict is not empty (do not use "is True") if new_material_params: # check material quantity units from materialtools.cardutils import check_mat_units as checkunits if checkunits(new_material_params) is True: self.material_r = new_material_params self.card_path_r = self.get_material_card(self.material_r) - FreeCAD.Console.PrintMessage('card_path: {}\n'.format(self.card_path_r)) + FreeCAD.Console.PrintMessage("card_path: {}\n".format(self.card_path_r)) if not self.card_path_r: FreeCAD.Console.PrintMessage( "Material card chosen by the material editor " @@ -464,13 +464,13 @@ class _TaskPanelFemMaterialReinforced: self.choose_material_r(index) else: error_message = ( - 'Due to some wrong material quantity units in data passed ' - 'by the material editor, the material data was not changed.\n' + "Due to some wrong material quantity units in data passed " + "by the material editor, the material data was not changed.\n" ) FreeCAD.Console.PrintError(error_message) QtGui.QMessageBox.critical(None, "Material data not changed", error_message) else: - FreeCAD.Console.PrintMessage('No changes where made by the material editor.\n') + FreeCAD.Console.PrintMessage("No changes where made by the material editor.\n") # fill the combo box with cards ************************************************************** def add_cards_to_combo_boxes(self): diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshBoundaryLayer.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshBoundaryLayer.py index f60a902c93..50a020305e 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshBoundaryLayer.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshBoundaryLayer.py @@ -90,9 +90,9 @@ class _ViewProviderFemMeshBoundaryLayer: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -103,7 +103,7 @@ class _ViewProviderFemMeshBoundaryLayer: class _TaskPanelFemMeshBoundaryLayer: - '''The TaskPanel for editing References property of FemMeshBoundaryLayer objects''' + """The TaskPanel for editing References property of FemMeshBoundaryLayer objects""" def __init__(self, obj): @@ -135,7 +135,7 @@ class _TaskPanelFemMeshBoundaryLayer: # start with Solid in list! self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection( obj.References, - ['Solid', 'Face', 'Edge', 'Vertex'] + ["Solid", "Face", "Edge", "Vertex"] ) # form made from param and selection widget diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshGmsh.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshGmsh.py index b286f2a682..bf46633b46 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshGmsh.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshGmsh.py @@ -91,7 +91,7 @@ class _ViewProviderFemMeshGmsh: # first check if there is an analysis in the active document found_an_analysis = False for o in gui_doc.Document.Objects: - if o.isDerivedFrom('Fem::FemAnalysisPython'): + if o.isDerivedFrom("Fem::FemAnalysisPython"): found_an_analysis = True break if found_an_analysis: @@ -102,66 +102,66 @@ class _ViewProviderFemMeshGmsh: gui_doc.setEdit(vobj.Object.Name) else: FreeCAD.Console.PrintError( - 'Activate the analysis this Gmsh FEM ' - 'mesh object belongs too!\n' + "Activate the analysis this Gmsh FEM " + "mesh object belongs too!\n" ) else: - print('Gmsh FEM mesh object does not belong to the active analysis.') + print("Gmsh FEM mesh object does not belong to the active analysis.") found_mesh_analysis = False for o in gui_doc.Document.Objects: - if o.isDerivedFrom('Fem::FemAnalysisPython'): + if o.isDerivedFrom("Fem::FemAnalysisPython"): for m in o.Group: if m == self.Object: found_mesh_analysis = True FemGui.setActiveAnalysis(o) print( - 'The analysis the Gmsh FEM mesh object ' - 'belongs to was found and activated: {}' + "The analysis the Gmsh FEM mesh object " + "belongs to was found and activated: {}" .format(o.Name) ) gui_doc.setEdit(vobj.Object.Name) break if not found_mesh_analysis: print( - 'Gmsh FEM mesh object does not belong to an analysis. ' - 'Analysis group meshing will be deactivated.' + "Gmsh FEM mesh object does not belong to an analysis. " + "Analysis group meshing will be deactivated." ) gui_doc.setEdit(vobj.Object.Name) else: - FreeCAD.Console.PrintError('Active analysis is not in active document.') + FreeCAD.Console.PrintError("Active analysis is not in active document.") else: print( - 'No active analysis in active document, ' - 'we are going to have a look if the Gmsh FEM mesh object ' - 'belongs to a non active analysis.' + "No active analysis in active document, " + "we are going to have a look if the Gmsh FEM mesh object " + "belongs to a non active analysis." ) found_mesh_analysis = False for o in gui_doc.Document.Objects: - if o.isDerivedFrom('Fem::FemAnalysisPython'): + if o.isDerivedFrom("Fem::FemAnalysisPython"): for m in o.Group: if m == self.Object: found_mesh_analysis = True FemGui.setActiveAnalysis(o) print( - 'The analysis the Gmsh FEM mesh object ' - 'belongs to was found and activated: {}'.format(o.Name) + "The analysis the Gmsh FEM mesh object " + "belongs to was found and activated: {}".format(o.Name) ) gui_doc.setEdit(vobj.Object.Name) break if not found_mesh_analysis: print( - 'Gmsh FEM mesh object does not belong to an analysis. ' - 'Analysis group meshing will be deactivated.' + "Gmsh FEM mesh object does not belong to an analysis. " + "Analysis group meshing will be deactivated." ) gui_doc.setEdit(vobj.Object.Name) else: - print('No analysis in the active document.') + print("No analysis in the active document.") gui_doc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -241,8 +241,8 @@ class _ViewProviderFemMeshGmsh: class _TaskPanelFemMeshGmsh: - '''The TaskPanel for editing References property of - FemMeshGmsh objects and creation of new FEM mesh''' + """The TaskPanel for editing References property of + FemMeshGmsh objects and creation of new FEM mesh""" def __init__(self, obj): self.mesh_obj = obj @@ -253,7 +253,7 @@ class _TaskPanelFemMeshGmsh: self.Timer = QtCore.QTimer() self.Timer.start(100) # 100 milli seconds self.gmsh_runs = False - self.console_message_gmsh = '' + self.console_message_gmsh = "" QtCore.QObject.connect( self.form.if_max, @@ -320,7 +320,7 @@ class _TaskPanelFemMeshGmsh: self.mesh_obj.ElementDimension = self.dimension def update(self): - 'fills the widgets' + "fills the widgets" self.form.if_max.setText(self.clmax.UserString) self.form.if_min.setText(self.clmin.UserString) index_dimension = self.form.cb_dimension.findText(self.dimension) @@ -328,7 +328,7 @@ class _TaskPanelFemMeshGmsh: def console_log(self, message="", color="#000000"): if (not isinstance(message, bytes)) and (sys.version_info.major < 3): - message = message.encode('utf-8', 'replace') + message = message.encode("utf-8", "replace") self.console_message_gmsh = self.console_message_gmsh + ( '{0:4.1f}: {2}
' .format(time.time() - self.Start, color, message) @@ -337,11 +337,11 @@ class _TaskPanelFemMeshGmsh: self.form.te_output.moveCursor(QtGui.QTextCursor.End) def update_timer_text(self): - # print('timer1') + # print("timer1") if self.gmsh_runs: - print('timer2') - # print('Time: {0:4.1f}: '.format(time.time() - self.Start)) - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) + print("timer2") + # print("Time: {0:4.1f}: ".format(time.time() - self.Start)) + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) def max_changed(self, base_quantity_value): self.clmax = base_quantity_value @@ -365,11 +365,11 @@ class _TaskPanelFemMeshGmsh: or part.Proxy.Type == "FeatureSlice" \ or part.Proxy.Type == "FeatureXOR": error_message = ( - 'The shape to mesh is a boolean split tools Compound ' - 'and the mesh has mesh region list. ' - 'Gmsh could return unexpected meshes in such circumstances. ' - 'It is strongly recommended to extract the shape ' - 'to mesh from the Compound and use this one.' + "The shape to mesh is a boolean split tools Compound " + "and the mesh has mesh region list. " + "Gmsh could return unexpected meshes in such circumstances. " + "It is strongly recommended to extract the shape " + "to mesh from the Compound and use this one." ) qtbox_title = ( "Shape to mesh is a BooleanFragmentsCompound " @@ -381,15 +381,15 @@ class _TaskPanelFemMeshGmsh: error_message ) self.Start = time.time() - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) - self.console_message_gmsh = '' + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) + self.console_message_gmsh = "" self.gmsh_runs = True self.console_log("We are going to start ...") self.get_active_analysis() import femmesh.gmshtools as gmshtools gmsh_mesh = gmshtools.GmshTools(self.obj, self.analysis) self.console_log("Start Gmsh ...") - error = '' + error = "" try: error = gmsh_mesh.create_mesh() except: @@ -397,12 +397,12 @@ class _TaskPanelFemMeshGmsh: print("Unexpected error when creating mesh: ", sys.exc_info()[0]) if error: print(error) - self.console_log('Gmsh had warnings ...') - self.console_log(error, '#FF0000') + self.console_log("Gmsh had warnings ...") + self.console_log(error, "#FF0000") else: - self.console_log('Clean run of Gmsh') + self.console_log("Clean run of Gmsh") self.console_log("Gmsh done!") - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) self.Timer.stop() self.update() QApplication.restoreOverrideCursor() @@ -413,11 +413,11 @@ class _TaskPanelFemMeshGmsh: if self.analysis: for m in FemGui.getActiveAnalysis().Group: if m.Name == self.mesh_obj.Name: - print('Active analysis found: ' + self.analysis.Name) + print("Active analysis found: " + self.analysis.Name) return else: - # print('Mesh is not member of active analysis, means no group meshing') + # print("Mesh is not member of active analysis, means no group meshing") self.analysis = None # no group meshing else: - # print('No active analysis, means no group meshing') + # print("No active analysis, means no group meshing") self.analysis = None # no group meshing diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshGroup.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshGroup.py index d246e361b5..7200073cfa 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshGroup.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshGroup.py @@ -89,9 +89,9 @@ class _ViewProviderFemMeshGroup: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -102,7 +102,7 @@ class _ViewProviderFemMeshGroup: class _TaskPanelFemMeshGroup: - '''The TaskPanel for editing References property of FemMeshGroup objects''' + """The TaskPanel for editing References property of FemMeshGroup objects""" def __init__(self, obj): @@ -128,7 +128,7 @@ class _TaskPanelFemMeshGroup: # start with Solid in list! self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection( obj.References, - ['Solid', 'Face', 'Edge', 'Vertex'] + ["Solid", "Face", "Edge", "Vertex"] ) # form made from param and selection widget diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshRegion.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshRegion.py index 760ddb443e..9e4995dad0 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshRegion.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemMeshRegion.py @@ -90,9 +90,9 @@ class _ViewProviderFemMeshRegion: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -103,7 +103,7 @@ class _ViewProviderFemMeshRegion: class _TaskPanelFemMeshRegion: - '''The TaskPanel for editing References property of FemMeshRegion objects''' + """The TaskPanel for editing References property of FemMeshRegion objects""" def __init__(self, obj): @@ -124,7 +124,7 @@ class _TaskPanelFemMeshRegion: # start with Solid in list! self.selectionWidget = FemSelectionWidgets.GeometryElementsSelection( obj.References, - ['Solid', 'Face', 'Edge', 'Vertex'] + ["Solid", "Face", "Edge", "Vertex"] ) # form made from param and selection widget diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemResultMechanical.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemResultMechanical.py index 66f531d43d..7d6d6d9dc1 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemResultMechanical.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemResultMechanical.py @@ -71,9 +71,9 @@ class _ViewProviderFemResultMechanical: guidoc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def setEdit(self, vobj, mode=0): @@ -86,10 +86,10 @@ class _ViewProviderFemResultMechanical: FreeCADGui.Control.showDialog(taskd) return True else: - error_message = 'FEM: Result object has no appropriate FEM mesh.\n' + error_message = "FEM: Result object has no appropriate FEM mesh.\n" FreeCAD.Console.PrintError(error_message) from PySide import QtGui - QtGui.QMessageBox.critical(None, 'No result object', error_message) + QtGui.QMessageBox.critical(None, "No result object", error_message) return False def unsetEdit(self, vobj, mode=0): @@ -117,7 +117,7 @@ class _ViewProviderFemResultMechanical: class _TaskPanelFemResultShow: - '''The task panel for the post-processing''' + """The task panel for the post-processing""" def __init__(self, obj): self.result_obj = obj @@ -508,8 +508,8 @@ class _TaskPanelFemResultShow: self.form.hsb_displacement_factor.setValue(value) def disable_empty_result_buttons(self): - ''' disable radio buttons if result does not exists in result object''' - '''assignments + """ disable radio buttons if result does not exists in result object""" + """assignments DisplacementLengths --> rb_abs_displacement DisplacementVectors --> rb_x_displacement, rb_y_displacement, rb_z_displacement Temperature --> rb_temperature @@ -519,7 +519,7 @@ class _TaskPanelFemResultShow: MaxShear --> rb_max_shear_stress MassFlowRate --> rb_massflowrate NetworkPressure --> rb_networkpressure - Peeq --> rb_peeq''' + Peeq --> rb_peeq""" if len(self.result_obj.DisplacementLengths) == 0: self.form.rb_abs_displacement.setEnabled(0) if len(self.result_obj.DisplacementVectors) == 0: @@ -552,15 +552,15 @@ class _TaskPanelFemResultShow: else: if not self.mesh_obj.FemMesh.VolumeCount: error_message = ( - 'FEM: Graphical bending stress output ' - 'for beam or shell FEM Meshes not yet supported.\n' + "FEM: Graphical bending stress output " + "for beam or shell FEM Meshes not yet supported.\n" ) FreeCAD.Console.PrintError(error_message) - QtGui.QMessageBox.critical(None, 'No result object', error_message) + QtGui.QMessageBox.critical(None, "No result object", error_message) else: - error_message = 'FEM: Result node numbers are not equal to FEM Mesh NodeCount.\n' + error_message = "FEM: Result node numbers are not equal to FEM Mesh NodeCount.\n" FreeCAD.Console.PrintError(error_message) - QtGui.QMessageBox.critical(None, 'No result object', error_message) + QtGui.QMessageBox.critical(None, "No result object", error_message) def reset_mesh_deformation(self): self.mesh_obj.ViewObject.applyDisplacement(0.0) @@ -593,7 +593,7 @@ def hide_parts_constraints(): hide_constraints = fem_prefs.GetBool("HideConstraint", False) if hide_constraints: for o in FreeCAD.ActiveDocument.Objects: - if o.isDerivedFrom('Fem::FemAnalysis'): + if o.isDerivedFrom("Fem::FemAnalysis"): for acnstrmesh in getActiveAnalysis().Group: if "Constraint" in acnstrmesh.TypeId: acnstrmesh.ViewObject.Visibility = False diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemSolverCalculix.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemSolverCalculix.py index 880bc4a645..fb150e1dc4 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemSolverCalculix.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemSolverCalculix.py @@ -79,9 +79,9 @@ class _ViewProviderFemSolverCalculix: doc.setEdit(vobj.Object.Name) else: from PySide.QtGui import QMessageBox - message = 'Active Task Dialog found! Please close this one before opening a new one!' + message = "Active Task Dialog found! Please close this one before opening a new one!" QMessageBox.critical(None, "Error in tree view", message) - FreeCAD.Console.PrintError(message + '\n') + FreeCAD.Console.PrintError(message + "\n") return True def __getstate__(self): @@ -92,7 +92,7 @@ class _ViewProviderFemSolverCalculix: class _TaskPanelFemSolverCalculix: - '''The TaskPanel for CalculiX ccx tools solver object''' + """The TaskPanel for CalculiX ccx tools solver object""" def __init__(self, solver_object): self.form = FreeCADGui.PySideUic.loadUi( @@ -109,7 +109,7 @@ class _TaskPanelFemSolverCalculix: self.Timer = QtCore.QTimer() self.Timer.start(300) - self.fem_console_message = '' + self.fem_console_message = "" # Connect Signals and Slots QtCore.QObject.connect( @@ -189,15 +189,15 @@ class _TaskPanelFemSolverCalculix: FreeCADGui.ActiveDocument.resetEdit() def update(self): - 'fills the widgets' + "fills the widgets" self.form.le_working_dir.setText(self.fea.working_dir) - if self.fea.solver.AnalysisType == 'static': + if self.fea.solver.AnalysisType == "static": self.form.rb_static_analysis.setChecked(True) - elif self.fea.solver.AnalysisType == 'frequency': + elif self.fea.solver.AnalysisType == "frequency": self.form.rb_frequency_analysis.setChecked(True) - elif self.fea.solver.AnalysisType == 'thermomech': + elif self.fea.solver.AnalysisType == "thermomech": self.form.rb_thermomech_analysis.setChecked(True) - elif self.fea.solver.AnalysisType == 'check': + elif self.fea.solver.AnalysisType == "check": self.form.rb_check_mesh.setChecked(True) return @@ -217,36 +217,36 @@ class _TaskPanelFemSolverCalculix: self.femConsoleMessage("CalculiX stdout is empty", "#FF0000") else: try: - out = unicode(out, 'utf-8', 'replace') + out = unicode(out, "utf-8", "replace") rx = QtCore.QRegExp("\\*ERROR.*\\n\\n") print(rx) rx.setMinimal(True) pos = rx.indexIn(out) while not pos < 0: match = rx.cap(0) - FreeCAD.Console.PrintError(match.strip().replace('\n', ' ') + '\n') + FreeCAD.Console.PrintError(match.strip().replace("\n", " ") + "\n") pos = rx.indexIn(out, pos + 1) out = os.linesep.join([s for s in out.splitlines() if s]) - self.femConsoleMessage(out.replace('\n', '
')) + self.femConsoleMessage(out.replace("\n", "
")) except UnicodeDecodeError: self.femConsoleMessage("Error converting stdout from CalculiX", "#FF0000") - if '*ERROR in e_c3d: nonpositive jacobian' in out: + if "*ERROR in e_c3d: nonpositive jacobian" in out: error_message = ( "\n\nCalculiX returned an error due to " "nonpositive jacobian determinant in at least one element\n" "Use the run button on selected solver to get a better error output.\n" ) FreeCAD.Console.PrintError(error_message) - if '*ERROR' in out: + if "*ERROR" in out: return False else: return True def UpdateText(self): if(self.Calculix.state() == QtCore.QProcess.ProcessState.Running): - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) - def calculixError(self, error=''): + def calculixError(self, error=""): print("Error() {}".format(error)) self.femConsoleMessage("CalculiX execute error: {}".format(error), "#FF0000") @@ -283,7 +283,7 @@ class _TaskPanelFemSolverCalculix: self.form.pb_run_ccx.setText("Re-run CalculiX") self.femConsoleMessage("Loading result sets...") - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) self.fea.reset_mesh_purge_results_checked() self.fea.inp_file_name = self.fea.inp_file_name @@ -307,10 +307,10 @@ class _TaskPanelFemSolverCalculix: QApplication.setOverrideCursor(Qt.WaitCursor) self.fea.load_results() QApplication.restoreOverrideCursor() - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) def choose_working_dir(self): - wd = QtGui.QFileDialog.getExistingDirectory(None, 'Choose CalculiX working directory', + wd = QtGui.QFileDialog.getExistingDirectory(None, "Choose CalculiX working directory", self.fea.working_dir) if os.path.isdir(wd): self.fea.setup_working_dir(wd) @@ -318,7 +318,7 @@ class _TaskPanelFemSolverCalculix: def write_input_file_handler(self): self.Start = time.time() - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) QApplication.restoreOverrideCursor() if self.check_prerequisites_helper(): QApplication.setOverrideCursor(Qt.WaitCursor) @@ -330,12 +330,12 @@ class _TaskPanelFemSolverCalculix: else: self.femConsoleMessage("Write .inp file failed!", "#FF0000") QApplication.restoreOverrideCursor() - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) def check_prerequisites_helper(self): self.Start = time.time() self.femConsoleMessage("Check dependencies...") - self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) + self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) self.fea.update_objects() message = self.fea.check_prerequisites() @@ -351,7 +351,7 @@ class _TaskPanelFemSolverCalculix: self.ext_editor_process.start(ext_editor_path, [filename]) def editCalculixInputFile(self): - print('editCalculixInputFile {}'.format(self.fea.inp_file_name)) + print("editCalculixInputFile {}".format(self.fea.inp_file_name)) ccx_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Ccx") if ccx_prefs.GetBool("UseInternalEditor", True): FemGui.open(self.fea.inp_file_name) @@ -367,7 +367,7 @@ class _TaskPanelFemSolverCalculix: FemGui.open(self.fea.inp_file_name) def runCalculix(self): - print('runCalculix') + print("runCalculix") self.Start = time.time() self.femConsoleMessage("CalculiX binary: {}".format(self.fea.ccx_binary)) @@ -375,7 +375,7 @@ class _TaskPanelFemSolverCalculix: # run Calculix print( - 'run CalculiX at: {} with: {}' + "run CalculiX at: {} with: {}" .format(self.fea.ccx_binary, os.path.splitext(self.fea.inp_file_name)[0]) ) # change cwd because ccx may crash if directory has no write permission @@ -383,7 +383,7 @@ class _TaskPanelFemSolverCalculix: self.cwd = QtCore.QDir.currentPath() fi = QtCore.QFileInfo(self.fea.inp_file_name) QtCore.QDir.setCurrent(fi.path()) - self.Calculix.start(self.fea.ccx_binary, ['-i', fi.baseName()]) + self.Calculix.start(self.fea.ccx_binary, ["-i", fi.baseName()]) QApplication.restoreOverrideCursor() @@ -394,13 +394,13 @@ class _TaskPanelFemSolverCalculix: self.form.pb_run_ccx.setEnabled(False) def select_static_analysis(self): - self.select_analysis_type('static') + self.select_analysis_type("static") def select_frequency_analysis(self): - self.select_analysis_type('frequency') + self.select_analysis_type("frequency") def select_thermomech_analysis(self): - self.select_analysis_type('thermomech') + self.select_analysis_type("thermomech") def select_check_mesh(self): - self.select_analysis_type('check') + self.select_analysis_type("check")