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

Method OnRenameGroup

Modules/SegmentationUI/src/QmitkMultiLabelInspector.cpp:1517–1554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1515}
1516
1517void QmitkMultiLabelInspector::OnRenameGroup()
1518{
1519 if (!m_AllowLabelModification)
1520 mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of RenameGroup.";
1521
1522 if (m_Segmentation.IsNull())
1523 return;
1524
1525 auto currentIndex = this->m_Controls->view->currentIndex();
1526 auto groupIDVariant = currentIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::GroupIDRole);
1527
1528 if (groupIDVariant.isValid())
1529 {
1530 auto groupID = groupIDVariant.value<mitk::MultiLabelSegmentation::GroupIndexType>();
1531
1532 bool dlgOK;
1533 auto groupName = mitk::LabelSetImageHelper::CreateDisplayGroupName(m_Segmentation, groupID);
1534 auto newName = QInputDialog::getText(this, "Change name of the group", "Group name:", QLineEdit::Normal, QString::fromStdString(groupName), &dlgOK);
1535 if (dlgOK)
1536 {
1537 mitk::SegGroupModifyUndoRedoHelper undoRedoGenerator(m_Segmentation, { groupID }, true, 0, true, true);
1538
1539 m_Segmentation->SetGroupName(groupID, newName.toStdString());
1540 // this is needed as workaround for (T27307). It circumvents the fact that modifications
1541 // of data (here the segmentation) does not directly trigger the modification of the
1542 // owning node (see T27307). Therefore other code (like renderers or model views) that e.g.
1543 // listens to the datastorage for modification would not get notified.
1544
1545 undoRedoGenerator.RegisterUndoRedoOperationEvent("Rename group #" + std::to_string(groupID));
1546
1547 if (m_SegmentationNode.IsNotNull())
1548 {
1549 m_SegmentationNode->Modified();
1550 }
1551
1552 }
1553 }
1554}
1555
1556void QmitkMultiLabelInspector::OnRenameLabel(bool /*value*/)
1557{

Callers

nothing calls this directly

Calls 6

SetGroupNameMethod · 0.80
IsNotNullMethod · 0.80
IsNullMethod · 0.45
dataMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected