summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/theme/q3dtheme.cpp
blob: e43eb52d99b66901b6722beb282bd71f63f63c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the QtDataVisualization module.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
**
****************************************************************************/

#include "q3dtheme_p.h"

QT_DATAVISUALIZATION_BEGIN_NAMESPACE

Q3DTheme::Q3DTheme(QObject *parent)
    : QObject(parent),
      d_ptr(new Q3DThemePrivate(this, QDataVis::ThemeUserDefined))
{
}

Q3DTheme::Q3DTheme(QDataVis::Theme themeType, QObject *parent)
    : QObject(parent),
      d_ptr(new Q3DThemePrivate(this, themeType))
{
}

Q3DTheme::Q3DTheme(Q3DThemePrivate *d, QDataVis::Theme themeType,
                   QObject *parent) :
    QObject(parent),
    d_ptr(d)
{
    d_ptr->m_themeId = themeType;
}

Q3DTheme::~Q3DTheme()
{

}

// TODO: Basecolors as a list, containing one for each series?
void Q3DTheme::setBaseColor(const QColor &color)
{
    if (d_ptr->m_baseColor != color) {
        d_ptr->m_dirtyBits.baseColorDirty = true;
        d_ptr->m_baseColor = color;
        emit baseColorChanged(color);
    }
}

QColor Q3DTheme::baseColor() const
{
    return d_ptr->m_baseColor;
}

void Q3DTheme::setBackgroundColor(const QColor &color)
{
    if (d_ptr->m_backgroundColor != color) {
        d_ptr->m_dirtyBits.backgroundColorDirty = true;
        d_ptr->m_backgroundColor = color;
        emit backgroundColorChanged(color);
    }
}

QColor Q3DTheme::backgroundColor() const
{
    return d_ptr->m_backgroundColor;
}

void Q3DTheme::setWindowColor(const QColor &color)
{
    if (d_ptr->m_windowColor != color) {
        d_ptr->m_dirtyBits.windowColorDirty = true;
        d_ptr->m_windowColor = color;
        emit windowColorChanged(color);
    }
}

QColor Q3DTheme::windowColor() const
{
    return d_ptr->m_windowColor;
}

void Q3DTheme::setTextColor(const QColor &color)
{
    if (d_ptr->m_textColor != color) {
        d_ptr->m_dirtyBits.textColorDirty = true;
        d_ptr->m_textColor = color;
        emit textColorChanged(color);
    }
}

QColor Q3DTheme::textColor() const
{
    return d_ptr->m_textColor;
}

void Q3DTheme::setTextBackgroundColor(const QColor &color)
{
    if (d_ptr->m_textBackgroundColor != color) {
        d_ptr->m_dirtyBits.textBackgroundColorDirty = true;
        d_ptr->m_textBackgroundColor = color;
        emit textBackgroundColorChanged(color);
    }
}

QColor Q3DTheme::textBackgroundColor() const
{
    return d_ptr->m_textBackgroundColor;
}

void Q3DTheme::setGridLineColor(const QColor &color)
{
    if (d_ptr->m_gridLineColor != color) {
        d_ptr->m_dirtyBits.gridLineColorDirty = true;
        d_ptr->m_gridLineColor = color;
        emit gridLineColorChanged(color);
    }
}

QColor Q3DTheme::gridLineColor() const
{
    return d_ptr->m_gridLineColor;
}

void Q3DTheme::setSingleHighlightColor(const QColor &color)
{
    if (d_ptr->m_singleHighlightColor != color) {
        d_ptr->m_dirtyBits.singleHighlightColorDirty = true;
        d_ptr->m_singleHighlightColor = color;
        emit singleHighlightColorChanged(color);
    }
}

QColor Q3DTheme::singleHighlightColor() const
{
    return d_ptr->m_singleHighlightColor;
}

void Q3DTheme::setMultiHighlightColor(const QColor &color)
{
    if (d_ptr->m_multiHighlightColor != color) {
        d_ptr->m_dirtyBits.multiHighlightColorDirty = true;
        d_ptr->m_multiHighlightColor = color;
        emit multiHighlightColorChanged(color);
    }
}

QColor Q3DTheme::multiHighlightColor() const
{
    return d_ptr->m_multiHighlightColor;
}

void Q3DTheme::setLightColor(const QColor &color)
{
    if (d_ptr->m_lightColor != color) {
        d_ptr->m_dirtyBits.lightColorDirty = true;
        d_ptr->m_lightColor = color;
        emit lightColorChanged(color);
    }
}

QColor Q3DTheme::lightColor() const
{
    return d_ptr->m_lightColor;
}

