diff --git a/Core/Code/IO/mitkAbstractFileIO.h b/Core/Code/IO/mitkAbstractFileIO.h index 3791432ac0..a24262a998 100644 --- a/Core/Code/IO/mitkAbstractFileIO.h +++ b/Core/Code/IO/mitkAbstractFileIO.h @@ -1,192 +1,197 @@ /*=================================================================== 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 MITKABSTRACTFILEIO_H #define MITKABSTRACTFILEIO_H #include "mitkAbstractFileReader.h" #include "mitkAbstractFileWriter.h" namespace mitk { #ifndef DOXYGEN_SKIP // Skip this code during Doxygen processing, because it only // exists to resolve name clashes when inheriting from both // AbstractFileReader and AbstractFileWriter. class AbstractFileIOReader : public AbstractFileReader { public: virtual ConfidenceLevel GetReaderConfidenceLevel() const { return AbstractFileReader::GetConfidenceLevel(); } virtual ConfidenceLevel GetConfidenceLevel() const { return this->GetReaderConfidenceLevel(); } protected: AbstractFileIOReader() {} AbstractFileIOReader(const CustomMimeType& mimeType, const std::string& description) : AbstractFileReader(mimeType, description) {} private: virtual IFileReader* ReaderClone() const = 0; IFileReader* Clone() const { return ReaderClone(); } }; struct AbstractFileIOWriter : public AbstractFileWriter { virtual ConfidenceLevel GetWriterConfidenceLevel() const { return AbstractFileWriter::GetConfidenceLevel(); } virtual ConfidenceLevel GetConfidenceLevel() const { return this->GetWriterConfidenceLevel(); } protected: AbstractFileIOWriter(const std::string& baseDataType) : AbstractFileWriter(baseDataType) {} AbstractFileIOWriter(const std::string& baseDataType, const CustomMimeType& mimeType, const std::string& description) : AbstractFileWriter(baseDataType, mimeType, description) {} private: virtual IFileWriter* WriterClone() const = 0; IFileWriter* Clone() const { return WriterClone(); } }; #endif // DOXYGEN_SKIP +/** + * @ingroup IO + * + * @brief Abstract class for implementing a reader and writer. + */ class MITK_CORE_EXPORT AbstractFileIO : public AbstractFileIOReader, public AbstractFileIOWriter { public: Options GetReaderOptions() const; us::Any GetReaderOption(const std::string &name) const; void SetReaderOptions(const Options& options); void SetReaderOption(const std::string& name, const us::Any& value); Options GetWriterOptions() const; us::Any GetWriterOption(const std::string &name) const; void SetWriterOptions(const Options& options); void SetWriterOption(const std::string& name, const us::Any& value); virtual ConfidenceLevel GetReaderConfidenceLevel() const; virtual ConfidenceLevel GetWriterConfidenceLevel() const; std::pair, us::ServiceRegistration > RegisterService(us::ModuleContext* context = us::GetModuleContext()); protected: AbstractFileIO(const AbstractFileIO& other); AbstractFileIO(const std::string& baseDataType); /** * Associate this reader instance with the given MIME type. * * @param mimeType The mime type this reader can read. * @param description A human readable description of this reader. * * @throws std::invalid_argument if \c mimeType is empty. * * @see RegisterService */ explicit AbstractFileIO(const std::string& baseDataType, const CustomMimeType& mimeType, const std::string& description); /** * Associate this reader with the given file extension. * * Additonal file extensions can be added by sub-classes by calling AddExtension * or SetExtensions on the CustomMimeType object returned by GetMimeType() and * setting the modified object again via SetMimeType(). * * @param extension The file extension (without a leading period) for which a registered * mime-type object is looked up and associated with this instance. * @param description A human readable description of this reader. * * @see RegisterService */ explicit AbstractFileIO(const std::string& baseDataType, const std::string& extension, const std::string& description); void SetMimeType(const CustomMimeType& mimeType); /** * @return The mime-type this reader can handle. */ const CustomMimeType* GetMimeType() const; void SetReaderDescription(const std::string& description); std::string GetReaderDescription() const; void SetWriterDescription(const std::string& description); std::string GetWriterDescription() const; void SetDefaultReaderOptions(const Options& defaultOptions); Options GetDefaultReaderOptions() const; void SetDefaultWriterOptions(const Options& defaultOptions); Options GetDefaultWriterOptions() const; /** * \brief Set the service ranking for this file reader. * * Default is zero and should only be chosen differently for a reason. * The ranking is used to determine which reader to use if several * equivalent readers have been found. * It may be used to replace a default reader from MITK in your own project. * E.g. if you want to use your own reader for nrrd files instead of the default, * implement it and give it a higher ranking than zero. */ void SetReaderRanking(int ranking); int GetReaderRanking() const; void SetWriterRanking(int ranking); int GetWriterRanking() const; private: AbstractFileIO& operator=(const AbstractFileIO& other); virtual AbstractFileIO* IOClone() const = 0; virtual IFileReader* ReaderClone() const; virtual IFileWriter* WriterClone() const; }; } #endif // MITKABSTRACTFILEIO_H diff --git a/Core/Code/IO/mitkCustomMimeType.h b/Core/Code/IO/mitkCustomMimeType.h index 8ae8fdcdd9..66e984b445 100644 --- a/Core/Code/IO/mitkCustomMimeType.h +++ b/Core/Code/IO/mitkCustomMimeType.h @@ -1,79 +1,85 @@ /*=================================================================== 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 MITKCUSTOMMIMETYPE_H #define MITKCUSTOMMIMETYPE_H #include #include #include #include namespace mitk { class MimeType; /** * @ingroup IO * @ingroup MicroServices_Interfaces * + * @brief The CustomMimeType class represents a custom mime-type which + * may be registered as a service object. + * + * Instances of this class are usually created and registered as a service. + * They wire files to specific IFileReader instances and provide data format + * meta-data for selecting compatible IFileWriter instances. */ class MITK_CORE_EXPORT CustomMimeType { public: CustomMimeType(); CustomMimeType(const std::string& name); CustomMimeType(const CustomMimeType& other); explicit CustomMimeType(const MimeType& other); virtual ~CustomMimeType(); CustomMimeType& operator=(const CustomMimeType& other); CustomMimeType& operator=(const MimeType& other); std::string GetName() const; std::string GetCategory() const; std::vector GetExtensions() const; std::string GetComment() const; virtual bool AppliesTo(const std::string& path) const; void SetName(const std::string& name); void SetCategory(const std::string& category); void SetExtension(const std::string& extension); void AddExtension(const std::string& extension); void SetComment(const std::string& comment); void Swap(CustomMimeType& r); virtual CustomMimeType* Clone() const; private: struct Impl; Impl* d; }; void swap(CustomMimeType& l, CustomMimeType& r); } MITK_DECLARE_SERVICE_INTERFACE(mitk::CustomMimeType, "org.mitk.CustomMimeType") #endif // MITKCUSTOMMIMETYPE_H diff --git a/Core/Code/IO/mitkFileReader.h b/Core/Code/IO/mitkFileReader.h index 762abc3053..120bce6062 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 +//## @ingroup DeprecatedIO //## @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 2c00675a04..3689d7820b 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 +//## @ingroup DeprecatedIO //## @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/mitkIFileIO.h b/Core/Code/IO/mitkIFileIO.h index 98d50c05e0..06f9885568 100644 --- a/Core/Code/IO/mitkIFileIO.h +++ b/Core/Code/IO/mitkIFileIO.h @@ -1,92 +1,126 @@ /*=================================================================== 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 MITKIFILEIO_H #define MITKIFILEIO_H #include #include #include #include #include namespace mitk { +/** + * \ingroup IO + * + * \brief Common interface for all MITK file reader and writer. + * + * This interface is not meant to be implemented directly. It is inherited + * from IFileWriter and IFileReader and a default implementation is provided + * in AbstractFileIO via AbstractFileWriter and AbstractFileReader. + */ struct MITK_CORE_EXPORT IFileIO { // The order of the enum values is important: it is used // to rank writer implementations + + /** + * @brief A confidence level describing the confidence of the reader or writer + * in handling the given data. + * + */ enum ConfidenceLevel { Unsupported = 0, PartiallySupported = 8, Supported = 16 }; + /** + * @brief Options for reading or writing data. + * + * Options are used in reader or writer implementations to customize + * certain aspects of the reading/writing process. Options may be supplied + * by users calling the SetOption() method or they may be presented + * as an input mask in the context of a graphical user interface. + * + * The keys are human-readable labels and the type of the option value + * specifies the user interface representation. If a key contains multiple + * segments (sub-strings separated by a '.' character, only the last segment + * is displayed. If the last segment is equal to the string 'enum', the option + * is treated as a finite enumeration of values where the values are contained + * in a corresponding \c std::vector value. the same option key + * without the 'enum' segment is considered to hold the current selection from + * the enumeration. + */ typedef std::map Options; typedef mitk::MessageAbstractDelegate1 ProgressCallback; virtual ~IFileIO(); + /** + * @brief The confidence level of the reader or writer implementation. + * @return Confidence level. + * + * The level is used to rank multiple competing implementations. + */ virtual ConfidenceLevel GetConfidenceLevel() const = 0; /** - * \brief returns a list of the supported Options + * \brief returns a list of the supported options * * Options are strings that are treated as flags when passed to the write method. */ virtual Options GetOptions() const = 0; virtual us::Any GetOption(const std::string& name) const = 0; virtual void SetOptions(const Options& options) = 0; virtual void SetOption(const std::string& name, const us::Any& value) = 0; - /** - * \brief Returns a value between 0 and 1 depending on the progress of the writing process. - * This method need not necessarily be implemented meaningfully, always returning zero is accepted. - */ virtual void AddProgressCallback(const ProgressCallback& callback) = 0; virtual void RemoveProgressCallback(const ProgressCallback& callback) = 0; /** * @brief Service property name for a description. * * The property value must be of type \c std::string. * * @return The property name. */ static std::string PROP_DESCRIPTION(); /** * @brief Service property name for the mime-type associated with this file writer. * * The property value must be of type \c std::string. * * @return The property name. */ static std::string PROP_MIMETYPE(); }; } #endif // MITKIFILEIO_H diff --git a/Core/Code/IO/mitkIOAdapter.h b/Core/Code/IO/mitkIOAdapter.h index 19e3ff8c83..8017f263d2 100644 --- a/Core/Code/IO/mitkIOAdapter.h +++ b/Core/Code/IO/mitkIOAdapter.h @@ -1,99 +1,99 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkIOAdapter_h #define __mitkIOAdapter_h #include "mitkBaseProcess.h" #include "itkObject.h" namespace mitk { /** * @brief IOAdapterBase class is an abstract adapter class for IO process objects. * - * @ingroup IO + * @ingroup DeprecatedIO * @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 }; /** * @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_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/mitkIOConstants.h b/Core/Code/IO/mitkIOConstants.h index 14879353fd..3bf7d2dbcb 100644 --- a/Core/Code/IO/mitkIOConstants.h +++ b/Core/Code/IO/mitkIOConstants.h @@ -1,55 +1,59 @@ /*=================================================================== 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 MITKIOCONSTANTS_H_ #define MITKIOCONSTANTS_H_ #include #include namespace mitk { +/** + * @ingroup IO + * @brief The IOConstants struct + */ struct MITK_CORE_EXPORT IOConstants { static std::string PIXEL_TYPE(); static std::string PIXEL_TYPE_CHAR(); static std::string PIXEL_TYPE_UCHAR(); static std::string PIXEL_TYPE_SHORT(); static std::string PIXEL_TYPE_USHORT(); static std::string PIXEL_TYPE_INT(); static std::string PIXEL_TYPE_UINT(); static std::string PIXEL_TYPE_FLOAT(); static std::string PIXEL_TYPE_DOUBLE(); static std::string PIXEL_TYPE_ENUM(); static std::string DIMENSION(); static std::string DIMENSION_ENUM(); static std::string ENDIANNESS(); static std::string ENDIANNESS_LITTLE(); static std::string ENDIANNESS_BIG(); static std::string ENDIANNESS_ENUM(); static std::string SIZE_X(); static std::string SIZE_Y(); static std::string SIZE_Z(); static std::string SIZE_T(); }; } #endif // MITKIOCONSTANTS_H_ diff --git a/Core/Code/IO/mitkIOMimeTypes.h b/Core/Code/IO/mitkIOMimeTypes.h index 8898ba4fcd..4fe2db733b 100644 --- a/Core/Code/IO/mitkIOMimeTypes.h +++ b/Core/Code/IO/mitkIOMimeTypes.h @@ -1,90 +1,94 @@ /*=================================================================== 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 MITKIOMIMETYPES_H #define MITKIOMIMETYPES_H #include "mitkCustomMimeType.h" #include namespace mitk { +/** + * @ingroup IO + * @brief The IOMimeTypes class + */ class MITK_CORE_EXPORT IOMimeTypes { public: class MITK_CORE_EXPORT DicomMimeType : public CustomMimeType { public: DicomMimeType(); virtual bool AppliesTo(const std::string &path) const; virtual DicomMimeType* Clone() const; }; static std::vector Get(); static std::string DEFAULT_BASE_NAME(); // application/vnd.mitk static std::string CATEGORY_IMAGES(); // Images static std::string CATEGORY_SURFACES(); // Surfaces // ------------------------------ VTK formats ---------------------------------- static CustomMimeType VTK_IMAGE_MIMETYPE(); // (mitk::Image) vti static CustomMimeType VTK_IMAGE_LEGACY_MIMETYPE(); // (mitk::Image) vtk static CustomMimeType VTK_PARALLEL_IMAGE_MIMETYPE(); // (mitk::Image) pvti static CustomMimeType VTK_POLYDATA_MIMETYPE(); // (mitk::Surface) vtp, vtk static CustomMimeType VTK_POLYDATA_LEGACY_MIMETYPE(); // (mitk::Surface) vtk static CustomMimeType VTK_PARALLEL_POLYDATA_MIMETYPE(); // (mitk::Surface) pvtp static CustomMimeType STEREOLITHOGRAPHY_MIMETYPE(); // (mitk::Surface) stl static std::string STEREOLITHOGRAPHY_NAME(); // DEFAULT_BASE_NAME.stl static std::string VTK_IMAGE_NAME(); // DEFAULT_BASE_NAME.vtk.image static std::string VTK_IMAGE_LEGACY_NAME(); // DEFAULT_BASE_NAME.vtk.image.legacy static std::string VTK_PARALLEL_IMAGE_NAME(); // DEFAULT_BASE_NAME.vtk.parallel.image static std::string VTK_POLYDATA_NAME(); // DEFAULT_BASE_NAME.vtk.polydata static std::string VTK_POLYDATA_LEGACY_NAME(); // DEFAULT_BASE_NAME.vtk.polydata.legacy static std::string VTK_PARALLEL_POLYDATA_NAME(); // DEFAULT_BASE_NAME.vtk.parallel.polydata // ------------------------- Image formats (ITK based) -------------------------- static CustomMimeType NRRD_MIMETYPE(); // nrrd, nhdr static CustomMimeType NIFTI_MIMETYPE(); static CustomMimeType RAW_MIMETYPE(); // raw static DicomMimeType DICOM_MIMETYPE(); static std::string NRRD_MIMETYPE_NAME(); // DEFAULT_BASE_NAME.nrrd static std::string NIFTI_MIMETYPE_NAME(); static std::string RAW_MIMETYPE_NAME(); // DEFAULT_BASE_NAME.raw static std::string DICOM_MIMETYPE_NAME(); // ------------------------------ MITK formats ---------------------------------- static CustomMimeType POINTSET_MIMETYPE(); // mps static std::string POINTSET_MIMETYPE_NAME(); // DEFAULT_BASE_NAME.pointset private: // purposely not implemented IOMimeTypes(); IOMimeTypes(const IOMimeTypes&); }; } #endif // MITKIOMIMETYPES_H diff --git a/Core/Code/IO/mitkMimeType.h b/Core/Code/IO/mitkMimeType.h index 269fb1d543..9f360ea5cb 100644 --- a/Core/Code/IO/mitkMimeType.h +++ b/Core/Code/IO/mitkMimeType.h @@ -1,84 +1,88 @@ /*=================================================================== 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 MITKMIMETYPE_H #define MITKMIMETYPE_H #include #include #include #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4251) #endif namespace mitk { class CustomMimeType; /** * @ingroup IO * + * @brief The MimeType class represens a registered mime-type. + * + * MimeType instances support the MITK I/O system and represent mime-types + * for data formats. */ class MITK_CORE_EXPORT MimeType { public: MimeType(); MimeType(const MimeType& other); MimeType(const CustomMimeType& x, int rank, long id); ~MimeType(); MimeType& operator=(const MimeType& other); bool operator==(const MimeType& other) const; bool operator<(const MimeType& other) const; std::string GetName() const; std::string GetCategory() const; std::vector GetExtensions() const; std::string GetComment() const; bool AppliesTo(const std::string& path) const; bool IsValid() const; void Swap(MimeType& m); private: struct Impl; // Use C++11 shared_ptr instead us::SharedDataPointer m_Data; }; void swap(MimeType& m1, MimeType& m2); std::ostream& operator<<(std::ostream& os, const MimeType& mimeType); } #ifdef _MSC_VER #pragma warning(pop) #endif #endif // MITKMIMETYPE_H diff --git a/Core/Code/Interfaces/mitkIFileReader.h b/Core/Code/Interfaces/mitkIFileReader.h index 880503f558..cd4e8ef200 100644 --- a/Core/Code/Interfaces/mitkIFileReader.h +++ b/Core/Code/Interfaces/mitkIFileReader.h @@ -1,101 +1,129 @@ /*=================================================================== 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 IFileReader_H_HEADER_INCLUDED_C1E7E521 #define IFileReader_H_HEADER_INCLUDED_C1E7E521 #include #include #include namespace mitk { class BaseData; } namespace itk { template class SmartPointer; } namespace mitk { /** - * \brief The common interface for all MITK file readers. * \ingroup IO * \ingroup MicroServices_Interfaces * + * \brief The common interface for all MITK file readers. + * * Implementations of this interface must be registered as a service * to make themselve available via the service registry. If the * implementation is state-full, the service should be registered using * a PrototypeServiceFactory. * * The file reader implementation is associated with a mime-type, specified * in the service property PROP_MIMETYPE(). The specified mime-type should * have a corresponding CustomMimeType service object, registered by the reader * or some other party. * * It is recommended to derive new implementations from AbstractFileReader or * from AbstractFileIO (if both reader and writer is implemented), * which provide correct service registration semantics. * * \sa AbstractFileReader * \sa AbstractFileIO * \sa CustomMimeType * \sa FileReaderRegistry * \sa IFileWriter */ struct MITK_CORE_EXPORT IFileReader : public IFileIO { virtual ~IFileReader(); /** - * \brief Set the input file name. + * \brief Set the input location. * \param location The file name to read from. */ virtual void SetInput(const std::string& location) = 0; + /** + * @brief Set an input stream to read from. + * @param location A custom label for the input stream. + * @param is The input stream. + * + * If \c is is \c NULL, this clears the current input stream and \c location + * is interpreted as a file-system path. Otherwise, \c location is a custom + * label describing the input stream \c is. + */ virtual void SetInput(const std::string &location, std::istream* is) = 0; + /** + * @brief Get the current input location. + * @return The input location. + */ virtual std::string GetInputLocation() const = 0; + /** + * @brief Get the input stream. + * @return The currently set input stream. + */ virtual std::istream* GetInputStream() const = 0; /** * \brief Reads the specified file or input stream and returns its contents. * * \return A list of created BaseData objects. + * + * If GetInputStream() returns a non-null value, this method must use + * the returned stream object to read the data from. If no input stream + * was set, the data must be read from the path returned by GetInputLocation(). + * * \throws mitk::Exception */ virtual std::vector > Read() = 0; /** * \brief Reads the specified file or input stream, loading its * contents into the provided DataStorage. * * \param ds The DataStorage to which the data is added. * \return The set of added DataNodes to \c ds. + * + * This method may be overridden by implementations to create or + * reconstructed a hierarchy of mitk::DataNode instances in the + * provided mitk::DataStorage. + * * \throws mitk::Exception */ virtual DataStorage::SetOfObjects::Pointer Read(mitk::DataStorage& ds) = 0; }; } // namespace mitk MITK_DECLARE_SERVICE_INTERFACE(mitk::IFileReader, "org.mitk.IFileReader") #endif /* IFileReader_H_HEADER_INCLUDED_C1E7E521 */ diff --git a/Core/Code/Interfaces/mitkIFileWriter.h b/Core/Code/Interfaces/mitkIFileWriter.h index fa65ac5c9b..5cf5faa53e 100644 --- a/Core/Code/Interfaces/mitkIFileWriter.h +++ b/Core/Code/Interfaces/mitkIFileWriter.h @@ -1,88 +1,137 @@ /*=================================================================== 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 IFileWriter_H_HEADER_INCLUDED_C1E7E521 #define IFileWriter_H_HEADER_INCLUDED_C1E7E521 #include #include namespace mitk { class BaseData; } namespace mitk { /** * \ingroup IO * \ingroup MicroServices_Interfaces * * \brief The common interface of all MITK file writers. * * Implementations of this interface must be registered as a service * to make themselve available via the service registry. If the * implementation is state-full, the service should be registered using * a PrototypeServiceFactory. * * The file writer implementation is associated with a mime-type, specified * in the service property PROP_MIMETYPE() and a mitk::BaseData sub-class * as specified in the PROP_BASEDATA_TYPE() service property. * The specified mime-type should have a corresponding CustomMimeType service * object, registered by the reader or some other party. * * It is recommended to derive new implementations from AbstractFileWriter or * AbstractFileIO (if both reader and writer is implemented), * which provide correct service registration semantics. * * \sa AbstractFileWriter * \sa AbstractFileIO * \sa CustomMimeType * \sa FileWriterRegistry * \sa IFileReader */ struct MITK_CORE_EXPORT IFileWriter : public IFileIO { virtual ~IFileWriter(); + /** + * @brief Set the input data for writing. + * @param data The input data. + */ virtual void SetInput(const BaseData* data) = 0; + + /** + * @brief Get the input data set via SetInput(). + * @return The input data. + */ virtual const BaseData* GetInput() const = 0; + /** + * @brief Set the output location. + * @param location A file-system path. + * + * The location argument specifies a file-system path where the input + * data must be written. This method must remove any previously set + * output stream. + */ virtual void SetOutputLocation(const std::string& location) = 0; + + /** + * @brief Get the current output location. + * @return The output location. + * + * If no stream is set (i.e. GetOutputStream returns \c NULL), the + * returned location string is required to represent a file-system path. + */ virtual std::string GetOutputLocation() const = 0; + /** + * @brief Set an output stream for writing. + * @param location A custom label for the output stream. + * @param os The output stream. + * + * If \c os is \c NULL, this clears the current output stream and \c location + * is interpreted as a file-system path. Otherwise, \c location is a custom + * label describing the output stream \c os. + */ virtual void SetOutputStream(const std::string& location, std::ostream* os) = 0; + + /** + * @brief Get the output stream. + * @return The currently set output stream. + */ virtual std::ostream* GetOutputStream() const = 0; + /** + * @brief Write the input data. + * + * If GetOutputStream() returns a non-null value, this method must use + * the returned stream object to write the data set via SetInput(). If no + * output stream was set, the data must be written to the path returned + * by GetOutputLocation(). + * + * @throws mitk::Exception + */ virtual void Write() = 0; /** - * @brief Service property name for the supported mitk::BaseData sub-class + * @brief Service property name for the supported mitk::BaseData sub-class. * * The property value must be of type \c std::string. * * @return The property name. */ static std::string PROP_BASEDATA_TYPE(); }; } // namespace mitk MITK_DECLARE_SERVICE_INTERFACE(mitk::IFileWriter, "org.mitk.IFileWriter") #endif /* IFileWriter_H_HEADER_INCLUDED_C1E7E521 */ diff --git a/Core/Documentation/Doxygen/Concepts/ReaderWriterPage.md b/Core/Documentation/Doxygen/Concepts/ReaderWriterPage.md index b69a5c954a..0741586d80 100644 --- a/Core/Documentation/Doxygen/Concepts/ReaderWriterPage.md +++ b/Core/Documentation/Doxygen/Concepts/ReaderWriterPage.md @@ -1,37 +1,73 @@ Reader and Writer {#ReaderWriterPage} ================= +This page is work in progress. ## Mime Types +The MimeType class provides meta-data about a specific data format. +Every mitk::IFileReader and mitk::IFileWriter instance must be associated +with exactly one mime-type via a service property. + +Mime-type are used for categorizing data formats and creating filter +strings in file open and save dialogs. Hence they effectively control +the accessible set of data formats from a graphical user interface. + ## The IFileReader interface +This is the main interface for reading data from files or streams. +However, instances of this interface are rarely used directly. +See the mitk::IOUtil section below. + ## The IFileWriter interface +This is the main interface for writing data to files or streams. +However, instances of this interface are rarely used directly. +See the mitk::IOUtil section below. + +## Ranking strategies + +Todo. + ## Convenience classes -### mitk:IOUtil +Developers usually do not interact with the service registry directly +to retrieve and select a matching mitk::IFileReader or mitk::IFileWriter instance. -For loading data into a data storage or just returning BaseData objects. -Handles all the details for you. +### IOUtil -### QmitkIOUtil +This class provides convenience methods for loading data into a data +storage or just returning BaseData objects. The mitk::IOUtil::Save() +and mitk::IOUtil::Load() methods cover thy typical use cases and +automatically select the best matching mitk::IFileReader and mitk::IFileWriter +instance. -### mitk::FileReaderRegistry and mitk::FileWriterRegistry +### %QmitkIOUtil -Access to IFileReader and IFileWriter objects and their service references. +The QmitkIOUtil class is a wrapper around mitk::IOUtil, providing +file open and save dialogs for selecting a file name from a within +a graphical user interface. -## Meta Data +### FileReaderRegistry and FileWriterRegistry -## Options +Access to mitk::IFileReader and mitk::IFileWriter objects and their service references. -#### raw image file reader +## Integrating external I/O mechanisms -### ITK Reader and Writer +The MITK I/O system integrates with several external I/O systems. -Dynamic object factory registration? +### ITK Reader and Writer +The I/O classes from ITK are automatically added to the service registry +of MITK. They can be transparently used via the mitk::IFileReader and mitk::IFileWriter +interfaces or the mitk::IOUtil methods. ### VTK Reader and Writer +VTK does not provide a mechanism to enumerate all available I/O classes. +Hence MITK provides manual integration of a specific set of VTK readers +and writers. + ## Error handling and recovery + +Todo. diff --git a/Core/Documentation/Doxygen/Groups/Modules.dox b/Core/Documentation/Doxygen/Groups/Modules.dox index 8a1f055fd8..00dabce1db 100644 --- a/Core/Documentation/Doxygen/Groups/Modules.dox +++ b/Core/Documentation/Doxygen/Groups/Modules.dox @@ -1,98 +1,105 @@ /** \defgroup Core Core \ingroup MITKModules \brief This category includes classes of the MITK Core module. The MITK Core module contains abstractions for common data types and their geometries, I/O facilities for loading and saving data in various formats, infrastructures for handling user interaction and undo/redo operations, GUI toolkit independent visualization classes, and a generic service registry. In almost all cases, additional MITK modules will make use of classes contained in the Core module. */ /** \defgroup Data Data Classes \ingroup Core \brief This subcategory includes the data classes, e.g., for images (mitk::Image), surfaces (mitk::Surface), vessel-trees (mitk::VesselTreeData), etc. Data access classes are only included, if there is no equivalent in itk (see \ref ProcessAndAdaptorClasses "Process and Adaptor Classes" below). */ /** \defgroup IO IO Classes \ingroup Core \brief This subcategory includes the IO classes to read or write data objects. */ +/** + \defgroup DeprecatedIO Deprecated IO Classes + \ingroup Core + + \brief This subcategory includes the Deprecated IO classes to read or write data objects. +*/ + /** \defgroup DataStorage Data Storage Classes \ingroup Core \brief This subcategory includes the classes to store and retrieve objects from the mitk::DataStorage */ /** \defgroup ProcessAdaptor Process and Adaptor Classes \ingroup Core \brief This category includes process (algorithm) classes developed specifically for mitk and (mainly) adaptor classes for the integration of algorithms from other toolkits (currently vtk, itk). The itk adaptor classes are also useful for data access to mitk data objects. */ /** \defgroup Process Process Classes \ingroup ProcessAdaptor \brief This subcategory includes process (algorithm) classes developed specifically for mitk. */ /** \defgroup InteractionUndo Interaction and Undo Classes \ingroup Core \brief This category includes classes that support the developer to create software that allows the user to interact with the data. This includes complex interactions that have multiple states (e.g., moving a handle of an active contour vs changing its local elasicity) and a concept to realize an undo/redo-mechanism. A detailed description of the rationale for these classes can be found in \ref InteractionPage. */ /** \defgroup Interaction Interaction Classes \ingroup InteractionUndo \brief This subcategory includes interaction classes (subclasses of mitk::StateMachine) that change the data according to the input of the user. For undo-support, the change is done by sending an OperationEvent to the respective data object, which changes itself accordingly. A detailed description of the rationale for these classes can be found in \ref InteractionPage. */ /** \defgroup Undo Undo Classes \ingroup InteractionUndo \brief This subcategory includes the undo/redo-specific classes. For undo-support, the change is done by sending an OperationEvent to the respective data object, which changes itself accordingly. A detailed description of the rationale for these classes can be found in \ref InteractionPage. */ diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowserControls.ui b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowserControls.ui index 7dfd7b9d0a..6e48e64c1e 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowserControls.ui +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowserControls.ui @@ -1,307 +1,307 @@ QmitkDicomBrowserControls 0 0 752 696 0 0 0 0 false QmitkTemplate true 0 0 738 682 0 0 true 0 0 QTabWidget::North QTabWidget::Rounded - 2 + 1 32 32 0 0 :/org.mitk.gui.qt.dicom/drive-harddisk_32.png:/org.mitk.gui.qt.dicom/drive-harddisk_32.png Local Storage Manage your local dicom imports 0 0 0 0 :/org.mitk.gui.qt.dicom/import_32.png :/org.mitk.gui.qt.dicom/import_32.png:/org.mitk.gui.qt.dicom/import_32.png Import Import dicom data from any hard drive 0 0 0 0 :/org.mitk.gui.qt.dicom/network-workgroup_32.png:/org.mitk.gui.qt.dicom/network-workgroup_32.png Query Retrieve Query and retrieve dicom data from server 0 0 color: rgb(255, 0, 0); Warning: This is currently an experimental feature! 0 0 0 0 QFrame::StyledPanel QFrame::Raised 0 0 Qt::Horizontal QSizePolicy::Minimum 4 20 0 0 Qt::RichText Qt::Horizontal 40 20 Qt::Vertical 20 40 ctkDICOMQueryRetrieveWidget QWidget
ctkDICOMQueryRetrieveWidget.h
1
QmitkDicomLocalStorageWidget QWidget
Qmitk/QmitkDicomLocalStorageWidget.h
1
QmitkDicomExternalDataWidget QWidget
Qmitk/QmitkDicomExternalDataWidget.h
1
OnChangePage(int)
diff --git a/README.md b/README.md index 4986268598..f2b3c3f068 100644 --- a/README.md +++ b/README.md @@ -1,94 +1,94 @@ ![MITK Logo][logo] The [Medical Imaging Interaction Toolkit][mitk] (MITK) is a free open-source software system for development of interactive medical image processing software. MITK combines the [Insight Toolkit][itk] (ITK) and the [Visualization Toolkit][vtk] (VTK) with an application framework. The links below provide high-level and reference documentation targeting different usage scenarios: - Get a [high-level overview][mitk-overview] about MITK with pointers to further documentation - End-users looking for help with MITK applications should read the [MITK User Manual][mitk-usermanual] - Developers contributing to or using MITK, please see the [MITK Developer Manual][mitk-devmanual] as well as the [MITK API Reference][mitk-apiref] See the [MITK homepage][mitk] for details. Supported Platforms ----------------------------- MITK is a cross-platform C++ toolkit and officially supports: - Windows - MacOS X - Linux For details, please read the [Supported Platforms][platforms] page. License ----------- Copyright (c) [German Cancer Research Center][dkfz]. MITK is available as free open-source software under a [BSD-style license][license]. Download --------- The MITK source code and binaries for the *mitkWorkbench* application are released regularly according to the [MITK release cycle][release-cycle]. See the [Download][download] page for a list of releases. The official MITK source code is available in the [MITK Git repository][gitweb]. The Git clone command is git clone http://git.mitk.org/MITK.git Active development takes place in the MITK master branch and its usage is advised for advanced users only. How to Contribute -------------- Contributions of all kind are happily accepted. However, to make the contribution process as smooth as possible, please read the [How to contribute to MITK][contribute] page if you plan to contribute to MITK. Build Instructions ------------------------ MITK uses [CMake][cmake] to configure a build tree. The following is a crash course about cloning, configuring, and building MITK on a Linux/Unix system: git clone http://git.mitk.org/MITK.git mkdir MITK-build cd MITK-build cmake ../MITK make -j4 Read the comprehensive [Build Instructions][build] page for details. Useful Links ------------------ - [Homepage][mitk] - [Download][download] - [Mailing List][mailinglist] - [Bug Tracker][bugs] [logo]: https://github.com/MITK/MITK/raw/master/mitk.png [mitk]: http://mitk.org [itk]: http://www.itk.org [vtk]: http://www.vtk.org -[mitk-overview]: http://docs.mitk.org/nightly-qt4/Overview.html -[mitk-usermanual]: http://docs.mitk.org/nightly-qt4/UserManualPortal.html -[mitk-devmanual]: http://docs.mitk.org/nightly-qt4/DeveloperManualPortal.html -[mitk-apiref]: http://docs.mitk.org/nightly-qt4/usergroup0.html -[platforms]: http://docs.mitk.org/nightly-qt4/SupportedPlatformsPage.html +[mitk-overview]: http://docs.mitk.org/2014.10/Overview.html +[mitk-usermanual]: http://docs.mitk.org/2014.10/UserManualPortal.html +[mitk-devmanual]: http://docs.mitk.org/2014.10/DeveloperManualPortal.html +[mitk-apiref]: http://docs.mitk.org/2014.10/usergroup0.html +[platforms]: http://docs.mitk.org/2014.10/SupportedPlatformsPage.html [dkfz]: http://www.dkfz.de [license]: http://mitk.org/git/?p=MITK.git;a=blob_plain;f=LICENSE.txt [release-cycle]: http://mitk.org/MitkReleaseCycle [download]: http://mitk.org/Download [gitweb]: http://mitk.org/git/?p=MITK.git [contribute]: http://mitk.org/How_to_contribute [cmake]: http://www.cmake.org -[build]: http://docs.mitk.org/nightly-qt4/BuildInstructionsPage.html +[build]: http://docs.mitk.org/2014.10/BuildInstructionsPage.html [mailinglist]: http://mitk.org/Mailinglist [bugs]: http://bugs.mitk.org/