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

Method OnClearLabels

Modules/SegmentationUI/src/QmitkMultiLabelInspector.cpp:1282–1320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1280}
1281
1282void QmitkMultiLabelInspector::OnClearLabels(bool /*value*/)
1283{
1284 QString question = "Do you really want to clear the selected labels?";
1285
1286 QMessageBox::StandardButton answerButton = QMessageBox::question(
1287 this, "Clear selected labels", question, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
1288
1289 if (answerButton == QMessageBox::Yes)
1290 {
1291 this->WaitCursorOn();
1292
1293 auto labelValues = this->GetSelectedLabels();
1294 mitk::SegGroupModifyUndoRedoHelper::GroupIndexSetType containingGroups;
1295 for (const auto label : labelValues) containingGroups.insert(m_Segmentation->GetGroupIndexOfLabel(label));
1296 auto clearedLabelName = mitk::LabelSetImageHelper::CreateDisplayLabelName(m_Segmentation, m_Segmentation->GetLabel(labelValues.front()));
1297 mitk::SegGroupModifyUndoRedoHelper undoRedoGenerator(m_Segmentation, containingGroups, true, 0, true, false, true);
1298
1299 m_Segmentation->EraseLabels(labelValues);
1300
1301 std::ostringstream stream;
1302 stream << "Clear labels \"" << clearedLabelName << "\"";
1303 if (labelValues.size() > 1)
1304 {
1305 stream << "and " << labelValues.size() - 1 << "other labels";
1306 }
1307 undoRedoGenerator.RegisterUndoRedoOperationEvent(stream.str());
1308
1309 this->WaitCursorOff();
1310 // this is needed as workaround for (T27307). It circumvents the fact that modifications
1311 // of data (here the segmentation) does not directly trigger the modification of the
1312 // owning node (see T27307). Therefore other code (like renderers or model views) that e.g.
1313 // listens to the datastorage for modification would not get notified.
1314 if (m_SegmentationNode.IsNotNull())
1315 {
1316 m_SegmentationNode->Modified();
1317 mitk::RenderingManager::GetInstance()->RequestUpdateAll();
1318 }
1319 }
1320}
1321
1322void QmitkMultiLabelInspector::OnDeleteAffectedLabel()
1323{

Callers

nothing calls this directly

Calls 12

WaitCursorOnMethod · 0.95
GetSelectedLabelsMethod · 0.95
WaitCursorOffMethod · 0.95
GetGroupIndexOfLabelMethod · 0.80
frontMethod · 0.80
EraseLabelsMethod · 0.80
IsNotNullMethod · 0.80
GetLabelMethod · 0.45
sizeMethod · 0.45
ModifiedMethod · 0.45
RequestUpdateAllMethod · 0.45

Tested by

no test coverage detected