From 7f02269c73ebcfccd2edf508cd01440d016e1ab9 Mon Sep 17 00:00:00 2001 From: Kyle Sunderland <sunderlandkyl@gmail.com> Date: Mon, 3 May 2021 17:19:57 -0400 Subject: [PATCH] ENH: Restore removed RegisterIncomingMRMLNode function Some extensions still used the RegisterIncomingMRMLNode(vtkMRMLNode*) signature. Restored so that those extensions can keep working. --- .../MRML/vtkMRMLIGTLConnectorNode.cxx | 39 ++++++++++++++++++- OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.h | 1 + 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.cxx b/OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.cxx index 7291406..c6557fe 100644 --- a/OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.cxx +++ b/OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.cxx @@ -619,7 +619,7 @@ void vtkMRMLIGTLConnectorNode::vtkInternal::ProcessIncomingDeviceModifiedEvent( this->IncomingNodeClientIDMap[modifiedNode->GetName()] = modifiedDevice->GetClientID(); modifiedNode->EndModify(wasModifyingNode); - + if(isNewNodeCreated) { //New device event needs to be forward with the MRMLNode to other objects, such as openigtlinkRemote. where the node will be processed to set name accordingly. @@ -1879,6 +1879,43 @@ void vtkMRMLIGTLConnectorNode::OnNodeReferenceModified(vtkMRMLNodeReference* ref } } +//--------------------------------------------------------------------------- +bool vtkMRMLIGTLConnectorNode::RegisterIncomingMRMLNode(vtkMRMLNode* node) +{ + if (!node) + { + vtkErrorMacro("Error registering incoming node. Incoming node is NULL"); + return false; + } + + if (!node->GetScene()) + { + vtkErrorMacro("Error registering incoming node. Node scene is NULL"); + return false; + } + + igtlioDevicePointer device = NULL; + igtlioDeviceKeyType key; + key.name = node->GetName(); + std::vector<std::string> deviceTypes = this->GetDeviceTypeFromMRMLNodeType(node->GetNodeTagName()); + for (size_t typeIndex = 0; typeIndex < deviceTypes.size(); typeIndex++) + { + key.type = deviceTypes[typeIndex]; + device = this->Internal->IOConnector->GetDevice(key); + if (device != NULL) + { + break; + } + } + + if (device == NULL) + { + device = this->Internal->IOConnector->GetDeviceFactory()->create(key.type, key.name); + } + + return this->RegisterIncomingMRMLNode(node, device);; +} + //--------------------------------------------------------------------------- bool vtkMRMLIGTLConnectorNode::RegisterIncomingMRMLNode(vtkMRMLNode* node, IGTLDevicePointer device) { diff --git a/OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.h b/OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.h index 6950b60..8f94cd3 100644 --- a/OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.h +++ b/OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.h @@ -166,6 +166,7 @@ class VTK_SLICER_OPENIGTLINKIF_MODULE_MRML_EXPORT vtkMRMLIGTLConnectorNode : pub // Description: // Register MRML node for incoming data. // Returns true on success. + bool RegisterIncomingMRMLNode(vtkMRMLNode* node); bool RegisterIncomingMRMLNode(vtkMRMLNode* node, IGTLDevicePointer device); // Description: