Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLCameraWidget.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 
30 #ifndef vtkMRMLCameraWidget_h
31 #define vtkMRMLCameraWidget_h
32 
33 #include "vtkMRMLDisplayableManagerExport.h" // For export macro
34 #include "vtkMRMLAbstractWidget.h"
35 #include "vtkMRMLCameraNode.h"
36 
37 class vtkSliceIntersectionRepresentation2D;
39 
40 
41 class VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLCameraWidget : public vtkMRMLAbstractWidget
42 {
43 public:
47  static vtkMRMLCameraWidget *New();
48 
50 
54  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
60  void CreateDefaultRepresentation();
61 
62  void SetCameraNode(vtkMRMLCameraNode* cameraNode);
63  vtkMRMLCameraNode* GetCameraNode();
64 
66  bool CanProcessInteractionEvent(vtkMRMLInteractionEventData* eventData, double &distance2) override;
67 
69  bool ProcessInteractionEvent(vtkMRMLInteractionEventData* eventData) override;
70 
72  bool GetTiltLocked();
75  void SetTiltLocked(bool lockState);
77 
79  enum
80  {
81  WidgetStateMoveCrosshair = WidgetStateUser,
83  WidgetStateTouchGesture
84  };
85 
87  enum
88  {
89  WidgetEventSpinStart = WidgetEventUser,
91 
94 
101 
108 
115 
118  WidgetEventCameraWheelZoomIn, // same as WidgetEventCameraZoomIn but with using wheel scaling factor
120 
122 
126  WidgetEventCameraResetFieldOfView, // VTK's standard camera reset (centers and resets field of view)
127 
130 
136 
138  WidgetEventSetCrosshairPositionBackground, //< set crosshair position without consuming the event (so that other widgets can process the event)
140  };
141 
143  vtkGetMacro(MotionFactor, double);
144  vtkSetMacro(MotionFactor, double);
145 
147  vtkGetMacro(MouseWheelMotionFactor, double);
148  vtkSetMacro(MouseWheelMotionFactor, double);
149 
150 protected:
152  ~vtkMRMLCameraWidget() override;
153 
154  bool ProcessStartMouseDrag(vtkMRMLInteractionEventData* eventData);
155  bool ProcessMouseMove(vtkMRMLInteractionEventData* eventData);
156  bool ProcessEndMouseDrag(vtkMRMLInteractionEventData* eventData);
157 
158  bool ProcessTranslate(vtkMRMLInteractionEventData* eventData);
159  bool ProcessRotate(vtkMRMLInteractionEventData* eventData);
160  bool ProcessScale(vtkMRMLInteractionEventData* eventData);
161  bool ProcessSpin(vtkMRMLInteractionEventData* eventData);
162  bool ProcessSetCrosshair(vtkMRMLInteractionEventData* eventData);
163  bool ProcessSetCrosshairBackground(vtkMRMLInteractionEventData* eventData);
164 
165  bool ProcessTouchGestureStart(vtkMRMLInteractionEventData* eventData);
166  bool ProcessTouchGestureEnd(vtkMRMLInteractionEventData* eventData);
167  bool ProcessTouchCameraSpin(vtkMRMLInteractionEventData* eventData);
168  bool ProcessTouchCameraZoom(vtkMRMLInteractionEventData* eventData);
169  bool ProcessTouchCameraTranslate(vtkMRMLInteractionEventData* eventData);
170 
171  bool ProcessWidgetMenu(vtkMRMLInteractionEventData* eventData);
172 
173  bool ProcessMaximizeView(vtkMRMLInteractionEventData* eventData);
174 
175  bool Dolly(double factor);
176  vtkCamera* GetCamera();
177 
178  bool CameraModifyStart();
179  void CameraModifyEnd(bool wasModified, bool updateClippingRange, bool updateLights);
180 
181  void SaveStateForUndo();
182 
183  double MotionFactor;
186 
187  vtkWeakPointer<vtkMRMLCameraNode> CameraNode;
188 
189  double StartEventPosition[2];
190  int PreviousEventPosition[2];
191 
195 
196 
197 private:
198  vtkMRMLCameraWidget(const vtkMRMLCameraWidget&) = delete;
199  void operator=(const vtkMRMLCameraWidget&) = delete;
200 };
201 
202 #endif
virtual bool CanProcessInteractionEvent(vtkMRMLInteractionEventData *eventData, double &distance2)
Process camera manipulation events.
MRML node for representing segmentation display attributes.
this is a starting index that can be used for widget-specific events
virtual bool ProcessInteractionEvent(vtkMRMLInteractionEventData *eventData)
void PrintSelf(ostream &os, vtkIndent indent) override
MRML node to represent camera node.
Process interaction events to update state of MRML widget nodes.
this is a starting index that can be used for widget-specific states
vtkWeakPointer< vtkMRMLCameraNode > CameraNode