]> Creatis software - clitk.git/blobdiff - vv/vvSlicerManagerCommand.cxx
Use Tab key for next and previous image
[clitk.git] / vv / vvSlicerManagerCommand.cxx
index 80f6d514ead0428ab80f82d086be67feaff18688..37d78e6a066090bdecfdeefbde1c08d9cf16346c 100644 (file)
@@ -1,41 +1,35 @@
 /*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
-Program:   vv
-Language:  C++
-Author :   Pierre Seroul (pierre.seroul@gmail.com)
+  Authors belong to: 
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
-Copyright (C) 2008
-Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
-CREATIS-LRMN http://www.creatis.insa-lyon.fr
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
 
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
+  It is distributed under dual licence
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-=========================================================================*/
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+======================================================================-====*/
 #include "vvSlicerManagerCommand.h"
 #include "vvSlicerManager.h"
 
-#include "vtkTextProperty.h"
-#include "vtkRenderer.h"
-#include "vtkImageActor.h"
-#include "vtkRenderWindowInteractor.h"
-#include "vtkPropPicker.h"
-#include "vtkCamera.h"
-#include "vtkImageMapToWindowLevelColors.h"
-#include "vtkLookupTable.h"
-#include "vtkMath.h"
-#include "vtkAbstractPropPicker.h"
-#include "vtkAssemblyPath.h"
-#include "vtkCornerAnnotation.h"
+#include <vtkTextProperty.h>
+#include <vtkRenderer.h>
+#include <vtkImageActor.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkPropPicker.h>
+#include <vtkCamera.h>
+#include <vtkImageMapToWindowLevelColors.h>
+#include <vtkLookupTable.h>
+#include <vtkMath.h>
+#include <vtkAbstractPropPicker.h>
+#include <vtkAssemblyPath.h>
+#include <vtkCornerAnnotation.h>
 #include <vtkRenderWindow.h>
 
 #include "vvSlicer.h"
