Slicer  4.11
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  enum
73  {
74  WidgetStateFollowCursor = WidgetStateUser,
77  };
78 
80  enum
81  {
82  WidgetEventSpinStart = WidgetEventUser,
84 
91 
98 
105 
108  WidgetEventCameraWheelZoomIn, // same as WidgetEventCameraZoomIn but with using wheel scaling factor
110 
114 
117 
123 
125  };
126 
128  vtkGetMacro(MotionFactor, double);
129  vtkSetMacro(MotionFactor, double);
130 
132  vtkGetMacro(MouseWheelMotionFactor, double);
133  vtkSetMacro(MouseWheelMotionFactor, double);
134 
135 protected:
137  ~vtkMRMLCameraWidget() override;
138 
139  bool ProcessStartMouseDrag(vtkMRMLInteractionEventData* eventData);
140  bool ProcessMouseMove(vtkMRMLInteractionEventData* eventData);
141  bool ProcessEndMouseDrag(vtkMRMLInteractionEventData* eventData);
142 
143  bool ProcessTranslate(vtkMRMLInteractionEventData* eventData);
144  bool ProcessRotate(vtkMRMLInteractionEventData* eventData);
145  bool ProcessScale(vtkMRMLInteractionEventData* eventData);
146  bool ProcessSpin(vtkMRMLInteractionEventData* eventData);
147  bool ProcessSetCrosshair(vtkMRMLInteractionEventData* eventData);
148 
149  bool ProcessTouchGestureStart(vtkMRMLInteractionEventData* eventData);
150  bool ProcessTouchGestureEnd(vtkMRMLInteractionEventData* eventData);
151  bool ProcessTouchCameraSpin(vtkMRMLInteractionEventData* eventData);
152  bool ProcessTouchCameraZoom(vtkMRMLInteractionEventData* eventData);
153  bool ProcessTouchCameraTranslate(vtkMRMLInteractionEventData* eventData);
154 
155  bool Dolly(double factor);
156  vtkCamera* GetCamera();
157 
158  bool CameraModifyStart();
159  void CameraModifyEnd(bool wasModified, bool updateClippingRange, bool updateLights);
160 
161  void SaveStateForUndo();
162 
163  double MotionFactor;
165 
166  vtkWeakPointer<vtkMRMLCameraNode> CameraNode;
167 
168  double StartEventPosition[2];
169  int PreviousEventPosition[2];
170 
174 
175 
176 private:
177  vtkMRMLCameraWidget(const vtkMRMLCameraWidget&) = delete;
178  void operator=(const vtkMRMLCameraWidget&) = delete;
179 };
180 
181 #endif
virtual bool CanProcessInteractionEvent(vtkMRMLInteractionEventData *eventData, double &distance2)
bool ModifierKeyPressedSinceLastMouseButtonRelease
Process camera manipulation events.
MRML node for representing segmentation display attributes.
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.
vtkWeakPointer< vtkMRMLCameraNode > CameraNode