Slicer  4.13
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 
639  void AddNodeReferenceRole(const char *referenceRole, const char *mrmlAttributeName=nullptr, vtkIntArray *events=nullptr);
640 
642  vtkMRMLNode* SetNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
643 
645  vtkMRMLNode* AddNodeReferenceID(const char* referenceRole , const char* referencedNodeID);
646 
649  vtkMRMLNode* SetNthNodeReferenceID(const char* referenceRole, int n, const char* referencedNodeID);
650 
655  vtkMRMLNode* SetAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID, vtkIntArray *events=nullptr);
656 
661  vtkMRMLNode* AddAndObserveNodeReferenceID(const char* referenceRole , const char* referencedNodeID, vtkIntArray *events=nullptr);
662 
678  vtkMRMLNode* SetAndObserveNthNodeReferenceID(const char* referenceRole, int n, const char *referencedNodeID, vtkIntArray *events=nullptr);
679 
681  void RemoveNthNodeReferenceID(const char* referenceRole, int n);
682 
686  void RemoveNodeReferenceIDs(const char* referenceRole);
687 
692  bool HasNodeReferenceID(const char* referenceRole, const char* referencedNodeID);
693 
696  int GetNumberOfNodeReferences(const char* referenceRole);
697 
704  const char *GetNthNodeReferenceID(const char* referenceRole, int n);
705 
710  const char *GetNodeReferenceID(const char* referenceRole);
711 
722  vtkMRMLNode* GetNthNodeReference(const char* referenceRole, int n);
723 
726  vtkMRMLNode* GetNodeReference(const char* referenceRole);
727 
735  void GetNodeReferences(const char* referenceRole, std::vector<vtkMRMLNode*> &nodes);
736 
742  void GetNodeReferenceIDs(const char* referenceRole,
743  std::vector<const char*> &referencedNodeIDs);
744 
747  void GetNodeReferenceRoles(std::vector<std::string> &roles);
748 
752 
755  const char* GetNthNodeReferenceRole(int n);
756 
759  enum
760  {
762  IDChangedEvent = 16001,
767  };
768 
769 
770 protected:
771 
773  class VTK_MRML_EXPORT vtkMRMLNodeReference : public vtkObject
774  {
775  public:
776  vtkTypeMacro(vtkMRMLNodeReference,vtkObject);
777  static vtkMRMLNodeReference *New();
778  void PrintSelf(ostream& vtkNotUsed(os), vtkIndent vtkNotUsed(indent)) override {};
779 
780  public:
781  vtkSetStringMacro(ReferenceRole);
782  vtkGetStringMacro(ReferenceRole);
783 
784  vtkSetStringMacro(ReferencedNodeID);
785  vtkGetStringMacro(ReferencedNodeID);
786 
792  void SetEvents(vtkIntArray* events);
793  vtkIntArray* GetEvents() const;
794 
795  void SetReferencingNode(vtkMRMLNode* node);
796  vtkMRMLNode* GetReferencingNode() const;
797 
798  void SetReferencedNode(vtkMRMLNode* node);
799  vtkMRMLNode* GetReferencedNode() const;
800 
801  protected:
803  ~vtkMRMLNodeReference() override;
804 
806  void operator=(const vtkMRMLNodeReference&);
807 
810 
812  vtkWeakPointer<vtkMRMLNode> ReferencingNode;
814  vtkSmartPointer<vtkMRMLNode> ReferencedNode;
815 
821  vtkSmartPointer<vtkIntArray> Events;
822  };
823 
824  vtkMRMLNode();
826  ~vtkMRMLNode() override;
827  vtkMRMLNode(const vtkMRMLNode&);
828  void operator=(const vtkMRMLNode&);
829 
832  static void MRMLCallback( vtkObject *caller,
833  unsigned long eid, void *clientData, void *callData );
834 
837  vtkSetStringMacro( TempURLString );
838  vtkGetStringMacro( TempURLString );
839 
847  virtual const char* GetReferenceRoleFromMRMLAttributeName(const char* attName);
848 
856  virtual const char* GetMRMLAttributeNameFromReferenceRole(const char* refRole);
857 
861  virtual bool IsReferenceRoleGeneric(const char* refRole);
862 
866  virtual void UpdateNodeReferences(const char* referenceRole = nullptr);
867 
872  virtual void UpdateNthNodeReference(const char* referenceRole, int n);
873 
877  vtkMRMLNode* UpdateNodeReferenceEventObserver(vtkMRMLNode *oldReferencedNode, vtkMRMLNode *newReferencedNode,
878  vtkIntArray *newEvents, vtkMRMLNodeReference* referenceToIgnore);
879 
885  void GetUpdatedReferencedNodeEventList(int& oldReferencedNodeUseCount, int& newReferencedNodeUseCount,
886  vtkIntArray* oldConsolidatedEventList, vtkIntArray* newConsolidatedEventList,
887  vtkMRMLNode* oldReferencedNode, vtkMRMLNode* newReferencedNode,
888  vtkMRMLNodeReference* referenceToIgnore, vtkIntArray* newEvents);
889 
892  virtual void InvalidateNodeReferences();
893 
898  {
899  this->InvokeEvent(vtkMRMLNode::ReferenceAddedEvent, reference);
900  }
901 
904  {
905  this->InvokeEvent(vtkMRMLNode::ReferenceModifiedEvent, reference);
906  }
907 
910  {
911  this->InvokeEvent(vtkMRMLNode::ReferenceRemovedEvent, reference);
912  }
913 
916  void ParseReferencesAttribute(const char *attValue, std::set<std::string> &references);
917 
919  vtkCallbackCommand *MRMLCallbackCommand;
920 
921  char *ID{nullptr};
922  char *Name{nullptr};
923  char *Description{nullptr};
924  int HideFromEditors{0};
925  int Selectable{1};
926  int Selected{0};
927  int AddToScene{1};
928  bool UndoEnabled{false};
929 
930  int SaveWithScene{true};
931 
934  int InMRMLCallbackFlag{0};
935 
936  // We don't increase the reference count of Scene when store its pointer
937  // therefore we must use a weak pointer to prevent pointer dangling when
938  // the scene is deleted.
939  vtkWeakPointer<vtkMRMLScene> Scene;
940 
941  typedef std::map< std::string, std::string > AttributesType;
943 
944  vtkIntArray* ContentModifiedEvents;
945 
947 
950  typedef std::vector< vtkSmartPointer<vtkMRMLNodeReference> > NodeReferenceListType;
951  typedef std::map< std::string, NodeReferenceListType > NodeReferencesType;
953 
954  std::map< std::string, std::string> NodeReferenceMRMLAttributeNames;
955 
956  typedef std::map< std::string, vtkSmartPointer<vtkIntArray> > NodeReferenceEventsType;
957  NodeReferenceEventsType NodeReferenceEvents; // for each role it specifies which referenced node emitted events this node should observe
958 
959 private:
960 
963  void SetID(const char* newID);
964 
966  char *TempURLString{nullptr};
967 
968  char *SingletonTag{nullptr};
969 
970  int DisableModifiedEvent{0};
971  int ModifiedEventPending{0};
972  std::map<int, int> CustomModifiedEventPending; // event id, pending value (number of events grouped together)
973 };
974 
983 class VTK_MRML_EXPORT MRMLNodeModifyBlocker
984 {
985 public:
986  vtkWeakPointer<vtkMRMLNode> Node;
989  {
990  this->Node = node;
991  if (this->Node)
992  {
993  this->WasModifying = this->Node->StartModify();
994  }
995  };
997  {
998  if (this->Node)
999  {
1000  this->Node->EndModify(this->WasModifying);
1001  }
1002  }
1003 };
1004 
1005 #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:950
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:951
std::vector< std::string > GetAttributeNames()
Get all attribute names.
vtkWeakPointer< vtkMRMLNode > ReferencingNode
Points to this MRML node (that added the reference)
Definition: vtkMRMLNode.h:812
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:934
vtkObserverManager * MRMLObserverManager
Definition: vtkMRMLNode.h:946
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:778
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:956
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:954
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:903
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:922
virtual char * GetSingletonTag()
NodeReferenceEventsType NodeReferenceEvents
Definition: vtkMRMLNode.h:957
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:814
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:944
Safe replacement of MRML node start/end modify.
Definition: vtkMRMLNode.h:983
vtkSmartPointer< vtkIntArray > Events
Definition: vtkMRMLNode.h:821
char * Description
Definition: vtkMRMLNode.h:923
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:909
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:809
AttributesType Attributes
Definition: vtkMRMLNode.h:942
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:941
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:919
vtkWeakPointer< vtkMRMLScene > Scene
Definition: vtkMRMLNode.h:939
int SaveWithScene
Definition: vtkMRMLNode.h:930
MRMLNodeModifyBlocker(vtkMRMLNode *node)
Definition: vtkMRMLNode.h:988
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:897
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:773
bool UndoEnabled
Definition: vtkMRMLNode.h:928
const char * URLEncodeString(const char *inString)
Encode a URL string.
NodeReferencesType NodeReferences
Definition: vtkMRMLNode.h:952
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:924
vtkWeakPointer< vtkMRMLNode > Node
Definition: vtkMRMLNode.h:986
virtual void UpdateScene(vtkMRMLScene *)
Definition: vtkMRMLNode.h:206