// TODO: Surfacegradients as a list, containing one for each series?
void Q3DTheme::setBaseGradient(const QLinearGradient &gradient)
{
    if (d_ptr->m_baseGradient != gradient) {
        d_ptr->m_dirtyBits.baseGradientDirty = true;
        d_ptr->m_baseGradient = gradient;
        emit baseGradientChanged(gradient);
    }
}

QLinearGradient Q3DTheme::baseGradient() const
{
    return d_ptr->m_baseGradient;
}

void Q3DTheme::setSingleHighlightGradient(const QLinearGradient &gradient)
{
    if (d_ptr->m_singleHighlightGradient != gradient) {
        d_ptr->m_dirtyBits.singleHighlightGradientDirty = true;
        d_ptr->m_singleHighlightGradient = gradient;
        emit singleHighlightGradientChanged(gradient);
    }
}

QLinearGradient Q3DTheme::singleHighlightGradient() const
{
    return d_ptr->m_singleHighlightGradient;
}

void Q3DTheme::setMultiHighlightGradient(const QLinearGradient &gradient)
{
    if (d_ptr->m_multiHighlightGradient != gradient) {
        d_ptr->m_dirtyBits.multiHighlightGradientDirty = true;
        d_ptr->m_multiHighlightGradient = gradient;
        emit multiHighlightGradientChanged(gradient);
    }
}

QLinearGradient Q3DTheme::multiHighlightGradient() const
{
    return d_ptr->m_multiHighlightGradient;
}

void Q3DTheme::setLightStrength(float strength)
{
    if (d_ptr->m_lightStrength != strength) {
        d_ptr->m_dirtyBits.lightStrengthDirty = true;
        d_ptr->m_lightStrength = strength;
        emit lightStrengthChanged(strength);
    }
}

float Q3DTheme::lightStrength() const
{
    return d_ptr->m_lightStrength;
}

void Q3DTheme::setAmbientLightStrength(float strength)
{
    if (d_ptr->m_ambientLightStrength != strength) {
        d_ptr->m_dirtyBits.ambientLightStrengthDirty = true;
        d_ptr->m_ambientLightStrength = strength;
        emit ambientLightStrengthChanged(strength);
    }
}

float Q3DTheme::ambientLightStrength() const
{
    return d_ptr->m_ambientLightStrength;
}

void Q3DTheme::setHighlightLightStrength(float strength)
{
    if (d_ptr->m_highlightLightStrength != strength) {
        d_ptr->m_dirtyBits.highlightLightStrengthDirty = true;
        d_ptr->m_highlightLightStrength = strength;
        emit highlightLightStrengthChanged(strength);
    }
}

float Q3DTheme::highlightLightStrength() const
{
    return d_ptr->m_highlightLightStrength;
}

void Q3DTheme::setLabelBorderEnabled(bool enabled)
{
    if (d_ptr->m_labelBorders != enabled) {
        d_ptr->m_dirtyBits.labelBorderEnabledDirty = true;
        d_ptr->m_labelBorders = enabled;
        emit labelBorderEnabledChanged(enabled);
    }
}

bool Q3DTheme::isLabelBorderEnabled() const
{
    return d_ptr->m_labelBorders;
}

void Q3DTheme::setColorStyle(QDataVis::ColorStyle style)
{
    if (d_ptr->m_colorStyle != style) {
        d_ptr->m_dirtyBits.colorStyleDirty = true;
        d_ptr->m_colorStyle = style;
        emit colorStyleChanged(style);
    }
}

QDataVis::ColorStyle Q3DTheme::colorStyle() const
{
    return d_ptr->m_colorStyle;
}

void Q3DTheme::setType(QDataVis::Theme themeType)
{
    if (d_ptr->m_themeId != themeType) {
        d_ptr->m_themeId = themeType;
        emit typeChanged(themeType);
    }
}

QDataVis::Theme Q3DTheme::type() const
{
    return d_ptr->m_themeId;
}

// Q3DThemePrivate

Q3DThemePrivate::Q3DThemePrivate(Q3DTheme *q, QDataVis::Theme theme_id)
    : QObject(0),
      m_themeId(theme_id),
      m_baseGradient(QLinearGradient(qreal(gradientTextureWidth),
                                     qreal(gradientTextureHeight),
                                     0.0, 0.0)),
      m_singleHighlightGradient(QLinearGradient(qreal(gradientTextureWidth),
                                                qreal(gradientTextureHeight),
                                                0.0, 0.0)),
      m_multiHighlightGradient(QLinearGradient(qreal(gradientTextureWidth),
                                               qreal(gradientTextureHeight),
                                               0.0, 0.0)),
      q_ptr(q)
{
}

Q3DThemePrivate::~Q3DThemePrivate()
{
}

QT_DATAVISUALIZATION_END_NAMESPACE