Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cuboidgeometry_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef CUBOIDGEOMETRY_P_H
7#define CUBOIDGEOMETRY_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtQuick3DHelpers/qtquick3dhelpersexports.h>
21#include <QQuick3DGeometry>
22#include <QQmlEngine>
23#include <QVector3D>
24
25#if QT_CONFIG(concurrent)
26#include <QFuture>
27#include <QFutureWatcher>
28#endif
29
31
32class Q_QUICK3DHELPERS_EXPORT CuboidGeometry : public QQuick3DGeometry
33{
34 Q_OBJECT
35 Q_PROPERTY(float xExtent READ xExtent WRITE setXExtent NOTIFY xExtentChanged FINAL)
36 Q_PROPERTY(float yExtent READ yExtent WRITE setYExtent NOTIFY yExtentChanged FINAL)
37 Q_PROPERTY(float zExtent READ zExtent WRITE setZExtent NOTIFY zExtentChanged FINAL)
38 Q_PROPERTY(QSize yzMeshResolution READ yzMeshResolution WRITE setYzMeshResolution NOTIFY yzMeshResolutionChanged FINAL)
39 Q_PROPERTY(QSize xzMeshResolution READ xzMeshResolution WRITE setXzMeshResolution NOTIFY xzMeshResolutionChanged FINAL)
40 Q_PROPERTY(QSize xyMeshResolution READ xyMeshResolution WRITE setXyMeshResolution NOTIFY xyMeshResolutionChanged FINAL)
41 Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
42 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
43 QML_ELEMENT
44 QML_ADDED_IN_VERSION(6, 9)
45public:
46 enum Status { Null, Ready, Loading, Error };
47 Q_ENUM(Status)
48
49 explicit CuboidGeometry(QQuick3DObject *parent = nullptr);
50 ~CuboidGeometry() override;
51 float xExtent() const;
52 void setXExtent(float newXExtent);
53 float yExtent() const;
54 void setYExtent(float newYExtent);
55
56 float zExtent() const;
57 void setZExtent(float newZExtent);
58
59 QSize yzMeshResolution() const;
60 void setYzMeshResolution(const QSize &newYzMeshResolution);
61
62 QSize xzMeshResolution() const;
63 void setXzMeshResolution(const QSize &newXzMeshResolution);
64
65 QSize xyMeshResolution() const;
66 void setXyMeshResolution(const QSize &newXyMeshResolution);
67
68 bool asynchronous() const;
69 void setAsynchronous(bool newAsynchronous);
70
71 Status status() const;
72
73private Q_SLOTS:
74 void doUpdateGeometry();
75 void requestFinished();
76
77Q_SIGNALS:
78 void xExtentChanged();
79 void yExtentChanged();
80 void zExtentChanged();
81 void yzMeshResolutionChanged();
82 void xzMeshResolutionChanged();
83 void xyMeshResolutionChanged();
84 void asynchronousChanged();
85 void statusChanged();
86
87private:
88 struct GeometryData {
89 QByteArray vertexData;
90 QByteArray indexData;
91 QVector3D boundsMin;
92 QVector3D boundsMax;
93 };
94
95 void scheduleGeometryUpdate();
96 void updateGeometry(const GeometryData &geometryData);
97
98 static CuboidGeometry::GeometryData generateCuboidGeometry(float xExtent,
99 float yExtent,
100 float zExtent,
101 QSize yzMeshResolution,
102 QSize xzMeshResolution,
103 QSize xyMeshResolution);
104#if QT_CONFIG(concurrent)
105 static void generateCuboidGeometryAsync(QPromise<CuboidGeometry::GeometryData> &promise,
106 float xExtent,
107 float yExtent,
108 float zExtent,
109 QSize yzMeshResolution,
110 QSize xzMeshResolution,
111 QSize xyMeshResolution);
112#endif
113
114 float m_xExtent = 100.0f;
115 float m_yExtent = 100.0f;
116 float m_zExtent = 100.0f;
117 QSize m_yzMeshResolution = QSize(2, 2);
118 QSize m_xzMeshResolution = QSize(2, 2);
119 QSize m_xyMeshResolution = QSize(2, 2);
120 bool m_asynchronous = true;
121 Status m_status = Null;
122#if QT_CONFIG(concurrent)
123 QFuture<GeometryData> m_geometryDataFuture;
124 QFutureWatcher<GeometryData> m_geometryDataWatcher;
125#endif
126 bool m_geometryUpdateRequested = false;
127 bool m_pendingAsyncUpdate = false;
128};
129
130QT_END_NAMESPACE
131
132#endif // CUBOIDGEOMETRY_P_H
Combined button and popup list for selecting options.