| 305 | } |
| 306 | |
| 307 | void 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 | |
| 353 | void QmitkMultiLabelManager::OnCreateSmoothedSurface(bool /*triggered*/) |
| 354 | { |
nothing calls this directly
no test coverage detected