1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef _USE_MATH_DEFINES
6# define _USE_MATH_DEFINES // For MSVC
7#endif
8
9#include "qcylindermesh.h"
10#include "qcylindergeometryview.h"
11
12#include <Qt3DCore/qbuffer.h>
13#include <Qt3DCore/qattribute.h>
14#include <QtGui/QVector3D>
15
16#include <qmath.h>
17
18QT_BEGIN_NAMESPACE
19
20
21namespace Qt3DExtras {
22
23using namespace Qt3DCore;
24
25/*!
26 * \qmltype CylinderMesh
27 * \nativetype Qt3DExtras::QCylinderMesh
28 * \inqmlmodule Qt3D.Extras
29 * \brief A cylindrical mesh.
30 *
31 * This component can be used to render a cylinder when combined with a
32 * material component.
33 */
34
35/*!
36 * \qmlproperty int CylinderMesh::rings
37 *
38 * Holds the number of rings in the mesh.
39 */
40
41/*!
42 * \qmlproperty int CylinderMesh::slices
43 *
44 * Holds the number of slices in the mesh.
45 */
46
47/*!
48 * \qmlproperty real CylinderMesh::radius
49 *
50 * Holds the radius of the cylinder.
51 */
52
53/*!
54 * \qmlproperty real CylinderMesh::length
55 *
56 * Holds the length of the cylinder.
57 */
58
59/*!
60 * \class Qt3DExtras::QCylinderMesh
61 * \ingroup qt3d-extras-geometries
62 * \inheaderfile Qt3DExtras/QCylinderMesh
63 * \inmodule Qt3DExtras
64 *
65 * \inherits Qt3DRender::QGeometryRenderer
66 *
67 * \brief A cylindrical mesh.
68 *
69 * This component can be used to render a cylinder when combined with a
70 * material component.
71 */
72
73/*!
74 * Constructs a new QCylinderMesh with \a parent.
75 */
76QCylinderMesh::QCylinderMesh(QNode *parent)
77 : Qt3DRender::QGeometryRenderer(parent)
78{
79 QCylinderGeometryView *geometry = new QCylinderGeometryView(this);
80 QObject::connect(sender: geometry, signal: &QCylinderGeometryView::radiusChanged, context: this, slot: &QCylinderMesh::radiusChanged);
81 QObject::connect(sender: geometry, signal: &QCylinderGeometryView::ringsChanged, context: this, slot: &QCylinderMesh::ringsChanged);
82 QObject::connect(sender: geometry, signal: &QCylinderGeometryView::slicesChanged, context: this, slot: &QCylinderMesh::slicesChanged);
83 QObject::connect(sender: geometry, signal: &QCylinderGeometryView::lengthChanged, context: this, slot: &QCylinderMesh::lengthChanged);
84
85 setView(geometry);
86}
87
88/*! \internal */
89QCylinderMesh::~QCylinderMesh()
90{
91}
92
93void QCylinderMesh::setRings(int rings)
94{
95 static_cast<QCylinderGeometryView *>(view())->setRings(rings);
96}
97
98void QCylinderMesh::setSlices(int slices)
99{
100 static_cast<QCylinderGeometryView *>(view())->setSlices(slices);
101}
102
103void QCylinderMesh::setRadius(float radius)
104{
105 static_cast<QCylinderGeometryView *>(view())->setRadius(radius);
106}
107
108void QCylinderMesh::setLength(float length)
109{
110 static_cast<QCylinderGeometryView *>(view())->setLength(length);
111}
112
113/*!
114 * \property Qt3DExtras::QCylinderMesh::rings
115 *
116 * Holds the number of rings in the mesh.
117 */
118int QCylinderMesh::rings() const
119{
120 return static_cast<QCylinderGeometryView *>(view())->rings();
121}
122
123/*!
124 * \property Qt3DExtras::QCylinderMesh::slices
125 *
126 * Holds the number of slices in the mesh.
127 */
128int QCylinderMesh::slices() const
129{
130 return static_cast<QCylinderGeometryView *>(view())->slices();
131}
132
133/*!
134 * \property Qt3DExtras::QCylinderMesh::radius
135 *
136 * Holds the radius of the cylinder.
137 */
138float QCylinderMesh::radius() const
139{
140 return static_cast<QCylinderGeometryView *>(view())->radius();
141}
142
143/*!
144 * \property Qt3DExtras::QCylinderMesh::length
145 *
146 * Holds the length of the cylinder.
147 */
148float QCylinderMesh::length() const
149{
150 return static_cast<QCylinderGeometryView *>(view())->length();
151}
152
153} // namespace Qt3DExtras
154
155QT_END_NAMESPACE
156
157#include "moc_qcylindermesh.cpp"
158

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

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