1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the QtDataVisualization API. It exists purely as an
9// implementation detail. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13
14#ifndef DECLARATIVESERIES_P_H
15#define DECLARATIVESERIES_P_H
16
17#include "qbar3dseries.h"
18#include "qscatter3dseries.h"
19#include "qsurface3dseries.h"
20#include "colorgradient_p.h"
21#include "declarativecolor_p.h"
22
23#include <private/datavisualizationglobal_p.h>
24#include <QtQml/qqml.h>
25
26QT_BEGIN_NAMESPACE
27
28enum GradientType {
29 GradientTypeBase,
30 GradientTypeSingle,
31 GradientTypeMulti
32};
33
34class DeclarativeBar3DSeries : public QBar3DSeries
35{
36 Q_OBJECT
37 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
38 // This property is overloaded to use QPointF instead of QPoint to work around qml bug
39 // where Qt.point(0, 0) can't be assigned due to error "Cannot assign QPointF to QPoint".
40 Q_PROPERTY(QPointF selectedBar READ selectedBar WRITE setSelectedBar NOTIFY selectedBarChanged)
41 // This is static method in parent class, overload as constant property for qml.
42 Q_PROPERTY(QPointF invalidSelectionPosition READ invalidSelectionPosition CONSTANT)
43 Q_PROPERTY(ColorGradient *baseGradient READ baseGradient WRITE setBaseGradient NOTIFY baseGradientChanged)
44 Q_PROPERTY(ColorGradient *singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged)
45 Q_PROPERTY(ColorGradient *multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged)
46 Q_PROPERTY(QQmlListProperty<DeclarativeColor> rowColors READ rowColors REVISION(6, 3))
47 Q_CLASSINFO("DefaultProperty", "seriesChildren")
48
49 QML_NAMED_ELEMENT(Bar3DSeries)
50 QML_ADDED_IN_VERSION(1, 0)
51
52public:
53 DeclarativeBar3DSeries(QObject *parent = 0);
54 virtual ~DeclarativeBar3DSeries();
55
56 QQmlListProperty<QObject> seriesChildren();
57 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
58
59 void setSelectedBar(const QPointF &position);
60 QPointF selectedBar() const;
61 QPointF invalidSelectionPosition() const;
62
63 void setBaseGradient(ColorGradient *gradient);
64 ColorGradient *baseGradient() const;
65 void setSingleHighlightGradient(ColorGradient *gradient);
66 ColorGradient *singleHighlightGradient() const;
67 void setMultiHighlightGradient(ColorGradient *gradient);
68 ColorGradient *multiHighlightGradient() const;
69
70 QQmlListProperty<DeclarativeColor> rowColors();
71 static void appendRowColorsFunc(QQmlListProperty<DeclarativeColor> *list,
72 DeclarativeColor *color);
73 static qsizetype countRowColorsFunc(QQmlListProperty<DeclarativeColor> *list);
74 static DeclarativeColor *atRowColorsFunc(QQmlListProperty<DeclarativeColor> *list,
75 qsizetype index);
76 static void clearRowColorsFunc(QQmlListProperty<DeclarativeColor> *list);
77
78public Q_SLOTS:
79 void handleBaseGradientUpdate();
80 void handleSingleHighlightGradientUpdate();
81 void handleMultiHighlightGradientUpdate();
82 void handleRowColorUpdate();
83
84Q_SIGNALS:
85 void selectedBarChanged(const QPointF &position);
86 void baseGradientChanged(ColorGradient *gradient);
87 void singleHighlightGradientChanged(ColorGradient *gradient);
88 void multiHighlightGradientChanged(ColorGradient *gradient);
89
90private:
91 ColorGradient *m_baseGradient; // Not owned
92 ColorGradient *m_singleHighlightGradient; // Not owned
93 ColorGradient *m_multiHighlightGradient; // Not owned
94
95 QList<DeclarativeColor *> m_rowColors;
96 bool m_dummyColors;
97
98 void addColor(DeclarativeColor *color);
99 QList<DeclarativeColor *> colorList();
100 void clearColors();
101 void clearDummyColors();
102};
103
104class DeclarativeScatter3DSeries : public QScatter3DSeries
105{
106 Q_OBJECT
107 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
108 Q_PROPERTY(ColorGradient *baseGradient READ baseGradient WRITE setBaseGradient NOTIFY baseGradientChanged)
109 Q_PROPERTY(ColorGradient *singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged)
110 Q_PROPERTY(ColorGradient *multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged)
111 // This is static method in parent class, overload as constant property for qml.
112 Q_PROPERTY(int invalidSelectionIndex READ invalidSelectionIndex CONSTANT)
113 Q_CLASSINFO("DefaultProperty", "seriesChildren")
114
115 QML_NAMED_ELEMENT(Scatter3DSeries)
116 QML_ADDED_IN_VERSION(1, 0)
117
118public:
119 DeclarativeScatter3DSeries(QObject *parent = 0);
120 virtual ~DeclarativeScatter3DSeries();
121
122 QQmlListProperty<QObject> seriesChildren();
123 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
124
125 void setBaseGradient(ColorGradient *gradient);
126 ColorGradient *baseGradient() const;
127 void setSingleHighlightGradient(ColorGradient *gradient);
128 ColorGradient *singleHighlightGradient() const;
129 void setMultiHighlightGradient(ColorGradient *gradient);
130 ColorGradient *multiHighlightGradient() const;
131
132 int invalidSelectionIndex() const;
133
134public Q_SLOTS:
135 void handleBaseGradientUpdate();
136 void handleSingleHighlightGradientUpdate();
137 void handleMultiHighlightGradientUpdate();
138
139Q_SIGNALS:
140 void baseGradientChanged(ColorGradient *gradient);
141 void singleHighlightGradientChanged(ColorGradient *gradient);
142 void multiHighlightGradientChanged(ColorGradient *gradient);
143
144private:
145 ColorGradient *m_baseGradient; // Not owned
146 ColorGradient *m_singleHighlightGradient; // Not owned
147 ColorGradient *m_multiHighlightGradient; // Not owned
148};
149
150class DeclarativeSurface3DSeries : public QSurface3DSeries
151{
152 Q_OBJECT
153 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
154 // This property is overloaded to use QPointF instead of QPoint to work around qml bug
155 // where Qt.point(0, 0) can't be assigned due to error "Cannot assign QPointF to QPoint".
156 Q_PROPERTY(QPointF selectedPoint READ selectedPoint WRITE setSelectedPoint NOTIFY selectedPointChanged)
157 // This is static method in parent class, overload as constant property for qml.
158 Q_PROPERTY(QPointF invalidSelectionPosition READ invalidSelectionPosition CONSTANT)
159 Q_PROPERTY(ColorGradient *baseGradient READ baseGradient WRITE setBaseGradient NOTIFY baseGradientChanged)
160 Q_PROPERTY(ColorGradient *singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged)
161 Q_PROPERTY(ColorGradient *multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged)
162 Q_CLASSINFO("DefaultProperty", "seriesChildren")
163
164 QML_NAMED_ELEMENT(Surface3DSeries)
165 QML_ADDED_IN_VERSION(1, 0)
166
167public:
168 DeclarativeSurface3DSeries(QObject *parent = 0);
169 virtual ~DeclarativeSurface3DSeries();
170
171 void setSelectedPoint(const QPointF &position);
172 QPointF selectedPoint() const;
173 QPointF invalidSelectionPosition() const;
174
175 QQmlListProperty<QObject> seriesChildren();
176 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
177
178 void setBaseGradient(ColorGradient *gradient);
179 ColorGradient *baseGradient() const;
180 void setSingleHighlightGradient(ColorGradient *gradient);
181 ColorGradient *singleHighlightGradient() const;
182 void setMultiHighlightGradient(ColorGradient *gradient);
183 ColorGradient *multiHighlightGradient() const;
184
185public Q_SLOTS:
186 void handleBaseGradientUpdate();
187 void handleSingleHighlightGradientUpdate();
188 void handleMultiHighlightGradientUpdate();
189
190Q_SIGNALS:
191 void selectedPointChanged(const QPointF &position);
192 void baseGradientChanged(ColorGradient *gradient);
193 void singleHighlightGradientChanged(ColorGradient *gradient);
194 void multiHighlightGradientChanged(ColorGradient *gradient);
195
196private:
197 ColorGradient *m_baseGradient; // Not owned
198 ColorGradient *m_singleHighlightGradient; // Not owned
199 ColorGradient *m_multiHighlightGradient; // Not owned
200};
201
202QT_END_NAMESPACE
203
204#endif
205

source code of qtdatavis3d/src/datavisualizationqml/declarativeseries_p.h