Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkIOUtil Class Reference

QmitkIOUtil Provides static helper methods to open and save files with Qt dialogs. More...

#include <QmitkIOUtil.h>

Inheritance diagram for QmitkIOUtil:
Collaboration diagram for QmitkIOUtil:

Classes

class  SaveFilter
 

Static Public Member Functions

static QString GetFileOpenFilterString ()
 GetFilterString. More...
 
static QList< mitk::BaseData::PointerLoad (const QStringList &paths, QWidget *parent=NULL)
 Loads the specified files. More...
 
static mitk::DataStorage::SetOfObjects::Pointer Load (const QStringList &paths, mitk::DataStorage &storage, QWidget *parent=NULL)
 
static QList< mitk::BaseData::PointerLoad (const QString &path, QWidget *parent=NULL)
 
static mitk::DataStorage::SetOfObjects::Pointer Load (const QString &path, mitk::DataStorage &storage, QWidget *parent=NULL)
 
static QString Save (const mitk::BaseData *data, const QString &defaultBaseName, const QString &defaultPath=QString(), QWidget *parent=NULL)
 
static QStringList Save (const std::vector< const mitk::BaseData * > &data, const QStringList &defaultBaseNames, const QString &defaultPath=QString(), QWidget *parent=NULL)
 Save a list of BaseData objects using a "File Save Dialog". More...
 
static void SaveBaseDataWithDialog (mitk::BaseData *data, std::string fileName, QWidget *parent=NULL)
 SaveBaseDataWithDialog Convenience method to save any data with a Qt dialog. More...
 
static void SaveSurfaceWithDialog (mitk::Surface::Pointer surface, std::string fileName="", QWidget *parent=NULL)
 SaveSurfaceWithDialog Convenience method to save a surface with a Qt dialog. More...
 
static void SaveImageWithDialog (mitk::Image::Pointer image, std::string fileName="", QWidget *parent=NULL)
 SaveImageWithDialog Convenience method to save an image with a Qt dialog. More...
 
static void SavePointSetWithDialog (mitk::PointSet::Pointer pointset, std::string fileName="", QWidget *parent=NULL)
 SavePointSetWithDialog Convenience method to save a pointset with a Qt dialog. More...
 
- Static Public Member Functions inherited from mitk::IOUtil
static std::string GetProgramPath ()
 
static std::string GetTempPath ()
 
static char GetDirectorySeparator ()
 
static std::string CreateTemporaryFile (std::ofstream &tmpStream, const std::string &templateName="XXXXXX", std::string path=std::string())
 
static std::string CreateTemporaryFile (std::ofstream &tmpStream, std::ios_base::openmode mode, const std::string &templateName="XXXXXX", std::string path=std::string())
 
static std::string CreateTemporaryFile (const std::string &templateName="XXXXXX", std::string path=std::string())
 
static std::string CreateTemporaryDirectory (const std::string &templateName="XXXXXX", std::string path=std::string())
 
static DataStorage::SetOfObjects::Pointer Load (const std::string &path, DataStorage &storage)
 Load a file into the given DataStorage. More...
 
static DataStorage::SetOfObjects::Pointer Load (const std::string &path, const IFileReader::Options &options, DataStorage &storage)
 
static std::vector< BaseData::PointerLoad (const std::string &path)
 
static std::vector< BaseData::PointerLoad (const std::string &path, const IFileReader::Options &options)
 
static DataStorage::SetOfObjects::Pointer Load (const std::vector< std::string > &paths, DataStorage &storage)
 Loads a list of file paths into the given DataStorage. More...
 
static std::vector< BaseData::PointerLoad (const std::vector< std::string > &paths)
 
static int LoadFiles (const std::vector< std::string > &fileNames, DataStorage &storage)
 
static DataStorage::Pointer LoadFiles (const std::vector< std::string > &fileNames)
 
static mitk::BaseData::Pointer LoadBaseData (const std::string &path)
 Create a BaseData object from the given file. More...
 
