<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.3%2FDevelopers%2FMRML%2FNodeReferences</id>
	<title>Documentation/4.3/Developers/MRML/NodeReferences - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.3%2FDevelopers%2FMRML%2FNodeReferences"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.3/Developers/MRML/NodeReferences&amp;action=history"/>
	<updated>2026-05-08T01:35:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.3/Developers/MRML/NodeReferences&amp;diff=37991&amp;oldid=prev</id>
		<title>JChris.FillionR: moved Documentation/4.3/Developers/MRMLNodeReferences to Documentation/4.3/Developers/MRML/NodeReferences</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.3/Developers/MRML/NodeReferences&amp;diff=37991&amp;oldid=prev"/>
		<updated>2014-05-19T16:51:42Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/wiki/Documentation/4.3/Developers/MRMLNodeReferences&quot; class=&quot;mw-redirect&quot; title=&quot;Documentation/4.3/Developers/MRMLNodeReferences&quot;&gt;Documentation/4.3/Developers/MRMLNodeReferences&lt;/a&gt; to &lt;a href=&quot;/wiki/Documentation/4.3/Developers/MRML/NodeReferences&quot; title=&quot;Documentation/4.3/Developers/MRML/NodeReferences&quot;&gt;Documentation/4.3/Developers/MRML/NodeReferences&lt;/a&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 16:51, 19 May 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>JChris.FillionR</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.3/Developers/MRML/NodeReferences&amp;diff=35065&amp;oldid=prev</id>
		<title>UpdateBot: Nightly -&gt; 4.3</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.3/Developers/MRML/NodeReferences&amp;diff=35065&amp;oldid=prev"/>
		<updated>2013-09-05T03:26:57Z</updated>

		<summary type="html">&lt;p&gt;Nightly -&amp;gt; 4.3&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
== Goal ==&lt;br /&gt;
This page explains how to create a MRML node that reference and observes&lt;br /&gt;
other MRML nodes.&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
In Slicer4.2 prior to March of 2013 each MRML node that contained&lt;br /&gt;
references to other MRML nodes (for example each vtkMRMLDispalyableNode contained&lt;br /&gt;
a reference to an instance vtkMRMLDisplayNode) was responsible for&lt;br /&gt;
managing the references internally. This involved complicated logic and&lt;br /&gt;
bookkeeping to maintain the references in sync when importing scenes,&lt;br /&gt;
adding/deleting nodes, modifying referenced nodes, etc.&lt;br /&gt;
&lt;br /&gt;
When creating a new node with the reference to another node the following&lt;br /&gt;
methods needed to be created/updated to handle the references:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Copy&lt;br /&gt;
* PrintSelf&lt;br /&gt;
* ReadXMLAttributes&lt;br /&gt;
* WriteXML&lt;br /&gt;
* ProcessMRMLEvents&lt;br /&gt;
* UpdateReferenceIS&lt;br /&gt;
* SetSceneRefeecnes&lt;br /&gt;
* UpdateScene&lt;br /&gt;
* UpdateReferences&lt;br /&gt;
* SetAndObserveReferenedNode&lt;br /&gt;
&lt;br /&gt;
== New API ==&lt;br /&gt;
The new node reference API automatically takes care of read/write/copy of&lt;br /&gt;
node references, updating references on scene import, adding and deleting&lt;br /&gt;
nodes. All that functionality in implemented the vtkMRMLNode base&lt;br /&gt;
class. The only thing that needs to happen in the derived MRML node class&lt;br /&gt;
(usually in the constructor of the class)&lt;br /&gt;
is a call to vtkMRMLNode::AddNodeReferenceRole(const char *referenceRole,&lt;br /&gt;
const char *mrmlAttributeName)&lt;br /&gt;
that takes a unique string defining the reference role between this node&lt;br /&gt;
and the referenced node, and a MRML attribute name for storing the&lt;br /&gt;
reference in the .mrml file.&lt;br /&gt;
&lt;br /&gt;
The only other call that is needed is either:&lt;br /&gt;
vtkMRMLNode* SetAndObserveNodeReferenceID(const char* referenceRole , const&lt;br /&gt;
char* referencedNodeID, vtkIntArray *events=0);&lt;br /&gt;
or &lt;br /&gt;
vtkMRMLNode* AddAndObserveNodeReferenceID(const char* referenceRole , const&lt;br /&gt;
char* referencedNodeID, vtkIntArray *events=0);&lt;br /&gt;
if the multiple instances of this reference are allowed.&lt;br /&gt;
&lt;br /&gt;
vtkMRMLNode also provides virtual callbacks that can be extended in the&lt;br /&gt;
derived calsses:&lt;br /&gt;
* OnNodeReferenceAdded(vtkMRMLNodeReference *reference)&lt;br /&gt;
* OnNodeReferenceRemoved(vtkMRMLNodeReference *reference)&lt;br /&gt;
* OnNodeReferenceModified(vtkMRMLNodeReference *reference)&lt;br /&gt;
&lt;br /&gt;
By default those methods generate the following events:&lt;br /&gt;
* vtkMRMLNode::ReferenceAddedEvent&lt;br /&gt;
* vtkMRMLNode::ReferenceRemovedEvent&lt;br /&gt;
* vtkMRMLNode::ReferenceModifiedEvent&lt;br /&gt;
&lt;br /&gt;
In the derived classes those methods could be extended using vtkMRMLNode&lt;br /&gt;
API that allows querying of node's references:&lt;br /&gt;
&lt;br /&gt;
* char *GetNthNodeReferenceID(const char* referenceRole, int n);&lt;br /&gt;
* vtkMRMLNode* GetNthNodeReference(const char* referenceRole, int n);&lt;br /&gt;
* int GetNumberOfNodeReferences(const char* referenceRole);&lt;br /&gt;
* etc.&lt;br /&gt;
&lt;br /&gt;
For full API see:&lt;br /&gt;
&lt;br /&gt;
http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/Core/vtkMRMLNode.h?view=log&lt;br /&gt;
&lt;br /&gt;
Currently the following MRML nodes are implemented using new API:&lt;br /&gt;
* vtkMRMLStorableNode&lt;br /&gt;
* vtkMRMLTransformableNode&lt;br /&gt;
* vtkMRMLDisplayableNode&lt;br /&gt;
&lt;br /&gt;
Other references to MRML nodes such as to vtkMRMLColorTableNode, vtkMRMLDiffusionTensorDisplayPropertiesNode are currently not using new API.&lt;br /&gt;
&lt;br /&gt;
Module parameter nodes that contain references to input/output Volume/Model, etc. nodes may or may not require a new API since not all of them contain logic to deal with reference changes.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
* vtkMRMLTransformableNode implementation:&lt;br /&gt;
http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/Core/vtkMRMLTransformableNode.h?view=log&lt;br /&gt;
* vtkMRMLDisplayableNodeimplementation:&lt;br /&gt;
http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/Core/vtkMRMLDisplayableNode.h?view=log&lt;br /&gt;
* vtkMRMLStorableNodeimplementation:&lt;br /&gt;
http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/Core/vtkMRMLStorableNode.h?view=log&lt;/div&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
</feed>