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
extrudedtextgeometry_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 EXTRUDEDTEXTGEOMETRY_P_H
7#define EXTRUDEDTEXTGEOMETRY_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#include <QFont>
25
26#if QT_CONFIG(concurrent)
27#include <QFuture>
28#include <QFutureWatcher>
29#endif
30
32
33class Q_QUICK3DHELPERS_EXPORT ExtrudedTextGeometry : public QQuick3DGeometry
34{
35 Q_OBJECT
36 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
37 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
38 Q_PROPERTY(float depth READ depth WRITE setDepth NOTIFY depthChanged)
39 Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged FINAL)
40 Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
41 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
42 QML_ELEMENT
43 QML_ADDED_IN_VERSION(6, 9)
44public:
45 enum Status { Null, Ready, Loading, Error };
46 Q_ENUM(Status)
47
48 explicit ExtrudedTextGeometry(QQuick3DObject *parent = nullptr);
49 ~ExtrudedTextGeometry() override;
50
51 QString text() const;
52 void setText(const QString &newText);
53
54 QFont font() const;
55 void setFont(const QFont &newFont);
56
57 float depth() const;
58 void setDepth(float newDepth);
59
60 float scale() const;
61 void setScale(float newScale);
62
63 bool asynchronous() const;
64 void setAsynchronous(bool newAsynchronous);
65
66 Status status() const;
67
68 using IndexType = quint32;
69
70private Q_SLOTS:
71 void doUpdateGeometry();
72 void requestFinished();
73
74Q_SIGNALS:
75 void textChanged();
76 void fontChanged();
77 void depthChanged();
78 void scaleChanged();
79 void asynchronousChanged();
80 void statusChanged();
81
82private:
83 struct GeometryData {
84 QByteArray vertexData;
85 QByteArray indexData;
86 QVector3D boundsMin;
87 QVector3D boundsMax;
88 };
89
90 void scheduleGeometryUpdate();
91 void updateGeometry(const GeometryData &geometryData);
92
93 static ExtrudedTextGeometry::GeometryData generateExtrudedTextGeometry(const QString &text,
94 const QFont &font,
95 float depth,
96 float scale);
97#if QT_CONFIG(concurrent)
98 static void generateExtrudedTextGeometryAsync(QPromise<ExtrudedTextGeometry::GeometryData> &promise,
99 const QString &text,
100 const QFont &font,
101 float depth,
102 float scale);
103#endif
104
105
106 QString m_text;
107 QFont m_font = QFont(QStringLiteral("Arial"), 4);
108 float m_depth = 1.0f;
109 float m_scale = 1.0f;
110 bool m_asynchronous = true;
111 Status m_status = Null;
112#if QT_CONFIG(concurrent)
113 QFuture<GeometryData> m_geometryDataFuture;
114 QFutureWatcher<GeometryData> m_geometryDataWatcher;
115#endif
116 bool m_geometryUpdateRequested = false;
117 bool m_pendingAsyncUpdate = false;
118};
119
120QT_END_NAMESPACE
121
122#endif // EXTRUDEDTEXTGEOMETRY_P_H
Combined button and popup list for selecting options.
QVector3D mix(const QVector3D &a, const QVector3D &b, float ratio)
TriangulationData triangulate(const QString &text, const QFont &font, float scale)
std::vector< ExtrudedTextGeometry::IndexType > indices
std::vector< ExtrudedTextGeometry::IndexType > outlineIndices