summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/theme
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/theme')
-rw-r--r--src/datavisualization/theme/builtin3dthemes.cpp230
-rw-r--r--src/datavisualization/theme/builtin3dthemes_p.h87
-rw-r--r--src/datavisualization/theme/q3dtheme.cpp1064
-rw-r--r--src/datavisualization/theme/q3dtheme.h188
-rw-r--r--src/datavisualization/theme/q3dtheme_p.h136
-rw-r--r--src/datavisualization/theme/theme.pri8
-rw-r--r--src/datavisualization/theme/thememanager.cpp552
-rw-r--r--src/datavisualization/theme/thememanager_p.h81
8 files changed, 2346 insertions, 0 deletions
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..3d85b9fa
--- /dev/null
+++ b/src/datavisualization/theme/q3dtheme.cpp
@@ -0,0 +1,1064 @@
+/****************************************************************************
+**
+** 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
+
+/*!
+ * \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 baseColors
+ * \li List of colors for the objects in the graph. Colors are applied to series one by one.
+ * If there are more series than colors, the color list is reused from the start.
+ * The colors in this property are used if colorStyle is ColorStyleUniform. This can be
+ * overridden by setting the baseColor explicitly in series.
+ * \li Qt::black
+ * \row
+ * \li baseGradients
+ * \li List of gradients for the objects in the graph. Gradients are applied to series one by
+ * one. If there are more series than gradients, the gradient list is reused from the start.
+ * The gradients in this property are 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 alpha release.
+ * \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::baseColors
+ *
+ * List of base colors to be used for all the objects in the graph, series by series. If there
+ * are more series than colors, color list wraps and starts again with the first color in the list.
+ * 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 alpha release.
+ */
+
+/*!
+ * \qmlproperty ColorGradient Theme3D::baseGradients
+ *
+ * List of base gradients to be used for all the objects in the graph, series by series. If there
+ * are more series than gradients, gradient list wraps and starts again with the first gradient in
+ * the list
+ * 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, ThemeUserDefined))
+{
+}
+
+/*!
+ * 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))
+{
+}
+
+/*!
+ * \internal
+ */
+Q3DTheme::Q3DTheme(Q3DThemePrivate *d, Theme themeType,
+ QObject *parent) :
+ QObject(parent),
+ d_ptr(d)
+{
+ 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)
+/*!
+ * \property Q3DTheme::baseColors
+ *
+ * List of base colors to be used for all the objects in the graph, series by series. If there
+ * are more series than colors, color list wraps and starts again with the first color in the list.
+ * Has no immediate effect if colorStyle is not ColorStyleUniform.
+ */
+void Q3DTheme::setBaseColors(const QList<QColor> &colors)
+{
+ if (colors.size()) {
+ d_ptr->m_dirtyBits.baseColorDirty = true;
+ if (d_ptr->m_baseColors != colors) {
+ d_ptr->m_baseColors.clear();
+ d_ptr->m_baseColors = colors;
+ emit baseColorsChanged(colors);
+ }
+ } else {
+ d_ptr->m_baseColors.clear();
+ }
+}
+
+QList<QColor> Q3DTheme::baseColors() const
+{
+ return d_ptr->m_baseColors;
+}
+
+/*!
+ * \property Q3DTheme::backgroundColor
+ *
+ * Color for the graph background.
+ */
+void Q3DTheme::setBackgroundColor(const QColor &color)
+{
+ d_ptr->m_dirtyBits.backgroundColorDirty = true;
+ if (d_ptr->m_backgroundColor != color) {
+ d_ptr->m_backgroundColor = color;
+ emit backgroundColorChanged(color);
+ emit d_ptr->needRender();
+ }
+}
+
+QColor Q3DTheme::backgroundColor() const
+{
+ return d_ptr->m_backgroundColor;
+}
+
+/*!
+ * \property Q3DTheme::windowColor
+ *
+ * Color for the application window.
+ */
+void Q3DTheme::setWindowColor(const QColor &color)
+{
+ d_ptr->m_dirtyBits.windowColorDirty = true;
+ if (d_ptr->m_windowColor != color) {
+ d_ptr->m_windowColor = color;
+ emit windowColorChanged(color);
+ emit d_ptr->needRender();
+ }
+}
+
+QColor Q3DTheme::windowColor() const
+{
+ return d_ptr->m_windowColor;
+}
+
+/*!
+ * \property Q3DTheme::labelTextColor
+ *
+ * Color for the font used for labels.
+ */
+void Q3DTheme::setLabelTextColor(const QColor &color)
+{
+ d_ptr->m_dirtyBits.labelTextColorDirty = true;
+ if (d_ptr->m_textColor != color) {
+ d_ptr->m_textColor = color;
+ emit labelTextColorChanged(color);
+ emit d_ptr->needRender();
+ }
+}
+
+QColor Q3DTheme::labelTextColor() const
+{
+ return d_ptr->m_textColor;
+}
+
+/*!
+ * \property Q3DTheme::labelBackgroundColor
+ *
+ * Color for the label backgrounds. Has no effect if labelBackgroundEnabled is \c false.
+ */
+void Q3DTheme::setLabelBackgroundColor(const QColor &color)
+{
+ d_ptr->m_dirtyBits.labelBackgroundColorDirty = true;
+ if (d_ptr->m_textBackgroundColor != color) {
+ d_ptr->m_textBackgroundColor = color;
+ emit labelBackgroundColorChanged(color);
+ emit d_ptr->needRender();
+ }
+}
+
+QColor Q3DTheme::labelBackgroundColor() const
+{
+ return d_ptr->m_textBackgroundColor;
+}
+
+/*!
+ * \property Q3DTheme::gridLineColor
+ *
+ * Color for the grid lines.
+ */
+void Q3DTheme::setGridLineColor(const QColor &color)
+{
+ d_ptr->m_dirtyBits.gridLineColorDirty = true;
+ if (d_ptr->m_gridLineColor != color) {
+ d_ptr->m_gridLineColor = color;
+ emit gridLineColorChanged(color);
+ emit d_ptr->needRender();
+ }
+}
+
+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)
+{
+ d_ptr->m_dirtyBits.singleHighlightColorDirty = true;
+ if (d_ptr->m_singleHighlightColor != color) {
+ d_ptr->m_singleHighlightColor = color;
+ emit singleHighlightColorChanged(color);
+ }
+}
+
+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)
+{
+ d_ptr->m_dirtyBits.multiHighlightColorDirty = true;
+ if (d_ptr->m_multiHighlightColor != color) {
+ d_ptr->m_multiHighlightColor = color;
+ emit multiHighlightColorChanged(color);
+ }
+}
+
+QColor Q3DTheme::multiHighlightColor() const
+{
+ return d_ptr->m_multiHighlightColor;
+}
+
+/*!
+ * \property Q3DTheme::lightColor
+ *
+ * Color for the specular light defined in Q3DScene.
+ *
+ * \warning Not supported in alpha release.
+ */
+void Q3DTheme::setLightColor(const QColor &color)
+{
+ d_ptr->m_dirtyBits.lightColorDirty = true;
+ if (d_ptr->m_lightColor != color) {
+ d_ptr->m_lightColor = color;
+ emit lightColorChanged(color);
+ emit d_ptr->needRender();
+ }
+}
+
+QColor Q3DTheme::lightColor() const
+{
+ return d_ptr->m_lightColor;
+}
+
+/*!
+ * \property Q3DTheme::baseGradients
+ *
+ * List of base gradients to be used for all the objects in the graph, series by series. If there
+ * are more series than gradients, gradient list wraps and starts again with the first gradient in
+ * the list
+ * Has no immediate effect if colorStyle is ColorStyleUniform.
+ */
+void Q3DTheme::setBaseGradients(const QList<QLinearGradient> &gradients)
+{
+ if (gradients.size()) {
+ d_ptr->m_dirtyBits.baseGradientDirty = true;
+ if (d_ptr->m_baseGradients != gradients) {
+ d_ptr->m_baseGradients.clear();
+ d_ptr->m_baseGradients = gradients;
+ emit baseGradientsChanged(gradients);
+ }
+ } else {
+ d_ptr->m_baseGradients.clear();
+ }
+}
+
+QList<QLinearGradient> Q3DTheme::baseGradients() const
+{
+ return d_ptr->m_baseGradients;
+}
+
+/*!
+ * \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)
+{
+ d_ptr->m_dirtyBits.singleHighlightGradientDirty = true;
+ if (d_ptr->m_singleHighlightGradient != gradient) {
+ d_ptr->m_singleHighlightGradient = gradient;
+ emit singleHighlightGradientChanged(gradient);
+ }
+}
+
+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)
+{
+ d_ptr->m_dirtyBits.multiHighlightGradientDirty = true;
+ if (d_ptr->m_multiHighlightGradient != gradient) {
+ d_ptr->m_multiHighlightGradient = gradient;
+ emit multiHighlightGradientChanged(gradient);
+ }
+}
+
+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)
+{
+ d_ptr->m_dirtyBits.lightStrengthDirty = true;
+ 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_lightStrength = strength;
+ emit lightStrengthChanged(strength);
+ emit d_ptr->needRender();
+ }
+}
+
+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)
+{
+ d_ptr->m_dirtyBits.ambientLightStrengthDirty = true;
+ 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_ambientLightStrength = strength;
+ emit ambientLightStrengthChanged(strength);
+ emit d_ptr->needRender();
+ }
+}
+
+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)
+{
+ d_ptr->m_dirtyBits.highlightLightStrengthDirty = true;
+ 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_highlightLightStrength = strength;
+ emit highlightLightStrengthChanged(strength);
+ emit d_ptr->needRender();
+ }
+}
+
+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)
+{
+ d_ptr->m_dirtyBits.labelBorderEnabledDirty = true;
+ if (d_ptr->m_labelBorders != enabled) {
+ d_ptr->m_labelBorders = enabled;
+ emit labelBorderEnabledChanged(enabled);
+ emit d_ptr->needRender();
+ }
+}
+
+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)
+{
+ d_ptr->m_dirtyBits.fontDirty = true;
+ if (d_ptr->m_font != font) {
+ d_ptr->m_font = font;
+ emit fontChanged(font);
+ emit d_ptr->needRender();
+ }
+}
+
+QFont Q3DTheme::font() const
+{
+ return d_ptr->m_font;
+}
+
+/*!
+ * \property Q3DTheme::backgroundEnabled
+ *
+ * Set background enabled or disabled.
+ */
+void Q3DTheme::setBackgroundEnabled(bool enabled)
+{
+ d_ptr->m_dirtyBits.backgroundEnabledDirty = true;
+ if (d_ptr->m_backgoundEnabled != enabled) {
+ d_ptr->m_backgoundEnabled = enabled;
+ emit backgroundEnabledChanged(enabled);
+ emit d_ptr->needRender();
+ }
+}
+
+bool Q3DTheme::isBackgroundEnabled() const
+{
+ return d_ptr->m_backgoundEnabled;
+}
+
+/*!
+ * \property Q3DTheme::gridEnabled
+ *
+ * Set grid lines enabled or disabled.
+ */
+void Q3DTheme::setGridEnabled(bool enabled)
+{
+ d_ptr->m_dirtyBits.gridEnabledDirty = true;
+ if (d_ptr->m_gridEnabled != enabled) {
+ d_ptr->m_gridEnabled = enabled;
+ emit gridEnabledChanged(enabled);
+ emit d_ptr->needRender();
+ }
+}
+
+bool Q3DTheme::isGridEnabled() const
+{
+ return d_ptr->m_gridEnabled;
+}
+
+/*!
+ * \property Q3DTheme::labelBackgroundEnabled
+ *
+ * Set label backgrounds enabled or disabled.
+ */
+void Q3DTheme::setLabelBackgroundEnabled(bool enabled)
+{
+ d_ptr->m_dirtyBits.labelBackgroundEnabledDirty = true;
+ if (d_ptr->m_labelBackground != enabled) {
+ d_ptr->m_labelBackground = enabled;
+ emit labelBackgroundEnabledChanged(enabled);
+ emit d_ptr->needRender();
+ }
+}
+
+bool Q3DTheme::isLabelBackgroundEnabled() const
+{
+ return d_ptr->m_labelBackground;
+}
+
+/*!
+ * \property Q3DTheme::colorStyle
+ *
+ * The \a style of the graph colors. One of ColorStyle.
+ */
+void Q3DTheme::setColorStyle(ColorStyle style)
+{
+ d_ptr->m_dirtyBits.colorStyleDirty = true;
+ if (d_ptr->m_colorStyle != style) {
+ d_ptr->m_colorStyle = style;
+ emit colorStyleChanged(style);
+ }
+}
+
+Q3DTheme::ColorStyle Q3DTheme::colorStyle() const
+{
+ return d_ptr->m_colorStyle;
+}
+
+/*!
+ * \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)
+{
+ d_ptr->m_dirtyBits.themeIdDirty = true;
+ if (d_ptr->m_themeId != themeType) {
+ d_ptr->m_themeId = themeType;
+ emit typeChanged(themeType);
+ }
+}
+
+Q3DTheme::Theme Q3DTheme::type() const
+{
+ return d_ptr->m_themeId;
+}
+
+// Q3DThemePrivate
+
+Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, Q3DTheme::Theme theme_id)
+ : QObject(0),
+ m_themeId(theme_id),
+ m_backgroundColor(Qt::black),
+ m_windowColor(Qt::black),
+ m_textColor(Qt::white),
+ m_textBackgroundColor(Qt::gray),
+ m_gridLineColor(Qt::white),
+ m_singleHighlightColor(Qt::red),
+ m_multiHighlightColor(Qt::blue),
+ m_lightColor(Qt::white),
+ m_singleHighlightGradient(QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0)),
+ m_multiHighlightGradient(QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0)),
+ m_lightStrength(5.0f),
+ m_ambientLightStrength(0.25f),
+ m_highlightLightStrength(7.5f),
+ m_labelBorders(true),
+ m_colorStyle(Q3DTheme::ColorStyleUniform),
+ m_font(QFont()),
+ m_backgoundEnabled(true),
+ m_gridEnabled(true),
+ m_labelBackground(true),
+ q_ptr(q)
+{
+ m_baseColors.append(QColor(Qt::black));
+ m_baseGradients.append(QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0));
+}
+
+Q3DThemePrivate::~Q3DThemePrivate()
+{
+}
+
+void Q3DThemePrivate::resetDirtyBits()
+{
+ m_dirtyBits.ambientLightStrengthDirty = true;
+ m_dirtyBits.backgroundColorDirty = true;
+ m_dirtyBits.backgroundEnabledDirty = true;
+ m_dirtyBits.baseColorDirty = true;
+ m_dirtyBits.baseGradientDirty = true;
+ m_dirtyBits.colorStyleDirty = true;
+ m_dirtyBits.fontDirty = true;
+ 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.themeIdDirty = true;
+ m_dirtyBits.windowColorDirty = true;
+}
+
+bool Q3DThemePrivate::sync(Q3DThemePrivate &other)
+{
+ bool changed = false;
+ if (m_dirtyBits.ambientLightStrengthDirty) {
+ other.q_ptr->setAmbientLightStrength(m_ambientLightStrength);
+ m_dirtyBits.ambientLightStrengthDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.backgroundColorDirty) {
+ other.q_ptr->setBackgroundColor(m_backgroundColor);
+ m_dirtyBits.backgroundColorDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.backgroundEnabledDirty) {
+ other.q_ptr->setBackgroundEnabled(m_backgoundEnabled);
+ m_dirtyBits.backgroundEnabledDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.baseColorDirty) {
+ other.q_ptr->setBaseColors(m_baseColors);
+ m_dirtyBits.baseColorDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.baseGradientDirty) {
+ other.q_ptr->setBaseGradients(m_baseGradients);
+ m_dirtyBits.baseGradientDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.colorStyleDirty) {
+ other.q_ptr->setColorStyle(m_colorStyle);
+ m_dirtyBits.colorStyleDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.fontDirty) {
+ other.q_ptr->setFont(m_font);
+ m_dirtyBits.fontDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.gridEnabledDirty) {
+ other.q_ptr->setGridEnabled(m_gridEnabled);
+ m_dirtyBits.gridEnabledDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.gridLineColorDirty) {
+ other.q_ptr->setGridLineColor(m_gridLineColor);
+ m_dirtyBits.gridLineColorDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.highlightLightStrengthDirty) {
+ other.q_ptr->setHighlightLightStrength(m_highlightLightStrength);
+ 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;
+ changed = true;
+ }
+ if (m_dirtyBits.labelBorderEnabledDirty) {
+ other.q_ptr->setLabelBorderEnabled(m_labelBorders);
+ 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;
+ changed = true;
+ }
+ if (m_dirtyBits.lightStrengthDirty) {
+ other.q_ptr->setLightStrength(m_lightStrength);
+ m_dirtyBits.lightStrengthDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.multiHighlightColorDirty) {
+ other.q_ptr->setMultiHighlightColor(m_multiHighlightColor);
+ m_dirtyBits.multiHighlightColorDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.multiHighlightGradientDirty) {
+ other.q_ptr->setMultiHighlightGradient(m_multiHighlightGradient);
+ m_dirtyBits.multiHighlightGradientDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.singleHighlightColorDirty) {
+ other.q_ptr->setSingleHighlightColor(m_singleHighlightColor);
+ m_dirtyBits.singleHighlightColorDirty = false;
+ changed = true;
+ }
+ if (m_dirtyBits.singleHighlightGradientDirty) {
+ other.q_ptr->setSingleHighlightGradient(m_singleHighlightGradient);
+ m_dirtyBits.singleHighlightGradientDirty = 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;
+ changed = true;
+ }
+ if (m_dirtyBits.windowColorDirty) {
+ other.q_ptr->setWindowColor(m_windowColor);
+ m_dirtyBits.windowColorDirty = false;
+ changed = true;
+ }
+ return changed;
+}
+
+QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/theme/q3dtheme.h b/src/datavisualization/theme/q3dtheme.h
new file mode 100644
index 00000000..44e58e5d
--- /dev/null
+++ b/src/datavisualization/theme/q3dtheme.h
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** 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>
+#include <QFont>
+#include <QColor>
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class Q3DThemePrivate;
+
+class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(ColorStyle)
+ Q_ENUMS(Theme)
+ Q_PROPERTY(Theme type READ type WRITE setType NOTIFY typeChanged)
+ Q_PROPERTY(QList<QColor> baseColors READ baseColors WRITE setBaseColors NOTIFY baseColorsChanged)
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
+ Q_PROPERTY(QColor windowColor READ windowColor WRITE setWindowColor NOTIFY windowColorChanged)
+ 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)
+ Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged) // TODO: Not used yet
+ Q_PROPERTY(QList<QLinearGradient> baseGradients READ baseGradients WRITE setBaseGradients NOTIFY baseGradientsChanged)
+ 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(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ 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(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(Theme themeType, QObject *parent = 0);
+ virtual ~Q3DTheme();
+
+ void setType(Theme themeType);
+ Theme type() const;
+
+ void setBaseColors(const QList<QColor> &colors);
+ QList<QColor> baseColors() const;
+
+ void setBackgroundColor(const QColor &color);
+ QColor backgroundColor() const;
+
+ void setWindowColor(const QColor &color);
+ QColor windowColor() const;
+
+ void setLabelTextColor(const QColor &color);
+ QColor labelTextColor() const;
+
+ void setLabelBackgroundColor(const QColor &color);
+ QColor labelBackgroundColor() 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 setBaseGradients(const QList<QLinearGradient> &gradients);
+ QList<QLinearGradient> baseGradients() 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 setFont(const QFont &font);
+ QFont font() const;
+
+ void setBackgroundEnabled(bool enabled);
+ bool isBackgroundEnabled() const;
+
+ void setGridEnabled(bool enabled);
+ bool isGridEnabled() const;
+
+ void setLabelBackgroundEnabled(bool enabled);
+ bool isLabelBackgroundEnabled() const;
+
+ void setColorStyle(ColorStyle style);
+ ColorStyle colorStyle() const;
+
+signals:
+ void typeChanged(Theme themeType);
+ void baseColorsChanged(QList<QColor> colors);
+ void backgroundColorChanged(QColor color);
+ void windowColorChanged(QColor color);
+ void labelTextColorChanged(QColor color);
+ void labelBackgroundColorChanged(QColor color);
+ void gridLineColorChanged(QColor color);
+ void singleHighlightColorChanged(QColor color);
+ void multiHighlightColorChanged(QColor color);
+ void lightColorChanged(QColor color);
+ void baseGradientsChanged(QList<QLinearGradient> gradients);
+ 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 fontChanged(QFont font);
+ void backgroundEnabledChanged(bool enabled);
+ void gridEnabledChanged(bool enabled);
+ void labelBackgroundEnabledChanged(bool enabled);
+ void colorStyleChanged(ColorStyle style);
+
+protected:
+ explicit Q3DTheme(Q3DThemePrivate *d, Theme themeType, QObject *parent = 0);
+ QScopedPointer<Q3DThemePrivate> d_ptr;
+
+ friend class ThemeManager;
+ friend class Abstract3DRenderer;
+ friend class Bars3DController;
+
+private:
+ Q_DISABLE_COPY(Q3DTheme)
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif
diff --git a/src/datavisualization/theme/q3dtheme_p.h b/src/datavisualization/theme/q3dtheme_p.h
new file mode 100644
index 00000000..c9f59d99
--- /dev/null
+++ b/src/datavisualization/theme/q3dtheme_p.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** 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 Q3DTHEME_P_H
+#define Q3DTHEME_P_H
+
+#include "datavisualizationglobal_p.h"
+#include "q3dtheme.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+struct Q3DThemeDirtyBitField {
+ bool baseColorDirty : 1;
+ bool backgroundColorDirty : 1;
+ bool windowColorDirty : 1;
+ bool labelTextColorDirty : 1;
+ bool labelBackgroundColorDirty : 1;
+ bool gridLineColorDirty : 1;
+ bool singleHighlightColorDirty : 1;
+ bool multiHighlightColorDirty : 1;
+ bool lightColorDirty : 1;
+ bool baseGradientDirty : 1;
+ bool singleHighlightGradientDirty : 1;
+ bool multiHighlightGradientDirty : 1;
+ bool lightStrengthDirty : 1;
+ bool ambientLightStrengthDirty : 1;
+ bool highlightLightStrengthDirty : 1;
+ bool labelBorderEnabledDirty : 1;
+ bool colorStyleDirty : 1;
+ bool fontDirty : 1;
+ bool backgroundEnabledDirty : 1;
+ bool gridEnabledDirty : 1;
+ bool labelBackgroundEnabledDirty : 1;
+ bool themeIdDirty : 1;
+
+ Q3DThemeDirtyBitField()
+ : baseColorDirty(false),
+ backgroundColorDirty(false),
+ windowColorDirty(false),
+ labelTextColorDirty(false),
+ labelBackgroundColorDirty(false),
+ gridLineColorDirty(false),
+ singleHighlightColorDirty(false),
+ multiHighlightColorDirty(false),
+ lightColorDirty(false),
+ baseGradientDirty(false),
+ singleHighlightGradientDirty(false),
+ multiHighlightGradientDirty(false),
+ lightStrengthDirty(false),
+ ambientLightStrengthDirty(false),
+ highlightLightStrengthDirty(false),
+ labelBorderEnabledDirty(false),
+ colorStyleDirty(false),
+ fontDirty(false),
+ backgroundEnabledDirty(false),
+ gridEnabledDirty(false),
+ labelBackgroundEnabledDirty(false),
+ themeIdDirty(false)
+ {
+ }
+};
+
+class Q3DThemePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ Q3DThemePrivate(Q3DTheme *q,
+ Q3DTheme::Theme theme_id = Q3DTheme::ThemeUserDefined);
+ virtual ~Q3DThemePrivate();
+
+ void resetDirtyBits();
+
+ bool sync(Q3DThemePrivate &other);
+
+signals:
+ void needRender();
+
+public:
+ Q3DTheme::Theme m_themeId;
+
+ Q3DThemeDirtyBitField m_dirtyBits;
+
+ QList<QColor> m_baseColors;
+ QColor m_backgroundColor;
+ QColor m_windowColor;
+ QColor m_textColor;
+ QColor m_textBackgroundColor;
+ QColor m_gridLineColor;
+ QColor m_singleHighlightColor;
+ QColor m_multiHighlightColor;
+ QColor m_lightColor;
+ QList<QLinearGradient> m_baseGradients;
+ QLinearGradient m_singleHighlightGradient;
+ QLinearGradient m_multiHighlightGradient;
+ float m_lightStrength;
+ float m_ambientLightStrength;
+ float m_highlightLightStrength;
+ bool m_labelBorders;
+ Q3DTheme::ColorStyle m_colorStyle;
+ QFont m_font;
+ bool m_backgoundEnabled;
+ bool m_gridEnabled;
+ bool m_labelBackground;
+
+protected:
+ Q3DTheme *q_ptr;
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif
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..cc5362ef
--- /dev/null
+++ b/src/datavisualization/theme/thememanager.cpp
@@ -0,0 +1,552 @@
+/****************************************************************************
+**
+** 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"
+#include "q3dtheme_p.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+const float defaultBuiltInColorLevel = 0.7f; // for built-in gradient themes
+const float defaultColorLevel = 0.5f; // for built-in uniform themes
+
+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->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);
+
+ Q3DTheme::Theme type = m_theme->type();
+
+ if (type != Q3DTheme::ThemeUserDefined) {
+ useTheme(type);
+ // Reset all bits to dirty for sync
+ m_theme->d_ptr->resetDirtyBits();
+ }
+
+ // Connect signals from new one
+ connectThemeSignals();
+ }
+}
+
+Q3DTheme *ThemeManager::theme() const
+{
+ return m_theme.data();
+}
+
+void ThemeManager::connectThemeSignals()
+{
+ connect(m_theme.data(), &Q3DTheme::colorStyleChanged,
+ m_controller, &Abstract3DController::handleThemeColorStyleChanged);
+ connect(m_theme.data(), &Q3DTheme::baseColorsChanged,
+ m_controller, &Abstract3DController::handleThemeBaseColorsChanged);
+ connect(m_theme.data(), &Q3DTheme::singleHighlightColorChanged,
+ m_controller, &Abstract3DController::handleThemeSingleHighlightColorChanged);
+ connect(m_theme.data(), &Q3DTheme::multiHighlightColorChanged,
+ m_controller, &Abstract3DController::handleThemeMultiHighlightColorChanged);
+ connect(m_theme.data(), &Q3DTheme::baseGradientsChanged,
+ m_controller, &Abstract3DController::handleThemeBaseGradientsChanged);
+ connect(m_theme.data(), &Q3DTheme::singleHighlightGradientChanged,
+ m_controller, &Abstract3DController::handleThemeSingleHighlightGradientChanged);
+ connect(m_theme.data(), &Q3DTheme::multiHighlightGradientChanged,
+ m_controller, &Abstract3DController::handleThemeMultiHighlightGradientChanged);
+
+ connect(m_theme->d_ptr.data(), &Q3DThemePrivate::needRender,
+ m_controller, &Abstract3DController::needRender);
+
+ connect(m_theme.data(), &Q3DTheme::typeChanged, this, &ThemeManager::useTheme);
+}
+
+void ThemeManager::useTheme(Q3DTheme::Theme type)
+{
+ switch (type) {
+ case Q3DTheme::ThemeQt: {
+ QList<QColor> baseColors;
+ baseColors.append(QColor(QRgb(0x80c342)));
+ baseColors.append(QColor(QRgb(0x469835)));
+ baseColors.append(QColor(QRgb(0x006325)));
+ baseColors.append(QColor(QRgb(0x5caa15)));
+ baseColors.append(QColor(QRgb(0x328930)));
+
+ QList<QLinearGradient> baseGradients;
+ baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
+
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
+ setBaseColors(baseColors);
+ 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(Q3DTheme::ColorStyleUniform);
+ setBaseGradients(baseGradients);
+ setSingleHighlightGradient(createGradient(QColor(QRgb(0x14aaff)), defaultColorLevel));
+ setMultiHighlightGradient(createGradient(QColor(QRgb(0x6400aa)), defaultColorLevel));
+ break;
+ }
+
+ case Q3DTheme::ThemePrimaryColors: {
+ QList<QColor> baseColors;
+ baseColors.append(QColor(QRgb(0xffe400)));
+ baseColors.append(QColor(QRgb(0xfaa106)));
+ baseColors.append(QColor(QRgb(0xf45f0d)));
+ baseColors.append(QColor(QRgb(0xfcba04)));
+ baseColors.append(QColor(QRgb(0xf7800a)));
+
+ QList<QLinearGradient> baseGradients;
+ baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
+
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
+ setBaseColors(baseColors);
+ 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(Q3DTheme::ColorStyleUniform);
+ setBaseGradients(baseGradients);
+ setSingleHighlightGradient(createGradient(QColor(QRgb(0x27beee)), defaultColorLevel));
+ setMultiHighlightGradient(createGradient(QColor(QRgb(0xee1414)), defaultColorLevel));
+ break;
+ }
+
+ case Q3DTheme::ThemeDigia: {
+ QList<QColor> baseColors;
+ baseColors.append(QColor(QRgb(0xeaeaea)));
+ baseColors.append(QColor(QRgb(0xa0a0a0)));
+ baseColors.append(QColor(QRgb(0x626262)));
+ baseColors.append(QColor(QRgb(0xbebebe)));
+ baseColors.append(QColor(QRgb(0x818181)));
+
+ QList<QLinearGradient> baseGradients;
+ baseGradients.append(createGradient(baseColors.at(0), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(1), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(2), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(3), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(4), defaultBuiltInColorLevel));
+
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
+ setBaseColors(baseColors);
+ 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(0x333333)));
+ setLightStrength(5.0f);
+ setAmbientLightStrength(0.5f);
+ setHighlightLightStrength(5.0f);
+ setLabelBorderEnabled(false);
+ setColorStyle(Q3DTheme::ColorStyleObjectGradient);
+ setBaseGradients(baseGradients);
+ setSingleHighlightGradient(createGradient(QColor(QRgb(0xfa0000)), defaultBuiltInColorLevel));
+ setMultiHighlightGradient(createGradient(QColor(QRgb(0x333333)), defaultBuiltInColorLevel));
+ break;
+ }
+
+ case Q3DTheme::ThemeStoneMoss: {
+ QList<QColor> baseColors;
+ baseColors.append(QColor(QRgb(0xbeb32b)));
+ baseColors.append(QColor(QRgb(0x928327)));
+ baseColors.append(QColor(QRgb(0x665423)));
+ baseColors.append(QColor(QRgb(0xa69929)));
+ baseColors.append(QColor(QRgb(0x7c6c25)));
+
+ QList<QLinearGradient> baseGradients;
+ baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
+
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
+ setBaseColors(baseColors);
+ 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(Q3DTheme::ColorStyleUniform);
+ setBaseGradients(baseGradients);
+ setSingleHighlightGradient(createGradient(QColor(QRgb(0xfbf6d6)), defaultColorLevel));
+ setMultiHighlightGradient(createGradient(QColor(QRgb(0x442f20)), defaultColorLevel));
+ break;
+ }
+
+ case Q3DTheme::ThemeArmyBlue: {
+ QList<QColor> baseColors;
+ baseColors.append(QColor(QRgb(0x495f76)));
+ baseColors.append(QColor(QRgb(0x81909f)));
+ baseColors.append(QColor(QRgb(0xbec5cd)));
+ baseColors.append(QColor(QRgb(0x687a8d)));
+ baseColors.append(QColor(QRgb(0xa3aeb9)));
+
+ QList<QLinearGradient> baseGradients;
+ baseGradients.append(createGradient(baseColors.at(0), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(1), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(2), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(3), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(4), defaultBuiltInColorLevel));
+
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
+ setBaseColors(baseColors);
+ 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(Q3DTheme::ColorStyleObjectGradient);
+ setBaseGradients(baseGradients);
+ setSingleHighlightGradient(createGradient(QColor(QRgb(0x2aa2f9)), defaultBuiltInColorLevel));
+ setMultiHighlightGradient(createGradient(QColor(QRgb(0x103753)), defaultBuiltInColorLevel));
+ break;
+ }
+
+ case Q3DTheme::ThemeRetro: {
+ QList<QColor> baseColors;
+ baseColors.append(QColor(QRgb(0x533b23)));
+ baseColors.append(QColor(QRgb(0x83715a)));
+ baseColors.append(QColor(QRgb(0xb3a690)));
+ baseColors.append(QColor(QRgb(0x6b563e)));
+ baseColors.append(QColor(QRgb(0x9b8b75)));
+
+ QList<QLinearGradient> baseGradients;
+ baseGradients.append(createGradient(baseColors.at(0), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(1), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(2), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(3), defaultBuiltInColorLevel));
+ baseGradients.append(createGradient(baseColors.at(4), defaultBuiltInColorLevel));
+
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
+ setBaseColors(baseColors);
+ 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(Q3DTheme::ColorStyleObjectGradient);
+ setBaseGradients(baseGradients);
+ setSingleHighlightGradient(createGradient(QColor(QRgb(0x8ea317)), defaultBuiltInColorLevel));
+ setMultiHighlightGradient(createGradient(QColor(QRgb(0xc25708)), defaultBuiltInColorLevel));
+ break;
+ }
+
+ case Q3DTheme::ThemeEbony: {
+ QList<QColor> baseColors;
+ baseColors.append(QColor(QRgb(0xffffff)));
+ baseColors.append(QColor(QRgb(0x999999)));
+ baseColors.append(QColor(QRgb(0x474747)));
+ baseColors.append(QColor(QRgb(0xc7c7c7)));
+ baseColors.append(QColor(QRgb(0x6b6b6b)));
+
+ QList<QLinearGradient> baseGradients;
+ baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
+
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
+ setBaseColors(baseColors);
+ 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(Q3DTheme::ColorStyleUniform);
+ setBaseGradients(baseGradients);
+ setSingleHighlightGradient(createGradient(QColor(QRgb(0xf5dc0d)), defaultColorLevel));
+ setMultiHighlightGradient(createGradient(QColor(QRgb(0xd72222)), defaultColorLevel));
+ break;
+ }
+
+ case Q3DTheme::ThemeIsabelle: {
+ QList<QColor> baseColors;
+ baseColors.append(QColor(QRgb(0xf9d900)));
+ baseColors.append(QColor(QRgb(0xf09603)));
+ baseColors.append(QColor(QRgb(0xe85506)));
+ baseColors.append(QColor(QRgb(0xf5b802)));
+ baseColors.append(QColor(QRgb(0xec7605)));
+
+ QList<QLinearGradient> baseGradients;
+ baseGradients.append(createGradient(baseColors.at(0), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(1), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(2), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(3), defaultColorLevel));
+ baseGradients.append(createGradient(baseColors.at(4), defaultColorLevel));
+
+ setBackgroundEnabled(true);
+ setGridEnabled(true);
+ setFont(QFont(QStringLiteral("Arial")));
+ setLabelBackgroundEnabled(true);
+ setLightColor(Qt::white);
+ setBaseColors(baseColors);
+ 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(Q3DTheme::ColorStyleUniform);
+ setBaseGradients(baseGradients);
+ setSingleHighlightGradient(createGradient(QColor(QRgb(0xfff7cc)), defaultColorLevel));
+ setMultiHighlightGradient(createGradient(QColor(QRgb(0xde0a0a)), defaultColorLevel));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+QLinearGradient ThemeManager::createGradient(const QColor &color, float colorLevel)
+{
+ QColor startColor;
+ QLinearGradient gradient = QLinearGradient(qreal(gradientTextureWidth),
+ qreal(gradientTextureHeight),
+ 0.0, 0.0);;
+ startColor.setRed(color.red() * colorLevel);
+ startColor.setGreen(color.green() * colorLevel);
+ startColor.setBlue(color.blue() * colorLevel);
+ gradient.setColorAt(0.0, startColor);
+ gradient.setColorAt(1.0, color);
+ return gradient;
+}
+
+void ThemeManager::setBaseColors(const QList<QColor> &colors)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.baseColorDirty)
+ m_theme->setBaseColors(colors);
+}
+
+void ThemeManager::setBackgroundColor(const QColor &color)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.backgroundColorDirty)
+ m_theme->setBackgroundColor(color);
+}
+
+void ThemeManager::setWindowColor(const QColor &color)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.windowColorDirty)
+ m_theme->setWindowColor(color);
+}
+
+void ThemeManager::setTextColor(const QColor &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.labelBackgroundColorDirty)
+ m_theme->setLabelBackgroundColor(color);
+}
+
+void ThemeManager::setGridLineColor(const QColor &color)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.gridLineColorDirty)
+ m_theme->setGridLineColor(color);
+}
+
+void ThemeManager::setSingleHighlightColor(const QColor &color)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.singleHighlightColorDirty)
+ m_theme->setSingleHighlightColor(color);
+}
+
+void ThemeManager::setMultiHighlightColor(const QColor &color)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.multiHighlightColorDirty)
+ m_theme->setMultiHighlightColor(color);
+}
+
+void ThemeManager::setLightColor(const QColor &color)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.lightColorDirty)
+ m_theme->setLightColor(color);
+}
+
+void ThemeManager::setBaseGradients(const QList<QLinearGradient> &gradients)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.baseGradientDirty)
+ m_theme->setBaseGradients(gradients);
+}
+
+void ThemeManager::setSingleHighlightGradient(const QLinearGradient &gradient)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.singleHighlightGradientDirty)
+ m_theme->setSingleHighlightGradient(gradient);
+}
+
+void ThemeManager::setMultiHighlightGradient(const QLinearGradient &gradient)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.multiHighlightGradientDirty)
+ m_theme->setMultiHighlightGradient(gradient);
+}
+
+void ThemeManager::setLightStrength(float strength)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.lightStrengthDirty)
+ m_theme->setLightStrength(strength);
+}
+
+void ThemeManager::setAmbientLightStrength(float strength)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.ambientLightStrengthDirty)
+ m_theme->setAmbientLightStrength(strength);
+}
+
+void ThemeManager::setHighlightLightStrength(float strength)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.highlightLightStrengthDirty)
+ m_theme->setHighlightLightStrength(strength);
+}
+
+void ThemeManager::setLabelBorderEnabled(bool enabled)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.labelBorderEnabledDirty)
+ m_theme->setLabelBorderEnabled(enabled);
+}
+
+void ThemeManager::setFont(const QFont &font)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.fontDirty)
+ m_theme->setFont(font);
+}
+
+void ThemeManager::setBackgroundEnabled(bool enabled)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.backgroundEnabledDirty)
+ m_theme->setBackgroundEnabled(enabled);
+}
+
+void ThemeManager::setGridEnabled(bool enabled)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.gridEnabledDirty)
+ m_theme->setGridEnabled(enabled);
+}
+
+void ThemeManager::setLabelBackgroundEnabled(bool enabled)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.labelBackgroundEnabledDirty)
+ m_theme->setLabelBackgroundEnabled(enabled);
+}
+
+void ThemeManager::setColorStyle(Q3DTheme::ColorStyle style)
+{
+ if (!m_theme->d_ptr->m_dirtyBits.colorStyleDirty)
+ m_theme->setColorStyle(style);
+}
+
+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..c6e6a107
--- /dev/null
+++ b/src/datavisualization/theme/thememanager_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** 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(Q3DTheme::Theme type);
+ QLinearGradient createGradient(const QColor &color, float colorLevel);
+ void setBaseColors(const QList<QColor> &colors);
+ void setBackgroundColor(const QColor &color);
+ void setWindowColor(const QColor &color);
+ void setTextColor(const QColor &color);
+ void setTextBackgroundColor(const QColor &color);
+ void setGridLineColor(const QColor &color);
+ void setSingleHighlightColor(const QColor &color);
+ void setMultiHighlightColor(const QColor &color);
+ void setLightColor(const QColor &color);
+ void setBaseGradients(const QList<QLinearGradient> &gradients);
+ void setSingleHighlightGradient(const QLinearGradient &gradient);
+ void setMultiHighlightGradient(const QLinearGradient &gradient);
+ void setLightStrength(float strength);
+ void setAmbientLightStrength(float strength);
+ void setHighlightLightStrength(float strength);
+ void setLabelBorderEnabled(bool enabled);
+ void setFont(const QFont &font);
+ void setBackgroundEnabled(bool enabled);
+ void setGridEnabled(bool enabled);
+ void setLabelBackgroundEnabled(bool enabled);
+ void setColorStyle(Q3DTheme::ColorStyle style);
+
+private:
+ QScopedPointer<Q3DTheme> m_theme;
+ Abstract3DController *m_controller;
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif