Slicer 5.8
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 Q_PROPERTY(int defaultMaximumFileNameLength READ defaultMaximumFileNameLength WRITE setDefaultMaximumFileNameLength)
54
55public:
56 qSlicerCoreIOManager(QObject* parent = nullptr);
58
60 Q_INVOKABLE qSlicerIO::IOFileType fileType(const QString& file)const;
62 Q_INVOKABLE QList<qSlicerIO::IOFileType> fileTypes(const QString& file)const;
63
65 Q_INVOKABLE qSlicerIO::IOFileType fileTypeFromDescription(const QString& fileDescription)const;
66
70 Q_INVOKABLE QStringList fileDescriptions(const QString& file)const;
71
74 QStringList fileDescriptionsByType(const qSlicerIO::IOFileType fileType)const;
75
77 qSlicerFileWriter* writer(vtkObject* object, const QString& extension = QString())const;
78
80 Q_INVOKABLE qSlicerIO::IOFileType fileWriterFileType(vtkObject* object, const QString& extension=QString())const;
81
82 Q_INVOKABLE QStringList fileWriterDescriptions(const qSlicerIO::IOFileType& fileType)const;
83 Q_INVOKABLE QStringList fileWriterExtensions(vtkObject* object)const;
86 Q_INVOKABLE QStringList allWritableFileExtensions()const;
89 Q_INVOKABLE QStringList allReadableFileExtensions()const;
90
92 qSlicerIOOptions* fileOptions(const QString& fileDescription)const;
93
95 qSlicerIOOptions* fileWriterOptions(vtkObject* object, const QString& extension)const;
96
102 Q_INVOKABLE QString completeSlicerWritableFileNameSuffix(vtkMRMLStorableNode *node)const;
103
108 Q_INVOKABLE static QRegExp fileNameRegExp(const QString& extension = QString());
109
111 Q_INVOKABLE static QString forceFileNameValidCharacters(const QString& filename);
112
118 Q_INVOKABLE QString forceFileNameMaxLength(const QString& filename, int extensionLength, int maxLength=-1);
119
123 int defaultMaximumFileNameLength()const;
124
129 Q_INVOKABLE QString extractKnownExtension(const QString& fileName, vtkObject* object);
130
135 Q_INVOKABLE QString stripKnownExtension(const QString& fileName, vtkObject* object);
136
148 Q_INVOKABLE virtual bool loadNodes(const qSlicerIO::IOFileType& fileType,
149 const qSlicerIO::IOProperties& parameters,
150 vtkCollection* loadedNodes = nullptr,
151 vtkMRMLMessageCollection* userMessages = nullptr);
152
156 virtual bool loadNodes(const QList<qSlicerIO::IOProperties>& files,
157 vtkCollection* loadedNodes = nullptr,
158 vtkMRMLMessageCollection* userMessages = nullptr);
159
164 vtkMRMLNode* loadNodesAndGetFirst(qSlicerIO::IOFileType fileType,
165 const qSlicerIO::IOProperties& parameters,
166 vtkMRMLMessageCollection* userMessages = nullptr);
167
172 Q_INVOKABLE bool loadScene(const QString& fileName, bool clear = true,
173 vtkMRMLMessageCollection* userMessages = nullptr);
174
178 Q_INVOKABLE bool loadFile(const QString& fileName, vtkMRMLMessageCollection* userMessages = nullptr);
179
189 Q_INVOKABLE bool saveNodes(qSlicerIO::IOFileType fileType,
190 const qSlicerIO::IOProperties& parameters,
191 vtkMRMLMessageCollection* userMessages=nullptr,
192 vtkMRMLScene* scene=nullptr
193 );
194
203 Q_INVOKABLE bool exportNodes(
204 const QList<qSlicerIO::IOProperties>& parameterMaps,
205 bool hardenTransforms,
206 vtkMRMLMessageCollection* userMessages=nullptr
207 );
208
213 Q_INVOKABLE bool exportNodes(
214 const QStringList& nodeIDs,
215 const QStringList& fileNames,
216 const qSlicerIO::IOProperties& commonParameterMap,
217 bool hardenTransforms,
218 vtkMRMLMessageCollection* userMessages = nullptr
219 );
220
226 Q_INVOKABLE bool saveScene(const QString& fileName, QImage screenShot,
227 vtkMRMLMessageCollection* userMessages=nullptr);
228
235 Q_INVOKABLE void addDefaultStorageNodes();
236
239 void registerIO(qSlicerIO* io);
240
248 Q_INVOKABLE int registeredFileReaderCount(const qSlicerIO::IOFileType& fileType) const;
249 Q_INVOKABLE int registeredFileWriterCount(const qSlicerIO::IOFileType& fileType) const;
251
253 Q_INVOKABLE static vtkMRMLStorageNode* createAndAddDefaultStorageNode(vtkMRMLStorableNode* node);
254
258 Q_INVOKABLE void emitNewFileLoaded(const QVariantMap& loadedFileParameters);
259
263 Q_INVOKABLE void emitFileSaved(const QVariantMap& savedFileParameters);
264
266 Q_INVOKABLE QString defaultSceneFileType()const;
267
281 Q_INVOKABLE bool examineFileInfoList(QFileInfoList &fileInfoList, QFileInfo &archetypeEntry, QString &readerDescription, qSlicerIO::IOProperties &ioProperties)const;
282
283public slots:
284
288 void setDefaultSceneFileType(QString);
289
292 void setDefaultMaximumFileNameLength(int);
293
294signals:
295
301 void newFileLoaded(const qSlicerIO::IOProperties& loadedFileParameters);
302
307 void fileSaved(const qSlicerIO::IOProperties& savedFileParameters);
308
309protected:
310
312 const QList<qSlicerFileReader*>& readers()const;
313
315 const QList<qSlicerFileWriter*>& writers()const;
317 QList<qSlicerFileWriter*> writers(const qSlicerIO::IOFileType& fileType)const;
318
320 QList<qSlicerFileReader*> readers(const qSlicerIO::IOFileType& fileType)const;
321 qSlicerFileReader* reader(const QString& ioDescription)const;
322
323protected:
324 QScopedPointer<qSlicerCoreIOManagerPrivate> d_ptr;
325
326private:
327 Q_DECLARE_PRIVATE(qSlicerCoreIOManager);
328 Q_DISABLE_COPY(qSlicerCoreIOManager);
329};
330
331#endif
Base class for qSlicerFileReader and qSlicerFileWriter.
Definition qSlicerIO.h:44
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.