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

Method AddNewLabelInternal

Modules/SegmentationUI/src/QmitkMultiLabelInspector.cpp:588–626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586}
587
588mitk::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
628mitk::Label* QmitkMultiLabelInspector::AddNewLabel(bool skipNamingPrompt)
629{

Callers 2

AddNewGroupMethod · 0.95
OnAddLabelMethod · 0.95

Calls 7

SetSelectedLabelMethod · 0.95
AddLabelMethod · 0.80
SetActiveLabelMethod · 0.80
indexOfLabelMethod · 0.80
GetValueMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected