]> SALOME platform Git repositories - modules/hydrosolver.git/commitdiff
Salome HOME
Modifications for generation of study
authorYoann AUDOUIN <B61570@dsp0761867.postes.calibre.edf.fr>
Tue, 6 Jun 2017 14:09:03 +0000 (16:09 +0200)
committerYoann AUDOUIN <B61570@dsp0761867.postes.calibre.edf.fr>
Tue, 6 Jun 2017 14:09:03 +0000 (16:09 +0200)
src/HYDROGUI/HYDROSOLVERGUI.py
src/salome_hydro/study.py
src/salome_hydro/telemac2d/CMakeLists.txt

index 69a34c411f4bde158bb10c98a4a9e82ef72d3aa9..9cfb6d86663f52946f78ef8c75ef00a5ce505f10 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
@@ -146,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",
@@ -274,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))
@@ -416,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
@@ -478,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,
index 13237fd81884e72022e40252b1cdaa62c08c0c70..68b410b6b0626949d32704d3508945d26c2ed46a 100644 (file)
@@ -177,6 +177,7 @@ class HydroStudyEditor:
         params = jdc_to_dict(jdc, ["TELEMAC2D", "_F"])
 
         yacs_scheme = generate_yacs(params)
+        print yacs_scheme
 
         # TODO: Replace that by adding yacs scheme and python script ?
 
index ffcf67054c2e8afcc43f5650c2214868453658ae..f52adbc60a7a9e2dc0e3fec2668a40b4ad96c60c 100644 (file)
@@ -15,4 +15,8 @@
 #  You should have received a copy of the GNU General Public License
 #  along with SALOME HYDRO module.  If not, see <http://www.gnu.org/licenses/>.
 
+SET(PYFILES
+  __init__.py
+)
+
 ADD_SUBDIRECTORY(eficas)