Salome HOME
Error
[modules/hydrosolver.git] / src / HYDROGUI / HYDROSOLVERGUI.py
index d0d6cb80456616c760dc52cb8ea0968262c91391..7f95c1e3f897aad88e78db01b118d9b9b84b6c88 100755 (executable)
@@ -71,6 +71,7 @@ class GUIcontext:
     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
@@ -78,13 +79,6 @@ class GUIcontext:
         # 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",
@@ -120,10 +114,15 @@ class GUIcontext:
         sgPyQt.createMenu( a, mid )
         sgPyQt.createTool( a, tid )
 
-        a = sgPyQt.createSeparator()
+        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" )
@@ -148,6 +147,9 @@ class GUIcontext:
         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",
@@ -276,6 +278,7 @@ def createPopupMenu(popup, context):
         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))
@@ -418,6 +421,20 @@ def run_telemac2d():
                       "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
@@ -468,7 +485,7 @@ def generate_interpolz_py():
 ###
 # Open dialog for boundary conditions edition
 ###
-def eficas_for_cas_Telemac2D()
+def eficas_for_cas_Telemac2D():
    runEficas(code='TELEMAC')
 ###
 # Commands dictionary
@@ -480,6 +497,7 @@ 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,
@@ -491,5 +509,5 @@ dict_command = {
     #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.GUIcontext.DEFINE_CAS_FILE: eficas_for_cas_Telemac2D,
+    GUIcontext.DEFINE_CAS_FILE: eficas_for_cas_Telemac2D,
     }