Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
vtkMRMLAbstractWidget Class Reference

Process interaction events to update state of MRML widget nodes. More...

#include <Libs/MRML/DisplayableManager/vtkMRMLAbstractWidget.h>

Inheritance diagram for vtkMRMLAbstractWidget:
Inheritance graph
[legend]
Collaboration diagram for vtkMRMLAbstractWidget:
Collaboration graph
[legend]

Public Types

enum  {
  WidgetStateAny, WidgetStateIdle, WidgetStateOnWidget, WidgetStateTranslate,
  WidgetStateRotate, WidgetStateScale, WidgetStateUser
}
 The state of the widget. More...
 
typedef vtkObject Superclass
 Standard methods for a VTK class. More...
 
enum  WidgetEvents {
  WidgetEventNone, WidgetEventMouseMove, WidgetEventTranslateStart, WidgetEventTranslateEnd,
  WidgetEventRotateStart, WidgetEventRotateEnd, WidgetEventScaleStart, WidgetEventScaleEnd,
  WidgetEventPick, WidgetEventJumpCursor, WidgetEventAction, WidgetEventCustomAction1,
  WidgetEventCustomAction2, WidgetEventCustomAction3, WidgetEventCustomAction4, WidgetEventCustomAction5,
  WidgetEventCustomAction6, WidgetEventSelect, WidgetEventUnselect, WidgetEventToggleSelect,
  WidgetEventMenu, WidgetEventReset, WidgetEventUser
}
 Widget events. More...
 

Public Member Functions

virtual bool CanProcessInteractionEvent (vtkMRMLInteractionEventData *eventData, double &distance2)
 
virtual const char * GetClassName ()
 
virtual vtkWidgetEventTranslator * GetEventTranslator (int widgetState)
 
virtual bool GetGrabFocus ()
 
vtkMRMLInteractionNodeGetInteractionNode ()
 
virtual bool GetInteractive ()
 
virtual int GetMouseCursor ()
 
vtkMRMLApplicationLogicGetMRMLApplicationLogic ()
 
virtual bool GetNeedToRender ()
 
virtual int GetNumberOfEventTranslators ()
 
vtkRenderer * GetRenderer ()
 
virtual vtkMRMLAbstractWidgetRepresentationGetRepresentation ()
 Get the representation. More...
 
virtual int GetWidgetState ()
 Convenient method to determine the state of the method. More...
 
virtual int IsA (const char *type)
 
virtual void Leave (vtkMRMLInteractionEventData *eventData)
 Called when the the widget loses the focus. More...
 
virtual void NeedToRenderOff ()
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
virtual bool ProcessInteractionEvent (vtkMRMLInteractionEventData *eventData)
 
void SetEventTranslation (int widgetState, unsigned long interactionEvent, int modifiers, unsigned long widgetEvent)
 
void SetEventTranslation (unsigned long interactionEvent, int modifiers, unsigned long widgetEvent)
 
void SetEventTranslationClickAndDrag (int widgetState, unsigned long startInteractionEvent, int modifiers, int widgetStateDragging, unsigned long widgetStartEvent, unsigned long widgetEndEvent)
 
void SetKeyboardEventTranslation (int modifier, char keyCode, int repeatCount, const char *keySym, unsigned long widgetEvent)
 
void SetKeyboardEventTranslation (int widgetState, int modifier, char keyCode, int repeatCount, const char *keySym, unsigned long widgetEvent)
 
virtual void SetMRMLApplicationLogic (vtkMRMLApplicationLogic *applicationLogic)
 
void SetRenderer (vtkRenderer *renderer)
 
virtual void SetRepresentation (vtkMRMLAbstractWidgetRepresentation *r)
 
virtual void SetWidgetState (int)
 Convenient method to change what state the widget is in. More...
 
virtual unsigned long TranslateInteractionEventToWidgetEvent (vtkMRMLInteractionEventData *eventData)
 Get widget event from translation event. More...
 
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. More...
 

Static Public Member Functions

static int IsTypeOf (const char *type)
 
static vtkMRMLAbstractWidgetSafeDownCast (vtkObject *o)
 

Protected Member Functions

bool CanProcessButtonClickEvent (vtkMRMLInteractionEventData *eventData, double &distance2)
 Generate a button click event and checks if it can be processed with CanProcessInteractionEvent. More...
 
