diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-09-29 15:14:25 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-09-30 10:08:14 +0300 |
commit | 6821c16e36a7454627ac9a18cd1d8b0f0bd9246f (patch) | |
tree | c2b1197792f511dc53393fc8372fc2bc0852a958 /src/datavisualization/engine/bars3drenderer.cpp | |
parent | 084010113485262ad4495e0af2d57ad3aa0fcf7e (diff) |
Make background margin configurable
Added margin as abstract graph property.
If the margin is narrow, the positions of theedge labels of the axes
are adjusted to avoid overlap with edge labels on other axes.
Task-number: QTRD-3204
Change-Id: I7fa5a04c8f2091519d99689ef2f6cbcf799fb15e
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/engine/bars3drenderer.cpp')
-rw-r--r-- | src/datavisualization/engine/bars3drenderer.cpp | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp index 2d394d57..47c9b84c 100644 --- a/src/datavisualization/engine/bars3drenderer.cpp +++ b/src/datavisualization/engine/bars3drenderer.cpp @@ -1702,7 +1702,8 @@ void Bars3DRenderer::drawBackground(GLfloat backgroundRotation, QMatrix4x4 MVPMatrix; QMatrix4x4 itModelMatrix; - QVector3D backgroundScaler(m_xScaleFactor, 1.0f, m_zScaleFactor); + QVector3D backgroundScaler(m_scaleXWithBackground, m_scaleYWithBackground, + m_scaleZWithBackground); QVector4D backgroundColor = Utils::vectorFromColor(m_cachedTheme->backgroundColor()); if (m_reflectionEnabled) backgroundColor.setW(backgroundColor.w() * m_reflectivity); @@ -1845,7 +1846,7 @@ void Bars3DRenderer::drawGridLines(const QMatrix4x4 &depthProjectionViewMatrix, if (m_yFlipped) yFloorLinePosition = -yFloorLinePosition; - QVector3D gridLineScaler(m_xScaleFactor, gridLineWidth, gridLineWidth); + QVector3D gridLineScaler(m_scaleXWithBackground, gridLineWidth, gridLineWidth); if (m_yFlipped) lineRotation = m_xRightAngleRotation; @@ -1894,7 +1895,7 @@ void Bars3DRenderer::drawGridLines(const QMatrix4x4 &depthProjectionViewMatrix, #if defined(QT_OPENGL_ES_2) lineRotation = m_yRightAngleRotation; #endif - gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, m_zScaleFactor); + gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, m_scaleZWithBackground); for (GLfloat bar = 0.0f; bar <= m_cachedColumnCount; bar++) { QMatrix4x4 modelMatrix; QMatrix4x4 MVPMatrix; @@ -1936,11 +1937,11 @@ void Bars3DRenderer::drawGridLines(const QMatrix4x4 &depthProjectionViewMatrix, // Wall lines: back wall int gridLineCount = m_axisCacheY.gridLineCount(); - GLfloat zWallLinePosition = -m_zScaleFactor + gridLineOffset; + GLfloat zWallLinePosition = -m_scaleZWithBackground + gridLineOffset; if (m_zFlipped) zWallLinePosition = -zWallLinePosition; - gridLineScaler = QVector3D(m_xScaleFactor, gridLineWidth, gridLineWidth); + gridLineScaler = QVector3D(m_scaleXWithBackground, gridLineWidth, gridLineWidth); for (int line = 0; line < gridLineCount; line++) { QMatrix4x4 modelMatrix; QMatrix4x4 MVPMatrix; @@ -1981,7 +1982,7 @@ void Bars3DRenderer::drawGridLines(const QMatrix4x4 &depthProjectionViewMatrix, } // Wall lines: side wall - GLfloat xWallLinePosition = -m_xScaleFactor + gridLineOffset; + GLfloat xWallLinePosition = -m_scaleXWithBackground + gridLineOffset; if (m_xFlipped) xWallLinePosition = -xWallLinePosition; @@ -1990,7 +1991,7 @@ void Bars3DRenderer::drawGridLines(const QMatrix4x4 &depthProjectionViewMatrix, else lineRotation = m_yRightAngleRotation; - gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, m_zScaleFactor); + gridLineScaler = QVector3D(gridLineWidth, gridLineWidth, m_scaleZWithBackground); for (int line = 0; line < gridLineCount; line++) { QMatrix4x4 modelMatrix; QMatrix4x4 MVPMatrix; @@ -2064,8 +2065,8 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer int labelCount = m_axisCacheY.labelCount(); GLfloat labelMarginXTrans = labelMargin; GLfloat labelMarginZTrans = labelMargin; - GLfloat labelXTrans = m_xScaleFactor; - GLfloat labelZTrans = m_zScaleFactor; + GLfloat labelXTrans = m_scaleXWithBackground; + GLfloat labelZTrans = m_scaleZWithBackground; QVector3D backLabelRotation(0.0f, -90.0f, 0.0f); QVector3D sideLabelRotation(0.0f, 0.0f, 0.0f); Qt::AlignmentFlag backAlignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight; @@ -2169,10 +2170,8 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer fractionCamY = activeCamera->yRotation() * labelAngleFraction; fractionCamX = activeCamera->xRotation() * labelAngleFraction; GLfloat labelYAdjustment = 0.005f; - GLfloat scaledRowWidth = m_xScaleFactor; - GLfloat scaledColumnDepth = m_zScaleFactor; - GLfloat colPosValue = scaledRowWidth + labelMargin; - GLfloat rowPosValue = scaledColumnDepth + labelMargin; + GLfloat colPosValue = m_scaleXWithBackground + labelMargin; + GLfloat rowPosValue = m_scaleZWithBackground + labelMargin; GLfloat rowPos = 0.0f; GLfloat colPos = 0.0f; Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight; @@ -2599,6 +2598,18 @@ void Bars3DRenderer::calculateSceneScalingFactors() m_xScaleFactor = m_rowWidth / m_scaleFactor; m_zScaleFactor = m_columnDepth / m_scaleFactor; + if (m_requestedMargin < 0.0f) { + m_hBackgroundMargin = 0.0f; + m_vBackgroundMargin = 0.0f; + } else { + m_hBackgroundMargin = m_requestedMargin; + m_vBackgroundMargin = m_requestedMargin; + } + + m_scaleXWithBackground = m_xScaleFactor + m_hBackgroundMargin; + m_scaleYWithBackground = 1.0f + m_vBackgroundMargin; + m_scaleZWithBackground = m_zScaleFactor + m_hBackgroundMargin; + updateCameraViewport(); updateCustomItemPositions(); } @@ -2858,4 +2869,10 @@ void Bars3DRenderer::updateFloorLevel(float level) calculateHeightAdjustment(); } +void Bars3DRenderer::updateMargin(float margin) +{ + Abstract3DRenderer::updateMargin(margin); + calculateSceneScalingFactors(); +} + QT_END_NAMESPACE_DATAVISUALIZATION |