Slicer  4.11
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 SetRotation(double v);
89  double GetRotation() const;
90  void SetLastRotation(double v);
91  double GetLastRotation() const;
92  void SetScale(double scale);
93  double GetScale() const;
94  void SetLastScale(double scale);
95  double GetLastScale() const;
96  void SetTranslation(const double translation[2]);
97  const double *GetTranslation() const;
98  void SetLastTranslation(const double translation[2]);
99  const double* GetLastTranslation() const;
100  void SetWorldToPhysicalScale(double v);
101  double GetWorldToPhysicalScale() const;
102 
104  void SetAttributesFromInteractor(vtkRenderWindowInteractor* interactor);
105 
106  vtkRenderer* GetRenderer() const;
107  void SetRenderer(vtkRenderer* ren);
108 
109  void SetAccuratePicker(vtkCellPicker* picker);
110  vtkCellPicker* GetAccuratePicker() const;
111 
112  void SetInteractionContextName(const std::string& v);
113  const std::string& GetInteractionContextName();
114 
115 protected:
117  int DisplayPosition[2];
123  vtkRenderer* Renderer;
124  vtkCellPicker* AccuratePicker;
127 
129  char KeyCode;
132  std::string KeySym;
134 
135  // Gesture events
137  double Rotation;
139  double LastRotation;
140  double Scale;
141  double LastScale;
142  double Translation[2];
143  double LastTranslation[2];
145 
149 
152 
153  bool Equivalent(const vtkEventData *e) const override;
154 
156  ~vtkMRMLInteractionEventData() override = default;
157 
158 private:
160  void operator=(const vtkMRMLInteractionEventData&) = delete;
161 };
162 
163 #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.