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

Method OnLabelModified

Modules/SegmentationUI/src/QmitkMultiLabelTreeModel.cpp:986–1023  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

984}
985
986void 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
1025const QmitkMultiLabelSegTreeItem* QmitkMultiLabelTreeModel::ClosestLabelInstanceIndex(const QmitkMultiLabelSegTreeItem* currentItem) const
1026{

Callers 1

ITKEventHandlerMethod · 0.95

Calls 10

columnCountMethod · 0.95
OnLabelRemovedMethod · 0.95
OnLabelAddedMethod · 0.95
GetInstanceItemFunction · 0.85
GetIndexByItemFunction · 0.85
ParentItemMethod · 0.80
HandleAsInstanceMethod · 0.80
GetLabelMethod · 0.45
GetNameMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected