Skip to content

Commit

Permalink
[FEM] fix enable editing for all solvers
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
donovaly committed Aug 4, 2022
1 parent 0549a47 commit 357989c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Mod/Fem/Gui/AppFemGuiPy.cpp
Expand Up @@ -125,11 +125,14 @@ class Module : public Py::ExtensionModule<Module>
}
}

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);
Expand Down
17 changes: 17 additions & 0 deletions src/Mod/Fem/femsolver/elmer/solver.py
Expand Up @@ -28,6 +28,11 @@
## \addtogroup FEM
# @{

import glob
import os

import FreeCAD

from . import tasks
from .equations import elasticity
from .equations import electrostatic
Expand All @@ -39,6 +44,9 @@
from .. import solverbase
from femtools import femutils

if FreeCAD.GuiUp:
import FemGui


def create(doc, name="ElmerSolver"):
return femutils.createObject(
Expand Down Expand Up @@ -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."""
Expand Down
22 changes: 21 additions & 1 deletion src/Mod/Fem/femsolver/z88/solver.py
Expand Up @@ -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)
Expand Down

0 comments on commit 357989c

Please sign in to comment.