10#ifndef __vtkMRMLAbstractLogic_h
11#define __vtkMRMLAbstractLogic_h
22#include <vtkCommand.h>
27#include "vtkMRMLLogicExport.h"
34#ifndef vtkSetMRMLNodeMacro
35# define vtkSetMRMLNodeMacro(node, value) \
37 vtkObject* _oldNode = (node); \
38 this->GetMRMLNodesObserverManager()->SetObject(vtkObjectPointer(&(node)), (value)); \
39 vtkObject* _newNode = (node); \
40 if (_oldNode != _newNode) \
48#ifndef vtkSetAndObserveMRMLNodeMacro
65# define vtkSetAndObserveMRMLNodeMacro(node, value) \
67 vtkObject* _oldNode = (node); \
68 this->GetMRMLNodesObserverManager()->SetAndObserveObject(vtkObjectPointer(&(node)), (value)); \
69 vtkObject* _newNode = (node); \
70 if (_oldNode != _newNode) \
78#ifndef vtkSetAndObserveMRMLNodeEventsMacro
79# define vtkSetAndObserveMRMLNodeEventsMacro(node, value, events) \
81 vtkObject* _oldNode = (node); \
82 this->GetMRMLNodesObserverManager()->SetAndObserveObjectEvents(vtkObjectPointer(&(node)), (value), (events)); \
83 vtkObject* _newNode = (node); \
84 if (_oldNode != _newNode) \
91#ifndef vtkObserveMRMLNodeMacro
92# define vtkObserveMRMLNodeMacro(node) \
94 this->GetMRMLNodesObserverManager()->ObserveObject((node)); \
98#ifndef vtkObserveMRMLNodeEventsMacro
99# define vtkObserveMRMLNodeEventsMacro(node, events) \
101 this->GetMRMLNodesObserverManager()->AddObjectEvents((node), (events)); \
105#ifndef vtkUnObserveMRMLNodeMacro
106# define vtkUnObserveMRMLNodeMacro(node) \
108 this->GetMRMLNodesObserverManager()->RemoveObjectEvents((node)); \
112#ifndef vtkIsObservedMRMLNodeEventMacro
113# define vtkIsObservedMRMLNodeEventMacro(node, event) (this->GetMRMLNodesObserverManager()->GetObservationsCount(node, event) != 0)
158 void SetAndObserveMRMLSceneEvents(
vtkMRMLScene* newScene, vtkIntArray* events, vtkFloatArray* priorities =
nullptr);
314 void SetAndObserveMRMLSceneInternal(
vtkMRMLScene* newScene);
390 static void MRMLSceneCallback(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
393 static void MRMLNodesCallback(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
396 static void MRMLLogicsCallback(vtkObject* caller,
unsigned long eid,
void* clientData,
void* callData);
429 vtkInternal* Internal;
437 return disabledModify;
444 if (!previousDisableModifiedEventState)
int GetProcessingMRMLSceneEvent() const
Return the event id currently processed or 0 if any.
virtual void OnMRMLSceneStartImport()
virtual void OnMRMLSceneStartClose()
virtual void OnMRMLNodeModified(vtkMRMLNode *)
vtkMRMLScene * GetMRMLScene() const
Return a reference to the current MRML scene.
vtkCallbackCommand * GetMRMLLogicsCallbackCommand()
int GetInMRMLSceneCallbackFlag() const
static vtkMRMLAbstractLogic * New()
void PrintSelf(ostream &os, vtkIndent indent) override
vtkCallbackCommand * GetMRMLNodesCallbackCommand()
void SetDisableModifiedEvent(bool onOff)
~vtkMRMLAbstractLogic() override
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData)
virtual bool EnterMRMLLogicsCallback() const
void SetInMRMLNodesCallbackFlag(int flag)
vtkCallbackCommand * GetMRMLSceneCallbackCommand()
virtual void UpdateFromMRMLScene()
void SetMRMLScene(vtkMRMLScene *newScene)
Set and observe the MRMLScene.
virtual void ProcessMRMLSceneEvents(vtkObject *caller, unsigned long event, void *callData)
virtual vtkMRMLApplicationLogic * GetMRMLApplicationLogic() const
Get access to overall application state.
virtual bool EnterMRMLSceneCallback() const
static void MRMLLogicsCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
MRMLLogicCallback is a static function to relay modified events from the logics.
static void MRMLNodesCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
MRMLNodesCallback is a static function to relay modified events from the nodes.
vtkObserverManager * GetMRMLLogicsObserverManager() const
bool GetDisableModifiedEvent() const
virtual void OnMRMLSceneEndClose()
vtkObserverManager * GetMRMLNodesObserverManager() const
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode *)
virtual void SetMRMLApplicationLogic(vtkMRMLApplicationLogic *logic)
virtual void UnobserveMRMLScene()
void(vtkMRMLAbstractLogic::* TaskFunctionPointer)(void *clientdata)
int EndModify(bool wasModifying)
int GetPendingModifiedEventCount() const
virtual void ObserveMRMLScene()
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
void SetAndObserveMRMLSceneEventsInternal(vtkMRMLScene *newScene, vtkIntArray *events, vtkFloatArray *priorities=nullptr)
virtual void OnMRMLSceneEndBatchProcess()
void SetInMRMLLogicsCallbackFlag(int flag)
virtual void OnMRMLSceneNew()
void SetInMRMLSceneCallbackFlag(int flag)
virtual void RegisterNodes()
int GetInMRMLNodesCallbackFlag() const
virtual void ProcessMRMLLogicsEvents(vtkObject *caller, unsigned long event, void *callData)
int InvokePendingModifiedEvent()
int GetInMRMLLogicsCallbackFlag() const
virtual void OnMRMLSceneEndImport()
virtual bool EnterMRMLNodesCallback() const
virtual void OnMRMLSceneStartRestore()
vtkObserverManager * GetMRMLSceneObserverManager() const
void SetProcessingMRMLSceneEvent(int event)
virtual void OnMRMLSceneEndRestore()
static void MRMLSceneCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
virtual void OnMRMLSceneStartBatchProcess()
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
Manages adding and deleting of observers with events.