1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Data Visualization module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#include "qabstract3dseries_p.h"
31#include "qabstractdataproxy_p.h"
32#include "abstract3dcontroller_p.h"
33
34QT_BEGIN_NAMESPACE_DATAVISUALIZATION
35
36/*!
37 * \class QAbstract3DSeries
38 * \inmodule QtDataVisualization
39 * \brief The QAbstract3DSeries class is a base class for all data series.
40 * \since QtDataVisualization 1.0
41 *
42 * There are inherited classes for each supported series type: QBar3DSeries,
43 * QScatter3DSeries, and QSurface3DSeries.
44 *
45 * For more information, see \l{Qt Data Visualization Data Handling}.
46 */
47
48/*!
49 * \class QAbstract3DSeriesChangeBitField
50 * \internal
51 */
52
53/*!
54 * \class QAbstract3DSeriesThemeOverrideBitField
55 * \internal
56 */
57
58/*!
59 * \qmltype Abstract3DSeries
60 * \inqmlmodule QtDataVisualization
61 * \since QtDataVisualization 1.0
62 * \ingroup datavisualization_qml
63 * \instantiates QAbstract3DSeries
64 * \brief A base type for all data series.
65 *
66 * This type is uncreatable, but contains properties that are exposed via the
67 * following subtypes: Bar3DSeries, Scatter3DSeries, and Surface3DSeries.
68 *
69 * For more information, see \l{Qt Data Visualization Data Handling}.
70 */
71
72/*!
73 * \enum QAbstract3DSeries::SeriesType
74 *
75 * Type of the series.
76 *
77 * \value SeriesTypeNone
78 * No series type.
79 * \value SeriesTypeBar
80 * Series type for Q3DBars.
81 * \value SeriesTypeScatter
82 * Series type for Q3DScatter.
83 * \value SeriesTypeSurface
84 * Series type for Q3DSurface.
85 */
86
87/*!
88 * \enum QAbstract3DSeries::Mesh
89 *
90 * Predefined mesh types. All styles are not usable with all visualization types.
91 *
92 * \value MeshUserDefined
93 * User defined mesh, set via QAbstract3DSeries::userDefinedMesh property.
94 * \value MeshBar
95 * Basic rectangular bar.
96 * \value MeshCube
97 * Basic cube.
98 * \value MeshPyramid
99 * Four-sided pyramid.
100 * \value MeshCone
101 * Basic cone.
102 * \value MeshCylinder
103 * Basic cylinder.
104 * \value MeshBevelBar
105 * Slightly beveled (rounded) rectangular bar.
106 * \value MeshBevelCube
107 * Slightly beveled (rounded) cube.
108 * \value MeshSphere
109 * Sphere.
110 * \value MeshMinimal
111 * The minimal 3D mesh: a triangular pyramid. Usable only with Q3DScatter.
112 * \value MeshArrow
113 * Arrow pointing upwards.
114 * \value MeshPoint
115 * 2D point. Usable only with Q3DScatter.
116 * Shadows do not affect this style. Color style Q3DTheme::ColorStyleObjectGradient
117 * is not supported by this style.
118 */
119
120/*!
121 * \qmlproperty Abstract3DSeries.SeriesType Abstract3DSeries::type
122 * The type of the series. One of the QAbstract3DSeries::SeriesType values.
123 *
124 */
125
126/*!
127 * \qmlproperty string Abstract3DSeries::itemLabelFormat
128 *
129 * The label format for data items in this series. This format is used for single item labels,
130 * for example, when an item is selected. How the format is interpreted depends
131 * on series type: Bar3DSeries, Scatter3DSeries, Surface3DSeries.
132 */
133
134/*!
135 * \qmlproperty bool Abstract3DSeries::visible
136 * Sets the visibility of the series. If \c false, the series is not rendered.
137 */
138
139/*!
140 * \qmlproperty Abstract3DSeries.Mesh Abstract3DSeries::mesh
141 *
142 * Sets the mesh of the items in the series, or the selection pointer in case of
143 * Surface3DSeries. If the mesh is \l{QAbstract3DSeries::MeshUserDefined}{Abstract3DSeries.MeshUserDefined},
144 * then the userDefinedMesh property must also be set for items to render properly.
145 * The default value depends on the graph type.
146 *
147 * \sa QAbstract3DSeries::Mesh
148 */
149
150/*!
151 * \qmlproperty bool Abstract3DSeries::meshSmooth
152 *
153 * If \c true, smooth versions of predefined meshes set via the \l mesh property are used.
154 * This property does not affect custom meshes used when the mesh is set to
155 * \l{QAbstract3DSeries::MeshUserDefined}{Abstract3DSeries.MeshUserDefined}.
156 * Defaults to \c{false}.
157 */
158
159/*!
160 * \qmlproperty quaternion Abstract3DSeries::meshRotation
161 *
162 * Sets the mesh rotation that is applied to all items of the series.
163 * The rotation should be a normalized quaternion.
164 * For those series types that support item specific rotation, the rotations are
165 * multiplied together.
166 * Bar3DSeries ignores any rotation that is not around the y-axis.
167 * Surface3DSeries applies the rotation only to the selection pointer.
168 * Defaults to no rotation.
169 */
170
171/*!
172 * \qmlproperty string Abstract3DSeries::userDefinedMesh
173 *
174 * Sets the filename for a user defined custom mesh for objects that is used when \l mesh
175 * is \l{QAbstract3DSeries::MeshUserDefined}{Abstract3DSeries.MeshUserDefined}.
176 * \note The file needs to be in the Wavefront OBJ format and include
177 * vertices, normals, and UVs. It also needs to be in triangles.
178 */
179
180/*!
181 * \qmlproperty Theme3D.ColorStyle Abstract3DSeries::colorStyle
182 *
183 * Sets the color style for the series.
184 *
185 * \sa {Theme3D::colorStyle}{Theme3D.colorStyle}
186 */
187
188/*!
189 * \qmlproperty color Abstract3DSeries::baseColor
190 *
191 * Sets the base color of the series.
192 *
193 * \sa colorStyle, {Theme3D::baseColors}{Theme3D.baseColors}
194 */
195
196/*!
197 * \qmlproperty ColorGradient Abstract3DSeries::baseGradient
198 *
199 * Sets the base gradient of the series.
200 *
201 * \sa colorStyle, {Theme3D::baseGradients}{Theme3D.baseGradients}
202 */
203
204/*!
205 * \qmlproperty color Abstract3DSeries::singleHighlightColor
206 *
207 * Sets the single item highlight color of the series.
208 *
209 * \sa colorStyle, {Theme3D::singleHighlightColor}{Theme3D.singleHighlightColor}
210 */
211
212/*!
213 * \qmlproperty ColorGradient Abstract3DSeries::singleHighlightGradient
214 *
215 * Sets the single item highlight gradient of the series.
216 *
217 * \sa colorStyle, {Theme3D::singleHighlightGradient}{Theme3D.singleHighlightGradient}
218 */
219
220/*!
221 * \qmlproperty color Abstract3DSeries::multiHighlightColor
222 *
223 * Sets the multiple item highlight color of the series.
224 *
225 * \sa colorStyle, {Theme3D::multiHighlightColor}{Theme3D.multiHighlightColor}
226 */
227
228/*!
229 * \qmlproperty ColorGradient Abstract3DSeries::multiHighlightGradient
230 *
231 * Sets the multiple item highlight gradient of the series.
232 *
233 * \sa colorStyle, {Theme3D::multiHighlightGradient}{Theme3D.multiHighlightGradient}
234 */
235
236/*!
237 * \qmlproperty string Abstract3DSeries::name
238 *
239 * The series name.
240 * It can be used in item label format with the tag \c{@seriesName}.
241 *
242 * \sa itemLabelFormat
243 */
244
245/*!
246 * \qmlproperty string Abstract3DSeries::itemLabel
247 * \since QtDataVisualization 1.1
248 *
249 * The formatted item label. If there is no selected item or the selected item is not
250 * visible, returns an empty string.
251 *
252 * \sa itemLabelFormat
253 */
254
255/*!
256 * \qmlproperty bool Abstract3DSeries::itemLabelVisible
257 * \since QtDataVisualization 1.1
258 *
259 * If \c true, item labels are drawn as floating labels in the graph. Otherwise,
260 * item labels are not drawn. To show the item label in an external control,
261 * this property is set to \c false. Defaults to \c true.
262 *
263 * \sa itemLabelFormat, itemLabel
264 */
265
266/*!
267 * \qmlmethod void Abstract3DSeries::setMeshAxisAndAngle(vector3d axis, real angle)
268 *
269 * A convenience function to construct a mesh rotation quaternion from \a axis
270 * and \a angle.
271 *
272 * \sa meshRotation
273 */
274
275/*!
276 * \internal
277 */
278QAbstract3DSeries::QAbstract3DSeries(QAbstract3DSeriesPrivate *d, QObject *parent) :
279 QObject(parent),
280 d_ptr(d)
281{
282}
283
284/*!
285 * Deletes the abstract 3D series.
286 */
287QAbstract3DSeries::~QAbstract3DSeries()
288{
289}
290
291/*!
292 * \property QAbstract3DSeries::type
293 *
294 * \brief The type of the series.
295 */
296QAbstract3DSeries::SeriesType QAbstract3DSeries::type() const
297{
298 return d_ptr->m_type;
299}
300
301/*!
302 * \property QAbstract3DSeries::itemLabelFormat
303 *
304 * \brief The label format for data items in this series.
305 *
306 * This format is used for single item labels,
307 * for example, when an item is selected. How the format is interpreted depends
308 * on series type: QBar3DSeries, QScatter3DSeries, QSurface3DSeries.
309 */
310void QAbstract3DSeries::setItemLabelFormat(const QString &format)
311{
312 if (d_ptr->m_itemLabelFormat != format) {
313 d_ptr->setItemLabelFormat(format);
314 emit itemLabelFormatChanged(format);
315 }
316}
317
318QString QAbstract3DSeries::itemLabelFormat() const
319{
320 return d_ptr->m_itemLabelFormat;
321}
322
323/*!
324 * \property QAbstract3DSeries::visible
325 *
326 * \brief The visibility of the series.
327 *
328 * If this property is \c false, the series is not rendered.
329 * Defaults to \c{true}.
330 */
331void QAbstract3DSeries::setVisible(bool visible)
332{
333 if (d_ptr->m_visible != visible) {
334 d_ptr->setVisible(visible);
335 emit visibilityChanged(visible);
336 }
337}
338
339bool QAbstract3DSeries::isVisible() const
340{
341 return d_ptr->m_visible;
342}
343
344/*!
345 * \property QAbstract3DSeries::mesh
346 *
347 * \brief The mesh of the items in the series.
348 *
349 * For QSurface3DSeries, this property holds the selection pointer.
350 *
351 * If the mesh is MeshUserDefined, then the userDefinedMesh property
352 * must also be set for items to render properly. The default value depends on the graph type.
353 */
354void QAbstract3DSeries::setMesh(QAbstract3DSeries::Mesh mesh)
355{
356 if ((mesh == QAbstract3DSeries::MeshPoint || mesh == QAbstract3DSeries::MeshMinimal
357 || mesh == QAbstract3DSeries::MeshArrow)
358 && type() != QAbstract3DSeries::SeriesTypeScatter) {
359 qWarning() << "Specified style is only supported for QScatter3DSeries.";
360 } else if (d_ptr->m_mesh != mesh) {
361 d_ptr->setMesh(mesh);
362 emit meshChanged(mesh);
363 }
364}
365
366QAbstract3DSeries::Mesh QAbstract3DSeries::mesh() const
367{
368 return d_ptr->m_mesh;
369}
370
371/*!
372 * \property QAbstract3DSeries::meshSmooth
373 *
374 * \brief Whether smooth versions of predefined meshes are used.
375 *
376 * If \c true, smooth versions set via the \l mesh property are used.
377 * This property does not affect custom meshes used when the mesh is set to
378 * MeshUserDefined. Defaults to \c{false}.
379 */
380void QAbstract3DSeries::setMeshSmooth(bool enable)
381{
382 if (d_ptr->m_meshSmooth != enable) {
383 d_ptr->setMeshSmooth(enable);
384 emit meshSmoothChanged(enabled: enable);
385 }
386}
387
388bool QAbstract3DSeries::isMeshSmooth() const
389{
390 return d_ptr->m_meshSmooth;
391}
392
393/*!
394 * \property QAbstract3DSeries::meshRotation
395 *
396 * \brief The mesh rotation that is applied to all items of the series.
397 *
398 * The rotation should be a normalized QQuaternion.
399 * For those series types that support item specific rotation, the rotations are
400 * multiplied together.
401 * QBar3DSeries ignores any rotation that is not around the y-axis.
402 * QSurface3DSeries applies the rotation only to the selection pointer.
403 * Defaults to no rotation.
404 */
405void QAbstract3DSeries::setMeshRotation(const QQuaternion &rotation)
406{
407 if (d_ptr->m_meshRotation != rotation) {
408 d_ptr->setMeshRotation(rotation);
409 emit meshRotationChanged(rotation);
410 }
411}
412
413QQuaternion QAbstract3DSeries::meshRotation() const
414{
415 return d_ptr->m_meshRotation;
416}
417
418/*!
419 * A convenience function to construct a mesh rotation quaternion from
420 * \a axis and \a angle.
421 *
422 * \sa meshRotation
423 */
424void QAbstract3DSeries::setMeshAxisAndAngle(const QVector3D &axis, float angle)
425{
426 setMeshRotation(QQuaternion::fromAxisAndAngle(axis, angle));
427}
428
429/*!
430 * \property QAbstract3DSeries::userDefinedMesh
431 *
432 * \brief The filename for a user defined custom mesh for objects.
433 *
434 * The custom mesh is used when \l mesh is MeshUserDefined.
435 * \note The file needs to be in the Wavefront OBJ format and include
436 * vertices, normals, and UVs. It also needs to be in triangles.
437 */
438void QAbstract3DSeries::setUserDefinedMesh(const QString &fileName)
439{
440 if (d_ptr->m_userDefinedMesh != fileName) {
441 d_ptr->setUserDefinedMesh(fileName);
442 emit userDefinedMeshChanged(fileName);
443 }
444}
445
446QString QAbstract3DSeries::userDefinedMesh() const
447{
448 return d_ptr->m_userDefinedMesh;
449}
450
451/*!
452 * \property QAbstract3DSeries::colorStyle
453 *
454 * \brief The color style for the series.
455 *
456 * \sa Q3DTheme::ColorStyle
457 */
458void QAbstract3DSeries::setColorStyle(Q3DTheme::ColorStyle style)
459{
460 if (d_ptr->m_colorStyle != style) {
461 d_ptr->setColorStyle(style);
462 emit colorStyleChanged(style);
463 }
464 d_ptr->m_themeTracker.colorStyleOverride = true;
465}
466
467Q3DTheme::ColorStyle QAbstract3DSeries::colorStyle() const
468{
469 return d_ptr->m_colorStyle;
470}
471
472/*!
473 * \property QAbstract3DSeries::baseColor
474 *
475 * \brief The base color of the series.
476 *
477 * \sa colorStyle, Q3DTheme::baseColors
478 */
479void QAbstract3DSeries::setBaseColor(const QColor &color)
480{
481 if (d_ptr->m_baseColor != color) {
482 d_ptr->setBaseColor(color);
483 emit baseColorChanged(color);
484 }
485 d_ptr->m_themeTracker.baseColorOverride = true;
486}
487
488QColor QAbstract3DSeries::baseColor() const
489{
490 return d_ptr->m_baseColor;
491}
492
493/*!
494 * \property QAbstract3DSeries::baseGradient
495 *
496 * \brief The base gradient of the series.
497 *
498 * \sa colorStyle, Q3DTheme::baseGradients
499 */
500void QAbstract3DSeries::setBaseGradient(const QLinearGradient &gradient)
501{
502 if (d_ptr->m_baseGradient != gradient) {
503 d_ptr->setBaseGradient(gradient);
504 emit baseGradientChanged(gradient);
505 }
506 d_ptr->m_themeTracker.baseGradientOverride = true;
507}
508
509QLinearGradient QAbstract3DSeries::baseGradient() const
510{
511 return d_ptr->m_baseGradient;
512}
513
514/*!
515 * \property QAbstract3DSeries::singleHighlightColor
516 *
517 * \brief The single item highlight color of the series.
518 *
519 * \sa colorStyle, Q3DTheme::singleHighlightColor
520 */
521void QAbstract3DSeries::setSingleHighlightColor(const QColor &color)
522{
523 if (d_ptr->m_singleHighlightColor != color) {
524 d_ptr->setSingleHighlightColor(color);
525 emit singleHighlightColorChanged(color);
526 }
527 d_ptr->m_themeTracker.singleHighlightColorOverride = true;
528}
529
530QColor QAbstract3DSeries::singleHighlightColor() const
531{
532 return d_ptr->m_singleHighlightColor;
533}
534
535/*!
536 * \property QAbstract3DSeries::singleHighlightGradient
537 *
538 * \brief The single item highlight gradient of the series.
539 *
540 * \sa colorStyle, Q3DTheme::singleHighlightGradient
541 */
542void QAbstract3DSeries::setSingleHighlightGradient(const QLinearGradient &gradient)
543{
544 if (d_ptr->m_singleHighlightGradient != gradient) {
545 d_ptr->setSingleHighlightGradient(gradient);
546 emit singleHighlightGradientChanged(gradient);
547 }
548 d_ptr->m_themeTracker.singleHighlightGradientOverride = true;
549}
550
551QLinearGradient QAbstract3DSeries::singleHighlightGradient() const
552{
553 return d_ptr->m_singleHighlightGradient;
554}
555
556/*!
557 * \property QAbstract3DSeries::multiHighlightColor
558 *
559 * \brief The multiple item highlight color of the series.
560 *
561 * \sa colorStyle, Q3DTheme::multiHighlightColor
562 */
563void QAbstract3DSeries::setMultiHighlightColor(const QColor &color)
564{
565 if (d_ptr->m_multiHighlightColor != color) {
566 d_ptr->setMultiHighlightColor(color);
567 emit multiHighlightColorChanged(color);
568 }
569 d_ptr->m_themeTracker.multiHighlightColorOverride = true;
570}
571
572QColor QAbstract3DSeries::multiHighlightColor() const
573{
574 return d_ptr->m_multiHighlightColor;
575}
576
577/*!
578 * \property QAbstract3DSeries::multiHighlightGradient
579 *
580 * \brief The multiple item highlight gradient of the series.
581 *
582 * \sa colorStyle, Q3DTheme::multiHighlightGradient
583 */
584void QAbstract3DSeries::setMultiHighlightGradient(const QLinearGradient &gradient)
585{
586 if (d_ptr->m_multiHighlightGradient != gradient) {
587 d_ptr->setMultiHighlightGradient(gradient);
588 emit multiHighlightGradientChanged(gradient);
589 }
590 d_ptr->m_themeTracker.multiHighlightGradientOverride = true;
591}
592
593QLinearGradient QAbstract3DSeries::multiHighlightGradient() const
594{
595 return d_ptr->m_multiHighlightGradient;
596}
597
598/*!
599 * \property QAbstract3DSeries::name
600 *
601 * \brief The series name.
602 *
603 * The series name can be used in item label format with the tag \c{@seriesName}.
604 *
605 * \sa itemLabelFormat
606 */
607void QAbstract3DSeries::setName(const QString &name)
608{
609 if (d_ptr->m_name != name) {
610 d_ptr->setName(name);
611 emit nameChanged(name);
612 }
613}
614
615QString QAbstract3DSeries::name() const
616{
617 return d_ptr->m_name;
618}
619
620/*!
621 * \property QAbstract3DSeries::itemLabel
622 * \since QtDataVisualization 1.1
623 *
624 * \brief The formatted item label.
625 *
626 * If there is no selected item or the selected item is not
627 * visible, returns an empty string.
628 *
629 * \sa itemLabelFormat
630 */
631QString QAbstract3DSeries::itemLabel() const
632{
633 return d_ptr->itemLabel();
634}
635
636/*!
637 * \property QAbstract3DSeries::itemLabelVisible
638 * \since QtDataVisualization 1.1
639 *
640 * \brief The visibility of item labels in the graph.
641 *
642 * If \c true, item labels are drawn as floating labels in the graph. Otherwise,
643 * item labels are not drawn. To show the item label in an external control,
644 * this property is set to \c false. Defaults to \c true.
645 *
646 * \sa itemLabelFormat, itemLabel
647 */
648void QAbstract3DSeries::setItemLabelVisible(bool visible)
649{
650 if (d_ptr->m_itemLabelVisible != visible) {
651 d_ptr->setItemLabelVisible(visible);
652 emit itemLabelVisibilityChanged(visible);
653 }
654}
655
656bool QAbstract3DSeries::isItemLabelVisible() const
657{
658 return d_ptr->m_itemLabelVisible;
659}
660
661// QAbstract3DSeriesPrivate
662
663QAbstract3DSeriesPrivate::QAbstract3DSeriesPrivate(QAbstract3DSeries *q,
664 QAbstract3DSeries::SeriesType type)
665 : QObject(0),
666 q_ptr(q),
667 m_type(type),
668 m_dataProxy(0),
669 m_visible(true),
670 m_controller(0),
671 m_mesh(QAbstract3DSeries::MeshCube),
672 m_meshSmooth(false),
673 m_colorStyle(Q3DTheme::ColorStyleUniform),
674 m_baseColor(Qt::black),
675 m_singleHighlightColor(Qt::black),
676 m_multiHighlightColor(Qt::black),
677 m_itemLabelDirty(true),
678 m_itemLabelVisible(true)
679{
680}
681
682QAbstract3DSeriesPrivate::~QAbstract3DSeriesPrivate()
683{
684}
685
686QAbstractDataProxy *QAbstract3DSeriesPrivate::dataProxy() const
687{
688 return m_dataProxy;
689}
690
691void QAbstract3DSeriesPrivate::setDataProxy(QAbstractDataProxy *proxy)
692{
693 Q_ASSERT(proxy && proxy != m_dataProxy && !proxy->d_ptr->series());
694
695 delete m_dataProxy;
696 m_dataProxy = proxy;
697
698 proxy->d_ptr->setSeries(q_ptr); // also sets parent
699
700 if (m_controller) {
701 connectControllerAndProxy(newController: m_controller);
702 m_controller->markDataDirty();
703 }
704}
705
706void QAbstract3DSeriesPrivate::setController(Abstract3DController *controller)
707{
708 connectControllerAndProxy(newController: controller);
709 m_controller = controller;
710 q_ptr->setParent(controller);
711 markItemLabelDirty();
712}
713
714void QAbstract3DSeriesPrivate::setItemLabelFormat(const QString &format)
715{
716 m_itemLabelFormat = format;
717 markItemLabelDirty();
718}
719
720void QAbstract3DSeriesPrivate::setVisible(bool visible)
721{
722 m_visible = visible;
723 markItemLabelDirty();
724}
725
726void QAbstract3DSeriesPrivate::setMesh(QAbstract3DSeries::Mesh mesh)
727{
728 m_mesh = mesh;
729 m_changeTracker.meshChanged = true;
730 if (m_controller) {
731 m_controller->markSeriesVisualsDirty();
732
733 if (m_controller->optimizationHints().testFlag(flag: QAbstract3DGraph::OptimizationStatic))
734 m_controller->markDataDirty();
735 }
736}
737
738void QAbstract3DSeriesPrivate::setMeshSmooth(bool enable)
739{
740 m_meshSmooth = enable;
741 m_changeTracker.meshSmoothChanged = true;
742 if (m_controller) {
743 m_controller->markSeriesVisualsDirty();
744
745 if (m_controller->optimizationHints().testFlag(flag: QAbstract3DGraph::OptimizationStatic))
746 m_controller->markDataDirty();
747 }
748}
749
750void QAbstract3DSeriesPrivate::setMeshRotation(const QQuaternion &rotation)
751{
752 m_meshRotation = rotation;
753 m_changeTracker.meshRotationChanged = true;
754 if (m_controller) {
755 m_controller->markSeriesVisualsDirty();
756
757 if (m_controller->optimizationHints().testFlag(flag: QAbstract3DGraph::OptimizationStatic))
758 m_controller->markDataDirty();
759 }
760}
761
762void QAbstract3DSeriesPrivate::setUserDefinedMesh(const QString &meshFile)
763{
764 m_userDefinedMesh = meshFile;
765 m_changeTracker.userDefinedMeshChanged = true;
766 if (m_controller) {
767 m_controller->markSeriesVisualsDirty();
768
769 if (m_controller->optimizationHints().testFlag(flag: QAbstract3DGraph::OptimizationStatic))
770 m_controller->markDataDirty();
771 }
772}
773
774void QAbstract3DSeriesPrivate::setColorStyle(Q3DTheme::ColorStyle style)
775{
776 m_colorStyle = style;
777 m_changeTracker.colorStyleChanged = true;
778 if (m_controller)
779 m_controller->markSeriesVisualsDirty();
780}
781
782void QAbstract3DSeriesPrivate::setBaseColor(const QColor &color)
783{
784 m_baseColor = color;
785 m_changeTracker.baseColorChanged = true;
786 if (m_controller)
787 m_controller->markSeriesVisualsDirty();
788}
789
790void QAbstract3DSeriesPrivate::setBaseGradient(const QLinearGradient &gradient)
791{
792 m_baseGradient = gradient;
793 m_changeTracker.baseGradientChanged = true;
794 if (m_controller)
795 m_controller->markSeriesVisualsDirty();
796}
797
798void QAbstract3DSeriesPrivate::setSingleHighlightColor(const QColor &color)
799{
800 m_singleHighlightColor = color;
801 m_changeTracker.singleHighlightColorChanged = true;
802 if (m_controller)
803 m_controller->markSeriesVisualsDirty();
804}
805
806void QAbstract3DSeriesPrivate::setSingleHighlightGradient(const QLinearGradient &gradient)
807{
808 m_singleHighlightGradient = gradient;
809 m_changeTracker.singleHighlightGradientChanged = true;
810 if (m_controller)
811 m_controller->markSeriesVisualsDirty();
812}
813
814void QAbstract3DSeriesPrivate::setMultiHighlightColor(const QColor &color)
815{
816 m_multiHighlightColor = color;
817 m_changeTracker.multiHighlightColorChanged = true;
818 if (m_controller)
819 m_controller->markSeriesVisualsDirty();
820}
821
822void QAbstract3DSeriesPrivate::setMultiHighlightGradient(const QLinearGradient &gradient)
823{
824 m_multiHighlightGradient = gradient;
825 m_changeTracker.multiHighlightGradientChanged = true;
826 if (m_controller)
827 m_controller->markSeriesVisualsDirty();
828}
829
830void QAbstract3DSeriesPrivate::setName(const QString &name)
831{
832 m_name = name;
833 markItemLabelDirty();
834 m_changeTracker.nameChanged = true;
835}
836
837void QAbstract3DSeriesPrivate::resetToTheme(const Q3DTheme &theme, int seriesIndex, bool force)
838{
839 int themeIndex = seriesIndex;
840 if (force || !m_themeTracker.colorStyleOverride) {
841 q_ptr->setColorStyle(theme.colorStyle());
842 m_themeTracker.colorStyleOverride = false;
843 }
844 if (force || !m_themeTracker.baseColorOverride) {
845 if (theme.baseColors().size() <= seriesIndex)
846 themeIndex = seriesIndex % theme.baseColors().size();
847 q_ptr->setBaseColor(theme.baseColors().at(i: themeIndex));
848 m_themeTracker.baseColorOverride = false;
849 }
850 if (force || !m_themeTracker.baseGradientOverride) {
851 if (theme.baseGradients().size() <= seriesIndex)
852 themeIndex = seriesIndex % theme.baseGradients().size();
853 q_ptr->setBaseGradient(theme.baseGradients().at(i: themeIndex));
854 m_themeTracker.baseGradientOverride = false;
855 }
856 if (force || !m_themeTracker.singleHighlightColorOverride) {
857 q_ptr->setSingleHighlightColor(theme.singleHighlightColor());
858 m_themeTracker.singleHighlightColorOverride = false;
859 }
860 if (force || !m_themeTracker.singleHighlightGradientOverride) {
861 q_ptr->setSingleHighlightGradient(theme.singleHighlightGradient());
862 m_themeTracker.singleHighlightGradientOverride = false;
863 }
864 if (force || !m_themeTracker.multiHighlightColorOverride) {
865 q_ptr->setMultiHighlightColor(theme.multiHighlightColor());
866 m_themeTracker.multiHighlightColorOverride = false;
867 }
868 if (force || !m_themeTracker.multiHighlightGradientOverride) {
869 q_ptr->setMultiHighlightGradient(theme.multiHighlightGradient());
870 m_themeTracker.multiHighlightGradientOverride = false;
871 }
872}
873
874QString QAbstract3DSeriesPrivate::itemLabel()
875{
876 if (m_itemLabelDirty) {
877 QString oldLabel = m_itemLabel;
878 if (m_controller && m_visible)
879 createItemLabel();
880 else
881 m_itemLabel = QString();
882 m_itemLabelDirty = false;
883
884 if (oldLabel != m_itemLabel)
885 emit q_ptr->itemLabelChanged(label: m_itemLabel);
886 }
887
888 return m_itemLabel;
889}
890
891void QAbstract3DSeriesPrivate::markItemLabelDirty()
892{
893 m_itemLabelDirty = true;
894 m_changeTracker.itemLabelChanged = true;
895 if (m_controller)
896 m_controller->markSeriesVisualsDirty();
897}
898
899void QAbstract3DSeriesPrivate::setItemLabelVisible(bool visible)
900{
901 m_itemLabelVisible = visible;
902 markItemLabelDirty();
903 m_changeTracker.itemLabelVisibilityChanged = true;
904}
905
906QT_END_NAMESPACE_DATAVISUALIZATION
907

source code of qtdatavis3d/src/datavisualization/data/qabstract3dseries.cpp