diff options
author | Tomi Korpipää <tomi.korpipaa@qt.io> | 2016-11-18 13:12:13 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2016-11-18 11:17:22 +0000 |
commit | e584f8753a39d3364aa50b4b89bafa4a0209af7c (patch) | |
tree | d6438e2c66dd3ae5310bce8e0b49bae84cf228cc /src/datavisualization/engine/q3dlight.cpp | |
parent | 4ff14c23b271747cc7a23fd72499d2032d692185 (diff) |
Allow light position modification by user
Change-Id: I7efd56754bae16990fd11081493da0a37698f76b
Task-number: QTRD-1803
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/datavisualization/engine/q3dlight.cpp')
-rw-r--r-- | src/datavisualization/engine/q3dlight.cpp | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/src/datavisualization/engine/q3dlight.cpp b/src/datavisualization/engine/q3dlight.cpp index bc337512..8c439023 100644 --- a/src/datavisualization/engine/q3dlight.cpp +++ b/src/datavisualization/engine/q3dlight.cpp @@ -37,7 +37,9 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION * \brief Representation of a light source in 3D space. * \since QtDataVisualization 1.0 * - * Q3DLight represents a monochrome non variable light source in 3D space. + * Q3DLight represents a monochrome light source in 3D space. + * + * \note Default light has isAutoPosition() \c true. */ /*! @@ -48,7 +50,18 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION * \instantiates Q3DLight * \brief Representation of a light source in 3D space. * - * Light3D represents a monochrome non variable light source in 3D space. + * Light3D represents a monochrome light source in 3D space. + * + * \note Default light has autoPosition \c true. + */ + +/*! + * \qmlproperty bool Light3D::autoPosition + * \since QtDataVisualization 1.3 + * Holds a flag telling if the light position is automatic or not. If true, light position follows + * camera automatically. + * \note Has no effect if shadows are enabled. Remember to disable shadows before setting light's + * position, or it will be overwritten by automatic positioning, if autoPosition is false. */ /*! @@ -68,8 +81,31 @@ Q3DLight::~Q3DLight() { } +/*! + * \property Q3DLight::autoPosition + * \since QtDataVisualization 5.9 + * Holds a flag telling if the light position is automatic or not. If true, light position follows + * camera automatically. + * \note Has no effect if shadows are enabled. Remember to disable shadows before setting light's + * position, or it will be overwritten by automatic positioning, if isAutoPosition() is false. + */ +void Q3DLight::setAutoPosition(bool enabled) +{ + if (enabled != d_ptr->m_automaticLight) { + d_ptr->m_automaticLight = enabled; + setDirty(true); + emit autoPositionChanged(enabled); + } +} + +bool Q3DLight::isAutoPosition() +{ + return d_ptr->m_automaticLight; +} + Q3DLightPrivate::Q3DLightPrivate(Q3DLight *q) : - q_ptr(q) + q_ptr(q), + m_automaticLight(false) { } @@ -79,8 +115,11 @@ Q3DLightPrivate::~Q3DLightPrivate() void Q3DLightPrivate::sync(Q3DLight &other) { - Q_UNUSED(other); - // Do nothing. Only value light has to sync is the position, which we handle internally. + if (q_ptr->isDirty()) { + other.setPosition(q_ptr->position()); + other.setAutoPosition(q_ptr->isAutoPosition()); + q_ptr->setDirty(false); + } } QT_END_NAMESPACE_DATAVISUALIZATION |