Slicer  4.13
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 
75  void dragEnterEvent(QDragEnterEvent *event);
76 
83  void dropEvent(QDropEvent *event);
84 
85 public slots:
86 
87  void openScreenshotDialog();
88  void openSceneViewsDialog();
89  bool openLoadSceneDialog();
90  bool openAddSceneDialog();
91  inline bool openAddDataDialog();
92  inline bool openAddDataDialog(QString fileName);
93  inline bool openAddVolumeDialog();
94  inline bool openAddVolumesDialog();
95  inline bool openAddModelDialog();
96  inline bool openAddScalarOverlayDialog();
97  inline bool openAddTransformDialog();
98  inline bool openAddColorTableDialog();
99  inline bool openAddFiducialDialog();
100  inline bool openAddMarkupsDialog();
101  inline bool openAddFiberBundleDialog();
102  inline bool openSaveDataDialog();
103 
104 protected slots:
105  void updateProgressDialog();
106  void execDelayedFileDialog();
107 
108 protected:
109  friend class qSlicerFileDialog;
111 protected:
112  QScopedPointer<qSlicerIOManagerPrivate> d_ptr;
113 
114 private:
115  Q_DECLARE_PRIVATE(qSlicerIOManager);
116  Q_DISABLE_COPY(qSlicerIOManager);
117 };
118 
119 //------------------------------------------------------------------------------
121 {
122  qSlicerIO::IOProperties ioProperties;
123  ioProperties["fileName"] = fileName;
124  return this->openDialog(QString("NoFile"), qSlicerFileDialog::Read, ioProperties);
125 }
126 
127 //------------------------------------------------------------------------------
129 {
130  return this->openDialog(QString("NoFile"), qSlicerFileDialog::Read);
131 }
132 
133 //-----------------------------------------------------------------------------
135 {
136  return this->openDialog(QString("VolumeFile"), qSlicerFileDialog::Read);
137 }
138 
139 //-----------------------------------------------------------------------------
141 {
142  qSlicerIO::IOProperties ioProperties;
143  ioProperties["multipleFiles"] = true;
144  return this->openDialog(QString("VolumeFile"), qSlicerFileDialog::Read, ioProperties);
145 }
146 
147 //-----------------------------------------------------------------------------
149 {
150  return this->openDialog(QString("ModelFile"), qSlicerFileDialog::Read);
151 }
152 
153 //-----------------------------------------------------------------------------
155 {
156  return this->openDialog(QString("ScalarOverlayFile"), qSlicerFileDialog::Read);
157 }
158 
159 //-----------------------------------------------------------------------------
161 {
162  return this->openDialog(QString("TransformFile"), qSlicerFileDialog::Read);
163 }
164 
165 //-----------------------------------------------------------------------------
167 {
168  return this->openDialog(QString("ColorTableFile"), qSlicerFileDialog::Read);
169 }
170 
171 //-----------------------------------------------------------------------------
173 {
174  return this->openDialog(QString("FiducialListFile"), qSlicerFileDialog::Read);
175 }
176 
177 //-----------------------------------------------------------------------------
179 {
180  return this->openDialog(QString("MarkupsFiducials"), qSlicerFileDialog::Read);
181 }
182 
183 //-----------------------------------------------------------------------------
185 {
186  return this->openDialog(QString("FiberBundleFile"), qSlicerFileDialog::Read);
187 }
188 
189 //------------------------------------------------------------------------------
191 {
192  return this->openDialog(QString("NoFile"), qSlicerFileDialog::Write);
193 }
194 
195 #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()