X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVTKViewer%2FVTKViewer_InteractorStyle.cxx;h=53221dd592c555c6cec874e0cec2ab9c3505e375;hb=0f9dfaa83b994c9d7fdd893f418395fad145f388;hp=f1eee7c6951f63c865cb8fa4452af274a726b03b;hpb=af07426a4bcf27234daf56881653080f64c4936e;p=modules%2Fgui.git diff --git a/src/VTKViewer/VTKViewer_InteractorStyle.cxx b/src/VTKViewer/VTKViewer_InteractorStyle.cxx index f1eee7c69..53221dd59 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyle.cxx +++ b/src/VTKViewer/VTKViewer_InteractorStyle.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -6,7 +6,7 @@ // 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 @@ -628,6 +628,28 @@ void VTKViewer_InteractorStyle::ViewFitAll() { ::ResetCameraClippingRange(CurrentRenderer); } +/*!View fit selection.*/ +void VTKViewer_InteractorStyle::ViewFitSelection() { + + vtkActorCollection* aSelectedCollection = vtkActorCollection::New(); + + VTK::ActorCollectionCopy aCopy( CurrentRenderer->GetActors() ); + vtkActorCollection* aCollection = aCopy.GetActors(); + aCollection->InitTraversal(); + while ( vtkActor* aProp = aCollection->GetNextActor() ) + if ( VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast( aProp ) ) + if ( anActor->isPreselected() ) + aSelectedCollection->AddItem( aProp ); + + double bounds[6]; + ::ComputeBounds( aSelectedCollection, bounds ); + + if ( aSelectedCollection->GetNumberOfItems() && ::isBoundValid( bounds ) ) { + CurrentRenderer->ResetCamera( bounds ); + CurrentRenderer->ResetCameraClippingRange( bounds ); + } +} + /*! starts Global Panning operation (e.g. through menu command)*/ void VTKViewer_InteractorStyle::startGlobalPan() @@ -652,7 +674,7 @@ void VTKViewer_InteractorStyle::startGlobalPan() } -/*!\retval TRUE if needs redrawing*/ +/*!\retval \c true if needs redrawing*/ bool VTKViewer_InteractorStyle::needsRedrawing() { return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM || @@ -1460,7 +1482,7 @@ void VTKViewer_InteractorStyle::RemoveFilter( const int theId ) /*!Checks: is valid cell(node) with id \a theId in actor \a theActor. *\param theActor - VTKViewer_Actor pointer. *\param theId - cell id. - *\param theIsNode - boolean flag, if true - node, else - cell. + *\param theIsNode - boolean flag, if \c true - node, else - cell. */ bool VTKViewer_InteractorStyle::IsValid( VTKViewer_Actor* theActor, const int theId,