From a1293a58e0909d56e34654549ba719bacfdda1bb Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 30 Jun 2014 10:33:33 +0300 Subject: Added horizontal aspect ratio property for abstract graphs Value 0.0 indicates automatic scaling (the default). Task-number: QTRD-3192 Change-Id: I5e4cc1b7a03c0ba811e2ed3916a440906429af57 Reviewed-by: Mika Salmela --- src/datavisualization/engine/surface3drenderer.cpp | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/datavisualization/engine/surface3drenderer.cpp') diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 50104a93..c1a23493 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -2399,17 +2399,26 @@ void Surface3DRenderer::calculateSceneScalingFactors() // Calculate scene scaling and translation factors m_heightNormalizer = GLfloat(m_axisCacheY.max() - m_axisCacheY.min()); + + float horizontalAspectRatio; + if (m_polarGraph) + horizontalAspectRatio = 1.0f; + else + horizontalAspectRatio = m_graphHorizontalAspectRatio; + QSizeF areaSize; - areaSize.setHeight(m_axisCacheZ.max() - m_axisCacheZ.min()); - areaSize.setWidth(m_axisCacheX.max() - m_axisCacheX.min()); - float scaleFactor = qMax(areaSize.width(), areaSize.height()); - if (m_polarGraph) { - m_scaleX = m_graphAspectRatio; - m_scaleZ = m_graphAspectRatio; + if (horizontalAspectRatio == 0.0f) { + areaSize.setHeight(m_axisCacheZ.max() - m_axisCacheZ.min()); + areaSize.setWidth(m_axisCacheX.max() - m_axisCacheX.min()); } else { - m_scaleX = m_graphAspectRatio * areaSize.width() / scaleFactor; - m_scaleZ = m_graphAspectRatio * areaSize.height() / scaleFactor; + areaSize.setHeight(1.0f); + areaSize.setWidth(horizontalAspectRatio); } + + float scaleFactor = qMax(areaSize.width(), areaSize.height()); + m_scaleX = m_graphAspectRatio * areaSize.width() / scaleFactor; + m_scaleZ = m_graphAspectRatio * areaSize.height() / scaleFactor; + m_scaleXWithBackground = m_scaleX + m_hBackgroundMargin; m_scaleZWithBackground = m_scaleZ + m_hBackgroundMargin; m_scaleYWithBackground = m_vBackgroundMargin + 1.0f; -- cgit v1.2.3