Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkCreateSurfaceTool.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkCreateSurfaceTool.h"
18 
19 #include "mitkCreateSurfaceTool.xpm"
20 
21 #include "mitkProgressBar.h"
23 #include "mitkStatusBar.h"
24 #include "mitkToolManager.h"
25 
26 #include "itkCommand.h"
27 
28 namespace mitk
29 {
31 }
32 
34 {
35 }
36 
38 {
39 }
40 
41 const char **mitk::CreateSurfaceTool::GetXPM() const
42 {
43  return mitkCreateSurfaceTool_xpm;
44 }
45 
47 {
48  return "Surface";
49 }
50 
52 {
53  return "No surfaces created for these segmentations:";
54 }
55 
57 {
58  if (node)
59  {
60  Image::Pointer image = dynamic_cast<Image *>(node->GetData());
61  if (image.IsNull())
62  return false;
63 
64  try
65  {
67 
68  // attach observer to get notified about result
71  goodCommand->SetCallbackFunction(this, &CreateSurfaceTool::OnSurfaceCalculationDone);
72  surfaceFilter->AddObserver(mitk::ResultAvailable(), goodCommand);
75  badCommand->SetCallbackFunction(this, &CreateSurfaceTool::OnSurfaceCalculationDone);
76  surfaceFilter->AddObserver(mitk::ProcessingError(), badCommand);
77 
78  DataNode::Pointer nodepointer = node;
79  surfaceFilter->SetPointerParameter("Input", image);
80  surfaceFilter->SetPointerParameter("Group node", nodepointer);
81  surfaceFilter->SetParameter("Show result", true);
82  surfaceFilter->SetParameter("Sync visibility", false);
83  surfaceFilter->SetDataStorage(*m_ToolManager->GetDataStorage());
84 
86  StatusBar::GetInstance()->DisplayText("Surface creation started in background...");
87  surfaceFilter->StartAlgorithm();
88  }
89  catch (...)
90  {
91  return false;
92  }
93  }
94 
95  return true;
96 }
97 
99 {
101  m_ToolManager->NewNodesGenerated();
102 }
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
itk::SmartPointer< Self > Pointer
Creates surface models from segmentations.
virtual bool ProcessOneWorkingData(DataNode *node) override
Subclasses should override this method.
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
virtual std::string GetErrorMessage() override
Describes the error (if one occurred during processing).
#define MITK_TOOL_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
void DisplayText(const char *t)
Send a string to the applications StatusBar.
Image class for storing images.
Definition: mitkImage.h:76
static StatusBar * GetInstance()
static method to get the GUI dependent StatusBar-instance so the methods DisplayText, etc. can be called No reference counting, cause of decentral static use!
void AddStepsToDo(unsigned int steps)
Adds steps to totalSteps.
virtual const char * GetName() const override
Returns the name of this tool. Make it short!
virtual const char ** GetXPM() const override
Returns an icon in the XPM format.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.