1 | // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
3 | |
4 | #include "qextrudedtextmesh.h" |
5 | #include "qextrudedtextgeometry.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | namespace Qt3DExtras { |
10 | |
11 | /*! |
12 | * \qmltype ExtrudedTextMesh |
13 | * \instantiates Qt3DExtras::QExtrudedTextMesh |
14 | * \inqmlmodule Qt3D.Extras |
15 | * \brief A 3D extruded Text mesh. |
16 | * |
17 | * The origin of the mesh is the rear left end of the text's baseline. |
18 | */ |
19 | |
20 | /*! |
21 | * \qmlproperty QString Qt3D.Extras::ExtrudedTextMesh::text |
22 | * |
23 | * Holds the text used for the mesh. |
24 | */ |
25 | |
26 | /*! |
27 | * \qmlproperty QFont Qt3D.Extras::ExtrudedTextMesh::font |
28 | * |
29 | * Holds the font of the text. |
30 | |
31 | * The mesh geometry is normalized by the font's pointSize, so a larger pointSize |
32 | * will result in smoother, rather than larger, text. pixelSize should not |
33 | * be used. |
34 | */ |
35 | |
36 | /*! |
37 | * \qmlproperty float Qt3D.Extras::ExtrudedTextMesh::depth |
38 | * |
39 | * Holds the extrusion depth of the text. |
40 | */ |
41 | |
42 | /*! |
43 | * \class Qt3DExtras::QExtrudedTextMesh |
44 | * \inheaderfile Qt3DExtras/QExtrudedTextMesh |
45 | * \inmodule Qt3DExtras |
46 | * |
47 | * \inherits Qt3DRender::QGeometryRenderer |
48 | * |
49 | * \brief A 3D extruded Text mesh. |
50 | * |
51 | * The origin of the mesh is the rear left end of the text's baseline. |
52 | */ |
53 | |
54 | /*! |
55 | * Constructs a new QText3DMesh with \a parent. |
56 | */ |
57 | QExtrudedTextMesh::(Qt3DCore::QNode *parent) |
58 | : QGeometryRenderer(parent) |
59 | { |
60 | QExtrudedTextGeometry *geometry = new QExtrudedTextGeometry(); |
61 | QObject::connect(sender: geometry, signal: &QExtrudedTextGeometry::depthChanged, context: this, slot: &QExtrudedTextMesh::depthChanged); |
62 | QObject::connect(sender: geometry, signal: &QExtrudedTextGeometry::textChanged, context: this, slot: &QExtrudedTextMesh::textChanged); |
63 | QObject::connect(sender: geometry, signal: &QExtrudedTextGeometry::fontChanged, context: this, slot: &QExtrudedTextMesh::fontChanged); |
64 | QGeometryRenderer::setGeometry(geometry); |
65 | } |
66 | |
67 | /*! \internal */ |
68 | QExtrudedTextMesh::() |
69 | {} |
70 | |
71 | void QExtrudedTextMesh::(const QString &text) |
72 | { |
73 | static_cast<QExtrudedTextGeometry*>(geometry())->setText(text); |
74 | } |
75 | |
76 | void QExtrudedTextMesh::(const QFont &font) |
77 | { |
78 | static_cast<QExtrudedTextGeometry*>(geometry())->setFont(font); |
79 | } |
80 | |
81 | void QExtrudedTextMesh::(float depth) |
82 | { |
83 | static_cast<QExtrudedTextGeometry*>(geometry())->setDepth(depth); |
84 | } |
85 | |
86 | /*! |
87 | * \property QExtrudedTextMesh::text |
88 | * |
89 | * Holds the text used for the mesh. |
90 | */ |
91 | QString QExtrudedTextMesh::() const |
92 | { |
93 | return static_cast<QExtrudedTextGeometry*>(geometry())->text(); |
94 | } |
95 | |
96 | /*! |
97 | * \property QExtrudedTextMesh::font |
98 | * |
99 | * Holds the font of the text. |
100 | * |
101 | * The mesh geometry is normalized by the font's pointSize, so a larger pointSize |
102 | * will result in smoother, rather than larger, text. pixelSize should not |
103 | * be used. |
104 | */ |
105 | QFont QExtrudedTextMesh::() const |
106 | { |
107 | return static_cast<QExtrudedTextGeometry*>(geometry())->font(); |
108 | } |
109 | |
110 | /*! |
111 | * \property QExtrudedTextMesh::depth |
112 | * |
113 | * Holds the extrusion depth of the text. |
114 | */ |
115 | float QExtrudedTextMesh::() const |
116 | { |
117 | return static_cast<QExtrudedTextGeometry*>(geometry())->extrusionLength(); |
118 | } |
119 | |
120 | } // namespace Qt3DExtras |
121 | |
122 | QT_END_NAMESPACE |
123 | |
124 | #include "moc_qextrudedtextmesh.cpp" |
125 | |