1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "surfaceseriesrendercache_p.h"
5#include "surface3drenderer_p.h"
6#include "texturehelper_p.h"
7
8QT_BEGIN_NAMESPACE
9
10SurfaceSeriesRenderCache::SurfaceSeriesRenderCache(QAbstract3DSeries *series,
11 Surface3DRenderer *renderer)
12 : SeriesRenderCache(series, renderer),
13 m_surfaceVisible(false),
14 m_surfaceGridVisible(false),
15 m_surfaceFlatShading(false),
16 m_surfaceObj(new SurfaceObject(renderer)),
17 m_sliceSurfaceObj(new SurfaceObject(renderer)),
18 m_sampleSpace(QRect(0, 0, 0, 0)),
19 m_selectionTexture(0),
20 m_selectionIdStart(0),
21 m_selectionIdEnd(0),
22 m_flatChangeAllowed(true),
23 m_flatStatusDirty(true),
24 m_sliceSelectionPointer(0),
25 m_mainSelectionPointer(0),
26 m_slicePointerActive(false),
27 m_mainPointerActive(false),
28 m_surfaceTexture(0)
29{
30}
31
32SurfaceSeriesRenderCache::~SurfaceSeriesRenderCache()
33{
34}
35
36void SurfaceSeriesRenderCache::populate(bool newSeries)
37{
38 SeriesRenderCache::populate(newSeries);
39
40 QSurface3DSeries::DrawFlags drawMode = series()->drawMode();
41 m_surfaceVisible = drawMode.testFlag(flag: QSurface3DSeries::DrawSurface);
42 m_surfaceGridVisible = drawMode.testFlag(flag: QSurface3DSeries::DrawWireframe);
43 QColor lineColor = series()->wireframeColor();
44 m_surfaceObj->setLineColor(lineColor);
45 m_sliceSurfaceObj->setLineColor(lineColor);
46
47 if (m_flatChangeAllowed && m_surfaceFlatShading != series()->isFlatShadingEnabled()) {
48 m_surfaceFlatShading = series()->isFlatShadingEnabled();
49 m_flatStatusDirty = true;
50 }
51}
52
53void SurfaceSeriesRenderCache::cleanup(TextureHelper *texHelper)
54{
55 if (QOpenGLContext::currentContext()) {
56 texHelper->deleteTexture(texture: &m_selectionTexture);
57 texHelper->deleteTexture(texture: &m_surfaceTexture);
58 }
59
60 delete m_surfaceObj;
61 delete m_sliceSurfaceObj;
62 for (int i = 0; i < m_dataArray.size(); i++)
63 delete m_dataArray.at(i);
64 m_dataArray.clear();
65
66 for (int i = 0; i < m_sliceDataArray.size(); i++)
67 delete m_sliceDataArray.at(i);
68 m_sliceDataArray.clear();
69
70 delete m_sliceSelectionPointer;
71 delete m_mainSelectionPointer;
72
73 SeriesRenderCache::cleanup(texHelper);
74}
75
76QT_END_NAMESPACE
77

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