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 
139 class VTK_MRML_EXPORT vtkMRMLNode : public vtkObject
140 {
143  friend class vtkMRMLScene;
144  friend class vtkMRMLSceneViewNode;
145 
146 public:
147  vtkTypeMacro(vtkMRMLNode,vtkObject);
148  void PrintSelf(ostream& os, vtkIndent indent) override;
149 
153  virtual vtkMRMLNode* CreateNodeInstance() = 0;
154 
160  virtual void ReadXMLAttributes(const char** atts);
161 
166  virtual void UpdateReferences();
167 
170  virtual void ProcessChildNode(vtkMRMLNode *){};
171 
175  virtual void UpdateScene(vtkMRMLScene *)
176  {
177  this->UpdateNodeReferences();
178  };
179 
182  virtual void OnNodeAddedToScene()
183  {
184  this->UpdateNodeReferences();
185  };
186 
193  virtual void WriteXML(ostream& of, int indent);
194 
196  virtual void WriteNodeBodyXML(ostream& of, int indent);
197 
205  virtual void Copy(vtkMRMLNode *node);
206 
211  virtual void CopyReferences(vtkMRMLNode* node);
212 
226  void CopyWithScene(vtkMRMLNode *node);
227 
248  virtual void Reset(vtkMRMLNode* defaultNode);
249 
256  virtual int StartModify()
257  {
258  int disabledModify = this->GetDisableModifiedEvent();
259  this->DisableModifiedEventOn();
260  return disabledModify;
261  };
262 
270  virtual int EndModify(int previousDisableModifiedEventState)
271  {
272  this->SetDisableModifiedEvent(previousDisableModifiedEventState);
273  if (!previousDisableModifiedEventState)
274  {
275  return this->InvokePendingModifiedEvent();
276  }
277  return this->ModifiedEventPending;
278  };
279 
280 
284  virtual const char* GetNodeTagName() = 0;
285 
297  void SetAttribute(const char* name, const char* value);
298 
300  void RemoveAttribute(const char* name);
301 
305  const char* GetAttribute(const char* name);
306 
308  std::vector< std::string > GetAttributeNames();
309 
311  void GetAttributeNames(vtkStringArray* attributeNames);
312 
314  vtkGetMacro(HideFromEditors, int);
315  vtkSetMacro(HideFromEditors, int);
316  vtkBooleanMacro(HideFromEditors, int);
317 
319  vtkGetMacro(Selectable, int);
320  vtkSetMacro(Selectable, int);
321  vtkBooleanMacro(Selectable, int);
322 
332  vtkGetMacro(UndoEnabled, bool);
333  vtkSetMacro(UndoEnabled, bool);
334  vtkBooleanMacro(UndoEnabled, bool);
335 
337  virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData );
338 
343  vtkGetMacro(InMRMLCallbackFlag, int);
344  void SetInMRMLCallbackFlag (int flag) {
345  this->InMRMLCallbackFlag = flag;
346  }
347 
349  vtkSetStringMacro(Description);
350  vtkGetStringMacro(Description);
351 
353  vtkSetStringMacro(Name);
354  vtkGetStringMacro(Name);
355 
357  //vtkSetStringMacro(ID);
358  vtkGetStringMacro(ID);
359 
386  vtkSetStringMacro(SingletonTag);
387  vtkGetStringMacro(SingletonTag);
389  {
390  this->SetSingletonTag("Singleton");
391  }
393  {
394  this->SetSingletonTag(nullptr);
395  }
396  bool IsSingleton()
397  {
398  return (this->GetSingletonTag() != nullptr);
399  }
400 
402  vtkGetMacro(SaveWithScene, int);
403  vtkSetMacro(SaveWithScene, int);
404  vtkBooleanMacro(SaveWithScene, int);
405 
407  vtkGetMacro(AddToScene, int);
408  vtkSetMacro(AddToScene, int);
409  vtkBooleanMacro(AddToScene, int);
410  void SetAddToSceneNoModify(int value);
411 
413  vtkGetMacro(DisableModifiedEvent, int);
414  void SetDisableModifiedEvent(int onOff)
415  {
416  this->DisableModifiedEvent = onOff;
417  }
419  {
420  this->SetDisableModifiedEvent(1);
421  }
423  {
424  this->SetDisableModifiedEvent(0);
425  }
426 
432  vtkGetMacro(ModifiedEventPending, int);
433 
447  void Modified() override
448  {
449  if (!this->GetDisableModifiedEvent())
450  {
452  }
453  else
454  {
455  ++this->ModifiedEventPending;
456  }
457  }
458 
467  {
468  int oldModifiedEventPending = 0;
469  // Invoke pending standard Modified event
470  if ( this->ModifiedEventPending )
471  {
472  oldModifiedEventPending += this->ModifiedEventPending;
473  this->ModifiedEventPending = 0;
475  }
476  // Invoke pending custom modified events
477  if (!this->CustomModifiedEventPending.empty())
478  {
479  // Need to make a copy of the event IDs stored in this->CustomModifiedEventPending,
480  // because event invocation may add more events to this->CustomModifiedEventPending,
481  // which would then make the iterator invalid.
482  std::vector<int> customEventsToInvoke;
483  for (std::map< int, int >::iterator it=this->CustomModifiedEventPending.begin(); it!=this->CustomModifiedEventPending.end(); ++it)
484  {
485  oldModifiedEventPending += it->second;
486  customEventsToInvoke.push_back(it->first);
487  }
488  this->CustomModifiedEventPending.clear();
489  for (std::vector<int>::iterator it=customEventsToInvoke.begin(); it!=customEventsToInvoke.end(); ++it)
490  {
491  this->InvokeEvent(*it);
492  }
493  }
494  return oldModifiedEventPending;
495  }
496 
509  virtual void InvokeCustomModifiedEvent(int eventId, void *callData=nullptr)
510  {
511  if (!this->GetDisableModifiedEvent())
512  {
513  // DisableModify is inactive, we immediately invoke the event
514  this->InvokeEvent(eventId, callData);
515  }
516  else
517  {
518  // just remember the custom modified event and invoke it once,
519  // when DisableModify is deactivated
520  ++this->CustomModifiedEventPending[eventId];
521  }
522  }
523 
525  {
526  int oldMode = this->GetDisableModifiedEvent();
527  this->DisableModifiedEventOn();
528  this->Copy(node);
530  this->SetDisableModifiedEvent(oldMode);
531  }
532 
534  {
535  int oldMode = this->GetDisableModifiedEvent();
536  this->DisableModifiedEventOn();
537  this->Copy(node);
538  this->SetDisableModifiedEvent(oldMode);
539  }
540 
550  {
551  int oldMode = this->StartModify();
552  this->CopyWithScene(node);
553  this->EndModify(oldMode);
554  }
555 
557  virtual vtkMRMLScene* GetScene();
558 
564  virtual void SetScene(vtkMRMLScene* scene);
565 
570  virtual void SetSceneReferences();
571 
573  virtual void UpdateReferenceID(const char *oldID, const char *newID);
574 
581  const char *URLEncodeString(const char *inString);
582 
589  const char *URLDecodeString(const char *inString);
590 
594  std::string XMLAttributeEncodeString(const std::string& inString);
595 
603  std::string XMLAttributeDecodeString(const std::string& inString);
604 
606  vtkGetMacro(Selected, int);
607  vtkSetMacro(Selected, int);
608  vtkBooleanMacro(Selected, int);
609 
623  void AddNodeReferenceRole(const char *referenceRole, const char *mrmlAttributeName=nullptr, vtkIntArray *events=nullptr);
624 
626  vtkMRMLNode* SetNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
627 
629  vtkMRMLNode* AddNodeReferenceID(const char* referenceRole , const char* referencedNodeID);
630 
633  vtkMRMLNode* SetNthNodeReferenceID(const char* referenceRole, int n, const char* referencedNodeID);
634 
639  vtkMRMLNode* SetAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID, vtkIntArray *events=nullptr);
640 
645  vtkMRMLNode* AddAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID, vtkIntArray *events=nullptr);
646 
662  vtkMRMLNode* SetAndObserveNthNodeReferenceID(const char* referenceRole, int n, const char *referencedNodeID, vtkIntArray *events=nullptr);
663 
665  void RemoveNthNodeReferenceID(const char* referenceRole, int n);
666 
670  void RemoveNodeReferenceIDs(const char* referenceRole);
671 
676  bool HasNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
677 
680  int GetNumberOfNodeReferences(const char* referenceRole);
681 
688  const char *GetNthNodeReferenceID(const char* referenceRole, int n);
689 
694  const char *GetNodeReferenceID(const char* referenceRole);
695 
706  vtkMRMLNode* GetNthNodeReference(const char* referenceRole, int n);
707 
710  vtkMRMLNode* GetNodeReference(const char* referenceRole);
711 
719  void GetNodeReferences(const char* referenceRole, std::vector<vtkMRMLNode*> &nodes);
720 
726  void GetNodeReferenceIDs(const char* referenceRole,
727  std::vector<const char*> &referencedNodeIDs);
728 
731  void GetNodeReferenceRoles(std::vector<std::string> &roles);
732 
736 
739  const char* GetNthNodeReferenceRole(int n);
740 
743  enum
744  {
746  IDChangedEvent = 16001,
751  };
752 
753 
754 protected:
755 
757  class VTK_MRML_EXPORT vtkMRMLNodeReference : public vtkObject
758  {
759  public:
760  vtkTypeMacro(vtkMRMLNodeReference,vtkObject);
761  static vtkMRMLNodeReference *New();
762  void PrintSelf(ostream& vtkNotUsed(os), vtkIndent vtkNotUsed(indent)) override {};
763 
764  public:
765  vtkSetStringMacro(ReferenceRole);
766  vtkGetStringMacro(ReferenceRole);
767 
768  vtkSetStringMacro(ReferencedNodeID);
769  vtkGetStringMacro(ReferencedNodeID);
770 
776  void SetEvents(vtkIntArray* events);
777  vtkIntArray* GetEvents() const;
778 
779  void SetReferencingNode(vtkMRMLNode* node);
780  vtkMRMLNode* GetReferencingNode() const;
781 
782  void SetReferencedNode(vtkMRMLNode* node);
783  vtkMRMLNode* GetReferencedNode() const;
784 
785  protected:
787  ~vtkMRMLNodeReference() override;
788 
790  void operator=(const vtkMRMLNodeReference&);
791 
794 
796  vtkWeakPointer<vtkMRMLNode> ReferencingNode;
798  vtkSmartPointer<vtkMRMLNode> ReferencedNode;
799 
805  vtkSmartPointer<vtkIntArray> Events;
806  };
807 
808  vtkMRMLNode();
810  ~vtkMRMLNode() override;
811  vtkMRMLNode(const vtkMRMLNode&);
812  void operator=(const vtkMRMLNode&);
813 
816  static void MRMLCallback( vtkObject *caller,
817  unsigned long eid, void *clientData, void *callData );
818 
821  vtkSetStringMacro( TempURLString );
822  vtkGetStringMacro( TempURLString );
823 
831  virtual const char* GetReferenceRoleFromMRMLAttributeName(const char* attName);
832 
840  virtual const char* GetMRMLAttributeNameFromReferenceRole(const char* refRole);
841 
845  virtual bool IsReferenceRoleGeneric(const char* refRole);
846 
850  virtual void UpdateNodeReferences(const char* referenceRole = nullptr);
851 
856  virtual void UpdateNthNodeReference(const char* referenceRole, int n);
857 
861  vtkMRMLNode* UpdateNodeReferenceEventObserver(vtkMRMLNode *oldReferencedNode, vtkMRMLNode *newReferencedNode,
862  vtkIntArray *newEvents, vtkMRMLNodeReference* referenceToIgnore);
863 
869  void GetUpdatedReferencedNodeEventList(int& oldReferencedNodeUseCount, int& newReferencedNodeUseCount,
870  vtkIntArray* oldConsolidatedEventList, vtkIntArray* newConsolidatedEventList,
871  vtkMRMLNode* oldReferencedNode, vtkMRMLNode* newReferencedNode,
872  vtkMRMLNodeReference* referenceToIgnore, vtkIntArray* newEvents);
873 
876  virtual void InvalidateNodeReferences();
877 
882  {
883  this->InvokeEvent(vtkMRMLNode::ReferenceAddedEvent, reference);
884  }
885 
888  {
889  this->InvokeEvent(vtkMRMLNode::ReferenceModifiedEvent, reference);
890  }
891 
894  {
895  this->InvokeEvent(vtkMRMLNode::ReferenceRemovedEvent, reference);
896  }
897 
900  void ParseReferencesAttribute(const char *attValue, std::set<std::string> &references);
901 
903  vtkCallbackCommand *MRMLCallbackCommand;
904 
905  char *ID;
906  char *Name;
907  char *Description;
910  int Selected;
913 
915 
919 
920  // We don't increase the reference count of Scene when store its pointer
921  // therefore we must use a weak pointer to prevent pointer dangling when
922  // the scene is deleted.
923  vtkWeakPointer<vtkMRMLScene> Scene;
924 
925  typedef std::map< std::string, std::string > AttributesType;
927 
929 
932  typedef std::vector< vtkSmartPointer<vtkMRMLNodeReference> > NodeReferenceListType;
933  typedef std::map< std::string, NodeReferenceListType > NodeReferencesType;
935 
936  std::map< std::string, std::string> NodeReferenceMRMLAttributeNames;
937 
938  typedef std::map< std::string, vtkSmartPointer<vtkIntArray> > NodeReferenceEventsType;
939  NodeReferenceEventsType NodeReferenceEvents; // for each role it specifies which referenced node emitted events this node should observe
940 
941 private:
942 
945  void SetID(const char* newID);
946 
948  char *TempURLString;
949 
950  char *SingletonTag;
951 
952  int DisableModifiedEvent;
953  int ModifiedEventPending;
954  std::map<int, int> CustomModifiedEventPending; // event id, pending value (number of events grouped together)
955 };
956 
965 class VTK_MRML_EXPORT MRMLNodeModifyBlocker
966 {
967 public:
968  vtkWeakPointer<vtkMRMLNode> Node;
971  {
972  this->Node = node;
973  if (this->Node)
974  {
975  this->WasModifying = this->Node->StartModify();
976  }
977  };
979  {
980  if (this->Node)
981  {
982  this->Node->EndModify(this->WasModifying);
983  }
984  }
985 };
986 
987 #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:396
void DisableModifiedEventOff()
Definition: vtkMRMLNode.h:422
void PrintSelf(ostream &os, vtkIndent indent) override
std::vector< vtkSmartPointer< vtkMRMLNodeReference > > NodeReferenceListType
Definition: vtkMRMLNode.h:932
virtual int InvokePendingModifiedEvent()
Invokes any modified events that are pending.
Definition: vtkMRMLNode.h:466
void SetSingletonOn()
Definition: vtkMRMLNode.h:388
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:933
std::vector< std::string > GetAttributeNames()
Get all attribute names.
vtkWeakPointer< vtkMRMLNode > ReferencingNode
Points to this MRML node (that added the reference)
Definition: vtkMRMLNode.h:796
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.
void CopyWithSceneWithSingleModifiedEvent(vtkMRMLNode *node)
Copy everything (including Scene and ID) from another node of the same type.
Definition: vtkMRMLNode.h:549
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:918
vtkObserverManager * MRMLObserverManager
Definition: vtkMRMLNode.h:928
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:509
virtual void OnNodeAddedToScene()
Definition: vtkMRMLNode.h:182
const char * GetNthNodeReferenceRole(int n)
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file
virtual int StartModify()
Start modifying the node. Disable Modify events.
Definition: vtkMRMLNode.h:256
void PrintSelf(ostream &vtkNotUsed(os), vtkIndent vtkNotUsed(indent)) override
Definition: vtkMRMLNode.h:762
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:938
void SetDisableModifiedEvent(int onOff)
Definition: vtkMRMLNode.h:414
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:936
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:887
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:906
virtual char * GetSingletonTag()
NodeReferenceEventsType NodeReferenceEvents
Definition: vtkMRMLNode.h:939
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:798
void SetSingletonOff()
Definition: vtkMRMLNode.h:392
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:56
Safe replacement of MRML node start/end modify.
Definition: vtkMRMLNode.h:965
vtkSmartPointer< vtkIntArray > Events
Definition: vtkMRMLNode.h:805
char * Description
Definition: vtkMRMLNode.h:907
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:270
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:893
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:170
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:793
AttributesType Attributes
Definition: vtkMRMLNode.h:926
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:925
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
alternative method to propagate events generated in Storage nodes
void CopyWithSingleModifiedEvent(vtkMRMLNode *node)
Definition: vtkMRMLNode.h:524
void RemoveNodeReferenceIDs(const char *referenceRole)
Remove all node IDs and associated nodes for a specific referenceRole.
void CopyWithoutModifiedEvent(vtkMRMLNode *node)
Definition: vtkMRMLNode.h:533
void Copy(vtkMRMLNode *node) override
Copy the node&#39;s attributes to this object
vtkCallbackCommand * MRMLCallbackCommand
Holders for MRML callbacks.
Definition: vtkMRMLNode.h:903
vtkWeakPointer< vtkMRMLScene > Scene
Definition: vtkMRMLNode.h:923
int SaveWithScene
Definition: vtkMRMLNode.h:914
MRMLNodeModifyBlocker(vtkMRMLNode *node)
Definition: vtkMRMLNode.h:970
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:881
void Modified() override
Customized version of Modified() allowing to compress vtkCommand::ModifiedEvent.
Definition: vtkMRMLNode.h:447
void GetNodeReferences(const char *referenceRole, std::vector< vtkMRMLNode *> &nodes)
Return a list of the referenced nodes.
void SetInMRMLCallbackFlag(int flag)
Definition: vtkMRMLNode.h:344
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:139
Class to hold information about a node reference.
Definition: vtkMRMLNode.h:757
bool UndoEnabled
Definition: vtkMRMLNode.h:912
const char * URLEncodeString(const char *inString)
Encode a URL string.
NodeReferencesType NodeReferences
Definition: vtkMRMLNode.h:934
virtual void SetSingletonTag(const char *)
Tag that make this node a singleton in the scene.
void DisableModifiedEventOn()
Definition: vtkMRMLNode.h:418
int GetNumberOfNodeReferenceRoles()
int HideFromEditors
Definition: vtkMRMLNode.h:908
vtkWeakPointer< vtkMRMLNode > Node
Definition: vtkMRMLNode.h:968
virtual void UpdateScene(vtkMRMLScene *)
Definition: vtkMRMLNode.h:175