summaryrefslogtreecommitdiffstats
path: root/src/datavisualizationqml2
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-01-08 11:32:33 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-01-08 14:36:21 +0200
commit0144b397eff1340497ac2e599f7d9238bf99609c (patch)
treee65e1d9c0f8ddd077cf559c7c0e705eea9a027f4 /src/datavisualizationqml2
parent467e729eabece018cd42eeee0160f932983561b0 (diff)
Enable showing multiple graphs in QML
+ other minor fixes Task-number: QTRD-2749 Change-Id: I654d41fd4124d6596f9df3ace7019706452d8bfa Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
Diffstat (limited to 'src/datavisualizationqml2')
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp38
-rw-r--r--src/datavisualizationqml2/abstractdeclarative_p.h21
2 files changed, 42 insertions, 17 deletions
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