Salome HOME
update CoreFlows GUI from pyqt4 to pyqt5
authorBernard Sécherà <bernard.secher@cea.fr>
Tue, 19 Jan 2021 13:13:27 +0000 (14:13 +0100)
committerBernard Sécherà <bernard.secher@cea.fr>
Tue, 19 Jan 2021 13:13:27 +0000 (14:13 +0100)
CMakeLists.txt
CoreFlows/CMakeLists.txt
CoreFlows/examples/Python/CMakeLists.txt
CoreFlows/gui/CMakeLists.txt
CoreFlows/gui/src/CFDesktop.py
CoreFlows/gui/src/CoreFlows_Standalone.py
CoreFlows/gui/src/SalomePyQt_MockUp.py.in
CoreFlows/gui/src/ui/MainCFWidget.py

index 5c85481e576df44be82265a3af10347919ef8580..ff02f666134f3f6ef583939713d0be7359c867e6 100644 (file)
@@ -497,7 +497,6 @@ IF   ( NOT HDF5_ROOT_DIR )
   ENDIF( ENV{HDF5_ROOT_DIR} )
 ENDIF( NOT HDF5_ROOT_DIR )
 
-
 #Paraview library paths
 set (PV_LIB_DIR    /usr/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/dist-packages/paraview/:/usr/lib64/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/vtk/:${MATPLOTLIB_ROOT_DIR}/lib/:${PARAVIEW_LIBRARIES_DIR})
 set (PV_PYTHON_DIR /usr/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/dist-packages/paraview/:/usr/lib64/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/vtk/:/usr/lib64/paraview/site-packages/:/usr/lib64/paraview/site-packages/paraview/:/usr/lib64/paraview/site-packages/vtk/:/usr/lib64/paraview/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/:/usr/lib64/paraview/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/paraview/:/usr/lib64/paraview/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/vtkmodules:/usr/lib/paraview/site-packages/paraview:/usr/lib/paraview/site-packages/paraview/vtk:${PARAVIEW_ROOT_DIR}/lib/:${PARAVIEW_ROOT_DIR}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/:${PARAVIEW_ROOT_DIR}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/vtkmodules/:${MATPLOTLIB_ROOT_DIR}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages:${PYQT5_ROOT_DIR}:${PYQT5_ROOT_DIR}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages)
index cfe07a7c5f2b0b18b3588fa49b9b46f834cc4ee9..7d8aed341e2a0c234aeed06de5749074c1afce96 100755 (executable)
@@ -73,10 +73,9 @@ endif ()
 
 # Graphic interface-----------------------------------------------------------------------------------------#
                                                                                                            #
-if (COREFLOWS_WITH_GUI)                                                                                                                                                                                                                                                    #
- set (CoreFlows_GUI_DIR ${CoreFlows_SOURCE_DIR}/gui)                                                        #
- add_subdirectory(${CoreFlows_GUI_DIR})                        
-
+if (COREFLOWS_WITH_GUI)                                                                                                                    #
+  set (CoreFlows_GUI_DIR ${CoreFlows_SOURCE_DIR}/gui)                                                        #
+  add_subdirectory(${CoreFlows_GUI_DIR})
 endif ()                                                                                                    #
                                                                                                            #
 # ------------- --------------------------------------------------------------------------------------------#
index 3411857e1dcd36b92c399e219a867f2a6005df62..9d085be9b60c808cbd7550ed1b99c014a586be24 100755 (executable)
@@ -1,14 +1,19 @@
 # Graphic interface---------------------------------------------------------------------------------------------#
                                                                                                                #
-if (COREFLOWS_WITH_GUI)                                                                                                                                 
+if (COREFLOWS_WITH_GUI)
+
+       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 NO_POLICY_SCOPE)
+       ELSE()
+         MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
+       ENDIF()
                                                                                                                #
        # Find KERNEL 
        # ==============
        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")
