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