Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMultilabelObjectFactory.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 #include <mitkCoreServices.h>
24 #include <mitkIPropertyFilters.h>
26 #include <mitkPropertyFilter.h>
27 
29 {
30  static bool alreadyDone = false;
31  if (!alreadyDone)
32  {
33  MITK_DEBUG << "MultilabelObjectFactory c'tor" << std::endl;
34 
36 
37  alreadyDone = true;
38  }
39 }
40 
42 {
43 }
44 
46 {
47  mitk::Mapper::Pointer newMapper = NULL;
48  mitk::BaseData *data = node->GetData();
49 
51  {
52  if ((dynamic_cast<mitk::LabelSetImage *>(data) != NULL))
53  {
55  newMapper->SetDataNode(node);
56  }
57  }
58  return newMapper;
59 }
60 
62 {
63  if (node == nullptr)
64  return;
65 
66  if (node->GetData() == nullptr)
67  return;
68 
69  if (dynamic_cast<LabelSetImage *>(node->GetData()) != nullptr)
70  {
72 
73  auto propertyFilters = CoreServices::GetPropertyFilters();
74 
75  if (propertyFilters != nullptr)
76  {
77  PropertyFilter labelSetImageFilter;
78  labelSetImageFilter.AddEntry("binaryimage.hoveringannotationcolor", PropertyFilter::Blacklist);
79  labelSetImageFilter.AddEntry("binaryimage.hoveringcolor", PropertyFilter::Blacklist);
80  labelSetImageFilter.AddEntry("binaryimage.selectedannotationcolor", PropertyFilter::Blacklist);
81  labelSetImageFilter.AddEntry("binaryimage.selectedcolor", PropertyFilter::Blacklist);
82  labelSetImageFilter.AddEntry("outline binary shadow color", PropertyFilter::Blacklist);
83 
84  propertyFilters->AddFilter(labelSetImageFilter, "LabelSetImage");
85  }
86  }
87 }
88 
90 {
91  std::string fileExtension;
92  this->CreateFileExtensions(m_FileExtensionsMap, fileExtension);
93  return fileExtension.c_str();
94 }
95 
97 {
98  return m_FileExtensionsMap;
99 }
100 
102 {
103  return m_SaveFileExtensionsMap;
104 }
105 
107 {
108 }
109 
111 {
112  std::string fileExtension;
113  this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension);
114  return fileExtension.c_str();
115 }
116 
117 struct RegisterMultilabelObjectFactory
118 {
119  RegisterMultilabelObjectFactory() : m_Factory(mitk::MultilabelObjectFactory::New())
120  {
121  mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(m_Factory);
122  }
123 
124  ~RegisterMultilabelObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory(m_Factory); }
126 };
127 
128 static RegisterMultilabelObjectFactory registerMultilabelObjectFactory;
Base of all data objects.
Definition: mitkBaseData.h:39
void AddEntry(const std::string &propertyName, List list)
Add a filter entry for a specific property.
#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.
static RegisterMultilabelObjectFactory registerMultilabelObjectFactory
virtual const char * GetFileExtensions() override
virtual void SetDefaultProperties(mitk::DataNode *node) override
virtual mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap() override
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Set the default properties for general image rendering.
virtual Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) override
virtual const char * GetSaveFileExtensions() override
static IPropertyFilters * GetPropertyFilters(us::ModuleContext *context=us::GetModuleContext())
Get an IPropertyFilters instance.
unsigned int MapperSlotId
Definition: mitkCommon.h:37
std::multimap< std::string, std::string > MultimapType
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.
Consists of blacklist and whitelist entries.