Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLInteractionEventData.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 ==============================================================================*/
17 
18 #ifndef __vtkMRMLInteractionEventData_h
19 #define __vtkMRMLInteractionEventData_h
20 
21 // VTK includes
22 #include "vtkEventData.h"
23 
24 // MRML includes
25 #include "vtkMRMLDisplayableManagerExport.h"
26 
28 class vtkRenderWindowInteractor;
29 class vtkRenderer;
30 class vtkCellPicker;
31 
35 class VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLInteractionEventData : public vtkEventDataDevice3D
36 {
37 public:
38  vtkTypeMacro(vtkMRMLInteractionEventData, vtkEventDataDevice3D);
39  static vtkMRMLInteractionEventData *New();
40 
43  {
44  LeftButtonClickEvent = vtkCommand::UserEvent + 300, // button press and release without moving mouse
47  };
48 
49  void SetType(unsigned long v);
50 
51  void SetModifiers(int v);
52  int GetModifiers();
53 
55  void SetWorldPosition(const double p[3], bool accurate = true);
59  bool IsWorldPositionValid();
60  bool IsWorldPositionAccurate();
61  void SetWorldPositionInvalid();
62 
63  bool ComputeAccurateWorldPosition(bool force = false);
65 
66  void GetDisplayPosition(int v[2]) const;
67  const int *GetDisplayPosition() const;
68  void SetDisplayPosition(const int p[2]);
69  bool IsDisplayPositionValid();
70  void SetDisplayPositionInvalid();
71 
72  void SetKeyCode(char v);
73  char GetKeyCode();
74  void SetKeyRepeatCount(char v);
75  int GetKeyRepeatCount();
76  void SetKeySym(const std::string &v);
77  const std::string& GetKeySym();
78 
79  void SetViewNode(vtkMRMLAbstractViewNode* viewNode);
80  vtkMRMLAbstractViewNode* GetViewNode() const;
81 
82  void SetComponentType(int componentType);
83  int GetComponentType() const;
84 
85  void SetComponentIndex(int componentIndex);
86  int GetComponentIndex() const;
87 
88  void SetMouseMovedSinceButtonDown(bool moved);
89  bool GetMouseMovedSinceButtonDown() const;
90 
91  void SetRotation(double v);
92  double GetRotation() const;
93  void SetLastRotation(double v);
94  double GetLastRotation() const;
95  void SetScale(double scale);
96  double GetScale() const;
97  void SetLastScale(double scale);
98  double GetLastScale() const;
99  void SetTranslation(const double translation[2]);
100  const double *GetTranslation() const;
101  void SetLastTranslation(const double translation[2]);
102  const double* GetLastTranslation() const;
103  void SetWorldToPhysicalScale(double v);
104  double GetWorldToPhysicalScale() const;
105 
107  void SetAttributesFromInteractor(vtkRenderWindowInteractor* interactor);
108 
109  vtkRenderer* GetRenderer() const;
110  void SetRenderer(vtkRenderer* ren);
111 
112  void SetAccuratePicker(vtkCellPicker* picker);
113  vtkCellPicker* GetAccuratePicker() const;
114 
115  void SetInteractionContextName(const std::string& v);
116  const std::string& GetInteractionContextName();
117 
118  void WorldToDisplay(const double worldPosition[3], double displayPosition[3]);
119 
120 protected:
122  int DisplayPosition[2];
128  vtkRenderer* Renderer;
129  vtkCellPicker* AccuratePicker;
133  double WorldToViewTransformMatrix[16];
135 
137  char KeyCode;
140  std::string KeySym;
142 
143  // Gesture events
145  double Rotation;
147  double LastRotation;
148  double Scale;
149  double LastScale;
150  double Translation[2];
151  double LastTranslation[2];
153 
157 
160 
161  bool Equivalent(const vtkEventData *e) const override;
162 
164  ~vtkMRMLInteractionEventData() override = default;
165 
166 private:
168  void operator=(const vtkMRMLInteractionEventData&) = delete;
169 };
170 
171 #endif
MRMLInteractionEvents
Extends vtkCommand events.
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D...
std::string InteractionContextName
Name of interaction context. In case of the mouse, it is empty string.