summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-05-19 12:57:20 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-05-19 13:09:05 +0300
commit0c1389258e8c3bdb7ccd2ae55959e4e99a460970 (patch)
tree1002218975189205c5eb94152e541268f41fb346 /src
parent806fd8ab43dd59da89d04651b22c5c0440032b94 (diff)
Optimize label rotations a bit
Change-Id: Ie6075aefa70228769d5a2717e9d96c23b9fee494 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp37
-rw-r--r--src/datavisualization/engine/drawer.cpp8
-rw-r--r--src/datavisualization/engine/drawer_p.h2
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp15
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp30
-rw-r--r--src/datavisualization/utils/utils.cpp9
-rw-r--r--src/datavisualization/utils/utils_p.h1
7 files changed, 65 insertions, 37 deletions
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 537bb1ca..8b234afb 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -585,7 +585,6 @@ void Bars3DRenderer::drawSlicedScene()
// Draw grid labels
int labelNbr = 0;
int labelCount = m_axisCacheY.labelCount();
- QVector3D backLabelRotation(0.0f, 0.0f, 0.0f);
QVector3D labelTrans = QVector3D(scaleFactor + labelMargin, 0.0f, 0.0f);
for (int i = 0; i < labelCount; i++) {
@@ -595,7 +594,7 @@ void Bars3DRenderer::drawSlicedScene()
labelTrans.setY(gridPos);
m_dummyBarRenderItem.setTranslation(labelTrans);
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix,
- projectionMatrix, zeroVector, backLabelRotation, 0,
+ projectionMatrix, zeroVector, identityQuaternion, 0,
m_cachedSelectionMode, m_labelShader, m_labelObj,
activeCamera, true, true, Drawer::LabelMid, Qt::AlignRight);
}
@@ -786,6 +785,8 @@ void Bars3DRenderer::drawSlicedScene()
// Draw labels for bars
QVector3D sliceValueRotation(0.0f, 0.0f, 90.0f);
QVector3D sliceLabelRotation(0.0f, 0.0f, -45.0f);
+ QQuaternion totalSliceValueRotation = Utils::calculateRotation(sliceValueRotation);
+ QQuaternion totalSliceLabelRotation = Utils::calculateRotation(sliceLabelRotation);
int labelCount = m_sliceCache->labelItems().size();
@@ -798,7 +799,7 @@ void Bars3DRenderer::drawSlicedScene()
// Draw labels
m_drawer->drawLabel(m_dummyBarRenderItem, *m_sliceCache->labelItems().at(labelNo),
- viewMatrix, projectionMatrix, positionComp, sliceLabelRotation,
+ viewMatrix, projectionMatrix, positionComp, totalSliceLabelRotation,
0, m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, Drawer::LabelMid,
Qt::AlignRight, true);
@@ -831,7 +832,7 @@ void Bars3DRenderer::drawSlicedScene()
item.translation().z()));
m_drawer->drawLabel(m_dummyBarRenderItem, item.sliceLabelItem(), viewMatrix,
- projectionMatrix, zeroVector, sliceValueRotation,
+ projectionMatrix, zeroVector, totalSliceValueRotation,
item.height(), m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, labelPos,
alignment, true);
@@ -857,7 +858,7 @@ void Bars3DRenderer::drawSlicedScene()
selectedItem->translation().z()));
m_drawer->drawLabel(m_dummyBarRenderItem, selectedItem->sliceLabelItem(), viewMatrix,
- projectionMatrix, zeroVector, sliceValueRotation,
+ projectionMatrix, zeroVector, totalSliceValueRotation,
selectedItem->height(), m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, labelPos,
alignment, true);
@@ -867,22 +868,22 @@ void Bars3DRenderer::drawSlicedScene()
if (rowMode) {
if (m_sliceTitleItem) {
m_drawer->drawLabel(*dummyItem, sliceSelectionLabel, viewMatrix, projectionMatrix,
- positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ positionComp, identityQuaternion, 0, m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, Drawer::LabelTop,
Qt::AlignCenter, true);
}
m_drawer->drawLabel(*dummyItem, m_axisCacheX.titleItem(), viewMatrix, projectionMatrix,
- positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ positionComp, identityQuaternion, 0, m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, Drawer::LabelBottom,
Qt::AlignCenter, true);
} else {
m_drawer->drawLabel(*dummyItem, m_axisCacheZ.titleItem(), viewMatrix, projectionMatrix,
- positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ positionComp, identityQuaternion, 0, m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, Drawer::LabelBottom,
Qt::AlignCenter, true);
if (m_sliceTitleItem) {
m_drawer->drawLabel(*dummyItem, sliceSelectionLabel, viewMatrix, projectionMatrix,
- positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ positionComp, identityQuaternion, 0, m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, Drawer::LabelTop,
Qt::AlignCenter, true);
}
@@ -891,7 +892,7 @@ void Bars3DRenderer::drawSlicedScene()
QVector3D labelTrans = QVector3D(-scaleFactor - labelMargin, 0.2f, 0.0f); // y = 0.2 for row/column labels (see barPosYAdjustment)
m_dummyBarRenderItem.setTranslation(labelTrans);
m_drawer->drawLabel(m_dummyBarRenderItem, m_axisCacheY.titleItem(), viewMatrix,
- projectionMatrix, zeroVector, QVector3D(0.0f, 0.0f, 90.0f), 0,
+ projectionMatrix, zeroVector, totalSliceValueRotation, 0,
m_cachedSelectionMode, m_labelShader, m_labelObj, activeCamera,
false, false, Drawer::LabelMid, Qt::AlignBottom);
@@ -1838,7 +1839,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
}
m_drawer->drawLabel(*selectedBar, labelItem, viewMatrix, projectionMatrix,
- zeroVector, zeroVector, selectedBar->height(),
+ zeroVector, identityQuaternion, selectedBar->height(),
m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, true, false);
@@ -1929,6 +1930,9 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
sideLabelRotation.setX(-fractionCamY);
backLabelRotation.setX(-fractionCamY);
+ QQuaternion totalSideRotation = Utils::calculateRotation(sideLabelRotation);
+ QQuaternion totalBackRotation = Utils::calculateRotation(backLabelRotation);
+
QVector3D backLabelTrans = QVector3D(labelXTrans, 0.0f,
labelZTrans + labelMarginZTrans);
QVector3D sideLabelTrans = QVector3D(-labelXTrans - labelMarginXTrans,
@@ -1952,14 +1956,14 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
// Back wall
m_dummyBarRenderItem.setTranslation(backLabelTrans);
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, backLabelRotation, 0, m_cachedSelectionMode,
+ zeroVector, totalBackRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, backAlignment);
// Side wall
m_dummyBarRenderItem.setTranslation(sideLabelTrans);
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, sideLabelRotation, 0, m_cachedSelectionMode,
+ zeroVector, totalSideRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, sideAlignment);
}
@@ -2043,6 +2047,7 @@ 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
@@ -2068,7 +2073,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
}
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, labelRotation, 0, m_cachedSelectionMode,
+ zeroVector, totalRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, alignment,
false, drawSelection);
@@ -2144,6 +2149,8 @@ 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
@@ -2170,7 +2177,7 @@ void Bars3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCamer
}
m_drawer->drawLabel(m_dummyBarRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, labelRotation, 0, m_cachedSelectionMode,
+ zeroVector, totalRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, alignment, false, drawSelection);
}
diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp
index 0e336019..a5fd6601 100644
--- a/src/datavisualization/engine/drawer.cpp
+++ b/src/datavisualization/engine/drawer.cpp
@@ -233,7 +233,7 @@ void Drawer::drawLine(ShaderHelper *shader)
void Drawer::drawLabel(const AbstractRenderItem &item, const LabelItem &labelItem,
const QMatrix4x4 &viewmatrix, const QMatrix4x4 &projectionmatrix,
- const QVector3D &positionComp, const QVector3D &rotation,
+ const QVector3D &positionComp, const QQuaternion &rotation,
GLfloat itemHeight, QAbstract3DGraph::SelectionFlags mode,
ShaderHelper *shader, ObjectHelper *object,
const Q3DCamera *camera, bool useDepth, bool rotateAlong,
@@ -342,11 +342,7 @@ void Drawer::drawLabel(const AbstractRenderItem &item, const LabelItem &labelIte
modelMatrix.rotate(-camRotationX, 0.0f, 1.0f, 0.0f);
modelMatrix.rotate(-camRotationY - yComp, 1.0f, 0.0f, 0.0f);
} else {
- QQuaternion rotQuatX = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, rotation.x());
- QQuaternion rotQuatY = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, rotation.y());
- QQuaternion rotQuatZ = QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, rotation.z());
- QQuaternion rotQuaternion = rotQuatY * rotQuatZ * rotQuatX;
- modelMatrix.rotate(rotQuaternion);
+ modelMatrix.rotate(rotation);
}
modelMatrix.translate(anchorPoint);
diff --git a/src/datavisualization/engine/drawer_p.h b/src/datavisualization/engine/drawer_p.h
index c4fb749f..cdda4f7d 100644
--- a/src/datavisualization/engine/drawer_p.h
+++ b/src/datavisualization/engine/drawer_p.h
@@ -80,7 +80,7 @@ public:
void drawLine(ShaderHelper *shader);
void drawLabel(const AbstractRenderItem &item, const LabelItem &labelItem,
const QMatrix4x4 &viewmatrix, const QMatrix4x4 &projectionmatrix,
- const QVector3D &positionComp, const QVector3D &rotation, GLfloat itemHeight,
+ const QVector3D &positionComp, const QQuaternion &rotation, GLfloat itemHeight,
QAbstract3DGraph::SelectionFlags mode, ShaderHelper *shader, ObjectHelper *object,
const Q3DCamera *camera, bool useDepth = false, bool rotateAlong = false,
LabelPosition position = LabelOver,
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 3fd8ece4..940260d9 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -1310,7 +1310,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
}
m_drawer->drawLabel(*selectedItem, labelItem, viewMatrix, projectionMatrix,
- zeroVector, zeroVector, selectedItemSize, m_cachedSelectionMode,
+ zeroVector, identityQuaternion, selectedItemSize, m_cachedSelectionMode,
m_labelShader, m_labelObj, activeCamera, true, false,
Drawer::LabelOver);
@@ -1433,6 +1433,7 @@ 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) {
@@ -1451,7 +1452,7 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, labelRotation, 0, m_cachedSelectionMode,
+ zeroVector, totalRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera, true, true,
Drawer::LabelMid, alignment);
}
@@ -1544,6 +1545,7 @@ 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) {
@@ -1562,7 +1564,7 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, labelRotation, 0, m_cachedSelectionMode,
+ zeroVector, totalRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera, true, true,
Drawer::LabelMid, alignment);
}
@@ -1629,6 +1631,9 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
sideLabelRotation.setX(-fractionCamY);
backLabelRotation.setX(-fractionCamY);
+ QQuaternion totalSideRotation = Utils::calculateRotation(sideLabelRotation);
+ QQuaternion totalBackRotation = Utils::calculateRotation(backLabelRotation);
+
QVector3D labelTransBack = QVector3D(labelXTrans, 0.0f, labelZTrans + labelMarginZTrans);
QVector3D labelTransSide(-labelXTrans - labelMarginXTrans, 0.0f, -labelZTrans);
@@ -1649,7 +1654,7 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelTransBack.setY(labelYTrans);
m_dummyRenderItem.setTranslation(labelTransBack);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, backLabelRotation, 0, m_cachedSelectionMode,
+ zeroVector, totalBackRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera, true, true,
Drawer::LabelMid, backAlignment);
@@ -1657,7 +1662,7 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelTransSide.setY(labelYTrans);
m_dummyRenderItem.setTranslation(labelTransSide);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- zeroVector, sideLabelRotation, 0, m_cachedSelectionMode,
+ zeroVector, totalSideRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera, true, true,
Drawer::LabelMid, sideAlignment);
}
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index b68a8087..03bd2ccd 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -958,7 +958,6 @@ void Surface3DRenderer::drawSlicedScene()
int labelNbr = 0;
QVector3D positionComp(0.0f, 0.0f, 0.0f);
- QVector3D rotation(0.0f, 0.0f, 0.0f);
QVector3D labelTrans = QVector3D(scaleXBackground + labelMargin, 0.0f, 0.0f);
int labelCount = m_axisCacheY.labelCount();
for (int label = 0; label < labelCount; label++) {
@@ -969,7 +968,7 @@ void Surface3DRenderer::drawSlicedScene()
// Draw the label here
m_dummyRenderItem.setTranslation(labelTrans);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- positionComp, rotation, 0, m_cachedSelectionMode, m_labelShader,
+ positionComp, identityQuaternion, 0, m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera,
true, true, Drawer::LabelMid, Qt::AlignRight, true);
}
@@ -979,9 +978,11 @@ void Surface3DRenderer::drawSlicedScene()
// X Labels to ground
int countLabelItems = sliceCache.labelItems().size();
+ QVector3D rotation(0.0f, 0.0f, -45.0f);
+ QQuaternion totalRotation = Utils::calculateRotation(rotation);
+
labelNbr = 0;
positionComp.setY(-0.1f);
- rotation.setZ(-45.0f);
labelTrans.setY(-backgroundMargin);
labelCount = sliceCache.labelCount();
for (int label = 0; label < labelCount; label++) {
@@ -995,7 +996,7 @@ void Surface3DRenderer::drawSlicedScene()
axisLabelItem = sliceCache.labelItems().at(labelNbr);
m_drawer->drawLabel(m_dummyRenderItem, *axisLabelItem, viewMatrix, projectionMatrix,
- positionComp, rotation, 0, QAbstract3DGraph::SelectionRow,
+ positionComp, totalRotation, 0, QAbstract3DGraph::SelectionRow,
m_labelShader, m_labelObj, activeCamera,
false, false, Drawer::LabelBelow, Qt::AlignBottom, true);
}
@@ -1006,15 +1007,17 @@ void Surface3DRenderer::drawSlicedScene()
AbstractRenderItem *dummyItem(0);
positionComp.setY(m_autoScaleAdjustment);
m_drawer->drawLabel(*dummyItem, sliceCache.titleItem(), viewMatrix, projectionMatrix,
- positionComp, zeroVector, 0, m_cachedSelectionMode, m_labelShader,
+ positionComp, identityQuaternion, 0, m_cachedSelectionMode, m_labelShader,
m_labelObj, activeCamera, false, false, Drawer::LabelBottom,
Qt::AlignCenter, true);
// Y-axis label
+ rotation = QVector3D(0.0f, 0.0f, 90.0f);
+ totalRotation = Utils::calculateRotation(rotation);
labelTrans = QVector3D(-scaleXBackground - labelMargin, 0.0f, 0.0f);
m_dummyRenderItem.setTranslation(labelTrans);
m_drawer->drawLabel(m_dummyRenderItem, m_axisCacheY.titleItem(), viewMatrix,
- projectionMatrix, zeroVector, QVector3D(0.0f, 0.0f, 90.0f), 0,
+ projectionMatrix, zeroVector, totalRotation, 0,
m_cachedSelectionMode, m_labelShader, m_labelObj, activeCamera,
false, false, Drawer::LabelMid, Qt::AlignBottom);
@@ -1915,6 +1918,8 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
}
+ QQuaternion totalRotation = Utils::calculateRotation(labelRotation);
+
QVector3D labelTrans = QVector3D(labelXTrans,
labelYTrans,
0.0f);
@@ -1934,7 +1939,7 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- positionZComp, labelRotation, 0, m_cachedSelectionMode,
+ positionZComp, totalRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, alignment);
}
@@ -2020,6 +2025,8 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
}
}
+ QQuaternion totalRotation = Utils::calculateRotation(labelRotation);
+
QVector3D labelTrans = QVector3D(0.0f,
labelYTrans,
labelZTrans);
@@ -2039,7 +2046,7 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- positionZComp, labelRotation, 0, m_cachedSelectionMode,
+ positionZComp, totalRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, alignment);
}
@@ -2097,6 +2104,9 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
sideLabelRotation.setX(-fractionCamY);
backLabelRotation.setX(-fractionCamY);
+ QQuaternion totalSideRotation = Utils::calculateRotation(sideLabelRotation);
+ QQuaternion totalBackRotation = Utils::calculateRotation(backLabelRotation);
+
QVector3D labelTransBack = QVector3D(labelXTrans, 0.0f, labelZTrans + labelMarginZTrans);
QVector3D labelTransSide(-labelXTrans - labelMarginXTrans, 0.0f, -labelZTrans);
@@ -2117,7 +2127,7 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelTransBack.setY(labelYTrans);
m_dummyRenderItem.setTranslation(labelTransBack);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- positionZComp, backLabelRotation, 0, m_cachedSelectionMode,
+ positionZComp, totalBackRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, backAlignment);
@@ -2125,7 +2135,7 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelTransSide.setY(labelYTrans);
m_dummyRenderItem.setTranslation(labelTransSide);
m_drawer->drawLabel(m_dummyRenderItem, axisLabelItem, viewMatrix, projectionMatrix,
- positionZComp, sideLabelRotation, 0, m_cachedSelectionMode,
+ positionZComp, totalSideRotation, 0, m_cachedSelectionMode,
shader, m_labelObj, activeCamera,
true, true, Drawer::LabelMid, sideAlignment);
}
diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp
index b00d1251..7343148d 100644
--- a/src/datavisualization/utils/utils.cpp
+++ b/src/datavisualization/utils/utils.cpp
@@ -234,4 +234,13 @@ float Utils::wrapValue(float value, float min, float max)
return value;
}
+QQuaternion Utils::calculateRotation(const QVector3D &xyzRotations)
+{
+ QQuaternion rotQuatX = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, xyzRotations.x());
+ QQuaternion rotQuatY = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, xyzRotations.y());
+ QQuaternion rotQuatZ = QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, xyzRotations.z());
+ QQuaternion totalRotation = rotQuatY * rotQuatZ * rotQuatX;
+ return totalRotation;
+}
+
QT_END_NAMESPACE_DATAVISUALIZATION
diff --git a/src/datavisualization/utils/utils_p.h b/src/datavisualization/utils/utils_p.h
index 46df980f..a7c73731 100644
--- a/src/datavisualization/utils/utils_p.h
+++ b/src/datavisualization/utils/utils_p.h
@@ -72,6 +72,7 @@ public:
static QString defaultLabelFormat();
static float wrapValue(float value, float min, float max);
+ static QQuaternion calculateRotation(const QVector3D &xyzRotations);
private:
static ParamType mapFormatCharToParamType(const QChar &formatChar);