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 Q3DSCATTERCONTROLLER_p_H
41#define Q3DSCATTERCONTROLLER_p_H
42
43#include "datavisualizationglobal_p.h"
44#include "abstract3dcontroller_p.h"
45
46QT_BEGIN_NAMESPACE_DATAVISUALIZATION
47
48class Scatter3DRenderer;
49class QScatterDataProxy;
50class QScatter3DSeries;
51
52struct Scatter3DChangeBitField {
53 bool selectedItemChanged : 1;
54 bool itemChanged : 1;
55
56 Scatter3DChangeBitField() :
57 selectedItemChanged(true),
58 itemChanged(false)
59 {
60 }
61};
62
63class QT_DATAVISUALIZATION_EXPORT Scatter3DController : public Abstract3DController
64{
65 Q_OBJECT
66
67public:
68 struct ChangeItem {
69 QScatter3DSeries *series;
70 int index;
71 };
72private:
73 Scatter3DChangeBitField m_changeTracker;
74 QVector<ChangeItem> m_changedItems;
75
76 // Rendering
77 Scatter3DRenderer *m_renderer;
78 int m_selectedItem;
79 QScatter3DSeries *m_selectedItemSeries; // Points to the series for which the bar is selected
80 // in single series selection cases.
81
82 struct InsertRemoveRecord {
83 bool m_isInsert;
84 int m_startIndex;
85 int m_count;
86 QAbstract3DSeries *m_series;
87
88 InsertRemoveRecord() :
89 m_isInsert(false),
90 m_startIndex(0),
91 m_count(0),
92 m_series(0)
93 {}
94
95 InsertRemoveRecord(bool isInsert, int startIndex, int count, QAbstract3DSeries *series) :
96 m_isInsert(isInsert),
97 m_startIndex(startIndex),
98 m_count(count),
99 m_series(series)
100 {}
101 };
102
103 QVector<InsertRemoveRecord> m_insertRemoveRecords;
104 bool m_recordInsertsAndRemoves;
105
106public:
107 explicit Scatter3DController(QRect rect, Q3DScene *scene = 0);
108 ~Scatter3DController();
109
110 virtual void initializeOpenGL();
111
112 // Change selection mode
113 void setSelectionMode(QAbstract3DGraph::SelectionFlags mode);
114
115 inline QScatter3DSeries *selectedSeries() const { return m_selectedItemSeries; }
116
117 void setSelectedItem(int index, QScatter3DSeries *series);
118 static inline int invalidSelectionIndex() { return -1; }
119 virtual void clearSelection();
120
121 void synchDataToRenderer();
122
123 virtual void addSeries(QAbstract3DSeries *series);
124 virtual void removeSeries(QAbstract3DSeries *series);
125 virtual QList<QScatter3DSeries *> scatterSeriesList();
126
127 virtual void handleAxisAutoAdjustRangeChangedInOrientation(
128 QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust);
129 virtual void handleAxisRangeChangedBySender(QObject *sender);
130 virtual void handlePendingClick();
131 virtual void adjustAxisRanges();
132
133public Q_SLOTS:
134 void handleArrayReset();
135 void handleItemsAdded(int startIndex, int count);
136 void handleItemsChanged(int startIndex, int count);
137 void handleItemsRemoved(int startIndex, int count);
138 void handleItemsInserted(int startIndex, int count);
139
140Q_SIGNALS:
141 void selectedSeriesChanged(QScatter3DSeries *series);
142
143protected:
144 virtual void startRecordingRemovesAndInserts();
145
146private:
147
148 Q_DISABLE_COPY(Scatter3DController)
149};
150
151QT_END_NAMESPACE_DATAVISUALIZATION
152
153#endif
154

source code of qtdatavis3d/src/datavisualization/engine/scatter3dcontroller_p.h