diff options
author | Mika Salmela <mika.salmela@digia.com> | 2014-07-04 09:58:12 +0300 |
---|---|---|
committer | Mika Salmela <mika.salmela@digia.com> | 2014-07-04 10:03:13 +0300 |
commit | 6e4fb232702fa128b5efa3eef5dfaff4870a9fd0 (patch) | |
tree | 315abbc95d09a558e3eb47c757c06fe66ce3c236 /src/datavisualization/data/qsurface3dseries.cpp | |
parent | 6264a2ff1518d374e6150bf584f2ad3d133457dd (diff) |
Texture to surface
API for setting a texture to surface.
Task-number: QTRD-3232
Change-Id: Icd9de61882b54b9c1fc84a742e49980926ca681d
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavisualization/data/qsurface3dseries.cpp')
-rw-r--r-- | src/datavisualization/data/qsurface3dseries.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/datavisualization/data/qsurface3dseries.cpp b/src/datavisualization/data/qsurface3dseries.cpp index 1107d721..bcfc4042 100644 --- a/src/datavisualization/data/qsurface3dseries.cpp +++ b/src/datavisualization/data/qsurface3dseries.cpp @@ -300,6 +300,54 @@ QSurface3DSeries::DrawFlags QSurface3DSeries::drawMode() const } /*! + * Set the \a texture as a QImage for the surface. To clear the texture, set empty + * QImage as texture. + */ +void QSurface3DSeries::setTexture(const QImage &texture) +{ + if (dptr()->m_texture != texture) { + dptr()->setTexture(texture); + + emit textureChanged(texture); + dptr()->m_textureFile.clear(); + } +} + +QImage QSurface3DSeries::texture() const +{ + return dptrc()->m_texture; +} + +/*! \property QSurface3DSeries::textureFile + * + * Holds the texture file name for the surface texture. To clear the texture, set empty + * file name. + */ +void QSurface3DSeries::setTextureFile(const QString &filename) +{ + if (dptr()->m_textureFile != filename) { + if (filename.isEmpty()) { + setTexture(QImage()); + } else { + QImage image(filename); + if (image.isNull()) { + qWarning() << "Warning: Tried to set invalid image file as surface texture."; + return; + } + setTexture(image); + } + + dptr()->m_textureFile = filename; + emit textureFileChanged(filename); + } +} + +QString QSurface3DSeries::textureFile() const +{ + return dptrc()->m_textureFile; +} + +/*! * \internal */ QSurface3DSeriesPrivate *QSurface3DSeries::dptr() @@ -445,4 +493,11 @@ void QSurface3DSeriesPrivate::setDrawMode(QSurface3DSeries::DrawFlags mode) } } +void QSurface3DSeriesPrivate::setTexture(const QImage &texture) +{ + m_texture = texture; + if (static_cast<Surface3DController *>(m_controller)) + static_cast<Surface3DController *>(m_controller)->updateSurfaceTexture(qptr()); +} + QT_END_NAMESPACE_DATAVISUALIZATION |