From 5273db8cbc592ee5d2da767e3a8e873f2a83784f Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 18 Dec 2013 14:19:33 +0200 Subject: Fix minor cosmetic issues in examples Task-id: QTRD-2741 Change-Id: Ifdd49bc9541c2893a7c6f3629cde12e2d15ad7c0 Reviewed-by: Mika Salmela --- examples/qmlcustominput/qml/qmlcustominput/main.qml | 2 +- examples/scatter/doc/src/scatter.qdoc | 2 +- examples/scatter/scatterdatamodifier.cpp | 1 + examples/surface/surfacegraph.cpp | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/qmlcustominput/qml/qmlcustominput/main.qml b/examples/qmlcustominput/qml/qmlcustominput/main.qml index f777fd6b..2a235986 100644 --- a/examples/qmlcustominput/qml/qmlcustominput/main.qml +++ b/examples/qmlcustominput/qml/qmlcustominput/main.qml @@ -182,7 +182,7 @@ Item { id: cameraToggle Layout.fillHeight: true Layout.minimumWidth: parent.width / 3 - text: "Animate Camera" + text: "Pause Camera" onClicked: { cameraAnimationX.paused = !cameraAnimationX.paused; diff --git a/examples/scatter/doc/src/scatter.qdoc b/examples/scatter/doc/src/scatter.qdoc index 173ea6e3..9bef441c 100644 --- a/examples/scatter/doc/src/scatter.qdoc +++ b/examples/scatter/doc/src/scatter.qdoc @@ -80,7 +80,7 @@ \snippet ../examples/scatter/scatterdatamodifier.cpp 1 And finally we create a QScatterDataProxy and the associated QScatter3DSeries. We set custom label format - for the series and add it to the graph: + and mesh smoothing for the series and add it to the graph: \snippet ../examples/scatter/scatterdatamodifier.cpp 2 diff --git a/examples/scatter/scatterdatamodifier.cpp b/examples/scatter/scatterdatamodifier.cpp index ade4eb59..6cdb1458 100644 --- a/examples/scatter/scatterdatamodifier.cpp +++ b/examples/scatter/scatterdatamodifier.cpp @@ -57,6 +57,7 @@ ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter) QScatterDataProxy *proxy = new QScatterDataProxy; QScatter3DSeries *series = new QScatter3DSeries(proxy); series->setItemLabelFormat("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel"); + series->setMeshSmooth(m_smooth); m_graph->addSeries(series); //! [2] diff --git a/examples/surface/surfacegraph.cpp b/examples/surface/surfacegraph.cpp index 24ab3715..7ebb6b72 100644 --- a/examples/surface/surfacegraph.cpp +++ b/examples/surface/surfacegraph.cpp @@ -49,6 +49,7 @@ SurfaceGraph::SurfaceGraph(Q3DSurface *surface) QImage heightMapImage(":/maps/mountain"); m_heightMapProxy = new QHeightMapSurfaceDataProxy(heightMapImage); m_heightMapSeries = new QSurface3DSeries(m_heightMapProxy); + m_heightMapSeries->setItemLabelFormat(QStringLiteral("(@xLabel, @zLabel): @yLabel")); m_heightMapProxy->setValueRanges(34.0f, 40.0f, 18.0f, 24.0f); //! [2] m_heightMapWidth = heightMapImage.width(); -- cgit v1.2.3 From 6de5b7a0bb9fe79ccd56cc5088464143794d7135 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Thu, 19 Dec 2013 11:12:38 +0200 Subject: Clear the depth texture when surface not visible Also grid and surface visibility should not affect on updates. Task-number: QTRD-2742 Change-Id: I9605897599d571b1ee39dab7f6c93d5c80110f0c Reviewed-by: Miikka Heikkinen --- src/datavisualization/engine/surface3drenderer.cpp | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 7049632d..d9351cc9 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -264,6 +264,9 @@ void Surface3DRenderer::updateData() delete m_surfaceObj; m_surfaceObj = 0; + + m_textureHelper->fillDepthTexture(m_depthTexture, m_primarySubViewport.size(), + m_shadowQualityMultiplier, 1.0f); } for (int i = 0; i < m_sliceDataArray.size(); i++) @@ -285,6 +288,10 @@ void Surface3DRenderer::updateSeries(const QList &seriesLis QSurface3DSeries::DrawFlags drawMode = series->drawMode(); m_cachedSurfaceVisible = drawMode.testFlag(QSurface3DSeries::DrawSurface); + if (!m_cachedSurfaceVisible) { + m_textureHelper->fillDepthTexture(m_depthTexture, m_primarySubViewport.size(), + m_shadowQualityMultiplier, 1.0f); + } m_cachedSurfaceGridOn = drawMode.testFlag(QSurface3DSeries::DrawWireframe); QVector3D seriesColor = Utils::vectorFromColor(series->baseColor()); @@ -304,11 +311,9 @@ void Surface3DRenderer::updateRows(const QVector &rows) const QSurfaceDataArray *array = 0; if (m_visibleSeriesList.size()) { QSurface3DSeries *firstSeries = static_cast(m_visibleSeriesList.at(0).series()); - if (m_cachedSurfaceGridOn || m_cachedSurfaceVisible) { - QSurfaceDataProxy *dataProxy = firstSeries->dataProxy(); - if (dataProxy) - array = dataProxy->array(); - } + QSurfaceDataProxy *dataProxy = firstSeries->dataProxy(); + if (dataProxy) + array = dataProxy->array(); } if (array && array->size() >= 2 && array->at(0)->size() >= 2 && @@ -346,11 +351,9 @@ void Surface3DRenderer::updateItem(const QVector &points) const QSurfaceDataArray *array = 0; if (m_visibleSeriesList.size()) { QSurface3DSeries *firstSeries = static_cast(m_visibleSeriesList.at(0).series()); - if (m_cachedSurfaceGridOn || m_cachedSurfaceVisible) { - QSurfaceDataProxy *dataProxy = firstSeries->dataProxy(); - if (dataProxy) - array = dataProxy->array(); - } + QSurfaceDataProxy *dataProxy = firstSeries->dataProxy(); + if (dataProxy) + array = dataProxy->array(); } if (array && array->size() >= 2 && array->at(0)->size() >= 2 && -- cgit v1.2.3 From ceda9bb5f39305d8f6467f574c7c7693b8a779f8 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Thu, 19 Dec 2013 13:49:18 +0200 Subject: IFDEFs for fillDepthTexture Task-number: QTRD-2742 Change-Id: Iab7787196bfd56ee57f5ed6604bb6dd04e5be4f9 Reviewed-by: Miikka Heikkinen --- src/datavisualization/engine/surface3drenderer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index d9351cc9..69acb6b2 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -264,9 +264,10 @@ void Surface3DRenderer::updateData() delete m_surfaceObj; m_surfaceObj = 0; - +#if !defined(QT_OPENGL_ES_2) m_textureHelper->fillDepthTexture(m_depthTexture, m_primarySubViewport.size(), m_shadowQualityMultiplier, 1.0f); +#endif } for (int i = 0; i < m_sliceDataArray.size(); i++) @@ -288,10 +289,12 @@ void Surface3DRenderer::updateSeries(const QList &seriesLis QSurface3DSeries::DrawFlags drawMode = series->drawMode(); m_cachedSurfaceVisible = drawMode.testFlag(QSurface3DSeries::DrawSurface); +#if !defined(QT_OPENGL_ES_2) if (!m_cachedSurfaceVisible) { m_textureHelper->fillDepthTexture(m_depthTexture, m_primarySubViewport.size(), m_shadowQualityMultiplier, 1.0f); } +#endif m_cachedSurfaceGridOn = drawMode.testFlag(QSurface3DSeries::DrawWireframe); QVector3D seriesColor = Utils::vectorFromColor(series->baseColor()); -- cgit v1.2.3 From dcf57ae33cbe173724f7f18d94c3d67cac27fac1 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 19 Dec 2013 13:38:31 +0200 Subject: Documentation and example fixes Task-id: QTRD-2744 Change-Id: I901f05b737e24c363d7ed897e1baadc9f9a03333 Reviewed-by: Mika Salmela --- examples/qmlbars/qml/qmlbars/main.qml | 1 - .../qmlcustominput/qml/qmlcustominput/main.qml | 1 - examples/qmlscatter/doc/src/qmlscatter.qdoc | 7 +- examples/qmlscatter/qml/qmlscatter/main.qml | 1 - examples/qmlsurface/qml/qmlsurface/main.qml | 1 - .../doc/snippets/doc_src_qmldatavisualization.cpp | 160 +++++++++++++-------- .../doc/src/qtdatavisualization-qml-bars3d.qdoc | 6 + .../doc/src/qtdatavisualization-qml-scatter3d.qdoc | 6 + .../doc/src/qtdatavisualization-qml-surface3d.qdoc | 6 + 9 files changed, 123 insertions(+), 66 deletions(-) diff --git a/examples/qmlbars/qml/qmlbars/main.qml b/examples/qmlbars/qml/qmlbars/main.qml index 1f8c1a3d..0581f834 100644 --- a/examples/qmlbars/qml/qmlbars/main.qml +++ b/examples/qmlbars/qml/qmlbars/main.qml @@ -27,7 +27,6 @@ Item { id: mainview width: 1280 height: 1024 - visible: true property int buttonLayoutHeight: 180; state: Screen.width < Screen.height ? "portrait" : "landscape" diff --git a/examples/qmlcustominput/qml/qmlcustominput/main.qml b/examples/qmlcustominput/qml/qmlcustominput/main.qml index 2a235986..54ec3342 100644 --- a/examples/qmlcustominput/qml/qmlcustominput/main.qml +++ b/examples/qmlcustominput/qml/qmlcustominput/main.qml @@ -25,7 +25,6 @@ Item { id: mainView width: 1280 height: 720 - visible: true Data { id: graphData diff --git a/examples/qmlscatter/doc/src/qmlscatter.qdoc b/examples/qmlscatter/doc/src/qmlscatter.qdoc index b0f1fd1f..06719ffc 100644 --- a/examples/qmlscatter/doc/src/qmlscatter.qdoc +++ b/examples/qmlscatter/doc/src/qmlscatter.qdoc @@ -86,10 +86,15 @@ The last \c import just imports all the qml files in the same directory as our \c {main.qml}, because that's where \c newbutton.qml and \c data.qml are. - Then we create our main \c Item, call it \c mainView and set it visible: + Then we create our main \c Item and call it \c mainView: \snippet ../examples/qmlscatter/qml/qmlscatter/main.qml 1 + \note The Qt Creator application wizard will set a \c Rectangle item as the main item, which + is opaque white by default. This doesn't work for us, because the graphs are rendered behind the other + QML elements. We change the main item type to \c Item, which is invisible. This way the graph is + not covered by the main item. + Then we'll add another \c Item inside it, and call it \c dataView. This will be the item to hold the Scatter3D graph. We'll anchor it to the parent bottom: diff --git a/examples/qmlscatter/qml/qmlscatter/main.qml b/examples/qmlscatter/qml/qmlscatter/main.qml index 22eab76b..62727f84 100644 --- a/examples/qmlscatter/qml/qmlscatter/main.qml +++ b/examples/qmlscatter/qml/qmlscatter/main.qml @@ -26,7 +26,6 @@ import "." //! [1] Item { id: mainView - visible: true //! [1] //! [4] diff --git a/examples/qmlsurface/qml/qmlsurface/main.qml b/examples/qmlsurface/qml/qmlsurface/main.qml index 07a07891..9f37a3f5 100644 --- a/examples/qmlsurface/qml/qmlsurface/main.qml +++ b/examples/qmlsurface/qml/qmlsurface/main.qml @@ -25,7 +25,6 @@ Item { id: mainview width: 1280 height: 720 - visible: true property int buttonMaximumWidth: surfaceGridToggle.width property int buttonMinimumHeight: seriesToggle.height diff --git a/src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp b/src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp index 03f6e847..623f7f6f 100644 --- a/src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp +++ b/src/datavisualization/doc/snippets/doc_src_qmldatavisualization.cpp @@ -21,86 +21,124 @@ import QtDataVisualization 1.0 //! [0] //! [1] -Bars3D { - rows: 4 - columns: 4 - barSpacing: Qt.size(0.5, 0.5) - barSpacingRelative: false - - Bar3DSeries { - itemLabelFormat: "@valueTitle for @colLabel, @rowLabel: @valueLabel" - - ItemModelBarDataProxy { - itemModel: model // E.g. a list model defined elsewhere containing monthly expenses data. - // Mapping model roles to bar series rows, columns, and values. - rowRole: "year" - columnRole: "city" - valueRole: "expenses" - rowCategories: ["2010", "2011", "2012", "2013"] - columnCategories: ["Oulu", "Rauma", "Helsinki", "Tampere"] +import QtQuick 2.0 +import QtDataVisualization 1.0 + +Item { + width: 640 + height: 480 + + Bars3D { + width: parent.width + height: parent.height + + Bar3DSeries { + itemLabelFormat: "@colLabel, @rowLabel: @valueLabel" + + ItemModelBarDataProxy { + itemModel: dataModel + // Mapping model roles to bar series rows, columns, and values. + rowRole: "year" + columnRole: "city" + valueRole: "expenses" + } } } + + ListModel { + id: dataModel + ListElement{ year: "2012"; city: "Oulu"; expenses: "4200"; } + ListElement{ year: "2012"; city: "Rauma"; expenses: "2100"; } + ListElement{ year: "2012"; city: "Helsinki"; expenses: "7040"; } + ListElement{ year: "2012"; city: "Tampere"; expenses: "4330"; } + ListElement{ year: "2013"; city: "Oulu"; expenses: "3960"; } + ListElement{ year: "2013"; city: "Rauma"; expenses: "1990"; } + ListElement{ year: "2013"; city: "Helsinki"; expenses: "7230"; } + ListElement{ year: "2013"; city: "Tampere"; expenses: "4650"; } + } } //! [1] //! [2] -Scatter3D { - axisX.segmentCount: 2 - axisX.subSegmentCount: 2 - axisX.labelFormat: "%.2f" - axisZ.segmentCount: 2 - axisZ.subSegmentCount: 2 - axisZ.labelFormat: "%.2f" - axisY.segmentCount: 3 - axisY.subSegmentCount: 2 - axisY.labelFormat: "%.2f" - - Scatter3DSeries { - itemLabelFormat: "X:@xLabel Y:@yLabel Z:@zLabel" - - ItemModelScatterDataProxy { - itemModel: model // E.g. a list model defined elsewhere containing point coordinates. - // Mapping model roles to scatter series item coordinates. - xPosRole: "xPos" - yPosRole: "yPos" - zPosRole: "zPos" +import QtQuick 2.0 +import QtDataVisualization 1.0 + +Item { + width: 640 + height: 480 + + Scatter3D { + width: parent.width + height: parent.height + Scatter3DSeries { + ItemModelScatterDataProxy { + itemModel: dataModel + // Mapping model roles to scatter series item coordinates. + xPosRole: "xPos" + yPosRole: "yPos" + zPosRole: "zPos" + } } } + + ListModel { + id: dataModel + ListElement{ xPos: "2.754"; yPos: "1.455"; zPos: "3.362"; } + ListElement{ xPos: "3.164"; yPos: "2.022"; zPos: "4.348"; } + ListElement{ xPos: "4.564"; yPos: "1.865"; zPos: "1.346"; } + ListElement{ xPos: "1.068"; yPos: "1.224"; zPos: "2.983"; } + ListElement{ xPos: "2.323"; yPos: "2.502"; zPos: "3.133"; } + } } //! [2] //! [3] -Surface3D { - axisX.min: 0.0 - axisX.max: 10.0 - axisZ.min: 0.0 - axisZ.max: 10.0 - axisY.min: 0.0 - axisY.max: 5.0 - axisX.segmentCount: 5 - axisX.subSegmentCount: 2 - axisX.labelFormat: "%i" - axisZ.segmentCount: 5 - axisZ.subSegmentCount: 2 - axisZ.labelFormat: "%i" - axisY.segmentCount: 5 - axisY.labelFormat: "%.1f" - - Surface3DSeries { - ItemModelSurfaceDataProxy { - itemModel: model // E.g. a list model defined elsewhere containing population data. - // Mapping model roles to surface series rows, columns, and values. - rowRole: "longitude" - columnRole: "latitude" - valueRole: "pop_density" +import QtQuick 2.0 +import QtDataVisualization 1.0 + +Item { + width: 640 + height: 480 + + Surface3D { + width: parent.width + height: parent.height + Surface3DSeries { + itemLabelFormat: "Pop density at (@xLabel N, @zLabel E): @yLabel" + ItemModelSurfaceDataProxy { + itemModel: dataModel + // Mapping model roles to surface series rows, columns, and values. + rowRole: "longitude" + columnRole: "latitude" + valueRole: "pop_density" + } } } + ListModel { + id: dataModel + ListElement{ longitude: "20"; latitude: "10"; pop_density: "4.75"; } + ListElement{ longitude: "21"; latitude: "10"; pop_density: "3.00"; } + ListElement{ longitude: "22"; latitude: "10"; pop_density: "1.24"; } + ListElement{ longitude: "23"; latitude: "10"; pop_density: "2.53"; } + ListElement{ longitude: "20"; latitude: "11"; pop_density: "2.55"; } + ListElement{ longitude: "21"; latitude: "11"; pop_density: "2.03"; } + ListElement{ longitude: "22"; latitude: "11"; pop_density: "3.46"; } + ListElement{ longitude: "23"; latitude: "11"; pop_density: "5.12"; } + ListElement{ longitude: "20"; latitude: "12"; pop_density: "1.37"; } + ListElement{ longitude: "21"; latitude: "12"; pop_density: "2.98"; } + ListElement{ longitude: "22"; latitude: "12"; pop_density: "3.33"; } + ListElement{ longitude: "23"; latitude: "12"; pop_density: "3.23"; } + ListElement{ longitude: "20"; latitude: "13"; pop_density: "4.34"; } + ListElement{ longitude: "21"; latitude: "13"; pop_density: "3.54"; } + ListElement{ longitude: "22"; latitude: "13"; pop_density: "1.65"; } + ListElement{ longitude: "23"; latitude: "13"; pop_density: "2.67"; } + } } //! [3] //! [7] ItemModelBarDataProxy { - itemModel: model // E.g. a list model defined elsewhere containing monthly expenses data. + itemModel: model // E.g. a list model defined elsewhere containing yearly expenses data. // Mapping model roles to bar series rows, columns, and values. rowRole: "year" columnRole: "city" diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc index fc1b732c..edeb5530 100644 --- a/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization-qml-bars3d.qdoc @@ -36,6 +36,11 @@ * * See \l{Qt Quick 2 Bars Example} for more thorough usage example. * + * \note Qt Data Visualization graphs are rendered behind any other QML elements on screen, including + * the parent elements of the graph. To make the whole graph show, ensure that no other element + * draws anything over the area the graph occupies. For example, having a non-transparent \c Rectangle + * item as the parent of a graph causes the graph to be hidden. + * * \sa Bar3DSeries, ItemModelBarDataProxy, Scatter3D, Surface3D, {Qt Data Visualization C++ Classes} */ @@ -83,6 +88,7 @@ /*! * \qmlproperty list Bars3D::seriesList + * \default * This property holds the series of the graph. * By default, this property contains an empty list. * To set the series, either use the addSeries() function or define them as children of the graph. diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc index 1f04424f..0a8e1674 100644 --- a/src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization-qml-scatter3d.qdoc @@ -36,6 +36,11 @@ See \l{Qt Quick 2 Scatter Example} for more thorough usage example. + \note Qt Data Visualization graphs are rendered behind any other QML elements on screen, including + the parent elements of the graph. To make the whole graph show, ensure that no other element + draws anything over the area the graph occupies. For example, having a non-transparent \c Rectangle + item as the parent of a graph causes the graph to be hidden. + \sa Scatter3DSeries, ScatterDataProxy, Bars3D, Surface3D, {Qt Data Visualization C++ Classes} */ @@ -68,6 +73,7 @@ /*! * \qmlproperty list Scatter3D::seriesList + * \default * This property holds the series of the graph. * By default, this property contains an empty list. * To set the series, either use the addSeries() function or define them as children of the graph. diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc index a3886008..b28d30a7 100644 --- a/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization-qml-surface3d.qdoc @@ -36,6 +36,11 @@ See \l{Qt Quick 2 Surface Example} for more thorough usage example. + \note Qt Data Visualization graphs are rendered behind any other QML elements on screen, including + the parent elements of the graph. To make the whole graph show, ensure that no other element + draws anything over the area the graph occupies. For example, having a non-transparent \c Rectangle + item as the parent of a graph causes the graph to be hidden. + \sa Surface3DSeries, ItemModelSurfaceDataProxy, Bars3D, Scatter3D, {Qt Data Visualization C++ Classes} */ @@ -74,6 +79,7 @@ /*! * \qmlproperty list Surface3D::seriesList + * \default * This property holds the series of the graph. * By default, this property contains an empty list. * To set the series, either use the addSeries() function or define them as children of the graph. -- cgit v1.2.3 From c32f52c8a00292d91ada5b8cf05b6edc6713ead2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 20 Dec 2013 11:31:04 +0200 Subject: Check context before attempting to release opengl resources In case of QMl ApplicationWindow using applications, openGL context seems to be 0 when the renderer gets destroyed at application shutdown. Work around this by checking for context validity on destructors before attempting to free openGL resources. Change-Id: I5ba5209740f8f4467f4ba2cc8dd195171bcd13c8 Reviewed-by: Mika Salmela --- src/datavisualization/engine/bars3drenderer.cpp | 12 +++++++----- src/datavisualization/engine/drawer.cpp | 3 ++- src/datavisualization/engine/scatter3drenderer.cpp | 12 +++++++----- src/datavisualization/engine/surface3drenderer.cpp | 19 ++++++++++--------- src/datavisualization/utils/abstractobjecthelper.cpp | 10 ++++++---- src/datavisualization/utils/surfaceobject.cpp | 3 ++- 6 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp index ecdac21f..f13b6e79 100644 --- a/src/datavisualization/engine/bars3drenderer.cpp +++ b/src/datavisualization/engine/bars3drenderer.cpp @@ -99,11 +99,13 @@ Bars3DRenderer::Bars3DRenderer(Bars3DController *controller) Bars3DRenderer::~Bars3DRenderer() { - m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer); - m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer); - m_textureHelper->deleteTexture(&m_selectionTexture); - m_textureHelper->glDeleteFramebuffers(1, &m_depthFrameBuffer); - m_textureHelper->deleteTexture(&m_bgrTexture); + if (QOpenGLContext::currentContext()) { + m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer); + m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer); + m_textureHelper->deleteTexture(&m_selectionTexture); + m_textureHelper->glDeleteFramebuffers(1, &m_depthFrameBuffer); + m_textureHelper->deleteTexture(&m_bgrTexture); + } delete m_barShader; delete m_barGradientShader; diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp index 14f0b315..f78b2d29 100644 --- a/src/datavisualization/engine/drawer.cpp +++ b/src/datavisualization/engine/drawer.cpp @@ -56,7 +56,8 @@ Drawer::Drawer(Q3DTheme *theme) Drawer::~Drawer() { delete m_textureHelper; - glDeleteBuffers(1, &m_pointbuffer); + if (QOpenGLContext::currentContext()) + glDeleteBuffers(1, &m_pointbuffer); } void Drawer::initializeOpenGL() diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp index 00452cf7..ee5c119e 100644 --- a/src/datavisualization/engine/scatter3drenderer.cpp +++ b/src/datavisualization/engine/scatter3drenderer.cpp @@ -98,11 +98,13 @@ Scatter3DRenderer::Scatter3DRenderer(Scatter3DController *controller) Scatter3DRenderer::~Scatter3DRenderer() { - m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer); - m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer); - m_textureHelper->deleteTexture(&m_selectionTexture); - m_textureHelper->glDeleteFramebuffers(1, &m_depthFrameBuffer); - m_textureHelper->deleteTexture(&m_bgrTexture); + if (QOpenGLContext::currentContext()) { + m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer); + m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer); + m_textureHelper->deleteTexture(&m_selectionTexture); + m_textureHelper->glDeleteFramebuffers(1, &m_depthFrameBuffer); + m_textureHelper->deleteTexture(&m_bgrTexture); + } delete m_dotShader; delete m_dotGradientShader; delete m_depthShader; diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 69acb6b2..912edd97 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -134,16 +134,17 @@ Surface3DRenderer::Surface3DRenderer(Surface3DController *controller) Surface3DRenderer::~Surface3DRenderer() { - m_textureHelper->glDeleteFramebuffers(1, &m_depthFrameBuffer); - m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer); - m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer); - - m_textureHelper->deleteTexture(&m_depthTexture); - m_textureHelper->deleteTexture(&m_depthModelTexture); - m_textureHelper->deleteTexture(&m_selectionTexture); - m_textureHelper->deleteTexture(&m_selectionResultTexture); - m_textureHelper->deleteTexture(&m_uniformGradientTexture); + if (QOpenGLContext::currentContext()) { + m_textureHelper->glDeleteFramebuffers(1, &m_depthFrameBuffer); + m_textureHelper->glDeleteRenderbuffers(1, &m_selectionDepthBuffer); + m_textureHelper->glDeleteFramebuffers(1, &m_selectionFrameBuffer); + m_textureHelper->deleteTexture(&m_depthTexture); + m_textureHelper->deleteTexture(&m_depthModelTexture); + m_textureHelper->deleteTexture(&m_selectionTexture); + m_textureHelper->deleteTexture(&m_selectionResultTexture); + m_textureHelper->deleteTexture(&m_uniformGradientTexture); + } delete m_shader; delete m_depthShader; delete m_backgroundShader; diff --git a/src/datavisualization/utils/abstractobjecthelper.cpp b/src/datavisualization/utils/abstractobjecthelper.cpp index d47f2fe6..96cdc0c4 100644 --- a/src/datavisualization/utils/abstractobjecthelper.cpp +++ b/src/datavisualization/utils/abstractobjecthelper.cpp @@ -34,10 +34,12 @@ AbstractObjectHelper::AbstractObjectHelper() AbstractObjectHelper::~AbstractObjectHelper() { - glDeleteBuffers(1, &m_vertexbuffer); - glDeleteBuffers(1, &m_uvbuffer); - glDeleteBuffers(1, &m_normalbuffer); - glDeleteBuffers(1, &m_elementbuffer); + if (QOpenGLContext::currentContext()) { + glDeleteBuffers(1, &m_vertexbuffer); + glDeleteBuffers(1, &m_uvbuffer); + glDeleteBuffers(1, &m_normalbuffer); + glDeleteBuffers(1, &m_elementbuffer); + } } GLuint AbstractObjectHelper::vertexBuf() diff --git a/src/datavisualization/utils/surfaceobject.cpp b/src/datavisualization/utils/surfaceobject.cpp index 605376e2..6e4765e5 100644 --- a/src/datavisualization/utils/surfaceobject.cpp +++ b/src/datavisualization/utils/surfaceobject.cpp @@ -39,7 +39,8 @@ SurfaceObject::SurfaceObject() SurfaceObject::~SurfaceObject() { - glDeleteBuffers(1, &m_gridElementbuffer); + if (QOpenGLContext::currentContext()) + glDeleteBuffers(1, &m_gridElementbuffer); } void SurfaceObject::setUpSmoothData(const QSurfaceDataArray &dataArray, const QRect &space, -- cgit v1.2.3 From 68cb5bf802c3e4b08a7482932be005a44d9f0a13 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 20 Dec 2013 11:50:52 +0200 Subject: Add mention about opaque qml elements hiding graphs to readme Change-Id: I2bf7567166b990ab1dd6acd726e53b5480015c17 Reviewed-by: Mika Salmela --- README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README b/README index 998c2f58..acd34527 100644 --- a/README +++ b/README @@ -73,6 +73,12 @@ Please refer to the generated documentation for more information: Known Issues ============ +- All other QML elements are drawn on top of the Qt DataVisualization graphs, + including the parent elements of the graphs. To ensure the graphs are not + hidden, make sure you don't draw anything opaque on top of the graphs. + For example, Qt Creator application wizard for Qt Quick 2 applications + creates by default an opaque white Rectangle element as the main element, + which covers any graph added to it. - Using multiple graphs in one application crashes on application shutdown unless the last graph to have active context is deleted last. - Android doesn't support both widgets and OpenGL simultaneously, so only -- cgit v1.2.3 From e895c5085f6097983bdd617c39ea5184541d6c4d Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Fri, 20 Dec 2013 11:48:37 +0200 Subject: Added a void cast to suppress a warning Task-number: QTRD-2743 Change-Id: If4d04a935f6780570f60afff12c05d19a862df15 Reviewed-by: Miikka Heikkinen --- examples/audiolevels/audiolevelsiodevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/audiolevels/audiolevelsiodevice.cpp b/examples/audiolevels/audiolevelsiodevice.cpp index 970677c6..e4576638 100644 --- a/examples/audiolevels/audiolevelsiodevice.cpp +++ b/examples/audiolevels/audiolevelsiodevice.cpp @@ -66,7 +66,7 @@ qint64 AudioLevelsIODevice::writeData(const char *data, qint64 maxSize) for (int i = 0; i <= middleRow; i++) { QBarDataItem *srcPos = m_array->at(i)->data(); QBarDataItem *dstPos = srcPos + newDataSize; - memmove(dstPos, srcPos, (rowSize - newDataSize) * sizeof(QBarDataItem)); + memmove((void *)dstPos, (void *)srcPos, (rowSize - newDataSize) * sizeof(QBarDataItem)); } } @@ -90,7 +90,7 @@ qint64 AudioLevelsIODevice::writeData(const char *data, qint64 maxSize) for (int i = rowCount - 1; i > middleRow; i--) { QBarDataItem *srcPos = m_array->at(index++)->data(); QBarDataItem *dstPos = m_array->at(i)->data(); - memcpy(dstPos, srcPos, rowSize * sizeof(QBarDataItem)); + memcpy((void *)dstPos, (void *)srcPos, rowSize * sizeof(QBarDataItem)); } // Reset the proxy array now that data has been updated to trigger a redraw. -- cgit v1.2.3