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