| 984 | } |
| 985 | |
| 986 | void QmitkMultiLabelTreeModel::OnLabelModified(LabelValueType labelValue) |
| 987 | { |
| 988 | if (labelValue == mitk::MultiLabelSegmentation::UNLABELED_VALUE) return; |
| 989 | |
| 990 | auto instanceItem = GetInstanceItem(labelValue, this->m_RootItem.get()); |
| 991 | |
| 992 | if (nullptr == instanceItem) |
| 993 | { |
| 994 | mitkThrow() << "Internal invalid state. QmitkMultiLabelTreeModel received a LabelModified signal for a label that is not represented in the model. Invalid label: " << labelValue; |
| 995 | } |
| 996 | |
| 997 | auto internalLabel = instanceItem->GetLabel(); |
| 998 | auto segLabel = m_Segmentation->GetLabel(labelValue); |
| 999 | if (segLabel != internalLabel) |
| 1000 | { //label instance has been changed in the segmentation instance |
| 1001 | //we have to update internal pointer |
| 1002 | instanceItem->m_Label = segLabel; |
| 1003 | } |
| 1004 | |
| 1005 | auto labelItem = instanceItem->ParentItem(); |
| 1006 | |
| 1007 | m_ModelUpdateOngoing = true; |
| 1008 | if (labelItem->m_ClassName == instanceItem->GetLabel()->GetName()) |
| 1009 | { //only the state of the label changed, but not its position in the model tree. |
| 1010 | auto index = labelItem->HandleAsInstance() ? GetIndexByItem(labelItem, this) : GetIndexByItem(instanceItem, this); |
| 1011 | auto rightIndex = index.sibling(index.row(), this->columnCount() - 1); |
| 1012 | emit dataChanged(index, rightIndex); |
| 1013 | } |
| 1014 | else |
| 1015 | { //the name of the label changed and thus its place in the model tree, delete the current item and add a new one |
| 1016 | this->OnLabelRemoved(labelValue); |
| 1017 | this->OnLabelAdded(labelValue); |
| 1018 | } |
| 1019 | |
| 1020 | m_NearestLabelValueToLastChange = labelValue; |
| 1021 | m_ModelUpdateOngoing = false; |
| 1022 | emit modelChanged(); |
| 1023 | } |
| 1024 | |
| 1025 | const QmitkMultiLabelSegTreeItem* QmitkMultiLabelTreeModel::ClosestLabelInstanceIndex(const QmitkMultiLabelSegTreeItem* currentItem) const |
| 1026 | { |
no test coverage detected