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 GRAPHMODIFIER_H
31#define GRAPHMODIFIER_H
32
33#include <QtDataVisualization/Q3DSurface>
34#include <QtDataVisualization/QSurfaceDataProxy>
35#include <QtDataVisualization/QSurface3DSeries>
36#include <QSlider>
37#include <QTimer>
38#include <QLabel>
39#include <QCheckBox>
40
41#define MULTI_SERIES
42
43using namespace QtDataVisualization;
44
45class GraphModifier : public QObject
46{
47 Q_OBJECT
48public:
49 enum Samples {
50 SqrtSin = 1,
51 Plane,
52 Map
53 };
54
55 explicit GraphModifier(Q3DSurface *graph, QWidget *parentWidget);
56 ~GraphModifier();
57
58 void toggleSeries1(bool enabled);
59 void toggleSeries2(bool enabled);
60 void toggleSeries3(bool enabled);
61 void toggleSeries4(bool enabled);
62 void toggleSmooth(bool enabled);
63 void toggleSurfaceGrid(bool enable);
64 void toggleSurface(bool enable);
65 void toggleSeriesVisible(bool enable);
66 void toggleSmoothS2(bool enabled);
67 void toggleSurfaceGridS2(bool enable);
68 void toggleSurfaceS2(bool enable);
69 void toggleSeries2Visible(bool enable);
70 void toggleSmoothS3(bool enabled);
71 void toggleSurfaceGridS3(bool enable);
72 void toggleSurfaceS3(bool enable);
73 void toggleSeries3Visible(bool enable);
74 void toggleSmoothS4(bool enabled);
75 void toggleSurfaceGridS4(bool enable);
76 void toggleSurfaceS4(bool enable);
77 void toggleSeries4Visible(bool enable);
78
79 void toggleSqrtSin(bool enable);
80 void togglePlane(bool enable);
81 void setHeightMapData(bool enable);
82 void toggleGridSliderLock(bool enable);
83 void setGridSliderX(QSlider *slider) { m_gridSliderX = slider; }
84 void setGridSliderZ(QSlider *slider) { m_gridSliderZ = slider; }
85 void setAxisRangeSliderX(QSlider *slider) { m_axisRangeSliderX = slider; }
86 void setAxisRangeSliderZ(QSlider *slider) { m_axisRangeSliderZ = slider; }
87 void setAxisMinSliderX(QSlider *slider) { m_axisMinSliderX = slider; }
88 void setAxisMinSliderZ(QSlider *slider) { m_axisMinSliderZ = slider; }
89 void setSeries1CB(QCheckBox *cb) { m_series1CB = cb; }
90 void setSeries2CB(QCheckBox *cb) { m_series2CB = cb; }
91 void setSeries3CB(QCheckBox *cb) { m_series3CB = cb; }
92 void setSeries4CB(QCheckBox *cb) { m_series4CB = cb; }
93 void adjustXCount(int count);
94 void adjustZCount(int count);
95 void adjustXRange(int range);
96 void adjustYRange(int range);
97 void adjustZRange(int range);
98 void adjustXMin(int min);
99 void adjustYMin(int min);
100 void adjustZMin(int min);
101 void updateSamples();
102 void gradientPressed();
103 void changeFont(const QFont &font);
104 void changeStyle();
105 void selectButtonClicked();
106 void setSelectionInfoLabel(QLabel *label) {m_selectionInfoLabel = label; }
107 void selectedPointChanged(const QPoint &point);
108 void changeRow();
109 void changeRows();
110 void changeMesh();
111 void changeItem();
112 void changeMultipleItem();
113 void changeMultipleRows();
114 void addRow();
115 void addRows();
116 void insertRow();
117 void insertRows();
118 void removeRow();
119 void resetArray();
120 void resetArrayEmpty();
121 void massiveDataTest();
122 void massiveTestScroll();
123 void massiveTestAppendAndScroll();
124 void testAxisReverse();
125 void testDataOrdering();
126 void setAspectRatio(int ratio);
127 void setHorizontalAspectRatio(int ratio);
128 void setSurfaceTexture(bool enabled);
129
130public Q_SLOTS:
131 void changeShadowQuality(int quality);
132 void changeTheme(int theme);
133 void flipViews();
134 void changeSelectionMode(int mode);
135 void timeout();
136 void graphQueryTimeout();
137
138 void handleAxisXChanged(QValue3DAxis *axis);
139 void handleAxisYChanged(QValue3DAxis *axis);
140 void handleAxisZChanged(QValue3DAxis *axis);
141 void handleFpsChange(qreal fps);
142 void changeLabelRotation(int rotation);
143 void toggleAxisTitleVisibility(bool enabled);
144 void toggleAxisTitleFixed(bool enabled);
145 void toggleXAscending(bool enabled);
146 void toggleZAscending(bool enabled);
147 void togglePolar(bool enabled);
148 void setCameraTargetX(int value);
149 void setCameraTargetY(int value);
150 void setCameraTargetZ(int value);
151 void setGraphMargin(int value);
152
153private:
154 void fillSeries();
155 void resetArrayAndSliders(QSurfaceDataArray *array, float minZ, float maxZ, float minX,
156 float maxX);
157 QSurfaceDataRow *createMultiRow(int row, int series, bool change);
158 void populateRisingSeries(QSurface3DSeries *series, int rows, int columns, float minValue,
159 float maxValue, bool ascendingX, bool ascendingZ);
160
161 Q3DSurface *m_graph;
162 QSurface3DSeries *m_multiseries[4];
163 QSurface3DSeries *m_series1;
164 QSurface3DSeries *m_series2;
165 QSurface3DSeries *m_series3;
166 QSurface3DSeries *m_series4;
167 QSlider *m_gridSliderX;
168 QSlider *m_gridSliderZ;
169 QSlider *m_axisRangeSliderX;
170 QSlider *m_axisRangeSliderZ;
171 QSlider *m_axisMinSliderX;
172 QSlider *m_axisMinSliderZ;
173 QCheckBox *m_series1CB;
174 QCheckBox *m_series2CB;
175 QCheckBox *m_series3CB;
176 QCheckBox *m_series4CB;
177 bool m_gridSlidersLocked;
178 int m_xCount;
179 int m_zCount;
180 int m_activeSample;
181 int m_fontSize;
182 float m_rangeX;
183 float m_rangeY;
184 float m_rangeZ;
185 float m_minX;
186 float m_minY;
187 float m_minZ;
188 int m_addRowCounter;
189 int m_insertTestZPos;
190 int m_insertTestIndexPos;
191 QTimer m_timer;
192 QSurfaceDataArray *m_planeArray;
193 QLabel *m_selectionInfoLabel;
194 QSurface3DSeries *m_theSeries;
195 QSurface3DSeries::DrawFlags m_drawMode;
196 QSurface3DSeries::DrawFlags m_drawMode2;
197 QSurface3DSeries::DrawFlags m_drawMode3;
198 QSurface3DSeries::DrawFlags m_drawMode4;
199 float m_limitX;
200 float m_limitZ;
201 float m_offset;
202 float m_multiSampleOffsetX[4];
203 float m_multiSampleOffsetZ[4];
204 QSurfaceDataArray m_massiveTestCacheArray;
205 QVector3D m_cameraTarget;
206 QWidget *m_parentWidget;
207 QTimer m_graphPositionQueryTimer;
208 bool m_ascendingX;
209 bool m_ascendingZ;
210};
211
212#endif
213

source code of qtdatavis3d/tests/manual/surfacetest/graphmodifier.h