Salome HOME
94be8735a12d94a11cf760915ad54cf528b1b9b6
[modules/hydrosolver.git] / src / salome_hydro / run_study / 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.run_study.eficas.appli import EficasForRunStudyAppli
25 from .launcher import run_study
26 from .genjobwindow import GenJobDialog
27
28 from PyQt5.QtWidgets import  QFileDialog
29
30 def create_case_study():
31     EficasForRunStudyAppli()
32
33 def edit_selected_case_study():
34     file=get_and_check_selected_file_path()
35     if file == None:
36         file, filt = QFileDialog.getOpenFileName(sgPyQt.getDesktop(), "Open study file", "", )
37     EficasForRunStudyAppli(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, ["RUN_STUDY", "_F"])
47   return param_dict
48
49 def run_selected_case_study():
50   param_dict = get_params_from_selected_case()
51   run_study(param_dict)
52
53 def generate_job_for_selected_case_study():
54   param_dict = get_params_from_selected_case()
55   dialog = GenJobDialog(sgPyQt.getDesktop(), param_dict)
56   dialog.exec_()