const char * GetAssociatedNodeID (vtkMRMLInteractionEventData *eventData)
 
virtual int ProcessButtonClickEvent (vtkMRMLInteractionEventData *eventData)
 
unsigned long TranslateInteractionEventToWidgetEvent (vtkWidgetEventTranslator *translator, vtkMRMLInteractionEventData *eventData)
 Helper function that attempts to translate an event with a specific translator only. More...
 
 vtkMRMLAbstractWidget ()
 
 ~vtkMRMLAbstractWidget () override
 

Protected Attributes

vtkWeakPointer< vtkMRMLApplicationLogicApplicationLogic
 
std::vector< vtkSmartPointer< vtkWidgetEventTranslator > > EventTranslators
 
vtkWeakPointer< vtkRenderer > Renderer
 
vtkSmartPointer< vtkMRMLAbstractWidgetRepresentationWidgetRep
 
int WidgetState
 

Detailed Description

Process interaction events to update state of MRML widget nodes.

vtkMRMLAbstractWidget is the abstract class that handles interaction events received from the displayable manager. To decide which widget gets the chance to process an interaction event, this class does not use VTK picking manager, but interactor style class queries displayable managers about what events they can process, displayable manager queries its widgets, and based on the returned information, interactor style selects a displayable manager and the displayable manager selects a widget.

vtkAbstractWidget uses vtkSlicerWidgetEventTranslator to translate VTK interaction events (defined in vtkCommand.h) into widget events (defined in vtkMRMLAbstractWidget.h and subclasses). This class allows modification of event bindings.

See also
vtkSlicerWidgetRepresentation vtkSlicerWidgetEventTranslator

Definition at line 59 of file vtkMRMLAbstractWidget.h.

Member Typedef Documentation

◆ Superclass

Standard methods for a VTK class.

Definition at line 63 of file vtkMRMLAbstractWidget.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The state of the widget.

Enumerator
WidgetStateAny 

this state is used for referring to any widget state (for defining event translations)

WidgetStateIdle 

mouse pointer is outside the widget, click does not do anything

WidgetStateOnWidget 

mouse pointer is over the widget, clicking will add a point or manipulate the line

WidgetStateTranslate 

mouse move transforms the entire widget

WidgetStateRotate 

mouse move transforms the entire widget

WidgetStateScale 

mouse move transforms the entire widget

WidgetStateUser 

this is a starting index that can be used for widget-specific states

Definition at line 86 of file vtkMRMLAbstractWidget.h.

◆ WidgetEvents

Widget events.

Enumerator
WidgetEventNone 
WidgetEventMouseMove 
WidgetEventTranslateStart 
WidgetEventTranslateEnd 
WidgetEventRotateStart 
WidgetEventRotateEnd 
WidgetEventScaleStart 
WidgetEventScaleEnd 
WidgetEventPick 

generates a MRML Pick event (e.g., on left click)

WidgetEventJumpCursor 

jumps cursor to the selected position

WidgetEventAction 
WidgetEventCustomAction1 

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

WidgetEventCustomAction3 

allows modules to define custom widget actions and get notification via MRML node event

WidgetEventCustomAction4 

allows modules to define custom widget actions and get notification via MRML node event

WidgetEventCustomAction5 

allows modules to define custom widget actions and get notification via MRML node event

WidgetEventCustomAction6 

allows modules to define custom widget actions and get notification via MRML node event

WidgetEventSelect 

change MRML node Selected attribute

WidgetEventUnselect 

change MRML node Selected attribute

WidgetEventToggleSelect 

change MRML node Selected attribute

WidgetEventMenu 

show context menu

WidgetEventReset 

reset widget to initial state (clear all points)

WidgetEventUser 

this is a starting index that can be used for widget-specific events

Definition at line 98 of file vtkMRMLAbstractWidget.h.

Constructor & Destructor Documentation

◆ vtkMRMLAbstractWidget()

vtkMRMLAbstractWidget::vtkMRMLAbstractWidget ( )
protected

◆ ~vtkMRMLAbstractWidget()

vtkMRMLAbstractWidget::~vtkMRMLAbstractWidget ( )
overrideprotected

Member Function Documentation

◆ CanProcessButtonClickEvent()

bool vtkMRMLAbstractWidget::CanProcessButtonClickEvent ( vtkMRMLInteractionEventData eventData,
double &  distance2 
)
protected

