1/****************************************************************************
2**
3** Copyright (C) 2014 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 "qplanemesh.h"
41
42#include <Qt3DExtras/qplanegeometry.h>
43
44QT_BEGIN_NAMESPACE
45
46namespace Qt3DExtras {
47
48/*!
49 * \qmltype PlaneMesh
50 * \instantiates Qt3DExtras::QPlaneMesh
51 * \inqmlmodule Qt3D.Extras
52 * \brief A square planar mesh.
53 */
54
55/*!
56 * \qmlproperty real PlaneMesh::width
57 *
58 * Holds the plane width.
59 */
60
61/*!
62 * \qmlproperty real PlaneMesh::height
63 *
64 * Holds the plane height.
65 */
66
67/*!
68 * \qmlproperty size PlaneMesh::meshResolution
69 *
70 * Holds the plane resolution.
71 * The width and height values of this property specify the number of vertices generated for
72 * the mesh in the respective dimensions.
73 */
74
75/*!
76 * \qmlproperty bool PlaneMesh::mirrored
77 * \since 5.9
78 *
79 * Controls if the UV coordinates of the plane should be flipped vertically.
80 */
81
82/*!
83 * \class Qt3DExtras::QPlaneMesh
84 \ingroup qt3d-extras-geometries
85 * \inheaderfile Qt3DExtras/QPlaneMesh
86 * \inmodule Qt3DExtras
87 *
88 * \inherits Qt3DRender::QGeometryRenderer
89 *
90 * \brief A square planar mesh.
91 */
92
93/*!
94 * Constructs a new QPlaneMesh with \a parent.
95 */
96QPlaneMesh::QPlaneMesh(QNode *parent)
97 : QGeometryRenderer(parent)
98{
99 QPlaneGeometry *geometry = new QPlaneGeometry(this);
100 QObject::connect(sender: geometry, signal: &QPlaneGeometry::widthChanged, receiver: this, slot: &QPlaneMesh::widthChanged);
101 QObject::connect(sender: geometry, signal: &QPlaneGeometry::heightChanged, receiver: this, slot: &QPlaneMesh::heightChanged);
102 QObject::connect(sender: geometry, signal: &QPlaneGeometry::resolutionChanged, receiver: this, slot: &QPlaneMesh::meshResolutionChanged);
103 QObject::connect(sender: geometry, signal: &QPlaneGeometry::mirroredChanged, receiver: this, slot: &QPlaneMesh::mirroredChanged);
104 QGeometryRenderer::setGeometry(geometry);
105}
106
107/*! \internal */
108QPlaneMesh::~QPlaneMesh()
109{
110}
111
112void QPlaneMesh::setWidth(float width)
113{
114 static_cast<QPlaneGeometry *>(geometry())->setWidth(width);
115}
116
117/*!
118 * \property QPlaneMesh::width
119 *
120 * Holds the plane width.
121 */
122float QPlaneMesh::width() const
123{
124 return static_cast<QPlaneGeometry *>(geometry())->width();
125}
126
127void QPlaneMesh::setHeight(float height)
128{
129 static_cast<QPlaneGeometry *>(geometry())->setHeight(height);
130}
131
132/*!
133 * \property QPlaneMesh::height
134 *
135 * Holds the plane height.
136 */
137float QPlaneMesh::height() const
138{
139 return static_cast<QPlaneGeometry *>(geometry())->height();
140}
141
142void QPlaneMesh::setMeshResolution(const QSize &resolution)
143{
144 static_cast<QPlaneGeometry *>(geometry())->setResolution(resolution);
145}
146
147/*!
148 * \property QPlaneMesh::meshResolution
149 *
150 * Holds the plane resolution.
151 * The width and height values of this property specify the number of vertices generated for
152 * the mesh in the respective dimensions.
153 */
154QSize QPlaneMesh::meshResolution() const
155{
156 return static_cast<QPlaneGeometry *>(geometry())->resolution();
157}
158
159void QPlaneMesh::setMirrored(bool mirrored)
160{
161 static_cast<QPlaneGeometry *>(geometry())->setMirrored(mirrored);
162}
163
164/*!
165 * \property QPlaneMesh::mirrored
166 * \since 5.9
167 *
168 * Controls if the UV coordinates of the plane should be flipped vertically.
169 */
170bool QPlaneMesh::mirrored() const
171{
172 return static_cast<QPlaneGeometry *>(geometry())->mirrored();
173}
174
175} // namespace Qt3DExtras
176
177QT_END_NAMESPACE
178

source code of qt3d/src/extras/geometries/qplanemesh.cpp