diff options
author | Mika Salmela <mika.salmela@digia.com> | 2013-07-26 13:56:45 +0300 |
---|---|---|
committer | Mika Salmela <mika.salmela@digia.com> | 2013-07-26 13:59:23 +0300 |
commit | d1eb5ceed9bb4e35a185e575f9bd9d2228f9f5e4 (patch) | |
tree | 39b75e46322759c56c1be7588bf44541155d9771 | |
parent | 51d6d0258c8d1fe0608045986792ac5601f8613f (diff) |
Surface gradient to theme and drawing implementation to renderer.
Change-Id: I78a3f3d0aa9bd24a05368545cf8e779dda65ef4c
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
-rw-r--r-- | examples/surfacechart/chartmodifier.cpp | 20 | ||||
-rw-r--r-- | examples/surfacechart/chartmodifier.h | 1 | ||||
-rw-r--r-- | examples/surfacechart/main.cpp | 26 | ||||
-rw-r--r-- | src/datavis3d/engine/q3dsurface.cpp | 5 | ||||
-rw-r--r-- | src/datavis3d/engine/q3dsurface.h | 2 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/surface.frag | 6 | ||||
-rw-r--r-- | src/datavis3d/engine/shaders/surfaceFlat.frag | 8 | ||||
-rw-r--r-- | src/datavis3d/engine/surface3dcontroller.cpp | 6 | ||||
-rw-r--r-- | src/datavis3d/engine/surface3dcontroller_p.h | 4 | ||||
-rw-r--r-- | src/datavis3d/engine/surface3drenderer.cpp | 100 | ||||
-rw-r--r-- | src/datavis3d/engine/surface3drenderer_p.h | 14 | ||||
-rw-r--r-- | src/datavis3d/engine/theme.cpp | 6 | ||||
-rw-r--r-- | src/datavis3d/engine/theme_p.h | 2 |
13 files changed, 127 insertions, 73 deletions
diff --git a/examples/surfacechart/chartmodifier.cpp b/examples/surfacechart/chartmodifier.cpp index a78b2d2e..010c0b6f 100644 --- a/examples/surfacechart/chartmodifier.cpp +++ b/examples/surfacechart/chartmodifier.cpp @@ -85,7 +85,7 @@ void ChartModifier::toggleSqrtSin(bool enable) for (qreal i = -8.0 + stepZ / 2.0 ; i < 8.0 ; i += stepZ) { for (qreal j = -8.0 + stepX / 2.0; j < 8.0; j += stepX) { qreal R = qSqrt(i*i + j*j) + 0.01; - qreal y = sin(R)/R + 1.0; + qreal y = (sin(R)/R + 0.24) * 1.61; series << y; if (y > biggest) biggest = y; if (y < smallest) smallest = y; @@ -101,6 +101,24 @@ void ChartModifier::toggleSqrtSin(bool enable) } } +void ChartModifier::togglePlane(bool enable) +{ + qDebug() << "ChartModifier::togglePlane " << enable; + if (enable) { + QList<qreal> series; + + qreal y = 2.0 / qreal(m_xCount - 1); + for (int i = 0; i < m_zCount; i++) { + for (int j = 0; j < m_xCount; j++) { + series << j * y; + } + } + + m_chart->setTickCount(4, 0.5f); + m_chart->appendSeries(series, m_xCount, m_zCount); + } +} + void ChartModifier::toggleGridSliderLock(bool enable) { m_gridSlidersLocked = enable; diff --git a/examples/surfacechart/chartmodifier.h b/examples/surfacechart/chartmodifier.h index 8b84efbb..3daf96ed 100644 --- a/examples/surfacechart/chartmodifier.h +++ b/examples/surfacechart/chartmodifier.h @@ -56,6 +56,7 @@ public: void toggleSmooth(bool enabled); void toggleSurfaceGrid(bool enable); void toggleSqrtSin(bool enable); + void togglePlane(bool enable); void toggleGridSliderLock(bool enable); void setGridSliderX(QSlider *slider) { m_gridSliderX = slider; } void setGridSliderZ(QSlider *slider) { m_gridSliderZ = slider; } diff --git a/examples/surfacechart/main.cpp b/examples/surfacechart/main.cpp index 474f273b..c9d95c67 100644 --- a/examples/surfacechart/main.cpp +++ b/examples/surfacechart/main.cpp @@ -51,6 +51,8 @@ #include <QSlider> #include <QLabel> #include <QScreen> +#include <QPainter> +#include <QDebug> using namespace QtDataVis3D; @@ -89,6 +91,10 @@ int main(int argc, char *argv[]) sqrtSinCB->setText(QStringLiteral("Sqrt & Sin")); sqrtSinCB->setChecked(false); + QCheckBox *planeCB = new QCheckBox(widget); + planeCB->setText(QStringLiteral("Plane")); + planeCB->setChecked(false); + QCheckBox *gridSlidersLockCB = new QCheckBox(widget); gridSlidersLockCB->setText(QStringLiteral("Lock")); gridSlidersLockCB->setChecked(false); @@ -106,16 +112,32 @@ int main(int argc, char *argv[]) gridSliderZ->setMaximum(200); gridSliderZ->setEnabled(true); + QLinearGradient gr(0, 0, 100, 1); + gr.setColorAt(0.0, Qt::green); + gr.setColorAt(0.5, Qt::yellow); + gr.setColorAt(1.0, Qt::red); + QPixmap pm(100, 24); + QPainter pmp(&pm); + pmp.setBrush(QBrush(gr)); + pmp.setPen(Qt::NoPen); + pmp.drawRect(0, 0, 100, 24); + //pm.save("C:\\Users\\misalmel\\Work\\test.png", "png"); + QPushButton *color = new QPushButton(); + color->setIcon(QIcon(pm)); + color->setIconSize(QSize(100, 24)); + color->setFlat(true); // Add controls to the layout vLayout->addWidget(smoothCB); vLayout->addWidget(surfaceGridCB); - vLayout->addWidget(new QLabel(QStringLiteral("Select surface"))); + vLayout->addWidget(new QLabel(QStringLiteral("Select surface sample"))); vLayout->addWidget(sqrtSinCB); + vLayout->addWidget(planeCB); vLayout->addWidget(new QLabel(QStringLiteral("Adjust sample count"))); vLayout->addWidget(gridSlidersLockCB); vLayout->addWidget(gridSliderX); vLayout->addWidget(gridSliderZ); + vLayout->addWidget(color); widget->show(); @@ -128,6 +150,8 @@ int main(int argc, char *argv[]) modifier, &ChartModifier::toggleSurfaceGrid); QObject::connect(sqrtSinCB, &QCheckBox::stateChanged, modifier, &ChartModifier::toggleSqrtSin); + QObject::connect(planeCB, &QCheckBox::stateChanged, + modifier, &ChartModifier::togglePlane); QObject::connect(gridSlidersLockCB, &QCheckBox::stateChanged, modifier, &ChartModifier::toggleGridSliderLock); QObject::connect(gridSliderX, &QSlider::valueChanged, diff --git a/src/datavis3d/engine/q3dsurface.cpp b/src/datavis3d/engine/q3dsurface.cpp index 951c3e58..c4465165 100644 --- a/src/datavis3d/engine/q3dsurface.cpp +++ b/src/datavis3d/engine/q3dsurface.cpp @@ -147,6 +147,11 @@ void Q3DSurface::setTickCount(int tickCount, qreal step, qreal minimum) d_ptr->m_shared->setTickCount(GLint(tickCount), GLfloat(step), GLfloat(minimum)); } +void Q3DSurface::setGradientColorAt(qreal pos, const QColor &color) +{ + d_ptr->m_shared->setGradientColorAt(pos, color); +} + // TODO ///////////////////////////////////////// void Q3DSurface::appendSeries(QList<qreal> series, int width, int depth ) { diff --git a/src/datavis3d/engine/q3dsurface.h b/src/datavis3d/engine/q3dsurface.h index 03be2f17..3c169a84 100644 --- a/src/datavis3d/engine/q3dsurface.h +++ b/src/datavis3d/engine/q3dsurface.h @@ -67,6 +67,8 @@ public: void setSurfaceGrid(bool enable); bool surfaceGrid(); + void setGradientColorAt(qreal pos, const QColor &color); + // Set tick count and step. Note; tickCount * step should be the maximum possible value of data // set. Minimum is the absolute minimum possible value a bar can have. This is especially // important to set if values can be negative. diff --git a/src/datavis3d/engine/shaders/surface.frag b/src/datavis3d/engine/shaders/surface.frag index af75cbb9..c67055fe 100644 --- a/src/datavis3d/engine/shaders/surface.frag +++ b/src/datavis3d/engine/shaders/surface.frag @@ -7,13 +7,15 @@ varying highp vec3 normal_cmr; varying highp vec3 eyeDirection_cmr; varying highp vec3 lightDirection_cmr; +uniform sampler2D textureSampler; uniform highp vec3 lightPosition_wrld; -uniform highp vec3 color_mdl; +//uniform highp vec3 color_mdl; uniform highp float lightStrength; uniform highp float ambientStrength; void main() { - highp vec3 materialDiffuseColor = vec3(position_wrld.y, 1.0 - position_wrld.y, 0.0); + highp vec2 guv = vec2(0.5, (coords_mdl.y + 1.0) / 2.0); + highp vec3 materialDiffuseColor = texture2D(textureSampler, guv).xyz; highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor; highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0); diff --git a/src/datavis3d/engine/shaders/surfaceFlat.frag b/src/datavis3d/engine/shaders/surfaceFlat.frag index b07acbad..32efe274 100644 --- a/src/datavis3d/engine/shaders/surfaceFlat.frag +++ b/src/datavis3d/engine/shaders/surfaceFlat.frag @@ -7,13 +7,15 @@ flat in highp vec3 normal_cmr; varying highp vec3 eyeDirection_cmr; varying highp vec3 lightDirection_cmr; +uniform sampler2D textureSampler; uniform highp vec3 lightPosition_wrld; -uniform highp vec3 color_mdl; +//uniform highp vec3 color_mdl; uniform highp float lightStrength; uniform highp float ambientStrength; void main() { - highp vec3 materialDiffuseColor = vec3(position_wrld.y, 1.0 - position_wrld.y, 0.0); + highp vec2 guv = vec2(0.5, (coords_mdl.y + 1.0) / 2.0); + highp vec3 materialDiffuseColor = texture2D(textureSampler, guv).xyz; highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor; highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0); @@ -27,7 +29,7 @@ void main() { highp vec3 R = reflect(-l, n); highp float cosAlpha = clamp(dot(E, R), 0.0, 1.0); -// gl_FragColor.rgb = n; +// gl_FragColor.rgb = materialDiffuseColor; gl_FragColor.rgb = materialAmbientColor + materialDiffuseColor * lightStrength * pow(cosTheta, 2) / distance + diff --git a/src/datavis3d/engine/surface3dcontroller.cpp b/src/datavis3d/engine/surface3dcontroller.cpp index ca24da09..9996e1b8 100644 --- a/src/datavis3d/engine/surface3dcontroller.cpp +++ b/src/datavis3d/engine/surface3dcontroller.cpp @@ -191,6 +191,12 @@ void Surface3dController::setTickCount(GLint tickCount, GLfloat step, GLfloat mi emit tickCountChanged(m_tickCount, m_tickStep, m_tickMinimum); } +void Surface3dController::setGradientColorAt(qreal pos, const QColor &color) +{ + Theme t = theme(); + t.m_surfaceGradient.setColorAt(pos, color); + emit themeChanged(t); +} // TODO: Temp void Surface3dController::setData(QList<qreal> series, int width, int depth) diff --git a/src/datavis3d/engine/surface3dcontroller_p.h b/src/datavis3d/engine/surface3dcontroller_p.h index 3207f6f3..021e32d3 100644 --- a/src/datavis3d/engine/surface3dcontroller_p.h +++ b/src/datavis3d/engine/surface3dcontroller_p.h @@ -55,6 +55,8 @@ #include "abstract3dcontroller_p.h" #include "datavis3dglobal_p.h" +#include <QLinearGradient> + QT_DATAVIS3D_BEGIN_NAMESPACE class Surface3dRenderer; @@ -101,6 +103,8 @@ public: void setSurfaceGrid(bool enable); bool surfaceGrid(); + void setGradientColorAt(qreal pos, const QColor &color); + // Set tick count and step. Note; tickCount * step should be the maximum possible value of data // set. Minimum is the absolute minimum possible value a bar can have. This is especially // important to set if values can be negative. diff --git a/src/datavis3d/engine/surface3drenderer.cpp b/src/datavis3d/engine/surface3drenderer.cpp index 1cd9231e..01bb8c7e 100644 --- a/src/datavis3d/engine/surface3drenderer.cpp +++ b/src/datavis3d/engine/surface3drenderer.cpp @@ -54,6 +54,9 @@ #include <QMouseEvent> #include <qmath.h> +#include <QLinearGradient> +#include <QPainter> + #include <QDebug> QT_DATAVIS3D_BEGIN_NAMESPACE @@ -63,7 +66,6 @@ Surface3dRenderer::Surface3dRenderer(Surface3dController *controller) m_controller(controller), m_mousePressed(MouseNone), m_mousePos(QPoint(0, 0)), - m_theme(new Theme()), m_isGridEnabled(true), m_isBackgroundEnabled(true), m_shadowQuality(ShadowLow), @@ -92,8 +94,9 @@ Surface3dRenderer::Surface3dRenderer(Surface3dController *controller) m_surfaceObj(0), m_depthTexture(0), m_depthFrameBuffer(0), + m_gradientTexture(0), m_shadowQualityToShader(33.3f), - m_drawer(new Drawer(*m_theme, m_font, m_labelTransparency)) + m_drawer(new Drawer(m_cachedTheme, m_font, m_labelTransparency)) { // Listen to changes in the controller QObject::connect(m_controller, &Surface3dController::smoothStatusChanged, this, @@ -102,9 +105,12 @@ Surface3dRenderer::Surface3dRenderer(Surface3dController *controller) &Surface3dRenderer::updateSurfaceGridStatus); QObject::connect(m_controller, &Surface3dController::tickCountChanged, this, &Surface3dRenderer::updateTickCount); + QObject::connect(m_controller, &Surface3dController::themeChanged, this, + &Surface3dRenderer::updateTheme); m_cachedSmoothSurface = m_controller->smoothSurface(); updateSurfaceGridStatus(m_controller->surfaceGrid()); + updateTheme(m_controller->theme()); initializeOpenGL(); } @@ -117,8 +123,8 @@ Surface3dRenderer::~Surface3dRenderer() if (m_backgroundShader) delete m_backgroundShader; - if (m_depthTexture) - m_textureHelper->deleteTexture(&m_depthTexture); + m_textureHelper->deleteTexture(&m_depthTexture); + m_textureHelper->deleteTexture(&m_gradientTexture); delete m_backgroundObj; delete m_surfaceObj; @@ -204,7 +210,7 @@ void Surface3dRenderer::render(CameraHelper *camera, const GLuint defaultFboHand glCullFace(GL_BACK); } - QVector3D clearColor = Utils::vectorFromColor(m_theme->m_windowColor); + QVector3D clearColor = Utils::vectorFromColor(m_cachedTheme.m_windowColor); glClearColor(clearColor.x(), clearColor.y(), clearColor.z(), 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -294,25 +300,22 @@ void Surface3dRenderer::drawScene(CameraHelper *camera, const GLuint defaultFboH // TODO Check the usage? depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix; - QVector3D baseColor = Utils::vectorFromColor(QColor(Qt::red)/*m_theme->m_baseColor*/); - // Set shader bindings m_surfaceShader->setUniformValue(m_surfaceShader->lightP(), lightPos); m_surfaceShader->setUniformValue(m_surfaceShader->view(), viewMatrix); m_surfaceShader->setUniformValue(m_surfaceShader->model(), modelMatrix); m_surfaceShader->setUniformValue(m_surfaceShader->nModel(), itModelMatrix.inverted().transposed()); m_surfaceShader->setUniformValue(m_surfaceShader->MVP(), MVPMatrix); - m_surfaceShader->setUniformValue(m_surfaceShader->color(), baseColor); - m_surfaceShader->setUniformValue(m_surfaceShader->ambientS(), m_theme->m_ambientStrength); + m_surfaceShader->setUniformValue(m_surfaceShader->ambientS(), m_cachedTheme.m_ambientStrength); //IF QT_OPENGL_ES_2 TODO // Shadow quality etc. //m_backgroundShader->setUniformValue(m_backgroundShader->shadowQ(), m_shadowQualityToShader); //m_backgroundShader->setUniformValue(m_backgroundShader->depth(), depthMVPMatrix); m_surfaceShader->setUniformValue(m_surfaceShader->lightS(), - m_theme->m_lightStrength * 2.0f); + m_cachedTheme.m_lightStrength * 2.0f); - m_drawer->drawObject(m_surfaceShader, m_surfaceObj, 0, m_depthTexture); + m_drawer->drawObject(m_surfaceShader, m_surfaceObj, m_gradientTexture, m_depthTexture); m_surfaceShader->release(); if (m_cachedSurfaceGridOn) { @@ -370,7 +373,7 @@ void Surface3dRenderer::drawScene(CameraHelper *camera, const GLuint defaultFboH #endif depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix; - QVector3D backgroundColor = Utils::vectorFromColor(m_theme->m_backgroundColor); + QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme.m_backgroundColor); // Set shader bindings m_backgroundShader->setUniformValue(m_backgroundShader->lightP(), lightPos); @@ -381,7 +384,7 @@ void Surface3dRenderer::drawScene(CameraHelper *camera, const GLuint defaultFboH m_backgroundShader->setUniformValue(m_backgroundShader->MVP(), MVPMatrix); m_backgroundShader->setUniformValue(m_backgroundShader->color(), backgroundColor); m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(), - m_theme->m_ambientStrength * 2.0f); + m_cachedTheme.m_ambientStrength * 2.0f); #if !defined(QT_OPENGL_ES_2) if (m_shadowQuality > ShadowNone) { @@ -390,7 +393,7 @@ void Surface3dRenderer::drawScene(CameraHelper *camera, const GLuint defaultFboH m_shadowQualityToShader); m_backgroundShader->setUniformValue(m_backgroundShader->depth(), depthMVPMatrix); m_backgroundShader->setUniformValue(m_backgroundShader->lightS(), - m_theme->m_lightStrength / 10.0f); + m_cachedTheme.m_lightStrength / 10.0f); // Draw the object m_drawer->drawObject(m_backgroundShader, m_backgroundObj, 0, m_depthTexture); @@ -399,7 +402,7 @@ void Surface3dRenderer::drawScene(CameraHelper *camera, const GLuint defaultFboH { // Set shadowless shader bindings m_backgroundShader->setUniformValue(m_backgroundShader->lightS(), - m_theme->m_lightStrength); + m_cachedTheme.m_lightStrength); // Draw the object m_drawer->drawObject(m_backgroundShader, m_backgroundObj); @@ -443,16 +446,33 @@ void Surface3dRenderer::setXZStuff(GLint tickXCount, GLint tickZCount) calculateSceneScalingFactors(); } +void Surface3dRenderer::updateTheme(Theme theme) +{ + m_cachedTheme.setFromTheme(theme); + + // Update things depending from the theme + updateSurfaceGradient(); +} + +void Surface3dRenderer::updateSurfaceGradient() +{ + QImage image(QSize(4, 100), QImage::Format_RGB32); + QPainter pmp(&image); + pmp.setBrush(QBrush(m_cachedTheme.m_surfaceGradient)); + pmp.setPen(Qt::NoPen); + pmp.drawRect(0, 0, 4, 100); + image.save("C:\\Users\\misalmel\\Work\\image.png", "png"); + + if (m_gradientTexture) { + m_textureHelper->deleteTexture(&m_gradientTexture); + m_gradientTexture = 0; + } + + m_gradientTexture = m_textureHelper->create2DTexture(image, false, true); +} + void Surface3dRenderer::setSeries(QList<qreal> series) { -// QList<qreal> temp; -// temp.append(10);temp.append(150);temp.append(50); -// temp.append(10);temp.append(150);temp.append(50); -// temp.append(10);temp.append(150);temp.append(50); -// if (m_smoothSurface) -// m_surfaceObj->setUpSmoothData(temp, 3, 3, m_yRange); -// else -// m_surfaceObj->setUpData(temp, 3, 3, m_yRange); m_series = series; // TODO temp solution @@ -600,40 +620,6 @@ int Surface3dRenderer::y() return m_boundingRect.y(); } -#if defined(Q_OS_ANDROID) -void Surface3dRenderer::mouseDoubleClickEvent(QMouseEvent *event) -{ - -} - -void Surface3dRenderer::touchEvent(QTouchEvent *event) -{ - -} -#endif -void Surface3dRenderer::mousePressEvent(QMouseEvent *event, const QPoint &mousePos) -{ - Q_UNUSED(event) - Q_UNUSED(mousePos) -} - -void Surface3dRenderer::mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos) -{ - Q_UNUSED(event) - Q_UNUSED(mousePos) -} - -void Surface3dRenderer::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos) -{ - Q_UNUSED(event) - Q_UNUSED(mousePos) -} - -void Surface3dRenderer::wheelEvent(QWheelEvent *event) -{ - Q_UNUSED(event) -} - void Surface3dRenderer::handleResize() { if (!m_isInitialized) diff --git a/src/datavis3d/engine/surface3drenderer_p.h b/src/datavis3d/engine/surface3drenderer_p.h index 1d6ffafe..7c3ca040 100644 --- a/src/datavis3d/engine/surface3drenderer_p.h +++ b/src/datavis3d/engine/surface3drenderer_p.h @@ -56,6 +56,7 @@ #include <QtCore/QObject> #include <QtGui/QOpenGLFunctions> #include <QtGui/QFont> +#include <QLinearGradient> #include <QWindow> #include "datavis3dglobal_p.h" @@ -96,7 +97,7 @@ public: // Visual parameters QRect m_boundingRect; - Theme *m_theme; + Theme m_cachedTheme; LabelTransparency m_labelTransparency; QFont m_font; bool m_isGridEnabled; @@ -134,6 +135,7 @@ private: SurfaceObject *m_surfaceObj; GLuint m_depthTexture; GLuint m_depthFrameBuffer; + GLuint m_gradientTexture; GLfloat m_shadowQualityToShader; bool m_cachedSmoothSurface; bool m_cachedSurfaceGridOn; @@ -151,8 +153,10 @@ public: Drawer *drawer() { return m_drawer; } public slots: + void updateTheme(Theme theme); void updateSmoothStatus(bool enable); void updateSurfaceGridStatus(bool enable); + void updateSurfaceGradient(); void updateTickCount(GLint tickCount, GLfloat step, GLfloat minimum = 0.0f); public: @@ -169,14 +173,6 @@ public: void setY(const int y); int y(); -#if defined(Q_OS_ANDROID) - void mouseDoubleClickEvent(QMouseEvent *event); - void touchEvent(QTouchEvent *event); -#endif - void mousePressEvent(QMouseEvent *event, const QPoint &mousePos); - void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos); - void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos); - void wheelEvent(QWheelEvent *event); void handleResize(); #if !defined(QT_OPENGL_ES_2) diff --git a/src/datavis3d/engine/theme.cpp b/src/datavis3d/engine/theme.cpp index 796d32e6..5b6ff87a 100644 --- a/src/datavis3d/engine/theme.cpp +++ b/src/datavis3d/engine/theme.cpp @@ -60,11 +60,16 @@ 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_lightStrength(4.0f), m_ambientStrength(0.3f), m_highlightLightStrength(8.0f), m_uniformColor(true) { + // Default values for surface gradient + m_surfaceGradient.setColorAt(0.0, Qt::green); + m_surfaceGradient.setColorAt(0.5, Qt::yellow); + m_surfaceGradient.setColorAt(1.0, Qt::red); } Theme::~Theme() @@ -315,6 +320,7 @@ void Theme::setFromTheme(Theme &theme) m_highlightBarColor = theme.m_highlightBarColor; m_highlightRowColor = theme.m_highlightRowColor; m_highlightColumnColor = theme.m_highlightColumnColor; + m_surfaceGradient = theme.m_surfaceGradient; m_lightStrength = theme.m_lightStrength; m_ambientStrength = theme.m_ambientStrength; m_highlightLightStrength = theme.m_highlightLightStrength; diff --git a/src/datavis3d/engine/theme_p.h b/src/datavis3d/engine/theme_p.h index 91275fd5..3de1c9ea 100644 --- a/src/datavis3d/engine/theme_p.h +++ b/src/datavis3d/engine/theme_p.h @@ -54,6 +54,7 @@ #include "datavis3dglobal_p.h" #include "q3dbars.h" +#include <QLinearGradient> class QColor; @@ -89,6 +90,7 @@ private: QColor m_highlightBarColor; QColor m_highlightRowColor; QColor m_highlightColumnColor; + QLinearGradient m_surfaceGradient; float m_lightStrength; float m_ambientStrength; float m_highlightLightStrength; |