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#include "surfaceseriesrendercache_p.h"
31#include "surface3drenderer_p.h"
32#include "texturehelper_p.h"
33
34QT_BEGIN_NAMESPACE_DATAVISUALIZATION
35
36SurfaceSeriesRenderCache::SurfaceSeriesRenderCache(QAbstract3DSeries *series,
37 Surface3DRenderer *renderer)
38 : SeriesRenderCache(series, renderer),
39 m_surfaceVisible(false),
40 m_surfaceGridVisible(false),
41 m_surfaceFlatShading(false),
42 m_surfaceObj(new SurfaceObject(renderer)),
43 m_sliceSurfaceObj(new SurfaceObject(renderer)),
44 m_sampleSpace(QRect(0, 0, 0, 0)),
45 m_selectionTexture(0),
46 m_selectionIdStart(0),
47 m_selectionIdEnd(0),
48 m_flatChangeAllowed(true),
49 m_flatStatusDirty(true),
50 m_sliceSelectionPointer(0),
51 m_mainSelectionPointer(0),
52 m_slicePointerActive(false),
53 m_mainPointerActive(false),
54 m_surfaceTexture(0)
55{
56}
57
58SurfaceSeriesRenderCache::~SurfaceSeriesRenderCache()
59{
60}
61
62void SurfaceSeriesRenderCache::populate(bool newSeries)
63{
64 SeriesRenderCache::populate(newSeries);
65
66 QSurface3DSeries::DrawFlags drawMode = series()->drawMode();
67 m_surfaceVisible = drawMode.testFlag(flag: QSurface3DSeries::DrawSurface);
68 m_surfaceGridVisible = drawMode.testFlag(flag: QSurface3DSeries::DrawWireframe);
69 if (m_flatChangeAllowed && m_surfaceFlatShading != series()->isFlatShadingEnabled()) {
70 m_surfaceFlatShading = series()->isFlatShadingEnabled();
71 m_flatStatusDirty = true;
72 }
73}
74
75void SurfaceSeriesRenderCache::cleanup(TextureHelper *texHelper)
76{
77 if (QOpenGLContext::currentContext()) {
78 texHelper->deleteTexture(texture: &m_selectionTexture);
79 texHelper->deleteTexture(texture: &m_surfaceTexture);
80 }
81
82 delete m_surfaceObj;
83 delete m_sliceSurfaceObj;
84 for (int i = 0; i < m_dataArray.size(); i++)
85 delete m_dataArray.at(i);
86 m_dataArray.clear();
87
88 for (int i = 0; i < m_sliceDataArray.size(); i++)
89 delete m_sliceDataArray.at(i);
90 m_sliceDataArray.clear();
91
92 delete m_sliceSelectionPointer;
93 delete m_mainSelectionPointer;
94
95 SeriesRenderCache::cleanup(texHelper);
96}
97
98QT_END_NAMESPACE_DATAVISUALIZATION
99

source code of qtdatavis3d/src/datavisualization/engine/surfaceseriesrendercache.cpp