VTK
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 vtkObject Superclass
 
typedef std::vector< vtkAbstractWidget * > WidgetContainerType
 
typedef WidgetContainerType::iterator WidgetIteratorType
 
typedef WidgetContainerType::const_iterator WidgetConstIteratorType
 
- Public Types inherited from vtkObject
typedef vtkObjectBase Superclass
 

Public Member Functions

virtual int IsA (const char *type)
 
vtkWidgetSetNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent)
 
virtual void SetEnabled (int)
 
virtual void EnabledOn ()
 
virtual void EnabledOff ()
 
void AddWidget (vtkAbstractWidget *)
 
void RemoveWidget (vtkAbstractWidget *)
 
unsigned int GetNumberOfWidgets ()
 
vtkAbstractWidgetGetNthWidget (unsigned int)
 
template<class TWidget >
void DispatchAction (TWidget *caller, typename ActionFunction< TWidget >::TActionFunctionPointer action)
 
- Public Member Functions inherited from vtkObject
vtkObjectNewInstance () const
 
virtual void DebugOn ()
 
virtual void DebugOff ()
 
bool GetDebug ()
 
void SetDebug (bool debugFlag)
 
virtual void Modified ()
 
virtual unsigned long GetMTime ()
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 
vtkCommandGetCommand (unsigned long tag)
 
void RemoveObserver (vtkCommand *)
 
void RemoveObservers (unsigned long event, vtkCommand *)
 
void RemoveObservers (const char *event, vtkCommand *)
 
int HasObserver (unsigned long event, vtkCommand *)
 
int HasObserver (const char *event, vtkCommand *)
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
int HasObserver (unsigned long event)
 
int HasObserver (const char *event)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
int InvokeEvent (unsigned long event, void *callData)
 
int InvokeEvent (const char *event, void *callData)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 
virtual void Delete ()
 
virtual void FastDelete ()
 
void Print (ostream &os)
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 
virtual void Register (vtkObjectBase *o)
 
virtual void UnRegister (vtkObjectBase *o)
 
int GetReferenceCount ()
 
void SetReferenceCount (int)
 
void PrintRevisions (ostream &)
 

Static Public Member Functions

static vtkWidgetSetNew ()
 
static int IsTypeOf (const char *type)
 
static vtkWidgetSetSafeDownCast (vtkObjectBase *o)
 
- Static Public Member Functions inherited from vtkObject
static int IsTypeOf (const char *type)
 
static vtkObjectSafeDownCast (vtkObjectBase *o)
 
static vtkObjectNew ()
 
static void BreakOnError ()
 
static void SetGlobalWarningDisplay (int val)
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static int GetGlobalWarningDisplay ()
 
- Static Public Member Functions inherited from vtkObjectBase
static int IsTypeOf (const char *name)
 
static vtkObjectBaseNew ()
 

Public Attributes

WidgetContainerType Widget
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkWidgetSet ()
 
 ~vtkWidgetSet ()
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
virtual ~vtkObject ()
 
virtual void RegisterInternal (vtkObjectBase *, int check)
 
virtual void UnRegisterInternal (vtkObjectBase *, int check)
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
 
void InternalReleaseFocus ()
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void CollectRevisions (ostream &)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Additional Inherited Members

- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
- Protected Attributes inherited from vtkObjectBase
vtkAtomicInt32 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);
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, NULL,
vtkPaintbrushWidget::BeginDrawStrokeEvent,
this, vtkPaintbrushWidget::BeginDrawCallback);
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);
}
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 112 of file vtkWidgetSet.h.

Member Typedef Documentation

◆ Superclass

Standard methods for a VTK class.

Definition at line 120 of file vtkWidgetSet.h.

◆ WidgetContainerType

Definition at line 145 of file vtkWidgetSet.h.

◆ WidgetIteratorType

typedef WidgetContainerType::iterator vtkWidgetSet::WidgetIteratorType

Definition at line 146 of file vtkWidgetSet.h.

◆ WidgetConstIteratorType

typedef WidgetContainerType::const_iterator vtkWidgetSet::WidgetConstIteratorType

Definition at line 147 of file vtkWidgetSet.h.

Constructor & Destructor Documentation

◆ vtkWidgetSet()

vtkWidgetSet::vtkWidgetSet ( )
protected

◆ ~vtkWidgetSet()

vtkWidgetSet::~vtkWidgetSet ( )
protected

Member Function Documentation

◆ New()

static vtkWidgetSet* vtkWidgetSet::New ( )
static

Instantiate this class.

◆ IsTypeOf()

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

◆ IsA()

virtual int vtkWidgetSet::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase* vtkWidgetSet::NewInstanceInternal ( ) const
protectedvirtual

Reimplemented from vtkObject.

◆ NewInstance()

vtkWidgetSet* vtkWidgetSet::NewInstance ( ) const

◆ PrintSelf()

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

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

◆ SetEnabled()

virtual void vtkWidgetSet::SetEnabled ( int  )
virtual

Method for activating and deactivating all widgets in the group.

◆ EnabledOn()

virtual void vtkWidgetSet::EnabledOn ( )
virtual

◆ EnabledOff()

virtual void vtkWidgetSet::EnabledOff ( )
virtual

◆ 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 154 of file vtkWidgetSet.h.

Member Data Documentation

◆ Widget

WidgetContainerType vtkWidgetSet::Widget

Definition at line 148 of file vtkWidgetSet.h.


The documentation for this class was generated from the following file:
vtkWidgetSet::SetEnabled
virtual void SetEnabled(int)
vtkgl::w1
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
Definition: vtkgl.h:15056
vtkParallelopipedWidget::New
static vtkParallelopipedWidget * New()
vtkgl::w2
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
Definition: vtkgl.h:15056
vtkWidgetSet::New
static vtkWidgetSet * New()
vtkAbstractWidget
define the API for widget / widget representation
Definition: vtkAbstractWidget.h:66
vtkParallelopipedWidget
a widget to manipulate 3D parallelopipeds
Definition: vtkParallelopipedWidget.h:57
vtkWidgetSet
Synchronize a collection on vtkWidgets drawn on different renderwindows using the Callback - Dispatch...
Definition: vtkWidgetSet.h:113
vtkWidgetSet::AddWidget
void AddWidget(vtkAbstractWidget *)
vtkInteractorObserver::SetInteractor
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
vtkEvent::NoModifier
@ NoModifier
Definition: vtkEvent.h:51
vtkgl::w
GLubyte GLubyte GLubyte GLubyte w
Definition: vtkgl.h:12054