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#ifndef SURFACEGRAPH_H
31#define SURFACEGRAPH_H
32
33#include <QtDataVisualization/Q3DSurface>
34#include <QtDataVisualization/QSurfaceDataProxy>
35#include <QtDataVisualization/QHeightMapSurfaceDataProxy>
36#include <QtDataVisualization/QSurface3DSeries>
37#include <QtWidgets/QSlider>
38
39using namespace QtDataVisualization;
40
41class SurfaceGraph : public QObject
42{
43 Q_OBJECT
44public:
45 explicit SurfaceGraph(Q3DSurface *surface);
46 ~SurfaceGraph();
47
48 void enableHeightMapModel(bool enable);
49 void enableSqrtSinModel(bool enable);
50
51 //! [0]
52 void toggleModeNone() { m_graph->setSelectionMode(QAbstract3DGraph::SelectionNone); }
53 void toggleModeItem() { m_graph->setSelectionMode(QAbstract3DGraph::SelectionItem); }
54 void toggleModeSliceRow() { m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemAndRow
55 | QAbstract3DGraph::SelectionSlice); }
56 void toggleModeSliceColumn() { m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemAndColumn
57 | QAbstract3DGraph::SelectionSlice); }
58 //! [0]
59
60 void setBlackToYellowGradient();
61 void setGreenToRedGradient();
62
63 void setAxisMinSliderX(QSlider *slider) { m_axisMinSliderX = slider; }
64 void setAxisMaxSliderX(QSlider *slider) { m_axisMaxSliderX = slider; }
65 void setAxisMinSliderZ(QSlider *slider) { m_axisMinSliderZ = slider; }
66 void setAxisMaxSliderZ(QSlider *slider) { m_axisMaxSliderZ = slider; }
67
68 void adjustXMin(int min);
69 void adjustXMax(int max);
70 void adjustZMin(int min);
71 void adjustZMax(int max);
72
73public Q_SLOTS:
74 void changeTheme(int theme);
75
76private:
77 Q3DSurface *m_graph;
78 QHeightMapSurfaceDataProxy *m_heightMapProxy;
79 QSurfaceDataProxy *m_sqrtSinProxy;
80 QSurface3DSeries *m_heightMapSeries;
81 QSurface3DSeries *m_sqrtSinSeries;
82
83 QSlider *m_axisMinSliderX;
84 QSlider *m_axisMaxSliderX;
85 QSlider *m_axisMinSliderZ;
86 QSlider *m_axisMaxSliderZ;
87 float m_rangeMinX;
88 float m_rangeMinZ;
89 float m_stepX;
90 float m_stepZ;
91 int m_heightMapWidth;
92 int m_heightMapHeight;
93
94 void setAxisXRange(float min, float max);
95 void setAxisZRange(float min, float max);
96 void fillSqrtSinProxy();
97};
98
99#endif // SURFACEGRAPH_H
100

source code of qtdatavis3d/examples/datavisualization/surface/surfacegraph.h