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 | // |
31 | // W A R N I N G |
32 | // ------------- |
33 | // |
34 | // This file is not part of the QtDataVisualization API. It exists purely as an |
35 | // implementation detail. This header file may change from version to |
36 | // version without notice, or even be removed. |
37 | // |
38 | // We mean it. |
39 | |
40 | #ifndef DECLARATIVESERIES_P_H |
41 | #define DECLARATIVESERIES_P_H |
42 | |
43 | #include "datavisualizationglobal_p.h" |
44 | #include "qbar3dseries.h" |
45 | #include "qscatter3dseries.h" |
46 | #include "qsurface3dseries.h" |
47 | #include "colorgradient_p.h" |
48 | #include <QtQml/QQmlListProperty> |
49 | |
50 | QT_BEGIN_NAMESPACE_DATAVISUALIZATION |
51 | |
52 | enum GradientType { |
53 | GradientTypeBase, |
54 | GradientTypeSingle, |
55 | GradientTypeMulti |
56 | }; |
57 | |
58 | class DeclarativeBar3DSeries : public QBar3DSeries |
59 | { |
60 | Q_OBJECT |
61 | Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) |
62 | // This property is overloaded to use QPointF instead of QPoint to work around qml bug |
63 | // where Qt.point(0, 0) can't be assigned due to error "Cannot assign QPointF to QPoint". |
64 | Q_PROPERTY(QPointF selectedBar READ selectedBar WRITE setSelectedBar NOTIFY selectedBarChanged) |
65 | // This is static method in parent class, overload as constant property for qml. |
66 | Q_PROPERTY(QPointF invalidSelectionPosition READ invalidSelectionPosition CONSTANT) |
67 | Q_PROPERTY(ColorGradient *baseGradient READ baseGradient WRITE setBaseGradient NOTIFY baseGradientChanged) |
68 | Q_PROPERTY(ColorGradient *singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged) |
69 | Q_PROPERTY(ColorGradient *multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged) |
70 | Q_CLASSINFO("DefaultProperty" , "seriesChildren" ) |
71 | |
72 | public: |
73 | DeclarativeBar3DSeries(QObject *parent = 0); |
74 | virtual ~DeclarativeBar3DSeries(); |
75 | |
76 | QQmlListProperty<QObject> seriesChildren(); |
77 | static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); |
78 | |
79 | void setSelectedBar(const QPointF &position); |
80 | QPointF selectedBar() const; |
81 | QPointF invalidSelectionPosition() const; |
82 | |
83 | void setBaseGradient(ColorGradient *gradient); |
84 | ColorGradient *baseGradient() const; |
85 | void setSingleHighlightGradient(ColorGradient *gradient); |
86 | ColorGradient *singleHighlightGradient() const; |
87 | void setMultiHighlightGradient(ColorGradient *gradient); |
88 | ColorGradient *multiHighlightGradient() const; |
89 | |
90 | public Q_SLOTS: |
91 | void handleBaseGradientUpdate(); |
92 | void handleSingleHighlightGradientUpdate(); |
93 | void handleMultiHighlightGradientUpdate(); |
94 | |
95 | Q_SIGNALS: |
96 | void selectedBarChanged(QPointF position); |
97 | void baseGradientChanged(ColorGradient *gradient); |
98 | void singleHighlightGradientChanged(ColorGradient *gradient); |
99 | void multiHighlightGradientChanged(ColorGradient *gradient); |
100 | |
101 | private: |
102 | ColorGradient *m_baseGradient; // Not owned |
103 | ColorGradient *m_singleHighlightGradient; // Not owned |
104 | ColorGradient *m_multiHighlightGradient; // Not owned |
105 | }; |
106 | |
107 | class DeclarativeScatter3DSeries : public QScatter3DSeries |
108 | { |
109 | Q_OBJECT |
110 | Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) |
111 | Q_PROPERTY(ColorGradient *baseGradient READ baseGradient WRITE setBaseGradient NOTIFY baseGradientChanged) |
112 | Q_PROPERTY(ColorGradient *singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged) |
113 | Q_PROPERTY(ColorGradient *multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged) |
114 | // This is static method in parent class, overload as constant property for qml. |
115 | Q_PROPERTY(int invalidSelectionIndex READ invalidSelectionIndex CONSTANT) |
116 | Q_CLASSINFO("DefaultProperty" , "seriesChildren" ) |
117 | |
118 | public: |
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 | |
134 | public Q_SLOTS: |
135 | void handleBaseGradientUpdate(); |
136 | void handleSingleHighlightGradientUpdate(); |
137 | void handleMultiHighlightGradientUpdate(); |
138 | |
139 | Q_SIGNALS: |
140 | void baseGradientChanged(ColorGradient *gradient); |
141 | void singleHighlightGradientChanged(ColorGradient *gradient); |
142 | void multiHighlightGradientChanged(ColorGradient *gradient); |
143 | |
144 | private: |
145 | ColorGradient *m_baseGradient; // Not owned |
146 | ColorGradient *m_singleHighlightGradient; // Not owned |
147 | ColorGradient *m_multiHighlightGradient; // Not owned |
148 | }; |
149 | |
150 | class 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 | public: |
165 | DeclarativeSurface3DSeries(QObject *parent = 0); |
166 | virtual ~DeclarativeSurface3DSeries(); |
167 | |
168 | void setSelectedPoint(const QPointF &position); |
169 | QPointF selectedPoint() const; |
170 | QPointF invalidSelectionPosition() const; |
171 | |
172 | QQmlListProperty<QObject> seriesChildren(); |
173 | static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); |
174 | |
175 | void setBaseGradient(ColorGradient *gradient); |
176 | ColorGradient *baseGradient() const; |
177 | void setSingleHighlightGradient(ColorGradient *gradient); |
178 | ColorGradient *singleHighlightGradient() const; |
179 | void setMultiHighlightGradient(ColorGradient *gradient); |
180 | ColorGradient *multiHighlightGradient() const; |
181 | |
182 | public Q_SLOTS: |
183 | void handleBaseGradientUpdate(); |
184 | void handleSingleHighlightGradientUpdate(); |
185 | void handleMultiHighlightGradientUpdate(); |
186 | |
187 | Q_SIGNALS: |
188 | void selectedPointChanged(QPointF position); |
189 | void baseGradientChanged(ColorGradient *gradient); |
190 | void singleHighlightGradientChanged(ColorGradient *gradient); |
191 | void multiHighlightGradientChanged(ColorGradient *gradient); |
192 | |
193 | private: |
194 | ColorGradient *m_baseGradient; // Not owned |
195 | ColorGradient *m_singleHighlightGradient; // Not owned |
196 | ColorGradient *m_multiHighlightGradient; // Not owned |
197 | }; |
198 | |
199 | QT_END_NAMESPACE_DATAVISUALIZATION |
200 | |
201 | #endif |
202 | |