Slicer  4.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLSliceIntersectionWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMRMLSliceIntersectionWidget.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
25 #ifndef vtkMRMLSliceIntersectionWidget_h
26 #define vtkMRMLSliceIntersectionWidget_h
27 
28 #include "vtkMRMLDisplayableManagerExport.h" // For export macro
29 #include "vtkMRMLAbstractWidget.h"
30 #include "vtkMRMLSliceLogic.h"
31 #include "vtkMRMLSliceNode.h"
32 
33 #include <vtkCallbackCommand.h>
34 #include <vtkCollection.h>
35 #include <vtkSmartPointer.h>
36 #include <vtkWeakPointer.h>
37 
38 class vtkSliceIntersectionRepresentation2D;
41 
42 
43 class VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLSliceIntersectionWidget : public vtkMRMLAbstractWidget
44 {
45 public:
49  static vtkMRMLSliceIntersectionWidget *New();
50 
52 
56  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
62  void CreateDefaultRepresentation();
63 
64  void SetSliceNode(vtkMRMLSliceNode* sliceNode);
65  vtkMRMLSliceNode* GetSliceNode();
66 
67  void SetMRMLApplicationLogic(vtkMRMLApplicationLogic* applicationLogic) override;
68 
70  bool CanProcessInteractionEvent(vtkMRMLInteractionEventData* eventData, double &distance2) override;
71 
73  bool ProcessInteractionEvent(vtkMRMLInteractionEventData* eventData) override;
74 
76  void Leave(vtkMRMLInteractionEventData* eventData) override;
77 
79  enum
80  {
81  WidgetStateFollowCursor = WidgetStateUser,
86  };
87 
89  enum
90  {
91  WidgetEventTouchGestureStart = WidgetEventUser,
105  WidgetEventToggleAllSlicesVisibility, // currently does not work, only toggles current slice
116  };
117 
119  enum
120  {
121  ActionNone = 0,
122  ActionTranslate = 1,
123  ActionZoom = 2,
124  ActionRotate = 4, /* not used */
125  ActionBlend = 8, /* fg to bg, labelmap to bg */
126  ActionBrowseSlice = 64,
127  ActionShowSlice = 128,
128  ActionAdjustLightbox = 256,
129  ActionSelectVolume = 512,
130  ActionSetCursorPosition = 1024, /* adjust cursor position in crosshair node as mouse is moved */
131  ActionSetCrosshairPosition = 2048, /* adjust cursor position in crosshair node as mouse is moved */
132  ActionTranslateSliceIntersection = 4096,
133  ActionRotateSliceIntersection = 8192,
134  ActionAll = ActionTranslate | ActionZoom | ActionRotate | ActionBlend
135  | ActionBrowseSlice | ActionShowSlice | ActionAdjustLightbox | ActionSelectVolume
136  | ActionSetCursorPosition | ActionSetCrosshairPosition
137  | ActionTranslateSliceIntersection | ActionRotateSliceIntersection
138  };
139 
141  void SetActionsEnabled(int actions);
142 
144  int GetActionsEnabled();
145 
150  void SetActionEnabled(int actionsMask, bool enable = true);
153  bool GetActionEnabled(int actionsMask);
154 
155  void UpdateInteractionEventMapping();
156 
157 protected:
159  ~vtkMRMLSliceIntersectionWidget() override;
160 
161  bool ProcessStartMouseDrag(vtkMRMLInteractionEventData* eventData);
162  bool ProcessMouseMove(vtkMRMLInteractionEventData* eventData);
163  bool ProcessEndMouseDrag(vtkMRMLInteractionEventData* eventData);
164  bool ProcessBlend(vtkMRMLInteractionEventData* eventData);
165 
166  bool ProcessRotateStart(vtkMRMLInteractionEventData* eventData);
167  bool ProcessRotate(vtkMRMLInteractionEventData* eventData);
168  bool ProcessSetCrosshair(vtkMRMLInteractionEventData* eventData);
169  double GetSliceRotationAngleRad(double eventPos[2]);
170 
171  // Move slice in-plane by click-and-drag
172  bool ProcessTranslateSlice(vtkMRMLInteractionEventData* eventData);
173 
174  bool ProcessZoomSlice(vtkMRMLInteractionEventData* eventData);
175 
176  bool ProcessTouchGestureStart(vtkMRMLInteractionEventData* eventData);
177  bool ProcessTouchGestureEnd(vtkMRMLInteractionEventData* eventData);
178  bool ProcessTouchRotate(vtkMRMLInteractionEventData* eventData);
179  bool ProcessTouchZoom(vtkMRMLInteractionEventData* eventData);
180  bool ProcessTouchTranslate(vtkMRMLInteractionEventData* eventData);
181 
183  bool Rotate(double sliceRotationAngleRad);
184 
188  void ScaleZoom(double zoomScaleFactor, vtkMRMLInteractionEventData* eventData);
189 
191  void SetLabelOpacity(double opacity);
192  double GetLabelOpacity();
193 
196  bool IsEventInsideVolume(bool background, vtkMRMLInteractionEventData* eventData);
197 
198  vtkMRMLSegmentationDisplayNode* GetVisibleSegmentationDisplayNode();
199 
200  static void SliceLogicsModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
201 
202  vtkWeakPointer<vtkCollection> SliceLogics;
203  vtkWeakPointer<vtkMRMLSliceNode> SliceNode;
204  vtkWeakPointer<vtkMRMLSliceLogic> SliceLogic;
205  vtkNew<vtkCallbackCommand> SliceLogicsModifiedCommand;
206 
207  double StartEventPosition[2];
209  int PreviousEventPosition[2];
210  double StartRotationCenter[2];
211  double StartRotationCenter_RAS[4];
212 
213  double StartActionFOV[3];
214  double VolumeScalarRange[2];
215 
216  enum
217  {
220  LayerLabelmap
221  };
222 
223  // Blend
227 
228  // Browse slice
232  double GetSliceSpacing();
234  void IncrementSlice();
235  void DecrementSlice();
236  void MoveSlice(double delta);
237 
243  void CycleVolumeLayer(int layer, int direction);
244 
248 
250 
260 
261 private:
263  void operator=(const vtkMRMLSliceIntersectionWidget&) = delete;
264 };
265 
266 #endif
virtual bool CanProcessInteractionEvent(vtkMRMLInteractionEventData *eventData, double &distance2)
vtkMRMLSegmentationDisplayNode * StartActionSegmentationDisplayNode
vtkWeakPointer< vtkMRMLSliceNode > SliceNode
MRML node for storing a slice through RAS space.
vtkWeakPointer< vtkMRMLSliceLogic > SliceLogic
vtkWeakPointer< vtkCollection > SliceLogics
vtkNew< vtkCallbackCommand > SliceLogicsModifiedCommand
MRML node for representing segmentation display attributes.
virtual bool ProcessInteractionEvent(vtkMRMLInteractionEventData *eventData)
virtual void Leave(vtkMRMLInteractionEventData *eventData)
Called when the the widget loses the focus.
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void SetMRMLApplicationLogic(vtkMRMLApplicationLogic *applicationLogic)
Process interaction events to update state of MRML widget nodes.