1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include "qcolormask.h" |
41 | #include "qcolormask_p.h" |
42 | #include <Qt3DRender/private/qrenderstatecreatedchange_p.h> |
43 | |
44 | QT_BEGIN_NAMESPACE |
45 | |
46 | namespace Qt3DRender { |
47 | |
48 | /*! |
49 | \class Qt3DRender::QColorMask |
50 | \inmodule Qt3DRender |
51 | \since 5.7 |
52 | \brief Allows specifying which color components should be written to the |
53 | currently bound frame buffer. |
54 | |
55 | By default, the property for each color component (red, green, blue, alpha) |
56 | is set to \c true which means they will be written to the frame buffer. |
57 | Setting any of the color component to \c false will prevent it from being |
58 | written into the frame buffer. |
59 | */ |
60 | |
61 | /*! |
62 | \qmltype ColorMask |
63 | \inqmlmodule Qt3D.Render |
64 | \since 5.7 |
65 | \inherits RenderState |
66 | \instantiates Qt3DRender::QColorMask |
67 | \brief Allows specifying which color components should be written to the |
68 | currently bound frame buffer. |
69 | |
70 | By default, the property for each color component (red, green, blue, alpha) |
71 | is set to \c true which means they will be written to the frame buffer. |
72 | Setting any of the color component to \c false will prevent it from being |
73 | written into the frame buffer. |
74 | */ |
75 | |
76 | /*! |
77 | \qmlproperty bool ColorMask::redMasked |
78 | Holds whether red color component should be written to the frame buffer. |
79 | */ |
80 | |
81 | /*! |
82 | \qmlproperty bool ColorMask::greenMasked |
83 | Holds whether green color component should be written to the frame buffer. |
84 | */ |
85 | |
86 | /*! |
87 | \qmlproperty bool ColorMask::blueMasked |
88 | Holds whether blue color component should be written to the frame buffer. |
89 | */ |
90 | |
91 | /*! |
92 | \qmlproperty bool ColorMask::alphaMasked |
93 | Holds whether alpha component should be written to the frame buffer. |
94 | */ |
95 | |
96 | |
97 | /*! |
98 | Constructs a new Qt3DCore::QColorMask instance with \a parent as parent. |
99 | */ |
100 | QColorMask::QColorMask(QNode *parent) |
101 | : QRenderState(*new QColorMaskPrivate, parent) |
102 | { |
103 | } |
104 | |
105 | /*! \internal */ |
106 | QColorMask::~QColorMask() |
107 | { |
108 | } |
109 | |
110 | bool QColorMask::isRedMasked() const |
111 | { |
112 | Q_D(const QColorMask); |
113 | return d->m_redMasked; |
114 | } |
115 | |
116 | bool QColorMask::isGreenMasked() const |
117 | { |
118 | Q_D(const QColorMask); |
119 | return d->m_greenMasked; |
120 | } |
121 | |
122 | bool QColorMask::isBlueMasked() const |
123 | { |
124 | Q_D(const QColorMask); |
125 | return d->m_blueMasked; |
126 | } |
127 | |
128 | bool QColorMask::isAlphaMasked() const |
129 | { |
130 | Q_D(const QColorMask); |
131 | return d->m_alphaMasked; |
132 | } |
133 | |
134 | /*! |
135 | \property QColorMask::redMasked |
136 | Holds whether the red color component should be written to the frame buffer. |
137 | */ |
138 | void QColorMask::setRedMasked(bool redMasked) |
139 | { |
140 | Q_D(QColorMask); |
141 | if (redMasked != d->m_redMasked) { |
142 | d->m_redMasked = redMasked; |
143 | emit redMaskedChanged(redMasked); |
144 | } |
145 | } |
146 | |
147 | /*! |
148 | \property QColorMask::greenMasked |
149 | Holds whether the green color component should be written to the frame buffer. |
150 | */ |
151 | void QColorMask::setGreenMasked(bool greenMasked) |
152 | { |
153 | Q_D(QColorMask); |
154 | if (greenMasked != d->m_greenMasked) { |
155 | d->m_greenMasked = greenMasked; |
156 | emit greenMaskedChanged(greenMasked); |
157 | } |
158 | } |
159 | |
160 | /*! |
161 | \property QColorMask::blueMasked |
162 | Holds whether the blue color component should be written to the frame buffer. |
163 | */ |
164 | void QColorMask::setBlueMasked(bool blueMasked) |
165 | { |
166 | Q_D(QColorMask); |
167 | if (blueMasked != d->m_blueMasked) { |
168 | d->m_blueMasked = blueMasked; |
169 | emit blueMaskedChanged(blueMasked); |
170 | } |
171 | } |
172 | |
173 | /*! |
174 | \property QColorMask::alphaMasked |
175 | Holds whether the alphaMasked component should be written to the frame buffer. |
176 | */ |
177 | void QColorMask::setAlphaMasked(bool alphaMasked) |
178 | { |
179 | Q_D(QColorMask); |
180 | if (alphaMasked != d->m_alphaMasked) { |
181 | d->m_alphaMasked = alphaMasked; |
182 | emit alphaMaskedChanged(alphaMasked); |
183 | } |
184 | } |
185 | |
186 | Qt3DCore::QNodeCreatedChangeBasePtr QColorMask::createNodeCreationChange() const |
187 | { |
188 | auto creationChange = QRenderStateCreatedChangePtr<QColorMaskData>::create(arguments: this); |
189 | auto &data = creationChange->data; |
190 | Q_D(const QColorMask); |
191 | data.redMasked = d->m_redMasked; |
192 | data.greenMasked = d->m_greenMasked; |
193 | data.blueMasked = d->m_blueMasked; |
194 | data.alphaMasked = d->m_alphaMasked; |
195 | return creationChange; |
196 | } |
197 | |
198 | } // namespace Qt3DRender |
199 | |
200 | QT_END_NAMESPACE |
201 | |
202 | |