From a94f9816a9bae2baea38681096a209bf3839a883 Mon Sep 17 00:00:00 2001 From: Sami Varanka Date: Thu, 10 Jun 2021 12:45:14 +0300 Subject: Fix bargraph labels face wrong direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Fixes: QTBUG-90371 Change-Id: I80115b8b363a7385dfd2cb1f004a05368549ed48 Reviewed-by: Tomi Korpipää (cherry picked from commit d2543d8bbd27e9dd13698f457845adb0f5a6d428) Reviewed-by: Qt Cherry-pick Bot --- src/datavisualization/engine/bars3drenderer.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp index 329f5666..6107e7a1 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); -- cgit v1.2.3