| 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 SURFACE3DCONTROLLER_P_H |
| 15 | #define SURFACE3DCONTROLLER_P_H |
| 16 | |
| 17 | #include <private/abstract3dcontroller_p.h> |
| 18 | #include <private/datavisualizationglobal_p.h> |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | class Surface3DRenderer; |
| 23 | class QSurface3DSeries; |
| 24 | |
| 25 | struct Surface3DChangeBitField { |
| 26 | bool selectedPointChanged : 1; |
| 27 | bool rowsChanged : 1; |
| 28 | bool itemChanged : 1; |
| 29 | bool flipHorizontalGridChanged : 1; |
| 30 | bool surfaceTextureChanged : 1; |
| 31 | |
| 32 | Surface3DChangeBitField() : |
| 33 | selectedPointChanged(true), |
| 34 | rowsChanged(false), |
| 35 | itemChanged(false), |
| 36 | flipHorizontalGridChanged(true), |
| 37 | surfaceTextureChanged(true) |
| 38 | { |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | class Q_DATAVISUALIZATION_EXPORT Surface3DController : public Abstract3DController |
| 43 | { |
| 44 | Q_OBJECT |
| 45 | |
| 46 | public: |
| 47 | struct ChangeItem { |
| 48 | QSurface3DSeries *series; |
| 49 | QPoint point; |
| 50 | }; |
| 51 | struct ChangeRow { |
| 52 | QSurface3DSeries *series; |
| 53 | int row; |
| 54 | }; |
| 55 | |
| 56 | private: |
| 57 | Surface3DChangeBitField m_changeTracker; |
| 58 | Surface3DRenderer *m_renderer; |
| 59 | QPoint m_selectedPoint; |
| 60 | QSurface3DSeries *m_selectedSeries; // Points to the series for which the point is selected in |
| 61 | // single series selection cases. |
| 62 | bool m_flatShadingSupported; |
| 63 | QList<ChangeItem> m_changedItems; |
| 64 | QList<ChangeRow> m_changedRows; |
| 65 | bool m_flipHorizontalGrid; |
| 66 | QList<QSurface3DSeries *> m_changedTextures; |
| 67 | |
| 68 | public: |
| 69 | explicit Surface3DController(QRect rect, Q3DScene *scene = 0); |
| 70 | ~Surface3DController(); |
| 71 | |
| 72 | void initializeOpenGL() override; |
| 73 | void synchDataToRenderer() override; |
| 74 | |
| 75 | void setSelectionMode(QAbstract3DGraph::SelectionFlags mode) override; |
| 76 | void setSelectedPoint(const QPoint &position, QSurface3DSeries *series, bool enterSlice); |
| 77 | void clearSelection() override; |
| 78 | |
| 79 | inline QSurface3DSeries *selectedSeries() const { return m_selectedSeries; } |
| 80 | |
| 81 | void handleAxisAutoAdjustRangeChangedInOrientation( |
| 82 | QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust) override; |
| 83 | void handleAxisRangeChangedBySender(QObject *sender) override; |
| 84 | void handleSeriesVisibilityChangedBySender(QObject *sender) override; |
| 85 | void handlePendingClick() override; |
| 86 | void adjustAxisRanges() override; |
| 87 | |
| 88 | static QPoint invalidSelectionPosition(); |
| 89 | bool isFlatShadingSupported(); |
| 90 | |
| 91 | void addSeries(QAbstract3DSeries *series) override; |
| 92 | void removeSeries(QAbstract3DSeries *series) override; |
| 93 | virtual QList<QSurface3DSeries *> surfaceSeriesList(); |
| 94 | |
| 95 | void setFlipHorizontalGrid(bool flip); |
| 96 | bool flipHorizontalGrid() const; |
| 97 | |
| 98 | void updateSurfaceTexture(QSurface3DSeries *series); |
| 99 | |
| 100 | public Q_SLOTS: |
| 101 | void handleArrayReset(); |
| 102 | void handleRowsAdded(int startIndex, int count); |
| 103 | void handleRowsChanged(int startIndex, int count); |
| 104 | void handleRowsRemoved(int startIndex, int count); |
| 105 | void handleRowsInserted(int startIndex, int count); |
| 106 | void handleItemChanged(int rowIndex, int columnIndex); |
| 107 | |
| 108 | void handleFlatShadingSupportedChange(bool supported); |
| 109 | |
| 110 | Q_SIGNALS: |
| 111 | void selectedSeriesChanged(QSurface3DSeries *series); |
| 112 | void flipHorizontalGridChanged(bool flip); |
| 113 | |
| 114 | private: |
| 115 | Q_DISABLE_COPY(Surface3DController) |
| 116 | }; |
| 117 | |
| 118 | QT_END_NAMESPACE |
| 119 | |
| 120 | #endif |
| 121 | |