| 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 SURFACESERIESRENDERCACHE_P_H | 
| 41 | #define SURFACESERIESRENDERCACHE_P_H | 
| 42 | |
| 43 | #include "datavisualizationglobal_p.h" | 
| 44 | #include "seriesrendercache_p.h" | 
| 45 | #include "qsurface3dseries_p.h" | 
| 46 | #include "surfaceobject_p.h" | 
| 47 | #include "selectionpointer_p.h" | 
| 48 | |
| 49 | #include <QtGui/QMatrix4x4> | 
| 50 | |
| 51 | QT_BEGIN_NAMESPACE_DATAVISUALIZATION | 
| 52 | |
| 53 | class Surface3DRenderer; | 
| 54 | |
| 55 | class SurfaceSeriesRenderCache : public SeriesRenderCache | 
| 56 | { | 
| 57 | public: | 
| 58 | SurfaceSeriesRenderCache(QAbstract3DSeries *series, Surface3DRenderer *renderer); | 
| 59 | virtual ~SurfaceSeriesRenderCache(); | 
| 60 | |
| 61 | virtual void populate(bool newSeries); | 
| 62 | virtual void cleanup(TextureHelper *texHelper); | 
| 63 | |
| 64 | inline bool surfaceVisible() const { return m_surfaceVisible; } | 
| 65 | inline bool surfaceGridVisible() const { return m_surfaceGridVisible; } | 
| 66 | inline bool isFlatShadingEnabled() const { return m_surfaceFlatShading; } | 
| 67 | inline void setFlatShadingEnabled(bool enabled) { m_surfaceFlatShading = enabled; } | 
| 68 | inline void setFlatChangeAllowed(bool allowed) { m_flatChangeAllowed = allowed; } | 
| 69 | inline SurfaceObject *surfaceObject() { return m_surfaceObj; } | 
| 70 | inline SurfaceObject *sliceSurfaceObject() { return m_sliceSurfaceObj; } | 
| 71 | inline const QRect &sampleSpace() const { return m_sampleSpace; } | 
| 72 | inline void setSampleSpace(const QRect &sampleSpace) { m_sampleSpace = sampleSpace; } | 
| 73 | inline QSurface3DSeries *series() const { return static_cast<QSurface3DSeries *>(m_series); } | 
| 74 | inline QSurfaceDataArray &dataArray() { return m_dataArray; } | 
| 75 | inline QSurfaceDataArray &sliceDataArray() { return m_sliceDataArray; } | 
| 76 | inline bool renderable() const { return m_visible && (m_surfaceVisible || | 
| 77 | m_surfaceGridVisible); } | 
| 78 | inline void setSelectionTexture(GLuint texture) { m_selectionTexture = texture; } | 
| 79 | inline GLuint selectionTexture() const { return m_selectionTexture; } | 
| 80 | inline void setSelectionIdRange(uint start, uint end) { m_selectionIdStart = start; | 
| 81 | m_selectionIdEnd = end; } | 
| 82 | inline uint selectionIdStart() const { return m_selectionIdStart; } | 
| 83 | inline bool isWithinIdRange(uint selection) const { return selection >= m_selectionIdStart && | 
| 84 | selection <= m_selectionIdEnd; } | 
| 85 | inline bool isFlatStatusDirty() const { return m_flatStatusDirty; } | 
| 86 | inline void setFlatStatusDirty(bool status) { m_flatStatusDirty = status; } | 
| 87 | inline void setMVPMatrix(const QMatrix4x4 &matrix) { m_MVPMatrix = matrix; } | 
| 88 | inline const QMatrix4x4 &MVPMatrix() { return m_MVPMatrix; } | 
| 89 | |
| 90 | inline void setSliceSelectionPointer(SelectionPointer *pointer) { m_sliceSelectionPointer = pointer; } | 
| 91 | inline SelectionPointer *sliceSelectionPointer() const { return m_sliceSelectionPointer; } | 
| 92 | inline void setMainSelectionPointer(SelectionPointer *pointer) { m_mainSelectionPointer = pointer; } | 
| 93 | inline SelectionPointer *mainSelectionPointer() const { return m_mainSelectionPointer; } | 
| 94 | |
| 95 | inline void setSlicePointerActivity(bool activity) { m_slicePointerActive = activity; } | 
| 96 | inline bool slicePointerActive() const { return m_slicePointerActive; } | 
| 97 | inline void setMainPointerActivity(bool activity) { m_mainPointerActive = activity; } | 
| 98 | inline bool mainPointerActive() const { return m_mainPointerActive; } | 
| 99 | inline void setSurfaceTexture(GLuint texture) { m_surfaceTexture = texture; } | 
| 100 | inline GLuint surfaceTexture() const { return m_surfaceTexture; } | 
| 101 | |
| 102 | protected: | 
| 103 | bool m_surfaceVisible; | 
| 104 | bool m_surfaceGridVisible; | 
| 105 | bool m_surfaceFlatShading; | 
| 106 | SurfaceObject *m_surfaceObj; | 
| 107 | SurfaceObject *m_sliceSurfaceObj; | 
| 108 | QRect m_sampleSpace; | 
| 109 | QSurfaceDataArray m_dataArray; | 
| 110 | QSurfaceDataArray m_sliceDataArray; | 
| 111 | GLuint m_selectionTexture; | 
| 112 | uint m_selectionIdStart; | 
| 113 | uint m_selectionIdEnd; | 
| 114 | bool m_flatChangeAllowed; | 
| 115 | bool m_flatStatusDirty; | 
| 116 | QMatrix4x4 m_MVPMatrix; | 
| 117 | SelectionPointer *m_sliceSelectionPointer; | 
| 118 | SelectionPointer *m_mainSelectionPointer; | 
| 119 | bool m_slicePointerActive; | 
| 120 | bool m_mainPointerActive; | 
| 121 | GLuint m_surfaceTexture; | 
| 122 | }; | 
| 123 | |
| 124 | QT_END_NAMESPACE_DATAVISUALIZATION | 
| 125 | |
| 126 | #endif | 
| 127 | 
