Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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 
24 class vtkMRMLScene;
25 class vtkStringArray;
26 
27 // VTK includes
28 #include <vtkObject.h>
29 #include <vtkSmartPointer.h>
30 #include <vtkWeakPointer.h>
31 class 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) \
110 virtual void Set##name (const char* _arg) \
111  { \
112  vtkSetReferenceStringBodyMacro(name)\
113  }
114 #endif
115 
116 #ifndef vtkCxxSetReferenceStringMacro
117 #define vtkCxxSetReferenceStringMacro(class,name) \
118 void 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 
167 class VTK_MRML_EXPORT vtkMRMLNode : public vtkObject
168 {
171  friend class vtkMRMLScene;
172  friend class vtkMRMLSceneViewNode;
173 
174 public:
175  vtkTypeMacro(vtkMRMLNode,vtkObject);
176  void PrintSelf(ostream& os, vtkIndent indent) override;
177 
181  virtual vtkMRMLNode* CreateNodeInstance() = 0;
182 
184  virtual bool HasCopyContent() const;
185 
191  virtual void ReadXMLAttributes(const char** atts);
192 
197  virtual void UpdateReferences();
198 
201  virtual void ProcessChildNode(vtkMRMLNode *){};
202 
206  virtual void UpdateScene(vtkMRMLScene *)
207  {
208  this->UpdateNodeReferences();
209  };
210 
213  virtual void OnNodeAddedToScene()
214  {
215  this->UpdateNodeReferences();
216  };
217 
224  virtual void WriteXML(ostream& of, int indent);
225 
227  virtual void WriteNodeBodyXML(ostream& of, int indent);
228 
235  virtual void Copy(vtkMRMLNode *node);
236 
246  virtual void CopyContent(vtkMRMLNode* node, bool deepCopy=true);
247 
252  virtual void CopyReferences(vtkMRMLNode* node);
253 
268  void CopyWithScene(vtkMRMLNode *node);
269 
290  virtual void Reset(vtkMRMLNode* defaultNode);
291 
298  virtual int StartModify()
299  {
300  int disabledModify = this->GetDisableModifiedEvent();
301  this->DisableModifiedEventOn();
302  return disabledModify;
303  };
304 
312  virtual int EndModify(int previousDisableModifiedEventState)
313  {
314  this->SetDisableModifiedEvent(previousDisableModifiedEventState);
315  if (!previousDisableModifiedEventState)
316  {
317  return this->InvokePendingModifiedEvent();
318  }
319  return this->ModifiedEventPending;
320  };
321 
322 
326  virtual const char* GetNodeTagName() = 0;
327 
339  void SetAttribute(const char* name, const char* value);
340 
342  void RemoveAttribute(const char* name);
343 
347  const char* GetAttribute(const char* name);
348 
350  std::vector< std::string > GetAttributeNames();
351 
353  void GetAttributeNames(vtkStringArray* attributeNames);
354 
356  vtkGetMacro(HideFromEditors, int);
357  vtkSetMacro(HideFromEditors, int);
358  vtkBooleanMacro(HideFromEditors, int);
359 
361  vtkGetMacro(Selectable, int);
362  vtkSetMacro(Selectable, int);
363  vtkBooleanMacro(Selectable, int);
364 
374  vtkGetMacro(UndoEnabled, bool);
375  vtkSetMacro(UndoEnabled, bool);
376  vtkBooleanMacro(UndoEnabled, bool);
377 
379  virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData );
380 
385  vtkGetMacro(InMRMLCallbackFlag, int);
386  void SetInMRMLCallbackFlag (int flag) {
387  this->InMRMLCallbackFlag = flag;
388  }
389 
391  vtkSetStringMacro(Description);
392  vtkGetStringMacro(Description);
393 
395  vtkSetStringMacro(Name);
396  vtkGetStringMacro(Name);
397 
399  //vtkSetStringMacro(ID);
400  vtkGetStringMacro(ID);
401 
428  vtkSetStringMacro(SingletonTag);
429  vtkGetStringMacro(SingletonTag);
431  {
432  this->SetSingletonTag("Singleton");
433  }
435  {
436  this->SetSingletonTag(nullptr);
437  }
438  bool IsSingleton()
439  {
440  return (this->GetSingletonTag() != nullptr);
441  }
442 
444  vtkGetMacro(SaveWithScene, int);
445  vtkSetMacro(SaveWithScene, int);
446  vtkBooleanMacro(SaveWithScene, int);
447 
449  vtkGetMacro(AddToScene, int);
450  vtkSetMacro(AddToScene, int);
451  vtkBooleanMacro(AddToScene, int);
452  void SetAddToSceneNoModify(int value);
453 
455  vtkGetMacro(DisableModifiedEvent, int);
456  void SetDisableModifiedEvent(int onOff)
457  {
458  this->DisableModifiedEvent = onOff;
459  }
461  {
462  this->SetDisableModifiedEvent(1);
463  }
465  {
466  this->SetDisableModifiedEvent(0);
467  }
468 
474  vtkGetMacro(ModifiedEventPending, int);
475 
489  void Modified() override
490  {
491  if (!this->GetDisableModifiedEvent())
492  {
494  }
495  else
496  {
497  ++this->ModifiedEventPending;
498  }
499  }
500 
509  {
510  int oldModifiedEventPending = 0;
511  // Invoke pending standard Modified event
512  if ( this->ModifiedEventPending )
513  {
514  oldModifiedEventPending += this->ModifiedEventPending;
515  this->ModifiedEventPending = 0;
517  }
518  // Invoke pending custom modified events
519  if (!this->CustomModifiedEventPending.empty())
520  {
521  // Need to make a copy of the event IDs stored in this->CustomModifiedEventPending,
522  // because event invocation may add more events to this->CustomModifiedEventPending,
523  // which would then make the iterator invalid.
524  std::vector<int> customEventsToInvoke;
525  for (std::map< int, int >::iterator it=this->CustomModifiedEventPending.begin(); it!=this->CustomModifiedEventPending.end(); ++it)
526  {
527  oldModifiedEventPending += it->second;
528  customEventsToInvoke.push_back(it->first);
529  }
530  this->CustomModifiedEventPending.clear();
531  for (std::vector<int>::iterator it=customEventsToInvoke.begin(); it!=customEventsToInvoke.end(); ++it)
532  {
533  this->InvokeEvent(*it);
534  }
535  }
536  return oldModifiedEventPending;
537  }
538 
551  virtual void InvokeCustomModifiedEvent(int eventId, void *callData=nullptr)
552  {
553  if (!this->GetDisableModifiedEvent())
554  {
555  // DisableModify is inactive, we immediately invoke the event
556  this->InvokeEvent(eventId, callData);
557  }
558  else
559  {
560  // just remember the custom modified event and invoke it once,
561  // when DisableModify is deactivated
562  ++this->CustomModifiedEventPending[eventId];
563  }
564  }
565 
567  virtual vtkMRMLScene* GetScene();
568 
574  virtual void SetScene(vtkMRMLScene* scene);
575 
580  virtual void SetSceneReferences();
581 
583  virtual void UpdateReferenceID(const char *oldID, const char *newID);
584 
589  vtkGetObjectMacro(ContentModifiedEvents, vtkIntArray);
590 
597  const char *URLEncodeString(const char *inString);
598 
605  const char *URLDecodeString(const char *inString);
606 
610  std::string XMLAttributeEncodeString(const std::string& inString);
611 
619  std::string XMLAttributeDecodeString(const std::string& inString);
620 
622  vtkGetMacro(Selected, int);
623  vtkSetMacro(Selected, int);
624  vtkBooleanMacro(Selected, int);
625 
641  void AddNodeReferenceRole(const char *referenceRole, const char *mrmlAttributeName=nullptr, vtkIntArray *events=nullptr);
642 
644  vtkMRMLNode* SetNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
645 
647  vtkMRMLNode* AddNodeReferenceID(const char* referenceRole , const char* referencedNodeID);
648 
651  vtkMRMLNode* SetNthNodeReferenceID(const char* referenceRole, int n, const char* referencedNodeID);
652 
657  vtkMRMLNode* SetAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID, vtkIntArray *events=nullptr);
658 
663  vtkMRMLNode* AddAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID, vtkIntArray *events=nullptr);
664 
680  vtkMRMLNode* SetAndObserveNthNodeReferenceID(const char* referenceRole, int n, const char *referencedNodeID, vtkIntArray *events=nullptr);
681 
683  void RemoveNthNodeReferenceID(const char* referenceRole, int n);
684 
688  void RemoveNodeReferenceIDs(const char* referenceRole);
689 
694  bool HasNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
695 
698  int GetNumberOfNodeReferences(const char* referenceRole);
699 
706  const char *GetNthNodeReferenceID(const char* referenceRole, int n);
707 
712  const char *GetNodeReferenceID(const char* referenceRole);
713 
724  vtkMRMLNode* GetNthNodeReference(const char* referenceRole, int n);
725 
728  vtkMRMLNode* GetNodeReference(const char* referenceRole);
729 
737  void GetNodeReferences(const char* referenceRole, std::vector<vtkMRMLNode*> &nodes);
738 
744  void GetNodeReferenceIDs(const char* referenceRole,
745  std::vector<const char*> &referencedNodeIDs);
746 
749  void GetNodeReferenceRoles(std::vector<std::string> &roles);
750 
754 
757  const char* GetNthNodeReferenceRole(int n);
758 
761  enum
762  {
764  IDChangedEvent = 16001,
769  };
770 
771 
772 protected:
773 
775  class VTK_MRML_EXPORT vtkMRMLNodeReference : public vtkObject
776  {
777  public:
778  vtkTypeMacro(vtkMRMLNodeReference,vtkObject);
779  static vtkMRMLNodeReference *New();
780  void PrintSelf(ostream& vtkNotUsed(os), vtkIndent vtkNotUsed(indent)) override {};
781 
782  public:
783  vtkSetStringMacro(ReferenceRole);
784  vtkGetStringMacro(ReferenceRole);
785 
786  vtkSetStringMacro(ReferencedNodeID);
787  vtkGetStringMacro(ReferencedNodeID);
788 
794  void SetEvents(vtkIntArray* events);
795  vtkIntArray* GetEvents() const;
796 
797  void SetReferencingNode(vtkMRMLNode* node);
798  vtkMRMLNode* GetReferencingNode() const;
799 
800  void SetReferencedNode(vtkMRMLNode* node);
801  vtkMRMLNode* GetReferencedNode() const;
802 
803  protected:
805  ~vtkMRMLNodeReference() override;
806 
808  void operator=(const vtkMRMLNodeReference&);
809 
812 
814  vtkWeakPointer<vtkMRMLNode> ReferencingNode;
816  vtkSmartPointer<vtkMRMLNode> ReferencedNode;
817 
823  vtkSmartPointer<vtkIntArray> Events;
824  };
825 
826  vtkMRMLNode();
828  ~vtkMRMLNode() override;
829  vtkMRMLNode(const vtkMRMLNode&);
830  void operator=(const vtkMRMLNode&);
831 
834  static void MRMLCallback( vtkObject *caller,
835  unsigned long eid, void *clientData, void *callData );
836 
839  vtkSetStringMacro( TempURLString );
840  vtkGetStringMacro( TempURLString );
841 
849  virtual const char* GetReferenceRoleFromMRMLAttributeName(const char* attName);
850 
858  virtual const char* GetMRMLAttributeNameFromReferenceRole(const char* refRole);
859 
863  virtual bool IsReferenceRoleGeneric(const char* refRole);
864 
868  virtual void UpdateNodeReferences(const char* referenceRole = nullptr);
869 
874  virtual void UpdateNthNodeReference(const char* referenceRole, int n);
875 
879  vtkMRMLNode* UpdateNodeReferenceEventObserver(vtkMRMLNode *oldReferencedNode, vtkMRMLNode *newReferencedNode,
880  vtkIntArray *newEvents, vtkMRMLNodeReference* referenceToIgnore);
881 
887  void GetUpdatedReferencedNodeEventList(int& oldReferencedNodeUseCount, int& newReferencedNodeUseCount,
888  vtkIntArray* oldConsolidatedEventList, vtkIntArray* newConsolidatedEventList,
889  vtkMRMLNode* oldReferencedNode, vtkMRMLNode* newReferencedNode,
890  vtkMRMLNodeReference* referenceToIgnore, vtkIntArray* newEvents);
891 
894  virtual void InvalidateNodeReferences();
895 
900  {
901  this->InvokeEvent(vtkMRMLNode::ReferenceAddedEvent, reference);
902  }
903 
906  {
907  this->InvokeEvent(vtkMRMLNode::ReferenceModifiedEvent, reference);
908  }
909 
912  {
913  this->InvokeEvent(vtkMRMLNode::ReferenceRemovedEvent, reference);
914  }
915 
918  void ParseReferencesAttribute(const char *attValue, std::set<std::string> &references);
919 
921  vtkCallbackCommand *MRMLCallbackCommand;
922 
923  char *ID{nullptr};
924  char *Name{nullptr};
925  char *Description{nullptr};
926  int HideFromEditors{0};
927  int Selectable{1};
928  int Selected{0};
929  int AddToScene{1};
930  bool UndoEnabled{false};
931 
932  int SaveWithScene{true};
933 
936  int InMRMLCallbackFlag{0};
937 
938  // We don't increase the reference count of Scene when store its pointer
939  // therefore we must use a weak pointer to prevent pointer dangling when
940  // the scene is deleted.
941  vtkWeakPointer<vtkMRMLScene> Scene;
942 
943  typedef std::map< std::string, std::string > AttributesType;
945 
946  vtkIntArray* ContentModifiedEvents;
947 
949 
952  typedef std::vector< vtkSmartPointer<vtkMRMLNodeReference> > NodeReferenceListType;
953  typedef std::map< std::string, NodeReferenceListType > NodeReferencesType;
955 
956  std::map< std::string, std::string> NodeReferenceMRMLAttributeNames;
957 
958  typedef std::map< std::string, vtkSmartPointer<vtkIntArray> > NodeReferenceEventsType;
959  NodeReferenceEventsType NodeReferenceEvents; // for each role it specifies which referenced node emitted events this node should observe
960 
961 private:
962 
965  void SetID(const char* newID);
966 
968  char *TempURLString{nullptr};
969 
970  char *SingletonTag{nullptr};
971 
972  int DisableModifiedEvent{0};
973  int ModifiedEventPending{0};
974  std::map<int, int> CustomModifiedEventPending; // event id, pending value (number of events grouped together)
975 };
976 
985 class VTK_MRML_EXPORT MRMLNodeModifyBlocker
986 {
987 public:
988  vtkWeakPointer<vtkMRMLNode> Node;
991  {
992  this->Node = node;
993  if (this->Node)
994  {
995  this->WasModifying = this->Node->StartModify();
996  }
997  };
999  {
1000  if (this->Node)
1001  {
1002  this->Node->EndModify(this->WasModifying);
1003  }
1004  }
1005 };
1006 
1007 #endif
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...
const char * GetNthNodeReferenceID(const char *referenceRole, int n)
Return the string of the Nth node ID for a specific reference role.
vtkMRMLNode * GetNodeReference(const char *referenceRole)
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
bool IsSingleton()
Definition: vtkMRMLNode.h:438
void DisableModifiedEventOff()
Definition: vtkMRMLNode.h:464
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void CopyContent(vtkMRMLNode *node, bool deepCopy=true)
Copy node contents from another node of the same type. Does not copy node ID, Scene, Name, SingletonTag, HideFromEditors, AddToScene, UndoEnabled, and node references. If deepCopy is set to false then a shallow copy of bulk data (such as image or mesh data) could be made; copying may be faster but the node may share some data with the source node instead of creating an independent copy.
std::vector< vtkSmartPointer< vtkMRMLNodeReference > > NodeReferenceListType
Definition: vtkMRMLNode.h:952
virtual int InvokePendingModifiedEvent()
Invokes any modified events that are pending.
Definition: vtkMRMLNode.h:508
void SetSingletonOn()
Definition: vtkMRMLNode.h:430
vtkMRMLNode * SetAndObserveNthNodeReferenceID(const char *referenceRole, int n, const char *referencedNodeID, vtkIntArray *events=nullptr)
Set and observe the Nth node ID for a specific reference role.
std::map< std::string, NodeReferenceListType > NodeReferencesType
Definition: vtkMRMLNode.h:953
std::vector< std::string > GetAttributeNames()
Get all attribute names.
vtkWeakPointer< vtkMRMLNode > ReferencingNode
Points to this MRML node (that added the reference)
Definition: vtkMRMLNode.h:814
std::string XMLAttributeDecodeString(const std::string &inString)
Decode an XML attribute string.
virtual vtkMRMLScene * GetScene()
Get the scene this node has been added to.
virtual void Reset(vtkMRMLNode *defaultNode)
Reset node attributes to the initial state as defined in the constructor or the passed default node...
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
Manages adding and deleting of obserevers with events.
const char * GetNodeReferenceID(const char *referenceRole)
Utility function that returns the first node id for a specific referenceRole.
void GetNodeReferenceRoles(std::vector< std::string > &roles)
void SetAttribute(const char *name, const char *value)
Set a name value pair attribute.
int InMRMLCallbackFlag
Flag to avoid event loops
Definition: vtkMRMLNode.h:936
vtkObserverManager * MRMLObserverManager
Definition: vtkMRMLNode.h:948
vtkMRMLNode * SetAndObserveNodeReferenceID(const char *referenceRole, const char *referencedNodeID, vtkIntArray *events=nullptr)
Set and observe a reference node from this node for a specific referenceRole.
virtual void InvokeCustomModifiedEvent(int eventId, void *callData=nullptr)
This method allows the node to compress events.
Definition: vtkMRMLNode.h:551
virtual void OnNodeAddedToScene()
Definition: vtkMRMLNode.h:213
const char * GetNthNodeReferenceRole(int n)
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file
virtual bool HasCopyContent() const
Returns true if the class supports deep and shallow copying node content.
virtual int StartModify()
Start modifying the node. Disable Modify events.
Definition: vtkMRMLNode.h:298
void PrintSelf(ostream &vtkNotUsed(os), vtkIndent vtkNotUsed(indent)) override
Definition: vtkMRMLNode.h:780
virtual void UpdateReferences()
The method should remove all pointers and observations to all nodes that are not in the scene anymore...
virtual void CopyReferences(vtkMRMLNode *node)
Copy the references of the node into this.
std::map< std::string, vtkSmartPointer< vtkIntArray > > NodeReferenceEventsType
Definition: vtkMRMLNode.h:958
void SetDisableModifiedEvent(int onOff)
Definition: vtkMRMLNode.h:456
virtual int GetDisableModifiedEvent()
Turn on/off generating InvokeEvent for set macros.
virtual void UpdateReferenceID(const char *oldID, const char *newID)
Update the stored reference to another node in the scene.
std::map< std::string, std::string > NodeReferenceMRMLAttributeNames
Definition: vtkMRMLNode.h:956
const char * GetAttribute(const char *name)
Get value of a name value pair attribute.
bool HasNodeReferenceID(const char *referenceRole, const char *referencedNodeID)
Return true if referencedNodeID is in the node ID list for a specific referenceRole.
virtual void OnNodeReferenceModified(vtkMRMLNodeReference *reference)
Called when a referenced node pointer is modified.
Definition: vtkMRMLNode.h:905
vtkMRMLNode * AddAndObserveNodeReferenceID(const char *referenceRole, const char *referencedNodeID, vtkIntArray *events=nullptr)
Add and observe a reference node from this node for a specific referenceRole.
char * Name
Definition: vtkMRMLNode.h:924
virtual char * GetSingletonTag()
NodeReferenceEventsType NodeReferenceEvents
Definition: vtkMRMLNode.h:959
void GetNodeReferenceIDs(const char *referenceRole, std::vector< const char *> &referencedNodeIDs)
Return a list of the referenced node IDs.
virtual void UpdateNodeReferences(const char *referenceRole=nullptr)
std::string XMLAttributeEncodeString(const std::string &inString)
Encode an XML attribute string (replaces special characters by code sequences)
void WriteNodeBodyXML(ostream &of, int indent) override
Write this node&#39;s body to a MRML file in XML format.
vtkSmartPointer< vtkMRMLNode > ReferencedNode
The referenced node that is actually observed now.
Definition: vtkMRMLNode.h:816
void SetSingletonOff()
Definition: vtkMRMLNode.h:434
void SetAddToSceneNoModify(int value)
virtual void SetSceneReferences()
Update the references of the node to the scene.
void RemoveAttribute(const char *name)
Remove attribute with the specified name.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
vtkIntArray * ContentModifiedEvents
Definition: vtkMRMLNode.h:946
Safe replacement of MRML node start/end modify.
Definition: vtkMRMLNode.h:985
vtkSmartPointer< vtkIntArray > Events
Definition: vtkMRMLNode.h:823
char * Description
Definition: vtkMRMLNode.h:925
vtkMRMLNode * AddNodeReferenceID(const char *referenceRole, const char *referencedNodeID)
Convenience method that adds a referencedNodeID at the end of the list.
virtual int EndModify(int previousDisableModifiedEventState)
End modifying the node.
Definition: vtkMRMLNode.h:312
void AddNodeReferenceRole(const char *referenceRole, const char *mrmlAttributeName=nullptr, vtkIntArray *events=nullptr)
Add a referenceRole.
void RemoveNthNodeReferenceID(const char *referenceRole, int n)
Convenience method that removes the Nth node ID from the list.
virtual void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference)
Called when a referenced node pointer is removed (set to nullptr).
Definition: vtkMRMLNode.h:911
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...
virtual void ProcessChildNode(vtkMRMLNode *)
Set dependencies between this node and a child node when parsing XML file.
Definition: vtkMRMLNode.h:201
virtual void SetScene(vtkMRMLScene *scene)
This method is for internal use only. Use AddNode method of vtkMRMLScene to add a node to the scene...
const char * URLDecodeString(const char *inString)
Decode a URL string.
char * ReferenceRole
Name of the reference role.
Definition: vtkMRMLNode.h:811
AttributesType Attributes
Definition: vtkMRMLNode.h:944
vtkMRMLNode * GetNthNodeReference(const char *referenceRole, int n)
Get referenced MRML node for a specific referenceRole.
std::map< std::string, std::string > AttributesType
Definition: vtkMRMLNode.h:943
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
alternative method to propagate events generated in Storage nodes
void RemoveNodeReferenceIDs(const char *referenceRole)
Remove all node IDs and associated nodes for a specific referenceRole.
void Copy(vtkMRMLNode *node) override
Copy the node&#39;s attributes to this object
vtkCallbackCommand * MRMLCallbackCommand
Holders for MRML callbacks.
Definition: vtkMRMLNode.h:921
vtkWeakPointer< vtkMRMLScene > Scene
Definition: vtkMRMLNode.h:941
int SaveWithScene
Definition: vtkMRMLNode.h:932
MRMLNodeModifyBlocker(vtkMRMLNode *node)
Definition: vtkMRMLNode.h:990
void WriteXML(ostream &of, int indent) override
Write this node&#39;s information to a MRML file in XML format.
vtkMRMLNode * SetNodeReferenceID(const char *referenceRole, const char *referencedNodeID)
Set a reference to a node with specified nodeID from this node for a specific referenceRole.
virtual void OnNodeReferenceAdded(vtkMRMLNodeReference *reference)
Definition: vtkMRMLNode.h:899
void Modified() override
Customized version of Modified() allowing to compress vtkCommand::ModifiedEvent.
Definition: vtkMRMLNode.h:489
void GetNodeReferences(const char *referenceRole, std::vector< vtkMRMLNode *> &nodes)
Return a list of the referenced nodes.
void SetInMRMLCallbackFlag(int flag)
Definition: vtkMRMLNode.h:386
void CopyWithScene(vtkMRMLNode *node)
Copy everything (including Scene and ID) from another node of the same type.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
Class to hold information about a node reference.
Definition: vtkMRMLNode.h:775
bool UndoEnabled
Definition: vtkMRMLNode.h:930
const char * URLEncodeString(const char *inString)
Encode a URL string.
NodeReferencesType NodeReferences
Definition: vtkMRMLNode.h:954
virtual void SetSingletonTag(const char *)
Tag that make this node a singleton in the scene.
void DisableModifiedEventOn()
Definition: vtkMRMLNode.h:460
int GetNumberOfNodeReferenceRoles()
int HideFromEditors
Definition: vtkMRMLNode.h:926
vtkWeakPointer< vtkMRMLNode > Node
Definition: vtkMRMLNode.h:988
virtual void UpdateScene(vtkMRMLScene *)
Definition: vtkMRMLNode.h:206