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
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
140 void SetEventTranslationClickAndDrag(int widgetState, unsigned long startInteractionEvent, int modifiers,
141 int widgetStateDragging, unsigned long widgetStartEvent, unsigned long widgetEndEvent);
142
145 void SetEventTranslation(unsigned long interactionEvent, int modifiers, unsigned long widgetEvent);
146
149 void SetKeyboardEventTranslation(int modifier, char keyCode, int repeatCount, const char* keySym, unsigned long widgetEvent);
150
153 void SetKeyboardEventTranslation(int widgetState, int modifier, char keyCode, int repeatCount, const char* keySym, unsigned long widgetEvent);
154
157
159 virtual void Leave(vtkMRMLInteractionEventData* eventData);
160
161 void SetRenderer(vtkRenderer* renderer);
162 vtkRenderer* GetRenderer();
163
165
166 // Allows the widget to request a cursor shape
167 virtual int GetMouseCursor();
168
169 // Allows the widget to request grabbing of all events (even when the mouse pointer moves out of view)
170 virtual bool GetGrabFocus();
171
172 // Allows the widget to request interactive mode (faster updates)
173 virtual bool GetInteractive();
174
175 // Allows the widget to request render
176 virtual bool GetNeedToRender();
177
178 // Acknowledge rendering request (rendering completed)
179 virtual void NeedToRenderOff();
180
181 virtual vtkWidgetEventTranslator* GetEventTranslator(int widgetState);
182
184
185protected:
188
192
195 vtkWidgetEventTranslator* translator, vtkMRMLInteractionEventData* eventData);
196
198 bool CanProcessButtonClickEvent(vtkMRMLInteractionEventData* eventData, double& distance2);
199
203
204 vtkWeakPointer<vtkRenderer> Renderer;
205
206 vtkWeakPointer<vtkMRMLApplicationLogic> ApplicationLogic;
207
208 // Translates interaction event to widget event.
209 // In the future, a vector of event translators could be added
210 // (one for each state) to be able to define events
211 // that are only allowed in a specific state.
212 std::vector< vtkSmartPointer<vtkWidgetEventTranslator> > EventTranslators;
213
215
216 vtkSmartPointer<vtkMRMLAbstractWidgetRepresentation> WidgetRep;
217
218// bool NeedToRender;
219
220private:
222 void operator=(const vtkMRMLAbstractWidget&) = delete;
223};
224
225#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
std::vector< vtkSmartPointer< vtkWidgetEventTranslator > > EventTranslators
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()
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.