Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLFileIOManager Class Reference

#include <Libs/MRML/Logic/vtkMRMLFileIOManager.h>

Inheritance diagram for vtkMRMLFileIOManager:
Collaboration diagram for vtkMRMLFileIOManager:

Classes

struct  ListProgress
 State of processing (loading or saving) a list of files. More...
 

Public Types

enum  {
  HandlerRegisteredEvent = 24100 , HandlerUnregisteredEvent , NewFileLoadedEvent , FileSavedEvent ,
  OperationStartEvent , OperationProgressEvent , OperationEndEvent
}
 
typedef vtkObject Superclass
 

Public Member Functions

void AddDefaultStorageNodes ()
 
vtkMRMLFileReader * ExamineFileList (std::vector< std::string > &fileList, vtkMRMLIOProperties *ioProperties)
 
bool ExportNodes (const std::vector< std::string > &nodeIDs, const std::vector< std::string > &fileNames, vtkMRMLIOProperties *commonProperties, bool hardenTransforms, vtkMRMLMessageCollection *userMessages=nullptr)
 Export nodes, with the same properties for all nodes.
 
bool ExportNodes (vtkCollection *propertiesList, bool hardenTransforms, vtkMRMLMessageCollection *userMessages=nullptr)
 
std::string ExtractKnownExtension (const std::string &fileName, vtkObject *object)
 
std::string ForceFileNameMaxLength (const std::string &filename, int extensionLength, int maxLength=-1)
 
std::vector< std::string > GetAllReadableFileExtensions ()
 All the readable file extensions for all registered types of storage nodes. Includes the leading dot.
 
std::vector< std::string > GetAllWritableFileExtensions ()
 File extensions and names.
 
vtkMRMLApplicationLogic * GetApplicationLogic () const
 
virtual const char * GetClassName ()
 
std::string GetCompleteSlicerWritableFileNameSuffix (vtkMRMLStorableNode *node)
 
virtual int GetDefaultMaximumFileNameLength ()
 
std::string GetDefaultSceneFileType () const
 
std::string GetDescriptionForFileType (const std::string &fileType, bool writers)
 What a file type is called ("Volume"), from the first handler that has a description.
 
std::vector< std::string > GetExtensionsForFileType (const std::string &fileType, bool writers)
 The extensions of every reader (or writer) of a file type: ".mcs", ".mcs.gz".
 
std::vector< std::string > GetFileDescriptionsByType (const std::string &fileType)
 Descriptions of all the readers of a file type. Usually there is only one reader for a file type.
 
std::vector< std::string > GetFileDescriptionsForFile (const std::string &filePath)
 The descriptions ("Volume", "Segmentation", ...) of the readers that can read the file, most likely first.
 
std::string GetFileTypeForFile (const std::string &filePath)
 The file type of the reader that is surest it can read this file ("VolumeFile"), or an empty string.
 
std::string GetFileTypeForObject (vtkObject *object)
 Same as GetFileWriterFileType(object).
 
std::string GetFileTypeFromDescription (const std::string &description)
 The file type of the reader that has the specified description, or an empty string.
 
std::vector< std::string > GetFileTypesForFile (const std::string &filePath)
 All the file types that can be used for reading the file, most likely first.
 
std::vector< std::string > GetFileWriterDescriptions (const std::string &fileType)
 Descriptions of all writers of a file type.
 
std::vector< std::string > GetFileWriterExtensions (vtkObject *object)
 Name filters of all writers that can write the object, the most confident writer's first.
 
std::string GetFileWriterFileType (vtkObject *object, const std::string &format=std::string())
 The file type of the best file writer for this object, or an empty string.
 
virtual double GetMaximumProgressUpdatesPerSecond ()
 
std::vector< std::string > GetNameFiltersForFileType (const std::string &fileType, bool writers)
 The name filters of every reader (or writer) of a file type: "Mimics project (*.mcs)".
 
vtkMRMLFileReader * GetNthReader (int index) const
 
vtkMRMLFileWriter * GetNthWriter (int index) const
 
int GetNumberOfReaders () const
 What is registered.
 
int GetNumberOfWriters () const
 
vtkMRMLFileReader * GetReaderByClassName (const std::string &className) const
 Get a registered reader or writer by its class name (exact match). Returns nullptr if not found.
 
vtkMRMLFileReader * GetReaderByDescription (const std::string &description)
 The reader that has the specified description, or nullptr.
 
std::vector< std::string > GetReaderFileTypes ()
 The file types that are registered, and what belongs to each of them.
 
vtkMRMLFileReader * GetReaderForFile (const std::string &filePath)
 The reader that is surest it can read this file, or nullptr.
 
std::vector< vtkSmartPointer< vtkMRMLFileReader > > GetReadersForFile (const std::string &filePath)
 Readers.
 
