Salome HOME
[fix #22458 and #22201] wrong function to display dialog fro changecoordiantes
[modules/hydrosolver.git] / src / HYDROGUI / HYDROSOLVERGUI.py
index 6521a77f5a83867720d4a521de3bf1f2534ed961..8ab7a44d605584247b3f3da72664ee89e40c60ff 100755 (executable)
@@ -36,6 +36,7 @@ import HYDROSOLVER_ORB
 
 from salome.hydro.interpolz_gui import InterpolzDlg
 from salome.hydro.assignStrickler_gui import assignStricklerDlg
+from salome.hydro.changeCoordsDialog import changeCoordsDialog
 from salome.hydro.gui_utils import HSGUIException, wait_cursor, \
                                    get_and_check_selected_file_path
 import salome.hydro.study as hydro_study
@@ -49,9 +50,9 @@ from salome.hydro.run_study.gui import create_case_study, \
 from eficasSalome import runEficas
 
 from BndConditionsDialog import BoundaryConditionsDialog
-from LiquidBoundariesDialog import LiquidBoundariesDialog
-from BreachesDialog import BreachesDialog
-from InitialConditionsDialog import InitialConditionsDialog
+from salome.hydro.initialFieldDialog import initialFieldDialog
+from salome.hydro.checkBoundariesDialog import checkBoundariesDialog
+
 
 ################################################
 # GUI context class
@@ -59,9 +60,9 @@ from InitialConditionsDialog import InitialConditionsDialog
 ################################################
 
 class GUIcontext:
-  
-    # --- menus/toolbars/actions IDs
-    
+
+    # --- menus/toolbars/actions IDss
+
     HYDRO_MENU_ID = 90
     CREATE_STUDY_ID = 951
     EDIT_STUDY_ID = 952
@@ -76,15 +77,16 @@ class GUIcontext:
 
     # TODO Add create and edit ?
     EDIT_BOUNDARY_CONDITIONS_FILE_ID = 959
-    EDIT_LIQUID_BOUNDARY_FILE_ID = 960
-    EDIT_BREACHES_FILE_ID = 961
-    EDIT_INITIAL_CONDITIONS_FILE_ID = 962
+    EDIT_INITIAL_FIELD_FILE_ID = 962
 
     CREATE_PARAM_STUDY_ID = 963
     EDIT_PARAM_STUDY_ID = 964
     GEN_PARAM_STUDY_PYTHON_ID = 965
     GEN_PARAM_STUDY_YACS_ID = 966
 
+    CHANGECOORDS_PY_ID = 967
+    CHECK_BOUNDARY_CONDITIONS_ID = 968
+
     def __init__(self):
         # create top-level menu
         mid = sgPyQt.createMenu("Hydro", -1, GUIcontext.HYDRO_MENU_ID,
@@ -92,6 +94,15 @@ class GUIcontext:
         # create toolbar
         tid = sgPyQt.createTool("Hydro")
         # create actions and fill menu and toolbar with actions
+        act = sgPyQt.createAction(\
+                GUIcontext.CHANGECOORDS_PY_ID,
+                "Change coordinates",
+                "Change coordinates",
+                "Change mesh coordinates",
+                "changes_coords.png")
+        sgPyQt.createMenu(act, mid)
+        sgPyQt.createTool(act, tid)
+
         act = sgPyQt.createAction(\
                 GUIcontext.GENERATE_INTERPOLZ_PY_ID,
                 "Generate interpolz.py",
@@ -106,10 +117,10 @@ class GUIcontext:
                 "Generate assignStrickler.py",
                 "Generate assignStrickler.py",
                 "Generate assignation script for bottom friction coefficients",
-                 "generate_interpolz_py.png" )
+                 "assign_Strickler_py.png" )
         sgPyQt.createMenu( act, mid )
         sgPyQt.createTool( act, tid )
-        
+
         act = sgPyQt.createSeparator()
 
         act = sgPyQt.createAction(\
@@ -122,29 +133,20 @@ class GUIcontext:
         sgPyQt.createTool(act, tid)
 
         act = sgPyQt.createAction(\
-                GUIcontext.EDIT_LIQUID_BOUNDARY_FILE_ID,
-                "Edit liquid boundary conditions file",
-                "Edit liquid boundary conditions file",
-                "Create/edit the liquid boundary conditions file for Telemac",
-                "edit_liquid_boundary_conditions_file.png")
+                GUIcontext.CHECK_BOUNDARY_CONDITIONS_ID,
+                "check boundary conditions",
+                "check boundary conditions",
+                "display a graph with boundary conditions on the mesh",
+                "check_boundary_conditions.png")
         sgPyQt.createMenu(act, mid)
         sgPyQt.createTool(act, tid)
 
         act = sgPyQt.createAction(\
-                GUIcontext.EDIT_BREACHES_FILE_ID,
-                "Edit breaches file",
-                "Edit breaches file",
-                "Create/edit the breaches file for Telemac",
-                "edit_breaches_file.png")
-        sgPyQt.createMenu(act, mid)
-        sgPyQt.createTool(act, tid)
-        
-        act = sgPyQt.createAction(\
-                GUIcontext.EDIT_INITIAL_CONDITIONS_FILE_ID,
-                "Edit initial conditions file",
-                "Edit initial conditions file",
-                "Create/edit the initial conditions file for Telemac",
-                "edit_boundary_conditions_file.png" )
+                GUIcontext.EDIT_INITIAL_FIELD_FILE_ID,
+                "Edit initial field file",
+                "Edit initial field file",
+                "Create/edit the initial field file for Telemac",
+                "edit_initial_field_file.png" )
         sgPyQt.createMenu( act, mid )
         sgPyQt.createTool( act, tid )
 
