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 Q3DSCATTERCONTROLLER_p_H
15#define Q3DSCATTERCONTROLLER_p_H
16
17#include <private/datavisualizationglobal_p.h>
18#include <private/abstract3dcontroller_p.h>
19
20QT_BEGIN_NAMESPACE
21
22class Scatter3DRenderer;
23class QScatterDataProxy;
24class QScatter3DSeries;
25
26struct Scatter3DChangeBitField {
27 bool selectedItemChanged : 1;
28 bool itemChanged : 1;
29
30 Scatter3DChangeBitField() :
31 selectedItemChanged(true),
32 itemChanged(false)
33 {
34 }
35};
36
37class Q_DATAVISUALIZATION_EXPORT Scatter3DController : public Abstract3DController
38{
39 Q_OBJECT
40
41public:
42 struct ChangeItem {
43 QScatter3DSeries *series;
44 int index;
45 };
46private:
47 Scatter3DChangeBitField m_changeTracker;
48 QList<ChangeItem> m_changedItems;
49
50 // Rendering
51 Scatter3DRenderer *m_renderer;
52 int m_selectedItem;
53 QScatter3DSeries *m_selectedItemSeries; // Points to the series for which the bar is selected
54 // in single series selection cases.
55
56 struct InsertRemoveRecord {
57 bool m_isInsert;
58 int m_startIndex;
59 int m_count;
60 QAbstract3DSeries *m_series;
61
62 InsertRemoveRecord() :
63 m_isInsert(false),
64 m_startIndex(0),
65 m_count(0),
66 m_series(0)
67 {}
68
69 InsertRemoveRecord(bool isInsert, int startIndex, int count, QAbstract3DSeries *series) :
70 m_isInsert(isInsert),
71 m_startIndex(startIndex),
72 m_count(count),
73 m_series(series)
74 {}
75 };
76
77 QList<InsertRemoveRecord> m_insertRemoveRecords;
78 bool m_recordInsertsAndRemoves;
79
80public:
81 explicit Scatter3DController(QRect rect, Q3DScene *scene = 0);
82 ~Scatter3DController();
83
84 void initializeOpenGL() override;
85
86 // Change selection mode
87 void setSelectionMode(QAbstract3DGraph::SelectionFlags mode) override;
88
89 inline QScatter3DSeries *selectedSeries() const { return m_selectedItemSeries; }
90
91 void setSelectedItem(int index, QScatter3DSeries *series);
92 static inline int invalidSelectionIndex() { return -1; }
93 void clearSelection() override;
94
95 void synchDataToRenderer() override;
96
97 void addSeries(QAbstract3DSeries *series) override;
98 void removeSeries(QAbstract3DSeries *series) override;
99 virtual QList<QScatter3DSeries *> scatterSeriesList();
100
101 void handleAxisAutoAdjustRangeChangedInOrientation(
102 QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust) override;
103 void handleAxisRangeChangedBySender(QObject *sender) override;
104 void handlePendingClick() override;
105 void adjustAxisRanges() override;
106
107public Q_SLOTS:
108 void handleArrayReset();
109 void handleItemsAdded(int startIndex, int count);
110 void handleItemsChanged(int startIndex, int count);
111 void handleItemsRemoved(int startIndex, int count);
112 void handleItemsInserted(int startIndex, int count);
113
114Q_SIGNALS:
115 void selectedSeriesChanged(QScatter3DSeries *series);
116
117protected:
118 void startRecordingRemovesAndInserts() override;
119
120private:
121
122 Q_DISABLE_COPY(Scatter3DController)
123};
124
125QT_END_NAMESPACE
126
127#endif
128

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