Skip to content
Permalink
Browse files

Merge pull request #1 from tokjun/master

Fix the issue #0002992 reported in Slicer Issue tracker.
  • Loading branch information...
tokjun committed Apr 16, 2013
2 parents cd34648 + b08e422 commit b05dca23ae49fc2e36414f905e96805b0e63dfac
Showing with 295 additions and 120 deletions.
  1. +34 −0 GUI/qMRMLIGTLIOModel.cxx
  2. +226 −115 MRML/vtkMRMLIGTLConnectorNode.cxx
  3. +35 −5 MRML/vtkMRMLIGTLConnectorNode.h
@@ -276,6 +276,20 @@ void qMRMLIGTLIOModel::updateIOTreeBranch(vtkMRMLIGTLConnectorNode* node, QStand
nnodes = node->GetNumberOfOutgoingMRMLNodes();
}

// GetNumberOfOutgoingMRMLNodes map to check if items in the tree exist in the MRML scene.
std::map<QString, bool> nodeExist;
nodeExist.clear();
int nRows = item->rowCount();
for (int r = 0; r < nRows; r ++)
{
QStandardItem* c = item->child(r, 0);
if (c)
{
QString text = c->data().toString();
nodeExist[text] = false;
}
}

for (int i = 0; i < nnodes; i ++)
{
vtkMRMLNode* inode;
@@ -311,13 +325,16 @@ void qMRMLIGTLIOModel::updateIOTreeBranch(vtkMRMLIGTLConnectorNode* node, QStand
{
// Found the node... skip
row = r;
nodeExist[text] = true;
break;
}
}
}

if (row < 0) // If the node is not in the tree, add it.
{
nodeExist["io"+QString(inode->GetID())] = true;

QList<QStandardItem*> items;
// Node name
QStandardItem* item0 = new QStandardItem;
@@ -387,6 +404,23 @@ void qMRMLIGTLIOModel::updateIOTreeBranch(vtkMRMLIGTLConnectorNode* node, QStand
//extraItems[extraType] = extraItems[extraType].toStringList() << text;
//parent->setData(extraItems, qMRMLSceneModel::ExtraItemsRole );
}

// Romove rows for nodes that does not exist in the MRML scene
nRows = item->rowCount();
for (int r = 0; r < nRows; r ++)
{
QStandardItem* c = item->child(r, 0);
if (c)
{
if (nodeExist[c->data().toString()] == false)
{
item->removeRow(r);
nRows = item->rowCount();
r --;
}
}
}

}


Oops, something went wrong.

0 comments on commit b05dca2

Please sign in to comment.
You can’t perform that action at this time.