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

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

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