Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
vtkMRMLInteractionWidget.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4 Queen's University, Kingston, ON, Canada. All Rights Reserved.
5
6 See COPYRIGHT.txt
7 or http://www.slicer.org/copyright/copyright.txt for details.
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14
15 This file was originally developed by Kyle Sunderland, PerkLab, Queen's University
16 and was supported through CANARIE's Research Software Program, Cancer
17 Care Ontario, OpenAnatomy, and Brigham and Women's Hospital through NIH grant R01MH112748.
18
19==============================================================================*/
20
27
28#ifndef vtkMRMLInteractionWidget_h
29#define vtkMRMLInteractionWidget_h
30
31// MRMLDisplayableManager includes
32#include "vtkMRMLDisplayableManagerExport.h"
34
35// MRML includes
36#include <vtkMRMLNode.h>
37
44class vtkIdList;
45class vtkPolyData;
47class vtkTransform;
48
49class VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLInteractionWidget
51{
52public:
56 void PrintSelf(ostream& os, vtkIndent indent) override;
58
59 enum
60 {
65 };
66
68 enum
69 {
71 WidgetStateOnTranslationHandle = WidgetStateInteraction_First, // hovering over a translation interaction handle
72 WidgetStateOnRotationHandle, // hovering over a rotation interaction handle
73 WidgetStateOnScaleHandle, // hovering over a scale interaction handle
74 WidgetStateUniformScale, // uniform scaling
76 };
77
79 enum
80 {
82 WidgetEventReserved = WidgetEventInteraction_First, // this events is only to prevent other widgets from processing an event
87 };
88
90 virtual void SetActiveComponentType(int type);
91
93 virtual void SetActiveComponentIndex(int index);
94
96 bool CanProcessInteractionEvent(vtkMRMLInteractionEventData* eventData, double &distance2) override;
97
100
102 void Leave(vtkMRMLInteractionEventData* eventData) override;
103
105 bool GetInteractive() override;
107 int GetMouseCursor() override;
108
109protected:
112
115
116 virtual void TranslateWidget(double eventPos[2]);
117 virtual void ScaleWidget(double eventPos[2], bool uniform=false);
118 virtual void RotateWidget(double eventPos[2]);
119 virtual void ApplyTransform(vtkTransform* transform) = 0;
120
124
129 virtual bool ProcessWidgetMenu(vtkMRMLInteractionEventData* eventData) = 0;
130 virtual bool ProcessWidgetMenuDisplayNodeTypeAndIndex(vtkMRMLInteractionEventData* eventData, vtkMRMLDisplayNode* displayNode, int type, int index);
138
139 virtual vtkMRMLNode* GetMRMLNode() = 0;
140 virtual void SaveInitialState();
141 virtual void RestoreInitialState();
142
143 // Jump to the handle position for the given type and index. Returns true if successful.
144 virtual bool JumpToHandlePosition(int type, int index);
145
148 virtual bool GetClosestPointOnInteractionAxis(int type, int index, const double inputDisplay[2], double outputIntersectionWorld[3]);
149
152 virtual bool GetIntersectionOnAxisPlane(int type, int index, const double inputDisplay[2], double outputIntersectionWorld[3]);
153
156
157 vtkSmartPointer<vtkMRMLNode> OriginalStateNode{ nullptr };
158
159private:
161 void operator=(const vtkMRMLInteractionWidget&) = delete;
162};
163
164#endif
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D,...
@ WidgetStateUser
this is a starting index that can be used for widget-specific states
@ WidgetEventUser
this is a starting index that can be used for widget-specific events
Abstract class that contains graphical display properties for displayable nodes.
Process interaction events to update state of interaction widgets.
void Leave(vtkMRMLInteractionEventData *eventData) override
Called when the the widget loses the focus.
virtual bool ProcessWidgetTranslateStart(vtkMRMLInteractionEventData *eventData)
virtual int GetActiveComponentIndex()
virtual int GetActiveComponentType()
virtual bool ProcessWidgetScaleStart(vtkMRMLInteractionEventData *eventData)
virtual void SaveInitialState()
void StartWidgetInteraction(vtkMRMLInteractionEventData *eventData)
virtual bool ProcessWidgetUniformScaleStart(vtkMRMLInteractionEventData *eventData)
virtual bool ProcessCancelEvent(vtkMRMLInteractionEventData *eventData)
virtual bool JumpToHandlePosition(int type, int index)
virtual bool ProcessEndMouseDrag(vtkMRMLInteractionEventData *eventData)
vtkSmartPointer< vtkMRMLNode > OriginalStateNode
virtual bool ProcessJumpCursor(vtkMRMLInteractionEventData *eventData)
int GetMouseCursor() override
Allows the widget to request a cursor shape.
virtual void RotateWidget(double eventPos[2])
virtual bool GetIntersectionOnAxisPlane(int type, int index, const double inputDisplay[2], double outputIntersectionWorld[3])
virtual vtkMRMLNode * GetMRMLNode()=0
virtual bool ProcessMouseMove(vtkMRMLInteractionEventData *eventData)
double LastEventPosition[2]
Variables for translate/rotate/scale.
bool GetInteractive() override
Allows the widget to request interactive mode (faster updates)
virtual bool GetClosestPointOnInteractionAxis(int type, int index, const double inputDisplay[2], double outputIntersectionWorld[3])
virtual void ScaleWidget(double eventPos[2], bool uniform=false)
virtual void SetActiveComponentType(int type)
virtual void ApplyTransform(vtkTransform *transform)=0
bool ProcessInteractionEvent(vtkMRMLInteractionEventData *eventData) override
Process interaction event.
virtual void SetActiveComponentIndex(int index)
void PrintSelf(ostream &os, vtkIndent indent) override
~vtkMRMLInteractionWidget() override
virtual void RestoreInitialState()
virtual bool ProcessWidgetMenu(vtkMRMLInteractionEventData *eventData)=0
virtual bool ProcessWidgetRotateStart(vtkMRMLInteractionEventData *eventData)
virtual bool ProcessWidgetMenuDisplayNodeTypeAndIndex(vtkMRMLInteractionEventData *eventData, vtkMRMLDisplayNode *displayNode, int type, int index)
bool CanProcessInteractionEvent(vtkMRMLInteractionEventData *eventData, double &distance2) override
Return true if the widget can process the event.
virtual void TranslateWidget(double eventPos[2])
Abstract Superclass for all specific types of MRML nodes.