Salome HOME
merge BR_PORTING_SALOME_8
authorPaul RASCLE <paul.rascle@edf.fr>
Wed, 1 Feb 2017 16:23:43 +0000 (17:23 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Wed, 1 Feb 2017 16:23:43 +0000 (17:23 +0100)
13 files changed:
CMakeLists.txt
src/HYDROGUI/BndConditionsDialog.py [changed mode: 0644->0755]
src/HYDROGUI/HYDROSOLVERGUI.py [changed mode: 0644->0755]
src/salome_hydro/CMakeLists.txt
src/salome_hydro/coupling1d2d/eficas/appli.py
src/salome_hydro/gui_utils.py
src/salome_hydro/interpolz_gui.py
src/salome_hydro/mascaret/eficas/appli.py
src/salome_hydro/pytel/CMakeLists.txt
src/salome_hydro/pytel/eficas/appli.py
src/salome_hydro/pytel/genjobwindow.py
src/salome_hydro/telemac2d/eficas/appli.py
tests/boundaryConditionsDlgTest.py

index a5c3f20e3642b202087c29dd9fc2dc20128d66d1..d2e0cbdfc1d4bfb751fa8dac1ffc0058d420ac15 100644 (file)
@@ -34,10 +34,18 @@ SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
 
 # Find KERNEL
 # ===========
+SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
+IF(EXISTS ${CONFIGURATION_ROOT_DIR})
+  LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
+  INCLUDE(SalomeMacros)
+ELSE()
+  MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
+ENDIF()
+
 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
 IF(EXISTS ${KERNEL_ROOT_DIR})
   LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
-  INCLUDE(SalomeMacros)
+  #INCLUDE(SalomeMacros)
   FIND_PACKAGE(SalomeKERNEL REQUIRED)
 ELSE(EXISTS ${KERNEL_ROOT_DIR})
   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
@@ -94,7 +102,7 @@ ENDIF(EXISTS ${GUI_ROOT_DIR})
 ##
 ## From GUI:
 ##
-FIND_PACKAGE(SalomePyQt4 REQUIRED)
+FIND_PACKAGE(SalomePyQt5 REQUIRED)
 
 ##
 ## HYDROSOLVER specifics
old mode 100644 (file)
new mode 100755 (executable)
index 7cc6f7c..4baad5b
 import os
 import sys
 
-from PyQt4 import QtCore, QtGui, uic
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+from PyQt5 import uic
 
 from MEDLoader import MEDFileMesh
 
@@ -35,7 +38,8 @@ def get_med_groups_on_edges(file_path):
     try:
         med_file_mesh = MEDFileMesh.New(file_path)
         groups = list(med_file_mesh.getGroupsOnSpecifiedLev(-1))
-    except:
+    except Exception as e:
+        print e.what()
         return []
 
     return groups
@@ -70,15 +74,15 @@ def get_int(str):
     return value
 
 """Item delegate for LIHBOR, LIUBOR, LIVBOR and LITBOR columns"""
-class ValueDelegate(QtGui.QStyledItemDelegate):
+class ValueDelegate(QStyledItemDelegate):
 
     def __init__(self, parent = None):
-        QtGui.QStyledItemDelegate.__init__(self, parent)
+        QStyledItemDelegate.__init__(self, parent)
 
     def createEditor(self, parent, option, index):
-        line_edit = QtGui.QLineEdit(parent)
+        line_edit = QLineEdit(parent)
 
-        validator = QtGui.QIntValidator(parent)
+        validator = QIntValidator(parent)
         validator.setRange(0, 6)
 
         line_edit.setValidator(validator)
@@ -86,24 +90,23 @@ class ValueDelegate(QtGui.QStyledItemDelegate):
         return line_edit
 
     def setEditorData(self, editor, index):
-        value, is_ok = index.model().data(index, QtCore.Qt.EditRole).toInt()
-
-        if is_ok:
-            editor.setText(str(value))
+        value = index.model().data(index, Qt.EditRole)
+        if value.isdigit():
+            editor.setText(value)
         else:
             editor.setText('')
 
     def setModelData(self, editor, model, index):
-        model.setData(index, editor.text(), QtCore.Qt.EditRole)
+        model.setData(index, editor.text(), Qt.EditRole)
 
     def updateEditorGeometry(self, editor, option, index):
         editor.setGeometry(option.rect)
 
 """Boundary conditions definition dialog"""
-class BoundaryConditionsDialog(QtGui.QDialog):
+class BoundaryConditionsDialog(QDialog):
 
     def __init__(self, parent = None, modal = 0):
-        QtGui.QDialog.__init__(self, parent)
+        QDialog.__init__(self, parent)
         uic.loadUi(os.path.join(hydro_solver_root, 'BndConditionsDialog.ui'), self )
 
         # Connections
@@ -174,7 +177,7 @@ class BoundaryConditionsDialog(QtGui.QDialog):
         preset_name = get_preset_name(self.presets, lihbor, liubor, livbor, litbor)
 
         combo = self.boundaryConditionsTable.cellWidget(row, 0)
-        if isinstance(combo, QtGui.QComboBox):
+        if isinstance(combo, QComboBox):
             ind = combo.findText(preset_name)
             if ind >= 0:
                 combo.setCurrentIndex(ind)
@@ -209,7 +212,7 @@ class BoundaryConditionsDialog(QtGui.QDialog):
     """Select MED file"""
     def on_med_file_browse(self):
         # Get file path
-        file_path = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open MED file"), "", self.tr("MED files (*.med)"))
+        file_path, filt = QFileDialog.getOpenFileName(self, self.tr("Open MED file"), "", self.tr("MED files (*.med)"))
         if not file_path:
             return
 
@@ -223,11 +226,11 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             # Update table
             self.set_groups(groups)
         else:
-            QtGui.QMessageBox.warning(self, self.tr("Warning"), self.tr("Can't get group names from the selected MED file."))
+            QMessageBox.warning(self, self.tr("Warning"), self.tr("Can't get group names from the selected MED file."))
 
     """Select boundary conditions file"""
     def on_bnd_file_browse(self):
-        file_path = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open boundary conditions file"))
+        file_path, filt = QFileDialog.getOpenFileName(self, self.tr("Open boundary conditions file"))
 
         if file_path:
             self.bndConditionsFileEdit.setText(file_path)
@@ -242,12 +245,12 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             read_errors = reader.errors
             if len( read_errors ) > 0:
                 msg = "\n".join(read_errors)
-                QtGui.QMessageBox.warning(self, self.tr("Warning"), msg)
+                QMessageBox.warning(self, self.tr("Warning"), msg)
 
             if len(self.input_conditions) > 0:
                 self.update_table()
             else:
-                QtGui.QMessageBox.warning(self, self.tr("Warning"), self.tr("No conditions have been read from the file."))
+                QMessageBox.warning(self, self.tr("Warning"), self.tr("No conditions have been read from the file."))
 
     """Called on preset selection in the first column of the table"""
     def on_preset_changed(self):
@@ -260,6 +263,9 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             row_nb, is_ok = combo.property(ROW_PROPERTY_NAME).toInt()
 
             if is_ok and row_nb >= 0 and row_nb < self.boundaryConditionsTable.rowCount():
+            #row_nb = combo.property(ROW_PROPERTY_NAME)
+
+            #if row_nb >= 0 and row_nb < self.boundaryConditionsTable.rowCount():
                 lihbor = values[0]
                 liubor = values[1]
                 livbor = values[2]
@@ -279,7 +285,8 @@ class BoundaryConditionsDialog(QtGui.QDialog):
 
     """Define result file path"""
     def on_result_file_browse(self):
-        file_path = QtGui.QFileDialog.getSaveFileName(self, self.tr("Select output file path"))
+        file_path, filt = QFileDialog.getSaveFileName(self, self.tr("Select output file path"))
+        #print file_path
         if file_path:
             self.resultBndConditionsFileEdit.setText(file_path)
 
@@ -292,7 +299,7 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             self.boundaryConditionsTable.insertRow(row_nb)
 
             # 'Preset' column
-            combo = QtGui.QComboBox(self)
+            combo = QComboBox(self)
             combo.addItem('')
             if len(self.presets) > 0:
                 combo.addItems(self.presets.keys())
@@ -304,23 +311,23 @@ class BoundaryConditionsDialog(QtGui.QDialog):
             self.boundaryConditionsTable.setCellWidget(row_nb, 0, combo)
 
             # 'LIHBOR' column
-            self.boundaryConditionsTable.setItem(row_nb, 1, QtGui.QTableWidgetItem(''))
+            self.boundaryConditionsTable.setItem(row_nb, 1, QTableWidgetItem(''))
 
             # 'LIUBOR' column
-            self.boundaryConditionsTable.setItem(row_nb, 2, QtGui.QTableWidgetItem(''))
+            self.boundaryConditionsTable.setItem(row_nb, 2, QTableWidgetItem(''))
 
             # 'LIVBOR' column
-            self.boundaryConditionsTable.setItem(row_nb, 3, QtGui.QTableWidgetItem(''))
+            self.boundaryConditionsTable.setItem(row_nb, 3, QTableWidgetItem(''))
 
             # 'LITBOR' column
-            self.boundaryConditionsTable.setItem(row_nb, 4, QtGui.QTableWidgetItem(''))
+            self.boundaryConditionsTable.setItem(row_nb, 4, QTableWidgetItem(''))
 
             # 'Group' column
-            item = QtGui.QTableWidgetItem(group)
+            item = QTableWidgetItem(group)
             font = item.font()
             font.setBold(True)
             item.setFont(font)
-            item.setFlags(QtCore.Qt.ItemIsEnabled)
+            item.setFlags(Qt.ItemIsEnabled)
             self.boundaryConditionsTable.setItem(row_nb, 5, item)
 
         self.update_table()
@@ -348,7 +355,7 @@ class BoundaryConditionsDialog(QtGui.QDialog):
                 is_updated = True
 
         if not is_updated and nb_rows > 0 and len(self.input_conditions) > 0:
-            QtGui.QMessageBox.information(self, self.tr("Information"), self.tr("No one group name from the MED file is presented in the input list of conditions."))
+            QMessageBox.information(self, self.tr("Information"), self.tr("No one group name from the MED file is presented in the input list of conditions."))
 
     """Get output file path"""
     def get_output_path(self):
@@ -364,9 +371,9 @@ class BoundaryConditionsDialog(QtGui.QDialog):
         is_ok = False
 
         if self.boundaryConditionsTable.rowCount() < 1:
-            QtGui.QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Boundary conditions list is empty."))
-        elif self.get_output_path().isEmpty():
-            QtGui.QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Output file path is empty."))
+            QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Boundary conditions list is empty."))
+        elif len(self.get_output_path())==0:
+            QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Output file path is empty."))
         else:
             has_empty_cells = False
             for row_nb in xrange(0, self.boundaryConditionsTable.rowCount()):
@@ -380,7 +387,7 @@ class BoundaryConditionsDialog(QtGui.QDialog):
                     break
 
             if has_empty_cells:
-                QtGui.QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Table has empty cell(s)."))
+                QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Table has empty cell(s)."))
             else:
                 is_ok = True
 
@@ -419,5 +426,5 @@ class BoundaryConditionsDialog(QtGui.QDialog):
         to perform the data export to the file.
         Click on "Close" button does not lead to saving the data and just closes the dialog.
         """
-        QtGui.QMessageBox.about(self, self.tr("About boundary conditions dialog"), msg);
-        pass
\ No newline at end of file
+        QMessageBox.about(self, self.tr("About boundary conditions dialog"), msg);
+        pass
old mode 100644 (file)
new mode 100755 (executable)
index 133e55c..bb2f422
@@ -20,7 +20,9 @@ import os
 import traceback
 import logging
 
-from PyQt4 import QtCore, QtGui
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
 
 import salome
 import SALOME
@@ -36,11 +38,11 @@ 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.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
 
 import BndConditionsDialog
 
@@ -62,9 +64,9 @@ class GUIcontext:
     CREATE_COUPLING1D2D_CASE_ID = 948
     EDIT_COUPLING1D2D_CASE_ID = 949
     OPEN_SCHEMA_IN_YACS_ID = 950
-    CREATE_PYTEL_CASE_ID = 951
-    RUN_PYTEL_ID = 952
-    EDIT_PYTEL_CASE_ID = 953
+    #CREATE_PYTEL_CASE_ID = 951
+    #RUN_PYTEL_ID = 952
+    #EDIT_PYTEL_CASE_ID = 953
     GENERATE_JOB = 954
     DEFINE_BOUNDARY_CONDITIONS_ID = 955
     EDIT_BOUNDARY_CONDITIONS_FILE_ID = 956
@@ -116,12 +118,12 @@ class GUIcontext:
         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.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 )
+        #sgPyQt.createMenu( a, mid )
+        #sgPyQt.createTool( a, tid )
 
         a = sgPyQt.createSeparator()
         sgPyQt.createMenu( a, mid )
@@ -152,10 +154,10 @@ class GUIcontext:
         sgPyQt.createAction( GUIcontext.OPEN_SCHEMA_IN_YACS_ID, "Open schema in YACS", "Open schema in YACS",
                              "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" )
-        sgPyQt.createAction( GUIcontext.EDIT_PYTEL_CASE_ID, "Edit case", "Edit case",
-                             "Edit the selected Pytel case" )
+        #sgPyQt.createAction( GUIcontext.RUN_PYTEL_ID, "Compute case", "Compute case",
+        #                     "Run Pytel launcher to compute the case" )
+        #sgPyQt.createAction( GUIcontext.EDIT_PYTEL_CASE_ID, "Edit case", "Edit 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")
 
@@ -271,10 +273,10 @@ def createPopupMenu(popup, context):
             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))
+        #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))
 
 # called when GUI action is activated
 # action ID is passed as parameter
@@ -282,17 +284,17 @@ def OnGUIEvent( commandID ):
     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())
@@ -308,13 +310,13 @@ def OnGUIEvent( commandID ):
 """
 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.connect(self.closeButton, SIGNAL("clicked()"), self.close)
     
     def set_log(self, log):
         self.contentTextEdit.setPlainText(log)
@@ -350,7 +352,7 @@ def run_mascaret():
             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)