Generate a button click event and checks if it can be processed with CanProcessInteractionEvent.

◆ CanProcessInteractionEvent()

virtual bool vtkMRMLAbstractWidget::CanProcessInteractionEvent ( vtkMRMLInteractionEventData eventData,
double &  distance2 
)
virtual

Return true if the widget can process the event. Distance2 is the squared distance in display coordinates from the closest interaction position. The displayable manager with the closest distance will get the chance to process the interaction event.

Reimplemented in vtkSlicerMarkupsWidget, vtkMRMLWindowLevelWidget, vtkSlicerPlaneWidget, vtkSlicerROIWidget, vtkMRMLSliceIntersectionWidget, and vtkMRMLCameraWidget.

◆ GetAssociatedNodeID()

const char* vtkMRMLAbstractWidget::GetAssociatedNodeID ( vtkMRMLInteractionEventData eventData)
protected

Get ID of the node at the specified event position. Returns nullptr if nothing can be found.

◆ GetClassName()

virtual const char* vtkMRMLAbstractWidget::GetClassName ( )
virtual

◆ GetEventTranslator()

virtual vtkWidgetEventTranslator* vtkMRMLAbstractWidget::GetEventTranslator ( int  widgetState)
virtual

◆ GetGrabFocus()

virtual bool vtkMRMLAbstractWidget::GetGrabFocus ( )
virtual

◆ GetInteractionNode()

vtkMRMLInteractionNode* vtkMRMLAbstractWidget::GetInteractionNode ( )

◆ GetInteractive()

virtual bool vtkMRMLAbstractWidget::GetInteractive ( )
virtual

Reimplemented in vtkSlicerMarkupsWidget.

◆ GetMouseCursor()

virtual int vtkMRMLAbstractWidget::GetMouseCursor ( )
virtual

◆ GetMRMLApplicationLogic()

vtkMRMLApplicationLogic* vtkMRMLAbstractWidget::GetMRMLApplicationLogic ( )

◆ GetNeedToRender()

virtual bool vtkMRMLAbstractWidget::GetNeedToRender ( )
virtual

◆ GetNumberOfEventTranslators()

virtual int vtkMRMLAbstractWidget::GetNumberOfEventTranslators ( )
virtual

◆ GetRenderer()

vtkRenderer* vtkMRMLAbstractWidget::GetRenderer ( )

◆ GetRepresentation()

virtual vtkMRMLAbstractWidgetRepresentation* vtkMRMLAbstractWidget::GetRepresentation ( )
virtual

Get the representation.

◆ GetWidgetState()

virtual int vtkMRMLAbstractWidget::GetWidgetState ( )
virtual

Convenient method to determine the state of the method.

◆ IsA()

virtual int vtkMRMLAbstractWidget::IsA ( const char *  type)
virtual

◆ IsTypeOf()

static int vtkMRMLAbstractWidget::IsTypeOf ( const char *  type)
static

◆ Leave()

virtual void vtkMRMLAbstractWidget::Leave ( vtkMRMLInteractionEventData eventData)
virtual

Called when the the widget loses the focus.

Reimplemented in vtkSlicerMarkupsWidget, vtkMRMLWindowLevelWidget, and vtkMRMLSliceIntersectionWidget.

◆ NeedToRenderOff()

virtual void vtkMRMLAbstractWidget::NeedToRenderOff ( )
virtual

◆ PrintSelf()

void vtkMRMLAbstractWidget::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
override

◆ ProcessButtonClickEvent()

virtual int vtkMRMLAbstractWidget::ProcessButtonClickEvent ( vtkMRMLInteractionEventData eventData)
protectedvirtual

Generate a button click event and get it processed with ProcessInteractionEvent. Returns true if the event was processed.

◆ ProcessInteractionEvent()

virtual bool vtkMRMLAbstractWidget::ProcessInteractionEvent ( vtkMRMLInteractionEventData eventData)
virtual

Allows injecting interaction events for processing, without directly observing window interactor events. Return true if the widget processed the event.

Reimplemented in vtkSlicerMarkupsWidget, vtkMRMLWindowLevelWidget, vtkSlicerPlaneWidget, vtkMRMLSliceIntersectionWidget, vtkSlicerROIWidget, and vtkMRMLCameraWidget.

◆ SafeDownCast()

static vtkMRMLAbstractWidget* vtkMRMLAbstractWidget::SafeDownCast ( vtkObject *  o)
static

