Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
qSlicerIOManager.h
Go to the documentation of this file.
1#ifndef __qSlicerIOManager_h
2#define __qSlicerIOManager_h
3
4// Qt includes
5#include <QList>
6#include <QString>
7#include <QUrl>
8
9// CTK includes
10#include <ctkVTKObject.h>
11
12// SlicerQ includes
13#include "qSlicerApplication.h"
15#include "qSlicerFileDialog.h"
16
17#include "qSlicerBaseQTGUIExport.h"
18
20class QDragEnterEvent;
21class QDropEvent;
22class QWidget;
23
24class qSlicerIOManagerPrivate;
26
27class Q_SLICER_BASE_QTGUI_EXPORT qSlicerIOManager : public qSlicerCoreIOManager
28{
29 Q_OBJECT;
30 QVTK_OBJECT;
31
32public:
34 qSlicerIOManager(QObject* parent = nullptr);
36
50 vtkCollection* loadedNodes = nullptr);
51
52 Q_INVOKABLE void addHistory(const QString& path);
53 Q_INVOKABLE QStringList history() const;
54
55 Q_INVOKABLE void setFavorites(const QList<QUrl>& urls);
56 Q_INVOKABLE QList<QUrl> favorites() const;
57
60 Q_INVOKABLE void registerDialog(qSlicerFileDialog* dialog);
61
68 qSlicerIOOptionsWidget* fileOptionsWidget(const QString& fileDescription, QWidget* parent = nullptr) const;
69
76 qSlicerIOOptionsWidget* fileWriterOptionsWidget(vtkObject* object, const QString& extension = QString(), QWidget* parent = nullptr) const;
77
84
87 Q_INVOKABLE bool loadNodes(const qSlicerIO::IOFileType& fileType,
88 const qSlicerIO::IOProperties& parameters,
89 vtkCollection* loadedNodes = nullptr,
90 vtkMRMLMessageCollection* userMessages = nullptr) override;
93 Q_INVOKABLE bool loadNodes(const QList<qSlicerIO::IOProperties>& files, vtkCollection* loadedNodes = nullptr, vtkMRMLMessageCollection* userMessages = nullptr) override;
94
100 Q_INVOKABLE static void showLoadNodesResultDialog(bool success, vtkMRMLMessageCollection* userMessages);
101
105 void dragEnterEvent(QDragEnterEvent* event);
106
113 void dropEvent(QDropEvent* event);
114
115public slots:
116
121 inline bool openAddDataDialog();
122 inline bool openAddDataDialog(QString fileName);
123 inline bool openAddVolumeDialog();
124 inline bool openAddVolumesDialog();
125 inline bool openAddModelDialog();
126 inline bool openAddScalarOverlayDialog();
127 inline bool openAddTransformDialog();
128 inline bool openAddColorTableDialog();
129 inline bool openAddFiducialDialog();
130 inline bool openAddMarkupsDialog();
131 inline bool openAddFiberBundleDialog();
132 inline bool openSaveDataDialog();
133
134protected slots:
136
137protected:
140
142 void startProgress(vtkMRMLOperationProgress* progress) override;
143 void updateProgress(vtkMRMLOperationProgress* progress) override;
144 void endProgress(vtkMRMLOperationProgress* progress) override;
145
146 friend class qSlicerFileDialog;
147
148protected:
149 QScopedPointer<qSlicerIOManagerPrivate> d_ptr;
150
151private:
152 Q_DECLARE_PRIVATE(qSlicerIOManager);
153 Q_DISABLE_COPY(qSlicerIOManager);
154};
155
156//------------------------------------------------------------------------------
158{
159 qSlicerIO::IOProperties ioProperties;
160 ioProperties["fileName"] = fileName;
161 return this->openDialog(QString("NoFile"), qSlicerFileDialog::Read, ioProperties);
162}
163
164//------------------------------------------------------------------------------
166{
167 return this->openDialog(QString("NoFile"), qSlicerFileDialog::Read);
168}
169
170//-----------------------------------------------------------------------------
172{
173 return this->openDialog(QString("VolumeFile"), qSlicerFileDialog::Read);
174}
175
176//-----------------------------------------------------------------------------
178{
179 qSlicerIO::IOProperties ioProperties;
180 ioProperties["multipleFiles"] = true;
181 return this->openDialog(QString("VolumeFile"), qSlicerFileDialog::Read, ioProperties);
182}
183
184//-----------------------------------------------------------------------------
186{
187 return this->openDialog(QString("ModelFile"), qSlicerFileDialog::Read);
188}
189
190//-----------------------------------------------------------------------------
192{
193 return this->openDialog(QString("ScalarOverlayFile"), qSlicerFileDialog::Read);
194}
195
196//-----------------------------------------------------------------------------
198{
199 return this->openDialog(QString("TransformFile"), qSlicerFileDialog::Read);
200}
201
202//-----------------------------------------------------------------------------
204{
205 return this->openDialog(QString("ColorTableFile"), qSlicerFileDialog::Read);
206}
207
208//-----------------------------------------------------------------------------
210{
211 return this->openDialog(QString("FiducialListFile"), qSlicerFileDialog::Read);
212}
213
214//-----------------------------------------------------------------------------
216{
217 return this->openDialog(QString("MarkupsFiducials"), qSlicerFileDialog::Read);
218}
219
220//-----------------------------------------------------------------------------
222{
223 return this->openDialog(QString("FiberBundleFile"), qSlicerFileDialog::Read);
224}
225
226//------------------------------------------------------------------------------
228{
229 return this->openDialog(QString("NoFile"), qSlicerFileDialog::Write);
230}
231
232#endif
Q_INVOKABLE qSlicerIO::IOFileType fileType(const QString &file) const
Return the most likely file type (SegmentationFile, TextFile, ...) for reading a file.
qSlicerCoreIOManager(QObject *parent=nullptr)
Q_INVOKABLE bool loadNodes(const QList< qSlicerIO::IOProperties > &files, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr) override
qSlicerIOOptionsWidget * fileWriterOptionsWidget(vtkObject *object, const QString &extension=QString(), QWidget *parent=nullptr) const
Q_INVOKABLE bool loadNodes(const qSlicerIO::IOFileType &fileType, const qSlicerIO::IOProperties &parameters, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr) override
void startProgress(vtkMRMLOperationProgress *progress) override
Show, update, and hide the progress dialog.
void execDelayedFileDialog()
Q_INVOKABLE bool isDialogRegistered(qSlicerIO::IOFileType fileType, qSlicerFileDialog::IOAction action) const
qSlicerIOOptionsWidget * fileOptionsWidget(const QString &fileDescription, QWidget *parent=nullptr) const
void openSceneViewsDialog()
static Q_INVOKABLE void showLoadNodesResultDialog(bool success, vtkMRMLMessageCollection *userMessages)
Q_INVOKABLE bool openDialog(qSlicerIO::IOFileType fileType, qSlicerFileDialog::IOAction action, qSlicerIO::IOProperties ioProperties=qSlicerIO::IOProperties(), vtkCollection *loadedNodes=nullptr)
qSlicerIOManager(QObject *parent=nullptr)
void dragEnterEvent(QDragEnterEvent *event)
Q_INVOKABLE QStringList history() const
bool openAddSceneDialog()
QScopedPointer< qSlicerIOManagerPrivate > d_ptr
qSlicerIOOptions * createGenericOptions(vtkMRMLFileIOHandler *ioHandler) const override
Create a qSlicerGenericIOOptionsWidget if the reader or writer describes its options.
qSlicerCoreIOManager Superclass
void dropEvent(QDropEvent *event)
Q_INVOKABLE void addHistory(const QString &path)
bool openAddScalarOverlayDialog()
void endProgress(vtkMRMLOperationProgress *progress) override
Q_INVOKABLE QList< QUrl > favorites() const
bool openLoadSceneDialog()
void openScreenshotDialog()
~qSlicerIOManager() override
void updateProgress(vtkMRMLOperationProgress *progress) override
Q_INVOKABLE void registerDialog(qSlicerFileDialog *dialog)
Q_INVOKABLE void setFavorites(const QList< QUrl > &urls)
friend class qSlicerFileDialog
QString IOFileType
Definition qSlicerIO.h:60
QVariantMap IOProperties
Definition qSlicerIO.h:61
Progress of a long operation, such as loading files.