summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/abstract3drenderer.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-06-25 13:00:55 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-06-26 10:43:39 +0300
commit36417dd3660f75c34328c3420bdd512436da86ff (patch)
treeb940d98d8df6a8a64adc1a638c57f20a4a955c5b /src/datavisualization/engine/abstract3drenderer.cpp
parentec195a34594dea6145af5e8f2fedc2f9401d0f14 (diff)
Add flipHorizontalGrid property for surface
This property allows drawind the horizontal grid and axis labels on top of the graph rather than on the bottom. This is useful when surface graph is used for 2D spectrograms in orthographic mode, as otherwise the grid is covered by the surface itself. Particularly relevant for polar plots of the same. Task-number: QTRD-3184 Change-Id: I9dbcdbfc754e13af52d2cf31a1d9991ef4b241f7 Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/datavisualization/engine/abstract3drenderer.cpp')
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 56a5ba60..f7cb5499 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -61,6 +61,7 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
m_xFlipped(false),
m_yFlipped(false),
m_zFlipped(false),
+ m_yFlippedForGrid(false),
m_backgroundObj(0),
m_gridLineObj(0),
m_labelObj(0),
@@ -665,7 +666,7 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
float offsetRotation = labelRotation.z();
float extraRotation = -90.0f;
Qt::AlignmentFlag alignment = Qt::AlignTop;
- if (m_yFlipped) {
+ if (m_yFlippedForGrid) {
alignment = Qt::AlignBottom;
zRotation = 180.0f;
if (m_zFlipped) {
@@ -745,7 +746,7 @@ void Abstract3DRenderer::drawAxisTitleZ(const QVector3D &labelRotation,
float xRotation = -90.0f;
float extraRotation = 90.0f;
Qt::AlignmentFlag alignment = Qt::AlignTop;
- if (m_yFlipped) {
+ if (m_yFlippedForGrid) {
alignment = Qt::AlignBottom;
xRotation = -xRotation;
if (m_zFlipped) {
@@ -1185,6 +1186,10 @@ void Abstract3DRenderer::drawRadialGrid(ShaderHelper *shader, float yFloorLinePo
const QVector<float> &subGridPositions = m_axisCacheZ.formatter()->subGridPositions();
int mainSize = gridPositions.size();
QVector3D translateVector(0.0f, yFloorLinePos, 0.0f);
+ QQuaternion finalRotation = m_xRightAngleRotationNeg;
+ if (m_yFlippedForGrid)
+ finalRotation *= m_xFlipRotation;
+
for (int i = 0; i < gridLineCount; i++) {
float gridPosition = (i >= mainSize)
? subGridPositions.at(i - mainSize) : gridPositions.at(i);
@@ -1200,8 +1205,8 @@ void Abstract3DRenderer::drawRadialGrid(ShaderHelper *shader, float yFloorLinePo
modelMatrix.translate(translateVector);
modelMatrix.scale(gridLineScaler);
itModelMatrix.scale(gridLineScaler);
- modelMatrix.rotate(m_xRightAngleRotationNeg);
- itModelMatrix.rotate(m_xRightAngleRotationNeg);
+ modelMatrix.rotate(finalRotation);
+ itModelMatrix.rotate(finalRotation);
QMatrix4x4 MVPMatrix = projectionViewMatrix * modelMatrix;
shader->setUniformValue(shader->model(), modelMatrix);
@@ -1229,13 +1234,16 @@ void Abstract3DRenderer::drawAngularGrid(ShaderHelper *shader, float yFloorLineP
const QMatrix4x4 &projectionViewMatrix,
const QMatrix4x4 &depthMatrix)
{
- float halfRatio(m_graphAspectRatio / 2.0f);
+ float halfRatio((m_graphAspectRatio + (labelMargin / 2.0f)) / 2.0f);
QVector3D gridLineScaler(gridLineWidth, gridLineWidth, halfRatio);
int gridLineCount = m_axisCacheX.gridLineCount();
const QVector<float> &gridPositions = m_axisCacheX.formatter()->gridPositions();
const QVector<float> &subGridPositions = m_axisCacheX.formatter()->subGridPositions();
int mainSize = gridPositions.size();
QVector3D translateVector(0.0f, yFloorLinePos, -halfRatio);
+ QQuaternion finalRotation = m_xRightAngleRotationNeg;
+ if (m_yFlippedForGrid)
+ finalRotation *= m_xFlipRotation;
for (int i = 0; i < gridLineCount; i++) {
QMatrix4x4 modelMatrix;
QMatrix4x4 itModelMatrix;
@@ -1247,8 +1255,8 @@ void Abstract3DRenderer::drawAngularGrid(ShaderHelper *shader, float yFloorLineP
modelMatrix.translate(translateVector);
modelMatrix.scale(gridLineScaler);
itModelMatrix.scale(gridLineScaler);
- modelMatrix.rotate(m_xRightAngleRotationNeg);
- itModelMatrix.rotate(m_xRightAngleRotationNeg);
+ modelMatrix.rotate(finalRotation);
+ itModelMatrix.rotate(finalRotation);
QMatrix4x4 MVPMatrix = projectionViewMatrix * modelMatrix;
shader->setUniformValue(shader->model(), modelMatrix);