◆ SetEventTranslation() [1/2]

void vtkMRMLAbstractWidget::SetEventTranslation ( int  widgetState,
unsigned long  interactionEvent,
int  modifiers,
unsigned long  widgetEvent 
)

Define interaction event to widget event translation for mouse and other controller events Used in the specified widget state only.

◆ SetEventTranslation() [2/2]

void vtkMRMLAbstractWidget::SetEventTranslation ( unsigned long  interactionEvent,
int  modifiers,
unsigned long  widgetEvent 
)

Define interaction event to widget event translation for mouse and other controller events. Used in any widget state.

◆ SetEventTranslationClickAndDrag()

void vtkMRMLAbstractWidget::SetEventTranslationClickAndDrag ( int  widgetState,
unsigned long  startInteractionEvent,
int  modifiers,
int  widgetStateDragging,
unsigned long  widgetStartEvent,
unsigned long  widgetEndEvent 
)

◆ SetKeyboardEventTranslation() [1/2]

void vtkMRMLAbstractWidget::SetKeyboardEventTranslation ( int  modifier,
char  keyCode,
int  repeatCount,
const char *  keySym,
unsigned long  widgetEvent 
)

Define interaction event to widget event translation for keyboard events. Used in any widget state.

◆ SetKeyboardEventTranslation() [2/2]

void vtkMRMLAbstractWidget::SetKeyboardEventTranslation ( int  widgetState,
int  modifier,
char  keyCode,
int  repeatCount,
const char *  keySym,
unsigned long  widgetEvent 
)

Define interaction event to widget event translation for keyboard events. Used in the specified widget state only.

◆ SetMRMLApplicationLogic()

virtual void vtkMRMLAbstractWidget::SetMRMLApplicationLogic ( vtkMRMLApplicationLogic applicationLogic)
virtual

◆ SetRenderer()

void vtkMRMLAbstractWidget::SetRenderer ( vtkRenderer *  renderer)

◆ SetRepresentation()

virtual void vtkMRMLAbstractWidget::SetRepresentation ( vtkMRMLAbstractWidgetRepresentation r)
virtual

Set the representation. The widget takes over the ownership of this actor.

◆ SetWidgetState()

virtual void vtkMRMLAbstractWidget::SetWidgetState ( int  )
virtual

Convenient method to change what state the widget is in.

◆ TranslateInteractionEventToWidgetEvent() [1/2]

virtual unsigned long vtkMRMLAbstractWidget::TranslateInteractionEventToWidgetEvent ( vtkMRMLInteractionEventData eventData)
virtual

Get widget event from translation event.

◆ TranslateInteractionEventToWidgetEvent() [2/2]

unsigned long vtkMRMLAbstractWidget::TranslateInteractionEventToWidgetEvent ( vtkWidgetEventTranslator *  translator,
vtkMRMLInteractionEventData eventData 
)
protected

Helper function that attempts to translate an event with a specific translator only.

◆ UpdateFromMRML()

virtual void vtkMRMLAbstractWidget::UpdateFromMRML ( vtkMRMLNode caller,
unsigned long  event,
void *  callData = nullptr 
)
virtual

Build the actors of the representation with the info stored in the MRML scene.

Member Data Documentation

◆ ApplicationLogic

vtkWeakPointer<vtkMRMLApplicationLogic> vtkMRMLAbstractWidget::ApplicationLogic
protected

Definition at line 206 of file vtkMRMLAbstractWidget.h.

◆ EventTranslators

std::vector< vtkSmartPointer<vtkWidgetEventTranslator> > vtkMRMLAbstractWidget::EventTranslators
protected

Definition at line 212 of file vtkMRMLAbstractWidget.h.

◆ Renderer

vtkWeakPointer<vtkRenderer> vtkMRMLAbstractWidget::Renderer
protected

Definition at line 204 of file vtkMRMLAbstractWidget.h.

◆ WidgetRep

vtkSmartPointer<vtkMRMLAbstractWidgetRepresentation> vtkMRMLAbstractWidget::WidgetRep
protected

Definition at line 216 of file vtkMRMLAbstractWidget.h.

◆ WidgetState

int vtkMRMLAbstractWidget::WidgetState
protected

Definition at line 214 of file vtkMRMLAbstractWidget.h.


The documentation for this class was generated from the following file: