summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-05-27 11:36:44 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-05-28 08:56:23 +0300
commitf48233015f5b3694002a456b9db61d3e58541c5c (patch)
tree9ad4b734c3797dce0a9f40d660051f4667fc1910
parentd9cb05d0f46efc58e508c233a3c67542a4c177fa (diff)
Fix labels transparency within each axis
Task-number: QTRD-3141 Change-Id: I8ca51b411e2d92e0c615c81d215d89575d614acd Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp185
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp157
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp161
3 files changed, 282 insertions, 221 deletions
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 97589765..87fecbf2 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -1875,8 +1875,11 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
float fractionCamX = activeCamera->xRotation() * labelAngleFraction;
float labelsMaxWidth = 0.0f;
+ int startIndex;
+ int endIndex;
+ int indexStep;
+
// Y Labels
- int labelNbr = 0;
int labelCount = m_axisCacheY.labelCount();
GLfloat labelMarginXTrans = labelMargin;
GLfloat labelMarginZTrans = labelMargin;
@@ -1928,38 +1931,44 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
QVector3D sideLabelTrans = QVector3D(-labelXTrans - labelMarginXTrans,
0.0f, -labelZTrans);
- for (int i = 0; i < labelCount; i++) {
- if (m_axisCacheY.labelItems().size() > labelNbr) {
- backLabelTrans.setY(m_axisCacheY.labelPosition(i));
- sideLabelTrans.setY(backLabelTrans.y());
+ if (m_yFlipped) {
+ startIndex = labelCount - 1;
+ endIndex = -1;
+ indexStep = -1;
+ } else {
+ startIndex = 0;
+ endIndex = labelCount;
+ indexStep = 1;
+ }
+ for (int i = startIndex; i != endIndex; i = i + indexStep) {
+ backLabelTrans.setY(m_axisCacheY.labelPosition(i));
+ sideLabelTrans.setY(backLabelTrans.y());
- glPolygonOffset(GLfloat(i) / -10.0f, 1.0f);
+ glPolygonOffset(GLfloat(i) / -10.0f, 1.0f);
- const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(labelNbr);
+ const LabelItem &axisLabelItem = *m_axisCacheY.labelItems().at(i);
- if (drawSelection) {
- QVector4D labelColor = QVector4D(0.0f, 0.0f, i / 255.0f,
- alphaForValueSelection);
- shader->setUniformValue(shader->color(), labelColor);
- }
-
- // Back wall
- m_dummyBarRenderItem.setTranslation(backLabelTrans);
- m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, totalBackRotation, 0, m_cachedSelectionMode,
- shader, m_labelObj, activeCamera,
- true, true, Drawer::LabelMid, backAlignment, false, drawSelection);
-
- // Side wall
- m_dummyBarRenderItem.setTranslation(sideLabelTrans);
- m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, 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, i / 255.0f,
+ alphaForValueSelection);
+ shader->setUniformValue(shader->color(), labelColor);
}
- labelNbr++;
+
+ // Back wall
+ m_dummyBarRenderItem.setTranslation(backLabelTrans);
+ m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
+ zeroVector, totalBackRotation, 0, m_cachedSelectionMode,
+ shader, m_labelObj, activeCamera,
+ true, true, Drawer::LabelMid, backAlignment, false, drawSelection);
+
+ // Side wall
+ m_dummyBarRenderItem.setTranslation(sideLabelTrans);
+ m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
+ zeroVector, 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()) {
@@ -2049,37 +2058,44 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
}
QQuaternion totalRotation = Utils::calculateRotation(labelRotation);
- for (int row = 0; row != m_cachedRowCount; row++) {
- if (m_axisCacheZ.labelItems().size() > row) {
- // Go through all rows and get position of max+1 or min-1 column, depending on x flip
- // We need only positions for them, labels have already been generated
- rowPos = (row + 0.5f) * m_cachedBarSpacing.height();
- if (m_xFlipped)
- colPos = -colPosValue;
- else
- colPos = colPosValue;
-
- glPolygonOffset(GLfloat(row) / -10.0f, 1.0f);
+ if (m_zFlipped) {
+ startIndex = 0;
+ endIndex = m_cachedRowCount;
+ indexStep = 1;
+ } else {
+ startIndex = m_cachedRowCount - 1;
+ endIndex = -1;
+ indexStep = -1;
+ }
+ for (int row = startIndex; row != endIndex; row = row + indexStep) {
+ // Go through all rows and get position of max+1 or min-1 column, depending on x flip
+ // We need only positions for them, labels have already been generated
+ rowPos = (row + 0.5f) * m_cachedBarSpacing.height();
+ if (m_xFlipped)
+ colPos = -colPosValue;
+ else
+ colPos = colPosValue;
- QVector3D labelPos = QVector3D(colPos,
- labelYAdjustment, // raise a bit over background to avoid depth "glimmering"
- (m_columnDepth - rowPos) / m_scaleFactor);
+ glPolygonOffset(GLfloat(row) / -10.0f, 1.0f);
- m_dummyBarRenderItem.setTranslation(labelPos);
- const LabelItem &axisLabelItem = *m_axisCacheZ.labelItems().at(row);
+ QVector3D labelPos = QVector3D(colPos,
+ labelYAdjustment, // raise a bit over background to avoid depth "glimmering"
+ (m_columnDepth - rowPos) / m_scaleFactor);
- if (drawSelection) {
- QVector4D labelColor = QVector4D(row / 255.0f, 0.0f, 0.0f, alphaForRowSelection);
- shader->setUniformValue(shader->color(), labelColor);
- }
+ m_dummyBarRenderItem.setTranslation(labelPos);
+ const LabelItem &axisLabelItem = *m_axisCacheZ.labelItems().at(row);
- m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, 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(row / 255.0f, 0.0f, 0.0f, alphaForRowSelection);
+ shader->setUniformValue(shader->color(), labelColor);
}
+
+ m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
+ zeroVector, 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()) {
@@ -2160,37 +2176,44 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
totalRotation = Utils::calculateRotation(labelRotation);
- for (int column = 0; column != m_cachedColumnCount; column++) {
- if (m_axisCacheX.labelItems().size() > column) {
- // Go through all columns and get position of max+1 or min-1 row, depending on z flip
- // We need only positions for them, labels have already been generated
- colPos = (column + 0.5f) * m_cachedBarSpacing.width();
- if (m_zFlipped)
- rowPos = -rowPosValue;
- else
- rowPos = rowPosValue;
-
- glPolygonOffset(GLfloat(column) / -10.0f, 1.0f);
+ if (m_xFlipped) {
+ startIndex = m_cachedColumnCount - 1;
+ endIndex = -1;
+ indexStep = -1;
+ } else {
+ startIndex = 0;
+ endIndex = m_cachedColumnCount;
+ indexStep = 1;
+ }
+ for (int column = startIndex; column != endIndex; column = column + indexStep) {
+ // Go through all columns and get position of max+1 or min-1 row, depending on z flip
+ // We need only positions for them, labels have already been generated
+ colPos = (column + 0.5f) * m_cachedBarSpacing.width();
+ if (m_zFlipped)
+ rowPos = -rowPosValue;
+ else
+ rowPos = rowPosValue;
- QVector3D labelPos = QVector3D((colPos - m_rowWidth) / m_scaleFactor,
- labelYAdjustment, // raise a bit over background to avoid depth "glimmering"
- rowPos);
+ glPolygonOffset(GLfloat(column) / -10.0f, 1.0f);
- m_dummyBarRenderItem.setTranslation(labelPos);
- const LabelItem &axisLabelItem = *m_axisCacheX.labelItems().at(column);
+ QVector3D labelPos = QVector3D((colPos - m_rowWidth) / m_scaleFactor,
+ labelYAdjustment, // raise a bit over background to avoid depth "glimmering"
+ rowPos);
- if (drawSelection) {
- QVector4D labelColor = QVector4D(0.0f, column / 255.0f, 0.0f,
- alphaForColumnSelection);
- shader->setUniformValue(shader->color(), labelColor);
- }
+ m_dummyBarRenderItem.setTranslation(labelPos);
+ const LabelItem &axisLabelItem = *m_axisCacheX.labelItems().at(column);
- m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, 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, column / 255.0f, 0.0f,
+ alphaForColumnSelection);
+ shader->setUniformValue(shader->color(), labelColor);
}
+
+ m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
+ zeroVector, 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()) {
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index dd84139d..10160bed 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -1345,6 +1345,10 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
float fractionCamX = activeCamera->xRotation() * labelAngleFraction;
float labelsMaxWidth = 0.0f;
+ int startIndex;
+ int endIndex;
+ int indexStep;
+
// Z Labels
if (m_axisCacheZ.segmentCount() > 0) {
int labelCount = m_axisCacheZ.labelCount();
@@ -1356,7 +1360,6 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
#else
GLfloat labelXTrans = m_graphAspectRatio + m_backgroundMargin + labelMargin;
#endif
- int labelNbr = 0;
GLfloat labelYTrans = -1.0f - m_backgroundMargin;
Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
QVector3D labelRotation;
@@ -1426,29 +1429,35 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
QQuaternion totalRotation = Utils::calculateRotation(labelRotation);
QVector3D labelTrans = QVector3D(labelXTrans, labelYTrans, 0.0f);
- for (int label = 0; label < labelCount; label++) {
- if (m_axisCacheZ.labelItems().size() > labelNbr) {
- labelTrans.setZ(m_axisCacheZ.labelPosition(label));
-
- glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
+ 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) {
+ labelTrans.setZ(m_axisCacheZ.labelPosition(label));
- // Draw the label here
- m_dummyRenderItem.setTranslation(labelTrans);
- const LabelItem &axisLabelItem = *m_axisCacheZ.labelItems().at(labelNbr);
+ glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
- if (drawSelection) {
- QVector4D labelColor = QVector4D(label / 255.0f, 0.0f, 0.0f,
- alphaForRowSelection);
- shader->setUniformValue(shader->color(), labelColor);
- }
+ // Draw the label here
+ m_dummyRenderItem.setTranslation(labelTrans);
+ const LabelItem &axisLabelItem = *m_axisCacheZ.labelItems().at(label);
- m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, 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,
+ zeroVector, 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);
@@ -1473,7 +1482,6 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
#else
GLfloat labelZTrans = m_graphAspectRatio + m_backgroundMargin + labelMargin;
#endif
- int labelNbr = 0;
GLfloat labelYTrans = -1.0f - m_backgroundMargin;
Qt::AlignmentFlag alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
QVector3D labelRotation;
@@ -1546,29 +1554,35 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
QQuaternion totalRotation = Utils::calculateRotation(labelRotation);
QVector3D labelTrans = QVector3D(0.0f, labelYTrans, labelZTrans);
- for (int label = 0; label < labelCount; label++) {
- if (m_axisCacheX.labelItems().size() > labelNbr) {
- labelTrans.setX(m_axisCacheX.labelPosition(label));
-
- glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
+ 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) {
+ labelTrans.setX(m_axisCacheX.labelPosition(label));
- // Draw the label here
- m_dummyRenderItem.setTranslation(labelTrans);
- const LabelItem &axisLabelItem = *m_axisCacheX.labelItems().at(labelNbr);
+ glPolygonOffset(GLfloat(label) / -10.0f, 1.0f);
- if (drawSelection) {
- QVector4D labelColor = QVector4D(0.0f, label / 255.0f, 0.0f,
- alphaForColumnSelection);
- shader->setUniformValue(shader->color(), labelColor);
- }
+ // Draw the label here
+ m_dummyRenderItem.setTranslation(labelTrans);
+ const LabelItem &axisLabelItem = *m_axisCacheX.labelItems().at(label);
- m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, 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,
+ zeroVector, 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);
@@ -1585,7 +1599,6 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
fractionCamY = activeCamera->yRotation() * labelAngleFraction;
fractionCamX = activeCamera->xRotation() * labelAngleFraction;
int labelCount = m_axisCacheY.labelCount();
- int labelNbr = 0;
#ifndef USE_UNIFORM_SCALING // Use this if we want to use autoscaling for x and z
GLfloat labelXTrans = (m_graphAspectRatio* m_areaSize.width())
/ m_scaleFactor + m_backgroundMargin;
@@ -1644,37 +1657,43 @@ void Scatter3DRenderer::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,
- zeroVector, 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,
- zeroVector, 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,
+ zeroVector, 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,
+ zeroVector, 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,
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,