summaryrefslogtreecommitdiffstats
path: root/src/datavisualizationqml2
diff options
context:
space:
mode:
authorKeränen Pasi <pasi.keranen@digia.com>2013-12-03 10:39:23 +0200
committerPasi Keränen <pasi.keranen@digia.com>2013-12-03 14:06:07 +0200
commit2af35db1a112c49991a80f48e3cd8d8814deb321 (patch)
tree69c7a37711f851473c87408ac446ae0c6dcff2c9 /src/datavisualizationqml2
parent5a3abb2517126239f1b916b7b0cbaaa624b1cb44 (diff)
Fixes to QML retina display issues.
Task-id: QTRD-2661 Change-Id: I05fa1d9c3d078a7ed552b2b225f0d9bb1c03a0aa Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualizationqml2')
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp34
-rw-r--r--src/datavisualizationqml2/abstractdeclarative_p.h4
-rw-r--r--src/datavisualizationqml2/datavisualizationqml2.pro8
-rw-r--r--src/datavisualizationqml2/declarativebars.cpp70
-rw-r--r--src/datavisualizationqml2/declarativebars_p.h6
-rw-r--r--src/datavisualizationqml2/declarativerenderer.cpp (renamed from src/datavisualizationqml2/declarativebarsrenderer.cpp)40
-rw-r--r--src/datavisualizationqml2/declarativerenderer_p.h (renamed from src/datavisualizationqml2/declarativebarsrenderer_p.h)21
-rw-r--r--src/datavisualizationqml2/declarativescatter.cpp56
-rw-r--r--src/datavisualizationqml2/declarativescatter_p.h6
-rw-r--r--src/datavisualizationqml2/declarativescatterrenderer.cpp88
-rw-r--r--src/datavisualizationqml2/declarativescatterrenderer_p.h65
-rw-r--r--src/datavisualizationqml2/declarativesurface.cpp58
-rw-r--r--src/datavisualizationqml2/declarativesurface_p.h6
-rw-r--r--src/datavisualizationqml2/declarativesurfacerenderer.cpp87
-rw-r--r--src/datavisualizationqml2/declarativesurfacerenderer_p.h65
15 files changed, 132 insertions, 482 deletions
diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp
index a22caf9f..1bfa2911 100644
--- a/src/datavisualizationqml2/abstractdeclarative.cpp
+++ b/src/datavisualizationqml2/abstractdeclarative.cpp
@@ -17,12 +17,16 @@
****************************************************************************/
#include "abstractdeclarative_p.h"
+#include "declarativerenderer_p.h"
#include "q3dvalueaxis.h"
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) :
- QQuickItem(parent)
+ QQuickItem(parent),
+ m_controller(0),
+ m_initialisedSize(0, 0),
+ m_devicePixelRatio(1.0)
{
}
@@ -79,6 +83,34 @@ void AbstractDeclarative::setSharedController(Abstract3DController *controller)
&AbstractDeclarative::selectionModeChanged);
}
+QSGNode *AbstractDeclarative::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ qreal devicePixelRatio = window()->devicePixelRatio();
+
+ // If old node exists and has right size and right device pixel ratio, reuse it.
+ if (oldNode && m_initialisedSize == boundingRect().size().toSize() && devicePixelRatio == m_devicePixelRatio) {
+ // Update bounding rectangle (that has same size as before).
+ static_cast<DeclarativeRenderer *>(oldNode)->setRect(boundingRect());
+ return oldNode;
+ }
+
+ // Create a new render node when size changes or if there is no node yet
+ m_initialisedSize = boundingRect().size().toSize();
+ m_devicePixelRatio = devicePixelRatio;
+
+ // Delete old node
+ if (oldNode)
+ delete oldNode;
+
+ // Create a new one and set it's bounding rectangle
+ DeclarativeRenderer *node = new DeclarativeRenderer(window(), m_controller);
+ node->setDevicePixelRatio(float(m_devicePixelRatio));
+ node->setRect(boundingRect());
+ m_controller->scene()->setDevicePixelRatio(m_devicePixelRatio);
+ m_controller->setBoundingRect(boundingRect().toRect());
+ return node;
+}
+
QAbstract3DInputHandler* AbstractDeclarative::inputHandler() const
{
return m_controller->activeInputHandler();
diff --git a/src/datavisualizationqml2/abstractdeclarative_p.h b/src/datavisualizationqml2/abstractdeclarative_p.h
index fd7d89f2..aa3cf498 100644
--- a/src/datavisualizationqml2/abstractdeclarative_p.h
+++ b/src/datavisualizationqml2/abstractdeclarative_p.h
@@ -36,6 +36,7 @@
#include <QAbstractItemModel>
#include <QQuickItem>
#include <QObject>
+#include <QQuickWindow>
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
@@ -75,6 +76,7 @@ protected:
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void wheelEvent(QWheelEvent *event);
+ virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
signals:
// Signals shadow quality changes.
@@ -87,6 +89,8 @@ signals:
private:
Abstract3DController *m_controller;
+ QSize m_initialisedSize;
+ qreal m_devicePixelRatio;
};
QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualizationqml2/datavisualizationqml2.pro b/src/datavisualizationqml2/datavisualizationqml2.pro
index 2ae9ae1a..b9785f44 100644
--- a/src/datavisualizationqml2/datavisualizationqml2.pro
+++ b/src/datavisualizationqml2/datavisualizationqml2.pro
@@ -21,27 +21,23 @@ INCLUDEPATH += ../../include \
SOURCES += \
datavisualizationqml2_plugin.cpp \
declarativebars.cpp \
- declarativebarsrenderer.cpp \
declarativescatter.cpp \
- declarativescatterrenderer.cpp \
declarativesurface.cpp \
- declarativesurfacerenderer.cpp \
abstractdeclarative.cpp \
colorgradient.cpp \
declarativeseries.cpp \
+ declarativerenderer.cpp \
declarativetheme.cpp
HEADERS += \
datavisualizationqml2_plugin.h \
declarativebars_p.h \
- declarativebarsrenderer_p.h \
declarativescatter_p.h \
- declarativescatterrenderer_p.h \
declarativesurface_p.h \
- declarativesurfacerenderer_p.h \
abstractdeclarative_p.h \
colorgradient_p.h \
declarativeseries_p.h \
+ declarativerenderer_p.h \
declarativetheme_p.h
OTHER_FILES = qmldir
diff --git a/src/datavisualizationqml2/declarativebars.cpp b/src/datavisualizationqml2/declarativebars.cpp
index 91b338bd..905a842e 100644
--- a/src/datavisualizationqml2/declarativebars.cpp
+++ b/src/datavisualizationqml2/declarativebars.cpp
@@ -17,7 +17,7 @@
****************************************************************************/
#include "declarativebars_p.h"
-#include "declarativebarsrenderer_p.h"
+#include "declarativerenderer_p.h"
#include "q3dvalueaxis.h"
#include "qitemmodelbardataproxy.h"
@@ -25,8 +25,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
DeclarativeBars::DeclarativeBars(QQuickItem *parent)
: AbstractDeclarative(parent),
- m_shared(0),
- m_initialisedSize(0, 0)
+ m_barsController(0)
{
setFlags(QQuickItem::ItemHasContents);
setAcceptedMouseButtons(Qt::AllButtons);
@@ -36,110 +35,87 @@ DeclarativeBars::DeclarativeBars(QQuickItem *parent)
setSmooth(true);
// Create the shared component on the main GUI thread.
- m_shared = new Bars3DController(boundingRect().toRect());
- AbstractDeclarative::setSharedController(m_shared);
+ m_barsController = new Bars3DController(boundingRect().toRect());
+ AbstractDeclarative::setSharedController(m_barsController);
}
DeclarativeBars::~DeclarativeBars()
{
- delete m_shared;
-}
-
-QSGNode *DeclarativeBars::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
-{
- // If old node exists and has right size, reuse it.
- if (oldNode && m_initialisedSize == boundingRect().size().toSize()) {
- // Update bounding rectangle (that has same size as before).
- static_cast<DeclarativeBarsRenderer *>( oldNode )->setRect(boundingRect());
- return oldNode;
- }
-
- // Create a new render node when size changes or if there is no node yet
- m_initialisedSize = boundingRect().size().toSize();
-
- // Delete old node
- if (oldNode)
- delete oldNode;
-
- // Create a new one and set it's bounding rectangle
- DeclarativeBarsRenderer *node = new DeclarativeBarsRenderer(window(), m_shared);
- node->setRect(boundingRect());
- m_shared->setBoundingRect(boundingRect().toRect());
- return node;
+ delete m_barsController;
}
void DeclarativeBars::setBarColor(const QColor &baseColor)
{
- m_shared->setBaseColor(baseColor);
+ m_barsController->setBaseColor(baseColor);
}
Q3DCategoryAxis *DeclarativeBars::rowAxis() const
{
- return static_cast<Q3DCategoryAxis *>(m_shared->axisX());
+ return static_cast<Q3DCategoryAxis *>(m_barsController->axisX());
}
void DeclarativeBars::setRowAxis(Q3DCategoryAxis *axis)
{
- m_shared->setAxisX(axis);
+ m_barsController->setAxisX(axis);
}
Q3DValueAxis *DeclarativeBars::valueAxis() const
{
- return static_cast<Q3DValueAxis *>(m_shared->axisY());
+ return static_cast<Q3DValueAxis *>(m_barsController->axisY());
}
void DeclarativeBars::setValueAxis(Q3DValueAxis *axis)
{
- m_shared->setAxisY(axis);
+ m_barsController->setAxisY(axis);
}
Q3DCategoryAxis *DeclarativeBars::columnAxis() const
{
- return static_cast<Q3DCategoryAxis *>(m_shared->axisZ());
+ return static_cast<Q3DCategoryAxis *>(m_barsController->axisZ());
}
void DeclarativeBars::setColumnAxis(Q3DCategoryAxis *axis)
{
- m_shared->setAxisZ(axis);
+ m_barsController->setAxisZ(axis);
}
void DeclarativeBars::setBarThickness(float thicknessRatio)
{
if (thicknessRatio != barThickness()) {
- m_shared->setBarSpecs(GLfloat(thicknessRatio), barSpacing(), isBarSpacingRelative());
+ m_barsController->setBarSpecs(GLfloat(thicknessRatio), barSpacing(), isBarSpacingRelative());
emit barThicknessChanged(thicknessRatio);
}
}
float DeclarativeBars::barThickness() const
{
- return m_shared->barThickness();
+ return m_barsController->barThickness();
}
void DeclarativeBars::setBarSpacing(QSizeF spacing)
{
if (spacing != barSpacing()) {
- m_shared->setBarSpecs(GLfloat(barThickness()), spacing, isBarSpacingRelative());
+ m_barsController->setBarSpecs(GLfloat(barThickness()), spacing, isBarSpacingRelative());
emit barSpacingChanged(spacing);
}
}
QSizeF DeclarativeBars::barSpacing() const
{
- return m_shared->barSpacing();
+ return m_barsController->barSpacing();
}
void DeclarativeBars::setBarSpacingRelative(bool relative)
{
if (relative != isBarSpacingRelative()) {
- m_shared->setBarSpecs(GLfloat(barThickness()), barSpacing(), relative);
+ m_barsController->setBarSpecs(GLfloat(barThickness()), barSpacing(), relative);
emit barSpacingRelativeChanged(relative);
}
}
bool DeclarativeBars::isBarSpacingRelative() const
{
- return m_shared->isBarSpecRelative();
+ return m_barsController->isBarSpecRelative();
}
QQmlListProperty<QBar3DSeries> DeclarativeBars::seriesList()
@@ -158,18 +134,18 @@ void DeclarativeBars::appendSeriesFunc(QQmlListProperty<QBar3DSeries> *list, QBa
int DeclarativeBars::countSeriesFunc(QQmlListProperty<QBar3DSeries> *list)
{
- return reinterpret_cast<DeclarativeBars *>(list->data)->m_shared->barSeriesList().size();
+ return reinterpret_cast<DeclarativeBars *>(list->data)->m_barsController->barSeriesList().size();
}
QBar3DSeries *DeclarativeBars::atSeriesFunc(QQmlListProperty<QBar3DSeries> *list, int index)
{
- return reinterpret_cast<DeclarativeBars *>(list->data)->m_shared->barSeriesList().at(index);
+ return reinterpret_cast<DeclarativeBars *>(list->data)->m_barsController->barSeriesList().at(index);
}
void DeclarativeBars::clearSeriesFunc(QQmlListProperty<QBar3DSeries> *list)
{
DeclarativeBars *declBars = reinterpret_cast<DeclarativeBars *>(list->data);
- QList<QBar3DSeries *> realList = declBars->m_shared->barSeriesList();
+ QList<QBar3DSeries *> realList = declBars->m_barsController->barSeriesList();
int count = realList.size();
for (int i = 0; i < count; i++)
declBars->removeSeries(realList.at(i));
@@ -177,12 +153,12 @@ void DeclarativeBars::clearSeriesFunc(QQmlListProperty<QBar3DSeries> *list)
void DeclarativeBars::addSeries(QBar3DSeries *series)
{
- m_shared->addSeries(series);
+ m_barsController->addSeries(series);
}
void DeclarativeBars::removeSeries(QBar3DSeries *series)
{
- m_shared->removeSeries(series);
+ m_barsController->removeSeries(series);
series->setParent(this); // Reparent as removing will leave series parentless
}
diff --git a/src/datavisualizationqml2/declarativebars_p.h b/src/datavisualizationqml2/declarativebars_p.h
index 6db17788..4bfe3755 100644
--- a/src/datavisualizationqml2/declarativebars_p.h
+++ b/src/datavisualizationqml2/declarativebars_p.h
@@ -93,12 +93,8 @@ signals:
void barSpacingRelativeChanged(bool relative);
void meshFileNameChanged(QString filename);
-protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
-
private:
- Bars3DController *m_shared;
- QSize m_initialisedSize;
+ Bars3DController *m_barsController;
};
QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualizationqml2/declarativebarsrenderer.cpp b/src/datavisualizationqml2/declarativerenderer.cpp
index 3925e062..419ef74e 100644
--- a/src/datavisualizationqml2/declarativebarsrenderer.cpp
+++ b/src/datavisualizationqml2/declarativerenderer.cpp
@@ -16,42 +16,49 @@
**
****************************************************************************/
-#include "declarativebarsrenderer_p.h"
+#include "declarativerenderer_p.h"
#include <QtQuick/QQuickWindow>
#include <QtGui/QOpenGLFramebufferObject>
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-DeclarativeBarsRenderer::DeclarativeBarsRenderer(QQuickWindow *window, Bars3DController *renderer)
- : m_fbo(0),
- m_texture(0),
- m_window(window),
- m_barsRenderer(renderer)
+DeclarativeRenderer::DeclarativeRenderer(QQuickWindow *window, Abstract3DController *controller) :
+ m_fbo(0),
+ m_texture(0),
+ m_window(window),
+ m_controller(controller)
{
connect(m_window, &QQuickWindow::beforeSynchronizing, this,
- &DeclarativeBarsRenderer::synchDataToRenderer, Qt::DirectConnection);
+ &DeclarativeRenderer::synchDataToRenderer, Qt::DirectConnection);
connect(m_window, &QQuickWindow::beforeRendering, this,
- &DeclarativeBarsRenderer::renderFBO, Qt::DirectConnection);
- connect(m_barsRenderer, &Abstract3DController::needRender, m_window,
+ &DeclarativeRenderer::renderFBO, Qt::DirectConnection);
+ connect(m_controller, &Abstract3DController::needRender, m_window,
&QQuickWindow::update);
}
-DeclarativeBarsRenderer::~DeclarativeBarsRenderer()
+DeclarativeRenderer::~DeclarativeRenderer()
{
delete m_texture;
delete m_fbo;
}
-void DeclarativeBarsRenderer::synchDataToRenderer()
+void DeclarativeRenderer::synchDataToRenderer()
{
- m_barsRenderer->initializeOpenGL();
- m_barsRenderer->synchDataToRenderer();
+ m_controller->initializeOpenGL();
+ m_controller->synchDataToRenderer();
}
-void DeclarativeBarsRenderer::renderFBO()
+void DeclarativeRenderer::setDevicePixelRatio(float devicePixelRatio )
+{
+ m_devicePixelRatio = devicePixelRatio;
+}
+
+void DeclarativeRenderer::renderFBO()
{
QSize size = rect().size().toSize();
+ size.setWidth(size.width() * m_devicePixelRatio);
+ size.setHeight(size.height() * m_devicePixelRatio);
// Create FBO
if (!m_fbo) {
@@ -73,13 +80,12 @@ void DeclarativeBarsRenderer::renderFBO()
QSGGeometry::updateTexturedRectGeometry(geometry, rect(),
m_texture->convertToNormalizedSourceRect(sourceRect));
markDirty(DirtyMaterial);
- //qDebug() << "create node" << m_fbo->handle() << m_texture->textureId() << m_fbo->size();
}
- // Call the shared rendering function
+ // Call the graph rendering function
m_fbo->bind();
- m_barsRenderer->render(m_fbo->handle());
+ m_controller->render(m_fbo->handle());
m_fbo->release();
}
diff --git a/src/datavisualizationqml2/declarativebarsrenderer_p.h b/src/datavisualizationqml2/declarativerenderer_p.h
index 3be9b911..07d95c2c 100644
--- a/src/datavisualizationqml2/declarativebarsrenderer_p.h
+++ b/src/datavisualizationqml2/declarativerenderer_p.h
@@ -26,12 +26,12 @@
//
// We mean it.
-#ifndef DECLARATIVEBARSRENDERER_H
-#define DECLARATIVEBARSRENDERER_H
+#ifndef ABSTRACTDECLARATIVERENDERER_P_H
+#define ABSTRACTDECLARATIVERENDERER_P_H
#include "datavisualizationglobal_p.h"
-#include "bars3dcontroller_p.h"
-#include <qsgsimpletexturenode.h>
+#include <abstract3dcontroller_p.h>
+#include <QSGSimpleTextureNode>
class QOpenGLFramebufferObject;
class QSGTexture;
@@ -39,27 +39,28 @@ class QQuickWindow;
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-class DeclarativeBarsRenderer : public QObject, public QSGSimpleTextureNode
+class DeclarativeRenderer : public QObject, public QSGSimpleTextureNode
{
Q_OBJECT
-
public:
- DeclarativeBarsRenderer(QQuickWindow *window, Bars3DController *shared);
- ~DeclarativeBarsRenderer();
+ explicit DeclarativeRenderer(QQuickWindow *window, Abstract3DController *shared);
+ virtual ~DeclarativeRenderer();
public slots:
// Used to synch up data model from controller to renderer while main thread is locked
void synchDataToRenderer();
// Renders view to FBO before render cycle starts.
void renderFBO();
+ void setDevicePixelRatio(float devicePixelRatio);
private:
QOpenGLFramebufferObject *m_fbo;
QSGTexture *m_texture;
QQuickWindow *m_window;
- Bars3DController *m_barsRenderer;
+ Abstract3DController *m_controller;
+ float m_devicePixelRatio;
};
QT_DATAVISUALIZATION_END_NAMESPACE
-#endif
+#endif // ABSTRACTDECLARATIVERENDERER_P_H
diff --git a/src/datavisualizationqml2/declarativescatter.cpp b/src/datavisualizationqml2/declarativescatter.cpp
index 2848997f..40ef2926 100644
--- a/src/datavisualizationqml2/declarativescatter.cpp
+++ b/src/datavisualizationqml2/declarativescatter.cpp
@@ -17,15 +17,14 @@
****************************************************************************/
#include "declarativescatter_p.h"
-#include "declarativescatterrenderer_p.h"
+#include "declarativerenderer_p.h"
#include "qitemmodelscatterdataproxy.h"
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
DeclarativeScatter::DeclarativeScatter(QQuickItem *parent)
: AbstractDeclarative(parent),
- m_shared(0),
- m_initialisedSize(0, 0)
+ m_scatterController(0)
{
setFlags(QQuickItem::ItemHasContents);
setAcceptedMouseButtons(Qt::AllButtons);
@@ -35,66 +34,43 @@ DeclarativeScatter::DeclarativeScatter(QQuickItem *parent)
setSmooth(true);
// Create the shared component on the main GUI thread.
- m_shared = new Scatter3DController(boundingRect().toRect());
- setSharedController(m_shared);
+ m_scatterController = new Scatter3DController(boundingRect().toRect());
+ setSharedController(m_scatterController);
}
DeclarativeScatter::~DeclarativeScatter()
{
- delete m_shared;
-}
-
-QSGNode *DeclarativeScatter::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
-{
- // If old node exists and has right size, reuse it.
- if (oldNode && m_initialisedSize == boundingRect().size().toSize()) {
- // Update bounding rectangle (that has same size as before).
- static_cast<DeclarativeScatterRenderer *>( oldNode )->setRect(boundingRect());
- return oldNode;
- }
-
- // Create a new render node when size changes or if there is no node yet
- m_initialisedSize = boundingRect().size().toSize();
-
- // Delete old node
- if (oldNode)
- delete oldNode;
-
- // Create a new one and set it's bounding rectangle
- DeclarativeScatterRenderer *node = new DeclarativeScatterRenderer(window(), m_shared);
- node->setRect(boundingRect());
- m_shared->setBoundingRect(boundingRect().toRect());
- return node;
+ delete m_scatterController;
}
Q3DValueAxis *DeclarativeScatter::axisX() const
{
- return static_cast<Q3DValueAxis *>(m_shared->axisX());
+ return static_cast<Q3DValueAxis *>(m_scatterController->axisX());
}
void DeclarativeScatter::setAxisX(Q3DValueAxis *axis)
{
- m_shared->setAxisX(axis);
+ m_scatterController->setAxisX(axis);
}
Q3DValueAxis *DeclarativeScatter::axisY() const
{
- return static_cast<Q3DValueAxis *>(m_shared->axisY());
+ return static_cast<Q3DValueAxis *>(m_scatterController->axisY());
}
void DeclarativeScatter::setAxisY(Q3DValueAxis *axis)
{
- m_shared->setAxisY(axis);
+ m_scatterController->setAxisY(axis);
}
Q3DValueAxis *DeclarativeScatter::axisZ() const
{
- return static_cast<Q3DValueAxis *>(m_shared->axisZ());
+ return static_cast<Q3DValueAxis *>(m_scatterController->axisZ());
}
void DeclarativeScatter::setAxisZ(Q3DValueAxis *axis)
{
- m_shared->setAxisZ(axis);
+ m_scatterController->setAxisZ(axis);
}
QQmlListProperty<QScatter3DSeries> DeclarativeScatter::seriesList()
@@ -113,18 +89,18 @@ void DeclarativeScatter::appendSeriesFunc(QQmlListProperty<QScatter3DSeries> *li
int DeclarativeScatter::countSeriesFunc(QQmlListProperty<QScatter3DSeries> *list)
{
- return reinterpret_cast<DeclarativeScatter *>(list->data)->m_shared->scatterSeriesList().size();
+ return reinterpret_cast<DeclarativeScatter *>(list->data)->m_scatterController->scatterSeriesList().size();
}
QScatter3DSeries *DeclarativeScatter::atSeriesFunc(QQmlListProperty<QScatter3DSeries> *list, int index)
{
- return reinterpret_cast<DeclarativeScatter *>(list->data)->m_shared->scatterSeriesList().at(index);
+ return reinterpret_cast<DeclarativeScatter *>(list->data)->m_scatterController->scatterSeriesList().at(index);
}
void DeclarativeScatter::clearSeriesFunc(QQmlListProperty<QScatter3DSeries> *list)
{
DeclarativeScatter *declScatter = reinterpret_cast<DeclarativeScatter *>(list->data);
- QList<QScatter3DSeries *> realList = declScatter->m_shared->scatterSeriesList();
+ QList<QScatter3DSeries *> realList = declScatter->m_scatterController->scatterSeriesList();
int count = realList.size();
for (int i = 0; i < count; i++)
declScatter->removeSeries(realList.at(i));
@@ -132,12 +108,12 @@ void DeclarativeScatter::clearSeriesFunc(QQmlListProperty<QScatter3DSeries> *lis
void DeclarativeScatter::addSeries(QScatter3DSeries *series)
{
- m_shared->addSeries(series);
+ m_scatterController->addSeries(series);
}
void DeclarativeScatter::removeSeries(QScatter3DSeries *series)
{
- m_shared->removeSeries(series);
+ m_scatterController->removeSeries(series);
series->setParent(this); // Reparent as removing will leave series parentless
}
diff --git a/src/datavisualizationqml2/declarativescatter_p.h b/src/datavisualizationqml2/declarativescatter_p.h
index 7490deda..8445b3d6 100644
--- a/src/datavisualizationqml2/declarativescatter_p.h
+++ b/src/datavisualizationqml2/declarativescatter_p.h
@@ -75,11 +75,7 @@ signals:
void meshFileNameChanged(QString filename);
protected:
- Scatter3DController *m_shared;
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
-
-private:
- QSize m_initialisedSize;
+ Scatter3DController *m_scatterController;
};
QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualizationqml2/declarativescatterrenderer.cpp b/src/datavisualizationqml2/declarativescatterrenderer.cpp
deleted file mode 100644
index 39aaa22e..00000000
--- a/src/datavisualizationqml2/declarativescatterrenderer.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the QtDataVisualization module.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-**
-****************************************************************************/
-
-#include "declarativescatterrenderer_p.h"
-
-#include <QtQuick/QQuickWindow>
-#include <QtGui/QOpenGLFramebufferObject>
-
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-
-DeclarativeScatterRenderer::DeclarativeScatterRenderer(QQuickWindow *window,
- Scatter3DController *renderer)
- : m_fbo(0),
- m_texture(0),
- m_window(window),
- m_scatterRenderer(renderer)
-{
- connect(m_window, &QQuickWindow::beforeSynchronizing, this,
- &DeclarativeScatterRenderer::synchDataToRenderer, Qt::DirectConnection);
- connect(m_window, &QQuickWindow::beforeRendering, this,
- &DeclarativeScatterRenderer::renderFBO, Qt::DirectConnection);
- connect(m_scatterRenderer, &Abstract3DController::needRender, m_window,
- &QQuickWindow::update);
-}
-
-DeclarativeScatterRenderer::~DeclarativeScatterRenderer()
-{
- delete m_texture;
- delete m_fbo;
-}
-
-void DeclarativeScatterRenderer::synchDataToRenderer()
-{
- m_scatterRenderer->initializeOpenGL();
- m_scatterRenderer->synchDataToRenderer();
-}
-
-void DeclarativeScatterRenderer::renderFBO()
-{
- QSize size = rect().size().toSize();
-
- // Create FBO
- if (!m_fbo) {
- QOpenGLFramebufferObjectFormat format;
- format.setAttachment(QOpenGLFramebufferObject::Depth);
- m_fbo = new QOpenGLFramebufferObject(size, format);
- m_texture = m_window->createTextureFromId(m_fbo->texture(), size);
-
- setTexture(m_texture);
-
- // Flip texture
- // TODO: Can be gotten rid of once support for texture flipping becomes available (in Qt5.2)
- QSize ts = m_texture->textureSize();
- QRectF sourceRect(0, 0, ts.width(), ts.height());
- float tmp = sourceRect.top();
- sourceRect.setTop(sourceRect.bottom());
- sourceRect.setBottom(tmp);
- QSGGeometry *geometry = this->geometry();
- QSGGeometry::updateTexturedRectGeometry(geometry, rect(),
- m_texture->convertToNormalizedSourceRect(sourceRect));
- markDirty(DirtyMaterial);
- //qDebug() << "create node" << m_fbo->handle() << m_texture->textureId() << m_fbo->size();
- }
-
- // Call the shared rendering function
- m_fbo->bind();
-
- m_scatterRenderer->render(m_fbo->handle());
-
- m_fbo->release();
-}
-
-QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualizationqml2/declarativescatterrenderer_p.h b/src/datavisualizationqml2/declarativescatterrenderer_p.h
deleted file mode 100644
index 0bbd01ec..00000000
--- a/src/datavisualizationqml2/declarativescatterrenderer_p.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the QtDataVisualization module.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtDataVisualization API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef DECLARATIVESCATTERRENDERER_P_H
-#define DECLARATIVESCATTERRENDERER_P_H
-
-#include "datavisualizationglobal_p.h"
-#include "scatter3dcontroller_p.h"
-#include <qsgsimpletexturenode.h>
-
-class QOpenGLFramebufferObject;
-class QSGTexture;
-class QQuickWindow;
-
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-
-class DeclarativeScatterRenderer : public QObject, public QSGSimpleTextureNode
-{
- Q_OBJECT
-
-public:
- DeclarativeScatterRenderer(QQuickWindow *window, Scatter3DController *shared);
- ~DeclarativeScatterRenderer();
-
-public slots:
- // Used to synch up data model from controller to renderer while main thread is locked
- void synchDataToRenderer();
- // Renders view to FBO before render cycle starts.
- void renderFBO();
-
-private:
- QOpenGLFramebufferObject *m_fbo;
- QSGTexture *m_texture;
- QQuickWindow *m_window;
- Scatter3DController *m_scatterRenderer;
-};
-
-QT_DATAVISUALIZATION_END_NAMESPACE
-
-#endif
diff --git a/src/datavisualizationqml2/declarativesurface.cpp b/src/datavisualizationqml2/declarativesurface.cpp
index 8c50ab34..a450645f 100644
--- a/src/datavisualizationqml2/declarativesurface.cpp
+++ b/src/datavisualizationqml2/declarativesurface.cpp
@@ -17,7 +17,7 @@
****************************************************************************/
#include "declarativesurface_p.h"
-#include "declarativesurfacerenderer_p.h"
+#include "declarativerenderer_p.h"
#include "q3dvalueaxis.h"
#include "qitemmodelsurfacedataproxy.h"
@@ -25,8 +25,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE
DeclarativeSurface::DeclarativeSurface(QQuickItem *parent)
: AbstractDeclarative(parent),
- m_shared(0),
- m_initialisedSize(0, 0),
+ m_surfaceController(0),
m_gradient(0)
{
setFlags(QQuickItem::ItemHasContents);
@@ -37,13 +36,13 @@ DeclarativeSurface::DeclarativeSurface(QQuickItem *parent)
setSmooth(true);
// Create the shared component on the main GUI thread.
- m_shared = new Surface3DController(boundingRect().toRect());
- setSharedController(m_shared);
+ m_surfaceController = new Surface3DController(boundingRect().toRect());
+ setSharedController(m_surfaceController);
}
DeclarativeSurface::~DeclarativeSurface()
{
- delete m_shared;
+ delete m_surfaceController;
}
void DeclarativeSurface::handleGradientUpdate()
@@ -52,57 +51,34 @@ void DeclarativeSurface::handleGradientUpdate()
setControllerGradient(*m_gradient);
}
-QSGNode *DeclarativeSurface::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
-{
- // If old node exists and has right size, reuse it.
- if (oldNode && m_initialisedSize == boundingRect().size().toSize()) {
- // Update bounding rectangle (that has same size as before).
- static_cast<DeclarativeSurfaceRenderer *>( oldNode )->setRect(boundingRect());
- return oldNode;
- }
-
- // Create a new render node when size changes or if there is no node yet
- m_initialisedSize = boundingRect().size().toSize();
-
- // Delete old node
- if (oldNode)
- delete oldNode;
-
- // Create a new one and set its bounding rectangle
- DeclarativeSurfaceRenderer *node = new DeclarativeSurfaceRenderer(window(), m_shared);
- node->setRect(boundingRect());
- m_shared->setBoundingRect(boundingRect().toRect());
- return node;
-}
-
Q3DValueAxis *DeclarativeSurface::axisX() const
{
- return static_cast<Q3DValueAxis *>(m_shared->axisX());
+ return static_cast<Q3DValueAxis *>(m_surfaceController->axisX());
}
void DeclarativeSurface::setAxisX(Q3DValueAxis *axis)
{
- m_shared->setAxisX(axis);
+ m_surfaceController->setAxisX(axis);
}
Q3DValueAxis *DeclarativeSurface::axisY() const
{
- return static_cast<Q3DValueAxis *>(m_shared->axisY());
+ return static_cast<Q3DValueAxis *>(m_surfaceController->axisY());
}
void DeclarativeSurface::setAxisY(Q3DValueAxis *axis)
{
- m_shared->setAxisY(axis);
+ m_surfaceController->setAxisY(axis);
}
Q3DValueAxis *DeclarativeSurface::axisZ() const
{
- return static_cast<Q3DValueAxis *>(m_shared->axisZ());
+ return static_cast<Q3DValueAxis *>(m_surfaceController->axisZ());
}
void DeclarativeSurface::setAxisZ(Q3DValueAxis *axis)
{
- m_shared->setAxisZ(axis);
+ m_surfaceController->setAxisZ(axis);
}
void DeclarativeSurface::setGradient(ColorGradient *gradient)
@@ -144,7 +120,7 @@ void DeclarativeSurface::setControllerGradient(const ColorGradient &gradient)
}
newGradient.setStops(stops);
- m_shared->setGradient(newGradient);
+ m_surfaceController->setGradient(newGradient);
}
QQmlListProperty<QSurface3DSeries> DeclarativeSurface::seriesList()
@@ -163,18 +139,18 @@ void DeclarativeSurface::appendSeriesFunc(QQmlListProperty<QSurface3DSeries> *li
int DeclarativeSurface::countSeriesFunc(QQmlListProperty<QSurface3DSeries> *list)
{
- return reinterpret_cast<DeclarativeSurface *>(list->data)->m_shared->surfaceSeriesList().size();
+ return reinterpret_cast<DeclarativeSurface *>(list->data)->m_surfaceController->surfaceSeriesList().size();
}
QSurface3DSeries *DeclarativeSurface::atSeriesFunc(QQmlListProperty<QSurface3DSeries> *list, int index)
{
- return reinterpret_cast<DeclarativeSurface *>(list->data)->m_shared->surfaceSeriesList().at(index);
+ return reinterpret_cast<DeclarativeSurface *>(list->data)->m_surfaceController->surfaceSeriesList().at(index);
}
void DeclarativeSurface::clearSeriesFunc(QQmlListProperty<QSurface3DSeries> *list)
{
DeclarativeSurface *declSurface = reinterpret_cast<DeclarativeSurface *>(list->data);
- QList<QSurface3DSeries *> realList = declSurface->m_shared->surfaceSeriesList();
+ QList<QSurface3DSeries *> realList = declSurface->m_surfaceController->surfaceSeriesList();
int count = realList.size();
for (int i = 0; i < count; i++)
declSurface->removeSeries(realList.at(i));
@@ -182,12 +158,12 @@ void DeclarativeSurface::clearSeriesFunc(QQmlListProperty<QSurface3DSeries> *lis
void DeclarativeSurface::addSeries(QSurface3DSeries *series)
{
- m_shared->addSeries(series);
+ m_surfaceController->addSeries(series);
}
void DeclarativeSurface::removeSeries(QSurface3DSeries *series)
{
- m_shared->removeSeries(series);
+ m_surfaceController->removeSeries(series);
series->setParent(this); // Reparent as removing will leave series parentless
}
diff --git a/src/datavisualizationqml2/declarativesurface_p.h b/src/datavisualizationqml2/declarativesurface_p.h
index 600aeb98..4c7377be 100644
--- a/src/datavisualizationqml2/declarativesurface_p.h
+++ b/src/datavisualizationqml2/declarativesurface_p.h
@@ -80,14 +80,10 @@ public:
protected:
void handleGradientUpdate();
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
-
private:
- Surface3DController *m_shared;
-
void setControllerGradient(const ColorGradient &gradient);
- QSize m_initialisedSize;
+ Surface3DController *m_surfaceController;
ColorGradient *m_gradient; // Not owned
};
diff --git a/src/datavisualizationqml2/declarativesurfacerenderer.cpp b/src/datavisualizationqml2/declarativesurfacerenderer.cpp
deleted file mode 100644
index 87a290ce..00000000
--- a/src/datavisualizationqml2/declarativesurfacerenderer.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the QtDataVisualization module.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-**
-****************************************************************************/
-
-#include "declarativesurfacerenderer_p.h"
-
-#include <QtQuick/QQuickWindow>
-#include <QtGui/QOpenGLFramebufferObject>
-
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-
-DeclarativeSurfaceRenderer::DeclarativeSurfaceRenderer(QQuickWindow *window,
- Surface3DController *renderer)
- : m_fbo(0),
- m_texture(0),
- m_window(window),
- m_surfaceRenderer(renderer)
-{
- connect(m_window, &QQuickWindow::beforeSynchronizing, this,
- &DeclarativeSurfaceRenderer::synchDataToRenderer, Qt::DirectConnection);
- connect(m_window, &QQuickWindow::beforeRendering, this,
- &DeclarativeSurfaceRenderer::renderFBO, Qt::DirectConnection);
- connect(m_surfaceRenderer, &Abstract3DController::needRender, m_window,
- &QQuickWindow::update);
-}
-
-DeclarativeSurfaceRenderer::~DeclarativeSurfaceRenderer()
-{
- delete m_texture;
- delete m_fbo;
-}
-
-void DeclarativeSurfaceRenderer::synchDataToRenderer()
-{
- m_surfaceRenderer->initializeOpenGL();
- m_surfaceRenderer->synchDataToRenderer();
-}
-
-void DeclarativeSurfaceRenderer::renderFBO()
-{
- QSize size = rect().size().toSize();
-
- // Create FBO
- if (!m_fbo) {
- QOpenGLFramebufferObjectFormat format;
- format.setAttachment(QOpenGLFramebufferObject::Depth);
- m_fbo = new QOpenGLFramebufferObject(size, format);
- m_texture = m_window->createTextureFromId(m_fbo->texture(), size);
-
- setTexture(m_texture);
-
- // Flip texture
- // TODO: Can be gotten rid of once support for texture flipping becomes available (in Qt5.2)
- QSize ts = m_texture->textureSize();
- QRectF sourceRect(0, 0, ts.width(), ts.height());
- float tmp = sourceRect.top();
- sourceRect.setTop(sourceRect.bottom());
- sourceRect.setBottom(tmp);
- QSGGeometry *geometry = this->geometry();
- QSGGeometry::updateTexturedRectGeometry(geometry, rect(),
- m_texture->convertToNormalizedSourceRect(sourceRect));
- markDirty(DirtyMaterial);
- }
-
- // Call the shared rendering function
- m_fbo->bind();
-
- m_surfaceRenderer->render(m_fbo->handle());
-
- m_fbo->release();
-}
-
-QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualizationqml2/declarativesurfacerenderer_p.h b/src/datavisualizationqml2/declarativesurfacerenderer_p.h
deleted file mode 100644
index 09128f59..00000000
--- a/src/datavisualizationqml2/declarativesurfacerenderer_p.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the QtDataVisualization module.
-**
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtDataVisualization API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef DECLARATIVESURFACERENDERER_H
-#define DECLARATIVESURFACERENDERER_H
-
-#include "datavisualizationglobal_p.h"
-#include "surface3dcontroller_p.h"
-#include <qsgsimpletexturenode.h>
-
-class QOpenGLFramebufferObject;
-class QSGTexture;
-class QQuickWindow;
-
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
-
-class DeclarativeSurfaceRenderer : public QObject, public QSGSimpleTextureNode
-{
- Q_OBJECT
-
-public:
- DeclarativeSurfaceRenderer(QQuickWindow *window, Surface3DController *shared);
- ~DeclarativeSurfaceRenderer();
-
-public slots:
- // Used to synch up data model from controller to renderer while main thread is locked
- void synchDataToRenderer();
- // Renders view to FBO before render cycle starts.
- void renderFBO();
-
-private:
- QOpenGLFramebufferObject *m_fbo;
- QSGTexture *m_texture;
- QQuickWindow *m_window;
- Surface3DController *m_surfaceRenderer;
-};
-
-QT_DATAVISUALIZATION_END_NAMESPACE
-
-#endif