| 1 | // Copyright (C) 2024 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICK3DXRSPATIALANCHOR_P_H |
| 5 | #define QQUICK3DXRSPATIALANCHOR_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtQuick3DXr/qtquick3dxrglobal.h> |
| 19 | #include <QtQuick3DXr/private/qtquick3dxrglobal_p.h> |
| 20 | |
| 21 | #include <QtCore/qobject.h> |
| 22 | #include <QtCore/quuid.h> |
| 23 | #include <QtCore/qstring.h> |
| 24 | |
| 25 | #include <QtGui/qvectornd.h> |
| 26 | #include <QtGui/qquaternion.h> |
| 27 | |
| 28 | #include <QtQmlIntegration/qqmlintegration.h> |
| 29 | |
| 30 | QT_BEGIN_NAMESPACE |
| 31 | |
| 32 | class QQuick3DXrSpatialAnchor : public QObject |
| 33 | { |
| 34 | Q_OBJECT |
| 35 | Q_PROPERTY(bool has2DBounds READ has2DBounds NOTIFY has2DBoundsChanged FINAL) |
| 36 | Q_PROPERTY(bool has3DBounds READ has3DBounds NOTIFY has3DBoundsChanged FINAL) |
| 37 | Q_PROPERTY(QVector2D offset2D READ offset2D NOTIFY offset2DChanged FINAL) |
| 38 | Q_PROPERTY(QVector2D extent2D READ extent2D NOTIFY extent2DChanged FINAL) |
| 39 | Q_PROPERTY(QVector3D offset3D READ offset3D NOTIFY offset3DChanged FINAL) |
| 40 | Q_PROPERTY(QVector3D extent3D READ extent3D NOTIFY extent3DChanged FINAL) |
| 41 | Q_PROPERTY(QVector3D position READ position NOTIFY positionChanged FINAL) |
| 42 | Q_PROPERTY(QQuaternion rotation READ rotation NOTIFY rotationChanged FINAL) |
| 43 | Q_PROPERTY(Classification classification READ classification NOTIFY classificationChanged FINAL) |
| 44 | Q_PROPERTY(QString classificationString READ classificationString NOTIFY classificationStringChanged FINAL) |
| 45 | Q_PROPERTY(QString identifier READ identifier CONSTANT) |
| 46 | |
| 47 | QML_NAMED_ELEMENT(XrSpatialAnchor) |
| 48 | QML_UNCREATABLE("Spatial anchor objects cannot be created in QML" ); |
| 49 | QML_ADDED_IN_VERSION(6, 8) |
| 50 | public: |
| 51 | enum class Classification { |
| 52 | Unknown, |
| 53 | Wall, |
| 54 | Ceiling, |
| 55 | Floor, |
| 56 | Table, |
| 57 | Seat, |
| 58 | Window, |
| 59 | Door, |
| 60 | Other, |
| 61 | }; |
| 62 | Q_ENUM(Classification) |
| 63 | |
| 64 | QQuick3DXrSpatialAnchor(QtQuick3DXr::XrSpaceId space, QUuid &uuid, QObject *parent = nullptr); |
| 65 | ~QQuick3DXrSpatialAnchor() override; |
| 66 | |
| 67 | QVector3D offset3D() const; |
| 68 | void setOffset3D(const QVector3D &newOffset); |
| 69 | |
| 70 | QVector3D extent3D() const; |
| 71 | void setExtent3D(const QVector3D &newExtent); |
| 72 | |
| 73 | QVector3D position() const; |
| 74 | void setPosition(const QVector3D &newPosition); |
| 75 | |
| 76 | QQuaternion rotation() const; |
| 77 | void setRotation(const QQuaternion &newRotation); |
| 78 | |
| 79 | Classification classification() const; |
| 80 | void setClassification(Classification newClassification); |
| 81 | |
| 82 | QString classificationString() const; |
| 83 | void setClassificationString(const QString &newClassificationString); |
| 84 | |
| 85 | bool has2DBounds() const; |
| 86 | void setBounds2D(const QVector2D &offset, const QVector2D &extent); |
| 87 | bool has3DBounds() const; |
| 88 | void setBounds3D(const QVector3D &offset, const QVector3D &extent); |
| 89 | |
| 90 | QVector2D offset2D() const; |
| 91 | QVector2D extent2D() const; |
| 92 | |
| 93 | QString identifier() const; |
| 94 | |
| 95 | QSet<QUuid> roomLayoutUuids() const; |
| 96 | void setRoomLayoutUuids(const QSet<QUuid> &newRoomLayoutUuids); |
| 97 | |
| 98 | QSet<QUuid> spaceContainerUuids() const; |
| 99 | void setSpaceContainerUuids(const QSet<QUuid> &newSpaceContainerUuids); |
| 100 | |
| 101 | QtQuick3DXr::XrSpaceId space() const { return m_space; } |
| 102 | |
| 103 | signals: |
| 104 | void offset3DChanged(); |
| 105 | void extent3DChanged(); |
| 106 | void positionChanged(); |
| 107 | void rotationChanged(); |
| 108 | void classificationChanged(); |
| 109 | void classificationStringChanged(); |
| 110 | void has2DBoundsChanged(); |
| 111 | void has3DBoundsChanged(); |
| 112 | void offset2DChanged(); |
| 113 | void extent2DChanged(); |
| 114 | |
| 115 | private: |
| 116 | // Note: internally, and from C++ we still store this as a QUuid, |
| 117 | // so this just keeps the compatibility and avoid conversions in |
| 118 | // in the managers. |
| 119 | friend class QQuick3DXrAnchorManager; |
| 120 | QUuid uuid() const { return m_uuid; } |
| 121 | |
| 122 | QtQuick3DXr::XrSpaceId m_space { }; |
| 123 | QUuid m_uuid; |
| 124 | QVector3D m_offset3D; |
| 125 | QVector3D m_extent3D; |
| 126 | QVector3D m_position; |
| 127 | QQuaternion m_rotation; |
| 128 | Classification m_classification { Classification::Unknown }; |
| 129 | QString m_classificationString; |
| 130 | QSet<QUuid> m_roomLayoutUuids; |
| 131 | QSet<QUuid> m_spaceContainerUuids; |
| 132 | bool m_has2DBounds = false; |
| 133 | bool m_has3DBounds = false; |
| 134 | QVector2D m_offset2D; |
| 135 | QVector2D m_extent2D; |
| 136 | }; |
| 137 | |
| 138 | QT_END_NAMESPACE |
| 139 | |
| 140 | #endif // QQUICK3DXRSPATIALANCHOR_P_H |
| 141 | |