summaryrefslogtreecommitdiffstats
path: root/src/graphs3d/data/qspline3dseries.cpp
blob: a8202379f26a45858d81168a73a44b2ea0497b44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <private/qspline3dseries_p.h>
#include "qgraphs3dlogging_p.h"

QT_BEGIN_NAMESPACE

/*!
 * \class QSpline3DSeries
 * \inmodule QtGraphs
 * \ingroup graphs_3D
 * \since 6.9
 * \brief The QSpline3DSeries class represents a data series as a spline.
 *
 * Spline graphs are used to show information as a series of data points connected
 * by a curved or straight Catmull-Rom spline.
 *
 * This class manages the spline specific visual elements.
 *
 * Spline3DSeries extends the Scatter3DSeries API.
 */

/*!
 * \qmltype Spline3DSeries
 * \nativetype QSpline3DSeries
 * \inqmlmodule QtGraphs
 * \ingroup graphs_qml_3D
 * \inherits Scatter3DSeries
 * \since 6.9
 * \brief Represents a data series in a 3D spline graph.
 *
 * Spline graphs are used to show information as a series of data points connected
 * by a curved or straight Catmull-Rom spline.
 *
 * This type manages the spline specific visual elements.
 *
 */

/*!
 * \qmlproperty bool Spline3DSeries::splineVisible
 *
 * Visibility of the spline. The default value is \c true.
 */

/*!
 * \qmlproperty real Spline3DSeries::splineTension
 *
 * The tension of the spline.
 *
 * The spline uses maximum curvature for segments at a value of \c 0.0
 * Segments are completely straight at a value of \c 1.0
 * Must be between \c 0.0 and \c 1.0
 * The default value is \c 0.0
 *
 */

/*!
 * \qmlproperty real Spline3DSeries::splineKnotting
 *
 * The knot parametrization of the spline.
 *
 * This parameter can change the profile of the curve.
 * The spline is classified as a uniform Catmull-Rom spline at a value of \c 0.0,
 * a centripetal Catmull-Rom spline at a value of \c 0.5,
 * and a chordal Catmull-Rom spline at a value of \c 1.0.
 *
 * The value must be between \c 0.0 and \c 1.0.
 * The default value is \c 0.5.
 *
 */

/*!
 * \qmlproperty bool Spline3DSeries::splineLooping
 *
 * Determines whether the spline loops.
 *
 * This adds a spline segment between the first and last points of the series
 * connecting the spline into a loop.
 *
 * The default value is \c false
 *
 */

/*!
 * \qmlproperty int QSpline3DSeries::splineResolution
 * 
 * The resolution of the segments spline.
 * 
 * The number of vertices per spline segment,
 * which is defined as the part between two points.
 * 
 * Must be a value above \c 2. 
 * The default value is \c 10.
 */

/*!
 * \qmlproperty color Spline3DSeries::splineColor
 *
 * The color of the spline.
 *
 */

/*!
    \qmlsignal Scatter3DSeries::splineVisibilityChanged(bool visible)

    This signal is emitted when splineVisible changes to \a visible.
*/

/*!
    \qmlsignal Scatter3DSeries::splineTensionChanged(real tension)

    This signal is emitted when splineTension changes to \a tension.
*/

/*!
    \qmlsignal Scatter3DSeries::splineKnottingChanged(real knotting)

    This signal is emitted when splineKnotting changes to \a knotting.
*/

/*!
    \qmlsignal Scatter3DSeries::splineLoopingChanged(bool looping)

    This signal is emitted when splineLooping changes to \a looping.
*/

/*!
    \qmlsignal Scatter3DSeries::splineColorChanged(color color)

    This signal is emitted when splineColor changes to \a color.
*/

/*!
    \qmlsignal Scatter3DSeries::splineResolutionChanged(int resolution)

    This signal is emitted when splineResolution changes to \a resolution.
*/

/*!
 * Constructs a spline 3D series with the parent \a parent.
 */
QSpline3DSeries ::QSpline3DSeries(QObject *parent)
    : QScatter3DSeries(*(new QSpline3DSeriesPrivate()), parent)
{
    Q_D(QScatter3DSeries);
    // Default proxy
    d->setDataProxy(new QScatterDataProxy);
}

/*!
 * Constructs a spline 3D series with the data proxy \a dataProxy and the
 * parent \a parent.
 */
QSpline3DSeries ::QSpline3DSeries(QScatterDataProxy *dataProxy, QObject *parent)
    : QScatter3DSeries(*(new QSpline3DSeriesPrivate()), parent)
{
    Q_D(QScatter3DSeries);
    // Default proxy
    d->setDataProxy(dataProxy);
}

/*!
 * \internal
 */
QSpline3DSeries ::QSpline3DSeries(QSpline3DSeriesPrivate &dd, QObject *parent)
    : QScatter3DSeries(dd, parent)
{}

/*!
 * Deletes the spline 3D series.
 */
QSpline3DSeries::~QSpline3DSeries() {}

/*!
 * \property QSpline3DSeries::splineVisible
 *
 * \brief Visibility of the spline.
 *
 * Visibility of the spline.
 * The default value is \c true.
 *
 */
void QSpline3DSeries::setSplineVisible(bool visible)
{
    Q_D(QSpline3DSeries);
    if (d->m_splineVisible == visible) {
        qCDebug(lcProperties3D) << __FUNCTION__
            << "value is already set to:" << visible;
        return;
    }
    d->m_splineVisible = visible;
    emit splineVisibilityChanged(visible);
}

