VTK  9.3.20240329
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
vtkWidgetSet Class Reference

Synchronize a collection on vtkWidgets drawn on different renderwindows using the Callback - Dispatch Action mechanism. More...

#include <vtkWidgetSet.h>

Inheritance diagram for vtkWidgetSet:
[legend]
Collaboration diagram for vtkWidgetSet:
[legend]

Public Types

typedef std::vector< vtkAbstractWidget * > WidgetContainerType
 
typedef WidgetContainerType::iterator WidgetIteratorType
 
typedef WidgetContainerType::const_iterator WidgetConstIteratorType
 

Public Member Functions

void AddWidget (vtkAbstractWidget *)
 Add a widget to the set. More...
 
void RemoveWidget (vtkAbstractWidget *)
 Remove a widget from the set. More...
 
unsigned int GetNumberOfWidgets ()
 Get number of widgets in the set. More...
 
vtkAbstractWidgetGetNthWidget (unsigned int)
 Get the Nth widget in the set. More...
 
virtual void SetEnabled (vtkTypeBool)
 Method for activating and deactivating all widgets in the group. More...
 
virtual void EnabledOn ()
 Method for activating and deactivating all widgets in the group. More...
 
virtual void EnabledOff ()
 Method for activating and deactivating all widgets in the group. More...
 
template<class TWidget >
void DispatchAction (TWidget *caller, typename ActionFunction< TWidget >::TActionFunctionPointer action)
 Dispatch an "Action" to every widget in this set. More...
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 Turn debugging output on. More...
 
virtual void DebugOff ()
 Turn debugging output off. More...
 
bool GetDebug ()
 Get the value of the debug flag. More...
 
void SetDebug (bool debugFlag)
 Set the value of the debug flag. More...
 
virtual void Modified ()
 Update the modification time for this object. More...
 
virtual vtkMTimeType GetMTime ()
 Return this object's modified time. More...
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
vtkTypeBool HasObserver (unsigned long event)
 
vtkTypeBool HasObserver (const char *event)
 
vtkTypeBool InvokeEvent (unsigned long event)
 
vtkTypeBool InvokeEvent (const char *event)
 
