summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-05-19 14:07:10 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-05-19 14:17:50 +0300
commitca8a5af99151250b676a4aaf387399165012ebb2 (patch)
tree4d07e15d885696b4844eae7d42e00af821f7f189 /src
parent05792cdf5140368a5dcf2e47886e34fd99c56398 (diff)
Fix label alignments
- Left and right were logically swapped - Horizontal axis labels on slice views were incorrectly aligned Change-Id: I8c13acaeec02961464ee63f8b489e353dcb379e6 Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp18
-rw-r--r--src/datavisualization/engine/drawer.cpp25
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp8
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp15
4 files changed, 28 insertions, 38 deletions
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 8b234afb..bc49e7ed 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -481,7 +481,7 @@ void Bars3DRenderer::drawSlicedScene()
scaleFactor = (1.1f * m_rowWidth) / m_scaleFactor;
else
scaleFactor = (1.1f * m_columnDepth) / m_scaleFactor;
- GLfloat barLabelYPos = barPosYAdjustment - 0.4f - labelMargin; // 0.4 for labels
+ GLfloat barLabelYPos = barPosYAdjustment - labelMargin;
GLfloat zeroPosAdjustment = 0.0f;
GLfloat directionMultiplier = 2.0f;
GLfloat directionBase = 0.0f;
@@ -596,7 +596,7 @@ void Bars3DRenderer::drawSlicedScene()
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix,
projectionMatrix, zeroVector, identityQuaternion, 0,
m_cachedSelectionMode, m_labelShader, m_labelObj,
- activeCamera, true, true, Drawer::LabelMid, Qt::AlignRight);
+ activeCamera, true, true, Drawer::LabelMid, Qt::AlignLeft);
}
labelNbr++;
}
@@ -802,7 +802,7 @@ void Bars3DRenderer::drawSlicedScene()
viewMatrix, projectionMatrix, positionComp, totalSliceLabelRotation,
0, m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, Drawer::LabelMid,
- Qt::AlignRight, true);
+ Qt::AlignmentFlag(Qt::AlignLeft | Qt::AlignTop), true);
}
if (!sliceGridLabels) {
@@ -824,7 +824,7 @@ void Bars3DRenderer::drawSlicedScene()
m_drawer->generateLabelItem(item.sliceLabelItem(), item.sliceLabel());
m_updateLabels = false;
}
- Qt::AlignmentFlag alignment = (item.height() < 0) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag alignment = (item.height() > 0) ? Qt::AlignLeft : Qt::AlignRight;
Drawer::LabelPosition labelPos = (item.height() < 0) ? Drawer::LabelBelow : Drawer::LabelOver;
m_dummyBarRenderItem.setTranslation(QVector3D(item.translation().x(),
barPosYAdjustment - zeroPosAdjustment
@@ -850,7 +850,7 @@ void Bars3DRenderer::drawSlicedScene()
m_drawer->generateLabelItem(selectedItem->sliceLabelItem(), selectedItem->sliceLabel());
m_updateLabels = false;
}
- Qt::AlignmentFlag alignment = (selectedItem->height() < 0) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag alignment = (selectedItem->height() > 0) ? Qt::AlignLeft : Qt::AlignRight;
Drawer::LabelPosition labelPos = (selectedItem->height() < 0) ? Drawer::LabelBelow : Drawer::LabelOver;
m_dummyBarRenderItem.setTranslation(QVector3D(selectedItem->translation().x(),
barPosYAdjustment - zeroPosAdjustment
@@ -1894,8 +1894,8 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
GLfloat labelZTrans = columnScaleFactor;
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;
- Qt::AlignmentFlag sideAlignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag backAlignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag sideAlignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
if (!m_xFlipped) {
labelXTrans = -labelXTrans;
@@ -1983,7 +1983,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
GLfloat rowPosValue = scaledColumnDepth + labelMargin;
GLfloat rowPos = 0.0f;
GLfloat colPos = 0.0f;
- Qt::AlignmentFlag alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
QVector3D labelRotation;
if (labelAutoAngle == 0.0f) {
@@ -2085,7 +2085,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
labelAngleFraction = labelAutoAngle / 90.0f;
fractionCamY = activeCamera->yRotation() * labelAngleFraction;
fractionCamX = activeCamera->xRotation() * labelAngleFraction;
- alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
if (labelAutoAngle == 0.0f) {
labelRotation = QVector3D(-90.0f, 90.0f, 0.0f);
if (m_xFlipped)
diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp
index a5fd6601..a14678ce 100644
--- a/src/datavisualization/engine/drawer.cpp
+++ b/src/datavisualization/engine/drawer.cpp
@@ -300,27 +300,16 @@ void Drawer::drawLabel(const AbstractRenderItem &item, const LabelItem &labelIte
// Apply alignment
QVector3D anchorPoint;
- switch (alignment) {
- case Qt::AlignLeft: {
- anchorPoint.setX(float(-textureSize.width()) * scaleFactor);
- break;
- }
- case Qt::AlignRight: {
+
+ if (alignment & Qt::AlignLeft)
anchorPoint.setX(float(textureSize.width()) * scaleFactor);
- break;
- }
- case Qt::AlignTop: {
+ else if (alignment & Qt::AlignRight)
+ anchorPoint.setX(float(-textureSize.width()) * scaleFactor);
+
+ if (alignment & Qt::AlignTop)
anchorPoint.setY(float(-textureSize.height()) * scaleFactor);
- break;
- }
- case Qt::AlignBottom: {
+ else if (alignment & Qt::AlignBottom)
anchorPoint.setY(float(textureSize.height()) * scaleFactor);
- break;
- }
- default: {
- break;
- }
- }
if (position < LabelBottom) {
xPosition = item.translation().x();
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 940260d9..3cf91833 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -1367,7 +1367,7 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
#endif
int labelNbr = 0;
GLfloat labelYTrans = -1.0f - m_backgroundMargin;
- Qt::AlignmentFlag alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
QVector3D labelRotation;
if (m_xFlipped)
labelXTrans = -labelXTrans;
@@ -1476,7 +1476,7 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
#endif
int labelNbr = 0;
GLfloat labelYTrans = -1.0f - m_backgroundMargin;
- Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
QVector3D labelRotation;
if (m_zFlipped)
labelZTrans = -labelZTrans;
@@ -1597,8 +1597,8 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
GLfloat labelMarginZTrans = labelMargin;
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;
- Qt::AlignmentFlag sideAlignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag backAlignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag sideAlignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
if (!m_xFlipped) {
labelXTrans = -labelXTrans;
labelMarginXTrans = -labelMargin;
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 03bd2ccd..66caedc2 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -969,8 +969,8 @@ void Surface3DRenderer::drawSlicedScene()
m_dummyRenderItem.setTranslation(labelTrans);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
positionComp, identityQuaternion, 0, m_cachedSelectionMode, m_labelShader,
- m_labelObj, activeCamera,
- true, true, Drawer::LabelMid, Qt::AlignRight, true);
+ m_labelObj, activeCamera, true, true, Drawer::LabelMid,
+ Qt::AlignLeft, true);
}
labelNbr++;
}
@@ -998,7 +998,8 @@ void Surface3DRenderer::drawSlicedScene()
m_drawer->drawLabel(m_dummyRenderItem, *axisLabelItem, viewMatrix, projectionMatrix,
positionComp, totalRotation, 0, QAbstract3DGraph::SelectionRow,
m_labelShader, m_labelObj, activeCamera,
- false, false, Drawer::LabelBelow, Qt::AlignBottom, true);
+ false, false, Drawer::LabelBelow,
+ Qt::AlignmentFlag(Qt::AlignLeft | Qt::AlignTop), true);
}
labelNbr++;
}
@@ -1851,7 +1852,7 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
int labelNbr = 0;
GLfloat labelXTrans = m_scaleXWithBackground + labelMargin;
GLfloat labelYTrans = -backgroundMargin;
- Qt::AlignmentFlag alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
QVector3D labelRotation;
if (m_xFlipped)
labelXTrans = -labelXTrans;
@@ -1957,7 +1958,7 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
int labelNbr = 0;
GLfloat labelZTrans = m_scaleZWithBackground + labelMargin;
GLfloat labelYTrans = -backgroundMargin;
- Qt::AlignmentFlag alignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag alignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
QVector3D labelRotation;
if (m_zFlipped)
labelZTrans = -labelZTrans;
@@ -2070,8 +2071,8 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
GLfloat labelMarginZTrans = labelMargin;
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;
- Qt::AlignmentFlag sideAlignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag backAlignment = (m_xFlipped != m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
+ Qt::AlignmentFlag sideAlignment = (m_xFlipped == m_zFlipped) ? Qt::AlignLeft : Qt::AlignRight;
if (!m_xFlipped) {
labelXTrans = -labelXTrans;
labelMarginXTrans = -labelMargin;