18#ifndef __vtkMRMLFileIOManager_h
19#define __vtkMRMLFileIOManager_h
21#include "vtkMRMLLogicExport.h"
24#include <vtkSmartPointer.h>
25#include <vtkWeakPointer.h>
54 void PrintSelf(ostream& os, vtkIndent indent)
override;
90 const std::string& fileType,
91 const std::vector<std::string>& nodeClassNames,
92 bool supportUseCompression =
true);
238 vtkCollection* loadedNodes =
nullptr,
274 const std::vector<std::string>& fileNames,
276 bool hardenTransforms,
308 template <
typename HandlerType>
309 static std::vector<vtkSmartPointer<HandlerType>>
SortedByConfidence(
const std::vector<vtkSmartPointer<HandlerType>>& handlers,
310 const std::vector<double>& confidences);
318 std::vector<vtkSmartPointer<vtkMRMLFileReader>>
Readers;
319 std::vector<vtkSmartPointer<vtkMRMLFileWriter>>
Writers;
bool LoadFile(const std::string &fileName, vtkMRMLMessageCollection *userMessages=nullptr)
Load a file. All the options (e.g., file type) are chosen by default.
std::vector< vtkSmartPointer< vtkMRMLFileReader > > GetReadersForFileType(const std::string &fileType)
The readers of a file type, in the order they were registered.
vtkWeakPointer< vtkMRMLApplicationLogic > ApplicationLogic
void PrintSelf(ostream &os, vtkIndent indent) override
std::string GetFileTypeForObject(vtkObject *object)
Same as GetFileWriterFileType(object).
@ HandlerUnregisteredEvent
std::vector< vtkSmartPointer< vtkMRMLFileWriter > > Writers
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)".
virtual bool LoadNodes(const std::string &fileType, vtkMRMLIOProperties *properties, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
Loading.
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.
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.
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".
vtkWeakPointer< vtkMRMLScene > Scene
std::vector< vtkSmartPointer< vtkMRMLFileReader > > Readers
std::vector< std::string > GetAllWritableFileExtensions()
File extensions and names.
vtkMRMLFileWriter * GetWriterByClassName(const std::string &className) const
static std::string ForceFileNameValidCharacters(const std::string &filename)
Remove characters that are likely to cause problems in a filename.
std::string GetDefaultSceneFileType() const
void AddDefaultStorageNodes()
std::vector< std::string > GetFileTypesForFile(const std::string &filePath)
All the file types that can be used for reading the file, most likely first.
void InvokeFileSavedEvent(vtkMRMLIOProperties *savedFileProperties)
Invoke FileSavedEvent. It may be used by writers that save files without the manager.
void RegisterReader(vtkMRMLFileReader *reader)
vtkMRMLNodeWriter * RegisterNodeWriter(const std::string &description, const std::string &fileType, const std::vector< std::string > &nodeClassNames, bool supportUseCompression=true)
~vtkMRMLFileIOManager() override
static vtkMRMLStorageNode * CreateAndAddDefaultStorageNode(vtkMRMLStorableNode *node)
Create and add default storage node.
vtkMRMLFileWriter * GetWriterForObject(vtkObject *object, const std::string &format=std::string())
std::string StripKnownExtension(const std::string &fileName, vtkObject *object)
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 > GetReaderFileTypes()
The file types that are registered, and what belongs to each of them.
void UnregisterHandler(vtkMRMLFileIOHandler *handler)
Remove a reader or a writer. Whoever registered a handler is responsible for unregistering it.
bool LoadScene(const std::string &fileName, bool clear=true, vtkMRMLMessageCollection *userMessages=nullptr)
Load or import a scene.
virtual void SetScene(vtkMRMLScene *scene)
The scene the handlers read into and write from.
void SetDefaultSceneFileType(const std::string &fileType)
static vtkMRMLFileIOManager * New()
std::vector< vtkSmartPointer< vtkMRMLFileReader > > GetReadersForFile(const std::string &filePath)
Readers.
static std::vector< vtkSmartPointer< HandlerType > > SortedByConfidence(const std::vector< vtkSmartPointer< HandlerType > > &handlers, const std::vector< double > &confidences)
int GetNumberOfWriters() const
void RegisterWriter(vtkMRMLFileWriter *writer)
bool SaveScene(const std::string &fileName, vtkImageData *screenShot=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
vtkMRMLFileReader * GetReaderByDescription(const std::string &description)
The reader that has the specified description, or nullptr.
std::vector< vtkSmartPointer< vtkMRMLFileWriter > > GetWritersForFile(const std::string &fileType, vtkMRMLIOProperties *properties, vtkMRMLScene *scene)
int GetNumberOfReaders() const
What is registered.
std::vector< vtkSmartPointer< vtkMRMLFileWriter > > GetWritersForObject(vtkObject *object)
Writers.
std::vector< std::string > GetFileWriterDescriptions(const std::string &fileType)
Descriptions of all writers of a file type.
vtkMRMLApplicationLogic * GetApplicationLogic() const
vtkMRMLFileReader * GetNthReader(int index) const
std::string GetFileTypeFromDescription(const std::string &description)
The file type of the reader that has the specified description, or an empty string.
virtual bool LoadNodesFromList(vtkCollection *propertiesList, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
void InvokeNewFileLoadedEvent(vtkMRMLIOProperties *loadedFileProperties)
Invoke NewFileLoadedEvent. It may be used by readers that load files without the manager.
vtkMRMLFileWriter * GetNthWriter(int index) const
std::string ForceFileNameMaxLength(const std::string &filename, int extensionLength, int maxLength=-1)
std::string DefaultSceneFileType
bool SaveNodes(const std::string &fileType, vtkMRMLIOProperties *properties, vtkMRMLMessageCollection *userMessages=nullptr, vtkMRMLScene *scene=nullptr)
Saving.
void SetApplicationLogic(vtkMRMLApplicationLogic *applicationLogic)
vtkMRMLScene * GetScene() const
vtkMRMLNode * LoadNodesAndGetFirst(const std::string &fileType, vtkMRMLIOProperties *properties, vtkMRMLMessageCollection *userMessages=nullptr)
Load nodes and return the first loaded node.
std::vector< vtkSmartPointer< vtkMRMLFileWriter > > GetWritersForFileType(const std::string &fileType)
The writers of a file type, in the order they were registered.
std::vector< std::string > GetWriterFileTypes()
static std::string GetFileNameValidCharactersPattern()
bool ExportNodes(vtkCollection *propertiesList, bool hardenTransforms, vtkMRMLMessageCollection *userMessages=nullptr)
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 ExtractKnownExtension(const std::string &fileName, vtkObject *object)
std::vector< std::string > GetAllReadableFileExtensions()
All the readable file extensions for all registered types of storage nodes. Includes the leading dot.
vtkMRMLFileReader * GetReaderForFile(const std::string &filePath)
The reader that is surest it can read this file, or nullptr.
void RegisterHandler(vtkMRMLFileIOHandler *handler)
std::string GetDescriptionForFileType(const std::string &fileType, bool writers)
What a file type is called ("Volume"), from the first handler that has a description.
vtkMRMLFileReader * ExamineFileList(std::vector< std::string > &fileList, vtkMRMLIOProperties *ioProperties)
std::vector< std::string > GetFileWriterExtensions(vtkObject *object)
Name filters of all writers that can write the object, the most confident writer's first.
int DefaultMaximumFileNameLength
std::vector< std::string > GetFileDescriptionsForFile(const std::string &filePath)
The descriptions ("Volume", "Segmentation", ...) of the readers that can read the file,...
std::string GetCompleteSlicerWritableFileNameSuffix(vtkMRMLStorableNode *node)
vtkMRMLFileReader * GetReaderByClassName(const std::string &className) const
Get a registered reader or writer by its class name (exact match). Returns nullptr if not found.
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node to represent a 3D surface model.
A superclass for other storage nodes.