static mitk::DataNode::Pointer LoadDataNode (const std::string &path)
 LoadDataNode Method to load an arbitrary DataNode. More...
 
static mitk::Image::Pointer LoadImage (const std::string &path)
 LoadImage Convenience method to load an arbitrary mitkImage. More...
 
static mitk::Surface::Pointer LoadSurface (const std::string &path)
 LoadSurface Convenience method to load an arbitrary mitkSurface. More...
 
static mitk::PointSet::Pointer LoadPointSet (const std::string &path)
 LoadPointSet Convenience method to load an arbitrary mitkPointSet. More...
 
static std::vector< BaseData::PointerLoad (const us::ModuleResource &usResource, std::ios_base::openmode mode=std::ios_base::in)
 Loads the contents of a us::ModuleResource and returns the corresponding mitk::BaseData. More...
 
static void Save (const mitk::BaseData *data, const std::string &path)
 Save a mitk::BaseData instance. More...
 
static void Save (const mitk::BaseData *data, const std::string &path, const IFileWriter::Options &options)
 Save a mitk::BaseData instance. More...
 
static void Save (const mitk::BaseData *data, const std::string &mimeType, const std::string &path, bool addExtension=true)
 Save a mitk::BaseData instance. More...
 
static void Save (const mitk::BaseData *data, const std::string &mimeType, const std::string &path, const mitk::IFileWriter::Options &options, bool addExtension=true)
 Save a mitk::BaseData instance. More...
 
static void Save (std::vector< SaveInfo > &saveInfos)
 Use SaveInfo objects to save BaseData instances. More...
 
static bool SaveImage (mitk::Image::Pointer image, const std::string &path)
 SaveImage Convenience method to save an arbitrary mitkImage. More...
 
static bool SaveBaseData (mitk::BaseData *data, const std::string &path)
 SaveBaseData Convenience method to save arbitrary baseData. More...
 
static bool SaveSurface (mitk::Surface::Pointer surface, const std::string &path)
 SaveSurface Convenience method to save an arbitrary mitkSurface. More...
 
static bool SavePointSet (mitk::PointSet::Pointer pointset, const std::string &path)
 SavePointSet Convenience method to save an mitkPointSet. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from mitk::IOUtil
static std::string Load (std::vector< LoadInfo > &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< SaveInfo > &saveInfos, WriterOptionsFunctorBase *optionsCallback)
 

Detailed Description

QmitkIOUtil Provides static helper methods to open and save files with Qt dialogs.

Definition at line 55 of file QmitkIOUtil.h.

Member Function Documentation

QString QmitkIOUtil::GetFileOpenFilterString ( )
static
QList< mitk::BaseData::Pointer > QmitkIOUtil::Load ( const QStringList &  paths,
QWidget *  parent = NULL 
)
static

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.

Parameters
filesA list of files to load.
dsAn optional data storage passed to IFileReader instances
Returns
A list of BaseData instances which have not already been added to the data storage.

Definition at line 117 of file QmitkIOUtil.cpp.

References mitkThrow.

Referenced by Load(), and mitk::WorkbenchUtil::LoadFiles().

mitk::DataStorage::SetOfObjects::Pointer QmitkIOUtil::Load ( const QStringList &  paths,
mitk::DataStorage storage,
QWidget *  parent = NULL 
)
static

Definition at line 145 of file QmitkIOUtil.cpp.

References Load(), and mitk::New().

QList< mitk::BaseData::Pointer > QmitkIOUtil::Load ( const QString &  path,
QWidget *  parent = NULL 
)
static

Definition at line 165 of file QmitkIOUtil.cpp.

References Load().

mitk::DataStorage::SetOfObjects::Pointer QmitkIOUtil::Load ( const QString &  path,
mitk::DataStorage storage,
QWidget *  parent = NULL 
)
static

Definition at line 172 of file QmitkIOUtil.cpp.

References Load().

