X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ShowHideOp.cxx;h=4dba86de8bea240269a8c7c8135c6f9e89253be6;hb=a300fde9adcb04f1d57269c2849e7337a6d3d4a3;hp=8d91cde4c7a2d83114bc3f7be737fb569bce298d;hpb=35a75ba275261aff7c8c48c0d16842dafd455007;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx index 8d91cde4..4dba86de 100644 --- a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx @@ -22,13 +22,26 @@ #include "HYDROGUI_ShowHideOp.h" +#include + #include "HYDROGUI_Module.h" #include "HYDROGUI_Operations.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" #include -#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include HYDROGUI_ShowHideOp::HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId ) : HYDROGUI_Operation( theModule ), @@ -55,9 +68,32 @@ void HYDROGUI_ShowHideOp::startOperation() { HYDROGUI_Operation::startOperation(); - startDocOperation(); + HYDROGUI_Module* aModule = module(); + + size_t aViewId = HYDROGUI_Tool::GetActiveViewId( aModule ); - size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() ); + int anUpdateFlags = 0; + + SUIT_ViewManager* aVTKMgr = NULL; + OCCViewer_ViewManager* anOCCManager = NULL; + + SUIT_ViewManager* aViewMgr = aModule->getApp()->activeViewManager(); + if ( aViewMgr ) + { + if ( aViewMgr->getType() == GraphicsView_Viewer::Type() ) + { + anUpdateFlags |= UF_Viewer; + } + else if ( aViewMgr->getType() == OCCViewer_Viewer::Type() ) + { + anUpdateFlags |= UF_OCCViewer; + anOCCManager = ::qobject_cast( aViewMgr ); + } + else if ( aViewMgr->getType() == SVTK_Viewer::Type() ) + { + anUpdateFlags |= UF_VTKViewer; + } + } // for all objects if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId ) @@ -66,28 +102,86 @@ void HYDROGUI_ShowHideOp::startOperation() HYDROData_Iterator anIterator( doc() ); for( ; anIterator.More(); anIterator.Next() ) { - Handle(HYDROData_Object) anObject = anIterator.Current(); + Handle(HYDROData_Entity) anObject = anIterator.Current(); if( !anObject.IsNull() ) - anObject->SetVisible( aViewId, aVisibility ); + aModule->setObjectVisible( aViewId, anObject, aVisibility ); } + + // For occ viewer we do the additional step to hide objects from other modules + if ( anOCCManager != NULL && !aVisibility ) + LightApp_Displayer().EraseAll( true ); } + bool isFoundImage = false; // for selected objects if( myId == ShowId || myId == ShowOnlyId || myId == HideId ) { - HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() ); - - bool aVisibility = myId == ShowId || myId == ShowOnlyId; + HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( aModule ); + + bool aVisibility = myId == ShowId || myId == ShowOnlyId || myId == ShowAllId; + Handle( HYDROData_Entity ) anObject; for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) { - Handle(HYDROData_Object) anObject = aSeq.Value( anIndex ); + anObject = aSeq.Value( anIndex ); if( !anObject.IsNull() ) - anObject->SetVisible( aViewId, aVisibility ); + { + if ( anObject->GetKind() == KIND_IMAGE ) + isFoundImage = true; + + aModule->setObjectVisible( aViewId, anObject, aVisibility ); + if ( anObject->GetKind() == KIND_REGION ) + { + Handle( HYDROData_Region ) aRegion = Handle( HYDROData_Region )::DownCast( anObject ); + if ( !aRegion.IsNull() ) + { + HYDROData_SequenceOfObjects aZonesSeq = aRegion->GetZones(); + for( Standard_Integer aZoneIdx = 1, aNbZones = aZonesSeq.Length(); aZoneIdx <= aNbZones; aZoneIdx++ ) + { + anObject = aZonesSeq.Value( aZoneIdx ); + if( !anObject.IsNull() ) + { + aModule->setObjectVisible( aViewId, anObject, aVisibility ); + } + } + } + } + else if ( anObject->GetKind() == KIND_BATHYMETRY && aVisibility ) + { + if ( anUpdateFlags & UF_OCCViewer ) + { + aModule->setObjectVisible( aViewId, anObject, aVisibility ); + } + else if ( !(anUpdateFlags & UF_VTKViewer) ) + { + // Activate VTK viewer if show a bathymetry + aVTKMgr = aModule->getApp()->viewManager( SVTK_Viewer::Type() ); + if ( !aVTKMgr ) + { + aVTKMgr = aModule->getApp()->createViewManager( SVTK_Viewer::Type() ); + } + if ( aVTKMgr ) + { + aModule->setObjectVisible( (size_t)aVTKMgr->getViewModel(), anObject, aVisibility ); + } + } + } + } } } - commitDocOperation(); + if ( myId == ShowOnlyId || myId == ShowId || myId == ShowAllId ) + { + if( isFoundImage || myId == ShowAllId ) + anUpdateFlags |= UF_FitAll; + } + + // Set VTK viewer active if show a bathymetry + if ( aVTKMgr ) + { + anUpdateFlags |= UF_VTKViewer; + aVTKMgr->setShown( true ); + } - module()->update( UF_Viewer ); + aModule->update( anUpdateFlags ); commit(); }