Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #ifndef SVGGENERATOR_H
24 : #define SVGGENERATOR_H
25 :
26 : #include <QtGui/qpaintdevice.h>
27 :
28 : #include <QtCore/qnamespace.h>
29 : #include <QtCore/qiodevice.h>
30 : #include <QtCore/qobjectdefs.h>
31 : #include <QtCore/qscopedpointer.h>
32 :
33 : namespace mu::engraving {
34 : class EngravingItem;
35 : }
36 :
37 : class SvgGeneratorPrivate;
38 :
39 : //---------------------------------------------------------
40 : // @@ SvgGenerator
41 : // @P size QSize
42 : // @P viewBox QRectF
43 : // @P title QString
44 : // @P description QString
45 : // @P fileName QString
46 : // @P outputDevice QIODevice
47 : // @P resolution int
48 : //---------------------------------------------------------
49 :
50 : class SvgGenerator : public QPaintDevice
51 : {
52 0 : Q_DECLARE_PRIVATE(SvgGenerator)
53 :
54 : Q_PROPERTY(QSize size READ size WRITE setSize)
55 : Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox)
56 : Q_PROPERTY(QString title READ title WRITE setTitle)
57 : Q_PROPERTY(QString description READ description WRITE setDescription)
58 : Q_PROPERTY(QString fileName READ fileName WRITE setFileName)
59 : Q_PROPERTY(QIODevice * outputDevice READ outputDevice WRITE setOutputDevice)
60 : Q_PROPERTY(int resolution READ resolution WRITE setResolution)
61 : public:
62 : SvgGenerator();
63 : ~SvgGenerator();
64 :
65 : QString title() const;
66 : void setTitle(const QString& title);
67 :
68 : QString description() const;
69 : void setDescription(const QString& description);
70 :
71 : QSize size() const;
72 : void setSize(const QSize& size);
73 :
74 : QRect viewBox() const;
75 : QRectF viewBoxF() const;
76 : void setViewBox(const QRect& viewBox);
77 : void setViewBox(const QRectF& viewBox);
78 :
79 : QString fileName() const;
80 : void setFileName(const QString& fileName);
81 :
82 : QIODevice* outputDevice() const;
83 : void setOutputDevice(QIODevice* outputDevice);
84 :
85 : void setResolution(int dpi);
86 : int resolution() const;
87 :
88 : void setElement(const mu::engraving::EngravingItem* e);
89 :
90 : void setReplaceClipPathWithMask(bool v);
91 :
92 : protected:
93 : QPaintEngine* paintEngine() const;
94 : int metric(QPaintDevice::PaintDeviceMetric metric) const;
95 :
96 : private:
97 : QScopedPointer<SvgGeneratorPrivate> d_ptr;
98 : };
99 :
100 : #endif // QSVGGENERATOR_H
|