import traceback
import logging
-from PyQt4 import QtCore, QtGui
+from PyQt5.QtWidgets import QMessageBox, QApplication, QDialog
import salome
import SALOME
#logger.setLevel(logging.ERROR)
import HYDROSOLVER_ORB
+from salome.hydro.interpolz_gui import InterpolzDlg
from salome.hydro.gui_utils import HSGUIException, wait_cursor, get_and_check_selected_file_path
import salome.hydro.study as hydro_study
from salome.hydro.mascaret.eficas.appli import EficasForMascaretAppli
from salome.hydro.telemac2d.eficas.appli import EficasForTelemac2DAppli
from salome.hydro.coupling1d2d.eficas.appli import EficasForCoupling1D2DAppli
-import salome.hydro.pytel.gui as pytel_gui
-from salome.hydro.boundary_conditions.eficas.appli import EficasForBoundaryConditionsAppli
+from salome.hydro.pytel.gui import create_case_pytel, run_selected_case_pytel, edit_selected_case_pytel, generate_job_for_selected_case_pytel
+#from salome.hydro.boundary_conditions.eficas.appli import EficasForBoundaryConditionsAppli
+from eficasSalome import runEficas
import BndConditionsDialog
RUN_PYTEL_ID = 952
EDIT_PYTEL_CASE_ID = 953
GENERATE_JOB = 954
- DEFINE_BOUNDARY_CONDITIONS_ID = 955
+ #DEFINE_BOUNDARY_CONDITIONS_ID = 955
+ DEFINE_CAS_FILE = 955
EDIT_BOUNDARY_CONDITIONS_FILE_ID = 956
+ GENERATE_INTERPOLZ_PY_ID = 957
+ GEN_TELEMAC2D_PYTHON_ID = 958
def __init__( self ):
# create top-level menu
# create toolbar
tid = sgPyQt.createTool( "Hydro" )
# create actions and fill menu and toolbar with actions
- a = sgPyQt.createAction( GUIcontext.DEFINE_BOUNDARY_CONDITIONS_ID,
- "Define boundary conditions", "Define boundary conditions",
- "Define the boundary conditions for Telemac",
- "define_boundary_conditions.png" )
- sgPyQt.createMenu( a, mid )
- sgPyQt.createTool( a, tid )
-
a = sgPyQt.createAction( GUIcontext.EDIT_BOUNDARY_CONDITIONS_FILE_ID,
"Edit boundary conditions file", "Edit boundary conditions file",
"Create/edit the boundary conditions file for Telemac",
sgPyQt.createMenu( a, mid )
sgPyQt.createTool( a, tid )
- a = sgPyQt.createSeparator()
- sgPyQt.createMenu( a, mid )
- sgPyQt.createTool( a, tid )
a = sgPyQt.createAction( GUIcontext.CREATE_MASCARET_CASE_ID,
"Create Mascaret case", "Create Mascaret case",
sgPyQt.createTool( a, tid )
a = sgPyQt.createSeparator()
+
+ a = sgPyQt.createAction( GUIcontext.CREATE_PYTEL_CASE_ID,
+ "Create case for Pytel execution", "Create case for Pytel execution",
+ "Create a new case for Pytel execution", "create_case_pytel.png" )
+
sgPyQt.createMenu( a, mid )
sgPyQt.createTool( a, tid )
- a = sgPyQt.createAction( GUIcontext.CREATE_PYTEL_CASE_ID,
- "Create case for Pytel execution", "Create case for Pytel execution",
- "Create a new case for Pytel execution", "create_case_pytel.png" )
+ a = sgPyQt.createAction( GUIcontext.EDIT_PYTEL_CASE_ID,
+ "Edit case for Pytel execution", "Edit case for Pytel execution",
+ "Edit a new case for Pytel execution", "edit_case_pytel.png" )
+
+ sgPyQt.createMenu( a, mid )
+ sgPyQt.createTool( a, tid )
+
+ a = sgPyQt.createSeparator()
+
+ a = sgPyQt.createAction( GUIcontext.GENERATE_INTERPOLZ_PY_ID,
+ "Generate interpolz.py", "Generate interpolz.py",
+ "Generate interpolation script from the template", "generate_interpolz_py.png" )
+
+ sgPyQt.createMenu( a, mid )
+ sgPyQt.createTool( a, tid )
+
+ a = sgPyQt.createSeparator()
+ a = sgPyQt.createAction( GUIcontext.DEFINE_CAS_FILE,
+ "Edit cas file", "Edit cas file",
+ "Create/edit a .cas file for Telemac",
+ "define_cas_file.png" )
sgPyQt.createMenu( a, mid )
sgPyQt.createTool( a, tid )
+
# the following action are used in context popup
sgPyQt.createAction( GUIcontext.RUN_MASCARET_ID, "Compute case", "Compute case",
"Run Mascaret solver to compute the case" )
sgPyQt.createAction( GUIcontext.SHOW_LOG_ID, "Show log", "Show log",
"Show the log for the selected variable" )
+ sgPyQt.createAction( GUIcontext.GEN_TELEMAC2D_PYTHON_ID, "Generate Python script",
+ "Generate Python script",
+ "Run Telemac2D solver to compute the case" )
sgPyQt.createAction( GUIcontext.RUN_TELEMAC2D_ID, "Compute case", "Compute case",
"Run Telemac2D solver to compute the case" )
sgPyQt.createAction( GUIcontext.EDIT_TELEMAC2D_CASE_ID, "Edit case", "Edit case",
"Open the selected 1D / 2D coupling schema in YACS" )
sgPyQt.createAction( GUIcontext.RUN_PYTEL_ID, "Compute case", "Compute case",
- "Run Pytel launcher to compute the case" )
+ "Run Pytel launcher to compute the case" )
sgPyQt.createAction( GUIcontext.EDIT_PYTEL_CASE_ID, "Edit case", "Edit case",
- "Edit the selected Pytel case" )
+ "Edit the selected Pytel case" )
sgPyQt.createAction( GUIcontext.GENERATE_JOB, "Generate batch job", "Generate batch job",
"Generate a batch job to run the selected case")
+ sgPyQt.createAction( GUIcontext.DEFINE_CAS_FILE, "Edit .cas file", "Edit .cas file",
+ "Edit .cas file")
+
+
################################################
# Global variables
################################################
elif selectedType == hydro_study.TELEMAC2D_CASE_TYPE_ID:
popup.addAction(sgPyQt.action(GUIcontext.EDIT_TELEMAC2D_CASE_ID))
popup.addAction(sgPyQt.action(GUIcontext.RUN_TELEMAC2D_ID))
+ popup.addAction(sgPyQt.action(GUIcontext.GEN_TELEMAC2D_PYTHON_ID))
elif selectedType == hydro_study.COUPLING1D2D_CASE_TYPE_ID:
popup.addAction(sgPyQt.action(GUIcontext.EDIT_COUPLING1D2D_CASE_ID))
popup.addAction(sgPyQt.action(GUIcontext.OPEN_SCHEMA_IN_YACS_ID))
elif selectedType == hydro_study.LOG_TYPE_ID:
popup.addAction(sgPyQt.action(GUIcontext.SHOW_LOG_ID))
elif selectedType == hydro_study.PYTEL_CASE_TYPE_ID:
- popup.addAction(sgPyQt.action(GUIcontext.EDIT_PYTEL_CASE_ID))
- popup.addAction(sgPyQt.action(GUIcontext.RUN_PYTEL_ID))
- popup.addAction(sgPyQt.action(GUIcontext.GENERATE_JOB))
+ popup.addAction(sgPyQt.action(GUIcontext.EDIT_PYTEL_CASE_ID))
+ popup.addAction(sgPyQt.action(GUIcontext.RUN_PYTEL_ID))
+ popup.addAction(sgPyQt.action(GUIcontext.GENERATE_JOB))
# called when GUI action is activated
# action ID is passed as parameter
try:
dict_command[commandID]()
except HSGUIException, exc:
- QtGui.QMessageBox.critical(sgPyQt.getDesktop(),
- QtGui.QApplication.translate("OnGUIEvent", "Error"),
+ QMessageBox.critical(sgPyQt.getDesktop(),
+ QApplication.translate("OnGUIEvent", "Error"),
unicode(exc))
except:
logger.exception("Unhandled exception caught in HYDROSOLVER GUI")
- msg = QtGui.QApplication.translate("OnGUIEvent",
+ msg = QApplication.translate("OnGUIEvent",
"Unhandled error happened in HYDROSOLVER module. Please report a bug on "
'<a href="https://forge-pleiade.der.edf.fr/projects/salome-rex/issues">SALOME bugtracker</a>, '
'category "HYDROSOLVER", describing how you got there and including the following traceback:')
- msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Critical,
- QtGui.QApplication.translate("OnGUIEvent", "Error"),
+ msgBox = QMessageBox(QMessageBox.Critical,
+ QApplication.translate("OnGUIEvent", "Error"),
msg,
parent = sgPyQt.getDesktop())
msgBox.setDetailedText(traceback.format_exc())
"""
from TextDisplayDialog import Ui_TextDisplayDialog
-class MyTextDisplayDialog(Ui_TextDisplayDialog, QtGui.QDialog):
+class MyTextDisplayDialog(Ui_TextDisplayDialog, QDialog):
def __init__(self, parent = None, modal = 0):
- QtGui.QDialog.__init__(self, parent)
+ QDialog.__init__(self, parent)
Ui_TextDisplayDialog.__init__(self)
self.setupUi(self)
- self.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.close)
-
+ (self.closeButton.clicked.connect(self.close)
+
def set_log(self, log):
self.contentTextEdit.setPlainText(log)
self.setWindowTitle("Coupling log")
salome.sg.updateObjBrowser( 0 )
except SALOME.SALOME_Exception, exc:
salome.sg.updateObjBrowser( 0 )
- msg = unicode(QtGui.QApplication.translate("run_mascaret",
+ msg = unicode(QApplication.translate("run_mascaret",
"An error happened while trying to run Mascaret:"))
msg += "\n" + exc.details.text
raise HSGUIException(msg)
except SALOME.SALOME_Exception, exc:
if engine is not None:
engine.GetContainerRef().Shutdown()
- msg = unicode(QtGui.QApplication.translate("run_telemac2d",
+ msg = unicode(QApplication.translate("run_telemac2d",
"An error happened while trying to run Telemac2D:"))
msg += "\n" + exc.details.text
raise HSGUIException(msg)
engine.GetContainerRef().Shutdown()
except:
pass
- msg = unicode(QtGui.QApplication.translate("run_telemac2d",
+ msg = unicode(QApplication.translate("run_telemac2d",
"An error happened in the computation (Telemac2D probably crashed, "
"see logs and listing files for more details):"))
msg += "\n" + unicode(exc)
raise HSGUIException(msg)
+# Generate a python script from the eficas file
+def generate_telemac2d_python():
+ try:
+ with wait_cursor:
+ ed = hydro_study.HydroStudyEditor()
+ sobj = ed.editor.study.FindObjectID(salome.sg.getSelected(0))
+ ed.find_or_create_telemac2d_case(sobj)
+ except SALOME.SALOME_Exception, exc:
+ salome.sg.updateObjBrowser( 0 )
+ msg = unicode(QApplication.translate("generate_telemac2d_python",
+ "An error happened while trying to generate telemac2d Python script:"))
+ msg += "\n" + exc.details.text
+ raise HSGUIException(msg)
+
###
# Open Eficas for 1D / 2D Coupling to create a new coupling case
if filename.endswith(".comm"):
filename = filename[:-5] + ".xml"
if not os.path.isfile(filename):
- raise HSGUIException(QtGui.QApplication.translate("open_schema_in_yacs",
+ raise HSGUIException(QApplication.translate("open_schema_in_yacs",
"Schema file %1 does not exist").arg(filename))
yg = salome.ImportComponentGUI("YACS")
yg.loadSchema(filename)
###
# Open Eficas for boundary conditions definition
###
-def define_boundary_conditions():
- EficasForBoundaryConditionsAppli()
+#def define_boundary_conditions():
+# EficasForBoundaryConditionsAppli()
###
# Open dialog for boundary conditions edition
###
def edit_boundary_conditions_file():
- dlg = BndConditionsDialog.BoundaryConditionsDialog()
+ desktop = sgPyQt.getDesktop()
+ dlg = BndConditionsDialog.BoundaryConditionsDialog(desktop)
dlg.exec_()
###
+# Open dialog for interpolz.py script generation
+###
+def generate_interpolz_py():
+ desktop = sgPyQt.getDesktop()
+ dlg = InterpolzDlg(desktop)
+ dlg.show()
+
+###
+# Open dialog for boundary conditions edition
+###
+def eficas_for_cas_Telemac2D():
+ runEficas(code='TELEMAC')
+###
# Commands dictionary
###
dict_command = {
GUIcontext.SHOW_LOG_ID: show_log,
GUIcontext.CREATE_TELEMAC2D_CASE_ID: create_telemac2d_case,
GUIcontext.RUN_TELEMAC2D_ID: run_telemac2d,
+ GUIcontext.GEN_TELEMAC2D_PYTHON_ID: generate_telemac2d_python,
GUIcontext.EDIT_TELEMAC2D_CASE_ID: edit_telemac2d_case,
GUIcontext.CREATE_COUPLING1D2D_CASE_ID: create_coupling1d2d_case,
GUIcontext.EDIT_COUPLING1D2D_CASE_ID: edit_coupling1d2d_case,
GUIcontext.OPEN_SCHEMA_IN_YACS_ID: open_schema_in_yacs,
- GUIcontext.CREATE_PYTEL_CASE_ID: pytel_gui.create_case,
- GUIcontext.RUN_PYTEL_ID: pytel_gui.run_selected_case,
- GUIcontext.EDIT_PYTEL_CASE_ID: pytel_gui.edit_selected_case,
- GUIcontext.GENERATE_JOB: pytel_gui.generate_job_for_selected_case,
- GUIcontext.DEFINE_BOUNDARY_CONDITIONS_ID: define_boundary_conditions,
+ GUIcontext.CREATE_PYTEL_CASE_ID: create_case_pytel,
+ GUIcontext.RUN_PYTEL_ID: run_selected_case_pytel,
+ GUIcontext.EDIT_PYTEL_CASE_ID: edit_selected_case_pytel,
+ GUIcontext.GENERATE_JOB: generate_job_for_selected_case_pytel,
+ #GUIcontext.DEFINE_BOUNDARY_CONDITIONS_ID: define_boundary_conditions,
GUIcontext.EDIT_BOUNDARY_CONDITIONS_FILE_ID: edit_boundary_conditions_file,
+ GUIcontext.GENERATE_INTERPOLZ_PY_ID: generate_interpolz_py,
+ GUIcontext.DEFINE_CAS_FILE: eficas_for_cas_Telemac2D,
}