std::string GetObjectDescription () const override
 The object description printed in messages and PrintSelf output. More...
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkCommandGetCommand (unsigned long tag)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObserver (vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Allow user to set the AbortFlagOn() with the return value of the callback method. More...
 
vtkTypeBool InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
vtkTypeBool InvokeEvent (const char *event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
virtual void SetObjectName (const std::string &objectName)
 Set/get the name of this object for reporting purposes. More...
 
virtual std::string GetObjectName () const
 Set/get the name of this object for reporting purposes. More...
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. More...
 
virtual vtkIdType GetNumberOfGenerationsFromBase (const char *name)
 Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
virtual void Delete ()
 Delete a VTK object. More...
 
virtual void FastDelete ()
 Delete a reference to this object. More...
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream. More...
 
void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object). More...
 
virtual void UnRegister (vtkObjectBase *o)
 Decrease the reference count (release by another object). More...
 
int GetReferenceCount ()
 Return the current reference count of this object. More...
 
void SetReferenceCount (int)
 Sets the reference count. More...
 
bool GetIsInMemkind () const
 A local state flag that remembers whether this object lives in the normal or extended memory space. More...
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual bool UsesGarbageCollector () const
 Indicate whether the class uses vtkGarbageCollector or not. More...
 

Static Public Member Functions

static vtkWidgetSetNew ()
 Instantiate this class. More...
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void BreakOnError ()
 This method is called when vtkErrorMacro executes. More...
 
static void SetGlobalWarningDisplay (vtkTypeBool val)
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOn ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOff ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static vtkTypeBool GetGlobalWarningDisplay ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class. More...
 
static vtkIdType GetNumberOfGenerationsFromBaseType (const char *name)
 Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void SetMemkindDirectory (const char *directoryname)
 The name of a directory, ideally mounted -o dax, to memory map an extended memory space within. More...
 
static bool GetUsingMemkind ()
 A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space. More...
 

Public Attributes

WidgetContainerType Widget
 

Protected Member Functions

 vtkWidgetSet ()
 
 ~vtkWidgetSet () override
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
 ~vtkObject () override
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
 These methods allow a command to exclusively grab all events. More...
 
void InternalReleaseFocus ()
 These methods allow a command to exclusively grab all events. More...
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 
typedef vtkObject Superclass
 Standard methods for a VTK class. More...
 
static vtkTypeBool IsTypeOf (const char *type)
 Standard methods for a VTK class. More...
 
static vtkWidgetSetSafeDownCast (vtkObjectBase *o)
 Standard methods for a VTK class. More...
 
virtual vtkTypeBool IsA (const char *type)
 Standard methods for a VTK class. More...
 
vtkWidgetSetNewInstance () const
 Standard methods for a VTK class. More...
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Standard methods for a VTK class. More...
 
virtual vtkObjectBaseNewInstanceInternal () const
 Standard methods for a VTK class. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from vtkObjectBase
static vtkMallocingFunction GetCurrentMallocFunction ()
 
static vtkReallocingFunction GetCurrentReallocFunction ()
 
static vtkFreeingFunction GetCurrentFreeFunction ()
 
static vtkFreeingFunction GetAlternateFreeFunction ()
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
std::string ObjectName
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

Synchronize a collection on vtkWidgets drawn on different renderwindows using the Callback - Dispatch Action mechanism.

The class synchronizes a set of vtkAbstractWidget(s). Widgets typically invoke "Actions" that drive the geometry/behaviour of their representations in response to interactor events. Interactor interactions on a render window are mapped into "Callbacks" by the widget, from which "Actions" are dispatched to the entire set. This architecture allows us to tie widgets existing in different render windows together. For instance a HandleWidget might exist on the sagittal view. Moving it around should update the representations of the corresponding handle widget that lies on the axial and coronal and volume views as well.

User API:
A user would use this class as follows.
set->AddWidget(w1);
w1->SetInteractor(axialRenderWindow->GetInteractor());
set->AddWidget(w2);
w2->SetInteractor(coronalRenderWindow->GetInteractor());
set->AddWidget(w3);
w3->SetInteractor(sagittalRenderWindow->GetInteractor());
set->SetEnabled(1);
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
This method is used to associate the widget with the render window interactor.
a widget to manipulate 3D parallelopipeds
static vtkParallelopipedWidget * New()
Instantiate the object.
Synchronize a collection on vtkWidgets drawn on different renderwindows using the Callback - Dispatch...
Definition: vtkWidgetSet.h:103
virtual void SetEnabled(vtkTypeBool)
Method for activating and deactivating all widgets in the group.
void AddWidget(vtkAbstractWidget *)
Add a widget to the set.
static vtkWidgetSet * New()
Instantiate this class.
Motivation:
The motivation for this class is really to provide a usable API to tie together multiple widgets of the same kind. To enable this, subclasses of vtkAbstractWidget, must be written as follows: They will generally have callback methods mapped to some user interaction such as:
this->CallbackMapper->SetCallbackMethod(vtkCommand::LeftButtonPressEvent,
vtkEvent::NoModifier, 0, 0, nullptr,
vtkPaintbrushWidget::BeginDrawStrokeEvent,
this, vtkPaintbrushWidget::BeginDrawCallback);
@ LeftButtonPressEvent
Definition: vtkCommand.h:451
@ NoModifier
Definition: vtkEvent.h:46
The callback invoked when the left button is pressed looks like:
void vtkPaintbrushWidget::BeginDrawCallback(vtkAbstractWidget *w)
{
vtkPaintbrushWidget *self = vtkPaintbrushWidget::SafeDownCast(w);
self->WidgetSet->DispatchAction(self, &vtkPaintbrushWidget::BeginDrawAction);
}
define the API for widget / widget representation
The actual code for handling the drawing is written in the BeginDrawAction method.
void vtkPaintbrushWidget::BeginDrawAction( vtkPaintbrushWidget *dispatcher)
{
// Do stuff to draw...
// Here dispatcher is the widget that was interacted with, the one that
// dispatched an action to all the other widgets in its group. You may, if
// necessary find it helpful to get parameters from it.
// For instance for a ResizeAction:
// if (this != dispatcher)
// {
// double *newsize = dispatcher->GetRepresentation()->GetSize();
// this->WidgetRep->SetSize(newsize);
// }
// else
// {
// this->WidgetRep->IncrementSizeByDelta();
// }
}
Warning
Actions are always dispatched first to the activeWidget, the one calling the set, and then to the other widgets in the set.

Definition at line 102 of file vtkWidgetSet.h.

Member Typedef Documentation

◆ Superclass

Standard methods for a VTK class.

Definition at line 114 of file vtkWidgetSet.h.

◆ WidgetContainerType

Definition at line 148 of file vtkWidgetSet.h.

◆ WidgetIteratorType

typedef WidgetContainerType::iterator vtkWidgetSet::WidgetIteratorType

Definition at line 149 of file vtkWidgetSet.h.

◆ WidgetConstIteratorType

typedef WidgetContainerType::const_iterator vtkWidgetSet::WidgetConstIteratorType

Definition at line 150 of file vtkWidgetSet.h.

Constructor & Destructor Documentation

◆ vtkWidgetSet()

vtkWidgetSet::vtkWidgetSet ( )
protected

◆ ~vtkWidgetSet()

vtkWidgetSet::~vtkWidgetSet ( )
overrideprotected

Member Function Documentation

◆ New()

static vtkWidgetSet* vtkWidgetSet::New ( )
static

Instantiate this class.

◆ IsTypeOf()

static vtkTypeBool vtkWidgetSet::IsTypeOf ( const char *  type)
static

Standard methods for a VTK class.

◆ IsA()

virtual vtkTypeBool vtkWidgetSet::IsA ( const char *  type)
virtual

Standard methods for a VTK class.

Reimplemented from vtkObjectBase.

◆ SafeDownCast()

static vtkWidgetSet* vtkWidgetSet::SafeDownCast ( vtkObjectBase o)
static

Standard methods for a VTK class.

◆ NewInstanceInternal()

virtual vtkObjectBase* vtkWidgetSet::NewInstanceInternal ( ) const
protectedvirtual

Standard methods for a VTK class.

◆ NewInstance()

vtkWidgetSet* vtkWidgetSet::NewInstance ( ) const

Standard methods for a VTK class.

◆ PrintSelf()

void vtkWidgetSet::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
overridevirtual

Standard methods for a VTK class.

Reimplemented from vtkObject.

◆ SetEnabled()

virtual void vtkWidgetSet::SetEnabled ( vtkTypeBool  )
virtual

Method for activating and deactivating all widgets in the group.

◆ EnabledOn()

virtual void vtkWidgetSet::EnabledOn ( )
virtual

Method for activating and deactivating all widgets in the group.

◆ EnabledOff()

virtual void vtkWidgetSet::EnabledOff ( )
virtual

Method for activating and deactivating all widgets in the group.

◆ AddWidget()

void vtkWidgetSet::AddWidget ( vtkAbstractWidget )

Add a widget to the set.

◆ RemoveWidget()

void vtkWidgetSet::RemoveWidget ( vtkAbstractWidget )

Remove a widget from the set.

◆ GetNumberOfWidgets()

unsigned int vtkWidgetSet::GetNumberOfWidgets ( )

Get number of widgets in the set.

◆ GetNthWidget()

vtkAbstractWidget* vtkWidgetSet::GetNthWidget ( unsigned int  )

Get the Nth widget in the set.

◆ DispatchAction()

template<class TWidget >
void vtkWidgetSet::DispatchAction ( TWidget *  caller,
typename ActionFunction< TWidget >::TActionFunctionPointer  action 
)
inline

Dispatch an "Action" to every widget in this set.

This is meant to be invoked from a "Callback" in a widget.

Definition at line 159 of file vtkWidgetSet.h.

Member Data Documentation

◆ Widget

WidgetContainerType vtkWidgetSet::Widget

Definition at line 151 of file vtkWidgetSet.h.


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