X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ShowHideOp.cxx;h=7dc0a007e2dad3e5669444e131c7ebdc4ef0f892;hb=HEAD;hp=90a1c4d1cd98cdcf2e25b1c6d07e104a151b0a9a;hpb=1abcf8de100d14016ab483553c2d3c0f2d706daf;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx index 90a1c4d1..7dc0a007 100644 --- a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,8 +21,9 @@ #include #include "HYDROGUI_Module.h" +#include "HYDROGUI_OCCDisplayer.h" #include "HYDROGUI_Operations.h" -#include "HYDROGUI_Tool.h" +#include "HYDROGUI_Tool2.h" #include "HYDROGUI_UpdateFlags.h" #include @@ -34,16 +31,23 @@ #include #include +#include #include +#include + #include #include +//#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + HYDROGUI_ShowHideOp::HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId ) : HYDROGUI_Operation( theModule ), myId( theId ) { + DEBTRACE("HYDROGUI_ShowHideOp " << theId); QString aName; switch( myId ) { @@ -63,26 +67,19 @@ HYDROGUI_ShowHideOp::~HYDROGUI_ShowHideOp() void HYDROGUI_ShowHideOp::startOperation() { + DEBTRACE("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 +89,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,10 +97,28 @@ 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 ) + LightApp_Displayer().EraseAll( true ); + } + + 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; @@ -111,7 +127,10 @@ void HYDROGUI_ShowHideOp::startOperation() anObject = aSeq.Value( anIndex ); if( !anObject.IsNull() ) { - module()->setObjectVisible( aViewId, anObject, 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 ); @@ -123,24 +142,28 @@ void HYDROGUI_ShowHideOp::startOperation() anObject = aZonesSeq.Value( aZoneIdx ); if( !anObject.IsNull() ) { - module()->setObjectVisible( aViewId, anObject, aVisibility ); + aModule->setObjectVisible( aViewId, anObject, aVisibility ); } } } } else if ( anObject->GetKind() == KIND_BATHYMETRY && aVisibility ) { - if ( !(anUpdateFlags & UF_VTKViewer) ) + if ( anUpdateFlags & UF_OCCViewer ) + { + aModule->setObjectVisible( aViewId, anObject, aVisibility ); + } + else 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 ); } } } @@ -150,7 +173,8 @@ void HYDROGUI_ShowHideOp::startOperation() if ( myId == ShowOnlyId || myId == ShowId || myId == ShowAllId ) { - //anUpdateFlags |= UF_FitAll; + if( isFoundImage || myId == ShowAllId ) + anUpdateFlags |= UF_FitAll; } // Set VTK viewer active if show a bathymetry @@ -160,6 +184,6 @@ void HYDROGUI_ShowHideOp::startOperation() aVTKMgr->setShown( true ); } - module()->update( anUpdateFlags ); + aModule->update( anUpdateFlags ); commit(); }