summaryrefslogtreecommitdiffstats
path: root/src/extras/3dtext/qextrudedtextmesh.cpp
blob: e6e80a787d885f4992781a7f1c22d86149899c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "qextrudedtextmesh.h"
#include "qextrudedtextgeometry.h"

QT_BEGIN_NAMESPACE

namespace Qt3DExtras {

/*!
 * \qmltype ExtrudedTextMesh
 * \instantiates Qt3DExtras::QExtrudedTextMesh
 * \inqmlmodule Qt3D.Extras
 * \brief A 3D extruded Text mesh.
 *
 * The origin of the mesh is the rear left end of the text's baseline.
 */

/*!
 * \qmlproperty QString Qt3DExtras::ExtrudedTextMesh::text
 *
 * Holds the text used for the mesh.
 */

/*!
 * \qmlproperty QFont Qt3DExtras::ExtrudedTextMesh::font
 *
 * Holds the font of the text.

 * The mesh geometry is normalized by the font's pointSize, so a larger pointSize
 * will result in smoother, rather than larger, text. pixelSize should not
 * be used.
 */

/*!
 * \qmlproperty float Qt3DExtras::ExtrudedTextMesh::depth
 *
 * Holds the extrusion depth of the text.
 */

/*!
 * \class Qt3DExtras::QExtrudedTextMesh
 * \inheaderfile Qt3DExtras/QExtrudedTextMesh
 * \inmodule Qt3DExtras
 *
 * \inherits Qt3DRender::QGeometryRenderer
 *
 * \brief A 3D extruded Text mesh.
 *
 * The origin of the mesh is the rear left end of the text's baseline.
 */

/*!
 * Constructs a new QText3DMesh with \a parent.
 */
QExtrudedTextMesh::QExtrudedTextMesh(Qt3DCore::QNode *parent)
    : QGeometryRenderer(parent)
{
    QExtrudedTextGeometry *geometry = new QExtrudedTextGeometry();
    QObject::connect(geometry, &QExtrudedTextGeometry::depthChanged, this, &QExtrudedTextMesh::depthChanged);
    QObject::connect(geometry, &QExtrudedTextGeometry::textChanged,  this, &QExtrudedTextMesh::textChanged);
    QObject::connect(geometry, &QExtrudedTextGeometry::fontChanged,  this, &QExtrudedTextMesh::fontChanged);
    QGeometryRenderer::setGeometry(geometry);
}

/*! \internal */
QExtrudedTextMesh::~QExtrudedTextMesh()
{}

void QExtrudedTextMesh::setText(const QString &text)
{
    static_cast<QExtrudedTextGeometry*>(geometry())->setText(text);
}

void QExtrudedTextMesh::setFont(const QFont &font)
{
    static_cast<QExtrudedTextGeometry*>(geometry())->setFont(font);
}

void QExtrudedTextMesh::setDepth(float depth)
{
    static_cast<QExtrudedTextGeometry*>(geometry())->setDepth(depth);
}

/*!
 * \property QExtrudedTextMesh::text
 *
 * Holds the text used for the mesh.
 */
QString QExtrudedTextMesh::text() const
{
    return static_cast<QExtrudedTextGeometry*>(geometry())->text();
}

/*!
 * \property QExtrudedTextMesh::font
 *
 * Holds the font of the text.
 *
 * The mesh geometry is normalized by the font's pointSize, so a larger pointSize
 * will result in smoother, rather than larger, text. pixelSize should not
 * be used.
 */
QFont QExtrudedTextMesh::font() const
{
    return static_cast<QExtrudedTextGeometry*>(geometry())->font();
}

/*!
 * \property QExtrudedTextMesh::depth
 *
 * Holds the extrusion depth of the text.
 */
float QExtrudedTextMesh::depth() const
{
    return static_cast<QExtrudedTextGeometry*>(geometry())->extrusionLength();
}

} // namespace Qt3DExtras

QT_END_NAMESPACE

#include "moc_qextrudedtextmesh.cpp"