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

Method OnDeleteLabels

Modules/SegmentationUI/src/QmitkMultiLabelInspector.cpp:1361–1401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1359}
1360
1361void QmitkMultiLabelInspector::OnDeleteLabels(bool /*value*/)
1362{
1363 QString question = "Do you really want to remove the selected labels?";
1364 QMessageBox::StandardButton answerButton = QMessageBox::question(
1365 this, "Remove selected labels", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
1366
1367 if (answerButton == QMessageBox::Yes)
1368 {
1369 auto labelValues = this->GetSelectedLabels();
1370
1371 if (labelValues.empty()) return;
1372
1373 this->WaitCursorOn();
1374
1375 mitk::SegGroupModifyUndoRedoHelper::GroupIndexSetType containingGroups;
1376 for (const auto label : labelValues) containingGroups.insert(m_Segmentation->GetGroupIndexOfLabel(label));
1377 auto deletedLabelName = mitk::LabelSetImageHelper::CreateDisplayLabelName(m_Segmentation, m_Segmentation->GetLabel(labelValues.front()));
1378 mitk::SegGroupModifyUndoRedoHelper undoRedoGenerator(m_Segmentation, containingGroups, true);
1379
1380 m_Segmentation->RemoveLabels(this->GetSelectedLabels());
1381
1382 std::ostringstream stream;
1383 stream << "Remove labels \"" << deletedLabelName << "\"";
1384 if (labelValues.size() > 1)
1385 {
1386 stream << "and " << labelValues.size() - 1 << "other labels";
1387 }
1388 undoRedoGenerator.RegisterUndoRedoOperationEvent(stream.str());
1389
1390 this->WaitCursorOff();
1391
1392 // this is needed as workaround for (T27307). It circumvents the fact that modifications
1393 // of data (here the segmentation) does not directly trigger the modification of the
1394 // owning node (see T27307). Therefore other code (like renderers or model views) that e.g.
1395 // listens to the datastorage for modification would not get notified.
1396 if (m_SegmentationNode.IsNotNull())
1397 {
1398 m_SegmentationNode->Modified();
1399 }
1400 }
1401}
1402
1403void QmitkMultiLabelInspector::OnMergeLabels(bool /*value*/)
1404{

Callers

nothing calls this directly

Calls 12

GetSelectedLabelsMethod · 0.95
WaitCursorOnMethod · 0.95
WaitCursorOffMethod · 0.95
GetGroupIndexOfLabelMethod · 0.80
frontMethod · 0.80
RemoveLabelsMethod · 0.80
IsNotNullMethod · 0.80
emptyMethod · 0.45
GetLabelMethod · 0.45
sizeMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected