From 6bcf3162164b54925142cd53bf93df3dc856f721 Mon Sep 17 00:00:00 2001 From: mzn Date: Tue, 10 Dec 2013 09:43:35 +0000 Subject: [PATCH] Issues ##68, 88: Swith between GEOM and HYDRO. --- src/HYDROGUI/HYDROGUI_Module.cxx | 40 ++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 3c7a5e59..7244bab7 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -153,6 +153,38 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) ); #endif + // Remove defunct view managers from the map. + // It's essential to do this before "update( UF_All )" call! + QList anObsoleteIds; + ViewManagerList anAllViewManagers = anApp->viewManagers(); + ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module + ViewManagerMapIterator anIter( myViewManagerMap ); + while( anIter.hasNext() ) { + int anId = anIter.next().key(); + const ViewManagerInfo& anInfo = anIter.value(); + + aHydroViewManagers << anInfo.first; + + if ( !anAllViewManagers.contains( anInfo.first ) ) { + anObsoleteIds << anId; + } + } + foreach ( const int anId, anObsoleteIds ) { + myViewManagerMap.remove( anId ); + myObjectStateMap.remove( anId ); + myShapesMap.remove( anId ); + myVTKPrsMap.remove( anId ); + } + // Replace the default selector for all view managers. + // Add view managers created outside of HYDRO module to the map. + foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) { + createSelector( aViewManager ); // replace the default selector + if ( !aHydroViewManagers.contains( aViewManager ) ) { + ViewManagerInfo anInfo( aViewManager, VMR_General ); + myViewManagerMap.insert( ViewManagerId++, anInfo ); + } + } + update( UF_All ); updateCommandsStatus(); @@ -180,11 +212,13 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy ) { + /* Issues ## 68, 88. ViewManagerMapIterator anIter( myViewManagerMap ); while( anIter.hasNext() ) if( SUIT_ViewManager* aViewManager = anIter.next().value().first ) getApp()->removeViewManager( aViewManager ); myViewManagerMap.clear(); + */ ViewManagerList anOCCViewManagers; getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers ); @@ -193,9 +227,11 @@ bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy ) this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); } + /* Issues ## 68, 88. myObjectStateMap.clear(); myShapesMap.clear(); myVTKPrsMap.clear(); + */ // clear the data model's list of copying objects HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() ); @@ -225,7 +261,7 @@ void HYDROGUI_Module::windows( QMap& theMap ) const void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const { - theTypesList << OCCViewer_Viewer::Type() << GraphicsView_Viewer::Type(); + theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type(); } void HYDROGUI_Module::contextMenuPopup( const QString& theClient, @@ -272,7 +308,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsGeomObject = false; // check the selected GEOM objects - if ( !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) { + if ( anIsObjectBrowser && !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) { theMenu->addAction( action( ImportGeomObjectId ) ); theMenu->addSeparator(); } -- 2.39.2