MCPcopy Create free account
hub / github.com/MITK/MITK / FirstLabelInstanceIndex

Method FirstLabelInstanceIndex

Modules/SegmentationUI/src/QmitkMultiLabelTreeModel.cpp:635–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635QModelIndex QmitkMultiLabelTreeModel::FirstLabelInstanceIndex(const QModelIndex& currentIndex) const
636{
637 const QmitkMultiLabelSegTreeItem* currentItem = nullptr;
638
639 if (!currentIndex.isValid())
640 {
641 currentItem = this->m_RootItem.get();
642 }
643 else
644 {
645 currentItem = static_cast<const QmitkMultiLabelSegTreeItem*>(currentIndex.internalPointer());
646 }
647
648 if (!currentItem) return QModelIndex();
649
650 if (currentItem->RootItem() != this->m_RootItem.get()) mitkThrow() << "Invalid call. Passed currentIndex does not seem to be a valid index of this model. It is either outdated or from another model.";
651
652 const QmitkMultiLabelSegTreeItem* resultItem = nullptr;
653 resultItem = GetFirstInstanceLikeItem(currentItem);
654
655 if (nullptr == resultItem)
656 return QModelIndex();
657
658 return GetIndexByItem(resultItem, this);
659}
660
661///** Returns the index to the next node in the tree that behaves like an instance (label node with only one instance
662//or instance node). If current index is at the end, an invalid index is returned.*/

Callers 1

InitializeMethod · 0.80

Calls 4

GetFirstInstanceLikeItemFunction · 0.85
GetIndexByItemFunction · 0.85
RootItemMethod · 0.80
QModelIndexClass · 0.50

Tested by 1

InitializeMethod · 0.64