1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DXRSPATIALANCHORLISTMODEL_P_H
5#define QQUICK3DXRSPATIALANCHORLISTMODEL_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 <QAbstractListModel>
19#include <QtQmlIntegration/qqmlintegration.h>
20#include <QtCore/qpointer.h>
21#include <QtCore/qstringlist.h>
22#include <QUuid>
23
24QT_BEGIN_NAMESPACE
25
26class QQuick3DXrAnchorManager;
27class QQuick3DXrSpatialAnchor;
28
29class QQuick3DXrSpatialAnchorListModel : public QAbstractListModel
30{
31 Q_OBJECT
32 Q_PROPERTY(FilterMode filterMode READ filterMode WRITE setFilterMode NOTIFY filterModeChanged FINAL)
33 Q_PROPERTY(ClassificationFlags classificationFilter READ classificationFilter WRITE setClassificationFilter NOTIFY classificationFilterChanged FINAL)
34 Q_PROPERTY(QStringList classificationStringFilter READ classificationStringFilter WRITE setClassificationStringFilter NOTIFY classificationStringFilterChanged FINAL)
35 Q_PROPERTY(QStringList identifierFilter READ identifierFilter WRITE setIdentifierFilter NOTIFY identifierFilterChanged FINAL)
36
37 QML_NAMED_ELEMENT(XrSpatialAnchorListModel)
38 QML_ADDED_IN_VERSION(6, 8)
39public:
40 enum class FilterMode {
41 All,
42 Classification,
43 Identifier
44 };
45 Q_ENUM(FilterMode)
46
47 enum ClassificationFlag : quint32 {
48 Wall = 0x1,
49 Ceiling = 0x2,
50 Floor = 0x4,
51 Table = 0x8,
52 Seat = 0x10,
53 Window = 0x20,
54 Door = 0x40,
55 Other = 0x80,
56 };
57 Q_ENUM(ClassificationFlag)
58 Q_DECLARE_FLAGS(ClassificationFlags , ClassificationFlag)
59 Q_FLAG(ClassificationFlags)
60
61 enum SpatialAnchorRoles {
62 Anchor = Qt::UserRole + 21
63 };
64
65 explicit QQuick3DXrSpatialAnchorListModel(QObject *parent = nullptr);
66
67 int rowCount(const QModelIndex &parent) const override;
68 QVariant data(const QModelIndex &index, int role) const override;
69 QHash<int, QByteArray> roleNames() const override;
70
71 Q_INVOKABLE void requestSceneCapture();
72 Q_INVOKABLE void queryAnchors();
73
74 FilterMode filterMode() const;
75 void setFilterMode(FilterMode newFilterMode);
76
77 QStringList identifierFilter() const;
78 void setIdentifierFilter(const QStringList &filter);
79
80 ClassificationFlags classificationFilter() const;
81 void setClassificationFilter(ClassificationFlags newClassFilter);
82
83 QStringList classificationStringFilter() const;
84 void setClassificationStringFilter(const QStringList &newClassStringFilter);
85
86signals:
87 void filterModeChanged();
88 void identifierFilterChanged();
89 void classificationFilterChanged();
90 void classificationStringFilterChanged();
91
92private Q_SLOTS:
93 void handleAnchorAdded(QQuick3DXrSpatialAnchor* anchor);
94 void handleAnchorRemoved(QUuid uuid);
95 void handleAnchorUpdated(QQuick3DXrSpatialAnchor* anchor);
96
97private:
98 QPointer<QQuick3DXrAnchorManager> m_anchorManager;
99 FilterMode m_filterMode = FilterMode::All;
100 QStringList m_uuids;
101 ClassificationFlags m_classFilter;
102 QSet<QString> m_classStringFilter;
103};
104
105QT_END_NAMESPACE
106
107#endif // QQUICK3DXRSPATIALANCHORLISTMODEL_P_H
108

source code of qtquick3d/src/xr/quick3dxr/qquick3dxrspatialanchorlistmodel_p.h