From 8424ccff029419ec00b380e1a33b40ea70102bee Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 14 Dec 2009 16:53:51 +0000 Subject: [PATCH] Phase 17 notebook imp: show Notebook item with own popup in the object browser --- src/LightApp/LightApp_Module.cxx | 10 +++++++++ src/LightApp/LightApp_Module.h | 5 +++++ src/SalomeApp/SalomeApp_Application.cxx | 25 +++++++++++++++++++++ src/SalomeApp/resources/SalomeApp_msg_en.ts | 4 ++++ 4 files changed, 44 insertions(+) diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 5ebe69044..c2d5b0121 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -200,6 +200,16 @@ bool LightApp_Module::isSelectionCompatible() return isCompatible; } +QList LightApp_Module::displayActions() const +{ + QList res; + if ( action( myDisplay ) ) res << action( myDisplay ); + if ( action( myErase ) ) res << action( myErase ); + if ( action( myDisplayOnly ) ) res << action( myDisplayOnly ); + if ( action( myEraseAll ) ) res << action( myEraseAll ); + return res; +} + /*!Activate module.*/ bool LightApp_Module::activateModule( SUIT_Study* study ) { diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index 88ed1b44e..6aec90653 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -30,6 +30,8 @@ #include "LightApp_Preferences.h" #include +#include + class LightApp_Application; class LightApp_Selection; class LightApp_Operation; @@ -45,6 +47,7 @@ class CAM_Application; class QtxPopupMgr; +class QAction; class QString; class QVariant; @@ -91,6 +94,8 @@ public: virtual LightApp_Displayer* displayer(); virtual LightApp_Selection* createSelection() const; + + QList displayActions() const; public slots: virtual bool activateModule( SUIT_Study* ); diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 71f9c3fd9..c43f37ea4 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include @@ -1181,14 +1182,34 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePop // "Activate module" item should appear only if it's necessary if (aList.Extent() != 1) return; + Handle(SALOME_InteractiveObject) aIObj = aList.First(); + // check if item is a "GUI state" item (also a first level object) QString entry( aIObj->getEntry() ); if ( entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) return; + QString aModuleName(aIObj->getComponentDataType()); QString aModuleTitle = moduleTitle(aModuleName); CAM_Module* currentModule = activeModule(); + + // check if it a "Notebook" item + if ( aModuleName == "NOTEBOOK" ) { + if ( currentModule ) { + LightApp_Module* lightModule = dynamic_cast( currentModule ); + if ( lightModule ) { + QList displayActions = lightModule->displayActions(); + QAction* a; + foreach( a, displayActions ) thePopup->removeAction( a ); + } + } + thePopup->insertSeparator( thePopup->actions()[0] ); + QAction* nbAction = new QAction( tr( "MEN_SHOW_NOTEBOOK" ), thePopup ); + connect( nbAction, SIGNAL( activated() ), this, SLOT( onNoteBook() ) ); + thePopup->insertAction( thePopup->actions()[0], nbAction ); + } + if (currentModule && currentModule->moduleName() == aModuleTitle) return; if ( !aModuleTitle.isEmpty() ) @@ -1350,6 +1371,8 @@ void SalomeApp_Application::onStudyCreated( SUIT_Study* study ) { LightApp_Application::onStudyCreated( study ); + updateObjectBrowser( true ); + objectBrowserColumnsVisibility(); } @@ -1370,6 +1393,8 @@ void SalomeApp_Application::onStudyOpened( SUIT_Study* study ) { LightApp_Application::onStudyOpened( study ); + updateObjectBrowser( true ); + objectBrowserColumnsVisibility(); // temporary commented diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index 1971b2a3b..27da359bb 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -118,6 +118,10 @@ Do you want to define them by the notebook? APPCLOSE_CLOSE &Close w/o saving + + MEN_SHOW_NOTEBOOK + Edit variables + MEN_WINDOWS_NEW New Window -- 2.39.2