diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp index e3d015967d..770f7a4fd4 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp @@ -133,7 +133,6 @@ void ViewProviderFemPostPipeline::onSelectionChanged(const Gui::SelectionChanges void ViewProviderFemPostPipeline::updateColorBars() { - // take all visible childs and update its shape coloring auto children = claimChildren(); for (auto& child : children) { diff --git a/src/Mod/Fem/ObjectsFem.py b/src/Mod/Fem/ObjectsFem.py index 5f3bfd94d1..91e9378d07 100644 --- a/src/Mod/Fem/ObjectsFem.py +++ b/src/Mod/Fem/ObjectsFem.py @@ -742,8 +742,13 @@ def makePostVtkResult( ): """makePostVtkResult(document, base_result, [name]): creates a FEM post processing result object (vtk based) to hold FEM results""" - obj = doc.addObject("Fem::FemPostPipeline", name) + Pipeline_Name = "Pipeline_" + name + obj = doc.addObject("Fem::FemPostPipeline", Pipeline_Name) obj.load(base_result) + if FreeCAD.GuiUp: + obj.ViewObject.SelectionStyle = "BoundBox" + # to assure the user sees something, set the default to Surface + obj.ViewObject.DisplayMode = "Surface" return obj diff --git a/src/Mod/Fem/feminout/importCcxFrdResults.py b/src/Mod/Fem/feminout/importCcxFrdResults.py index 99e4042f6f..79c36015a1 100644 --- a/src/Mod/Fem/feminout/importCcxFrdResults.py +++ b/src/Mod/Fem/feminout/importCcxFrdResults.py @@ -107,9 +107,7 @@ def importFrd( .format(result_name_prefix, eigenmode_number) ) elif number_of_increments > 1: - if result_analysis_type == "buckling": - results_name = ( "{}BucklingFactor_{}_Results" .format(result_name_prefix, step_time) @@ -119,7 +117,6 @@ def importFrd( "{}Time_{}_Results" .format(result_name_prefix, step_time) ) - else: results_name = ( "{}Results" @@ -193,6 +190,31 @@ def importFrd( # fill Stats res_obj = resulttools.fill_femresult_stats(res_obj) + # create a results pipeline if not already existing + pipeline_name = "Pipeline_" + results_name + pipeline_obj = doc.getObject(pipeline_name) + if pipeline_obj is None: + pipeline_obj = ObjectsFem.makePostVtkResult(doc, res_obj, results_name) + pipeline_visibility = True + if analysis: + analysis.addObject(pipeline_obj) + else: + if FreeCAD.GuiUp: + # store pipeline visibility because pipeline_obj.load makes the + # pipeline always visible + pipeline_visibility = pipeline_obj.ViewObject.Visibility + pipeline_obj.load(res_obj) + # update the pipeline + pipeline_obj.recomputeChildren() + pipeline_obj.recompute() + if FreeCAD.GuiUp: + pipeline_obj.ViewObject.updateColorBars() + # make results mesh invisible, will be made visible + # later in task_solver_ccxtools.py + res_obj.Mesh.ViewObject.Visibility = False + # restore pipeline visibility + pipeline_obj.ViewObject.Visibility = pipeline_visibility + else: error_message = ( "Nodes, but no results found in frd file. " diff --git a/src/Mod/Fem/femtaskpanels/task_result_mechanical.py b/src/Mod/Fem/femtaskpanels/task_result_mechanical.py index 9b92c9891e..799ec748c2 100644 --- a/src/Mod/Fem/femtaskpanels/task_result_mechanical.py +++ b/src/Mod/Fem/femtaskpanels/task_result_mechanical.py @@ -65,11 +65,6 @@ class _TaskPanel: # if Mesh and result are in active analysis # activate the result mesh object self.mesh_obj.ViewObject.show() - # hide pipeline if any - CCX_pipeline = FreeCADGui.ActiveDocument.getObject("SolverCCXResult") - if CCX_pipeline is not None: - self.pipeline_visibility = CCX_pipeline.Visibility - CCX_pipeline.hide() ui_path = FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/" self.result_widget = FreeCADGui.PySideUic.loadUi(ui_path + "ResultShow.ui") @@ -195,12 +190,6 @@ class _TaskPanel: self.result_widget.sb_displacement_factor_max.setValue(10. * scale_factor) self.result_widget.sb_displacement_factor.setValue(scale_factor) - def __del__(self): - # restore visibility - CCX_pipeline = FreeCADGui.ActiveDocument.getObject("SolverCCXResult") - if self.pipeline_visibility and CCX_pipeline is not None: - CCX_pipeline.Visibility = self.pipeline_visibility - def restore_result_dialog(self): try: rt = FreeCAD.FEM_dialog["results_type"] diff --git a/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py b/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py index 5e749aa98f..ecd7a5e7c3 100644 --- a/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py +++ b/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py @@ -249,8 +249,6 @@ class _TaskPanel: # print("calculixFinished(), exit code: {}".format(exitCode)) FreeCAD.Console.PrintLog("calculix state: {}\n".format(self.Calculix.state())) - had_errors = False - # Restore previous cwd QtCore.QDir.setCurrent(self.cwd) @@ -260,7 +258,6 @@ class _TaskPanel: self.calculixNoError() else: self.calculixError() - had_errors = True self.form.pb_run_ccx.setText("Re-run CalculiX") self.femConsoleMessage("Loading result sets...") @@ -290,47 +287,15 @@ class _TaskPanel: self.fea.load_results() except Exception: FreeCAD.Console.PrintError("loading results failed\n") - had_errors = True QApplication.restoreOverrideCursor() self.form.l_time.setText("Time: {0:4.1f}: ".format(time.time() - self.Start)) - # create a results pipeline from the just created results object - if not had_errors: - CCX_results = self.fea.analysis.Document.getObject("CCX_Results") - # safe guard - if CCX_results is None: - return - # check if there is already a pipeline - self.CCX_pipeline = self.fea.analysis.Document.getObject("SolverCCXResult") - if self.CCX_pipeline is None: - try: - self._createResults() - except Exception: - FreeCAD.Console.PrintError("Results pipeline could not be created\n") - had_errors = True - self.CCX_pipeline.load(CCX_results) - self.CCX_pipeline.recomputeChildren() - self.fea.analysis.Document.recompute() - # recompute() updated the result mesh data - # but not the shape and bar coloring - self.CCX_pipeline.ViewObject.updateColorBars() - # restore mesh object visibility - CCX_mesh = self.fea.analysis.Document.getObject("ResultMesh") - if CCX_mesh is not None: - CCX_mesh.ViewObject.Visibility = self.CCX_mesh_visibility - else: - FreeCAD.Console.PrintError("\nNo result pipeline was created.\n") - - def _createResults(self): - self.CCX_pipeline = self.fea.analysis.Document.addObject( - "Fem::FemPostPipeline", "SolverCCXResult") - self.CCX_pipeline.Label = "SolverCCXResult" - self.CCX_pipeline.ViewObject.SelectionStyle = "BoundBox" - self.fea.analysis.addObject(self.CCX_pipeline) - # to assure the user sees something, set the default to Surface - self.CCX_pipeline.ViewObject.DisplayMode = "Surface" - + # restore mesh object visibility + CCX_mesh = self.fea.analysis.Document.getObject("ResultMesh") + if CCX_mesh is not None: + CCX_mesh.ViewObject.Visibility = self.CCX_mesh_visibility + def choose_working_dir(self): wd = QtGui.QFileDialog.getExistingDirectory(None, "Choose CalculiX working directory", self.fea.working_dir) diff --git a/src/Mod/Fem/femtest/app/test_object.py b/src/Mod/Fem/femtest/app/test_object.py index 87011ac19a..a0123a499a 100644 --- a/src/Mod/Fem/femtest/app/test_object.py +++ b/src/Mod/Fem/femtest/app/test_object.py @@ -86,7 +86,7 @@ class TestObjectCreate(unittest.TestCase): # thus they should not be counted # solver children: equations --> 8 # gmsh mesh children: group, region, boundary layer --> 3 - # resule children: mesh result --> 1 + # result children: mesh result --> 1 # post pipeline children: region, scalar, cut, wrap --> 5 # analysis itself is not in analysis group --> 1 # thus: -18