std::vector< vtkSmartPointer< vtkMRMLFileReader > > GetReadersForFileType (const std::string &fileType)
 The readers of a file type, in the order they were registered.
 
vtkMRMLScene * GetScene () const
 
vtkMRMLFileWriter * GetWriterByClassName (const std::string &className) const
 
std::vector< std::string > GetWriterFileTypes ()
 
vtkMRMLFileWriter * GetWriterForObject (vtkObject *object, const std::string &format=std::string())
 
std::vector< vtkSmartPointer< vtkMRMLFileWriter > > GetWritersForFileType (const std::string &fileType)
 The writers of a file type, in the order they were registered.
 
std::vector< vtkSmartPointer< vtkMRMLFileWriter > > GetWritersForObject (vtkObject *object)
 Writers.
 
void InvokeFileSavedEvent (vtkMRMLIOProperties *savedFileProperties)
 Invoke FileSavedEvent. It may be used by writers that save files without the manager.
 
void InvokeNewFileLoadedEvent (vtkMRMLIOProperties *loadedFileProperties)
 Invoke NewFileLoadedEvent. It may be used by readers that load files without the manager.
 
virtual int IsA (const char *type)
 
bool LoadFile (const std::string &fileName, vtkMRMLMessageCollection *userMessages=nullptr)
 Load a file. All the options (e.g., file type) are chosen by default.
 
