diff options
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | examples/itemmodel/main.cpp | 2 | ||||
-rw-r--r-- | examples/qmlsurface/qml/qmlsurface/main.qml | 21 | ||||
-rw-r--r-- | src/datavisualization/engine/selectionpointer.cpp | 8 | ||||
-rw-r--r-- | src/datavisualization/engine/surface3dcontroller.cpp | 7 | ||||
-rw-r--r-- | src/datavisualization/engine/surface3dcontroller_p.h | 4 | ||||
-rw-r--r-- | src/datavisualization/engine/surface3drenderer.cpp | 10 | ||||
-rw-r--r-- | src/datavisualizationqml2/declarativesurface.cpp | 3 | ||||
-rw-r--r-- | src/datavisualizationqml2/declarativesurface_p.h | 5 |
9 files changed, 40 insertions, 21 deletions
@@ -59,3 +59,4 @@ others may be only partially implemented. Here are some known issues: - Android doesn't support both widgets and OpenGL simulataneously, so only the Qt Quick 2 API is usable in practice in Android. - Shadows are not supported with OpenGL ES2 (including Angle builds in Windows). +- Anti-aliasing doesn't work with OpenGL ES2 (including Angle builds in Windows). diff --git a/examples/itemmodel/main.cpp b/examples/itemmodel/main.cpp index 6ab685ed..fac6b442 100644 --- a/examples/itemmodel/main.cpp +++ b/examples/itemmodel/main.cpp @@ -159,7 +159,7 @@ void GraphDataGenerator::setupModel() weeks << "week 1" << "week 2" << "week 3" << "week 4" << "week 5"; // Set up data Mon Tue Wed Thu Fri Sat Sun - float hours[5][7] = {{2.0, 1.0, 3.0, 0.2, 1.0, 5.0, 10.0}, // week 1 + qreal hours[5][7] = {{2.0, 1.0, 3.0, 0.2, 1.0, 5.0, 10.0}, // week 1 {0.5, 1.0, 3.0, 1.0, 2.0, 2.0, 3.0}, // week 2 {1.0, 1.0, 2.0, 1.0, 4.0, 4.0, 4.0}, // week 3 {0.0, 1.0, 0.0, 0.0, 2.0, 2.0, 0.3}, // week 4 diff --git a/examples/qmlsurface/qml/qmlsurface/main.qml b/examples/qmlsurface/qml/qmlsurface/main.qml index 160fa9b6..bc8d9499 100644 --- a/examples/qmlsurface/qml/qmlsurface/main.qml +++ b/examples/qmlsurface/qml/qmlsurface/main.qml @@ -70,6 +70,17 @@ Item { axisY.subSegmentCount: 2 axisY.labelFormat: "%i" gradient: surfaceGradient + + // Since flat is not supported on all platforms, and changes back to smooth + // asynchronously on those platforms, handle button text on changed + // signal handler rather than when we set the value. + onSmoothSurfaceEnabledChanged: { + if (enabled === true) { + smoothSurfaceToggle.text = "Show Flat" + } else { + smoothSurfaceToggle.text = "Show Smooth" + } + } } } @@ -81,7 +92,7 @@ Item { text: "Show Surface Grid" //! [1] onClicked: { - if (surfaceplot.surfaceGridEnabled == false) { + if (surfaceplot.surfaceGridEnabled === false) { surfaceplot.surfaceGridEnabled = true; text = "Hide Surface Grid" } else { @@ -99,12 +110,10 @@ Item { text: "Show Flat" //! [2] onClicked: { - if (surfaceplot.smoothSurfaceEnabled == true) { + if (surfaceplot.smoothSurfaceEnabled === true) { surfaceplot.smoothSurfaceEnabled = false; - text = "Show Smooth" } else { surfaceplot.smoothSurfaceEnabled = true; - text = "Show Flat" } } //! [2] @@ -116,7 +125,7 @@ Item { width: smoothSurfaceToggle.width text: "Hide Background" onClicked: { - if (surfaceplot.backgroundVisible == true) { + if (surfaceplot.backgroundVisible === true) { surfaceplot.backgroundVisible = false; text = "Show Background" } else { @@ -132,7 +141,7 @@ Item { width: backgroundToggle.width text: "Hide Grid" onClicked: { - if (surfaceplot.gridVisible == true) { + if (surfaceplot.gridVisible === true) { surfaceplot.gridVisible = false; text = "Show Grid" } else { diff --git a/src/datavisualization/engine/selectionpointer.cpp b/src/datavisualization/engine/selectionpointer.cpp index 6c3e0c8b..4fa9f688 100644 --- a/src/datavisualization/engine/selectionpointer.cpp +++ b/src/datavisualization/engine/selectionpointer.cpp @@ -245,12 +245,12 @@ void SelectionPointer::initShaders() // The shader for the small point ball if (m_pointShader) delete m_pointShader; -#if defined (Q_OS_ANDROID) - m_pointShader = new ShaderHelper(this, QStringLiteral(":/shaders/vertexES2"), - QStringLiteral(":/shaders/fragmentES2")); -#else +#if !defined(QT_OPENGL_ES_2) m_pointShader = new ShaderHelper(this, QStringLiteral(":/shaders/vertex"), QStringLiteral(":/shaders/fragment")); +#else + m_pointShader = new ShaderHelper(this, QStringLiteral(":/shaders/vertexES2"), + QStringLiteral(":/shaders/fragmentES2")); #endif m_pointShader->initialize(); diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp index 2272b731..c8823eb7 100644 --- a/src/datavisualization/engine/surface3dcontroller.cpp +++ b/src/datavisualization/engine/surface3dcontroller.cpp @@ -79,8 +79,11 @@ void Surface3DController::synchDataToRenderer() } if (m_changeTracker.smoothStatusChanged) { + bool oldSmoothStatus = m_isSmoothSurfaceEnabled; m_isSmoothSurfaceEnabled = m_renderer->updateSmoothStatus(m_isSmoothSurfaceEnabled); m_changeTracker.smoothStatusChanged = false; + if (oldSmoothStatus != m_isSmoothSurfaceEnabled) + emit smoothSurfaceEnabledChanged(m_isSmoothSurfaceEnabled); } if (m_changeTracker.surfaceGridChanged) { @@ -110,9 +113,13 @@ void Surface3DController::handleAxisRangeChangedBySender(QObject *sender) void Surface3DController::setSmoothSurface(bool enable) { + bool changed = m_isSmoothSurfaceEnabled != enable; m_isSmoothSurfaceEnabled = enable; m_changeTracker.smoothStatusChanged = true; emitNeedRender(); + + if (changed) + emit smoothSurfaceEnabledChanged(m_isSmoothSurfaceEnabled); } bool Surface3DController::smoothSurface() diff --git a/src/datavisualization/engine/surface3dcontroller_p.h b/src/datavisualization/engine/surface3dcontroller_p.h index 0efece97..0698c291 100644 --- a/src/datavisualization/engine/surface3dcontroller_p.h +++ b/src/datavisualization/engine/surface3dcontroller_p.h @@ -93,9 +93,7 @@ public slots: void handleArrayReset(); signals: - void smoothStatusChanged(bool enable); - void surfaceGridChanged(bool enable); - void segmentCountChanged(GLint segmentCount, GLfloat step, GLfloat minimum); + void smoothSurfaceEnabledChanged(bool enable); private: void adjustValueAxisRange(); diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 7aec3ff4..b73332f3 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -114,7 +114,6 @@ Surface3DRenderer::Surface3DRenderer(Surface3DController *controller) m_selectionModeChanged(false), m_hasHeightAdjustmentChanged(true) { -#if !defined(QT_OPENGL_ES_2) // Check if flat feature is supported ShaderHelper tester(this, QStringLiteral(":/shaders/vertexSurfaceFlat"), QStringLiteral(":/shaders/fragmentSurfaceFlat")); @@ -122,7 +121,6 @@ Surface3DRenderer::Surface3DRenderer(Surface3DController *controller) m_flatSupported = false; m_controller->setSmoothSurface(true); } -#endif m_cachedSmoothSurface = m_controller->smoothSurface(); updateSurfaceGridStatus(m_controller->surfaceGrid()); @@ -815,13 +813,13 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle) QMatrix4x4 depthProjectionMatrix; QMatrix4x4 depthProjectionViewMatrix; - GLfloat adjustedLightStrength = m_cachedTheme.m_lightStrength / 10.0f; QVector3D surfaceScaler(m_surfaceScaleX, 1.0f, m_surfaceScaleZ); QVector3D surfaceOffset(m_surfaceOffsetX, 0.0f, m_surfaceOffsetZ + zComp); // Draw depth buffer #if !defined(QT_OPENGL_ES_2) + GLfloat adjustedLightStrength = m_cachedTheme.m_lightStrength / 10.0f; if (m_cachedShadowQuality > QDataVis::ShadowQualityNone && m_surfaceObj) { // Render scene into a depth texture for using with shadow mapping // Enable drawing to depth framebuffer @@ -966,10 +964,10 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle) m_selectionShader->release(); // Put the RGBA value back to uint -#if defined (Q_OS_ANDROID) - selectionId = pixel[0] + pixel[1] * 256 + pixel[2] * 65536; -#else +#if !defined(QT_OPENGL_ES_2) selectionId = pixel[0] + pixel[1] * 256 + pixel[2] * 65536 + pixel[3] * 16777216; +#else + selectionId = pixel[0] + pixel[1] * 256 + pixel[2] * 65536; #endif selectionDirty = true; diff --git a/src/datavisualizationqml2/declarativesurface.cpp b/src/datavisualizationqml2/declarativesurface.cpp index 8375fa53..af3e059b 100644 --- a/src/datavisualizationqml2/declarativesurface.cpp +++ b/src/datavisualizationqml2/declarativesurface.cpp @@ -41,6 +41,9 @@ DeclarativeSurface::DeclarativeSurface(QQuickItem *parent) m_shared = new Surface3DController(boundingRect().toRect()); setSharedController(m_shared); + QObject::connect(m_shared, &Surface3DController::smoothSurfaceEnabledChanged, this, + &DeclarativeSurface::smoothSurfaceEnabledChanged); + QItemModelSurfaceDataProxy *proxy = new QItemModelSurfaceDataProxy; m_shared->setActiveDataProxy(proxy); } diff --git a/src/datavisualizationqml2/declarativesurface_p.h b/src/datavisualizationqml2/declarativesurface_p.h index 6ba52146..6e35b3b3 100644 --- a/src/datavisualizationqml2/declarativesurface_p.h +++ b/src/datavisualizationqml2/declarativesurface_p.h @@ -51,7 +51,7 @@ class DeclarativeSurface : public AbstractDeclarative Q_PROPERTY(Q3DValueAxis *axisX READ axisX WRITE setAxisX) Q_PROPERTY(Q3DValueAxis *axisY READ axisY WRITE setAxisY) Q_PROPERTY(Q3DValueAxis *axisZ READ axisZ WRITE setAxisZ) - Q_PROPERTY(bool smoothSurfaceEnabled READ isSmoothSurfaceEnabled WRITE setSmoothSurfaceEnabled) + Q_PROPERTY(bool smoothSurfaceEnabled READ isSmoothSurfaceEnabled WRITE setSmoothSurfaceEnabled NOTIFY smoothSurfaceEnabledChanged) Q_PROPERTY(bool surfaceGridEnabled READ isSurfaceGridEnabled WRITE setSurfaceGridEnabled) Q_PROPERTY(ColorGradient *gradient READ gradient WRITE setGradient) @@ -78,6 +78,9 @@ public: void setGradient(ColorGradient *gradient); ColorGradient *gradient() const; +signals: + void smoothSurfaceEnabledChanged(bool enabled); + protected: void handleGradientUpdate(); |