summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-12-02 08:43:02 +0200
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-12-02 09:01:25 +0200
commit94235c2e633845951ce6c947965789bb3f8ee7c4 (patch)
tree60f902b9defe670736dff4bf33d13ef5bfb57804 /src
parent91c9f6791af049b873b7c60a88aa226eaec70c18 (diff)
Theme documented
Task-number: QTRD-2633 Change-Id: Ib274ec236f50145df8fd4c2d83f62d4a9154687a Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavisualization/data/qabstract3dseries.h2
-rw-r--r--src/datavisualization/doc/snippets/doc_src_q3dtheme.cpp113
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-index.qdoc2
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc24
-rw-r--r--src/datavisualization/engine/abstract3dcontroller.cpp14
-rw-r--r--src/datavisualization/engine/abstract3dcontroller_p.h18
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp10
-rw-r--r--src/datavisualization/engine/abstract3drenderer_p.h4
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp28
-rw-r--r--src/datavisualization/engine/drawer.cpp4
-rw-r--r--src/datavisualization/engine/q3dbars.cpp10
-rw-r--r--src/datavisualization/engine/q3dbars.h10
-rw-r--r--src/datavisualization/engine/q3dscatter.cpp8
-rw-r--r--src/datavisualization/engine/q3dscatter.h9
-rw-r--r--src/datavisualization/engine/q3dsurface.cpp4
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp12
-rw-r--r--src/datavisualization/global/qdatavisualizationenums.h23
-rw-r--r--src/datavisualization/global/qtdatavisualizationenums.qdoc44
-rw-r--r--src/datavisualization/theme/q3dtheme.cpp590
-rw-r--r--src/datavisualization/theme/q3dtheme.h63
-rw-r--r--src/datavisualization/theme/q3dtheme_p.h17
-rw-r--r--src/datavisualization/theme/thememanager.cpp52
-rw-r--r--src/datavisualization/theme/thememanager_p.h4
23 files changed, 798 insertions, 267 deletions
diff --git a/src/datavisualization/data/qabstract3dseries.h b/src/datavisualization/data/qabstract3dseries.h
index 4d971749..58346bec 100644
--- a/src/datavisualization/data/qabstract3dseries.h
+++ b/src/datavisualization/data/qabstract3dseries.h
@@ -94,7 +94,7 @@ signals:
protected:
QScopedPointer<QAbstract3DSeriesPrivate> d_ptr;
-// QDataVis::ColorStyle m_colorStyle;
+// Q3DTheme::ColorStyle m_colorStyle;
// QColor m_objectColor;
// QLinearGradient m_objectGradient;
// QColor m_singleHighlightColor;
diff --git a/src/datavisualization/doc/snippets/doc_src_q3dtheme.cpp b/src/datavisualization/doc/snippets/doc_src_q3dtheme.cpp
new file mode 100644
index 00000000..5a539e62
--- /dev/null
+++ b/src/datavisualization/doc/snippets/doc_src_q3dtheme.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** 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 <QtDataVisualization/Q3DBars>
+#include <QtDataVisualization/Q3DTheme>
+
+using namespace QtDataVisualization;
+
+int main(int argc, char **argv)
+{
+ //! [0]
+ Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeQt);
+ //! [0]
+
+ //! [1]
+ Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeQt);
+ theme->setBackgroundEnabled(false);
+ theme->setLabelBackgroundEnabled(false);
+ //! [1]
+
+ //! [2]
+ Q3DTheme *theme = new Q3DTheme();
+ theme->setAmbientLightStrength(0.3f);
+ theme->setBackgroundColor(QColor(QRgb(0x99ca53)));
+ theme->setBackgroundEnabled(true);
+ theme->setBaseColor(QColor(QRgb(0x209fdf)));
+ theme->setColorStyle(Q3DTheme::ColorStyleUniform);
+ theme->setFont(QFont(QStringLiteral("Impact"), 35));
+ theme->setGridEnabled(true);
+ theme->setGridLineColor(QColor(QRgb(0x99ca53)));
+ theme->setHighlightLightStrength(7.0f);
+ theme->setLabelBackgroundColor(QColor(0xf6, 0xa6, 0x25, 0xa0));
+ theme->setLabelBackgroundEnabled(true);
+ theme->setLabelBorderEnabled(true);
+ theme->setLabelTextColor(QColor(QRgb(0x404044)));
+ theme->setLightColor(Qt::white);
+ theme->setLightStrength(6.0f);
+ theme->setMultiHighlightColor(QColor(QRgb(0x6d5fd5)));
+ theme->setSingleHighlightColor(QColor(QRgb(0xf6a625)));
+ theme->setWindowColor(QColor(QRgb(0xffffff)));
+ //! [2]
+
+ //! [3]
+ Q3DBars *graph = new Q3DBars();
+ graph->setTheme(new Q3DTheme(Q3DTheme::ThemePrimaryColors));
+ graph->theme()->setBaseColor(Qt::red);
+ graph->theme()->setSingleHighlightColor(Qt::yellow);
+ //! [3]
+}
+
+//! [4]
+Scatter3D {
+ ...
+ theme: Theme3D { type: Theme3D.ThemeRetro }
+ ...
+}
+//! [4]
+
+//! [5]
+Bars3D {
+ ...
+ theme: Theme3D {
+ type: Theme3D.ThemeRetro
+ labelBorderEnabled: true
+ font.pointSize: 35
+ labelBackgroundEnabled: false
+ }
+ ...
+}
+//! [5]
+
+//! [6]
+Surface3D {
+ ...
+ theme: Theme3D {
+ ambientLightStrength: 0.5
+ backgroundColor: "red"
+ backgroundEnabled: true
+ baseColor: "blue"
+ colorStyle: Theme3D.ColorStyleUniform
+ font.family: "Lucida Handwriting"
+ font.pointSize: 35
+ gridEnabled: false
+ gridLineColor: "black"
+ highlightLightStrength: 0.5
+ labelBackgroundColor: "black"
+ labelBackgroundEnabled: true
+ labelBorderEnabled: false
+ labelTextColor: "white"
+ lightColor: "yellow"
+ lightStrength: 0.4
+ multiHighlightColor: "green"
+ singleHighlightColor: "darkRed"
+ windowColor: "white"
+ }
+ ...
+}
+//! [6]
diff --git a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
index 456f8ac5..e09ef7dc 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
@@ -35,7 +35,7 @@
\li Customizable input handling (upcoming feature - not supported in technology preview)
\li Customizable scene handling - full control of cameras and lights (upcoming feature -
not supported in technology preview)
- \li Customizable themes (upcoming feature - not supported in technology preview)
+ \li Customizable themes
\endlist
\section1 Getting Started
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
index 989bcc9b..f0fa9e29 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
@@ -35,10 +35,6 @@
\qmlproperty AbstractGraph3D.SelectionMode AbstractGraph3D::selectionMode
Active selection mode in the visualization.
*/
-/*!
- \qmlproperty AbstractGraph3D.LabelStyle AbstractGraph3D::labelStyle
- Label style.
- */
/*!
\qmlproperty AbstractGraph3D.ShadowQuality AbstractGraph3D::shadowQuality
@@ -51,22 +47,6 @@
*/
/*!
- \qmlproperty AbstractGraph3D.Theme AbstractGraph3D::theme
- Theme of the graph. Theme affects visualization colors, label colors, text color, background color, window
- color and grid color. Lighting is also adjusted by themes.
- */
-
-/*!
- \qmlproperty font AbstractGraph3D::font
- Font used for labels.
- */
-
-/*!
- \qmlproperty bool AbstractGraph3D::gridVisible
- Grid visibility. If false, grid lines are not drawn.
- */
-
-/*!
- \qmlproperty bool AbstractGraph3D::backgroundVisible
- Background visibility. If false, background is not drawn.
+ \qmlproperty Theme3D AbstractGraph3D::theme
+ Theme of the graph.
*/
diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp
index b8b2e826..7820cb31 100644
--- a/src/datavisualization/engine/abstract3dcontroller.cpp
+++ b/src/datavisualization/engine/abstract3dcontroller.cpp
@@ -38,14 +38,10 @@ Abstract3DController::Abstract3DController(QRect boundRect, QObject *parent) :
QObject(parent),
m_boundingRect(boundRect.x(), boundRect.y(), boundRect.width(), boundRect.height()),
m_themeManager(new ThemeManager(this)),
- m_font(QFont(QStringLiteral("Arial"))),
m_selectionMode(QDataVis::SelectionItem),
m_shadowQuality(QDataVis::ShadowQualityMedium),
- m_labelBackground(false),
- m_isBackgroundEnabled(true),
- m_isGridEnabled(true),
m_scene(new Q3DScene()),
- m_colorStyle(QDataVis::ColorStyleUniform),
+ m_colorStyle(Q3DTheme::ColorStyleUniform),
m_activeInputHandler(0),
m_axisX(0),
m_axisY(0),
@@ -57,7 +53,7 @@ Abstract3DController::Abstract3DController(QRect boundRect, QObject *parent) :
m_renderPending(false)
{
// Set initial theme
- setTheme(new Q3DTheme(QDataVis::ThemeQt));
+ setTheme(new Q3DTheme(Q3DTheme::ThemeQt));
// Populate the scene
m_scene->activeLight()->setPosition(defaultLightPos);
@@ -660,11 +656,11 @@ void Abstract3DController::setZoomLevel(int zoomLevel)
emitNeedRender();
}
-void Abstract3DController::setColorStyle(QDataVis::ColorStyle style)
+void Abstract3DController::setColorStyle(Q3DTheme::ColorStyle style)
{
if (style != m_colorStyle || m_changeTracker.themeChanged) {
Q3DTheme *theme = m_themeManager->theme();
- if (style == QDataVis::ColorStyleUniform) {
+ if (style == Q3DTheme::ColorStyleUniform) {
setBaseColor(theme->baseColor());
setSingleHighlightColor(theme->singleHighlightColor());
setMultiHighlightColor(theme->multiHighlightColor());
@@ -682,7 +678,7 @@ void Abstract3DController::setColorStyle(QDataVis::ColorStyle style)
}
}
-QDataVis::ColorStyle Abstract3DController::colorStyle() const
+Q3DTheme::ColorStyle Abstract3DController::colorStyle() const
{
return m_colorStyle;
}
diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h
index 27cfb9a1..850bd3e5 100644
--- a/src/datavisualization/engine/abstract3dcontroller_p.h
+++ b/src/datavisualization/engine/abstract3dcontroller_p.h
@@ -53,14 +53,11 @@ struct Abstract3DChangeBitField {
bool positionChanged : 1;
bool zoomLevelChanged : 1;
bool themeChanged : 1;
- bool fontChanged : 1;
- bool labelBackgroundEnabledChanged : 1;
bool boundingRectChanged : 1;
bool sizeChanged : 1;
bool shadowQualityChanged : 1;
bool selectionModeChanged : 1;
bool objFileChanged : 1;
- bool gridEnabledChanged : 1;
bool axisXTypeChanged : 1;
bool axisYTypeChanged : 1;
bool axisZTypeChanged : 1;
@@ -96,14 +93,11 @@ struct Abstract3DChangeBitField {
positionChanged(true),
zoomLevelChanged(true),
themeChanged(true),
- fontChanged(true),
- labelBackgroundEnabledChanged(true),
boundingRectChanged(true),
sizeChanged(true),
shadowQualityChanged(true),
selectionModeChanged(true),
objFileChanged(true),
- gridEnabledChanged(true),
axisXTypeChanged(true),
axisYTypeChanged(true),
axisZTypeChanged(true),
@@ -164,14 +158,10 @@ private:
GLfloat m_horizontalRotation;
GLfloat m_verticalRotation;
ThemeManager *m_themeManager;
- QFont m_font;
QDataVis::SelectionFlags m_selectionMode;
QDataVis::ShadowQuality m_shadowQuality;
- bool m_labelBackground;
- bool m_isBackgroundEnabled;
- bool m_isGridEnabled;
Q3DScene *m_scene;
- QDataVis::ColorStyle m_colorStyle;
+ Q3DTheme::ColorStyle m_colorStyle;
QColor m_objectColor;
QLinearGradient m_objectGradient;
QColor m_singleHighlightColor;
@@ -256,8 +246,8 @@ public:
// Properties from color api
// TODO: Rethink these after color api has been moveed to series (QTRD-2200/2557)
- virtual void setColorStyle(QDataVis::ColorStyle style);
- virtual QDataVis::ColorStyle colorStyle() const;
+ virtual void setColorStyle(Q3DTheme::ColorStyle style);
+ virtual Q3DTheme::ColorStyle colorStyle() const;
virtual void setBaseColor(const QColor &color);
virtual QColor baseColor() const;
virtual void setBaseGradient(const QLinearGradient &gradient);
@@ -325,7 +315,7 @@ signals:
void themeChanged(Q3DTheme *theme);
void selectionModeChanged(QDataVis::SelectionFlags mode);
void needRender();
- void colorStyleChanged(QDataVis::ColorStyle style);
+ void colorStyleChanged(Q3DTheme::ColorStyle style);
void objectColorChanged(QColor color);
void objectGradientChanged(QLinearGradient gradient);
void singleHighlightColorChanged(QColor color);
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 7e17baff..06f13b5d 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -40,7 +40,7 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
m_cachedShadowQuality(QDataVis::ShadowQualityMedium),
m_autoScaleAdjustment(1.0f),
m_cachedSelectionMode(QDataVis::SelectionNone),
- m_cachedColorStyle(QDataVis::ColorStyleUniform),
+ m_cachedColorStyle(Q3DTheme::ColorStyleUniform),
m_objectGradientTexture(0),
m_singleHighlightGradientTexture(0),
m_multiHighlightGradientTexture(0),
@@ -207,7 +207,7 @@ void Abstract3DRenderer::reInitShaders()
{
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QDataVis::ShadowQualityNone) {
- if (m_cachedColorStyle != QDataVis::ColorStyleUniform) {
+ if (m_cachedColorStyle != Q3DTheme::ColorStyleUniform) {
initShaders(QStringLiteral(":/shaders/vertexShadow"),
QStringLiteral(":/shaders/fragmentShadowNoTexColorOnY"));
} else {
@@ -217,7 +217,7 @@ void Abstract3DRenderer::reInitShaders()
initBackgroundShaders(QStringLiteral(":/shaders/vertexShadow"),
QStringLiteral(":/shaders/fragmentShadowNoTex"));
} else {
- if (m_cachedColorStyle != QDataVis::ColorStyleUniform) {
+ if (m_cachedColorStyle != Q3DTheme::ColorStyleUniform) {
initShaders(QStringLiteral(":/shaders/vertex"),
QStringLiteral(":/shaders/fragmentColorOnY"));
} else {
@@ -228,7 +228,7 @@ void Abstract3DRenderer::reInitShaders()
QStringLiteral(":/shaders/fragment"));
}
#else
- if (m_cachedColorStyle != QDataVis::ColorStyleUniform) {
+ if (m_cachedColorStyle != Q3DTheme::ColorStyleUniform) {
initShaders(QStringLiteral(":/shaders/vertex"),
QStringLiteral(":/shaders/fragmentColorOnYES2"));
} else {
@@ -317,7 +317,7 @@ void Abstract3DRenderer::updateAxisLabelFormat(Q3DAbstractAxis::AxisOrientation
axisCacheForOrientation(orientation).setLabelFormat(format);
}
-void Abstract3DRenderer::updateColorStyle(QDataVis::ColorStyle style)
+void Abstract3DRenderer::updateColorStyle(Q3DTheme::ColorStyle style)
{
bool changed = (m_cachedColorStyle != style);
diff --git a/src/datavisualization/engine/abstract3drenderer_p.h b/src/datavisualization/engine/abstract3drenderer_p.h
index fe213b33..98e3face 100644
--- a/src/datavisualization/engine/abstract3drenderer_p.h
+++ b/src/datavisualization/engine/abstract3drenderer_p.h
@@ -68,7 +68,7 @@ protected:
QDataVis::SelectionFlags m_cachedSelectionMode;
- QDataVis::ColorStyle m_cachedColorStyle;
+ Q3DTheme::ColorStyle m_cachedColorStyle;
QColor m_cachedObjectColor;
QLinearGradient m_cachedObjectGradient;
GLuint m_objectGradientTexture;
@@ -131,7 +131,7 @@ public:
virtual void updateAxisSegmentCount(Q3DAbstractAxis::AxisOrientation orientation, int count);
virtual void updateAxisSubSegmentCount(Q3DAbstractAxis::AxisOrientation orientation, int count);
virtual void updateAxisLabelFormat(Q3DAbstractAxis::AxisOrientation orientation, const QString &format);
- virtual void updateColorStyle(QDataVis::ColorStyle style);
+ virtual void updateColorStyle(Q3DTheme::ColorStyle style);
virtual void updateObjectColor(const QColor &color);
virtual void updateObjectGradient(const QLinearGradient &gradient);
virtual void updateSingleHighlightColor(const QColor &color);
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index addad904..e665eca1 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -471,9 +471,9 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
m_barShader->setUniformValue(m_barShader->lightS(), 0.5f);
m_barShader->setUniformValue(m_barShader->ambientS(),
m_cachedTheme->ambientLightStrength() * 2.0f);
- if (m_cachedColorStyle != QDataVis::ColorStyleUniform) {
+ if (m_cachedColorStyle != Q3DTheme::ColorStyleUniform) {
m_barShader->setUniformValue(m_barShader->gradientMin(), 0.0f);
- if (m_cachedColorStyle == QDataVis::ColorStyleObjectGradient)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleObjectGradient)
m_barShader->setUniformValue(m_barShader->gradientHeight(), 0.5f);
gradientTexture = m_objectGradientTexture;
@@ -516,12 +516,12 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
// TODO: Get color from correct series
if (itemMode && m_visualSelectedBarPos.x() == item->position().x()
&& m_visualSelectedBarPos.y() == item->position().y()) {
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform)
barColor = barHighlightColor;
else
gradientTexture = m_singleHighlightGradientTexture;
} else {
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform)
barColor = rowHighlightColor;
else
gradientTexture = m_multiHighlightGradientTexture;
@@ -533,9 +533,9 @@ void Bars3DRenderer::drawSlicedScene(const LabelItem &xLabel,
m_barShader->setUniformValue(m_barShader->nModel(),
itModelMatrix.inverted().transposed());
m_barShader->setUniformValue(m_barShader->MVP(), MVPMatrix);
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform) {
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform) {
m_barShader->setUniformValue(m_barShader->color(), barColor);
- } else if (m_cachedColorStyle == QDataVis::ColorStyleRangeGradient) {
+ } else if (m_cachedColorStyle == Q3DTheme::ColorStyleRangeGradient) {
m_barShader->setUniformValue(m_barShader->gradientHeight(),
(qAbs(item->height()) / m_gradientFraction));
}
@@ -990,9 +990,9 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_barShader->setUniformValue(m_barShader->view(), viewMatrix);
m_barShader->setUniformValue(m_barShader->ambientS(),
m_cachedTheme->ambientLightStrength());
- if (m_cachedColorStyle != QDataVis::ColorStyleUniform) {
+ if (m_cachedColorStyle != Q3DTheme::ColorStyleUniform) {
m_barShader->setUniformValue(m_barShader->gradientMin(), 0.0f);
- if (m_cachedColorStyle == QDataVis::ColorStyleObjectGradient)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleObjectGradient)
m_barShader->setUniformValue(m_barShader->gradientHeight(), 0.5f);
gradientTexture = m_objectGradientTexture;
@@ -1066,7 +1066,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform)
barColor = baseColor;
else
gradientTexture = m_objectGradientTexture;
@@ -1081,7 +1081,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
switch (selectionType) {
case Bars3DController::SelectionItem: {
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform)
barColor = barHighlightColor;
else
gradientTexture = m_singleHighlightGradientTexture;
@@ -1113,7 +1113,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
case Bars3DController::SelectionRow: {
// Current bar is on the same row as the selected bar
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform)
barColor = rowHighlightColor;
else
gradientTexture = m_multiHighlightGradientTexture;
@@ -1134,7 +1134,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
case Bars3DController::SelectionColumn: {
// Current bar is on the same column as the selected bar
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform)
barColor = rowHighlightColor;
else
gradientTexture = m_multiHighlightGradientTexture;
@@ -1174,9 +1174,9 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_barShader->setUniformValue(m_barShader->nModel(),
itModelMatrix.transposed().inverted());
m_barShader->setUniformValue(m_barShader->MVP(), MVPMatrix);
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform) {
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform) {
m_barShader->setUniformValue(m_barShader->color(), barColor);
- } else if (m_cachedColorStyle == QDataVis::ColorStyleRangeGradient) {
+ } else if (m_cachedColorStyle == Q3DTheme::ColorStyleRangeGradient) {
m_barShader->setUniformValue(m_barShader->gradientHeight(),
qAbs(item.height()) / m_gradientFraction);
}
diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp
index 87f64e4f..f88b1f49 100644
--- a/src/datavisualization/engine/drawer.cpp
+++ b/src/datavisualization/engine/drawer.cpp
@@ -364,8 +364,8 @@ 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->textBackgroundColor(),
- m_theme->textColor(),
+ m_theme->labelBackgroundColor(),
+ m_theme->labelTextColor(),
m_labelBackground,
m_theme->isLabelBorderEnabled(),
widestLabel);
diff --git a/src/datavisualization/engine/q3dbars.cpp b/src/datavisualization/engine/q3dbars.cpp
index 095c5d8d..1d297f1b 100644
--- a/src/datavisualization/engine/q3dbars.cpp
+++ b/src/datavisualization/engine/q3dbars.cpp
@@ -300,9 +300,9 @@ bool Q3DBars::isBarSpacingRelative()
/*!
* \property Q3DBars::theme
*
- * A user-defined theme.
- *
- * TODO: Add docs.
+ * A \a theme to be used for the graph. Ownership of the \a theme is transferred. Previous theme
+ * is deleted when a new one is set. Properties of the \a theme can be modified even after setting
+ * it, and the modifications take effect immediately.
*/
void Q3DBars::setTheme(Q3DTheme *theme)
{
@@ -368,12 +368,12 @@ QDataVis::ShadowQuality Q3DBars::shadowQuality() const
*
* \sa barColor, barGradient
*/
-void Q3DBars::setColorStyle(QDataVis::ColorStyle style)
+void Q3DBars::setColorStyle(Q3DTheme::ColorStyle style)
{
d_ptr->m_shared->setColorStyle(style);
}
-QDataVis::ColorStyle Q3DBars::colorStyle() const
+Q3DTheme::ColorStyle Q3DBars::colorStyle() const
{
return d_ptr->m_shared->colorStyle();
}
diff --git a/src/datavisualization/engine/q3dbars.h b/src/datavisualization/engine/q3dbars.h
index 37243a0d..cdb0d9a7 100644
--- a/src/datavisualization/engine/q3dbars.h
+++ b/src/datavisualization/engine/q3dbars.h
@@ -21,6 +21,7 @@
#include <QtDataVisualization/qdatavisualizationenums.h>
#include <QtDataVisualization/q3dwindow.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <QFont>
#include <QLinearGradient>
@@ -32,7 +33,6 @@ class Q3DCategoryAxis;
class Q3DValueAxis;
class Q3DScene;
class QBar3DSeries;
-class Q3DTheme;
class QT_DATAVISUALIZATION_EXPORT Q3DBars : public Q3DWindow
{
@@ -44,7 +44,7 @@ class QT_DATAVISUALIZATION_EXPORT Q3DBars : public Q3DWindow
Q_PROPERTY(bool barSpacingRelative READ isBarSpacingRelative WRITE setBarSpacingRelative NOTIFY barSpacingRelativeChanged)
Q_PROPERTY(Q3DTheme* theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(Q3DScene* scene READ scene)
- Q_PROPERTY(QtDataVisualization::QDataVis::ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
+ Q_PROPERTY(QtDataVisualization::Q3DTheme::ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
Q_PROPERTY(QColor barColor READ barColor WRITE setBarColor NOTIFY barColorChanged)
Q_PROPERTY(QLinearGradient barGradient READ barGradient WRITE setBarGradient NOTIFY barGradientChanged)
Q_PROPERTY(QColor singleHighlightColor READ singleHighlightColor WRITE setSingleHighlightColor NOTIFY singleHighlightColorChanged)
@@ -84,8 +84,8 @@ public:
QDataVis::ShadowQuality shadowQuality() const;
// TODO: Move to dataset object once that is done QTRD-2121
- void setColorStyle(QDataVis::ColorStyle style);
- QDataVis::ColorStyle colorStyle() const;
+ void setColorStyle(Q3DTheme::ColorStyle style);
+ Q3DTheme::ColorStyle colorStyle() const;
void setBarColor(const QColor &color);
QColor barColor() const;
void setBarGradient(const QLinearGradient &gradient);
@@ -116,7 +116,7 @@ signals:
void barSpacingChanged(QSizeF spacing);
void barSpacingRelativeChanged(bool relative);
void themeChanged(Q3DTheme *theme);
- void colorStyleChanged(QDataVis::ColorStyle style);
+ void colorStyleChanged(Q3DTheme::ColorStyle style);
void barColorChanged(QColor color);
void barGradientChanged(QLinearGradient gradient);
void singleHighlightColorChanged(QColor color);
diff --git a/src/datavisualization/engine/q3dscatter.cpp b/src/datavisualization/engine/q3dscatter.cpp
index a71bdb18..e65aef0f 100644
--- a/src/datavisualization/engine/q3dscatter.cpp
+++ b/src/datavisualization/engine/q3dscatter.cpp
@@ -221,7 +221,9 @@ void Q3DScatter::setHeight(const int height)
/*!
* \property Q3DScatter::theme
*
- * TODO: Add docs
+ * A \a theme to be used for the graph. Ownership of the \a theme is transferred. Previous theme
+ * is deleted when a new one is set. Properties of the \a theme can be modified even after setting
+ * it, and the modifications take effect immediately.
*/
void Q3DScatter::setTheme(Q3DTheme *theme)
{
@@ -289,12 +291,12 @@ QDataVis::ShadowQuality Q3DScatter::shadowQuality() const
*
* \sa itemColor, itemGradient
*/
-void Q3DScatter::setColorStyle(QDataVis::ColorStyle style)
+void Q3DScatter::setColorStyle(Q3DTheme::ColorStyle style)
{
d_ptr->m_shared->setColorStyle(style);
}
-QDataVis::ColorStyle Q3DScatter::colorStyle() const
+Q3DTheme::ColorStyle Q3DScatter::colorStyle() const
{
return d_ptr->m_shared->colorStyle();
}
diff --git a/src/datavisualization/engine/q3dscatter.h b/src/datavisualization/engine/q3dscatter.h
index 917b31bc..96ccf69b 100644
--- a/src/datavisualization/engine/q3dscatter.h
+++ b/src/datavisualization/engine/q3dscatter.h
@@ -22,6 +22,7 @@
#include <QtDataVisualization/qdatavisualizationenums.h>
#include <QtDataVisualization/q3dwindow.h>
#include <QtDataVisualization/q3dscene.h>
+#include <QtDataVisualization/q3dtheme.h>
#include <QFont>
#include <QLinearGradient>
@@ -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(Q3DTheme* theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(Q3DScene* scene READ scene)
- Q_PROPERTY(QtDataVisualization::QDataVis::ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
+ Q_PROPERTY(QtDataVisualization::Q3DTheme::ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
Q_PROPERTY(QColor itemColor READ itemColor WRITE setItemColor NOTIFY itemColorChanged)
Q_PROPERTY(QLinearGradient itemGradient READ itemGradient WRITE setItemGradient NOTIFY itemGradientChanged)
Q_PROPERTY(QColor singleHighlightColor READ singleHighlightColor WRITE setSingleHighlightColor NOTIFY singleHighlightColorChanged)
@@ -72,8 +73,8 @@ public:
QDataVis::ShadowQuality shadowQuality() const;
// TODO: Move to dataset object once that is done QTRD-2121
- void setColorStyle(QDataVis::ColorStyle style);
- QDataVis::ColorStyle colorStyle() const;
+ void setColorStyle(Q3DTheme::ColorStyle style);
+ Q3DTheme::ColorStyle colorStyle() const;
void setItemColor(const QColor &color);
QColor itemColor() const;
void setItemGradient(const QLinearGradient &gradient);
@@ -101,7 +102,7 @@ signals:
void selectionModeChanged(QDataVis::SelectionFlags mode);
void shadowQualityChanged(QDataVis::ShadowQuality quality);
void themeChanged(Q3DTheme* theme);
- void colorStyleChanged(QDataVis::ColorStyle style);
+ void colorStyleChanged(Q3DTheme::ColorStyle style);
void itemColorChanged(QColor color);
void itemGradientChanged(QLinearGradient gradient);
void singleHighlightColorChanged(QColor color);
diff --git a/src/datavisualization/engine/q3dsurface.cpp b/src/datavisualization/engine/q3dsurface.cpp
index 22b671e1..b678ba16 100644
--- a/src/datavisualization/engine/q3dsurface.cpp
+++ b/src/datavisualization/engine/q3dsurface.cpp
@@ -209,7 +209,9 @@ void Q3DSurface::resizeEvent(QResizeEvent *event)
/*!
* \property Q3DSurface::theme
*
- * TODO: Add docs
+ * A \a theme to be used for the graph. Ownership of the \a theme is transferred. Previous theme
+ * is deleted when a new one is set. Properties of the \a theme can be modified even after setting
+ * it, and the modifications take effect immediately.
*/
void Q3DSurface::setTheme(Q3DTheme *theme)
{
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 27262c4c..627fc88a 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -561,8 +561,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
dotShader->setUniformValue(dotShader->lightP(), lightPos);
dotShader->setUniformValue(dotShader->view(), viewMatrix);
dotShader->setUniformValue(dotShader->ambientS(), m_cachedTheme->ambientLightStrength());
- if (m_cachedColorStyle != QDataVis::ColorStyleUniform) {
- if (m_cachedColorStyle == QDataVis::ColorStyleObjectGradient) {
+ if (m_cachedColorStyle != Q3DTheme::ColorStyleUniform) {
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleObjectGradient) {
dotShader->setUniformValue(dotShader->gradientMin(), 0.0f);
dotShader->setUniformValue(dotShader->gradientHeight(), 0.5f);
} else {
@@ -624,14 +624,14 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
MVPMatrix = projectionViewMatrix * modelMatrix;
#endif
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform || drawingPoints)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform || drawingPoints)
dotColor = baseColor;
else
gradientTexture = m_objectGradientTexture;
GLfloat lightStrength = m_cachedTheme->lightStrength();
if (m_cachedSelectionMode > QDataVis::SelectionNone && (m_selectedItemTotalIndex == dotNo)) {
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform || drawingPoints)
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform || drawingPoints)
dotColor = Utils::vectorFromColor(m_cachedSingleHighlightColor);
else
gradientTexture = m_singleHighlightGradientTexture;
@@ -648,9 +648,9 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
itModelMatrix.inverted().transposed());
}
dotShader->setUniformValue(dotShader->MVP(), MVPMatrix);
- if (m_cachedColorStyle == QDataVis::ColorStyleUniform || drawingPoints) {
+ if (m_cachedColorStyle == Q3DTheme::ColorStyleUniform || drawingPoints) {
dotShader->setUniformValue(dotShader->color(), dotColor);
- } else if (m_cachedColorStyle == QDataVis::ColorStyleRangeGradient) {
+ } else if (m_cachedColorStyle == Q3DTheme::ColorStyleRangeGradient) {
dotShader->setUniformValue(dotShader->gradientMin(),
(item.position().y() + 1.0f) / 2.0f);
}
diff --git a/src/datavisualization/global/qdatavisualizationenums.h b/src/datavisualization/global/qdatavisualizationenums.h
index 712ae38d..e3cdf669 100644
--- a/src/datavisualization/global/qdatavisualizationenums.h
+++ b/src/datavisualization/global/qdatavisualizationenums.h
@@ -29,11 +29,8 @@ class QT_DATAVISUALIZATION_EXPORT QDataVis : public QObject
{
Q_OBJECT
Q_ENUMS(CameraPreset)
- Q_ENUMS(Theme)
Q_ENUMS(ShadowQuality)
- Q_ENUMS(LabelStyle)
Q_FLAGS(SelectionFlag SelectionFlags)
- Q_ENUMS(ColorStyle)
public:
// TODO: Move to input handler (QTRD-2505)
@@ -75,19 +72,6 @@ public:
CameraPresetDirectlyBelow
};
- // TODO: Move to theme
- enum Theme {
- ThemeQt,
- ThemePrimaryColors,
- ThemeDigia,
- ThemeStoneMoss,
- ThemeArmyBlue,
- ThemeRetro,
- ThemeEbony,
- ThemeIsabelle,
- ThemeUserDefined
- };
-
enum SelectionFlag {
SelectionNone = 0,
SelectionItem = 1,
@@ -111,13 +95,6 @@ public:
ShadowQualitySoftMedium,
ShadowQualitySoftHigh
};
-
- // TODO: to theme
- enum ColorStyle {
- ColorStyleUniform = 0,
- ColorStyleObjectGradient,
- ColorStyleRangeGradient
- };
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QDataVis::SelectionFlags)
diff --git a/src/datavisualization/global/qtdatavisualizationenums.qdoc b/src/datavisualization/global/qtdatavisualizationenums.qdoc
index cb285397..4bedcefe 100644
--- a/src/datavisualization/global/qtdatavisualizationenums.qdoc
+++ b/src/datavisualization/global/qtdatavisualizationenums.qdoc
@@ -92,22 +92,6 @@
*/
/*!
- \enum QtDataVisualization::QDataVis::Theme
-
- Predefined themes.
-
- \value ThemeQt
- \value ThemePrimaryColors
- \value ThemeDigia
- \value ThemeStoneMoss
- \value ThemeArmyBlue
- \value ThemeRetro
- \value ThemeEbony
- \value ThemeIsabelle
- \value ThemeUserDefined
-*/
-
-/*!
\enum QtDataVisualization::QDataVis::SelectionFlag
Item selection modes. Values of this enumeration can be combined with OR operator.
@@ -159,31 +143,3 @@
\value ShadowQualitySoftHigh
Shadows are rendered in high quality with softened edges.
*/
-
-/*!
- \enum QtDataVisualization::QDataVis::LabelStyle
-
- Label styles.
-
- \value LabelStyleOpaque
- Fully opaque background, using colors and borders from theme.
- \value LabelStyleFromTheme
- Use transparencies, colors and borders from theme.
- \value LabelStyleTransparent
- Fully transparent background, using text color from theme.
-*/
-
-/*!
- \enum QtDataVisualization::QDataVis::ColorStyle
-
- Color styles.
-
- \value ColorStyleUniform
- Objects are rendered in a single color.
- \value ColorStyleObjectGradient
- Objects are colored using a full gradient for each object regardless
- of object height.
- \value ColorStyleRangeGradient
- Objects are colored using a portion of the full gradient determined by
- the object's height and its position on the Y-axis.
-*/
diff --git a/src/datavisualization/theme/q3dtheme.cpp b/src/datavisualization/theme/q3dtheme.cpp
index 21c21c98..1d7aac5e 100644
--- a/src/datavisualization/theme/q3dtheme.cpp
+++ b/src/datavisualization/theme/q3dtheme.cpp
@@ -20,19 +20,384 @@
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+/*!
+ * \class Q3DTheme
+ * \inmodule QtDataVisualization
+ * \brief Q3DTheme class provides a visual style for graphs.
+ * \since Qt Data Visualization 1.0
+ *
+ * Q3DTheme is used to specify visual properties that affect the whole graph. There are several
+ * built-in themes that can be used directly, or be modified freely. User can also create a theme
+ * from scratch using \c ThemeUserDefined. Creating a theme using the default constructor
+ * produces a new user-defined theme.
+ *
+ * \section1 Properties controlled by theme
+ * \table
+ * \header
+ * \li Property
+ * \li Effect
+ * \li Default in ThemeUserDefined
+ * \row
+ * \li ambientLightStrength
+ * \li The strength of the ambient light in the graph. This affects how evenly and brightly the
+ * colors are shown throughout the graph regardless of light position.
+ * \li 0.25
+ * \row
+ * \li backgroundColor
+ * \li Color of the graph background.
+ * \li Qt::black
+ * \row
+ * \li backgroundEnabled
+ * \li Is the graph background drawn or not.
+ * \li true
+ * \row
+ * \li baseColor
+ * \li The color for the objects in the graph. The color in this property is used if colorStyle
+ * is ColorStyleUniform. This can be overridden by setting the baseColor explicitly in
+ * series.
+ * \li Qt::white
+ * \row
+ * \li baseGradient
+ * \li The gradient for the objects in the graph. The gradient in this property is used if
+ * colorStyle is ColorStyleObjectGradient or ColorStyleRangeGradient. This can be overridden
+ * by setting the baseGradient explicitly in series.
+ * \li QLinearGradient(). Essentially fully black.
+ * \row
+ * \li colorStyle
+ * \li The color style of the objects in the graph. See ColorStyle for detailed description of
+ * the styles. This can be overridden by setting the colorStyle explicitly in series.
+ * \li ColorStyleUniform
+ * \row
+ * \li \l font
+ * \li The font to be used for labels.
+ * \li QFont()
+ * \row
+ * \li gridEnabled
+ * \li Is the grid on the background drawn or not. This affects all grid lines.
+ * \li true
+ * \row
+ * \li gridLineColor
+ * \li The color for the grid lines.
+ * \li Qt::white
+ * \row
+ * \li highlightLightStrength
+ * \li The specular light strength for highlighted objects.
+ * \li 7.5
+ * \row
+ * \li labelBackgroundColor
+ * \li The color of the label background. This property has no effect if labelBackgroundEnabled
+ * is \c false.
+ * \li Qt::gray
+ * \row
+ * \li labelBackgroundEnabled
+ * \li Are the labels to be drawn with a background using labelBackgroundColor (including alpha),
+ * or with a fully transparent background. Labels with background are drawn to equal sizes
+ * per axis based on the longest label, and the text is centered in it. Labels without
+ * background are drawn as is and are left/right aligned based on their position in the
+ * graph.
+ * \li true
+ * \row
+ * \li labelBorderEnabled
+ * \li Are the labels to be drawn with a border or not. This property affects only labels with
+ * a background.
+ * \li true
+ * \row
+ * \li labelTextColor
+ * \li The color for the font used in labels.
+ * \li Qt::white
+ * \row
+ * \li lightColor
+ * \li The color of the specular light. Doesn't affect ambient light. \note Not yet supported
+ * in technology preview.
+ * \li Qt::white
+ * \row
+ * \li lightStrength
+ * \li The strength of the specular light in the graph. This affects the light specified in
+ * Q3DScene.
+ * \li 5.0
+ * \row
+ * \li multiHighlightColor
+ * \li The color to be used for highlighted objects, if \l{Q3DBars::selectionMode}{selectionMode}
+ * of the graph has \c QDataVis::SelectionRow or \c QDataVis::SelectionColumn flag set.
+ * \li Qt::blue
+ * \row
+ * \li multiHighlightGradient
+ * \li The gradient to be used for highlighted objects, if \l{Q3DBars::selectionMode}{selectionMode}
+ * of the graph has \c QDataVis::SelectionRow or \c QDataVis::SelectionColumn flag set.
+ * \li QLinearGradient(). Essentially fully black.
+ * \row
+ * \li singleHighlightColor
+ * \li The color to be used for a highlighted object, if \l{Q3DBars::selectionMode}{selectionMode}
+ * of the graph has \c QDataVis::SelectionItem flag set.
+ * \li Qt::red
+ * \row
+ * \li singleHighlightGradient
+ * \li The gradient to be used for a highlighted object, if \l{Q3DBars::selectionMode}{selectionMode}
+ * of the graph has \c QDataVis::SelectionItem flag set.
+ * \li QLinearGradient(). Essentially fully black.
+ * \row
+ * \li windowColor
+ * \li The color of the window the graph is drawn into.
+ * \li Qt::black
+ * \endtable
+ *
+ * \section1 Usage examples
+ *
+ * Creating a built-in theme without any modifications:
+ *
+ * \snippet doc_src_q3dtheme.cpp 0
+ *
+ * Creating a built-in theme and modifying some properties:
+ *
+ * \snippet doc_src_q3dtheme.cpp 1
+ *
+ * Creating a user-defined theme:
+ *
+ * \snippet doc_src_q3dtheme.cpp 2
+ *
+ * Creating a built-in theme and modifying some properties after it has been set:
+ *
+ * \snippet doc_src_q3dtheme.cpp 3
+ *
+ */
+
+/*!
+ * \enum Q3DTheme::ColorStyle
+ *
+ * Color styles.
+ *
+ * \value ColorStyleUniform
+ * Objects are rendered in a single color. The color used is specified in baseColor,
+ * singleHighlightColor and multiHighlightColor properties.
+ * \value ColorStyleObjectGradient
+ * Objects are colored using a full gradient for each object regardless of object height. The
+ * gradient used is specified in baseGradient, singleHighlightGradient and
+ * multiHighlightGradient properties.
+ * \value ColorStyleRangeGradient
+ * Objects are colored using a portion of the full gradient determined by the object's
+ * height and its position on the Y-axis. The gradient used is specified in baseGradient,
+ * singleHighlightGradient and multiHighlightGradient properties.
+ */
+
+/*!
+ * \enum Q3DTheme::Theme
+ *
+ * Built-in themes.
+ *
+ * \value ThemeQt
+ * A light theme with green as the base color.
+ * \value ThemePrimaryColors
+ * A light theme with yellow as the base color.
+ * \value ThemeDigia
+ * A light theme with gray as the base color.
+ * \value ThemeStoneMoss
+ * A medium dark theme with yellow as the base color.
+ * \value ThemeArmyBlue
+ * A medium light theme with blue as the base color.
+ * \value ThemeRetro
+ * A medium light theme with brown as the base color.
+ * \value ThemeEbony
+ * A dark theme with white as the base color.
+ * \value ThemeIsabelle
+ * A dark theme with yellow as the base color.
+ * \value ThemeUserDefined
+ * A user-defined theme. See \l {Properties controlled by theme} for theme defaults.
+ */
+
+/*!
+ * \qmltype Theme3D
+ * \inqmlmodule QtDataVisualization
+ * \since QtDataVisualization 1.0
+ * \ingroup datavisualization_qml
+ * \instantiates Q3DTheme
+ * \brief A visual style for graphs.
+ *
+ * This type is used to specify visual properties that affect the whole graph. There are several
+ * built-in themes that can be used directly, or be modified freely. User can also create a theme
+ * from scratch using \c Theme3D.ThemeUserDefined.
+ *
+ * For a more complete description, see Q3DTheme.
+ *
+ * \section1 Usage examples
+ *
+ * Using a built-in theme without any modifications:
+ *
+ * \snippet doc_src_q3dtheme.cpp 4
+ *
+ * Using a built-in theme and modifying some properties:
+ *
+ * \snippet doc_src_q3dtheme.cpp 5
+ *
+ * Using a user-defined theme:
+ *
+ * \snippet doc_src_q3dtheme.cpp 6
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::baseColor
+ *
+ * Color to be used for all the objects in the graph. Has no immediate effect if colorStyle is not
+ * \c Theme3D.ColorStyleUniform.
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::backgroundColor
+ *
+ * Color for the graph background.
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::windowColor
+ *
+ * Color for the application window.
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::labelTextColor
+ *
+ * Color for the font used for labels.
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::labelBackgroundColor
+ *
+ * Color for the label backgrounds. Has no effect if labelBackgroundEnabled is \c false.
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::gridLineColor
+ *
+ * Color for the grid lines.
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::singleHighlightColor
+ *
+ * Highlight color for a highlighted object. Used if \l{AbstractGraph3D::selectionMode}{selectionMode}
+ * has \c AbstractGraph3D.SelectionItem flag set.
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::multiHighlightColor
+ *
+ * Highlight color for highlighted objects. Used if \l{AbstractGraph3D::selectionMode}{selectionMode}
+ * has \c AbstractGraph3D.SelectionRow or \c AbstractGraph3D.SelectionColumn flag set.
+ */
+
+/*!
+ * \qmlproperty Color Theme3D::lightColor
+ *
+ * Color for the specular light defined in Scene3D.
+ *
+ * \warning Not supported in technology preview.
+ */
+
+/*!
+ * \qmlproperty ColorGradient Theme3D::baseGradient
+ *
+ * Base gradient to be used for all the objects in the graph. Has no immediate effect if colorStyle
+ * is \c Theme3D.ColorStyleUniform.
+ */
+
+/*!
+ * \qmlproperty ColorGradient Theme3D::singleHighlightGradient
+ *
+ * Highlight gradient for a highlighted object. Used if \l{AbstractGraph3D::selectionMode}{selectionMode}
+ * has \c AbstractGraph3D.SelectionItem flag set.
+ */
+
+/*!
+ * \qmlproperty ColorGradient Theme3D::multiHighlightGradient
+ *
+ * Highlight gradient for highlighted objects. Used if \l{AbstractGraph3D::selectionMode}{selectionMode}
+ * has \c AbstractGraph3D.SelectionRow or \c AbstractGraph3D.SelectionColumn flag set.
+ */
+
+/*!
+ * \qmlproperty float Theme3D::lightStrength
+ *
+ * Specular light strength for the whole graph. Value must be between 0.0 and 1.0.
+ */
+
+/*!
+ * \qmlproperty float Theme3D::ambientLightStrength
+ *
+ * Ambient light strength for the whole graph. Value must be between 0.0 and 1.0.
+ */
+
+/*!
+ * \qmlproperty float Theme3D::highlightLightStrength
+ *
+ * Specular light strength for highlighted objects. Value must be between 0.0 and 1.0.
+ */
+
+/*!
+ * \qmlproperty bool Theme3D::labelBorderEnabled
+ *
+ * Set label borders enabled or disabled. Has no effect if labelBackgroundEnabled is \c false.
+ */
+
+/*!
+ * \qmlproperty Font Theme3D::font
+ *
+ * Set \a font to be used for labels.
+ */
+
+/*!
+ * \qmlproperty bool Theme3D::backgroundEnabled
+ *
+ * Set background enabled or disabled.
+ */
+
+/*!
+ * \qmlproperty bool Theme3D::gridEnabled
+ *
+ * Set grid lines enabled or disabled.
+ */
+
+/*!
+ * \qmlproperty bool Theme3D::labelBackgroundEnabled
+ *
+ * Set label backgrounds enabled or disabled.
+ */
+
+/*!
+ * \qmlproperty Theme3D.ColorStyle Theme3D::colorStyle
+ *
+ * The \a style of the graph colors. One of \c Theme3D.ColorStyle.
+ */
+
+/*!
+ * \qmlproperty Theme3D.Theme Theme3D::type
+ *
+ * The type of the theme. If no type is set, the type is \c Theme3D.ThemeUserDefined.
+ */
+
+/*!
+ * Constructs a new theme of type ThemeUserDefined. An optional \a parent parameter
+ * can be given and is then passed to QObject constructor.
+ */
Q3DTheme::Q3DTheme(QObject *parent)
: QObject(parent),
- d_ptr(new Q3DThemePrivate(this, QDataVis::ThemeUserDefined))
+ d_ptr(new Q3DThemePrivate(this, ThemeUserDefined))
{
}
-Q3DTheme::Q3DTheme(QDataVis::Theme themeType, QObject *parent)
+/*!
+ * Constructs a new theme with \a themeType, which can be one of the built-in themes from
+ * \l Theme. An optional \a parent parameter can be given and is then passed to QObject
+ * constructor.
+ */
+Q3DTheme::Q3DTheme(Theme themeType, QObject *parent)
: QObject(parent),
d_ptr(new Q3DThemePrivate(this, themeType))
{
}
-Q3DTheme::Q3DTheme(Q3DThemePrivate *d, QDataVis::Theme themeType,
+/*!
+ * \internal
+ */
+Q3DTheme::Q3DTheme(Q3DThemePrivate *d, Theme themeType,
QObject *parent) :
QObject(parent),
d_ptr(d)
@@ -40,13 +405,21 @@ Q3DTheme::Q3DTheme(Q3DThemePrivate *d, QDataVis::Theme themeType,
d_ptr->m_themeId = themeType;
}
+/*!
+ * Destroys the theme.
+ */
Q3DTheme::~Q3DTheme()
{
-
}
// TODO: Add needRenders if necessary after color api has been added to series (QTRD-2200/2557)
// TODO: Basecolors as a list, containing one for each series?
+/*!
+ * \property Q3DTheme::baseColor
+ *
+ * Color to be used for all the objects in the graph. Has no immediate effect if colorStyle is not
+ * ColorStyleUniform.
+ */
void Q3DTheme::setBaseColor(const QColor &color)
{
if (d_ptr->m_baseColor != color) {
@@ -61,13 +434,18 @@ QColor Q3DTheme::baseColor() const
return d_ptr->m_baseColor;
}
+/*!
+ * \property Q3DTheme::backgroundColor
+ *
+ * Color for the graph background.
+ */
void Q3DTheme::setBackgroundColor(const QColor &color)
{
if (d_ptr->m_backgroundColor != color) {
d_ptr->m_dirtyBits.backgroundColorDirty = true;
d_ptr->m_backgroundColor = color;
emit backgroundColorChanged(color);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -76,13 +454,18 @@ QColor Q3DTheme::backgroundColor() const
return d_ptr->m_backgroundColor;
}
+/*!
+ * \property Q3DTheme::windowColor
+ *
+ * Color for the application window.
+ */
void Q3DTheme::setWindowColor(const QColor &color)
{
if (d_ptr->m_windowColor != color) {
d_ptr->m_dirtyBits.windowColorDirty = true;
d_ptr->m_windowColor = color;
emit windowColorChanged(color);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -91,43 +474,58 @@ QColor Q3DTheme::windowColor() const
return d_ptr->m_windowColor;
}
-void Q3DTheme::setTextColor(const QColor &color)
+/*!
+ * \property Q3DTheme::labelTextColor
+ *
+ * Color for the font used for labels.
+ */
+void Q3DTheme::setLabelTextColor(const QColor &color)
{
if (d_ptr->m_textColor != color) {
- d_ptr->m_dirtyBits.textColorDirty = true;
+ d_ptr->m_dirtyBits.labelTextColorDirty = true;
d_ptr->m_textColor = color;
- emit textColorChanged(color);
- emit needRender();
+ emit labelTextColorChanged(color);
+ emit d_ptr->needRender();
}
}
-QColor Q3DTheme::textColor() const
+QColor Q3DTheme::labelTextColor() const
{
return d_ptr->m_textColor;
}
-void Q3DTheme::setTextBackgroundColor(const QColor &color)
+/*!
+ * \property Q3DTheme::labelBackgroundColor
+ *
+ * Color for the label backgrounds. Has no effect if labelBackgroundEnabled is \c false.
+ */
+void Q3DTheme::setLabelBackgroundColor(const QColor &color)
{
if (d_ptr->m_textBackgroundColor != color) {
- d_ptr->m_dirtyBits.textBackgroundColorDirty = true;
+ d_ptr->m_dirtyBits.labelBackgroundColorDirty = true;
d_ptr->m_textBackgroundColor = color;
- emit textBackgroundColorChanged(color);
- emit needRender();
+ emit labelBackgroundColorChanged(color);
+ emit d_ptr->needRender();
}
}
-QColor Q3DTheme::textBackgroundColor() const
+QColor Q3DTheme::labelBackgroundColor() const
{
return d_ptr->m_textBackgroundColor;
}
+/*!
+ * \property Q3DTheme::gridLineColor
+ *
+ * Color for the grid lines.
+ */
void Q3DTheme::setGridLineColor(const QColor &color)
{
if (d_ptr->m_gridLineColor != color) {
d_ptr->m_dirtyBits.gridLineColorDirty = true;
d_ptr->m_gridLineColor = color;
emit gridLineColorChanged(color);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -136,6 +534,12 @@ QColor Q3DTheme::gridLineColor() const
return d_ptr->m_gridLineColor;
}
+/*!
+ * \property Q3DTheme::singleHighlightColor
+ *
+ * Highlight color for a highlighted object. Used if \l{Q3DBars::selectionMode}{selectionMode} has
+ * \c QDataVis::SelectionItem flag set.
+ */
void Q3DTheme::setSingleHighlightColor(const QColor &color)
{
if (d_ptr->m_singleHighlightColor != color) {
@@ -150,6 +554,12 @@ QColor Q3DTheme::singleHighlightColor() const
return d_ptr->m_singleHighlightColor;
}
+/*!
+ * \property Q3DTheme::multiHighlightColor
+ *
+ * Highlight color for highlighted objects. Used if \l{Q3DBars::selectionMode}{selectionMode} has
+ * \c QDataVis::SelectionRow or \c QDataVis::SelectionColumn flag set.
+ */
void Q3DTheme::setMultiHighlightColor(const QColor &color)
{
if (d_ptr->m_multiHighlightColor != color) {
@@ -164,13 +574,20 @@ QColor Q3DTheme::multiHighlightColor() const
return d_ptr->m_multiHighlightColor;
}
+/*!
+ * \property Q3DTheme::lightColor
+ *
+ * Color for the specular light defined in Q3DScene.
+ *
+ * \warning Not supported in technology preview.
+ */
void Q3DTheme::setLightColor(const QColor &color)
{
if (d_ptr->m_lightColor != color) {
d_ptr->m_dirtyBits.lightColorDirty = true;
d_ptr->m_lightColor = color;
emit lightColorChanged(color);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -180,6 +597,12 @@ QColor Q3DTheme::lightColor() const
}
// TODO: Surfacegradients as a list, containing one for each series?
+/*!
+ * \property Q3DTheme::baseGradient
+ *
+ * Base gradient to be used for all the objects in the graph. Has no immediate effect if colorStyle
+ * is ColorStyleUniform.
+ */
void Q3DTheme::setBaseGradient(const QLinearGradient &gradient)
{
if (d_ptr->m_baseGradient != gradient) {
@@ -194,6 +617,12 @@ QLinearGradient Q3DTheme::baseGradient() const
return d_ptr->m_baseGradient;
}
+/*!
+ * \property Q3DTheme::singleHighlightGradient
+ *
+ * Highlight gradient for a highlighted object. Used if \l{Q3DBars::selectionMode}{selectionMode}
+ * has \c QDataVis::SelectionItem flag set.
+ */
void Q3DTheme::setSingleHighlightGradient(const QLinearGradient &gradient)
{
if (d_ptr->m_singleHighlightGradient != gradient) {
@@ -208,6 +637,12 @@ QLinearGradient Q3DTheme::singleHighlightGradient() const
return d_ptr->m_singleHighlightGradient;
}
+/*!
+ * \property Q3DTheme::multiHighlightGradient
+ *
+ * Highlight gradient for highlighted objects. Used if \l{Q3DBars::selectionMode}{selectionMode}
+ * has \c QDataVis::SelectionRow or \c QDataVis::SelectionColumn flag set.
+ */
void Q3DTheme::setMultiHighlightGradient(const QLinearGradient &gradient)
{
if (d_ptr->m_multiHighlightGradient != gradient) {
@@ -222,13 +657,20 @@ QLinearGradient Q3DTheme::multiHighlightGradient() const
return d_ptr->m_multiHighlightGradient;
}
+/*!
+ * \property Q3DTheme::lightStrength
+ *
+ * Specular light strength for the whole graph. Value must be 0.0f and 10.0f.
+ */
void Q3DTheme::setLightStrength(float strength)
{
- if (d_ptr->m_lightStrength != strength) {
+ if (strength < 0.0f || strength > 10.0f) {
+ qWarning("Invalid value. Valid range for lightStrength is between 0.0f and 10.0f");
+ } else if (d_ptr->m_lightStrength != strength) {
d_ptr->m_dirtyBits.lightStrengthDirty = true;
d_ptr->m_lightStrength = strength;
emit lightStrengthChanged(strength);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -237,13 +679,20 @@ float Q3DTheme::lightStrength() const
return d_ptr->m_lightStrength;
}
+/*!
+ * \property Q3DTheme::ambientLightStrength
+ *
+ * Ambient light strength for the whole graph. Value must be between 0.0f and 1.0f.
+ */
void Q3DTheme::setAmbientLightStrength(float strength)
{
- if (d_ptr->m_ambientLightStrength != strength) {
+ if (strength < 0.0f || strength > 1.0f) {
+ qWarning("Invalid value. Valid range for ambientLightStrength is between 0.0f and 1.0f");
+ } else if (d_ptr->m_ambientLightStrength != strength) {
d_ptr->m_dirtyBits.ambientLightStrengthDirty = true;
d_ptr->m_ambientLightStrength = strength;
emit ambientLightStrengthChanged(strength);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -252,13 +701,20 @@ float Q3DTheme::ambientLightStrength() const
return d_ptr->m_ambientLightStrength;
}
+/*!
+ * \property Q3DTheme::highlightLightStrength
+ *
+ * Specular light strength for highlighted objects. Value must be between 0.0f and 10.0f.
+ */
void Q3DTheme::setHighlightLightStrength(float strength)
{
- if (d_ptr->m_highlightLightStrength != strength) {
+ if (strength < 0.0f || strength > 10.0f) {
+ qWarning("Invalid value. Valid range for highlightLightStrength is between 0.0f and 10.0f");
+ } else if (d_ptr->m_highlightLightStrength != strength) {
d_ptr->m_dirtyBits.highlightLightStrengthDirty = true;
d_ptr->m_highlightLightStrength = strength;
emit highlightLightStrengthChanged(strength);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -267,13 +723,18 @@ float Q3DTheme::highlightLightStrength() const
return d_ptr->m_highlightLightStrength;
}
+/*!
+ * \property Q3DTheme::labelBorderEnabled
+ *
+ * Set label borders enabled or disabled. Has no effect if labelBackgroundEnabled is \c false.
+ */
void Q3DTheme::setLabelBorderEnabled(bool enabled)
{
if (d_ptr->m_labelBorders != enabled) {
d_ptr->m_dirtyBits.labelBorderEnabledDirty = true;
d_ptr->m_labelBorders = enabled;
emit labelBorderEnabledChanged(enabled);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -282,13 +743,18 @@ bool Q3DTheme::isLabelBorderEnabled() const
return d_ptr->m_labelBorders;
}
+/*!
+ * \property Q3DTheme::font
+ *
+ * Set \a font to be used for labels.
+ */
void Q3DTheme::setFont(const QFont &font)
{
if (d_ptr->m_font != font) {
d_ptr->m_dirtyBits.fontDirty = true;
d_ptr->m_font = font;
emit fontChanged(font);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -297,13 +763,18 @@ QFont Q3DTheme::font() const
return d_ptr->m_font;
}
+/*!
+ * \property Q3DTheme::backgroundEnabled
+ *
+ * Set background enabled or disabled.
+ */
void Q3DTheme::setBackgroundEnabled(bool enabled)
{
if (d_ptr->m_backgoundEnabled != enabled) {
d_ptr->m_dirtyBits.backgroundEnabledDirty = true;
d_ptr->m_backgoundEnabled = enabled;
emit backgroundEnabledChanged(enabled);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -312,13 +783,18 @@ bool Q3DTheme::isBackgroundEnabled() const
return d_ptr->m_backgoundEnabled;
}
+/*!
+ * \property Q3DTheme::gridEnabled
+ *
+ * Set grid lines enabled or disabled.
+ */
void Q3DTheme::setGridEnabled(bool enabled)
{
if (d_ptr->m_gridEnabled != enabled) {
d_ptr->m_dirtyBits.gridEnabledDirty = true;
d_ptr->m_gridEnabled = enabled;
emit gridEnabledChanged(enabled);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -327,13 +803,18 @@ bool Q3DTheme::isGridEnabled() const
return d_ptr->m_gridEnabled;
}
+/*!
+ * \property Q3DTheme::labelBackgroundEnabled
+ *
+ * Set label backgrounds enabled or disabled.
+ */
void Q3DTheme::setLabelBackgroundEnabled(bool enabled)
{
if (d_ptr->m_labelBackground != enabled) {
d_ptr->m_dirtyBits.labelBackgroundEnabledDirty = true;
d_ptr->m_labelBackground = enabled;
emit labelBackgroundEnabledChanged(enabled);
- emit needRender();
+ emit d_ptr->needRender();
}
}
@@ -342,7 +823,12 @@ bool Q3DTheme::isLabelBackgroundEnabled() const
return d_ptr->m_labelBackground;
}
-void Q3DTheme::setColorStyle(QDataVis::ColorStyle style)
+/*!
+ * \property Q3DTheme::colorStyle
+ *
+ * The \a style of the graph colors. One of ColorStyle.
+ */
+void Q3DTheme::setColorStyle(ColorStyle style)
{
if (d_ptr->m_colorStyle != style) {
d_ptr->m_dirtyBits.colorStyleDirty = true;
@@ -351,12 +837,18 @@ void Q3DTheme::setColorStyle(QDataVis::ColorStyle style)
}
}
-QDataVis::ColorStyle Q3DTheme::colorStyle() const
+Q3DTheme::ColorStyle Q3DTheme::colorStyle() const
{
return d_ptr->m_colorStyle;
}
-void Q3DTheme::setType(QDataVis::Theme themeType)
+/*!
+ * \property Q3DTheme::type
+ *
+ * The type of the theme. Type is automatically set when constructing a theme. User should not
+ * need to use this when using C++ API.
+ */
+void Q3DTheme::setType(Theme themeType)
{
if (d_ptr->m_themeId != themeType) {
d_ptr->m_dirtyBits.themeIdDirty = true;
@@ -365,14 +857,14 @@ void Q3DTheme::setType(QDataVis::Theme themeType)
}
}
-QDataVis::Theme Q3DTheme::type() const
+Q3DTheme::Theme Q3DTheme::type() const
{
return d_ptr->m_themeId;
}
// Q3DThemePrivate
-Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, QDataVis::Theme theme_id)
+Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, Q3DTheme::Theme theme_id)
: QObject(0),
m_themeId(theme_id),
m_baseColor(Qt::white),
@@ -393,11 +885,11 @@ Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, QDataVis::Theme theme_id)
m_multiHighlightGradient(QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0)),
- m_lightStrength(0.5f),
+ m_lightStrength(5.0f),
m_ambientLightStrength(0.25f),
- m_highlightLightStrength(0.75f),
+ m_highlightLightStrength(7.5f),
m_labelBorders(true),
- m_colorStyle(QDataVis::ColorStyleUniform),
+ m_colorStyle(Q3DTheme::ColorStyleUniform),
m_font(QFont()),
m_backgoundEnabled(true),
m_gridEnabled(true),
@@ -422,16 +914,16 @@ void Q3DThemePrivate::resetDirtyBits()
m_dirtyBits.gridEnabledDirty = true;
m_dirtyBits.gridLineColorDirty = true;
m_dirtyBits.highlightLightStrengthDirty = true;
+ m_dirtyBits.labelBackgroundColorDirty = true;
m_dirtyBits.labelBackgroundEnabledDirty = true;
m_dirtyBits.labelBorderEnabledDirty = true;
+ m_dirtyBits.labelTextColorDirty = true;
m_dirtyBits.lightColorDirty = true;
m_dirtyBits.lightStrengthDirty = true;
m_dirtyBits.multiHighlightColorDirty = true;
m_dirtyBits.multiHighlightGradientDirty = true;
m_dirtyBits.singleHighlightColorDirty = true;
m_dirtyBits.singleHighlightGradientDirty = true;
- m_dirtyBits.textBackgroundColorDirty = true;
- m_dirtyBits.textColorDirty = true;
m_dirtyBits.themeIdDirty = true;
m_dirtyBits.windowColorDirty = true;
}
@@ -489,6 +981,11 @@ bool Q3DThemePrivate::sync(Q3DThemePrivate &other)
m_dirtyBits.highlightLightStrengthDirty = false;
changed = true;
}
+ if (m_dirtyBits.labelBackgroundColorDirty) {
+ other.q_ptr->setLabelBackgroundColor(m_textBackgroundColor);
+ m_dirtyBits.labelBackgroundColorDirty = false;
+ changed = true;
+ }
if (m_dirtyBits.labelBackgroundEnabledDirty) {
other.q_ptr->setLabelBackgroundEnabled(m_labelBackground);
m_dirtyBits.labelBackgroundEnabledDirty = false;
@@ -499,6 +996,11 @@ bool Q3DThemePrivate::sync(Q3DThemePrivate &other)
m_dirtyBits.labelBorderEnabledDirty = false;
changed = true;
}
+ if (m_dirtyBits.labelTextColorDirty) {
+ other.q_ptr->setLabelTextColor(m_textColor);
+ m_dirtyBits.labelTextColorDirty = false;
+ changed = true;
+ }
if (m_dirtyBits.lightColorDirty) {
other.q_ptr->setLightColor(m_lightColor);
m_dirtyBits.lightColorDirty = false;
@@ -529,16 +1031,6 @@ bool Q3DThemePrivate::sync(Q3DThemePrivate &other)
m_dirtyBits.singleHighlightGradientDirty = false;
changed = true;
}
- if (m_dirtyBits.textBackgroundColorDirty) {
- other.q_ptr->setTextBackgroundColor(m_textBackgroundColor);
- m_dirtyBits.textBackgroundColorDirty = false;
- changed = true;
- }
- if (m_dirtyBits.textColorDirty) {
- other.q_ptr->setTextColor(m_textColor);
- m_dirtyBits.textColorDirty = false;
- changed = true;
- }
if (m_dirtyBits.themeIdDirty) {
other.m_themeId = m_themeId; // Set directly to avoid a call to ThemeManager's useTheme()
m_dirtyBits.themeIdDirty = false;
diff --git a/src/datavisualization/theme/q3dtheme.h b/src/datavisualization/theme/q3dtheme.h
index ea6e0a4b..c3262b91 100644
--- a/src/datavisualization/theme/q3dtheme.h
+++ b/src/datavisualization/theme/q3dtheme.h
@@ -31,12 +31,14 @@ class Q3DThemePrivate;
class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
{
Q_OBJECT
- Q_PROPERTY(QtDataVisualization::QDataVis::Theme type READ type WRITE setType NOTIFY typeChanged)
+ Q_ENUMS(ColorStyle)
+ Q_ENUMS(Theme)
+ Q_PROPERTY(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 labelTextColor READ labelTextColor WRITE setLabelTextColor NOTIFY labelTextColorChanged)
+ Q_PROPERTY(QColor labelBackgroundColor READ labelBackgroundColor WRITE setLabelBackgroundColor NOTIFY labelBackgroundColorChanged)
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)
@@ -52,16 +54,35 @@ class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
Q_PROPERTY(bool backgroundEnabled READ isBackgroundEnabled WRITE setBackgroundEnabled NOTIFY backgroundEnabledChanged)
Q_PROPERTY(bool gridEnabled READ isGridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged)
Q_PROPERTY(bool labelBackgroundEnabled READ isLabelBackgroundEnabled WRITE setLabelBackgroundEnabled NOTIFY labelBackgroundEnabledChanged)
- Q_PROPERTY(QtDataVisualization::QDataVis::ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
- // TODO: Add everything that we need
+ Q_PROPERTY(ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
+ // TODO: Add everything we need (specularIntensity, lightDegradation, shaders?)
+
+public:
+ enum ColorStyle {
+ ColorStyleUniform = 0,
+ ColorStyleObjectGradient,
+ ColorStyleRangeGradient
+ };
+
+ enum Theme {
+ ThemeQt,
+ ThemePrimaryColors,
+ ThemeDigia,
+ ThemeStoneMoss,
+ ThemeArmyBlue,
+ ThemeRetro,
+ ThemeEbony,
+ ThemeIsabelle,
+ ThemeUserDefined
+ };
public:
explicit Q3DTheme(QObject *parent = 0);
- explicit Q3DTheme(QDataVis::Theme themeType, QObject *parent = 0);
+ explicit Q3DTheme(Theme themeType, QObject *parent = 0);
virtual ~Q3DTheme();
- void setType(QDataVis::Theme themeType);
- QDataVis::Theme type() const;
+ void setType(Theme themeType);
+ Theme type() const;
void setBaseColor(const QColor &color);
QColor baseColor() const;
@@ -72,11 +93,11 @@ public:
void setWindowColor(const QColor &color);
QColor windowColor() const;
- void setTextColor(const QColor &color);
- QColor textColor() const;
+ void setLabelTextColor(const QColor &color);
+ QColor labelTextColor() const;
- void setTextBackgroundColor(const QColor &color);
- QColor textBackgroundColor() const;
+ void setLabelBackgroundColor(const QColor &color);
+ QColor labelBackgroundColor() const;
void setGridLineColor(const QColor &color);
QColor gridLineColor() const;
@@ -123,16 +144,16 @@ public:
void setLabelBackgroundEnabled(bool enabled);
bool isLabelBackgroundEnabled() const;
- void setColorStyle(QDataVis::ColorStyle style);
- QDataVis::ColorStyle colorStyle() const;
+ void setColorStyle(ColorStyle style);
+ ColorStyle colorStyle() const;
signals:
- void typeChanged(QDataVis::Theme themeType);
+ void typeChanged(Theme themeType);
void baseColorChanged(QColor color);
void backgroundColorChanged(QColor color);
void windowColorChanged(QColor color);
- void textColorChanged(QColor color);
- void textBackgroundColorChanged(QColor color);
+ void labelTextColorChanged(QColor color);
+ void labelBackgroundColorChanged(QColor color);
void gridLineColorChanged(QColor color);
void singleHighlightColorChanged(QColor color);
void multiHighlightColorChanged(QColor color);
@@ -148,14 +169,10 @@ signals:
void backgroundEnabledChanged(bool enabled);
void gridEnabledChanged(bool enabled);
void labelBackgroundEnabledChanged(bool enabled);
- void colorStyleChanged(QDataVis::ColorStyle style);
-
- void needRender();
+ void colorStyleChanged(ColorStyle style);
protected:
- explicit Q3DTheme(Q3DThemePrivate *d,
- QDataVis::Theme themeType,
- QObject *parent = 0);
+ explicit Q3DTheme(Q3DThemePrivate *d, Theme themeType, QObject *parent = 0);
QScopedPointer<Q3DThemePrivate> d_ptr;
friend class ThemeManager;
diff --git a/src/datavisualization/theme/q3dtheme_p.h b/src/datavisualization/theme/q3dtheme_p.h
index 9107095c..1d2032fb 100644
--- a/src/datavisualization/theme/q3dtheme_p.h
+++ b/src/datavisualization/theme/q3dtheme_p.h
@@ -38,8 +38,8 @@ struct Q3DThemeDirtyBitField {
bool baseColorDirty : 1;
bool backgroundColorDirty : 1;
bool windowColorDirty : 1;
- bool textColorDirty : 1;
- bool textBackgroundColorDirty : 1;
+ bool labelTextColorDirty : 1;
+ bool labelBackgroundColorDirty : 1;
bool gridLineColorDirty : 1;
bool singleHighlightColorDirty : 1;
bool multiHighlightColorDirty : 1;
@@ -62,8 +62,8 @@ struct Q3DThemeDirtyBitField {
: baseColorDirty(false),
backgroundColorDirty(false),
windowColorDirty(false),
- textColorDirty(false),
- textBackgroundColorDirty(false),
+ labelTextColorDirty(false),
+ labelBackgroundColorDirty(false),
gridLineColorDirty(false),
singleHighlightColorDirty(false),
multiHighlightColorDirty(false),
@@ -90,15 +90,18 @@ class Q3DThemePrivate : public QObject
Q_OBJECT
public:
Q3DThemePrivate(Q3DTheme *q,
- QDataVis::Theme theme_id = QDataVis::ThemeUserDefined);
+ Q3DTheme::Theme theme_id = Q3DTheme::ThemeUserDefined);
virtual ~Q3DThemePrivate();
void resetDirtyBits();
bool sync(Q3DThemePrivate &other);
+signals:
+ void needRender();
+
public:
- QDataVis::Theme m_themeId;
+ Q3DTheme::Theme m_themeId;
Q3DThemeDirtyBitField m_dirtyBits;
@@ -118,7 +121,7 @@ public:
float m_ambientLightStrength;
float m_highlightLightStrength;
bool m_labelBorders;
- QDataVis::ColorStyle m_colorStyle;
+ Q3DTheme::ColorStyle m_colorStyle;
QFont m_font;
bool m_backgoundEnabled;
bool m_gridEnabled;
diff --git a/src/datavisualization/theme/thememanager.cpp b/src/datavisualization/theme/thememanager.cpp
index d552287b..644cedc9 100644
--- a/src/datavisualization/theme/thememanager.cpp
+++ b/src/datavisualization/theme/thememanager.cpp
@@ -39,15 +39,16 @@ void ThemeManager::setTheme(Q3DTheme *theme)
if (m_theme.data() != theme) {
// Disconnect old theme signal connections
if (m_theme) {
+ disconnect(m_theme->d_ptr.data(), 0, m_controller, 0);
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();
+ Q3DTheme::Theme type = m_theme->type();
- if (type != QDataVis::ThemeUserDefined) {
+ if (type != Q3DTheme::ThemeUserDefined) {
useTheme(type);
// Reset all bits to dirty for sync
m_theme->d_ptr->resetDirtyBits();
@@ -81,18 +82,19 @@ void ThemeManager::connectThemeSignals()
connect(m_theme.data(), &Q3DTheme::multiHighlightGradientChanged,
m_controller, &Abstract3DController::setMultiHighlightGradient);
- connect(m_theme.data(), &Q3DTheme::needRender, m_controller, &Abstract3DController::needRender);
+ connect(m_theme->d_ptr.data(), &Q3DThemePrivate::needRender,
+ m_controller, &Abstract3DController::needRender);
connect(m_theme.data(), &Q3DTheme::typeChanged, this, &ThemeManager::useTheme);
}
-void ThemeManager::useTheme(QDataVis::Theme type)
+void ThemeManager::useTheme(Q3DTheme::Theme type)
{
QColor color;
QLinearGradient gradient;
switch (type) {
- case QDataVis::ThemeQt: {
+ case Q3DTheme::ThemeQt: {
setBackgroundEnabled(true);
setGridEnabled(true);
setFont(QFont(QStringLiteral("Arial")));
@@ -110,7 +112,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
setAmbientLightStrength(0.5f);
setHighlightLightStrength(5.0f);
setLabelBorderEnabled(true);
- setColorStyle(QDataVis::ColorStyleUniform);
+ setColorStyle(Q3DTheme::ColorStyleUniform);
gradient = QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0);
@@ -135,7 +137,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
break;
}
- case QDataVis::ThemePrimaryColors: {
+ case Q3DTheme::ThemePrimaryColors: {
setBackgroundEnabled(true);
setGridEnabled(true);
setFont(QFont(QStringLiteral("Arial")));
@@ -153,7 +155,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
setAmbientLightStrength(0.5f);
setHighlightLightStrength(5.0f);
setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleUniform);
+ setColorStyle(Q3DTheme::ColorStyleUniform);
gradient = QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0);
@@ -178,7 +180,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
break;
}
- case QDataVis::ThemeDigia: {
+ case Q3DTheme::ThemeDigia: {
setBackgroundEnabled(true);
setGridEnabled(true);
setFont(QFont(QStringLiteral("Arial")));
@@ -196,7 +198,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
setAmbientLightStrength(0.5f);
setHighlightLightStrength(5.0f);
setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleObjectGradient);
+ setColorStyle(Q3DTheme::ColorStyleObjectGradient);
gradient = QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0);
@@ -221,7 +223,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
break;
}
- case QDataVis::ThemeStoneMoss: {
+ case Q3DTheme::ThemeStoneMoss: {
setBackgroundEnabled(true);
setGridEnabled(true);
setFont(QFont(QStringLiteral("Arial")));
@@ -239,7 +241,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
setAmbientLightStrength(0.5f);
setHighlightLightStrength(5.0f);
setLabelBorderEnabled(true);
- setColorStyle(QDataVis::ColorStyleUniform);
+ setColorStyle(Q3DTheme::ColorStyleUniform);
gradient = QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0);
@@ -264,7 +266,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
break;
}
- case QDataVis::ThemeArmyBlue: {
+ case Q3DTheme::ThemeArmyBlue: {
setBackgroundEnabled(true);
setGridEnabled(true);
setFont(QFont(QStringLiteral("Arial")));
@@ -282,7 +284,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
setAmbientLightStrength(0.5f);
setHighlightLightStrength(5.0f);
setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleObjectGradient);
+ setColorStyle(Q3DTheme::ColorStyleObjectGradient);
gradient = QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0);
@@ -307,7 +309,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
break;
}
- case QDataVis::ThemeRetro: {
+ case Q3DTheme::ThemeRetro: {
setBackgroundEnabled(true);
setGridEnabled(true);
setFont(QFont(QStringLiteral("Arial")));
@@ -325,7 +327,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
setAmbientLightStrength(0.5f);
setHighlightLightStrength(5.0f);
setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleObjectGradient);
+ setColorStyle(Q3DTheme::ColorStyleObjectGradient);
gradient = QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0);
@@ -350,7 +352,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
break;
}
- case QDataVis::ThemeEbony: {
+ case Q3DTheme::ThemeEbony: {
setBackgroundEnabled(true);
setGridEnabled(true);
setFont(QFont(QStringLiteral("Arial")));
@@ -368,7 +370,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
setAmbientLightStrength(0.5f);
setHighlightLightStrength(5.0f);
setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleUniform);
+ setColorStyle(Q3DTheme::ColorStyleUniform);
gradient = QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0);
@@ -393,7 +395,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
break;
}
- case QDataVis::ThemeIsabelle: {
+ case Q3DTheme::ThemeIsabelle: {
setBackgroundEnabled(true);
setGridEnabled(true);
setFont(QFont(QStringLiteral("Arial")));
@@ -411,7 +413,7 @@ void ThemeManager::useTheme(QDataVis::Theme type)
setAmbientLightStrength(0.5f);
setHighlightLightStrength(5.0f);
setLabelBorderEnabled(false);
- setColorStyle(QDataVis::ColorStyleUniform);
+ setColorStyle(Q3DTheme::ColorStyleUniform);
gradient = QLinearGradient(qreal(gradientTextureWidth),
qreal(gradientTextureHeight),
0.0, 0.0);
@@ -460,14 +462,14 @@ void ThemeManager::setWindowColor(const QColor &color)
void ThemeManager::setTextColor(const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.textColorDirty)
- m_theme->setTextColor(color);
+ if (!m_theme->d_ptr->m_dirtyBits.labelTextColorDirty)
+ m_theme->setLabelTextColor(color);
}
void ThemeManager::setTextBackgroundColor(const QColor &color)
{
- if (!m_theme->d_ptr->m_dirtyBits.textBackgroundColorDirty)
- m_theme->setTextBackgroundColor(color);
+ if (!m_theme->d_ptr->m_dirtyBits.labelBackgroundColorDirty)
+ m_theme->setLabelBackgroundColor(color);
}
void ThemeManager::setGridLineColor(const QColor &color)
@@ -560,7 +562,7 @@ void ThemeManager::setLabelBackgroundEnabled(bool enabled)
m_theme->setLabelBackgroundEnabled(enabled);
}
-void ThemeManager::setColorStyle(QDataVis::ColorStyle style)
+void ThemeManager::setColorStyle(Q3DTheme::ColorStyle style)
{
if (!m_theme->d_ptr->m_dirtyBits.colorStyleDirty)
m_theme->setColorStyle(style);
diff --git a/src/datavisualization/theme/thememanager_p.h b/src/datavisualization/theme/thememanager_p.h
index 33277105..4a394a4a 100644
--- a/src/datavisualization/theme/thememanager_p.h
+++ b/src/datavisualization/theme/thememanager_p.h
@@ -47,7 +47,7 @@ public:
protected:
void connectThemeSignals();
- void useTheme(QDataVis::Theme type);
+ void useTheme(Q3DTheme::Theme type);
void setBaseColor(const QColor &color);
void setBackgroundColor(const QColor &color);
void setWindowColor(const QColor &color);
@@ -68,7 +68,7 @@ protected:
void setBackgroundEnabled(bool enabled);
void setGridEnabled(bool enabled);
void setLabelBackgroundEnabled(bool enabled);
- void setColorStyle(QDataVis::ColorStyle style);
+ void setColorStyle(Q3DTheme::ColorStyle style);
private:
QScopedPointer<Q3DTheme> m_theme;