diff --git a/Core/Code/Common/mitkCoreObjectFactory.h b/Core/Code/Common/mitkCoreObjectFactory.h index a2f51f04cc..5183883c4e 100644 --- a/Core/Code/Common/mitkCoreObjectFactory.h +++ b/Core/Code/Common/mitkCoreObjectFactory.h @@ -1,148 +1,148 @@ /*=================================================================== 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 LegacyFileReaderService; class LegacyFileWriterService; class LegacyImageWriterService; 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 void MapEvent(const mitk::Event* event, const int eventID); virtual void RegisterExtraFactory(CoreObjectFactoryBase* factory); virtual void UnRegisterExtraFactory(CoreObjectFactoryBase* factory); static Pointer GetInstance(); ~CoreObjectFactory(); /** * @brief This method gets the supported (open) file extensions as string. * * This string can then used by the Qt QFileDialog widget. * * @return The c-string that contains the file extensions - * @deprecatedSince{2014_03} See mitk::FileReaderRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileReaderRegistry and QmitkIOUtil */ DEPRECATED(virtual const char* GetFileExtensions()); /** * @brief get the defined (open) file extension map * * @return the defined (open) file extension map - * @deprecatedSince{2014_03} See mitk::FileReaderRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileReaderRegistry and QmitkIOUtil */ DEPRECATED(virtual MultimapType GetFileExtensionsMap()); /** * @brief This method gets the supported (save) file extensions as string. * * This string can then used by the Qt QFileDialog widget. * * @return The c-string that contains the (save) file extensions - * @deprecatedSince{2014_03} See mitk::FileWriterRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileWriterRegistry and QmitkIOUtil */ DEPRECATED(virtual const char* GetSaveFileExtensions()); /** * @brief get the defined (save) file extension map * * @return the defined (save) file extension map - * @deprecatedSince{2014_03} See mitk::FileWriterRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileWriterRegistry and QmitkIOUtil */ virtual MultimapType GetSaveFileExtensionsMap(); /** - * @deprecatedSince{2014_03} See mitk::FileWriterRegistry + * @deprecatedSince{2014_10} See mitk::FileWriterRegistry */ DEPRECATED(virtual FileWriterList GetFileWriters()); /** - * @deprecatedSince{2014_03} See mitk::FileWriterRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileWriterRegistry and QmitkIOUtil */ DEPRECATED(std::string GetDescriptionForExtension(const std::string& extension)); protected: CoreObjectFactory(); /** * @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. - * @deprecatedSince{2014_03} + * @deprecatedSince{2014_10} */ void MergeFileExtensions(MultimapType& fileExtensionsMap, MultimapType inputMap); /** * @brief initialize the file extension entries for open and save - * @deprecatedSince{2014_03} + * @deprecatedSince{2014_10} */ void CreateFileExtensionsMap(); /** - * @deprecatedSince{2014_03} + * @deprecatedSince{2014_10} */ DEPRECATED(void CreateSaveFileExtensions()); typedef std::set ExtraFactoriesContainer; ExtraFactoriesContainer m_ExtraFactories; FileWriterList m_FileWriters; std::string m_FileExtensions; MultimapType m_FileExtensionsMap; std::string m_SaveFileExtensions; MultimapType m_SaveFileExtensionsMap; private: void RegisterLegacyReaders(mitk::CoreObjectFactoryBase* factory); void RegisterLegacyWriters(mitk::CoreObjectFactoryBase* factory); void UnRegisterLegacyReaders(mitk::CoreObjectFactoryBase* factory); void UnRegisterLegacyWriters(mitk::CoreObjectFactoryBase* factory); std::map > m_LegacyReaders; std::map > m_LegacyWriters; }; } // namespace mitk #endif diff --git a/Core/Code/Common/mitkCoreObjectFactoryBase.h b/Core/Code/Common/mitkCoreObjectFactoryBase.h index eeede7eb5c..bcf185b487 100644 --- a/Core/Code/Common/mitkCoreObjectFactoryBase.h +++ b/Core/Code/Common/mitkCoreObjectFactoryBase.h @@ -1,107 +1,107 @@ /*=================================================================== 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 COREOBJECTFACTORYBASE_H_INCLUDED #define COREOBJECTFACTORYBASE_H_INCLUDED // the mbilog header is necessary for CMake test drivers. // Since the EXTRA_INCLUDE parameter of CREATE_TEST_SOURCELIST only // allows one extra include file, we specify mitkLog.h here so it will // be available to all classes implementing this interface. #include "mitkLog.h" #include #include "mitkMapper.h" #include #include #include "mitkFileWriterWithInformation.h" namespace mitk { class DataNode; //## @brief base-class for factories of certain mitk objects. //## @ingroup Algorithms //## This interface can be implemented by factories which add new mapper classes or extend the //## data tree deserialization mechanism. class MITK_CORE_EXPORT CoreObjectFactoryBase : public itk::Object { public: typedef std::list FileWriterList; typedef std::multimap MultimapType; mitkClassMacro(CoreObjectFactoryBase,itk::Object) virtual Mapper::Pointer CreateMapper(mitk::DataNode* node, MapperSlotId slotId) = 0; virtual void SetDefaultProperties(mitk::DataNode* node) = 0; /** - * @deprecatedSince{2014_03} See mitk::FileReaderRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileReaderRegistry and QmitkIOUtil */ virtual const char* GetFileExtensions() = 0; /** - * @deprecatedSince{2014_03} See mitk::FileReaderRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileReaderRegistry and QmitkIOUtil */ virtual MultimapType GetFileExtensionsMap() = 0; /** - * @deprecatedSince{2014_03} See mitk::FileWriterRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileWriterRegistry and QmitkIOUtil */ virtual const char* GetSaveFileExtensions() = 0; /** - * @deprecatedSince{2014_03} See mitk::FileWriterRegistry and QmitkIOUtil + * @deprecatedSince{2014_10} See mitk::FileWriterRegistry and QmitkIOUtil */ virtual MultimapType GetSaveFileExtensionsMap() = 0; virtual const char* GetITKSourceVersion() const { return ITK_SOURCE_VERSION; } virtual const char* GetDescription() const { return "Core Object Factory"; } /** - * @deprecatedSince{2014_03} See mitk::FileWriterRegistry + * @deprecatedSince{2014_10} See mitk::FileWriterRegistry */ FileWriterList GetFileWriters() { return m_FileWriters; } protected: /** * @brief create a string from a map that contains the file extensions * @param fileExtensionsMap input map with the file extensions, e.g. ("*.dcm", "DICOM files")("*.dc3", "DICOM files") * @param fileExtensions the converted output string, suitable for the QT QFileDialog widget * e.g. "all (*.dcm *.DCM *.dc3 ... *.vti *.hdr *.nrrd *.nhdr );;Q-Ball Images (*.hqbi *qbi)" * - * @deprecatedSince{2014_03} + * @deprecatedSince{2014_10} */ static void CreateFileExtensions(MultimapType fileExtensionsMap, std::string& fileExtensions); FileWriterList m_FileWriters; friend class CoreObjectFactory; }; } #endif diff --git a/Core/Code/IO/mitkFileReader.h b/Core/Code/IO/mitkFileReader.h index 086f47e62b..762abc3053 100644 --- a/Core/Code/IO/mitkFileReader.h +++ b/Core/Code/IO/mitkFileReader.h @@ -1,107 +1,107 @@ /*=================================================================== 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 FILEREADER_H_HEADER_INCLUDED_C1E7E521 #define FILEREADER_H_HEADER_INCLUDED_C1E7E521 #include namespace mitk { //##Documentation //## @brief Interface class of readers that read from files //## @ingroup Process -//## @deprecatedSince{2014_03} Use mitk::IFileReader instead. +//## @deprecatedSince{2014_10} Use mitk::IFileReader instead. class MITK_CORE_EXPORT FileReader { public: //##Documentation //## @brief Get the specified the file to load. //## //## Either the FileName or FilePrefix plus FilePattern are used to read. virtual const char* GetFileName() const = 0; //##Documentation //## @brief Specify the file to load. //## //## Either the FileName or FilePrefix plus FilePattern are used to read. virtual void SetFileName(const char* aFileName) = 0; //##Documentation //## @brief Get the specified file prefix for the file(s) to load. //## //## You should specify either a FileName or FilePrefix. Use FilePrefix if //## the data is stored in multiple files. virtual const char* GetFilePrefix() const = 0; //##Documentation //## @brief Specify file prefix for the file(s) to load. //## //## You should specify either a FileName or FilePrefix. Use FilePrefix if //## the data is stored in multiple files. virtual void SetFilePrefix(const char* aFilePrefix) = 0; //##Documentation //## @brief Get the specified file pattern for the file(s) to load. The //## sprintf format used to build filename from FilePrefix and number. //## //## You should specify either a FileName or FilePrefix. Use FilePrefix if //## the data is stored in multiple files. virtual const char* GetFilePattern() const = 0; /** @brief Specified file pattern for the file(s) to load. The sprintf format used to build filename from FilePrefix and number. You should specify either a FileName or FilePrefix. Use FilePrefix if the data is stored in multiple files. */ virtual void SetFilePattern(const char* aFilePattern) = 0; /** @brief Specifies, whether the file reader also can read a file from a memory buffer */ virtual bool CanReadFromMemory( ); /** @brief Set/Get functions to advise the file reader to use a memory array for reading a file*/ virtual void SetReadFromMemory( bool read ); virtual bool GetReadFromMemory( ); /** @brief To be used along with a call of SetReadFromMemory(true). This sets the memory buffer and the size from which the reader will read.*/ virtual void SetMemoryBuffer(const char* dataArray, unsigned int size); protected: FileReader(); virtual ~FileReader(); bool m_CanReadFromMemory; bool m_ReadFromMemory; const char* m_MemoryBuffer; unsigned int m_MemorySize; public: protected: }; } // namespace mitk #endif /* FILEREADER_H_HEADER_INCLUDED_C1E7E521 */ diff --git a/Core/Code/IO/mitkFileWriter.h b/Core/Code/IO/mitkFileWriter.h index bf52617b6a..2c00675a04 100644 --- a/Core/Code/IO/mitkFileWriter.h +++ b/Core/Code/IO/mitkFileWriter.h @@ -1,166 +1,166 @@ /*=================================================================== 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 FILEWRITER_H_HEADER_INCLUDED #define FILEWRITER_H_HEADER_INCLUDED #include #include #include namespace mitk { //##Documentation //## @brief Interface class of writers that write data to files //## @ingroup Process -//## @deprecatedSince{2014_03} Use mitk::IFileWriter instead. +//## @deprecatedSince{2014_10} Use mitk::IFileWriter instead. class MITK_CORE_EXPORT FileWriter : public itk::ProcessObject { public: mitkClassMacro(FileWriter,itk::ProcessObject); //##Documentation //## @brief Get the specified the file to write //## //## Either the FileName or FilePrefix plus FilePattern are used to write. virtual const char* GetFileName() const = 0; //##Documentation //## @brief Specify the file to write. //## //## Either the FileName or FilePrefix plus FilePattern are used to write. virtual void SetFileName(const char* aFileName) = 0; //##Documentation //## @brief Get the specified file prefix for the file(s) to write. //## //## You should specify either a FileName or FilePrefix. Use FilePrefix if //## the data is stored in multiple files. virtual const char* GetFilePrefix() const = 0; //##Documentation //## @brief Specify file prefix for the file(s) to write. //## //## You should specify either a FileName or FilePrefix. Use FilePrefix if //## the data is stored in multiple files. virtual void SetFilePrefix(const char* aFilePrefix) = 0; //##Documentation //## @brief Get the specified file pattern for the file(s) to write. The //## sprintf format used to build filename from FilePrefix and number. //## //## You should specify either a FileName or FilePrefix. Use FilePrefix if //## the data is stored in multiple files. virtual const char* GetFilePattern() const = 0; //##Documentation //## @brief Specified file pattern for the file(s) to write. The sprintf //## format used to build filename from FilePrefix and number. //## //## You should specify either a FileName or FilePrefix. Use FilePrefix if //## the data is stored in multiple files. virtual void SetFilePattern(const char* aFilePattern) = 0; //##Documentation //## @brief Return the extension to be added to the filename. virtual std::string GetFileExtension(); //##Documentation //## @brief Checks if given extension is valid for file writer bool IsExtensionValid(std::string extension); //##Documentation //## @brief Return the possible file extensions for the data type associated with the writer virtual std::vector GetPossibleFileExtensions() = 0; //##Documentation //## @brief possible file extensions for the data type associated with the writer as string virtual std::string GetPossibleFileExtensionsAsString(); //##Documentation //## @brief Check if the Writer can write this type of data of the //## DataTreenode. virtual bool CanWriteDataType( DataNode* ); //##Documentation //## @brief Return the MimeType of the saved File. virtual std::string GetWritenMIMEType(); virtual std::string GetSupportedBaseData() const = 0; using ProcessObject::SetInput; void SetInput( BaseData* data ); virtual void Write() = 0; /** @brief Specifies, whether the file writer also can write a file to a memory buffer */ virtual bool CanWriteToMemory( ); /** @brief Set/Get functions to advise the file writer to use tis internal memory array as file writing destination*/ virtual void SetWriteToMemory( bool write ); virtual bool GetWriteToMemory( ); /** @brief To be used along with a call of SetWriteToMemory(true). This returns the memory buffer where the file was written.*/ virtual const char* GetMemoryPointer(); /** @brief To be used along with a call of SetWriteToMemory(true). This returns the size of the memory buffer where the file was written.*/ virtual unsigned int GetMemorySize(); /** @brief CAUTION: It's up to the user to call this function to release the memory buffer after use in case the file writer has written to its memory array.*/ virtual void ReleaseMemory(); protected: FileWriter(); virtual ~FileWriter(); bool m_CanWriteToMemory; bool m_WriteToMemory; char * m_MemoryBuffer; unsigned int m_MemoryBufferSize; }; #define mitkWriterMacro \ virtual void Write() \ { \ if ( this->GetInput() == NULL ) \ { \ itkExceptionMacro(<<"Write:Please specify an input!"); \ return; \ } \ /* Fill in image information.*/ \ this->UpdateOutputInformation(); \ (*(this->GetInputs().begin()))->SetRequestedRegionToLargestPossibleRegion();\ this->PropagateRequestedRegion(NULL); \ this->UpdateOutputData(NULL); \ } \ \ virtual void Update() \ { \ Write(); \ } } // namespace mitk #endif /* FILEWRITER_H_HEADER_INCLUDED */ diff --git a/Core/Code/IO/mitkFileWriterWithInformation.h b/Core/Code/IO/mitkFileWriterWithInformation.h index aad9b965e0..21692b755a 100644 --- a/Core/Code/IO/mitkFileWriterWithInformation.h +++ b/Core/Code/IO/mitkFileWriterWithInformation.h @@ -1,41 +1,41 @@ /*=================================================================== 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 FILEWRITERWITHINFORMATION_H_INCLUDED #define FILEWRITERWITHINFORMATION_H_INCLUDED #include "mitkFileWriter.h" #include "mitkBaseData.h" namespace mitk { /** * \brief Interface for FileWriters with extra information. * Should be merged into FileWriter. * - * \deprecatedSince{2014_03} Use mitk::IFileWriter instead. + * \deprecatedSince{2014_10} Use mitk::IFileWriter instead. */ class FileWriterWithInformation : public FileWriter { public: mitkClassMacro(FileWriterWithInformation,FileWriter); virtual const char *GetDefaultFilename() = 0; virtual const char *GetFileDialogPattern() = 0; virtual const char *GetDefaultExtension() = 0; virtual bool CanWriteBaseDataType(BaseData::Pointer data) = 0; virtual void DoWrite(BaseData::Pointer data) = 0; }; } #endif diff --git a/Core/Code/IO/mitkIOAdapter.h b/Core/Code/IO/mitkIOAdapter.h index 9fc3ea4997..cbc3308696 100644 --- a/Core/Code/IO/mitkIOAdapter.h +++ b/Core/Code/IO/mitkIOAdapter.h @@ -1,95 +1,95 @@ /*=================================================================== 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 __mitkIOAdapter_h #define __mitkIOAdapter_h #include "mitkBaseProcess.h" #include "itkObject.h" namespace mitk { //##Documentation //## @brief IOAdapterBase class is an abstract adapter class for IO process objects. //## //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IFileReader instead +//## @deprecatedSince{2014_10} Use mitk::IFileReader instead class IOAdapterBase: public itk::Object { public: /** Standard typedefs. */ typedef IOAdapterBase Self; typedef itk::Object Superclass; typedef itk::SmartPointerPointer; typedef itk::SmartPointerConstPointer; /// Create an object and return a pointer to it as a mitk::BaseProcess. virtual itk::SmartPointer CreateIOProcessObject(const std::string filename, const std::string filePrefix, const std::string filePattern) = 0; virtual bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern) = 0; protected: IOAdapterBase() {} ~IOAdapterBase() {} private: IOAdapterBase(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; //##Documentation //## @brief IOAdapter class is an adapter class for instantiation of IO process objects. //## Additional this interface defines the function CanReadFile(). //## This interface allows the target (object) the access to the adaptee (IO process object). //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IFileReader instead +//## @deprecatedSince{2014_10} Use mitk::IFileReader instead template class IOAdapter : public IOAdapterBase { public: /** Standard class typedefs. */ typedef IOAdapter Self; typedef itk::SmartPointer Pointer; /** Methods from mitk::BaseProcess. */ itkFactorylessNewMacro(Self); mitk::BaseProcess::Pointer CreateIOProcessObject(const std::string filename, const std::string filePrefix, const std::string filePattern) { typename T::Pointer ioProcessObject = T::New(); ioProcessObject->SetFileName(filename.c_str()); ioProcessObject->SetFilePrefix(filePrefix.c_str()); ioProcessObject->SetFilePattern(filePattern.c_str()); return ioProcessObject.GetPointer(); } virtual bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern) { return T::CanReadFile(filename, filePrefix, filePattern); } protected: IOAdapter() {} ~IOAdapter() {} private: IOAdapter(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Core/Code/IO/mitkIOUtil.h b/Core/Code/IO/mitkIOUtil.h index 6c6c9c75c4..f98b26b532 100644 --- a/Core/Code/IO/mitkIOUtil.h +++ b/Core/Code/IO/mitkIOUtil.h @@ -1,450 +1,450 @@ /*=================================================================== 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 MITKIOUTIL_H #define MITKIOUTIL_H #include #include #include #include #include #include #include #include #include #include namespace mitk { /** * \ingroup IO * * \brief A utility class to load and save data from/to the local file system. * * The methods LoadImage, LoadSurface, and LoadPointSet are convenience methods for general loading of * the three main data types in MITK. They all use the more generic method Load(). * * \see QmitkIOUtil */ class MITK_CORE_EXPORT IOUtil { public: struct MITK_CORE_EXPORT LoadInfo { LoadInfo(const std::string& path); std::string m_Path; std::vector m_Output; FileReaderSelector m_ReaderSelector; bool m_Cancel; }; struct MITK_CORE_EXPORT SaveInfo { SaveInfo(const BaseData* baseData, const MimeType& mimeType, const std::string& path); bool operator<(const SaveInfo& other) const; /// The BaseData object to save. const BaseData* m_BaseData; /// Contains a set of IFileWriter objects. FileWriterSelector m_WriterSelector; /// The selected mime-type, used to restrict results from FileWriterSelector. MimeType m_MimeType; /// The path to write the BaseData object to. std::string m_Path; /// Flag indicating if sub-sequent save operations are to be canceled. bool m_Cancel; }; /** * Get the file system path where the running executable is located. * * @return The location of the currently running executable, without the filename. */ static std::string GetProgramPath(); /** * Get the default temporary path. * * @return The default path for temporary data. */ static std::string GetTempPath(); /** * Returns the Directory Seperator for the current OS. * * @return the Directory Seperator for the current OS, i.e. "\\" for Windows and "/" otherwise. */ static char GetDirectorySeparator(); /** * Create and open a temporary file. * * This method generates a unique temporary filename from \c templateName, creates * and opens the file using the output stream \c tmpStream and returns the name of * the newly create file. * * The \c templateName argument must contain six consective 'X' characters ("XXXXXX") * and these are replaced with a string that makes the filename unique. * * The file is created with read and write permissions for owner only. * * @param tmpStream The output stream for writing to the temporary file. * @param templateName An optional template for the filename. * @param path An optional path where the temporary file should be created. Defaults * to the default temp path as returned by GetTempPath(). * @return The filename of the created temporary file. * * @throw mitk::Exception if the temporary file could not be created. */ static std::string CreateTemporaryFile(std::ofstream& tmpStream, const std::string& templateName = "XXXXXX", std::string path = std::string()); /** * Create and open a temporary file. * * This method generates a unique temporary filename from \c templateName, creates * and opens the file using the output stream \c tmpStream and the specified open * mode \c mode and returns the name of the newly create file. The open mode is always * OR'd with \begin{code}std::ios_base::out | std::ios_base::trunc\end{code}. * * The \c templateName argument must contain six consective 'X' characters ("XXXXXX") * and these are replaced with a string that makes the filename unique. * * The file is created with read and write permissions for owner only. * * @param tmpStream The output stream for writing to the temporary file. * @param mode The open mode for the temporary file stream. * @param templateName An optional template for the filename. * @param path An optional path where the temporary file should be created. Defaults * to the default temp path as returned by GetTempPath(). * @return The filename of the created temporary file. * * @throw mitk::Exception if the temporary file could not be created. */ static std::string CreateTemporaryFile(std::ofstream& tmpStream, std::ios_base::openmode mode, const std::string& templateName = "XXXXXX", std::string path = std::string()); /** * Creates an empty temporary file. * * This method generates a unique temporary filename from \c templateName and creates * this file. * * The file is created with read and write permissions for owner only. * * --- * This version is potentially unsafe because the created temporary file is not kept open * and could be used by another process between calling this method and opening the returned * file path for reading or writing. * --- * * @return The filename of the created temporary file. * @param templateName An optional template for the filename. * @param path An optional path where the temporary file should be created. Defaults * to the default temp path as returned by GetTempPath(). * @throw mitk::Exception if the temporary file could not be created. */ static std::string CreateTemporaryFile(const std::string& templateName = "XXXXXX", std::string path = std::string()); /** * Create a temporary directory. * * This method generates a uniquely named temporary directory from \c templateName. * The last set of six consecutive 'X' characters in \c templateName is replaced * with a string that makes the directory name unique. * * The directory is created with read, write and executable permissions for owner only. * * @param templateName An optional template for the directory name. * @param path An optional path where the temporary directory should be created. Defaults * to the default temp path as returned by GetTempPath(). * @return The filename of the created temporary file. * * @throw mitk::Exception if the temporary directory could not be created. */ static std::string CreateTemporaryDirectory(const std::string& templateName = "XXXXXX", std::string path = std::string()); /** * @brief Load a file into the given DataStorage. * * This method calls Load(const std::vector&, DataStorage&) with a * one-element vector. * * @param path The absolute file name including the file extension. * @param storage A DataStorage object to which the loaded data will be added. * @return The set of added DataNode objects. * @throws mitk::Exception if \c path could not be loaded. * * @sa Load(const std::vector&, DataStorage&) */ static DataStorage::SetOfObjects::Pointer Load(const std::string& path, DataStorage& storage); static DataStorage::SetOfObjects::Pointer Load(const std::string& path, const IFileReader::Options& options, DataStorage& storage); static std::vector Load(const std::string& path); static std::vector Load(const std::string& path, const IFileReader::Options& options); /** * @brief Loads a list of file paths into the given DataStorage. * * If an entry in \c paths cannot be loaded, this method will continue to load * the remaining entries into \c storage and throw an exception afterwards. * * @param paths A list of absolute file names including the file extension. * @param storage A DataStorage object to which the loaded data will be added. * @return The set of added DataNode objects. * @throws mitk::Exception if an entry in \c paths could not be loaded. */ static DataStorage::SetOfObjects::Pointer Load(const std::vector& paths, DataStorage& storage); static std::vector Load(const std::vector& paths); /** * Load files in fileNames and add the constructed mitk::DataNode instances * to the mitk::DataStorage storage * * @param fileNames A list (vector) of absolute file name paths. * @param storage The data storage to which the constructed data nodes are added. * @return The number of added mitk::DataNode instances. * - * @deprecatedSince{2014_03} Use Load() instead + * @deprecatedSince{2014_10} Use Load() instead */ DEPRECATED(static int LoadFiles(const std::vector&fileNames, DataStorage& storage)); /** * This method will create a new mitk::DataStorage instance and pass it to * LoadFiles(std::vector,DataStorage). * * @param fileNames A list (vector) of absolute file name paths. * @return The new mitk::DataStorage containing the constructed data nodes. * * @see LoadFiles(std::vector,DataStorage) * - * @deprecatedSince{2014_03} Use Load() instead + * @deprecatedSince{2014_10} Use Load() instead */ DEPRECATED(static DataStorage::Pointer LoadFiles(const std::vector& fileNames)); /** * @brief Create a BaseData object from the given file. * @param path The path to the file including file name and file extension. * @throws mitk::Exception In case of an error when reading the file. * @return Returns the created BaseData object. * - * @deprecatedSince{2014_03} Use Load() or FileReaderRegistry::Read() instead. + * @deprecatedSince{2014_10} Use Load() or FileReaderRegistry::Read() instead. */ DEPRECATED(static mitk::BaseData::Pointer LoadBaseData(const std::string& path)); /** * @brief LoadDataNode Method to load an arbitrary DataNode. * @param path The path to the file including file name and file extension. * @throws mitk::Exception This exception is thrown when the DataNodeFactory is not able to read/find the file * or the DataNode is NULL. * @return Returns the DataNode. * - * @deprecatedSince{2014_03} Use Load() instead. + * @deprecatedSince{2014_10} Use Load() instead. */ DEPRECATED(static mitk::DataNode::Pointer LoadDataNode(const std::string& path)); /** * @brief LoadImage Convenience method to load an arbitrary mitkImage. * @param path The path to the image including file name and file extension. * @throws mitk::Exception This exception is thrown when the Image is NULL. * @return Returns the mitkImage. */ static mitk::Image::Pointer LoadImage(const std::string& path); /** * @brief LoadSurface Convenience method to load an arbitrary mitkSurface. * @param path The path to the surface including file name and file extension. * @throws mitk::Exception This exception is thrown when the Surface is NULL. * @return Returns the mitkSurface. */ static mitk::Surface::Pointer LoadSurface(const std::string& path); /** * @brief LoadPointSet Convenience method to load an arbitrary mitkPointSet. * @param path The path to the pointset including file name and file extension (currently, only .mps is supported). * @throws mitk::Exception This exception is thrown when the PointSet is NULL. * @return Returns the mitkPointSet. */ static mitk::PointSet::Pointer LoadPointSet(const std::string& path); /** * @brief Save a mitk::BaseData instance. * @param data The data to save. * @param path The path to the image including file name and and optional file extension. * If no extension is set, the default extension and mime-type for the * BaseData type of \c data is used. * @throws mitk::Exception if no writer for \c data is available or the writer * is not able to write the image. */ static void Save(const mitk::BaseData* data, const std::string& path); /** * @brief Save a mitk::BaseData instance. * @param data The data to save. * @param path The path to the image including file name and an optional file extension. * If no extension is set, the default extension and mime-type for the * BaseData type of \c data is used. * @param options The IFileWriter options to use for the selected writer. * @throws mitk::Exception if no writer for \c data is available or the writer * is not able to write the image. */ static void Save(const mitk::BaseData* data, const std::string& path, const IFileWriter::Options& options); /** * @brief Save a mitk::BaseData instance. * @param data The data to save. * @param mimeType The mime-type to use for writing \c data. * @param path The path to the image including file name and an optional file extension. * @param addExtension If \c true, an extension according to the given \c mimeType * is added to \c path if it does not contain one. If \c path already contains * a file name extension, it is not checked for compatibility with \c mimeType. * * @throws mitk::Exception if no writer for the combination of \c data and \c mimeType is * available or the writer is not able to write the image. */ static void Save(const mitk::BaseData* data, const std::string& mimeType, const std::string& path, bool addExtension = true); /** * @brief Save a mitk::BaseData instance. * @param data The data to save. * @param mimeType The mime-type to use for writing \c data. * @param path The path to the image including file name and an optional file extension. * @param options Configuration data for the used IFileWriter instance. * @param addExtension If \c true, an extension according to the given \c mimeType * is added to \c path if it does not contain one. If \c path already contains * a file name extension, it is not checked for compatibility with \c mimeType. * * @throws mitk::Exception if no writer for the combination of \c data and \c mimeType is * available or the writer is not able to write the image. */ static void Save(const mitk::BaseData* data, const std::string& mimeType, const std::string& path, const mitk::IFileWriter::Options& options, bool addExtension = true); /** * @brief Use SaveInfo objects to save BaseData instances. * * This is a low-level method for directly working with SaveInfo objects. Usually, * the Save() methods taking a BaseData object as an argument are more appropriate. * * @param saveInfos A list of SaveInfo objects for saving contained BaseData objects. * * @see Save(const mitk::BaseData*, const std::string&) */ static void Save(std::vector& saveInfos); /** * @brief SaveImage Convenience method to save an arbitrary mitkImage. * @param path The path to the image including file name and file extension. * If no extention is set, the default value (defined in DEFAULTIMAGEEXTENSION) is used. * @param image The image to save. * @throws mitk::Exception This exception is thrown when the writer is not able to write the image. * @return Returns true for success else false. * - * @deprecatedSince{2014_03} Use Save() instead. + * @deprecatedSince{2014_10} Use Save() instead. */ DEPRECATED(static bool SaveImage(mitk::Image::Pointer image, const std::string& path)); /** * @brief SaveBaseData Convenience method to save arbitrary baseData. * @param path The path to the image including file name and file extension. * If no extention is set, the default extension is used. * @param data The data to save. * @throws mitk::Exception This exception is thrown when the writer is not able to write the image. * @return Returns true for success else false. * - * @deprecatedSince{2014_03} Use Save() instead. + * @deprecatedSince{2014_10} Use Save() instead. */ DEPRECATED(static bool SaveBaseData(mitk::BaseData* data, const std::string& path)); /** * @brief SaveSurface Convenience method to save an arbitrary mitkSurface. * @param path The path to the surface including file name and file extension. * If no extention is set, the default extension is used. * @throws mitk::Exception This exception is thrown when the writer is not able to write the surface. * or if the fileextension is not suitable for writing. * @return Returns true for success else false. * - * @deprecatedSince{2014_03} Use Save() instead. + * @deprecatedSince{2014_10} Use Save() instead. */ DEPRECATED(static bool SaveSurface(mitk::Surface::Pointer surface, const std::string& path)); /** * @brief SavePointSet Convenience method to save an mitkPointSet. * @param path The path to the pointset including file name and file extension. * If no extention is set, the default extension is used. * @throws mitk::Exception This exception is thrown when the writer is not able to write the pointset. * @return Returns true for success else false. * - * @deprecatedSince{2014_03} Use Save() instead. + * @deprecatedSince{2014_10} Use Save() instead. */ DEPRECATED(static bool SavePointSet(mitk::PointSet::Pointer pointset, const std::string& path)); - /** @deprecatedSince{2014_03} Use GetDefaultWriteExtension() instead */ + /** @deprecatedSince{2014_10} */ DEPRECATED(static const std::string DEFAULTIMAGEEXTENSION); - /** @deprecatedSince{2014_03} Use GetDefaultWriteExtension() instead */ + /** @deprecatedSince{2014_10} */ DEPRECATED(static const std::string DEFAULTSURFACEEXTENSION); - /** @deprecatedSince{2014_03} Use GetDefaultWriteExtension() instead */ + /** @deprecatedSince{2014_10} */ DEPRECATED(static const std::string DEFAULTPOINTSETEXTENSION); protected: struct ReaderOptionsFunctorBase { virtual bool operator()(LoadInfo& loadInfo) = 0; }; struct WriterOptionsFunctorBase { virtual bool operator()(SaveInfo& saveInfo) = 0; }; static std::string Load(std::vector& loadInfos, DataStorage::SetOfObjects* nodeResult, DataStorage* ds, ReaderOptionsFunctorBase* optionsCallback); static std::string Save(const BaseData* data, const std::string& mimeType, const std::string& path, WriterOptionsFunctorBase* optionsCallback, bool addExtension); static std::string Save(std::vector& saveInfos, WriterOptionsFunctorBase* optionsCallback); private: struct Impl; }; } #endif // MITKIOUTIL_H diff --git a/Core/Code/Interfaces/mitkIDataNodeReader.h b/Core/Code/Interfaces/mitkIDataNodeReader.h index dc46c0fc5c..badabdefae 100644 --- a/Core/Code/Interfaces/mitkIDataNodeReader.h +++ b/Core/Code/Interfaces/mitkIDataNodeReader.h @@ -1,60 +1,60 @@ /*=================================================================== 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 MITKIDATANODEREADER_H #define MITKIDATANODEREADER_H #include #include namespace mitk { class DataStorage; /** * \ingroup MicroServices_Interfaces * * This interface provides methods to load data from the local filesystem * into a given mitk::DataStorage. * - * \deprecatedSince{2014_03} Use mitk::IFileReader instead + * \deprecatedSince{2014_10} Use mitk::IFileReader instead */ struct IDataNodeReader { virtual ~IDataNodeReader() {} /** * Reads the local file given by fileName and constructs one or more * mitk::DataNode instances which are added to the given mitk::DataStorage storage. * * \param fileName The absolute path to a local file. * \param storage The mitk::DataStorage which will contain the constructed data nodes. * \return The number of constructed mitk::DataNode instances. * * \note Errors during reading the file or constructing the data node should be expressed by * throwing appropriate exceptions. * * \see mitk::DataNodeFactory */ virtual int Read(const std::string& fileName, mitk::DataStorage& storage) = 0; }; } MITK_DECLARE_SERVICE_INTERFACE(mitk::IDataNodeReader, "org.mitk.IDataNodeReader") #endif // MITKIDATANODEREADER_H diff --git a/Modules/IOExt/Internal/mitkIOExtObjectFactory.cpp b/Modules/IOExt/Internal/mitkIOExtObjectFactory.cpp index 286d7718f2..0470850d4e 100644 --- a/Modules/IOExt/Internal/mitkIOExtObjectFactory.cpp +++ b/Modules/IOExt/Internal/mitkIOExtObjectFactory.cpp @@ -1,195 +1,196 @@ /*=================================================================== 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 "mitkIOExtObjectFactory.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 "mitkMeshMapper2D.h" #include "mitkMeshVtkMapper3D.h" #include "mitkMesh.h" #include "mitkGPUVolumeMapper3D.h" #include "mitkUnstructuredGridMapper2D.h" #include "mitkUnstructuredGridVtkMapper3D.h" #include #include #include mitk::IOExtObjectFactory::IOExtObjectFactory() : 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 << "IOExtObjectFactory c'tor" << std::endl; 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 ); 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::IOExtObjectFactory::~IOExtObjectFactory() { 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::IOExtObjectFactory::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::IOExtObjectFactory::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::IOExtObjectFactory::GetFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_FileExtensionsMap, fileExtension); return fileExtension.c_str(); } mitk::CoreObjectFactoryBase::MultimapType mitk::IOExtObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } mitk::CoreObjectFactoryBase::MultimapType mitk::IOExtObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::IOExtObjectFactory::CreateFileExtensionsMap() { 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_FileExtensionsMap.insert(std::pair("*.obj", "Surfaces")); 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::IOExtObjectFactory::GetSaveFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); } struct RegisterIOExtObjectFactory { RegisterIOExtObjectFactory() : m_Factory( mitk::IOExtObjectFactory::New() ) { mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory( m_Factory ); } ~RegisterIOExtObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory( m_Factory ); } mitk::IOExtObjectFactory::Pointer m_Factory; }; static RegisterIOExtObjectFactory registerIOExtObjectFactory; diff --git a/Modules/LegacyIO/mitkBaseDataIOFactory.h b/Modules/LegacyIO/mitkBaseDataIOFactory.h index f19adff768..022a996077 100644 --- a/Modules/LegacyIO/mitkBaseDataIOFactory.h +++ b/Modules/LegacyIO/mitkBaseDataIOFactory.h @@ -1,67 +1,67 @@ /*=================================================================== 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 __mitkBaseDataIO_h #define __mitkBaseDataIO_h #include #include "mitkBaseData.h" #include "itkObject.h" namespace mitk { /*! @brief BaseDataIO creates instances of BaseData objects using an object factory. @todo Add file writing method, move writers into a similar factory scheme @ingroup IO - @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ class DEPRECATED() MitkLegacyIO_EXPORT BaseDataIO : public itk::Object { public: /** Standard class typedefs. */ typedef BaseDataIO Self; typedef itk::Object Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; /** Class Methods used to interface with the registered factories */ /** Run-time type information (and related methods). */ itkTypeMacro(BaseDataIO, Object); /** Create the appropriate BaseData depending on the particulars of the file. */ static std::vector LoadBaseDataFromFile(const std::string path, const std::string filePrefix, const std::string filePattern, bool series); protected: BaseDataIO(); ~BaseDataIO(); private: BaseDataIO(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; } // end namespace mitk #endif diff --git a/Modules/LegacyIO/mitkDataNodeFactory.h b/Modules/LegacyIO/mitkDataNodeFactory.h index 28378ac97c..17ddbca49b 100644 --- a/Modules/LegacyIO/mitkDataNodeFactory.h +++ b/Modules/LegacyIO/mitkDataNodeFactory.h @@ -1,184 +1,184 @@ /*=================================================================== 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 _DATA_TREE_NODE_FACTORY_H_ #define _DATA_TREE_NODE_FACTORY_H_ #include "mitkDataNodeSource.h" #include "mitkFileSeriesReader.h" #include "mitkColorProperty.h" #include #include namespace mitk { /** * @brief Factory, which creates instances of mitk::DataNodes filled with * data read from a given file * * This class reads files, creates an appropriate mitk::BaseData and adds the * BaseData to a mitk::DataNode. This filter may produce one or more outputs * (i.e. mitk::DataNodes). The number of generated nodes can be retrieved by a * call of GetNumberOfOutputs(). * * If you want to add a new file type, you have to register the factory * of the file reader in the class mitk::BaseDataIOFactory. * @ingroup IO -* @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +* @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ class MitkLegacyIO_EXPORT DataNodeFactory : public DataNodeSource, public FileSeriesReader { public: mitkClassMacro( DataNodeFactory, DataNodeSource ); DEPRECATED(itkFactorylessNewMacro(Self)) itkCloneMacro(Self) /** * Sets the filename of the file to read. * @param FileName the name of the file to read. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be read from disk. */ itkGetStringMacro( FileName ); /** * \brief Set prefix for multiple load */ itkSetStringMacro( FilePrefix ); /** * \brief Get prefix for multiple load */ itkGetStringMacro( FilePrefix ); /** * \brief Set pattern for multiple load */ itkSetStringMacro( FilePattern ); /** * \brief Get pattern for multiple load */ itkGetStringMacro( FilePattern ); /** * Nice default colors for segmentations of some "normal" organs. */ static ColorProperty::Pointer DefaultColorForOrgan( const std::string& ); void SetDefaultCommonProperties(mitk::DataNode::Pointer &node); /** * if true -> loaded image is part of a serie */ void SetImageSerie(bool serie); void AddSeriesRestriction(const std::string &tag) {m_SeriesRestrictions.push_back(tag);} static bool m_TextureInterpolationActive; protected: /** * Constructor. */ DataNodeFactory(); /** * Virtual destructor. */ virtual ~DataNodeFactory(); bool m_Serie; /** * Determines of which file type a given file is and calls the * appropriate reader function. */ virtual void GenerateData(); /** * Resizes the number of outputs of the factory. * The outputs are initialized by empty DataNodes * @param num the new number of outputs */ virtual void ResizeOutputs( const unsigned int& num ); /** * Checks if the file name m_FileName ends with the given name. * Currently, this check is done by a dumb search for name in * the filename. * @param name the extension of the file * @returns true, if the filename contains name. */ virtual bool FileNameEndsWith(const std::string& name); /** * Checks if the file pattern m_FilePattern ends with the given name. * Currently, this check is done by a dumb search for name in * the filename. * @param name the extension of the file * @returns true, if the filepattern contains name. */ virtual bool FilePatternEndsWith(const std::string& name); /** * @returns the plain filename, that is, without any directory. */ virtual std::string GetBaseFileName(); /** * @returns the plain file prefix, that is, without any directory. */ virtual std::string GetBaseFilePrefix(); /** * @returns the directory of the file name m_FileName. */ virtual std::string GetDirectory(); #ifdef MBI_INTERNAL virtual void ReadFileTypeHPSONOS(); #ifdef HAVE_IPDICOM virtual void ReadFileTypeIPDCM(); #endif /* HAVE_IPDICOM */ #ifdef USE_TUS_READER virtual void ReadFileTypeTUS(); #endif #endif /* MBI_INTERNAL */ virtual void ReadFileSeriesTypeDCM(); virtual void ReadFileSeriesTypeITKImageSeriesReader(); std::vector m_SeriesRestrictions; int m_OldProgress; }; } #endif //#ifndef __DATA_TREE_NODE_FACTORY_H diff --git a/Modules/LegacyIO/mitkFileSeriesReader.h b/Modules/LegacyIO/mitkFileSeriesReader.h index 1314517eb2..d17eea6671 100644 --- a/Modules/LegacyIO/mitkFileSeriesReader.h +++ b/Modules/LegacyIO/mitkFileSeriesReader.h @@ -1,65 +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 __MITK_FILE_SERIES_READER__H_ #define __MITK_FILE_SERIES_READER__H_ #include #include #include #include #include namespace mitk { /** * Provides a function which generates a list of files from * a given prefix and pattern. * Subclasses may use this function to load a series of files. * - * @deprecatedSince{2014_03} + * @deprecatedSince{2014_10} */ class MitkLegacyIO_EXPORT FileSeriesReader : public FileReader { public: mitkClassMacro( FileSeriesReader, FileReader ); typedef std::vector< std::string > MatchedFileNames; virtual MatchedFileNames GetMatchedFileNames( ); protected: FileSeriesReader(); virtual ~FileSeriesReader(); virtual bool GenerateFileList(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; MatchedFileNames m_MatchedFileNames; }; } #endif diff --git a/Modules/LegacyIO/mitkImageWriter.h b/Modules/LegacyIO/mitkImageWriter.h index 7bc22220f6..67ed3792d1 100644 --- a/Modules/LegacyIO/mitkImageWriter.h +++ b/Modules/LegacyIO/mitkImageWriter.h @@ -1,179 +1,179 @@ /*=================================================================== 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_IMAGE_WRITER__H_ #define _MITK_IMAGE_WRITER__H_ #include #include namespace mitk { class Image; /** * @brief Writer for mitk::Image * * Uses the given extension (SetExtension) to decide the format to write * (.mhd is default, .pic, .tif, .png, .jpg supported yet). * @ingroup IO - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileWriterRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileWriterRegistry instead. */ class MitkLegacyIO_EXPORT ImageWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( ImageWriter, mitk::FileWriter ); itkFactorylessNewMacro(Self) itkCloneMacro(Self) mitkWriterMacro; /** * Sets the filename of the file to write. * @param _arg the name of the file to write. */ virtual void SetFileName (const char* fileName); virtual void SetFileName (const std::string& fileName); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * \brief Explicitly set the extension to be added to the filename. * @param _arg to be added to the filename, including a "." * (e.g., ".mhd"). */ virtual void SetExtension (const char* extension); virtual void SetExtension (const std::string& extension); /** * \brief Get the extension to be added to the filename. * @returns the extension to be added to the filename (e.g., * ".mhd"). */ itkGetStringMacro( Extension ); /** * \brief Set the extension to be added to the filename to the default */ void SetDefaultExtension(); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the 0'th input object for the filter. * @param input the first input for the filter. */ void SetInput( mitk::Image* input ); //##Documentation //## @brief Return the possible file extensions for the data type associated with the writer virtual std::vector GetPossibleFileExtensions(); virtual std::string GetSupportedBaseData() const; /** * @brief Return the extension to be added to the filename. */ virtual std::string GetFileExtension(); /** * @brief Check if the Writer can write the Content of the */ virtual bool CanWriteDataType( DataNode* ); /** * @brief Return the MimeType of the saved File. */ virtual std::string GetWritenMIMEType(); using Superclass::SetInput; /** * @brief Set the DataTreenode as Input. Important: The Writer always have a SetInput-Function. */ virtual void SetInput( DataNode* ); /** * @returns the 0'th input object of the filter. */ const mitk::Image* GetInput(); // FileWriterWithInformation methods virtual const char* GetDefaultFilename(); virtual const char *GetFileDialogPattern(); virtual const char *GetDefaultExtension(); virtual bool CanWriteBaseDataType(BaseData::Pointer data); virtual void DoWrite(BaseData::Pointer data); void SetUseCompression( bool useCompression ); protected: /** * Constructor. */ ImageWriter(); /** * Virtual destructor. */ virtual ~ImageWriter(); virtual void GenerateData(); virtual void WriteByITK(mitk::Image* image, const std::string& fileName); std::string m_FileName; std::string m_FileNameWithoutExtension; std::string m_FilePrefix; std::string m_FilePattern; std::string m_Extension; std::string m_MimeType; bool m_UseCompression; }; } #endif //_MITK_IMAGE_WRITER__H_ diff --git a/Modules/LegacyIO/mitkImageWriterFactory.h b/Modules/LegacyIO/mitkImageWriterFactory.h index 0a6a2d6fe1..0d7e707aea 100644 --- a/Modules/LegacyIO/mitkImageWriterFactory.h +++ b/Modules/LegacyIO/mitkImageWriterFactory.h @@ -1,71 +1,71 @@ /*=================================================================== 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 #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { /** - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ class DEPRECATED() MitkLegacyIO_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 * \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/Modules/LegacyIO/mitkItkImageFileIOFactory.h b/Modules/LegacyIO/mitkItkImageFileIOFactory.h index 90bad267ab..4ab4b0b0b7 100644 --- a/Modules/LegacyIO/mitkItkImageFileIOFactory.h +++ b/Modules/LegacyIO/mitkItkImageFileIOFactory.h @@ -1,77 +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 __mitkItkImageFileIOFactory_h #define __mitkItkImageFileIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of ItkImageFileReader objects using an object factory. //## //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_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 * \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/Modules/LegacyIO/mitkItkImageFileReader.h b/Modules/LegacyIO/mitkItkImageFileReader.h index d7c2b807ea..d2d11b2c37 100644 --- a/Modules/LegacyIO/mitkItkImageFileReader.h +++ b/Modules/LegacyIO/mitkItkImageFileReader.h @@ -1,68 +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 ItkImageFileReader_H_HEADER_INCLUDED #define ItkImageFileReader_H_HEADER_INCLUDED #include #include "mitkFileReader.h" #include "mitkImageSource.h" namespace mitk { //##Documentation //## @brief Reader to read file formats supported by itk //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class MitkLegacyIO_EXPORT ItkImageFileReader : public ImageSource, public FileReader { public: mitkClassMacro(ItkImageFileReader, FileReader); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkSetStringMacro(FileName); itkGetStringMacro(FileName); itkSetStringMacro(FilePrefix); itkGetStringMacro(FilePrefix); itkSetStringMacro(FilePattern); itkGetStringMacro(FilePattern); static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); protected: virtual void GenerateData(); ItkImageFileReader(); ~ItkImageFileReader(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; }; } // namespace mitk #endif /* ItkImageFileReader_H_HEADER_INCLUDED */ diff --git a/Modules/LegacyIO/mitkItkPictureWrite.h b/Modules/LegacyIO/mitkItkPictureWrite.h index 5e1db9fb0c..80abc67ca6 100644 --- a/Modules/LegacyIO/mitkItkPictureWrite.h +++ b/Modules/LegacyIO/mitkItkPictureWrite.h @@ -1,45 +1,45 @@ /*=================================================================== 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. ===================================================================*/ /** @file mitkItkPictureWrite.h */ #ifndef MITKITKPICTUREWRITE_H #define MITKITKPICTUREWRITE_H #include #include /** * @brief ITK-Like method to be called for writing an single-component image using the AccessByItk Macros * * @param itkImage an image with single-component pixel type * - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ template < typename TPixel, unsigned int VImageDimension > DEPRECATED( void _mitkItkPictureWrite(itk::Image< TPixel, VImageDimension >* itkImage, const std::string& fileName) ); /** * @brief ITK-Like method to be called for writing an image * * @param itkImage an Image with single-component or composite pixel type * - * @deprecatedSince{2013_09} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ template < typename TPixel, unsigned int VImageDimension > DEPRECATED( void _mitkItkPictureWriteComposite(itk::Image< TPixel, VImageDimension >* itkImage, const std::string& fileName) ); #endif /* MITKITKPICTUREWRITE_H */ diff --git a/Modules/LegacyIO/mitkPointSetIOFactory.h b/Modules/LegacyIO/mitkPointSetIOFactory.h index c0e93db7ab..76bfeac9cb 100644 --- a/Modules/LegacyIO/mitkPointSetIOFactory.h +++ b/Modules/LegacyIO/mitkPointSetIOFactory.h @@ -1,77 +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 __mitkPointSetIOFactory_h #define __mitkPointSetIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of PointSetReader objects using an object factory. //## //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_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 * \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/Modules/LegacyIO/mitkPointSetReader.h b/Modules/LegacyIO/mitkPointSetReader.h index cb898af3ba..efc090ee51 100644 --- a/Modules/LegacyIO/mitkPointSetReader.h +++ b/Modules/LegacyIO/mitkPointSetReader.h @@ -1,149 +1,149 @@ /*=================================================================== 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_POINT_SET_READER__H_ #define _MITK_POINT_SET_READER__H_ #include #include #include #include #include #include #include namespace mitk { /** * @brief reads xml representations of mitk::PointSets from a file * * Reader for xml files containing one or multiple xml represenations of * mitk::PointSets. If multiple mitk::PointSets are stored in one file, * these are assigned to multiple outputs of the filter. The number of point * sets which have be read can be retrieven by a call to GetNumberOfOutputs() * after the pipeline update(). * The reader is able to read the old 3D Pointsets without the "specification" and "timeseries" tags and the new 4D Pointsets. * @note loading point sets from multiple files according to a given file pattern * is not yet supported! * @ingroup PSIO * @ingroup IO * - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ class MitkLegacyIO_EXPORT PointSetReader: public PointSetSource, public FileReader { public: mitkClassMacro( PointSetReader, FileReader ); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /** * @brief Sets the filename of the file to be read * @param _arg the filename of the point set xml-file */ itkSetStringMacro( FileName ); /** * @brief Returns the filename of the point set xml-file. * @returns the filename of the point set xml-file. */ itkGetStringMacro( FileName ); /** * @warning multiple load not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple load not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple load not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple load not (yet) supported */ itkGetStringMacro( FilePattern ); static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); /** * @returns whether the last read attempt was successful or not. */ bool GetSuccess() const; protected: /** * Constructor */ PointSetReader(); /** * Virtual destructor */ virtual ~PointSetReader(); /** * Actually reads the point sets from the given file */ virtual void GenerateData(); virtual mitk::PointSet::Pointer ReadPoint(mitk::PointSet::Pointer newPointSet, TiXmlElement* currentTimeSeries, unsigned int currentTimeStep); /** * Does nothing in the current implementation */ virtual void GenerateOutputInformation(); /** * Resizes the output-objects according to the given number. * @param num the new number of output objects. */ virtual void ResizeOutputs( const unsigned int& num ); /** * Checks if the given file has appropriate * read access. * @returns true if the file exists and may be read * or false otherwise. */ virtual int CanReadFile (const char *name); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } #endif diff --git a/Modules/LegacyIO/mitkPointSetWriter.h b/Modules/LegacyIO/mitkPointSetWriter.h index 35348e20a0..c0c493061e 100644 --- a/Modules/LegacyIO/mitkPointSetWriter.h +++ b/Modules/LegacyIO/mitkPointSetWriter.h @@ -1,273 +1,273 @@ /*=================================================================== 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_POINT_SET_WRITER__H_ #define _MITK_POINT_SET_WRITER__H_ #include #include #include #include namespace mitk { /** * @brief XML-based writer for mitk::PointSets * * XML-based writer for mitk::PointSets. Multiple PointSets can be written in * a single XML file by simply setting multiple inputs to the filter. * Writing of multiple XML files according to a given filename pattern is not * yet supported. * @ingroup PSIO * @ingroup Process * - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ class MitkLegacyIO_EXPORT PointSetWriter : public mitk::FileWriter { public: mitkClassMacro( PointSetWriter, mitk::FileWriter ); mitkWriterMacro; itkFactorylessNewMacro(Self) itkCloneMacro(Self) typedef mitk::PointSet InputType; typedef InputType::Pointer InputTypePointer; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the 0'th input object for the filter. * @param input the first input for the filter. */ void SetInput( InputType* input ); /** * Sets the n'th input object for the filter. If num is * larger than GetNumberOfInputs() the number of inputs is * resized appropriately. * @param input the n'th input for the filter. */ void SetInput( const unsigned int& num, InputType* input); /** * @returns the 0'th input object of the filter. */ PointSet* GetInput(); /** * @param num the index of the desired output object. * @returns the n'th input object of the filter. */ PointSet* GetInput( const unsigned int& num ); /** * @brief Return the possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); virtual std::string GetSupportedBaseData() const; /** * @brief Return the extension to be added to the filename. */ virtual std::string GetFileExtension(); /** * @brief Check if the Writer can write the Content of the */ virtual bool CanWriteDataType( DataNode* ); /** * @brief Return the MimeType of the saved File. */ virtual std::string GetWritenMIMEType(); using mitk::FileWriter::SetInput; /** * @brief Set the DataTreenode as Input. Important: The Writer always have a SetInput-Function. */ virtual void SetInput( DataNode* ); /** * @returns whether the last write attempt was successful or not. */ bool GetSuccess() const; protected: /** * Constructor. */ PointSetWriter(); /** * Virtual destructor. */ virtual ~PointSetWriter(); /** * Writes the XML file */ virtual void GenerateData(); /** * Resizes the number of inputs of the writer. * The inputs are initialized by empty PointSets * @param num the new number of inputs */ virtual void ResizeInputs( const unsigned int& num ); /** * Converts an arbitrary type to a string. The type has to * support the << operator. This works fine at least for integral * data types as float, int, long etc. * @param value the value to convert * @returns the string representation of value */ template < typename T> std::string ConvertToString( T value ); /** * Writes an XML representation of the given point set to * an outstream. The XML-Header an root node is not included! * @param pointSet the point set to be converted to xml * @param out the stream to write to. */ void WriteXML( mitk::PointSet* pointSet, std::ofstream& out ); /** * Writes an standard xml header to the given stream. * @param file the stream in which the header is written. */ void WriteXMLHeader( std::ofstream &file ); /** Write a start element tag */ void WriteStartElement( const char *const tag, std::ofstream &file ); /** * Write an end element tag * End-Elements following character data should pass indent = false. */ void WriteEndElement( const char *const tag, std::ofstream &file, const bool& indent = true ); /** Write character data inside a tag. */ void WriteCharacterData( const char *const data, std::ofstream &file ); /** Write a start element tag */ void WriteStartElement( std::string &tag, std::ofstream &file ); /** Write an end element tag */ void WriteEndElement( std::string &tag, std::ofstream &file, const bool& indent = true ); /** Write character data inside a tag. */ void WriteCharacterData( std::string &data, std::ofstream &file ); /** Writes empty spaces to the stream according to m_IndentDepth and m_Indent */ void WriteIndent( std::ofstream& file ); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; std::string m_Extension; std::string m_MimeType; unsigned int m_IndentDepth; unsigned int m_Indent; bool m_Success; public: static const char* XML_POINT_SET; static const char* XML_TIME_SERIES; static const char* XML_TIME_SERIES_ID; static const char* XML_POINT_SET_FILE; static const char* XML_FILE_VERSION; static const char* XML_POINT; static const char* XML_SPEC; static const char* XML_ID; static const char* XML_X; static const char* XML_Y; static const char* XML_Z; static const char* VERSION_STRING; }; } #endif diff --git a/Modules/LegacyIO/mitkPointSetWriterFactory.h b/Modules/LegacyIO/mitkPointSetWriterFactory.h index d1da7d0399..8415518e7d 100644 --- a/Modules/LegacyIO/mitkPointSetWriterFactory.h +++ b/Modules/LegacyIO/mitkPointSetWriterFactory.h @@ -1,71 +1,71 @@ /*=================================================================== 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 #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { /** - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ class DEPRECATED() MitkLegacyIO_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 * \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/Modules/LegacyIO/mitkRawImageFileReader.h b/Modules/LegacyIO/mitkRawImageFileReader.h index d47f721010..388188ca50 100644 --- a/Modules/LegacyIO/mitkRawImageFileReader.h +++ b/Modules/LegacyIO/mitkRawImageFileReader.h @@ -1,110 +1,110 @@ /*=================================================================== 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 RawImageFileReader_H_HEADER_INCLUDED #define RawImageFileReader_H_HEADER_INCLUDED #include "itkVector.h" #include #include "mitkFileReader.h" #include "mitkImageSource.h" namespace mitk { //##Documentation //## @brief Reader to read raw image files /** The user must set the dimensionality, the dimensions and the pixel type. If they are incorrect, the image will not be opened or the visualization will be incorrect. */ //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_EXPORT RawImageFileReader : public ImageSource, public FileReader { public: mitkClassMacro(RawImageFileReader, FileReader); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkSetMacro(FileName, std::string); itkSetStringMacro(FileName); itkGetMacro(FileName, std::string); itkGetStringMacro(FileName); itkSetMacro(FilePrefix, std::string); itkSetStringMacro(FilePrefix); itkGetMacro(FilePrefix, std::string); itkGetStringMacro(FilePrefix); itkSetMacro(FilePattern, std::string); itkSetStringMacro(FilePattern); itkGetMacro(FilePattern, std::string); itkGetStringMacro(FilePattern); /** Supported pixel types. */ typedef enum {UCHAR,SCHAR,USHORT,SSHORT, UINT, SINT, FLOAT, DOUBLE} IOPixelType; itkSetMacro(PixelType, IOPixelType); /** Endianity of bits. */ typedef enum {LITTLE, BIG} EndianityType; itkSetMacro(Endianity, EndianityType); itkSetMacro(Dimensionality, int); itkGetMacro(Dimensionality, int); /** Image dimensions must be set one by one, starting from dimension 0. */ void SetDimensions(unsigned int i, unsigned int dim); unsigned int GetDimensions(unsigned int i) const; static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); protected: RawImageFileReader(); ~RawImageFileReader(); virtual void GenerateData(); template < typename TPixel, unsigned int VImageDimensions > void TypedGenerateData(); /** Name of file to be read.*/ std::string m_FileName; /** File prefix. */ std::string m_FilePrefix; /** File pattern. */ std::string m_FilePattern; /** Pixel type of image to be read. Must be of type IOPixelType. */ IOPixelType m_PixelType; /** Dimensionality of file to be read. Can be 2 or 3. */ int m_Dimensionality; /** Endianity. Must be set to LITTLE or BIG. Default is BIG. */ EndianityType m_Endianity; /** Vector containing dimensions of image to be read. */ itk::Vector m_Dimensions; }; } // namespace mitk #endif /* RawImageFileReader_H_HEADER_INCLUDED */ diff --git a/Modules/LegacyIO/mitkSTLFileIOFactory.h b/Modules/LegacyIO/mitkSTLFileIOFactory.h index 82173df123..8e36cdeab8 100644 --- a/Modules/LegacyIO/mitkSTLFileIOFactory.h +++ b/Modules/LegacyIO/mitkSTLFileIOFactory.h @@ -1,77 +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 __mitkSTLFileIOFactory_h #define __mitkSTLFileIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of STLFileReader objects using an object factory. //## //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_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 * \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/Modules/LegacyIO/mitkSTLFileReader.h b/Modules/LegacyIO/mitkSTLFileReader.h index c13ab73f48..9d9105c03f 100644 --- a/Modules/LegacyIO/mitkSTLFileReader.h +++ b/Modules/LegacyIO/mitkSTLFileReader.h @@ -1,60 +1,60 @@ /*=================================================================== 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 STLFileReader_H_HEADER_INCLUDED #define STLFileReader_H_HEADER_INCLUDED #include #include "mitkSurfaceSource.h" namespace mitk { //##Documentation //## @brief Reader to read files in stl-format //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class MitkLegacyIO_EXPORT STLFileReader : public SurfaceSource { public: mitkClassMacro(STLFileReader, SurfaceSource); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkSetStringMacro(FileName); itkGetStringMacro(FileName); itkSetStringMacro(FilePrefix); itkGetStringMacro(FilePrefix); itkSetStringMacro(FilePattern); itkGetStringMacro(FilePattern); static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); protected: virtual void GenerateData(); STLFileReader(); ~STLFileReader(); std::string m_FileName, m_FilePrefix, m_FilePattern; }; } // namespace mitk #endif /* STLFileReader_H_HEADER_INCLUDED */ diff --git a/Modules/LegacyIO/mitkSurfaceVtkWriter.h b/Modules/LegacyIO/mitkSurfaceVtkWriter.h index 62eacac736..0390cc10ca 100644 --- a/Modules/LegacyIO/mitkSurfaceVtkWriter.h +++ b/Modules/LegacyIO/mitkSurfaceVtkWriter.h @@ -1,216 +1,216 @@ /*=================================================================== 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_SURFACE_VTK_WRITER__H_ #define _MITK_SURFACE_VTK_WRITER__H_ #include #include #include #include #include #include #include #include #include #include class vtkTransformPolyDataFilter; namespace mitk { /** * @brief VTK-based writer for mitk::Surface * * The mitk::Surface is written using the VTK-writer-type provided as the * template argument. If the mitk::Surface contains multiple points of * time, multiple files are written. The life-span (time-bounds) of each * each point of time is included in the filename according to the * following scheme: * <filename>_S<timebounds[0]>E<timebounds[1]>_T<framenumber> * (S=start, E=end, T=time). * Writing of multiple files according to a given filename pattern is not * yet supported. * @ingroup Process * - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ template class MitkLegacyIO_EXPORT SurfaceVtkWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( SurfaceVtkWriter, mitk::FileWriter ); itkFactorylessNewMacro(Self) itkCloneMacro(Self) mitkWriterMacro; typedef VTKWRITER VtkWriterType; /** * Sets the filename of the file to write. * @param _arg the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * \brief Explicitly set the extension to be added to the filename. * @param _arg to be added to the filename, including a "." * (e.g., ".vtk"). * * Partial template specialization is used for some vtk-writer types * to set a default extension. */ itkSetStringMacro( Extension ); /** * \brief Get the extension to be added to the filename. * @returns the extension to be added to the filename (e.g., * ".vtk"). */ itkGetStringMacro( Extension ); /** * \brief Set the extension to be added to the filename to the default * * Partial template specialization is used for some vtk-writer types * to define the default extension. */ void SetDefaultExtension(); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the 0'th input object for the filter. * @param input the first input for the filter. */ void SetInput( mitk::Surface* input ); /** * @returns the 0'th input object of the filter. */ const mitk::Surface* GetInput(); /** * @brief Return the extension to be added to the filename. */ virtual std::string GetFileExtension(); /** * @brief Check if the Writer can write the Content of the DataTreenode. */ virtual bool CanWriteDataType( DataNode* ); /** * @brief Return the MimeType of the saved File. */ virtual std::string GetWritenMIMEType(); using Superclass::SetInput; /** * @brief Set the DataTreenode as Input. Important: The Writer always have a SetInput-Function. */ virtual void SetInput( DataNode* ); VtkWriterType* GetVtkWriter() { return m_VtkWriter; } /** * @brief Return the possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); virtual std::string GetSupportedBaseData() const { return Surface::GetStaticNameOfClass(); } virtual const char *GetDefaultFilename(); virtual const char *GetFileDialogPattern(); virtual const char *GetDefaultExtension(); virtual bool CanWriteBaseDataType(BaseData::Pointer data); virtual void DoWrite(BaseData::Pointer data); protected: /** * Constructor. */ SurfaceVtkWriter(); /** * Virtual destructor. */ virtual ~SurfaceVtkWriter(); virtual void GenerateData(); void ExecuteWrite( VtkWriterType* vtkWriter ); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; std::string m_Extension; std::string m_MimeType; vtkSmartPointer m_VtkWriter; bool m_WriterWriteHasReturnValue; }; #ifndef MitkLegacyIO_EXPORTS extern template class SurfaceVtkWriter; extern template class SurfaceVtkWriter; extern template class SurfaceVtkWriter; #endif } #endif //_MITK_SURFACE_VTK_WRITER__H_ diff --git a/Modules/LegacyIO/mitkSurfaceVtkWriterFactory.h b/Modules/LegacyIO/mitkSurfaceVtkWriterFactory.h index abb80bc33a..78cefa0597 100644 --- a/Modules/LegacyIO/mitkSurfaceVtkWriterFactory.h +++ b/Modules/LegacyIO/mitkSurfaceVtkWriterFactory.h @@ -1,71 +1,71 @@ /*=================================================================== 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 #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { /** - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ class DEPRECATED() MitkLegacyIO_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 * \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/Modules/LegacyIO/mitkVtiFileIOFactory.h b/Modules/LegacyIO/mitkVtiFileIOFactory.h index d14ea3bea4..aa5e2102c1 100644 --- a/Modules/LegacyIO/mitkVtiFileIOFactory.h +++ b/Modules/LegacyIO/mitkVtiFileIOFactory.h @@ -1,77 +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 __mitkVtiFileIOFactory_h #define __mitkVtiFileIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of VtiFileReader objects using an object factory. //## //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_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 * \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/Modules/LegacyIO/mitkVtiFileReader.h b/Modules/LegacyIO/mitkVtiFileReader.h index 4b004e1b10..498bc8a163 100644 --- a/Modules/LegacyIO/mitkVtiFileReader.h +++ b/Modules/LegacyIO/mitkVtiFileReader.h @@ -1,72 +1,72 @@ /*=================================================================== 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 VtiFileReader_H_HEADER_INCLUDED #define VtiFileReader_H_HEADER_INCLUDED #include #include "mitkFileReader.h" #include "mitkImageSource.h" namespace mitk { //##Documentation //## @brief Reader to read image files in vtk file format //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_EXPORT VtiFileReader : public ImageSource, public FileReader { public: mitkClassMacro(VtiFileReader, FileReader); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkSetStringMacro(FileName); itkGetStringMacro(FileName); itkSetStringMacro(FilePrefix); itkGetStringMacro(FilePrefix); itkSetStringMacro(FilePattern); itkGetStringMacro(FilePattern); static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); protected: VtiFileReader(); ~VtiFileReader(); virtual void GenerateData(); //##Description //## @brief Time when Header was last read //itk::TimeStamp m_ReadHeaderTime; protected: std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; }; } // namespace mitk #endif /* VtiFileReader_H_HEADER_INCLUDED */ diff --git a/Modules/LegacyIO/mitkVtkImageIOFactory.h b/Modules/LegacyIO/mitkVtkImageIOFactory.h index 4fae3b7651..3eb804888c 100644 --- a/Modules/LegacyIO/mitkVtkImageIOFactory.h +++ b/Modules/LegacyIO/mitkVtkImageIOFactory.h @@ -1,77 +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 __mitkVtkImageIOFactory_h #define __mitkVtkImageIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of VtkImageReader objects using an object factory. //## //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_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 * \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/Modules/LegacyIO/mitkVtkImageReader.h b/Modules/LegacyIO/mitkVtkImageReader.h index 7b549044ab..49526b4f1f 100644 --- a/Modules/LegacyIO/mitkVtkImageReader.h +++ b/Modules/LegacyIO/mitkVtkImageReader.h @@ -1,72 +1,72 @@ /*=================================================================== 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 VtkImageReader_H_HEADER_INCLUDED #define VtkImageReader_H_HEADER_INCLUDED #include #include "mitkFileReader.h" #include "mitkImageSource.h" namespace mitk { //##Documentation //## @brief Reader to read image files in vtk file format //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_EXPORT VtkImageReader : public ImageSource, public FileReader { public: mitkClassMacro(VtkImageReader, FileReader); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkSetStringMacro(FileName); itkGetStringMacro(FileName); itkSetStringMacro(FilePrefix); itkGetStringMacro(FilePrefix); itkSetStringMacro(FilePattern); itkGetStringMacro(FilePattern); static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); protected: VtkImageReader(); ~VtkImageReader(); virtual void GenerateData(); //##Description //## @brief Time when Header was last read //itk::TimeStamp m_ReadHeaderTime; protected: std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; }; } // namespace mitk #endif /* VtkImageReader_H_HEADER_INCLUDED */ diff --git a/Modules/LegacyIO/mitkVtkSurfaceIOFactory.h b/Modules/LegacyIO/mitkVtkSurfaceIOFactory.h index 621309da13..07ff3c323a 100644 --- a/Modules/LegacyIO/mitkVtkSurfaceIOFactory.h +++ b/Modules/LegacyIO/mitkVtkSurfaceIOFactory.h @@ -1,77 +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 __mitkVtkSurfaceIOFactory_h #define __mitkVtkSurfaceIOFactory_h #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif #include #include "itkObjectFactoryBase.h" #include "mitkBaseData.h" namespace mitk { //##Documentation //## @brief Create instances of VtkSurfaceReader objects using an object factory. //## //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class DEPRECATED() MitkLegacyIO_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 * \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/LegacyIO/mitkVtkSurfaceReader.h b/Modules/LegacyIO/mitkVtkSurfaceReader.h index 5771b3df6a..2f3d8addd3 100644 --- a/Modules/LegacyIO/mitkVtkSurfaceReader.h +++ b/Modules/LegacyIO/mitkVtkSurfaceReader.h @@ -1,60 +1,60 @@ /*=================================================================== 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 VtkSurfaceReader_H_HEADER_INCLUDED #define VtkSurfaceReader_H_HEADER_INCLUDED #include #include "mitkSurfaceSource.h" namespace mitk { //##Documentation //## @brief Reader to read surface files in vtk-format //## @ingroup IO -//## @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. +//## @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. class MitkLegacyIO_EXPORT VtkSurfaceReader : public SurfaceSource { public: mitkClassMacro(VtkSurfaceReader, SurfaceSource); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkSetStringMacro(FileName); itkGetStringMacro(FileName); itkSetStringMacro(FilePrefix); itkGetStringMacro(FilePrefix); itkSetStringMacro(FilePattern); itkGetStringMacro(FilePattern); static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); protected: virtual void GenerateData(); VtkSurfaceReader(); ~VtkSurfaceReader(); std::string m_FileName, m_FilePrefix, m_FilePattern; }; } // namespace mitk #endif /* VtkSurfaceReader_H_HEADER_INCLUDED */ diff --git a/Modules/LegacyIO/vtkPointSetXMLParser.h b/Modules/LegacyIO/vtkPointSetXMLParser.h index 6eb35f5076..aeb48a648a 100644 --- a/Modules/LegacyIO/vtkPointSetXMLParser.h +++ b/Modules/LegacyIO/vtkPointSetXMLParser.h @@ -1,139 +1,139 @@ /*=================================================================== 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 _VTK_POINT_SET_XML_READER__H_ #define _VTK_POINT_SET_XML_READER__H_ #include #include #include #include #include #include namespace mitk { /** * @brief Implementation of the vtkXMLParser interface for reading mitk::PointSets. * * This class implements the XMLParser interface of the vtkXMLParser which is based * on expat. It is used by the mitk::PointSetReader and is NOT INTENDED TO BE USED * FROM THE END-USER. If you want to read point sets, use the mitk::PointSetReader. * @ingroup Process * - * @deprecatedSince{2014_03} Use mitk::IOUtils or mitk::FileReaderRegistry instead. + * @deprecatedSince{2014_10} Use mitk::IOUtils or mitk::FileReaderRegistry instead. */ class DEPRECATED() MitkLegacyIO_EXPORT vtkPointSetXMLParser : public vtkXMLParser { public: vtkTypeMacro(vtkPointSetXMLParser,vtkXMLParser); static vtkPointSetXMLParser* New(); typedef mitk::PointSet PointSetType; typedef std::stack< std::string > ParseStack; typedef std::list< PointSetType::Pointer > PointSetList; typedef PointSetType::DataType::PointIdentifier PointIdentifier; typedef PointSetType::PointType PointType; virtual int InitializeParser(); virtual int CleanupParser(); /** * Handler function which is called, when a new xml start-tag * has been parsed. */ virtual void StartElement (const char *name, const char **atts); /** * Handler function which is called, when a xml end-tag * has been parsed. */ virtual void EndElement (const char *name); /** * Handler function which is called, if characted data has been * parsed by expat. * @param inData a char array containing the parsed string data * @param inLength the length of the parsed data string. */ virtual void CharacterDataHandler (const char *inData, int inLength); /** * Converts the given data to mitk::ScalarType. */ virtual mitk::ScalarType ParseScalarType(const std::string &data); /** * Converts the given data to an PointIdentifier */ virtual PointIdentifier ParsePointIdentifier(const std::string &data); /** * @returns the list of point sets which have been read from file. * NOTE: your have to call the Parse() function, before this function. */ virtual PointSetList GetParsedPointSets(); protected: vtkPointSetXMLParser(); virtual ~vtkPointSetXMLParser(); /** * A stack containing the parsed start-tags. * If an end tag is encountered, it is matched with the * top element of the stack. */ ParseStack m_ParseStack; /** * Contains the parsed point sets. */ PointSetList m_PointSetList; /** * The current point set which is processed * by the parser. */ PointSetType::Pointer m_CurrentPointSet; /** * The current point which is processed * by the parser. */ PointType m_CurrentPoint; std::string m_CurId; std::string m_CurXString; std::string m_CurYString; std::string m_CurZString; /** * The current point id which is processed * by the parser. */ PointIdentifier m_CurrentPointId; std::locale m_PreviousLocale; }; } #endif // _VTK_POINT_SET_XML_READER__H_ diff --git a/Modules/QtWidgets/QmitkDataStorageTableModel.cpp b/Modules/QtWidgets/QmitkDataStorageTableModel.cpp index ad852bb6fb..dbedb4b827 100644 --- a/Modules/QtWidgets/QmitkDataStorageTableModel.cpp +++ b/Modules/QtWidgets/QmitkDataStorageTableModel.cpp @@ -1,524 +1,525 @@ /*=================================================================== 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 "QmitkDataStorageTableModel.h" //# Own includes #include "mitkNodePredicateBase.h" #include "mitkProperties.h" #include "mitkRenderingManager.h" #include "QmitkEnums.h" #include "QmitkCustomVariants.h" #include //# Toolkit includes #include #include +#include //#CTORS/DTOR QmitkDataStorageTableModel::QmitkDataStorageTableModel(mitk::DataStorage::Pointer _DataStorage , mitk::NodePredicateBase* _Predicate , QObject* parent ) : QAbstractTableModel(parent) , m_DataStorage(0) , m_Predicate(0) , m_BlockEvents(false) , m_SortDescending(false) { this->SetPredicate(_Predicate); this->SetDataStorage(_DataStorage); } QmitkDataStorageTableModel::~QmitkDataStorageTableModel() { // set data storage 0 to remove event listeners this->SetDataStorage(0); } //# Public GETTER const mitk::DataStorage::Pointer QmitkDataStorageTableModel::GetDataStorage() const { return m_DataStorage.GetPointer(); } mitk::NodePredicateBase::Pointer QmitkDataStorageTableModel::GetPredicate() const { return m_Predicate; } mitk::DataNode::Pointer QmitkDataStorageTableModel::GetNode( const QModelIndex &index ) const { mitk::DataNode::Pointer node; if(index.isValid()) { node = m_NodeSet.at(index.row()); } return node; } QVariant QmitkDataStorageTableModel::headerData(int section, Qt::Orientation orientation, int role) const { QVariant headerData; // show only horizontal header if ( role == Qt::DisplayRole ) { if( orientation == Qt::Horizontal ) { // first column: "Name" if(section == 0) headerData = "Name"; else if(section == 1) headerData = "Data Type"; else if(section == 2) headerData = "Visibility"; } else if( orientation == Qt::Vertical ) { // show numbers for rows headerData = section+1; } } return headerData; } Qt::ItemFlags QmitkDataStorageTableModel::flags(const QModelIndex &index) const { Qt::ItemFlags flags = QAbstractItemModel::flags(index); // name & visibility is editable if (index.column() == 0) { flags |= Qt::ItemIsEditable; } else if (index.column() == 2) { flags |= Qt::ItemIsUserCheckable; } return flags; } int QmitkDataStorageTableModel::rowCount(const QModelIndex &) const { return m_NodeSet.size(); } int QmitkDataStorageTableModel::columnCount(const QModelIndex &) const { // show name, type and visible columnn int columns = 3; return columns; } QVariant QmitkDataStorageTableModel::data(const QModelIndex &index, int role) const { QVariant data; if (index.isValid() && !m_NodeSet.empty()) { mitk::DataNode::Pointer node = m_NodeSet.at(index.row()); std::string nodeName = node->GetName(); if(nodeName.empty()) nodeName = "unnamed"; // get name if(index.column() == 0) { // get name of node (may also be edited) if (role == Qt::DisplayRole || role == Qt::EditRole) { - data = nodeName.c_str(); + data = QFile::encodeName(nodeName.c_str()); } else if (role == QmitkDataNodeRole) { data = QVariant::fromValue(node); } } else if (index.column() == 1) { QmitkNodeDescriptor* nodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(node); // get type property of mitk::BaseData if (role == Qt::DisplayRole) { data = nodeDescriptor->GetClassName(); } // show some nice icons for datatype else if(role == Qt::DecorationRole) { data = nodeDescriptor->GetIcon(); } } else if (index.column() == 2) { // get visible property of mitk::BaseData bool visibility = false; if(node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole) { data = (visibility ? Qt::Checked : Qt::Unchecked); } // node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole } // index.column() == 2 } // index.isValid() && !m_NodeSet.empty() return data; } //# Public SETTERS void QmitkDataStorageTableModel::SetPredicate( mitk::NodePredicateBase* _Predicate ) { // ensure that a new predicate is set in order to avoid unnecessary changed events if(m_Predicate != _Predicate) { m_Predicate = _Predicate; this->Reset(); } } void QmitkDataStorageTableModel::SetDataStorage( mitk::DataStorage::Pointer _DataStorage ) { // only proceed if we have a new datastorage if(m_DataStorage.GetPointer() != _DataStorage.GetPointer()) { // if a data storage was set before remove old event listeners if(m_DataStorage.IsNotNull()) { this->m_DataStorage->AddNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::AddNode ) ); this->m_DataStorage->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::RemoveNode ) ); } // set new data storage m_DataStorage = _DataStorage.GetPointer(); // if new storage is not 0 subscribe for events if(m_DataStorage.IsNotNull()) { // subscribe for node added/removed events this->m_DataStorage->AddNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::AddNode ) ); this->m_DataStorage->RemoveNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::RemoveNode ) ); } // Reset model (even if datastorage is 0->will be checked in Reset()) this->Reset(); } } void QmitkDataStorageTableModel::AddNode( const mitk::DataNode* node ) { // garantuee no recursions when a new node event is thrown if(!m_BlockEvents) { // if we have a predicate, check node against predicate first if(m_Predicate.IsNotNull() && !m_Predicate->CheckNode(node)) return; // dont add nodes without data (formerly known as helper objects) if(node->GetData() == 0) return; // create listener commands to listen to changes in the name or the visibility of the node itk::MemberCommand::Pointer propertyModifiedCommand = itk::MemberCommand::New(); propertyModifiedCommand->SetCallbackFunction(this, &QmitkDataStorageTableModel::PropertyModified); mitk::BaseProperty* tempProperty = 0; // add listener for properties tempProperty = node->GetProperty("visible"); if(tempProperty) m_VisiblePropertyModifiedObserverTags[tempProperty] = tempProperty->AddObserver(itk::ModifiedEvent(), propertyModifiedCommand); tempProperty = node->GetProperty("name"); if(tempProperty) m_NamePropertyModifiedObserverTags[tempProperty] = tempProperty->AddObserver(itk::ModifiedEvent(), propertyModifiedCommand); // emit beginInsertRows event beginInsertRows(QModelIndex(), m_NodeSet.size(), m_NodeSet.size()); // add node m_NodeSet.push_back(const_cast(node)); // emit endInsertRows event endInsertRows(); } } void QmitkDataStorageTableModel::RemoveNode( const mitk::DataNode* node ) { // garantuee no recursions when a new node event is thrown if(!m_BlockEvents) { // find corresponding node std::vector::iterator nodeIt = std::find(m_NodeSet.begin(), m_NodeSet.end(), node); if(nodeIt != m_NodeSet.end()) { // now: remove listeners for name property ... mitk::BaseProperty* tempProperty = 0; tempProperty = (*nodeIt)->GetProperty("visible"); if(tempProperty) tempProperty->RemoveObserver(m_VisiblePropertyModifiedObserverTags[tempProperty]); m_VisiblePropertyModifiedObserverTags.erase(tempProperty); // ... and visibility property tempProperty = (*nodeIt)->GetProperty("name"); if(tempProperty) tempProperty->RemoveObserver(m_NamePropertyModifiedObserverTags[tempProperty]); m_NamePropertyModifiedObserverTags.erase(tempProperty); // get an index from iterator int row = std::distance(m_NodeSet.begin(), nodeIt); // emit beginRemoveRows event (QModelIndex is empty because we dont have a tree model) this->beginRemoveRows(QModelIndex(), row, row); // remove node m_NodeSet.erase(nodeIt); // emit endRemoveRows event endRemoveRows(); } } } void QmitkDataStorageTableModel::PropertyModified( const itk::Object *caller, const itk::EventObject & ) { if(!m_BlockEvents) { // get modified property const mitk::BaseProperty* modifiedProperty = dynamic_cast(caller); if(modifiedProperty) { // find node that holds the modified property int row = -1; int column = -1; std::vector::iterator it; mitk::BaseProperty* visibilityProperty = 0; mitk::BaseProperty* nameProperty = 0; // search for property that changed and emit datachanged on the corresponding ModelIndex for(it=m_NodeSet.begin(); it!=m_NodeSet.end(); it++) { // check for the visible property or the name property visibilityProperty = (*it)->GetProperty("visible"); if(modifiedProperty == visibilityProperty) { column = 2; break; } nameProperty = (*it)->GetProperty("name"); if(modifiedProperty == nameProperty) { column = 0; break; } } // if we have the property we have a valid iterator if( it != m_NodeSet.end() ) row = std::distance(m_NodeSet.begin(), it); // now emit the dataChanged signal QModelIndex indexOfChangedProperty = index(row, column); emit dataChanged(indexOfChangedProperty, indexOfChangedProperty); } } } bool QmitkDataStorageTableModel::setData(const QModelIndex &index, const QVariant &value, int role) { bool noErr = false; if (index.isValid() && (role == Qt::EditRole || role == Qt::CheckStateRole)) { // any change events produced here should not be caught in this class // --> set m_BlockEvents to true m_BlockEvents = true; mitk::DataNode::Pointer node = m_NodeSet.at(index.row()); if(index.column() == 0) { node->SetStringProperty("name", value.toString().toStdString().c_str()); } else if(index.column() == 2) { node->SetBoolProperty("visible", (value.toInt() == Qt::Checked ? true : false)); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } // inform listeners about changes emit dataChanged(index, index); m_BlockEvents = false; noErr = true; } return noErr; } //#Protected SETTER void QmitkDataStorageTableModel::Reset() { mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet; // remove all nodes now (dont use iterators because removing elements // would invalidate the iterator) // start at the last element: first in, last out unsigned int i = m_NodeSet.size(); while(!m_NodeSet.empty()) { --i; this->RemoveNode(m_NodeSet.at(i)); } // normally now everything should be empty->just to be sure // erase all arrays again m_NamePropertyModifiedObserverTags.clear(); m_VisiblePropertyModifiedObserverTags.clear(); m_NodeSet.clear(); // the whole reset depends on the fact if a data storage is set or not if(m_DataStorage.IsNotNull()) { if(m_Predicate.IsNotNull()) // get subset _NodeSet = m_DataStorage->GetSubset(m_Predicate); // if predicate is NULL, select all nodes else { _NodeSet = m_DataStorage->GetAll(); // remove ghost root node } // finally add all nodes to the model for(mitk::DataStorage::SetOfObjects::const_iterator it=_NodeSet->begin(); it!=_NodeSet->end() ; it++) { // save node this->AddNode(*it); } } } void QmitkDataStorageTableModel::sort( int column, Qt::SortOrder order /*= Qt::AscendingOrder */ ) { bool sortDescending = (order == Qt::DescendingOrder) ? true: false; // do not sort twice !!! (dont know why, but qt calls this func twice. STUPID!) /* if(sortDescending != m_SortDescending) {*/ //m_SortDescending = sortDescending; DataNodeCompareFunction::CompareCriteria _CompareCriteria = DataNodeCompareFunction::CompareByName; DataNodeCompareFunction::CompareOperator _CompareOperator = sortDescending ? DataNodeCompareFunction::Greater: DataNodeCompareFunction::Less; if(column == 1) _CompareCriteria = DataNodeCompareFunction::CompareByClassName; else if(column == 2) _CompareCriteria = DataNodeCompareFunction::CompareByVisibility; DataNodeCompareFunction compareFunc(_CompareCriteria, _CompareOperator); std::sort(m_NodeSet.begin(), m_NodeSet.end(), compareFunc); QAbstractTableModel::reset(); //} } std::vector QmitkDataStorageTableModel::GetNodeSet() const { return m_NodeSet; } QmitkDataStorageTableModel::DataNodeCompareFunction::DataNodeCompareFunction( CompareCriteria _CompareCriteria , CompareOperator _CompareOperator ) : m_CompareCriteria(_CompareCriteria) , m_CompareOperator(_CompareOperator) { } bool QmitkDataStorageTableModel::DataNodeCompareFunction::operator() ( const mitk::DataNode::Pointer& _Left , const mitk::DataNode::Pointer& _Right ) const { switch(m_CompareCriteria) { case CompareByClassName: if(m_CompareOperator == Less) return (_Left->GetData()->GetNameOfClass() < _Right->GetData()->GetNameOfClass() ); else return (_Left->GetData()->GetNameOfClass() > _Right->GetData()->GetNameOfClass() ); break; case CompareByVisibility: { bool _LeftVisibility = false; bool _RightVisibility = false; _Left->GetVisibility(_LeftVisibility, 0); _Right->GetVisibility(_RightVisibility, 0); if(m_CompareOperator == Less) return (_LeftVisibility < _RightVisibility); else return (_LeftVisibility > _RightVisibility); } break; // CompareByName: default: if(m_CompareOperator == Less) return (_Left->GetName() < _Right->GetName()); else return (_Left->GetName() > _Right->GetName()); break; } } diff --git a/Modules/QtWidgets/QmitkDataStorageTreeModel.cpp b/Modules/QtWidgets/QmitkDataStorageTreeModel.cpp index 3f129ce411..e5c540b57a 100644 --- a/Modules/QtWidgets/QmitkDataStorageTreeModel.cpp +++ b/Modules/QtWidgets/QmitkDataStorageTreeModel.cpp @@ -1,855 +1,858 @@ /*=================================================================== 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 #include #include #include #include #include #include #include #include #include "QmitkDataStorageTreeModel.h" #include "QmitkNodeDescriptorManager.h" #include #include #include #include #include #include +#include #include QmitkDataStorageTreeModel::QmitkDataStorageTreeModel( mitk::DataStorage* _DataStorage , bool _PlaceNewNodesOnTop , QObject* parent ) : QAbstractItemModel(parent) , m_DataStorage(0) , m_PlaceNewNodesOnTop(_PlaceNewNodesOnTop) , m_Root(0) { this->SetDataStorage(_DataStorage); } QmitkDataStorageTreeModel::~QmitkDataStorageTreeModel() { // set data storage to 0 = remove all listeners this->SetDataStorage(0); m_Root->Delete(); m_Root = 0; } mitk::DataNode::Pointer QmitkDataStorageTreeModel::GetNode( const QModelIndex &index ) const { return this->TreeItemFromIndex(index)->GetDataNode(); } const mitk::DataStorage::Pointer QmitkDataStorageTreeModel::GetDataStorage() const { return m_DataStorage.GetPointer(); } QModelIndex QmitkDataStorageTreeModel::index( int row, int column, const QModelIndex & parent ) const { TreeItem* parentItem; if (!parent.isValid()) parentItem = m_Root; else parentItem = static_cast(parent.internalPointer()); TreeItem *childItem = parentItem->GetChild(row); if (childItem) return createIndex(row, column, childItem); else return QModelIndex(); } int QmitkDataStorageTreeModel::rowCount(const QModelIndex &parent) const { TreeItem *parentTreeItem = this->TreeItemFromIndex(parent); return parentTreeItem->GetChildCount(); } Qt::ItemFlags QmitkDataStorageTreeModel::flags( const QModelIndex& index ) const { mitk::DataNode* dataNode = this->TreeItemFromIndex(index)->GetDataNode(); if (index.isValid()) { if(DicomPropertiesExists(*dataNode)) { return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; } return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; }else{ return Qt::ItemIsDropEnabled; } } int QmitkDataStorageTreeModel::columnCount( const QModelIndex& /* parent = QModelIndex() */ ) const { return 1; } QModelIndex QmitkDataStorageTreeModel::parent(const QModelIndex &index) const { if (!index.isValid()) return QModelIndex(); TreeItem *childItem = this->TreeItemFromIndex(index); TreeItem *parentItem = childItem->GetParent(); if (parentItem == m_Root) return QModelIndex(); return this->createIndex(parentItem->GetIndex(), 0, parentItem); } QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItemFromIndex( const QModelIndex &index ) const { if (index.isValid()) return static_cast(index.internalPointer()); else return m_Root; } Qt::DropActions QmitkDataStorageTreeModel::supportedDropActions() const { return Qt::CopyAction | Qt::MoveAction; } Qt::DropActions QmitkDataStorageTreeModel::supportedDragActions() const { return Qt::CopyAction | Qt::MoveAction; } bool QmitkDataStorageTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int /*row*/, int /*column*/, const QModelIndex &parent) { // Early exit, returning true, but not actually doing anything (ignoring data). if (action == Qt::IgnoreAction) { return true; } // Note, we are returning true if we handled it, and false otherwise bool returnValue = false; if(data->hasFormat("application/x-qabstractitemmodeldatalist")) { returnValue = true; // First we extract a Qlist of TreeItem* pointers. QList listOfItemsToDrop = ToTreeItemPtrList(data); // Retrieve the TreeItem* where we are dropping stuff, and its parent. TreeItem* dropItem = this->TreeItemFromIndex(parent); TreeItem* parentItem = dropItem->GetParent(); // If item was dropped onto empty space, we select the root node if(dropItem == m_Root) { parentItem = m_Root; } // Dragging and Dropping is only allowed within the same parent, so use the first item in list to validate. // (otherwise, you could have a derived image such as a segmentation, and assign it to another image). // NOTE: We are assuming the input list is valid... i.e. when it was dragged, all the items had the same parent. if(listOfItemsToDrop[0] != dropItem && listOfItemsToDrop[0]->GetParent() == parentItem) { // Retrieve the index of where we are dropping stuff. QModelIndex dropItemModelIndex = this->IndexFromTreeItem(dropItem); QModelIndex parentModelIndex = this->IndexFromTreeItem(parentItem); // Iterate through the list of TreeItem (which may be at non-consecutive indexes). QList::iterator diIter; for (diIter = listOfItemsToDrop.begin(); diIter != listOfItemsToDrop.end(); diIter++) { // Here we assume that as you remove items, one at a time, that GetIndex() will be valid. this->beginRemoveRows(parentModelIndex, (*diIter)->GetIndex(), (*diIter)->GetIndex()); parentItem->RemoveChild(*diIter); this->endRemoveRows(); } // Select the target index position, or put it at the end of the list. int dropIndex = dropItemModelIndex.row(); if (dropIndex == -1) { dropIndex = parentItem->GetChildCount(); } // Now insert items again at the drop item position this->beginInsertRows(parentModelIndex, dropIndex, dropIndex + listOfItemsToDrop.size() - 1); for (diIter = listOfItemsToDrop.begin(); diIter != listOfItemsToDrop.end(); diIter++) { parentItem->InsertChild( (*diIter), dropIndex ); dropIndex++; } this->endInsertRows(); // Change Layers to match. this->AdjustLayerProperty(); } } else if(data->hasFormat("application/x-mitk-datanodes")) { returnValue = true; int numberOfNodesDropped = 0; QList dataNodeList = QmitkMimeTypes::ToDataNodePtrList(data); mitk::DataNode* node = NULL; foreach(node, dataNodeList) { if(node && m_DataStorage.IsNotNull() && !m_DataStorage->Exists(node)) { m_DataStorage->Add( node ); mitk::BaseData::Pointer basedata = node->GetData(); if (basedata.IsNotNull()) { mitk::RenderingManager::GetInstance()->InitializeViews( basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); numberOfNodesDropped++; } } } // Only do a rendering update, if we actually dropped anything. if (numberOfNodesDropped > 0) { mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } return returnValue; } QStringList QmitkDataStorageTreeModel::mimeTypes() const { QStringList types = QAbstractItemModel::mimeTypes(); types << "application/x-qabstractitemmodeldatalist"; types << "application/x-mitk-datanodes"; return types; } QMimeData * QmitkDataStorageTreeModel::mimeData(const QModelIndexList & indexes) const { return mimeDataFromModelIndexList(indexes); } QMimeData *QmitkDataStorageTreeModel::mimeDataFromModelIndexList(const QModelIndexList &indexes) { QMimeData * ret = new QMimeData; QString treeItemAddresses(""); QString dataNodeAddresses(""); QByteArray baTreeItemPtrs; QByteArray baDataNodePtrs; QDataStream dsTreeItemPtrs(&baTreeItemPtrs, QIODevice::WriteOnly); QDataStream dsDataNodePtrs(&baDataNodePtrs, QIODevice::WriteOnly); for (int i = 0; i < indexes.size(); i++) { TreeItem* treeItem = static_cast(indexes.at(i).internalPointer()); dsTreeItemPtrs << reinterpret_cast(treeItem); dsDataNodePtrs << reinterpret_cast(treeItem->GetDataNode().GetPointer()); // --------------- deprecated ----------------- unsigned long long treeItemAddress = reinterpret_cast(treeItem); unsigned long long dataNodeAddress = reinterpret_cast(treeItem->GetDataNode().GetPointer()); QTextStream(&treeItemAddresses) << treeItemAddress; QTextStream(&dataNodeAddresses) << dataNodeAddress; if (i != indexes.size() - 1) { QTextStream(&treeItemAddresses) << ","; QTextStream(&dataNodeAddresses) << ","; } // -------------- end deprecated ------------- } // ------------------ deprecated ----------------- ret->setData("application/x-qabstractitemmodeldatalist", QByteArray(treeItemAddresses.toAscii())); ret->setData("application/x-mitk-datanodes", QByteArray(dataNodeAddresses.toAscii())); // --------------- end deprecated ----------------- ret->setData(QmitkMimeTypes::DataStorageTreeItemPtrs, baTreeItemPtrs); ret->setData(QmitkMimeTypes::DataNodePtrs, baDataNodePtrs); return ret; } QVariant QmitkDataStorageTreeModel::data( const QModelIndex & index, int role ) const { mitk::DataNode* dataNode = this->TreeItemFromIndex(index)->GetDataNode(); // get name of treeItem (may also be edited) QString nodeName; if(DicomPropertiesExists(*dataNode)) { mitk::BaseProperty* seriesDescription = (dataNode->GetProperty("dicom.series.SeriesDescription")); mitk::BaseProperty* studyDescription = (dataNode->GetProperty("dicom.study.StudyDescription")); mitk::BaseProperty* patientsName = (dataNode->GetProperty("dicom.patient.PatientsName")); - nodeName.append(patientsName->GetValueAsString().c_str()).append("\n"); - nodeName.append(studyDescription->GetValueAsString().c_str()).append("\n"); - nodeName.append(seriesDescription->GetValueAsString().c_str()); - }else{ - nodeName = QString::fromStdString(dataNode->GetName()); + nodeName += QFile::encodeName(patientsName->GetValueAsString().c_str()) + "\n"; + nodeName += QFile::encodeName(studyDescription->GetValueAsString().c_str()) + "\n"; + nodeName += QFile::encodeName(seriesDescription->GetValueAsString().c_str()); + } + else + { + nodeName = QFile::encodeName(dataNode->GetName().c_str()); } if(nodeName.isEmpty()) { nodeName = "unnamed"; } if (role == Qt::DisplayRole) return nodeName; else if(role == Qt::ToolTipRole) return nodeName; else if(role == Qt::DecorationRole) { QmitkNodeDescriptor* nodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(dataNode); return nodeDescriptor->GetIcon(); } else if(role == Qt::CheckStateRole) { return dataNode->IsVisible(0); } else if(role == QmitkDataNodeRole) { return QVariant::fromValue(mitk::DataNode::Pointer(dataNode)); } else if(role == QmitkDataNodeRawPointerRole) { return QVariant::fromValue(dataNode); } return QVariant(); } bool QmitkDataStorageTreeModel::DicomPropertiesExists(const mitk::DataNode& node) const { bool propertiesExists = false; mitk::BaseProperty* seriesDescription = (node.GetProperty("dicom.series.SeriesDescription")); mitk::BaseProperty* studyDescription = (node.GetProperty("dicom.study.StudyDescription")); mitk::BaseProperty* patientsName = (node.GetProperty("dicom.patient.PatientsName")); if(patientsName!=NULL && studyDescription!=NULL && seriesDescription!=NULL) { if((!patientsName->GetValueAsString().empty())&& (!studyDescription->GetValueAsString().empty())&& (!seriesDescription->GetValueAsString().empty())) { propertiesExists = true; } } return propertiesExists; } QVariant QmitkDataStorageTreeModel::headerData(int /*section*/, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole && m_Root) return QString::fromStdString(m_Root->GetDataNode()->GetName()); return QVariant(); } void QmitkDataStorageTreeModel::SetDataStorage( mitk::DataStorage* _DataStorage ) { if(m_DataStorage != _DataStorage) // dont take the same again { if(m_DataStorage.IsNotNull()) { // remove Listener for the data storage itself m_DataStorage.ObjectDelete.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetDataStorageDeleted ) ); // remove listeners for the nodes m_DataStorage->AddNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::AddNode ) ); m_DataStorage->ChangedNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetNodeModified ) ); m_DataStorage->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::RemoveNode ) ); } // take over the new data storage m_DataStorage = _DataStorage; // delete the old root (if necessary, create new) if(m_Root) m_Root->Delete(); mitk::DataNode::Pointer rootDataNode = mitk::DataNode::New(); rootDataNode->SetName("Data Manager"); m_Root = new TreeItem(rootDataNode, 0); this->reset(); if(m_DataStorage.IsNotNull()) { // add Listener for the data storage itself m_DataStorage.ObjectDelete.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetDataStorageDeleted ) ); // add listeners for the nodes m_DataStorage->AddNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::AddNode ) ); m_DataStorage->ChangedNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetNodeModified ) ); m_DataStorage->RemoveNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::RemoveNode ) ); mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = m_DataStorage->GetSubset(m_Predicate); // finally add all nodes to the model this->Update(); } } } void QmitkDataStorageTreeModel::SetDataStorageDeleted( const itk::Object* /*_DataStorage*/ ) { this->SetDataStorage(0); } void QmitkDataStorageTreeModel::AddNodeInternal(const mitk::DataNode *node) { if(node == 0 || m_DataStorage.IsNull() || !m_DataStorage->Exists(node) || m_Root->Find(node) != 0) return; // find out if we have a root node TreeItem* parentTreeItem = m_Root; QModelIndex index; mitk::DataNode* parentDataNode = this->GetParentNode(node); if(parentDataNode) // no top level data node { parentTreeItem = m_Root->Find(parentDataNode); // find the corresponding tree item if(!parentTreeItem) { this->AddNode(parentDataNode); parentTreeItem = m_Root->Find(parentDataNode); if(!parentTreeItem) return; } // get the index of this parent with the help of the grand parent index = this->createIndex(parentTreeItem->GetIndex(), 0, parentTreeItem); } // add node if(m_PlaceNewNodesOnTop) { // emit beginInsertRows event beginInsertRows(index, 0, 0); parentTreeItem->InsertChild(new TreeItem( const_cast(node)), 0); } else { beginInsertRows(index, parentTreeItem->GetChildCount() , parentTreeItem->GetChildCount()); new TreeItem(const_cast(node), parentTreeItem); } // emit endInsertRows event endInsertRows(); this->AdjustLayerProperty(); } void QmitkDataStorageTreeModel::AddNode( const mitk::DataNode* node ) { if(node == 0 || m_DataStorage.IsNull() || !m_DataStorage->Exists(node) || m_Root->Find(node) != 0) return; this->AddNodeInternal(node); } void QmitkDataStorageTreeModel::SetPlaceNewNodesOnTop(bool _PlaceNewNodesOnTop) { m_PlaceNewNodesOnTop = _PlaceNewNodesOnTop; } void QmitkDataStorageTreeModel::RemoveNodeInternal( const mitk::DataNode* node ) { if(!m_Root) return; TreeItem* treeItem = m_Root->Find(node); if(!treeItem) return; // return because there is no treeitem containing this node TreeItem* parentTreeItem = treeItem->GetParent(); QModelIndex parentIndex = this->IndexFromTreeItem(parentTreeItem); // emit beginRemoveRows event (QModelIndex is empty because we dont have a tree model) this->beginRemoveRows(parentIndex, treeItem->GetIndex(), treeItem->GetIndex()); // remove node std::vector children = treeItem->GetChildren(); delete treeItem; // emit endRemoveRows event endRemoveRows(); // move all children of deleted node into its parent for ( std::vector::iterator it = children.begin() ; it != children.end(); it++) { // emit beginInsertRows event beginInsertRows(parentIndex, parentTreeItem->GetChildCount(), parentTreeItem->GetChildCount()); // add nodes again parentTreeItem->AddChild(*it); // emit endInsertRows event endInsertRows(); } this->AdjustLayerProperty(); } void QmitkDataStorageTreeModel::RemoveNode( const mitk::DataNode* node ) { if (node == 0) return; this->RemoveNodeInternal(node); } void QmitkDataStorageTreeModel::SetNodeModified( const mitk::DataNode* node ) { TreeItem* treeItem = m_Root->Find(node); if(treeItem) { TreeItem* parentTreeItem = treeItem->GetParent(); // as the root node should not be removed one should always have a parent item if(!parentTreeItem) return; QModelIndex index = this->createIndex(treeItem->GetIndex(), 0, treeItem); // now emit the dataChanged signal emit dataChanged(index, index); } } mitk::DataNode* QmitkDataStorageTreeModel::GetParentNode( const mitk::DataNode* node ) const { mitk::DataNode* dataNode = 0; mitk::DataStorage::SetOfObjects::ConstPointer _Sources = m_DataStorage->GetSources(node); if(_Sources->Size() > 0) dataNode = _Sources->front(); return dataNode; } bool QmitkDataStorageTreeModel::setData( const QModelIndex &index, const QVariant &value, int role ) { mitk::DataNode* dataNode = this->TreeItemFromIndex(index)->GetDataNode(); if(!dataNode) return false; if(role == Qt::EditRole && !value.toString().isEmpty()) { dataNode->SetStringProperty("name", value.toString().toStdString().c_str()); mitk::PlanarFigure* planarFigure = dynamic_cast(dataNode->GetData()); if (planarFigure != NULL) mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } else if(role == Qt::CheckStateRole) { // Please note: value.toInt() returns 2, independentely from the actual checkstate of the index element. // Therefore the checkstate is being estimated again here. QVariant qcheckstate = index.data(Qt::CheckStateRole); int checkstate = qcheckstate.toInt(); bool isVisible = bool(checkstate); dataNode->SetVisibility(!isVisible); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } // inform listeners about changes emit dataChanged(index, index); return true; } bool QmitkDataStorageTreeModel::setHeaderData( int /*section*/, Qt::Orientation /*orientation*/, const QVariant& /* value */, int /*role = Qt::EditRole*/ ) { return false; } void QmitkDataStorageTreeModel::AdjustLayerProperty() { /// transform the tree into an array and set the layer property descending std::vector vec; this->TreeToVector(m_Root, vec); int i = vec.size()-1; for(std::vector::const_iterator it = vec.begin(); it != vec.end(); ++it) { mitk::DataNode::Pointer dataNode = (*it)->GetDataNode(); bool fixedLayer = false; if (!(dataNode->GetBoolProperty("fixedLayer", fixedLayer) && fixedLayer)) dataNode->SetIntProperty("layer", i); --i; } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkDataStorageTreeModel::TreeToVector(TreeItem* parent, std::vector& vec) const { TreeItem* current; for(int i = 0; iGetChildCount(); ++i) { current = parent->GetChild(i); this->TreeToVector(current, vec); vec.push_back(current); } } QModelIndex QmitkDataStorageTreeModel::IndexFromTreeItem( TreeItem* item ) const { if(item == m_Root) return QModelIndex(); else return this->createIndex(item->GetIndex(), 0, item); } QList QmitkDataStorageTreeModel::GetNodeSet() const { QList res; if(m_Root) this->TreeToNodeSet(m_Root, res); return res; } void QmitkDataStorageTreeModel::TreeToNodeSet( TreeItem* parent, QList& vec ) const { TreeItem* current; for(int i = 0; iGetChildCount(); ++i) { current = parent->GetChild(i); vec.push_back(current->GetDataNode()); this->TreeToNodeSet(current, vec); } } QModelIndex QmitkDataStorageTreeModel::GetIndex( const mitk::DataNode* node ) const { if(m_Root) { TreeItem* item = m_Root->Find(node); if(item) return this->IndexFromTreeItem(item); } return QModelIndex(); } QList QmitkDataStorageTreeModel::ToTreeItemPtrList(const QMimeData* mimeData) { if (mimeData == NULL || !mimeData->hasFormat(QmitkMimeTypes::DataStorageTreeItemPtrs)) { return QList(); } return ToTreeItemPtrList(mimeData->data(QmitkMimeTypes::DataStorageTreeItemPtrs)); } QList QmitkDataStorageTreeModel::ToTreeItemPtrList(const QByteArray& ba) { QList result; QDataStream ds(ba); while(!ds.atEnd()) { quintptr treeItemPtr; ds >> treeItemPtr; result.push_back(reinterpret_cast(treeItemPtr)); } return result; } QmitkDataStorageTreeModel::TreeItem::TreeItem( mitk::DataNode* _DataNode, TreeItem* _Parent ) : m_Parent(_Parent) , m_DataNode(_DataNode) { if(m_Parent) m_Parent->AddChild(this); } QmitkDataStorageTreeModel::TreeItem::~TreeItem() { if(m_Parent) m_Parent->RemoveChild(this); } void QmitkDataStorageTreeModel::TreeItem::Delete() { while(m_Children.size() > 0) delete m_Children.back(); delete this; } QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::Find( const mitk::DataNode* _DataNode ) const { QmitkDataStorageTreeModel::TreeItem* item = 0; if(_DataNode) { if(m_DataNode == _DataNode) item = const_cast(this); else { for(std::vector::const_iterator it = m_Children.begin(); it != m_Children.end(); ++it) { if(item) break; item = (*it)->Find(_DataNode); } } } return item; } int QmitkDataStorageTreeModel::TreeItem::IndexOfChild( const TreeItem* item ) const { std::vector::const_iterator it = std::find(m_Children.begin(), m_Children.end(), item); return it != m_Children.end() ? std::distance(m_Children.begin(), it): -1; } QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::GetChild( int index ) const { return (m_Children.size() > 0 && index >= 0 && index < (int)m_Children.size())? m_Children.at(index): 0; } void QmitkDataStorageTreeModel::TreeItem::AddChild( TreeItem* item ) { this->InsertChild(item); } void QmitkDataStorageTreeModel::TreeItem::RemoveChild( TreeItem* item ) { std::vector::iterator it = std::find(m_Children.begin(), m_Children.end(), item); if(it != m_Children.end()) { m_Children.erase(it); item->SetParent(0); } } int QmitkDataStorageTreeModel::TreeItem::GetChildCount() const { return m_Children.size(); } int QmitkDataStorageTreeModel::TreeItem::GetIndex() const { if (m_Parent) return m_Parent->IndexOfChild(this); return 0; } QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::GetParent() const { return m_Parent; } mitk::DataNode::Pointer QmitkDataStorageTreeModel::TreeItem::GetDataNode() const { return m_DataNode; } void QmitkDataStorageTreeModel::TreeItem::InsertChild( TreeItem* item, int index ) { std::vector::iterator it = std::find(m_Children.begin(), m_Children.end(), item); if(it == m_Children.end()) { if(m_Children.size() > 0 && index >= 0 && index < (int)m_Children.size()) { it = m_Children.begin(); std::advance(it, index); m_Children.insert(it, item); } else m_Children.push_back(item); // add parent if necessary if(item->GetParent() != this) item->SetParent(this); } } std::vector QmitkDataStorageTreeModel::TreeItem::GetChildren() const { return m_Children; } void QmitkDataStorageTreeModel::TreeItem::SetParent( TreeItem* _Parent ) { m_Parent = _Parent; if(m_Parent) m_Parent->AddChild(this); } void QmitkDataStorageTreeModel::Update() { if (m_DataStorage.IsNotNull()) { this->reset(); mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = m_DataStorage->GetAll(); for (mitk::DataStorage::SetOfObjects::const_iterator it = _NodeSet->begin(); it != _NodeSet->end(); it++) { // save node this->AddNodeInternal(*it); } } } diff --git a/Modules/QtWidgets/QmitkIOUtil.h b/Modules/QtWidgets/QmitkIOUtil.h index 0faec01333..57fd830b33 100644 --- a/Modules/QtWidgets/QmitkIOUtil.h +++ b/Modules/QtWidgets/QmitkIOUtil.h @@ -1,232 +1,232 @@ /*=================================================================== 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 _QmitkIOUtil__h_ #define _QmitkIOUtil__h_ #include "MitkQtWidgetsExports.h" // std #include // mitk includes #include #include #include #include #include #include #include #include //Qt #include #include class QWidget; class QString; class QStringList; namespace mitk { class DataStorage; class MimeType; struct IFileReader; } /** * @brief QmitkIOUtil Provides static helper methods to open and save files with Qt dialogs. */ class QMITK_EXPORT QmitkIOUtil : public mitk::IOUtil { public: class QMITK_EXPORT SaveFilter { public: static mitk::MimeType ALL_MIMETYPE(); SaveFilter(const SaveFilter& other); SaveFilter(const SaveInfo& saveInfo); SaveFilter& operator=(const SaveFilter& other); QString GetFilterForMimeType(const std::string& mimeType) const; mitk::MimeType GetMimeTypeForFilter(const QString& filter) const; QString GetDefaultFilter() const; QString GetDefaultExtension() const; mitk::MimeType GetDefaultMimeType() const; QString ToString() const; int Size() const; bool IsEmpty() const; bool ContainsMimeType(const std::string& mimeType); private: struct Impl; QScopedPointer d; }; /** * @brief GetFilterString * @return */ static QString GetFileOpenFilterString(); /** * @brief Loads the specified files * * This methods tries to load all specified files and pop-ups dialog boxes if further * user input is required (e.g. ambiguous mime-types or reader options). * * If the provided DataStorage is not NULL, some files will be added to it automatically, * dependeing on the IFileReader used. * * @param files A list of files to load. * @param ds An optional data storage passed to IFileReader instances * @return A list of BaseData instances which have not already been added to the data storage. */ static QList Load(const QStringList& paths, QWidget* parent = NULL); static mitk::DataStorage::SetOfObjects::Pointer Load(const QStringList& paths, mitk::DataStorage& storage, QWidget* parent = NULL); static QList Load(const QString& path, QWidget* parent = NULL); static mitk::DataStorage::SetOfObjects::Pointer Load(const QString& path, mitk::DataStorage& storage, QWidget* parent = NULL); using mitk::IOUtil::Load; static QString Save(const mitk::BaseData* data, const QString& defaultBaseName, const QString& defaultPath = QString(), QWidget* parent = NULL); /** * @brief Save a list of BaseData objects using a "File Save Dialog". * * For each element in the \c data vector, the following algorithm is * used to find a IFileWriter instance for writing the BaseData object. * * First, the user is prompted to select file names for each BaseData object. This * is equivalent to choosing a specific mime-type, either by selecting a filter * in the save dialog or by explicitly providing a file name extension: *
    *
  1. Get a list of registered IFileWriter objects for the current BaseData object. * If no writers are found, a message box displays a warning and * the process starts from the beginning for the next BaseData object.
  2. *
  3. A QFileDialog for prompting the user to select a file name is opened. * The mime-type associated with each IFileWriter object is used to create * a filter for file name extensions. * The best IFileWriter (see FileWriterSelector) for the current BaseData object * defines the default file name suffix via its associated mime-type. If the * file name is empty (the user cancelled the dialog), the remaining * BaseData objects are skipped. *
  4. The file name suffix is extracted from the user-supplied file name and validated. * If the suffix is not empty and it is either not contained in the * extension list of the selected filter (from the QFileDialog) or the mime-type * containing the suffix as an extension is not contained in the original * list of compatible mime-types, a message box displays a warning and * the process starts from the beginning with the next BaseData object. * If the suffix is empty, a default suffix is created if the file name does * not point to an already existing file (in that case, the user already * confirmed to overwrite that file). The default suffix is the first entry * in the extension list of the selected filter. If the special "all" * filter is selected, the first entry from the extensions list of the * highest-ranked compatible mime-type for the current base data object is used. * The base data object is associated with the mime-type containing the suffix * in its extension list. If the suffix is empty (the user is overwriting an * existing file without an extension, the associated mime-type is the one * of the selected filter or the mime-type of the best matching IFileWriter * if the special "all" filter was selected.
  5. *
  6. The selected/derived file name and associated mime-type is stored in a list * and the process starts from the beginning for the next BaseData object.
  7. *
* * In the second phase, each BaseData object is saved to disk using the specified * file name and mime-type, according to the following procedure: *
    *
  1. If multiple IFileWriter objects are compatible with the current base data * object or if the single compatible IFileWriter provides configuration * options, a dialog window containing a list of IFileWriter objects and * configurable options is displayed. If the dialog is cancelled by the user, * neither the current nor the remaining base data objects are saved to disk. * If the user previously in this phase enabled the "remember options" checkbox * of the dialog, then the dialog is not shown for base data objects with the * same data type and associated mime-type if the file writer instance reports * a higher or equal confidence level for the current base data object.
  2. *
  3. The selected writer (either the only available one or the user selected one) * is used to write the base data object to disk. On failure, an error is * reported and the second phase continues with the next base data object.
  4. *
* * @param data * @param defaultBaseNames * @param defaultPath * @param parent * @return */ static QStringList Save(const std::vector& data, const QStringList& defaultBaseNames, const QString& defaultPath = QString(), QWidget* parent = NULL); using mitk::IOUtil::Save; /** * @brief SaveBaseDataWithDialog Convenience method to save any data with a Qt dialog. * @param data BaseData holding the data you wish to save. * @param fileName The file name where to save the data (including path and extension). * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. - * @deprecatedSince{2014_03} Use Save() instead. + * @deprecatedSince{2014_10} Use Save() instead. */ DEPRECATED(static void SaveBaseDataWithDialog(mitk::BaseData *data, std::string fileName, QWidget* parent = NULL)); /** * @brief SaveSurfaceWithDialog Convenience method to save a surface with a Qt dialog. * @param surface The surface to save. * @param fileName The file name where to save the data (including path and extension). * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. - * @deprecatedSince{2014_03} Use Save() instead. + * @deprecatedSince{2014_10} Use Save() instead. */ DEPRECATED(static void SaveSurfaceWithDialog(mitk::Surface::Pointer surface, std::string fileName = "", QWidget* parent = NULL)); /** * @brief SaveImageWithDialog Convenience method to save an image with a Qt dialog. * @param image The image to save. * @param fileName The file name where to save the data (including path and extension). * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. - * @deprecatedSince{2014_03} Use Save() instead. + * @deprecatedSince{2014_10} Use Save() instead. */ DEPRECATED(static void SaveImageWithDialog(mitk::Image::Pointer image, std::string fileName = "", QWidget* parent = NULL)); /** * @brief SavePointSetWithDialog Convenience method to save a pointset with a Qt dialog. * @param pointset The pointset to save. * @param fileName The file name where to save the data (including path and extension). * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. - * @deprecatedSince{2014_03} Use Save() instead. + * @deprecatedSince{2014_10} Use Save() instead. */ DEPRECATED(static void SavePointSetWithDialog(mitk::PointSet::Pointer pointset, std::string fileName = "", QWidget* parent = NULL)); private: struct Impl; }; #endif // _QmitkIOUtil__h_