@@ -320,17 +322,19 @@ def createPopupMenu(popup, context):
     if salome.sg.SelectedCount() == 1:
         # one object is selected
         sobj = ed.study.FindObjectID(salome.sg.getSelected(0))
-        selectedType = ed.getTypeId(sobj)
-        if selectedType == hydro_study.TELMA_TYPE_ID:
-            popup.addAction(sgPyQt.action(GUIcontext.EDIT_TELMA_CAS_ID))
-        elif selectedType == hydro_study.PARAM_STUDY_TYPE_ID:
-            popup.addAction(sgPyQt.action(GUIcontext.EDIT_PARAM_STUDY_ID))
-            popup.addAction(sgPyQt.action(GUIcontext.GEN_PARAM_STUDY_PYTHON_ID))
-            popup.addAction(sgPyQt.action(GUIcontext.GEN_PARAM_STUDY_YACS_ID))
-        elif selectedType == hydro_study.STUDY_TYPE_ID:
-            popup.addAction(sgPyQt.action(GUIcontext.EDIT_STUDY_ID))
-            popup.addAction(sgPyQt.action(GUIcontext.RUN_STUDY_ID))
-            popup.addAction(sgPyQt.action(GUIcontext.GEN_STUDY_BATCH_ID))
+        print("sobj: %s"%sobj) # strange bug with sobj is None when right clic on 3Dview in HYDROSOLVER used after HYDRO (generate AssignStrickler)
+        if sobj:
+            selectedType = ed.getTypeId(sobj)
+            if selectedType == hydro_study.TELMA_TYPE_ID:
+                popup.addAction(sgPyQt.action(GUIcontext.EDIT_TELMA_CAS_ID))
+            elif selectedType == hydro_study.PARAM_STUDY_TYPE_ID:
+                popup.addAction(sgPyQt.action(GUIcontext.EDIT_PARAM_STUDY_ID))
+                popup.addAction(sgPyQt.action(GUIcontext.GEN_PARAM_STUDY_PYTHON_ID))
+                popup.addAction(sgPyQt.action(GUIcontext.GEN_PARAM_STUDY_YACS_ID))
+            elif selectedType == hydro_study.STUDY_TYPE_ID:
+                popup.addAction(sgPyQt.action(GUIcontext.EDIT_STUDY_ID))
+                popup.addAction(sgPyQt.action(GUIcontext.RUN_STUDY_ID))
+                popup.addAction(sgPyQt.action(GUIcontext.GEN_STUDY_BATCH_ID))
 
 # called when GUI action is activated
 # action ID is passed as parameter
