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 "qtexturewrapmode.h"
41#include <private/qobject_p.h>
42
43QT_BEGIN_NAMESPACE
44
45namespace Qt3DRender {
46
47class QTextureWrapModePrivate : public QObjectPrivate
48{
49public:
50 QTextureWrapModePrivate()
51 : QObjectPrivate()
52 , m_x(QTextureWrapMode::ClampToEdge)
53 , m_y(QTextureWrapMode::ClampToEdge)
54 , m_z(QTextureWrapMode::ClampToEdge)
55 {
56 }
57
58 Q_DECLARE_PUBLIC(QTextureWrapMode)
59 QTextureWrapMode::WrapMode m_x;
60 QTextureWrapMode::WrapMode m_y;
61 QTextureWrapMode::WrapMode m_z;
62};
63
64/*!
65 \class Qt3DRender::QTextureWrapMode
66 \inmodule Qt3DRender
67 \since 5.5
68
69 \brief Defines the wrap mode a Qt3DRender::QAbstractTexture
70 should apply to a texture.
71 */
72
73QTextureWrapMode::QTextureWrapMode(WrapMode wrapMode, QObject *parent)
74 : QObject(*new QTextureWrapModePrivate, parent)
75{
76 d_func()->m_x = wrapMode;
77 d_func()->m_y = wrapMode;
78 d_func()->m_z = wrapMode;
79}
80
81/*!
82 Contrusts a new Qt3DRender::QTextureWrapMode instance with the wrap mode to apply to
83 each dimension \a x, \a y \a z of the texture and \a parent as parent.
84 */
85QTextureWrapMode::QTextureWrapMode(WrapMode x,WrapMode y, WrapMode z, QObject *parent)
86 : QObject(*new QTextureWrapModePrivate, parent)
87{
88 d_func()->m_x = x;
89 d_func()->m_y = y;
90 d_func()->m_z = z;
91}
92
93/*! \internal */
94QTextureWrapMode::~QTextureWrapMode()
95{
96}
97
98/*!
99 Sets the wrap mode of the x dimension to \a x.
100 */
101void QTextureWrapMode::setX(WrapMode x)
102{
103 Q_D(QTextureWrapMode);
104 if (d->m_x != x) {
105 d->m_x = x;
106 emit xChanged(x);
107 }
108}
109
110/*!
111 \property QTextureWrapMode::x
112
113 Returns the wrap mode of the x dimension.
114 */
115QTextureWrapMode::WrapMode QTextureWrapMode::x() const
116{
117 Q_D(const QTextureWrapMode);
118 return d->m_x;
119}
120
121/*!
122 \enum Qt3DRender::QTextureWrapMode::WrapMode
123
124 Specifies the type of text wrapping.
125 Possible values:
126
127 \value Repeat
128 \value MirroredRepeat
129 \value ClampToEdge
130 \value ClampToBorder
131*/
132
133
134/*!
135 Sets the wrap mode of the y dimension to \a y.
136 \note this is not available on 1D textures.
137 */
138void QTextureWrapMode::setY(WrapMode y)
139{
140 Q_D(QTextureWrapMode);
141 if (d->m_y != y) {
142 d->m_y = y;
143 emit yChanged(y);
144 }
145}
146
147/*!
148 \property QTextureWrapMode::y
149
150 Returns the wrap mode of the y dimension.
151 */
152QTextureWrapMode::WrapMode QTextureWrapMode::y() const
153{
154 Q_D(const QTextureWrapMode);
155 return d->m_y;
156}
157
158/*!
159 Sets the wrap mode of the z dimension to \a z.
160 \note this is only available on 3D textures.
161 */
162void QTextureWrapMode::setZ(WrapMode z)
163{
164 Q_D(QTextureWrapMode);
165 if (d->m_z != z) {
166 d->m_z = z;
167 emit zChanged(z);
168 }
169}
170
171/*!
172 \property QTextureWrapMode::z
173
174 Returns the wrap mode of the z dimension.
175 */
176QTextureWrapMode::WrapMode QTextureWrapMode::z() const
177{
178 Q_D(const QTextureWrapMode);
179 return d->m_z;
180}
181
182} // namespace Qt3DRender
183
184QT_END_NAMESPACE
185

source code of qt3d/src/render/texture/qtexturewrapmode.cpp