| 633 | } |
| 634 | |
| 635 | QModelIndex 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.*/ |