summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml16
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp23
-rw-r--r--src/datavisualization/engine/abstract3drenderer_p.h3
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp23
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp23
5 files changed, 76 insertions, 12 deletions
diff --git a/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml b/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml
index 97e47b96..66fa807f 100644
--- a/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml
+++ b/examples/datavisualization/qmlspectrogram/qml/qmlspectrogram/main.qml
@@ -80,6 +80,17 @@ Window {
titleFixed: false
}
+ Theme3D {
+ id: customTheme
+ type: Theme3D.ThemeQt
+ // Don't show specular spotlight as we don't want it to distort the colors
+ lightStrength: 0.0
+ ambientLightStrength: 0.9
+ backgroundEnabled: false
+ font.family: "Lucida Handwriting"
+ font.pointSize: 25
+ }
+
Surface3D {
id: surfaceGraph
width: surfaceView.width
@@ -92,10 +103,7 @@ Window {
axisY: yAxis
axisZ: zAxis
- // Don't show specular spotlight as we don't want it to distort the colors
- theme.lightStrength: 0.0
- theme.ambientLightStrength: 0.9
- theme.backgroundEnabled: false
+ theme: customTheme
orthoProjection: true
flipHorizontalGrid: true
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index f520e279..026795e9 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -74,7 +74,8 @@ Abstract3DRenderer::Abstract3DRenderer(Abstract3DController *controller)
m_xRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -90.0f)),
m_yRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, -90.0f)),
m_zRightAngleRotationNeg(QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -90.0f)),
- m_xFlipRotation(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -180.0f))
+ m_xFlipRotation(QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -180.0f)),
+ m_zFlipRotation(QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -180.0f))
{
QObject::connect(m_drawer, &Drawer::drawerChanged, this, &Abstract3DRenderer::updateTextures);
QObject::connect(this, &Abstract3DRenderer::needRender, controller,
@@ -662,10 +663,15 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
float labelsMaxWidth,
const QMatrix4x4 &viewMatrix,
const QMatrix4x4 &projectionMatrix,
- ShaderHelper *shader)
+ ShaderHelper *shader,
+ bool radial)
{
float scaleFactor = m_drawer->scaledFontSize() / m_axisCacheX.titleItem().size().height();
- float titleOffset = 2.0f * (labelMargin + (labelsMaxWidth * scaleFactor));
+ float titleOffset;
+ if (radial)
+ titleOffset = -2.0f * (labelMargin + m_drawer->scaledFontSize());
+ else
+ titleOffset = 2.0f * (labelMargin + (labelsMaxWidth * scaleFactor));
float zRotation = 0.0f;
float yRotation = 0.0f;
float xRotation = -90.0f + labelRotation.z();
@@ -712,6 +718,17 @@ void Abstract3DRenderer::drawAxisTitleX(const QVector3D &labelRotation,
}
}
+ if (radial) {
+ if (m_zFlipped) {
+ titleOffset = -titleOffset;
+ } else {
+ if (m_yFlippedForGrid)
+ alignment = Qt::AlignTop;
+ else
+ alignment = Qt::AlignBottom;
+ }
+ }
+
if (offsetRotation == 180.0f || offsetRotation == -180.0f)
offsetRotation = 0.0f;
QQuaternion offsetRotator = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, offsetRotation);
diff --git a/src/datavisualization/engine/abstract3drenderer_p.h b/src/datavisualization/engine/abstract3drenderer_p.h
index ed26a4ec..254d61ca 100644
--- a/src/datavisualization/engine/abstract3drenderer_p.h
+++ b/src/datavisualization/engine/abstract3drenderer_p.h
@@ -190,7 +190,7 @@ protected:
const QQuaternion &totalRotation, AbstractRenderItem &dummyItem,
const Q3DCamera *activeCamera, float labelsMaxWidth,
const QMatrix4x4 &viewMatrix, const QMatrix4x4 &projectionMatrix,
- ShaderHelper *shader);
+ ShaderHelper *shader, bool radial = false);
void drawAxisTitleZ(const QVector3D &labelRotation, const QVector3D &labelTrans,
const QQuaternion &totalRotation, AbstractRenderItem &dummyItem,
const Q3DCamera *activeCamera, float labelsMaxWidth,
@@ -264,6 +264,7 @@ protected:
QQuaternion m_yRightAngleRotationNeg;
QQuaternion m_zRightAngleRotationNeg;
QQuaternion m_xFlipRotation;
+ QQuaternion m_zFlipRotation;
private:
friend class Abstract3DController;
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 31c3973b..86faca96 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -1580,7 +1580,14 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width()));
}
if (!drawSelection && m_axisCacheZ.isTitleVisible()) {
- labelTrans.setZ(0.0f);
+ if (m_polarGraph) {
+ float titleZ = -m_graphAspectRatio / 2.0f;
+ if (m_zFlipped)
+ titleZ = -titleZ;
+ labelTrans.setZ(titleZ);
+ } else {
+ labelTrans.setZ(0.0f);
+ }
drawAxisTitleZ(labelRotation, labelTrans, totalRotation, m_dummyRenderItem,
activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader);
}
@@ -1746,8 +1753,20 @@ void Scatter3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
if (!drawSelection && m_axisCacheX.isTitleVisible()) {
labelTrans.setX(0.0f);
+ bool radial = false;
+ if (m_polarGraph) {
+ if (m_xFlipped == m_zFlipped)
+ totalRotation *= m_zRightAngleRotation;
+ else
+ totalRotation *= m_zRightAngleRotationNeg;
+ if (m_yFlippedForGrid)
+ totalRotation *= QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -180.0f);
+ labelTrans.setZ(-m_graphAspectRatio);
+ radial = true;
+ }
drawAxisTitleX(labelRotation, labelTrans, totalRotation, m_dummyRenderItem,
- activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader);
+ activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader,
+ radial);
}
}
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index cc1ac1ae..91aeb77f 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -1969,7 +1969,14 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
labelsMaxWidth = qMax(labelsMaxWidth, float(axisLabelItem.size().width()));
}
if (!drawSelection && m_axisCacheZ.isTitleVisible()) {
- labelTrans.setZ(0.0f);
+ if (m_polarGraph) {
+ float titleZ = -m_graphAspectRatio / 2.0f;
+ if (m_zFlipped)
+ titleZ = -titleZ;
+ labelTrans.setZ(titleZ);
+ } else {
+ labelTrans.setZ(0.0f);
+ }
drawAxisTitleZ(labelRotation, labelTrans, totalRotation, m_dummyRenderItem,
activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader);
}
@@ -2139,8 +2146,20 @@ void Surface3DRenderer::drawLabels(bool drawSelection, const Q3DCamera *activeCa
}
if (!drawSelection && m_axisCacheX.isTitleVisible()) {
labelTrans.setX(0.0f);
+ bool radial = false;
+ if (m_polarGraph) {
+ if (m_xFlipped == m_zFlipped)
+ totalRotation *= m_zRightAngleRotation;
+ else
+ totalRotation *= m_zRightAngleRotationNeg;
+ if (m_yFlippedForGrid)
+ totalRotation *= QQuaternion::fromAxisAndAngle(0.0f, 0.0f, 1.0f, -180.0f);
+ labelTrans.setZ(-m_graphAspectRatio);
+ radial = true;
+ }
drawAxisTitleX(labelRotation, labelTrans, totalRotation, m_dummyRenderItem,
- activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader);
+ activeCamera, labelsMaxWidth, viewMatrix, projectionMatrix, shader,
+ radial);
}
}
// Y Labels