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 "qpointsize.h" |
41 | #include "qpointsize_p.h" |
42 | #include <Qt3DRender/private/qrenderstatecreatedchange_p.h> |
43 | |
44 | QT_BEGIN_NAMESPACE |
45 | |
46 | namespace Qt3DRender { |
47 | |
48 | /*! |
49 | \class Qt3DRender::QPointSize |
50 | \inmodule Qt3DRender |
51 | \since 5.7 |
52 | \brief Specifies the size of rasterized points. May either be set statically |
53 | or by shader programs. |
54 | |
55 | When the sizeMode property is set to SizeMode::Fixed, the value is set |
56 | using glPointSize(), if available. When using SizeMode::Programmable, |
57 | gl_PointSize must be set within shader programs, the value provided to this |
58 | RenderState is ignored in that case. |
59 | */ |
60 | |
61 | /*! |
62 | \qmltype PointSize |
63 | \since 5.7 |
64 | \inherits RenderState |
65 | \instantiates Qt3DRender::QPointSize |
66 | \inqmlmodule Qt3D.Render |
67 | |
68 | \brief Specifies the size of rasterized points. May either be set statically |
69 | or by shader programs. |
70 | |
71 | When the sizeMode property is set to SizeMode::Fixed, the value is set |
72 | using glPointSize(), if available. When using SizeMode::Programmable, |
73 | gl_PointSize must be set within shader programs, the value provided to this |
74 | RenderState is ignored in that case. |
75 | */ |
76 | |
77 | /*! |
78 | \enum Qt3DRender::QPointSize::SizeMode |
79 | |
80 | This enumeration specifies values for the size mode. |
81 | \value Fixed The point size is by the QPointSize::value. |
82 | \value Programmable The point size value must be set in shader |
83 | */ |
84 | /*! |
85 | \qmlproperty real PointSize::value |
86 | Specifies the point size value to be used. |
87 | */ |
88 | |
89 | /*! |
90 | \qmlproperty enumeration PointSize::sizeMode |
91 | Specifies the sizeMode to be used. |
92 | */ |
93 | |
94 | /*! |
95 | \property QPointSize::value |
96 | Specifies the point size value to be used. |
97 | */ |
98 | |
99 | /*! |
100 | \property QPointSize::sizeMode |
101 | Specifies the sizeMode to be used. |
102 | */ |
103 | |
104 | QPointSize::QPointSize(Qt3DCore::QNode *parent) |
105 | : QRenderState(*new QPointSizePrivate(SizeMode::Programmable, 0.f), parent) |
106 | { |
107 | } |
108 | |
109 | /*! \internal */ |
110 | QPointSize::~QPointSize() |
111 | { |
112 | } |
113 | |
114 | QPointSize::SizeMode QPointSize::sizeMode() const |
115 | { |
116 | Q_D(const QPointSize); |
117 | return d->m_sizeMode; |
118 | } |
119 | |
120 | float QPointSize::value() const |
121 | { |
122 | Q_D(const QPointSize); |
123 | return d->m_value; |
124 | } |
125 | |
126 | void QPointSize::setSizeMode(SizeMode sizeMode) |
127 | { |
128 | Q_D(QPointSize); |
129 | d->m_sizeMode = sizeMode; |
130 | emit sizeModeChanged(sizeMode); |
131 | } |
132 | |
133 | void QPointSize::setValue(float size) |
134 | { |
135 | Q_D(QPointSize); |
136 | d->m_value = size; |
137 | emit valueChanged(value: size); |
138 | } |
139 | |
140 | Qt3DCore::QNodeCreatedChangeBasePtr QPointSize::createNodeCreationChange() const |
141 | { |
142 | auto creationChange = QRenderStateCreatedChangePtr<QPointSizeData>::create(arguments: this); |
143 | auto &data = creationChange->data; |
144 | Q_D(const QPointSize); |
145 | data.sizeMode = d->m_sizeMode; |
146 | data.value = d->m_value; |
147 | return creationChange; |
148 | } |
149 | |
150 | } // namespace Qt3DRender |
151 | |
152 | QT_END_NAMESPACE |
153 | |
154 | |