Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLAbstractWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Copyright (c) ProxSim ltd., Kwun Tong, Hong Kong. All Rights Reserved.
4
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13
14 This file was originally developed by Davide Punzo, punzodavide@hotmail.it,
15 and development was supported by ProxSim ltd.
16
17=========================================================================*/
18
40
41#ifndef vtkMRMLAbstractWidget_h
42#define vtkMRMLAbstractWidget_h
43
44#include "vtkMRMLDisplayableManagerExport.h"
45#include "vtkObject.h"
46#include "vtkSmartPointer.h"
47#include "vtkWeakPointer.h"
48#include <vector>
49
54class vtkMRMLNode;
56class vtkRenderer;
57class vtkWidgetEventTranslator;
58
59class VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLAbstractWidget : public vtkObject
60{
61public:
63 vtkTypeMacro(vtkMRMLAbstractWidget, vtkObject);
64 void PrintSelf(ostream& os, vtkIndent indent) override;
65
66 virtual void SetMRMLApplicationLogic(vtkMRMLApplicationLogic* applicationLogic);
68
72
75
77 virtual void UpdateFromMRML(vtkMRMLNode* caller, unsigned long event, void* callData = nullptr);
78
80 vtkSetMacro(WidgetState, int);
81
83 vtkGetMacro(WidgetState, int);
84
86 enum
87 {
95 };
96
126
130 virtual bool CanProcessInteractionEvent(vtkMRMLInteractionEventData* eventData, double& distance2);
131
135
138 void SetEventTranslation(int widgetState, unsigned long interactionEvent, int modifiers, unsigned long widgetEvent);
139
141 unsigned long startInteractionEvent,
142 int modifiers,
143 int widgetStateDragging,
144 unsigned long widgetStartEvent,
145 unsigned long widgetEndEvent);
146
149 void SetEventTranslation(unsigned long interactionEvent, int modifiers, unsigned long widgetEvent);
150
153 void SetKeyboardEventTranslation(int modifier, char keyCode, int repeatCount, const char* keySym, unsigned long widgetEvent);
154
157 void SetKeyboardEventTranslation(int widgetState, int modifier, char keyCode, int repeatCount, const char* keySym, unsigned long widgetEvent);
158
161
163 virtual void Leave(vtkMRMLInteractionEventData* eventData);
164
165 void SetRenderer(vtkRenderer* renderer);
166 vtkRenderer* GetRenderer();
167
169
170 // Allows the widget to request a cursor shape
171 virtual int GetMouseCursor();
172
173 // Allows the widget to request grabbing of all events (even when the mouse pointer moves out of view)
174 virtual bool GetGrabFocus();
175
176 // Allows the widget to request interactive mode (faster updates)
177 virtual bool GetInteractive();
178
179 // Allows the widget to request render
180 virtual bool GetNeedToRender();
181
182 // Acknowledge rendering request (rendering completed)
183 virtual void NeedToRenderOff();
184
185 virtual vtkWidgetEventTranslator* GetEventTranslator(int widgetState);
186
188
189protected:
192
196
198 unsigned long TranslateInteractionEventToWidgetEvent(vtkWidgetEventTranslator* translator, vtkMRMLInteractionEventData* eventData);
199
201 bool CanProcessButtonClickEvent(vtkMRMLInteractionEventData* eventData, double& distance2);
202
206
207 vtkWeakPointer<vtkRenderer> Renderer;
208
209 vtkWeakPointer<vtkMRMLApplicationLogic> ApplicationLogic;
210
211 // Translates interaction event to widget event.
212 // In the future, a vector of event translators could be added
213 // (one for each state) to be able to define events
214 // that are only allowed in a specific state.
215 std::vector<vtkSmartPointer<vtkWidgetEventTranslator>> EventTranslators;
216
218
219 vtkSmartPointer<vtkMRMLAbstractWidgetRepresentation> WidgetRep;
220
221 // bool NeedToRender;
222
223private:
225 void operator=(const vtkMRMLAbstractWidget&) = delete;
226};
227
228#endif
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D,...
vtkSmartPointer< vtkMRMLAbstractWidgetRepresentation > WidgetRep
virtual bool CanProcessInteractionEvent(vtkMRMLInteractionEventData *eventData, double &distance2)
virtual bool GetNeedToRender()
void PrintSelf(ostream &os, vtkIndent indent) override
~vtkMRMLAbstractWidget() override
vtkWeakPointer< vtkRenderer > Renderer
vtkMRMLApplicationLogic * GetMRMLApplicationLogic()
void SetEventTranslation(unsigned long interactionEvent, int modifiers, unsigned long widgetEvent)
unsigned long TranslateInteractionEventToWidgetEvent(vtkWidgetEventTranslator *translator, vtkMRMLInteractionEventData *eventData)
Helper function that attempts to translate an event with a specific translator only.
virtual int ProcessButtonClickEvent(vtkMRMLInteractionEventData *eventData)
vtkWeakPointer< vtkMRMLApplicationLogic > ApplicationLogic
@ WidgetStateRotate
mouse move transforms the entire widget
@ WidgetStateOnWidget
mouse pointer is over the widget, clicking will add a point or manipulate the line
@ WidgetStateIdle
mouse pointer is outside the widget, click does not do anything
@ WidgetStateUser
this is a starting index that can be used for widget-specific states
@ WidgetStateTranslate
mouse move transforms the entire widget
@ WidgetStateScale
mouse move transforms the entire widget
@ WidgetStateAny
this state is used for referring to any widget state (for defining event translations)
virtual vtkMRMLAbstractWidgetRepresentation * GetRepresentation()
Get the representation.
void SetKeyboardEventTranslation(int modifier, char keyCode, int repeatCount, const char *keySym, unsigned long widgetEvent)
virtual void Leave(vtkMRMLInteractionEventData *eventData)
Called when the the widget loses the focus.
const char * GetAssociatedNodeID(vtkMRMLInteractionEventData *eventData)
virtual unsigned long TranslateInteractionEventToWidgetEvent(vtkMRMLInteractionEventData *eventData)
Get widget event from translation event.
virtual bool GetGrabFocus()
virtual void UpdateFromMRML(vtkMRMLNode *caller, unsigned long event, void *callData=nullptr)
Build the actors of the representation with the info stored in the MRML scene.
void SetRenderer(vtkRenderer *renderer)
virtual int GetMouseCursor()
virtual void SetMRMLApplicationLogic(vtkMRMLApplicationLogic *applicationLogic)
void SetKeyboardEventTranslation(int widgetState, int modifier, char keyCode, int repeatCount, const char *keySym, unsigned long widgetEvent)
virtual bool GetInteractive()
void SetEventTranslation(int widgetState, unsigned long interactionEvent, int modifiers, unsigned long widgetEvent)
virtual vtkWidgetEventTranslator * GetEventTranslator(int widgetState)
virtual bool ProcessInteractionEvent(vtkMRMLInteractionEventData *eventData)
virtual int GetNumberOfEventTranslators()
virtual void SetRepresentation(vtkMRMLAbstractWidgetRepresentation *r)
vtkRenderer * GetRenderer()
std::vector< vtkSmartPointer< vtkWidgetEventTranslator > > EventTranslators
vtkMRMLInteractionNode * GetInteractionNode()
bool CanProcessButtonClickEvent(vtkMRMLInteractionEventData *eventData, double &distance2)
Generate a button click event and checks if it can be processed with CanProcessInteractionEvent.
@ WidgetEventCustomAction6
allows modules to define custom widget actions and get notification via MRML node event
@ WidgetEventCustomAction1
allows modules to define custom widget actions and get notification via MRML node event
@ WidgetEventJumpCursor
jumps cursor to the selected position
@ WidgetEventPick
generates a MRML Pick event (e.g., on left click)
@ WidgetEventSelect
change MRML node Selected attribute
@ WidgetEventCustomAction5
allows modules to define custom widget actions and get notification via MRML node event
@ WidgetEventUnselect
change MRML node Selected attribute
@ WidgetEventUser
this is a starting index that can be used for widget-specific events
@ WidgetEventCustomAction3
allows modules to define custom widget actions and get notification via MRML node event
@ WidgetEventReset
reset widget to initial state (clear all points)
@ WidgetEventToggleSelect
change MRML node Selected attribute
@ WidgetEventCustomAction4
allows modules to define custom widget actions and get notification via MRML node event
@ WidgetEventCustomAction2
allows modules to define custom widget actions and get notification via MRML node event
@ WidgetEventMenu
show context menu
void SetEventTranslationClickAndDrag(int widgetState, unsigned long startInteractionEvent, int modifiers, int widgetStateDragging, unsigned long widgetStartEvent, unsigned long widgetEndEvent)
virtual void NeedToRenderOff()
Abstract Superclass for all specific types of MRML nodes.