Slicer  5.1
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 
331  virtual const char* GetTypeDisplayName()
332  {
333  return this->GetNodeTagName();
334  }
335 
347  void SetAttribute(const char* name, const char* value);
348 
350  void RemoveAttribute(const char* name);
351 
355  const char* GetAttribute(const char* name);
356 
358  std::vector< std::string > GetAttributeNames();
359 
361  void GetAttributeNames(vtkStringArray* attributeNames);
362 
364  vtkGetMacro(HideFromEditors, int);
365  vtkSetMacro(HideFromEditors, int);
366  vtkBooleanMacro(HideFromEditors, int);
367 
369  vtkGetMacro(Selectable, int);
370  vtkSetMacro(Selectable, int);
371  vtkBooleanMacro(Selectable, int);
372 
382  vtkGetMacro(UndoEnabled, bool);
383  vtkSetMacro(UndoEnabled, bool);
384  vtkBooleanMacro(UndoEnabled, bool);
385 
387  virtual void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData );
388 
393  vtkGetMacro(InMRMLCallbackFlag, int);
394  void SetInMRMLCallbackFlag (int flag) {
395  this->InMRMLCallbackFlag = flag;
396  }
397 
399  vtkSetStringMacro(Description);
400  vtkGetStringMacro(Description);
401 
403  vtkSetStringMacro(Name);
404  vtkGetStringMacro(Name);
405 
407  //vtkSetStringMacro(ID);
408  vtkGetStringMacro(ID);
409 
436  vtkSetStringMacro(SingletonTag);
437  vtkGetStringMacro(SingletonTag);
439  {
440  this->SetSingletonTag("Singleton");
441  }
443  {
444  this->SetSingletonTag(nullptr);
445  }
446  bool IsSingleton()
447  {
448  return (this->GetSingletonTag() != nullptr);
449  }
450 
452  vtkGetMacro(SaveWithScene, int);
453  vtkSetMacro(SaveWithScene, int);
454  vtkBooleanMacro(SaveWithScene, int);
455 
457  vtkGetMacro(AddToScene, int);
458  vtkSetMacro(AddToScene, int);
459  vtkBooleanMacro(AddToScene, int);
460  void SetAddToSceneNoModify(int value);
461 
463  vtkGetMacro(DisableModifiedEvent, int);
464  void SetDisableModifiedEvent(int onOff)
465  {
466  this->DisableModifiedEvent = onOff;
467  }
469  {
470  this->SetDisableModifiedEvent(1);
471  }
473  {
474  this->SetDisableModifiedEvent(0);
475  }
476 
482  vtkGetMacro(ModifiedEventPending, int);
483 
490  {
491  std::map< int, int >::iterator it = this->CustomModifiedEventPending.find(eventId);
492  if (it == this->CustomModifiedEventPending.end())
493  {
494  return 0;
495  }
496  else
497  {
498  return it->second;
499  }
500  }
501 
515  void Modified() override
516  {
517  if (!this->GetDisableModifiedEvent())
518  {
520  }
521  else
522  {
523  ++this->ModifiedEventPending;
524  }
525  }
526 
535  {
536  int oldModifiedEventPending = 0;
537  // Invoke pending standard Modified event
538  if ( this->ModifiedEventPending )
539  {
540  oldModifiedEventPending += this->ModifiedEventPending;
541  this->ModifiedEventPending = 0;
543  }
544  // Invoke pending custom modified events
545  if (!this->CustomModifiedEventPending.empty())
546  {
547  // Need to make a copy of the event IDs stored in this->CustomModifiedEventPending,
548  // because event invocation may add more events to this->CustomModifiedEventPending,
549  // which would then make the iterator invalid.
550  std::vector<int> customEventsToInvoke;
551  for (std::map< int, int >::iterator it=this->CustomModifiedEventPending.begin(); it!=this->CustomModifiedEventPending.end(); ++it)
552  {
553  oldModifiedEventPending += it->second;
554  customEventsToInvoke.push_back(it->first);
555  }
556  this->CustomModifiedEventPending.clear();
557  for (std::vector<int>::iterator it=customEventsToInvoke.begin(); it!=customEventsToInvoke.end(); ++it)
558  {
559  this->InvokeEvent(*it);
560  }
561  }
562  return oldModifiedEventPending;
563  }
564 
577  virtual void InvokeCustomModifiedEvent(int eventId, void *callData=nullptr)
578  {
579  if (!this->GetDisableModifiedEvent())
580  {
581  // DisableModify is inactive, we immediately invoke the event
582  this->InvokeEvent(eventId, callData);
583  }
584  else
585  {
586  // just remember the custom modified event and invoke it once,
587  // when DisableModify is deactivated
588  ++this->CustomModifiedEventPending[eventId];
589  }
590  }
591 
593  virtual vtkMRMLScene* GetScene();
594 
600  virtual void SetScene(vtkMRMLScene* scene);
601 
606  virtual void SetSceneReferences();
607 
609  virtual void UpdateReferenceID(const char *oldID, const char *newID);
610 
615  vtkGetObjectMacro(ContentModifiedEvents, vtkIntArray);
616 
623  const char *URLEncodeString(const char *inString);
624 
631  const char *URLDecodeString(const char *inString);
632 
636  std::string XMLAttributeEncodeString(const std::string& inString);
637 
645  std::string XMLAttributeDecodeString(const std::string& inString);
646 
648  vtkGetMacro(Selected, int);
649  vtkSetMacro(Selected, int);
650  vtkBooleanMacro(Selected, int);
651 
667  void AddNodeReferenceRole(const char *referenceRole, const char *mrmlAttributeName=nullptr, vtkIntArray *events=nullptr);
668 
670  vtkMRMLNode* SetNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
671 
673  vtkMRMLNode* AddNodeReferenceID(const char* referenceRole , const char* referencedNodeID);
674 
677  vtkMRMLNode* SetNthNodeReferenceID(const char* referenceRole, int n, const char* referencedNodeID);
678 
683  vtkMRMLNode* SetAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID, vtkIntArray *events=nullptr);
684 
689  vtkMRMLNode* AddAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID, vtkIntArray *events=nullptr);
690 
706  vtkMRMLNode* SetAndObserveNthNodeReferenceID(const char* referenceRole, int n, const char *referencedNodeID, vtkIntArray *events=nullptr);
707 
709  void RemoveNthNodeReferenceID(const char* referenceRole, int n);
710 
714  void RemoveNodeReferenceIDs(const char* referenceRole);
715 
720  bool HasNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
721 
724  int GetNumberOfNodeReferences(const char* referenceRole);
725 
732  const char *GetNthNodeReferenceID(const char* referenceRole, int n);
733 
738  const char *GetNodeReferenceID(const char* referenceRole);
739 
750  vtkMRMLNode* GetNthNodeReference(const char* referenceRole, int n);
751 
754  vtkMRMLNode* GetNodeReference(const char* referenceRole);
755 
763  void GetNodeReferences(const char* referenceRole, std::vector<vtkMRMLNode*> &nodes);
764 
770  void GetNodeReferenceIDs(const char* referenceRole,
771  std::vector<const char*> &referencedNodeIDs);
772 
775  void GetNodeReferenceRoles(std::vector<std::string> &roles);
776 
780 
783  const char* GetNthNodeReferenceRole(int n);
784 
787  enum
788  {
790  IDChangedEvent = 16001,
795  };
796 
797 
798 protected:
799 
801  class VTK_MRML_EXPORT vtkMRMLNodeReference : public vtkObject
802  {
803  public:
804  vtkTypeMacro(vtkMRMLNodeReference,vtkObject);
805  static vtkMRMLNodeReference *New();
806  void PrintSelf(ostream& vtkNotUsed(os), vtkIndent vtkNotUsed(indent)) override {};
807 
808  public:
809  vtkSetStringMacro(ReferenceRole);
810  vtkGetStringMacro(ReferenceRole);
811 
812  vtkSetStringMacro(ReferencedNodeID);
813  vtkGetStringMacro(ReferencedNodeID);
814 
820  void SetEvents(vtkIntArray* events);
821  vtkIntArray* GetEvents() const;
822 
823  void SetReferencingNode(vtkMRMLNode* node);
824  vtkMRMLNode* GetReferencingNode() const;
825 
826  void SetReferencedNode(vtkMRMLNode* node);
827  vtkMRMLNode* GetReferencedNode() const;
828 
829  protected:
831  ~vtkMRMLNodeReference() override;
832 
834  void operator=(const vtkMRMLNodeReference&);
835 
838 
840  vtkWeakPointer<vtkMRMLNode> ReferencingNode;
842  vtkSmartPointer<vtkMRMLNode> ReferencedNode;
843 
849  vtkSmartPointer<vtkIntArray> Events;
850  };
851 
852  vtkMRMLNode();
854  ~vtkMRMLNode() override;
855  vtkMRMLNode(const vtkMRMLNode&);
856  void operator=(const vtkMRMLNode&);
857 
860  static void MRMLCallback( vtkObject *caller,
861  unsigned long eid, void *clientData, void *callData );
862 
865  vtkSetStringMacro( TempURLString );
866  vtkGetStringMacro( TempURLString );
867 
875  virtual const char* GetReferenceRoleFromMRMLAttributeName(const char* attName);
876 
884  virtual const char* GetMRMLAttributeNameFromReferenceRole(const char* refRole);
885 
889  virtual bool IsReferenceRoleGeneric(const char* refRole);
890 
894  virtual void UpdateNodeReferences(const char* referenceRole = nullptr);
895 
899  void RemoveInvalidReferences(const std::set<std::string>& validNodeIDs);
900 
905  virtual void UpdateNthNodeReference(const char* referenceRole, int n);
906 
910  vtkMRMLNode* UpdateNodeReferenceEventObserver(vtkMRMLNode *oldReferencedNode, vtkMRMLNode *newReferencedNode,
911  vtkIntArray *newEvents, vtkMRMLNodeReference* referenceToIgnore);
912 
918  void GetUpdatedReferencedNodeEventList(int& oldReferencedNodeUseCount, int& newReferencedNodeUseCount,
919  vtkIntArray* oldConsolidatedEventList, vtkIntArray* newConsolidatedEventList,
920  vtkMRMLNode* oldReferencedNode, vtkMRMLNode* newReferencedNode,
921  vtkMRMLNodeReference* referenceToIgnore, vtkIntArray* newEvents);
922 
925  virtual void InvalidateNodeReferences();
926 
931  {
932  this->InvokeEvent(vtkMRMLNode::ReferenceAddedEvent, reference);
933  }
934 
937  {
938  this->InvokeEvent(vtkMRMLNode::ReferenceModifiedEvent, reference);
939  }
940 
943  {
944  this->InvokeEvent(vtkMRMLNode::ReferenceRemovedEvent, reference);
945  }
946 
949  void ParseReferencesAttribute(const char *attValue, std::set<std::string> &references);
950 
952  vtkCallbackCommand *MRMLCallbackCommand;
953 
954  char *ID{nullptr};
955  char *Name{nullptr};
956  char *Description{nullptr};
957  int HideFromEditors{0};
958  int Selectable{1};
959  int Selected{0};
960  int AddToScene{1};
961  bool UndoEnabled{false};
962 
963  int SaveWithScene{true};
964 
967  int InMRMLCallbackFlag{0};
968 
969  // We don't increase the reference count of Scene when store its pointer
970  // therefore we must use a weak pointer to prevent pointer dangling when
971  // the scene is deleted.
972  vtkWeakPointer<vtkMRMLScene> Scene;
973 
974  typedef std::map< std::string, std::string > AttributesType;
976 
977  vtkIntArray* ContentModifiedEvents;
978 
980 
983  typedef std::vector< vtkSmartPointer<vtkMRMLNodeReference> > NodeReferenceListType;
984  typedef std::map< std::string, NodeReferenceListType > NodeReferencesType;
986 
987  std::map< std::string, std::string> NodeReferenceMRMLAttributeNames;
988 
989  typedef std::map< std::string, vtkSmartPointer<vtkIntArray> > NodeReferenceEventsType;
990  NodeReferenceEventsType NodeReferenceEvents; // for each role it specifies which referenced node emitted events this node should observe
991 
992 private:
993 
996  void SetID(const char* newID);
997 
999  char *TempURLString{nullptr};
1000 
1001  char *SingletonTag{nullptr};
1002 
1003  int DisableModifiedEvent{0};
1004  int ModifiedEventPending{0};
1005  std::map<int, int> CustomModifiedEventPending; // event id, pending value (number of events grouped together)
1006 };
1007 
1016 class VTK_MRML_EXPORT MRMLNodeModifyBlocker
1017 {
1018 public:
1019  vtkWeakPointer<vtkMRMLNode> Node;
1022  {
1023  this->Node = node;
1024  if (this->Node)
1025  {
1026  this->WasModifying = this->Node->StartModify();
1027  }
1028  };
1030  {
1031  if (this->Node)
1032  {
1033  this->Node->EndModify(this->WasModifying);
1034  }
1035  }
1036 };
1037 
1038 #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)
virtual const char * GetTypeDisplayName()
Definition: vtkMRMLNode.h:331
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
bool IsSingleton()
Definition: vtkMRMLNode.h:446
void DisableModifiedEventOff()
Definition: vtkMRMLNode.h:472
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:983
virtual int InvokePendingModifiedEvent()
Invokes any modified events that are pending.
Definition: vtkMRMLNode.h:534
void SetSingletonOn()
Definition: vtkMRMLNode.h:438
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:984
std::vector< std::string > GetAttributeNames()
Get all attribute names.
int GetCustomModifiedEventPending(int eventId)
Definition: vtkMRMLNode.h:489
vtkWeakPointer< vtkMRMLNode > ReferencingNode
Points to this MRML node (that added the reference)
Definition: vtkMRMLNode.h:840
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:967
vtkObserverManager * MRMLObserverManager
Definition: vtkMRMLNode.h:979
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:577
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:806
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:989
void SetDisableModifiedEvent(int onOff)
Definition: vtkMRMLNode.h:464
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:987
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:936
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:955
virtual char * GetSingletonTag()
NodeReferenceEventsType NodeReferenceEvents
Definition: vtkMRMLNode.h:990
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:842
void SetSingletonOff()
Definition: vtkMRMLNode.h:442
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:57
vtkIntArray * ContentModifiedEvents
Definition: vtkMRMLNode.h:977
Safe replacement of MRML node start/end modify.
Definition: vtkMRMLNode.h:1016
vtkSmartPointer< vtkIntArray > Events
Definition: vtkMRMLNode.h:849
char * Description
Definition: vtkMRMLNode.h:956
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:942
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:837
AttributesType Attributes
Definition: vtkMRMLNode.h:975
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:974
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:952
vtkWeakPointer< vtkMRMLScene > Scene
Definition: vtkMRMLNode.h:972
int SaveWithScene
Definition: vtkMRMLNode.h:963
MRMLNodeModifyBlocker(vtkMRMLNode *node)
Definition: vtkMRMLNode.h:1021
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:930
void Modified() override
Customized version of Modified() allowing to compress vtkCommand::ModifiedEvent.
Definition: vtkMRMLNode.h:515
void GetNodeReferences(const char *referenceRole, std::vector< vtkMRMLNode *> &nodes)
Return a list of the referenced nodes.
void SetInMRMLCallbackFlag(int flag)
Definition: vtkMRMLNode.h:394
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:801
bool UndoEnabled
Definition: vtkMRMLNode.h:961
const char * URLEncodeString(const char *inString)
Encode a URL string.
NodeReferencesType NodeReferences
Definition: vtkMRMLNode.h:985
virtual void SetSingletonTag(const char *)
Tag that make this node a singleton in the scene.
void DisableModifiedEventOn()
Definition: vtkMRMLNode.h:468
int GetNumberOfNodeReferenceRoles()
int HideFromEditors
Definition: vtkMRMLNode.h:957
vtkWeakPointer< vtkMRMLNode > Node
Definition: vtkMRMLNode.h:1019
virtual void UpdateScene(vtkMRMLScene *)
Definition: vtkMRMLNode.h:206