@@ -393,7 +395,7 @@ def run_telemac2d():
     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)
@@ -403,7 +405,7 @@ def run_telemac2d():
             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)
@@ -428,7 +430,7 @@ def open_schema_in_yacs():
     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)
@@ -469,10 +471,10 @@ dict_command = {
     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.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.EDIT_BOUNDARY_CONDITIONS_FILE_ID: edit_boundary_conditions_file,
     GUIcontext.GENERATE_INTERPOLZ_PY_ID: generate_interpolz_py,
index 530024021a1566d4b4ee209239e167b49bc20736..b9c66740d20a50c08faeeaa2ffa55b048d77f89e 100644 (file)
@@ -17,7 +17,7 @@
 
 ADD_SUBDIRECTORY(mascaret)
 ADD_SUBDIRECTORY(telemac2d)
-ADD_SUBDIRECTORY(pytel)
+#ADD_SUBDIRECTORY(pytel)
 ADD_SUBDIRECTORY(coupling1d2d)
 ADD_SUBDIRECTORY(boundary_conditions)
 
index 30843c479da7b16adcf082887559072788968655..9d379dd4dffff36edd88aebdbf6c4637b4fc036b 100644 (file)
@@ -21,7 +21,8 @@ import os
 import sys
 import re
 
-from PyQt4.QtGui import QMessageBox
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
 
 import salome
 import SalomePyQt
index 0463e04073890398eb3d74dfdb08cb9c806119c2..cc080aab08fb4e1250aded43617fefdf9d8f17b9 100644 (file)
@@ -16,7 +16,9 @@
 #  along with SALOME HYDRO module.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-from PyQt4 import QtCore, QtGui
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
 
 import salome
 from salome.kernel.studyedit import getStudyEditor
@@ -39,12 +41,12 @@ class OverrideCursorCM:
     self.cursor = cursor
   
   def __enter__(self):
-    QtGui.QApplication.setOverrideCursor(self.cursor)
+    QApplication.setOverrideCursor(self.cursor)
   
   def __exit__(self, exc_type, exc_value, traceback):
-    QtGui.QApplication.restoreOverrideCursor()
+    QApplication.restoreOverrideCursor()
 
-wait_cursor = OverrideCursorCM(QtGui.QCursor(QtCore.Qt.WaitCursor))
+wait_cursor = OverrideCursorCM(QCursor(Qt.WaitCursor))
 
 
 def get_and_check_selected_file_path():
@@ -56,6 +58,6 @@ def get_and_check_selected_file_path():
   sobj = ed.study.FindObjectID(salome.sg.getSelected(0))
   filepath = sobj.GetComment()
   if not os.path.isfile(filepath):
-    raise HSGUIException(QtGui.QApplication.translate("get_and_check_selected_file_path",
+    raise HSGUIException(QApplication.translate("get_and_check_selected_file_path",
                                                       "File %1 does not exist").arg(filepath))
   return filepath
index 2f5c5bc4e36a81c8cb0e79f0b8e4877bb1ee0991..b521c0423203db7a855d3908b420a6e9ff5fe283 100644 (file)
@@ -10,7 +10,10 @@ salome.salome_init()
 import MEDLoader
 import HYDROPy
 
-from PyQt4 import QtCore, QtGui, uic
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+from PyQt5 import uic
 
 import SalomePyQt
 import libSALOME_Swig
@@ -19,18 +22,22 @@ salome_gui = libSALOME_Swig.SALOMEGUI_Swig()
 from generate_interpolz import generate
 
 def get_med_groups( file_path ):
-    #print "get_med_groups", file_path
+    print "get_med_groups", file_path
     try:
-        meshes = MEDLoader.MEDLoader_GetMeshNames(file_path)
+        meshes = MEDLoader.GetMeshNames(file_path)
     except:
+        print 'No meshes found'
         return []
     if len(meshes)==0:
+        print 'No mesh found'
         return []
     mesh1 = meshes[0]
+    print 'Found mesh:', mesh1
     try:
         groups = list(MEDLoader.MEDLoader_GetMeshGroupsNames(file_path, mesh1))
-
+        print 'Found groups:', groups
     except:
+        print 'No groups found'
         return []
     return groups
 
@@ -60,31 +67,30 @@ def get_selected_calc_case():
     doc = HYDROPy.HYDROData_Document.Document( aStudyId )
     for i in ind:
         if i.column()==0:
-            name = i.data().toString()
+            name = str(i.data())
             case = doc.FindObjectByName( name )
             if isinstance(case, HYDROPy.HYDROData_CalculationCase):
                 return name
     return None
 
-class InterpolzDlg( QtGui.QDialog ):
+class InterpolzDlg( QDialog ):
     def __init__(self, parent = None):
-        QtGui.QDialog.__init__( self, parent )
+        QDialog.__init__( self, parent )
         p = hydro_solver_root
         uic.loadUi( p+'/interpolz.ui', self )
         self.setWindowTitle( 'Generate interpolz script' )
-        self.connect( SalomePyQt.SalomePyQt.getObjectBrowser(), QtCore.SIGNAL("selectionChanged()"), self.onSelectionChanged )
-        self.connect( self.btnOutputPath, QtCore.SIGNAL( "clicked()" ), self.onOutputFile )
-        self.connect( self.btnMEDFile, QtCore.SIGNAL( "clicked()" ), self.onMEDFile )
-        self.connect( self.CalcCase, QtCore.SIGNAL( "textChanged( const QString& )" ), self.onCalcCaseChanged )
-        self.connect( self.MEDFile, QtCore.SIGNAL( "textChanged( const QString& )" ), self.onMEDChanged )
+        SalomePyQt.SalomePyQt.getObjectBrowser().selectionChanged.connect(self.onSelectionChanged)
+        self.btnOutputPath.clicked.connect(self.onOutputFile)
+        self.btnMEDFile.clicked.connect(self.onMEDFile)
+        self.CalcCase.textChanged.connect(self.onCalcCaseChanged)
+        self.MEDFile.textChanged.connect(self.onMEDChanged)
         self.UndefZ.setRange( -100000, 100000 )
         self.UndefZ.setValue( -9999 )
         self.InterpMethod.addItem( "Interpolation at the nearest point" )
-        self.InterpMethod.addItem( "Linear interpolation on a cloud triangulation" )
-        self.connect( self.ApplyClose, QtCore.SIGNAL( "clicked()" ), self.onApplyClose )
-        self.connect( self.Apply, QtCore.SIGNAL( "clicked()" ), self.onApply )
-        self.connect( self.Close, QtCore.SIGNAL( "clicked()" ), self.onClose )
-        self.connect( self.Help, QtCore.SIGNAL( "clicked()" ), self.onHelp )
+        self.ApplyClose.clicked.connect(self.onApplyClose)
+        self.Apply.clicked.connect(self.onApply)
+        self.Close.clicked.connect(self.onClose)
+        self.Help.clicked.connect(self.onHelp)
 
     def onSelectionChanged( self ):
         calc_case_name = get_selected_calc_case()
@@ -94,16 +100,16 @@ class InterpolzDlg( QtGui.QDialog ):
     def onOutputFile( self ):
       caption = "Python file"
       mask = "*.py"
-      f = QtGui.QFileDialog.getSaveFileName( self, caption, ".", mask )
-      if f!=None and f!="":
-        self.OutputPath.setText( f )
+      fname, filt = QFileDialog.getSaveFileName( self, caption, ".", mask )
+      if fname!=None and fname!="":
+        self.OutputPath.setText( fname )
 
     def onMEDFile( self ):
       caption = "MED file"
       mask = "*.med"
-      f = QtGui.QFileDialog.getOpenFileName( self, caption, ".", mask )
-      if f!=None and f!="":
-        self.MEDFile.setText( f )
+      fname, filt = QFileDialog.getOpenFileName( self, caption, ".", mask )
+      if fname!=None and fname!="":
+        self.MEDFile.setText( fname )
 
     def onCalcCaseChanged( self ):
       self.regions = get_hydro_regions( str(self.CalcCase.text()) )
@@ -111,16 +117,16 @@ class InterpolzDlg( QtGui.QDialog ):
 
     def onMEDChanged( self ):
       self.med_groups = get_med_groups( str(self.MEDFile.text()) )
-      #print self.med_groups
+      print self.med_groups
       n = len( self.med_groups )
       self.Groups.setRowCount( n )
       for i in range( 0, n ):
         if self.Groups.item( i, 0 ) is None:
-          self.Groups.setItem( i, 0, QtGui.QTableWidgetItem() )
-          self.Groups.setItem( i, 1, QtGui.QTableWidgetItem() )
+          self.Groups.setItem( i, 0, QTableWidgetItem() )
+          self.Groups.setItem( i, 1, QTableWidgetItem() )
         self.Groups.item( i, 0 ).setText( self.med_groups[i] )
 
-        cb = QtGui.QComboBox( self.Groups )
+        cb = QComboBox( self.Groups )
         cb.addItem( 'None' )
         for r in self.regions:
           cb.addItem( r )
@@ -164,7 +170,7 @@ class InterpolzDlg( QtGui.QDialog ):
             msg = "InterpolZ script is successfully generated"
             result = True
 
-        QtGui.QMessageBox.information( self, "", msg )
+        QMessageBox.information( self, "", msg )
         return result
 
     def onClose( self ):
@@ -197,7 +203,7 @@ class InterpolzDlg( QtGui.QDialog ):
 
         When the data is input, the user clicks on "Apply" or "Apply and Close" button to perform the script generation.
         """
-        QtGui.QMessageBox.about(self, self.tr("About boundary conditions dialog"), msg);
+        QMessageBox.about(self, self.tr("About boundary conditions dialog"), msg);
 
 
 if __name__=='__main__':
index 126a184b214dd21ea24bb2e53b959fab02d22efa..b5fe0841829ac324d8e25e32a39e4a69cca50866 100644 (file)
@@ -21,7 +21,9 @@ import os
 import sys
 import re
 
-from PyQt4.QtGui import QMessageBox
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+
 
 import salome
 import SalomePyQt
index ca9b36c054449d1d5aa05b0341c76689d06bc68c..0620de64f5918632a79be0831fbd036fae6c0ea7 100644 (file)
@@ -17,7 +17,7 @@
 
 ADD_SUBDIRECTORY(eficas)
 
-INCLUDE(UsePyQt4)
+INCLUDE(UsePyQt5)
 
 # --- Python files ---
 
index 6963549c5a049c49f4fa274dba1907fa5528f613..35f669592ac3a49b5d7c4f72701a2556661221b9 100644 (file)
@@ -18,7 +18,9 @@
 import os
 import sys
 
-from PyQt4.QtGui import QMessageBox
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+
 
 import salome
 import SalomePyQt
index 5ea6df3d118c2fec899513029d51d919d8d3e419..df7df10fe74952c47c824f241580a0605a9193d4 100644 (file)
@@ -16,7 +16,9 @@
 #  along with SALOME HYDRO module.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-from PyQt4 import QtGui, QtCore
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
 
 import salome
 from salome.hydro.pytel.genjob import generate_job
@@ -28,10 +30,10 @@ class GenJobDialog(QtGui.QDialog, Ui_GenJobDialog):
   def __init__(self, parent, pytel_params):
     QtGui.QDialog.__init__(self, parent)
     self.setupUi(self)
-    self.connect(self.dialogButtonBox, QtCore.SIGNAL("accepted()"), self.validate)
-    self.connect(self.dialogButtonBox, QtCore.SIGNAL("rejected()"), self.close)
-    self.connect(self.chooseInputDataDirectoryButton, QtCore.SIGNAL("clicked()"), self.choose_input_dir)
-    self.connect(self.chooseResultDirectoryButton, QtCore.SIGNAL("clicked()"), self.choose_result_dir)
+    self.connect(self.dialogButtonBox, SIGNAL("accepted()"), self.validate)
+    self.connect(self.dialogButtonBox, SIGNAL("rejected()"), self.close)
+    self.connect(self.chooseInputDataDirectoryButton, SIGNAL("clicked()"), self.choose_input_dir)
+    self.connect(self.chooseResultDirectoryButton, SIGNAL("clicked()"), self.choose_result_dir)
     self.telemacRootDirLE.setText("/home/projets-bgq/systel/V6P2")
     self.telemacEnvFileLE.setText("/home/projets-bgq/systel/V6P2/config/pysource.zumbrota.xlf14.sh")
     casedir = os.path.dirname(pytel_params["FICHIER_CAS"])
@@ -47,16 +49,16 @@ class GenJobDialog(QtGui.QDialog, Ui_GenJobDialog):
     self.pytel_params = pytel_params
 
   def choose_input_dir(self):
-    directory = QtGui.QFileDialog.getExistingDirectory(self,
+    directory = QFileDialog.getExistingDirectory(self,
             directory = self.inputDataDirectoryLE.text(),
-            options = QtGui.QFileDialog.ShowDirsOnly)
+            options = QFileDialog.ShowDirsOnly)
     if not directory.isNull():
       self.inputDataDirectoryLE.setText(directory)
 
   def choose_result_dir(self):
-    directory = QtGui.QFileDialog.getExistingDirectory(self,
+    directory = QFileDialog.getExistingDirectory(self,
             directory = self.resultDirectoryLE.text(),
-            options = QtGui.QFileDialog.ShowDirsOnly)
+            options = QFileDialog.ShowDirsOnly)
     if not directory.isNull():
       self.resultDirectoryLE.setText(directory)
 
index 0684bf7834c605967d68bbdb429dc6dbe1b9f1cf..0df10c2360fdf73c0e5dac838e7098dc633f31ac 100644 (file)
@@ -21,7 +21,9 @@ import os
 import sys
 import re
 
-from PyQt4.QtGui import QMessageBox
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+
 
 import salome
 import SalomePyQt
index 150bc6dd4107b11c181fd8202bc0834a87f1b923..a74894d3e1d3ef5d640312db38df31ae2ed4930e 100644 (file)
@@ -1,7 +1,8 @@
 import os
 import sys
 
-from PyQt4 import QtGui
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
 
 cur_dir = os.path.dirname(os.path.realpath(__file__))
 data_dir = os.path.join(cur_dir, "data")
@@ -11,7 +12,7 @@ data_dir = os.path.join(cur_dir, "data")
 from BndConditionsDialog import BoundaryConditionsDialog
 
 # Show the dialog
-app = QtGui.QApplication(sys.argv)
+app = QApplication(sys.argv)
 window = BoundaryConditionsDialog()
 
 window.show()