Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
mitkAdaptiveRegionGrowingTool.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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 #include "mitkImage.h"
15 #include "mitkProperties.h"
16 #include "mitkToolManager.h"
17 // us
18 #include <usGetModuleContext.h>
19 #include <usModule.h>
20 #include <usModuleContext.h>
21 #include <usModuleResource.h>
22 
23 namespace mitk
24 {
26 }
27 
29 {
30  m_PointSetNode = mitk::DataNode::New();
31  m_PointSetNode->GetPropertyList()->SetProperty("name", mitk::StringProperty::New("3D_Regiongrowing_Seedpoint"));
32  m_PointSetNode->GetPropertyList()->SetProperty("helper object", mitk::BoolProperty::New(true));
33  m_PointSet = mitk::PointSet::New();
34  m_PointSetNode->SetData(m_PointSet);
35 }
36 
38 {
39 }
40 
42 {
43  if (referenceData == nullptr)
44  return false;
45 
46  auto *image = dynamic_cast<Image *>(referenceData);
47 
48  if (image == nullptr)
49  return false;
50 
51  if (image->GetDimension() < 3)
52  return false;
53 
54  return true;
55 }
56 
58 {
59  return nullptr;
60 }
61 
63 {
64  return "Region Growing 3D";
65 }
66 
68 {
70  us::ModuleResource resource = module->GetResource("RegionGrowing_48x48.png");
71  return resource;
72 }
73 
75 {
76  Superclass::Activated();
77 
78  if (!GetDataStorage()->Exists(m_PointSetNode))
79  GetDataStorage()->Add(m_PointSetNode, GetWorkingData());
80  m_SeedPointInteractor = mitk::SinglePointDataInteractor::New();
81  m_SeedPointInteractor->LoadStateMachine("PointSet.xml");
82  m_SeedPointInteractor->SetEventConfig("PointSetConfig.xml");
83  m_SeedPointInteractor->SetDataNode(m_PointSetNode);
84 }
85 
87 {
88  m_PointSet->Clear();
89  GetDataStorage()->Remove(m_PointSetNode);
90 
91  Superclass::Deactivated();
92 }
93 
95 {
96  m_ToolManager->ActivateTool(-1);
97 }
98 
100 {
101  return this->m_ToolManager->GetReferenceData(0);
102 }
103 
105 {
106  return this->m_ToolManager->GetDataStorage();
107 }
108 
110 {
111  return this->m_ToolManager->GetWorkingData(0);
112 }
113 
115 {
116  return m_PointSetNode;
117 }
void Deactivated() override
Removes all set points and interactors.
const char * GetName() const override
Get name.
Data management class that handles &#39;was created by&#39; relations.
Base of all data objects.
Definition: mitkBaseData.h:37
Dummy Tool for AdaptiveRegionGrowingToolGUI to get Tool functionality for AdaptiveRegionGrowing. The actual logic is implemented in QmitkAdaptiveRegionGrowingToolGUI.
static Pointer New()
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
mitk::DataNode * GetReferenceData()
get reference data
static Pointer New()
virtual DataNode::Pointer GetPointSetNode()
get pointset node
MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, LiveWireTool2D, "LiveWire tool")
static Pointer New()
mitk::DataStorage * GetDataStorage()
Get datastorage.
Module * GetModule() const
Image class for storing images.
Definition: mitkImage.h:72
ModuleResource GetResource(const std::string &path) const
Definition: usModule.cpp:267
us::ModuleResource GetIconResource() const override
Get icon resource.
mitk::Image::Pointer image
void Activated() override
Adds interactor for the seedpoint and creates a seedpoint if neccessary.
const char ** GetXPM() const override
Get XPM.
mitk::DataNode * GetWorkingData()
Get working data.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
static Pointer New()
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
bool CanHandle(BaseData *referenceData) const override