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

Method OnCreateMask

Modules/SegmentationUI/src/QmitkMultiLabelManager.cpp:307–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307void QmitkMultiLabelManager::OnCreateMask(bool /*triggered*/)
308{
309 mitk::ToolManagerProvider::GetInstance()->GetToolManager()->ActivateTool(-1);
310
311 auto currentLabel = this->GetMultiLabelSegmentation()->GetLabel(this->GetSelectedLabels().front());
312 mitk::Image::Pointer maskImage;
313 try
314 {
315 this->WaitCursorOn();
316
317 if (currentLabel.IsNull())
318 mitkThrow() << "Invalid state context menu action was triggered with an invalid label id. Label id: " << this->GetSelectedLabels().front();
319 auto pixelValue = currentLabel->GetValue();
320
321 maskImage = mitk::CreateLabelMask(GetMultiLabelSegmentation(),pixelValue);
322 this->WaitCursorOff();
323 }
324 catch (mitk::Exception &e)
325 {
326 this->WaitCursorOff();
327 MITK_ERROR << "Exception caught: " << e.GetDescription();
328 QMessageBox::information(this, "Create Mask", "Could not create a mask out of the selected label.\n");
329 return;
330 }
331
332 if (maskImage.IsNull())
333 {
334 QMessageBox::information(this, "Create Mask", "Could not create a mask out of the selected label.\n");
335 return;
336 }
337
338 mitk::DataNode::Pointer maskNode = mitk::DataNode::New();
339 std::string name = currentLabel->GetName();
340 name += "-mask";
341 maskNode->SetName(name);
342 maskNode->SetData(maskImage);
343 maskNode->SetBoolProperty("binary", true);
344 maskNode->SetBoolProperty("outline binary", true);
345 maskNode->SetBoolProperty("outline binary shadow", true);
346 maskNode->SetFloatProperty("outline width", 2.0);
347 maskNode->SetColor(currentLabel->GetColor());
348 maskNode->SetOpacity(1.0);
349
350 m_DataStorage->Add(maskNode, this->GetMultiLabelNode());
351}
352
353void QmitkMultiLabelManager::OnCreateSmoothedSurface(bool /*triggered*/)
354{

Callers

nothing calls this directly

Calls 15

GetSelectedLabelsMethod · 0.95
WaitCursorOnMethod · 0.95
WaitCursorOffMethod · 0.95
GetMultiLabelNodeMethod · 0.95
ActivateToolMethod · 0.80
frontMethod · 0.80
NewFunction · 0.50
GetToolManagerMethod · 0.45
GetLabelMethod · 0.45
IsNullMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected