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

Method OnRenameLabel

Modules/SegmentationUI/src/QmitkMultiLabelInspector.cpp:1556–1601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1554}
1555
1556void QmitkMultiLabelInspector::OnRenameLabel(bool /*value*/)
1557{
1558 auto relevantLabelValues = this->GetCurrentlyAffactedLabelInstances();
1559 auto currentLabel = this->GetCurrentLabel();
1560 auto selectedLabels = this->GetSelectedLabels();
1561
1562 mitk::SegLabelPropModifyUndoRedoHelper undoRedoHelper(m_Segmentation, relevantLabelValues);
1563
1564 bool canceled = false;
1565 emit LabelRenameRequested(currentLabel, true, canceled);
1566
1567 if (canceled) return;
1568
1569
1570 for (auto value : relevantLabelValues)
1571 {
1572 if (value != currentLabel->GetValue())
1573 {
1574 auto label = this->m_Segmentation->GetLabel(value);
1575 if (nullptr == label)
1576 mitkThrow() << "Invalid state. Internal model returned a label value that does not exist in segmentation. Invalid value:" << value;
1577
1578 label->SetName(currentLabel->GetName());
1579 label->SetColor(currentLabel->GetColor());
1580 m_Segmentation->UpdateLookupTable(label->GetValue());
1581
1582 // this is needed as workaround for (T27307). It circumvents the fact that modifications
1583 // of data (here the segmentation) does not directly trigger the modification of the
1584 // owning node (see T27307). Therefore other code (like renderers or model views) that e.g.
1585 // listens to the datastorage for modification would not get notified.
1586 if (m_SegmentationNode.IsNotNull())
1587 {
1588 m_SegmentationNode->Modified();
1589 }
1590 }
1591 }
1592 m_Segmentation->GetLookupTable()->Modified();
1593
1594 undoRedoHelper.RegisterUndoRedoOperationEvent("Change label(s) name/color");
1595
1596 // ensure that the labels that where selected before renaming are also selected afterwards
1597 // it can differ as renaming might change the location in the view, but the selected index in the view is kept
1598 this->SetSelectedLabels(selectedLabels);
1599
1600 emit ModelUpdated();
1601}
1602
1603
1604void QmitkMultiLabelInspector::SetLockOfAffectedLabels(bool locked) const

Callers 1

OnItemDoubleClickedMethod · 0.95

Calls 15

GetCurrentLabelMethod · 0.95
GetSelectedLabelsMethod · 0.95
SetSelectedLabelsMethod · 0.95
IsNotNullMethod · 0.80
GetValueMethod · 0.45
GetLabelMethod · 0.45
SetNameMethod · 0.45
GetNameMethod · 0.45
SetColorMethod · 0.45
GetColorMethod · 0.45

Tested by

no test coverage detected