From: apo Date: Mon, 15 Aug 2005 10:58:24 +0000 (+0000) Subject: To customize GAUSS Viewer X-Git-Tag: BR-D5-38-2003_D2005-12-09~118 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c96c837f768c7cebb6cfb4da1b2a3d6f7e5487cb;p=modules%2Fvisu.git To customize GAUSS Viewer Segmentation task --- diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 87601014..ed3d2792 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -40,7 +40,7 @@ EXPORT_HEADERS= \ # .po files to transform in .qm PO_FILES = \ - VISU_msg_en.po VISU_images.po + VISU_msg_en.po VISU_images.po VISUM_msg_en.po # Libraries targets LIB = libVISU.la diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po new file mode 100644 index 00000000..a4c4a6c4 --- /dev/null +++ b/src/VISUGUI/VISUM_msg_en.po @@ -0,0 +1,13 @@ +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-02-22 16:56:46 CET\n" +"PO-Revision-Date: 2005-06-27 12:38+0400\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +msgid "VisuGUI_Module::MEN_GAUSS" +msgstr "Gauss" + +msgid "VisuGUI_Module::MEN_NEW_VIEWER" +msgstr "New Viewer" diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 10252c3b..830df45f 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -31,69 +31,149 @@ #include "SUIT_Study.h" #include "SUIT_Desktop.h" +#include "CAM_Module.h" + #include "SalomeApp_Application.h" +#include "SalomeApp_SelectionMgr.h" #include "SalomeApp_VTKSelector.h" -#include "CAM_Module.h" #include "SVTK_ViewManager.h" #include "SVTK_ViewModel.h" -//using namespace VISU; - #ifdef _DEBUG_ static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif -VisuGUI_Module::VisuGUI_Module() : VisuGUI() +#define GAUSS_NEW_VIEWER 5100 + +using namespace VISU; + +namespace VISU +{ + //--------------------------------------------------------------- + class Viewer + { + SVTK_ViewManager* myViewManager; + SalomeApp_VTKSelector* mySelector; + public: + + Viewer(SalomeApp_Application* theApp, TViewerMap& theViewerMap) + { + myViewManager = new SVTK_ViewManager( theApp->activeStudy(), theApp->desktop() ); + SVTK_Viewer* aViewer = (SVTK_Viewer*)myViewManager->getViewModel(); + mySelector = new SalomeApp_VTKSelector( aViewer, theApp->selectionMgr() ); + theApp->addViewManager( myViewManager ); + theViewerMap.insert(TViewerMap::value_type(myViewManager,PViewer(this))); + + //aViewer->setBackgroundColor( Qt::darkGreen ); + myViewManager->createViewWindow(); + } + + virtual + ~Viewer() + { + } + }; + + + //--------------------------------------------------------------- + typedef void (SUIT_ViewWindow::* TViewVisibility)(); + void + SetViewVisibility(const TViewerMap& theViewerMap, + TViewVisibility theViewVisibility) + { + TViewerMap::const_iterator anIter = theViewerMap.begin(); + for(; anIter != theViewerMap.end(); anIter++){ + if(SUIT_ViewManager* aViewManager = anIter->first){ + QPtrVector aViews = aViewManager->getViews(); + int aSize = aViews.size(); + for(int anId = 0; anId < aSize; anId++){ + if(SUIT_ViewWindow* aView = aViews[anId]){ + (aView->* theViewVisibility)(); + } + } + } + } + } + +} + +//--------------------------------------------------------------- +VisuGUI_Module +::VisuGUI_Module() : + VisuGUI() { } -VisuGUI_Module::~VisuGUI_Module() +//--------------------------------------------------------------- +VisuGUI_Module +::~VisuGUI_Module() { } + +//--------------------------------------------------------------- void -VisuGUI_Module:: -initialize( CAM_Application* theApp ) +VisuGUI_Module +::initialize( CAM_Application* theApp ) { VisuGUI::initialize( theApp ); - myViewManager = new SVTK_ViewManager( getApp()->activeStudy(), getApp()->desktop() ); - - SVTK_Viewer* aViewer = new SVTK_Viewer(); - myViewManager->setViewModel( aViewer ); - - myViewManager->createViewWindow(); - myViewManager->getActiveView()->hide(); - - //aViewer->setBackgroundColor( Qt::darkGreen ); - - new SalomeApp_VTKSelector( aViewer, ( SUIT_SelectionMgr* )getApp()->selectionMgr() ); + onCreateViewManager(); - theApp->addViewManager( myViewManager ); + // Add menus + int aMenuId; + aMenuId = createMenu( tr( "MEN_GAUSS" ), -1, -1, 30 ); + createAction( GAUSS_NEW_VIEWER, tr("MEN_NEW_VIEWER"), QIconSet(), + tr("MEN_NEW_VIEWER"), "", 0, this, false, + this, SLOT(onCreateViewManager())); + createMenu( GAUSS_NEW_VIEWER, aMenuId, 10 ); // new viewer } + +//--------------------------------------------------------------- bool -VisuGUI_Module:: -activateModule( SUIT_Study* theStudy ) +VisuGUI_Module +::activateModule( SUIT_Study* theStudy ) { VisuGUI::activateModule( theStudy ); - myViewManager->getActiveView()->show(); + SetViewVisibility(myViewerMap,&SUIT_ViewWindow::show); return true; } + +//--------------------------------------------------------------- bool -VisuGUI_Module:: -deactivateModule( SUIT_Study* theStudy ) +VisuGUI_Module +::deactivateModule( SUIT_Study* theStudy ) { VisuGUI::deactivateModule( theStudy ); - myViewManager->getActiveView()->hide(); + SetViewVisibility(myViewerMap,&SUIT_ViewWindow::hide); return true; } + + +//--------------------------------------------------------------- +void +VisuGUI_Module +::onCreateViewManager() +{ + new Viewer(getApp(),myViewerMap); +} + + +//--------------------------------------------------------------- +void +VisuGUI_Module +::onLastViewClosed(SUIT_ViewManager* theViewManager) +{ + myViewerMap.erase(theViewManager); +} + diff --git a/src/VISUGUI/VisuGUI_Module.h b/src/VISUGUI/VisuGUI_Module.h index 02df1622..9eb309b0 100644 --- a/src/VISUGUI/VisuGUI_Module.h +++ b/src/VISUGUI/VisuGUI_Module.h @@ -30,25 +30,54 @@ #define VisuGUI_Module_HeaderFile #include "VisuGUI.h" +#include "STD_Application.h" +class SUIT_ViewManager; class SVTK_ViewManager; +#include "MED_SharedPtr.hxx" + +namespace VISU +{ + class Viewer; + typedef MED::SharedPtr PViewer; + + typedef std::map TViewerMap; +} + + class VisuGUI_Module: public VisuGUI { - Q_OBJECT + Q_OBJECT; public: VisuGUI_Module(); - virtual ~VisuGUI_Module(); - virtual void initialize( CAM_Application* ); + virtual + ~VisuGUI_Module(); + + virtual + void + initialize( CAM_Application* ); public slots: - virtual bool deactivateModule( SUIT_Study* ); - virtual bool activateModule( SUIT_Study* ); + virtual + bool + deactivateModule( SUIT_Study* ); + + virtual + bool + activateModule( SUIT_Study* ); + +protected slots: + void + onCreateViewManager(); + + void + onLastViewClosed(SUIT_ViewManager*); protected: - SVTK_ViewManager* myViewManager; + VISU::TViewerMap myViewerMap; }; #endif