Medical Imaging Interaction Toolkit  2023.04.00
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=nullptr)
 Loads the specified files. More...
 
static mitk::DataStorage::SetOfObjects::Pointer Load (const QStringList &paths, mitk::DataStorage &storage, QWidget *parent=nullptr)
 
static QList< mitk::BaseData::PointerLoad (const QString &path, QWidget *parent=nullptr)
 
static mitk::DataStorage::SetOfObjects::Pointer Load (const QString &path, mitk::DataStorage &storage, QWidget *parent=nullptr)
 
static QString Save (const mitk::BaseData *data, const QString &defaultBaseName, const QString &defaultPath=QString(), QWidget *parent=nullptr, bool setPathProperty=false)
 
static QStringList Save (const std::vector< const mitk::BaseData * > &data, const QStringList &defaultBaseNames, const QString &defaultPath=QString(), QWidget *parent=nullptr, bool setPathProperty=false)
 Save a list of BaseData objects using a "File Save Dialog". More...
 
static void SaveBaseDataWithDialog (mitk::BaseData *data, std::string fileName, QWidget *parent=nullptr)
 SaveBaseDataWithDialog Convenience method to save any data with a Qt dialog. More...
 
static void SaveSurfaceWithDialog (mitk::Surface::Pointer surface, std::string fileName="", QWidget *parent=nullptr)
 SaveSurfaceWithDialog Convenience method to save a surface with a Qt dialog. More...
 
static void SaveImageWithDialog (mitk::Image::Pointer image, std::string fileName="", QWidget *parent=nullptr)
 SaveImageWithDialog Convenience method to save an image with a Qt dialog. More...
 
static void SavePointSetWithDialog (mitk::PointSet::Pointer pointset, std::string fileName="", QWidget *parent=nullptr)
 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, const ReaderOptionsFunctorBase *optionsCallback=nullptr)
 Load a file into the given DataStorage. More...
 
static DataStorage::SetOfObjects::Pointer Load (const std::string &path, const IFileReader::Options &options, DataStorage &storage)
 Load a file into the given DataStorage given user defined IFileReader::Options. More...
 
static std::vector< BaseData::PointerLoad (const std::string &path, const ReaderOptionsFunctorBase *optionsCallback=nullptr)
 Load a file and return the loaded data. More...
 
template<typename T >
static T::Pointer Load (const std::string &path, const ReaderOptionsFunctorBase *optionsCallback=nullptr)
 
static std::vector< BaseData::PointerLoad (const std::string &path, const IFileReader::Options &options)
 Load a file and return the loaded data. More...
 
template<typename T >
static T::Pointer Load (const std::string &path, const IFileReader::Options &options)
 
static DataStorage::SetOfObjects::Pointer Load (const std::vector< std::string > &paths, DataStorage &storage, const ReaderOptionsFunctorBase *optionsCallback=nullptr)
 Loads a list of file paths into the given DataStorage. More...
 
static std::vector< BaseData::PointerLoad (const std::vector< std::string > &paths, const ReaderOptionsFunctorBase *optionsCallback=nullptr)
 
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...
 
template<typename T >
static T::Pointer Load (const us::ModuleResource &usResource, std::ios_base::openmode mode=std::ios_base::in)
 
static BaseData::Pointer Load (const std::string &path, const PropertyList *properties)
 
static void Save (const mitk::BaseData *data, const std::string &path, bool setPathProperty=false)
 Save a mitk::BaseData instance. More...
 
static void Save (const mitk::BaseData *data, const std::string &path, const IFileWriter::Options &options, bool setPathProperty=false)
 Save a mitk::BaseData instance. More...
 
static void Save (const mitk::BaseData *data, const std::string &mimeType, const std::string &path, bool addExtension=true, bool setPathProperty=false)
 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, bool setPathProperty=false)
 Save a mitk::BaseData instance. More...
 
static void Save (std::vector< SaveInfo > &saveInfos, bool setPathProperty=false)
 Use SaveInfo objects to save BaseData instances. 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, const ReaderOptionsFunctorBase *optionsCallback)
 
static std::string Save (const BaseData *data, const std::string &mimeType, const std::string &path, WriterOptionsFunctorBase *optionsCallback, bool addExtension, bool setPathProperty)
 
static std::string Save (std::vector< SaveInfo > &saveInfos, WriterOptionsFunctorBase *optionsCallback, bool setPathProperty)
 

Detailed Description

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

Definition at line 51 of file QmitkIOUtil.h.

Member Function Documentation

◆ GetFileOpenFilterString()

static QString QmitkIOUtil::GetFileOpenFilterString ( )
static

GetFilterString.

Returns

◆ Load() [1/4]

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

◆ Load() [2/4]

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

◆ Load() [3/4]

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

◆ Load() [4/4]

static QList<mitk::BaseData::Pointer> QmitkIOUtil::Load ( const QStringList &  paths,
QWidget *  parent = nullptr 
)
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 nullptr, some files will be added to it automatically, dependeing on the IFileReader used.

Parameters
paths
parent
Returns
A list of BaseData instances which have not already been added to the data storage.

◆ Save() [1/2]

static QString QmitkIOUtil::Save ( const mitk::BaseData data,
const QString &  defaultBaseName,
const QString &  defaultPath = QString(),
QWidget *  parent = nullptr,
bool  setPathProperty = false 
)
static

◆ Save() [2/2]

static QStringList QmitkIOUtil::Save ( const std::vector< const mitk::BaseData * > &  data,
const QStringList &  defaultBaseNames,
const QString &  defaultPath = QString(),
QWidget *  parent = nullptr,
bool  setPathProperty = false 
)
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
setPathProperty
Returns

◆ SaveBaseDataWithDialog()

static void QmitkIOUtil::SaveBaseDataWithDialog ( mitk::BaseData data,
std::string  fileName,
QWidget *  parent = nullptr 
)
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.

◆ SaveImageWithDialog()

static void QmitkIOUtil::SaveImageWithDialog ( mitk::Image::Pointer  image,
std::string  fileName = "",
QWidget *  parent = nullptr 
)
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.

◆ SavePointSetWithDialog()

static void QmitkIOUtil::SavePointSetWithDialog ( mitk::PointSet::Pointer  pointset,
std::string  fileName = "",
QWidget *  parent = nullptr 
)
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.

◆ SaveSurfaceWithDialog()

static void QmitkIOUtil::SaveSurfaceWithDialog ( mitk::Surface::Pointer  surface,
std::string  fileName = "",
QWidget *  parent = nullptr 
)
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.

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