Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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 <QList>
26 #include <QImage>
27 #include <QMap>
28 #include <QObject>
29 #include <QVariantMap>
30 
31 // CTK includes
32 #include <ctkPimpl.h>
33 
34 // QtCore includes
35 #include <qSlicerIO.h>
36 #include "qSlicerBaseQTCoreExport.h"
37 
38 class vtkMRMLNode;
40 class vtkMRMLStorageNode;
41 class vtkCollection;
42 class vtkObject;
43 class qSlicerCoreIOManagerPrivate;
44 class qSlicerFileReader;
45 class qSlicerFileWriter;
46 class Q_SLICER_BASE_QTCORE_EXPORT qSlicerCoreIOManager:public QObject
47 {
48  Q_OBJECT;
49  Q_PROPERTY(QString defaultSceneFileType READ defaultSceneFileType WRITE setDefaultSceneFileType)
50 
51 public:
52  qSlicerCoreIOManager(QObject* parent = 0);
53  virtual ~qSlicerCoreIOManager();
54 
56  Q_INVOKABLE qSlicerIO::IOFileType fileType(const QString& file)const;
57  Q_INVOKABLE QList<qSlicerIO::IOFileType> fileTypes(const QString& file)const;
58  Q_INVOKABLE qSlicerIO::IOFileType fileTypeFromDescription(const QString& fileDescription)const;
59 
63  Q_INVOKABLE QStringList fileDescriptions(const QString& file)const;
64  QStringList fileDescriptionsByType(const qSlicerIO::IOFileType fileType)const;
65 
67  Q_INVOKABLE qSlicerIO::IOFileType fileWriterFileType(vtkObject* object)const;
68 
69  Q_INVOKABLE QStringList fileWriterDescriptions(const qSlicerIO::IOFileType& fileType)const;
70  Q_INVOKABLE QStringList fileWriterExtensions(vtkObject* object)const;
73  Q_INVOKABLE QStringList allWritableFileExtensions()const;
76  Q_INVOKABLE QStringList allReadableFileExtensions()const;
77 
79  qSlicerIOOptions* fileOptions(const QString& fileDescription)const;
80  qSlicerIOOptions* fileWriterOptions(vtkObject* object, const QString& extension)const;
81 
87  Q_INVOKABLE QString completeSlicerWritableFileNameSuffix(vtkMRMLStorableNode *node)const;
88 
99 #if QT_VERSION < 0x040700
100  Q_INVOKABLE virtual bool loadNodes(const qSlicerIO::IOFileType& fileType,
101  const QVariantMap& parameters,
102  vtkCollection* loadedNodes = 0);
103 #else
104  Q_INVOKABLE virtual bool loadNodes(const qSlicerIO::IOFileType& fileType,
105  const qSlicerIO::IOProperties& parameters,
106  vtkCollection* loadedNodes = 0);
107 #endif
108 
111  virtual bool loadNodes(const QList<qSlicerIO::IOProperties>& files,
112  vtkCollection* loadedNodes = 0);
113 
117  vtkMRMLNode* loadNodesAndGetFirst(qSlicerIO::IOFileType fileType,
118  const qSlicerIO::IOProperties& parameters);
119 
123  Q_INVOKABLE bool loadScene(const QString& fileName, bool clear = true);
124 
127  Q_INVOKABLE bool loadFile(const QString& fileName);
128 
136 #if QT_VERSION < 0x040700
137  Q_INVOKABLE bool saveNodes(qSlicerIO::IOFileType fileType,
138  const QVariantMap& parameters);
139 #else
140  Q_INVOKABLE bool saveNodes(qSlicerIO::IOFileType fileType,
141  const qSlicerIO::IOProperties& parameters);
142 #endif
143 
148  Q_INVOKABLE bool saveScene(const QString& fileName, QImage screenShot);
149 
156  Q_INVOKABLE void addDefaultStorageNodes();
157 
160  void registerIO(qSlicerIO* io);
161 
163  Q_INVOKABLE static vtkMRMLStorageNode* createAndAddDefaultStorageNode(vtkMRMLStorableNode* node);
164 
168  Q_INVOKABLE void emitNewFileLoaded(const QVariantMap& loadedFileParameters);
169 
171  Q_INVOKABLE QString defaultSceneFileType()const;
172 
173 public slots:
174 
178  void setDefaultSceneFileType(QString);
179 
180 signals:
181 
187  void newFileLoaded(const qSlicerIO::IOProperties& loadedFileParameters);
188 
189 protected:
190 
192  const QList<qSlicerFileReader*>& readers()const;
193 
195  const QList<qSlicerFileWriter*>& writers()const;
197  QList<qSlicerFileWriter*> writers(const qSlicerIO::IOFileType& fileType)const;
198 
200  QList<qSlicerFileReader*> readers(const qSlicerIO::IOFileType& fileType)const;
201  qSlicerFileReader* reader(const QString& ioDescription)const;
202 
203 protected:
204  QScopedPointer<qSlicerCoreIOManagerPrivate> d_ptr;
205 
206 private:
207  Q_DECLARE_PRIVATE(qSlicerCoreIOManager);
208  Q_DISABLE_COPY(qSlicerCoreIOManager);
209 };
210 
211 #endif
212 
QScopedPointer< qSlicerCoreIOManagerPrivate > d_ptr
MRML node to represent a 3D surface model.
A superclass for other storage nodes.
Base class for qSlicerFileReader and qSlicerFileWriter.
Definition: qSlicerIO.h:39
QString IOFileType
Definition: qSlicerIO.h:50
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138