From 8bfe69ea6e84ab0eccd0f2f860ad6a9207f8e378 Mon Sep 17 00:00:00 2001 From: akl Date: Fri, 14 Feb 2014 16:35:34 +0400 Subject: [PATCH] A possibility to switch SALOME into "one-study-at-once" mode was added. --- CMakeLists.txt | 6 ++++++ SalomeGUIConfig.cmake.in | 8 ++++++++ src/LightApp/LightApp_Application.cxx | 19 ++++++++++++++++++- src/STD/STD_Application.cxx | 9 ++++++++- src/STD/STD_Application.h | 1 + src/SalomeApp/SalomeApp_Application.cxx | 4 ++++ 6 files changed, 45 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d31a2792e..3d3666f1f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,10 +70,12 @@ OPTION(SALOME_USE_GRAPHICSVIEW "Enable GraphicsView visualization (Mandatory in OPTION(SALOME_USE_PLOT2DVIEWER "Enable Plot2D visualization (Mandatory in classic configurations)" ON) OPTION(SALOME_USE_PYCONSOLE "Enable Python GUI interface (Mandatory in classic configurations)" ON) OPTION(SALOME_USE_QXGRAPHVIEWER "Enable QX graph visualization (Mandatory in classic configurations)" ON) +OPTION(SALOME_USE_SINGLE_DESKTOP "Enable multiple document interface" OFF) MARK_AS_ADVANCED(SALOME_USE_VTKVIEWER SALOME_USE_VTKVIEWER SALOME_USE_GRAPHICSVIEW) MARK_AS_ADVANCED(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_PLOT2DVIEWER) MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER) +MARK_AS_ADVANCED(SALOME_USE_SINGLE_DESKTOP) # Prerequisites # ============= @@ -122,6 +124,10 @@ IF(SALOME_GUI_USE_OBSERVERS) ADD_DEFINITIONS(-DWITH_SALOMEDS_OBSERVER) ENDIF() +IF(SALOME_USE_SINGLE_DESKTOP) + ADD_DEFINITIONS(-DSINGLE_DESKTOP) +ENDIF() + # OCCT FIND_PACKAGE(SalomeCAS REQUIRED) diff --git a/SalomeGUIConfig.cmake.in b/SalomeGUIConfig.cmake.in index 22754b5a3..02a1e7d34 100644 --- a/SalomeGUIConfig.cmake.in +++ b/SalomeGUIConfig.cmake.in @@ -61,6 +61,14 @@ SET(SALOME_USE_OCCVIEWER @SALOME_USE_OCCVIEWER@) SET(SALOME_USE_GLVIEWER @SALOME_USE_GLVIEWER@) SET(SALOME_USE_VTKVIEWER @SALOME_USE_VTKVIEWER@) SET(SALOME_USE_PLOT2DVIEWER @SALOME_USE_PLOT2DVIEWER@) +SET(SALOME_USE_SINGLE_DESKTOP @SALOME_USE_SINGLE_DESKTOP@) +IF(SALOME_USE_SINGLE_DESKTOP) + LIST(APPEND GUI_DEFINITIONS "-DSINGLE_DESKTOP") +ENDIF() +SET(SALOME_GUI_USE_OBSERVERS @SALOME_GUI_USE_OBSERVERS@) +IF(SALOME_GUI_USE_OBSERVERS) + LIST(APPEND GUI_DEFINITIONS "-DWITH_SALOMEDS_OBSERVER") +ENDIF() # Level 1 prerequisites: SET_AND_CHECK(KERNEL_ROOT_DIR_EXP "@PACKAGE_KERNEL_ROOT_DIR@") diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 1461178bc..06ee4d064 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -867,8 +867,13 @@ void LightApp_Application::onNewWindow() void LightApp_Application::onNewDoc() { //asl: fix for 0020515 - if ( activeStudy() ) + if ( activeStudy() ) { saveDockWindowsState(); +#ifdef SINGLE_DESKTOP + if ( !closeDoc() ) + return; +#endif + } CAM_Application::onNewDoc(); } @@ -880,6 +885,12 @@ void LightApp_Application::onOpenDoc() { SUIT_Study* study = activeStudy(); saveDockWindowsState(); + if (study) { +#ifdef SINGLE_DESKTOP + if ( !closeDoc() ) + return; +#endif + } CAM_Application::onOpenDoc(); @@ -896,6 +907,12 @@ void LightApp_Application::onOpenDoc() */ bool LightApp_Application::onOpenDoc( const QString& aName ) { + if ( activeStudy() ) { +#ifdef SINGLE_DESKTOP + if ( !closeDoc() ) + return false; +#endif + } // We should take mru action first because this application instance can be deleted later. QtxMRUAction* mru = ::qobject_cast( action( MRUId ) ); diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 1fc24b2a7..c6f61411b 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -390,11 +390,17 @@ void STD_Application::afterCloseDoc() /*!Close document, if it's possible.*/ void STD_Application::onCloseDoc( bool ask ) +{ + closeDoc( ask ); +} + +/*!Close document, if it's possible.*/ +bool STD_Application::closeDoc( bool ask ) { bool closePermanently = true; if ( ask && !isPossibleToClose( closePermanently ) ) - return; + return false; SUIT_Study* study = activeStudy(); @@ -430,6 +436,7 @@ void STD_Application::onCloseDoc( bool ask ) if ( !desktop() ) closeApplication(); + return true; } /*!Check the application on closing. diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 506f9b86e..51f8b836e 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -167,6 +167,7 @@ protected: virtual int closeChoice( const QString& ); virtual bool closeAction( const int, bool& ); + virtual bool closeDoc( bool ask = true ); private: ViewManagerList myViewMgrs; diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index c7b16a8ae..175d78c55 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -487,6 +487,10 @@ void SalomeApp_Application::onNewWithScript() /*!SLOT. Load document with \a aName.*/ bool SalomeApp_Application::onLoadDoc( const QString& aName ) { +#ifdef SINGLE_DESKTOP + if ( !LightApp_Application::closeDoc() ) + return false; +#endif bool res = true; if ( !activeStudy() ) { // if no study - load in current desktop -- 2.39.2