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

Method AddNewGroup

Modules/SegmentationUI/src/QmitkMultiLabelInspector.cpp:790–837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

788}
789
790mitk::Label* QmitkMultiLabelInspector::AddNewGroup()
791{
792 if (!m_AllowLabelModification)
793 mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of AddNewLabel.";
794
795 if (m_Segmentation.IsNull())
796 {
797 return nullptr;
798 }
799
800 mitk::MultiLabelSegmentation::GroupIndexType groupID = 0;
801 mitk::Label* newLabel = nullptr;
802 m_ModelManipulationOngoing = true;
803 try
804 {
805 this->WaitCursorOn();
806
807 groupID = m_Segmentation->AddGroup();
808
809 mitk::SegGroupInsertUndoRedoHelper undoRedoGenerator(m_Segmentation, { groupID }, false, true);
810 undoRedoGenerator.RegisterUndoRedoOperationEvent("Insert new group \"" + mitk::LabelSetImageHelper::CreateDisplayGroupName(m_Segmentation, groupID) + "\"");
811
812 this->WaitCursorOff();
813
814 newLabel = this->AddNewLabelInternal(groupID);
815 }
816 catch (mitk::Exception& e)
817 {
818 this->WaitCursorOff();
819 m_ModelManipulationOngoing = false;
820 MITK_ERROR << "Exception caught: " << e.GetDescription();
821 QMessageBox::information(this, "Add group", "Could not add a new group. See error log for details.");
822 }
823 m_ModelManipulationOngoing = false;
824
825 emit ModelUpdated();
826
827 // this is needed as workaround for (T27307). It circumvents the fact that modifications
828 // of data (here the segmentation) does not directly trigger the modification of the
829 // owning node (see T27307). Therefore other code (like renderers or model views) that e.g.
830 // listens to the datastorage for modification would not get notified.
831 if (m_SegmentationNode.IsNotNull())
832 {
833 m_SegmentationNode->Modified();
834 }
835
836 return newLabel;
837}
838
839void QmitkMultiLabelInspector::RemoveGroupInternal(const mitk::MultiLabelSegmentation::GroupIndexType& groupID)
840{

Callers

nothing calls this directly

Calls 9

WaitCursorOnMethod · 0.95
WaitCursorOffMethod · 0.95
AddNewLabelInternalMethod · 0.95
AddGroupMethod · 0.80
IsNotNullMethod · 0.80
IsNullMethod · 0.45
GetDescriptionMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected