Medical Imaging Interaction Toolkit  2018.4.99-67d34b5d
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 (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 
15 #include "mitkCoreObjectFactory.h"
16 
17 #include "mitkPlanarFigure.h"
20 #include "mitkVtkGLMapperWrapper.h"
21 
22 typedef std::multimap<std::string, std::string> MultimapType;
23 
25 {
26  static bool alreadyDone = false;
27  if (!alreadyDone)
28  {
30 
31  alreadyDone = true;
32  }
33 }
34 
36 {
37 }
38 
40 {
41  mitk::Mapper::Pointer newMapper = nullptr;
42  mitk::BaseData *data = node->GetData();
43 
44  if (dynamic_cast<PlanarFigure *>(data) != nullptr)
45  {
47  {
48  newMapper = mitk::PlanarFigureMapper2D::New();
49  newMapper->SetDataNode(node);
50  }
51  else if (id == mitk::BaseRenderer::Standard3D)
52  {
54  newMapper->SetDataNode(node);
55  }
56  }
57 
58  return newMapper;
59 }
60 
62 {
63  if (node == nullptr)
64  {
65  return;
66  }
67 
68  mitk::DataNode::Pointer nodePointer = node;
69 
70  mitk::PlanarFigure::Pointer pf = dynamic_cast<mitk::PlanarFigure *>(node->GetData());
71  if (pf.IsNotNull())
72  {
75  node->AddProperty("color", mitk::ColorProperty::New(1.0, 1.0, 1.0), nullptr, true);
76  node->AddProperty("opacity", mitk::FloatProperty::New(0.8), nullptr, true);
77  }
78 }
79 
81 {
82  return "";
83 }
84 
86 {
87  return {};
88 }
89 
91 {
92  std::string fileExtension;
93  this->CreateFileExtensions({}, fileExtension);
94  return fileExtension.c_str();
95 };
96 
98 {
99  return {};
100 }
101 
103 {
104 }
105 
106 struct RegisterPlanarFigureObjectFactory
107 {
108  RegisterPlanarFigureObjectFactory() : m_Factory(mitk::PlanarFigureObjectFactory::New())
109  {
110  mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(m_Factory);
111  }
112 
113  ~RegisterPlanarFigureObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory(m_Factory); }
115 };
116 
117 static RegisterPlanarFigureObjectFactory registerPlanarFigureObjectFactory;
mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap() override
Base of all data objects.
Definition: mitkBaseData.h:42
static Pointer New()
static void SetDefaultProperties(DataNode *, BaseRenderer *=nullptr, bool=false)
mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap() override
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
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 ...
void SetDefaultProperties(mitk::DataNode *node) override
static RegisterPlanarFigureObjectFactory registerPlanarFigureObjectFactory
std::multimap< std::string, std::string > MultimapType
static void CreateFileExtensions(MultimapType fileExtensionsMap, std::string &fileExtensions)
create a string from a map that contains the file extensions
static Pointer New()
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
unsigned int MapperSlotId
Definition: mitkCommon.h:33
std::multimap< std::string, std::string > MultimapType
Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) override
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57