Salome HOME
introduction of penta18 in VTK viewer
[modules/gui.git] / src / VTKViewer / VTKViewer_InteractorStyle.cxx
index 1553a2e0f7da78ac66d394990a959f54dbc593f8..53221dd592c555c6cec874e0cec2ab9c3505e375 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  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
@@ -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,