summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/engine')
-rw-r--r--src/datavisualization/engine/abstract3dcontroller.cpp49
-rw-r--r--src/datavisualization/engine/abstract3dcontroller_p.h32
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp6
-rw-r--r--src/datavisualization/engine/abstract3drenderer_p.h4
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp37
-rw-r--r--src/datavisualization/engine/drawer.cpp12
-rw-r--r--src/datavisualization/engine/drawer_p.h10
-rw-r--r--src/datavisualization/engine/engine.pri2
-rw-r--r--src/datavisualization/engine/q3dbars.cpp15
-rw-r--r--src/datavisualization/engine/q3dbars.h9
-rw-r--r--src/datavisualization/engine/q3dscatter.cpp12
-rw-r--r--src/datavisualization/engine/q3dscatter.h9
-rw-r--r--src/datavisualization/engine/q3dsurface.cpp12
-rw-r--r--src/datavisualization/engine/q3dsurface.h10
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp22
-rw-r--r--src/datavisualization/engine/selectionpointer.cpp6
-rw-r--r--src/datavisualization/engine/selectionpointer_p.h2
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp2
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp35
-rw-r--r--src/datavisualization/engine/theme.cpp245
-rw-r--r--src/datavisualization/engine/theme_p.h81
21 files changed, 139 insertions, 473 deletions
diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp
index 7f87ac7c..afe0b124 100644
--- a/src/datavisualization/engine/abstract3dcontroller.cpp
+++ b/src/datavisualization/engine/abstract3dcontroller.cpp
@@ -28,6 +28,7 @@
#include "qabstract3dinputhandler_p.h"
#include "qtouch3dinputhandler.h"
#include "qabstract3dseries_p.h"
+#include "thememanager_p.h"
#include <QThread>
@@ -36,7 +37,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
Abstract3DController::Abstract3DController(QRect boundRect, QObject *parent) :
QObject(parent),
m_boundingRect(boundRect.x(), boundRect.y(), boundRect.width(), boundRect.height()),
- m_theme(),
+ m_themeManager(new ThemeManager(this)),
m_font(QFont(QStringLiteral("Arial"))),
m_selectionMode(QDataVis::SelectionItem),
m_shadowQuality(QDataVis::ShadowQualityMedium),
@@ -55,7 +56,7 @@ Abstract3DController::Abstract3DController(QRect boundRect, QObject *parent) :
m_renderPending(false)
{
// Set initial theme
- setTheme(QDataVis::ThemeQt);
+ setTheme(new Q3DTheme(QDataVis::ThemeQt));
// Populate the scene
m_scene->activeLight()->setPosition(defaultLightPos);
@@ -142,7 +143,7 @@ void Abstract3DController::synchDataToRenderer()
// TODO: Renderer doesn't need to know the theme, so remove this bit entirely (QTRD-2538)
if (m_changeTracker.themeChanged) {
- m_renderer->updateTheme(m_theme);
+ m_renderer->updateTheme(m_themeManager->theme());
m_changeTracker.themeChanged = false;
}
@@ -786,25 +787,31 @@ QLinearGradient Abstract3DController::multiHighlightGradient() const
return m_multiHighlightGradient;
}
-void Abstract3DController::setTheme(QDataVis::Theme theme)
+void Abstract3DController::setTheme(Q3DTheme *theme)
{
- if (theme != m_theme.theme()) {
- m_theme.useTheme(theme);
+ if (theme != m_themeManager->theme()) {
+ m_themeManager->setTheme(theme);
+ QDataVis::ColorStyle colorStyle = theme->colorStyle();
m_changeTracker.themeChanged = true;
// TODO: set all colors/styles here (QTRD-2538)
- setColorStyle(QDataVis::ColorStyleUniform);
- setObjectColor(m_theme.m_baseColor);
- setSingleHighlightColor(m_theme.m_singleHighlightColor);
- setMultiHighlightColor(m_theme.m_multiHighlightColor);
+ setColorStyle(colorStyle);
+ if (colorStyle == QDataVis::ColorStyleUniform) {
+ setObjectColor(theme->baseColor());
+ setSingleHighlightColor(theme->singleHighlightColor());
+ setMultiHighlightColor(theme->multiHighlightColor());
+ } else {
+ setObjectGradient(theme->baseGradient());
+ setSingleHighlightGradient(theme->singleHighlightGradient());
+ setMultiHighlightGradient(theme->multiHighlightGradient());
+ }
emit themeChanged(theme);
- emitNeedRender();
}
}
-Theme Abstract3DController::theme()
+Q3DTheme *Abstract3DController::theme() const
{
- return m_theme;
+ return m_themeManager->theme();
}
void Abstract3DController::setFont(const QFont &font)
@@ -817,7 +824,7 @@ void Abstract3DController::setFont(const QFont &font)
}
}
-QFont Abstract3DController::font()
+QFont Abstract3DController::font() const
{
return m_font;
}
@@ -832,7 +839,7 @@ void Abstract3DController::setSelectionMode(QDataVis::SelectionFlags mode)
}
}
-QDataVis::SelectionFlags Abstract3DController::selectionMode()
+QDataVis::SelectionFlags Abstract3DController::selectionMode() const
{
return m_selectionMode;
}
@@ -847,7 +854,7 @@ void Abstract3DController::setShadowQuality(QDataVis::ShadowQuality quality)
}
}
-QDataVis::ShadowQuality Abstract3DController::shadowQuality()
+QDataVis::ShadowQuality Abstract3DController::shadowQuality() const
{
return m_shadowQuality;
}
@@ -862,7 +869,7 @@ void Abstract3DController::setLabelStyle(QDataVis::LabelStyle style)
}
}
-QDataVis::LabelStyle Abstract3DController::labelStyle()
+QDataVis::LabelStyle Abstract3DController::labelStyle() const
{
return m_labelStyle;
}
@@ -877,7 +884,7 @@ void Abstract3DController::setBackgroundEnabled(bool enable)
}
}
-bool Abstract3DController::backgroundEnabled()
+bool Abstract3DController::backgroundEnabled() const
{
return m_isBackgroundEnabled;
}
@@ -892,12 +899,12 @@ void Abstract3DController::setGridEnabled(bool enable)
}
}
-bool Abstract3DController::gridEnabled()
+bool Abstract3DController::gridEnabled() const
{
return m_isGridEnabled;
}
-bool Abstract3DController::isSlicingActive()
+bool Abstract3DController::isSlicingActive() const
{
return m_scene->isSlicingActive();
}
@@ -918,7 +925,7 @@ void Abstract3DController::setMeshFileName(const QString &fileName)
}
}
-QString Abstract3DController::meshFileName()
+QString Abstract3DController::meshFileName() const
{
return m_objFile;
}
diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h
index c86f9672..30c13e7d 100644
--- a/src/datavisualization/engine/abstract3dcontroller_p.h
+++ b/src/datavisualization/engine/abstract3dcontroller_p.h
@@ -26,11 +26,10 @@
//
// We mean it.
-#ifndef CONTROLLER3DBASE_H
-#define CONTROLLER3DBASE_H
+#ifndef ABSTRACT3DCONTROLLER_P_H
+#define ABSTRACT3DCONTROLLER_P_H
#include "datavisualizationglobal_p.h"
-#include "theme_p.h"
#include "q3dabstractaxis.h"
#include "drawer_p.h"
#include "qabstract3dinputhandler.h"
@@ -48,6 +47,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
class CameraHelper;
class Abstract3DRenderer;
class QAbstract3DSeries;
+class ThemeManager;
struct Abstract3DChangeBitField {
bool positionChanged : 1;
@@ -165,7 +165,7 @@ private:
QRect m_boundingRect;
GLfloat m_horizontalRotation;
GLfloat m_verticalRotation;
- Theme m_theme;
+ ThemeManager *m_themeManager;
QFont m_font;
QDataVis::SelectionFlags m_selectionMode;
QDataVis::ShadowQuality m_shadowQuality;
@@ -270,40 +270,40 @@ public:
// Set theme (bar colors, shaders, window color, background colors, light intensity and text
// colors are affected)
- virtual void setTheme(QDataVis::Theme theme);
- virtual Theme theme();
+ virtual void setTheme(Q3DTheme *theme);
+ virtual Q3DTheme *theme() const;
// Set font
virtual void setFont(const QFont &font);
- virtual QFont font();
+ virtual QFont font() const;
// Selection mode
virtual void setSelectionMode(QDataVis::SelectionFlags mode);
- virtual QDataVis::SelectionFlags selectionMode();
+ virtual QDataVis::SelectionFlags selectionMode() const;
// Adjust shadow quality
virtual void setShadowQuality(QDataVis::ShadowQuality quality);
- virtual QDataVis::ShadowQuality shadowQuality();
+ virtual QDataVis::ShadowQuality shadowQuality() const;
// Label style adjustment
virtual void setLabelStyle(QDataVis::LabelStyle style);
- virtual QDataVis::LabelStyle labelStyle();
+ virtual QDataVis::LabelStyle labelStyle() const;
// Enable or disable background mesh
virtual void setBackgroundEnabled(bool enable);
- virtual bool backgroundEnabled();
+ virtual bool backgroundEnabled() const;
// Enable or disable background grid
virtual void setGridEnabled(bool enable);
- virtual bool gridEnabled();
+ virtual bool gridEnabled() const;
// Enable or disable slicing mode
- bool isSlicingActive();
+ bool isSlicingActive() const;
void setSlicingActive(bool isSlicing);
// override bar type with own mesh
virtual void setMeshFileName(const QString &fileName);
- virtual QString meshFileName();
+ virtual QString meshFileName() const;
Q3DScene *scene();
@@ -345,7 +345,7 @@ public slots:
signals:
void shadowQualityChanged(QDataVis::ShadowQuality quality);
void activeInputHandlerChanged(QAbstract3DInputHandler *inputHandler);
- void themeChanged(QDataVis::Theme theme);
+ void themeChanged(Q3DTheme *theme);
void fontChanged(QFont font);
void selectionModeChanged(QDataVis::SelectionFlags mode);
void labelStyleChanged(QDataVis::LabelStyle style);
@@ -373,4 +373,4 @@ private:
QT_DATAVISUALIZATION_END_NAMESPACE
-#endif // CONTROLLER3DBASE_H
+#endif
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 0f1349d1..cd4f15b8 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -130,7 +130,7 @@ void Abstract3DRenderer::render(const GLuint defaultFboHandle)
m_cachedScene->viewport().width(),
m_cachedScene->viewport().height());
- QVector3D clearColor = Utils::vectorFromColor(m_cachedTheme.m_windowColor);
+ QVector3D clearColor = Utils::vectorFromColor(m_cachedTheme->windowColor());
glClearColor(clearColor.x(), clearColor.y(), clearColor.z(), 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
@@ -164,9 +164,9 @@ void Abstract3DRenderer::updatePosition(const QRect &boundingRect)
m_cachedBoundingRect = boundingRect;
}
-void Abstract3DRenderer::updateTheme(Theme theme)
+void Abstract3DRenderer::updateTheme(Q3DTheme *theme)
{
- m_cachedTheme.setFromTheme(theme);
+ m_cachedTheme = theme;
m_drawer->setTheme(m_cachedTheme);
diff --git a/src/datavisualization/engine/abstract3drenderer_p.h b/src/datavisualization/engine/abstract3drenderer_p.h
index 1a95aaeb..37ac69f3 100644
--- a/src/datavisualization/engine/abstract3drenderer_p.h
+++ b/src/datavisualization/engine/abstract3drenderer_p.h
@@ -60,7 +60,7 @@ protected:
};
bool m_hasNegativeValues;
- Theme m_cachedTheme;
+ Q3DTheme *m_cachedTheme;
QFont m_cachedFont;
QDataVis::LabelStyle m_cachedLabelStyle;
Drawer *m_drawer;
@@ -115,7 +115,7 @@ public:
virtual void updateBoundingRect(const QRect &boundingRect);
virtual void updatePosition(const QRect &boundingRect);
- virtual void updateTheme(Theme theme);
+ virtual void updateTheme(Q3DTheme *theme);
virtual void updateFont(const QFont &font);
virtual void updateLabelStyle(QDataVis::LabelStyle style);
virtual void updateSelectionMode(QDataVis::SelectionFlags newMode);
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 6c5d49c2..c96c33dc 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -22,7 +22,6 @@
#include "shaderhelper_p.h"
#include "objecthelper_p.h"
#include "texturehelper_p.h"
-#include "theme_p.h"
#include "utils_p.h"
#include "drawer_p.h"
#include "qbardataitem.h"
@@ -347,11 +346,11 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
lineShader->bind();
// Set unchanging shader bindings
- QVector3D lineColor = Utils::vectorFromColor(m_cachedTheme.m_gridLine);
+ QVector3D lineColor = Utils::vectorFromColor(m_cachedTheme->gridLineColor());
lineShader->setUniformValue(lineShader->lightP(), lightPos);
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
- lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength * 2.0f);
+ lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength() * 2.0f);
lineShader->setUniformValue(lineShader->lightS(), 0.25f);
GLfloat scaleFactor = 0.0f;
@@ -412,7 +411,7 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
itModelMatrix.inverted().transposed());
lineShader->setUniformValue(lineShader->MVP(), MVPMatrix);
lineShader->setUniformValue(lineShader->color(),
- Utils::vectorFromColor(m_cachedTheme.m_backgroundColor));
+ Utils::vectorFromColor(m_cachedTheme->backgroundColor()));
// Draw the object
m_drawer->drawObject(lineShader, m_gridLineObj);
@@ -476,7 +475,7 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
m_barShader->setUniformValue(m_barShader->view(), viewMatrix);
m_barShader->setUniformValue(m_barShader->lightS(), 0.5f);
m_barShader->setUniformValue(m_barShader->ambientS(),
- m_cachedTheme.m_ambientStrength * 2.0f);
+ m_cachedTheme->ambientLightStrength() * 2.0f);
if (m_cachedColorStyle != QDataVis::ColorStyleUniform) {
m_barShader->setUniformValue(m_barShader->gradientMin(), 0.0f);
if (m_cachedColorStyle == QDataVis::ColorStyleObjectGradient)
@@ -988,7 +987,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_barShader->setUniformValue(m_barShader->lightP(), lightPos);
m_barShader->setUniformValue(m_barShader->view(), viewMatrix);
m_barShader->setUniformValue(m_barShader->ambientS(),
- m_cachedTheme.m_ambientStrength);
+ m_cachedTheme->ambientLightStrength());
if (m_cachedColorStyle != QDataVis::ColorStyleUniform) {
m_barShader->setUniformValue(m_barShader->gradientMin(), 0.0f);
if (m_cachedColorStyle == QDataVis::ColorStyleObjectGradient)
@@ -1018,8 +1017,8 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
QVector3D baseColor(Utils::vectorFromColor(m_cachedObjectColor));
QVector3D barColor = baseColor;
- GLfloat adjustedLightStrength = m_cachedTheme.m_lightStrength / 10.0f;
- GLfloat adjustedHighlightStrength = m_cachedTheme.m_highlightLightStrength / 10.0f;
+ GLfloat adjustedLightStrength = m_cachedTheme->lightStrength() / 10.0f;
+ GLfloat adjustedHighlightStrength = m_cachedTheme->highlightLightStrength() / 10.0f;
bool barSelectionFound = false;
BarRenderItem *selectedBar(0);
@@ -1061,7 +1060,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
else
gradientTexture = m_objectGradientTexture;
- GLfloat lightStrength = m_cachedTheme.m_lightStrength;
+ GLfloat lightStrength = m_cachedTheme->lightStrength();
GLfloat shadowLightStrength = adjustedLightStrength;
if (m_cachedSelectionMode > QDataVis::SelectionNone) {
@@ -1076,7 +1075,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
else
gradientTexture = m_singleHighlightGradientTexture;
- lightStrength = m_cachedTheme.m_highlightLightStrength;
+ lightStrength = m_cachedTheme->highlightLightStrength();
shadowLightStrength = adjustedHighlightStrength;
// Insert position data into render item. We have no ownership, don't delete the previous one
if (!m_cachedIsSlicingActivated && m_visualSelectedBarSeriesIndex == series) {
@@ -1107,7 +1106,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
else
gradientTexture = m_multiHighlightGradientTexture;
- lightStrength = m_cachedTheme.m_highlightLightStrength;
+ lightStrength = m_cachedTheme->highlightLightStrength();
shadowLightStrength = adjustedHighlightStrength;
if (m_cachedIsSlicingActivated) {
item.setTranslation(modelMatrix.column(3).toVector3D());
@@ -1127,7 +1126,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
else
gradientTexture = m_multiHighlightGradientTexture;
- lightStrength = m_cachedTheme.m_highlightLightStrength;
+ lightStrength = m_cachedTheme->highlightLightStrength();
shadowLightStrength = adjustedHighlightStrength;
if (m_cachedIsSlicingActivated) {
QVector3D translation = modelMatrix.column(3).toVector3D();
@@ -1228,7 +1227,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
#else
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme.m_backgroundColor);
+ QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme->backgroundColor());
// Set shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->lightP(), lightPos);
@@ -1239,7 +1238,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_backgroundShader->setUniformValue(m_backgroundShader->MVP(), MVPMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->color(), backgroundColor);
m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(),
- m_cachedTheme.m_ambientStrength * 2.0f);
+ m_cachedTheme->ambientLightStrength() * 2.0f);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
@@ -1258,7 +1257,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
{
// Set shadowless shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_cachedTheme.m_lightStrength);
+ m_cachedTheme->lightStrength());
// Draw the object
m_drawer->drawObject(m_backgroundShader, m_backgroundObj);
@@ -1320,22 +1319,22 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
lineShader->bind();
// Set unchanging shader bindings
- QVector3D barColor = Utils::vectorFromColor(m_cachedTheme.m_gridLine);
+ QVector3D barColor = Utils::vectorFromColor(m_cachedTheme->gridLineColor());
lineShader->setUniformValue(lineShader->lightP(), lightPos);
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), barColor);
- lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength);
+ lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength());
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadowed shader bindings
lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 20.0f);
+ m_cachedTheme->lightStrength() / 20.0f);
} else
#endif
{
// Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength / 2.5f);
+ lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme->lightStrength() / 2.5f);
}
GLfloat yFloorLinePosition = 0.0f;
diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp
index 93336e96..dc149c4d 100644
--- a/src/datavisualization/engine/drawer.cpp
+++ b/src/datavisualization/engine/drawer.cpp
@@ -44,7 +44,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
// Vertex array buffer for point
const GLfloat point_data[] = {0.0f, 0.0f, 0.0f};
-Drawer::Drawer(const Theme &theme, const QFont &font, QDataVis::LabelStyle style)
+Drawer::Drawer(Q3DTheme *theme, const QFont &font, QDataVis::LabelStyle style)
: m_theme(theme),
m_font(font),
m_style(style),
@@ -67,13 +67,13 @@ void Drawer::initializeOpenGL()
}
}
-void Drawer::setTheme(const Theme &theme)
+void Drawer::setTheme(Q3DTheme *theme)
{
m_theme = theme;
emit drawerChanged();
}
-Theme Drawer::theme() const
+Q3DTheme *Drawer::theme() const
{
return m_theme;
}
@@ -358,10 +358,10 @@ void Drawer::generateLabelItem(LabelItem &item, const QString &text, int widestL
// Print label into a QImage using QPainter
QImage label = Utils::printTextToImage(m_font,
text,
- m_theme.m_textBackgroundColor,
- m_theme.m_textColor,
+ m_theme->textBackgroundColor(),
+ m_theme->textColor(),
m_style,
- m_theme.m_labelBorders,
+ m_theme->isLabelBorderEnabled(),
widestLabel);
// Set label size
diff --git a/src/datavisualization/engine/drawer_p.h b/src/datavisualization/engine/drawer_p.h
index c4bc8d1b..f9d70514 100644
--- a/src/datavisualization/engine/drawer_p.h
+++ b/src/datavisualization/engine/drawer_p.h
@@ -31,7 +31,7 @@
#include "datavisualizationglobal_p.h"
#include "q3dbars.h"
-#include "theme_p.h"
+#include "q3dtheme.h"
#include "labelitem_p.h"
#include "abstractrenderitem_p.h"
#include <QFont>
@@ -63,13 +63,13 @@ public:
};
public:
- explicit Drawer(const Theme &theme, const QFont &font, QDataVis::LabelStyle style);
+ explicit Drawer(Q3DTheme *theme, const QFont &font, QDataVis::LabelStyle style);
~Drawer();
void initializeOpenGL();
- void setTheme(const Theme &theme);
- Theme theme() const;
+ void setTheme(Q3DTheme *theme);
+ Q3DTheme *theme() const;
void setFont(const QFont &font);
QFont font() const;
void setStyle(QDataVis::LabelStyle style);
@@ -93,7 +93,7 @@ Q_SIGNALS:
void drawerChanged();
private:
- Theme m_theme;
+ Q3DTheme *m_theme;
QFont m_font;
QDataVis::LabelStyle m_style;
TextureHelper *m_textureHelper;
diff --git a/src/datavisualization/engine/engine.pri b/src/datavisualization/engine/engine.pri
index 7bf58379..899979e1 100644
--- a/src/datavisualization/engine/engine.pri
+++ b/src/datavisualization/engine/engine.pri
@@ -2,7 +2,6 @@ HEADERS += $$PWD/q3dwindow_p.h \
$$PWD/q3dwindow.h \
$$PWD/q3dbars.h \
$$PWD/q3dbars_p.h \
- $$PWD/theme_p.h \
$$PWD/drawer_p.h \
$$PWD/bars3dcontroller_p.h \
$$PWD/bars3drenderer_p.h \
@@ -31,7 +30,6 @@ HEADERS += $$PWD/q3dwindow_p.h \
SOURCES += $$PWD/q3dwindow.cpp \
$$PWD/q3dbars.cpp \
- $$PWD/theme.cpp \
$$PWD/drawer.cpp \
$$PWD/bars3dcontroller.cpp \
$$PWD/bars3drenderer.cpp \
diff --git a/src/datavisualization/engine/q3dbars.cpp b/src/datavisualization/engine/q3dbars.cpp
index 6fef5be4..00eb145c 100644
--- a/src/datavisualization/engine/q3dbars.cpp
+++ b/src/datavisualization/engine/q3dbars.cpp
@@ -323,23 +323,18 @@ void Q3DBars::setBarType(QDataVis::MeshStyle style, bool smooth)
/*!
* \property Q3DBars::theme
*
- * A predefined \a theme from \c QDataVis::Theme. 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.
+ * A user-defined theme.
*
- * \sa setBarColor()
- *
- * \preliminary
+ * TODO: Add docs.
*/
-
-void Q3DBars::setTheme(QDataVis::Theme theme)
+void Q3DBars::setTheme(Q3DTheme *theme)
{
d_ptr->m_shared->setTheme(theme);
}
-QDataVis::Theme Q3DBars::theme() const
+Q3DTheme *Q3DBars::theme() const
{
- return d_ptr->m_shared->theme().theme();
+ return d_ptr->m_shared->theme();
}
/*!
diff --git a/src/datavisualization/engine/q3dbars.h b/src/datavisualization/engine/q3dbars.h
index 86a02b5d..eb35f02d 100644
--- a/src/datavisualization/engine/q3dbars.h
+++ b/src/datavisualization/engine/q3dbars.h
@@ -32,6 +32,7 @@ class Q3DCategoryAxis;
class Q3DValueAxis;
class Q3DScene;
class QBar3DSeries;
+class Q3DTheme;
class QT_DATAVISUALIZATION_EXPORT Q3DBars : public Q3DWindow
{
@@ -44,7 +45,7 @@ class QT_DATAVISUALIZATION_EXPORT Q3DBars : public Q3DWindow
Q_PROPERTY(bool barSpacingRelative READ isBarSpacingRelative WRITE setBarSpacingRelative NOTIFY barSpacingRelativeChanged)
Q_PROPERTY(QString meshFileName READ meshFileName WRITE setMeshFileName NOTIFY meshFileNameChanged)
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
- Q_PROPERTY(QtDataVisualization::QDataVis::Theme theme READ theme WRITE setTheme NOTIFY themeChanged)
+ Q_PROPERTY(Q3DTheme* theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible NOTIFY gridVisibleChanged)
Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged)
Q_PROPERTY(Q3DScene* scene READ scene)
@@ -67,8 +68,8 @@ public:
// TODO: Move to dataset object once that is done QTRD-2121
void setBarType(QDataVis::MeshStyle style, bool smooth = false);
- void setTheme(QDataVis::Theme theme);
- QDataVis::Theme theme() const;
+ void setTheme(Q3DTheme *theme);
+ Q3DTheme *theme() const;
void setBarThickness(qreal thicknessRatio);
qreal barThickness();
@@ -141,7 +142,7 @@ signals:
void barSpacingRelativeChanged(bool relative);
void meshFileNameChanged(QString filename);
void fontChanged(QFont font);
- void themeChanged(QDataVis::Theme theme);
+ void themeChanged(Q3DTheme *theme);
void gridVisibleChanged(bool visible);
void backgroundVisibleChanged(bool visible);
void colorStyleChanged(QDataVis::ColorStyle style);
diff --git a/src/datavisualization/engine/q3dscatter.cpp b/src/datavisualization/engine/q3dscatter.cpp
index c01b5747..f336bda3 100644
--- a/src/datavisualization/engine/q3dscatter.cpp
+++ b/src/datavisualization/engine/q3dscatter.cpp
@@ -243,20 +243,16 @@ void Q3DScatter::setObjectType(QDataVis::MeshStyle style, bool smooth)
/*!
* \property Q3DScatter::theme
*
- * A predefined \a theme from \c QDataVis::Theme. 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.
- *
- * \preliminary
+ * TODO: Add docs
*/
-void Q3DScatter::setTheme(QDataVis::Theme theme)
+void Q3DScatter::setTheme(Q3DTheme *theme)
{
d_ptr->m_shared->setTheme(theme);
}
-QDataVis::Theme Q3DScatter::theme() const
+Q3DTheme *Q3DScatter::theme() const
{
- return d_ptr->m_shared->theme().theme();
+ return d_ptr->m_shared->theme();
}
/*!
diff --git a/src/datavisualization/engine/q3dscatter.h b/src/datavisualization/engine/q3dscatter.h
index 5f3a1024..9e2641fb 100644
--- a/src/datavisualization/engine/q3dscatter.h
+++ b/src/datavisualization/engine/q3dscatter.h
@@ -32,6 +32,7 @@ class LabelItem;
class Q3DValueAxis;
class Q3DCategoryAxis;
class QScatter3DSeries;
+class Q3DTheme;
class QT_DATAVISUALIZATION_EXPORT Q3DScatter : public Q3DWindow
{
@@ -41,7 +42,7 @@ class QT_DATAVISUALIZATION_EXPORT Q3DScatter : public Q3DWindow
Q_PROPERTY(QtDataVisualization::QDataVis::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality NOTIFY shadowQualityChanged)
Q_PROPERTY(QString meshFileName READ meshFileName WRITE setMeshFileName NOTIFY meshFileNameChanged)
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
- Q_PROPERTY(QtDataVisualization::QDataVis::Theme theme READ theme WRITE setTheme NOTIFY themeChanged)
+ Q_PROPERTY(Q3DTheme* theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible NOTIFY gridVisibleChanged)
Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged)
Q_PROPERTY(Q3DScene* scene READ scene)
@@ -63,8 +64,8 @@ public:
void setObjectType(QDataVis::MeshStyle style, bool smooth = false);
- void setTheme(QDataVis::Theme theme);
- QDataVis::Theme theme() const;
+ void setTheme(Q3DTheme *theme);
+ Q3DTheme *theme() const;
void setMeshFileName(const QString &objFileName);
QString meshFileName() const;
@@ -124,7 +125,7 @@ signals:
void shadowQualityChanged(QDataVis::ShadowQuality quality);
void meshFileNameChanged(QString filename);
void fontChanged(QFont font);
- void themeChanged(QDataVis::Theme theme);
+ void themeChanged(Q3DTheme* theme);
void gridVisibleChanged(bool visible);
void backgroundVisibleChanged(bool visible);
void colorStyleChanged(QDataVis::ColorStyle style);
diff --git a/src/datavisualization/engine/q3dsurface.cpp b/src/datavisualization/engine/q3dsurface.cpp
index 26f82611..b19b5a0c 100644
--- a/src/datavisualization/engine/q3dsurface.cpp
+++ b/src/datavisualization/engine/q3dsurface.cpp
@@ -250,20 +250,16 @@ bool Q3DSurface::isBackgroundVisible() const
/*!
* \property Q3DSurface::theme
*
- * A predefined \a theme from \c QDataVis::Theme. 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.
- *
- * \preliminary
+ * TODO: Add docs
*/
-void Q3DSurface::setTheme(QDataVis::Theme theme)
+void Q3DSurface::setTheme(Q3DTheme *theme)
{
d_ptr->m_shared->setTheme(theme);
}
-QDataVis::Theme Q3DSurface::theme() const
+Q3DTheme *Q3DSurface::theme() const
{
- return d_ptr->m_shared->theme().theme();
+ return d_ptr->m_shared->theme();
}
/*!
diff --git a/src/datavisualization/engine/q3dsurface.h b/src/datavisualization/engine/q3dsurface.h
index 29166362..3287bee4 100644
--- a/src/datavisualization/engine/q3dsurface.h
+++ b/src/datavisualization/engine/q3dsurface.h
@@ -30,13 +30,14 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
class Q3DSurfacePrivate;
class Q3DValueAxis;
class QSurface3DSeries;
+class Q3DTheme;
class QT_DATAVISUALIZATION_EXPORT Q3DSurface : public Q3DWindow
{
Q_OBJECT
Q_PROPERTY(QtDataVisualization::QDataVis::SelectionFlags selectionMode READ selectionMode WRITE setSelectionMode NOTIFY selectionModeChanged)
Q_PROPERTY(QtDataVisualization::QDataVis::LabelStyle labelStyle READ labelStyle WRITE setLabelStyle NOTIFY labelStyleChanged)
- Q_PROPERTY(QtDataVisualization::QDataVis::Theme theme READ theme WRITE setTheme NOTIFY themeChanged)
+ Q_PROPERTY(Q3DTheme* theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(QtDataVisualization::QDataVis::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality NOTIFY shadowQualityChanged)
Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible NOTIFY gridVisibleChanged)
Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged)
@@ -47,7 +48,6 @@ class QT_DATAVISUALIZATION_EXPORT Q3DSurface : public Q3DWindow
Q_PROPERTY(Q3DScene* scene READ scene)
Q_PROPERTY(QPoint selectedPoint READ selectedPoint WRITE setSelectedPoint NOTIFY selectedPointChanged)
-
public:
explicit Q3DSurface();
~Q3DSurface();
@@ -62,8 +62,8 @@ public:
void setBackgroundVisible(bool visible);
bool isBackgroundVisible() const;
- void setTheme(QDataVis::Theme theme);
- QDataVis::Theme theme() const;
+ void setTheme(Q3DTheme *theme);
+ Q3DTheme *theme() const;
void setShadowQuality(QDataVis::ShadowQuality quality);
QDataVis::ShadowQuality shadowQuality() const;
@@ -106,7 +106,7 @@ public:
signals:
void selectionModeChanged(QDataVis::SelectionFlags mode);
void labelStyleChanged(QDataVis::LabelStyle style);
- void themeChanged(QDataVis::Theme theme);
+ void themeChanged(Q3DTheme *theme);
void shadowQualityChanged(QDataVis::ShadowQuality quality);
void surfaceVisibleChanged(bool visible);
void gridVisibleChanged(bool visible);
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 5f03f982..56614746 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -538,7 +538,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
// Set unchanging shader bindings
dotShader->setUniformValue(dotShader->lightP(), lightPos);
dotShader->setUniformValue(dotShader->view(), viewMatrix);
- dotShader->setUniformValue(dotShader->ambientS(), m_cachedTheme.m_ambientStrength);
+ dotShader->setUniformValue(dotShader->ambientS(), m_cachedTheme->ambientLightStrength());
if (m_cachedColorStyle != QDataVis::ColorStyleUniform && !m_drawingPoints) {
if (m_cachedColorStyle == QDataVis::ColorStyleObjectGradient) {
// Round the gradient off a bit to avoid it looping over
@@ -605,13 +605,13 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
else
gradientTexture = m_objectGradientTexture;
- GLfloat lightStrength = m_cachedTheme.m_lightStrength;
+ GLfloat lightStrength = m_cachedTheme->lightStrength();
if (m_cachedSelectionMode > QDataVis::SelectionNone && (m_selectedItemTotalIndex == dotNo)) {
if (m_cachedColorStyle == QDataVis::ColorStyleUniform || m_drawingPoints)
dotColor = Utils::vectorFromColor(m_cachedSingleHighlightColor);
else
gradientTexture = m_singleHighlightGradientTexture;
- lightStrength = m_cachedTheme.m_highlightLightStrength;
+ lightStrength = m_cachedTheme->highlightLightStrength();
// Insert data to ScatterRenderItem. We have no ownership, don't delete the previous one
selectedItem = &item;
dotSelectionFound = true;
@@ -709,7 +709,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#else
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme.m_backgroundColor);
+ QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme->backgroundColor());
// Set shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->lightP(), lightPos);
@@ -720,7 +720,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
m_backgroundShader->setUniformValue(m_backgroundShader->MVP(), MVPMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->color(), backgroundColor);
m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(),
- m_cachedTheme.m_ambientStrength * 2.0f);
+ m_cachedTheme->ambientLightStrength() * 2.0f);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
@@ -730,7 +730,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
m_shadowQualityToShader);
m_backgroundShader->setUniformValue(m_backgroundShader->depth(), depthMVPMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_cachedTheme.m_lightStrength / 10.0f);
+ m_cachedTheme->lightStrength() / 10.0f);
// Draw the object
m_drawer->drawObject(m_backgroundShader, m_backgroundObj, 0, m_depthTexture);
@@ -739,7 +739,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
{
// Set shadowless shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_cachedTheme.m_lightStrength);
+ m_cachedTheme->lightStrength());
// Draw the object
m_drawer->drawObject(m_backgroundShader, m_backgroundObj);
@@ -768,22 +768,22 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
lineShader->bind();
// Set unchanging shader bindings
- QVector3D lineColor = Utils::vectorFromColor(m_cachedTheme.m_gridLine);
+ QVector3D lineColor = Utils::vectorFromColor(m_cachedTheme->gridLineColor());
lineShader->setUniformValue(lineShader->lightP(), lightPos);
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
- lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength);
+ lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength());
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadowed shader bindings
lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 20.0f);
+ m_cachedTheme->lightStrength() / 20.0f);
} else
#endif
{
// Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength / 2.5f);
+ lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme->lightStrength() / 2.5f);
}
QQuaternion lineYRotation = QQuaternion();
diff --git a/src/datavisualization/engine/selectionpointer.cpp b/src/datavisualization/engine/selectionpointer.cpp
index fd24da4f..7065ea8b 100644
--- a/src/datavisualization/engine/selectionpointer.cpp
+++ b/src/datavisualization/engine/selectionpointer.cpp
@@ -143,10 +143,10 @@ void SelectionPointer::render(GLuint defaultFboHandle)
m_pointShader->setUniformValue(m_pointShader->model(), modelMatrix);
m_pointShader->setUniformValue(m_pointShader->nModel(), itModelMatrix.inverted().transposed());
m_pointShader->setUniformValue(m_pointShader->color(),
- Utils::vectorFromColor(m_cachedTheme.m_singleHighlightColor));
+ Utils::vectorFromColor(m_cachedTheme->singleHighlightColor()));
m_pointShader->setUniformValue(m_pointShader->MVP(), MVPMatrix);
- m_pointShader->setUniformValue(m_pointShader->ambientS(), m_cachedTheme.m_ambientStrength);
- m_pointShader->setUniformValue(m_pointShader->lightS(), m_cachedTheme.m_lightStrength * 2.0f);
+ m_pointShader->setUniformValue(m_pointShader->ambientS(), m_cachedTheme->ambientLightStrength());
+ m_pointShader->setUniformValue(m_pointShader->lightS(), m_cachedTheme->lightStrength() * 2.0f);
m_drawer->drawObject(m_pointShader, m_pointObj);
diff --git a/src/datavisualization/engine/selectionpointer_p.h b/src/datavisualization/engine/selectionpointer_p.h
index 0e766035..e0b2558c 100644
--- a/src/datavisualization/engine/selectionpointer_p.h
+++ b/src/datavisualization/engine/selectionpointer_p.h
@@ -80,7 +80,7 @@ private:
ObjectHelper *m_pointObj;
TextureHelper *m_textureHelper;
bool m_isInitialized;
- Theme m_cachedTheme;
+ Q3DTheme *m_cachedTheme;
QDataVis::LabelStyle m_labelStyle;
LabelItem m_labelItem;
Drawer *m_drawer;
diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp
index 060e688f..9bd4b508 100644
--- a/src/datavisualization/engine/surface3dcontroller.cpp
+++ b/src/datavisualization/engine/surface3dcontroller.cpp
@@ -47,7 +47,7 @@ Surface3DController::Surface3DController(QRect rect)
setAxisZ(0);
// Set the default from the theme
- m_userDefinedGradient = theme().m_surfaceGradient;
+ m_userDefinedGradient = theme()->baseGradient();
}
Surface3DController::~Surface3DController()
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 85e189f8..e19b70d8 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -25,7 +25,6 @@
#include "surfaceobject_p.h"
#include "texturehelper_p.h"
#include "selectionpointer_p.h"
-#include "theme_p.h"
#include "utils_p.h"
#include "drawer_p.h"
#include "q3dlight.h"
@@ -523,7 +522,7 @@ void Surface3DRenderer::drawSlicedScene()
surfaceShader->bind();
QVector3D color;
- color = Utils::vectorFromColor(m_cachedTheme.m_multiHighlightColor);
+ color = Utils::vectorFromColor(m_cachedTheme->multiHighlightColor());
// Set shader bindings
surfaceShader->setUniformValue(surfaceShader->lightP(), lightPos);
@@ -535,7 +534,7 @@ void Surface3DRenderer::drawSlicedScene()
surfaceShader->setUniformValue(surfaceShader->color(), color);
surfaceShader->setUniformValue(surfaceShader->lightS(), 0.25f);
surfaceShader->setUniformValue(surfaceShader->ambientS(),
- m_cachedTheme.m_ambientStrength * 2.0f);
+ m_cachedTheme->ambientLightStrength() * 2.0f);
m_drawer->drawObject(surfaceShader, m_sliceSurfaceObj);
@@ -546,7 +545,7 @@ void Surface3DRenderer::drawSlicedScene()
if (m_cachedSurfaceGridOn) {
m_surfaceGridShader->bind();
m_surfaceGridShader->setUniformValue(m_surfaceGridShader->color(),
- Utils::vectorFromColor(m_cachedTheme.m_gridLine));
+ Utils::vectorFromColor(m_cachedTheme->gridLineColor()));
m_surfaceGridShader->setUniformValue(m_surfaceGridShader->MVP(), MVPMatrix);
m_drawer->drawSurfaceGrid(m_surfaceGridShader, m_sliceSurfaceObj);
m_surfaceGridShader->release();
@@ -565,11 +564,11 @@ void Surface3DRenderer::drawSlicedScene()
lineShader->bind();
// Set unchanging shader bindings
- QVector3D lineColor = Utils::vectorFromColor(m_cachedTheme.m_gridLine);
+ QVector3D lineColor = Utils::vectorFromColor(m_cachedTheme->gridLineColor());
lineShader->setUniformValue(lineShader->lightP(), lightPos);
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
- lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength * 2.0f);
+ lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength() * 2.0f);
lineShader->setUniformValue(lineShader->lightS(), 0.25f);
// Horizontal lines
@@ -781,7 +780,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
// Draw depth buffer
#if !defined(QT_OPENGL_ES_2)
- GLfloat adjustedLightStrength = m_cachedTheme.m_lightStrength / 10.0f;
+ GLfloat adjustedLightStrength = m_cachedTheme->lightStrength() / 10.0f;
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone && m_surfaceObj && m_cachedSurfaceVisible) {
// Render scene into a depth texture for using with shadow mapping
// Enable drawing to depth framebuffer
@@ -974,7 +973,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
itModelMatrix.inverted().transposed());
m_surfaceShader->setUniformValue(m_surfaceShader->MVP(), MVPMatrix);
m_surfaceShader->setUniformValue(m_surfaceShader->ambientS(),
- m_cachedTheme.m_ambientStrength);
+ m_cachedTheme->ambientLightStrength());
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
@@ -991,7 +990,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
{
// Set shadowless shader bindings
m_surfaceShader->setUniformValue(m_surfaceShader->lightS(),
- m_cachedTheme.m_lightStrength);
+ m_cachedTheme->lightStrength());
// Draw the object
m_drawer->drawObject(m_surfaceShader, m_surfaceObj, m_gradientTexture);
@@ -1006,7 +1005,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
if (m_cachedSurfaceGridOn) {
m_surfaceGridShader->bind();
m_surfaceGridShader->setUniformValue(m_surfaceGridShader->color(),
- Utils::vectorFromColor(m_cachedTheme.m_gridLine));
+ Utils::vectorFromColor(m_cachedTheme->gridLineColor()));
m_surfaceGridShader->setUniformValue(m_surfaceGridShader->MVP(), MVPMatrix);
m_drawer->drawSurfaceGrid(m_surfaceGridShader, m_surfaceObj);
m_surfaceGridShader->release();
@@ -1044,7 +1043,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme.m_backgroundColor);
+ QVector3D backgroundColor = Utils::vectorFromColor(m_cachedTheme->backgroundColor());
// Set shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->lightP(), lightPos);
@@ -1055,7 +1054,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
m_backgroundShader->setUniformValue(m_backgroundShader->MVP(), MVPMatrix);
m_backgroundShader->setUniformValue(m_backgroundShader->color(), backgroundColor);
m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(),
- m_cachedTheme.m_ambientStrength * 2.0f);
+ m_cachedTheme->ambientLightStrength() * 2.0f);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
@@ -1074,7 +1073,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
{
// Set shadowless shader bindings
m_backgroundShader->setUniformValue(m_backgroundShader->lightS(),
- m_cachedTheme.m_lightStrength);
+ m_cachedTheme->lightStrength());
// Draw the object
m_drawer->drawObject(m_backgroundShader, m_backgroundObj);
@@ -1096,22 +1095,22 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
lineShader->bind();
// Set unchanging shader bindings
- QVector3D lineColor = Utils::vectorFromColor(m_cachedTheme.m_gridLine);
+ QVector3D lineColor = Utils::vectorFromColor(m_cachedTheme->gridLineColor());
lineShader->setUniformValue(lineShader->lightP(), lightPos);
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
- lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme.m_ambientStrength);
+ lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength());
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
// Set shadowed shader bindings
lineShader->setUniformValue(lineShader->shadowQ(), m_shadowQualityToShader);
lineShader->setUniformValue(lineShader->lightS(),
- m_cachedTheme.m_lightStrength / 20.0f);
+ m_cachedTheme->lightStrength() / 20.0f);
} else
#endif
{
// Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme.m_lightStrength / 2.5f);
+ lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme->lightStrength() / 2.5f);
}
QQuaternion lineYRotation = QQuaternion();
@@ -1718,7 +1717,7 @@ void Surface3DRenderer::idToRGBA(uint id, uchar *r, uchar *g, uchar *b, uchar *a
void Surface3DRenderer::updateTextures()
{
- updateSurfaceGradient(m_cachedTheme.m_surfaceGradient);
+ updateSurfaceGradient(m_cachedTheme->baseGradient());
}
void Surface3DRenderer::calculateSceneScalingFactors()
diff --git a/src/datavisualization/engine/theme.cpp b/src/datavisualization/engine/theme.cpp
deleted file mode 100644
index 48685dc4..00000000
--- a/src/datavisualization/engine/theme.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the QtDataVisualization module.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-**
-****************************************************************************/
-
-#include "theme_p.h"
-
-#ifdef Q_OS_WIN
-#include <windows.h>
-#include <stdio.h>
-#endif
-
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-
-Theme::Theme()
- : m_theme(QDataVis::ThemeDefault),
- m_baseColor(QColor(Qt::gray)),
- m_heightColor(QColor(Qt::black)),
- m_depthColor(QColor(Qt::black)),
- m_backgroundColor(QColor(Qt::gray)),
- m_windowColor(QColor(Qt::gray)),
- m_textColor(QColor(Qt::white)),
- m_textBackgroundColor(QColor(0x00, 0x00, 0x00, 0xa0)),
- m_gridLine(QColor(Qt::black)),
- m_singleHighlightColor(QColor(Qt::red)),
- m_multiHighlightColor(QColor(Qt::darkRed)),
- m_surfaceGradient(QLinearGradient(qreal(gradientTextureWidth), qreal(gradientTextureHeight),
- 0.0, 0.0)),
- m_lightStrength(4.0f),
- m_ambientStrength(0.3f),
- m_highlightLightStrength(8.0f),
- m_uniformColor(true),
- m_labelBorders(false)
-{
- // Default values for surface gradient
-}
-
-Theme::~Theme()
-{
-}
-
-QDataVis::Theme Theme::theme()
-{
- return m_theme;
-}
-
-void Theme::useTheme(QDataVis::Theme theme)
-{
- m_theme = theme;
- switch (theme) {
- case QDataVis::ThemeQt: {
- m_baseColor = QColor(QRgb(0x80c342));
- //m_heightColor = QColor(QRgb(0x));
- //m_depthColor = QColor(QRgb(0x));
- m_backgroundColor = QColor(QRgb(0xffffff));
- m_windowColor = QColor(QRgb(0xffffff));
- m_textColor = QColor(QRgb(0x35322f));
- m_textBackgroundColor = QColor(0xff, 0xff, 0xff, 0x99);
- m_gridLine = QColor(QRgb(0xd7d6d5));
- m_singleHighlightColor = QColor(QRgb(0x14aaff));
- m_multiHighlightColor = QColor(QRgb(0x6400aa));
- m_lightStrength = 5.0f;
- m_ambientStrength = 0.5f;
- m_highlightLightStrength = 5.0f;
- m_uniformColor = true;
- m_labelBorders = true;
- break;
- }
- case QDataVis::ThemePrimaryColors: {
- m_baseColor = QColor(QRgb(0xffe400));
- //m_heightColor = QColor(QRgb(0x));
- //m_depthColor = QColor(QRgb(0x));
- m_backgroundColor = QColor(QRgb(0xffffff));
- m_windowColor = QColor(QRgb(0xffffff));
- m_textColor = QColor(QRgb(0x000000));
- m_textBackgroundColor = QColor(0xff, 0xff, 0xff, 0x99);
- m_gridLine = QColor(QRgb(0xd7d6d5));
- m_singleHighlightColor = QColor(QRgb(0x27beee));
- m_multiHighlightColor = QColor(QRgb(0xee1414));
- m_lightStrength = 5.0f;
- m_ambientStrength = 0.5f;
- m_highlightLightStrength = 5.0f;
- m_uniformColor = true;
- m_labelBorders = false;
- break;
- }
- case QDataVis::ThemeDigia: {
- m_baseColor = QColor(QRgb(0xcccccc));
- //m_heightColor = QColor(QRgb(0x));
- //m_depthColor = QColor(QRgb(0x));
- m_backgroundColor = QColor(QRgb(0xffffff));
- m_windowColor = QColor(QRgb(0xffffff));
- m_textColor = QColor(QRgb(0x000000));
- m_textBackgroundColor = QColor(0xff, 0xff, 0xff, 0x80);
- m_gridLine = QColor(QRgb(0xd7d6d5));
- m_singleHighlightColor = QColor(QRgb(0xfa0000));
- m_multiHighlightColor = QColor(QRgb(0x555555));
- m_lightStrength = 5.0f;
- m_ambientStrength = 0.5f;
- m_highlightLightStrength = 5.0f;
- m_uniformColor = false;
- m_labelBorders = false;
- break;
- }
- case QDataVis::ThemeStoneMoss: {
- m_baseColor = QColor(QRgb(0xbeb32b));
- //m_heightColor = QColor(QRgb(0x));
- //m_depthColor = QColor(QRgb(0x));
- m_backgroundColor = QColor(QRgb(0x4d4d4f));
- m_windowColor = QColor(QRgb(0x4d4d4f));
- m_textColor = QColor(QRgb(0xffffff));
- m_textBackgroundColor = QColor(0x4d, 0x4d, 0x4f, 0xcd);
- m_gridLine = QColor(QRgb(0x3e3e40));
- m_singleHighlightColor = QColor(QRgb(0xfbf6d6));
- m_multiHighlightColor = QColor(QRgb(0x442f20));
- m_lightStrength = 5.0f;
- m_ambientStrength = 0.5f;
- m_highlightLightStrength = 5.0f;
- m_uniformColor = true;
- m_labelBorders = true;
- break;
- }
- case QDataVis::ThemeArmyBlue: {
- m_baseColor = QColor(QRgb(0x495f76));
- //m_heightColor = QColor(QRgb(0x));
- //m_depthColor = QColor(QRgb(0x));
- m_backgroundColor = QColor(QRgb(0xd5d6d7));
- m_windowColor = QColor(QRgb(0xd5d6d7));
- m_textColor = QColor(QRgb(0x000000));
- m_textBackgroundColor = QColor(0xd5, 0xd6, 0xd7, 0xcd);
- m_gridLine = QColor(QRgb(0xaeadac));
- m_singleHighlightColor = QColor(QRgb(0x2aa2f9));
- m_multiHighlightColor = QColor(QRgb(0x103753));
- m_lightStrength = 5.0f;
- m_ambientStrength = 0.5f;
- m_highlightLightStrength = 5.0f;
- m_uniformColor = false;
- m_labelBorders = false;
- break;
- }
- case QDataVis::ThemeRetro: {
- m_baseColor = QColor(QRgb(0x533b23));
- //m_heightColor = QColor(QRgb(0x));
- //m_depthColor = QColor(QRgb(0x));
- m_backgroundColor = QColor(QRgb(0xe9e2ce));
- m_windowColor = QColor(QRgb(0xe9e2ce));
- m_textColor = QColor(QRgb(0x000000));
- m_textBackgroundColor = QColor(0xe9, 0xe2, 0xce, 0xc0);
- m_gridLine = QColor(QRgb(0xd0c0b0));
- m_singleHighlightColor = QColor(QRgb(0x8ea317));
- m_multiHighlightColor = QColor(QRgb(0xc25708));
- m_lightStrength = 5.0f;
- m_ambientStrength = 0.5f;
- m_highlightLightStrength = 5.0f;
- m_uniformColor = false;
- m_labelBorders = false;
- break;
- }
- case QDataVis::ThemeEbony: {
- m_baseColor = QColor(QRgb(0xffffff));
- //m_heightColor = QColor(QRgb(0x));
- //m_depthColor = QColor(QRgb(0x));
- m_backgroundColor = QColor(QRgb(0x000000));
- m_windowColor = QColor(QRgb(0x000000));
- m_textColor = QColor(QRgb(0xaeadac));
- m_textBackgroundColor = QColor(0x00, 0x00, 0x00, 0xcd);
- m_gridLine = QColor(QRgb(0x35322f));
- m_singleHighlightColor = QColor(QRgb(0xf5dc0d));
- m_multiHighlightColor = QColor(QRgb(0xd72222));
- m_lightStrength = 5.0f;
- m_ambientStrength = 0.5f;
- m_highlightLightStrength = 5.0f;
- m_uniformColor = true;
- m_labelBorders = false;
- break;
- }
- case QDataVis::ThemeIsabelle: {
- m_baseColor = QColor(QRgb(0xf9d900));
- //m_heightColor = QColor(QRgb(0x));
- //m_depthColor = QColor(QRgb(0x));
- m_backgroundColor = QColor(QRgb(0x000000));
- m_windowColor = QColor(QRgb(0x000000));
- m_textColor = QColor(QRgb(0xaeadac));
- m_textBackgroundColor = QColor(0x00, 0x00, 0x00, 0xc0);
- m_gridLine = QColor(QRgb(0x35322f));
- m_singleHighlightColor = QColor(QRgb(0xfff7cc));
- m_multiHighlightColor = QColor(QRgb(0xde0a0a));
- m_lightStrength = 5.0f;
- m_ambientStrength = 0.5f;
- m_highlightLightStrength = 5.0f;
- m_uniformColor = true;
- m_labelBorders = false;
- break;
- }
- default:
- break;
- }
-
- if (m_uniformColor) {
- m_surfaceGradient.setColorAt(0.0, m_baseColor);
- } else {
- QColor color;
- color.setRedF(m_baseColor.redF() * 0.7f);
- color.setGreenF(m_baseColor.greenF() * 0.7f);
- color.setBlueF(m_baseColor.blueF() * 0.7f);
- m_surfaceGradient.setColorAt(0.0, color);
- }
- m_surfaceGradient.setColorAt(1.0, m_baseColor);
-}
-
-void Theme::setFromTheme(Theme &theme)
-{
- m_theme = theme.m_theme;
- m_baseColor = theme.m_baseColor;
- m_heightColor = theme.m_heightColor;
- m_depthColor = theme.m_depthColor;
- m_backgroundColor = theme.m_backgroundColor;
- m_windowColor = theme.m_windowColor;
- m_textColor = theme.m_textColor;
- m_textBackgroundColor = theme.m_textBackgroundColor;
- m_gridLine = theme.m_gridLine;
- m_singleHighlightColor = theme.m_singleHighlightColor;
- m_multiHighlightColor = theme.m_multiHighlightColor;
- m_surfaceGradient = theme.m_surfaceGradient;
- m_lightStrength = theme.m_lightStrength;
- m_ambientStrength = theme.m_ambientStrength;
- m_highlightLightStrength = theme.m_highlightLightStrength;
- m_uniformColor = theme.m_uniformColor;
- m_labelBorders = theme.m_labelBorders;
-}
-
-QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/engine/theme_p.h b/src/datavisualization/engine/theme_p.h
deleted file mode 100644
index e0012f82..00000000
--- a/src/datavisualization/engine/theme_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the QtDataVisualization module.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtDataVisualization API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef THEME_P_H
-#define THEME_P_H
-
-#include "datavisualizationglobal_p.h"
-#include "q3dbars.h"
-#include <QLinearGradient>
-
-class QColor;
-
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-
-class QT_DATAVISUALIZATION_EXPORT Theme
-{
-public:
- explicit Theme();
- ~Theme();
-
- void useTheme(QDataVis::Theme theme);
- QDataVis::Theme theme();
- void setFromTheme(Theme &theme);
-
-private:
- friend class Abstract3DController;
- friend class Abstract3DRenderer;
- friend class Bars3DRenderer;
- friend class Surface3DRenderer;
- friend class Surface3DController;
- friend class Scatter3DRenderer;
- friend class SelectionPointer;
- friend class Drawer;
-
- QDataVis::Theme m_theme;
- QColor m_baseColor;
- QColor m_heightColor;
- QColor m_depthColor;
- QColor m_backgroundColor;
- QColor m_windowColor;
- QColor m_textColor;
- QColor m_textBackgroundColor;
- QColor m_gridLine;
- QColor m_singleHighlightColor;
- QColor m_multiHighlightColor;
- QLinearGradient m_surfaceGradient;
- float m_lightStrength;
- float m_ambientStrength;
- float m_highlightLightStrength;
- bool m_uniformColor;
- bool m_labelBorders;
-};
-
-QT_DATAVISUALIZATION_END_NAMESPACE
-
-#endif