| 1401 | } |
| 1402 | |
| 1403 | void QmitkMultiLabelInspector::OnMergeLabels(bool /*value*/) |
| 1404 | { |
| 1405 | auto currentLabel = GetCurrentLabel(); |
| 1406 | QString question = "Do you really want to merge selected labels into \"" + QString::fromStdString(currentLabel->GetName())+"\"?"; |
| 1407 | |
| 1408 | QMessageBox::StandardButton answerButton = QMessageBox::question( |
| 1409 | this, "Merge selected label", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes); |
| 1410 | |
| 1411 | if (answerButton == QMessageBox::Yes) |
| 1412 | { |
| 1413 | this->WaitCursorOn(); |
| 1414 | |
| 1415 | mitk::SegGroupModifyUndoRedoHelper undoRedoGenerator(m_Segmentation, { m_Segmentation->GetGroupIndexOfLabel(currentLabel->GetValue()) }, true); |
| 1416 | |
| 1417 | m_Segmentation->MergeLabels(currentLabel->GetValue(), this->GetSelectedLabels()); |
| 1418 | |
| 1419 | // Propagate the source labels' provenance into the merge target so its algorithm type/name reflect |
| 1420 | // the (possibly algorithmic) content it now contains. Done before RegisterUndoRedoOperationEvent so |
| 1421 | // the property change is captured in the same undo group as the pixel merge. |
| 1422 | for (const auto sourceValue : this->GetSelectedLabels()) |
| 1423 | { |
| 1424 | if (sourceValue == currentLabel->GetValue()) |
| 1425 | continue; |
| 1426 | if (const mitk::Label* sourceLabel = m_Segmentation->GetLabel(sourceValue)) |
| 1427 | currentLabel->MergeToolUses(sourceLabel); |
| 1428 | } |
| 1429 | |
| 1430 | undoRedoGenerator.RegisterUndoRedoOperationEvent("Merge into label \"" + mitk::LabelSetImageHelper::CreateDisplayLabelName(m_Segmentation, currentLabel) + "\""); |
| 1431 | |
| 1432 | this->WaitCursorOff(); |
| 1433 | |
| 1434 | // this is needed as workaround for (T27307). It circumvents the fact that modifications |
| 1435 | // of data (here the segmentation) does not directly trigger the modification of the |
| 1436 | // owning node (see T27307). Therefore other code (like renderers or model views) that e.g. |
| 1437 | // listens to the datastorage for modification would not get notified. |
| 1438 | if (m_SegmentationNode.IsNotNull()) |
| 1439 | { |
| 1440 | m_SegmentationNode->Modified(); |
| 1441 | } |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | void QmitkMultiLabelInspector::OnAddLabel() |
| 1446 | { |
nothing calls this directly
no test coverage detected