]> Creatis software - clitk.git/blobdiff - vv/vvSlicerManagerCommand.cxx
remove useless logs
[clitk.git] / vv / vvSlicerManagerCommand.cxx
index 017c7afb02ef91a4a22e9cbec4d47b575694cffb..32ef0593eaa09dbb3ae6cebe2e79de069ac18130 100644 (file)
@@ -43,28 +43,34 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <cmath>
 
-vvSlicerManagerCallback::vvSlicerManagerCallback()
+//------------------------------------------------------------------------------
+vvSlicerManagerCommand::vvSlicerManagerCommand()
 {
     mStartSlicer = -1;
+    mSlicerNumber=-1;
 }
+//------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
 //return the num of the current slicer if visible (-1 else)
-int vvSlicerManagerCallback::FindSlicerNumber(vtkRenderWindow* renwin)
+int vvSlicerManagerCommand::FindSlicerNumber(vtkRenderWindow* renwin)
 {
-    for (int i = 0; i < SM->NumberOfSlicers(); i++)
-    {
-        if (SM->GetSlicer(i)->GetRenderWindow() == renwin
-                && SM->GetSlicer(i)->GetRenderer()->GetDraw())
-        {
-            return i;
-        }
-    }
-    return -1;
+    int rvalue;
+    if (renwin != SM->GetSlicer(mSlicerNumber)->GetRenderWindow() ||
+            !SM->GetSlicer(mSlicerNumber)->GetRenderer()->GetDraw())
+        rvalue = -1;
+    else rvalue = mSlicerNumber;
+    //std::cerr << this << ":" << mSlicerNumber << ": " << rvalue << endl;
+    return rvalue;
 }
+//------------------------------------------------------------------------------
+
 
