summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/audiolevels/audiolevels.cpp3
-rw-r--r--examples/audiolevels/main.cpp2
-rw-r--r--examples/bars/graphmodifier.cpp3
-rw-r--r--examples/customproxy/rainfallgraph.cpp3
-rw-r--r--examples/itemmodel/main.cpp3
-rw-r--r--examples/qmlbars/qml/qmlbars/main.qml2
-rw-r--r--examples/qmlscatter/qml/qmlscatter/main.qml10
-rw-r--r--examples/qmlsurface/qml/qmlsurface/main.qml2
-rw-r--r--examples/scatter/scatterdatamodifier.cpp5
-rw-r--r--examples/surface/surfacegraph.cpp3
-rw-r--r--src/datavisualization/common.pri3
-rw-r--r--src/datavisualization/data/qbar3dseries.h1
-rw-r--r--src/datavisualization/datavisualization.pro1
-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/global/qdatavisualizationenums.h4
-rw-r--r--src/datavisualization/global/qtdatavisualizationenums.qdoc3
-rw-r--r--src/datavisualization/theme/builtin3dthemes.cpp230
-rw-r--r--src/datavisualization/theme/builtin3dthemes_p.h87
-rw-r--r--src/datavisualization/theme/q3dtheme.cpp306
-rw-r--r--src/datavisualization/theme/q3dtheme.h145
-rw-r--r--src/datavisualization/theme/q3dtheme_p.h (renamed from src/datavisualization/engine/theme_p.h)46
-rw-r--r--src/datavisualization/theme/theme.pri8
-rw-r--r--src/datavisualization/theme/thememanager.cpp307
-rw-r--r--src/datavisualization/theme/thememanager_p.h59
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp8
-rw-r--r--src/datavisualizationqml2/abstractdeclarative_p.h8
-rw-r--r--src/datavisualizationqml2/datavisualizationqml2.pro3
-rw-r--r--src/datavisualizationqml2/datavisualizationqml2_plugin.cpp2
-rw-r--r--src/datavisualizationqml2/datavisualizationqml2_plugin.h3
-rw-r--r--src/datavisualizationqml2/declarativebars.cpp1
-rw-r--r--src/datavisualizationqml2/declarativescatter.cpp1
-rw-r--r--src/datavisualizationqml2/declarativesurface.cpp1
-rw-r--r--tests/barstest/chart.cpp202
-rw-r--r--tests/barstest/chart.h8
-rw-r--r--tests/barstest/main.cpp15
-rw-r--r--tests/multigraphs/data.cpp11
-rw-r--r--tests/qmlcamera/qml/qmlcamera/main.qml2
-rw-r--r--tests/scattertest/scatterchart.cpp5
-rw-r--r--tests/surfacetest/graphmodifier.cpp3
-rw-r--r--tests/surfacetest/main.cpp3
59 files changed, 1495 insertions, 548 deletions
diff --git a/examples/audiolevels/audiolevels.cpp b/examples/audiolevels/audiolevels.cpp
index 4c64cbbe..0fc6d3c5 100644
--- a/examples/audiolevels/audiolevels.cpp
+++ b/examples/audiolevels/audiolevels.cpp
@@ -24,6 +24,7 @@
#include <QtDataVisualization/q3dscene.h>
#include <QtDataVisualization/q3dcamera.h>
#include <QtDataVisualization/qbar3dseries.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <QAudioDeviceInfo>
#include <QAudioInput>
@@ -47,7 +48,7 @@ AudioLevels::AudioLevels(Q3DBars *graph, QObject *parent)
m_graph->setShadowQuality(QDataVis::ShadowQualityNone);
m_graph->setSelectionMode(QDataVis::SelectionNone);
m_graph->scene()->activeCamera()->setCameraPosition(-25.0, 10.0, 190.0);
- m_graph->setTheme(QDataVis::ThemeIsabelle);
+ m_graph->setTheme(new Q3DTheme(QDataVis::ThemeIsabelle));
m_graph->setBarType(QDataVis::MeshStyleBars);
m_graph->addSeries(new QBar3DSeries);
diff --git a/examples/audiolevels/main.cpp b/examples/audiolevels/main.cpp
index 524c53b1..bdeb74b3 100644
--- a/examples/audiolevels/main.cpp
+++ b/examples/audiolevels/main.cpp
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
Q3DBars window;
- window.resize(900, 1000);
+ window.resize(800, 500);
window.setTitle("Qt Data Visualization - Microphone audio levels visualizer");
window.show();
diff --git a/examples/bars/graphmodifier.cpp b/examples/bars/graphmodifier.cpp
index 132ba4d6..f38d88e9 100644
--- a/examples/bars/graphmodifier.cpp
+++ b/examples/bars/graphmodifier.cpp
@@ -23,6 +23,7 @@
#include <QtDataVisualization/q3dscene.h>
#include <QtDataVisualization/q3dcamera.h>
#include <QtDataVisualization/qbar3dseries.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <QTime>
#include <QComboBox>
@@ -174,7 +175,7 @@ void GraphModifier::changePresetCamera()
void GraphModifier::changeTheme(int theme)
{
- m_graph->setTheme((QDataVis::Theme)theme);
+ m_graph->setTheme(new Q3DTheme(QDataVis::Theme(theme)));
}
void GraphModifier::changeLabelStyle()
diff --git a/examples/customproxy/rainfallgraph.cpp b/examples/customproxy/rainfallgraph.cpp
index 36ab9786..a31200e8 100644
--- a/examples/customproxy/rainfallgraph.cpp
+++ b/examples/customproxy/rainfallgraph.cpp
@@ -22,6 +22,7 @@
#include <QtDataVisualization/q3dscene.h>
#include <QtDataVisualization/q3dcamera.h>
#include <QtDataVisualization/qbar3dseries.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <QGuiApplication>
#include <QFont>
#include <QDebug>
@@ -74,7 +75,7 @@ RainfallGraph::RainfallGraph(Q3DBars *rainfall)
m_graph->setSelectionMode(QDataVis::SelectionItemAndColumn | QDataVis::SelectionSlice);
// Set theme
- m_graph->setTheme(QDataVis::ThemeArmyBlue);
+ m_graph->setTheme(new Q3DTheme(QDataVis::ThemeArmyBlue));
// Set camera position and zoom
m_graph->scene()->activeCamera()->setCameraPreset(QDataVis::CameraPresetIsometricRightHigh);
diff --git a/examples/itemmodel/main.cpp b/examples/itemmodel/main.cpp
index 3325d6a2..0c9ee0cb 100644
--- a/examples/itemmodel/main.cpp
+++ b/examples/itemmodel/main.cpp
@@ -23,6 +23,7 @@
#include <QtDataVisualization/q3dscene.h>
#include <QtDataVisualization/q3dcamera.h>
#include <QtDataVisualization/qbar3dseries.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <QApplication>
#include <QVBoxLayout>
@@ -113,7 +114,7 @@ GraphDataGenerator::GraphDataGenerator(Q3DBars *bargraph, QTableWidget *tableWid
//! [7]
// Set theme
- m_graph->setTheme(QDataVis::ThemeDigia);
+ m_graph->setTheme(new Q3DTheme(QDataVis::ThemeDigia));
// Set preset camera position
m_graph->scene()->activeCamera()->setCameraPreset(QDataVis::CameraPresetFront);
diff --git a/examples/qmlbars/qml/qmlbars/main.qml b/examples/qmlbars/qml/qmlbars/main.qml
index a3274f25..de1275ee 100644
--- a/examples/qmlbars/qml/qmlbars/main.qml
+++ b/examples/qmlbars/qml/qmlbars/main.qml
@@ -79,7 +79,7 @@ Item {
shadowQuality: AbstractGraph3D.ShadowQualityMedium
selectionMode: AbstractGraph3D.SelectionItem
font.pointSize: 35
- theme: AbstractGraph3D.ThemeRetro
+ theme: Theme3D { type: AbstractGraph3D.ThemeRetro }
labelStyle: AbstractGraph3D.LabelStyleFromTheme
barThickness: 0.7
barSpacing: Qt.size(0.5, 0.5)
diff --git a/examples/qmlscatter/qml/qmlscatter/main.qml b/examples/qmlscatter/qml/qmlscatter/main.qml
index 6cae72f8..8ca73628 100644
--- a/examples/qmlscatter/qml/qmlscatter/main.qml
+++ b/examples/qmlscatter/qml/qmlscatter/main.qml
@@ -53,7 +53,7 @@ Item {
//! [3]
font.family: "Lucida Handwriting"
font.pointSize: 40
- theme: AbstractGraph3D.ThemeIsabelle
+ theme: Theme3D { type: AbstractGraph3D.ThemeIsabelle }
shadowQuality: AbstractGraph3D.ShadowQualitySoftLow
//! [3]
//! [6]
@@ -135,10 +135,12 @@ Item {
text: "Change Theme"
anchors.left: cameraToggle.right
onClicked: {
- if (scatterGraph.theme === AbstractGraph3D.ThemeArmyBlue) {
- scatterGraph.theme = AbstractGraph3D.ThemeIsabelle;
+ if (scatterGraph.theme.type === AbstractGraph3D.ThemeArmyBlue) {
+ // Ownership of the theme is transferred and old theme is destroyed when setting
+ // a new one, so we need to create them dynamically
+ scatterGraph.theme = Qt.createQmlObject('import QtDataVisualization 1.0; Theme3D {type: AbstractGraph3D.ThemeIsabelle}', parent);
} else {
- scatterGraph.theme = AbstractGraph3D.ThemeArmyBlue;
+ scatterGraph.theme = Qt.createQmlObject('import QtDataVisualization 1.0; Theme3D {type: AbstractGraph3D.ThemeArmyBlue}', parent);
}
}
}
diff --git a/examples/qmlsurface/qml/qmlsurface/main.qml b/examples/qmlsurface/qml/qmlsurface/main.qml
index 2b44b1d4..a78ac796 100644
--- a/examples/qmlsurface/qml/qmlsurface/main.qml
+++ b/examples/qmlsurface/qml/qmlsurface/main.qml
@@ -49,7 +49,7 @@ Item {
id: surfaceplot
width: surfaceView.width
height: surfaceView.height
- theme: AbstractGraph3D.ThemeStoneMoss
+ theme: Theme3D { type: AbstractGraph3D.ThemeStoneMoss }
shadowQuality: AbstractGraph3D.ShadowQualityMedium
selectionMode: AbstractGraph3D.SelectionSlice | AbstractGraph3D.SelectionItemAndRow
smoothSurfaceEnabled: true
diff --git a/examples/scatter/scatterdatamodifier.cpp b/examples/scatter/scatterdatamodifier.cpp
index 1bdd089d..f92ffd0f 100644
--- a/examples/scatter/scatterdatamodifier.cpp
+++ b/examples/scatter/scatterdatamodifier.cpp
@@ -22,6 +22,7 @@
#include <QtDataVisualization/q3dscene.h>
#include <QtDataVisualization/q3dcamera.h>
#include <QtDataVisualization/qscatter3dseries.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <qmath.h>
using namespace QtDataVisualization;
@@ -40,7 +41,7 @@ ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter)
font.setPointSize(m_fontSize);
m_graph->setFont(font);
m_graph->setObjectType(QDataVis::MeshStyleSpheres, true);
- m_graph->setTheme(QDataVis::ThemeEbony);
+ m_graph->setTheme(new Q3DTheme(QDataVis::ThemeEbony));
m_graph->setShadowQuality(QDataVis::ShadowQualitySoftLow);
m_graph->scene()->activeCamera()->setCameraPreset(QDataVis::CameraPresetFront);
//! [0]
@@ -128,7 +129,7 @@ void ScatterDataModifier::setSmoothDots(int smooth)
void ScatterDataModifier::changeTheme(int theme)
{
- m_graph->setTheme((QDataVis::Theme)theme);
+ m_graph->setTheme(new Q3DTheme(QDataVis::Theme(theme)));
}
void ScatterDataModifier::changePresetCamera()
diff --git a/examples/surface/surfacegraph.cpp b/examples/surface/surfacegraph.cpp
index f5a2e00b..f774c537 100644
--- a/examples/surface/surfacegraph.cpp
+++ b/examples/surface/surfacegraph.cpp
@@ -19,6 +19,7 @@
#include "surfacegraph.h"
#include <QtDataVisualization/Q3DValueAxis>
+#include <QtDataVisualization/Q3DTheme>
#include <QtGui/QImage>
#include <QtCore/qmath.h>
@@ -224,7 +225,7 @@ void SurfaceGraph::setAxisZRange(qreal min, qreal max)
//! [6]
void SurfaceGraph::changeTheme(int theme)
{
- m_graph->setTheme((QDataVis::Theme)theme);
+ m_graph->setTheme(new Q3DTheme(QDataVis::Theme(theme)));
}
//! [6]
diff --git a/src/datavisualization/common.pri b/src/datavisualization/common.pri
index 5b03ab98..4ffa5646 100644
--- a/src/datavisualization/common.pri
+++ b/src/datavisualization/common.pri
@@ -6,4 +6,5 @@ INCLUDEPATH += $$PWD/engine \
$$PWD/utils \
$$PWD/axis \
$$PWD/data \
- $$PWD/input
+ $$PWD/input \
+ $$PWD/theme
diff --git a/src/datavisualization/data/qbar3dseries.h b/src/datavisualization/data/qbar3dseries.h
index ddc52170..5883cbfb 100644
--- a/src/datavisualization/data/qbar3dseries.h
+++ b/src/datavisualization/data/qbar3dseries.h
@@ -21,6 +21,7 @@
#include <QtDataVisualization/qabstract3dseries.h>
#include <QtDataVisualization/qbardataproxy.h>
+#include <QPoint>
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
diff --git a/src/datavisualization/datavisualization.pro b/src/datavisualization/datavisualization.pro
index bfb07440..7792c564 100644
--- a/src/datavisualization/datavisualization.pro
+++ b/src/datavisualization/datavisualization.pro
@@ -14,6 +14,7 @@ include($$PWD/common.pri)
include($$PWD/engine/engine.pri)
include($$PWD/global/global.pri)
include($$PWD/utils/utils.pri)
+include($$PWD/theme/theme.pri)
include($$PWD/axis/axis.pri)
include($$PWD/data/data.pri)
include($$PWD/input/input.pri)
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/global/qdatavisualizationenums.h b/src/datavisualization/global/qdatavisualizationenums.h
index b8114f61..61735b03 100644
--- a/src/datavisualization/global/qdatavisualizationenums.h
+++ b/src/datavisualization/global/qdatavisualizationenums.h
@@ -86,7 +86,6 @@ public:
};
enum Theme {
- ThemeDefault = -1,
ThemeQt,
ThemePrimaryColors,
ThemeDigia,
@@ -94,7 +93,8 @@ public:
ThemeArmyBlue,
ThemeRetro,
ThemeEbony,
- ThemeIsabelle
+ ThemeIsabelle,
+ ThemeUserDefined
};
enum SelectionFlag {
diff --git a/src/datavisualization/global/qtdatavisualizationenums.qdoc b/src/datavisualization/global/qtdatavisualizationenums.qdoc
index 67d5d1bc..6488f438 100644
--- a/src/datavisualization/global/qtdatavisualizationenums.qdoc
+++ b/src/datavisualization/global/qtdatavisualizationenums.qdoc
@@ -120,8 +120,6 @@
Predefined themes.
- \value ThemeDefault
- Used only in QML to indicate a theme has not been set.
\value ThemeQt
\value ThemePrimaryColors
\value ThemeDigia
@@ -130,6 +128,7 @@
\value ThemeRetro
\value ThemeEbony
\value ThemeIsabelle
+ \value ThemeUserDefined
*/
/*!
diff --git a/src/datavisualization/theme/builtin3dthemes.cpp b/src/datavisualization/theme/builtin3dthemes.cpp
new file mode 100644
index 00000000..9848e6e5
--- /dev/null
+++ b/src/datavisualization/theme/builtin3dthemes.cpp
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** 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 "builtin3dthemes_p.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+BuiltIn3DThemeQt::BuiltIn3DThemeQt()
+ : Q3DTheme(QDataVis::ThemeQt)
+{
+ setBaseColor(QColor(QRgb(0x80c342)));
+ setBackgroundColor(QColor(QRgb(0xffffff)));
+ setWindowColor(QColor(QRgb(0xffffff)));
+ setTextColor(QColor(QRgb(0x35322f)));
+ setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x99));
+ setGridLineColor(QColor(QRgb(0xd7d6d5)));
+ setSingleHighlightColor(QColor(QRgb(0x14aaff)));
+ setMultiHighlightColor(QColor(QRgb(0x6400aa)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(true);
+ setColorStyle(QDataVis::ColorStyleUniform);
+}
+
+BuiltIn3DThemePrimaryColors::BuiltIn3DThemePrimaryColors()
+ : Q3DTheme(QDataVis::ThemePrimaryColors)
+{
+ setBaseColor(QColor(QRgb(0xffe400)));
+ setBackgroundColor(QColor(QRgb(0xffffff)));
+ setWindowColor(QColor(QRgb(0xffffff)));
+ setTextColor(QColor(QRgb(0x000000)));
+ setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x99));
+ setGridLineColor(QColor(QRgb(0xd7d6d5)));
+ setSingleHighlightColor(QColor(QRgb(0x27beee)));
+ setMultiHighlightColor(QColor(QRgb(0xee1414)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(false);
+ setColorStyle(QDataVis::ColorStyleUniform);
+}
+
+BuiltIn3DThemeDigia::BuiltIn3DThemeDigia()
+ : Q3DTheme(QDataVis::ThemeDigia)
+{
+ setBackgroundColor(QColor(QRgb(0xffffff)));
+ setWindowColor(QColor(QRgb(0xffffff)));
+ setTextColor(QColor(QRgb(0x000000)));
+ setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x80));
+ setGridLineColor(QColor(QRgb(0xd7d6d5)));
+ setSingleHighlightColor(QColor(QRgb(0xfa0000)));
+ setMultiHighlightColor(QColor(QRgb(0x555555)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(false);
+ setColorStyle(QDataVis::ColorStyleObjectGradient);
+ QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0);
+ QColor color;
+ color.setRed(0xcc * 0.7);
+ color.setGreen(0xcc * 0.7);
+ color.setBlue(0xcc * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0xcccccc)));
+ setBaseGradient(gradient);
+ color.setRed(0xfa * 0.7);
+ color.setGreen(0x00);
+ color.setBlue(0x00);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0xfa0000)));
+ setSingleHighlightGradient(gradient);
+ color.setRed(0x55 * 0.7);
+ color.setGreen(0x55 * 0.7);
+ color.setBlue(0x55 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x555555)));
+ setMultiHighlightGradient(gradient);
+}
+
+BuiltIn3DThemeStoneMoss::BuiltIn3DThemeStoneMoss()
+ : Q3DTheme(QDataVis::ThemeStoneMoss)
+{
+ setBaseColor(QColor(QRgb(0xbeb32b)));
+ setBackgroundColor(QColor(QRgb(0x4d4d4f)));
+ setWindowColor(QColor(QRgb(0x4d4d4f)));
+ setTextColor(QColor(QRgb(0xffffff)));
+ setTextBackgroundColor(QColor(0x4d, 0x4d, 0x4f, 0xcd));
+ setGridLineColor(QColor(QRgb(0x3e3e40)));
+ setSingleHighlightColor(QColor(QRgb(0xfbf6d6)));
+ setMultiHighlightColor(QColor(QRgb(0x442f20)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(true);
+ setColorStyle(QDataVis::ColorStyleUniform);
+}
+
+BuiltIn3DThemeArmyBlue::BuiltIn3DThemeArmyBlue()
+ : Q3DTheme(QDataVis::ThemeArmyBlue)
+{
+ setBackgroundColor(QColor(QRgb(0xd5d6d7)));
+ setWindowColor(QColor(QRgb(0xd5d6d7)));
+ setTextColor(QColor(QRgb(0x000000)));
+ setTextBackgroundColor(QColor(0xd5, 0xd6, 0xd7, 0xcd));
+ setGridLineColor(QColor(QRgb(0xaeadac)));
+ setSingleHighlightColor(QColor(QRgb(0x2aa2f9)));
+ setMultiHighlightColor(QColor(QRgb(0x103753)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(false);
+ setColorStyle(QDataVis::ColorStyleObjectGradient);
+ QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0);
+ QColor color;
+ color.setRed(0x49 * 0.7);
+ color.setGreen(0x5f * 0.7);
+ color.setBlue(0x76 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x495f76)));
+ setBaseGradient(gradient);
+ color.setRed(0x2a * 0.7);
+ color.setGreen(0xa2 * 0.7);
+ color.setBlue(0xf9 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x2aa2f9)));
+ setSingleHighlightGradient(gradient);
+ color.setRed(0x10 * 0.7);
+ color.setGreen(0x37 * 0.7);
+ color.setBlue(0x53 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x103753)));
+ setMultiHighlightGradient(gradient);
+}
+
+BuiltIn3DThemeRetro::BuiltIn3DThemeRetro()
+ : Q3DTheme(QDataVis::ThemeRetro)
+{
+ setBackgroundColor(QColor(QRgb(0xe9e2ce)));
+ setWindowColor(QColor(QRgb(0xe9e2ce)));
+ setTextColor(QColor(QRgb(0x000000)));
+ setTextBackgroundColor(QColor(0xe9, 0xe2, 0xce, 0xc0));
+ setGridLineColor(QColor(QRgb(0xd0c0b0)));
+ setSingleHighlightColor(QColor(QRgb(0x8ea317)));
+ setMultiHighlightColor(QColor(QRgb(0xc25708)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(false);
+ setColorStyle(QDataVis::ColorStyleObjectGradient);
+ QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0);
+ QColor color;
+ color.setRed(0x53 * 0.7);
+ color.setGreen(0x3b * 0.7);
+ color.setBlue(0x23 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x533b23)));
+ setBaseGradient(gradient);
+ color.setRed(0x8e * 0.7);
+ color.setGreen(0xa3 * 0.7);
+ color.setBlue(0x17 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x8ea317)));
+ setSingleHighlightGradient(gradient);
+ color.setRed(0xc2 * 0.7);
+ color.setGreen(0x57 * 0.7);
+ color.setBlue(0x08 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0xc25708)));
+ setMultiHighlightGradient(gradient);
+}
+
+BuiltIn3DThemeEbony::BuiltIn3DThemeEbony()
+ : Q3DTheme(QDataVis::ThemeEbony)
+{
+ setBaseColor(QColor(QRgb(0xffffff)));
+ setBackgroundColor(QColor(QRgb(0x000000)));
+ setWindowColor(QColor(QRgb(0x000000)));
+ setTextColor(QColor(QRgb(0xaeadac)));
+ setTextBackgroundColor(QColor(0x00, 0x00, 0x00, 0xcd));
+ setGridLineColor(QColor(QRgb(0x35322f)));
+ setSingleHighlightColor(QColor(QRgb(0xf5dc0d)));
+ setMultiHighlightColor(QColor(QRgb(0xd72222)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(false);
+ setColorStyle(QDataVis::ColorStyleUniform);
+}
+
+BuiltIn3DThemeIsabelle::BuiltIn3DThemeIsabelle()
+ : Q3DTheme(QDataVis::ThemeIsabelle)
+{
+ setBaseColor(QColor(QRgb(0xf9d900)));
+ setBackgroundColor(QColor(QRgb(0x000000)));
+ setWindowColor(QColor(QRgb(0x000000)));
+ setTextColor(QColor(QRgb(0xaeadac)));
+ setTextBackgroundColor(QColor(0x00, 0x00, 0x00, 0xc0));
+ setGridLineColor(QColor(QRgb(0x35322f)));
+ setSingleHighlightColor(QColor(QRgb(0xfff7cc)));
+ setMultiHighlightColor(QColor(QRgb(0xde0a0a)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(false);
+ setColorStyle(QDataVis::ColorStyleUniform);
+}
+
+QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/theme/builtin3dthemes_p.h b/src/datavisualization/theme/builtin3dthemes_p.h
new file mode 100644
index 00000000..8f2c3d04
--- /dev/null
+++ b/src/datavisualization/theme/builtin3dthemes_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** 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 BUILTIN3DTHEMES_P_H
+#define BUILTIN3DTHEMES_P_H
+
+#include "datavisualizationglobal_p.h"
+#include "q3dtheme_p.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class BuiltIn3DThemeQt : public Q3DTheme
+{
+public:
+ BuiltIn3DThemeQt();
+};
+
+class BuiltIn3DThemePrimaryColors : public Q3DTheme
+{
+public:
+ BuiltIn3DThemePrimaryColors();
+};
+
+class BuiltIn3DThemeDigia : public Q3DTheme
+{
+public:
+ BuiltIn3DThemeDigia();
+};
+
+class BuiltIn3DThemeStoneMoss : public Q3DTheme
+{
+public:
+ BuiltIn3DThemeStoneMoss();
+};
+
+class BuiltIn3DThemeArmyBlue : public Q3DTheme
+{
+public:
+ BuiltIn3DThemeArmyBlue();
+};
+
+class BuiltIn3DThemeRetro : public Q3DTheme
+{
+public:
+ BuiltIn3DThemeRetro();
+};
+
+class BuiltIn3DThemeEbony : public Q3DTheme
+{
+public:
+ BuiltIn3DThemeEbony();
+};
+
+class BuiltIn3DThemeIsabelle : public Q3DTheme
+{
+public:
+ BuiltIn3DThemeIsabelle();
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif
diff --git a/src/datavisualization/theme/q3dtheme.cpp b/src/datavisualization/theme/q3dtheme.cpp
new file mode 100644
index 00000000..8aba6b48
--- /dev/null
+++ b/src/datavisualization/theme/q3dtheme.cpp
@@ -0,0 +1,306 @@
+/****************************************************************************
+**
+** 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 "q3dtheme_p.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+Q3DTheme::Q3DTheme(QObject *parent)
+ : QObject(parent),
+ d_ptr(new Q3DThemePrivate(this, QDataVis::ThemeUserDefined))
+{
+}
+
+Q3DTheme::Q3DTheme(QDataVis::Theme themeType, QObject *parent)
+ : QObject(parent),
+ d_ptr(new Q3DThemePrivate(this, themeType))
+{
+}
+
+Q3DTheme::Q3DTheme(Q3DThemePrivate *d, QDataVis::Theme themeType,
+ QObject *parent) :
+ QObject(parent),
+ d_ptr(d)
+{
+ d_ptr->m_themeId = themeType;
+}
+
+Q3DTheme::~Q3DTheme()
+{
+
+}
+
+// TODO: Basecolors as a list, containing one for each series?
+void Q3DTheme::setBaseColor(const QColor &color)
+{
+ if (d_ptr->m_baseColor != color) {
+ d_ptr->m_baseColor = color;
+ emit baseColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::baseColor() const
+{
+ return d_ptr->m_baseColor;
+}
+
+void Q3DTheme::setBackgroundColor(const QColor &color)
+{
+ if (d_ptr->m_backgroundColor != color) {
+ d_ptr->m_backgroundColor = color;
+ emit backgroundColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::backgroundColor() const
+{
+ return d_ptr->m_backgroundColor;
+}
+
+void Q3DTheme::setWindowColor(const QColor &color)
+{
+ if (d_ptr->m_windowColor != color) {
+ d_ptr->m_windowColor = color;
+ emit windowColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::windowColor() const
+{
+ return d_ptr->m_windowColor;
+}
+
+void Q3DTheme::setTextColor(const QColor &color)
+{
+ if (d_ptr->m_textColor != color) {
+ d_ptr->m_textColor = color;
+ emit textColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::textColor() const
+{
+ return d_ptr->m_textColor;
+}
+
+void Q3DTheme::setTextBackgroundColor(const QColor &color)
+{
+ if (d_ptr->m_textBackgroundColor != color) {
+ d_ptr->m_textBackgroundColor = color;
+ emit textBackgroundColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::textBackgroundColor() const
+{
+ return d_ptr->m_textBackgroundColor;
+}
+
+void Q3DTheme::setGridLineColor(const QColor &color)
+{
+ if (d_ptr->m_gridLineColor != color) {
+ d_ptr->m_gridLineColor = color;
+ emit gridLineColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::gridLineColor() const
+{
+ return d_ptr->m_gridLineColor;
+}
+
+void Q3DTheme::setSingleHighlightColor(const QColor &color)
+{
+ if (d_ptr->m_singleHighlightColor != color) {
+ d_ptr->m_singleHighlightColor = color;
+ emit singleHighlightColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::singleHighlightColor() const
+{
+ return d_ptr->m_singleHighlightColor;
+}
+
+void Q3DTheme::setMultiHighlightColor(const QColor &color)
+{
+ if (d_ptr->m_multiHighlightColor != color) {
+ d_ptr->m_multiHighlightColor = color;
+ emit multiHighlightColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::multiHighlightColor() const
+{
+ return d_ptr->m_multiHighlightColor;
+}
+
+void Q3DTheme::setLightColor(const QColor &color)
+{
+ if (d_ptr->m_lightColor != color) {
+ d_ptr->m_lightColor = color;
+ emit lightColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::lightColor() const
+{
+ return d_ptr->m_lightColor;
+}
+
+// TODO: Surfacegradients as a list, containing one for each series?
+void Q3DTheme::setBaseGradient(const QLinearGradient &gradient)
+{
+ if (d_ptr->m_baseGradient != gradient) {
+ d_ptr->m_baseGradient = gradient;
+ emit baseGradientChanged(gradient);
+ }
+}
+
+QLinearGradient Q3DTheme::baseGradient() const
+{
+ return d_ptr->m_baseGradient;
+}
+
+void Q3DTheme::setSingleHighlightGradient(const QLinearGradient &gradient)
+{
+ if (d_ptr->m_singleHighlightGradient != gradient) {
+ d_ptr->m_singleHighlightGradient = gradient;
+ emit singleHighlightGradientChanged(gradient);
+ }
+}
+
+QLinearGradient Q3DTheme::singleHighlightGradient() const
+{
+ return d_ptr->m_singleHighlightGradient;
+}
+
+void Q3DTheme::setMultiHighlightGradient(const QLinearGradient &gradient)
+{
+ if (d_ptr->m_multiHighlightGradient != gradient) {
+ d_ptr->m_multiHighlightGradient = gradient;
+ emit multiHighlightGradientChanged(gradient);
+ }
+}
+
+QLinearGradient Q3DTheme::multiHighlightGradient() const
+{
+ return d_ptr->m_multiHighlightGradient;
+}
+
+void Q3DTheme::setLightStrength(float strength)
+{
+ if (d_ptr->m_lightStrength != strength) {
+ d_ptr->m_lightStrength = strength;
+ emit lightStrengthChanged(strength);
+ }
+}
+
+float Q3DTheme::lightStrength() const
+{
+ return d_ptr->m_lightStrength;
+}
+
+void Q3DTheme::setAmbientLightStrength(float strength)
+{
+ if (d_ptr->m_ambientLightStrength != strength) {
+ d_ptr->m_ambientLightStrength = strength;
+ emit ambientLightStrengthChanged(strength);
+ }
+}
+
+float Q3DTheme::ambientLightStrength() const
+{
+ return d_ptr->m_ambientLightStrength;
+}
+
+void Q3DTheme::setHighlightLightStrength(float strength)
+{
+ if (d_ptr->m_highlightLightStrength != strength) {
+ d_ptr->m_highlightLightStrength = strength;
+ emit highlightLightStrengthChanged(strength);
+ }
+}
+
+float Q3DTheme::highlightLightStrength() const
+{
+ return d_ptr->m_highlightLightStrength;
+}
+
+void Q3DTheme::setLabelBorderEnabled(bool enabled)
+{
+ if (d_ptr->m_labelBorders != enabled) {
+ d_ptr->m_labelBorders = enabled;
+ emit labelBorderEnabledChanged(enabled);
+ }
+}
+
+bool Q3DTheme::isLabelBorderEnabled() const
+{
+ return d_ptr->m_labelBorders;
+}
+
+void Q3DTheme::setColorStyle(QDataVis::ColorStyle style)
+{
+ if (d_ptr->m_colorStyle != style) {
+ d_ptr->m_colorStyle = style;
+ emit colorStyleChanged(style);
+ }
+}
+
+QDataVis::ColorStyle Q3DTheme::colorStyle() const
+{
+ return d_ptr->m_colorStyle;
+}
+
+void Q3DTheme::setType(QDataVis::Theme themeType)
+{
+ if (d_ptr->m_themeId != themeType) {
+ d_ptr->m_themeId = themeType;
+ emit typeChanged(themeType);
+ }
+}
+
+QDataVis::Theme Q3DTheme::type() const
+{
+ return d_ptr->m_themeId;
+}
+
+// Q3DThemePrivate
+
+Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, QDataVis::Theme theme_id)
+ : QObject(0),
+ m_themeId(theme_id),
+ m_baseGradient(QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0)),
+ m_singleHighlightGradient(QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0)),
+ m_multiHighlightGradient(QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0)),
+ q_ptr(q)
+{
+}
+
+Q3DThemePrivate::~Q3DThemePrivate()
+{
+}
+
+QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/theme/q3dtheme.h b/src/datavisualization/theme/q3dtheme.h
new file mode 100644
index 00000000..8d42e6cf
--- /dev/null
+++ b/src/datavisualization/theme/q3dtheme.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** 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
+**
+****************************************************************************/
+
+#ifndef Q3DTHEME_H
+#define Q3DTHEME_H
+
+#include <QtDataVisualization/qdatavisualizationenums.h>
+#include <QLinearGradient>
+
+class QColor;
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class Q3DThemePrivate;
+
+class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QtDataVisualization::QDataVis::Theme type READ type WRITE setType NOTIFY typeChanged)
+ Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor NOTIFY baseColorChanged)
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
+ Q_PROPERTY(QColor windowColor READ windowColor WRITE setWindowColor NOTIFY windowColorChanged)
+ Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
+ Q_PROPERTY(QColor textBackgroundColor READ textBackgroundColor WRITE setTextBackgroundColor NOTIFY textBackgroundColorChanged)
+ Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged)
+ Q_PROPERTY(QColor singleHighlightColor READ singleHighlightColor WRITE setSingleHighlightColor NOTIFY singleHighlightColorChanged)
+ Q_PROPERTY(QColor multiHighlightColor READ multiHighlightColor WRITE setMultiHighlightColor NOTIFY multiHighlightColorChanged)
+ Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged) // TODO: Not used yet
+ Q_PROPERTY(QLinearGradient baseGradient READ baseGradient WRITE setBaseGradient NOTIFY baseGradientChanged)
+ Q_PROPERTY(QLinearGradient singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged)
+ Q_PROPERTY(QLinearGradient multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged)
+ Q_PROPERTY(float lightStrength READ lightStrength WRITE setLightStrength NOTIFY lightStrengthChanged)
+ Q_PROPERTY(float ambientLightStrength READ ambientLightStrength WRITE setAmbientLightStrength NOTIFY ambientLightStrengthChanged)
+ Q_PROPERTY(float highlightLightStrength READ highlightLightStrength WRITE setHighlightLightStrength NOTIFY highlightLightStrengthChanged)
+ Q_PROPERTY(bool labelBorderEnabled READ isLabelBorderEnabled WRITE setLabelBorderEnabled NOTIFY labelBorderEnabledChanged)
+ Q_PROPERTY(QtDataVisualization::QDataVis::ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
+ // TODO: Add everything that we need
+
+public:
+ explicit Q3DTheme(QObject *parent = 0);
+ explicit Q3DTheme(QDataVis::Theme themeType, QObject *parent = 0);
+ virtual ~Q3DTheme();
+
+ void setType(QDataVis::Theme themeType);
+ QDataVis::Theme type() const;
+
+ void setBaseColor(const QColor &color);
+ QColor baseColor() const;
+
+ void setBackgroundColor(const QColor &color);
+ QColor backgroundColor() const;
+
+ void setWindowColor(const QColor &color);
+ QColor windowColor() const;
+
+ void setTextColor(const QColor &color);
+ QColor textColor() const;
+
+ void setTextBackgroundColor(const QColor &color);
+ QColor textBackgroundColor() const;
+
+ void setGridLineColor(const QColor &color);
+ QColor gridLineColor() const;
+
+ void setSingleHighlightColor(const QColor &color);
+ QColor singleHighlightColor() const;
+
+ void setMultiHighlightColor(const QColor &color);
+ QColor multiHighlightColor() const;
+
+ void setLightColor(const QColor &color);
+ QColor lightColor() const;
+
+ void setBaseGradient(const QLinearGradient &gradient);
+ QLinearGradient baseGradient() const;
+
+ void setSingleHighlightGradient(const QLinearGradient &gradient);
+ QLinearGradient singleHighlightGradient() const;
+
+ void setMultiHighlightGradient(const QLinearGradient &gradient);
+ QLinearGradient multiHighlightGradient() const;
+
+ void setLightStrength(float strength);
+ float lightStrength() const;
+
+ void setAmbientLightStrength(float strength);
+ float ambientLightStrength() const;
+
+ void setHighlightLightStrength(float strength);
+ float highlightLightStrength() const;
+
+ void setLabelBorderEnabled(bool enabled);
+ bool isLabelBorderEnabled() const;
+
+ void setColorStyle(QDataVis::ColorStyle style);
+ QDataVis::ColorStyle colorStyle() const;
+
+signals:
+ void typeChanged(QDataVis::Theme themeType);
+ void baseColorChanged(QColor color);
+ void backgroundColorChanged(QColor color);
+ void windowColorChanged(QColor color);
+ void textColorChanged(QColor color);
+ void textBackgroundColorChanged(QColor color);
+ void gridLineColorChanged(QColor color);
+ void singleHighlightColorChanged(QColor color);
+ void multiHighlightColorChanged(QColor color);
+ void lightColorChanged(QColor color);
+ void baseGradientChanged(QLinearGradient gradient);
+ void singleHighlightGradientChanged(QLinearGradient gradient);
+ void multiHighlightGradientChanged(QLinearGradient gradient);
+ void lightStrengthChanged(float strength);
+ void ambientLightStrengthChanged(float strength);
+ void highlightLightStrengthChanged(float strength);
+ void labelBorderEnabledChanged(bool enabled);
+ void colorStyleChanged(QDataVis::ColorStyle style);
+
+protected:
+ explicit Q3DTheme(Q3DThemePrivate *d,
+ QDataVis::Theme themeType,
+ QObject *parent = 0);
+ QScopedPointer<Q3DThemePrivate> d_ptr;
+
+private:
+ Q_DISABLE_COPY(Q3DTheme)
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif
diff --git a/src/datavisualization/engine/theme_p.h b/src/datavisualization/theme/q3dtheme_p.h
index e0012f82..ae4bdbe4 100644
--- a/src/datavisualization/engine/theme_p.h
+++ b/src/datavisualization/theme/q3dtheme_p.h
@@ -26,38 +26,28 @@
//
// We mean it.
-#ifndef THEME_P_H
-#define THEME_P_H
+#ifndef Q3DTHEME_P_H
+#define Q3DTHEME_P_H
#include "datavisualizationglobal_p.h"
-#include "q3dbars.h"
-#include <QLinearGradient>
+#include "q3dtheme.h"
class QColor;
+class QLinearGradient;
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-class QT_DATAVISUALIZATION_EXPORT Theme
+class Q3DThemePrivate : public QObject
{
+ Q_OBJECT
public:
- explicit Theme();
- ~Theme();
+ Q3DThemePrivate(Q3DTheme *q,
+ QDataVis::Theme theme_id = QDataVis::ThemeUserDefined);
+ virtual ~Q3DThemePrivate();
- 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;
+public:
+ QDataVis::Theme m_themeId;
- QDataVis::Theme m_theme;
QColor m_baseColor;
QColor m_heightColor;
QColor m_depthColor;
@@ -65,15 +55,21 @@ private:
QColor m_windowColor;
QColor m_textColor;
QColor m_textBackgroundColor;
- QColor m_gridLine;
+ QColor m_gridLineColor;
QColor m_singleHighlightColor;
QColor m_multiHighlightColor;
- QLinearGradient m_surfaceGradient;
+ QColor m_lightColor;
+ QLinearGradient m_baseGradient;
+ QLinearGradient m_singleHighlightGradient;
+ QLinearGradient m_multiHighlightGradient;
float m_lightStrength;
- float m_ambientStrength;
+ float m_ambientLightStrength;
float m_highlightLightStrength;
- bool m_uniformColor;
bool m_labelBorders;
+ QDataVis::ColorStyle m_colorStyle;
+
+protected:
+ Q3DTheme *q_ptr;
};
QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/theme/theme.pri b/src/datavisualization/theme/theme.pri
new file mode 100644
index 00000000..1de3035a
--- /dev/null
+++ b/src/datavisualization/theme/theme.pri
@@ -0,0 +1,8 @@
+HEADERS += \
+ $$PWD/q3dtheme.h \
+ $$PWD/q3dtheme_p.h \
+ $$PWD/thememanager_p.h
+
+SOURCES += \
+ $$PWD/q3dtheme.cpp \
+ $$PWD/thememanager.cpp
diff --git a/src/datavisualization/theme/thememanager.cpp b/src/datavisualization/theme/thememanager.cpp
new file mode 100644
index 00000000..57682958
--- /dev/null
+++ b/src/datavisualization/theme/thememanager.cpp
@@ -0,0 +1,307 @@
+/****************************************************************************
+**
+** 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 "thememanager_p.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+ThemeManager::ThemeManager(Abstract3DController *controller)
+ : m_theme(0),
+ m_controller(controller)
+{
+}
+
+ThemeManager::~ThemeManager()
+{
+}
+
+void ThemeManager::setTheme(Q3DTheme *theme)
+{
+ if (!theme)
+ return;
+
+ if (m_theme.data() != theme) {
+ // Disconnect old theme signal connections
+ if (m_theme) {
+ disconnect(m_theme.data(), 0, m_controller, 0);
+ disconnect(m_theme.data(), 0, this, 0);
+ }
+
+ m_theme.reset(theme);
+
+ QDataVis::Theme type = m_theme->type();
+
+ if (type != QDataVis::ThemeUserDefined)
+ useTheme(type);
+
+ // Connect signals from new one
+ connectThemeSignals();
+ }
+}
+
+Q3DTheme *ThemeManager::theme() const
+{
+ return m_theme.data();
+}
+
+void ThemeManager::connectThemeSignals()
+{
+ // TODO: Implement receiving end for the commented ones (QTRD-2538)
+ connect(m_theme.data(), &Q3DTheme::baseColorChanged,
+ m_controller, &Abstract3DController::setObjectColor);
+// connect(m_theme.data(), &Q3DTheme::backgroundColorChanged,
+// m_controller, &Abstract3DController::setBackgroundColorColor);
+// connect(m_theme.data(), &Q3DTheme::windowColorChanged,
+// m_controller, &Abstract3DController::setWindowColor);
+// connect(m_theme.data(), &Q3DTheme::textColorChanged,
+// m_controller, &Abstract3DController::setTextColor);
+// connect(m_theme.data(), &Q3DTheme::textBackgroundColorChanged,
+// m_controller, &Abstract3DController::setTextBackgroundColor);
+// connect(m_theme.data(), &Q3DTheme::gridLineColorChanged,
+// m_controller, &Abstract3DController::setGridLineColor);
+ connect(m_theme.data(), &Q3DTheme::singleHighlightColorChanged,
+ m_controller, &Abstract3DController::setSingleHighlightColor);
+ connect(m_theme.data(), &Q3DTheme::multiHighlightColorChanged,
+ m_controller, &Abstract3DController::setMultiHighlightColor);
+// connect(m_theme.data(), &Q3DTheme::lightColorChanged,
+// m_controller, &Abstract3DController::setLightColor);
+ connect(m_theme.data(), &Q3DTheme::baseGradientChanged,
+ m_controller, &Abstract3DController::setObjectGradient);
+ connect(m_theme.data(), &Q3DTheme::singleHighlightGradientChanged,
+ m_controller, &Abstract3DController::setSingleHighlightGradient);
+ connect(m_theme.data(), &Q3DTheme::multiHighlightGradientChanged,
+ m_controller, &Abstract3DController::setMultiHighlightGradient);
+// connect(m_theme.data(), &Q3DTheme::lightStrengthChanged,
+// m_controller, &Abstract3DController::setLightStrength);
+// connect(m_theme.data(), &Q3DTheme::ambientLightStrengthChanged,
+// m_controller, &Abstract3DController::setAmbientLightStrength);
+// connect(m_theme.data(), &Q3DTheme::highlightLightStrengthChanged,
+// m_controller, &Abstract3DController::setHighlightLightStrength);
+// connect(m_theme.data(), &Q3DTheme::labelBorderEnabledChanged,
+// m_controller, &Abstract3DController::setLabelBorderEnabled);
+ connect(m_theme.data(), &Q3DTheme::colorStyleChanged,
+ m_controller, &Abstract3DController::setColorStyle);
+
+ connect(m_theme.data(), &Q3DTheme::typeChanged, this, &ThemeManager::useTheme);
+}
+
+void ThemeManager::useTheme(QDataVis::Theme type)
+{
+ switch (type) {
+ case QDataVis::ThemeQt: {
+ m_theme->setBaseColor(QColor(QRgb(0x80c342)));
+ m_theme->setBackgroundColor(QColor(QRgb(0xffffff)));
+ m_theme->setWindowColor(QColor(QRgb(0xffffff)));
+ m_theme->setTextColor(QColor(QRgb(0x35322f)));
+ m_theme->setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x99));
+ m_theme->setGridLineColor(QColor(QRgb(0xd7d6d5)));
+ m_theme->setSingleHighlightColor(QColor(QRgb(0x14aaff)));
+ m_theme->setMultiHighlightColor(QColor(QRgb(0x6400aa)));
+ m_theme->setLightStrength(5.0f);
+ m_theme->setAmbientLightStrength(0.5f);
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBorderEnabled(true);
+ m_theme->setColorStyle(QDataVis::ColorStyleUniform);
+ break;
+ }
+
+ case QDataVis::ThemePrimaryColors: {
+ m_theme->setBaseColor(QColor(QRgb(0xffe400)));
+ m_theme->setBackgroundColor(QColor(QRgb(0xffffff)));
+ m_theme->setWindowColor(QColor(QRgb(0xffffff)));
+ m_theme->setTextColor(QColor(QRgb(0x000000)));
+ m_theme->setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x99));
+ m_theme->setGridLineColor(QColor(QRgb(0xd7d6d5)));
+ m_theme->setSingleHighlightColor(QColor(QRgb(0x27beee)));
+ m_theme->setMultiHighlightColor(QColor(QRgb(0xee1414)));
+ m_theme->setLightStrength(5.0f);
+ m_theme->setAmbientLightStrength(0.5f);
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBorderEnabled(false);
+ m_theme->setColorStyle(QDataVis::ColorStyleUniform);
+ break;
+ }
+
+ case QDataVis::ThemeDigia: {
+ m_theme->setBackgroundColor(QColor(QRgb(0xffffff)));
+ m_theme->setWindowColor(QColor(QRgb(0xffffff)));
+ m_theme->setTextColor(QColor(QRgb(0x000000)));
+ m_theme->setTextBackgroundColor(QColor(0xff, 0xff, 0xff, 0x80));
+ m_theme->setGridLineColor(QColor(QRgb(0xd7d6d5)));
+ m_theme->setSingleHighlightColor(QColor(QRgb(0xfa0000)));
+ m_theme->setMultiHighlightColor(QColor(QRgb(0x555555)));
+ m_theme->setLightStrength(5.0f);
+ m_theme->setAmbientLightStrength(0.5f);
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBorderEnabled(false);
+ m_theme->setColorStyle(QDataVis::ColorStyleObjectGradient);
+ QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0);
+ QColor color;
+ color.setRed(0xcc * 0.7);
+ color.setGreen(0xcc * 0.7);
+ color.setBlue(0xcc * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0xcccccc)));
+ m_theme->setBaseGradient(gradient);
+ color.setRed(0xfa * 0.7);
+ color.setGreen(0x00);
+ color.setBlue(0x00);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0xfa0000)));
+ m_theme->setSingleHighlightGradient(gradient);
+ color.setRed(0x55 * 0.7);
+ color.setGreen(0x55 * 0.7);
+ color.setBlue(0x55 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x555555)));
+ m_theme->setMultiHighlightGradient(gradient);
+ break;
+ }
+
+ case QDataVis::ThemeStoneMoss: {
+ m_theme->setBaseColor(QColor(QRgb(0xbeb32b)));
+ m_theme->setBackgroundColor(QColor(QRgb(0x4d4d4f)));
+ m_theme->setWindowColor(QColor(QRgb(0x4d4d4f)));
+ m_theme->setTextColor(QColor(QRgb(0xffffff)));
+ m_theme->setTextBackgroundColor(QColor(0x4d, 0x4d, 0x4f, 0xcd));
+ m_theme->setGridLineColor(QColor(QRgb(0x3e3e40)));
+ m_theme->setSingleHighlightColor(QColor(QRgb(0xfbf6d6)));
+ m_theme->setMultiHighlightColor(QColor(QRgb(0x442f20)));
+ m_theme->setLightStrength(5.0f);
+ m_theme->setAmbientLightStrength(0.5f);
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBorderEnabled(true);
+ m_theme->setColorStyle(QDataVis::ColorStyleUniform);
+ break;
+ }
+
+ case QDataVis::ThemeArmyBlue: {
+ m_theme->setBackgroundColor(QColor(QRgb(0xd5d6d7)));
+ m_theme->setWindowColor(QColor(QRgb(0xd5d6d7)));
+ m_theme->setTextColor(QColor(QRgb(0x000000)));
+ m_theme->setTextBackgroundColor(QColor(0xd5, 0xd6, 0xd7, 0xcd));
+ m_theme->setGridLineColor(QColor(QRgb(0xaeadac)));
+ m_theme->setSingleHighlightColor(QColor(QRgb(0x2aa2f9)));
+ m_theme->setMultiHighlightColor(QColor(QRgb(0x103753)));
+ m_theme->setLightStrength(5.0f);
+ m_theme->setAmbientLightStrength(0.5f);
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBorderEnabled(false);
+ m_theme->setColorStyle(QDataVis::ColorStyleObjectGradient);
+ QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0);
+ QColor color;
+ color.setRed(0x49 * 0.7);
+ color.setGreen(0x5f * 0.7);
+ color.setBlue(0x76 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x495f76)));
+ m_theme->setBaseGradient(gradient);
+ color.setRed(0x2a * 0.7);
+ color.setGreen(0xa2 * 0.7);
+ color.setBlue(0xf9 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x2aa2f9)));
+ m_theme->setSingleHighlightGradient(gradient);
+ color.setRed(0x10 * 0.7);
+ color.setGreen(0x37 * 0.7);
+ color.setBlue(0x53 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x103753)));
+ m_theme->setMultiHighlightGradient(gradient);
+ break;
+ }
+
+ case QDataVis::ThemeRetro: {
+ m_theme->setBackgroundColor(QColor(QRgb(0xe9e2ce)));
+ m_theme->setWindowColor(QColor(QRgb(0xe9e2ce)));
+ m_theme->setTextColor(QColor(QRgb(0x000000)));
+ m_theme->setTextBackgroundColor(QColor(0xe9, 0xe2, 0xce, 0xc0));
+ m_theme->setGridLineColor(QColor(QRgb(0xd0c0b0)));
+ m_theme->setSingleHighlightColor(QColor(QRgb(0x8ea317)));
+ m_theme->setMultiHighlightColor(QColor(QRgb(0xc25708)));
+ m_theme->setLightStrength(5.0f);
+ m_theme->setAmbientLightStrength(0.5f);
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBorderEnabled(false);
+ m_theme->setColorStyle(QDataVis::ColorStyleObjectGradient);
+ QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0);
+ QColor color;
+ color.setRed(0x53 * 0.7);
+ color.setGreen(0x3b * 0.7);
+ color.setBlue(0x23 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x533b23)));
+ m_theme->setBaseGradient(gradient);
+ color.setRed(0x8e * 0.7);
+ color.setGreen(0xa3 * 0.7);
+ color.setBlue(0x17 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0x8ea317)));
+ m_theme->setSingleHighlightGradient(gradient);
+ color.setRed(0xc2 * 0.7);
+ color.setGreen(0x57 * 0.7);
+ color.setBlue(0x08 * 0.7);
+ gradient.setColorAt(0.0, color);
+ gradient.setColorAt(1.0, QColor(QRgb(0xc25708)));
+ m_theme->setMultiHighlightGradient(gradient);
+ break;
+ }
+
+ case QDataVis::ThemeEbony: {
+ m_theme->setBaseColor(QColor(QRgb(0xffffff)));
+ m_theme->setBackgroundColor(QColor(QRgb(0x000000)));
+ m_theme->setWindowColor(QColor(QRgb(0x000000)));
+ m_theme->setTextColor(QColor(QRgb(0xaeadac)));
+ m_theme->setTextBackgroundColor(QColor(0x00, 0x00, 0x00, 0xcd));
+ m_theme->setGridLineColor(QColor(QRgb(0x35322f)));
+ m_theme->setSingleHighlightColor(QColor(QRgb(0xf5dc0d)));
+ m_theme->setMultiHighlightColor(QColor(QRgb(0xd72222)));
+ m_theme->setLightStrength(5.0f);
+ m_theme->setAmbientLightStrength(0.5f);
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBorderEnabled(false);
+ m_theme->setColorStyle(QDataVis::ColorStyleUniform);
+ break;
+ }
+
+ case QDataVis::ThemeIsabelle: {
+ m_theme->setBaseColor(QColor(QRgb(0xf9d900)));
+ m_theme->setBackgroundColor(QColor(QRgb(0x000000)));
+ m_theme->setWindowColor(QColor(QRgb(0x000000)));
+ m_theme->setTextColor(QColor(QRgb(0xaeadac)));
+ m_theme->setTextBackgroundColor(QColor(0x00, 0x00, 0x00, 0xc0));
+ m_theme->setGridLineColor(QColor(QRgb(0x35322f)));
+ m_theme->setSingleHighlightColor(QColor(QRgb(0xfff7cc)));
+ m_theme->setMultiHighlightColor(QColor(QRgb(0xde0a0a)));
+ m_theme->setLightStrength(5.0f);
+ m_theme->setAmbientLightStrength(0.5f);
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBorderEnabled(false);
+ m_theme->setColorStyle(QDataVis::ColorStyleUniform);
+ break;
+ }
+ }
+}
+
+QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/theme/thememanager_p.h b/src/datavisualization/theme/thememanager_p.h
new file mode 100644
index 00000000..0b05dc9b
--- /dev/null
+++ b/src/datavisualization/theme/thememanager_p.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** 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 THEMEMANAGER_P_H
+#define THEMEMANAGER_P_H
+
+#include "datavisualizationglobal_p.h"
+#include "abstract3dcontroller_p.h"
+#include "q3dtheme.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class ThemeManager : public QObject
+{
+ Q_OBJECT
+public:
+ ThemeManager(Abstract3DController *controller);
+ ~ThemeManager();
+
+ void setTheme(Q3DTheme *theme);
+ Q3DTheme *theme() const;
+
+protected:
+ void connectThemeSignals();
+ void useTheme(QDataVis::Theme type);
+
+private:
+ QScopedPointer<Q3DTheme> m_theme;
+ Abstract3DController *m_controller;
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif
diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp
index 80752019..06c68cb0 100644
--- a/src/datavisualizationqml2/abstractdeclarative.cpp
+++ b/src/datavisualizationqml2/abstractdeclarative.cpp
@@ -18,7 +18,6 @@
#include "abstractdeclarative_p.h"
#include "q3dvalueaxis.h"
-#include "theme_p.h"
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
@@ -36,15 +35,14 @@ Q3DScene* AbstractDeclarative::scene() const
return m_controller->scene();
}
-void AbstractDeclarative::setTheme(QDataVis::Theme theme)
+void AbstractDeclarative::setTheme(Q3DTheme *theme)
{
- // TODO: Implement correctly once "user-modifiable themes" (QTRD-2120) is implemented
m_controller->setTheme(theme);
}
-QDataVis::Theme AbstractDeclarative::theme() const
+Q3DTheme *AbstractDeclarative::theme() const
{
- return m_controller->theme().theme();
+ return m_controller->theme();
}
void AbstractDeclarative::setSelectionMode(QDataVis::SelectionFlags mode)
diff --git a/src/datavisualizationqml2/abstractdeclarative_p.h b/src/datavisualizationqml2/abstractdeclarative_p.h
index 1740b816..27572f7b 100644
--- a/src/datavisualizationqml2/abstractdeclarative_p.h
+++ b/src/datavisualizationqml2/abstractdeclarative_p.h
@@ -47,7 +47,7 @@ class AbstractDeclarative : public QQuickItem
Q_PROPERTY(QtDataVisualization::QDataVis::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality NOTIFY shadowQualityChanged)
Q_PROPERTY(Q3DScene* scene READ scene)
Q_PROPERTY(QAbstract3DInputHandler* inputHandler READ inputHandler WRITE setInputHandler NOTIFY inputHandlerChanged)
- Q_PROPERTY(QtDataVisualization::QDataVis::Theme theme READ theme WRITE setTheme NOTIFY themeChanged)
+ Q_PROPERTY(Q3DTheme* theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible NOTIFY gridVisibleChanged)
Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged)
@@ -61,8 +61,8 @@ public:
virtual QAbstract3DInputHandler *inputHandler() const;
virtual void setInputHandler(QAbstract3DInputHandler *inputHandler);
- virtual void setTheme(QDataVis::Theme theme);
- virtual QDataVis::Theme theme() const;
+ virtual void setTheme(Q3DTheme *theme);
+ virtual Q3DTheme *theme() const;
virtual void setSelectionMode(QDataVis::SelectionFlags mode);
virtual QDataVis::SelectionFlags selectionMode() const;
@@ -96,7 +96,7 @@ signals:
// Signals shadow quality changes.
void shadowQualityChanged(QDataVis::ShadowQuality quality);
void inputHandlerChanged(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);
diff --git a/src/datavisualizationqml2/datavisualizationqml2.pro b/src/datavisualizationqml2/datavisualizationqml2.pro
index 073b1250..5a5ab476 100644
--- a/src/datavisualizationqml2/datavisualizationqml2.pro
+++ b/src/datavisualizationqml2/datavisualizationqml2.pro
@@ -15,7 +15,8 @@ INCLUDEPATH += ../../include \
../../include/QtDataVisualization \
../datavisualization/engine \
../datavisualization/global \
- ../datavisualization/data
+ ../datavisualization/data \
+ ../datavisualization/theme
SOURCES += \
datavisualizationqml2_plugin.cpp \
diff --git a/src/datavisualizationqml2/datavisualizationqml2_plugin.cpp b/src/datavisualizationqml2/datavisualizationqml2_plugin.cpp
index 7e7f636a..e1a74691 100644
--- a/src/datavisualizationqml2/datavisualizationqml2_plugin.cpp
+++ b/src/datavisualizationqml2/datavisualizationqml2_plugin.cpp
@@ -73,6 +73,8 @@ void Datavis3Dqml2Plugin::registerTypes(const char *uri)
qmlRegisterType<ColorGradientStop>(uri, 1, 0, "ColorGradientStop");
qmlRegisterType<ColorGradient>(uri, 1, 0, "ColorGradient");
+ qmlRegisterType<Q3DTheme>(uri, 1, 0, "Theme3D");
+
qmlRegisterType<DeclarativeBar3DSeries>(uri, 1, 0, "Bar3DSeries");
qmlRegisterType<DeclarativeScatter3DSeries>(uri, 1, 0, "Scatter3DSeries");
qmlRegisterType<DeclarativeSurface3DSeries>(uri, 1, 0, "Surface3DSeries");
diff --git a/src/datavisualizationqml2/datavisualizationqml2_plugin.h b/src/datavisualizationqml2/datavisualizationqml2_plugin.h
index 2635dcbd..5552e94d 100644
--- a/src/datavisualizationqml2/datavisualizationqml2_plugin.h
+++ b/src/datavisualizationqml2/datavisualizationqml2_plugin.h
@@ -40,6 +40,7 @@
#include "qscatter3dseries.h"
#include "qsurface3dseries.h"
#include "declarativeseries_p.h"
+#include "q3dtheme.h"
#include <QQmlExtensionPlugin>
@@ -84,6 +85,8 @@ QML_DECLARE_TYPE(DeclarativeSurface3DSeries)
QML_DECLARE_TYPE(ColorGradientStop)
QML_DECLARE_TYPE(ColorGradient)
+QML_DECLARE_TYPE(Q3DTheme)
+
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
class Datavis3Dqml2Plugin : public QQmlExtensionPlugin
diff --git a/src/datavisualizationqml2/declarativebars.cpp b/src/datavisualizationqml2/declarativebars.cpp
index 55c02cce..f229cfed 100644
--- a/src/datavisualizationqml2/declarativebars.cpp
+++ b/src/datavisualizationqml2/declarativebars.cpp
@@ -20,7 +20,6 @@
#include "declarativebarsrenderer_p.h"
#include "q3dvalueaxis.h"
#include "qitemmodelbardataproxy.h"
-#include "theme_p.h"
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
diff --git a/src/datavisualizationqml2/declarativescatter.cpp b/src/datavisualizationqml2/declarativescatter.cpp
index b71fb820..52c75962 100644
--- a/src/datavisualizationqml2/declarativescatter.cpp
+++ b/src/datavisualizationqml2/declarativescatter.cpp
@@ -19,7 +19,6 @@
#include "declarativescatter_p.h"
#include "declarativescatterrenderer_p.h"
#include "qitemmodelscatterdataproxy.h"
-#include "theme_p.h"
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
diff --git a/src/datavisualizationqml2/declarativesurface.cpp b/src/datavisualizationqml2/declarativesurface.cpp
index 25f27f16..72dda752 100644
--- a/src/datavisualizationqml2/declarativesurface.cpp
+++ b/src/datavisualizationqml2/declarativesurface.cpp
@@ -20,7 +20,6 @@
#include "declarativesurfacerenderer_p.h"
#include "q3dvalueaxis.h"
#include "qitemmodelsurfacedataproxy.h"
-#include "theme_p.h"
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
diff --git a/tests/barstest/chart.cpp b/tests/barstest/chart.cpp
index dda3aee4..14990640 100644
--- a/tests/barstest/chart.cpp
+++ b/tests/barstest/chart.cpp
@@ -22,14 +22,16 @@
#include <QtDataVisualization/qbardataproxy.h>
#include <QtDataVisualization/q3dscene.h>
#include <QtDataVisualization/q3dcamera.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <QTime>
QT_DATAVISUALIZATION_USE_NAMESPACE
const QString celsiusString = QString(QChar(0xB0)) + "C";
-GraphModifier::GraphModifier(Q3DBars *barchart)
- : m_chart(barchart),
+GraphModifier::GraphModifier(Q3DBars *barchart, QColorDialog *colorDialog)
+ : m_graph(barchart),
+ m_colorDialog(colorDialog),
m_columnCount(21),
m_rowCount(21),
m_xRotation(0.0),
@@ -101,30 +103,30 @@ GraphModifier::GraphModifier(Q3DBars *barchart)
m_monthAxis->setTitle("Month");
- m_chart->addAxis(m_autoAdjustingAxis);
- m_chart->addAxis(m_fixedRangeAxis);
- m_chart->addAxis(m_temperatureAxis);
- m_chart->addAxis(m_yearAxis);
- m_chart->addAxis(m_monthAxis);
- m_chart->addAxis(m_genericRowAxis);
- m_chart->addAxis(m_genericColumnAxis);
+ m_graph->addAxis(m_autoAdjustingAxis);
+ m_graph->addAxis(m_fixedRangeAxis);
+ m_graph->addAxis(m_temperatureAxis);
+ m_graph->addAxis(m_yearAxis);
+ m_graph->addAxis(m_monthAxis);
+ m_graph->addAxis(m_genericRowAxis);
+ m_graph->addAxis(m_genericColumnAxis);
- m_chart->setTheme(QDataVis::ThemeStoneMoss);
- m_chart->setShadowQuality(QDataVis::ShadowQualitySoftMedium);
+ m_graph->setTheme(new Q3DTheme(QDataVis::ThemeStoneMoss));
+ m_graph->setShadowQuality(QDataVis::ShadowQualitySoftMedium);
m_temperatureData->setItemLabelFormat(QStringLiteral("1: @valueTitle for @colLabel @rowLabel: @valueLabel"));
m_temperatureData2->setItemLabelFormat(QStringLiteral("2: @valueTitle for @colLabel @rowLabel: @valueLabel"));
m_genericData->setItemLabelFormat(QStringLiteral("3: @valueTitle for (@rowIdx, @colIdx): @valueLabel"));
m_genericData->dataProxy()->setColumnLabels(genericColumnLabels);
- m_chart->setFont(QFont("Times Roman", 20));
+ m_graph->setFont(QFont("Times Roman", 20));
// Release and store the default input handler.
- m_defaultInputHandler = m_chart->activeInputHandler();
- m_chart->releaseInputHandler(m_defaultInputHandler);
- m_chart->setActiveInputHandler(m_defaultInputHandler);
+ m_defaultInputHandler = m_graph->activeInputHandler();
+ m_graph->releaseInputHandler(m_defaultInputHandler);
+ m_graph->setActiveInputHandler(m_defaultInputHandler);
- QObject::connect(m_chart, &Q3DBars::shadowQualityChanged, this,
+ QObject::connect(m_graph, &Q3DBars::shadowQualityChanged, this,
&GraphModifier::shadowQualityUpdatedByVisual);
QObject::connect(m_temperatureData, &QBar3DSeries::selectedBarChanged, this,
&GraphModifier::handleSelectionChange);
@@ -133,15 +135,15 @@ GraphModifier::GraphModifier(Q3DBars *barchart)
QObject::connect(m_genericData, &QBar3DSeries::selectedBarChanged, this,
&GraphModifier::handleSelectionChange);
- m_chart->addSeries(m_temperatureData);
- m_chart->addSeries(m_temperatureData2);
+ m_graph->addSeries(m_temperatureData);
+ m_graph->addSeries(m_temperatureData2);
resetTemperatureData();
}
GraphModifier::~GraphModifier()
{
- delete m_chart;
+ delete m_graph;
delete m_defaultInputHandler;
}
@@ -155,24 +157,24 @@ void GraphModifier::restart(bool dynamicData)
m_static = !dynamicData;
if (m_static) {
- m_chart->removeSeries(m_genericData);
+ m_graph->removeSeries(m_genericData);
- m_chart->setTitle(QStringLiteral("Average temperatures in Oulu, Finland (2006-2012)"));
+ m_graph->setTitle(QStringLiteral("Average temperatures in Oulu, Finland (2006-2012)"));
- m_chart->setValueAxis(m_temperatureAxis);
- m_chart->setRowAxis(m_yearAxis);
- m_chart->setColumnAxis(m_monthAxis);
+ m_graph->setValueAxis(m_temperatureAxis);
+ m_graph->setRowAxis(m_yearAxis);
+ m_graph->setColumnAxis(m_monthAxis);
} else {
- m_chart->addSeries(m_genericData);
+ m_graph->addSeries(m_genericData);
- m_chart->setTitle(QStringLiteral("Generic data"));
+ m_graph->setTitle(QStringLiteral("Generic data"));
m_minval = m_fixedRangeAxis->min();
m_maxval = m_fixedRangeAxis->max();
- m_chart->setValueAxis(m_currentAxis);
- m_chart->setRowAxis(m_genericRowAxis);
- m_chart->setColumnAxis(m_genericColumnAxis);
+ m_graph->setValueAxis(m_currentAxis);
+ m_graph->setRowAxis(m_genericRowAxis);
+ m_graph->setColumnAxis(m_genericColumnAxis);
}
}
@@ -181,9 +183,9 @@ void GraphModifier::selectBar()
QPoint targetBar(5, 5);
QPoint noSelection(-1, -1);
if (m_selectedBar != targetBar)
- m_chart->seriesList().at(0)->setSelectedBar(targetBar);
+ m_graph->seriesList().at(0)->setSelectedBar(targetBar);
else
- m_chart->seriesList().at(0)->setSelectedBar(noSelection);
+ m_graph->seriesList().at(0)->setSelectedBar(noSelection);
}
void GraphModifier::swapAxis()
@@ -202,7 +204,7 @@ void GraphModifier::swapAxis()
qDebug() << "default axis";
}
- m_chart->setValueAxis(m_currentAxis);
+ m_graph->setValueAxis(m_currentAxis);
}
void GraphModifier::releaseAxes()
@@ -210,32 +212,32 @@ void GraphModifier::releaseAxes()
// Releases all axes - results in default axes for all dimensions.
// Axes reset when the graph is switched as set*Axis calls are made, which
// implicitly add axes.
- m_chart->releaseAxis(m_autoAdjustingAxis);
- m_chart->releaseAxis(m_fixedRangeAxis);
- m_chart->releaseAxis(m_temperatureAxis);
- m_chart->releaseAxis(m_yearAxis);
- m_chart->releaseAxis(m_monthAxis);
- m_chart->releaseAxis(m_genericRowAxis);
- m_chart->releaseAxis(m_genericColumnAxis);
+ m_graph->releaseAxis(m_autoAdjustingAxis);
+ m_graph->releaseAxis(m_fixedRangeAxis);
+ m_graph->releaseAxis(m_temperatureAxis);
+ m_graph->releaseAxis(m_yearAxis);
+ m_graph->releaseAxis(m_monthAxis);
+ m_graph->releaseAxis(m_genericRowAxis);
+ m_graph->releaseAxis(m_genericColumnAxis);
}
void GraphModifier::releaseProxies()
{
// Releases all series/add all series toggle
- if (m_chart->seriesList().size() > 0) {
- m_chart->removeSeries(m_temperatureData);
- m_chart->removeSeries(m_temperatureData2);
- m_chart->removeSeries(m_genericData);
+ if (m_graph->seriesList().size() > 0) {
+ m_graph->removeSeries(m_temperatureData);
+ m_graph->removeSeries(m_temperatureData2);
+ m_graph->removeSeries(m_genericData);
} else {
- m_chart->addSeries(m_temperatureData);
- m_chart->addSeries(m_temperatureData2);
- m_chart->addSeries(m_genericData);
+ m_graph->addSeries(m_temperatureData);
+ m_graph->addSeries(m_temperatureData2);
+ m_graph->addSeries(m_genericData);
}
}
void GraphModifier::flipViews()
{
- m_chart->scene()->setSecondarySubviewOnTop(!m_chart->scene()->isSecondarySubviewOnTop());
+ m_graph->scene()->setSecondarySubviewOnTop(!m_graph->scene()->isSecondarySubviewOnTop());
}
void GraphModifier::createMassiveArray()
@@ -464,34 +466,34 @@ void GraphModifier::changeStyle()
static int model = 0;
switch (model) {
case 0:
- m_chart->setBarType(QDataVis::MeshStyleCylinders, false);
+ m_graph->setBarType(QDataVis::MeshStyleCylinders, false);
break;
case 1:
- m_chart->setBarType(QDataVis::MeshStyleCylinders, true);
+ m_graph->setBarType(QDataVis::MeshStyleCylinders, true);
break;
case 2:
- m_chart->setBarType(QDataVis::MeshStyleCones, false);
+ m_graph->setBarType(QDataVis::MeshStyleCones, false);
break;
case 3:
- m_chart->setBarType(QDataVis::MeshStyleCones, true);
+ m_graph->setBarType(QDataVis::MeshStyleCones, true);
break;
case 4:
- m_chart->setBarType(QDataVis::MeshStyleBars, false);
+ m_graph->setBarType(QDataVis::MeshStyleBars, false);
break;
case 5:
- m_chart->setBarType(QDataVis::MeshStyleBars, true);
+ m_graph->setBarType(QDataVis::MeshStyleBars, true);
break;
case 6:
- m_chart->setBarType(QDataVis::MeshStylePyramids, false);
+ m_graph->setBarType(QDataVis::MeshStylePyramids, false);
break;
case 7:
- m_chart->setBarType(QDataVis::MeshStylePyramids, true);
+ m_graph->setBarType(QDataVis::MeshStylePyramids, true);
break;
case 8:
- m_chart->setBarType(QDataVis::MeshStyleBevelBars, false);
+ m_graph->setBarType(QDataVis::MeshStyleBevelBars, false);
break;
case 9:
- m_chart->setBarType(QDataVis::MeshStyleBevelBars, true);
+ m_graph->setBarType(QDataVis::MeshStyleBevelBars, true);
break;
}
model++;
@@ -503,7 +505,7 @@ void GraphModifier::changePresetCamera()
{
static int preset = QDataVis::CameraPresetFrontLow;
- m_chart->scene()->activeCamera()->setCameraPreset((QDataVis::CameraPreset)preset);
+ m_graph->scene()->activeCamera()->setCameraPreset((QDataVis::CameraPreset)preset);
if (++preset > QDataVis::CameraPresetDirectlyBelow)
preset = QDataVis::CameraPresetFrontLow;
@@ -513,7 +515,7 @@ void GraphModifier::changeTheme()
{
static int theme = QDataVis::ThemeQt;
- m_chart->setTheme((QDataVis::Theme)theme);
+ m_graph->setTheme(new Q3DTheme((QDataVis::Theme)theme));
if (++theme > QDataVis::ThemeIsabelle)
theme = QDataVis::ThemeQt;
@@ -523,7 +525,7 @@ void GraphModifier::changeLabelStyle()
{
static int style = QDataVis::LabelStyleOpaque;
- m_chart->setLabelStyle((QDataVis::LabelStyle)style);
+ m_graph->setLabelStyle((QDataVis::LabelStyle)style);
if (++style > QDataVis::LabelStyleTransparent)
style = QDataVis::LabelStyleOpaque;
@@ -531,27 +533,27 @@ void GraphModifier::changeLabelStyle()
void GraphModifier::changeSelectionMode()
{
- static int selectionMode = m_chart->selectionMode();
+ static int selectionMode = m_graph->selectionMode();
if (++selectionMode > (QDataVis::SelectionItemAndColumn | QDataVis::SelectionSlice | QDataVis::SelectionMultiSeries))
selectionMode = QDataVis::SelectionNone;
- m_chart->setSelectionMode((QDataVis::SelectionFlag)selectionMode);
+ m_graph->setSelectionMode((QDataVis::SelectionFlag)selectionMode);
}
void GraphModifier::changeFont(const QFont &font)
{
QFont newFont = font;
newFont.setPointSize(m_fontSize);
- m_chart->setFont(newFont);
+ m_graph->setFont(newFont);
}
void GraphModifier::changeFontSize(int fontsize)
{
m_fontSize = fontsize;
- QFont font = m_chart->font();
+ QFont font = m_graph->font();
font.setPointSize(m_fontSize);
- m_chart->setFont(font);
+ m_graph->setFont(font);
}
void GraphModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq)
@@ -565,7 +567,7 @@ void GraphModifier::handleSelectionChange(const QPoint &position)
{
m_selectedBar = position;
int index = 0;
- foreach (QBar3DSeries *series, m_chart->seriesList()) {
+ foreach (QBar3DSeries *series, m_graph->seriesList()) {
if (series == sender())
break;
index++;
@@ -583,56 +585,56 @@ void GraphModifier::setUseNullInputHandler(bool useNull)
m_useNullInputHandler = useNull;
if (useNull)
- m_chart->setActiveInputHandler(0);
+ m_graph->setActiveInputHandler(0);
else
- m_chart->setActiveInputHandler(m_defaultInputHandler);
+ m_graph->setActiveInputHandler(m_defaultInputHandler);
}
void GraphModifier::changeShadowQuality(int quality)
{
QDataVis::ShadowQuality sq = QDataVis::ShadowQuality(quality);
- m_chart->setShadowQuality(sq);
+ m_graph->setShadowQuality(sq);
emit shadowQualityChanged(quality);
}
void GraphModifier::setBackgroundEnabled(int enabled)
{
- m_chart->setBackgroundVisible((bool)enabled);
+ m_graph->setBackgroundVisible((bool)enabled);
}
void GraphModifier::setGridEnabled(int enabled)
{
- m_chart->setGridVisible((bool)enabled);
+ m_graph->setGridVisible((bool)enabled);
}
void GraphModifier::rotateX(int rotation)
{
m_xRotation = rotation;
- m_chart->scene()->activeCamera()->setCameraPosition(m_xRotation, m_yRotation);
+ m_graph->scene()->activeCamera()->setCameraPosition(m_xRotation, m_yRotation);
}
void GraphModifier::rotateY(int rotation)
{
m_yRotation = rotation;
- m_chart->scene()->activeCamera()->setCameraPosition(m_xRotation, m_yRotation);
+ m_graph->scene()->activeCamera()->setCameraPosition(m_xRotation, m_yRotation);
}
void GraphModifier::setSpecsRatio(int barwidth)
{
- m_chart->setBarThickness((qreal)barwidth / 30.0);
+ m_graph->setBarThickness((qreal)barwidth / 30.0);
}
void GraphModifier::setSpacingSpecsX(int spacing)
{
m_barSpacingX = (qreal)spacing / 100.0;
- m_chart->setBarSpacing(QSizeF(m_barSpacingX, m_barSpacingZ));
+ m_graph->setBarSpacing(QSizeF(m_barSpacingX, m_barSpacingZ));
}
void GraphModifier::setSpacingSpecsZ(int spacing)
{
m_barSpacingZ = (qreal)spacing / 100.0;
- m_chart->setBarSpacing(QSizeF(m_barSpacingX, m_barSpacingZ));
+ m_graph->setBarSpacing(QSizeF(m_barSpacingX, m_barSpacingZ));
}
void GraphModifier::setSampleCountX(int samples)
@@ -670,6 +672,34 @@ void GraphModifier::setMaxY(int max)
m_maxval = max;
}
+void GraphModifier::useOwnTheme()
+{
+ Q3DTheme *theme = new Q3DTheme();
+ theme->setAmbientLightStrength(0.3f);
+ theme->setBackgroundColor(QColor(QRgb(0x99ca53)));
+ theme->setBaseColor(QColor(QRgb(0x209fdf)));
+ theme->setColorStyle(QDataVis::ColorStyleUniform);
+ theme->setGridLineColor(QColor(QRgb(0x99ca53)));
+ theme->setHighlightLightStrength(7.0f);
+ theme->setLabelBorderEnabled(false);
+ theme->setLightColor(Qt::white);
+ theme->setLightStrength(6.0f);
+ theme->setMultiHighlightColor(QColor(QRgb(0x6d5fd5)));
+ theme->setSingleHighlightColor(QColor(QRgb(0xf6a625)));
+ theme->setTextBackgroundColor(QColor(0xf6, 0xa6, 0x25, 0xa0));
+ theme->setTextColor(QColor(QRgb(0x404044)));
+ theme->setWindowColor(QColor(QRgb(0xffffff)));
+
+ m_graph->setTheme(theme);
+
+ m_colorDialog->open();
+}
+
+void GraphModifier::changeBaseColor(const QColor &color)
+{
+ qDebug() << "base color changed to" << color;
+ m_graph->theme()->setBaseColor(color);
+}
void GraphModifier::setGradient()
{
@@ -697,19 +727,19 @@ void GraphModifier::setGradient()
multiHighlightGradient.setColorAt(0.25, Qt::darkYellow);
multiHighlightGradient.setColorAt(0.0, Qt::darkGray);
- m_chart->setBarColor(Qt::green);
- m_chart->setSingleHighlightColor(Qt::white);
- m_chart->setMultiHighlightColor(Qt::cyan);
+ m_graph->setBarColor(Qt::green);
+ m_graph->setSingleHighlightColor(Qt::white);
+ m_graph->setMultiHighlightColor(Qt::cyan);
- m_chart->setBarGradient(barGradient);
- m_chart->setSingleHighlightGradient(singleHighlightGradient);
- m_chart->setMultiHighlightGradient(multiHighlightGradient);
+ m_graph->setBarGradient(barGradient);
+ m_graph->setSingleHighlightGradient(singleHighlightGradient);
+ m_graph->setMultiHighlightGradient(multiHighlightGradient);
- QDataVis::ColorStyle oldStyle = m_chart->colorStyle();
+ QDataVis::ColorStyle oldStyle = m_graph->colorStyle();
if (oldStyle == QDataVis::ColorStyleUniform)
- m_chart->setColorStyle(QDataVis::ColorStyleObjectGradient);
+ m_graph->setColorStyle(QDataVis::ColorStyleObjectGradient);
else if (oldStyle == QDataVis::ColorStyleObjectGradient)
- m_chart->setColorStyle(QDataVis::ColorStyleRangeGradient);
+ m_graph->setColorStyle(QDataVis::ColorStyleRangeGradient);
if (oldStyle == QDataVis::ColorStyleRangeGradient)
- m_chart->setColorStyle(QDataVis::ColorStyleUniform);
+ m_graph->setColorStyle(QDataVis::ColorStyleUniform);
}
diff --git a/tests/barstest/chart.h b/tests/barstest/chart.h
index a9d6119b..7db8f1bd 100644
--- a/tests/barstest/chart.h
+++ b/tests/barstest/chart.h
@@ -26,6 +26,7 @@
#include <QDebug>
#include <QStringList>
#include <QPointer>
+#include <QColorDialog>
using namespace QtDataVisualization;
@@ -33,7 +34,7 @@ class GraphModifier : public QObject
{
Q_OBJECT
public:
- explicit GraphModifier(Q3DBars *barchart);
+ explicit GraphModifier(Q3DBars *barchart, QColorDialog *colorDialog);
~GraphModifier();
void resetTemperatureData();
@@ -74,6 +75,8 @@ public:
void releaseAxes();
void releaseProxies();
void createMassiveArray();
+ void useOwnTheme();
+ void changeBaseColor(const QColor &color);
public slots:
void flipViews();
@@ -87,7 +90,8 @@ signals:
void shadowQualityChanged(int quality);
private:
- Q3DBars *m_chart;
+ Q3DBars *m_graph;
+ QColorDialog *m_colorDialog;
int m_columnCount;
int m_rowCount;
qreal m_xRotation;
diff --git a/tests/barstest/main.cpp b/tests/barstest/main.cpp
index 158aae15..2644cae9 100644
--- a/tests/barstest/main.cpp
+++ b/tests/barstest/main.cpp
@@ -31,6 +31,7 @@
#include <QFontDatabase>
#include <QLinearGradient>
#include <QPainter>
+#include <QColorDialog>
int main(int argc, char **argv)
{
@@ -130,6 +131,12 @@ int main(int argc, char **argv)
flipViewsButton->setText(QStringLiteral("Flip views"));
flipViewsButton->setEnabled(true);
+ QPushButton *ownThemeButton = new QPushButton(widget);
+ ownThemeButton->setText(QStringLiteral("Use own theme"));
+ ownThemeButton->setEnabled(true);
+
+ QColorDialog *colorDialog = new QColorDialog(widget);
+
QLinearGradient grBtoY(0, 0, 100, 0);
grBtoY.setColorAt(1.0, Qt::black);
grBtoY.setColorAt(0.67, Qt::blue);
@@ -269,6 +276,8 @@ int main(int argc, char **argv)
vLayout->addWidget(releaseAxesButton, 0, Qt::AlignTop);
vLayout->addWidget(releaseProxiesButton, 1, Qt::AlignTop);
vLayout->addWidget(flipViewsButton, 0, Qt::AlignTop);
+ vLayout->addWidget(ownThemeButton, 0, Qt::AlignTop);
+ vLayout->addWidget(colorDialog, 0, Qt::AlignTop);
vLayout->addWidget(gradientBtoYPB, 1, Qt::AlignTop);
vLayout2->addWidget(staticCheckBox, 0, Qt::AlignTop);
@@ -300,7 +309,7 @@ int main(int argc, char **argv)
widget->show();
- GraphModifier *modifier = new GraphModifier(widgetchart);
+ GraphModifier *modifier = new GraphModifier(widgetchart, colorDialog);
QObject::connect(rotationSliderX, &QSlider::valueChanged, modifier, &GraphModifier::rotateX);
QObject::connect(rotationSliderY, &QSlider::valueChanged, modifier, &GraphModifier::rotateY);
@@ -361,6 +370,10 @@ int main(int argc, char **argv)
QObject::connect(flipViewsButton, &QPushButton::clicked, modifier,
&GraphModifier::flipViews);
+ QObject::connect(ownThemeButton, &QPushButton::clicked, modifier,
+ &GraphModifier::useOwnTheme);
+ QObject::connect(colorDialog, &QColorDialog::currentColorChanged, modifier,
+ &GraphModifier::changeBaseColor);
QObject::connect(gradientBtoYPB, &QPushButton::clicked, modifier,
&GraphModifier::setGradient);
diff --git a/tests/multigraphs/data.cpp b/tests/multigraphs/data.cpp
index a488a276..f69c296e 100644
--- a/tests/multigraphs/data.cpp
+++ b/tests/multigraphs/data.cpp
@@ -24,6 +24,7 @@
#include <QtDataVisualization/QBar3DSeries>
#include <QtDataVisualization/QScatter3DSeries>
#include <QtDataVisualization/QSurface3DSeries>
+#include <QtDataVisualization/Q3DTheme>
#include <QScrollBar>
#include <QSize>
#include <QImage>
@@ -44,7 +45,7 @@ Data::Data(Q3DSurface *surface, Q3DScatter *scatter, Q3DBars *bars,
m_started(false)
{
// Initialize surface
- m_surface->setTheme(QDataVis::ThemeIsabelle);
+ m_surface->setTheme(new Q3DTheme(QDataVis::ThemeIsabelle));
QLinearGradient gradient;
gradient.setColorAt(0.0, Qt::black);
gradient.setColorAt(0.33, Qt::blue);
@@ -60,7 +61,7 @@ Data::Data(Q3DSurface *surface, Q3DScatter *scatter, Q3DBars *bars,
m_surface->addSeries(new QSurface3DSeries(new QHeightMapSurfaceDataProxy()));
// Initialize scatter
- m_scatter->setTheme(QDataVis::ThemeStoneMoss);
+ m_scatter->setTheme(new Q3DTheme(QDataVis::ThemeStoneMoss));
m_scatter->setSelectionMode(QDataVis::SelectionNone);
m_scatter->setGridVisible(false);
m_scatter->setObjectType(QDataVis::MeshStylePoints);
@@ -69,7 +70,7 @@ Data::Data(Q3DSurface *surface, Q3DScatter *scatter, Q3DBars *bars,
m_scatter->addSeries(new QScatter3DSeries);
// Initialize bars
- m_bars->setTheme(QDataVis::ThemeQt);
+ m_bars->setTheme(new Q3DTheme(QDataVis::ThemeQt));
m_bars->setSelectionMode(QDataVis::SelectionItemAndRow | QDataVis::SelectionSlice);
m_bars->setGridVisible(false);
m_bars->setBarType(QDataVis::MeshStyleBars, false);
@@ -179,7 +180,7 @@ void Data::scrollDown()
void Data::useGradientOne()
{
- m_surface->setTheme(QDataVis::ThemeIsabelle);
+ m_surface->setTheme(new Q3DTheme(QDataVis::ThemeIsabelle));
QLinearGradient gradient;
gradient.setColorAt(0.0, Qt::black);
gradient.setColorAt(0.33, Qt::blue);
@@ -191,7 +192,7 @@ void Data::useGradientOne()
void Data::useGradientTwo()
{
- m_surface->setTheme(QDataVis::ThemeQt);
+ m_surface->setTheme(new Q3DTheme(QDataVis::ThemeQt));
QLinearGradient gradient;
gradient.setColorAt(0.0, Qt::white);
gradient.setColorAt(0.8, Qt::red);
diff --git a/tests/qmlcamera/qml/qmlcamera/main.qml b/tests/qmlcamera/qml/qmlcamera/main.qml
index 705f284d..5b80abfd 100644
--- a/tests/qmlcamera/qml/qmlcamera/main.qml
+++ b/tests/qmlcamera/qml/qmlcamera/main.qml
@@ -48,7 +48,7 @@ Item {
shadowQuality: Bars3D.ShadowQualityMedium
selectionMode: Bars3D.SelectionItem
font.pointSize: 35
- theme: Bars3D.ThemeRetro
+ theme: Theme3D { type: Bars3D.ThemeRetro }
labelStyle: Bars3D.LabelStyleFromTheme
seriesList: [chartData.series]
barThickness: 0.5
diff --git a/tests/scattertest/scatterchart.cpp b/tests/scattertest/scatterchart.cpp
index 6b809198..eba69888 100644
--- a/tests/scattertest/scatterchart.cpp
+++ b/tests/scattertest/scatterchart.cpp
@@ -22,6 +22,7 @@
#include <QtDataVisualization/q3dvalueaxis.h>
#include <QtDataVisualization/q3dscene.h>
#include <QtDataVisualization/q3dcamera.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <qmath.h>
using namespace QtDataVisualization;
@@ -40,7 +41,7 @@ ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter)
font.setPointSize(m_fontSize);
m_chart->setFont(font);
m_chart->setObjectType(QDataVis::MeshStyleSpheres, true);
- m_chart->setTheme(QDataVis::ThemeStoneMoss);
+ m_chart->setTheme(new Q3DTheme(QDataVis::ThemeStoneMoss));
m_chart->setShadowQuality(QDataVis::ShadowQualityNone);
m_chart->scene()->activeCamera()->setCameraPreset(QDataVis::CameraPresetFront);
m_chart->setAxisX(new Q3DValueAxis);
@@ -146,7 +147,7 @@ void ScatterDataModifier::changeTheme()
{
static int theme = QDataVis::ThemeQt;
- m_chart->setTheme((QDataVis::Theme)theme);
+ m_chart->setTheme(new Q3DTheme(QDataVis::Theme(theme)));
if (++theme > QDataVis::ThemeIsabelle)
theme = QDataVis::ThemeQt;
diff --git a/tests/surfacetest/graphmodifier.cpp b/tests/surfacetest/graphmodifier.cpp
index 4365e055..d415b9af 100644
--- a/tests/surfacetest/graphmodifier.cpp
+++ b/tests/surfacetest/graphmodifier.cpp
@@ -20,6 +20,7 @@
#include <QtDataVisualization/Q3DValueAxis>
#include <QtDataVisualization/QSurfaceDataProxy>
#include <QtDataVisualization/QSurface3DSeries>
+#include <QtDataVisualization/Q3DTheme>
#include <qmath.h>
#include <QLinearGradient>
@@ -334,7 +335,7 @@ void GraphModifier::selectedPointChanged(const QPoint &point)
void GraphModifier::changeTheme(int theme)
{
- m_graph->setTheme((QDataVis::Theme)theme);
+ m_graph->setTheme(new Q3DTheme(QDataVis::Theme(theme)));
}
diff --git a/tests/surfacetest/main.cpp b/tests/surfacetest/main.cpp
index fc33a4cf..acb6fa37 100644
--- a/tests/surfacetest/main.cpp
+++ b/tests/surfacetest/main.cpp
@@ -17,6 +17,7 @@
****************************************************************************/
#include "graphmodifier.h"
+#include <QtDataVisualization/q3dtheme.h>
#include <QApplication>
#include <QWidget>
@@ -49,7 +50,7 @@ int main(int argc, char *argv[])
QSize screenSize = surfaceGraph->screen()->size();
// Set to default, should be same as the initial on themeList
- surfaceGraph->setTheme(QDataVis::Theme(initialTheme));
+ surfaceGraph->setTheme(new Q3DTheme(QDataVis::Theme(initialTheme)));
QWidget *container = QWidget::createWindowContainer(surfaceGraph);
container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 2));