summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/bars3drenderer.cpp
diff options
context:
space:
mode:
authorSami Varanka <sami.varanka@qt.io>2021-06-10 12:45:14 +0300
committerSami Varanka <sami.varanka@qt.io>2021-06-11 12:37:25 +0300
commitd2543d8bbd27e9dd13698f457845adb0f5a6d428 (patch)
tree8622393e2f10ac350cc8a1b3f03c61912b69956d /src/datavisualization/engine/bars3drenderer.cpp
parent8691caff2b685aba4b1e83292de6c4d34775ec0b (diff)
Fix bargraph labels face wrong direction
When the camera's X rotation is 180.0f, the labels were rotated to face wrong direction. The axis title labels do not respect the Abstract3DAxis's titleFixed property. Created a new bugreport QTBUG-94441. Pick-to: 5.15 6.1 Fixes: QTBUG-90371 Change-Id: I80115b8b363a7385dfd2cb1f004a05368549ed48 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/datavisualization/engine/bars3drenderer.cpp')
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 952b235a..3f36f8d1 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -2051,10 +2051,14 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
glEnable(GL_POLYGON_OFFSET_FILL);
+ // If camera x rotation is 180, side labels face wrong direction
+ float activeCameraXRotation = (activeCamera->xRotation() >= 180.0f) ? -180.0f
+ : activeCamera->xRotation();
+
float labelAutoAngle = m_axisCacheY.labelAutoRotation();
float labelAngleFraction = labelAutoAngle / 90.0f;
float fractionCamY = activeCamera->yRotation() * labelAngleFraction;
- float fractionCamX = activeCamera->xRotation() * labelAngleFraction;
+ float fractionCamX = activeCameraXRotation * labelAngleFraction;
float labelsMaxWidth = 0.0f;
int startIndex;
@@ -2168,7 +2172,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
labelAutoAngle = m_axisCacheZ.labelAutoRotation();
labelAngleFraction = labelAutoAngle / 90.0f;
fractionCamY = activeCamera->yRotation() * labelAngleFraction;
- fractionCamX = activeCamera->xRotation() * labelAngleFraction;
+ fractionCamX = activeCameraXRotation * labelAngleFraction;
GLfloat labelYAdjustment = 0.005f;
GLfloat colPosValue = m_scaleXWithBackground + labelMargin;
GLfloat rowPosValue = m_scaleZWithBackground + labelMargin;
@@ -2293,7 +2297,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
labelAutoAngle = m_axisCacheX.labelAutoRotation();
labelAngleFraction = labelAutoAngle / 90.0f;
fractionCamY = activeCamera->yRotation() * labelAngleFraction;
- fractionCamX = activeCamera->xRotation() * labelAngleFraction;
+ fractionCamX = activeCameraXRotation * labelAngleFraction;
alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
if (labelAutoAngle == 0.0f) {
labelRotation = QVector3D(-90.0f, 90.0f, 0.0f);