summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--dist/changes-5.10.022
-rw-r--r--examples/datavisualization/bars/graphmodifier.cpp2
-rw-r--r--examples/datavisualization/draggableaxes/data.cpp10
-rw-r--r--examples/datavisualization/itemmodel/main.cpp4
-rw-r--r--examples/datavisualization/qmloscilloscope/datasource.cpp3
-rw-r--r--examples/datavisualization/scatter/scatterdatamodifier.cpp10
-rw-r--r--src/datavisualization/data/qbar3dseries.cpp2
-rw-r--r--src/datavisualization/doc/qtdatavis3d.qdocconf3
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp2
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp72
-rw-r--r--src/datavisualizationqml2/abstractdeclarative_p.h18
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/cpptest/common/cpptestutil.h49
-rw-r--r--tests/auto/cpptest/common/cpptestutil.pri2
-rw-r--r--tests/auto/cpptest/cpptest.pro11
-rw-r--r--tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro1
-rw-r--r--tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp5
-rw-r--r--tests/auto/cpptest/q3dbars/q3dbars.pro2
-rw-r--r--tests/auto/cpptest/q3dbars/tst_bars.cpp4
-rw-r--r--tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro1
-rw-r--r--tests/auto/cpptest/q3dcustom-label/tst_custom.cpp4
-rw-r--r--tests/auto/cpptest/q3dscatter/q3dscatter.pro1
-rw-r--r--tests/auto/cpptest/q3dscatter/tst_scatter.cpp4
-rw-r--r--tests/auto/cpptest/q3dscene/q3dscene.pro1
-rw-r--r--tests/auto/cpptest/q3dscene/tst_scene.cpp5
-rw-r--r--tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro1
-rw-r--r--tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp5
-rw-r--r--tests/auto/cpptest/q3dsurface/q3dsurface.pro1
-rw-r--r--tests/auto/cpptest/q3dsurface/tst_surface.cpp4
-rw-r--r--tests/manual/barstest/chart.cpp34
-rw-r--r--tests/manual/directional/scatterdatamodifier.cpp13
-rw-r--r--tests/manual/galaxy/cumulativedistributor.cpp1
-rw-r--r--tests/manual/galaxy/galaxy.pro1
-rw-r--r--tests/manual/galaxy/galaxydata.cpp18
-rw-r--r--tests/manual/galaxy/star.cpp4
-rw-r--r--tests/manual/itemmodeltest/main.cpp5
-rw-r--r--tests/manual/qmlperf/datagenerator.cpp15
-rw-r--r--tests/manual/scattertest/scatterchart.cpp25
-rw-r--r--tests/manual/surfacetest/graphmodifier.cpp41
40 files changed, 249 insertions, 161 deletions
diff --git a/.qmake.conf b/.qmake.conf
index e83ee5d4..c969459a 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,5 +1,5 @@
load(qt_build_config)
-MODULE_VERSION = 5.9.4
+MODULE_VERSION = 5.10.1
CONFIG += warning_clean
CMAKE_MODULE_TESTS=-
diff --git a/dist/changes-5.10.0 b/dist/changes-5.10.0
new file mode 100644
index 00000000..6847eb8d
--- /dev/null
+++ b/dist/changes-5.10.0
@@ -0,0 +1,22 @@
+Qt 5.10 introduces many new features and improvements as well as bugfixes
+over the 5.9.x series. For more details, refer to the online documentation
+included in this distribution. The documentation is also available online:
+
+http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.10 series is binary compatible with the 5.10.x series.
+Applications compiled for 5.9 will continue to run with 5.10.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Qt 5.10.0 Changes *
+****************************************************************************
+
+ - This release contains only minor code improvements.
diff --git a/examples/datavisualization/bars/graphmodifier.cpp b/examples/datavisualization/bars/graphmodifier.cpp
index 8ef1c536..a130b0ff 100644
--- a/examples/datavisualization/bars/graphmodifier.cpp
+++ b/examples/datavisualization/bars/graphmodifier.cpp
@@ -353,7 +353,7 @@ void GraphModifier::zoomToSelectedBar()
// Rotate the camera so that it always points approximately to the graph center
//! [15]
- qreal endAngleX = qAtan(qreal(endTarget.z() / endTarget.x())) / M_PI * -180.0 + 90.0;
+ qreal endAngleX = 90.0 - qRadiansToDegrees(qAtan(qreal(endTarget.z() / endTarget.x())));
if (endTarget.x() > 0.0f)
endAngleX -= 180.0f;
float barValue = m_graph->selectedSeries()->dataProxy()->itemAt(selectedBar.x(),
diff --git a/examples/datavisualization/draggableaxes/data.cpp b/examples/datavisualization/draggableaxes/data.cpp
index c2907c4d..f7f4a31e 100644
--- a/examples/datavisualization/draggableaxes/data.cpp
+++ b/examples/datavisualization/draggableaxes/data.cpp
@@ -29,6 +29,7 @@
#include "data.h"
+#include <QtCore/QRandomGenerator>
#include <QtDataVisualization/QScatterDataProxy>
#include <QtDataVisualization/Q3DScene>
#include <QtDataVisualization/Q3DCamera>
@@ -165,7 +166,10 @@ void Data::addData()
QVector3D Data::randVector()
{
return QVector3D(
- (float)(rand() % 100) / 2.0f - (float)(rand() % 100) / 2.0f,
- (float)(rand() % 100) / 2.0f - (float)(rand() % 100) / 2.0f,
- (float)(rand() % 100) / 2.0f - (float)(rand() % 100) / 2.0f);
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f -
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f,
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f -
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f,
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f -
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f);
}
diff --git a/examples/datavisualization/itemmodel/main.cpp b/examples/datavisualization/itemmodel/main.cpp
index f2197785..782d9dd2 100644
--- a/examples/datavisualization/itemmodel/main.cpp
+++ b/examples/datavisualization/itemmodel/main.cpp
@@ -40,6 +40,7 @@
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QTableWidget>
#include <QtGui/QScreen>
+#include <QtCore/QRandomGenerator>
#include <QtCore/QTimer>
#include <QtGui/QFont>
#include <QtCore/QDebug>
@@ -216,7 +217,8 @@ void GraphDataGenerator::addRow()
for (int i = 0; i < m_columnCount; i++) {
QModelIndex index = m_tableWidget->model()->index(0, i);
m_tableWidget->model()->setData(index,
- ((float)i / (float)m_columnCount) / 2.0f + (float)(rand() % 30) / 100.0f);
+ ((float)i / (float)m_columnCount) / 2.0f +
+ (float)(QRandomGenerator::global()->bounded(30)) / 100.0f);
}
m_tableWidget->resizeColumnsToContents();
}
diff --git a/examples/datavisualization/qmloscilloscope/datasource.cpp b/examples/datavisualization/qmloscilloscope/datasource.cpp
index 58e72d99..19580e03 100644
--- a/examples/datavisualization/qmloscilloscope/datasource.cpp
+++ b/examples/datavisualization/qmloscilloscope/datasource.cpp
@@ -29,6 +29,7 @@
#include "datasource.h"
#include <QtCore/qmath.h>
+#include <QtCore/qrandom.h>
using namespace QtDataVisualization;
@@ -95,7 +96,7 @@ void DataSource::generateData(int cacheCount, int rowCount, int columnCount,
float colWave = float(qSin((2.0 * M_PI * colMod) - (1.0 / 2.0 * M_PI)) + 1.0);
float y = (colWave * ((float(qSin(rowColWaveAngleMul * colMod) + 1.0))))
* rowColWaveMul
- + (0.15f * float(qrand()) / float(RAND_MAX)) * yRangeMod;
+ + QRandomGenerator::global()->bounded(0.15f) * yRangeMod;
int index = k + cacheIndexAdjustment;
if (index >= columnCount) {
diff --git a/examples/datavisualization/scatter/scatterdatamodifier.cpp b/examples/datavisualization/scatter/scatterdatamodifier.cpp
index efb859a9..504645da 100644
--- a/examples/datavisualization/scatter/scatterdatamodifier.cpp
+++ b/examples/datavisualization/scatter/scatterdatamodifier.cpp
@@ -35,6 +35,7 @@
#include <QtDataVisualization/qscatter3dseries.h>
#include <QtDataVisualization/q3dtheme.h>
#include <QtCore/qmath.h>
+#include <QtCore/qrandom.h>
#include <QtWidgets/QComboBox>
using namespace QtDataVisualization;
@@ -208,7 +209,10 @@ void ScatterDataModifier::toggleItemCount()
QVector3D ScatterDataModifier::randVector()
{
return QVector3D(
- (float)(rand() % 100) / 2.0f - (float)(rand() % 100) / 2.0f,
- (float)(rand() % 100) / 100.0f - (float)(rand() % 100) / 100.0f,
- (float)(rand() % 100) / 2.0f - (float)(rand() % 100) / 2.0f);
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f -
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f,
+ (float)(QRandomGenerator::global()->bounded(100)) / 100.0f -
+ (float)(QRandomGenerator::global()->bounded(100)) / 100.0f,
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f -
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f);
}
diff --git a/src/datavisualization/data/qbar3dseries.cpp b/src/datavisualization/data/qbar3dseries.cpp
index c338b859..e2be7cc9 100644
--- a/src/datavisualization/data/qbar3dseries.cpp
+++ b/src/datavisualization/data/qbar3dseries.cpp
@@ -246,7 +246,7 @@ QPoint QBar3DSeries::invalidSelectionPosition()
static inline float quaternionAngle(const QQuaternion &rotation)
{
- return qAcos(rotation.scalar()) * 360.0f / M_PI;
+ return qRadiansToDegrees(qAcos(rotation.scalar())) * 2.f;
}
/*!
diff --git a/src/datavisualization/doc/qtdatavis3d.qdocconf b/src/datavisualization/doc/qtdatavis3d.qdocconf
index 63aa334d..71eb43ec 100644
--- a/src/datavisualization/doc/qtdatavis3d.qdocconf
+++ b/src/datavisualization/doc/qtdatavis3d.qdocconf
@@ -49,4 +49,5 @@ navigation.landingpage = Qt Data Visualization
navigation.cppclassespage = Qt Data Visualization C++ Classes
navigation.qmltypespage = Qt Data Visualization QML Types
-manifestmeta.highlighted.names += "QtDataVisualization/Bars Example"
+manifestmeta.highlighted.names = "QtDataVisualization/Bars Example" \
+ "QtDataVisualization/Qt Quick 2 Surface Multiseries Example"
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 9fa1eeb8..cad9b97c 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -1154,7 +1154,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
// Need to determine if camera is below graph top
float distanceToCenter = activeCamera->position().length()
/ activeCamera->zoomLevel() / m_autoScaleAdjustment * 100.0f;
- qreal cameraAngle = qreal(activeCamera->yRotation()) / 180.0 * M_PI;
+ qreal cameraAngle = qDegreesToRadians(qreal(activeCamera->yRotation()));
float cameraYPos = float(qSin(cameraAngle)) * distanceToCenter;
m_yFlippedForGrid = cameraYPos < (m_scaleYWithBackground - m_oldCameraTarget.y());
} else if (m_useOrthoProjection && activeCamera->yRotation() == 0.0f) {
diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp
index a35970a7..03d1f41d 100644
--- a/src/datavisualizationqml2/abstractdeclarative.cpp
+++ b/src/datavisualizationqml2/abstractdeclarative.cpp
@@ -38,6 +38,12 @@
#include <qpa/qplatformnativeinterface.h>
#endif
+#if !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID) && !defined(Q_OS_WINRT)
+#define USE_SHARED_CONTEXT
+#else
+#include "glstatestore_p.h"
+#endif
+
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
static QList<const QQuickWindow *> clearList;
@@ -52,11 +58,7 @@ AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) :
m_samples(0),
m_windowSamples(0),
m_initialisedSize(0, 0),
- #ifdef USE_SHARED_CONTEXT
- m_context(0),
- #else
- m_stateStore(0),
- #endif
+ m_contextOrStateStore(0),
m_qtContext(0),
m_mainThread(QThread::currentThread()),
m_contextThread(0)
@@ -352,60 +354,44 @@ void AbstractDeclarative::setSharedController(Abstract3DController *controller)
void AbstractDeclarative::activateOpenGLContext(QQuickWindow *window)
{
-#ifdef USE_SHARED_CONTEXT
// We can assume we are not in middle of AbstractDeclarative destructor when we are here,
// since m_context creation is always done when this function is called from
// synchDataToRenderer(), which blocks main thread -> no need to mutex.
- if (!m_context || !m_qtContext || m_contextWindow != window) {
+ if (!m_contextOrStateStore || !m_qtContext || m_contextWindow != window) {
QOpenGLContext *currentContext = QOpenGLContext::currentContext();
// Note: Changing graph to different window when using multithreaded renderer will break!
- delete m_context;
+ delete m_contextOrStateStore;
m_contextThread = QThread::currentThread();
m_contextWindow = window;
m_qtContext = currentContext;
+
+#ifdef USE_SHARED_CONTEXT
m_context = new QOpenGLContext();
m_context->setFormat(m_qtContext->format());
m_context->setShareContext(m_qtContext);
m_context->create();
-
m_context->makeCurrent(window);
- m_controller->initializeOpenGL();
-
- // Make sure context gets deleted.
- QObject::connect(m_contextThread, &QThread::finished, this,
- &AbstractDeclarative::destroyContext, Qt::DirectConnection);
- } else {
- m_context->makeCurrent(window);
- }
#else
- // Shared contexts don't work properly in some platforms, so just store the
- // context state on those
- if (!m_stateStore || !m_qtContext || m_contextWindow != window) {
- QOpenGLContext *currentContext = QOpenGLContext::currentContext();
-
- // Note: Changing graph to different window when using multithreaded renderer will break!
-
- delete m_stateStore;
-
- m_contextThread = QThread::currentThread();
- m_contextWindow = window;
- m_qtContext = currentContext;
-
+ // Shared contexts don't work properly in some platforms, so just store the
+ // context state on those
m_stateStore = new GLStateStore(QOpenGLContext::currentContext());
-
m_stateStore->storeGLState();
+#endif
m_controller->initializeOpenGL();
- // Make sure state store gets deleted.
+ // Make sure context / state store gets deleted.
QObject::connect(m_contextThread, &QThread::finished, this,
&AbstractDeclarative::destroyContext, Qt::DirectConnection);
} else {
+#ifdef USE_SHARED_CONTEXT
+ m_context->makeCurrent(window);
+#else
m_stateStore->storeGLState();
- }
#endif
+ }
}
void AbstractDeclarative::doneOpenGLContext(QQuickWindow *window)
@@ -854,24 +840,14 @@ void AbstractDeclarative::windowDestroyed(QObject *obj)
void AbstractDeclarative::destroyContext()
{
-#ifdef USE_SHARED_CONTEXT
- // Context can be in another thread, don't delete it directly in that case
if (m_contextThread && m_contextThread != m_mainThread) {
- if (m_context)
- m_context->deleteLater();
+ if (m_contextOrStateStore)
+ m_contextOrStateStore->deleteLater();
} else {
- delete m_context;
+ delete m_contextOrStateStore;
}
- m_context = 0;
-#else
- if (m_contextThread && m_contextThread != m_mainThread) {
- if (m_stateStore)
- m_stateStore->deleteLater();
- } else {
- delete m_stateStore;
- }
- m_stateStore = 0;
-#endif
+ m_contextOrStateStore = 0;
+
if (m_contextThread) {
QObject::disconnect(m_contextThread, &QThread::finished, this,
&AbstractDeclarative::destroyContext);
diff --git a/src/datavisualizationqml2/abstractdeclarative_p.h b/src/datavisualizationqml2/abstractdeclarative_p.h
index f49da398..18cca6e2 100644
--- a/src/datavisualizationqml2/abstractdeclarative_p.h
+++ b/src/datavisualizationqml2/abstractdeclarative_p.h
@@ -50,13 +50,7 @@
#include <QtCore/QMutex>
#include <QtCore/QSharedPointer>
-#if !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID) && !defined(Q_OS_WINRT)
-#define USE_SHARED_CONTEXT
-#endif
-
-#ifndef USE_SHARED_CONTEXT
-#include "glstatestore_p.h"
-#endif
+class GLStateStore;
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -297,11 +291,11 @@ private:
int m_samples;
int m_windowSamples;
QSize m_initialisedSize;
-#ifdef USE_SHARED_CONTEXT
- QOpenGLContext *m_context;
-#else
- GLStateStore *m_stateStore;
-#endif
+ union {
+ QObject *m_contextOrStateStore;
+ QOpenGLContext *m_context;
+ GLStateStore *m_stateStore;
+ };
QPointer<QOpenGLContext> m_qtContext;
QThread *m_mainThread;
QThread *m_contextThread;
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index ec2dc3ba..38f40591 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -6,5 +6,5 @@ qtHaveModule(quick): SUBDIRS += qmltest
installed_cmake.depends = cmake
-# QTBUG-60268
+# OpenGL support is needed for all qmltests but it's not available on boot2qt
boot2qt: SUBDIRS -= qmltest
diff --git a/tests/auto/cpptest/common/cpptestutil.h b/tests/auto/cpptest/common/cpptestutil.h
new file mode 100644
index 00000000..986ba8b9
--- /dev/null
+++ b/tests/auto/cpptest/common/cpptestutil.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Data Visualization module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CPPTESTUTIL_H
+#define CPPTESTUTIL_H
+
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace CpptestUtil {
+
+static bool isOpenGLSupported()
+{
+ return QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL);
+}
+
+} // CpptestUtil namespace
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/tests/auto/cpptest/common/cpptestutil.pri b/tests/auto/cpptest/common/cpptestutil.pri
new file mode 100644
index 00000000..0bac2856
--- /dev/null
+++ b/tests/auto/cpptest/common/cpptestutil.pri
@@ -0,0 +1,2 @@
+QT += gui-private
+INCLUDEPATH += $$PWD/
diff --git a/tests/auto/cpptest/cpptest.pro b/tests/auto/cpptest/cpptest.pro
index ac91d813..abd8f38e 100644
--- a/tests/auto/cpptest/cpptest.pro
+++ b/tests/auto/cpptest/cpptest.pro
@@ -24,14 +24,3 @@ SUBDIRS = q3dbars \
q3dcustom \
q3dcustom-label \
q3dcustom-volume
-
-# QTBUG-60268
-boot2qt {
- SUBDIRS -= q3dbars \
- q3dcustom-label \
- q3dsurface-modelproxy \
- q3dbars-modelproxy \
- q3dscene \
- q3dscatter \
- q3dsurface
-}
diff --git a/tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro b/tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro
index c383ec25..ad1fe0cc 100644
--- a/tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro
+++ b/tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro
@@ -1,3 +1,4 @@
+include(../common/cpptestutil.pri)
QT += testlib datavisualization widgets
TARGET = tst_cpptest
diff --git a/tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp b/tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp
index 2de9380d..dfeee506 100644
--- a/tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp
+++ b/tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp
@@ -33,6 +33,8 @@
#include <QtDataVisualization/Q3DBars>
#include <QtWidgets/QTableWidget>
+#include "cpptestutil.h"
+
using namespace QtDataVisualization;
class tst_proxy: public QObject
@@ -220,6 +222,9 @@ void tst_proxy::initializeProperties()
void tst_proxy::multiMatch()
{
+ if (!CpptestUtil::isOpenGLSupported())
+ QSKIP("OpenGL not supported on this platform");
+
Q3DBars graph;
QTableWidget table;
diff --git a/tests/auto/cpptest/q3dbars/q3dbars.pro b/tests/auto/cpptest/q3dbars/q3dbars.pro
index a7f7c809..bba500fa 100644
--- a/tests/auto/cpptest/q3dbars/q3dbars.pro
+++ b/tests/auto/cpptest/q3dbars/q3dbars.pro
@@ -1,3 +1,5 @@
+include(../common/cpptestutil.pri)
+
QT += testlib datavisualization
TARGET = tst_cpptest
diff --git a/tests/auto/cpptest/q3dbars/tst_bars.cpp b/tests/auto/cpptest/q3dbars/tst_bars.cpp
index 952682b9..0d128c36 100644
--- a/tests/auto/cpptest/q3dbars/tst_bars.cpp
+++ b/tests/auto/cpptest/q3dbars/tst_bars.cpp
@@ -34,6 +34,8 @@
#include <QtDataVisualization/Q3DInputHandler>
#include <QtDataVisualization/QTouch3DInputHandler>
+#include "cpptestutil.h"
+
using namespace QtDataVisualization;
class tst_bars: public QObject
@@ -85,6 +87,8 @@ QBar3DSeries *newSeries()
void tst_bars::initTestCase()
{
+ if (!CpptestUtil::isOpenGLSupported())
+ QSKIP("OpenGL not supported on this platform");
}
void tst_bars::cleanupTestCase()
diff --git a/tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro b/tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro
index af584baa..c47e018a 100644
--- a/tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro
+++ b/tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro
@@ -1,3 +1,4 @@
+include(../common/cpptestutil.pri)
QT += testlib datavisualization
TARGET = tst_cpptest
diff --git a/tests/auto/cpptest/q3dcustom-label/tst_custom.cpp b/tests/auto/cpptest/q3dcustom-label/tst_custom.cpp
index 1c45c908..44c9d2b2 100644
--- a/tests/auto/cpptest/q3dcustom-label/tst_custom.cpp
+++ b/tests/auto/cpptest/q3dcustom-label/tst_custom.cpp
@@ -31,6 +31,8 @@
#include <QtDataVisualization/QCustom3DLabel>
+#include "cpptestutil.h"
+
using namespace QtDataVisualization;
class tst_custom: public QObject
@@ -55,6 +57,8 @@ private:
void tst_custom::initTestCase()
{
+ if (!CpptestUtil::isOpenGLSupported())
+ QSKIP("OpenGL not supported on this platform");
}
void tst_custom::cleanupTestCase()
diff --git a/tests/auto/cpptest/q3dscatter/q3dscatter.pro b/tests/auto/cpptest/q3dscatter/q3dscatter.pro
index 9f356ebc..6c94fe64 100644
--- a/tests/auto/cpptest/q3dscatter/q3dscatter.pro
+++ b/tests/auto/cpptest/q3dscatter/q3dscatter.pro
@@ -1,3 +1,4 @@
+include(../common/cpptestutil.pri)
QT += testlib datavisualization
TARGET = tst_cpptest
diff --git a/tests/auto/cpptest/q3dscatter/tst_scatter.cpp b/tests/auto/cpptest/q3dscatter/tst_scatter.cpp
index 016985ea..64561340 100644
--- a/tests/auto/cpptest/q3dscatter/tst_scatter.cpp
+++ b/tests/auto/cpptest/q3dscatter/tst_scatter.cpp
@@ -31,6 +31,8 @@
#include <QtDataVisualization/Q3DScatter>
+#include "cpptestutil.h"
+
using namespace QtDataVisualization;
class tst_scatter: public QObject
@@ -70,6 +72,8 @@ QScatter3DSeries *newSeries()
void tst_scatter::initTestCase()
{
+ if (!CpptestUtil::isOpenGLSupported())
+ QSKIP("OpenGL not supported on this platform");
}
void tst_scatter::cleanupTestCase()
diff --git a/tests/auto/cpptest/q3dscene/q3dscene.pro b/tests/auto/cpptest/q3dscene/q3dscene.pro
index b9be69c0..b7a0110c 100644
--- a/tests/auto/cpptest/q3dscene/q3dscene.pro
+++ b/tests/auto/cpptest/q3dscene/q3dscene.pro
@@ -1,3 +1,4 @@
+include(../common/cpptestutil.pri)
QT += testlib datavisualization
TARGET = tst_cpptest
diff --git a/tests/auto/cpptest/q3dscene/tst_scene.cpp b/tests/auto/cpptest/q3dscene/tst_scene.cpp
index 1336f400..2b450f64 100644
--- a/tests/auto/cpptest/q3dscene/tst_scene.cpp
+++ b/tests/auto/cpptest/q3dscene/tst_scene.cpp
@@ -32,6 +32,8 @@
#include <QtDataVisualization/Q3DScene>
#include <QtDataVisualization/Q3DBars>
+#include "cpptestutil.h"
+
using namespace QtDataVisualization;
class tst_scene: public QObject
@@ -142,6 +144,9 @@ void tst_scene::invalidProperties()
void tst_scene::subViews()
{
+ if (!CpptestUtil::isOpenGLSupported())
+ QSKIP("OpenGL not supported on this platform");
+
Q3DBars graph;
graph.setPosition(QPoint(0, 0));
graph.setWidth(200);
diff --git a/tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro b/tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro
index c383ec25..ad1fe0cc 100644
--- a/tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro
+++ b/tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro
@@ -1,3 +1,4 @@
+include(../common/cpptestutil.pri)
QT += testlib datavisualization widgets
TARGET = tst_cpptest
diff --git a/tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp b/tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp
index 9bea4ae0..eb984c1a 100644
--- a/tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp
+++ b/tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp
@@ -33,6 +33,8 @@
#include <QtDataVisualization/Q3DSurface>
#include <QtWidgets/QTableWidget>
+#include "cpptestutil.h"
+
using namespace QtDataVisualization;
class tst_proxy: public QObject
@@ -234,6 +236,9 @@ void tst_proxy::initializeProperties()
void tst_proxy::multiMatch()
{
+ if (!CpptestUtil::isOpenGLSupported())
+ QSKIP("OpenGL not supported on this platform");
+
Q3DSurface graph;
QTableWidget table;
diff --git a/tests/auto/cpptest/q3dsurface/q3dsurface.pro b/tests/auto/cpptest/q3dsurface/q3dsurface.pro
index b7a6bf08..9ed3c7f5 100644
--- a/tests/auto/cpptest/q3dsurface/q3dsurface.pro
+++ b/tests/auto/cpptest/q3dsurface/q3dsurface.pro
@@ -1,3 +1,4 @@
+include(../common/cpptestutil.pri)
QT += testlib datavisualization
TARGET = tst_cpptest
diff --git a/tests/auto/cpptest/q3dsurface/tst_surface.cpp b/tests/auto/cpptest/q3dsurface/tst_surface.cpp
index 676f785e..04fe5d21 100644
--- a/tests/auto/cpptest/q3dsurface/tst_surface.cpp
+++ b/tests/auto/cpptest/q3dsurface/tst_surface.cpp
@@ -31,6 +31,8 @@
#include <QtDataVisualization/Q3DSurface>
+#include "cpptestutil.h"
+
using namespace QtDataVisualization;
class tst_surface: public QObject
@@ -75,6 +77,8 @@ QSurface3DSeries *newSeries()
void tst_surface::initTestCase()
{
+ if (!CpptestUtil::isOpenGLSupported())
+ QSKIP("OpenGL not supported on this platform");
}
void tst_surface::cleanupTestCase()
diff --git a/tests/manual/barstest/chart.cpp b/tests/manual/barstest/chart.cpp
index 4aee80cf..528b32a5 100644
--- a/tests/manual/barstest/chart.cpp
+++ b/tests/manual/barstest/chart.cpp
@@ -38,6 +38,7 @@
#include <QtDataVisualization/q3dtheme.h>
#include <QtDataVisualization/q3dinputhandler.h>
#include <QtDataVisualization/qcustom3ditem.h>
+#include <QtCore/QRandomGenerator>
#include <QtCore/QTime>
#include <QtCore/qmath.h>
@@ -378,10 +379,11 @@ void GraphModifier::createMassiveArray()
QBarDataRow *dataRow = new QBarDataRow(arrayDimension);
for (int j = 0; j < arrayDimension; j++) {
if (!m_negativeValuesOn)
- (*dataRow)[j].setValue((float(i % 300 + 1) / 300.0) * float(rand() % int(m_maxval)));
+ (*dataRow)[j].setValue((float(i % 300 + 1) / 300.0)
+ * QRandomGenerator::global()->bounded(m_maxval));
else
- (*dataRow)[j].setValue((float(i % 300 + 1) / 300.0) * float(rand() % int(m_maxval))
- + m_minval);
+ (*dataRow)[j].setValue((float(i % 300 + 1) / 300.0)
+ * QRandomGenerator::global()->bounded(m_maxval) + m_minval);
}
dataArray->append(dataRow);
}
@@ -449,10 +451,12 @@ void GraphModifier::addRow()
QBarDataRow *dataRow = new QBarDataRow(m_columnCount);
for (float i = 0; i < m_columnCount; i++) {
if (!m_negativeValuesOn)
- (*dataRow)[i].setValue(((i + 1) / (float)m_columnCount) * (float)(rand() % int(m_maxval)));
+ (*dataRow)[i].setValue(((i + 1) / (float)m_columnCount)
+ * QRandomGenerator::global()->bounded(m_maxval));
else
- (*dataRow)[i].setValue(((i + 1) / (float)m_columnCount) * (float)(rand() % int(m_maxval))
- - (float)(rand() % int(m_minval)));
+ (*dataRow)[i].setValue(((i + 1) / (float)m_columnCount)
+ * QRandomGenerator::global()->bounded(m_maxval)
+ - QRandomGenerator::global()->bounded(m_minval));
}
// TODO Needs to be changed to account for data window offset once it is implemented.
@@ -480,8 +484,8 @@ void GraphModifier::insertRow()
{
QBarDataRow *dataRow = new QBarDataRow(m_columnCount);
for (float i = 0; i < m_columnCount; i++)
- (*dataRow)[i].setValue(((i + 1) / (float)m_columnCount) * (float)(rand() % int(m_maxval))
- + m_minval);
+ (*dataRow)[i].setValue(((i + 1) / (float)m_columnCount)
+ * QRandomGenerator::global()->bounded(m_maxval) + m_minval);
// TODO Needs to be changed to account for data window offset once it is implemented.
int row = qMax(m_selectedBar.x(), 0);
@@ -515,7 +519,7 @@ void GraphModifier::changeItem()
int row = m_selectedBar.x();
int column = m_selectedBar.y();
if (row >= 0 && column >= 0) {
- QBarDataItem item(float(rand() % 100));
+ QBarDataItem item(float(QRandomGenerator::global()->bounded(100)));
m_genericData->dataProxy()->setItem(row, column, item);
}
}
@@ -527,7 +531,7 @@ void GraphModifier::changeRow()
if (row >= 0) {
QBarDataRow *newRow = new QBarDataRow(m_genericData->dataProxy()->rowAt(row)->size());
for (int i = 0; i < newRow->size(); i++)
- (*newRow)[i].setValue(float(rand() % int(m_maxval)) + m_minval);
+ (*newRow)[i].setValue(QRandomGenerator::global()->bounded(m_maxval) + m_minval);
QString label = QStringLiteral("Change %1").arg(changeCounter++);
m_genericData->dataProxy()->setRow(row, newRow, label);
}
@@ -544,7 +548,7 @@ void GraphModifier::changeRows()
for (int i = startRow; i <= row; i++ ) {
QBarDataRow *newRow = new QBarDataRow(m_genericData->dataProxy()->rowAt(i)->size());
for (int j = 0; j < newRow->size(); j++)
- (*newRow)[j].setValue(float(rand() % int(m_maxval)) + m_minval);
+ (*newRow)[j].setValue(QRandomGenerator::global()->bounded(m_maxval) + m_minval);
newArray.append(newRow);
labels.append(QStringLiteral("Change %1").arg(changeCounter++));
}
@@ -1453,7 +1457,7 @@ void GraphModifier::insertRemoveTimerTimeout()
for (int k = 0; k < 1; k++) {
QBarDataRow *dataRow = new QBarDataRow(10);
for (float i = 0; i < 10; i++)
- (*dataRow)[i].setValue(((i + 1) / 10.0f) * (float)(rand() % 100));
+ (*dataRow)[i].setValue(((i + 1) / 10.0f) * (float)(QRandomGenerator::global()->bounded(100)));
QString label = QStringLiteral("Insert %1").arg(insertCounter++);
m_dummyData->dataProxy()->insertRow(0, dataRow, label);
@@ -1467,7 +1471,7 @@ void GraphModifier::insertRemoveTimerTimeout()
for (int k = 0; k < 2; k++) {
QBarDataRow *dataRow = new QBarDataRow(10);
for (float i = 0; i < 10; i++)
- (*dataRow)[i].setValue(((i + 1) / 10.0f) * (float)(rand() % 100));
+ (*dataRow)[i].setValue(((i + 1) / 10.0f) * (float)(QRandomGenerator::global()->bounded(100)));
QString label = QStringLiteral("Insert %1").arg(insertCounter++);
m_dummyData2->dataProxy()->insertRow(0, dataRow, label);
@@ -1770,7 +1774,7 @@ void GraphModifier::toggleCustomItem()
item->setMeshFile(":/shuttle.obj");
item->setPosition(positionOne);
item->setScaling(QVector3D(0.1f, 0.1f, 0.1f));
- item->setRotation(QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, rand()));
+ item->setRotation(QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, QRandomGenerator::global()->generate()));
item->setTextureImage(QImage(":/shuttle.png"));
m_graph->addCustomItem(item);
} else {
@@ -1779,7 +1783,7 @@ void GraphModifier::toggleCustomItem()
item->setMeshFile(":/shuttle.obj");
item->setPosition(positionTwo);
item->setScaling(QVector3D(0.1f, 0.1f, 0.1f));
- item->setRotation(QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, rand()));
+ item->setRotation(QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, QRandomGenerator::global()->generate()));
item->setTextureImage(QImage(":/shuttle.png"));
m_graph->addCustomItem(item);
}
diff --git a/tests/manual/directional/scatterdatamodifier.cpp b/tests/manual/directional/scatterdatamodifier.cpp
index a11278fa..2a98625d 100644
--- a/tests/manual/directional/scatterdatamodifier.cpp
+++ b/tests/manual/directional/scatterdatamodifier.cpp
@@ -42,7 +42,6 @@ using namespace QtDataVisualization;
const int numberOfCols = 8;
const int numberOfRows = 8;
const float limit = 8.0f;
-const float PI = 3.14159f;
#define HEDGEHOG
ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter)
@@ -97,18 +96,18 @@ void ScatterDataModifier::addData()
for (float i = 0; i < numberOfRows; i++) {
float latAngle = float(i) * latAngleStep + 40.0f;
- float radius = qSin(latAngle * PI / 180.0f) * limit;
- float y = qCos(latAngle * PI / 180.0f) * 1.0f;
+ float radius = qSin(qDegreesToRadians(latAngle)) * limit;
+ float y = qCos(qDegreesToRadians(latAngle)) * 1.0f;
#ifdef HEDGEHOG
- float angleZ = (qAtan((y * limit / 2.0f) / radius) * 180.0f / PI);
+ float angleZ = qRadiansToDegrees(qAtan((y * limit / 2.0f) / radius));
QQuaternion rotationZ = QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 0.0f, 1.0f), angleZ - 90.0f);
#endif
for (float j = 0; j < numberOfCols; j++) {
float angle = float(j) * angleStep;
- float x = qCos(angle * PI / 180.0f) * radius;
- float z = qSin(angle * PI / 180.0f) * radius;
+ float x = qCos(qDegreesToRadians(angle)) * radius;
+ float z = qSin(qDegreesToRadians(angle)) * radius;
- float angleY = (qAtan(z / x) * 180.0f / PI);
+ float angleY = qRadiansToDegrees(qAtan(z / x));
if (x < 0)
angleY = 180.0f + angleY;
if (x > 0 && z < 0)
diff --git a/tests/manual/galaxy/cumulativedistributor.cpp b/tests/manual/galaxy/cumulativedistributor.cpp
index b5d6f8c6..4506480c 100644
--- a/tests/manual/galaxy/cumulativedistributor.cpp
+++ b/tests/manual/galaxy/cumulativedistributor.cpp
@@ -37,6 +37,7 @@
#include "cumulativedistributor.h"
#include <QDebug>
+#include <math.h>
CumulativeDistributor::CumulativeDistributor()
: m_pDistFun(NULL),
diff --git a/tests/manual/galaxy/galaxy.pro b/tests/manual/galaxy/galaxy.pro
index 0b602e16..5c35b862 100644
--- a/tests/manual/galaxy/galaxy.pro
+++ b/tests/manual/galaxy/galaxy.pro
@@ -17,6 +17,7 @@ HEADERS += \
star.h
QT += widgets
+CONFIG += exceptions
OTHER_FILES += doc/src/* \
doc/images/*
diff --git a/tests/manual/galaxy/galaxydata.cpp b/tests/manual/galaxy/galaxydata.cpp
index 8a409132..c49e07fd 100644
--- a/tests/manual/galaxy/galaxydata.cpp
+++ b/tests/manual/galaxy/galaxydata.cpp
@@ -44,6 +44,7 @@
#include <QtDataVisualization/qscatter3dseries.h>
#include <QtDataVisualization/q3dtheme.h>
#include <QtCore/qmath.h>
+#include <QtCore/qrandom.h>
#include <QPainter>
#include <QDebug>
@@ -53,7 +54,6 @@ using namespace QtDataVisualization;
static const int numOfStars = 70000;
static const int numOfDust = numOfStars / 2;
static const int numOfH2 = 200;
-static const qreal rand_max = qreal(RAND_MAX);
GalaxyData::GalaxyData(Q3DScatter *scatter,
qreal rad,
@@ -163,12 +163,12 @@ void GalaxyData::createGalaxy()
1000.0); // Anzahl der st├╝tzstellen
for (int i = 3; i < numOfStars; ++i) {
- qreal rad = cd.valFromProp(qreal(qrand()) / rand_max);
+ qreal rad = cd.valFromProp(QRandomGenerator::global()->generateDouble());
m_pStars[i].m_a = rad;
m_pStars[i].m_b = rad * getExcentricity(rad);
m_pStars[i].m_angle = getAngularOffset(rad);
- m_pStars[i].m_theta = 360.0 * ((double)rand() / RAND_MAX);
+ m_pStars[i].m_theta = 360.0 * QRandomGenerator::global()->generateDouble();
m_pStars[i].m_center = QVector2D(0.0f, 0.0f);
m_pStars[i].calcXY();
@@ -179,14 +179,14 @@ void GalaxyData::createGalaxy()
qreal x, y, rad;
for (int i = 0; i < numOfDust; ++i)
{
- x = 2.0 * m_radGalaxy * ((double)rand() / RAND_MAX) - m_radGalaxy;
- y = 2.0 * m_radGalaxy * ((double)rand() / RAND_MAX) - m_radGalaxy;
+ x = 2.0 * m_radGalaxy * QRandomGenerator::global()->generateDouble() - m_radGalaxy;
+ y = 2.0 * m_radGalaxy * QRandomGenerator::global()->generateDouble() - m_radGalaxy;
rad = sqrt(x*x + y*y);
m_pDust[i].m_a = rad;
m_pDust[i].m_b = rad * getExcentricity(rad);
m_pDust[i].m_angle = getAngularOffset(rad);
- m_pDust[i].m_theta = 360.0 * ((double)rand() / RAND_MAX);
+ m_pDust[i].m_theta = 360.0 * QRandomGenerator::global()->generateDouble();
m_pDust[i].m_center = QVector2D(0.0f, 0.0f);
m_pDust[i].calcXY();
@@ -196,15 +196,15 @@ void GalaxyData::createGalaxy()
// Initialize H2
for (int i = 0; i < numOfH2; ++i)
{
- x = 2*(m_radGalaxy) * ((double)rand() / RAND_MAX) - (m_radGalaxy);
- y = 2*(m_radGalaxy) * ((double)rand() / RAND_MAX) - (m_radGalaxy);
+ x = 2*(m_radGalaxy) * QRandomGenerator::global()->generateDouble() - (m_radGalaxy);
+ y = 2*(m_radGalaxy) * QRandomGenerator::global()->generateDouble() - (m_radGalaxy);
rad = sqrt(x*x + y*y);
int k1 = 2*i;
m_pH2[k1].m_a = rad;
m_pH2[k1].m_b = rad * getExcentricity(rad);
m_pH2[k1].m_angle = getAngularOffset(rad);
- m_pH2[k1].m_theta = 360.0 * ((double)rand() / RAND_MAX);
+ m_pH2[k1].m_theta = 360.0 * QRandomGenerator::global()->generateDouble();
m_pH2[k1].m_center = QVector2D(0.0f, 0.0f);
m_pH2[k1].calcXY();
diff --git a/tests/manual/galaxy/star.cpp b/tests/manual/galaxy/star.cpp
index 1513c93b..ca6b66f0 100644
--- a/tests/manual/galaxy/star.cpp
+++ b/tests/manual/galaxy/star.cpp
@@ -31,8 +31,6 @@
#include <QtCore/qmath.h>
-static const double DEG_TO_RAD = M_PI / 180.0;
-
Star::Star()
: m_theta(0),
m_a(0),
@@ -49,7 +47,7 @@ const void Star::calcXY()
const QVector2D &p = m_center;
qreal beta = -m_angle;
- qreal alpha = theta * DEG_TO_RAD;
+ qreal alpha = qDegreesToRadians(theta);
// temporaries to save cpu time
qreal cosalpha = qCos(alpha);
diff --git a/tests/manual/itemmodeltest/main.cpp b/tests/manual/itemmodeltest/main.cpp
index 63aa2036..6cb97fc8 100644
--- a/tests/manual/itemmodeltest/main.cpp
+++ b/tests/manual/itemmodeltest/main.cpp
@@ -43,6 +43,7 @@
#include <QtWidgets/QTableWidget>
#include <QtGui/QScreen>
#include <QtCore/QTimer>
+#include <QtCore/QRandomGenerator>
#include <QtCore/QDebug>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QPushButton>
@@ -201,7 +202,7 @@ void GraphDataGenerator::addRow()
QModelIndex index = m_tableWidget->model()->index(0, i);
m_tableWidget->model()->setData(index,
((float)i / (float)m_columnCount) / 2.0f
- + (float)(rand() % 30) / 100.0f);
+ + QRandomGenerator::global()->bounded(30.0 / 100.0f));
}
m_tableWidget->resizeColumnsToContents();
}
@@ -234,7 +235,7 @@ void GraphDataGenerator::fixTableSize()
void GraphDataGenerator::changeSelectedButtonClicked()
{
// Change all selected cells to a random value 1-10
- QVariant value = QVariant::fromValue(float((rand() % 10) + 1));
+ QVariant value = QVariant::fromValue(QRandomGenerator::global()->bounded(10.0) + 1);
QList<QTableWidgetItem *> selectedItems = m_tableWidget->selectedItems();
foreach (QTableWidgetItem *item, selectedItems) {
QString oldData = item->data(Qt::DisplayRole).toString();
diff --git a/tests/manual/qmlperf/datagenerator.cpp b/tests/manual/qmlperf/datagenerator.cpp
index cb5767d3..0d8cf9b2 100644
--- a/tests/manual/qmlperf/datagenerator.cpp
+++ b/tests/manual/qmlperf/datagenerator.cpp
@@ -29,6 +29,7 @@
#include "datagenerator.h"
#include <QDebug>
+#include <QRandomGenerator>
using namespace QtDataVisualization;
@@ -58,11 +59,10 @@ void DataGenerator::generateData(QScatter3DSeries *series, uint count)
dataArray->resize(count);
QScatterDataItem *ptrToDataArray = &dataArray->first();
- float rand_max = float(RAND_MAX);
for (uint i = 0; i < count; i++) {
- ptrToDataArray->setPosition(QVector3D(float(qrand()) / rand_max,
- float(qrand()) / rand_max,
- float(qrand()) / rand_max));
+ ptrToDataArray->setPosition(QVector3D(QRandomGenerator::global()->generateDouble(),
+ QRandomGenerator::global()->generateDouble(),
+ QRandomGenerator::global()->generateDouble()));
ptrToDataArray++;
}
@@ -74,11 +74,10 @@ void DataGenerator::add(QScatter3DSeries *series, uint count)
QScatterDataArray appendArray;
appendArray.resize(count);
- float rand_max = float(RAND_MAX);
for (uint i = 0; i < count; i++) {
- appendArray[i].setPosition(QVector3D(float(qrand()) / rand_max,
- float(qrand()) / rand_max,
- float(qrand()) / rand_max));
+ appendArray[i].setPosition(QVector3D(QRandomGenerator::global()->generateDouble(),
+ QRandomGenerator::global()->generateDouble(),
+ QRandomGenerator::global()->generateDouble()));
}
series->dataProxy()->addItems(appendArray);
diff --git a/tests/manual/scattertest/scatterchart.cpp b/tests/manual/scattertest/scatterchart.cpp
index 3bc7aff4..c6775df2 100644
--- a/tests/manual/scattertest/scatterchart.cpp
+++ b/tests/manual/scattertest/scatterchart.cpp
@@ -36,6 +36,7 @@
#include <QtDataVisualization/q3dtheme.h>
#include <QtDataVisualization/Q3DInputHandler>
#include <qmath.h>
+#include <qrandom.h>
using namespace QtDataVisualization;
//#define RANDOM_SCATTER
@@ -119,7 +120,7 @@ void ScatterDataModifier::massiveDataTest()
m_massiveTestCacheArray.resize(cacheSize);
int totalIndex = 0;
for (int i = 0; i < unitCount && totalIndex < cacheSize; i++) {
- unitBase += direction * (float(rand() % 3) / 100.0f);
+ unitBase += direction * (QRandomGenerator::global()->bounded(3) / 100.0f);
if (unitBase > maxY) {
unitBase = maxY;
direction = -1.0f;
@@ -128,9 +129,9 @@ void ScatterDataModifier::massiveDataTest()
direction = 1.0f;
}
for (int j = 0; j < itemsPerUnit && totalIndex < cacheSize; j++) {
- float randFactor = float(rand() % 100) / (100 / yRangeMargin);
+ float randFactor = float(QRandomGenerator::global()->bounded(100)) / (100 / yRangeMargin);
m_massiveTestCacheArray[totalIndex].setPosition(
- QVector3D(float(qrand() % itemsPerUnit),
+ QVector3D(float(QRandomGenerator::global()->bounded(itemsPerUnit)),
unitBase + randFactor, 0.0f));
// Z value is irrelevant, we replace it anyway when we take item to use
totalIndex++;
@@ -780,8 +781,8 @@ void ScatterDataModifier::removeBunch()
void ScatterDataModifier::timeout()
{
- int doWhat = rand() % 10;
- if (!(rand() % 100))
+ int doWhat = QRandomGenerator::global()->bounded(10);
+ if (!(QRandomGenerator::global()->bounded(100)))
doWhat = -1;
switch (doWhat) {
@@ -814,7 +815,7 @@ void ScatterDataModifier::timeout()
break;
case 9:
if (m_chart->seriesList().size())
- m_targetSeries = m_chart->seriesList().at(rand() % m_chart->seriesList().size());
+ m_targetSeries = m_chart->seriesList().at(QRandomGenerator::global()->bounded(m_chart->seriesList().size()));
else
addSeries();
break;
@@ -937,7 +938,7 @@ void ScatterDataModifier::toggleSeriesVisibility()
void ScatterDataModifier::changeSeriesName()
{
if (m_targetSeries)
- m_targetSeries->setName(m_targetSeries->name().append("-").append(QString::number(qrand() % 10)));
+ m_targetSeries->setName(m_targetSeries->name().append("-").append(QString::number(QRandomGenerator::global()->bounded(10))));
}
void ScatterDataModifier::handleAxisXChanged(QValue3DAxis *axis)
@@ -1119,9 +1120,9 @@ void ScatterDataModifier::setHorizontalAspectRatio(int ratio)
QVector3D ScatterDataModifier::randVector()
{
QVector3D retvec = QVector3D(
- (float)(rand() % 100) / 2.0f - (float)(rand() % 100) / 2.0f,
- (float)(rand() % 100) / 100.0f - (float)(rand() % 100) / 100.0f,
- (float)(rand() % 100) / 2.0f - (float)(rand() % 100) / 2.0f);
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f - (float)(QRandomGenerator::global()->bounded(100)) / 2.0f,
+ (float)(QRandomGenerator::global()->bounded(100)) / 100.0f - (float)(QRandomGenerator::global()->bounded(100)) / 100.0f,
+ (float)(QRandomGenerator::global()->bounded(100)) / 2.0f - (float)(QRandomGenerator::global()->bounded(100)) / 2.0f);
qDebug() << __FUNCTION__ << retvec;
@@ -1142,8 +1143,8 @@ QScatter3DSeries *ScatterDataModifier::createAndAddSeries()
series->setItemLabelFormat(QStringLiteral("@seriesName: (X:@xLabel / Z:@zLabel) Y:@yLabel"));
series->setMesh(QAbstract3DSeries::MeshSphere);
series->setMeshSmooth(true);
- series->setBaseColor(QColor(rand() % 256, rand() % 256, rand() % 256));
- series->setItemSize(float(rand() % 90 + 10) / 100.0f);
+ series->setBaseColor(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ series->setItemSize(float(QRandomGenerator::global()->bounded(90) + 10) / 100.0f);
QObject::connect(series, &QScatter3DSeries::selectedItemChanged, this,
&ScatterDataModifier::handleSelectionChange);
diff --git a/tests/manual/surfacetest/graphmodifier.cpp b/tests/manual/surfacetest/graphmodifier.cpp
index 42407ddd..11cabb4d 100644
--- a/tests/manual/surfacetest/graphmodifier.cpp
+++ b/tests/manual/surfacetest/graphmodifier.cpp
@@ -35,6 +35,7 @@
#include <QtDataVisualization/Q3DInputHandler>
#include <qmath.h>
+#include <qrandom.h>
#include <QLinearGradient>
#include <QDebug>
#include <QComboBox>
@@ -668,8 +669,8 @@ void GraphModifier::changeStyle()
void GraphModifier::selectButtonClicked()
{
QSurfaceDataProxy *proxy = m_theSeries->dataProxy();
- int row = rand() % proxy->rowCount();
- int col = rand() % proxy->columnCount();
+ int row = QRandomGenerator::global()->bounded(proxy->rowCount());
+ int col = QRandomGenerator::global()->bounded(proxy->columnCount());
m_theSeries->setSelectedPoint(QPoint(row, col));
}
@@ -700,11 +701,11 @@ void GraphModifier::timeout()
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
(*m_planeArray->at(i))[j].setX(m_planeArray->at(i)->at(j).x()
- * ((float((rand() % 10) + 5.0f) / 10000.0f) + 0.999f));
+ * ((float((QRandomGenerator::global()->bounded(10)) + 5.0f) / 10000.0f) + 0.999f));
(*m_planeArray->at(i))[j].setY(m_planeArray->at(i)->at(j).y()
- * ((float((rand() % 10) + 5.0f) / 1000.0f) + 0.99f) + 0.0001f);
+ * ((float((QRandomGenerator::global()->bounded(10)) + 5.0f) / 1000.0f) + 0.99f) + 0.0001f);
(*m_planeArray->at(i))[j].setZ(m_planeArray->at(i)->at(j).z()
- * ((float((rand() % 10) + 5.0f) / 10000.0f) + 0.999f));
+ * ((float((QRandomGenerator::global()->bounded(10)) + 5.0f) / 10000.0f) + 0.999f));
}
}
@@ -893,7 +894,7 @@ void GraphModifier::changeRow()
float maxZ = 10.0f;
float stepX = (maxX - minX) / float(m_xCount - 1);
float stepZ = (maxZ - minZ) / float(m_zCount - 1);
- float i = float(rand() % m_zCount);
+ float i = float(QRandomGenerator::global()->bounded(m_zCount));
QSurfaceDataRow *newRow = new QSurfaceDataRow(m_xCount);
float z = qMin(maxZ, (i * stepZ + minZ));
@@ -910,7 +911,7 @@ void GraphModifier::changeRow()
static int changeRowSeries = 0;
qDebug() << "Generating new values to a row at random pos for series " << changeRowSeries;
- int row = rand() % m_zCount;
+ int row = QRandomGenerator::global()->bounded(m_zCount);
QSurfaceDataRow *newRow = createMultiRow(row, changeRowSeries, true);
if (m_ascendingZ)
m_multiseries[changeRowSeries]->dataProxy()->setRow(row, newRow);
@@ -984,7 +985,7 @@ void GraphModifier::changeRows()
float maxZ = 10.0f;
float stepX = (maxX - minX) / float(m_xCount - 1);
float stepZ = (maxZ - minZ) / float(m_zCount - 1);
- float start = float(rand() % (m_zCount - 3));
+ float start = float(QRandomGenerator::global()->bounded(m_zCount - 3));
QSurfaceDataArray dataArray;
@@ -1006,7 +1007,7 @@ void GraphModifier::changeRows()
static int changeRowSeries = 0;
qDebug() << "Generating new values for 3 rows at random pos for series " << changeRowSeries;
- int row = rand() % (m_zCount - 3);
+ int row = QRandomGenerator::global()->bounded(m_zCount - 3);
QSurfaceDataArray dataArray;
for (int i = 0; i < 3; i++) {
QSurfaceDataRow *newRow = createMultiRow(row + i, changeRowSeries, true);
@@ -1033,8 +1034,8 @@ void GraphModifier::changeItem()
float maxZ = 10.0f;
float stepX = (maxX - minX) / float(m_xCount - 1);
float stepZ = (maxZ - minZ) / float(m_zCount - 1);
- float i = float(rand() % m_zCount);
- float j = float(rand() % m_xCount);
+ float i = float(QRandomGenerator::global()->bounded(m_zCount));
+ float j = float(QRandomGenerator::global()->bounded(m_xCount));
float x = qMin(maxX, (j * stepX + minX));
float z = qMin(maxZ, (i * stepZ + minZ));
@@ -1047,8 +1048,8 @@ void GraphModifier::changeItem()
#ifdef MULTI_SERIES
static int changeItemSeries = 0;
int full = m_limitX * m_limitZ;
- float i = float(rand() % m_zCount);
- float j = float(rand() % m_xCount);
+ float i = float(QRandomGenerator::global()->bounded(m_zCount));
+ float j = float(QRandomGenerator::global()->bounded(m_xCount));
float x = float(j) - m_limitX + 0.5f + m_multiSampleOffsetX[changeItemSeries];
float z = float(i) - m_limitZ + 0.5f + m_multiSampleOffsetZ[changeItemSeries];
float angle = (z * x) / float(full) * 1.57f;
@@ -1290,10 +1291,10 @@ void GraphModifier::removeRow()
if (m_zCount < 1)
return;
- int row = rand() % m_zCount;
+ int row = QRandomGenerator::global()->bounded(m_zCount);
#ifdef MULTI_SERIES
- int series = rand() % 4;
+ int series = QRandomGenerator::global()->bounded(4);
m_multiseries[series]->dataProxy()->removeRows(row, 1);
#else
m_theSeries->dataProxy()->removeRows(row, 1);
@@ -1306,7 +1307,7 @@ void GraphModifier::resetArray()
qDebug() << "Reset series data array";
int rows = 10;
int columns = 10;
- float randFactor = float(rand() % 100) / 100.0f;
+ float randFactor = float(QRandomGenerator::global()->bounded(100)) / 100.0f;
QSurfaceDataArray *planeArray = new QSurfaceDataArray;
planeArray->reserve(rows);
@@ -1321,7 +1322,7 @@ void GraphModifier::resetArray()
}
#ifdef MULTI_SERIES
- int series = rand() % 4;
+ int series = QRandomGenerator::global()->bounded(4);
m_multiseries[series]->dataProxy()->resetArray(planeArray);
#else
m_theSeries->dataProxy()->resetArray(planeArray);
@@ -1332,7 +1333,7 @@ void GraphModifier::resetArrayEmpty()
{
QSurfaceDataArray *emptyArray = new QSurfaceDataArray;
#ifdef MULTI_SERIES
- int series = rand() % 4;
+ int series = QRandomGenerator::global()->bounded(4);
m_multiseries[series]->dataProxy()->resetArray(emptyArray);
#else
m_theSeries->dataProxy()->resetArray(emptyArray);
@@ -1363,7 +1364,7 @@ void GraphModifier::massiveDataTest()
for (int i = 0; i < cacheSize; i++) {
m_massiveTestCacheArray.append(new QSurfaceDataRow);
m_massiveTestCacheArray[i]->resize(columns);
- rowBase += direction * (float(rand() % 3) / 100.0f);
+ rowBase += direction * (float(QRandomGenerator::global()->bounded(3)) / 100.0f);
if (rowBase > maxY) {
rowBase = maxY;
direction = -1.0f;
@@ -1372,7 +1373,7 @@ void GraphModifier::massiveDataTest()
direction = 1.0f;
}
for (int j = 0; j < columns; j++) {
- float randFactor = float(rand() % 100) / (100 / yRangeMargin);
+ float randFactor = float(QRandomGenerator::global()->bounded(100)) / (100 / yRangeMargin);
(*m_massiveTestCacheArray.at(i))[j].setX(float(j));
(*m_massiveTestCacheArray.at(i))[j].setY(rowBase + randFactor);
// Z value is irrelevant, we replace it anyway when we take row to use