Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerScriptedFileReader.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 __qSlicerScriptedFileReader_h
22 #define __qSlicerScriptedFileReader_h
23 
24 // Slicer includes
25 #include "qSlicerFileReader.h"
26 #include "qSlicerBaseQTCoreExport.h"
27 
28 // Forward Declare PyObject*
29 #ifndef PyObject_HEAD
30 struct _object;
31 typedef _object PyObject;
32 #endif
33 class qSlicerScriptedFileReaderPrivate;
34 class vtkObject;
35 
36 class Q_SLICER_BASE_QTCORE_EXPORT qSlicerScriptedFileReader
37  : public qSlicerFileReader
38 {
39  Q_OBJECT
40 
42  Q_PROPERTY(QStringList loadedNodes READ loadedNodes WRITE setLoadedNodes)
43 
44 public:
46  qSlicerScriptedFileReader(QObject* parent = nullptr);
47  ~qSlicerScriptedFileReader() override;
48 
49  QString pythonSource()const;
50 
53  bool setPythonSource(const QString& newPythonSource, const QString& className = QLatin1String(""), bool missingClassIsExpected = true);
54 
56  Q_INVOKABLE PyObject* self() const;
57 
60  QString description()const override;
61 
64  IOFileType fileType()const override;
65 
68  QStringList extensions()const override;
69 
72  bool canLoadFile(const QString& file)const override;
73 
76  bool load(const qSlicerIO::IOProperties& properties) override;
77 
82  QStringList loadedNodes()const override {
83  return Superclass::loadedNodes();
84  };
85  void setLoadedNodes(const QStringList& nodes) override {
86  Superclass::setLoadedNodes(nodes);
87  };
88 
89 protected:
90  QScopedPointer<qSlicerScriptedFileReaderPrivate> d_ptr;
91 
92 private:
93  Q_DECLARE_PRIVATE(qSlicerScriptedFileReader);
94  Q_DISABLE_COPY(qSlicerScriptedFileReader);
95 };
96 
97 #endif
virtual bool load(const IOProperties &properties)
Properties availables : fileMode, multipleFiles, fileType.
virtual Q_INVOKABLE IOFileType fileType() const =0
Multiple readers can share the same file type.
virtual QStringList extensions() const
virtual Q_INVOKABLE QString description() const =0
Unique name of the reader/writer.
void setLoadedNodes(const QStringList &nodes) override
virtual bool canLoadFile(const QString &file) const
QScopedPointer< qSlicerFileReaderPrivate > d_ptr
QStringList loadedNodes() const override
QString IOFileType
Definition: qSlicerIO.h:52
_object PyObject