@@ -422,56 +426,28 @@ def edit_boundary_conditions_file():
     dlg.exec_()
 
 ###
-# Open dialog for liquid boundaries edition
-###
-def edit_liquid_boundaries_file():
-    desktop = sgPyQt.getDesktop()
-    dlg = LiquidBoundariesDialog(desktop)
-    dlg.exec_()
-
-###
-# Open dialog for breaches edition
+# Open dialog for initial conditions edition
 ###
-def edit_breaches_file():
+def edit_initial_field_file():
     desktop = sgPyQt.getDesktop()
-    dlg = BreachesDialog(desktop)
+    dlg = initialFieldDialog(desktop)
     dlg.exec_()
 
 ###
 # Open dialog for initial conditions edition
 ###
-def edit_initial_conditions_file():
+def check_boundaries():
     desktop = sgPyQt.getDesktop()
-    dlg = InitialConditionsDialog(desktop)
+    dlg = checkBoundariesDialog(desktop)
     dlg.exec_()
 
-###
-# Open dialog for liquid boundary conditions edition
-###
-def edit_liquid_boundary_file():
-    # TODO: Implement gui
-    QMessageBox.warning(sgPyQt.getDesktop(),
-                        "",
-                        "Liquid boundary file handling not implemented yet")
-    return
-
-###
-# Open dialog for breaches file edition
-###
-def edit_breaches_file():
-    # TODO: Implement gui
-    QMessageBox.warning(sgPyQt.getDesktop(),
-                        "",
-                        "Breaches file handling not implemented yet")
-    return
-
 ###
 # Open dialog for interpolz.py script generation
 ###
 def generate_interpolz_py():
     desktop = sgPyQt.getDesktop()
     dlg = InterpolzDlg(desktop)
-    dlg.show()
+    dlg.exec_()
 
 ###
 # Open dialog for assignStrickler.py script generation
@@ -479,7 +455,12 @@ def generate_interpolz_py():
 def generate_assignStrickler_py():
     desktop = sgPyQt.getDesktop()
     dlg = assignStricklerDlg(desktop)
-    dlg.show()
+    dlg.exec_()
+
+def changeCoords_py():
+    desktop = sgPyQt.getDesktop()
+    dlg = changeCoordsDialog(desktop)
+    dlg.exec_()
 
 ###
 # Open dialog for boundary conditions edition
@@ -516,10 +497,10 @@ dict_command = {
     GUIcontext.EDIT_TELMA_CAS_ID: edit_telma_cas,
     GUIcontext.GENERATE_INTERPOLZ_PY_ID: generate_interpolz_py,
     GUIcontext.GENERATE_ASSIGNSTRICKLER_PY_ID: generate_assignStrickler_py,
-    GUIcontext.EDIT_LIQUID_BOUNDARY_FILE_ID: edit_liquid_boundary_file,
+    GUIcontext.CHANGECOORDS_PY_ID: changeCoords_py,
     GUIcontext.EDIT_BOUNDARY_CONDITIONS_FILE_ID: edit_boundary_conditions_file,
-    GUIcontext.EDIT_BREACHES_FILE_ID: edit_breaches_file,
-    GUIcontext.EDIT_INITIAL_CONDITIONS_FILE_ID: edit_initial_conditions_file,
+    GUIcontext.CHECK_BOUNDARY_CONDITIONS_ID: check_boundaries,
+    GUIcontext.EDIT_INITIAL_FIELD_FILE_ID: edit_initial_field_file,
     GUIcontext.CREATE_PARAM_STUDY_ID: create_param_study,
     GUIcontext.EDIT_PARAM_STUDY_ID: edit_param_study,
     GUIcontext.GEN_PARAM_STUDY_PYTHON_ID: generate_param_study_python,