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 "qcylindergeometryview.h"
10
11#include <Qt3DExtras/qcylindergeometry.h>
12#include <Qt3DCore/qbuffer.h>
13#include <Qt3DCore/qattribute.h>
14#include <QtGui/QVector3D>
15
16#include <qmath.h>
17
18QT_BEGIN_NAMESPACE
19
20using namespace Qt3DCore;
21
22namespace Qt3DExtras {
23
24/*!
25 * \qmltype CylinderGeometryView
26 * \instantiates Qt3DExtras::QCylinderGeometryView
27 * \inqmlmodule Qt3D.Extras
28 * \brief A cylindrical mesh.
29 */
30
31/*!
32 * \qmlproperty int CylinderGeometryView::rings
33 *
34 * Holds the number of rings in the mesh.
35 */
36
37/*!
38 * \qmlproperty int CylinderGeometryView::slices
39 *
40 * Holds the number of slices in the mesh.
41 */
42
43/*!
44 * \qmlproperty real CylinderGeometryView::radius
45 *
46 * Holds the radius of the cylinder.
47 */
48
49/*!
50 * \qmlproperty real CylinderGeometryView::length
51 *
52 * Holds the length of the cylinder.
53 */
54
55/*!
56 * \class Qt3DExtras::QCylinderGeometryView
57 \ingroup qt3d-extras-geometries
58 * \inheaderfile Qt3DExtras/QCylinderGeometryView
59 * \inmodule Qt3DExtras
60 *
61 * \inherits Qt3DRender::QGeometryRenderer
62 *
63 * \brief A cylindrical mesh.
64 */
65
66/*!
67 * Constructs a new QCylinderGeometryView with \a parent.
68 */
69QCylinderGeometryView::QCylinderGeometryView(QNode *parent)
70 : Qt3DCore::QGeometryView(parent)
71{
72 QCylinderGeometry *geometry = new QCylinderGeometry(this);
73 QObject::connect(sender: geometry, signal: &QCylinderGeometry::radiusChanged, context: this, slot: &QCylinderGeometryView::radiusChanged);
74 QObject::connect(sender: geometry, signal: &QCylinderGeometry::ringsChanged, context: this, slot: &QCylinderGeometryView::ringsChanged);
75 QObject::connect(sender: geometry, signal: &QCylinderGeometry::slicesChanged, context: this, slot: &QCylinderGeometryView::slicesChanged);
76 QObject::connect(sender: geometry, signal: &QCylinderGeometry::lengthChanged, context: this, slot: &QCylinderGeometryView::lengthChanged);
77
78 QGeometryView::setGeometry(geometry);
79}
80
81/*! \internal */
82QCylinderGeometryView::~QCylinderGeometryView()
83{
84}
85
86void QCylinderGeometryView::setRings(int rings)
87{
88 static_cast<QCylinderGeometry *>(geometry())->setRings(rings);
89}
90
91void QCylinderGeometryView::setSlices(int slices)
92{
93 static_cast<QCylinderGeometry *>(geometry())->setSlices(slices);
94}
95
96void QCylinderGeometryView::setRadius(float radius)
97{
98 static_cast<QCylinderGeometry *>(geometry())->setRadius(radius);
99}
100
101void QCylinderGeometryView::setLength(float length)
102{
103 static_cast<QCylinderGeometry *>(geometry())->setLength(length);
104}
105
106/*!
107 * \property QCylinderGeometryView::rings
108 *
109 * Holds the number of rings in the mesh.
110 */
111int QCylinderGeometryView::rings() const
112{
113 return static_cast<QCylinderGeometry *>(geometry())->rings();
114}
115
116/*!
117 * \property QCylinderGeometryView::slices
118 *
119 * Holds the number of slices in the mesh.
120 */
121int QCylinderGeometryView::slices() const
122{
123 return static_cast<QCylinderGeometry *>(geometry())->slices();
124}
125
126/*!
127 * \property QCylinderGeometryView::radius
128 *
129 * Holds the radius of the cylinder.
130 */
131float QCylinderGeometryView::radius() const
132{
133 return static_cast<QCylinderGeometry *>(geometry())->radius();
134}
135
136/*!
137 * \property QCylinderGeometryView::length
138 *
139 * Holds the length of the cylinder.
140 */
141float QCylinderGeometryView::length() const
142{
143 return static_cast<QCylinderGeometry *>(geometry())->length();
144}
145
146} // namespace Qt3DExtras
147
148QT_END_NAMESPACE
149
150#include "moc_qcylindergeometryview.cpp"
151

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