]> SALOME platform Git repositories - modules/hydrosolver.git/blob - src/salome_hydro/pytel/eficas/appli.py
Salome HOME
porting to PyQt5
[modules/hydrosolver.git] / src / salome_hydro / pytel / eficas / appli.py
1 #  Copyright (C) 2012-2013 EDF
2 #
3 #  This file is part of SALOME HYDRO module.
4 #
5 #  SALOME HYDRO module is free software: you can redistribute it and/or modify
6 #  it under the terms of the GNU General Public License as published by
7 #  the Free Software Foundation, either version 3 of the License, or
8 #  (at your option) any later version.
9 #
10 #  SALOME HYDRO module is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU General Public License for more details.
14 #
15 #  You should have received a copy of the GNU General Public License
16 #  along with SALOME HYDRO module.  If not, see <http://www.gnu.org/licenses/>.
17
18 import os
19 import sys
20
21 from PyQt5.QtGui import *
22 from PyQt5.QtWidgets import *
23
24
25 import salome
26 import SalomePyQt
27 sgPyQt = SalomePyQt.SalomePyQt()
28
29 from salome.kernel.logger import Logger
30 from salome.kernel import termcolor
31 logger = Logger("salome.hydro.pytel.eficas.appli",
32                 color = termcolor.GREEN_FG)
33
34 import eficasSalome
35
36 from salome.hydro.study import HydroStudyEditor
37
38 class EficasForPytelAppli(eficasSalome.MyEficas):
39     """
40     This class launches Eficas and adds entries for the created files in
41     HYDRO component in the study tree.
42
43     :type  fichier: string
44     :param fichier: path of an Eficas file to open
45
46     """
47     def __init__(self, fichier = None, version = None):
48         self.ed = HydroStudyEditor()
49         self.codedir = os.path.dirname(__file__)
50         sys.path[:0] = [self.codedir]
51         eficasSalome.MyEficas.__init__(self, sgPyQt.getDesktop(), "pytel",
52                                        fichier, version = version)
53         sgPyQt.createView("Eficas Pytel", self)
54
55     def addJdcInSalome(self, jdcPath):
56         """
57         Add the newly created file in Salome study
58         """
59         try:
60             self.ed.find_or_create_pytel_case(jdcPath)
61         except Exception, exc:
62             msgError = "Can't add file to Salome study tree"
63             logger.exception(msgError)
64             QMessageBox.warning(self, self.tr("Warning"),
65                                 self.tr("%s. Reason:\n%s\n\nSee logs for more details." % (msgError, exc)))
66         salome.sg.updateObjBrowser(0)
67
68     def closeEvent(self, event):
69         while self.codedir in sys.path:
70             sys.path.remove(self.codedir)
71         eficasSalome.MyEficas.closeEvent(self, event)