| 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 SURFACE3DCONTROLLER_P_H | 
| 41 | #define SURFACE3DCONTROLLER_P_H | 
| 42 |  | 
| 43 | #include "abstract3dcontroller_p.h" | 
| 44 | #include "datavisualizationglobal_p.h" | 
| 45 |  | 
| 46 | QT_BEGIN_NAMESPACE_DATAVISUALIZATION | 
| 47 |  | 
| 48 | class Surface3DRenderer; | 
| 49 | class QSurface3DSeries; | 
| 50 |  | 
| 51 | struct Surface3DChangeBitField { | 
| 52 |     bool selectedPointChanged      : 1; | 
| 53 |     bool rowsChanged               : 1; | 
| 54 |     bool itemChanged               : 1; | 
| 55 |     bool flipHorizontalGridChanged : 1; | 
| 56 |     bool surfaceTextureChanged     : 1; | 
| 57 |  | 
| 58 |     Surface3DChangeBitField() : | 
| 59 |         selectedPointChanged(true), | 
| 60 |         rowsChanged(false), | 
| 61 |         itemChanged(false), | 
| 62 |         flipHorizontalGridChanged(true), | 
| 63 |         surfaceTextureChanged(true) | 
| 64 |     { | 
| 65 |     } | 
| 66 | }; | 
| 67 |  | 
| 68 | class QT_DATAVISUALIZATION_EXPORT Surface3DController : public Abstract3DController | 
| 69 | { | 
| 70 |     Q_OBJECT | 
| 71 |  | 
| 72 | public: | 
| 73 |     struct ChangeItem { | 
| 74 |         QSurface3DSeries *series; | 
| 75 |         QPoint point; | 
| 76 |     }; | 
| 77 |     struct ChangeRow { | 
| 78 |         QSurface3DSeries *series; | 
| 79 |         int row; | 
| 80 |     }; | 
| 81 |  | 
| 82 | private: | 
| 83 |     Surface3DChangeBitField m_changeTracker; | 
| 84 |     Surface3DRenderer *m_renderer; | 
| 85 |     QPoint m_selectedPoint; | 
| 86 |     QSurface3DSeries *m_selectedSeries; // Points to the series for which the point is selected in | 
| 87 |                                         // single series selection cases. | 
| 88 |     bool m_flatShadingSupported; | 
| 89 |     QVector<ChangeItem> m_changedItems; | 
| 90 |     QVector<ChangeRow> m_changedRows; | 
| 91 |     bool m_flipHorizontalGrid; | 
| 92 |     QVector<QSurface3DSeries *> m_changedTextures; | 
| 93 |  | 
| 94 | public: | 
| 95 |     explicit Surface3DController(QRect rect, Q3DScene *scene = 0); | 
| 96 |     ~Surface3DController(); | 
| 97 |  | 
| 98 |     virtual void initializeOpenGL(); | 
| 99 |     virtual void synchDataToRenderer(); | 
| 100 |  | 
| 101 |     void setSelectionMode(QAbstract3DGraph::SelectionFlags mode); | 
| 102 |     void setSelectedPoint(const QPoint &position, QSurface3DSeries *series, bool enterSlice); | 
| 103 |     virtual void clearSelection(); | 
| 104 |  | 
| 105 |     inline QSurface3DSeries *selectedSeries() const { return m_selectedSeries; } | 
| 106 |  | 
| 107 |     virtual void handleAxisAutoAdjustRangeChangedInOrientation( | 
| 108 |             QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust); | 
| 109 |     virtual void handleAxisRangeChangedBySender(QObject *sender); | 
| 110 |     virtual void handleSeriesVisibilityChangedBySender(QObject *sender); | 
| 111 |     virtual void handlePendingClick(); | 
| 112 |     virtual void adjustAxisRanges(); | 
| 113 |  | 
| 114 |     static QPoint invalidSelectionPosition(); | 
| 115 |     bool isFlatShadingSupported(); | 
| 116 |  | 
| 117 |     virtual void addSeries(QAbstract3DSeries *series); | 
| 118 |     virtual void removeSeries(QAbstract3DSeries *series); | 
| 119 |     virtual QList<QSurface3DSeries *> surfaceSeriesList(); | 
| 120 |  | 
| 121 |     void setFlipHorizontalGrid(bool flip); | 
| 122 |     bool flipHorizontalGrid() const; | 
| 123 |  | 
| 124 |     void updateSurfaceTexture(QSurface3DSeries *series); | 
| 125 |  | 
| 126 | public Q_SLOTS: | 
| 127 |     void handleArrayReset(); | 
| 128 |     void handleRowsAdded(int startIndex, int count); | 
| 129 |     void handleRowsChanged(int startIndex, int count); | 
| 130 |     void handleRowsRemoved(int startIndex, int count); | 
| 131 |     void handleRowsInserted(int startIndex, int count); | 
| 132 |     void handleItemChanged(int rowIndex, int columnIndex); | 
| 133 |  | 
| 134 |     void handleFlatShadingSupportedChange(bool supported); | 
| 135 |  | 
| 136 | Q_SIGNALS: | 
| 137 |     void selectedSeriesChanged(QSurface3DSeries *series); | 
| 138 |     void flipHorizontalGridChanged(bool flip); | 
| 139 |  | 
| 140 | private: | 
| 141 |     Q_DISABLE_COPY(Surface3DController) | 
| 142 | }; | 
| 143 |  | 
| 144 | QT_END_NAMESPACE_DATAVISUALIZATION | 
| 145 |  | 
| 146 | #endif | 
| 147 |  |