1 | // Copyright (C) 2023 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 QtGraphs 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 SURFACE3DCONTROLLER_P_H |
15 | #define SURFACE3DCONTROLLER_P_H |
16 | |
17 | #include <private/abstract3dcontroller_p.h> |
18 | #include <private/graphsglobal_p.h> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | class QSurface3DSeries; |
23 | |
24 | struct Surface3DChangeBitField { |
25 | bool selectedPointChanged : 1; |
26 | bool rowsChanged : 1; |
27 | bool itemChanged : 1; |
28 | bool flipHorizontalGridChanged : 1; |
29 | bool surfaceTextureChanged : 1; |
30 | |
31 | Surface3DChangeBitField() : |
32 | selectedPointChanged(true), |
33 | rowsChanged(false), |
34 | itemChanged(false), |
35 | flipHorizontalGridChanged(true), |
36 | surfaceTextureChanged(true) |
37 | { |
38 | } |
39 | }; |
40 | |
41 | class Q_GRAPHS_EXPORT Surface3DController : public Abstract3DController |
42 | { |
43 | Q_OBJECT |
44 | |
45 | public: |
46 | struct ChangeItem { |
47 | QSurface3DSeries *series; |
48 | QPoint point; |
49 | }; |
50 | struct ChangeRow { |
51 | QSurface3DSeries *series; |
52 | int row; |
53 | }; |
54 | enum DataDimension { |
55 | BothAscending = 0, |
56 | XDescending = 1, |
57 | ZDescending = 2, |
58 | BothDescending = XDescending | ZDescending |
59 | }; |
60 | Q_DECLARE_FLAGS(DataDimensions, DataDimension) |
61 | |
62 | explicit Surface3DController(QRect rect, Q3DScene *scene = 0); |
63 | ~Surface3DController(); |
64 | |
65 | void setSelectionMode(QAbstract3DGraph::SelectionFlags mode) override; |
66 | void setSelectedPoint(const QPoint &position, QSurface3DSeries *series, bool enterSlice); |
67 | void clearSelection() override; |
68 | |
69 | inline QSurface3DSeries *selectedSeries() const { return m_selectedSeries; } |
70 | |
71 | void handleAxisAutoAdjustRangeChangedInOrientation( |
72 | QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust) override; |
73 | void handleAxisRangeChangedBySender(QObject *sender) override; |
74 | void handleSeriesVisibilityChangedBySender(QObject *sender) override; |
75 | void adjustAxisRanges() override; |
76 | |
77 | static QPoint invalidSelectionPosition(); |
78 | bool isFlatShadingSupported(); |
79 | |
80 | void addSeries(QAbstract3DSeries *series) override; |
81 | void removeSeries(QAbstract3DSeries *series) override; |
82 | virtual QList<QSurface3DSeries *> surfaceSeriesList(); |
83 | |
84 | void setFlipHorizontalGrid(bool flip); |
85 | bool flipHorizontalGrid() const; |
86 | |
87 | void updateSurfaceTexture(QSurface3DSeries *series); |
88 | |
89 | void setDataDimensions(DataDimensions dimension) { m_dataDimensions = dimension; } |
90 | DataDimensions dataDimensions() { return m_dataDimensions; } |
91 | |
92 | bool hasChangedSeriesList() const { return !m_changedSeriesList.isEmpty(); } |
93 | bool isSeriesVisibilityDirty() const { return m_isSeriesVisibilityDirty; } |
94 | void setSeriesVisibilityDirty(bool dirty) { m_isSeriesVisibilityDirty = dirty; } |
95 | bool isDataDirty() const { return m_isDataDirty; } |
96 | void setDataDirty(bool dirty) { m_isDataDirty = dirty; } |
97 | bool isSeriesVisualsDirty() const { return m_isSeriesVisualsDirty; } |
98 | void setSeriesVisualsDirty(bool dirty) { m_isSeriesVisualsDirty = dirty; } |
99 | |
100 | QList<QAbstract3DSeries *> changedSeriesList() { return m_changedSeriesList; } |
101 | |
102 | bool isSelectedPointChanged() const { return m_changeTracker.selectedPointChanged; } |
103 | void setSelectedPointChanged(bool changed) { m_changeTracker.selectedPointChanged = changed; } |
104 | |
105 | bool isFlipHorizontalGridChanged() const { return m_changeTracker.flipHorizontalGridChanged; } |
106 | void setFlipHorizontalGridChanged(bool changed) { m_changeTracker.flipHorizontalGridChanged = changed; } |
107 | |
108 | bool isSurfaceTextureChanged() const { return m_changeTracker.surfaceTextureChanged; } |
109 | void setSurfaceTextureChanged(bool changed) { m_changeTracker.surfaceTextureChanged = changed; } |
110 | bool isChangedTexturesEmpty() const { return m_changedTextures.empty(); } |
111 | bool hasSeriesToChangeTexture(QSurface3DSeries *series) const { return m_changedTextures.contains(t: series); } |
112 | |
113 | public Q_SLOTS: |
114 | void handleArrayReset(); |
115 | void handleRowsAdded(int startIndex, int count); |
116 | void handleRowsChanged(int startIndex, int count); |
117 | void handleRowsRemoved(int startIndex, int count); |
118 | void handleRowsInserted(int startIndex, int count); |
119 | void handleItemChanged(int rowIndex, int columnIndex); |
120 | |
121 | void handleFlatShadingSupportedChange(bool supported); |
122 | |
123 | Q_SIGNALS: |
124 | void selectedSeriesChanged(QSurface3DSeries *series); |
125 | void flipHorizontalGridChanged(bool flip); |
126 | |
127 | private: |
128 | Surface3DChangeBitField m_changeTracker; |
129 | QPoint m_selectedPoint; |
130 | QSurface3DSeries *m_selectedSeries; // Points to the series for which the point is selected in |
131 | // single series selection cases. |
132 | bool m_flatShadingSupported; |
133 | QList<ChangeItem> m_changedItems; |
134 | QList<ChangeRow> m_changedRows; |
135 | bool m_flipHorizontalGrid; |
136 | QList<QSurface3DSeries *> m_changedTextures; |
137 | bool m_isSeriesVisibilityDirty; |
138 | |
139 | Surface3DController::DataDimensions m_dataDimensions; |
140 | |
141 | Q_DISABLE_COPY(Surface3DController) |
142 | }; |
143 | |
144 | QT_END_NAMESPACE |
145 | |
146 | #endif |
147 | |