Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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 https://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
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
38class vtkSliceIntersectionRepresentation2D;
42
43class VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLSliceIntersectionWidget : public vtkMRMLAbstractWidget
44{
45public:
50
52
56 void PrintSelf(ostream& os, vtkIndent indent) override;
58
63
66
68
69 void SetMRMLApplicationLogic(vtkMRMLApplicationLogic* applicationLogic) override;
70
72 bool CanProcessInteractionEvent(vtkMRMLInteractionEventData* eventData, double &distance2) override;
73
76
78 void Leave(vtkMRMLInteractionEventData* eventData) override;
79
81 enum
82 {
83 // Interactions without handles
84 WidgetStateMoveCrosshair = WidgetStateUser,
90
91 // Interactions with slice intersection handles
98
99 WidgetState_Last
100 };
101
103 enum
104 {
105 // Interactions without handles
106 WidgetEventTouchGestureStart = WidgetEventUser,
122 WidgetEventToggleAllSlicesVisibility, // currently does not work, only toggles current slice
128 WidgetEventRotateIntersectingSlicesStart, // rotate all intersecting slices (ctrl-alt-left-click-and-drag)
135 WidgetEventSetCrosshairPositionBackground, //< set crosshair position without consuming the event (so that other widgets can process the event)
137
138 // Interactions with slice intersection handles
139 // WidgetStateOnTranslateIntersectingSlicesHandle/WidgetStateTranslateIntersectingSlicesHandle
142 // WidgetStateOnRotateIntersectingSlicesHandle/WidgetStateRotateIntersectingSlicesHandle
145 // WidgetStateOnTranslateSingleIntersectingSliceHandle/WidgetStateOnTranslateSingleIntersectingSliceHandle
148 };
149
151 enum
152 {
153 ActionNone = 0,
154 ActionTranslate = 1,
155 ActionZoom = 2,
156 ActionRotate = 4, /* not used */
157 ActionBlend = 8, /* fg to bg, labelmap to bg */
158 ActionBrowseSlice = 64,
159 ActionShowSlice = 128,
160 ActionAdjustLightbox = 256,
161 ActionSelectVolume = 512,
162 ActionSetCursorPosition = 1024, /* adjust cursor position in crosshair node as mouse is moved */
163 ActionSetCrosshairPosition = 2048, /* adjust cursor position in crosshair node as mouse is moved */
164 ActionTranslateSliceIntersection = 4096,
165 ActionRotateSliceIntersection = 8192,
166 ActionAll = ActionTranslate | ActionZoom | ActionRotate | ActionBlend
167 | ActionBrowseSlice | ActionShowSlice | ActionAdjustLightbox | ActionSelectVolume
168 | ActionSetCursorPosition | ActionSetCrosshairPosition
169 | ActionTranslateSliceIntersection | ActionRotateSliceIntersection
170 };
171
173 void SetActionsEnabled(int actions);
174
177
182 void SetActionEnabled(int actionsMask, bool enable = true);
185 bool GetActionEnabled(int actionsMask);
186
188
189 // Allows the widget to request a cursor shape
190 int GetMouseCursor() override;
191
192protected:
195
200
205 double GetSliceRotationAngleRad(double eventPos[2]);
206
207 // Pan (move slice in-plane) by click-and-drag
209
211
217
224
226
228
230 bool Rotate(double sliceRotationAngleRad);
231
235 void ScaleZoom(double zoomScaleFactor, vtkMRMLInteractionEventData* eventData);
236
238 void SetLabelOpacity(double opacity);
240
243 bool IsEventInsideVolume(bool background, vtkMRMLInteractionEventData* eventData);
244
246
247 static void SliceModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
248 static void SliceLogicsModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
249
250 vtkWeakPointer<vtkCollection> SliceLogics;
251 vtkWeakPointer<vtkMRMLSliceNode> SliceNode;
252 vtkWeakPointer<vtkMRMLSliceLogic> SliceLogic;
253 vtkNew<vtkCallbackCommand> SliceLogicsModifiedCommand;
254 vtkNew<vtkCallbackCommand> SliceModifiedCommand;
255
256 double StartEventPosition[2];
258 int PreviousEventPosition[2];
259 double StartRotationCenter[2];
260 double StartRotationCenter_RAS[4];
261
262 double StartTranslationPoint[2];
263 double StartTranslationPoint_RAS[3];
264 double CurrentTranslationPoint_RAS[3];
265
266 double StartActionFOV[3];
267 double VolumeScalarRange[2];
268
269 enum
270 {
273 LayerLabelmap
274 };
275
276 // Blend
280
281 // Browse slice
289 void MoveSlice(double delta);
290
296 void CycleVolumeLayer(int layer, int direction);
297
299
303
305
315
316 // Last intersecting slice node where interaction occurred
318
319private:
321 void operator=(const vtkMRMLSliceIntersectionWidget&) = delete;
322};
323
324#endif
Process interaction events to update state of MRML widget nodes.
MRML node for representing segmentation display attributes.
MRML node to store display properties of slice nodes.
static void SliceLogicsModifiedCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
vtkWeakPointer< vtkMRMLSliceNode > SliceNode
void SetMRMLApplicationLogic(vtkMRMLApplicationLogic *applicationLogic) override
void SetLabelOpacity(double opacity)
Get/Set labelmap or segmentation opacity.
vtkMRMLSliceDisplayNode * GetSliceDisplayNode()
bool ProcessMaximizeView(vtkMRMLInteractionEventData *eventData)
double GetSliceRotationAngleRad(double eventPos[2])
bool ProcessZoomSlice(vtkMRMLInteractionEventData *eventData)
bool ProcessTouchGestureEnd(vtkMRMLInteractionEventData *eventData)
void SetActionEnabled(int actionsMask, bool enable=true)
void PrintSelf(ostream &os, vtkIndent indent) override
void IncrementSlice()
Adjust the slice position with respect to current slice node offset.
bool ProcessRotateIntersectingSlicesHandle(vtkMRMLInteractionEventData *eventData)
static vtkMRMLSliceIntersectionWidget * New()
void CycleVolumeLayer(int layer, int direction)
void Leave(vtkMRMLInteractionEventData *eventData) override
Called when the the widget loses the focus.
bool ProcessTranslateIntersectingSlicesHandle(vtkMRMLInteractionEventData *eventData)
bool ProcessRotateIntersectingSlicesHandleStart(vtkMRMLInteractionEventData *eventData)
bool ProcessTouchRotate(vtkMRMLInteractionEventData *eventData)
bool ProcessWidgetMenu(vtkMRMLInteractionEventData *eventData)
vtkMRMLSegmentationDisplayNode * GetVisibleSegmentationDisplayNode()
vtkNew< vtkCallbackCommand > SliceLogicsModifiedCommand
bool ProcessTranslateSingleIntersectingSliceHandleStart(vtkMRMLInteractionEventData *eventData)
static void SliceModifiedCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
vtkMRMLSliceNode * GetSliceNode()
bool ProcessBlend(vtkMRMLInteractionEventData *eventData)
vtkWeakPointer< vtkCollection > SliceLogics
bool ProcessRotateIntersectingSlices(vtkMRMLInteractionEventData *eventData)
void MoveSlice(double delta)
~vtkMRMLSliceIntersectionWidget() override
vtkMRMLSegmentationDisplayNode * StartActionSegmentationDisplayNode
bool GetActionEnabled(int actionsMask)
bool ProcessTouchGestureStart(vtkMRMLInteractionEventData *eventData)
bool ProcessTouchZoom(vtkMRMLInteractionEventData *eventData)
bool IsEventInsideVolume(bool background, vtkMRMLInteractionEventData *eventData)
bool ProcessStartMouseDrag(vtkMRMLInteractionEventData *eventData)
bool ProcessTouchTranslate(vtkMRMLInteractionEventData *eventData)
bool ProcessTranslateIntersectingSlicesHandleStart(vtkMRMLInteractionEventData *eventData)
bool ProcessSetCrosshairBackground(vtkMRMLInteractionEventData *eventData)
int GetActionsEnabled()
Set full list of enabled actions.
bool ProcessEndMouseDrag(vtkMRMLInteractionEventData *eventData)
bool ProcessRotateIntersectingSlicesStart(vtkMRMLInteractionEventData *eventData)
vtkNew< vtkCallbackCommand > SliceModifiedCommand
bool ProcessTranslateSingleIntersectingSliceHandle(vtkMRMLInteractionEventData *eventData)
bool CanProcessInteractionEvent(vtkMRMLInteractionEventData *eventData, double &distance2) override
Return true if the widget can process the event.
bool ProcessTranslateSlice(vtkMRMLInteractionEventData *eventData)
vtkWeakPointer< vtkMRMLSliceLogic > SliceLogic
bool ProcessMouseMove(vtkMRMLInteractionEventData *eventData)
@ WidgetStateBlend
Fade between foreground/background volumes.
@ WidgetStateTranslateIntersectingSlicesHandle
translating all intersecting slices by drag-and-dropping handle
@ WidgetStateRotateIntersectingSlices
Rotate all intersecting slices (ctrl+alt+left-click-and-drag)
@ WidgetStateTouchGesture
Pinch/zoom/pan using touch gestures.
@ WidgetStateTranslateSlice
Pan (translate in-plane) the current slice (using shift+left-click-and-drag or middle-click-and-drag)
@ WidgetStateOnTranslateSingleIntersectingSliceHandle
hovering over a single-slice translation interaction handle
@ WidgetStateTranslateSingleIntersectingSliceHandle
translating a single slice by drag-and-dropping handle
@ WidgetStateZoomSlice
Zoom slice (using right-button or mouse wheel)
@ WidgetStateRotateIntersectingSlicesHandle
rotating all intersecting slices by drag-and-dropping handle
@ WidgetStateOnRotateIntersectingSlicesHandle
hovering over a rotation interaction handle
@ WidgetStateOnTranslateIntersectingSlicesHandle
hovering over a slice intersection point
bool ProcessSetCrosshair(vtkMRMLInteractionEventData *eventData)
void ScaleZoom(double zoomScaleFactor, vtkMRMLInteractionEventData *eventData)
void SetActionsEnabled(int actions)
Set exact list of actions to enable.
bool Rotate(double sliceRotationAngleRad)
Rotate the message by the specified amount. Used for touchpad events.
void SetSliceNode(vtkMRMLSliceNode *sliceNode)
bool ProcessInteractionEvent(vtkMRMLInteractionEventData *eventData) override
Process interaction event.
MRML node for storing a slice through RAS space.