X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ShowHideOp.cxx;h=6ff798943be9ba6eb0bf539e0169ac2ac717d6f2;hb=3ee052316eb0a4857a0241a22275528191ce3687;hp=47e0a2b6e2362b06018c3b06ca51e5eeed6f6ced;hpb=94f079c9197f9655e023e5047feffea452b4a1fe;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx index 47e0a2b6..6ff79894 100644 --- a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx @@ -22,17 +22,23 @@ #include "HYDROGUI_ShowHideOp.h" -#include "HYDROGUI_DataModel.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 ), @@ -59,7 +65,7 @@ void HYDROGUI_ShowHideOp::startOperation() { HYDROGUI_Operation::startOperation(); - HYDROGUI_DataModel* aModel = module()->getDataModel(); + size_t aViewId = HYDROGUI_Tool::GetActiveViewId( module() ); // for all objects if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId ) @@ -68,31 +74,97 @@ 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->SetVisibility( aVisibility ); + module()->setObjectVisible( aViewId, anObject, aVisibility ); + } + } + + int anUpdateFlags = 0; + SUIT_ViewManager* aVTKMgr = 0; + SUIT_ViewManager* aViewMgr = module()->getApp()->activeViewManager(); + if ( aViewMgr ) + { + if ( aViewMgr->getType() == GraphicsView_Viewer::Type() ) + { + anUpdateFlags |= UF_Viewer; + } + else if ( aViewMgr->getType() == OCCViewer_Viewer::Type() ) + { + anUpdateFlags |= UF_OCCViewer; + } + else if ( aViewMgr->getType() == SVTK_Viewer::Type() ) + { + anUpdateFlags |= UF_VTKViewer; } } + bool isFoundImage = false; // for selected objects if( myId == ShowId || myId == ShowOnlyId || myId == HideId ) { - SUIT_SelectionMgr* aSelectionMgr = selectionMgr(); - SUIT_DataOwnerPtrList anOwners; - aSelectionMgr->selected( anOwners ); - - bool aVisibility = myId == ShowId || myId == ShowOnlyId; - foreach( SUIT_DataOwner* aSUITOwner, anOwners ) + HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() ); + + bool aVisibility = myId == ShowId || myId == ShowOnlyId || myId == ShowAllId; + Handle( HYDROData_Entity ) anObject; + for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) { - if( LightApp_DataOwner* anOwner = dynamic_cast( aSUITOwner ) ) + anObject = aSeq.Value( anIndex ); + if( !anObject.IsNull() ) { - Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() ); - if( !anObject.IsNull() ) - anObject->SetVisibility( aVisibility ? true : false ); + if ( anObject->GetKind() == KIND_IMAGE ) + isFoundImage = true; + + module()->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() ) + { + module()->setObjectVisible( aViewId, anObject, aVisibility ); + } + } + } + } + else if ( anObject->GetKind() == KIND_BATHYMETRY && aVisibility ) + { + if ( !(anUpdateFlags & UF_VTKViewer) ) + { + // Activate VTK viewer if show a bathymetry + aVTKMgr = module()->getApp()->viewManager( SVTK_Viewer::Type() ); + if ( !aVTKMgr ) + { + aVTKMgr = module()->getApp()->createViewManager( SVTK_Viewer::Type() ); + } + if ( aVTKMgr ) + { + module()->setObjectVisible( (size_t)aVTKMgr->getViewModel(), anObject, aVisibility ); + } + } + } } } } - module()->update( UF_Viewer ); + 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( anUpdateFlags ); commit(); }