- //KeyPress event
- vvInteractorStyleNavigator *isi =
- dynamic_cast<vvInteractorStyleNavigator *>(caller);
- if (isi)
- {
- double x = isi->GetInteractor()->GetEventPosition()[0];
- double y = isi->GetInteractor()->GetEventPosition()[1];
- double z;
-
- int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
- vtkRenderer* renderer=NULL;
- if (VisibleInWindow>-1)
- renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
- newLandmark = false;
-
- if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1)
- {
- for (int i = 0; i < this->SM->NumberOfSlicers(); i++)
- {
- if (this->SM->GetSlicer(i)->GetCursorVisibility())
- {
- this->SM->GetSlicer(i)->SetCursorVisibility(0);
- this->SM->GetSlicer(i)->Render();
- }
- }
- }
- if ( VisibleInWindow > -1 )
- {
- if (event == vtkCommand::KeyPressEvent)
- {
- std::string KeyPress = isi->GetInteractor()->GetKeySym();
- if (KeyPress == "f" || KeyPress == "F")
- {
- FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
- }
- if (KeyPress == "z")
- {
- this->SM->SetLocalColorWindowing(VisibleInWindow);
- return;
- }
- if (KeyPress == "0")
- {
- this->SM->SetPreset(0);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "1")
- {
- this->SM->SetPreset(1);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "2")
- {
- this->SM->SetPreset(2);
- this->SM->UpdateWindowLevel();
-
- return;
- }
- if (KeyPress == "3")
- {
- this->SM->SetPreset(3);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "4")
- {
- this->SM->SetPreset(4);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "5")
- {
- this->SM->SetPreset(5);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "6")
- {
- this->SM->SetColorMap(0);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "7")
- {
- this->SM->SetColorMap(1);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "8")
- {
- this->SM->SetColorMap(2);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "9")
- {
- this->SM->SetColorMap(3);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "equal") //keycodes are in vtkWin32RenderWindowInteractor
- {
- this->SM->SetPreset(7);
- //this->SM->SetColorMap(1);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "minus")
- {
- this->SM->SetColorWindow(-this->SM->GetColorWindow());
- this->SM->SetColorMap(-1);
- this->SM->UpdateWindowLevel();
- return;
- }
- if (KeyPress == "u")
- {
- this->SM->ToggleContourSuperposition();
- this->SM->Render();
- return;
- }
- if (KeyPress == "i")
- {
- this->SM->ToggleInterpolation();
- this->SM->Render();
- return;
- }
- if (KeyPress == "h")
- {
- this->SM->SetCursorVisibility(0);
- this->SM->Render();
- return;
- }
- if (KeyPress == "l")
- {
- this->SM->Reload();
- this->SM->Render();
- return;
- }
- if (KeyPress == "r" || KeyPress=="R")
- {
- this->SM->GetSlicer(VisibleInWindow)->ResetCamera();
- this->SM->GetSlicer(VisibleInWindow)->Render();
- return;
- }
- if (KeyPress == "g")
- {
- double* cursorPos = this->SM->GetSlicer(VisibleInWindow)->GetCursorPosition();
- this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(
- cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
- this->SM->UpdateViews(1,VisibleInWindow);
- this->SM->UpdateLinked(VisibleInWindow);
- return;
- }
- if (KeyPress == "F5")
- {
- this->SM->GetSlicer(VisibleInWindow)->FlipHorizontalView();
- this->SM->GetSlicer(VisibleInWindow)->Render();
- return;
- }
- if (KeyPress == "F6")
- {
- this->SM->GetSlicer(VisibleInWindow)->FlipVerticalView();
- this->SM->GetSlicer(VisibleInWindow)->Render();
- return;
- }
- if (KeyPress == "Up")
- {
- this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
- this->SM->UpdateSlice(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
- }
- if (KeyPress == "Down")
- {
- this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
- this->SM->UpdateSlice(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
- }
- if (KeyPress == "space")
- {
- newLandmark = true;
- }
- if (KeyPress == "Left")
- this->SM->SetPreviousTSlice(VisibleInWindow);
- if (KeyPress == "Right")
- this->SM->SetNextTSlice(VisibleInWindow);
-
- if (KeyPress == "F1")
- {
- this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
- this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
- this->SM->UpdateSliceRange(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
- }
- if (KeyPress == "F2")
- {
- this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Coronal\n<slice>");
- this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(1);
- this->SM->UpdateSliceRange(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
- }
- if (KeyPress == "F3")
- {
- this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Axial\n<slice>");
- this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(2);
- this->SM->UpdateSliceRange(VisibleInWindow);
- this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
- }
- }
-
- //All type of mouse events
- if (event == vtkCommand::LeaveEvent)
- {
- this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
- -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
- this->SM->GetSlicer(VisibleInWindow)->Render();
- return;
- }
-
- if (event == vtkCommand::StartWindowLevelEvent)
- {
- mStartSlicer = -1;
- this->InitialWindow = this->SM->GetColorWindow();
- this->InitialLevel = this->SM->GetColorLevel();
-
- if (VisibleInWindow > -1)
- {
- mStartSlicer = VisibleInWindow;
- }
- return;
- }
-
- if (event == vtkCommand::EndWindowLevelEvent)
- {
- mStartSlicer = -1;
- }