1 # Copyright (C) 2012-2013 EDF
3 # This file is part of SALOME HYDRO module.
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.
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.
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/>.
21 from PyQt4.QtGui import QMessageBox
25 sgPyQt = SalomePyQt.SalomePyQt()
27 from salome.kernel.logger import Logger
28 from salome.kernel import termcolor
29 logger = Logger("salome.hydro.pytel.eficas.appli",
30 color = termcolor.GREEN_FG)
34 from salome.hydro.study import HydroStudyEditor
36 class EficasForPytelAppli(eficasSalome.MyEficas):
38 This class launches Eficas and adds entries for the created files in
39 HYDRO component in the study tree.
42 :param fichier: path of an Eficas file to open
45 def __init__(self, fichier = None, version = None):
46 self.ed = HydroStudyEditor()
47 self.codedir = os.path.dirname(__file__)
48 sys.path[:0] = [self.codedir]
49 eficasSalome.MyEficas.__init__(self, sgPyQt.getDesktop(), "pytel",
50 fichier, version = version)
51 sgPyQt.createView("Eficas Pytel", self)
53 def addJdcInSalome(self, jdcPath):
55 Add the newly created file in Salome study
58 self.ed.find_or_create_pytel_case(jdcPath)
59 except Exception, exc:
60 msgError = "Can't add file to Salome study tree"
61 logger.exception(msgError)
62 QMessageBox.warning(self, self.tr("Warning"),
63 self.tr("%s. Reason:\n%s\n\nSee logs for more details." % (msgError, exc)))
64 salome.sg.updateObjBrowser(0)
66 def closeEvent(self, event):
67 while self.codedir in sys.path:
68 sys.path.remove(self.codedir)
69 eficasSalome.MyEficas.closeEvent(self, event)