Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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"
14 #include "qSlicerCoreIOManager.h"
15 #include "qSlicerFileDialog.h"
16 
17 #include "qSlicerBaseQTGUIExport.h"
18 
20 class QDragEnterEvent;
21 class QDropEvent;
22 class QWidget;
23 
24 class qSlicerIOManagerPrivate;
25 
26 class Q_SLICER_BASE_QTGUI_EXPORT qSlicerIOManager : public qSlicerCoreIOManager
27 {
28  Q_OBJECT;
29  QVTK_OBJECT;
30 public:
32  qSlicerIOManager(QObject* parent = nullptr);
33  ~qSlicerIOManager() override;
34 
45  Q_INVOKABLE bool openDialog(qSlicerIO::IOFileType fileType,
48  vtkCollection* loadedNodes = nullptr);
49 
50  void addHistory(const QString& path);
51  const QStringList& history()const;
52 
53  void setFavorites(const QList<QUrl>& urls);
54  const QList<QUrl>& favorites()const;
55 
58  void registerDialog(qSlicerFileDialog* dialog);
59 
64  Q_INVOKABLE bool loadNodes(const qSlicerIO::IOFileType& fileType, const qSlicerIO::IOProperties& parameters,
65  vtkCollection* loadedNodes = nullptr, vtkMRMLMessageCollection* userMessages = nullptr) override;
69  bool loadNodes(const QList<qSlicerIO::IOProperties>& files, vtkCollection* loadedNodes = nullptr,
70  vtkMRMLMessageCollection* userMessages = nullptr) override;
71 
77  Q_INVOKABLE static void showLoadNodesResultDialog(bool success, vtkMRMLMessageCollection* userMessages);
78 
82  void dragEnterEvent(QDragEnterEvent *event);
83 
90  void dropEvent(QDropEvent *event);
91 
92 public slots:
93 
94  void openScreenshotDialog();
95  void openSceneViewsDialog();
96  bool openLoadSceneDialog();
97  bool openAddSceneDialog();
98  inline bool openAddDataDialog();
99  inline bool openAddDataDialog(QString fileName);
100  inline bool openAddVolumeDialog();
101  inline bool openAddVolumesDialog();
102  inline bool openAddModelDialog();
103  inline bool openAddScalarOverlayDialog();
104  inline bool openAddTransformDialog();
105  inline bool openAddColorTableDialog();
106  inline bool openAddFiducialDialog();
107  inline bool openAddMarkupsDialog();
108  inline bool openAddFiberBundleDialog();
109  inline bool openSaveDataDialog();
110 
111 protected slots:
112  void updateProgressDialog();
113  void execDelayedFileDialog();
114 
115 protected:
116  friend class qSlicerFileDialog;
118 protected:
119  QScopedPointer<qSlicerIOManagerPrivate> d_ptr;
120 
121 private:
122  Q_DECLARE_PRIVATE(qSlicerIOManager);
123  Q_DISABLE_COPY(qSlicerIOManager);
124 };
125 
126 //------------------------------------------------------------------------------
128 {
129  qSlicerIO::IOProperties ioProperties;
130  ioProperties["fileName"] = fileName;
131  return this->openDialog(QString("NoFile"), qSlicerFileDialog::Read, ioProperties);
132 }
133 
134 //------------------------------------------------------------------------------
136 {
137  return this->openDialog(QString("NoFile"), qSlicerFileDialog::Read);
138 }
139 
140 //-----------------------------------------------------------------------------
142 {
143  return this->openDialog(QString("VolumeFile"), qSlicerFileDialog::Read);
144 }
145 
146 //-----------------------------------------------------------------------------
148 {
149  qSlicerIO::IOProperties ioProperties;
150  ioProperties["multipleFiles"] = true;
151  return this->openDialog(QString("VolumeFile"), qSlicerFileDialog::Read, ioProperties);
152 }
153 
154 //-----------------------------------------------------------------------------
156 {
157  return this->openDialog(QString("ModelFile"), qSlicerFileDialog::Read);
158 }
159 
160 //-----------------------------------------------------------------------------
162 {
163  return this->openDialog(QString("ScalarOverlayFile"), qSlicerFileDialog::Read);
164 }
165 
166 //-----------------------------------------------------------------------------
168 {
169  return this->openDialog(QString("TransformFile"), qSlicerFileDialog::Read);
170 }
171 
172 //-----------------------------------------------------------------------------
174 {
175  return this->openDialog(QString("ColorTableFile"), qSlicerFileDialog::Read);
176 }
177 
178 //-----------------------------------------------------------------------------
180 {
181  return this->openDialog(QString("FiducialListFile"), qSlicerFileDialog::Read);
182 }
183 
184 //-----------------------------------------------------------------------------
186 {
187  return this->openDialog(QString("MarkupsFiducials"), qSlicerFileDialog::Read);
188 }
189 
190 //-----------------------------------------------------------------------------
192 {
193  return this->openDialog(QString("FiberBundleFile"), qSlicerFileDialog::Read);
194 }
195 
196 //------------------------------------------------------------------------------
198 {
199  return this->openDialog(QString("NoFile"), qSlicerFileDialog::Write);
200 }
201 
202 #endif
Q_INVOKABLE bool openDialog(qSlicerIO::IOFileType fileType, qSlicerFileDialog::IOAction action, qSlicerIO::IOProperties ioProperties=qSlicerIO::IOProperties(), vtkCollection *loadedNodes=nullptr)
QScopedPointer< qSlicerIOManagerPrivate > d_ptr
const QList< qSlicerFileReader * > & readers() const
Returns the list of registered readers.
bool openAddScalarOverlayDialog()
bool openAddFiberBundleDialog()
QString IOFileType
Definition: qSlicerIO.h:52
virtual Q_INVOKABLE bool loadNodes(const qSlicerIO::IOFileType &fileType, const qSlicerIO::IOProperties &parameters, vtkCollection *loadedNodes=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
qSlicerCoreIOManager Superclass
bool openAddColorTableDialog()