-void vvSlicerManagerCallback::Execute(vtkObject *caller,
-                                       unsigned long event,
-                                       void *vtkNotUsed(callData))
+//------------------------------------------------------------------------------
+void vvSlicerManagerCommand::Execute(vtkObject *caller,
+        unsigned long event,
+        void *vtkNotUsed(callData))
 {
     //KeyPress event
     vvInteractorStyleNavigator *isi =
@@ -101,6 +107,11 @@ void vvSlicerManagerCallback::Execute(vtkObject *caller,
                 {
                     FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
                 }
+               if (KeyPress == "z")
+               {
+                   this->SM->SetLocalColorWindowing(VisibleInWindow);
+                  return;
+               }
                 if (KeyPress == "0")
                 {
                     this->SM->SetPreset(0);
@@ -171,7 +182,6 @@ void vvSlicerManagerCallback::Execute(vtkObject *caller,
                 }
                 if (KeyPress == "minus")
                 {
-                    std::cout << "KeyPress : - " << std::endl;
                     this->SM->SetColorWindow(-this->SM->GetColorWindow());
                     this->SM->SetColorMap(-1);
                     this->SM->UpdateWindowLevel();
@@ -201,7 +211,7 @@ void vvSlicerManagerCallback::Execute(vtkObject *caller,
                     this->SM->Render();
                     return;
                 }
-                if (KeyPress == "r" or KeyPress=="R")
+                if (KeyPress == "r" || KeyPress=="R")
                 {
                     this->SM->GetSlicer(VisibleInWindow)->ResetCamera();
                     this->SM->GetSlicer(VisibleInWindow)->Render();
@@ -338,36 +348,36 @@ void vvSlicerManagerCallback::Execute(vtkObject *caller,
             renderer->ViewToWorld(x,y,z);
             switch (this->SM->GetSlicer(VisibleInWindow)->GetSliceOrientation())
             {
-            case vtkImageViewer2::SLICE_ORIENTATION_XY:
-                xWorld = x;
-                yWorld = y;
-                zWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[2] +
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[2];
-                break;
-
-            case vtkImageViewer2::SLICE_ORIENTATION_XZ:
-                xWorld = x;
-                yWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[1] +
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[1];
-                zWorld = z;
-                break;
-
-            case vtkImageViewer2::SLICE_ORIENTATION_YZ:
-                xWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[0] +
-                         this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[0];
-                yWorld = y;
-                zWorld = z;
-                break;
+                case vtkImageViewer2::SLICE_ORIENTATION_XY:
+                    xWorld = x;
+                    yWorld = y;
+                    zWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+                        this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[2] +
+                        this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[2];
+                    break;
+
+                case vtkImageViewer2::SLICE_ORIENTATION_XZ:
+                    xWorld = x;
+                    yWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+                        this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[1] +
+                        this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[1];
+                    zWorld = z;
+                    break;
+
+                case vtkImageViewer2::SLICE_ORIENTATION_YZ:
+                    xWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
+                        this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[0] +
+                        this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[0];
+                    yWorld = y;
+                    zWorld = z;
+                    break;
             }
             this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
                     this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
             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();
             }
@@ -382,7 +392,7 @@ void vvSlicerManagerCallback::Execute(vtkObject *caller,
                 this->SM->GetSlicer(VisibleInWindow)->Render();
             }
             //this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
-                    //-VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
+            //-VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
             //this->SM->GetSlicer(VisibleInWindow)->Render();
         }
 
@@ -398,9 +408,9 @@ void vvSlicerManagerCallback::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
@@ -414,8 +424,11 @@ void vvSlicerManagerCallback::Execute(vtkObject *caller,
         }
     }
 }
+//------------------------------------------------------------------------------
 
-void vvSlicerManagerCallback::Dolly(double factor, vtkRenderWindowInteractor *interactor)
+
+//------------------------------------------------------------------------------
+void vvSlicerManagerCommand::Dolly(double factor, vtkRenderWindowInteractor *interactor)
 {
     int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
     vtkRenderer* renderer;
@@ -442,9 +455,9 @@ void vvSlicerManagerCallback::Dolly(double factor, vtkRenderWindowInteractor *in
     oldPos[2] = focalDepth;
 
     distance[0] = 1/factor*
-                  (interactor->GetEventPosition()[0]-renderer->GetCenter()[0]);
+        (interactor->GetEventPosition()[0]-renderer->GetCenter()[0]);
     distance[1] = 1/factor*
-                  (interactor->GetEventPosition()[1]-renderer->GetCenter()[1]);
+        (interactor->GetEventPosition()[1]-renderer->GetCenter()[1]);
 
     newPos[0] = interactor->GetEventPosition()[0] - distance[0];
     newPos[1] = interactor->GetEventPosition()[1] - distance[1];
@@ -469,12 +482,12 @@ void vvSlicerManagerCallback::Dolly(double factor, vtkRenderWindowInteractor *in
     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())
     {
@@ -493,7 +506,7 @@ void vvSlicerManagerCallback::Dolly(double factor, vtkRenderWindowInteractor *in
     //interactor->Render();
 }
 
-void vvSlicerManagerCallback::FlyToPosition(vtkRenderWindowInteractor *interactor,vvSlicer* slicer)
+void vvSlicerManagerCommand::FlyToPosition(vtkRenderWindowInteractor *interactor,vvSlicer* slicer)
 {
     double flyFrom[3], flyTo[3];
     double d[3], focalPt[3], position[3], positionFrom[3];
@@ -506,8 +519,8 @@ void vvSlicerManagerCallback::FlyToPosition(vtkRenderWindowInteractor *interacto
         return;
 
     interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
-                                  interactor->GetEventPosition()[1], 0.0,
-                                  renderer);
+            interactor->GetEventPosition()[1], 0.0,
+            renderer);
 
     vtkAssemblyPath *path=NULL;
     vtkAbstractPropPicker *picker;
@@ -525,17 +538,17 @@ void vvSlicerManagerCallback::FlyToPosition(vtkRenderWindowInteractor *interacto
 
         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;
         }