Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkContourObjectFactory.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 
19 #include "mitkBaseRenderer.h"
20 #include "mitkCoreObjectFactory.h"
21 #include "mitkDataNode.h"
22 #include "mitkProperties.h"
23 
24 #include "mitkContourModel.h"
28 #include "mitkContourModelSet.h"
32 #include "mitkContourModelWriter.h"
33 #include "mitkVtkGLMapperWrapper.h"
34 
36 {
37  static bool alreadyDone = false;
38  if (!alreadyDone)
39  {
40  MITK_DEBUG << "ContourObjectFactory c'tor" << std::endl;
41 
42  alreadyDone = true;
43  }
44 }
45 
47 {
48 }
49 
51 {
52  mitk::Mapper::Pointer newMapper = NULL;
53 
55  {
56  std::string classname("ContourModel");
57  if (dynamic_cast<mitk::ContourModel *>(node->GetData()) != NULL)
58  {
60  newMapper->SetDataNode(node);
61  }
62  else if (dynamic_cast<mitk::ContourModelSet *>(node->GetData()) != NULL)
63  {
65  newMapper->SetDataNode(node);
66  }
67  }
68  else if (id == mitk::BaseRenderer::Standard3D)
69  {
70  if (dynamic_cast<mitk::ContourModel *>(node->GetData()) != NULL)
71  {
72  newMapper = mitk::ContourModelMapper3D::New();
73  newMapper->SetDataNode(node);
74  }
75  else if (dynamic_cast<mitk::ContourModelSet *>(node->GetData()) != NULL)
76  {
78  newMapper->SetDataNode(node);
79  }
80  }
81  return newMapper;
82 }
83 
85 {
86  if (node == NULL)
87  return;
88 
89  mitk::DataNode::Pointer nodePointer = node;
90 
91  if (node->GetData() == NULL)
92  return;
93 
94  if (dynamic_cast<mitk::ContourModel *>(node->GetData()) != NULL)
95  {
98  }
99  else if (dynamic_cast<mitk::ContourModelSet *>(node->GetData()) != NULL)
100  {
103  }
104 }
105 
107 {
108  std::string fileExtension;
109  this->CreateFileExtensions(m_FileExtensionsMap, fileExtension);
110  return fileExtension.c_str();
111 };
112 
114 {
115  return m_FileExtensionsMap;
116 }
117 
119 {
120  return m_SaveFileExtensionsMap;
121 }
122 
124 {
125 }
126 
128 {
129  std::string fileExtension;
130  this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension);
131  return fileExtension.c_str();
132 }
133 
135 {
136 }
137 
138 struct RegisterContourObjectFactory
139 {
140  RegisterContourObjectFactory() : m_Factory(mitk::ContourObjectFactory::New())
141  {
142  mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(m_Factory);
143  }
144 
145  ~RegisterContourObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory(m_Factory); }
147 };
148 
149 static RegisterContourObjectFactory registerContourObjectFactory;
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
#define MITK_DEBUG
Definition: mitkLogMacros.h:26
DataCollection - Class to facilitate loading/accessing structured data.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
virtual Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) override
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
virtual mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap() override
virtual const char * GetSaveFileExtensions() override
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Set the default properties for general image rendering.
virtual mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap() override
static RegisterContourObjectFactory registerContourObjectFactory
virtual void SetDefaultProperties(mitk::DataNode *node) override
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Set the default properties for general image rendering.
unsigned int MapperSlotId
Definition: mitkCommon.h:37
std::multimap< std::string, std::string > MultimapType
virtual const char * GetFileExtensions() override
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.