blob: 129f6491b7ead94c204029137c2b2e2eeecd0f43 (
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
|
// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qshaderdata.h"
#include "qshaderdata_p.h"
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
PropertyReaderInterface::~PropertyReaderInterface()
{
}
QShaderDataPrivate::QShaderDataPrivate()
: QComponentPrivate()
, m_propertyReader(PropertyReaderInterfacePtr(new QShaderDataPropertyReader()))
{
}
QShaderDataPrivate::QShaderDataPrivate(PropertyReaderInterfacePtr reader)
: QComponentPrivate()
, m_propertyReader(reader)
{
}
/*!
* \class Qt3DRender::QShaderData
* \inheaderfile Qt3DRender/QShaderData
* \inmodule Qt3DRender
*
* \brief Provides a way of specifying values of a Uniform Block or a shader
* structure.
*
* \note When subclassing and adding properties to QShaderData, note that if
* you need to nest an inner Qt3DRender::QShaderData, the data type of the
* property should be Qt3DRender::QShaderData* instead of the name of your
* subclass.
*
* \since 5.5
*/
/*!
\fn Qt3DRender::PropertyReaderInterface::readProperty(const QVariant &v)
\return the property identified by \a v.
*/
/*!
* Constructs a new QShaderData with the specified \a parent.
*/
QShaderData::QShaderData(QNode *parent)
: QComponent(*new QShaderDataPrivate, parent)
{
}
/*! \internal */
QShaderData::~QShaderData()
{
}
/*!
* \brief QShaderData::propertyReader
* Returns the PropertyReaderInterfacePtr for this shader data
*/
PropertyReaderInterfacePtr QShaderData::propertyReader() const
{
Q_D(const QShaderData);
return d->m_propertyReader;
}
/*! \internal */
QShaderData::QShaderData(QShaderDataPrivate &dd, QNode *parent)
: QComponent(dd, parent)
{
}
/*! \internal */
bool QShaderData::event(QEvent *event)
{
Q_D(QShaderData);
if (event->type() == QEvent::DynamicPropertyChange) {
auto e = static_cast<QDynamicPropertyChangeEvent*>(event);
const auto propertyName = e->propertyName();
const QVariant data = property(propertyName);
if (data.canConvert<Qt3DCore::QNode*>()) {
const auto node = data.value<Qt3DCore::QNode*>();
const auto id = node ? node->id() : Qt3DCore::QNodeId();
d->notifyDynamicPropertyChange(propertyName, QVariant::fromValue(id));
} else {
d->notifyDynamicPropertyChange(propertyName, data);
}
}
return QComponent::event(event);
}
} // namespace Qt3DRender
QT_END_NAMESPACE
#include "moc_qshaderdata.cpp"
|