diff options
Diffstat (limited to 'src/datavisualization')
-rw-r--r-- | src/datavisualization/engine/q3dsurface.cpp | 32 | ||||
-rw-r--r-- | src/datavisualization/engine/q3dsurface.h | 11 | ||||
-rw-r--r-- | src/datavisualization/engine/surface3dcontroller.cpp | 14 | ||||
-rw-r--r-- | src/datavisualization/engine/surface3dcontroller_p.h | 5 | ||||
-rw-r--r-- | src/datavisualization/engine/surface3drenderer.cpp | 4 | ||||
-rw-r--r-- | src/datavisualization/engine/theme.cpp | 2 |
6 files changed, 57 insertions, 11 deletions
diff --git a/src/datavisualization/engine/q3dsurface.cpp b/src/datavisualization/engine/q3dsurface.cpp index e066f717..78ec70d4 100644 --- a/src/datavisualization/engine/q3dsurface.cpp +++ b/src/datavisualization/engine/q3dsurface.cpp @@ -198,6 +198,11 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE */ /*! + * \qmlproperty var Surface3D::gradient + * The current surface gradient. Setting this property replaces the previous gradient. + */ + +/*! * Constructs a new 3D surface window. */ Q3DSurface::Q3DSurface() @@ -307,17 +312,24 @@ bool Q3DSurface::isBackgroundVisible() const } /*! - * Sets a predefined \a theme from \c QDataVis::ColorTheme. It is preset to \c QDataVis::ThemeQt by + * \property Q3DSurface::theme + * + * A predefined \a theme from \c QDataVis::ColorTheme. It is preset to \c QDataVis::ThemeQt by * default. Theme affects label colors, text color, background color, window color and * grid color. Lighting is also adjusted by themes. * - * \warning This method is subject to change. + * \warning This property is subject to change. */ void Q3DSurface::setTheme(QDataVis::ColorTheme theme) { d_ptr->m_shared->setColorTheme(theme); } +QDataVis::ColorTheme Q3DSurface::theme() const +{ + return d_ptr->m_shared->theme().colorTheme(); +} + /*! * \property Q3DSurface::shadowQuality * @@ -372,6 +384,22 @@ bool Q3DSurface::isSurfaceGridEnabled() const } /*! + * \property Q3DSurface::gradient + * + * The current surface gradient. Setting this property replaces the previous gradient with + * the given \a gradient. + */ +void Q3DSurface::setGradient(const QLinearGradient &gradient) +{ + d_ptr->m_shared->setGradient(gradient); +} + +QLinearGradient Q3DSurface::gradient() const +{ + return d_ptr->m_shared->gradient(); +} + +/*! * \property Q3DSurface::font * * Sets the \a font for labels. It is preset to \c Arial by default. diff --git a/src/datavisualization/engine/q3dsurface.h b/src/datavisualization/engine/q3dsurface.h index 1622def3..167af32d 100644 --- a/src/datavisualization/engine/q3dsurface.h +++ b/src/datavisualization/engine/q3dsurface.h @@ -22,6 +22,7 @@ #include <QtDataVisualization/qdatavisualizationenums.h> #include <QtDataVisualization/q3dwindow.h> #include <QFont> +#include <QLinearGradient> QT_DATAVISUALIZATION_BEGIN_NAMESPACE @@ -33,11 +34,13 @@ class QT_DATAVISUALIZATION_EXPORT Q3DSurface : public Q3DWindow { Q_OBJECT Q_PROPERTY(QtDataVisualization::QDataVis::LabelTransparency labelTransparency READ labelTransparency WRITE setLabelTransparency) + Q_PROPERTY(QtDataVisualization::QDataVis::ColorTheme theme READ theme WRITE setTheme) Q_PROPERTY(QtDataVisualization::QDataVis::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality) Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible) Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) Q_PROPERTY(bool smoothSurfaceEnabled READ isSmoothSurfaceEnabled WRITE setSmoothSurfaceEnabled) Q_PROPERTY(bool surfaceGridEnabled READ isSurfaceGridEnabled WRITE setSurfaceGridEnabled) + Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient) Q_PROPERTY(QFont font READ font WRITE setFont) Q_ENUMS(QtDataVisualization::QDataVis::LabelTransparency) @@ -45,27 +48,27 @@ public: explicit Q3DSurface(); ~Q3DSurface(); - // Enable or disable background grid void setGridVisible(bool visible); bool isGridVisible() const; - // Enable or disable background mesh void setBackgroundVisible(bool visible); bool isBackgroundVisible() const; void setTheme(QDataVis::ColorTheme theme); + QDataVis::ColorTheme theme() const; void setShadowQuality(QDataVis::ShadowQuality quality); QDataVis::ShadowQuality shadowQuality() const; - // Enable or disable the smoothes of the surface void setSmoothSurfaceEnabled(bool enabled); bool isSmoothSurfaceEnabled() const; - // Enable or disable the grid on the surface void setSurfaceGridEnabled(bool enabled); bool isSurfaceGridEnabled() const; + void setGradient(const QLinearGradient &gradient); + QLinearGradient gradient() const; + void setGradientColorAt(qreal pos, const QColor &color); // Axes diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp index 675552ed..e4903a6f 100644 --- a/src/datavisualization/engine/surface3dcontroller.cpp +++ b/src/datavisualization/engine/surface3dcontroller.cpp @@ -129,6 +129,20 @@ bool Surface3DController::surfaceGrid() return m_isSurfaceGridEnabled; } +void Surface3DController::setGradient(const QLinearGradient &gradient) +{ + m_userDefinedGradient = gradient; + m_userDefinedGradient.setStart(1, 1000); + m_userDefinedGradient.setFinalStop(0, 0); + m_changeTracker.gradientColorChanged = true; + emitNeedRender(); +} + +QLinearGradient Surface3DController::gradient() const +{ + return m_userDefinedGradient; +} + void Surface3DController::setGradientColorAt(qreal pos, const QColor &color) { m_userDefinedGradient.setColorAt(pos, color); diff --git a/src/datavisualization/engine/surface3dcontroller_p.h b/src/datavisualization/engine/surface3dcontroller_p.h index 7a2087ff..bf7167a6 100644 --- a/src/datavisualization/engine/surface3dcontroller_p.h +++ b/src/datavisualization/engine/surface3dcontroller_p.h @@ -71,14 +71,15 @@ public: void initializeOpenGL(); virtual void synchDataToRenderer(); - // Enable or disable the smoothes of the surface void setSmoothSurface(bool enable); bool smoothSurface(); - // Enable or disable the grid on the surface void setSurfaceGrid(bool enable); bool surfaceGrid(); + void setGradient(const QLinearGradient &gradient); + QLinearGradient gradient() const; + void setGradientColorAt(qreal pos, const QColor &color); virtual void setActiveDataProxy(QAbstractDataProxy *proxy); diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 67f12b0a..ac8bef4b 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -1225,11 +1225,11 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle) void Surface3DRenderer::updateSurfaceGradient(const QLinearGradient &gradient) { - QImage image(QSize(4, 100), QImage::Format_RGB32); + QImage image(QSize(4, 1000), QImage::Format_RGB32); QPainter pmp(&image); pmp.setBrush(QBrush(gradient)); pmp.setPen(Qt::NoPen); - pmp.drawRect(0, 0, 4, 100); + pmp.drawRect(0, 0, 4, 1000); if (m_gradientTexture) { m_textureHelper->deleteTexture(&m_gradientTexture); diff --git a/src/datavisualization/engine/theme.cpp b/src/datavisualization/engine/theme.cpp index dfa189a4..38a54196 100644 --- a/src/datavisualization/engine/theme.cpp +++ b/src/datavisualization/engine/theme.cpp @@ -37,7 +37,7 @@ Theme::Theme() m_highlightBarColor(QColor(Qt::red)), m_highlightRowColor(QColor(Qt::darkRed)), m_highlightColumnColor(QColor(Qt::darkMagenta)), - m_surfaceGradient(QLinearGradient(1, 100, 0, 0)), + m_surfaceGradient(QLinearGradient(1, 1000, 0, 0)), m_lightStrength(4.0f), m_ambientStrength(0.3f), m_highlightLightStrength(8.0f), |