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
planegeometry_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 PLANEGEOMETRY_P_H
7#define PLANEGEOMETRY_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 PlaneGeometry : public QQuick3DGeometry
33{
34 Q_OBJECT
35 Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged FINAL)
36 Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged FINAL)
37 Q_PROPERTY(QSize meshResolution READ meshResolution WRITE setMeshResolution NOTIFY meshResolutionChanged FINAL)
38 Q_PROPERTY(Plane plane READ plane WRITE setPlane NOTIFY planeChanged FINAL)
39 Q_PROPERTY(bool reversed READ reversed WRITE setReversed NOTIFY reversedChanged FINAL)
40 Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored NOTIFY mirroredChanged 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 enum Plane { XY, XZ, ZY };
50 Q_ENUM(Plane)
51
52 explicit PlaneGeometry(QQuick3DObject *parent = nullptr);
53 ~PlaneGeometry() override;
54
55 float width() const;
56 void setWidth(float newWidth);
57 float height() const;
58 void setHeight(float newHeight);
59
60 QSize meshResolution() const;
61 void setMeshResolution(const QSize &newMeshResolution);
62
63 Plane plane() const;
64 void setPlane(Plane newPlane);
65
66 bool mirrored() const;
67 void setMirrored(bool newMirrored);
68
69 bool asynchronous() const;
70 void setAsynchronous(bool newAsynchronous);
71
72 Status status() const;
73
74 bool reversed() const;
75 void setReversed(bool newReversed);
76
77private Q_SLOTS:
78 void doUpdateGeometry();
79 void requestFinished();
80
81Q_SIGNALS:
82 void widthChanged();
83 void heightChanged();
84 void meshResolutionChanged();
85 void planeChanged();
86 void mirroredChanged();
87 void asynchronousChanged();
88 void statusChanged();
89 void reversedChanged();
90
91private:
92 struct GeometryData {
93 QByteArray vertexData;
94 QByteArray indexData;
95 QVector3D boundsMin;
96 QVector3D boundsMax;
97 };
98
99 void scheduleGeometryUpdate();
100 void updateGeometry(const GeometryData &geometryData);
101
102 static PlaneGeometry::GeometryData generatePlaneGeometry(float width,
103 float height,
104 QSize meshResolution,
105 Plane plane,
106 bool reversed,
107 bool mirrored);
108#if QT_CONFIG(concurrent)
109 static void generatePlaneGeometryAsync(QPromise<PlaneGeometry::GeometryData> &promise,
110 float width,
111 float height,
112 QSize meshResolution,
113 Plane plane,
114 bool reversed,
115 bool mirrored);
116#endif
117 float m_width = 100.0f;
118 float m_height = 100.0f;
119 QSize m_meshResolution = QSize(2, 2);
120 Plane m_plane = XY;
121 bool m_reversed = false;
122 bool m_mirrored = false;
123 bool m_asynchronous = true;
124 Status m_status = Null;
125#if QT_CONFIG(concurrent)
126 QFuture<GeometryData> m_geometryDataFuture;
127 QFutureWatcher<GeometryData> m_geometryDataWatcher;
128#endif
129 bool m_geometryUpdateRequested = false;
130 bool m_pendingAsyncUpdate = false;
131};
132
133QT_END_NAMESPACE
134
135#endif // PLANEGEOMETRY_P_H