| 586 | } |
| 587 | |
| 588 | mitk::Label* QmitkMultiLabelInspector::AddNewLabelInternal(const mitk::MultiLabelSegmentation::GroupIndexType& containingGroup, |
| 589 | bool skipNamingPrompt) |
| 590 | { |
| 591 | auto newLabel = mitk::LabelSetImageHelper::CreateNewLabel(m_Segmentation); |
| 592 | |
| 593 | bool canceled = false; |
| 594 | if (!skipNamingPrompt) |
| 595 | { |
| 596 | auto suggestionPref = mitk::LabelSuggestionHelper::GetSuggestionPreferences(); |
| 597 | if (!m_DefaultLabelNaming || suggestionPref.enforceSuggestions) |
| 598 | emit LabelRenameRequested(newLabel, false, canceled); |
| 599 | } |
| 600 | |
| 601 | if (canceled) return nullptr; |
| 602 | |
| 603 | mitk::SegGroupModifyUndoRedoHelper undoRedoGenerator(m_Segmentation, { containingGroup }, |
| 604 | false, 0, false, true, true); |
| 605 | |
| 606 | m_ModelManipulationOngoing = true; |
| 607 | m_Segmentation->AddLabel(newLabel, containingGroup, false); |
| 608 | m_Segmentation->SetActiveLabel(newLabel->GetValue()); |
| 609 | m_ModelManipulationOngoing = false; |
| 610 | |
| 611 | undoRedoGenerator.RegisterUndoRedoOperationEvent("Add label \""+ mitk::LabelSetImageHelper::CreateDisplayLabelName(m_Segmentation, newLabel)+"\""); |
| 612 | |
| 613 | this->SetSelectedLabel(newLabel->GetValue()); |
| 614 | |
| 615 | auto index = m_Model->indexOfLabel(newLabel->GetValue()); |
| 616 | |
| 617 | if (!index.isValid()) |
| 618 | mitkThrow() << "Segmentation or QmitkMultiLabelTreeModel is in an invalid state. Label is not present in the " |
| 619 | "model after adding it to the segmentation. Label value: " << newLabel->GetValue(); |
| 620 | |
| 621 | m_Controls->view->expand(index.parent()); |
| 622 | |
| 623 | emit ModelUpdated(); |
| 624 | |
| 625 | return newLabel; |
| 626 | } |
| 627 | |
| 628 | mitk::Label* QmitkMultiLabelInspector::AddNewLabel(bool skipNamingPrompt) |
| 629 | { |
no test coverage detected