Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkSegmentationsProcessingTool.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 
18 #include "mitkProgressBar.h"
19 #include "mitkToolManager.h"
20 
22 {
23 }
24 
26 {
27 }
28 
30 {
31  return "segmentationProcessing";
32 }
33 
35 {
36  Superclass::Activated();
37 
38  ProcessAllObjects();
39  m_ToolManager->ActivateTool(-1);
40 }
41 
43 {
44  Superclass::Deactivated();
45 }
46 
48 {
49  m_FailedNodes.clear();
50  StartProcessingAllData();
51 
52  ToolManager::DataVectorType nodes = m_ToolManager->GetWorkingData();
53  ProgressBar::GetInstance()->AddStepsToDo(nodes.size() + 2);
54 
55  // for all selected nodes
56  for (ToolManager::DataVectorType::iterator nodeiter = nodes.begin(); nodeiter != nodes.end(); ++nodeiter)
57  {
58  DataNode::Pointer node = *nodeiter;
59 
60  if (!ProcessOneWorkingData(node))
61  {
62  std::string nodeName;
63  m_FailedNodes += " '";
64  if (node->GetName(nodeName))
65  {
66  m_FailedNodes += nodeName.c_str();
67  }
68  else
69  {
70  m_FailedNodes += "(no name)";
71  }
72  m_FailedNodes += "'";
73  }
74 
76  }
77 
78  FinishProcessingAllData();
80 }
81 
83 {
84 }
85 
87 {
88  return true;
89 }
90 
92 {
93  SendErrorMessageIfAny();
94 }
95 
97 {
98  if (!m_FailedNodes.empty())
99  {
100  Tool::ErrorMessage(GetErrorMessage() + m_FailedNodes);
101  }
102 }
103 
105 {
106  return "Processing of these nodes failed:";
107 }
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:92
std::vector< DataNode * > DataVectorType
Message1< std::string > ErrorMessage
To send error messages (to be shown by some GUI)
Definition: mitkTool.h:105
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
virtual void ProcessAllObjects()
Loop over all working data items.
virtual void Activated() override
Called when the tool gets activated.
virtual void Deactivated() override
Called when the tool gets deactivated.
virtual void StartProcessingAllData()
Subclasses should override this method.
virtual std::string GetErrorMessage()
Describes the error (if one occurred during processing).
virtual void SendErrorMessageIfAny()
Sends an error message if there was an error during processing.
void AddStepsToDo(unsigned int steps)
Adds steps to totalSteps.
virtual const char * GetGroup() const override
Name of a group.
virtual bool ProcessOneWorkingData(DataNode *node)
Subclasses should override this method.
virtual void FinishProcessingAllData()
Subclasses should override this method.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66