Permalink
Browse files

BUG: 2727. converted vtkMRMLNodeReference class into a proper VTK cla…

…ss. Converted std::string's into char *. vtkMRMLNodeReference is now protected class inside vtkMRMLNode class.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21850 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information...
1 parent 20dd21f commit 7c165bc88bcd24fec807bcc54619616fb0b518b8 alexy committed Mar 29, 2013
@@ -135,7 +135,6 @@ set(MRMLCore_SRCS
vtkMRMLModelNode.cxx
vtkMRMLModelStorageNode.cxx
vtkMRMLNode.cxx
- vtkMRMLNodeReference.cxx
vtkMRMLParser.cxx
vtkMRMLProceduralColorNode.cxx
vtkMRMLROIListNode.cxx
@@ -13,7 +13,6 @@
// MRML includes
#include "vtkMRMLCoreTestingMacros.h"
#include "vtkMRMLScene.h"
-#include "vtkMRMLNodeReference.h"
// VTK includes
#include <vtkNew.h>
@@ -387,25 +386,6 @@ bool TestAddRefrencedNodeIDWithNoScene()
// in the scene.
scene->AddNode(referencingNode.GetPointer());
- //std::map< std::string, std::vector< vtkMRMLNodeReference *> > refs = referencingNode->GetInternalReferencedNodes();
-
- //refs = referencingNode->GetInternalReferencedNodes();
- /**
- if (referencingNode->GetInternalReferencedNodes()[role1].size() != 2 ||
- referencingNode->GetInternalReferencedNodes()[role1][0]->ReferencedNode != referencedNode2.GetPointer() ||
- referencingNode->GetInternalReferencedNodes()[role1][1]->ReferencedNode != referencedNode3.GetPointer() ||
- referencingNode->GetNthNodeReferenceID(role1.c_str(), 1) == 0 ||
- strcmp(referencingNode->GetNthNodeReferenceID(role1.c_str(), 1), referencedNode3->GetID()) ||
- referencingNode->GetNthNodeReference(role1.c_str(), 1) != referencedNode3.GetPointer() ||
- // make sure it didn't change the first referenced node ID
- referencingNode->GetNthNodeReferenceID(role1.c_str(), 0) == 0 ||
- strcmp(referencingNode->GetNthNodeReferenceID(role1.c_str(), 0), referencedNode2->GetID()) ||
- referencingNode->GetNthNodeReference(role1.c_str(), 0) != referencedNode2.GetPointer())
- {
- std::cout << __LINE__ << ": AddNode failed" << std::endl;
- return false;
- }
- **/
if (
referencingNode->GetNthNodeReferenceID(role1.c_str(), 1) == 0 ||
strcmp(referencingNode->GetNthNodeReferenceID(role1.c_str(), 1), referencedNode3->GetID()) ||
@@ -29,14 +29,18 @@ Version: $Revision: 1.3 $
#include <cassert>
#include <sstream>
-const std::string vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE = "display";
-const std::string vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_MRML_ATTRIBUTE_NAME = "displayNodeRef";
//----------------------------------------------------------------------------
vtkMRMLDisplayableNode::vtkMRMLDisplayableNode()
{
- this->AddNodeReferenceRole(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(),
- vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_MRML_ATTRIBUTE_NAME.c_str() );
+ this->DisplayNodeReferenceRole = 0;
+ this->DisplayNodeReferenceRererenceMRMLAttributeName = 0;
+
+ this->SetDisplayNodeReferenceRole("display");
+ this->SetDisplayNodeReferenceRererenceMRMLAttributeName("displayNodeRef");
+
+ this->AddNodeReferenceRole(this->GetDisplayNodeReferenceRole(),
+ this->GetDisplayNodeReferenceRererenceMRMLAttributeName() );
}
//----------------------------------------------------------------------------
@@ -81,11 +85,11 @@ void vtkMRMLDisplayableNode::PrintSelf(ostream& os, vtkIndent indent)
Superclass::PrintSelf(os,indent);
- int numDisplayNodes = this->GetNumberOfNodeReferences(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str());
+ int numDisplayNodes = this->GetNumberOfNodeReferences(this->GetDisplayNodeReferenceRole());
for (unsigned int i=0; i<numDisplayNodes; i++)
{
- const char * id = this->GetNthNodeReferenceID(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), i);
+ const char * id = this->GetNthNodeReferenceID(this->GetDisplayNodeReferenceRole(), i);
os << indent << "DisplayNodeIDs[" << i << "]: " <<
id << "\n";
@@ -96,13 +100,13 @@ void vtkMRMLDisplayableNode::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
const std::vector<vtkMRMLDisplayNode*>& vtkMRMLDisplayableNode::GetDisplayNodes()
{
- int numDisplayNodes = this->GetNumberOfNodeReferences(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str());
+ int numDisplayNodes = this->GetNumberOfNodeReferences(this->GetDisplayNodeReferenceRole());
vtkMRMLDisplayNode *dnode;
this->DisplayNodes.clear();
for (int i=0; i<numDisplayNodes; i++)
{
dnode = vtkMRMLDisplayNode::SafeDownCast(
- this->GetNthNodeReference(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), i));
+ this->GetNthNodeReference(this->GetDisplayNodeReferenceRole(), i));
this->DisplayNodes.push_back(dnode);
}
@@ -113,7 +117,7 @@ const std::vector<vtkMRMLDisplayNode*>& vtkMRMLDisplayableNode::GetDisplayNodes(
vtkMRMLDisplayNode* vtkMRMLDisplayableNode::GetNthDisplayNode(int n)
{
return vtkMRMLDisplayNode::SafeDownCast(
- this->GetNthNodeReference(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), n));
+ this->GetNthNodeReference(this->GetDisplayNodeReferenceRole(), n));
}
//---------------------------------------------------------------------------
@@ -122,7 +126,7 @@ void vtkMRMLDisplayableNode::ProcessMRMLEvents ( vtkObject *caller,
void *callData )
{
Superclass::ProcessMRMLEvents(caller, event, callData);
- int numDisplayNodes = this->GetNumberOfNodeReferences(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str());
+ int numDisplayNodes = this->GetNumberOfNodeReferences(this->GetDisplayNodeReferenceRole());
for (int i=0; i<numDisplayNodes; i++)
{
vtkMRMLDisplayNode *dnode = this->GetNthDisplayNode(i);
@@ -75,30 +75,30 @@ class VTK_MRML_EXPORT vtkMRMLDisplayableNode : public vtkMRMLStorableNode
/// \sa SetAndObserverNthDisplayNodeID(int, const char*)
inline void SetAndObserveDisplayNodeID(const char *displayNodeID)
{
- this->SetAndObserveNodeReferenceID(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), displayNodeID);
+ this->SetAndObserveNodeReferenceID(this->GetDisplayNodeReferenceRole(), displayNodeID);
}
///
/// Convenience method that adds a display node ID at the end of the list.
/// \sa SetAndObserverNthDisplayNodeID(int, const char*)
inline void AddAndObserveDisplayNodeID(const char *displayNodeID)
{
- this->AddAndObserveNodeReferenceID(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), displayNodeID);
+ this->AddAndObserveNodeReferenceID(this->GetDisplayNodeReferenceRole(), displayNodeID);
}
///
/// Convenience method that removes the Nth display node ID from the list
/// \sa SetAndObserverNthDisplayNodeID(int, const char*)
inline void RemoveNthDisplayNodeID(int n)
{
- this->RemoveNthNodeReferenceID(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), n);
+ this->RemoveNthNodeReferenceID(this->GetDisplayNodeReferenceRole(), n);
}
///
/// Remove all display node IDs and associated display nodes.
inline void RemoveAllDisplayNodeIDs()
{
- this->RemoveAllNodeReferenceIDs(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str());
+ this->RemoveAllNodeReferenceIDs(this->GetDisplayNodeReferenceRole());
}
///
@@ -117,22 +117,22 @@ class VTK_MRML_EXPORT vtkMRMLDisplayableNode : public vtkMRMLStorableNode
/// AddAndObserveDisplayNodeID(const char *), RemoveNthDisplayNodeID(int)
inline void SetAndObserveNthDisplayNodeID(int n, const char *displayNodeID)
{
- this->SetAndObserveNthNodeReferenceID(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), n, displayNodeID);
+ this->SetAndObserveNthNodeReferenceID(this->GetDisplayNodeReferenceRole(), n, displayNodeID);
}
///
/// Return true if displayNodeID is in the display node ID list.
inline bool HasDisplayNodeID(const char* displayNodeID)
{
- return this->HasNodeReferenceID(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), displayNodeID);
+ return this->HasNodeReferenceID(this->GetDisplayNodeReferenceRole(), displayNodeID);
}
///
/// Return the number of display node IDs (and display nodes as they always
/// have the same size).
inline int GetNumberOfDisplayNodes()
{
- return this->GetNumberOfNodeReferences(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str());
+ return this->GetNumberOfNodeReferences(this->GetDisplayNodeReferenceRole());
}
///
@@ -142,7 +142,7 @@ class VTK_MRML_EXPORT vtkMRMLDisplayableNode : public vtkMRMLStorableNode
/// is returned.
inline const char *GetNthDisplayNodeID(int n)
{
- return this->GetNthNodeReferenceID(vtkMRMLDisplayableNode::DISPLAY_NODE_REFERENCE_ROLE.c_str(), n);
+ return this->GetNthNodeReferenceID(this->GetDisplayNodeReferenceRole(), n);
}
///
@@ -220,22 +220,27 @@ class VTK_MRML_EXPORT vtkMRMLDisplayableNode : public vtkMRMLStorableNode
/// Get bounding box in global RAS the form (xmin,xmax, ymin,ymax, zmin,zmax).
virtual void GetRASBounds(double bounds[6]);
- static const std::string DISPLAY_NODE_REFERENCE_ROLE;
- static const std::string DISPLAY_NODE_REFERENCE_MRML_ATTRIBUTE_NAME;
-
protected:
vtkMRMLDisplayableNode();
~vtkMRMLDisplayableNode();
vtkMRMLDisplayableNode(const vtkMRMLDisplayableNode&);
void operator=(const vtkMRMLDisplayableNode&);
+ char *DisplayNodeReferenceRole;
+ char *DisplayNodeReferenceRererenceMRMLAttributeName;
+
+ vtkSetStringMacro(DisplayNodeReferenceRole);
+ vtkGetStringMacro(DisplayNodeReferenceRole);
+
+ vtkSetStringMacro(DisplayNodeReferenceRererenceMRMLAttributeName);
+ vtkGetStringMacro(DisplayNodeReferenceRererenceMRMLAttributeName);
///
/// Called when a node reference ID is added (list size increased).
virtual void OnNodeReferenceAdded(vtkMRMLNodeReference *reference)
{
Superclass::OnNodeReferenceAdded(reference);
- if (reference->ReferenceRole == this->DISPLAY_NODE_REFERENCE_ROLE)
+ if (std::string(reference->GetReferenceRole()) == this->DisplayNodeReferenceRole)
{
this->InvokeEvent(vtkMRMLDisplayableNode::DisplayModifiedEvent, reference->ReferencedNode);
}
Oops, something went wrong.

0 comments on commit 7c165bc

Please sign in to comment.