1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2012-2013 EDF
5 # This file is part of SALOME HYDRO module.
7 # SALOME HYDRO module is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # SALOME HYDRO module is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with SALOME HYDRO module. If not, see <http://www.gnu.org/licenses/>.
24 from PyQt5.QtWidgets import QMessageBox , QScrollArea, QGridLayout
29 sgPyQt = SalomePyQt.SalomePyQt()
31 from salome.kernel.logger import Logger
32 from salome.kernel import termcolor
33 logger = Logger("salome.hydro.telemac2d.eficas.appli",
34 color = termcolor.GREEN_FG)
38 from salome.hydro.study import HydroStudyEditor
42 Horrible hack to allow a correct load of a Telemac case file when done after
43 some other edition, such as create case for Pytel execution.
45 eficasTelemacPath = os.path.join(eficasSalome.eficasConfig.eficasPath,'Telemac')
46 sys.path.insert(0, eficasTelemacPath)
47 from enum_Telemac2d_auto import TelemacdicoEn
52 class EficasForTelemac2DAppli(eficasSalome.MyEficas):
54 This class launches Eficas and adds entries for the created files in
55 HYDRO component in the study tree. The messages in this class are in
56 french because they are displayed in Eficas interface.
59 :param fichier: path of an Eficas file to open
62 def __init__(self, code = "telemac2d", fichier = None, version = None, lang = None):
63 self.ed = HydroStudyEditor()
64 self.codedir = os.path.dirname(__file__)
65 sys.path[:0] = [self.codedir]
66 #eficasSalome.MyEficas.__init__(self, sgPyQt.getDesktop(),
67 # code = code, fichier = fichier,
68 # version = version, lang = lang)
69 #area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
70 area = QScrollArea(SalomePyQt.SalomePyQt().getDesktop());
71 eficasSalome.MyEficas.__init__(self, area,
72 code = code, fichier = fichier,
73 version = version, lang = lang)
74 gridLayout = QGridLayout(area)
75 gridLayout.addWidget(self)
76 area.setWidgetResizable(1)
77 sgPyQt.createView("Eficas Telemac2D", self)
82 def addJdcInSalome(self, jdcPath):
84 Add the newly created file in Salome study
87 self.ed.find_or_create_telemac2d_case(jdcPath)
88 except Exception, exc:
89 msgError = "Can't add file to Salome study tree"
90 logger.exception(msgError)
91 QMessageBox.warning(self, self.tr("Warning"),
92 self.tr("%s. Reason:\n%s\n\nSee logs for "
93 "more details." % (msgError, exc)))
94 salome.sg.updateObjBrowser(0)
96 def closeEvent(self, event):
97 while self.codedir in sys.path:
98 sys.path.remove(self.codedir)
99 eficasSalome.MyEficas.closeEvent(self, event)