diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-05-27 11:36:44 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-05-28 08:56:23 +0300 |
commit | f48233015f5b3694002a456b9db61d3e58541c5c (patch) | |
tree | 9ad4b734c3797dce0a9f40d660051f4667fc1910 /src/datavisualization/engine/surface3drenderer.cpp | |
parent | d9cb05d0f46efc58e508c233a3c67542a4c177fa (diff) |
Fix labels transparency within each axis
Task-number: QTRD-3141
Change-Id: I8ca51b411e2d92e0c615c81d215d89575d614acd
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/engine/surface3drenderer.cpp')
-rw-r--r-- | src/datavisualization/engine/surface3drenderer.cpp | 161 |
1 files changed, 90 insertions, 71 deletions
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index 83bf738c..6fc0aec1 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -1830,11 +1830,14 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa float fractionCamX = activeCamera->xRotation() * labelAngleFraction; float labelsMaxWidth = 0.0f; + int startIndex; + int endIndex; + int indexStep; + // Z Labels QVector3D positionZComp(0.0f, 0.0f, 0.0f); if (m_axisCacheZ.segmentCount() > 0) { int labelCount = m_axisCacheZ.labelCount(); - int labelNbr = 0; GLfloat labelXTrans = m_scaleXWithBackground + labelMargin; GLfloat labelYTrans = -backgroundMargin; Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight; @@ -1910,27 +1913,33 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa labelYTrans, 0.0f); - for (int label = 0; label < labelCount; label++) { - if (m_axisCacheZ.labelItems().size() > labelNbr) { - glPolygonOffset(GLfloat(label) / -10.0f, 1.0f); - // Draw the label here - labelTrans.setZ(m_axisCacheZ.labelPosition(label)); - m_dummyRenderItem.setTranslation(labelTrans); - const LabelItem &axisLabelItem = *m_axisCacheZ.labelItems().at(labelNbr); - - if (drawSelection) { - QVector4D labelColor = QVector4D(label / 255.0f, 0.0f, 0.0f, - alphaForRowSelection); - shader->setUniformValue(shader->color(), labelColor); - } + if (m_zFlipped) { + startIndex = 0; + endIndex = labelCount; + indexStep = 1; + } else { + startIndex = labelCount - 1; + endIndex = -1; + indexStep = -1; + } + for (int label = startIndex; label != endIndex; label = label + indexStep) { + glPolygonOffset(GLfloat(label) / -10.0f, 1.0f); + // Draw the label here + labelTrans.setZ(m_axisCacheZ.labelPosition(label)); + m_dummyRenderItem.setTranslation(labelTrans); + const LabelItem &axisLabelItem = *m_axisCacheZ.labelItems().at(label); - m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix, - positionZComp, totalRotation, 0, m_cachedSelectionMode, - shader, m_labelObj, activeCamera, - true, true, Drawer::LabelMid, alignment, false, drawSelection); - labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width())); + if (drawSelection) { + QVector4D labelColor = QVector4D(label / 255.0f, 0.0f, 0.0f, + alphaForRowSelection); + shader->setUniformValue(shader->color(), labelColor); } - labelNbr++; + + m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix, + positionZComp, totalRotation, 0, m_cachedSelectionMode, + shader, m_labelObj, activeCamera, + true, true, Drawer::LabelMid, alignment, false, drawSelection); + labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width())); } if (!drawSelection && m_axisCacheZ.isTitleVisible()) { labelTrans.setZ(0.0f); @@ -1947,7 +1956,6 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa fractionCamX = activeCamera->xRotation() * labelAngleFraction; int labelCount = m_axisCacheX.labelCount(); - int labelNbr = 0; GLfloat labelZTrans = m_scaleZWithBackground + labelMargin; GLfloat labelYTrans = -backgroundMargin; Qt::AlignmentFlag alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight; @@ -2024,27 +2032,33 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa labelYTrans, labelZTrans); - for (int label = 0; label < labelCount; label++) { - if (m_axisCacheX.labelItems().size() > labelNbr) { - glPolygonOffset(GLfloat(label) / -10.0f, 1.0f); - // Draw the label here - labelTrans.setX(m_axisCacheX.labelPosition(label)); - m_dummyRenderItem.setTranslation(labelTrans); - const LabelItem &axisLabelItem = *m_axisCacheX.labelItems().at(labelNbr); - - if (drawSelection) { - QVector4D labelColor = QVector4D(0.0f, label / 255.0f, 0.0f, - alphaForColumnSelection); - shader->setUniformValue(shader->color(), labelColor); - } + if (m_xFlipped) { + startIndex = labelCount - 1; + endIndex = -1; + indexStep = -1; + } else { + startIndex = 0; + endIndex = labelCount; + indexStep = 1; + } + for (int label = startIndex; label != endIndex; label = label + indexStep) { + glPolygonOffset(GLfloat(label) / -10.0f, 1.0f); + // Draw the label here + labelTrans.setX(m_axisCacheX.labelPosition(label)); + m_dummyRenderItem.setTranslation(labelTrans); + const LabelItem &axisLabelItem = *m_axisCacheX.labelItems().at(label); - m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix, - positionZComp, totalRotation, 0, m_cachedSelectionMode, - shader, m_labelObj, activeCamera, - true, true, Drawer::LabelMid, alignment, false, drawSelection); - labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width())); + if (drawSelection) { + QVector4D labelColor = QVector4D(0.0f, label / 255.0f, 0.0f, + alphaForColumnSelection); + shader->setUniformValue(shader->color(), labelColor); } - labelNbr++; + + m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix, + positionZComp, totalRotation, 0, m_cachedSelectionMode, + shader, m_labelObj, activeCamera, + true, true, Drawer::LabelMid, alignment, false, drawSelection); + labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width())); } if (!drawSelection && m_axisCacheX.isTitleVisible()) { labelTrans.setX(0.0f); @@ -2061,7 +2075,6 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa fractionCamX = activeCamera->xRotation() * labelAngleFraction; int labelCount = m_axisCacheY.labelCount(); - int labelNbr = 0; GLfloat labelXTrans = m_scaleXWithBackground; GLfloat labelZTrans = m_scaleZWithBackground; @@ -2110,39 +2123,45 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa QVector3D labelTransBack = QVector3D(labelXTrans, 0.0f, labelZTrans + labelMarginZTrans); QVector3D labelTransSide(-labelXTrans - labelMarginXTrans, 0.0f, -labelZTrans); - for (int label = 0; label < labelCount; label++) { - if (m_axisCacheY.labelItems().size() > labelNbr) { - const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(labelNbr); - const GLfloat labelYTrans = m_axisCacheY.labelPosition(label); - - glPolygonOffset(GLfloat(label) / -10.0f, 1.0f); + if (m_yFlipped) { + startIndex = labelCount - 1; + endIndex = -1; + indexStep = -1; + } else { + startIndex = 0; + endIndex = labelCount; + indexStep = 1; + } + for (int label = startIndex; label != endIndex; label = label + indexStep) { + const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(label); + const GLfloat labelYTrans = m_axisCacheY.labelPosition(label); - if (drawSelection) { - QVector4D labelColor = QVector4D(0.0f, 0.0f, label / 255.0f, - alphaForValueSelection); - shader->setUniformValue(shader->color(), labelColor); - } + glPolygonOffset(GLfloat(label) / -10.0f, 1.0f); - // Back wall - labelTransBack.setY(labelYTrans); - m_dummyRenderItem.setTranslation(labelTransBack); - m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix, - positionZComp, totalBackRotation, 0, m_cachedSelectionMode, - shader, m_labelObj, activeCamera, - true, true, Drawer::LabelMid, backAlignment, false, - drawSelection); - - // Side wall - labelTransSide.setY(labelYTrans); - m_dummyRenderItem.setTranslation(labelTransSide); - m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix, - positionZComp, totalSideRotation, 0, m_cachedSelectionMode, - shader, m_labelObj, activeCamera, - true, true, Drawer::LabelMid, sideAlignment, false, - drawSelection); - labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width())); + if (drawSelection) { + QVector4D labelColor = QVector4D(0.0f, 0.0f, label / 255.0f, + alphaForValueSelection); + shader->setUniformValue(shader->color(), labelColor); } - labelNbr++; + + // Back wall + labelTransBack.setY(labelYTrans); + m_dummyRenderItem.setTranslation(labelTransBack); + m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix, + positionZComp, totalBackRotation, 0, m_cachedSelectionMode, + shader, m_labelObj, activeCamera, + true, true, Drawer::LabelMid, backAlignment, false, + drawSelection); + + // Side wall + labelTransSide.setY(labelYTrans); + m_dummyRenderItem.setTranslation(labelTransSide); + m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix, + positionZComp, totalSideRotation, 0, m_cachedSelectionMode, + shader, m_labelObj, activeCamera, + true, true, Drawer::LabelMid, sideAlignment, false, + drawSelection); + labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width())); } if (!drawSelection && m_axisCacheY.isTitleVisible()) { drawAxisTitleY(sideLabelRotation, backLabelRotation, labelTransSide, labelTransBack, |