summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Varanka <sami.varanka@qt.io>2021-05-12 13:03:07 +0300
committerSami Varanka <sami.varanka@qt.io>2021-05-18 12:44:28 +0300
commitc9768c1e2440e52976c3456a9a4d302edf49f56a (patch)
treea11032d74b493fc94da94a58ead7522fb681db0f
parentddbed903550cbec68688a4bcd4cb2bdddc9a850c (diff)
Fix Gradients don't show
Added pointer to graph in Abstract3DController. Controller can use that pointer to check whether the graph is ready when receiving a themetypeChanged signal. Added manual test for gradients. Pick-to: 6.1 Fixes: QTBUG-93506 Change-Id: I13df962b807feb615e3267f580ef57dd62a0b058 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/datavisualization/CMakeLists.txt1
-rw-r--r--src/datavisualization/engine/abstract3dcontroller.cpp9
-rw-r--r--src/datavisualization/engine/abstract3dcontroller_p.h2
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp1
-rw-r--r--src/datavisualizationqml2/abstractdeclarative_p.h2
-rw-r--r--tests/manual/CMakeLists.txt1
-rw-r--r--tests/manual/qmlgradient/CMakeLists.txt24
-rw-r--r--tests/manual/qmlgradient/crater.pngbin0 -> 28296 bytes
-rw-r--r--tests/manual/qmlgradient/main.cpp63
-rw-r--r--tests/manual/qmlgradient/qml.qrc5
-rw-r--r--tests/manual/qmlgradient/qml/qmlgradient/main.qml217
11 files changed, 323 insertions, 2 deletions
diff --git a/src/datavisualization/CMakeLists.txt b/src/datavisualization/CMakeLists.txt
index 2496aa69..5c7d5594 100644
--- a/src/datavisualization/CMakeLists.txt
+++ b/src/datavisualization/CMakeLists.txt
@@ -84,6 +84,7 @@ qt_internal_add_module(DataVisualization
input
theme
utils
+ ../datavisualizationqml2
PUBLIC_LIBRARIES
Qt::Core
Qt::Gui
diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp
index 3481f4eb..5ed62ca9 100644
--- a/src/datavisualization/engine/abstract3dcontroller.cpp
+++ b/src/datavisualization/engine/abstract3dcontroller.cpp
@@ -27,6 +27,7 @@
**
****************************************************************************/
+#include "abstractdeclarative_p.h"
#include "abstract3dcontroller_p.h"
#include "qabstract3daxis_p.h"
#include "qvalue3daxis_p.h"
@@ -692,12 +693,16 @@ void Abstract3DController::handleThemeTypeChanged(Q3DTheme::Theme theme)
{
Q_UNUSED(theme);
+ if (!m_qml)
+ return;
+
// Changing theme type is logically equivalent of changing the entire theme
// object, so reset all attached series to the new theme.
-
+ bool force = m_qml->isReady();
Q3DTheme *activeTheme = m_themeManager->activeTheme();
for (int i = 0; i < m_seriesList.size(); i++)
- m_seriesList.at(i)->d_ptr->resetToTheme(*activeTheme, i, true);
+ m_seriesList.at(i)->d_ptr->resetToTheme(*activeTheme, i, force);
+
markSeriesVisualsDirty();
}
diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h
index 5a99ecfc..916b3e1e 100644
--- a/src/datavisualization/engine/abstract3dcontroller_p.h
+++ b/src/datavisualization/engine/abstract3dcontroller_p.h
@@ -56,6 +56,7 @@ QT_FORWARD_DECLARE_CLASS(QOpenGLFramebufferObject)
QT_BEGIN_NAMESPACE
+class AbstractDeclarative;
class Abstract3DRenderer;
class QAbstract3DSeries;
class ThemeManager;
@@ -225,6 +226,7 @@ protected:
qreal m_margin;
QMutex m_renderMutex;
+ AbstractDeclarative *m_qml = nullptr;
explicit Abstract3DController(QRect initialViewport, Q3DScene *scene, QObject *parent = 0);
diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp
index d0830f70..ccc03d19 100644
--- a/src/datavisualizationqml2/abstractdeclarative.cpp
+++ b/src/datavisualizationqml2/abstractdeclarative.cpp
@@ -293,6 +293,7 @@ void AbstractDeclarative::setSharedController(Abstract3DController *controller)
{
Q_ASSERT(controller);
m_controller = controller;
+ m_controller->m_qml = this;
if (!m_controller->isOpenGLES())
m_samples = 4;
diff --git a/src/datavisualizationqml2/abstractdeclarative_p.h b/src/datavisualizationqml2/abstractdeclarative_p.h
index f0ebf4cf..dd560150 100644
--- a/src/datavisualizationqml2/abstractdeclarative_p.h
+++ b/src/datavisualizationqml2/abstractdeclarative_p.h
@@ -231,6 +231,8 @@ public:
QMutex *mutex() { return &m_mutex; }
+ bool isReady() { return isComponentComplete(); }
+
public Q_SLOTS:
virtual void handleAxisXChanged(QAbstract3DAxis *axis) = 0;
virtual void handleAxisYChanged(QAbstract3DAxis *axis) = 0;
diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt
index 66cd3967..36175991 100644
--- a/tests/manual/CMakeLists.txt
+++ b/tests/manual/CMakeLists.txt
@@ -3,6 +3,7 @@ if(TARGET Qt::Quick)
add_subdirectory(qmlmultitest)
add_subdirectory(qmlvolume)
add_subdirectory(qmlperf)
+ add_subdirectory(qmlgradient)
endif()
if(NOT ANDROID AND NOT IOS AND NOT WINRT)
add_subdirectory(barstest)
diff --git a/tests/manual/qmlgradient/CMakeLists.txt b/tests/manual/qmlgradient/CMakeLists.txt
new file mode 100644
index 00000000..067741e2
--- /dev/null
+++ b/tests/manual/qmlgradient/CMakeLists.txt
@@ -0,0 +1,24 @@
+qt_add_executable(qmlgradient
+ GUI
+ SOURCES
+ main.cpp
+ PUBLIC_LIBRARIES
+ Qt::Gui
+ Qt::DataVisualization
+)
+
+set(qmlgradient_resource_files
+ "qml/qmlgradient/main.qml"
+ "crater.png"
+)
+
+set_source_files_properties("crater.png"
+ PROPERTIES QT_RESOURCE_ALIAS "map"
+)
+
+qt_add_resource(qmlgradient "qmlgradient"
+ PREFIX
+ "/"
+ FILES
+ ${qmlgradient_resource_files}
+)
diff --git a/tests/manual/qmlgradient/crater.png b/tests/manual/qmlgradient/crater.png
new file mode 100644
index 00000000..91bba197
--- /dev/null
+++ b/tests/manual/qmlgradient/crater.png
Binary files differ
diff --git a/tests/manual/qmlgradient/main.cpp b/tests/manual/qmlgradient/main.cpp
new file mode 100644
index 00000000..48210ef2
--- /dev/null
+++ b/tests/manual/qmlgradient/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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$
+** 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 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** 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$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtCore/QDir>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ qputenv("QSG_RHI_BACKEND", "opengl");
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
+
+ QGuiApplication app(argc, argv);
+
+ QQuickView viewer;
+
+ const QUrl url(QStringLiteral("qrc:/qml/qmlgradient/main.qml"));
+
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../%2"));
+#endif
+
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect( viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+ viewer.setSource(url);
+ viewer.show();
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ return app.exec();
+}
diff --git a/tests/manual/qmlgradient/qml.qrc b/tests/manual/qmlgradient/qml.qrc
new file mode 100644
index 00000000..cd67689c
--- /dev/null
+++ b/tests/manual/qmlgradient/qml.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlgradient/main.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/qmlgradient/qml/qmlgradient/main.qml b/tests/manual/qmlgradient/qml/qmlgradient/main.qml
new file mode 100644
index 00000000..8aff340c
--- /dev/null
+++ b/tests/manual/qmlgradient/qml/qmlgradient/main.qml
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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$
+** 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 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** 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$
+**
+****************************************************************************/
+
+import QtQuick
+import QtQuick.Window
+import QtQuick.Layouts
+import QtQuick.Controls
+import QtDataVisualization 1.2
+import "."
+
+Rectangle {
+ id: mainwindow
+
+ function updateinfoLabels()
+ {
+ if (surfaceGraph.theme.baseGradients[0] === mainGradient)
+ gradientLabel.text = "Main gradient";
+ else if (surfaceGraph.theme.baseGradients[0] === secondaryGradient)
+ gradientLabel.text = "Secondary gradient";
+ }
+
+ width: 1024
+ height: 768
+ visible: true
+
+ Item {
+ id: surfaceview
+ width: mainwindow.width
+ height: mainwindow.height
+
+ anchors.top: mainwindow.top
+ anchors.left: mainwindow.left
+
+ ColorGradient {
+ id: mainGradient
+ ColorGradientStop { position: 0.0; color: "red"}
+ ColorGradientStop { position: 0.5; color: "green"}
+ ColorGradientStop { position: 0.8; color: "blue"}
+ ColorGradientStop { position: 0.6; color: "yellow"}
+ ColorGradientStop { position: 0.8; color: "black"}
+ ColorGradientStop { position: 1.0; color: "peru"}
+ }
+
+ ColorGradient {
+ id: secondaryGradient
+ ColorGradientStop { position: 0.0; color: "crimson"}
+ ColorGradientStop { position: 0.5; color: "chartreuse"}
+ ColorGradientStop { position: 0.8; color: "blueviolet"}
+ ColorGradientStop { position: 0.6; color: "gold"}
+ ColorGradientStop { position: 0.8; color: "darkslategrey"}
+ ColorGradientStop { position: 1.0; color: "seagreen"}
+ }
+
+ ColorGradient {
+ id: seriesGradient
+ ColorGradientStop { position: 0.0; color: "gold" }
+ ColorGradientStop { position: 0.5; color: "crimson" }
+ ColorGradientStop { position: 1.0; color: "blueviolet" }
+ }
+
+ Theme3D {
+ id: mainTheme
+ type: Q3DTheme.ThemeStoneMoss
+
+ colorStyle: Q3DTheme.ColorStyleRangeGradient
+ baseGradients: [mainGradient]
+ }
+
+ Theme3D {
+ id: secondaryTheme
+ type: Q3DTheme.ThemeArmyBlue
+ baseGradients: [secondaryGradient]
+ }
+
+ Surface3D {
+ id: surfaceGraph
+ width: surfaceview.width
+ height: surfaceview.height
+ theme: mainTheme
+
+ shadowQuality: AbstractGraph3D.ShadowQualityMedium
+ selectionMode: AbstractGraph3D.SelectionSlice | AbstractGraph3D.SelectionItemAndRow
+ scene.activeCamera.cameraPreset: Camera3D.CameraPresetIsometricLeft
+ axisY.min: 0.0
+ axisY.max: 500.0
+ axisX.segmentCount: 10
+ axisX.subSegmentCount: 2
+ axisX.labelFormat: "%i"
+ axisZ.segmentCount: 10
+ axisZ.subSegmentCount: 2
+ axisZ.labelFormat: "%i"
+ axisY.segmentCount: 5
+ axisY.subSegmentCount: 2
+ axisY.labelFormat: "%i"
+ axisY.title: "Height"
+ axisX.title: "Latitude"
+ axisZ.title: "Longitude"
+
+ Surface3DSeries{
+ id: heightSeries
+ drawMode: Surface3DSeries.DrawSurface
+ visible: true
+ flatShadingEnabled: false
+
+ HeightMapSurfaceDataProxy {
+ heightMapFile: ":/map"
+ }
+ }
+ }
+
+ RowLayout {
+ id: buttonLayout
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ Button {
+ id: toggleTheme
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ text: qsTr("Toggle theme")
+ onClicked: {
+ if (surfaceGraph.theme == mainTheme) {
+ surfaceGraph.theme = secondaryTheme;
+ themeLabel.text = "Secondary theme";
+ updateinfoLabels();
+ } else if (surfaceGraph.theme == secondaryTheme) {
+ surfaceGraph.theme = mainTheme;
+ updateinfoLabels();
+ themeLabel.text = "Main theme";
+ }
+ }
+ }
+
+ Button {
+ id: toggleGradient
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ text: qsTr("Toggle theme gradient")
+ onClicked: {
+ if (surfaceGraph.theme.baseGradients[0] === mainGradient) {
+ surfaceGraph.theme.baseGradients[0] = secondaryGradient;
+ updateinfoLabels();
+ } else if (surfaceGraph.theme.baseGradients[0] === secondaryGradient) {
+ surfaceGraph.theme.baseGradients[0] = mainGradient;
+ updateinfoLabels();
+ }
+ }
+ }
+
+ Button {
+ id: toggleSeriesGradient
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ text: qsTr("Override theme gradient with series gradient")
+
+ onClicked: {
+ heightSeries.baseGradient = seriesGradient;
+ gradientLabel.text = "Series gradient";
+ }
+ }
+ }
+
+ ColumnLayout {
+ id: infoLayout
+ anchors.top: buttonLayout.bottom
+ anchors.left: parent.left
+
+ Rectangle {
+ Layout.minimumHeight: 20
+
+ Label {
+ id: themeLabel
+ text: qsTr("Main theme")
+ }
+ }
+
+ Rectangle {
+ Layout.minimumHeight: 20
+
+ Label {
+ id: gradientLabel
+ text: qsTr("Main gradient")
+ }
+ }
+ }
+ }
+}