Salome HOME
Nouveau Patch Yoann pour 16614
[modules/hydrosolver.git] / src / salome_hydro / pytel / gui.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 SalomePyQt
19 sgPyQt = SalomePyQt.SalomePyQt()
20
21 from salome.hydro.gui_utils import get_and_check_selected_file_path
22 from salome.hydro.study import jdc_to_dict
23
24 from salome.hydro.pytel.eficas.appli import EficasForPytelAppli
25 from launcher import run_pytel
26 from genjobwindow import GenJobDialog
27
28 from PyQt5.QtWidgets import  QFileDialog
29
30 def create_case_pytel():
31   EficasForPytelAppli()
32
33 def edit_selected_case_pytel():
34   file=get_and_check_selected_file_path()
35   if file == None :
36      file, filt = QFileDialog.getOpenFileName(sgPyQt.getDesktop(), "Open Pytel file", "", )
37   EficasForPytelAppli(fichier=file)
38
39 def get_params_from_selected_case():
40   """
41   Get the parameters dict from the selected case in Salome study
42   """
43   jdcpath = get_and_check_selected_file_path()
44   with open(jdcpath) as jdcfile:
45     jdc = jdcfile.read()
46   param_dict = jdc_to_dict(jdc, ["PYTEL", "_F"])
47   return param_dict
48
49 def run_selected_case_pytel():
50   param_dict = get_params_from_selected_case()
51   run_pytel(param_dict)
52
53 def generate_job_for_selected_case_pytel():
54   param_dict = get_params_from_selected_case()
55   dialog = GenJobDialog(sgPyQt.getDesktop(), param_dict)
56   dialog.exec_()