VMTK
Loading...
Searching...
No Matches
vtkvmtkImagePlaneWidget.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3Program: VMTK
4Module: vtkvmtkImagePlaneWidget
5Language: C++
6Date: $Date: 2006/07/17 09:52:56 $
7Version: $Revision: 1.1 $
8
9 Copyright (c) Luca Antiga, David Steinman. All rights reserved.
10 See LICENSE file for details.
11
12 Portions of this code are covered under the VTK copyright.
13 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
14 for details.
15
16 This software is distributed WITHOUT ANY WARRANTY; without even
17 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 PURPOSE. See the above copyright notices for more information.
19
20=========================================================================*/
22#include "vtkObjectFactory.h"
23
24#include "vtkRenderWindowInteractor.h"
25#include "vtkCallbackCommand.h"
26#include "vtkCommand.h"
27
29
31{
32 this->EventCallbackCommand->SetCallback(vtkvmtkImagePlaneWidget::ProcessEvents);
33 this->LastDownShift = 0;
34 this->LastDownControl = 0;
35}
36
37void vtkvmtkImagePlaneWidget::ProcessEvents(vtkObject* vtkNotUsed(object),
38 unsigned long event,
39 void* clientdata,
40 void* vtkNotUsed(calldata))
41{
43 reinterpret_cast<vtkvmtkImagePlaneWidget *>( clientdata );
44
45 self->LastButtonPressed = vtkvmtkImagePlaneWidget::VTK_NO_BUTTON;
46
47 switch ( event )
48 {
49 case vtkCommand::LeftButtonPressEvent:
50 self->LastButtonPressed = vtkvmtkImagePlaneWidget::VTK_LEFT_BUTTON;
51 self->LastDownShift = self->Interactor->GetShiftKey();
52 self->LastDownControl = self->Interactor->GetControlKey();
53 if (self->LastDownShift && self->LastDownControl)
54 {
55 self->Interactor->SetControlKey(0);
56 self->Interactor->SetShiftKey(0);
57 self->OnRightButtonDown();
58 self->Interactor->SetControlKey(1);
59 self->Interactor->SetShiftKey(1);
60 }
61 else if (self->LastDownShift)
62 {
63 self->Interactor->SetShiftKey(0);
64 self->OnMiddleButtonDown();
65 self->Interactor->SetShiftKey(1);
66 }
67 else
68 {
69 self->OnLeftButtonDown();
70 }
71 break;
72 case vtkCommand::LeftButtonReleaseEvent:
73 self->LastButtonPressed = vtkvmtkImagePlaneWidget::VTK_LEFT_BUTTON;
74 if (self->LastDownShift)
75 {
76 self->OnMiddleButtonUp();
77 }
78 else if (self->LastDownShift && self->LastDownControl)
79 {
80 self->OnRightButtonUp();
81 }
82 else
83 {
84 self->OnLeftButtonUp();
85 }
86 break;
87 case vtkCommand::MiddleButtonPressEvent:
88 self->LastButtonPressed = vtkvmtkImagePlaneWidget::VTK_MIDDLE_BUTTON;
89 self->OnMiddleButtonDown();
90 break;
91 case vtkCommand::MiddleButtonReleaseEvent:
92 self->LastButtonPressed = vtkvmtkImagePlaneWidget::VTK_MIDDLE_BUTTON;
93 self->OnMiddleButtonUp();
94 break;
95 case vtkCommand::RightButtonPressEvent:
96 self->LastButtonPressed = vtkvmtkImagePlaneWidget::VTK_RIGHT_BUTTON;
97 self->OnRightButtonDown();
98 break;
99 case vtkCommand::RightButtonReleaseEvent:
100 self->LastButtonPressed = vtkvmtkImagePlaneWidget::VTK_RIGHT_BUTTON;
101 self->OnRightButtonUp();
102 break;
103 case vtkCommand::MouseMoveEvent:
104 self->OnMouseMove();
105 break;
106 case vtkCommand::CharEvent:
107 self->OnChar();
108 break;
109 }
110}
111
Generates an interactive widget used to browse through image data.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkStandardNewMacro(vtkvmtkImagePlaneWidget)