| 1554 | } |
| 1555 | |
| 1556 | void 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 | |
| 1604 | void QmitkMultiLabelInspector::SetLockOfAffectedLabels(bool locked) const |
no test coverage detected