From 2bfa5c7a86b2968c2648650ba54cd082caa80f96 Mon Sep 17 00:00:00 2001 From: adv Date: Thu, 30 Jan 2014 11:33:40 +0000 Subject: [PATCH] Hide objects from other modules if hide all requested (Bug #355). --- src/HYDROGUI/HYDROGUI_ShowHideOp.cxx | 68 +++++++++++++++++++--------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx index 6ff79894..05f5fb25 100644 --- a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx @@ -34,8 +34,11 @@ #include #include +#include #include +#include + #include #include @@ -65,24 +68,16 @@ void HYDROGUI_ShowHideOp::startOperation() { HYDROGUI_Operation::startOperation(); - size_t aViewId = HYDROGUI_Tool::GetActiveViewId( module() ); + HYDROGUI_Module* aModule = module(); - // for all objects - if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId ) - { - bool aVisibility = myId == ShowAllId; - HYDROData_Iterator anIterator( doc() ); - for( ; anIterator.More(); anIterator.Next() ) - { - Handle(HYDROData_Entity) anObject = anIterator.Current(); - if( !anObject.IsNull() ) - module()->setObjectVisible( aViewId, anObject, aVisibility ); - } - } + size_t aViewId = HYDROGUI_Tool::GetActiveViewId( aModule ); int anUpdateFlags = 0; - SUIT_ViewManager* aVTKMgr = 0; - SUIT_ViewManager* aViewMgr = module()->getApp()->activeViewManager(); + + SUIT_ViewManager* aVTKMgr = NULL; + OCCViewer_ViewManager* anOCCManager = NULL; + + SUIT_ViewManager* aViewMgr = aModule->getApp()->activeViewManager(); if ( aViewMgr ) { if ( aViewMgr->getType() == GraphicsView_Viewer::Type() ) @@ -92,6 +87,7 @@ void HYDROGUI_ShowHideOp::startOperation() else if ( aViewMgr->getType() == OCCViewer_Viewer::Type() ) { anUpdateFlags |= UF_OCCViewer; + anOCCManager = ::qobject_cast( aViewMgr ); } else if ( aViewMgr->getType() == SVTK_Viewer::Type() ) { @@ -99,11 +95,39 @@ void HYDROGUI_ShowHideOp::startOperation() } } + // for all objects + if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId ) + { + bool aVisibility = myId == ShowAllId; + HYDROData_Iterator anIterator( doc() ); + for( ; anIterator.More(); anIterator.Next() ) + { + Handle(HYDROData_Entity) anObject = anIterator.Current(); + if( !anObject.IsNull() ) + aModule->setObjectVisible( aViewId, anObject, aVisibility ); + } + + // For occ viewer we do the additional step to hide objects from other modules + if ( anOCCManager != NULL && !aVisibility ) + { + if ( SUIT_ViewModel* vmod = anOCCManager->getViewModel() ) + { + SALOME_View* vf = dynamic_cast( vmod ); + if ( vf ) + vf->EraseAll( true ); + } + + LightApp_Study* aStudy = dynamic_cast( aModule->getApp()->activeStudy() ); + if ( aStudy ) + aStudy->setVisibilityStateForAll( Qtx::HiddenState ); + } + } + bool isFoundImage = false; // for selected objects if( myId == ShowId || myId == ShowOnlyId || myId == HideId ) { - HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() ); + HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( aModule ); bool aVisibility = myId == ShowId || myId == ShowOnlyId || myId == ShowAllId; Handle( HYDROData_Entity ) anObject; @@ -115,7 +139,7 @@ void HYDROGUI_ShowHideOp::startOperation() if ( anObject->GetKind() == KIND_IMAGE ) isFoundImage = true; - module()->setObjectVisible( aViewId, anObject, aVisibility ); + aModule->setObjectVisible( aViewId, anObject, aVisibility ); if ( anObject->GetKind() == KIND_REGION ) { Handle( HYDROData_Region ) aRegion = Handle( HYDROData_Region )::DownCast( anObject ); @@ -127,7 +151,7 @@ void HYDROGUI_ShowHideOp::startOperation() anObject = aZonesSeq.Value( aZoneIdx ); if( !anObject.IsNull() ) { - module()->setObjectVisible( aViewId, anObject, aVisibility ); + aModule->setObjectVisible( aViewId, anObject, aVisibility ); } } } @@ -137,14 +161,14 @@ void HYDROGUI_ShowHideOp::startOperation() if ( !(anUpdateFlags & UF_VTKViewer) ) { // Activate VTK viewer if show a bathymetry - aVTKMgr = module()->getApp()->viewManager( SVTK_Viewer::Type() ); + aVTKMgr = aModule->getApp()->viewManager( SVTK_Viewer::Type() ); if ( !aVTKMgr ) { - aVTKMgr = module()->getApp()->createViewManager( SVTK_Viewer::Type() ); + aVTKMgr = aModule->getApp()->createViewManager( SVTK_Viewer::Type() ); } if ( aVTKMgr ) { - module()->setObjectVisible( (size_t)aVTKMgr->getViewModel(), anObject, aVisibility ); + aModule->setObjectVisible( (size_t)aVTKMgr->getViewModel(), anObject, aVisibility ); } } } @@ -165,6 +189,6 @@ void HYDROGUI_ShowHideOp::startOperation() aVTKMgr->setShown( true ); } - module()->update( anUpdateFlags ); + aModule->update( anUpdateFlags ); commit(); } -- 2.39.2