Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPlanarFigureObjectFactory.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 "mitkPlanarFigureWriter.h"
19 
20 #include "mitkCoreObjectFactory.h"
21 
22 #include "mitkPlanarFigure.h"
27 #include "mitkVtkGLMapperWrapper.h"
28 
29 typedef std::multimap<std::string, std::string> MultimapType;
30 
32  : m_PlanarFigureIOFactory(PlanarFigureIOFactory::New().GetPointer()),
33  m_PlanarFigureWriterFactory(PlanarFigureWriterFactory::New().GetPointer())
34 {
35  static bool alreadyDone = false;
36  if (!alreadyDone)
37  {
38  itk::ObjectFactoryBase::RegisterFactory(m_PlanarFigureIOFactory);
39  itk::ObjectFactoryBase::RegisterFactory(m_PlanarFigureWriterFactory);
40 
41  m_FileWriters.push_back(PlanarFigureWriter::New().GetPointer());
42 
44 
45  alreadyDone = true;
46  }
47 }
48 
50 {
51  itk::ObjectFactoryBase::UnRegisterFactory(m_PlanarFigureWriterFactory);
52  itk::ObjectFactoryBase::UnRegisterFactory(m_PlanarFigureIOFactory);
53 }
54 
56 {
57  mitk::Mapper::Pointer newMapper = NULL;
58  mitk::BaseData *data = node->GetData();
59 
60  if (dynamic_cast<PlanarFigure *>(data) != NULL)
61  {
63  {
65  newMapper->SetDataNode(node);
66  }
67  else if (id == mitk::BaseRenderer::Standard3D)
68  {
70  newMapper->SetDataNode(node);
71  }
72  }
73 
74  return newMapper;
75 }
76 
78 {
79  if (node == NULL)
80  {
81  return;
82  }
83 
84  mitk::DataNode::Pointer nodePointer = node;
85 
86  mitk::PlanarFigure::Pointer pf = dynamic_cast<mitk::PlanarFigure *>(node->GetData());
87  if (pf.IsNotNull())
88  {
91  node->AddProperty("color", mitk::ColorProperty::New(1.0, 1.0, 1.0), NULL, true);
92  node->AddProperty("opacity", mitk::FloatProperty::New(0.8), NULL, true);
93  }
94 }
95 
97 {
98  return "";
99 }
100 
102 {
103  return m_FileExtensionsMap;
104 }
105 
107 {
108  // return ";;Planar Figures (*.pf)"; // for mitk::PlanarFigure and derived classes
109  std::string fileExtension;
110  this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension);
111  return fileExtension.c_str();
112 };
113 
115 {
116  return m_SaveFileExtensionsMap;
117 }
118 
120 {
121  m_FileExtensionsMap.insert(std::pair<std::string, std::string>("*.pf", "Planar Figure Files"));
122  m_SaveFileExtensionsMap.insert(std::pair<std::string, std::string>("*.pf", "Planar Figure Files"));
123 }
124 
126 {
127 }
128 
129 struct RegisterPlanarFigureObjectFactory
130 {
131  RegisterPlanarFigureObjectFactory() : m_Factory(mitk::PlanarFigureObjectFactory::New())
132  {
133  mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(m_Factory);
134  }
135 
136  ~RegisterPlanarFigureObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory(m_Factory); }
138 };
139 
140 static RegisterPlanarFigureObjectFactory registerPlanarFigureObjectFactory;
virtual mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap() override
Base of all data objects.
Definition: mitkBaseData.h:39
static Pointer New()
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 mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap() override
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
Create instances of PlanarFigureReader objects using an object factory.
virtual const char * GetSaveFileExtensions() override
virtual void SetDefaultProperties(mitk::DataNode *node) override
virtual const char * GetFileExtensions() override
static RegisterPlanarFigureObjectFactory registerPlanarFigureObjectFactory
std::multimap< std::string, std::string > MultimapType
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
static Pointer New()
static void SetDefaultProperties(DataNode *, BaseRenderer *=NULL, bool=false)
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
static Pointer New()
unsigned int MapperSlotId
Definition: mitkCommon.h:37
std::multimap< std::string, std::string > MultimapType
virtual Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) 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.