diff options
Diffstat (limited to 'src')
9 files changed, 91 insertions, 20 deletions
diff --git a/src/datavisualization/data/qbar3dseries.cpp b/src/datavisualization/data/qbar3dseries.cpp index 357feca6..6f0973cc 100644 --- a/src/datavisualization/data/qbar3dseries.cpp +++ b/src/datavisualization/data/qbar3dseries.cpp @@ -212,7 +212,7 @@ QBar3DSeriesPrivate::QBar3DSeriesPrivate(QBar3DSeries *q) : QAbstract3DSeriesPrivate(q, QAbstract3DSeries::SeriesTypeBar), m_selectedBar(Bars3DController::invalidSelectionPosition()) { - m_itemLabelFormat = QStringLiteral("@valueTitle: @valueLabel"); + m_itemLabelFormat = QStringLiteral("@valueLabel"); m_mesh = QAbstract3DSeries::MeshBevelBar; } diff --git a/src/datavisualization/data/qscatter3dseries.cpp b/src/datavisualization/data/qscatter3dseries.cpp index 8604c3f0..0e7ce921 100644 --- a/src/datavisualization/data/qscatter3dseries.cpp +++ b/src/datavisualization/data/qscatter3dseries.cpp @@ -237,7 +237,7 @@ QScatter3DSeriesPrivate::QScatter3DSeriesPrivate(QScatter3DSeries *q) m_selectedItem(Scatter3DController::invalidSelectionIndex()), m_itemSize(0.0f) { - m_itemLabelFormat = QStringLiteral("@valueTitle: @valueLabel"); + m_itemLabelFormat = QStringLiteral("@xLabel, @yLabel, @zLabel"); m_mesh = QAbstract3DSeries::MeshSphere; } diff --git a/src/datavisualization/data/qsurface3dseries.cpp b/src/datavisualization/data/qsurface3dseries.cpp index 1d456243..da285b2d 100644 --- a/src/datavisualization/data/qsurface3dseries.cpp +++ b/src/datavisualization/data/qsurface3dseries.cpp @@ -306,7 +306,7 @@ QSurface3DSeriesPrivate::QSurface3DSeriesPrivate(QSurface3DSeries *q) m_flatShadingEnabled(true), m_drawMode(QSurface3DSeries::DrawSurfaceAndWireframe) { - m_itemLabelFormat = QStringLiteral("(@xLabel, @yLabel, @zLabel)"); + m_itemLabelFormat = QStringLiteral("@xLabel, @yLabel, @zLabel"); m_mesh = QAbstract3DSeries::MeshSphere; } diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc index 21dabf66..5ac6a03f 100644 --- a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc @@ -42,6 +42,11 @@ */ /*! + \qmlproperty Scene3D AbstractGraph3D::scene + Read only Q3DScene that can be used to access e.g. camera object. + */ + +/*! \qmlproperty AbstractInputHandler3D AbstractGraph3D::inputHandler Input handler. You can disable default input handlers by setting this property to \c null. */ @@ -50,3 +55,24 @@ \qmlproperty Theme3D AbstractGraph3D::theme The active theme of the graph. */ + +/*! + \qmlproperty bool AbstractGraph3D::clearWindowBeforeRendering + + Indicates if the graph should also clear the whole window before rendering the graph, + including the areas outside the graph. + Since the graphs are drawn first under other QML items, the regular QML window clearing + before rendering is suppressed when there are any graphs in the window; the graphs + handle the clearing themselves instead. + If you have any other items besides graphs that do similar + custom drawing under other QML items, you need to set this property to false on all graphs + drawn to same window with the other custom items, or it is likely that the + other custom items do not render properly. + Defaults to true. + + \note This property should be set to the same value for all graphs in the same window. + Otherwise some graphs may not show. + + \note If window clearing before rendering is suppressed, any areas of the window not fully + covered with opaque items may not draw properly. + */ diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp index 32435946..19b9a8c8 100644 --- a/src/datavisualization/engine/abstract3drenderer.cpp +++ b/src/datavisualization/engine/abstract3drenderer.cpp @@ -122,9 +122,15 @@ void Abstract3DRenderer::render(const GLuint defaultFboHandle) m_viewport.y(), m_viewport.width(), m_viewport.height()); + glScissor(m_viewport.x(), + m_viewport.y(), + m_viewport.width(), + m_viewport.height()); + glEnable(GL_SCISSOR_TEST); QVector3D clearColor = Utils::vectorFromColor(m_cachedTheme->windowColor()); glClearColor(clearColor.x(), clearColor.y(), clearColor.z(), 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); } QString Abstract3DRenderer::generateValueLabel(const QString &format, float value) diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp index b70fd5b4..85863519 100644 --- a/src/datavisualization/engine/scatter3drenderer.cpp +++ b/src/datavisualization/engine/scatter3drenderer.cpp @@ -454,6 +454,10 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) && SelectOnScene == m_selectionState && seriesCount > 0) { // Draw dots to selection buffer glBindFramebuffer(GL_FRAMEBUFFER, m_selectionFrameBuffer); + glViewport(0, 0, + m_primarySubViewport.width(), + m_primarySubViewport.height()); + glEnable(GL_DEPTH_TEST); // Needed, otherwise the depth render buffer is not used glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Set clear color to white (= skipColor) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Needed for clearing the frame buffer @@ -552,7 +556,12 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) selectionColorToSeriesAndIndex(clickedColor, clickedIndex, clickedSeries); emit itemClicked(clickedIndex, clickedSeries); + // Revert to original fbo and viewport glBindFramebuffer(GL_FRAMEBUFFER, defaultFboHandle); + glViewport(m_primarySubViewport.x(), + m_primarySubViewport.y(), + m_primarySubViewport.width(), + m_primarySubViewport.height()); #if 0 // Use this if you want to see what is being drawn to the framebuffer m_labelShader->bind(); diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 912edd97..13a95670 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -881,6 +881,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle) // Render scene into a depth texture for using with shadow mapping // Enable drawing to depth framebuffer glBindFramebuffer(GL_FRAMEBUFFER, m_depthFrameBuffer); + // Attach texture to depth attachment glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0); glClear(GL_DEPTH_BUFFER_BIT); @@ -2147,6 +2148,10 @@ void Surface3DRenderer::updateDepthBuffer() m_textureHelper->deleteTexture(&m_depthTexture); m_depthTexture = 0; } + if (m_depthModelTexture) { + m_textureHelper->deleteTexture(&m_depthModelTexture); + m_depthModelTexture = 0; + } if (m_primarySubViewport.size().isEmpty()) return; diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp index 5cac1882..65f27da0 100644 --- a/src/datavisualizationqml2/abstractdeclarative.cpp +++ b/src/datavisualizationqml2/abstractdeclarative.cpp @@ -24,9 +24,12 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE +static QList<const QQuickWindow *> clearList; + AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) : QQuickItem(parent), - m_controller(0) + m_controller(0), + m_clearWindowBeforeRendering(true) { connect(this, &QQuickItem::windowChanged, this, &AbstractDeclarative::handleWindowChanged); setAntialiasing(true); @@ -51,6 +54,19 @@ Q3DTheme *AbstractDeclarative::theme() const return m_controller->activeTheme(); } +void AbstractDeclarative::setClearWindowBeforeRendering(bool enable) +{ + if (m_clearWindowBeforeRendering != enable) { + m_clearWindowBeforeRendering = enable; + emit clearWindowBeforeRenderingChanged(enable); + } +} + +bool AbstractDeclarative::clearWindowBeforeRendering() const +{ + return m_clearWindowBeforeRendering; +} + void AbstractDeclarative::setSelectionMode(QDataVis::SelectionFlags mode) { m_controller->setSelectionMode(mode); @@ -87,6 +103,8 @@ void AbstractDeclarative::setSharedController(Abstract3DController *controller) void AbstractDeclarative::synchDataToRenderer() { + if (m_clearWindowBeforeRendering && clearList.size()) + clearList.clear(); m_controller->initializeOpenGL(); m_controller->synchDataToRenderer(); } @@ -140,10 +158,9 @@ void AbstractDeclarative::updateWindowParameters() win->update(); } - QPointF point = QQuickItem::mapToScene(QPointF(m_cachedGeometry.x(), m_cachedGeometry.y())); - if (m_controller) { + QPointF point = QQuickItem::mapToScene(QPointF(0.0f, 0.0f)); + if (m_controller) scene->d_ptr->setViewport(QRect(point.x(), point.y(), m_cachedGeometry.width(), m_cachedGeometry.height())); - } } } @@ -151,11 +168,14 @@ void AbstractDeclarative::render() { updateWindowParameters(); - // Clear the background as that is not done by default - glViewport(0, 0, window()->width(), window()->height()); - QColor clearColor = window()->color(); - glClearColor(clearColor.redF(), clearColor.greenF(), clearColor.blueF(), 1.0f); - glClear(GL_COLOR_BUFFER_BIT); + // Clear the background once per window as that is not done by default + const QQuickWindow *win = window(); + if (m_clearWindowBeforeRendering && !clearList.contains(win)) { + clearList.append(win); + QColor clearColor = win->color(); + glClearColor(clearColor.redF(), clearColor.greenF(), clearColor.blueF(), 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + } // TODO: Store the state of these and restore before returning glDepthMask(GL_TRUE); diff --git a/src/datavisualizationqml2/abstractdeclarative_p.h b/src/datavisualizationqml2/abstractdeclarative_p.h index 42cf13a4..5da22df3 100644 --- a/src/datavisualizationqml2/abstractdeclarative_p.h +++ b/src/datavisualizationqml2/abstractdeclarative_p.h @@ -48,11 +48,18 @@ class AbstractDeclarative : public QQuickItem Q_PROPERTY(Q3DScene* scene READ scene NOTIFY sceneChanged) Q_PROPERTY(QAbstract3DInputHandler* inputHandler READ inputHandler WRITE setInputHandler NOTIFY inputHandlerChanged) Q_PROPERTY(Q3DTheme* theme READ theme WRITE setTheme NOTIFY themeChanged) + Q_PROPERTY(bool clearWindowBeforeRendering READ clearWindowBeforeRendering WRITE setClearWindowBeforeRendering NOTIFY clearWindowBeforeRenderingChanged) public: explicit AbstractDeclarative(QQuickItem *parent = 0); virtual ~AbstractDeclarative(); + virtual void setSelectionMode(QDataVis::SelectionFlags mode); + virtual QDataVis::SelectionFlags selectionMode() const; + + virtual void setShadowQuality(QDataVis::ShadowQuality quality); + virtual QDataVis::ShadowQuality shadowQuality() const; + virtual Q3DScene *scene() const; virtual QAbstract3DInputHandler *inputHandler() const; @@ -61,14 +68,11 @@ public: virtual void setTheme(Q3DTheme *theme); virtual Q3DTheme *theme() const; - virtual void setSelectionMode(QDataVis::SelectionFlags mode); - virtual QDataVis::SelectionFlags selectionMode() const; + virtual void setClearWindowBeforeRendering(bool enable); + virtual bool clearWindowBeforeRendering() const; virtual void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry); - virtual void setShadowQuality(QDataVis::ShadowQuality quality); - virtual QDataVis::ShadowQuality shadowQuality() const; - void setSharedController(Abstract3DController *controller); // Used to synch up data model from controller to renderer while main thread is locked void synchDataToRenderer(); @@ -87,16 +91,17 @@ protected: signals: // Signals shadow quality changes. + void selectionModeChanged(QDataVis::SelectionFlags mode); void shadowQualityChanged(QDataVis::ShadowQuality quality); + void sceneChanged(Q3DScene *scene); void inputHandlerChanged(QAbstract3DInputHandler *inputHandler); void themeChanged(Q3DTheme *theme); - void selectionModeChanged(QDataVis::SelectionFlags mode); - void itemLabelFormatChanged(QString format); - void sceneChanged(Q3DScene *scene); + void clearWindowBeforeRenderingChanged(bool enable); private: Abstract3DController *m_controller; QRectF m_cachedGeometry; + bool m_clearWindowBeforeRendering; }; QT_DATAVISUALIZATION_END_NAMESPACE |