| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2017 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 "qlevelofdetailboundingsphere.h" | 
| 41 | #include <QSharedData> | 
| 42 |  | 
| 43 | QT_BEGIN_NAMESPACE | 
| 44 |  | 
| 45 | namespace Qt3DRender { | 
| 46 |  | 
| 47 | class QLevelOfDetailBoundingSpherePrivate: public QSharedData | 
| 48 | { | 
| 49 | public: | 
| 50 |     QLevelOfDetailBoundingSpherePrivate() | 
| 51 |         : QSharedData() | 
| 52 |         , m_radius(0.0f) | 
| 53 |     {} | 
| 54 |  | 
| 55 |     QLevelOfDetailBoundingSpherePrivate(QVector3D center, float radius) | 
| 56 |         : QSharedData() | 
| 57 |         , m_center(center) | 
| 58 |         , m_radius(radius) | 
| 59 |     {} | 
| 60 |  | 
| 61 |     ~QLevelOfDetailBoundingSpherePrivate() | 
| 62 |     {} | 
| 63 |  | 
| 64 |     QVector3D m_center; | 
| 65 |     float m_radius; | 
| 66 | }; | 
| 67 |  | 
| 68 | /*! | 
| 69 |     \class Qt3DRender::QLevelOfDetailBoundingSphere | 
| 70 |     \inmodule Qt3DRender | 
| 71 |     \since 5.9 | 
| 72 |     \brief The QLevelOfDetailBoundingSphere class provides a simple spherical volume, defined by its center and radius. | 
| 73 | */ | 
| 74 |  | 
| 75 | /*! | 
| 76 |     \qmltype LevelOfDetailBoundingSphere | 
| 77 |     \instantiates Qt3DRender::QLevelOfDetailBoundingSphere | 
| 78 |     \inherits Component3D | 
| 79 |     \inqmlmodule Qt3D.Render | 
| 80 |     \brief The LevelOfDetailBoundingSphere QML type provides a simple spherical volume, defined by its center and radius. | 
| 81 | */ | 
| 82 |  | 
| 83 | /*! | 
| 84 |  * \qmlproperty QVector3D LevelOfDetailBoundingSphere::center | 
| 85 |  * | 
| 86 |  * Specifies the center of the bounding sphere | 
| 87 |  */ | 
| 88 |  | 
| 89 | /*! | 
| 90 |  * \property QLevelOfDetailBoundingSphere::center | 
| 91 |  * | 
| 92 |  * Specifies the center of the bounding sphere | 
| 93 |  */ | 
| 94 |  | 
| 95 | /*! | 
| 96 |  * \qmlproperty qreal LevelOfDetailBoundingSphere::radius | 
| 97 |  * | 
| 98 |  * Specifies the radius of the bounding sphere | 
| 99 |  */ | 
| 100 |  | 
| 101 | /*! | 
| 102 |  * \property QLevelOfDetailBoundingSphere::radius | 
| 103 |  * | 
| 104 |  * Specifies the radius of the bounding sphere | 
| 105 |  */ | 
| 106 |  | 
| 107 | /*! | 
| 108 |   Constructs a new QLevelOfDetailBoundingSphere with the specified \a center and \a radius. | 
| 109 |  */ | 
| 110 | QLevelOfDetailBoundingSphere::QLevelOfDetailBoundingSphere(QVector3D center, float radius) | 
| 111 |     : d_ptr(new QLevelOfDetailBoundingSpherePrivate(center, radius)) | 
| 112 | { | 
| 113 | } | 
| 114 |  | 
| 115 | QLevelOfDetailBoundingSphere::QLevelOfDetailBoundingSphere(const QLevelOfDetailBoundingSphere &other) | 
| 116 |     : d_ptr(other.d_ptr) | 
| 117 | { | 
| 118 | } | 
| 119 |  | 
| 120 | QLevelOfDetailBoundingSphere::~QLevelOfDetailBoundingSphere() | 
| 121 | { | 
| 122 | } | 
| 123 |  | 
| 124 | QLevelOfDetailBoundingSphere &QLevelOfDetailBoundingSphere::operator =(const QLevelOfDetailBoundingSphere &other) | 
| 125 | { | 
| 126 |     d_ptr = other.d_ptr; | 
| 127 |     return *this; | 
| 128 | } | 
| 129 |  | 
| 130 | QVector3D QLevelOfDetailBoundingSphere::center() const | 
| 131 | { | 
| 132 |     return d_ptr->m_center; | 
| 133 | } | 
| 134 |  | 
| 135 | float QLevelOfDetailBoundingSphere::radius() const | 
| 136 | { | 
| 137 |     return d_ptr->m_radius; | 
| 138 | } | 
| 139 |  | 
| 140 | bool QLevelOfDetailBoundingSphere::isEmpty() const | 
| 141 | { | 
| 142 |     return d_ptr->m_radius <= 0.0f; | 
| 143 | } | 
| 144 |  | 
| 145 | bool QLevelOfDetailBoundingSphere::operator ==(const QLevelOfDetailBoundingSphere &other) const | 
| 146 | { | 
| 147 |     return d_ptr->m_center == other.center() && other.d_ptr->m_radius == other.radius(); | 
| 148 | } | 
| 149 |  | 
| 150 | bool QLevelOfDetailBoundingSphere::operator !=(const QLevelOfDetailBoundingSphere &other) const | 
| 151 | { | 
| 152 |     return !(*this == other); | 
| 153 | } | 
| 154 |  | 
| 155 | } // namespace Qt3DRender | 
| 156 |  | 
| 157 | QT_END_NAMESPACE | 
| 158 |  |