diff --git a/CMake/ToolExtensionITKFactory.cpp.in b/CMake/ToolExtensionITKFactory.cpp.in index a0041dbca6..8638f8202f 100644 --- a/CMake/ToolExtensionITKFactory.cpp.in +++ b/CMake/ToolExtensionITKFactory.cpp.in @@ -1,71 +1,85 @@ /** * This defines an itk::ObjectFactory subclass specific for * creation of mitk::Tool instances (in this case mitk::PlainExternalTool). */ #include #include #include "mitk@TOOL_NAME@.h" namespace mitk { /* class @EXPORT_MACRO@ @FACTORY_NAME@ : public ::itk::ObjectFactoryBase */ class @FACTORY_NAME@ : public ::itk::ObjectFactoryBase { - public: + public: /* ITK typedefs */ typedef @FACTORY_NAME@ Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; - + /* Methods from ObjectFactoryBase */ virtual const char* GetITKSourceVersion() const { return ITK_VERSION_STRING; }\ - + virtual const char* GetDescription() const { return "@FACTORY_DESCRIPTION@"; }\ - + /* Method for class instantiation. */ itkFactorylessNewMacro(Self); - + /* Run-time type information (and related methods). */ itkTypeMacro(@FACTORY_NAME@, itkObjectFactoryBase); - /* Register one factory of this type */ - static void RegisterOneFactory() - { - @FACTORY_NAME@::Pointer factory = @FACTORY_NAME@::New(); - itk::ObjectFactoryBase::RegisterFactory(factory); - } - protected: @FACTORY_NAME@() { itk::ObjectFactoryBase::RegisterOverride("mitkTool", "@TOOL_NAME@", "@FACTORY_DESCRIPTION@", 1, itk::CreateObjectFunction<@TOOL_NAME@>::New()); } ~@FACTORY_NAME@() { } private: @FACTORY_NAME@(const Self&); /* purposely not implemented */ void operator=(const Self&); /* purposely not implemented */ }; +class @FACTORY_NAME@RegistrationMethod +{ + public: + + @FACTORY_NAME@RegistrationMethod() + { + m_Factory = @FACTORY_NAME@::New(); + itk::ObjectFactoryBase::RegisterFactory( m_Factory ); + } + + ~@FACTORY_NAME@RegistrationMethod() + { + itk::ObjectFactoryBase::UnRegisterFactory( m_Factory ); + } + + private: + + @FACTORY_NAME@::Pointer m_Factory; +}; + } // end namespace +static mitk::@FACTORY_NAME@RegistrationMethod somestaticinitializer_@FACTORY_NAME@; diff --git a/CMake/ToolExtensionITKFactoryLoader.cpp.in b/CMake/ToolExtensionITKFactoryLoader.cpp.in index 1bb44e5919..77a5e2df10 100644 --- a/CMake/ToolExtensionITKFactoryLoader.cpp.in +++ b/CMake/ToolExtensionITKFactoryLoader.cpp.in @@ -1,76 +1,69 @@ #include #include /* No EXPORT, should not be used by any other lib, right? */ class mitkToolExtensionITKFactoryLoader : public ::itk::ObjectFactoryBase { - public: + public: /* ITK typedefs */ typedef mitkToolExtensionITKFactoryLoader Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; - + /* Methods from ObjectFactoryBase */ virtual const char* GetITKSourceVersion() const { return ITK_SOURCE_VERSION; }\ - + virtual const char* GetDescription() const { return "Generated factory for registration of MITK tools"; }\ - + /* Method for class instantiation. */ itkFactorylessNewMacro(Self); - + /* Run-time type information (and related methods). */ itkTypeMacro(mitkToolExtensionITKFactoryLoader, itkObjectFactoryBase); - /* Register one factory of this type */ - static void RegisterOneFactory() - { - mitkToolExtensionITKFactoryLoader::Pointer factory = mitkToolExtensionITKFactoryLoader::New(); - itk::ObjectFactoryBase::RegisterFactory(factory); - } - protected: mitkToolExtensionITKFactoryLoader() { // this is a dummy factory which is here just to // ensure that itkLoad can return something other // than NULL. // This should ensure that ITK does not unload // the shared library } ~mitkToolExtensionITKFactoryLoader() { } private: mitkToolExtensionITKFactoryLoader(const Self&); /* purposely not implemented */ void operator=(const Self&); /* purposely not implemented */ }; extern "C" { /* @EXPORT_MACRO@ itk::ObjectFactoryBase* itkLoad() */ #ifdef WIN32 __declspec(dllexport) #endif - itk::ObjectFactoryBase* itkLoad() + itk::ObjectFactoryBase* itkLoad() { static mitkToolExtensionITKFactoryLoader::Pointer factory = mitkToolExtensionITKFactoryLoader::New(); return factory; } } // end extern "C" diff --git a/CMake/ToolGUIExtensionITKFactory.cpp.in b/CMake/ToolGUIExtensionITKFactory.cpp.in index 7c265ae62a..6f98f453fb 100644 --- a/CMake/ToolGUIExtensionITKFactory.cpp.in +++ b/CMake/ToolGUIExtensionITKFactory.cpp.in @@ -1,66 +1,80 @@ /** * This defines an itk::ObjectFactory subclass specific for * creation of mitk::Tool instances (in this case mitk::PlainExternalTool). */ #include #include "Qmitk@TOOL_NAME@GUI.h" //class @EXPORT_MACRO@ @FACTORY_NAME@ : public ::itk::ObjectFactoryBase class @FACTORY_NAME@ : public ::itk::ObjectFactoryBase { - public: + public: /* ITK typedefs */ typedef @FACTORY_NAME@ Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; - + /* Methods from ObjectFactoryBase */ virtual const char* GetITKSourceVersion() const { return ITK_SOURCE_VERSION; }\ - + virtual const char* GetDescription() const { return "@FACTORY_DESCRIPTION@"; }\ - + /* Method for class instantiation. */ itkFactorylessNewMacro(Self); - + /* Run-time type information (and related methods). */ itkTypeMacro(@FACTORY_NAME@, itkObjectFactoryBase); - /* Register one factory of this type */ - static void RegisterOneFactory() - { - @FACTORY_NAME@::Pointer factory = @FACTORY_NAME@::New(); - itk::ObjectFactoryBase::RegisterFactory(factory); - } - protected: @FACTORY_NAME@() { itk::ObjectFactoryBase::RegisterOverride("Qmitk@TOOL_NAME@GUI", "Qmitk@TOOL_NAME@GUI", "@FACTORY_DESCRIPTION@", 1, itk::CreateObjectFunction::New()); } ~@FACTORY_NAME@() { } private: @FACTORY_NAME@(const Self&); /* purposely not implemented */ void operator=(const Self&); /* purposely not implemented */ }; +class @FACTORY_NAME@RegistrationMethod +{ + public: + + @FACTORY_NAME@RegistrationMethod() + { + m_Factory = @FACTORY_NAME@::New(); + itk::ObjectFactoryBase::RegisterFactory( m_Factory ); + } + + ~@FACTORY_NAME@RegistrationMethod() + { + itk::ObjectFactoryBase::UnRegisterFactory( m_Factory ); + } + + private: + + @FACTORY_NAME@::Pointer m_Factory; +}; + +static @FACTORY_NAME@RegistrationMethod somestaticinitializer_@FACTORY_NAME@; diff --git a/Core/Code/Common/mitkCoreObjectFactory.cpp b/Core/Code/Common/mitkCoreObjectFactory.cpp index 9f057e86e3..74957ccc36 100644 --- a/Core/Code/Common/mitkCoreObjectFactory.cpp +++ b/Core/Code/Common/mitkCoreObjectFactory.cpp @@ -1,409 +1,431 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkConfig.h" #include "mitkCoreObjectFactory.h" #include "mitkAffineInteractor.h" #include "mitkColorProperty.h" #include "mitkDataNode.h" #include "mitkEnumerationProperty.h" #include "mitkGeometry2DData.h" #include "mitkGeometry2DDataMapper2D.h" #include "mitkGeometry2DDataVtkMapper3D.h" #include "mitkGeometry3D.h" #include "mitkGeometryData.h" #include "mitkImage.h" #include #include "mitkLevelWindowProperty.h" #include "mitkLookupTable.h" #include "mitkLookupTableProperty.h" #include "mitkPlaneGeometry.h" #include "mitkPointSet.h" #include "mitkPointSetVtkMapper2D.h" #include "mitkPointSetVtkMapper3D.h" #include "mitkPolyDataGLMapper2D.h" #include "mitkProperties.h" #include "mitkPropertyList.h" #include "mitkSlicedGeometry3D.h" #include "mitkSmartPointerProperty.h" #include "mitkStringProperty.h" #include "mitkSurface.h" #include "mitkSurface.h" #include "mitkSurfaceGLMapper2D.h" #include "mitkSurfaceVtkMapper3D.h" #include "mitkTimeGeometry.h" #include "mitkTransferFunctionProperty.h" #include "mitkVolumeDataVtkMapper3D.h" #include "mitkVtkInterpolationProperty.h" #include "mitkVtkRepresentationProperty.h" #include "mitkVtkResliceInterpolationProperty.h" //#include "mitkPicFileIOFactory.h" #include "mitkPointSetIOFactory.h" #include "mitkItkImageFileIOFactory.h" #include "mitkSTLFileIOFactory.h" #include "mitkVtkSurfaceIOFactory.h" #include "mitkVtkImageIOFactory.h" #include "mitkVtiFileIOFactory.h" //#include "mitkPicVolumeTimeSeriesIOFactory.h" #include "mitkImageWriterFactory.h" #include "mitkImageWriter.h" #include "mitkPointSetWriterFactory.h" #include "mitkSurfaceVtkWriterFactory.h" mitk::CoreObjectFactory::FileWriterList mitk::CoreObjectFactory::m_FileWriters; void mitk::CoreObjectFactory::RegisterExtraFactory(CoreObjectFactoryBase* factory) { MITK_DEBUG << "CoreObjectFactory: registering extra factory of type " << factory->GetNameOfClass(); m_ExtraFactories.insert(CoreObjectFactoryBase::Pointer(factory)); } void mitk::CoreObjectFactory::UnRegisterExtraFactory(CoreObjectFactoryBase *factory) { MITK_DEBUG << "CoreObjectFactory: un-registering extra factory of type " << factory->GetNameOfClass(); try { m_ExtraFactories.erase(factory); } catch( std::exception const& e) { MITK_ERROR << "Caugt exception while unregistering: " << e.what(); } } mitk::CoreObjectFactory::Pointer mitk::CoreObjectFactory::GetInstance() { static mitk::CoreObjectFactory::Pointer instance; if (instance.IsNull()) { instance = mitk::CoreObjectFactory::New(); } return instance; } #include void mitk::CoreObjectFactory::SetDefaultProperties(mitk::DataNode* node) { if(node==NULL) return; mitk::DataNode::Pointer nodePointer = node; mitk::Image::Pointer image = dynamic_cast(node->GetData()); if(image.IsNotNull() && image->IsInitialized()) { mitk::ImageVtkMapper2D::SetDefaultProperties(node); mitk::VolumeDataVtkMapper3D::SetDefaultProperties(node); } mitk::Surface::Pointer surface = dynamic_cast(node->GetData()); if(surface.IsNotNull()) { mitk::SurfaceGLMapper2D::SetDefaultProperties(node); mitk::SurfaceVtkMapper3D::SetDefaultProperties(node); } mitk::PointSet::Pointer pointSet = dynamic_cast(node->GetData()); if(pointSet.IsNotNull()) { mitk::PointSetVtkMapper2D::SetDefaultProperties(node); mitk::PointSetVtkMapper3D::SetDefaultProperties(node); } for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { (*it)->SetDefaultProperties(node); } } mitk::CoreObjectFactory::CoreObjectFactory() + : m_PointSetIOFactory(PointSetIOFactory::New().GetPointer()) + , m_STLFileIOFactory(STLFileIOFactory::New().GetPointer()) + , m_VtkSurfaceIOFactory(VtkSurfaceIOFactory::New().GetPointer()) + , m_VtkImageIOFactory(VtkImageIOFactory::New().GetPointer()) + , m_VtiFileIOFactory(VtiFileIOFactory::New().GetPointer()) + , m_ItkImageFileIOFactory(ItkImageFileIOFactory::New().GetPointer()) + , m_SurfaceVtkWriterFactory(SurfaceVtkWriterFactory::New().GetPointer()) + , m_PointSetWriterFactory(PointSetWriterFactory::New().GetPointer()) + , m_ImageWriterFactory(ImageWriterFactory::New().GetPointer()) { static bool alreadyDone = false; if (!alreadyDone) { MITK_DEBUG << "CoreObjectFactory c'tor" << std::endl; - // FIXME itk::ObjectFactoryBase::RegisterFactory( PicFileIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( PointSetIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( STLFileIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( VtkSurfaceIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( VtkImageIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( VtiFileIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( ItkImageFileIOFactory::New() ); - // FIXME itk::ObjectFactoryBase::RegisterFactory( PicVolumeTimeSeriesIOFactory::New() ); - - mitk::SurfaceVtkWriterFactory::RegisterOneFactory(); - mitk::PointSetWriterFactory::RegisterOneFactory(); - mitk::ImageWriterFactory::RegisterOneFactory(); + itk::ObjectFactoryBase::RegisterFactory( m_PointSetIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_STLFileIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_VtkSurfaceIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_VtkImageIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_VtiFileIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_ItkImageFileIOFactory ); + + itk::ObjectFactoryBase::RegisterFactory( m_SurfaceVtkWriterFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_PointSetWriterFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_ImageWriterFactory ); + m_FileWriters.push_back(mitk::ImageWriter::New().GetPointer()); CreateFileExtensionsMap(); alreadyDone = true; } } +mitk::CoreObjectFactory::~CoreObjectFactory() +{ + itk::ObjectFactoryBase::UnRegisterFactory( m_PointSetIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_STLFileIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_VtkSurfaceIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_VtkImageIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_VtiFileIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_ItkImageFileIOFactory ); + + itk::ObjectFactoryBase::UnRegisterFactory( m_SurfaceVtkWriterFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_PointSetWriterFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_ImageWriterFactory ); +} + mitk::Mapper::Pointer mitk::CoreObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper = NULL; mitk::Mapper::Pointer tmpMapper = NULL; // check whether extra factories provide mapper for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { tmpMapper = (*it)->CreateMapper(node,id); if(tmpMapper.IsNotNull()) newMapper = tmpMapper; } if (newMapper.IsNull()) { mitk::BaseData *data = node->GetData(); if ( id == mitk::BaseRenderer::Standard2D ) { if((dynamic_cast(data)!=NULL)) { newMapper = mitk::ImageVtkMapper2D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::Geometry2DDataMapper2D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::SurfaceGLMapper2D::New(); // cast because SetDataNode is not virtual mitk::SurfaceGLMapper2D *castedMapper = dynamic_cast(newMapper.GetPointer()); castedMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::PointSetVtkMapper2D::New(); newMapper->SetDataNode(node); } } else if ( id == mitk::BaseRenderer::Standard3D ) { if((dynamic_cast(data) != NULL)) { newMapper = mitk::VolumeDataVtkMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::Geometry2DDataVtkMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::SurfaceVtkMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::PointSetVtkMapper3D::New(); newMapper->SetDataNode(node); } } } return newMapper; } /* // @deprecated // #define EXTERNAL_FILE_EXTENSIONS \ "All known formats(*.dcm *.DCM *.dc3 *.DC3 *.gdcm *.ima *.mhd *.mps *.nii *.pic *.pic.gz *.bmp *.png *.jpg *.tiff *.pvtk *.stl *.vtk *.vtp *.vtu *.obj *.vti *.hdr *.nrrd *.nhdr );;" \ "DICOM files(*.dcm *.DCM *.dc3 *.DC3 *.gdcm);;" \ "DKFZ Pic (*.seq *.pic *.pic.gz *.seq.gz);;" \ "NRRD Vector Images (*.nrrd *.nhdr);;" \ "Point sets (*.mps);;" \ "Sets of 2D slices (*.pic *.pic.gz *.bmp *.png *.dcm *.gdcm *.ima *.tiff);;" \ "Surface files (*.stl *.vtk *.vtp *.obj);;" \ "NIfTI format (*.nii)" #define SAVE_FILE_EXTENSIONS "all (*.pic *.mhd *.vtk *.vti *.hdr *.png *.tiff *.jpg *.hdr *.bmp *.dcm *.gipl *.nii *.nrrd *.nhdr *.spr *.lsm *.dwi *.hdwi *.qbi *.hqbi)" */ /** * @brief This method gets the supported (open) file extensions as string. This string is can then used by the QT QFileDialog widget. * @return The c-string that contains the file extensions * */ const char* mitk::CoreObjectFactory::GetFileExtensions() { MultimapType aMap; for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { aMap = (*it)->GetFileExtensionsMap(); this->MergeFileExtensions(m_FileExtensionsMap, aMap); } this->CreateFileExtensions(m_FileExtensionsMap, m_FileExtensions); return m_FileExtensions.c_str(); } /** * @brief Merge the input map into the fileExtensionsMap. Duplicate entries are removed * @param fileExtensionsMap the existing map, it contains value pairs like ("*.dcm", "DICOM files"),("*.dc3", "DICOM files"). * This map is extented/merged with the values from the input map. * @param inputMap the input map, it contains value pairs like ("*.dcm", "DICOM files"),("*.dc3", "DICOM files") returned by * the extra factories. * */ void mitk::CoreObjectFactory::MergeFileExtensions(MultimapType& fileExtensionsMap, MultimapType inputMap) { bool duplicateFound = false; std::pair pairOfIter; for (MultimapType::iterator it = inputMap.begin(); it != inputMap.end(); ++it) { duplicateFound = false; pairOfIter = fileExtensionsMap.equal_range((*it).first); for (MultimapType::iterator it2 = pairOfIter.first; it2 != pairOfIter.second; ++it2) { //cout << " [" << (*it).first << ", " << (*it).second << "]" << endl; std::string aString = (*it2).second; if (aString.compare((*it).second) == 0) { //cout << " DUP!! [" << (*it).first << ", " << (*it).second << "]" << endl; duplicateFound = true; break; } } if (!duplicateFound) { fileExtensionsMap.insert(std::pair((*it).first, (*it).second)); } } } /** * @brief get the defined (open) file extension map * @return the defined (open) file extension map */ mitk::CoreObjectFactoryBase::MultimapType mitk::CoreObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } /** * @brief initialize the file extension entries for open and save */ void mitk::CoreObjectFactory::CreateFileExtensionsMap() { m_FileExtensionsMap.insert(std::pair("*.dcm", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.DCM", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.dc3", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.DC3", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.gdcm", "DICOM files")); m_FileExtensionsMap.insert(std::pair("*.seq", "DKFZ Pic")); m_FileExtensionsMap.insert(std::pair("*.pic", "DKFZ Pic")); m_FileExtensionsMap.insert(std::pair("*.pic.gz", "DKFZ Pic")); m_FileExtensionsMap.insert(std::pair("*.mhd", "MetaImage")); m_FileExtensionsMap.insert(std::pair("*.seq.gz", "DKFZ Pic")); m_FileExtensionsMap.insert(std::pair("*.hdr", "Analyze Format")); m_FileExtensionsMap.insert(std::pair("*.img", "Analyze Format")); m_FileExtensionsMap.insert(std::pair("*.img.gz", "Analyze Format")); m_FileExtensionsMap.insert(std::pair("*.nrrd", "Nearly Raw Raster Data")); m_FileExtensionsMap.insert(std::pair("*.nhdr", "NRRD with detached header")); m_FileExtensionsMap.insert(std::pair("*.mps", "Point sets")); m_FileExtensionsMap.insert(std::pair("*.pic", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.pic.gz", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.bmp", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.png", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.jpg", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.jpeg", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.dcm", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.gdcm", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.ima", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.tiff", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.tif", "Sets of 2D slices")); m_FileExtensionsMap.insert(std::pair("*.stl", "Surface files")); m_FileExtensionsMap.insert(std::pair("*.vtk", "Surface files")); m_FileExtensionsMap.insert(std::pair("*.vtp", "Surface files")); m_FileExtensionsMap.insert(std::pair("*.obj", "Surface files")); m_FileExtensionsMap.insert(std::pair("*.nii", "NIfTI format")); m_FileExtensionsMap.insert(std::pair("*.nii.gz", "NIfTI format")); m_FileExtensionsMap.insert(std::pair("*.gipl", "UMDS GIPL Format Files")); m_FileExtensionsMap.insert(std::pair("*.gipl.gz", "UMDS GIPL Format Files")); //m_SaveFileExtensionsMap.insert(std::pair("*.pic", "DKFZ Pic")); m_SaveFileExtensionsMap.insert(std::pair("*.mhd", "MetaImage")); m_SaveFileExtensionsMap.insert(std::pair("*.vtk", "Surface Files")); m_SaveFileExtensionsMap.insert(std::pair("*.vti", "VTK Image Data Files")); m_SaveFileExtensionsMap.insert(std::pair("*.hdr", "Analyze Format")); m_SaveFileExtensionsMap.insert(std::pair("*.png", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.tiff", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.tif", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.jpg", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.jpeg", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.bmp", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.dcm", "Sets of 2D slices")); m_SaveFileExtensionsMap.insert(std::pair("*.gipl", "UMDS GIPL Format Files")); m_SaveFileExtensionsMap.insert(std::pair("*.gipl.gz", "UMDS compressed GIPL Format Files")); m_SaveFileExtensionsMap.insert(std::pair("*.nii", "NIfTI format")); m_SaveFileExtensionsMap.insert(std::pair("*.nii.gz", "NIfTI compressed format")); m_SaveFileExtensionsMap.insert(std::pair("*.nrrd", "Nearly Raw Raster Data")); m_SaveFileExtensionsMap.insert(std::pair("*.nhdr", "NRRD with detached header")); m_SaveFileExtensionsMap.insert(std::pair("*.lsm", "Microscope Images")); m_SaveFileExtensionsMap.insert(std::pair("*.dwi", "Diffusion Weighted Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hdwi", "Diffusion Weighted Images")); m_SaveFileExtensionsMap.insert(std::pair("*.qbi", "Q-Ball Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hqbi", "Q-Ball Images")); } /** * @brief This method gets the supported (save) file extensions as string. This string is can then used by the QT QFileDialog widget. * @return The c-string that contains the (save) file extensions * */ const char* mitk::CoreObjectFactory::GetSaveFileExtensions() { MultimapType aMap; for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { aMap = (*it)->GetSaveFileExtensionsMap(); this->MergeFileExtensions(m_SaveFileExtensionsMap, aMap); } this->CreateFileExtensions(m_SaveFileExtensionsMap, m_SaveFileExtensions); return m_SaveFileExtensions.c_str(); }; /** * @brief get the defined (save) file extension map * @return the defined (save) file extension map */ mitk::CoreObjectFactoryBase::MultimapType mitk::CoreObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } mitk::CoreObjectFactory::FileWriterList mitk::CoreObjectFactory::GetFileWriters() { FileWriterList allWriters = m_FileWriters; for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { FileWriterList list2 = (*it)->GetFileWriters(); allWriters.merge(list2); } return allWriters; } void mitk::CoreObjectFactory::MapEvent(const mitk::Event*, const int) { } diff --git a/Core/Code/Common/mitkCoreObjectFactory.h b/Core/Code/Common/mitkCoreObjectFactory.h index a06f22ce47..44e0426fad 100644 --- a/Core/Code/Common/mitkCoreObjectFactory.h +++ b/Core/Code/Common/mitkCoreObjectFactory.h @@ -1,62 +1,77 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef COREOBJECTFACTORY_H_INCLUDED #define COREOBJECTFACTORY_H_INCLUDED #include #include #include "mitkCoreObjectFactoryBase.h" #include "mitkFileWriterWithInformation.h" namespace mitk { class Event; class MITK_CORE_EXPORT CoreObjectFactory : public CoreObjectFactoryBase { public: mitkClassMacro(CoreObjectFactory,CoreObjectFactoryBase); itkFactorylessNewMacro(CoreObjectFactory); virtual Mapper::Pointer CreateMapper(mitk::DataNode* node, MapperSlotId slotId); virtual void SetDefaultProperties(mitk::DataNode* node); virtual const char* GetFileExtensions(); virtual MultimapType GetFileExtensionsMap(); virtual const char* GetSaveFileExtensions(); virtual MultimapType GetSaveFileExtensionsMap(); virtual FileWriterList GetFileWriters(); virtual void MapEvent(const mitk::Event* event, const int eventID); virtual void RegisterExtraFactory(CoreObjectFactoryBase* factory); virtual void UnRegisterExtraFactory(CoreObjectFactoryBase* factory); static Pointer GetInstance(); + + ~CoreObjectFactory(); + protected: + CoreObjectFactory(); void MergeFileExtensions(MultimapType& fileExtensionsMap, MultimapType inputMap); void CreateFileExtensionsMap(); void CreateSaveFileExtensions(); typedef std::set ExtraFactoriesContainer; + ExtraFactoriesContainer m_ExtraFactories; static FileWriterList m_FileWriters; std::string m_FileExtensions; MultimapType m_FileExtensionsMap; std::string m_SaveFileExtensions; MultimapType m_SaveFileExtensionsMap; + itk::ObjectFactoryBase::Pointer m_PointSetIOFactory; + itk::ObjectFactoryBase::Pointer m_STLFileIOFactory; + itk::ObjectFactoryBase::Pointer m_VtkSurfaceIOFactory; + itk::ObjectFactoryBase::Pointer m_VtkImageIOFactory; + itk::ObjectFactoryBase::Pointer m_VtiFileIOFactory; + itk::ObjectFactoryBase::Pointer m_ItkImageFileIOFactory; + + itk::ObjectFactoryBase::Pointer m_SurfaceVtkWriterFactory; + itk::ObjectFactoryBase::Pointer m_PointSetWriterFactory; + itk::ObjectFactoryBase::Pointer m_ImageWriterFactory; }; } // namespace mitk #endif diff --git a/Core/Code/IO/mitkImageWriterFactory.h b/Core/Code/IO/mitkImageWriterFactory.h index 6be37feb28..a4802d4fb8 100644 --- a/Core/Code/IO/mitkImageWriterFactory.h +++ b/Core/Code/IO/mitkImageWriterFactory.h @@ -1,63 +1,66 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef IMAGEWRITERFACTORY_H_HEADER_INCLUDED #define IMAGEWRITERFACTORY_H_HEADER_INCLUDED #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { class MITK_CORE_EXPORT ImageWriterFactory : public itk::ObjectFactoryBase { public: mitkClassMacro( mitk::ImageWriterFactory, itk::ObjectFactoryBase ) /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { static bool IsRegistered = false; if ( !IsRegistered ) { ImageWriterFactory::Pointer imageWriterFactory = ImageWriterFactory::New(); ObjectFactoryBase::RegisterFactory( imageWriterFactory ); IsRegistered = true; } } protected: ImageWriterFactory(); ~ImageWriterFactory(); private: ImageWriterFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkItkImageFileIOFactory.h b/Core/Code/IO/mitkItkImageFileIOFactory.h index 991c9e25a0..a912071103 100644 --- a/Core/Code/IO/mitkItkImageFileIOFactory.h +++ b/Core/Code/IO/mitkItkImageFileIOFactory.h @@ -1,71 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkItkImageFileIOFactory_h #define __mitkItkImageFileIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of ItkImageFileReader objects using an object factory. //## //## @ingroup IO class MITK_CORE_EXPORT ItkImageFileIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef ItkImageFileIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static ItkImageFileIOFactory* FactoryNew() { return new ItkImageFileIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(ItkImageFileIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { ItkImageFileIOFactory::Pointer ItkImageFileIOFactory = ItkImageFileIOFactory::New(); ObjectFactoryBase::RegisterFactory(ItkImageFileIOFactory); } protected: ItkImageFileIOFactory(); ~ItkImageFileIOFactory(); private: ItkImageFileIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkPointSetIOFactory.h b/Core/Code/IO/mitkPointSetIOFactory.h index b739392faa..f59980522d 100644 --- a/Core/Code/IO/mitkPointSetIOFactory.h +++ b/Core/Code/IO/mitkPointSetIOFactory.h @@ -1,71 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkPointSetIOFactory_h #define __mitkPointSetIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of PointSetReader objects using an object factory. //## //## @ingroup IO class MITK_CORE_EXPORT PointSetIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef PointSetIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static PointSetIOFactory* FactoryNew() { return new PointSetIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(PointSetIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { PointSetIOFactory::Pointer PointSetIOFactory = PointSetIOFactory::New(); ObjectFactoryBase::RegisterFactory(PointSetIOFactory); } protected: PointSetIOFactory(); ~PointSetIOFactory(); private: PointSetIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkPointSetWriterFactory.h b/Core/Code/IO/mitkPointSetWriterFactory.h index bb63c3f17a..0eacd88236 100644 --- a/Core/Code/IO/mitkPointSetWriterFactory.h +++ b/Core/Code/IO/mitkPointSetWriterFactory.h @@ -1,63 +1,66 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef POINTSETWRITERFACTORY_H_HEADER_INCLUDED #define POINTSETWRITERFACTORY_H_HEADER_INCLUDED #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { class MITK_CORE_EXPORT PointSetWriterFactory : public itk::ObjectFactoryBase { public: mitkClassMacro( mitk::PointSetWriterFactory, itk::ObjectFactoryBase ) /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { static bool IsRegistered = false; if ( !IsRegistered ) { PointSetWriterFactory::Pointer pointSetWriterFactory = PointSetWriterFactory::New(); ObjectFactoryBase::RegisterFactory( pointSetWriterFactory ); IsRegistered = true; } } protected: PointSetWriterFactory(); ~PointSetWriterFactory(); private: PointSetWriterFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkSTLFileIOFactory.h b/Core/Code/IO/mitkSTLFileIOFactory.h index eee06b2694..d8f141c016 100644 --- a/Core/Code/IO/mitkSTLFileIOFactory.h +++ b/Core/Code/IO/mitkSTLFileIOFactory.h @@ -1,71 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkSTLFileIOFactory_h #define __mitkSTLFileIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of STLFileReader objects using an object factory. //## //## @ingroup IO class MITK_CORE_EXPORT STLFileIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef STLFileIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static STLFileIOFactory* FactoryNew() { return new STLFileIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(STLFileIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { STLFileIOFactory::Pointer STLFileIOFactory = STLFileIOFactory::New(); ObjectFactoryBase::RegisterFactory(STLFileIOFactory); } protected: STLFileIOFactory(); ~STLFileIOFactory(); private: STLFileIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkSurfaceVtkWriterFactory.h b/Core/Code/IO/mitkSurfaceVtkWriterFactory.h index 00f5522024..a7aafd7272 100644 --- a/Core/Code/IO/mitkSurfaceVtkWriterFactory.h +++ b/Core/Code/IO/mitkSurfaceVtkWriterFactory.h @@ -1,66 +1,69 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef SURFACEWRITERFACTORY_H_HEADER_INCLUDED #define SURFACEWRITERFACTORY_H_HEADER_INCLUDED #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { class MITK_CORE_EXPORT SurfaceVtkWriterFactory : public itk::ObjectFactoryBase { public: mitkClassMacro( mitk::SurfaceVtkWriterFactory, itk::ObjectFactoryBase ) /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { static bool IsRegistered = false; if ( !IsRegistered ) { SurfaceVtkWriterFactory::Pointer surfaceVtkWriterFactory = SurfaceVtkWriterFactory::New(); ObjectFactoryBase::RegisterFactory( surfaceVtkWriterFactory ); IsRegistered = true; } } protected: SurfaceVtkWriterFactory(); ~SurfaceVtkWriterFactory(); private: SurfaceVtkWriterFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkVtiFileIOFactory.h b/Core/Code/IO/mitkVtiFileIOFactory.h index 1e77fa0b81..7829e4dd17 100644 --- a/Core/Code/IO/mitkVtiFileIOFactory.h +++ b/Core/Code/IO/mitkVtiFileIOFactory.h @@ -1,71 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkVtiFileIOFactory_h #define __mitkVtiFileIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of VtiFileReader objects using an object factory. //## //## @ingroup IO class MITK_CORE_EXPORT VtiFileIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef VtiFileIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static VtiFileIOFactory* FactoryNew() { return new VtiFileIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(VtiFileIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { VtiFileIOFactory::Pointer VtiFileIOFactory = VtiFileIOFactory::New(); ObjectFactoryBase::RegisterFactory(VtiFileIOFactory); } protected: VtiFileIOFactory(); ~VtiFileIOFactory(); private: VtiFileIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkVtkImageIOFactory.h b/Core/Code/IO/mitkVtkImageIOFactory.h index b05e8ebede..b6d7ce6374 100644 --- a/Core/Code/IO/mitkVtkImageIOFactory.h +++ b/Core/Code/IO/mitkVtkImageIOFactory.h @@ -1,71 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkVtkImageIOFactory_h #define __mitkVtkImageIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of VtkImageReader objects using an object factory. //## //## @ingroup IO class MITK_CORE_EXPORT VtkImageIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef VtkImageIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static VtkImageIOFactory* FactoryNew() { return new VtkImageIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(VtkImageIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { VtkImageIOFactory::Pointer VtkImageIOFactory = VtkImageIOFactory::New(); ObjectFactoryBase::RegisterFactory(VtkImageIOFactory); } protected: VtkImageIOFactory(); ~VtkImageIOFactory(); private: VtkImageIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkVtkSurfaceIOFactory.h b/Core/Code/IO/mitkVtkSurfaceIOFactory.h index 427a0228ed..2b32315d84 100644 --- a/Core/Code/IO/mitkVtkSurfaceIOFactory.h +++ b/Core/Code/IO/mitkVtkSurfaceIOFactory.h @@ -1,71 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkVtkSurfaceIOFactory_h #define __mitkVtkSurfaceIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of VtkSurfaceReader objects using an object factory. //## //## @ingroup IO class MITK_CORE_EXPORT VtkSurfaceIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef VtkSurfaceIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static VtkSurfaceIOFactory* FactoryNew() { return new VtkSurfaceIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(VtkSurfaceIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { VtkSurfaceIOFactory::Pointer VtkSurfaceIOFactory = VtkSurfaceIOFactory::New(); ObjectFactoryBase::RegisterFactory(VtkSurfaceIOFactory); } protected: VtkSurfaceIOFactory(); ~VtkSurfaceIOFactory(); private: VtkSurfaceIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/ContourModel/Algorithms/mitkContourObjectFactory.cpp b/Modules/ContourModel/Algorithms/mitkContourObjectFactory.cpp index c028162db7..9585fc5071 100644 --- a/Modules/ContourModel/Algorithms/mitkContourObjectFactory.cpp +++ b/Modules/ContourModel/Algorithms/mitkContourObjectFactory.cpp @@ -1,154 +1,154 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkContourObjectFactory.h" #include "mitkProperties.h" #include "mitkBaseRenderer.h" #include "mitkDataNode.h" #include "mitkCoreObjectFactory.h" #include "mitkContourModel.h" #include "mitkContourModelIOFactory.h" #include "mitkContourModelWriterFactory.h" #include "mitkContourModelWriter.h" #include "mitkContourModelMapper2D.h" #include "mitkContourModelGLMapper2D.h" #include "mitkContourModelMapper3D.h" mitk::ContourObjectFactory::ContourObjectFactory() -: CoreObjectFactoryBase() -, m_ContourModelIOFactory(mitk::ContourModelIOFactory::New().GetPointer()) + : CoreObjectFactoryBase() + , m_ContourModelIOFactory(mitk::ContourModelIOFactory::New().GetPointer()) + , m_ContourModelWriterFactory(mitk::ContourModelWriterFactory::New().GetPointer()) { static bool alreadyDone = false; if (!alreadyDone) { MITK_DEBUG << "ContourObjectFactory c'tor" << std::endl; itk::ObjectFactoryBase::RegisterFactory( m_ContourModelIOFactory ); - - mitk::ContourModelWriterFactory::RegisterOneFactory(); + itk::ObjectFactoryBase::RegisterFactory( m_ContourModelWriterFactory ); this->m_FileWriters.push_back(mitk::ContourModelWriter::New().GetPointer()); CreateFileExtensionsMap(); alreadyDone = true; } } mitk::ContourObjectFactory::~ContourObjectFactory() { - mitk::ContourModelWriterFactory::UnRegisterOneFactory(); itk::ObjectFactoryBase::UnRegisterFactory(m_ContourModelIOFactory); + itk::ObjectFactoryBase::UnRegisterFactory(m_ContourModelWriterFactory); } mitk::Mapper::Pointer mitk::ContourObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper=NULL; mitk::BaseData *data = node->GetData(); if ( id == mitk::BaseRenderer::Standard2D ) { std::string classname("ContourModel"); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::ContourModelGLMapper2D::New(); newMapper->SetDataNode(node); } } else if ( id == mitk::BaseRenderer::Standard3D ) { std::string classname("ContourModel"); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::ContourModelMapper3D::New(); newMapper->SetDataNode(node); } } return newMapper; } void mitk::ContourObjectFactory::SetDefaultProperties(mitk::DataNode* node) { if(node==NULL) return; mitk::DataNode::Pointer nodePointer = node; std::string classname("ContourModel"); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::ContourModelGLMapper2D::SetDefaultProperties(node); mitk::ContourModelMapper3D::SetDefaultProperties(node); } } const char* mitk::ContourObjectFactory::GetFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_FileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::ContourObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } mitk::CoreObjectFactoryBase::MultimapType mitk::ContourObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::ContourObjectFactory::CreateFileExtensionsMap() { m_SaveFileExtensionsMap.insert(std::pair("*.cnt", "Contour Files")); m_FileExtensionsMap.insert(std::pair("*.cnt", "Contour File")); } const char* mitk::ContourObjectFactory::GetSaveFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); } void mitk::ContourObjectFactory::RegisterIOFactories() { } struct RegisterContourObjectFactory{ RegisterContourObjectFactory() : m_Factory( mitk::ContourObjectFactory::New() ) { mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory( m_Factory ); } ~RegisterContourObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory( m_Factory ); } mitk::ContourObjectFactory::Pointer m_Factory; }; static RegisterContourObjectFactory registerContourObjectFactory; diff --git a/Modules/ContourModel/Algorithms/mitkContourObjectFactory.h b/Modules/ContourModel/Algorithms/mitkContourObjectFactory.h index 3f8096fc85..4250fe74b2 100644 --- a/Modules/ContourModel/Algorithms/mitkContourObjectFactory.h +++ b/Modules/ContourModel/Algorithms/mitkContourObjectFactory.h @@ -1,50 +1,54 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef SEGMENTATIONOBJECTFACTORY_H_INCLUDED #define SEGMENTATIONOBJECTFACTORY_H_INCLUDED #include "mitkCoreObjectFactoryBase.h" #include "ContourModelExports.h" namespace mitk { class ContourModel_EXPORT ContourObjectFactory : public CoreObjectFactoryBase { public: mitkClassMacro(ContourObjectFactory,CoreObjectFactoryBase); itkNewMacro(ContourObjectFactory); virtual Mapper::Pointer CreateMapper(mitk::DataNode* node, MapperSlotId slotId); virtual void SetDefaultProperties(mitk::DataNode* node); virtual const char* GetFileExtensions(); virtual mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap(); virtual const char* GetSaveFileExtensions(); virtual mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap(); - void RegisterIOFactories(); + + /** \deprecatedSince{2013_09} */ + DEPRECATED(void RegisterIOFactories()); + protected: ContourObjectFactory(); ~ContourObjectFactory(); void CreateFileExtensionsMap(); MultimapType m_FileExtensionsMap; MultimapType m_SaveFileExtensionsMap; private: itk::ObjectFactoryBase::Pointer m_ContourModelIOFactory; + itk::ObjectFactoryBase::Pointer m_ContourModelWriterFactory; }; } #endif diff --git a/Modules/ContourModel/IO/mitkContourModelIOFactory.h b/Modules/ContourModel/IO/mitkContourModelIOFactory.h index 40a1109e16..7d4395b80b 100644 --- a/Modules/ContourModel/IO/mitkContourModelIOFactory.h +++ b/Modules/ContourModel/IO/mitkContourModelIOFactory.h @@ -1,72 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkContourModelIOFactory_h #define __mitkContourModelIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "ContourModelExports.h" #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of ContourModelReader objects using an object factory. //## //## @ingroup IO class ContourModel_EXPORT ContourModelIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef ContourModelIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static ContourModelIOFactory* FactoryNew() { return new ContourModelIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(ContourModelIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { ContourModelIOFactory::Pointer ContourModelIOFactory = ContourModelIOFactory::New(); ObjectFactoryBase::RegisterFactory(ContourModelIOFactory); } protected: ContourModelIOFactory(); ~ContourModelIOFactory(); private: ContourModelIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/ContourModel/IO/mitkContourModelWriterFactory.h b/Modules/ContourModel/IO/mitkContourModelWriterFactory.h index b38f476684..bcfcbb1732 100644 --- a/Modules/ContourModel/IO/mitkContourModelWriterFactory.h +++ b/Modules/ContourModel/IO/mitkContourModelWriterFactory.h @@ -1,57 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef CONTOURMODELWRITERFACTORY_H_HEADER_INCLUDED #define CONTOURMODELWRITERFACTORY_H_HEADER_INCLUDED #include "ContourModelExports.h" #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { class ContourModel_EXPORT ContourModelWriterFactory : public itk::ObjectFactoryBase { public: mitkClassMacro( mitk::ContourModelWriterFactory, itk::ObjectFactoryBase ) /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); - /** Register one factory of this type */ - static void RegisterOneFactory(void); - - /** UnRegister one factory of this type */ - static void UnRegisterOneFactory(void); + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)); + + /** + * UnRegister one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void UnRegisterOneFactory(void)); protected: ContourModelWriterFactory(); ~ContourModelWriterFactory(); private: ContourModelWriterFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented static itk::ObjectFactoryBase::Pointer GetInstance(); }; } #endif //CONTOURMODELWRITERFACTORY_H_HEADER_INCLUDED diff --git a/Modules/MitkExt/Algorithms/mitkCoreExtObjectFactory.cpp b/Modules/MitkExt/Algorithms/mitkCoreExtObjectFactory.cpp index ee6ff1ada2..7c0c1a65a1 100644 --- a/Modules/MitkExt/Algorithms/mitkCoreExtObjectFactory.cpp +++ b/Modules/MitkExt/Algorithms/mitkCoreExtObjectFactory.cpp @@ -1,192 +1,208 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkCoreExtObjectFactory.h" #include "mitkProperties.h" #include "mitkBaseRenderer.h" #include "mitkDataNode.h" #include "mitkCoreObjectFactory.h" #include "mitkParRecFileIOFactory.h" #include "mitkObjFileIOFactory.h" #include "mitkVtkUnstructuredGridIOFactory.h" #include "mitkStlVolumeTimeSeriesIOFactory.h" #include "mitkVtkVolumeTimeSeriesIOFactory.h" #include "mitkUnstructuredGridVtkWriterFactory.h" #include "mitkUnstructuredGridVtkWriter.h" #include #include #include #include "mitkCone.h" #include "mitkCuboid.h" #include "mitkCylinder.h" #include "mitkEllipsoid.h" #include "mitkMeshMapper2D.h" #include "mitkMeshVtkMapper3D.h" #include "mitkUnstructuredGridMapper2D.h" #include "mitkEnhancedPointSetVtkMapper3D.h" #include "mitkSeedsImage.h" #include "mitkUnstructuredGrid.h" #include "mitkUnstructuredGridVtkMapper3D.h" #include "mitkPolyDataGLMapper2D.h" #include "mitkGPUVolumeMapper3D.h" #include "mitkVolumeDataVtkMapper3D.h" mitk::CoreExtObjectFactory::CoreExtObjectFactory() -:CoreObjectFactoryBase() + : CoreObjectFactoryBase() + , m_ParRecFileIOFactory(ParRecFileIOFactory::New().GetPointer()) + , m_ObjFileIOFactory(ObjFileIOFactory::New().GetPointer()) + , m_VtkUnstructuredGridIOFactory(VtkUnstructuredGridIOFactory::New().GetPointer()) + , m_StlVolumeTimeSeriesIOFactory(StlVolumeTimeSeriesIOFactory::New().GetPointer()) + , m_VtkVolumeTimeSeriesIOFactory(VtkVolumeTimeSeriesIOFactory::New().GetPointer()) + , m_UnstructuredGridVtkWriterFactory(UnstructuredGridVtkWriterFactory::New().GetPointer()) { static bool alreadyDone = false; if (!alreadyDone) { MITK_DEBUG << "CoreExtObjectFactory c'tor" << std::endl; - RegisterIOFactories(); - itk::ObjectFactoryBase::RegisterFactory( ParRecFileIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( ObjFileIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( VtkUnstructuredGridIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( StlVolumeTimeSeriesIOFactory::New() ); - itk::ObjectFactoryBase::RegisterFactory( VtkVolumeTimeSeriesIOFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory( m_ParRecFileIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_ObjFileIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_VtkUnstructuredGridIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_StlVolumeTimeSeriesIOFactory ); + itk::ObjectFactoryBase::RegisterFactory( m_VtkVolumeTimeSeriesIOFactory ); - mitk::UnstructuredGridVtkWriterFactory::RegisterOneFactory(); + itk::ObjectFactoryBase::RegisterFactory( m_UnstructuredGridVtkWriterFactory ); m_FileWriters.push_back(mitk::UnstructuredGridVtkWriter::New().GetPointer()); m_FileWriters.push_back(mitk::UnstructuredGridVtkWriter::New().GetPointer()); m_FileWriters.push_back(mitk::UnstructuredGridVtkWriter::New().GetPointer()); CreateFileExtensionsMap(); alreadyDone = true; } } +mitk::CoreExtObjectFactory::~CoreExtObjectFactory() +{ + itk::ObjectFactoryBase::UnRegisterFactory( m_ParRecFileIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_ObjFileIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_VtkUnstructuredGridIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_StlVolumeTimeSeriesIOFactory ); + itk::ObjectFactoryBase::UnRegisterFactory( m_VtkVolumeTimeSeriesIOFactory ); + + itk::ObjectFactoryBase::UnRegisterFactory( m_UnstructuredGridVtkWriterFactory ); +} + mitk::Mapper::Pointer mitk::CoreExtObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper=NULL; mitk::BaseData *data = node->GetData(); if ( id == mitk::BaseRenderer::Standard2D ) { if((dynamic_cast(data)!=NULL)) { newMapper = mitk::MeshMapper2D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::UnstructuredGridMapper2D::New(); newMapper->SetDataNode(node); } } else if ( id == mitk::BaseRenderer::Standard3D ) { if((dynamic_cast(data) != NULL)) { newMapper = mitk::GPUVolumeMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::MeshVtkMapper3D::New(); newMapper->SetDataNode(node); } else if((dynamic_cast(data)!=NULL)) { newMapper = mitk::UnstructuredGridVtkMapper3D::New(); newMapper->SetDataNode(node); } } return newMapper; } void mitk::CoreExtObjectFactory::SetDefaultProperties(mitk::DataNode* node) { if(node==NULL) return; mitk::DataNode::Pointer nodePointer = node; mitk::Image::Pointer image = dynamic_cast(node->GetData()); if(image.IsNotNull() && image->IsInitialized()) { mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } if (dynamic_cast(node->GetData())) { mitk::UnstructuredGridVtkMapper3D::SetDefaultProperties(node); } } const char* mitk::CoreExtObjectFactory::GetFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_FileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::CoreExtObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } mitk::CoreObjectFactoryBase::MultimapType mitk::CoreExtObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::CoreExtObjectFactory::CreateFileExtensionsMap() { m_FileExtensionsMap.insert(std::pair("*.mitk", "MITK scene files")); //a better place to add this file ending might be the scene serialization class //at the moment this is not done because there is a plan to restructure the //ObjectFactories. When this is done we have to check where we want to add this file ending. m_FileExtensionsMap.insert(std::pair("*.vtu", "VTK Unstructured Grid")); m_FileExtensionsMap.insert(std::pair("*.vtk", "VTK Unstructured Grid")); m_FileExtensionsMap.insert(std::pair("*.pvtu", "VTK Unstructured Grid")); m_SaveFileExtensionsMap.insert(std::pair("*.pvtu", "VTK Parallel XML Unstructured Grid")); m_SaveFileExtensionsMap.insert(std::pair("*.vtu", "VTK XML Unstructured Grid")); m_SaveFileExtensionsMap.insert(std::pair("*.vtk", "VTK Legacy Unstructured Grid")); } const char* mitk::CoreExtObjectFactory::GetSaveFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); } void mitk::CoreExtObjectFactory::RegisterIOFactories() { } void RegisterCoreExtObjectFactory() { static bool oneCoreExtObjectFactoryRegistered = false; if ( ! oneCoreExtObjectFactoryRegistered ) { MITK_DEBUG << "Registering CoreExtObjectFactory..." << std::endl; mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(mitk::CoreExtObjectFactory::New()); oneCoreExtObjectFactoryRegistered = true; } } diff --git a/Modules/MitkExt/Algorithms/mitkCoreExtObjectFactory.h b/Modules/MitkExt/Algorithms/mitkCoreExtObjectFactory.h index 4ed2b1700c..8877d0a1e0 100644 --- a/Modules/MitkExt/Algorithms/mitkCoreExtObjectFactory.h +++ b/Modules/MitkExt/Algorithms/mitkCoreExtObjectFactory.h @@ -1,50 +1,65 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef COREEXTOBJECTFACTORY_H_INCLUDED #define COREEXTOBJECTFACTORY_H_INCLUDED #include "mitkCoreObjectFactoryBase.h" #include "MitkExtExports.h" namespace mitk { class MitkExt_EXPORT CoreExtObjectFactory : public CoreObjectFactoryBase { public: mitkClassMacro(CoreExtObjectFactory,CoreObjectFactoryBase); itkNewMacro(CoreExtObjectFactory); virtual Mapper::Pointer CreateMapper(mitk::DataNode* node, MapperSlotId slotId); virtual void SetDefaultProperties(mitk::DataNode* node); virtual const char* GetFileExtensions(); virtual mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap(); virtual const char* GetSaveFileExtensions(); virtual mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap(); - void RegisterIOFactories(); + + /** \deprecatedSince{2013_09} */ + DEPRECATED(void RegisterIOFactories()); + protected: CoreExtObjectFactory(); + ~CoreExtObjectFactory(); + void CreateFileExtensionsMap(); MultimapType m_FileExtensionsMap; MultimapType m_SaveFileExtensionsMap; + + private: + + itk::ObjectFactoryBase::Pointer m_ParRecFileIOFactory; + itk::ObjectFactoryBase::Pointer m_ObjFileIOFactory; + itk::ObjectFactoryBase::Pointer m_VtkUnstructuredGridIOFactory; + itk::ObjectFactoryBase::Pointer m_StlVolumeTimeSeriesIOFactory; + itk::ObjectFactoryBase::Pointer m_VtkVolumeTimeSeriesIOFactory; + + itk::ObjectFactoryBase::Pointer m_UnstructuredGridVtkWriterFactory; }; } // global declaration for simple call by // applications void MitkExt_EXPORT RegisterCoreExtObjectFactory(); #endif diff --git a/Modules/MitkExt/IO/mitkObjFileIOFactory.h b/Modules/MitkExt/IO/mitkObjFileIOFactory.h index ec454ebf6e..1ef13fdcbe 100644 --- a/Modules/MitkExt/IO/mitkObjFileIOFactory.h +++ b/Modules/MitkExt/IO/mitkObjFileIOFactory.h @@ -1,72 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkObjFileIOFactory_h #define __mitkObjFileIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "MitkExtExports.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of ObjFileReader objects using an object factory. //## //## @ingroup IO class MitkExt_EXPORT ObjFileIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef ObjFileIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static ObjFileIOFactory* FactoryNew() { return new ObjFileIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(ObjFileIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { ObjFileIOFactory::Pointer ObjFileIOFactory = ObjFileIOFactory::New(); ObjectFactoryBase::RegisterFactory(ObjFileIOFactory); } protected: ObjFileIOFactory(); ~ObjFileIOFactory(); private: ObjFileIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/MitkExt/IO/mitkParRecFileIOFactory.h b/Modules/MitkExt/IO/mitkParRecFileIOFactory.h index f3cc6416d6..334717fcb5 100644 --- a/Modules/MitkExt/IO/mitkParRecFileIOFactory.h +++ b/Modules/MitkExt/IO/mitkParRecFileIOFactory.h @@ -1,73 +1,76 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkParRecFileIOFactory_h #define __mitkParRecFileIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "MitkExtExports.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of ParRecFileReader objects using an object factory. //## //## @ingroup IO class MitkExt_EXPORT ParRecFileIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef ParRecFileIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static ParRecFileIOFactory* FactoryNew() { return new ParRecFileIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(ParRecFileIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { ParRecFileIOFactory::Pointer ParRecFileIOFactory = ParRecFileIOFactory::New(); ObjectFactoryBase::RegisterFactory(ParRecFileIOFactory); } protected: ParRecFileIOFactory(); ~ParRecFileIOFactory(); private: ParRecFileIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/MitkExt/IO/mitkStlVolumeTimeSeriesIOFactory.h b/Modules/MitkExt/IO/mitkStlVolumeTimeSeriesIOFactory.h index 46bd024943..fce9500ff4 100644 --- a/Modules/MitkExt/IO/mitkStlVolumeTimeSeriesIOFactory.h +++ b/Modules/MitkExt/IO/mitkStlVolumeTimeSeriesIOFactory.h @@ -1,72 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkStlVolumeTimeSeriesIOFactory_h #define __mitkStlVolumeTimeSeriesIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "MitkExtExports.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of StlVolumeTimeSeriesReader objects using an object factory. //## //## @ingroup IO class MitkExt_EXPORT StlVolumeTimeSeriesIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef StlVolumeTimeSeriesIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static StlVolumeTimeSeriesIOFactory* FactoryNew() { return new StlVolumeTimeSeriesIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(StlVolumeTimeSeriesIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { StlVolumeTimeSeriesIOFactory::Pointer StlVolumeTimeSeriesIOFactory = StlVolumeTimeSeriesIOFactory::New(); ObjectFactoryBase::RegisterFactory(StlVolumeTimeSeriesIOFactory); } protected: StlVolumeTimeSeriesIOFactory(); ~StlVolumeTimeSeriesIOFactory(); private: StlVolumeTimeSeriesIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriterFactory.h b/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriterFactory.h index d086a20633..1319b7f9d9 100644 --- a/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriterFactory.h +++ b/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriterFactory.h @@ -1,67 +1,70 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef UNSTRUCTURED_GRID_WRITERFACTORY_H_HEADER_INCLUDED #define UNSTRUCTURED_GRID_WRITERFACTORY_H_HEADER_INCLUDED #include "itkObjectFactoryBase.h" #include "MitkExtExports.h" #include "mitkBaseData.h" namespace mitk { class MitkExt_EXPORT UnstructuredGridVtkWriterFactory : public itk::ObjectFactoryBase { public: mitkClassMacro( mitk::UnstructuredGridVtkWriterFactory, itk::ObjectFactoryBase ) /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { static bool IsRegistered = false; if ( !IsRegistered ) { UnstructuredGridVtkWriterFactory::Pointer ugVtkWriterFactory = UnstructuredGridVtkWriterFactory::New(); ObjectFactoryBase::RegisterFactory( ugVtkWriterFactory ); IsRegistered = true; } } protected: UnstructuredGridVtkWriterFactory(); ~UnstructuredGridVtkWriterFactory(); private: UnstructuredGridVtkWriterFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif // UNSTRUCTURED_GRID_WRITERFACTORY_H_HEADER_INCLUDED diff --git a/Modules/MitkExt/IO/mitkVtkUnstructuredGridIOFactory.h b/Modules/MitkExt/IO/mitkVtkUnstructuredGridIOFactory.h index de70fc41a3..92ae0e0cbe 100644 --- a/Modules/MitkExt/IO/mitkVtkUnstructuredGridIOFactory.h +++ b/Modules/MitkExt/IO/mitkVtkUnstructuredGridIOFactory.h @@ -1,72 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __MITK_VTK_UNSTRUCTURED_GRID_IO_FACTORY_H_HEADER__ #define __MITK_VTK_UNSTRUCTURED_GRID_IO_FACTORY_H_HEADER__ #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "MitkExtExports.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of VtkUnstructuredGridReader objects using an object factory. //## //## @ingroup IO class MitkExt_EXPORT VtkUnstructuredGridIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef VtkUnstructuredGridIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static VtkUnstructuredGridIOFactory* FactoryNew() { return new VtkUnstructuredGridIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(VtkUnstructuredGridIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { VtkUnstructuredGridIOFactory::Pointer VtkUnstructuredGridIOFactory = VtkUnstructuredGridIOFactory::New(); ObjectFactoryBase::RegisterFactory(VtkUnstructuredGridIOFactory); } protected: VtkUnstructuredGridIOFactory(); ~VtkUnstructuredGridIOFactory(); private: VtkUnstructuredGridIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif // __MITK_VTK_UNSTRUCTURED_GRID_IO_FACTORY_H_HEADER__ diff --git a/Modules/MitkExt/IO/mitkVtkVolumeTimeSeriesIOFactory.h b/Modules/MitkExt/IO/mitkVtkVolumeTimeSeriesIOFactory.h index 9aa82a8ddc..49c2b60412 100644 --- a/Modules/MitkExt/IO/mitkVtkVolumeTimeSeriesIOFactory.h +++ b/Modules/MitkExt/IO/mitkVtkVolumeTimeSeriesIOFactory.h @@ -1,72 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkVtkVolumeTimeSeriesIOFactory_h #define __mitkVtkVolumeTimeSeriesIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "MitkExtExports.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of VtkVolumeTimeSeriesReader objects using an object factory. //## //## @ingroup IO class MitkExt_EXPORT VtkVolumeTimeSeriesIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef VtkVolumeTimeSeriesIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static VtkVolumeTimeSeriesIOFactory* FactoryNew() { return new VtkVolumeTimeSeriesIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(VtkVolumeTimeSeriesIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { VtkVolumeTimeSeriesIOFactory::Pointer VtkVolumeTimeSeriesIOFactory = VtkVolumeTimeSeriesIOFactory::New(); ObjectFactoryBase::RegisterFactory(VtkVolumeTimeSeriesIOFactory); } protected: VtkVolumeTimeSeriesIOFactory(); ~VtkVolumeTimeSeriesIOFactory(); private: VtkVolumeTimeSeriesIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/PlanarFigure/Algorithms/mitkPlanarFigureObjectFactory.cpp b/Modules/PlanarFigure/Algorithms/mitkPlanarFigureObjectFactory.cpp index 3e6318dbb1..1b92af848d 100644 --- a/Modules/PlanarFigure/Algorithms/mitkPlanarFigureObjectFactory.cpp +++ b/Modules/PlanarFigure/Algorithms/mitkPlanarFigureObjectFactory.cpp @@ -1,148 +1,146 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPlanarFigureObjectFactory.h" #include "mitkPlanarFigureWriter.h" #include "mitkCoreObjectFactory.h" #include "mitkPlanarFigureIOFactory.h" #include "mitkPlanarFigureWriterFactory.h" #include "mitkPlanarFigure.h" #include "mitkPlanarFigureMapper2D.h" #include "mitkPlanarFigureVtkMapper3D.h" typedef std::multimap MultimapType; mitk::PlanarFigureObjectFactory::PlanarFigureObjectFactory() : m_PlanarFigureIOFactory(PlanarFigureIOFactory::New().GetPointer()) +, m_PlanarFigureWriterFactory(PlanarFigureWriterFactory::New().GetPointer()) { static bool alreadyDone = false; if ( !alreadyDone ) { - RegisterIOFactories(); - itk::ObjectFactoryBase::RegisterFactory( m_PlanarFigureIOFactory ); - - PlanarFigureWriterFactory::RegisterOneFactory(); + itk::ObjectFactoryBase::RegisterFactory( m_PlanarFigureWriterFactory ); m_FileWriters.push_back( PlanarFigureWriter::New().GetPointer() ); CreateFileExtensionsMap(); alreadyDone = true; } } mitk::PlanarFigureObjectFactory::~PlanarFigureObjectFactory() { - PlanarFigureWriterFactory::UnRegisterOneFactory(); + itk::ObjectFactoryBase::UnRegisterFactory(m_PlanarFigureWriterFactory); itk::ObjectFactoryBase::UnRegisterFactory(m_PlanarFigureIOFactory); } mitk::Mapper::Pointer mitk::PlanarFigureObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper=NULL; mitk::BaseData *data = node->GetData(); if ( dynamic_cast(data) != NULL ) { if ( id == mitk::BaseRenderer::Standard2D ) { newMapper = mitk::PlanarFigureMapper2D::New(); newMapper->SetDataNode(node); } else if ( id == mitk::BaseRenderer::Standard3D ) { newMapper = mitk::PlanarFigureVtkMapper3D::New(); newMapper->SetDataNode(node); } } return newMapper; } void mitk::PlanarFigureObjectFactory::SetDefaultProperties(mitk::DataNode* node) { if ( node == NULL ) { return; } mitk::DataNode::Pointer nodePointer = node; mitk::PlanarFigure::Pointer pf = dynamic_cast( node->GetData() ); if ( pf.IsNotNull() ) { mitk::PlanarFigureMapper2D::SetDefaultProperties(node); node->AddProperty( "color", mitk::ColorProperty::New(1.0,1.0,1.0), NULL, true ); node->AddProperty( "opacity", mitk::FloatProperty::New(0.8), NULL, true ); node->AddProperty( "planarfigure.3drendering", mitk::BoolProperty::New(false), NULL, true ); } } const char* mitk::PlanarFigureObjectFactory::GetFileExtensions() { return ""; } mitk::CoreObjectFactoryBase::MultimapType mitk::PlanarFigureObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } const char* mitk::PlanarFigureObjectFactory::GetSaveFileExtensions() { //return ";;Planar Figures (*.pf)"; // for mitk::PlanarFigure and derived classes std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::PlanarFigureObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::PlanarFigureObjectFactory::CreateFileExtensionsMap() { m_FileExtensionsMap.insert(std::pair("*.pf", "Planar Figure Files")); m_SaveFileExtensionsMap.insert(std::pair("*.pf", "Planar Figure Files")); } void mitk::PlanarFigureObjectFactory::RegisterIOFactories() { } struct RegisterPlanarFigureObjectFactory{ RegisterPlanarFigureObjectFactory() : m_Factory( mitk::PlanarFigureObjectFactory::New() ) { mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory( m_Factory ); } ~RegisterPlanarFigureObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory( m_Factory ); } mitk::PlanarFigureObjectFactory::Pointer m_Factory; }; static RegisterPlanarFigureObjectFactory registerPlanarFigureObjectFactory; diff --git a/Modules/PlanarFigure/Algorithms/mitkPlanarFigureObjectFactory.h b/Modules/PlanarFigure/Algorithms/mitkPlanarFigureObjectFactory.h index 8d915c460e..afaccaceba 100644 --- a/Modules/PlanarFigure/Algorithms/mitkPlanarFigureObjectFactory.h +++ b/Modules/PlanarFigure/Algorithms/mitkPlanarFigureObjectFactory.h @@ -1,61 +1,62 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef PLANARFIGUREOBJECTFACTORY_H_INCLUDED #define PLANARFIGUREOBJECTFACTORY_H_INCLUDED #include "mitkCoreObjectFactoryBase.h" #include "PlanarFigureExports.h" namespace mitk { class PlanarFigure_EXPORT PlanarFigureObjectFactory : public CoreObjectFactoryBase { public: mitkClassMacro(PlanarFigureObjectFactory,CoreObjectFactoryBase) itkNewMacro(PlanarFigureObjectFactory) ~PlanarFigureObjectFactory(); virtual Mapper::Pointer CreateMapper(mitk::DataNode* node, MapperSlotId slotId); virtual void SetDefaultProperties(mitk::DataNode* node); virtual const char* GetFileExtensions(); virtual mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap(); virtual const char* GetSaveFileExtensions(); virtual mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap(); - void RegisterIOFactories(); + DEPRECATED(void RegisterIOFactories()); protected: PlanarFigureObjectFactory(); void CreateFileExtensionsMap(); MultimapType m_FileExtensionsMap; MultimapType m_SaveFileExtensionsMap; private: itk::ObjectFactoryBase::Pointer m_PlanarFigureIOFactory; + itk::ObjectFactoryBase::Pointer m_PlanarFigureWriterFactory; }; } #endif // PLANARFIGUREOBJECTFACTORY_H_INCLUDED diff --git a/Modules/PlanarFigure/IO/mitkPlanarFigureIOFactory.h b/Modules/PlanarFigure/IO/mitkPlanarFigureIOFactory.h index d29b1bf422..261210942a 100644 --- a/Modules/PlanarFigure/IO/mitkPlanarFigureIOFactory.h +++ b/Modules/PlanarFigure/IO/mitkPlanarFigureIOFactory.h @@ -1,72 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkPlanarFigureIOFactory_h #define __mitkPlanarFigureIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include "itkObjectFactoryBase.h" #include "PlanarFigureExports.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of PlanarFigureReader objects using an object factory. //## //## @ingroup IO class PlanarFigure_EXPORT PlanarFigureIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ typedef PlanarFigureIOFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); static PlanarFigureIOFactory* FactoryNew() { return new PlanarFigureIOFactory;} /** Run-time type information (and related methods). */ itkTypeMacro(PlanarFigureIOFactory, ObjectFactoryBase); - /** Register one factory of this type */ - static void RegisterOneFactory(void) + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)) { PlanarFigureIOFactory::Pointer PlanarFigureIOFactory = PlanarFigureIOFactory::New(); ObjectFactoryBase::RegisterFactory(PlanarFigureIOFactory); } protected: PlanarFigureIOFactory(); ~PlanarFigureIOFactory(); private: PlanarFigureIOFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/PlanarFigure/IO/mitkPlanarFigureWriterFactory.h b/Modules/PlanarFigure/IO/mitkPlanarFigureWriterFactory.h index 01c448feb8..ffa8f038fb 100644 --- a/Modules/PlanarFigure/IO/mitkPlanarFigureWriterFactory.h +++ b/Modules/PlanarFigure/IO/mitkPlanarFigureWriterFactory.h @@ -1,62 +1,68 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef PLANARFIGURE_WRITERFACTORY_H_HEADER_INCLUDED #define PLANARFIGURE_WRITERFACTORY_H_HEADER_INCLUDED #include "itkObjectFactoryBase.h" #include "PlanarFigureExports.h" #include "mitkBaseData.h" namespace mitk { class PlanarFigure_EXPORT PlanarFigureWriterFactory : public itk::ObjectFactoryBase { public: mitkClassMacro( mitk::PlanarFigureWriterFactory, itk::ObjectFactoryBase ) /** Class methods used to interface with the registered factories. */ virtual const char* GetITKSourceVersion(void) const; virtual const char* GetDescription(void) const; /** Method for class instantiation. */ itkFactorylessNewMacro(Self) - /** Register one factory of this type */ - static void RegisterOneFactory(void); - - /** UnRegister one factory of this type */ - static void UnRegisterOneFactory(void); + /** + * Register one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void RegisterOneFactory(void)); + + /** + * UnRegister one factory of this type + * \deprecatedSince{2013_09} + */ + DEPRECATED(static void UnRegisterOneFactory(void)); protected: PlanarFigureWriterFactory(); ~PlanarFigureWriterFactory(); private: PlanarFigureWriterFactory(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented static itk::ObjectFactoryBase::Pointer GetInstance(); }; } // end namespace mitk #endif // PLANARFIGURE_WRITERFACTORY_H_HEADER_INCLUDED diff --git a/Modules/SceneSerializationBase/mitkSerializerMacros.h b/Modules/SceneSerializationBase/mitkSerializerMacros.h index 89ed146c1f..769c2de067 100644 --- a/Modules/SceneSerializationBase/mitkSerializerMacros.h +++ b/Modules/SceneSerializationBase/mitkSerializerMacros.h @@ -1,106 +1,99 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #define MITK_REGISTER_SERIALIZER(classname) \ \ namespace mitk \ { \ \ class classname ## Factory : public ::itk::ObjectFactoryBase \ { \ public: \ \ /* ITK typedefs */ \ typedef classname ## Factory Self; \ typedef itk::ObjectFactoryBase Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ \ /* Methods from ObjectFactoryBase */ \ virtual const char* GetITKSourceVersion() const \ { \ return ITK_SOURCE_VERSION; \ } \ \ virtual const char* GetDescription() const \ { \ return "Generated factory for " #classname; \ } \ \ /* Method for class instantiation. */ \ itkFactorylessNewMacro(Self); \ \ /* Run-time type information (and related methods). */ \ itkTypeMacro(classname ## Factory, itkObjectFactoryBase); \ - \ - /* Register one factory of this type */ \ - static void RegisterOneFactory() \ - { \ - classname ## Factory::Pointer factory = classname ## Factory::New(); \ - itk::ObjectFactoryBase::RegisterFactory(factory); \ - } \ \ protected: \ \ classname ## Factory() \ { \ itk::ObjectFactoryBase::RegisterOverride(#classname, \ #classname, \ "Generated factory for " #classname, \ 1, \ itk::CreateObjectFunction::New()); \ } \ \ ~classname ## Factory() \ { \ } \ \ private: \ \ classname ## Factory(const Self&); /* purposely not implemented */ \ void operator=(const Self&); /* purposely not implemented */ \ \ }; \ \ \ \ class classname ## RegistrationMethod \ { \ public: \ \ classname ## RegistrationMethod() \ { \ m_Factory = classname ## Factory::New(); \ itk::ObjectFactoryBase::RegisterFactory( m_Factory ); \ } \ \ ~classname ## RegistrationMethod() \ { \ itk::ObjectFactoryBase::UnRegisterFactory( m_Factory ); \ } \ \ private: \ \ classname ## Factory::Pointer m_Factory; \ \ }; \ } \ \ static mitk::classname ## RegistrationMethod somestaticinitializer_ ## classname ; diff --git a/Modules/Segmentation/Interactions/mitkToolFactoryMacro.h b/Modules/Segmentation/Interactions/mitkToolFactoryMacro.h index ba0ed663e5..fe55dbd80e 100644 --- a/Modules/Segmentation/Interactions/mitkToolFactoryMacro.h +++ b/Modules/Segmentation/Interactions/mitkToolFactoryMacro.h @@ -1,243 +1,229 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #define MITK_TOOL_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ \ class EXPORT_SPEC CLASS_NAME ## Factory : public ::itk::ObjectFactoryBase \ { \ public: \ \ /* ITK typedefs */ \ typedef CLASS_NAME ## Factory Self; \ typedef itk::ObjectFactoryBase Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ \ /* Methods from ObjectFactoryBase */ \ virtual const char* GetITKSourceVersion() const \ { \ return ITK_SOURCE_VERSION; \ }\ \ virtual const char* GetDescription() const \ { \ return DESCRIPTION; \ }\ \ /* Method for class instantiation. */ \ itkFactorylessNewMacro(Self); \ \ /* Run-time type information (and related methods). */ \ itkTypeMacro(CLASS_NAME ## Factory, itkObjectFactoryBase); \ - \ - /* Register one factory of this type */ \ - static void RegisterOneFactory() \ - { \ - CLASS_NAME ## Factory::Pointer CLASS_NAME ## Factory = CLASS_NAME ## Factory::New(); \ - itk::ObjectFactoryBase::RegisterFactory(CLASS_NAME ## Factory); \ - } \ \ protected: \ \ CLASS_NAME ## Factory() \ { \ itk::ObjectFactoryBase::RegisterOverride("mitkTool", \ #CLASS_NAME, \ DESCRIPTION, \ 1, \ itk::CreateObjectFunction::New()); \ } \ \ ~CLASS_NAME ## Factory() \ { \ } \ \ private: \ \ CLASS_NAME ## Factory(const Self&); /* purposely not implemented */ \ void operator=(const Self&); /* purposely not implemented */ \ \ }; \ \ class CLASS_NAME ## RegistrationMethod \ { \ public: \ \ CLASS_NAME ## RegistrationMethod() \ { \ /*MITK_INFO("tools") << "Registered " #CLASS_NAME; */ \ m_Factory = CLASS_NAME ## Factory::New(); \ itk::ObjectFactoryBase::RegisterFactory( m_Factory ); \ } \ \ ~CLASS_NAME ## RegistrationMethod() \ { \ /*MITK_INFO("tools") << "UnRegistered " #CLASS_NAME; */ \ itk::ObjectFactoryBase::UnRegisterFactory( m_Factory ); \ } \ \ private: \ \ CLASS_NAME ## Factory::Pointer m_Factory; \ }; \ \ static mitk::CLASS_NAME ## RegistrationMethod somestaticinitializer_ ## CLASS_NAME ; #define MITK_DERIVED_SM_TOOL_MACRO(EXPORT_SPEC, BASE_CLASS, CLASS_NAME, DESCRIPTION) \ \ class EXPORT_SPEC CLASS_NAME ## Tool : public BASE_CLASS \ { \ public: \ \ typedef CLASS_NAME ## Tool Self; \ typedef BASE_CLASS Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ \ itkNewMacro(CLASS_NAME ## Tool); \ \ protected: \ \ CLASS_NAME ## Tool() \ { \ m_SegmentationGenerator = CLASS_NAME::New(); \ } \ \ void RegisterProgressObserver() \ { \ itk::ReceptorMemberCommand< CLASS_NAME ## Tool >::Pointer command = itk::ReceptorMemberCommand< CLASS_NAME ## Tool >::New(); \ command->SetCallbackFunction(this, &CLASS_NAME ## Tool::OnProgressEvent); \ m_SegmentationGenerator->AddSegmentationProgressObserver< CLASS_NAME ## Tool >( command ); \ } \ \ void RegisterFinishedSegmentationObserver() \ { \ itk::ReceptorMemberCommand< CLASS_NAME ## Tool >::Pointer command = itk::ReceptorMemberCommand< CLASS_NAME ## Tool >::New(); \ command->SetCallbackFunction(this, &CLASS_NAME ## Tool::OnSegmentationFinished); \ m_SegmentationGenerator->AddSegmentationFinishedObserver< CLASS_NAME ## Tool >( command ); \ } \ \ ~CLASS_NAME ## Tool() \ { \ } \ }; \ MITK_TOOL_MACRO(EXPORT_SPEC, CLASS_NAME ## Tool, DESCRIPTION); /* GUI classes are _not_ exported! */ #define MITK_TOOL_GUI_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ \ class EXPORT_SPEC CLASS_NAME ## Factory : public ::itk::ObjectFactoryBase \ { \ public: \ \ /* ITK typedefs */ \ typedef CLASS_NAME ## Factory Self; \ typedef itk::ObjectFactoryBase Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ \ /* Methods from ObjectFactoryBase */ \ virtual const char* GetITKSourceVersion() const \ { \ return ITK_SOURCE_VERSION; \ }\ \ virtual const char* GetDescription() const \ { \ return DESCRIPTION; \ }\ \ /* Method for class instantiation. */ \ itkFactorylessNewMacro(Self); \ \ /* Run-time type information (and related methods). */ \ itkTypeMacro(CLASS_NAME ## Factory, itkObjectFactoryBase); \ - \ - /* Register one factory of this type */ \ - static void RegisterOneFactory() \ - { \ - CLASS_NAME ## Factory::Pointer CLASS_NAME ## Factory = CLASS_NAME ## Factory::New(); \ - itk::ObjectFactoryBase::RegisterFactory(CLASS_NAME ## Factory); \ - } \ \ protected: \ \ CLASS_NAME ## Factory() \ { \ itk::ObjectFactoryBase::RegisterOverride(#CLASS_NAME, \ #CLASS_NAME, \ DESCRIPTION, \ 1, \ itk::CreateObjectFunction::New()); \ } \ \ ~CLASS_NAME ## Factory() \ { \ } \ \ private: \ \ CLASS_NAME ## Factory(const Self&); /* purposely not implemented */ \ void operator=(const Self&); /* purposely not implemented */ \ \ }; \ \ class CLASS_NAME ## RegistrationMethod \ { \ public: \ \ CLASS_NAME ## RegistrationMethod() \ { \ /*MITK_INFO("tools") << "Registered " #CLASS_NAME; */ \ m_Factory = CLASS_NAME ## Factory::New(); \ itk::ObjectFactoryBase::RegisterFactory( m_Factory ); \ } \ \ ~CLASS_NAME ## RegistrationMethod() \ { \ /*MITK_INFO("tools") << "UnRegistered " #CLASS_NAME; */ \ itk::ObjectFactoryBase::UnRegisterFactory( m_Factory ); \ } \ \ private: \ \ CLASS_NAME ## Factory::Pointer m_Factory; \ }; \ \ static CLASS_NAME ## RegistrationMethod somestaticinitializer_ ## CLASS_NAME ; #define MITK_EXTERNAL_TOOL_GUI_HEADER_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ extern "C" { \ EXPORT_SPEC itk::ObjectFactoryBase* itkLoad(); \ } #define MITK_EXTERNAL_TOOL_GUI_CPP_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ MITK_TOOL_GUI_MACRO(EXPORT_SPEC, CLASS_NAME, DESCRIPTION) \ extern "C" { \ EXPORT_SPEC itk::ObjectFactoryBase* itkLoad() { \ static CLASS_NAME ## Factory::Pointer p = CLASS_NAME ## Factory::New(); \ return p; \ } \ }