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
vtkObserverManager.h
Go to the documentation of this file.
1/*=auto=========================================================================
2
3 Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7
8 Program: 3D Slicer
9 Module: $RCSfile: vtkObserverManager.h,v $
10 Date: $Date: 2006/01/08 04:48:05 $
11 Version: $Revision: 1.45 $
12
13=========================================================================auto=*/
14
15#ifndef __vtkObserverManager_h
16#define __vtkObserverManager_h
17
18// MRML includes
19#include "vtkMRML.h"
20
21// VTK includes
22#include <vtkObject.h>
23
24// STD includes
25#include <map>
26
27class vtkCallbackCommand;
28class vtkIntArray;
29class vtkFloatArray;
30class vtkUnsignedLongArray;
31
32#ifndef vtkObjectPointer
33#define vtkObjectPointer(xx) (reinterpret_cast <vtkObject **>( (xx) ))
34#endif
35
41class VTK_MRML_EXPORT vtkObserverManager : public vtkObject
42{
43 public:
44
47 vtkTypeMacro(vtkObserverManager,vtkObject);
48 void PrintSelf(ostream& os, vtkIndent indent) override;
49
51 void SetObject(vtkObject **nodePtr, vtkObject *node);
52
54 void SetAndObserveObject(vtkObject **nodePtr, vtkObject *node, float priority=0.0, bool logWarningIfSameObservationExists=true);
55
57 void SetAndObserveObjectEvents(vtkObject **nodePtr, vtkObject *node, vtkIntArray *events, vtkFloatArray *priorities=nullptr, bool logWarningIfSameObservationExists=true);
58
60 void RemoveObjectEvents(vtkObject *nodePtr);
61
63 void GetObjectEvents(vtkObject *nodePtr, vtkIntArray *events, vtkFloatArray *priorities);
64
66 void ObserveObject(vtkObject *node, float priority=0.0, bool logWarningIfSameObservationExists=true);
67
69 void AddObjectEvent(vtkObject *node, unsigned long event, float priority=0.0, bool logWarningIfSameObservationExists=true);
70
72 void AddObjectEvents(vtkObject *nodePtr, vtkIntArray *events, vtkFloatArray *priorities=nullptr, bool logWarningIfSameObservationExists=true);
73
79 vtkGetObjectMacro (Owner, vtkObject);
80 void AssignOwner (vtkObject *owner) { this->Owner = owner; };
82 vtkObject* GetObserver();
83
84 vtkGetObjectMacro (CallbackCommand, vtkCallbackCommand);
85
88 int GetObservationsCount(vtkObject* nodePtr, unsigned long event = 0);
89protected:
94
97 vtkObject *Owner;
98
101 vtkCallbackCommand *CallbackCommand;
102
103 std::map< vtkObject*, vtkUnsignedLongArray* > ObserverTags;
104
105};
106
107#endif
vtkObserverManager(const vtkObserverManager &)
void SetAndObserveObjectEvents(vtkObject **nodePtr, vtkObject *node, vtkIntArray *events, vtkFloatArray *priorities=nullptr, bool logWarningIfSameObservationExists=true)
set vtkObject to a specified pointer, remove all observers for all events, add observers for specifie...
~vtkObserverManager() override
void GetObjectEvents(vtkObject *nodePtr, vtkIntArray *events, vtkFloatArray *priorities)
get a list of all observed events and priorities for the selected node
vtkCallbackCommand * CallbackCommand
Holder for callback.
vtkObject * Owner
The owner of the observer manager (e.g. the vtkMRMLNode)
void RemoveObjectEvents(vtkObject *nodePtr)
remove all observers for all events
void AddObjectEvent(vtkObject *node, unsigned long event, float priority=0.0, bool logWarningIfSameObservationExists=true)
add observers for specified events
void AddObjectEvents(vtkObject *nodePtr, vtkIntArray *events, vtkFloatArray *priorities=nullptr, bool logWarningIfSameObservationExists=true)
add observers for specified events
void ObserveObject(vtkObject *node, float priority=0.0, bool logWarningIfSameObservationExists=true)
observe ModifiedEvent on the object (convenience method that calls AddObjectEvent with ModifiedEvent)
void operator=(const vtkObserverManager &)
vtkObject * GetObserver()
Returns the owner if any, otherwise returns the manager itself.
void SetObject(vtkObject **nodePtr, vtkObject *node)
set vtkObject to a specified pointer and remove all observers for all events
static vtkObserverManager * New()
The Usual vtk class functions.
void AssignOwner(vtkObject *owner)
void SetAndObserveObject(vtkObject **nodePtr, vtkObject *node, float priority=0.0, bool logWarningIfSameObservationExists=true)
set vtkObject to a specified pointer, remove all observers for all events, add observer for Modify ev...
std::map< vtkObject *, vtkUnsignedLongArray * > ObserverTags
void PrintSelf(ostream &os, vtkIndent indent) override
int GetObservationsCount(vtkObject *nodePtr, unsigned long event=0)