-         LIST(APPEND CMAKE_PREFIX_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
-         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!")
@@ -18,8 +23,6 @@ if (COREFLOWS_WITH_GUI)
        # ==============
        SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
        IF(EXISTS ${GUI_ROOT_DIR})
-         LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
-         LIST(APPEND CMAKE_PREFIX_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
          FIND_PACKAGE(SalomeGUI)
        ELSE(EXISTS ${GUI_ROOT_DIR})
          MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR!")
@@ -33,12 +36,8 @@ if (COREFLOWS_WITH_GUI)
        # =============
        
        # Mandatory products
-       IF(  $ENV{PARAVIEW_VERSION} STRLESS "5")
-                FIND_PACKAGE(SalomePython REQUIRED)
-       ELSE()
-                FIND_PACKAGE(SalomePythonInterp REQUIRED)
-                FIND_PACKAGE(SalomePythonLibs REQUIRED)
-       ENDIF()
+#      FIND_PACKAGE(SalomePythonInterp REQUIRED)
+#      FIND_PACKAGE(SalomePythonLibs REQUIRED)
        
        SET(_all_SCRIPTS
            main_tests.py
index 9fb0d38d36456cd3d5a3723e0a3a3d1a5d641091..1009e35ab19e9307034ee2357e68357f75c5eac1 100755 (executable)
@@ -16,6 +16,9 @@
 #
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
+cmake_minimum_required (VERSION 3.1)
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
 INCLUDE(CMakeDependentOption)
 
 # Versioning
@@ -35,13 +38,20 @@ SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
 OPTION(SALOME_BUILD_DOC "Generate SALOME CoreFlows documentation" ON)
 OPTION(SALOME_BUILD_TESTS "Generate SALOME CoreFlows tests" ON)
 
+# Common CMake macros
+# ===================
+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 NO_POLICY_SCOPE)
+ELSE()
+  MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
+ENDIF()
 
 # Find KERNEL 
 # ==============
 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)
   FIND_PACKAGE(SalomeKERNEL REQUIRED)
 ELSE( EXISTS ${KERNEL_ROOT_DIR} )
   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR!")
@@ -51,7 +61,6 @@ ENDIF( EXISTS ${KERNEL_ROOT_DIR} )
 # ==============
 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
 IF(EXISTS ${GUI_ROOT_DIR})
-  LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
   FIND_PACKAGE(SalomeGUI)
 ELSE(EXISTS ${GUI_ROOT_DIR})
   MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR!")
@@ -73,8 +82,8 @@ ELSE()
 ENDIF()
 MESSAGE(STATUS "SalomeKERNEL_VERSION is ${SalomeKERNEL_VERSION}")
 
-# Qt4
-FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
+# Qt5
+FIND_PACKAGE(SalomeQt5 REQUIRED COMPONENTS QtCore QtGui)
 
 IF(SALOME_BUILD_DOC)
 #  FIND_PACKAGE(SalomeDoxygen)
index e70c4d96d8c683aa11521c25d6f26be2a8ff92e4..df832964e12fe7322253495bbb95f35ebe92458d 100755 (executable)
@@ -23,8 +23,8 @@
 # Author : A. Bruneton
 #
 
-from PyQt4.QtCore import Qt 
-from PyQt4.QtGui import QMainWindow,QMenu, QDockWidget
+from PyQt5.QtCore import Qt
+from PyQt5.QtWidgets import QMainWindow,QMenu, QDockWidget
 from MainCFWidget import MainCFWidget
 
 class CFDesktop(QMainWindow):
index ca9f9f5c9100e961c8c3999c4dcdf2ee79803e2a..37db116ce91fb2397ca75ec087a742210450b669 100755 (executable)
 # Author : A. Bruneton
 #
 import sys, os
-from PyQt4.QtGui import QApplication 
-from PyQt4.QtCore import SIGNAL, SLOT
+from PyQt5.QtWidgets import QApplication
+#from PyQt5.QtCore import SIGNAL, SLOT
 
 from CFDesktop import CFDesktop
 import SalomePyQt_MockUp
-from PyQt4.QtCore import QTimer, QTranslator, Qt
+from PyQt5.QtCore import QTimer, QTranslator, Qt
 
 desktop = None
 
@@ -52,7 +52,8 @@ def main(args) :
     
     
     #
-    app.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()"))
+#    app.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()"))
+    app.lastWindowClosed.connect(quit)
     app.exec_()
 
 if __name__ == "__main__" :
index a09d5de1d3beb6e0f51305569e9e2e344c9b0aa5..f0b8af1063e5d99ee7f33ff8ff719d6d9699ff9f 100755 (executable)
 # Author : A. Bruneton
 #
 
-from PyQt4.QtGui import QApplication, QTabWidget 
-from PyQt4.QtGui import QAction, QMenu, QIcon, QPixmap, QDesktopWidget, QFileDialog
-from PyQt4.QtCore import SIGNAL, SLOT, QObject, pyqtSlot, pyqtSignal
+from PyQt5.QtWidgets import QApplication, QTabWidget
+from PyQt5.QtWidgets import QAction, QMenu, QDesktopWidget, QFileDialog
+from PyQt5.QtGui import QIcon, QPixmap
+#from PyQt5.QtCore import SIGNAL, SLOT, QObject, pyqtSlot, pyqtSignal
+from PyQt5.QtCore import QObject, pyqtSlot, pyqtSignal
 
 RESOURCE_DIR = "@SGPYQT_RES_DIR@"
 
@@ -47,7 +49,8 @@ class SalomePyQt(QObject):
     if self._mainWindow:
       self._menuBar = self._mainWindow.menuBar()
       self._mainWindow.setCentralWidget(self._tabWidget)
-    self.connect(self._tabWidget, SIGNAL("currentChanged(int)"), self, SLOT("onTabChanged(int)"))
+#    self.connect(self._tabWidget, SIGNAL("currentChanged(int)"), self, SLOT("onTabChanged(int)"))
+    self._tabWidget.currentChanged.connect(self.onTabChanged)
     self._blockSignal = False
   
   def getDesktop(self):
@@ -63,7 +66,8 @@ class SalomePyQt(QObject):
     if self._blockSignal:
       return
     invDict = dict([(v, k) for k,v in self._viewIDs.items()])
-    if invDict.has_key(index):
+    if index in invDict:
+#    if invDict.has_key(index):
       self._blockSignal = True
       self.currentTabChanged.emit(invDict[index])
       self._blockSignal = False
index 9aaeabd62be685a521e8836abae5c21fde49e111..60e6fe2600bb5178a191fd1a2c2359edf8682094 100755 (executable)
@@ -1,27 +1,28 @@
-from PyQt4 import QtGui, QtCore
-from PyQt4.uic import loadUi
+# -*- coding: utf-8 -*-
+from PyQt5 import QtWidgets, QtCore
+from PyQt5.uic import loadUi
 from utils import completeResPath
 
 import CoreFlows as cf
 import cdmath as cm
 
-class MainCFWidget(QtGui.QTabWidget):
+class MainCFWidget(QtWidgets.QTabWidget):
   def __init__(self):
-    QtGui.QTabWidget.__init__(self)
+    QtWidgets.QTabWidget.__init__(self)
     loadUi(completeResPath("MainCFWidget.ui"), self)
     self._python_dump = []
     
   def scanWidgets(self):
-    print self.tabModel
+    print(self.tabModel)
     dictCF={}
     for k in self.__dict__:
       att = self.__dict__[k] 
-      if isinstance(att, QtGui.QWidget):
+      if isinstance(att, QtWidgets.QWidget):
         name = str(att.objectName())
         if name != "":
 #          print(name)
           if name.endswith("RadioButton"):
-            assert(isinstance(att, QtGui.QRadioButton))
+            assert(isinstance(att, QtWidgets.QRadioButton))
             if att.isChecked() :
               # parse name
               name=name[:len(name)-len("_RadioButton")]#On retire le suffixe _Radiobutton
@@ -34,7 +35,7 @@ class MainCFWidget(QtGui.QTabWidget):
               elif name=="MeshCreation" :
                 dictCF["MeshCreation"]=True
           elif name.endswith("spinBox") :
-            assert(isinstance(att, QtGui.QSpinBox))
+            assert(isinstance(att, QtWidgets.QSpinBox))
             val = att.value()
             # parse name
             name=name[:len(name)-len("_spinBox")]#On retire le suffixe _SpinBox
@@ -49,7 +50,7 @@ class MainCFWidget(QtGui.QTabWidget):
             elif name=="NO_FreqSave" :
               dictCF["FreqSave"]=val
           elif name.endswith("doubleSpinBox"):
-            assert(isinstance(att, QtGui.QDoubleSpinBox))
+            assert(isinstance(att, QtWidgets.QDoubleSpinBox))
             val = att.value()
             # parse name
             name=name[:len(name)-len("_doubleSpinBox")]#On retire le suffixe _doubleSpinBox
@@ -113,7 +114,7 @@ class MainCFWidget(QtGui.QTabWidget):
               name=name[3:len(name)-len("_BC")]#On retire le préfixe SP_ ou DM_ au début et le suffixe _BC à la fin
               dictCF[name]=val
           elif name.endswith('comboBox'):
-            assert(isinstance(att, QtGui.QComboBox))
+            assert(isinstance(att, QtWidgets.QComboBox))
             val = att.currentText()
             # parse name
             name=name[:len(name)-len("_comboBox")]#On retire le suffixe _comboBox
@@ -135,7 +136,7 @@ class MainCFWidget(QtGui.QTabWidget):
             elif name=="NO_Preconditioner" :
               dictCF["Preconditioner"]=val 
           elif name.endswith('lineEdit'):
-            assert(isinstance(att, QtGui.QLineEdit))
+            assert(isinstance(att, QtWidgets.QLineEdit))
             val = str(att.text())
             # parse name
             name=name[:len(name)-len("_lineEdit")]#On retire le suffixe _comboBox
@@ -148,13 +149,13 @@ class MainCFWidget(QtGui.QTabWidget):
     return dictCF  
           
   def onLaunchSimu(self):
-    print "Reading widgets"
+    print("Reading widgets")
     dictCF = self.scanWidgets()
 
-    print "Setting Model and VV_Constant"
+    print("Setting Model and VV_Constant")
     ######## Setting Model and VV_Constant #########################
     if dictCF["ModelName"]=="SinglePhase" :
-      exec "myProblem = cf.%s(cf.%s,cf.%s,%s)" % (dictCF["ModelName"],dictCF["fluidType"],dictCF["pressureEstimate"],dictCF["spaceDim"])
+      exec("myProblem = cf.%s(cf.%s,cf.%s,%s)" % (dictCF["ModelName"],dictCF["fluidType"],dictCF["pressureEstimate"],dictCF["spaceDim"]))
       nVar =  myProblem.getNumberOfVariables()
       VV_Constant =[0]*nVar
       VV_Constant[0] = dictCF["InitialPressure"]
@@ -165,7 +166,7 @@ class MainCFWidget(QtGui.QTabWidget):
           VV_Constant[3] = dictCF["InitialVelocity_3d"]
       VV_Constant[nVar-1] = dictCF["InitialTemperature"]
     elif dictCF["ModelName"]=="DriftModel" :
-      exec "myProblem = cf.%s(cf.%s,%s)" % (dictCF["ModelName"],dictCF["pressureEstimate"],dictCF["spaceDim"])
+      exec("myProblem = cf.%s(cf.%s,%s)" % (dictCF["ModelName"],dictCF["pressureEstimate"],dictCF["spaceDim"]))
       nVar =  myProblem.getNumberOfVariables()
       VV_Constant =[0]*nVar
       VV_Constant[0] = dictCF["InitialConcentration"]
@@ -177,18 +178,18 @@ class MainCFWidget(QtGui.QTabWidget):
           VV_Constant[4] = dictCF["InitialVelocity_3d"]
       VV_Constant[nVar-1] = dictCF["InitialTemperature"]
     else :
-      raise NameError('Model not yet handled', dictCF["ModelName"])  
+      raise NameError('Model not yet handled', dictCF["ModelName"])
 
-    print "Setting initial data"
+    print("Setting initial data")
     ############ setting initial data ################################
     if dictCF["spaceDim"] ==1 :
-      print "spaceDim= ", dictCF["spaceDim"]
-      print "VV_Constant= ", VV_Constant
-      print "Xinf= ", dictCF["Xinf"]
-      print "Xsup= ", dictCF["Xsup"]
-      print "Nx= ", dictCF["Nx"]
+      print("spaceDim= ", dictCF["spaceDim"])
+      print("VV_Constant= ", VV_Constant)
+      print("Xinf= ", dictCF["Xinf"])
+      print("Xsup= ", dictCF["Xsup"])
+      print("Nx= ", dictCF["Nx"])
       myProblem.setInitialFieldConstant( dictCF["spaceDim"], VV_Constant, dictCF["Xinf"], dictCF["Xsup"], dictCF["Nx"],"Left","Right");
-      print "Initial field set"
+      print("Initial field set")
     elif dictCF["spaceDim"] ==2 :
       myProblem.setInitialFieldConstant( dictCF["spaceDim"], VV_Constant, dictCF["Xinf"], dictCF["Xsup"], dictCF["Nx"],"Left","Right", dictCF["Yinf"], dictCF["Ysup"], dictCF["Ny"],"Bottom","Top");
     elif dictCF["spaceDim"] ==3 :
@@ -198,7 +199,7 @@ class MainCFWidget(QtGui.QTabWidget):
 
 #    for k, v in dictCF.items():
 #        line = "cf.set%s(%s)" % (k, v)
-#        #exec line
+#        #exec(line)
 #        self._python_dump.append(line)
 
     ######## 1D for the moment ######################
@@ -220,7 +221,7 @@ class MainCFWidget(QtGui.QTabWidget):
     myProblem.setGravity(gravite)
 
     ########## Numerical options ###############
-    exec "myProblem.setNumericalScheme(cf.%s, cf.%s)" % (dictCF["Scheme"],dictCF["Method"])
+    exec("myProblem.setNumericalScheme(cf.%s, cf.%s)" % (dictCF["Scheme"],dictCF["Method"]))
     myProblem.setWellBalancedCorrection(True);  
 
     myProblem.setCFL(dictCF["CFL"]);