From: akl Date: Mon, 22 Sep 2014 13:24:39 +0000 (+0400) Subject: Multi-study support removal: finalization X-Git-Tag: V7_5_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e72e7051c3c2a01ecbddba3eee4bd98c16dd8996;p=modules%2Fgui.git Multi-study support removal: finalization --- diff --git a/doc/salome/gui/images/closestudy.png b/doc/salome/gui/images/closestudy.png index 4099cc803..f53bd1dfe 100755 Binary files a/doc/salome/gui/images/closestudy.png and b/doc/salome/gui/images/closestudy.png differ diff --git a/doc/salome/gui/images/disconnect_study.png b/doc/salome/gui/images/disconnect_study.png new file mode 100644 index 000000000..74c14f86d Binary files /dev/null and b/doc/salome/gui/images/disconnect_study.png differ diff --git a/doc/salome/gui/images/menu_file.png b/doc/salome/gui/images/menu_file.png new file mode 100644 index 000000000..ca8d843f5 Binary files /dev/null and b/doc/salome/gui/images/menu_file.png differ diff --git a/doc/salome/gui/images/studymanagement.png b/doc/salome/gui/images/studymanagement.png old mode 100755 new mode 100644 index a7a4b97dc..2f7b61e30 Binary files a/doc/salome/gui/images/studymanagement.png and b/doc/salome/gui/images/studymanagement.png differ diff --git a/doc/salome/gui/input/introduction_to_gui.doc b/doc/salome/gui/input/introduction_to_gui.doc index 449baa0ce..1814130db 100644 --- a/doc/salome/gui/input/introduction_to_gui.doc +++ b/doc/salome/gui/input/introduction_to_gui.doc @@ -4,13 +4,13 @@ \image html view2.png -\n SALOME GUI is based on SUIT (Salome User Interface +\b SALOME \b GUI is based on SUIT (Salome User Interface Toolkit) that proposes very flexible, powerful and safe mechanisms of interaction with SALOME tool components (both CORBA and standalone), resource management, viewers and selection handling, -exception and signals processing. This approach brings to the top -Salome multi-desktop dockable-windowed user interface. -\n All Graphical User Interfaces of standard modules have plug-in +exception and signals processing. + +All Graphical User Interfaces of standard modules have plug-in structure, i.e. each module is placed in a dynamic library which is loaded on demand. So, all modules add their own menu items, buttons in toolbar, windows etc. @@ -22,7 +22,7 @@ basic GUI functionalities, common for all modules. -To confirm your choice click \b Save. +To confirm your choice click \a Save. Load Script - allows to load a saved Python Script. \image html loadscript.png -To confirm your choice click \b Open. +To confirm your choice click \a Open. Properties - allows to show/edit the properties of the current study. diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 53b251f4a..e4dd2537a 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -415,6 +415,7 @@ void LightApp_Application::start() updateWindows(); updateViewManagers(); + updateCommandsStatus(); putInfo( "" ); desktop()->statusBar()->showMessage( "" ); @@ -860,16 +861,14 @@ void LightApp_Application::onNewWindow() */ void LightApp_Application::onNewDoc() { - //asl: fix for 0020515 - if ( activeStudy() ) { - saveDockWindowsState(); - } - #ifdef SINGLE_DESKTOP if ( !checkExistingDoc() ) return; #endif + //asl: fix for 0020515 + saveDockWindowsState(); + CAM_Application::onNewDoc(); } @@ -879,7 +878,6 @@ void LightApp_Application::onNewDoc() void LightApp_Application::onOpenDoc() { SUIT_Study* study = activeStudy(); - saveDockWindowsState(); #ifdef SINGLE_DESKTOP if ( !checkExistingDoc() ) @@ -905,6 +903,9 @@ bool LightApp_Application::onOpenDoc( const QString& aName ) if ( !checkExistingDoc() ) return false; #endif + + saveDockWindowsState(); + // We should take mru action first because this application instance can be deleted later. QtxMRUAction* mru = ::qobject_cast( action( MRUId ) ); @@ -1587,6 +1588,11 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy ) if ( objectBrowser() ) objectBrowser()->openLevels(); + +#ifndef DISABLE_PYCONSOLE + if( pythonConsole() ) + pythonConsole()->getInterp()->initStudy(); +#endif } /*! @@ -1614,6 +1620,11 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) if ( objectBrowser() ) objectBrowser()->openLevels(); +#ifndef DISABLE_PYCONSOLE + if( pythonConsole() ) + pythonConsole()->getInterp()->initStudy(); +#endif + emit studyOpened(); } @@ -1792,6 +1803,8 @@ void LightApp_Application::onPreferenceChanged( QString& modName, QString& secti /*!Remove all windows from study.*/ void LightApp_Application::beforeCloseDoc( SUIT_Study* s ) { + saveDockWindowsState(); + if ( SUIT_DataBrowser* ob = objectBrowser() ) ob->setModel(0); @@ -1907,11 +1920,13 @@ QWidget* LightApp_Application::createWindow( const int flag ) */ void LightApp_Application::defaultWindows( QMap& aMap ) const { - aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea ); #ifndef DISABLE_PYCONSOLE aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea ); #endif - // aMap.insert( WT_LogWindow, Qt::DockBottom ); + if ( activeStudy() ) { + aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea ); + // aMap.insert( WT_LogWindow, Qt::DockBottom ); + } } /*!Default view managers*/ @@ -3167,9 +3182,6 @@ void LightApp_Application::removeModuleAction( const QString& modName ) void LightApp_Application::currentWindows( QMap& winMap ) const { winMap.clear(); - if ( !activeStudy() ) - return; - if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) ) ((LightApp_Module*)activeModule())->windows( winMap ); else @@ -3200,28 +3212,22 @@ void LightApp_Application::updateWindows() QMap winMap; currentWindows( winMap ); - if ( activeStudy() ) + for ( QMap::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) { - for ( QMap::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) - { - if ( !dockWindow( it.key() ) ) - getWindow( it.key() ); - } + if ( !dockWindow( it.key() ) ) + getWindow( it.key() ); } for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it ) { QWidget* wid = it.value(); - if ( activeStudy() ) - wid->setVisible( winMap.contains( it.key() ) ); + if ( winMap.contains( it.key() ) ) + wid->setVisible( true ); else delete wid; } - if ( activeStudy() ) - loadDockWindowsState(); - else - myWin.clear(); + loadDockWindowsState(); } /*! @@ -3246,18 +3252,19 @@ void LightApp_Application::loadDockWindowsState() SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true ); bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true ); - long version = Qtx::versionToId( aResMgr->stringValue( "salome", "version", "" ) ); QString modName; if ( activeModule() ) modName = activeModule()->name(); + else if ( activeStudy() ) + modName = "nomodule"; QtxResourceMgr::WorkingMode prevMode = aResMgr->workingMode(); - aResMgr->setWorkingMode(QtxResourceMgr::IgnoreUserValues); + aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues ); QByteArray aDefaultState; - aResMgr->value("windows_geometry", modName , aDefaultState ); + aResMgr->value( "windows_geometry", modName, aDefaultState ); QByteArray aDefaultVisibility; - aResMgr->value("windows_visibility", modName , aDefaultVisibility ); + aResMgr->value( "windows_visibility", modName, aDefaultVisibility ); bool hasDefaultVisibility = !aDefaultVisibility.isEmpty(); aResMgr->setWorkingMode(prevMode); @@ -3265,6 +3272,7 @@ void LightApp_Application::loadDockWindowsState() return; if ( aResMgr->hasValue("windows_geometry" ,modName ) ) { + long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) ); QByteArray arr; if ( version > Qtx::versionToId( "7.4.1" ) ) aResMgr->value( "windows_geometry", modName , arr ); @@ -3355,9 +3363,17 @@ void LightApp_Application::saveDockWindowsState() QString modName; if ( activeModule() ) modName = activeModule()->name(); + else if ( activeStudy() ) + modName = "nomodule"; + + QString versionId = GUI_VERSION_STR; +#if GUI_DEVELOPMENT > 0 + versionId += "dev"; +#endif QByteArray arr = desktop()->saveState(); resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) ); + resourceMgr()->setValue( "windows_geometry_version", modName, versionId ); QByteArray visArr; if ( myWinVis.contains( modName ) ) @@ -4375,7 +4391,34 @@ void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* ) /*! Check existing document. */ -bool LightApp_Application::checkExistingDoc() { - return true; +bool LightApp_Application::checkExistingDoc() +{ + bool result = true; + if( activeStudy() ) { + int answer = SUIT_MessageBox::question( desktop(), + tr( "APPCLOSE_CAPTION" ), + tr( "STUDYCLOSE_DESCRIPTION" ), + tr( "APPCLOSE_SAVE" ), + tr( "APPCLOSE_CLOSE" ), + tr( "APPCLOSE_CANCEL" ), 0 ); + if(answer == 0) { + if ( activeStudy()->isSaved() ) { + onSaveDoc(); + closeDoc( false ); + } else if ( onSaveAsDoc() ) { + if( !closeDoc( false ) ) { + result = false; + } + } else { + result = false; + } + } + else if( answer == 1 ) { + closeDoc( false ); + } else if( answer == 2 ) { + result = false; + } + } + return result; } diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 35aaef3da..9fcf985aa 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -246,9 +246,11 @@
- + +
- + +
diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 94dae2e0b..7922e42b9 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -50,6 +50,26 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASENTRY_COLUMN Entry + + APPCLOSE_CAPTION + Close active study + + + STUDYCLOSE_DESCRIPTION + You already have an active study in your session. It has to be closed before working with another study. + + + APPCLOSE_SAVE + &Save && Close + + + APPCLOSE_CLOSE + &Close w/o saving + + + APPCLOSE_CANCEL + &Cancel + LightApp_Application diff --git a/src/LightApp/resources/LightApp_msg_fr.ts b/src/LightApp/resources/LightApp_msg_fr.ts index 50918d26f..6d3691647 100755 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -50,6 +50,26 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASENTRY_COLUMN Entrée + + APPCLOSE_CAPTION + Fermer l'étude actuelle + + + STUDYCLOSE_DESCRIPTION + You already have an active study in your session. It has to be closed before working with another study. + + + APPCLOSE_SAVE + &Sauvegarder && Fermer + + + APPCLOSE_CLOSE + &Fermer sans sauvegarder + + + APPCLOSE_CANCEL + &Annuler + LightApp_Application diff --git a/src/LightApp/resources/LightApp_msg_ja.ts b/src/LightApp/resources/LightApp_msg_ja.ts index bdf471261..d90b91b08 100644 --- a/src/LightApp/resources/LightApp_msg_ja.ts +++ b/src/LightApp/resources/LightApp_msg_ja.ts @@ -50,6 +50,27 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASENTRY_COLUMN エントリ + + APPCLOSE_CAPTION + 現在のスタディを閉じる + + + STUDYCLOSE_DESCRIPTION + You already have an active study in your +session. It has to be closed before working with another study. + + + APPCLOSE_SAVE + 保存して閉じる(&S) + + + APPCLOSE_CLOSE + 保存せずに閉じる(&C) + + + APPCLOSE_CANCEL + キャンセル(&C) + LightApp_Application diff --git a/src/PyInterp/PyInterp_Interp.h b/src/PyInterp/PyInterp_Interp.h index 9b855a4f2..33c6a2d47 100644 --- a/src/PyInterp/PyInterp_Interp.h +++ b/src/PyInterp/PyInterp_Interp.h @@ -65,6 +65,7 @@ public: void destroy(); virtual int run(const char *command); + virtual void initStudy(){}; // [ABN] - the PyLockWrapper is no more attached to the interpreter // PyLockWrapper GetLockWrapper() const; diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 994edd195..51354196a 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -229,10 +229,9 @@ void STD_Application::createActions() createMenu( FileNewId, fileMenu, 0 ); createMenu( FileOpenId, fileMenu, 0 ); createMenu( FileReopenId, fileMenu, 0 ); - createMenu( FileCloseId, fileMenu, 5 ); - createMenu( separator(), fileMenu, -1, 5 ); createMenu( FileSaveId, fileMenu, 5 ); createMenu( FileSaveAsId, fileMenu, 5 ); + createMenu( FileCloseId, fileMenu, 5 ); createMenu( separator(), fileMenu, -1, 5 ); createMenu( separator(), fileMenu ); @@ -403,12 +402,18 @@ bool STD_Application::closeDoc( bool ask ) if ( ask && !isPossibleToClose( closePermanently ) ) return false; + return closeActiveDoc( closePermanently ); +} + +/*!Close document.*/ +bool STD_Application::closeActiveDoc( bool permanently ) +{ SUIT_Study* study = activeStudy(); beforeCloseDoc( study ); if ( study ) - study->closeDocument( closePermanently ); + study->closeDocument( permanently ); clearViewManagers(); diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 8e5703b01..8073407c3 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -168,6 +168,7 @@ protected: virtual int closeChoice( const QString& ); virtual bool closeAction( const int, bool& ); virtual bool closeDoc( bool ask = true ); + virtual bool closeActiveDoc( bool permanently = true ); private: ViewManagerList myViewMgrs; diff --git a/src/STD/resources/STD_msg_en.ts b/src/STD/resources/STD_msg_en.ts index dd91f9b92..382d9db5a 100644 --- a/src/STD/resources/STD_msg_en.ts +++ b/src/STD/resources/STD_msg_en.ts @@ -362,10 +362,6 @@ Do you want to overwrite it? TOT_DESK_FILE_EXIT Exit from application - - TOT_DESK_FILE_LOAD - Load document - TOT_DESK_FILE_OPEN Open document @@ -390,10 +386,6 @@ Do you want to overwrite it? PRP_DESK_FILE_SAVE Saves the active document - - PRP_DESK_FILE_LOAD - Loads a document - PRP_DESK_WINDOW_HTILE Arranges the windows as nonoverlapping horizontal tiles @@ -418,10 +410,6 @@ Do you want to overwrite it? MEN_DESK_FILE_REOPEN Reopen - - MEN_DESK_FILE_LOAD - Conn&ect... - MEN_DESK_FILE_SAVE &Save diff --git a/src/STD/resources/STD_msg_fr.ts b/src/STD/resources/STD_msg_fr.ts index 87c71765e..4b2aa2a99 100755 --- a/src/STD/resources/STD_msg_fr.ts +++ b/src/STD/resources/STD_msg_fr.ts @@ -362,10 +362,6 @@ Voulez-vous l'écraser ? TOT_DESK_FILE_EXIT Quitter l'application - - TOT_DESK_FILE_LOAD - Charger le document - TOT_DESK_FILE_OPEN Ouvrir un document @@ -390,10 +386,6 @@ Voulez-vous l'écraser ? PRP_DESK_FILE_SAVE Sauvegarder le document actuel - - PRP_DESK_FILE_LOAD - Charge un document - PRP_DESK_WINDOW_HTILE Ranger les fenêtres en mosaïque horizontale @@ -418,10 +410,6 @@ Voulez-vous l'écraser ? MEN_DESK_FILE_REOPEN &Réouvrir - - MEN_DESK_FILE_LOAD - Connec&ter... - MEN_DESK_FILE_SAVE &Enregistrer diff --git a/src/STD/resources/STD_msg_ja.ts b/src/STD/resources/STD_msg_ja.ts index 6f7dbd730..476d9c716 100644 --- a/src/STD/resources/STD_msg_ja.ts +++ b/src/STD/resources/STD_msg_ja.ts @@ -355,10 +355,6 @@ TOT_DESK_FILE_EXIT アプリケーションを終了 - - TOT_DESK_FILE_LOAD - ドキュメントを読み込む - TOT_DESK_FILE_OPEN 文書を開く @@ -383,10 +379,6 @@ PRP_DESK_FILE_SAVE 現在のドキュメントを保存 - - PRP_DESK_FILE_LOAD - ドキュメントを読み込み - PRP_DESK_WINDOW_HTILE ウィンドウを左右に並べて表示 @@ -411,10 +403,6 @@ MEN_DESK_FILE_REOPEN 再読み込み - - MEN_DESK_FILE_LOAD - 接続...(&e) - MEN_DESK_FILE_SAVE 保存(&S) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 282a26f30..32d2f1d5d 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -164,8 +164,6 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() SalomeApp_Application::SalomeApp_Application() : LightApp_Application() { - connect( desktop(), SIGNAL( message( const QString& ) ), - this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection ); myIsSiman = false; // default } @@ -320,12 +318,13 @@ void SalomeApp_Application::createActions() tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ), /*Qt::SHIFT+Qt::Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) ); - //rnv commented : implementation of the mono-study in GUI - // - //createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ), - // resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ), - // tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ), - // Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) ); + createAction( ConnectId, tr( "TOT_DESK_CONNECT_STUDY" ), QIcon(), + tr( "MEN_DESK_CONNECT" ), tr( "PRP_DESK_CONNECT" ), + Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) ); + + createAction( DisconnectId, tr( "TOT_DESK_DISCONNECT_STUDY" ), QIcon(), + tr( "MEN_DESK_DISCONNECT" ), tr( "PRP_DESK_DISCONNECT" ), + Qt::CTRL+Qt::Key_U, desk, false, this, SLOT( onUnloadDoc() ) ); #ifdef WITH_SIMANIO @@ -346,7 +345,9 @@ void SalomeApp_Application::createActions() // creation of menu item is moved to VISU // createMenu( SaveGUIStateId, fileMenu, 10, -1 ); - // createMenu( FileLoadId, fileMenu, 0 ); + createMenu( ConnectId, fileMenu, 5 ); + createMenu( DisconnectId, fileMenu, 5 ); + createMenu( separator(), fileMenu, -1, 5 ); #ifdef WITH_SIMANIO if (myIsSiman) { @@ -358,7 +359,6 @@ void SalomeApp_Application::createActions() } #endif createMenu( DumpStudyId, fileMenu, 10, -1 ); - createMenu( separator(), fileMenu, -1, 10, -1 ); createMenu( LoadScriptId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 10, -1 ); createMenu( PropertiesId, fileMenu, 10, -1 ); @@ -387,18 +387,6 @@ void SalomeApp_Application::createActions() } - -/*!Set desktop:*/ -void SalomeApp_Application::setDesktop( SUIT_Desktop* desk ) -{ - LightApp_Application::setDesktop( desk ); - - if ( desk ) { - connect( desk, SIGNAL( message( const QString& ) ), - this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection ); - } -} - /*! \brief Close application. */ @@ -477,6 +465,31 @@ void SalomeApp_Application::onLoadDoc() } } +/*!SLOT. Unload document.*/ +void SalomeApp_Application::onUnloadDoc( bool ask ) +{ + if ( ask ) { + activeStudy()->abortAllOperations(); + if ( activeStudy()->isModified() ) { + QString docName = activeStudy()->studyName().trimmed(); + int answer = SUIT_MessageBox::question( desktop(), tr( "DISCONNECT_CAPTION" ), + tr( "DISCONNECT_DESCRIPTION" ), + tr( "DISCONNECT_SAVE" ), + tr( "DISCONNECT_WO_SAVE" ), + tr( "APPCLOSE_CANCEL" ), 0 ); + if ( answer == 0 ) { // save before unload + if ( activeStudy()->isSaved() ) + onSaveDoc(); + else if ( !onSaveAsDoc() ) + return; + } + else if ( answer == 2 ) // Cancel + return; + } + } + closeActiveDoc( false ); +} + /*!SLOT. Create new study and load script*/ void SalomeApp_Application::onNewWithScript() { @@ -543,18 +556,36 @@ bool SalomeApp_Application::onLoadDoc( const QString& aName ) return res; } -/*!SLOT. Load document with a name, specified in \a aMessage.*/ -void SalomeApp_Application::onLoadDocMessage(const QString& aMessage) +/*!SLOT. Parse message for desktop.*/ +void SalomeApp_Application::onDesktopMessage( const QString& message ) { - if (aMessage.indexOf("simanCheckoutDone ") == 0) { + if (message.indexOf("simanCheckoutDone ") == 0) { #ifdef WITH_SIMANIO - onLoadDoc(aMessage.section(' ', 1)); + // Load document with a name, specified in aMessage. + onLoadDoc(message.section(' ', 1)); #else printf( "****************************************************************\n" ); printf( "* Warning: SALOME is built without SIMAN support.\n" ); printf( "****************************************************************\n" ); #endif } + else if (message.indexOf("studyCreated:") == 0) { + // Enable 'Connect' action + updateCommandsStatus(); + } + else if (message.indexOf("studyClosed:") == 0) { + /* message also contains ID of the closed study, + but as soon as SALOME is mono-study application for the moment, + this ID is not needed now.*/ + //long aStudyId = message.section(':', 1).toLong(); + // Disconnect GUI from active study, because it was closed on DS side. + closeActiveDoc( false ); + // Disable 'Connect' action + QAction* a = action( ConnectId ); + if ( a ) + a->setEnabled( false ); + } + LightApp_Application::onDesktopMessage( message ); } /*!SLOT. Copy objects to study maneger from selection maneger..*/ @@ -641,7 +672,6 @@ void SalomeApp_Application::onCloseDoc( bool ask ) } } - LightApp_Application::onCloseDoc( ask ); } @@ -760,8 +790,8 @@ void SalomeApp_Application::updateCommandsStatus() // Load script menu a = action( LoadScriptId ); - if ( a ) - a->setEnabled( activeStudy() ); + if( a ) + a->setEnabled( pythonConsole() ); // Properties menu a = action( PropertiesId ); @@ -773,6 +803,16 @@ void SalomeApp_Application::updateCommandsStatus() if( a ) a->setEnabled( activeStudy() ); + // Connect study menu + a = action( ConnectId ); + if( a ) + a->setEnabled( !activeStudy() && studyMgr()->GetOpenStudies().size() > 0 ); + + // Disconnect study menu + a = action( DisconnectId ); + if( a ) + a->setEnabled( activeStudy() ); + // update state of Copy/Paste menu items onSelectionChanged(); } @@ -894,14 +934,14 @@ void SalomeApp_Application::onDumpStudy( ) void SalomeApp_Application::onLoadScript( ) { SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); - if ( !appStudy ) return; - _PTR(Study) aStudy = appStudy->studyDS(); - - if ( aStudy->GetProperties()->IsLocked() ) { - SUIT_MessageBox::warning( desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED") ); - return; + if ( appStudy ) { + _PTR(Study) aStudy = appStudy->studyDS(); + if ( aStudy->GetProperties()->IsLocked() ) { + SUIT_MessageBox::warning( desktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED") ); + return; + } } QStringList filtersList; @@ -1268,8 +1308,7 @@ QMap SalomeApp_Application::activateModuleActions() const { QMap opmap = LightApp_Application::activateModuleActions(); - // rnv commented : implementation of the mono-study in GUI - // opmap.insert( LoadStudyId, tr( "ACTIVATE_MODULE_OP_LOAD" ) ); + opmap.insert( LoadStudyId, tr( "ACTIVATE_MODULE_OP_LOAD" ) ); opmap.insert( NewAndScriptId, tr( "ACTIVATE_MODULE_OP_SCRIPT" ) ); return opmap; @@ -2050,42 +2089,15 @@ void SalomeApp_Application::afterCloseDoc() /* Asks to close existing document. */ -bool SalomeApp_Application::checkExistingDoc() { - bool result = true; - if( activeStudy() ) { - int answer = SUIT_MessageBox::question( desktop(), - tr( "APPCLOSE_CAPTION" ), - tr( "STUDYCLOSE_DESCRIPTION" ), - tr( "APPCLOSE_SAVE" ), - tr( "APPCLOSE_CLOSE" ), - tr( "APPCLOSE_CANCEL" ), 0 ); - if(answer == 0) { - if ( activeStudy()->isSaved() ) { - onSaveDoc(); - closeDoc( false ); - } else if ( onSaveAsDoc() ) { - if( !closeDoc( false ) ) { - result = false; - } - } else { - result = false; - } - } - else if( answer == 1 ) { - closeDoc( false ); - } else if( answer == 2 ) { - result = false; - } - } else { +bool SalomeApp_Application::checkExistingDoc() +{ + bool result = LightApp_Application::checkExistingDoc(); + if ( result && !activeStudy() ) { SALOMEDSClient_StudyManager* aMgr = studyMgr(); - if( aMgr ) { + if ( aMgr ) { std::vector List = studyMgr()->GetOpenStudies(); if( List.size() > 0 ) { - int answer = SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_ACTIVEDOC_LOAD" ), - SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ); - if ( answer == SUIT_MessageBox::Yes ) { - onLoadDoc(); - } + SUIT_MessageBox::critical( desktop(), tr( "WRN_WARNING" ), tr( "ERR_ACTIVEDOC_LOAD" )); result = false; } } diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 5d999d1a9..d54a6b8c2 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -69,8 +69,9 @@ class SALOMEAPP_EXPORT SalomeApp_Application : public LightApp_Application public: enum { MenuToolsId = 5 }; enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId, - CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID, - SimanCheckInId, SimanLocalCheckInId }; + CatalogGenId, RegDisplayId, SaveGUIStateId, ConnectId, DisconnectId, + SimanCheckInId, SimanLocalCheckInId, + UserID }; typedef enum { WT_NoteBook = LightApp_Application::WT_User, WT_User @@ -94,8 +95,6 @@ public: virtual void contextMenuPopup( const QString&, QMenu*, QString& ); virtual bool checkDataObject(LightApp_DataObject* theObj); - - virtual void setDesktop( SUIT_Desktop* ); virtual bool checkExistingDoc(); @@ -124,8 +123,8 @@ public slots: virtual void onLoadDoc(); virtual void onNewWithScript(); virtual bool onLoadDoc( const QString& ); + virtual void onUnloadDoc( bool ask = true); virtual void onCloseDoc( bool ask = true); - virtual void onLoadDocMessage(const QString&); virtual void onExit(); virtual void onCopy(); @@ -144,6 +143,7 @@ public slots: protected slots: void onStudyCreated( SUIT_Study* ); void onStudyOpened( SUIT_Study* ); + void onDesktopMessage( const QString& ); protected: virtual void createActions(); diff --git a/src/SalomeApp/SalomeApp_PyInterp.cxx b/src/SalomeApp/SalomeApp_PyInterp.cxx index 3adde1b6b..1107c03a3 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.cxx +++ b/src/SalomeApp/SalomeApp_PyInterp.cxx @@ -37,7 +37,7 @@ * initstate & initcontext redefined here. */ SalomeApp_PyInterp::SalomeApp_PyInterp(): - PyConsole_EnhInterp(), myFirstRun( true ) + PyConsole_EnhInterp(), myFirstRun( true ), myFirstInitStudy( false ) { } @@ -68,7 +68,10 @@ int SalomeApp_PyInterp::beforeRun() int ret = simpleRun( "from Help import *", false ); if ( ret ) return ret; - ret = simpleRun( "import salome", false ); + } + if( myFirstInitStudy ) { + myFirstInitStudy = false; + int ret = simpleRun( "import salome", false ); if (ret) return ret; ret = simpleRun( "salome.salome_init(0,1)", false ); @@ -78,8 +81,14 @@ int SalomeApp_PyInterp::beforeRun() return true; } +void SalomeApp_PyInterp::initStudy() +{ + myFirstInitStudy = true; +} + void SalomeApp_PyInterp::closeContext() { - simpleRun( "import salome", false ); - simpleRun( "salome.salome_close()", false ); + myFirstInitStudy = false; + simpleRun( "import salome", false ); + simpleRun( "salome.salome_close()", false ); } diff --git a/src/SalomeApp/SalomeApp_PyInterp.h b/src/SalomeApp/SalomeApp_PyInterp.h index 95855f3a4..bf7bd8d50 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.h +++ b/src/SalomeApp/SalomeApp_PyInterp.h @@ -36,6 +36,7 @@ public: virtual ~SalomeApp_PyInterp(); virtual void initPython(); + virtual void initStudy(); virtual void closeContext(); protected: @@ -43,6 +44,7 @@ protected: private: bool myFirstRun; + bool myFirstInitStudy; }; #endif diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 70bd944cb..293488936 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -47,6 +47,11 @@ #include +#ifndef DISABLE_PYCONSOLE + #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first! + #include +#endif + #include "utilities.h" #include "SALOMEDS_Tool.hxx" @@ -729,7 +734,16 @@ void SalomeApp_Study::closeDocument(bool permanently) if ( myObserver ) myStudyDS->detach( myObserver->_this() ); if ( permanently ) { + SUIT_Desktop* desk = SUIT_Session::session()->activeApplication()->desktop(); + bool isBlocked = desk->signalsBlocked(); + desk->blockSignals( true ); SalomeApp_Application::studyMgr()->Close( studyPtr ); + desk->blockSignals( isBlocked ); +#ifndef DISABLE_PYCONSOLE + SalomeApp_Application* app = dynamic_cast( application() ); + if( app->pythonConsole() ) + app->pythonConsole()->getInterp()->destroy(); +#endif } SALOMEDSClient_Study* aStudy = 0; setStudyDS( _PTR(Study)(aStudy) ); diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index af08eef16..d73f74105 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -13,16 +13,8 @@ Python file must include only letters, digits and underscores and start from let The file %1 does not exist. - QUE_ACTIVEDOC_LOAD - There is an active study in the session. -Do you want to load it? - - - - STUDYCLOSE_DESCRIPTION - You should close an existing study before. -Do you want to close it? - + ERR_ACTIVEDOC_LOAD + A study is already active in your session, but you are not connected to it. Use the Connect button to load it in the interface. WRN_STUDY_LOCKED @@ -118,6 +110,30 @@ Launch a new session or close the study. CREATE_DOCUMENT_PROBLEM Unknown problem during creation of the document + + TOT_DESK_CONNECT_STUDY + Connect study + + + TOT_DESK_DISCONNECT_STUDY + Disconnect study + + + PRP_DESK_CONNECT + Connect active study + + + PRP_DESK_DISCONNECT + Disconnect the current study + + + MEN_DESK_CONNECT + Conn&ect + + + MEN_DESK_DISCONNECT + D&isconnect + SalomeApp_Application @@ -129,10 +145,6 @@ Launch a new session or close the study. APPCLOSE_UNLOAD &Unload - - APPCLOSE_CLOSE - &Close w/o saving - MEN_WINDOWS_NEW New Window @@ -157,10 +169,6 @@ Launch a new session or close the study. MEN_DESK_REGISTRY_DISPLAY Registry &Display - - APPCLOSE_SAVE - &Save && Close - TOT_DESK_FILE_LOAD_SCRIPT Load python script @@ -254,10 +262,6 @@ Do you want to reload it ? STUDY_LOCKED LOCKED - - APPCLOSE_CANCEL - &Cancel - OBJ_BROWSER_NAME Object @@ -362,10 +366,6 @@ Do you want to reload it ? MEN_DESK_ADD_VARS_TO_NOTEBOOK Add vars to NoteBook - - APPCLOSE_CAPTION - Close active study - MEN_DESK_MRU Most Recently Used @@ -376,7 +376,7 @@ Do you want to reload it ? ACTIVATE_MODULE_OP_LOAD - &Load... + &Connect ACTIVATE_MODULE_OP_SCRIPT @@ -406,6 +406,22 @@ Do you want to reload it ? PRP_SIMAN_LOCAL_CHECK_IN Check In for module + + DISCONNECT_CAPTION + Disconnect active study + + + DISCONNECT_DESCRIPTION + Do you want to save study before disconnect? + + + DISCONNECT_SAVE + &Save && Disconnect + + + DISCONNECT_WO_SAVE + &Disconnect w/o saving + SalomeApp_StudyPropertiesDlg diff --git a/src/SalomeApp/resources/SalomeApp_msg_fr.ts b/src/SalomeApp/resources/SalomeApp_msg_fr.ts index 345a295e0..dade025d2 100755 --- a/src/SalomeApp/resources/SalomeApp_msg_fr.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_fr.ts @@ -12,6 +12,10 @@ Un fichier Python ne doit être composé que de lettres, chiffres et tirets bas WRN_FILE_NOT_EXIST Le fichier %1 n'existe pas. + + ERR_ACTIVEDOC_LOAD + A study is already active in your session, but you are not connected to it. Use the Connect button to load it in the interface. + WRN_STUDY_LOCKED L'étude est verrouillée @@ -94,6 +98,30 @@ Lancez une nouvelle session ou fermez l'étude en cours. Impossible d'ouvrir l'étude car il y en a déjà une d'active. Lancez une nouvelle session ou fermez l'étude en cours. + + TOT_DESK_CONNECT_STUDY + Connect study + + + TOT_DESK_DISCONNECT_STUDY + Disconnect study + + + PRP_DESK_CONNECT + Connect active study + + + PRP_DESK_DISCONNECT + Disconnect the current study + + + MEN_DESK_CONNECT + Conn&ect + + + MEN_DESK_DISCONNECT + D&isconnect + SalomeApp_Application @@ -105,10 +133,6 @@ Lancez une nouvelle session ou fermez l'étude en cours. APPCLOSE_UNLOAD &Déconnecter - - APPCLOSE_CLOSE - &Fermer sans sauvegarder - MEN_WINDOWS_NEW Nouvelle fenêtre @@ -133,10 +157,6 @@ Lancez une nouvelle session ou fermez l'étude en cours. MEN_DESK_REGISTRY_DISPLAY Affichage du registre CORBA - - APPCLOSE_SAVE - &Sauvegarder && Fermer - TOT_DESK_FILE_LOAD_SCRIPT Exécuter un script python @@ -230,10 +250,6 @@ Voulez-vous le recharger ? STUDY_LOCKED VERROUILLEE - - APPCLOSE_CANCEL - &Annuler - OBJ_BROWSER_NAME Objet @@ -338,10 +354,6 @@ Voulez-vous le recharger ? MEN_DESK_ADD_VARS_TO_NOTEBOOK Ajouter les variables au registre - - APPCLOSE_CAPTION - Fermer l'étude actuelle - MEN_DESK_MRU Dernières études ouvertes @@ -352,7 +364,7 @@ Voulez-vous le recharger ? ACTIVATE_MODULE_OP_LOAD - &Charger... + &Connect ACTIVATE_MODULE_OP_SCRIPT @@ -382,6 +394,22 @@ Voulez-vous le recharger ? PRP_SIMAN_LOCAL_CHECK_IN Check In pour la module" + + DISCONNECT_CAPTION + Disconnect active study + + + DISCONNECT_DESCRIPTION + Do you want to save study before disconnect? + + + DISCONNECT_SAVE + &Save && Disconnect + + + DISCONNECT_WO_SAVE + &Disconnect w/o saving + SalomeApp_StudyPropertiesDlg diff --git a/src/SalomeApp/resources/SalomeApp_msg_ja.ts b/src/SalomeApp/resources/SalomeApp_msg_ja.ts index 4c0b3b964..c11f45b10 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_ja.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_ja.ts @@ -12,13 +12,8 @@ ファイル %1 は存在しません。 - QUE_ACTIVEDOC_LOAD - セッションにスタディがあります。読み込みますか? - - - STUDYCLOSE_DESCRIPTION - 既存のスタディを閉じる必要があります。閉じますか? - + ERR_ACTIVEDOC_LOAD + A study is already active in your session, but you are not connected to it. Use the Connect button to load it in the interface. WRN_STUDY_LOCKED @@ -114,6 +109,30 @@ CREATE_DOCUMENT_PROBLEM ドキュメント作成中に不明な問題が発生しました + + TOT_DESK_CONNECT_STUDY + Connect study + + + TOT_DESK_DISCONNECT_STUDY + Disconnect study + + + PRP_DESK_CONNECT + Connect active study + + + PRP_DESK_DISCONNECT + Disconnect the current study + + + MEN_DESK_CONNECT + Conn&ect + + + MEN_DESK_DISCONNECT + D&isconnect + SalomeApp_Application @@ -125,10 +144,6 @@ APPCLOSE_UNLOAD アンロード(&U) - - APPCLOSE_CLOSE - 保存せずに閉じる(&C) - MEN_WINDOWS_NEW 新しいウィンドウ @@ -153,10 +168,6 @@ MEN_DESK_REGISTRY_DISPLAY レジストリの表示(&D) - - APPCLOSE_SAVE - 保存して閉じる(&S) - TOT_DESK_FILE_LOAD_SCRIPT Python スクリプトを実行 @@ -249,10 +260,6 @@ STUDY_LOCKED ロック - - APPCLOSE_CANCEL - キャンセル(&C) - OBJ_BROWSER_NAME オブジェクト @@ -357,10 +364,6 @@ MEN_DESK_ADD_VARS_TO_NOTEBOOK 変数をレジストリに追加します。 - - APPCLOSE_CAPTION - 現在のスタディを閉じる - MEN_DESK_MRU 最近のスタディ @@ -371,7 +374,7 @@ ACTIVATE_MODULE_OP_LOAD - 読込み(&L) + &Connect ACTIVATE_MODULE_OP_SCRIPT @@ -401,6 +404,22 @@ PRP_SIMAN_LOCAL_CHECK_IN モジュールにチェックイン + + DISCONNECT_CAPTION + Disconnect active study + + + DISCONNECT_DESCRIPTION + Do you want to save study before disconnect? + + + DISCONNECT_SAVE + &Save && Disconnect + + + DISCONNECT_WO_SAVE + &Disconnect w/o saving + SalomeApp_StudyPropertiesDlg