virtual bool LoadNodes (const std::string &fileType, vtkMRMLIOProperties *properties, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
 Loading.
 
vtkMRMLNode * LoadNodesAndGetFirst (const std::string &fileType, vtkMRMLIOProperties *properties, vtkMRMLMessageCollection *userMessages=nullptr)
 Load nodes and return the first loaded node.
 
virtual bool LoadNodesFromList (vtkCollection *propertiesList, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
 
bool LoadScene (const std::string &fileName, bool clear=true, vtkMRMLMessageCollection *userMessages=nullptr)
 Load or import a scene.
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
void RegisterHandler (vtkMRMLFileIOHandler *handler)
 Add a reader or a writer (calls RegisterReader() or RegisterWriter(), depending on the type of the handler).
 
vtkMRMLNodeWriter * RegisterNodeWriter (const std::string &description, const std::string &fileType, const std::vector< std::string > &nodeClassNames, bool supportUseCompression=true)
 
void RegisterReader (vtkMRMLFileReader *reader)
 
void RegisterWriter (vtkMRMLFileWriter *writer)
 
bool SaveNodes (const std::string &fileType, vtkMRMLIOProperties *properties, vtkMRMLMessageCollection *userMessages=nullptr, vtkMRMLScene *scene=nullptr)
 Saving.
 
bool SaveScene (const std::string &fileName, vtkImageData *screenShot=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
 
void SetApplicationLogic (vtkMRMLApplicationLogic *applicationLogic)
 
virtual void SetDefaultMaximumFileNameLength (int)
 
void SetDefaultSceneFileType (const std::string &fileType)
 
virtual void SetMaximumProgressUpdatesPerSecond (double)
 
virtual void SetScene (vtkMRMLScene *scene)
 The scene the handlers read into and write from.
 
std::string StripKnownExtension (const std::string &fileName, vtkObject *object)
 
void UnregisterHandler (vtkMRMLFileIOHandler *handler)
 Remove a reader or a writer. Whoever registered a handler is responsible for unregistering it.
 

Static Public Member Functions

static vtkMRMLStorageNode * CreateAndAddDefaultStorageNode (vtkMRMLStorableNode *node)
 Create and add default storage node.
 
static std::string ForceFileNameValidCharacters (const std::string &filename)
 Remove characters that are likely to cause problems in a filename.
 
static std::string GetFileNameValidCharactersPattern ()
 
static int IsTypeOf (const char *type)
 
static vtkMRMLFileIOManager * New ()
 
static vtkMRMLFileIOManager * SafeDownCast (vtkObject *o)
 

Protected Member Functions

bool EndListItemProgress (ListProgress &listProgress, int fileIndex)
 
void EndListProgress (ListProgress &listProgress, vtkMRMLMessageCollection *userMessages, const std::string &abortedMessageFormat)
 
void EndOperationProgress (bool operationStarted, bool aborted=false)
 
bool ExportNode (vtkMRMLIOProperties *properties, vtkMRMLScene *temporaryScene, bool hardenTransforms, vtkMRMLMessageCollection *userMessages)
 
std::vector< vtkSmartPointer< vtkMRMLFileWriter > > GetWritersForFile (const std::string &fileType, vtkMRMLIOProperties *properties, vtkMRMLScene *scene)
 
void InvokeProgressEvent (bool force=false)
 
void ReportFileProgress (double fileProgress, const std::string &text=std::string())
 
void StartListItemProgress (ListProgress &listProgress, int fileIndex)
 Report that processing of the file at fileIndex starts.
 
ListProgress StartListProgress (const std::string &title, int numberOfFiles)
 
bool StartOperationProgress (const std::string &title, int numberOfFiles)
 
 vtkMRMLFileIOManager ()
 
 ~vtkMRMLFileIOManager () override
 

Static Protected Member Functions

static void OnSceneProgress (vtkObject *caller, unsigned long eid, void *clientData, void *callData)
 Forwards scene import or save progress (percent) as file progress.
 
template<typename HandlerType>
static std::vector< vtkSmartPointer< HandlerType > > SortedByConfidence (const std::vector< vtkSmartPointer< HandlerType > > &handlers, const std::vector< double > &confidences)
 

Protected Attributes

vtkWeakPointer< vtkMRMLApplicationLogic > ApplicationLogic
 
int DefaultMaximumFileNameLength { 1000 }
 
std::string DefaultSceneFileType
 
double LastProgressEventTime { 0.0 }
 Time of the last invoked progress event (universal time in seconds)
 
double MaximumProgressUpdatesPerSecond { 3.0 }
 
vtkSmartPointer< vtkMRMLOperationProgress > OperationProgress
 Progress of the loading or saving operation that is in progress (nullptr if no operation is in progress)
 
bool ProgressEventPending { false }
 True if progress changed since the last progress event.
 
std::vector< vtkSmartPointer< vtkMRMLFileReader > > Readers
 
vtkWeakPointer< vtkMRMLScene > Scene
 
bool SceneProgressObserved { false }
 True while the scene is observed for reporting its import progress.
 
std::vector< vtkSmartPointer< vtkMRMLFileWriter > > Writers
 

Detailed Description

Manages reading and writing of files: keeps the list of registered readers and writers, chooses the reader or writer to use for a file or a node, and loads and saves nodes using them. The application logic owns the file IO manager of the application (vtkMRMLApplicationLogic::GetFileIOManager()).

See https://slicer.readthedocs.io/en/latest/developer_guide/mrml_overview.html#file-reading-and-writing

Definition at line 50 of file vtkMRMLFileIOManager.h.

Member Typedef Documentation

◆ Superclass

Definition at line 54 of file vtkMRMLFileIOManager.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
HandlerRegisteredEvent 

A reader or writer is registered. Call data: the reader or writer (vtkMRMLFileIOHandler).

HandlerUnregisteredEvent 

A reader or writer is unregistered. Call data: the reader or writer (vtkMRMLFileIOHandler).

NewFileLoadedEvent 

A file is loaded. Call data: vtkMRMLIOProperties of the loaded file, which contains "fileType" and the IDs of the loaded nodes in "nodeIDs".

FileSavedEvent 

A file is saved. Call data: vtkMRMLIOProperties of the saved file.

OperationStartEvent 

Loading or saving of files is started. Call data: vtkMRMLOperationProgress.

OperationProgressEvent 

Progress of loading or saving files changed. Call data: vtkMRMLOperationProgress. The number of these events per second is limited by MaximumProgressUpdatesPerSecond (except when processing of a new file starts).

OperationEndEvent 

Loading or saving of files is completed. Call data: vtkMRMLOperationProgress.

Definition at line 57 of file vtkMRMLFileIOManager.h.

Constructor & Destructor Documentation

◆ vtkMRMLFileIOManager()

vtkMRMLFileIOManager::vtkMRMLFileIOManager ( )
protected

◆ ~vtkMRMLFileIOManager()

vtkMRMLFileIOManager::~vtkMRMLFileIOManager ( )
overrideprotected

Member Function Documentation

◆ AddDefaultStorageNodes()

void vtkMRMLFileIOManager::AddDefaultStorageNodes ( )

Create default storage nodes for all storable nodes that are to be saved with the scene and do not have a storage node already.

◆ CreateAndAddDefaultStorageNode()

static vtkMRMLStorageNode * vtkMRMLFileIOManager::CreateAndAddDefaultStorageNode ( vtkMRMLStorableNode * node)
static

Create and add default storage node.

◆ EndListItemProgress()

bool vtkMRMLFileIOManager::EndListItemProgress ( ListProgress & listProgress,
int fileIndex )
protected

Report that processing of the file at fileIndex is completed. Returns true if processing of the list must be stopped, because the operation is aborted.

◆ EndListProgress()

void vtkMRMLFileIOManager::EndListProgress ( ListProgress & listProgress,
vtkMRMLMessageCollection * userMessages,
const std::string & abortedMessageFormat )
protected

End processing of the list. If processing was aborted then a warning is added to userMessages (abortedMessageFormat contains %1 for the number of processed files and %2 for the number of files).

◆ EndOperationProgress()

void vtkMRMLFileIOManager::EndOperationProgress ( bool operationStarted,
bool aborted = false )
protected

End the operation (invokes OperationEndEvent), if it was started by StartOperationProgress(). If the operation is not aborted then completion of the operation is reported.

◆ ExamineFileList()

vtkMRMLFileReader * vtkMRMLFileIOManager::ExamineFileList ( std::vector< std::string > & fileList,
vtkMRMLIOProperties * ioProperties )

Iterates through readers looking at the file list to see if there is an entry that can serve as an archetype for loading multiple files. If so, the reader removes the recognized files from the list and sets the ioProperties so that the corresponding loader will read these files. The "fileName" property is set to the archetype file. Returns the reader that recognized the files or nullptr if no pattern is recognized. If multiple readers recognize a group of files then the one with the highest confidence (see vtkMRMLFileReader::ExamineFileListConfidence) is used. The specific motivating use case is when the file list contains a set of related files, such as a list of image files that are recognized as a volume. In Python, fileList must be a list (it is modified in place).

◆ ExportNode()

bool vtkMRMLFileIOManager::ExportNode ( vtkMRMLIOProperties * properties,
vtkMRMLScene * temporaryScene,
bool hardenTransforms,
vtkMRMLMessageCollection * userMessages )
protected

Export a single node to a file. Used by ExportNodes() to export each node of the list.

The node is copied into temporaryScene (with its display node and, if requested, with its parent transforms hardened) and saved from there, so that the storage nodes of the main scene are not modified.

Parameters
propertiesExport options: "nodeID" (ID of the node in the main scene), "fileName", "fileFormat", and any other options that the writer uses.
temporarySceneScene that ExportNodes() created for exporting. It is shared by all nodes of the list.
hardenTransformsIf true, parent transforms of the node are applied to the exported data.
userMessagesErrors and warnings to display to the user are added to this collection (may be nullptr).
Returns
True if the node was exported successfully. False if any error occurred, for example: the "nodeID", "fileName", or "fileFormat" property is missing, no storable node exists with the specified "nodeID", the node cannot be copied into the temporary scene, or the writer fails to write the file.

◆ ExportNodes() [1/2]

bool vtkMRMLFileIOManager::ExportNodes ( const std::vector< std::string > & nodeIDs,
const std::vector< std::string > & fileNames,
vtkMRMLIOProperties * commonProperties,
bool hardenTransforms,
vtkMRMLMessageCollection * userMessages = nullptr )

Export nodes, with the same properties for all nodes.

◆ ExportNodes() [2/2]

bool vtkMRMLFileIOManager::ExportNodes ( vtkCollection * propertiesList,
bool hardenTransforms,
vtkMRMLMessageCollection * userMessages = nullptr )

Export nodes using the registered writers. Unlike SaveNodes(), this function creates a temporary scene while saving, in order to avoid modifying storage nodes in the current scene. Saving progress is reported (see SaveNodes()), each exported node counts as one file. Exporting of multiple nodes is abortable. Each item in propertiesList is a vtkMRMLIOProperties object that specifies a "nodeID" (ID of a node in the main scene), a "fileName" (an absolute file path), a "fileFormat" (e.g. "NRRD (.nrrd)"), and any other options that the associated writer may use. If hardenTransforms is true then transforms are temporarily hardened before export. If a node cannot be exported then the remaining nodes are still exported. Returns true if all nodes were exported successfully.

◆ ExtractKnownExtension()

std::string vtkMRMLFileIOManager::ExtractKnownExtension ( const std::string & fileName,
vtkObject * object )

If fileName ends with an extension that is associated with the object, then return that extension. Otherwise return an empty string. If there are multiple candidates (such as for "something.seg.nrrd" both ".nrrd" and ".seg.nrrd" extensions match) then the longest is returned.

◆ ForceFileNameMaxLength()

std::string vtkMRMLFileIOManager::ForceFileNameMaxLength ( const std::string & filename,
int extensionLength,
int maxLength = -1 )

Clamp the length of a filename to a maximum number of characters. The length of the filename extension must also be specified so that it is not included in the shortened section. If the extension is not known then ExtractKnownExtension() method can be used to get the extension. If maxLength is negative, the default maximum length (DefaultMaximumFileNameLength) is used.

◆ ForceFileNameValidCharacters()

static std::string vtkMRMLFileIOManager::ForceFileNameValidCharacters ( const std::string & filename)
static

Remove characters that are likely to cause problems in a filename.

◆ GetAllReadableFileExtensions()

std::vector< std::string > vtkMRMLFileIOManager::GetAllReadableFileExtensions ( )

All the readable file extensions for all registered types of storage nodes. Includes the leading dot.

◆ GetAllWritableFileExtensions()

std::vector< std::string > vtkMRMLFileIOManager::GetAllWritableFileExtensions ( )

File extensions and names.

All the writable file extensions for all registered types of storage nodes. Includes the leading dot.

◆ GetApplicationLogic()

vtkMRMLApplicationLogic * vtkMRMLFileIOManager::GetApplicationLogic ( ) const

◆ GetClassName()

virtual const char * vtkMRMLFileIOManager::GetClassName ( )
virtual

◆ GetCompleteSlicerWritableFileNameSuffix()

std::string vtkMRMLFileIOManager::GetCompleteSlicerWritableFileNameSuffix ( vtkMRMLStorableNode * node)

Returns a full extension for this storable node that is recognised by Slicer IO. Consults the storage node for a list of known suffixes. If no match is found then "." is returned. Always includes the leading dot.

◆ GetDefaultMaximumFileNameLength()

virtual int vtkMRMLFileIOManager::GetDefaultMaximumFileNameLength ( )
virtual

Default maximum length for a filename. It is used when maximum filename length is enforced by calling ForceFileNameMaxLength() without providing a specific maximum length value.

◆ GetDefaultSceneFileType()

std::string vtkMRMLFileIOManager::GetDefaultSceneFileType ( ) const

Defines the file format that should be offered by default when the scene is saved. Valid options are defined by the scene writer (for example, "MRML Scene (.mrml)" or "Medical Reality Bundle (.mrb)").

◆ GetDescriptionForFileType()

std::string vtkMRMLFileIOManager::GetDescriptionForFileType ( const std::string & fileType,
bool writers )

What a file type is called ("Volume"), from the first handler that has a description.

◆ GetExtensionsForFileType()

std::vector< std::string > vtkMRMLFileIOManager::GetExtensionsForFileType ( const std::string & fileType,
bool writers )

The extensions of every reader (or writer) of a file type: ".mcs", ".mcs.gz".

◆ GetFileDescriptionsByType()

std::vector< std::string > vtkMRMLFileIOManager::GetFileDescriptionsByType ( const std::string & fileType)

Descriptions of all the readers of a file type. Usually there is only one reader for a file type.

◆ GetFileDescriptionsForFile()

std::vector< std::string > vtkMRMLFileIOManager::GetFileDescriptionsForFile ( const std::string & filePath)

The descriptions ("Volume", "Segmentation", ...) of the readers that can read the file, most likely first.

◆ GetFileNameValidCharactersPattern()

static std::string vtkMRMLFileIOManager::GetFileNameValidCharactersPattern ( )
static

Characters that are allowed in file names by ForceFileNameValidCharacters, as a regular expression character set.

◆ GetFileTypeForFile()

std::string vtkMRMLFileIOManager::GetFileTypeForFile ( const std::string & filePath)

The file type of the reader that is surest it can read this file ("VolumeFile"), or an empty string.

◆ GetFileTypeForObject()

std::string vtkMRMLFileIOManager::GetFileTypeForObject ( vtkObject * object)

Same as GetFileWriterFileType(object).

◆ GetFileTypeFromDescription()

std::string vtkMRMLFileIOManager::GetFileTypeFromDescription ( const std::string & description)

The file type of the reader that has the specified description, or an empty string.

◆ GetFileTypesForFile()

std::vector< std::string > vtkMRMLFileIOManager::GetFileTypesForFile ( const std::string & filePath)

All the file types that can be used for reading the file, most likely first.

◆ GetFileWriterDescriptions()

std::vector< std::string > vtkMRMLFileIOManager::GetFileWriterDescriptions ( const std::string & fileType)

Descriptions of all writers of a file type.

◆ GetFileWriterExtensions()

std::vector< std::string > vtkMRMLFileIOManager::GetFileWriterExtensions ( vtkObject * object)

Name filters of all writers that can write the object, the most confident writer's first.

◆ GetFileWriterFileType()

std::string vtkMRMLFileIOManager::GetFileWriterFileType ( vtkObject * object,
const std::string & format = std::string() )

The file type of the best file writer for this object, or an empty string.

◆ GetMaximumProgressUpdatesPerSecond()

virtual double vtkMRMLFileIOManager::GetMaximumProgressUpdatesPerSecond ( )
virtual

Maximum number of progress events (OperationProgressEvent) per second while loading or saving files. Progress changes that would exceed this rate are reported in the next progress event. 0 means that every progress change is reported. Default: 3.

◆ GetNameFiltersForFileType()

std::vector< std::string > vtkMRMLFileIOManager::GetNameFiltersForFileType ( const std::string & fileType,
bool writers )

The name filters of every reader (or writer) of a file type: "Mimics project (*.mcs)".

◆ GetNthReader()

vtkMRMLFileReader * vtkMRMLFileIOManager::GetNthReader ( int index) const

◆ GetNthWriter()

vtkMRMLFileWriter * vtkMRMLFileIOManager::GetNthWriter ( int index) const

◆ GetNumberOfReaders()

int vtkMRMLFileIOManager::GetNumberOfReaders ( ) const

What is registered.

◆ GetNumberOfWriters()

int vtkMRMLFileIOManager::GetNumberOfWriters ( ) const

◆ GetReaderByClassName()

vtkMRMLFileReader * vtkMRMLFileIOManager::GetReaderByClassName ( const std::string & className) const

Get a registered reader or writer by its class name (exact match). Returns nullptr if not found.

◆ GetReaderByDescription()

vtkMRMLFileReader * vtkMRMLFileIOManager::GetReaderByDescription ( const std::string & description)

The reader that has the specified description, or nullptr.

◆ GetReaderFileTypes()

std::vector< std::string > vtkMRMLFileIOManager::GetReaderFileTypes ( )

The file types that are registered, and what belongs to each of them.

◆ GetReaderForFile()

vtkMRMLFileReader * vtkMRMLFileIOManager::GetReaderForFile ( const std::string & filePath)

The reader that is surest it can read this file, or nullptr.

◆ GetReadersForFile()

std::vector< vtkSmartPointer< vtkMRMLFileReader > > vtkMRMLFileIOManager::GetReadersForFile ( const std::string & filePath)

Readers.

The readers that can read this file, the one that is surest of itself first. Only readers that answer a confidence above zero are in the list.

◆ GetReadersForFileType()

std::vector< vtkSmartPointer< vtkMRMLFileReader > > vtkMRMLFileIOManager::GetReadersForFileType ( const std::string & fileType)

The readers of a file type, in the order they were registered.

◆ GetScene()

vtkMRMLScene * vtkMRMLFileIOManager::GetScene ( ) const

◆ GetWriterByClassName()

vtkMRMLFileWriter * vtkMRMLFileIOManager::GetWriterByClassName ( const std::string & className) const

◆ GetWriterFileTypes()

std::vector< std::string > vtkMRMLFileIOManager::GetWriterFileTypes ( )

◆ GetWriterForObject()

vtkMRMLFileWriter * vtkMRMLFileIOManager::GetWriterForObject ( vtkObject * object,
const std::string & format = std::string() )

Return the best file writer for this object. Best match is the writer that supports the node type and the specific format (name filter, such as "NRRD (.nrrd)"), closest match is the writer that supports the node type but not that specific format. If there are multiple matches then the one with the highest confidence is returned. If format is empty then the writer with the highest confidence is returned.

◆ GetWritersForFile()

std::vector< vtkSmartPointer< vtkMRMLFileWriter > > vtkMRMLFileIOManager::GetWritersForFile ( const std::string & fileType,
vtkMRMLIOProperties * properties,
vtkMRMLScene * scene )
protected

Writers that can write the file, writers that match the file extension first and generic writers (that can write any file) last.

◆ GetWritersForFileType()

std::vector< vtkSmartPointer< vtkMRMLFileWriter > > vtkMRMLFileIOManager::GetWritersForFileType ( const std::string & fileType)

The writers of a file type, in the order they were registered.

◆ GetWritersForObject()

std::vector< vtkSmartPointer< vtkMRMLFileWriter > > vtkMRMLFileIOManager::GetWritersForObject ( vtkObject * object)

Writers.

The writers that can write this node, the one that is surest of itself first.

◆ InvokeFileSavedEvent()

void vtkMRMLFileIOManager::InvokeFileSavedEvent ( vtkMRMLIOProperties * savedFileProperties)

Invoke FileSavedEvent. It may be used by writers that save files without the manager.

◆ InvokeNewFileLoadedEvent()

void vtkMRMLFileIOManager::InvokeNewFileLoadedEvent ( vtkMRMLIOProperties * loadedFileProperties)

Invoke NewFileLoadedEvent. It may be used by readers that load files without the manager.

◆ InvokeProgressEvent()

void vtkMRMLFileIOManager::InvokeProgressEvent ( bool force = false)
protected

Invoke OperationProgressEvent with the current progress, unless the maximum update rate would be exceeded (then the event is invoked later). If force is true then the event is invoked regardless of the update rate.

◆ IsA()

virtual int vtkMRMLFileIOManager::IsA ( const char * type)
virtual

◆ IsTypeOf()

static int vtkMRMLFileIOManager::IsTypeOf ( const char * type)
static

◆ LoadFile()

bool vtkMRMLFileIOManager::LoadFile ( const std::string & fileName,
vtkMRMLMessageCollection * userMessages = nullptr )

Load a file. All the options (e.g., file type) are chosen by default.

◆ LoadNodes()

virtual bool vtkMRMLFileIOManager::LoadNodes ( const std::string & fileType,
vtkMRMLIOProperties * properties,
vtkCollection * loadedNodes = nullptr,
vtkMRMLMessageCollection * userMessages = nullptr )
virtual

Loading.

Load nodes using the readers of the file type. The properties must contain "fileName" (a string or a list of strings) and may contain more specific properties. For example, the volume reader can be called with the following parameters: "labelmap" (bool), "center" (bool). Nodes that are loaded are added to loadedNodes (if not nullptr). If a valid userMessages is passed then additional error or warning information is added to it. Returns false if loading fails.

Progress is reported by OperationStartEvent, OperationProgressEvent, and OperationEndEvent. A list of files is loaded as one operation, which can be aborted between files.

◆ LoadNodesAndGetFirst()

vtkMRMLNode * vtkMRMLFileIOManager::LoadNodesAndGetFirst ( const std::string & fileType,
vtkMRMLIOProperties * properties,
vtkMRMLMessageCollection * userMessages = nullptr )

Load nodes and return the first loaded node.

◆ LoadNodesFromList()

virtual bool vtkMRMLFileIOManager::LoadNodesFromList ( vtkCollection * propertiesList,
vtkCollection * loadedNodes = nullptr,
vtkMRMLMessageCollection * userMessages = nullptr )
virtual

Load a list of files. Each item in propertiesList is a vtkMRMLIOProperties object that specifies the "fileType" property in addition to the properties needed by the reader. Loading progress is reported (see LoadNodes()).

◆ LoadScene()

bool vtkMRMLFileIOManager::LoadScene ( const std::string & fileName,
bool clear = true,
vtkMRMLMessageCollection * userMessages = nullptr )

Load or import a scene.

◆ New()

static vtkMRMLFileIOManager * vtkMRMLFileIOManager::New ( )
static

◆ OnSceneProgress()

static void vtkMRMLFileIOManager::OnSceneProgress ( vtkObject * caller,
unsigned long eid,
void * clientData,
void * callData )
staticprotected

Forwards scene import or save progress (percent) as file progress.

◆ PrintSelf()

void vtkMRMLFileIOManager::PrintSelf ( ostream & os,
vtkIndent indent )
override

◆ RegisterHandler()

void vtkMRMLFileIOManager::RegisterHandler ( vtkMRMLFileIOHandler * handler)

Add a reader or a writer (calls RegisterReader() or RegisterWriter(), depending on the type of the handler).

◆ RegisterNodeWriter()

vtkMRMLNodeWriter * vtkMRMLFileIOManager::RegisterNodeWriter ( const std::string & description,
const std::string & fileType,
const std::vector< std::string > & nodeClassNames,
bool supportUseCompression = true )

Convenience method for creating and registering a vtkMRMLNodeWriter, which writes nodes of the specified classes using their storage nodes. Returns the registered writer.

See also
vtkMRMLNodeWriter::CreateNodeWriter()

◆ RegisterReader()

void vtkMRMLFileIOManager::RegisterReader ( vtkMRMLFileReader * reader)

Add a reader or a writer. The manager keeps a reference to it; registering the same object twice does nothing.

◆ RegisterWriter()

void vtkMRMLFileIOManager::RegisterWriter ( vtkMRMLFileWriter * writer)

◆ ReportFileProgress()

void vtkMRMLFileIOManager::ReportFileProgress ( double fileProgress,
const std::string & text = std::string() )
protected

Report progress of processing (loading or saving) the current file (0.0-1.0; negative value if only the text changes) and optionally update the progress text.

◆ SafeDownCast()

static vtkMRMLFileIOManager * vtkMRMLFileIOManager::SafeDownCast ( vtkObject * o)
static

◆ SaveNodes()

bool vtkMRMLFileIOManager::SaveNodes ( const std::string & fileType,
vtkMRMLIOProperties * properties,
vtkMRMLMessageCollection * userMessages = nullptr,
vtkMRMLScene * scene = nullptr )

Saving.

Save nodes (or scene) using the registered writers. Progress is reported the same way as for loading (see LoadNodes()). Properties are typically: "fileName"; for nodes: "nodeID", "useCompression", "fileFormat". If a valid scene is passed then the writers use that scene instead of the scene of the manager. Returns true on success.

◆ SaveScene()

bool vtkMRMLFileIOManager::SaveScene ( const std::string & fileName,
vtkImageData * screenShot = nullptr,
vtkMRMLMessageCollection * userMessages = nullptr )

Save the scene. Equivalent to calling SaveNodes with "SceneFile" file type with the fileName and screenShot set as properties.

◆ SetApplicationLogic()

void vtkMRMLFileIOManager::SetApplicationLogic ( vtkMRMLApplicationLogic * applicationLogic)

Application logic that owns this manager (not reference counted). Readers and writers may use it for accessing application-wide logic, such as the color logic.

◆ SetDefaultMaximumFileNameLength()

virtual void vtkMRMLFileIOManager::SetDefaultMaximumFileNameLength ( int )
virtual

◆ SetDefaultSceneFileType()

void vtkMRMLFileIOManager::SetDefaultSceneFileType ( const std::string & fileType)

◆ SetMaximumProgressUpdatesPerSecond()

virtual void vtkMRMLFileIOManager::SetMaximumProgressUpdatesPerSecond ( double )
virtual

◆ SetScene()

virtual void vtkMRMLFileIOManager::SetScene ( vtkMRMLScene * scene)
virtual

The scene the handlers read into and write from.

◆ SortedByConfidence()

template<typename HandlerType>
static std::vector< vtkSmartPointer< HandlerType > > vtkMRMLFileIOManager::SortedByConfidence ( const std::vector< vtkSmartPointer< HandlerType > > & handlers,
const std::vector< double > & confidences )
staticprotected

Handlers with their confidence, highest first; ties keep the order of registration. Handlers with zero confidence are not included.

◆ StartListItemProgress()

void vtkMRMLFileIOManager::StartListItemProgress ( ListProgress & listProgress,
int fileIndex )
protected

Report that processing of the file at fileIndex starts.

◆ StartListProgress()

ListProgress vtkMRMLFileIOManager::StartListProgress ( const std::string & title,
int numberOfFiles )
protected

Start processing a list of files (starts an operation if no operation is in progress). Each file covers an equal part of the progress range of the list. If the operation is started by the list then the files of the list are the files of the operation (see vtkMRMLOperationProgress::GetNumberOfFiles()).

◆ StartOperationProgress()

bool vtkMRMLFileIOManager::StartOperationProgress ( const std::string & title,
int numberOfFiles )
protected

Start a loading or saving operation, if no operation is in progress (invokes OperationStartEvent). numberOfFiles is 0 if a single file is processed (progress of processing a file is only known if it is reported). Returns true if a new operation is started.

◆ StripKnownExtension()

std::string vtkMRMLFileIOManager::StripKnownExtension ( const std::string & fileName,
vtkObject * object )

If fileName ends with an extension that is associated with the object, then return a stripped version of fileName, where that extension has been chopped off. If the extension is duplicated in the tail of fileName, then all duplicates are stripped away.

◆ UnregisterHandler()

void vtkMRMLFileIOManager::UnregisterHandler ( vtkMRMLFileIOHandler * handler)

Remove a reader or a writer. Whoever registered a handler is responsible for unregistering it.

Member Data Documentation

◆ ApplicationLogic

vtkWeakPointer<vtkMRMLApplicationLogic> vtkMRMLFileIOManager::ApplicationLogic
protected

Definition at line 339 of file vtkMRMLFileIOManager.h.

◆ DefaultMaximumFileNameLength

int vtkMRMLFileIOManager::DefaultMaximumFileNameLength { 1000 }
protected

Definition at line 344 of file vtkMRMLFileIOManager.h.

◆ DefaultSceneFileType

std::string vtkMRMLFileIOManager::DefaultSceneFileType
protected

Definition at line 343 of file vtkMRMLFileIOManager.h.

◆ LastProgressEventTime

double vtkMRMLFileIOManager::LastProgressEventTime { 0.0 }
protected

Time of the last invoked progress event (universal time in seconds)

Definition at line 406 of file vtkMRMLFileIOManager.h.

◆ MaximumProgressUpdatesPerSecond

double vtkMRMLFileIOManager::MaximumProgressUpdatesPerSecond { 3.0 }
protected

Definition at line 404 of file vtkMRMLFileIOManager.h.

◆ OperationProgress

vtkSmartPointer<vtkMRMLOperationProgress> vtkMRMLFileIOManager::OperationProgress
protected

Progress of the loading or saving operation that is in progress (nullptr if no operation is in progress)

Definition at line 411 of file vtkMRMLFileIOManager.h.

◆ ProgressEventPending

bool vtkMRMLFileIOManager::ProgressEventPending { false }
protected

True if progress changed since the last progress event.

Definition at line 408 of file vtkMRMLFileIOManager.h.

◆ Readers

std::vector<vtkSmartPointer<vtkMRMLFileReader> > vtkMRMLFileIOManager::Readers
protected

Definition at line 340 of file vtkMRMLFileIOManager.h.

◆ Scene

vtkWeakPointer<vtkMRMLScene> vtkMRMLFileIOManager::Scene
protected

Definition at line 338 of file vtkMRMLFileIOManager.h.

◆ SceneProgressObserved

bool vtkMRMLFileIOManager::SceneProgressObserved { false }
protected

True while the scene is observed for reporting its import progress.

Definition at line 413 of file vtkMRMLFileIOManager.h.

◆ Writers

std::vector<vtkSmartPointer<vtkMRMLFileWriter> > vtkMRMLFileIOManager::Writers
protected

Definition at line 341 of file vtkMRMLFileIOManager.h.


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