summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-06-26 15:03:14 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-06-27 08:12:27 +0300
commita0196afc135d63f69aab5626424cc2e21ccac611 (patch)
treee712cfbcd3405ae8554fb39adbf6a6cc34bc3ac6 /src
parentf642e1c6eb37e50d52e2abf9289c98d953d42868 (diff)
Fix polar axis title positioning
Task-number: QTRD-3184 Change-Id: I366f41b928e06931784c6ff74e9b6b8a52414e3f Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp23
-rw-r--r--src/datavisualization/engine/abstract3drenderer_p.h3
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp23
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp23
4 files changed, 64 insertions, 8 deletions
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index f520e279..026795e9 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -74,7 +74,8 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
m_xRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -90.0f)),
m_yRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, -90.0f)),
m_zRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -90.0f)),
- m_xFlipRotation(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -180.0f))
+ m_xFlipRotation(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -180.0f)),
+ m_zFlipRotation(QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -180.0f))
{
QObject::connect(m_drawer, &Drawer::drawerChanged, this, &Abstract3DRenderer::updateTextures);
QObject::connect(this, &Abstract3DRenderer::needRender, controller,
@@ -662,10 +663,15 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
float labelsMaxWidth,
const QMatrix4x4 &viewMatrix,
const QMatrix4x4 &projectionMatrix,
- ShaderHelper *shader)
+ ShaderHelper *shader,
+ bool radial)
{
float scaleFactor = m_drawer->scaledFontSize() / m_axisCacheX.titleItem().size().height();
- float titleOffset = 2.0f * (labelMargin + (labelsMaxWidth * scaleFactor));
+ float titleOffset;
+ if (radial)
+ titleOffset = -2.0f * (labelMargin + m_drawer->scaledFontSize());
+ else
+ titleOffset = 2.0f * (labelMargin + (labelsMaxWidth * scaleFactor));
float zRotation = 0.0f;
float yRotation = 0.0f;
float xRotation = -90.0f + labelRotation.z();
@@ -712,6 +718,17 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
}
}
+ if (radial) {
+ if (m_zFlipped) {
+ titleOffset = -titleOffset;
+ } else {
+ if (m_yFlippedForGrid)
+ alignment = Qt::AlignTop;
+ else
+ alignment = Qt::AlignBottom;
+ }
+ }
+
if (offsetRotation == 180.0f || offsetRotation == -180.0f)
offsetRotation = 0.0f;
QQuaternion offsetRotator = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, offsetRotation);
diff --git a/src/datavisualization/engine/abstract3drenderer_p.h b/src/datavisualization/engine/abstract3drenderer_p.h
index ed26a4ec..254d61ca 100644
--- a/src/datavisualization/engine/abstract3drenderer_p.h
+++ b/src/datavisualization/engine/abstract3drenderer_p.h
@@ -190,7 +190,7 @@ protected:
const QQuaternion &totalRotation, AbstractRenderItem &dummyItem,
const Q3DCamera *activeCamera, float labelsMaxWidth,
const QMatrix4x4 &viewMatrix, const QMatrix4x4 &projectionMatrix,
- ShaderHelper *shader);
+ ShaderHelper *shader, bool radial = false);
void drawAxisTitleZ(const QVector3D &labelRotation, const QVector3D &labelTrans,
const QQuaternion &totalRotation, AbstractRenderItem &dummyItem,
const Q3DCamera *activeCamera, float labelsMaxWidth,
@@ -264,6 +264,7 @@ protected:
QQuaternion m_yRightAngleRotationNeg;
QQuaternion m_zRightAngleRotationNeg;
QQuaternion m_xFlipRotation;
+ QQuaternion m_zFlipRotation;
private:
friend class Abstract3DController;
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 31c3973b..86faca96 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -1580,7 +1580,14 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width()));
}
if (!drawSelection && m_axisCacheZ.isTitleVisible()) {
- labelTrans.setZ(0.0f);
+ if (m_polarGraph) {
+ float titleZ = -m_graphAspectRatio / 2.0f;
+ if (m_zFlipped)
+ titleZ = -titleZ;
+ labelTrans.setZ(titleZ);
+ } else {
+ labelTrans.setZ(0.0f);
+ }
drawAxisTitleZ(labelRotation, labelTrans, totalRotation, m_dummyRenderItem,
activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader);
}
@@ -1746,8 +1753,20 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
if (!drawSelection && m_axisCacheX.isTitleVisible()) {
labelTrans.setX(0.0f);
+ bool radial = false;
+ if (m_polarGraph) {
+ if (m_xFlipped == m_zFlipped)
+ totalRotation *= m_zRightAngleRotation;
+ else
+ totalRotation *= m_zRightAngleRotationNeg;
+ if (m_yFlippedForGrid)
+ totalRotation *= QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -180.0f);
+ labelTrans.setZ(-m_graphAspectRatio);
+ radial = true;
+ }
drawAxisTitleX(labelRotation, labelTrans, totalRotation, m_dummyRenderItem,
- activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader);
+ activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader,
+ radial);
}
}
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index cc1ac1ae..91aeb77f 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -1969,7 +1969,14 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width()));
}
if (!drawSelection && m_axisCacheZ.isTitleVisible()) {
- labelTrans.setZ(0.0f);
+ if (m_polarGraph) {
+ float titleZ = -m_graphAspectRatio / 2.0f;
+ if (m_zFlipped)
+ titleZ = -titleZ;
+ labelTrans.setZ(titleZ);
+ } else {
+ labelTrans.setZ(0.0f);
+ }
drawAxisTitleZ(labelRotation, labelTrans, totalRotation, m_dummyRenderItem,
activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader);
}
@@ -2139,8 +2146,20 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
if (!drawSelection && m_axisCacheX.isTitleVisible()) {
labelTrans.setX(0.0f);
+ bool radial = false;
+ if (m_polarGraph) {
+ if (m_xFlipped == m_zFlipped)
+ totalRotation *= m_zRightAngleRotation;
+ else
+ totalRotation *= m_zRightAngleRotationNeg;
+ if (m_yFlippedForGrid)
+ totalRotation *= QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -180.0f);
+ labelTrans.setZ(-m_graphAspectRatio);
+ radial = true;
+ }
drawAxisTitleX(labelRotation, labelTrans, totalRotation, m_dummyRenderItem,
- activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader);
+ activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader,
+ radial);
}
}
// Y Labels