bool QSpline3DSeries::isSplineVisible() const
{
    const Q_D(QSpline3DSeries);
    return d->m_splineVisible;
}

/*!
 * \property QSpline3DSeries::splineTension
 *
 * \brief The tension of the spline.
 *
 * The spline uses maximum curvature for segments at a value of \c 0.0
 * Segments are completely straight at a value of \c 1.0
 * Must be between \c 0.0 and \c 1.0
 * The default value is \c 0.0
 *
 */
void QSpline3DSeries::setSplineTension(qreal tension)
{
    Q_D(QSpline3DSeries);
    if (tension < 0.0f || tension > 1.0f) {
        qCWarning(lcProperties3D, "%s invalid tension. Valid range for tension is 0.0f...1.0f",
                  qUtf8Printable(QLatin1String(__FUNCTION__)));
        return;
    } else if (d->m_tension == tension) {
        qCDebug(lcProperties3D, "%s value is already set to: %f",
                qUtf8Printable(QLatin1String(__FUNCTION__)), tension);
        return;
    }
    d->m_tension = tension;
    emit splineTensionChanged(tension);
}

qreal QSpline3DSeries::splineTension() const
{
    const Q_D(QSpline3DSeries);
    return d->m_tension;
}

/*!
 * \property QSpline3DSeries::splineKnotting
 *
 * \brief The knot parametrization of the spline.
 *
 * This parameter can change the profile of the curve.
 * The spline is classified as a uniform Catmull-Rom spline at a value of \c 0.0,
 * a centripetal Catmull-Rom spline at a value of \c 0.5,
 * and a chordal Catmull-Rom spline at a value of \c 1.0.
 *
 * The value must be between \c 0.0 and \c 1.0.
 * The default value is \c 0.5.
 *
 */
void QSpline3DSeries::setSplineKnotting(qreal knotting)
{
    Q_D(QSpline3DSeries);
    if (knotting < 0.0f || knotting > 1.0f) {
        qCWarning(lcProperties3D, "%s invalid knotting. Valid range for knotting is 0.0f...1.0f",
                  qUtf8Printable(QLatin1String(__FUNCTION__)));
        return;
    } else if (d->m_knotting == knotting) {
        qCDebug(lcProperties3D, "%s value is already set to: %f",
                qUtf8Printable(QLatin1String(__FUNCTION__)), knotting);
        return;
    }
    d->m_knotting = knotting;
    emit splineKnottingChanged(knotting);
}

qreal QSpline3DSeries::splineKnotting() const
{
    const Q_D(QSpline3DSeries);
    return d->m_knotting;
}

/*!
 * \property QSpline3DSeries::splineLooping
 *
 * \brief Determines whether the spline loops.
 *
 * This adds a spline segment between the first and last points of the series
 * connecting the spline into a loop.
 *
 * The default value is \c false
 *
 */
void QSpline3DSeries::setSplineLooping(bool looping)
{
    Q_D(QSpline3DSeries);
    if (d->m_looping == looping) {
        qCDebug(lcProperties3D) << __FUNCTION__
            << "value is already set to:" << looping;
        return;
    }
    d->m_looping = looping;
    emit splineLoopingChanged(looping);
}

bool QSpline3DSeries::isSplineLooping() const
{
    const Q_D(QSpline3DSeries);
    return d->m_looping;
}

/*!
 * \property QSpline3DSeries::splineColor
 *
 * \brief The color of the spline.
 *
 */
void QSpline3DSeries::setSplineColor(QColor color)
{
    Q_D(QSpline3DSeries);
    if (d->m_splineColor == color) {
        qCDebug(lcProperties3D) << __FUNCTION__
            << "value is already set to:" << color;
        return;
    }
    d->m_splineColor = color;
    emit splineColorChanged(color);
}

QColor QSpline3DSeries::splineColor() const
{
    const Q_D(QSpline3DSeries);
    return d->m_splineColor;
}

/*!
 * \property QSpline3DSeries::splineResolution
 *
 * \brief The resolution of the segments spline.
 * 
 * The number of vertices per spline segment,
 * which is defined as the part between two points.
 * 
 * Must be a value above \c 2. 
 * The default value is \c 10.
 */

void QSpline3DSeries::setSplineResolution(int resolution)
{
    Q_D(QSpline3DSeries);
    if (resolution < 2) {
        qCWarning(lcProperties3D, "%s invalid resolution. The resolution must be 2 or above",
                  qUtf8Printable(QLatin1String(__FUNCTION__)));
        return;
    } else if (d->m_resolution == resolution) {
        qCDebug(lcProperties3D, "%s value is already set to: %d",
                qUtf8Printable(QLatin1String(__FUNCTION__)), resolution);
        return;
    }
    d->m_resolution = resolution;
    emit splineResolutionChanged(resolution);
}

int QSpline3DSeries::splineResolution() const
{
    const Q_D(QSpline3DSeries);
    return d->m_resolution;
}

// QSpline3DSeriesPrivate

QSpline3DSeriesPrivate::QSpline3DSeriesPrivate()
    : QScatter3DSeriesPrivate()
{}

QSpline3DSeriesPrivate::~QSpline3DSeriesPrivate() {}

QT_END_NAMESPACE