Slicer 5.6
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLNode.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: vtkMRMLNode.h,v $
10 Date: $Date: 2006/03/19 17:12:29 $
11 Version: $Revision: 1.18 $
12
13=========================================================================auto=*/
14
15#ifndef __vtkMRMLNode_h
16#define __vtkMRMLNode_h
17
18// MRML includes
19#include "vtkMRML.h"
20#include "vtkObserverManager.h"
21#include "vtkIdTypeArray.h"
22#include "vtkIntArray.h"
23
24class vtkMRMLScene;
25class vtkStringArray;
26
27// VTK includes
28#include <vtkObject.h>
29#include <vtkSmartPointer.h>
30#include <vtkWeakPointer.h>
31class vtkCallbackCommand;
32
33// Slicer VTK add-on includes
34#include <vtkLoggingMacros.h>
35
36// Helper macros for simplifying reading, writing, copying, and printing node properties.
38
39// STD includes
40#include <map>
41#include <set>
42#include <string>
43#include <vector>
44
45#ifndef vtkSetMRMLObjectMacro
46#define vtkSetMRMLObjectMacro(node,value) {this->MRMLObserverManager->SetObject ( vtkObjectPointer( &(node)), (value) );};
47#endif
48
50#ifndef vtkSetAndObserveMRMLObjectMacro
51#define vtkSetAndObserveMRMLObjectMacro(node,value) {this->MRMLObserverManager->SetAndObserveObject ( vtkObjectPointer( &(node)), (value) );};
52#endif
53
54#ifndef vtkSetAndObserveMRMLObjectMacroNoWarning
55#define vtkSetAndObserveMRMLObjectMacroNoWarning(node,value) {this->MRMLObserverManager->SetAndObserveObject ( vtkObjectPointer( &(node)), (value), 0.0, false /* no warning */ );};
56#endif
57
58#ifndef vtkSetAndObserveMRMLObjectEventsMacro
59#define vtkSetAndObserveMRMLObjectEventsMacro(node,value,events) {this->MRMLObserverManager->SetAndObserveObjectEvents ( vtkObjectPointer( &(node)), (value), (events));};
60#endif
61
62#ifndef vtkSetAndObserveMRMLObjectEventsMacroNoWarning
63#define vtkSetAndObserveMRMLObjectEventsMacroNoWarning(node,value,events) {this->MRMLObserverManager->SetAndObserveObjectEvents ( vtkObjectPointer( &(node)), (value), (events), nullptr /* priorities */, false /* no warning */);};
64#endif
65
66#ifndef vtkObserveMRMLObjectMacro
67#define vtkObserveMRMLObjectMacro(node) {this->MRMLObserverManager->ObserveObject ( (node) );};
68#endif
69
70#ifndef vtkObserveMRMLObjectEventsMacro
71#define vtkObserveMRMLObjectEventsMacro(node, events) {this->MRMLObserverManager->AddObjectEvents ( (node), (events) );};
72#endif
73
74#ifndef vtkUnObserveMRMLObjectMacro
75#define vtkUnObserveMRMLObjectMacro(node) {this->MRMLObserverManager->RemoveObjectEvents ( (node) );};
76#endif
77
78#ifndef vtkSetReferenceStringBodyMacro
79#define vtkSetReferenceStringBodyMacro(name) \
80 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to " << (_arg?_arg:"(null)") ); \
81 if ( this->name == nullptr && _arg == nullptr) { return;} \
82 if ( this->name && _arg && (!strcmp(this->name,_arg))) { return;} \
83 std::string oldValue; \
84 if (this->name) { oldValue = this->name; delete [] this->name; } \
85 if (_arg) \
86 { \
87 size_t n = strlen(_arg) + 1; \
88 char *cp1 = new char[n]; \
89 const char *cp2 = (_arg); \
90 this->name = cp1; \
91 do { *cp1++ = *cp2++; } while ( --n ); \
92 } \
93 else \
94 { \
95 this->name = nullptr; \
96 } \
97 this->Modified(); \
98 if (this->Scene && this->name) \
99 { \
100 if (oldValue.size() > 0) \
101 { \
102 this->Scene->RemoveReferencedNodeID(oldValue.c_str(), this); \
103 } \
104 this->Scene->AddReferencedNodeID(this->name, this); \
105 }
106#endif
107
108#ifndef vtkSetReferenceStringMacro
109#define vtkSetReferenceStringMacro(name) \
110virtual void Set##name (const char* _arg) \
111 { \
112 vtkSetReferenceStringBodyMacro(name)\
113 }
114#endif
115
116#ifndef vtkCxxSetReferenceStringMacro
117#define vtkCxxSetReferenceStringMacro(class,name) \
118void class::Set##name (const char* _arg) \
119 { \
120 vtkSetReferenceStringBodyMacro(name); \
121 }
122#endif
123
124#ifndef vtkMRMLNodeNewMacro
125#define vtkMRMLNodeNewMacro(newClass) \
126 vtkStandardNewMacro(newClass); \
127 vtkMRMLNode* newClass::CreateNodeInstance() \
128 { \
129 return newClass::New(); \
130 }
131#endif
132
133// Use this macro to declare that this node supports
134// CopyContent.It also declares CopyContent and
135// HasCopyContent methods.
136//
137// The use of HasCopyContent() may be needed to determine if
138// a specific node class has implemented CopyContent (if only
139// a parent class implemented it that may not be enough).
140//
141#ifndef vtkMRMLCopyContentMacro
142#define vtkMRMLCopyContentMacro(thisClassName) \
143 void CopyContent(vtkMRMLNode* node, bool deepCopy=true) override; \
144 bool HasCopyContent() const override \
145 { \
146 return strcmp(#thisClassName, this->GetClassNameInternal()) == 0; \
147 }
148#endif
149
150// Use this macro to declare that this node supports
151// CopyContent by only declaring HasCopyContent without
152// implementing CopyContent method
153// (this is the case when parent classes copy all content).
154#ifndef vtkMRMLCopyContentDefaultMacro
155#define vtkMRMLCopyContentDefaultMacro(thisClassName) \
156 bool HasCopyContent() const override \
157 { \
158 return strcmp(#thisClassName, this->GetClassNameInternal()) == 0; \
159 }
160#endif
161
167class VTK_MRML_EXPORT vtkMRMLNode : public vtkObject
168{
171 friend class vtkMRMLScene;
173
174public:
175 vtkTypeMacro(vtkMRMLNode,vtkObject);
176 void PrintSelf(ostream& os, vtkIndent indent) override;
177
181 {
182 ContentModifiedObserveUndefined = -1,
183 ContentModifiedObserveDisabled = 0,
184 ContentModifiedObserveEnabled = 1
185 };
186
191
193 virtual bool HasCopyContent() const;
194
200 virtual void ReadXMLAttributes(const char** atts);
201
206 virtual void UpdateReferences();
207
210 virtual void ProcessChildNode(vtkMRMLNode *){};
211
215 virtual void UpdateScene(vtkMRMLScene *)
216 {
217 this->UpdateNodeReferences();
218 };
219
222 virtual void OnNodeAddedToScene()
223 {
224 this->UpdateNodeReferences();
225 };
226
233 virtual void WriteXML(ostream& of, int indent);
234
236 virtual void WriteNodeBodyXML(ostream& of, int indent);
237
244 virtual void Copy(vtkMRMLNode *node);
245
255 virtual void CopyContent(vtkMRMLNode* node, bool deepCopy=true);
256
261 virtual void CopyReferences(vtkMRMLNode* node);
262
278
299 virtual void Reset(vtkMRMLNode* defaultNode);
300
307 virtual int StartModify()
308 {
309 int disabledModify = this->GetDisableModifiedEvent();
310 this->DisableModifiedEventOn();
311 return disabledModify;
312 };
313
321 virtual int EndModify(int previousDisableModifiedEventState)
322 {
323 this->SetDisableModifiedEvent(previousDisableModifiedEventState);
324 if (!previousDisableModifiedEventState)
325 {
326 return this->InvokePendingModifiedEvent();
327 }
328 return this->ModifiedEventPending;
329 };
330
331
335 virtual const char* GetNodeTagName() = 0;
336
340 virtual const char* GetTypeDisplayName()
341 {
342 return this->GetNodeTagName();
343 }
344
356 void SetAttribute(const char* name, const char* value);
357
359 void RemoveAttribute(const char* name);
360
364 const char* GetAttribute(const char* name);
365
367 std::vector< std::string > GetAttributeNames();
368
370 void GetAttributeNames(vtkStringArray* attributeNames);
371
373 vtkGetMacro(HideFromEditors, int);
374 vtkSetMacro(HideFromEditors, int);
375 vtkBooleanMacro(HideFromEditors, int);
376
378 vtkGetMacro(Selectable, int);
379 vtkSetMacro(Selectable, int);
380 vtkBooleanMacro(Selectable, int);
381
391 vtkGetMacro(UndoEnabled, bool);
392 vtkSetMacro(UndoEnabled, bool);
393 vtkBooleanMacro(UndoEnabled, bool);
394
396 virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData );
397
402 vtkGetMacro(InMRMLCallbackFlag, int);
403 void SetInMRMLCallbackFlag (int flag) {
404 this->InMRMLCallbackFlag = flag;
405 }
406
408 vtkSetStringMacro(Description);
409 vtkGetStringMacro(Description);
410
412 vtkSetStringMacro(Name);
413 vtkGetStringMacro(Name);
414
416 //vtkSetStringMacro(ID);
417 vtkGetStringMacro(ID);
418
445 vtkSetStringMacro(SingletonTag);
446 vtkGetStringMacro(SingletonTag);
448 {
449 this->SetSingletonTag("Singleton");
450 }
452 {
453 this->SetSingletonTag(nullptr);
454 }
456 {
457 return (this->GetSingletonTag() != nullptr);
458 }
459
461 vtkGetMacro(SaveWithScene, int);
462 vtkSetMacro(SaveWithScene, int);
463 vtkBooleanMacro(SaveWithScene, int);
464
466 vtkGetMacro(AddToScene, int);
467 vtkSetMacro(AddToScene, int);
468 vtkBooleanMacro(AddToScene, int);
469 void SetAddToSceneNoModify(int value);
470
472 vtkGetMacro(DisableModifiedEvent, int);
474 {
475 this->DisableModifiedEvent = onOff;
476 }
478 {
479 this->SetDisableModifiedEvent(1);
480 }
482 {
483 this->SetDisableModifiedEvent(0);
484 }
485
491 vtkGetMacro(ModifiedEventPending, int);
492
499 {
500 std::map< int, int >::iterator it = this->CustomModifiedEventPending.find(eventId);
501 if (it == this->CustomModifiedEventPending.end())
502 {
503 return 0;
504 }
505 else
506 {
507 return it->second;
508 }
509 }
510
524 void Modified() override
525 {
526 if (!this->GetDisableModifiedEvent())
527 {
528 Superclass::Modified();
529 }
530 else
531 {
532 ++this->ModifiedEventPending;
533 }
534 }
535
544 {
545 int oldModifiedEventPending = 0;
546 // Invoke pending standard Modified event
547 if ( this->ModifiedEventPending )
548 {
549 oldModifiedEventPending += this->ModifiedEventPending;
550 this->ModifiedEventPending = 0;
551 Superclass::Modified();
552 }
553 // Invoke pending custom modified events
554 if (!this->CustomModifiedEventPending.empty())
555 {
556 // Need to make a copy of the event IDs stored in this->CustomModifiedEventPending,
557 // because event invocation may add more events to this->CustomModifiedEventPending,
558 // which would then make the iterator invalid.
559 std::vector<int> customEventsToInvoke;
560 for (std::map< int, int >::iterator it=this->CustomModifiedEventPending.begin(); it!=this->CustomModifiedEventPending.end(); ++it)
561 {
562 oldModifiedEventPending += it->second;
563 customEventsToInvoke.push_back(it->first);
564 }
565 this->CustomModifiedEventPending.clear();
566 for (std::vector<int>::iterator it=customEventsToInvoke.begin(); it!=customEventsToInvoke.end(); ++it)
567 {
568 this->InvokeEvent(*it);
569 }
570 }
571 return oldModifiedEventPending;
572 }
573
586 virtual void InvokeCustomModifiedEvent(int eventId, void *callData=nullptr)
587 {
588 if (!this->GetDisableModifiedEvent())
589 {
590 // DisableModify is inactive, we immediately invoke the event
591 this->InvokeEvent(eventId, callData);
592 }
593 else
594 {
595 // just remember the custom modified event and invoke it once,
596 // when DisableModify is deactivated
597 ++this->CustomModifiedEventPending[eventId];
598 }
599 }
600
603
609 virtual void SetScene(vtkMRMLScene* scene);
610
615 virtual void SetSceneReferences();
616
618 virtual void UpdateReferenceID(const char *oldID, const char *newID);
619
624 vtkGetObjectMacro(ContentModifiedEvents, vtkIntArray);
625
632 const char *URLEncodeString(const char *inString);
633
640 const char *URLDecodeString(const char *inString);
641
645 std::string XMLAttributeEncodeString(const std::string& inString);
646
654 std::string XMLAttributeDecodeString(const std::string& inString);
655
657 vtkGetMacro(Selected, int);
658 vtkSetMacro(Selected, int);
659 vtkBooleanMacro(Selected, int);
660
681 void AddNodeReferenceRole(const char *referenceRole, const char *mrmlAttributeName=nullptr,
682 vtkIntArray *events=nullptr, bool observeContentModifiedEvents=false);
683
685 vtkMRMLNode* SetNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
686
688 vtkMRMLNode* AddNodeReferenceID(const char* referenceRole , const char* referencedNodeID);
689
692 vtkMRMLNode* SetNthNodeReferenceID(const char* referenceRole, int n, const char* referencedNodeID);
693
703 vtkMRMLNode* SetAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID,
704 vtkIntArray *events=nullptr, ContentModifiedObserveType observeContentModifiedEvents=ContentModifiedObserveUndefined);
705
715 vtkMRMLNode* AddAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID,
716 vtkIntArray *events=nullptr, ContentModifiedObserveType observeContentModifiedEvents=ContentModifiedObserveUndefined);
717
739 vtkMRMLNode* SetAndObserveNthNodeReferenceID(const char* referenceRole, int n, const char *referencedNodeID,
740 vtkIntArray *events=nullptr, ContentModifiedObserveType observeContentModifiedEvents=ContentModifiedObserveUndefined);
741
743 void RemoveNthNodeReferenceID(const char* referenceRole, int n);
744
748 void RemoveNodeReferenceIDs(const char* referenceRole);
749
754 bool HasNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
755
758 int GetNumberOfNodeReferences(const char* referenceRole);
759
766 const char *GetNthNodeReferenceID(const char* referenceRole, int n);
767
772 const char *GetNodeReferenceID(const char* referenceRole);
773
784 vtkMRMLNode* GetNthNodeReference(const char* referenceRole, int n);
785
788 vtkMRMLNode* GetNodeReference(const char* referenceRole);
789
797 void GetNodeReferences(const char* referenceRole, std::vector<vtkMRMLNode*> &nodes);
798
804 void GetNodeReferenceIDs(const char* referenceRole,
805 std::vector<const char*> &referencedNodeIDs);
806
809 void GetNodeReferenceRoles(std::vector<std::string> &roles);
810
814
817 const char* GetNthNodeReferenceRole(int n);
818
821 enum
822 {
823 HierarchyModifiedEvent = 16000,
824 IDChangedEvent = 16001,
828 ReferencedNodeModifiedEvent
829 };
830
831
832protected:
833
835 class VTK_MRML_EXPORT vtkMRMLNodeReference : public vtkObject
836 {
837 public:
838 vtkTypeMacro(vtkMRMLNodeReference,vtkObject);
840 void PrintSelf(ostream& vtkNotUsed(os), vtkIndent vtkNotUsed(indent)) override {};
841
842 public:
843 vtkSetStringMacro(ReferenceRole);
844 vtkGetStringMacro(ReferenceRole);
845
846 vtkSetStringMacro(ReferencedNodeID);
847 vtkGetStringMacro(ReferencedNodeID);
848
854 void SetStaticEvents(vtkIntArray* events);
855 vtkIntArray* GetStaticEvents() const;
856
858 vtkSetMacro(ObserveContentModifiedEvents, ContentModifiedObserveType);
859 vtkGetMacro(ObserveContentModifiedEvents, ContentModifiedObserveType);
860
863
866
867 protected:
870
873
876
878 vtkWeakPointer<vtkMRMLNode> ReferencingNode;
880 vtkSmartPointer<vtkMRMLNode> ReferencedNode;
881
886 vtkSmartPointer<vtkIntArray> StaticEvents;
891 };
892
895 ~vtkMRMLNode() override;
897 void operator=(const vtkMRMLNode&);
898
901 static void MRMLCallback( vtkObject *caller,
902 unsigned long eid, void *clientData, void *callData );
903
906 vtkSetStringMacro( TempURLString );
907 vtkGetStringMacro( TempURLString );
908
916 virtual const char* GetReferenceRoleFromMRMLAttributeName(const char* attName);
917
925 virtual const char* GetMRMLAttributeNameFromReferenceRole(const char* refRole);
926
930 virtual bool IsReferenceRoleGeneric(const char* refRole);
931
935 virtual void UpdateNodeReferences(const char* referenceRole = nullptr);
936
940 void RemoveInvalidReferences(const std::set<std::string>& validNodeIDs);
941
946 virtual void UpdateNthNodeReference(const char* referenceRole, int n);
947
952 vtkIntArray *newEvents, bool newObserveContentModifiedEvents, vtkMRMLNodeReference* referenceToIgnore);
953
959 void GetUpdatedReferencedNodeEventList(int& oldReferencedNodeUseCount, int& newReferencedNodeUseCount,
960 vtkIntArray* oldConsolidatedEventList, vtkIntArray* newConsolidatedEventList,
961 vtkMRMLNode* oldReferencedNode, vtkMRMLNode* newReferencedNode,
962 vtkMRMLNodeReference* referenceToIgnore, vtkIntArray* newEvents, bool newObserveContentModifiedEvents);
963
967
972 {
973 this->InvokeEvent(vtkMRMLNode::ReferenceAddedEvent, reference);
974 }
975
978 {
979 this->InvokeEvent(vtkMRMLNode::ReferenceModifiedEvent, reference);
980 }
981
984 {
985 this->InvokeEvent(vtkMRMLNode::ReferenceRemovedEvent, reference);
986 }
987
990 void ParseReferencesAttribute(const char *attValue, std::set<std::string> &references);
991
993 vtkCallbackCommand *MRMLCallbackCommand;
994
995 char *ID{nullptr};
996 char *Name{nullptr};
997 char *Description{nullptr};
998 int HideFromEditors{0};
999 int Selectable{1};
1000 int Selected{0};
1001 int AddToScene{1};
1002 bool UndoEnabled{false};
1003
1004 int SaveWithScene{true};
1005
1008 int InMRMLCallbackFlag{0};
1009
1010 // We don't increase the reference count of Scene when store its pointer
1011 // therefore we must use a weak pointer to prevent pointer dangling when
1012 // the scene is deleted.
1013 vtkWeakPointer<vtkMRMLScene> Scene;
1014
1015 typedef std::map< std::string, std::string > AttributesType;
1017
1019
1021
1024 typedef std::vector< vtkSmartPointer<vtkMRMLNodeReference> > NodeReferenceListType;
1025 typedef std::map< std::string, NodeReferenceListType > NodeReferencesType;
1027
1028 std::map< std::string, std::string> NodeReferenceMRMLAttributeNames;
1029
1031 {
1032 vtkSmartPointer<vtkIntArray> StaticEvents;
1033 ContentModifiedObserveType ObserveContentModifiedEvents{ ContentModifiedObserveUndefined };
1034 };
1035 typedef std::map< std::string, NodeReferenceEventList> NodeReferenceEventsType;
1036 NodeReferenceEventsType NodeReferenceEvents; // for each role it specifies which referenced node emitted events this node should observe
1037
1038private:
1039
1042 void SetID(const char* newID);
1043
1045 char *TempURLString{nullptr};
1046
1047 char *SingletonTag{nullptr};
1048
1049 int DisableModifiedEvent{0};
1050 int ModifiedEventPending{0};
1051 std::map<int, int> CustomModifiedEventPending; // event id, pending value (number of events grouped together)
1052};
1053
1062class VTK_MRML_EXPORT MRMLNodeModifyBlocker
1063{
1064public:
1065 vtkWeakPointer<vtkMRMLNode> Node;
1068 {
1069 this->Node = node;
1070 if (this->Node)
1071 {
1072 this->WasModifying = this->Node->StartModify();
1073 }
1074 };
1076 {
1077 if (this->Node)
1078 {
1079 this->Node->EndModify(this->WasModifying);
1080 }
1081 }
1082};
1083
1084#endif
Safe replacement of MRML node start/end modify.
MRMLNodeModifyBlocker(vtkMRMLNode *node)
vtkWeakPointer< vtkMRMLNode > Node
Class to hold information about a node reference.
void SetReferencingNode(vtkMRMLNode *node)
vtkIntArray * GetStaticEvents() const
void PrintSelf(ostream &vtkNotUsed(os), vtkIndent vtkNotUsed(indent)) override
vtkMRMLNodeReference(const vtkMRMLNodeReference &)
vtkWeakPointer< vtkMRMLNode > ReferencingNode
Points to this MRML node (that added the reference)
vtkSmartPointer< vtkIntArray > StaticEvents
Events that should be observed.
void SetReferencedNode(vtkMRMLNode *node)
static vtkMRMLNodeReference * New()
vtkMRMLNode * GetReferencingNode() const
char * ReferenceRole
Name of the reference role.
vtkMRMLNode * GetReferencedNode() const
void SetStaticEvents(vtkIntArray *events)
Set the events that will be observed when the referenced node will be available.
vtkSmartPointer< vtkMRMLNode > ReferencedNode
The referenced node that is actually observed now.
void operator=(const vtkMRMLNodeReference &)
Abstract Superclass for all specific types of MRML nodes.
virtual void UpdateReferences()
The method should remove all pointers and observations to all nodes that are not in the scene anymore...
void DisableModifiedEventOn()
std::vector< vtkSmartPointer< vtkMRMLNodeReference > > NodeReferenceListType
virtual void SetScene(vtkMRMLScene *scene)
This method is for internal use only. Use AddNode method of vtkMRMLScene to add a node to the scene.
virtual int StartModify()
Start modifying the node. Disable Modify events.
vtkMRMLNode * GetNodeReference(const char *referenceRole)
vtkMRMLNode * AddAndObserveNodeReferenceID(const char *referenceRole, const char *referencedNodeID, vtkIntArray *events=nullptr, ContentModifiedObserveType observeContentModifiedEvents=ContentModifiedObserveUndefined)
Add and observe a reference node from this node for a specific referenceRole.
void DisableModifiedEventOff()
virtual void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference)
Called when a referenced node pointer is removed (set to nullptr).
void ParseReferencesAttribute(const char *attValue, std::set< std::string > &references)
virtual void UpdateNodeReferences(const char *referenceRole=nullptr)
virtual void UpdateNthNodeReference(const char *referenceRole, int n)
int GetNumberOfNodeReferenceRoles()
virtual void OnNodeReferenceModified(vtkMRMLNodeReference *reference)
Called when a referenced node pointer is modified.
virtual const char * GetMRMLAttributeNameFromReferenceRole(const char *refRole)
Return the mrml attribute name (if found) associated with a reference role. Return 0 otherwise.
virtual void WriteNodeBodyXML(ostream &of, int indent)
Write this node's body to a MRML file in XML format.
NodeReferenceEventsType NodeReferenceEvents
vtkMRMLNode * AddNodeReferenceID(const char *referenceRole, const char *referencedNodeID)
Convenience method that adds a referencedNodeID at the end of the list.
vtkMRMLNode * UpdateNodeReferenceEventObserver(vtkMRMLNode *oldReferencedNode, vtkMRMLNode *newReferencedNode, vtkIntArray *newEvents, bool newObserveContentModifiedEvents, vtkMRMLNodeReference *referenceToIgnore)
void GetAttributeNames(vtkStringArray *attributeNames)
Get all attribute names. Python-wrappable version.
void GetNodeReferenceRoles(std::vector< std::string > &roles)
void SetAddToSceneNoModify(int value)
void RemoveNthNodeReferenceID(const char *referenceRole, int n)
Convenience method that removes the Nth node ID from the list.
virtual int InvokePendingModifiedEvent()
Invokes any modified events that are pending.
std::map< std::string, NodeReferenceListType > NodeReferencesType
virtual void CopyReferences(vtkMRMLNode *node)
Copy the references of the node into this.
virtual void InvalidateNodeReferences()
virtual void Reset(vtkMRMLNode *defaultNode)
Reset node attributes to the initial state as defined in the constructor or the passed default node.
vtkIntArray * ContentModifiedEvents
std::string XMLAttributeEncodeString(const std::string &inString)
Encode an XML attribute string (replaces special characters by code sequences)
AttributesType Attributes
NodeReferencesType NodeReferences
@ ContentModifiedObserveUndefined
Observe content modified events if it is enabled in the node reference role.
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
void GetNodeReferences(const char *referenceRole, std::vector< vtkMRMLNode * > &nodes)
Return a list of the referenced nodes.
virtual const char * GetNodeTagName()=0
std::map< std::string, std::string > NodeReferenceMRMLAttributeNames
void RemoveNodeReferenceIDs(const char *referenceRole)
Remove all node IDs and associated nodes for a specific referenceRole.
void RemoveInvalidReferences(const std::set< std::string > &validNodeIDs)
bool HasNodeReferenceID(const char *referenceRole, const char *referencedNodeID)
Return true if referencedNodeID is in the node ID list for a specific referenceRole.
virtual const char * GetTypeDisplayName()
virtual void ReadXMLAttributes(const char **atts)
void GetUpdatedReferencedNodeEventList(int &oldReferencedNodeUseCount, int &newReferencedNodeUseCount, vtkIntArray *oldConsolidatedEventList, vtkIntArray *newConsolidatedEventList, vtkMRMLNode *oldReferencedNode, vtkMRMLNode *newReferencedNode, vtkMRMLNodeReference *referenceToIgnore, vtkIntArray *newEvents, bool newObserveContentModifiedEvents)
virtual void OnNodeAddedToScene()
virtual bool HasCopyContent() const
Returns true if the class supports deep and shallow copying node content.
virtual void SetSceneReferences()
Update the references of the node to the scene.
const char * GetNodeReferenceID(const char *referenceRole)
Utility function that returns the first node id for a specific referenceRole.
virtual void OnNodeReferenceAdded(vtkMRMLNodeReference *reference)
std::map< std::string, NodeReferenceEventList > NodeReferenceEventsType
virtual bool IsReferenceRoleGeneric(const char *refRole)
Return true if the reference role is generic (ends with '/') or false otherwise.
void SetAttribute(const char *name, const char *value)
Set a name value pair attribute.
const char * GetNthNodeReferenceRole(int n)
void RemoveAttribute(const char *name)
Remove attribute with the specified name.
virtual void CopyContent(vtkMRMLNode *node, bool deepCopy=true)
Copy node contents from another node of the same type. Does not copy node ID, Scene,...
const char * URLEncodeString(const char *inString)
Encode a URL string.
const char * GetNthNodeReferenceID(const char *referenceRole, int n)
Return the string of the Nth node ID for a specific reference role.
virtual int EndModify(int previousDisableModifiedEventState)
End modifying the node.
void CopyWithScene(vtkMRMLNode *node)
Copy everything (including Scene and ID) from another node of the same type.
void GetNodeReferenceIDs(const char *referenceRole, std::vector< const char * > &referencedNodeIDs)
Return a list of the referenced node IDs.
void PrintSelf(ostream &os, vtkIndent indent) override
int GetNumberOfNodeReferences(const char *referenceRole)
Return the number of node IDs for a specific reference role (and nodes as they always have the same s...
vtkMRMLNode * SetAndObserveNthNodeReferenceID(const char *referenceRole, int n, const char *referencedNodeID, vtkIntArray *events=nullptr, ContentModifiedObserveType observeContentModifiedEvents=ContentModifiedObserveUndefined)
Set and observe the Nth node ID for a specific reference role.
virtual vtkMRMLScene * GetScene()
Get the scene this node has been added to.
@ ReferenceModifiedEvent
@ ReferenceRemovedEvent
const char * URLDecodeString(const char *inString)
Decode a URL string.
vtkMRMLNode * SetNodeReferenceID(const char *referenceRole, const char *referencedNodeID)
Set a reference to a node with specified nodeID from this node for a specific referenceRole.
vtkObserverManager * MRMLObserverManager
virtual void WriteXML(ostream &of, int indent)
void SetSingletonOff()
vtkCallbackCommand * MRMLCallbackCommand
Holders for MRML callbacks.
vtkWeakPointer< vtkMRMLScene > Scene
bool IsSingleton()
vtkMRMLNode * SetAndObserveNodeReferenceID(const char *referenceRole, const char *referencedNodeID, vtkIntArray *events=nullptr, ContentModifiedObserveType observeContentModifiedEvents=ContentModifiedObserveUndefined)
Set and observe a reference node from this node for a specific referenceRole.
std::vector< std::string > GetAttributeNames()
Get all attribute names.
virtual void UpdateReferenceID(const char *oldID, const char *newID)
Update the stored reference to another node in the scene.
void SetDisableModifiedEvent(int onOff)
const char * GetAttribute(const char *name)
Get value of a name value pair attribute.
virtual const char * GetReferenceRoleFromMRMLAttributeName(const char *attName)
Return the reference role (if found) associated with the attribute name found in a MRML scene file....
void Modified() override
Customized version of Modified() allowing to compress vtkCommand::ModifiedEvent.
void AddNodeReferenceRole(const char *referenceRole, const char *mrmlAttributeName=nullptr, vtkIntArray *events=nullptr, bool observeContentModifiedEvents=false)
Add a referenceRole.
int GetCustomModifiedEventPending(int eventId)
virtual void ProcessChildNode(vtkMRMLNode *)
Set dependencies between this node and a child node when parsing XML file.
void operator=(const vtkMRMLNode &)
void SetInMRMLCallbackFlag(int flag)
virtual void InvokeCustomModifiedEvent(int eventId, void *callData=nullptr)
This method allows the node to compress events.
std::map< std::string, std::string > AttributesType
virtual void Copy(vtkMRMLNode *node)
Copy node contents from another node of the same type. Does not copy node ID and Scene....
std::string XMLAttributeDecodeString(const std::string &inString)
Decode an XML attribute string.
vtkMRMLNode * GetNthNodeReference(const char *referenceRole, int n)
Get referenced MRML node for a specific referenceRole.
vtkMRMLNode * SetNthNodeReferenceID(const char *referenceRole, int n, const char *referencedNodeID)
Set a N-th reference from this node with specified referencedNodeID for a specific referenceRole.
void SetSingletonOn()
virtual void UpdateScene(vtkMRMLScene *)
~vtkMRMLNode() override
critical to have a virtual destructor!
vtkMRMLNode(const vtkMRMLNode &)
virtual void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData)
Propagate events generated in mrml.
static void MRMLCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
A set of MRML Nodes that supports serialization and undo/redo.
Manages adding and deleting of observers with events.
vtkSmartPointer< vtkIntArray > StaticEvents