From 357989c55231d02ce33c1717f406a56ffb4dd518 Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 4 Aug 2022 04:19:55 +0200 Subject: [PATCH] [FEM] fix enable editing for all solvers - currently for Z88 nothing happens when clicking the Edit button in the solver task dialog. The reason is that opening *.txt files was never implemented - also do this for Elmer - for Z88 we need to open several file for a proper editing because the solver info is distributed over these files --- src/Mod/Fem/Gui/AppFemGuiPy.cpp | 7 +++++-- src/Mod/Fem/femsolver/elmer/solver.py | 17 +++++++++++++++++ src/Mod/Fem/femsolver/z88/solver.py | 22 +++++++++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/Mod/Fem/Gui/AppFemGuiPy.cpp b/src/Mod/Fem/Gui/AppFemGuiPy.cpp index fd9f3276e112..bed5bebb03e1 100755 --- a/src/Mod/Fem/Gui/AppFemGuiPy.cpp +++ b/src/Mod/Fem/Gui/AppFemGuiPy.cpp @@ -125,11 +125,14 @@ class Module : public Py::ExtensionModule } } - if (ext == QLatin1String("inp")) { + if ( (ext == QLatin1String("inp")) + || (ext == QLatin1String("sif")) + || (ext == QLatin1String("txt")) ) { Gui::TextEditor* editor = new Gui::TextEditor(); editor->setWindowIcon(Gui::BitmapFactory().pixmap(":/icons/fem-solver-inp-editor.svg")); Gui::EditorView* edit = new Gui::EditorView(editor, Gui::getMainWindow()); - editor->setSyntaxHighlighter(new FemGui::AbaqusHighlighter(editor)); + if (ext == QLatin1String("inp")) + editor->setSyntaxHighlighter(new FemGui::AbaqusHighlighter(editor)); edit->setDisplayName(Gui::EditorView::FileName); edit->open(fileName); edit->resize(400, 300); diff --git a/src/Mod/Fem/femsolver/elmer/solver.py b/src/Mod/Fem/femsolver/elmer/solver.py index 5b425f100440..6392e9afc22c 100644 --- a/src/Mod/Fem/femsolver/elmer/solver.py +++ b/src/Mod/Fem/femsolver/elmer/solver.py @@ -28,6 +28,11 @@ ## \addtogroup FEM # @{ +import glob +import os + +import FreeCAD + from . import tasks from .equations import elasticity from .equations import electrostatic @@ -39,6 +44,9 @@ from .. import solverbase from femtools import femutils +if FreeCAD.GuiUp: + import FemGui + def create(doc, name="ElmerSolver"): return femutils.createObject( @@ -109,6 +117,15 @@ def createEquation(self, doc, eqId): def isSupported(self, eqId): return eqId in self._EQUATIONS + def editSupported(self): + return True + + def edit(self, directory): + pattern = os.path.join(directory, "case.sif") + FreeCAD.Console.PrintMessage("{}\n".format(pattern)) + f = glob.glob(pattern)[0] + FemGui.open(f) + class ViewProxy(solverbase.ViewProxy): """Proxy for FemSolverElmers View Provider.""" diff --git a/src/Mod/Fem/femsolver/z88/solver.py b/src/Mod/Fem/femsolver/z88/solver.py index 8f223cde7398..089a3198b38c 100644 --- a/src/Mod/Fem/femsolver/z88/solver.py +++ b/src/Mod/Fem/femsolver/z88/solver.py @@ -78,7 +78,27 @@ def editSupported(self): return True def edit(self, directory): - pattern = os.path.join(directory, "*.txt") + pattern = os.path.join(directory, "z88i1.txt") + FreeCAD.Console.PrintMessage("{}\n".format(pattern)) + f = glob.glob(pattern)[0] + FemGui.open(f) + pattern = os.path.join(directory, "z88i2.txt") + FreeCAD.Console.PrintMessage("{}\n".format(pattern)) + f = glob.glob(pattern)[0] + FemGui.open(f) + pattern = os.path.join(directory, "z88i5.txt") + FreeCAD.Console.PrintMessage("{}\n".format(pattern)) + f = glob.glob(pattern)[0] + FemGui.open(f) + pattern = os.path.join(directory, "z88man.txt") + FreeCAD.Console.PrintMessage("{}\n".format(pattern)) + f = glob.glob(pattern)[0] + FemGui.open(f) + pattern = os.path.join(directory, "z88mat.txt") + FreeCAD.Console.PrintMessage("{}\n".format(pattern)) + f = glob.glob(pattern)[0] + FemGui.open(f) + pattern = os.path.join(directory, "z88elp.txt") FreeCAD.Console.PrintMessage("{}\n".format(pattern)) f = glob.glob(pattern)[0] FemGui.open(f)