Slicer  4.8
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 public:
50  qSlicerCoreIOManager(QObject* parent = 0);
51  virtual ~qSlicerCoreIOManager();
52 
54  Q_INVOKABLE qSlicerIO::IOFileType fileType(const QString& file)const;
55  Q_INVOKABLE QList<qSlicerIO::IOFileType> fileTypes(const QString& file)const;
56  Q_INVOKABLE qSlicerIO::IOFileType fileTypeFromDescription(const QString& fileDescription)const;
57 
61  Q_INVOKABLE QStringList fileDescriptions(const QString& file)const;
62  QStringList fileDescriptionsByType(const qSlicerIO::IOFileType fileType)const;
63 
65  Q_INVOKABLE qSlicerIO::IOFileType fileWriterFileType(vtkObject* object)const;
66 
67  Q_INVOKABLE QStringList fileWriterDescriptions(const qSlicerIO::IOFileType& fileType)const;
68  Q_INVOKABLE QStringList fileWriterExtensions(vtkObject* object)const;
71  Q_INVOKABLE QStringList allWritableFileExtensions()const;
74  Q_INVOKABLE QStringList allReadableFileExtensions()const;
75 
77  qSlicerIOOptions* fileOptions(const QString& fileDescription)const;
78  qSlicerIOOptions* fileWriterOptions(vtkObject* object, const QString& extension)const;
79 
85  Q_INVOKABLE QString completeSlicerWritableFileNameSuffix(vtkMRMLStorableNode *node)const;
86 
97 #if QT_VERSION < 0x040700
98  Q_INVOKABLE virtual bool loadNodes(const qSlicerIO::IOFileType& fileType,
99  const QVariantMap& parameters,
100  vtkCollection* loadedNodes = 0);
101 #else
102  Q_INVOKABLE virtual bool loadNodes(const qSlicerIO::IOFileType& fileType,
103  const qSlicerIO::IOProperties& parameters,
104  vtkCollection* loadedNodes = 0);
105 #endif
106 
109  virtual bool loadNodes(const QList<qSlicerIO::IOProperties>& files,
110  vtkCollection* loadedNodes = 0);
111 
115  vtkMRMLNode* loadNodesAndGetFirst(qSlicerIO::IOFileType fileType,
116  const qSlicerIO::IOProperties& parameters);
117 
121  Q_INVOKABLE bool loadScene(const QString& fileName, bool clear = true);
122 
125  Q_INVOKABLE bool loadFile(const QString& fileName);
126 
134 #if QT_VERSION < 0x040700
135  Q_INVOKABLE bool saveNodes(qSlicerIO::IOFileType fileType,
136  const QVariantMap& parameters);
137 #else
138  Q_INVOKABLE bool saveNodes(qSlicerIO::IOFileType fileType,
139  const qSlicerIO::IOProperties& parameters);
140 #endif
141 
146  Q_INVOKABLE bool saveScene(const QString& fileName, QImage screenShot);
147 
150  void registerIO(qSlicerIO* io);
151 
153  Q_INVOKABLE static vtkMRMLStorageNode* createAndAddDefaultStorageNode(vtkMRMLStorableNode* node);
154 
158  Q_INVOKABLE void emitNewFileLoaded(const QVariantMap& loadedFileParameters);
159 
160 signals:
161 
167  void newFileLoaded(const qSlicerIO::IOProperties& loadedFileParameters);
168 
169 protected:
170 
172  const QList<qSlicerFileReader*>& readers()const;
173 
175  const QList<qSlicerFileWriter*>& writers()const;
177  QList<qSlicerFileWriter*> writers(const qSlicerIO::IOFileType& fileType)const;
178 
180  QList<qSlicerFileReader*> readers(const qSlicerIO::IOFileType& fileType)const;
181  qSlicerFileReader* reader(const QString& ioDescription)const;
182 
183 protected:
184  QScopedPointer<qSlicerCoreIOManagerPrivate> d_ptr;
185 
186 private:
187  Q_DECLARE_PRIVATE(qSlicerCoreIOManager);
188  Q_DISABLE_COPY(qSlicerCoreIOManager);
189 };
190 
191 #endif
192 
QScopedPointer< qSlicerCoreIOManagerPrivate > d_ptr
MRML node to represent a 3D surface model.
A supercalss 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:135