Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkQuantificationObjectFactory.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 "mitkTbssImageMapper.h"
20 
24 
28 
29 #include "mitkGPUVolumeMapper3D.h"
30 
31 typedef char TbssRoiPixelType;
32 typedef float TbssPixelType;
34 
37  , m_NrrdTbssImageIOFactory(mitk::NrrdTbssImageIOFactory::New().GetPointer())
38  , m_NrrdTbssRoiImageIOFactory(mitk::NrrdTbssRoiImageIOFactory::New().GetPointer())
39  , m_NrrdTbssImageWriterFactory(mitk::NrrdTbssImageWriterFactory::New().GetPointer())
40  , m_NrrdTbssRoiImageWriterFactory(mitk::NrrdTbssRoiImageWriterFactory::New().GetPointer())
41 {
42 
43  static bool alreadyDone = false;
44  if (!alreadyDone)
45  {
46  MITK_DEBUG << "QuantificationObjectFactory c'tor" << std::endl;
47 
48  itk::ObjectFactoryBase::RegisterFactory(m_NrrdTbssImageIOFactory);
49  itk::ObjectFactoryBase::RegisterFactory(m_NrrdTbssRoiImageIOFactory);
50 
51  itk::ObjectFactoryBase::RegisterFactory(m_NrrdTbssImageWriterFactory);
52  itk::ObjectFactoryBase::RegisterFactory(m_NrrdTbssRoiImageWriterFactory);
53 
54  m_FileWriters.push_back( NrrdTbssImageWriter::New().GetPointer() );
55  m_FileWriters.push_back( NrrdTbssRoiImageWriter::New().GetPointer() );
56 
57  CreateFileExtensionsMap();
58 
59  alreadyDone = true;
60  }
61 
62 }
63 
65 {
66  itk::ObjectFactoryBase::UnRegisterFactory(m_NrrdTbssImageIOFactory);
67  itk::ObjectFactoryBase::RegisterFactory(m_NrrdTbssRoiImageIOFactory);
68 
69  itk::ObjectFactoryBase::UnRegisterFactory(m_NrrdTbssImageWriterFactory);
70  itk::ObjectFactoryBase::UnRegisterFactory(m_NrrdTbssRoiImageWriterFactory);
71 }
72 
74 {
75  mitk::Mapper::Pointer newMapper=NULL;
76 
78  {
79  std::string classname = "TbssRoiImage";
80  if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0)
81  {
82  newMapper = mitk::ImageVtkMapper2D::New();
83  newMapper->SetDataNode(node);
84  }
85 
86  classname = "TbssImage";
87  if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0)
88  {
89  newMapper = mitk::TbssImageMapper::New();
90  newMapper->SetDataNode(node);
91  }
92 
93  }
94  else if ( id == mitk::BaseRenderer::Standard3D )
95  {
96  std::string classname = "TbssImage";
97  if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0)
98  {
99  newMapper = mitk::TbssImageMapper::New();
100  newMapper->SetDataNode(node);
101  }
102 
103  }
104 
105  return newMapper;
106 }
107 
109 {
110  std::string classname = "TbssRoiImage";
111  if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0)
112  {
114  }
115 
116  classname = "TbssImage";
117  if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0)
118  {
121  }
122 }
123 
125 {
126  std::string fileExtension;
127  this->CreateFileExtensions(m_FileExtensionsMap, fileExtension);
128  return fileExtension.c_str();
129 };
130 
132 {
133  return m_FileExtensionsMap;
134 }
135 
137 {
138  std::string fileExtension;
139  this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension);
140  return fileExtension.c_str();
141 };
142 
144 {
145  return m_SaveFileExtensionsMap;
146 }
147 
148 void mitk::QuantificationObjectFactory::CreateFileExtensionsMap()
149 {
150  m_FileExtensionsMap.insert(std::pair<std::string, std::string>("*.tbss", "TBSS data"));
151  m_FileExtensionsMap.insert(std::pair<std::string, std::string>("*.roi", "TBSS ROI data"));
152 
153  m_SaveFileExtensionsMap.insert(std::pair<std::string, std::string>("*.tbss", "TBSS data"));
154  m_SaveFileExtensionsMap.insert(std::pair<std::string, std::string>("*.roi", "TBSS ROI data"));
155 }
156 
157 struct RegisterQuantificationObjectFactory{
158  RegisterQuantificationObjectFactory()
159  : m_Factory( mitk::QuantificationObjectFactory::New() )
160  {
161  mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory( m_Factory );
162  }
163 
164  ~RegisterQuantificationObjectFactory()
165  {
166  mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory( m_Factory );
167  }
168 
170 };
171 
172 static RegisterQuantificationObjectFactory registerQuantificationObjectFactory;
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.
static Pointer New()
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=NULL, bool overwrite=false)
virtual Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) override
#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.
Create instances of NrrdDiffusionImageReader objects using an object factory.
Create instances of NrrdDiffusionImageReader objects using an object factory.
static RegisterQuantificationObjectFactory registerQuantificationObjectFactory
virtual const char * GetFileExtensions() override
static Pointer New()
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
virtual mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap() override
unsigned int MapperSlotId
Definition: mitkCommon.h:37
std::multimap< std::string, std::string > MultimapType
virtual void SetDefaultProperties(mitk::DataNode *node) override
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
virtual mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap() override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.