Slicer 5.6
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
qSlicerCoreIOManager.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Kitware Inc.
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17 and was partially funded by NIH grant 3P41RR013218-12S1
18
19==============================================================================*/
20
21#ifndef __qSlicerCoreIOManager_h
22#define __qSlicerCoreIOManager_h
23
24// Qt includes
25#include <QFileInfo>
26#include <QImage>
27#include <QList>
28#include <QMap>
29#include <QObject>
30#include <QString>
31#include <QVariantMap>
32
33// CTK includes
34#include <ctkPimpl.h>
35
36// QtCore includes
37#include <qSlicerIO.h>
38#include "qSlicerBaseQTCoreExport.h"
39
41class vtkMRMLNode;
44class vtkCollection;
45class vtkObject;
46class qSlicerCoreIOManagerPrivate;
49class Q_SLICER_BASE_QTCORE_EXPORT qSlicerCoreIOManager:public QObject
50{
51 Q_OBJECT;
52 Q_PROPERTY(QString defaultSceneFileType READ defaultSceneFileType WRITE setDefaultSceneFileType)
53
54public:
55 qSlicerCoreIOManager(QObject* parent = nullptr);
57
59 Q_INVOKABLE qSlicerIO::IOFileType fileType(const QString& file)const;
61 Q_INVOKABLE QList<qSlicerIO::IOFileType> fileTypes(const QString& file)const;
62
64 Q_INVOKABLE qSlicerIO::IOFileType fileTypeFromDescription(const QString& fileDescription)const;
65
69 Q_INVOKABLE QStringList fileDescriptions(const QString& file)const;
70
73 QStringList fileDescriptionsByType(const qSlicerIO::IOFileType fileType)const;
74
76 qSlicerFileWriter* writer(vtkObject* object, const QString& extension = QString())const;
77
79 Q_INVOKABLE qSlicerIO::IOFileType fileWriterFileType(vtkObject* object, const QString& extension=QString())const;
80
81 Q_INVOKABLE QStringList fileWriterDescriptions(const qSlicerIO::IOFileType& fileType)const;
82 Q_INVOKABLE QStringList fileWriterExtensions(vtkObject* object)const;
85 Q_INVOKABLE QStringList allWritableFileExtensions()const;
88 Q_INVOKABLE QStringList allReadableFileExtensions()const;
89
91 qSlicerIOOptions* fileOptions(const QString& fileDescription)const;
92
94 qSlicerIOOptions* fileWriterOptions(vtkObject* object, const QString& extension)const;
95
102
107 Q_INVOKABLE static QRegExp fileNameRegExp(const QString& extension = QString());
108
110 Q_INVOKABLE static QString forceFileNameValidCharacters(const QString& filename);
111
116 Q_INVOKABLE QString extractKnownExtension(const QString& fileName, vtkObject* object);
117
122 Q_INVOKABLE QString stripKnownExtension(const QString& fileName, vtkObject* object);
123
135 Q_INVOKABLE virtual bool loadNodes(const qSlicerIO::IOFileType& fileType,
136 const qSlicerIO::IOProperties& parameters,
137 vtkCollection* loadedNodes = nullptr,
138 vtkMRMLMessageCollection* userMessages = nullptr);
139
143 virtual bool loadNodes(const QList<qSlicerIO::IOProperties>& files,
144 vtkCollection* loadedNodes = nullptr,
145 vtkMRMLMessageCollection* userMessages = nullptr);
146
152 const qSlicerIO::IOProperties& parameters,
153 vtkMRMLMessageCollection* userMessages = nullptr);
154
159 Q_INVOKABLE bool loadScene(const QString& fileName, bool clear = true,
160 vtkMRMLMessageCollection* userMessages = nullptr);
161
165 Q_INVOKABLE bool loadFile(const QString& fileName, vtkMRMLMessageCollection* userMessages = nullptr);
166
176 Q_INVOKABLE bool saveNodes(qSlicerIO::IOFileType fileType,
177 const qSlicerIO::IOProperties& parameters,
178 vtkMRMLMessageCollection* userMessages=nullptr,
179 vtkMRMLScene* scene=nullptr
180 );
181
190 Q_INVOKABLE bool exportNodes(
191 const QList<qSlicerIO::IOProperties>& parameterMaps,
192 bool hardenTransforms,
193 vtkMRMLMessageCollection* userMessages=nullptr
194 );
195
200 Q_INVOKABLE bool exportNodes(
201 const QStringList& nodeIDs,
202 const QStringList& fileNames,
203 const qSlicerIO::IOProperties& commonParameterMap,
204 bool hardenTransforms,
205 vtkMRMLMessageCollection* userMessages = nullptr
206 );
207
213 Q_INVOKABLE bool saveScene(const QString& fileName, QImage screenShot,
214 vtkMRMLMessageCollection* userMessages=nullptr);
215
222 Q_INVOKABLE void addDefaultStorageNodes();
223
227
235 Q_INVOKABLE int registeredFileReaderCount(const qSlicerIO::IOFileType& fileType) const;
236 Q_INVOKABLE int registeredFileWriterCount(const qSlicerIO::IOFileType& fileType) const;
238
241
245 Q_INVOKABLE void emitNewFileLoaded(const QVariantMap& loadedFileParameters);
246
250 Q_INVOKABLE void emitFileSaved(const QVariantMap& savedFileParameters);
251
253 Q_INVOKABLE QString defaultSceneFileType()const;
254
268 Q_INVOKABLE bool examineFileInfoList(QFileInfoList &fileInfoList, QFileInfo &archetypeEntry, QString &readerDescription, qSlicerIO::IOProperties &ioProperties)const;
269
270public slots:
271
276
277signals:
278
284 void newFileLoaded(const qSlicerIO::IOProperties& loadedFileParameters);
285
290 void fileSaved(const qSlicerIO::IOProperties& savedFileParameters);
291
292protected:
293
296
301
304 qSlicerFileReader* reader(const QString& ioDescription)const;
305
306protected:
307 QScopedPointer<qSlicerCoreIOManagerPrivate> d_ptr;
308
309private:
310 Q_DECLARE_PRIVATE(qSlicerCoreIOManager);
311 Q_DISABLE_COPY(qSlicerCoreIOManager);
312};
313
314#endif
315
Q_INVOKABLE QStringList fileWriterExtensions(vtkObject *object) const
virtual Q_INVOKABLE bool loadNodes(const qSlicerIO::IOFileType &fileType, const qSlicerIO::IOProperties &parameters, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
Q_INVOKABLE QString completeSlicerWritableFileNameSuffix(vtkMRMLStorableNode *node) const
Q_INVOKABLE bool loadFile(const QString &fileName, vtkMRMLMessageCollection *userMessages=nullptr)
Q_INVOKABLE QString extractKnownExtension(const QString &fileName, vtkObject *object)
Q_INVOKABLE void emitFileSaved(const QVariantMap &savedFileParameters)
Q_INVOKABLE QStringList allReadableFileExtensions() const
void newFileLoaded(const qSlicerIO::IOProperties &loadedFileParameters)
Q_INVOKABLE bool loadScene(const QString &fileName, bool clear=true, vtkMRMLMessageCollection *userMessages=nullptr)
Q_INVOKABLE qSlicerIO::IOFileType fileWriterFileType(vtkObject *object, const QString &extension=QString()) const
Return the file type of the best file writer for the input VTK object.
Q_INVOKABLE QList< qSlicerIO::IOFileType > fileTypes(const QString &file) const
Return all supported file types for reading a file.
Q_INVOKABLE qSlicerIO::IOFileType fileTypeFromDescription(const QString &fileDescription) const
Return the most likely file description (SegmentationFile, TextFile, ...) for reading a file.
const QList< qSlicerFileReader * > & readers() const
Returns the list of registered readers.
virtual bool loadNodes(const QList< qSlicerIO::IOProperties > &files, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
const QList< qSlicerFileWriter * > & writers() const
Returns the list of registered writers.
Q_INVOKABLE QString stripKnownExtension(const QString &fileName, vtkObject *object)
void registerIO(qSlicerIO *io)
QScopedPointer< qSlicerCoreIOManagerPrivate > d_ptr
~qSlicerCoreIOManager() override
qSlicerFileWriter * writer(vtkObject *object, const QString &extension=QString()) const
Return best file writer for this object.
qSlicerFileReader * reader(const QString &ioDescription) const
Q_INVOKABLE QStringList fileDescriptions(const QString &file) const
static Q_INVOKABLE QRegExp fileNameRegExp(const QString &extension=QString())
static Q_INVOKABLE vtkMRMLStorageNode * createAndAddDefaultStorageNode(vtkMRMLStorableNode *node)
}@
vtkMRMLNode * loadNodesAndGetFirst(qSlicerIO::IOFileType fileType, const qSlicerIO::IOProperties &parameters, vtkMRMLMessageCollection *userMessages=nullptr)
void fileSaved(const qSlicerIO::IOProperties &savedFileParameters)
Q_INVOKABLE bool exportNodes(const QList< qSlicerIO::IOProperties > &parameterMaps, bool hardenTransforms, vtkMRMLMessageCollection *userMessages=nullptr)
qSlicerIOOptions * fileWriterOptions(vtkObject *object, const QString &extension) const
Return the file write options of the best file writer for the input VTK object.
Q_INVOKABLE void emitNewFileLoaded(const QVariantMap &loadedFileParameters)
Q_INVOKABLE qSlicerIO::IOFileType fileType(const QString &file) const
Return the most likely file type (SegmentationFile, TextFile, ...) for reading a file.
qSlicerIOOptions * fileOptions(const QString &fileDescription) const
Return the file read options for the best reader associated with a file type.
Q_INVOKABLE bool examineFileInfoList(QFileInfoList &fileInfoList, QFileInfo &archetypeEntry, QString &readerDescription, qSlicerIO::IOProperties &ioProperties) const
Q_INVOKABLE QStringList fileWriterDescriptions(const qSlicerIO::IOFileType &fileType) const
void setDefaultSceneFileType(QString)
QStringList fileDescriptionsByType(const qSlicerIO::IOFileType fileType) const
QList< qSlicerFileReader * > readers(const qSlicerIO::IOFileType &fileType) const
Returns the list of registered readers or writers associated with fileType.
Q_INVOKABLE void addDefaultStorageNodes()
Q_INVOKABLE bool saveScene(const QString &fileName, QImage screenShot, vtkMRMLMessageCollection *userMessages=nullptr)
Q_INVOKABLE bool exportNodes(const QStringList &nodeIDs, const QStringList &fileNames, const qSlicerIO::IOProperties &commonParameterMap, bool hardenTransforms, vtkMRMLMessageCollection *userMessages=nullptr)
Q_INVOKABLE int registeredFileWriterCount(const qSlicerIO::IOFileType &fileType) const
qSlicerCoreIOManager(QObject *parent=nullptr)
static Q_INVOKABLE QString forceFileNameValidCharacters(const QString &filename)
Remove characters that are likely to cause problems in a filename.
Q_INVOKABLE int registeredFileReaderCount(const qSlicerIO::IOFileType &fileType) const
Q_INVOKABLE QStringList allWritableFileExtensions() const
Q_INVOKABLE QString defaultSceneFileType() const
Defines the file format that should be offered by default when the scene is saved.
QList< qSlicerFileWriter * > writers(const qSlicerIO::IOFileType &fileType) const
Returns the list of registered writers for a given fileType.
Q_INVOKABLE bool saveNodes(qSlicerIO::IOFileType fileType, const qSlicerIO::IOProperties &parameters, vtkMRMLMessageCollection *userMessages=nullptr, vtkMRMLScene *scene=nullptr)
Base class for qSlicerFileReader and qSlicerFileWriter.
Definition qSlicerIO.h:44
QString IOFileType
Definition qSlicerIO.h:52
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.