From fb8c6f7abeaf617e94326e3cd540d3d6f538ddce Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Mon, 5 Jul 2021 13:06:21 +0200 Subject: [PATCH] FEM: code formating --- src/Mod/Fem/femguiutils/selection_widgets.py | 22 +++++++++++--------- src/Mod/Fem/femsolver/calculix/writer.py | 12 +++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Mod/Fem/femguiutils/selection_widgets.py b/src/Mod/Fem/femguiutils/selection_widgets.py index f423a19509..c7ae25c214 100644 --- a/src/Mod/Fem/femguiutils/selection_widgets.py +++ b/src/Mod/Fem/femguiutils/selection_widgets.py @@ -277,19 +277,21 @@ class GeometryElementsSelection(QtGui.QWidget): # label self._helpTextLbl = QtGui.QLabel() self._helpTextLbl.setWordWrap(True) - helpTextPart1 = self.tr('Click on "Add" and select geometric elements to add them to the list.') - helpTextPart2 = self.tr("The following geometry elements are allowed to select: ") + "" + self.sel_elem_text + "" - helpTextPart3 = self.tr("If no geometry is added to the list, all remaining ones are used.") + helpTextPart1 = self.tr( + 'Click on "Add" and select geometric elements to add them to the list.{}' + "The following geometry elements are allowed to select: {}{}{}" + .format("
", "", self.sel_elem_text, "") + ) + helpTextEmpty = self.tr( + "{}If no geometry is added to the list, all remaining ones are used.".format("
") + ) if self.showHintEmptyList is True: self._helpTextLbl.setText( - helpTextPart1 + "
" + - helpTextPart2 + "
" + - helpTextPart3 + helpTextPart1 + helpTextEmpty ) else: self._helpTextLbl.setText( - helpTextPart1 + "
" + - helpTextPart2 + helpTextPart1 ) # list self.list_References = QtGui.QListWidget() @@ -310,13 +312,13 @@ class GeometryElementsSelection(QtGui.QWidget): mainLayout.addWidget(self.list_References) # if only "Solid" is avail, std-sel-mode is obsolete - if "Solid" in self.sel_elem_types and len (self.sel_elem_types) == 1: + if "Solid" in self.sel_elem_types and len(self.sel_elem_types) == 1: self.selection_mode_solid = True else: self.selection_mode_solid = False # show radio buttons, if a solid and at least one nonsolid is allowed - if "Solid" in self.sel_elem_types and len (self.sel_elem_types) > 1: + if "Solid" in self.sel_elem_types and len(self.sel_elem_types) > 1: self.rb_standard.setChecked(True) self.rb_solid.setChecked(False) mainLayout.addLayout(rbtnLayout) diff --git a/src/Mod/Fem/femsolver/calculix/writer.py b/src/Mod/Fem/femsolver/calculix/writer.py index 4cf3a3d3c9..7df2fca43d 100644 --- a/src/Mod/Fem/femsolver/calculix/writer.py +++ b/src/Mod/Fem/femsolver/calculix/writer.py @@ -1662,13 +1662,13 @@ class FemInputWriterCcx(writerbase.FemInputWriter): ccx_elset["ccx_mat_name"] = mat_obj.Material["Name"] self.ccx_elsets.append(ccx_elset) - def is_DENSITY_card_needed(self): + def is_density_needed(self): if self.analysis_type == "frequency": return True - if self.selfweight_objects: - return True if self.analysis_type == "thermomech" and not self.solver_obj.ThermoMechSteadyState: return True + if self.selfweight_objects: + return True return False def write_materials(self, f): @@ -1676,7 +1676,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter): f.write("** Materials\n") f.write("** written by {} function\n".format(sys._getframe().f_code.co_name)) f.write("** Young\'s modulus unit is MPa = N/mm2\n") - if self.is_DENSITY_card_needed() is True: + if self.is_density_needed() is True: f.write("** Density\'s unit is t/mm^3\n") if self.analysis_type == "thermomech": f.write("** Thermal conductivity unit is kW/mm/K = t*mm/K*s^3\n") @@ -1692,7 +1692,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter): YM = FreeCAD.Units.Quantity(mat_obj.Material["YoungsModulus"]) YM_in_MPa = float(YM.getValueAs("MPa")) PR = float(mat_obj.Material["PoissonRatio"]) - if self.is_DENSITY_card_needed() is True: + if self.is_density_needed() is True: density = FreeCAD.Units.Quantity(mat_obj.Material["Density"]) density_in_tonne_per_mm3 = float(density.getValueAs("t/mm^3")) if self.analysis_type == "thermomech": @@ -1717,7 +1717,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter): f.write("*ELASTIC\n") f.write("{0:.0f}, {1:.3f}\n".format(YM_in_MPa, PR)) - if self.is_DENSITY_card_needed() is True: + if self.is_density_needed() is True: f.write("*DENSITY\n") f.write("{0:.3e}\n".format(density_in_tonne_per_mm3)) if self.analysis_type == "thermomech":