Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerScriptedFileWriter.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 __qSlicerScriptedFileWriter_h
22 #define __qSlicerScriptedFileWriter_h
23 
24 // Slicer includes
25 #include "qSlicerFileWriter.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 qSlicerScriptedFileWriterPrivate;
34 
35 class Q_SLICER_BASE_QTCORE_EXPORT qSlicerScriptedFileWriter
36  : public qSlicerFileWriter
37 {
38  Q_OBJECT
39 
41  Q_PROPERTY(QStringList writtenNodes READ writtenNodes WRITE setWrittenNodes)
42 
43 public:
45  qSlicerScriptedFileWriter(QObject* parent = nullptr);
46  ~qSlicerScriptedFileWriter() override;
47 
48  QString pythonSource()const;
49 
52  bool setPythonSource(const QString& newPythonSource, const QString& className = QLatin1String(""), bool missingClassIsExpected = true);
53 
55  Q_INVOKABLE PyObject* self() const;
56 
59  QString description()const override;
60 
63  IOFileType fileType()const override;
64 
67  bool canWriteObject(vtkObject* object)const override;
68 
71  QStringList extensions(vtkObject* object)const override;
72 
75  bool write(const qSlicerIO::IOProperties& properties) override;
76 
79  void addWrittenNode(const QString& writtenNode);
80 
85  QStringList writtenNodes()const override {
86  return Superclass::writtenNodes();
87  };
88  void setWrittenNodes(const QStringList& nodes) override {
89  Superclass::setWrittenNodes(nodes);
90  };
91 
92 protected:
93  QScopedPointer<qSlicerScriptedFileWriterPrivate> d_ptr;
94 
95 private:
96  Q_DECLARE_PRIVATE(qSlicerScriptedFileWriter);
97  Q_DISABLE_COPY(qSlicerScriptedFileWriter);
98 };
99 
100 #endif
virtual QStringList extensions(vtkObject *object) const =0
QStringList writtenNodes() const override
virtual bool write(const qSlicerIO::IOProperties &properties)
QScopedPointer< qSlicerFileWriterPrivate > d_ptr
void setWrittenNodes(const QStringList &nodes) override
virtual Q_INVOKABLE IOFileType fileType() const =0
Multiple readers can share the same file type.
virtual Q_INVOKABLE QString description() const =0
Unique name of the reader/writer.
QString IOFileType
Definition: qSlicerIO.h:52
virtual bool canWriteObject(vtkObject *object) const
Return true if the object is handled by the writer.
_object PyObject
_object PyObject