@@ -69,8 +63,8 @@ int vvSlicerManagerCommand::FindSlicerNumber(vtkRenderWindow* renwin)
 
 //------------------------------------------------------------------------------
 void vvSlicerManagerCommand::Execute(vtkObject *caller,
-        unsigned long event,
-        void *vtkNotUsed(callData))
+                                     unsigned long event,
+                                     void *vtkNotUsed(callData))
 {
     //KeyPress event
     vvInteractorStyleNavigator *isi =
@@ -83,7 +77,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
 
         int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
         vtkRenderer* renderer=NULL;
-        if (VisibleInWindow>-1) 
+        if (VisibleInWindow>-1)
             renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
         newLandmark = false;
 
@@ -103,10 +97,24 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
             if (event == vtkCommand::KeyPressEvent)
             {
                 std::string KeyPress = isi->GetInteractor()->GetKeySym();
+                if (KeyPress == "Tab")
+                {
+                    if(isi->GetInteractor()->GetShiftKey())
+                        this->SM->PrevImage(VisibleInWindow);
+                    else
+                        this->SM->NextImage(VisibleInWindow);
+                    return;
+                }
                 if (KeyPress == "f" || KeyPress == "F")
                 {
                     FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
+                  return;
                 }
+               if (KeyPress == "z")
+               {
+                   this->SM->SetLocalColorWindowing(VisibleInWindow);
+                  return;
+               }
                 if (KeyPress == "0")
                 {
                     this->SM->SetPreset(0);
@@ -177,7 +185,6 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
                 }
                 if (KeyPress == "minus")
                 {
-                    std::cout << "KeyPress : - " << std::endl;
                     this->SM->SetColorWindow(-this->SM->GetColorWindow());
                     this->SM->SetColorMap(-1);
                     this->SM->UpdateWindowLevel();
@@ -257,7 +264,6 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
 
                 if (KeyPress == "F1")
                 {
-                    //std::cerr << this << ":" << this->SM->GetId() << "\t" << VisibleInWindow << endl;
                     this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
                     this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
                     this->SM->UpdateSliceRange(VisibleInWindow);
@@ -374,7 +380,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
             if (newLandmark)
             {
                 this->SM->AddLandmark(xWorld,yWorld,zWorld,
-                        this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+                                      this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
                 this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
                 this->SM->Render();
             }
@@ -405,9 +411,9 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
 
             // Compute normalized delta
             double dx = static_cast<double>(isi->GetWindowLevelCurrentPosition()[0] -
-                    isi->GetWindowLevelStartPosition()[0]) / size[0];
+                                            isi->GetWindowLevelStartPosition()[0]) / size[0];
             double dy = static_cast<double>(isi->GetWindowLevelStartPosition()[1] -
-                    isi->GetWindowLevelCurrentPosition()[1]) / size[1];
+                                            isi->GetWindowLevelCurrentPosition()[1]) / size[1];
             //Window is exponential in nature, use exponential to avoid falling into negative numbers
             dx = std::exp(1.0 * (dx*fabs(dx) + dx)) ; //Quadratic behavior for more reactive interface
             dy = 0.15 * (dy*fabs(dy) + dy) * (range[1]-range[0]);//Quadratic behavior for more reactive interface
@@ -429,7 +435,7 @@ void vvSlicerManagerCommand::Dolly(double factor, vtkRenderWindowInteractor *int
 {
     int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
     vtkRenderer* renderer;
-    if (VisibleInWindow>-1) 
+    if (VisibleInWindow>-1)
         renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
     else
     {
@@ -479,12 +485,12 @@ void vvSlicerManagerCommand::Dolly(double factor, vtkRenderWindowInteractor *int
     camera->GetFocalPoint(viewFocus);
     camera->GetPosition(viewPoint);
     camera->SetFocalPoint(motionVector[0] + viewFocus[0],
-            motionVector[1] + viewFocus[1],
-            motionVector[2] + viewFocus[2]);
+                          motionVector[1] + viewFocus[1],
+                          motionVector[2] + viewFocus[2]);
 
     camera->SetPosition(motionVector[0] + viewPoint[0],
-            motionVector[1] + viewPoint[1],
-            motionVector[2] + viewPoint[2]);
+                        motionVector[1] + viewPoint[1],
+                        motionVector[2] + viewPoint[2]);
 
     if (camera->GetParallelProjection())
     {
@@ -510,14 +516,14 @@ void vvSlicerManagerCommand::FlyToPosition(vtkRenderWindowInteractor *interactor
     int i, j;
     int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
     vtkRenderer* renderer=NULL;
-    if (VisibleInWindow>-1) 
+    if (VisibleInWindow>-1)
         renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
     else
         return;
 
     interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
-            interactor->GetEventPosition()[1], 0.0,
-            renderer);
+                                  interactor->GetEventPosition()[1], 0.0,
+                                  renderer);
 
     vtkAssemblyPath *path=NULL;
     vtkAbstractPropPicker *picker;
@@ -535,17 +541,17 @@ void vvSlicerManagerCommand::FlyToPosition(vtkRenderWindowInteractor *interactor
 
         switch (slicer->GetSliceOrientation())
         {
-            case vtkImageViewer2::SLICE_ORIENTATION_XY:
-                flyTo[2] = flyFrom[2];
-                break;
+        case vtkImageViewer2::SLICE_ORIENTATION_XY:
+            flyTo[2] = flyFrom[2];
+            break;
 
-            case vtkImageViewer2::SLICE_ORIENTATION_XZ:
-                flyTo[1] = flyFrom[1];
-                break;
+        case vtkImageViewer2::SLICE_ORIENTATION_XZ:
+            flyTo[1] = flyFrom[1];
+            break;
 
-            case vtkImageViewer2::SLICE_ORIENTATION_YZ:
-                flyTo[0] = flyFrom[0];
-                break;
+        case vtkImageViewer2::SLICE_ORIENTATION_YZ:
+            flyTo[0] = flyFrom[0];
+            break;
         }