QString QmitkIOUtil::Save ( const mitk::BaseData data,
const QString &  defaultBaseName,
const QString &  defaultPath = QString(),
QWidget *  parent = NULL 
)
static
QStringList QmitkIOUtil::Save ( const std::vector< const mitk::BaseData * > &  data,
const QStringList &  defaultBaseNames,
const QString &  defaultPath = QString(),
QWidget *  parent = NULL 
)
static

Save a list of BaseData objects using a "File Save Dialog".

For each element in the 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. 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.
  3. The file name is matched against valid mime-types. The first mime-type which accepts the file name is associated with the current BaseData object. If no mime-type accepts the supplied file name and the file already exists, the process starts from the beginning with the next BaseData object. Otherwise, if the selected filter is the special "all" filter and the file name does not contain periods (which may or may not mark the start of a file extension), the current BaseData object is associated with the default mime-type. If the selected filter is not the special "all" filter, the mime-type for this filter is associated with the current BaseData object. The default extension of the associated mime-type is then appended to the supplied file name.
  4. 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.

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. 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.
Parameters
data
defaultBaseNames
defaultPath
parent
Returns

Definition at line 193 of file QmitkIOUtil.cpp.

References QmitkIOUtil::SaveFilter::ALL_MIMETYPE(), QmitkIOUtil::SaveFilter::GetDefaultFilter(), QmitkIOUtil::SaveFilter::GetDefaultMimeType(), mitk::MimeType::GetExtensions(), QmitkIOUtil::SaveFilter::GetMimeTypeForFilter(), QmitkIOUtil::SaveFilter::GetMimeTypes(), mitk::MimeType::GetName(), mitk::MimeType::IsValid(), mitk::IOUtil::SaveInfo::m_MimeType, mitk::IOUtil::SaveInfo::m_Path, mitk::IOUtil::SaveInfo::m_WriterSelector, mitkThrow, Save(), mitk::FileWriterSelector::Select(), QmitkIOUtil::SaveFilter::Size(), and QmitkIOUtil::SaveFilter::ToString().

void QmitkIOUtil::SaveBaseDataWithDialog ( mitk::BaseData data,
std::string  fileName,
QWidget *  parent = NULL 
)
static

SaveBaseDataWithDialog Convenience method to save any data with a Qt dialog.

Parameters
dataBaseData holding the data you wish to save.
fileNameThe file name where to save the data (including path and extension).
parentAn optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen.
Deprecated:
(as of 2014_10) Use Save() instead.

Definition at line 374 of file QmitkIOUtil.cpp.

References Save().

void QmitkIOUtil::SaveImageWithDialog ( mitk::Image::Pointer  image,
std::string  fileName = "",
QWidget *  parent = NULL 
)
static

SaveImageWithDialog Convenience method to save an image with a Qt dialog.

Parameters
imageThe image to save.
fileNameThe file name where to save the data (including path and extension).
parentAn optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen.
Deprecated:
(as of 2014_10) Use Save() instead.

Definition at line 384 of file QmitkIOUtil.cpp.

References Save().

void QmitkIOUtil::SavePointSetWithDialog ( mitk::PointSet::Pointer  pointset,
std::string  fileName = "",
QWidget *  parent = NULL 
)
static

SavePointSetWithDialog Convenience method to save a pointset with a Qt dialog.

Parameters
pointsetThe pointset to save.
fileNameThe file name where to save the data (including path and extension).
parentAn optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen.
Deprecated:
(as of 2014_10) Use Save() instead.

Definition at line 389 of file QmitkIOUtil.cpp.

References Save().

void QmitkIOUtil::SaveSurfaceWithDialog ( mitk::Surface::Pointer  surface,
std::string  fileName = "",
QWidget *  parent = NULL 
)
static

SaveSurfaceWithDialog Convenience method to save a surface with a Qt dialog.

Parameters
surfaceThe surface to save.
fileNameThe file name where to save the data (including path and extension).
parentAn optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen.
Deprecated:
(as of 2014_10) Use Save() instead.

Definition at line 379 of file QmitkIOUtil.cpp.

References Save().


The documentation for this class was generated from the following files: