summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-index.qdoc9
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp3
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp24
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp38
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp24
-rw-r--r--src/datavisualization/utils/scatterobjectbufferhelper.cpp62
-rw-r--r--src/datavisualization/utils/scatterpointbufferhelper.cpp28
7 files changed, 115 insertions, 73 deletions
diff --git a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
index d7c002e4..48efd49b 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
@@ -31,9 +31,16 @@
\li Interactive data: rotate, zoom, and highlight data using mouse or touch
\li Uses OpenGL for rendering the data
\li QML2 support
- \li Customizable axes for data - control viewable data window with axis ranges
+ \li Customizable axes for data
+ \list
+ \li Control viewable data window with axis ranges
+ \li Customize value axis grid lines and labels with axis formatters
+ \endlist
\li Customizable input handling
\li Customizable themes
+ \li Custom items and labels can be added to any graph
+ \li Ready-made data proxies to visualize data from Qt item models and height maps
+ \li Perspective and orthographic projections
\endlist
\section1 Getting Started
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 5d97a6ca..04ede782 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -640,8 +640,8 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
Qt::AlignmentFlag alignment = Qt::AlignTop;
if (m_yFlipped) {
alignment = Qt::AlignBottom;
+ zRotation = 180.0f;
if (m_zFlipped) {
- zRotation = 180.0f;
titleOffset = -titleOffset;
if (m_xFlipped) {
offsetRotation = -offsetRotation;
@@ -650,7 +650,6 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
xRotation = -90.0f - labelRotation.z();
}
} else {
- zRotation = 180.0f;
yRotation = 180.0f;
if (m_xFlipped) {
offsetRotation = -offsetRotation;
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 3805e760..689f3f5d 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -1951,11 +1951,12 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
endIndex = labelCount;
indexStep = 1;
}
+ float offsetValue = 0.0f;
for (int i = startIndex; i != endIndex; i = i + indexStep) {
backLabelTrans.setY(m_axisCacheY.labelPosition(i));
sideLabelTrans.setY(backLabelTrans.y());
- glPolygonOffset(GLfloat(i) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(i);
@@ -2008,15 +2009,16 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
QVector3D labelRotation;
if (labelAutoAngle == 0.0f) {
- labelRotation.setX(-90.0f);
if (m_zFlipped)
labelRotation.setY(180.0f);
if (m_yFlipped) {
if (m_zFlipped)
- labelRotation.setY(0.0f);
- else
labelRotation.setY(180.0f);
- labelRotation.setZ(180.0f);
+ else
+ labelRotation.setY(0.0f);
+ labelRotation.setX(90.0f);
+ } else {
+ labelRotation.setX(-90.0f);
}
} else {
if (m_zFlipped)
@@ -2079,6 +2081,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
endIndex = -1;
indexStep = -1;
}
+ offsetValue = 0.0f;
for (int row = startIndex; row != endIndex; row = row + indexStep) {
// Go through all rows and get position of max+1 or min-1 column, depending on x flip
// We need only positions for them, labels have already been generated
@@ -2088,7 +2091,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
else
colPos = colPosValue;
- glPolygonOffset(GLfloat(row) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
QVector3D labelPos = QVector3D(colPos,
labelYAdjustment, // raise a bit over background to avoid depth "glimmering"
@@ -2129,10 +2132,10 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
labelRotation.setY(-90.0f);
if (m_yFlipped) {
if (m_xFlipped)
- labelRotation.setY(90.0f);
- else
labelRotation.setY(-90.0f);
- labelRotation.setZ(180.0f);
+ else
+ labelRotation.setY(90.0f);
+ labelRotation.setX(90.0f);
}
} else {
if (m_xFlipped)
@@ -2197,6 +2200,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
endIndex = labelCount;
indexStep = 1;
}
+ offsetValue = 0.0f;
for (int column = startIndex; column != endIndex; column = column + indexStep) {
// Go through all columns and get position of max+1 or min-1 row, depending on z flip
// We need only positions for them, labels have already been generated
@@ -2206,7 +2210,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
else
rowPos = rowPosValue;
- glPolygonOffset(GLfloat(column) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
QVector3D labelPos = QVector3D((colPos - m_rowWidth) / m_scaleFactor,
labelYAdjustment, // raise a bit over background to avoid depth "glimmering"
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 21d86d03..dd50188b 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -444,6 +444,12 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
}
QVector3D modelScaler(itemSize, itemSize, itemSize);
+ if (!optimizationDefault
+ && ((drawingPoints && cache->bufferPoints()->indexCount() == 0)
+ || (!drawingPoints && cache->bufferObject()->indexCount() == 0))) {
+ continue;
+ }
+
int loopCount = 1;
if (optimizationDefault)
loopCount = renderArraySize;
@@ -709,6 +715,12 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#endif
QVector3D modelScaler(itemSize, itemSize, itemSize);
+ if (!optimizationDefault
+ && ((drawingPoints && cache->bufferPoints()->indexCount() == 0)
+ || (!drawingPoints && cache->bufferObject()->indexCount() == 0))) {
+ continue;
+ }
+
// Rebind shader if it has changed
if (drawingPoints != previousDrawingPoints
|| (!drawingPoints &&
@@ -920,7 +932,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
if (!drawingPoints) {
glEnable(GL_POLYGON_OFFSET_FILL);
- glPolygonOffset(-0.5f, 1.0f);
+ glPolygonOffset(-1.0f, 1.0f);
}
#if !defined(QT_OPENGL_ES_2)
@@ -1536,15 +1548,16 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
if (m_yFlipped)
labelYTrans = -labelYTrans;
if (labelAutoAngle == 0.0f) {
- labelRotation.setX(-90.0f);
if (m_zFlipped)
labelRotation.setY(180.0f);
if (m_yFlipped) {
if (m_zFlipped)
- labelRotation.setY(0.0f);
- else
labelRotation.setY(180.0f);
- labelRotation.setZ(180.0f);
+ else
+ labelRotation.setY(0.0f);
+ labelRotation.setX(90.0f);
+ } else {
+ labelRotation.setX(-90.0f);
}
} else {
if (m_zFlipped)
@@ -1606,10 +1619,11 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
endIndex = -1;
indexStep = -1;
}
+ float offsetValue = 0.0f;
for (int label = startIndex; label != endIndex; label = label + indexStep) {
labelTrans.setZ(m_axisCacheZ.labelPosition(label));
- glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
// Draw the label here
m_dummyRenderItem.setTranslation(labelTrans);
@@ -1663,10 +1677,10 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelRotation.setY(-90.0f);
if (m_yFlipped) {
if (m_xFlipped)
- labelRotation.setY(90.0f);
- else
labelRotation.setY(-90.0f);
- labelRotation.setZ(180.0f);
+ else
+ labelRotation.setY(90.0f);
+ labelRotation.setX(90.0f);
}
} else {
if (m_xFlipped)
@@ -1731,10 +1745,11 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
endIndex = labelCount;
indexStep = 1;
}
+ float offsetValue = 0.0f;
for (int label = startIndex; label != endIndex; label = label + indexStep) {
labelTrans.setX(m_axisCacheX.labelPosition(label));
- glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
// Draw the label here
m_dummyRenderItem.setTranslation(labelTrans);
@@ -1836,11 +1851,12 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
endIndex = labelCount;
indexStep = 1;
}
+ float offsetValue = 0.0f;
for (int label = startIndex; label != endIndex; label = label + indexStep) {
const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(label);
const GLfloat labelYTrans = m_axisCacheY.labelPosition(label);
- glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
if (drawSelection) {
QVector4D labelColor = QVector4D(0.0f, 0.0f, label / 255.0f,
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 12627966..e4dfebfc 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -1838,15 +1838,16 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
if (m_yFlipped)
labelYTrans = -labelYTrans;
if (labelAutoAngle == 0.0f) {
- labelRotation.setX(-90.0f);
if (m_zFlipped)
labelRotation.setY(180.0f);
if (m_yFlipped) {
if (m_zFlipped)
- labelRotation.setY(0.0f);
- else
labelRotation.setY(180.0f);
- labelRotation.setZ(180.0f);
+ else
+ labelRotation.setY(0.0f);
+ labelRotation.setX(90.0f);
+ } else {
+ labelRotation.setX(-90.0f);
}
} else {
if (m_zFlipped)
@@ -1913,8 +1914,9 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
endIndex = -1;
indexStep = -1;
}
+ float offsetValue = 0.0f;
for (int label = startIndex; label != endIndex; label = label + indexStep) {
- glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
// Draw the label here
labelTrans.setZ(m_axisCacheZ.labelPosition(label));
m_dummyRenderItem.setTranslation(labelTrans);
@@ -1961,10 +1963,10 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelRotation.setY(-90.0f);
if (m_yFlipped) {
if (m_xFlipped)
- labelRotation.setY(90.0f);
- else
labelRotation.setY(-90.0f);
- labelRotation.setZ(180.0f);
+ else
+ labelRotation.setY(90.0f);
+ labelRotation.setX(90.0f);
}
} else {
if (m_xFlipped)
@@ -2032,8 +2034,9 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
endIndex = labelCount;
indexStep = 1;
}
+ float offsetValue = 0.0f;
for (int label = startIndex; label != endIndex; label = label + indexStep) {
- glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
// Draw the label here
labelTrans.setX(m_axisCacheX.labelPosition(label));
m_dummyRenderItem.setTranslation(labelTrans);
@@ -2125,11 +2128,12 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
endIndex = labelCount;
indexStep = 1;
}
+ float offsetValue = 0.0f;
for (int label = startIndex; label != endIndex; label = label + indexStep) {
const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(label);
const GLfloat labelYTrans = m_axisCacheY.labelPosition(label);
- glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
+ glPolygonOffset(offsetValue++ / -10.0f, 1.0f);
if (drawSelection) {
QVector4D labelColor = QVector4D(0.0f, 0.0f, label / 255.0f,
diff --git a/src/datavisualization/utils/scatterobjectbufferhelper.cpp b/src/datavisualization/utils/scatterobjectbufferhelper.cpp
index 123588f1..d68b9df4 100644
--- a/src/datavisualization/utils/scatterobjectbufferhelper.cpp
+++ b/src/datavisualization/utils/scatterobjectbufferhelper.cpp
@@ -38,12 +38,16 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal
{
initializeOpenGLFunctions();
+ m_meshDataLoaded = false;
+ m_indexCount = 0;
+
ObjectHelper *dotObj = cache->object();
ScatterRenderItemArray &renderArray = cache->renderArray();
const uint renderArraySize = renderArray.size();
+ if (renderArraySize == 0)
+ return; // No use to go forward
uint itemCount = renderArraySize;
QQuaternion seriesRotation(cache->meshRotation());
-
if (m_meshDataLoaded) {
// Delete old data
glDeleteBuffers(1, &m_vertexbuffer);
@@ -51,7 +55,6 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal
glDeleteBuffers(1, &m_normalbuffer);
glDeleteBuffers(1, &m_elementbuffer);
}
-
// Index vertices
const QVector<unsigned short> indices = dotObj->indices();
const QVector<QVector3D> indexed_vertices = dotObj->indexedvertices();
@@ -89,6 +92,7 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal
buffered_uvs.resize(uvsCount * renderArraySize);
buffered_normals.resize(normalsCount * renderArraySize);
uint pos = 0;
+
for (uint i = 0; i < renderArraySize; i++) {
ScatterRenderItem &item = renderArray[i];
if (!item.isVisible()) {
@@ -130,32 +134,34 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal
m_indexCount = indicesCount * itemCount;
- glGenBuffers(1, &m_vertexbuffer);
- glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
- glBufferData(GL_ARRAY_BUFFER, verticeCount * itemCount * sizeof(QVector3D),
- &buffered_vertices.at(0),
- GL_STATIC_DRAW);
-
- glGenBuffers(1, &m_normalbuffer);
- glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
- glBufferData(GL_ARRAY_BUFFER, normalsCount * itemCount * sizeof(QVector3D),
- &buffered_normals.at(0),
- GL_STATIC_DRAW);
-
- glGenBuffers(1, &m_uvbuffer);
- glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
- glBufferData(GL_ARRAY_BUFFER, uvsCount * itemCount * sizeof(QVector2D),
- &buffered_uvs.at(0), GL_STATIC_DRAW);
-
- glGenBuffers(1, &m_elementbuffer);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesCount * itemCount * sizeof(GLint),
- &buffered_indices.at(0), GL_STATIC_DRAW);
-
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
- m_meshDataLoaded = true;
+ if (itemCount > 0) {
+ glGenBuffers(1, &m_vertexbuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
+ glBufferData(GL_ARRAY_BUFFER, verticeCount * itemCount * sizeof(QVector3D),
+ &buffered_vertices.at(0),
+ GL_STATIC_DRAW);
+
+ glGenBuffers(1, &m_normalbuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
+ glBufferData(GL_ARRAY_BUFFER, normalsCount * itemCount * sizeof(QVector3D),
+ &buffered_normals.at(0),
+ GL_STATIC_DRAW);
+
+ glGenBuffers(1, &m_uvbuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
+ glBufferData(GL_ARRAY_BUFFER, uvsCount * itemCount * sizeof(QVector2D),
+ &buffered_uvs.at(0), GL_STATIC_DRAW);
+
+ glGenBuffers(1, &m_elementbuffer);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesCount * itemCount * sizeof(GLint),
+ &buffered_indices.at(0), GL_STATIC_DRAW);
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ m_meshDataLoaded = true;
+ }
}
void ScatterObjectBufferHelper::update(ScatterSeriesRenderCache *cache, qreal dotScale)
diff --git a/src/datavisualization/utils/scatterpointbufferhelper.cpp b/src/datavisualization/utils/scatterpointbufferhelper.cpp
index 0f290aeb..b14d84ad 100644
--- a/src/datavisualization/utils/scatterpointbufferhelper.cpp
+++ b/src/datavisualization/utils/scatterpointbufferhelper.cpp
@@ -20,7 +20,6 @@
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
-const GLfloat itemScaler = 3.0f;
const QVector3D hiddenPos(-1000.0f, -1000.0f, -1000.0f);
ScatterPointBufferHelper::ScatterPointBufferHelper()
@@ -82,6 +81,7 @@ void ScatterPointBufferHelper::load(ScatterSeriesRenderCache *cache)
ScatterRenderItemArray &renderArray = cache->renderArray();
const int renderArraySize = renderArray.size();
+ m_indexCount = 0;
if (m_meshDataLoaded) {
// Delete old data
@@ -89,25 +89,31 @@ void ScatterPointBufferHelper::load(ScatterSeriesRenderCache *cache)
m_bufferedPoints.clear();
}
+ bool itemsVisible = false;
m_bufferedPoints.resize(renderArraySize);
for (int i = 0; i < renderArraySize; i++) {
ScatterRenderItem &item = renderArray[i];
- if (!item.isVisible())
+ if (!item.isVisible()) {
m_bufferedPoints[i] = hiddenPos;
- else
+ } else {
+ itemsVisible = true;
m_bufferedPoints[i] = item.translation();
+ }
}
- m_indexCount = renderArraySize;
+ if (itemsVisible)
+ m_indexCount = renderArraySize;
- glGenBuffers(1, &m_pointbuffer);
- glBindBuffer(GL_ARRAY_BUFFER, m_pointbuffer);
- glBufferData(GL_ARRAY_BUFFER, m_bufferedPoints.size() * sizeof(QVector3D),
- &m_bufferedPoints.at(0),
- GL_DYNAMIC_DRAW);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
+ if (m_indexCount > 0) {
+ glGenBuffers(1, &m_pointbuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, m_pointbuffer);
+ glBufferData(GL_ARRAY_BUFFER, m_bufferedPoints.size() * sizeof(QVector3D),
+ &m_bufferedPoints.at(0),
+ GL_DYNAMIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
- m_meshDataLoaded = true;
+ m_meshDataLoaded = true;
+ }
}
QT_END_NAMESPACE_DATAVISUALIZATION