From e552a4efd6b20c51240b662088babcff9ab978af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernard=20S=C3=A9cher=C3=83?= Date: Fri, 5 Feb 2021 14:54:49 +0100 Subject: [PATCH] show GUI in salome --- CoreFlows/gui/CMakeLists.txt | 2 +- CoreFlows/gui/salome/src/SOLVERLABGUI.py | 132 ++++++++++++++++------- CoreFlows/gui/ui/CMakeLists.txt | 2 +- 3 files changed, 97 insertions(+), 39 deletions(-) diff --git a/CoreFlows/gui/CMakeLists.txt b/CoreFlows/gui/CMakeLists.txt index 5fae7d7..eeb4b94 100644 --- a/CoreFlows/gui/CMakeLists.txt +++ b/CoreFlows/gui/CMakeLists.txt @@ -43,7 +43,7 @@ ELSE ( (EXISTS $ENV{CONFIGURATION_ROOT_DIR}) AND (EXISTS $ENV{KERNEL_ROOT_DIR}) ) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SalomePyQt_MockUp.py DESTINATION lib/python) # Configure file utils.py - SET(SALOME_INSTALL_PYTHON "lib/python")#This is to use the same variable as salome + SET(SALOME_INSTALL_PYTHON "lib/python"${PYTHON_VERSION}"/site-packages/salome")#This is to use the same variable as salome configure_file( utils.py.in utils.py diff --git a/CoreFlows/gui/salome/src/SOLVERLABGUI.py b/CoreFlows/gui/salome/src/SOLVERLABGUI.py index 9f6813c..94a9851 100755 --- a/CoreFlows/gui/salome/src/SOLVERLABGUI.py +++ b/CoreFlows/gui/salome/src/SOLVERLABGUI.py @@ -1,4 +1,3 @@ -# -*- coding: latin-1 -*- # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, @@ -20,12 +19,16 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# Author : A. Bruneton +# Author : A. Bruneton and B. Secher # -import sys, os -from CFDesktop import CFDesktop +import traceback +import string +import os +import sys +from qtsalome import * -desktop = None +import salome +from CFDesktop import CFDesktop # Get SALOME PyQt interface import SalomePyQt @@ -38,40 +41,46 @@ import libSALOME_Swig sgPyQt = SalomePyQt.SalomePyQt() sg = libSALOME_Swig.SALOMEGUI_Swig() sgDesktop = sgPyQt.getDesktop() +widgetDialogBox = None -moduleDesktop = {} +moduleDesktop = None ######################################################## # Internal methods ######################################################## -def getStudyId(): - """This method returns the active study ID""" - return sgPyQt.getStudyId() +def getDesktop(): + """This method returns the current SOLVERLABT desktop""" -def getStudy(): - """This method returns the active study""" + global moduleDesktop + return moduleDesktop - studyId = _getStudyId() - study = getStudyManager().GetStudyByID( studyId ) - return study +def setDesktop( ): + """This method sets and returns SOLVERLABT desktop""" -def getDesktop(): - """This method returns the current TRUST_PLOT2D desktop""" + global moduleDesktop + + if moduleDesktop is None: + moduleDesktop = CFDesktop( sgPyQt ) + pass + return moduleDesktop - global desktop - return desktop +def incObjToMap( m, id ): + """This method incrementes the object counter in the map""" -def setDesktop( studyID ): - """This method sets and returns TRUST_PLOT2D desktop""" + if id not in m: m[id] = 0 + m[id] += 1 + pass - global moduleDesktop, desktop +def getSelection(): + """This method analyses selection""" - if not moduleDesktop.has_key( studyID ): - moduleDesktop[studyID] = CFDesktop( sgPyQt ) - moduleDesktop[studyID].initialize() - desktop = moduleDesktop[studyID] - return desktop + selcount = sg.SelectedCount() + seltypes = {} + for i in range( selcount ): + incObjToMap( seltypes, getObjectID( sg.getSelected( i ) ) ) + pass + return selcount, seltypes ################################################ # Callback functions @@ -79,31 +88,80 @@ def setDesktop( studyID ): def initialize(): """This method is called when module is initialized. It performs initialization actions""" - setDesktop( getStudyId() ) - pass - -def activeStudyChanged( studyID ): - """This method is called when active study is changed""" - - setDesktop( getStudyId() ) + setDesktop() pass def windows(): """This method is called when module is initialized. It returns a map of popup windows to be used by the module""" + wm = {} + wm[SalomePyQt.WT_ObjectBrowser] = Qt.LeftDockWidgetArea + wm[SalomePyQt.WT_PyConsole] = Qt.BottomDockWidgetArea return wm def views(): """This method is called when module is initialized. It returns a list of 2D/3D views to be used by the module""" return [] +def createPreferences(): + """This method is called when module is initialized. It exports module preferences""" + pass + def activate(): - """This method mimicks SALOME's module activation """ - global desktop - fv = desktop.showCentralWidget() + """This method is called when module is initialized. It returns True if activating is successfull, False otherwise""" + + global moduleDesktop + + fv = moduleDesktop.showCentralWidget() return True +def viewTryClose( wid ): + sgPyQt.setViewClosable(wid, True) + pass + def deactivate(): """This method is called when module is deactivated""" + global moduleDesktop, widgetDialogBox - moduleDesktop[getStudyId()].hideCentralWidget() + moduleDesktop.hideCentralWidget() + pass + +def activeStudyChanged(): + """This method is called when active study is changed""" + + setDesktop() + pass + +def createPopupMenu( popup, context ): + """This method is called when popup menu is invocked""" + pass + +def OnGUIEvent( commandID ): + """This method is called when a GUI action is activated""" + + if commandID in dict_command: + dict_command[commandID]() + pass + pass + +def preferenceChanged( section, setting ): + """This method is called when module's preferences are changed""" + pass + +def activeViewChanged( viewID ): + """This method is called when active view is changed""" + pass + +def viewCloned( viewID ): + """This method is called when active view is cloned""" + pass + +def viewClosed( viewID ): + """This method is called when active view viewClosed""" + pass + +def engineIOR(): + """This method is called when study is opened. It returns engine IOR""" + return getEngineIOR() + +######################################################## diff --git a/CoreFlows/gui/ui/CMakeLists.txt b/CoreFlows/gui/ui/CMakeLists.txt index e0fef09..8089ce5 100755 --- a/CoreFlows/gui/ui/CMakeLists.txt +++ b/CoreFlows/gui/ui/CMakeLists.txt @@ -29,7 +29,7 @@ SET(_all_lib_SCRIPTS IF ( (EXISTS $ENV{CONFIGURATION_ROOT_DIR}) AND (EXISTS $ENV{KERNEL_ROOT_DIR}) AND (EXISTS $ENV{GUI_ROOT_DIR}) ) - SALOME_INSTALL_SCRIPTS("${_pyuic_SCRIPTS}" ${SALOME_INSTALL_PYTHON})#file MainCFWidget.ui + SALOME_INSTALL_SCRIPTS("${_pyuic_files}" ${SALOME_INSTALL_PYTHON})#file MainCFWidget.ui SALOME_INSTALL_SCRIPTS("${_all_lib_SCRIPTS}" ${SALOME_INSTALL_PYTHON})#file MainCFWidget.py ELSE ( (EXISTS $ENV{CONFIGURATION_ROOT_DIR}) AND (EXISTS $ENV{KERNEL_ROOT_DIR}) AND (EXISTS $ENV{GUI_ROOT_DIR}) ) INSTALL(FILES ${_pyuic_files} DESTINATION lib/python) -- 2.39.2