summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/selectionpointer.cpp
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2013-09-26 10:46:01 +0300
committerMika Salmela <mika.salmela@digia.com>2013-09-26 12:22:27 +0300
commit037d0960a2bde8ad310a9917055c7c0c3488152a (patch)
tree79996eeaa3396d0e2670a070559fd7674f9db462 /src/datavisualization/engine/selectionpointer.cpp
parent88695159e16bdfb8424de99d482adf332a93740d (diff)
Slice view implemented
Implemented slice view and fixed selection mechanism. Task-number: QTRD-2321 Task-number: QTRD-2307 Change-Id: I492bd96678bb1bdb8020448e122931a0deccdc0d Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/engine/selectionpointer.cpp')
-rw-r--r--src/datavisualization/engine/selectionpointer.cpp79
1 files changed, 48 insertions, 31 deletions
diff --git a/src/datavisualization/engine/selectionpointer.cpp b/src/datavisualization/engine/selectionpointer.cpp
index 2476740d..3178863d 100644
--- a/src/datavisualization/engine/selectionpointer.cpp
+++ b/src/datavisualization/engine/selectionpointer.cpp
@@ -92,13 +92,24 @@ void SelectionPointer::render(GLuint defaultFboHandle)
{
Q_UNUSED(defaultFboHandle)
+ glViewport(m_mainViewPort.x(), m_mainViewPort.y(),
+ m_mainViewPort.width(), m_mainViewPort.height());
+
Q3DCamera *camera = m_cachedScene->activeCamera();
QSize textureSize = m_labelItem.size();
QMatrix4x4 itModelMatrix;
// Get view matrix
- QMatrix4x4 viewMatrix = camera->viewMatrix();
+ QMatrix4x4 viewMatrix;
+ if (m_cachedIsSlicingActivated) {
+ GLfloat camZPosSliced = 5.0f / m_autoScaleAdjustment + zComp;
+ viewMatrix.lookAt(QVector3D(0.0f, 0.0f, camZPosSliced),
+ QVector3D(0.0f, 0.0f, zComp),
+ QVector3D(0.0f, 1.0f, 0.0f));
+ } else {
+ viewMatrix = camera->viewMatrix();
+ }
itModelMatrix.scale(m_scale);
@@ -148,50 +159,50 @@ void SelectionPointer::render(GLuint defaultFboHandle)
//
// Draw the label
//
- if (m_labelItem.textureId()) {
- QMatrix4x4 modelMatrixLabel;
+ QMatrix4x4 modelMatrixLabel;
- // Position label
- QVector3D labelAlign(0.0f, 1.0f * scaledFontSize + 0.05f, 0.0f);
- modelMatrixLabel.translate(m_position * m_scale + labelAlign + QVector3D(0.0f, 0.0f, zComp));
+ // Position label
+ QVector3D labelAlign(0.0f, 1.0f * scaledFontSize + 0.05f, 0.0f);
+ modelMatrixLabel.translate(m_position * m_scale + labelAlign + QVector3D(0.0f, 0.0f, zComp));
- // Position the label towards the camera
- QPointF camRotations = camera->rotations();
+ // Position the label towards the camera
+ QPointF camRotations = camera->rotations();
+ if (!m_cachedIsSlicingActivated) {
modelMatrixLabel.rotate(-camRotations.x(), 0.0f, 1.0f, 0.0f);
modelMatrixLabel.rotate(-camRotations.y(), 1.0f, 0.0f, 0.0f);
+ }
- // Scale label based on text size
- modelMatrixLabel.scale(QVector3D((GLfloat)textureSize.width() * scaleFactor,
- scaledFontSize,
- 0.0f));
+ // Scale label based on text size
+ modelMatrixLabel.scale(QVector3D((GLfloat)textureSize.width() * scaleFactor,
+ scaledFontSize,
+ 0.0f));
- // Make label to be always on top
- glDisable(GL_DEPTH_TEST);
+ // Make label to be always on top
+ glDisable(GL_DEPTH_TEST);
- // Make label transparent
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ // Make label transparent
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- m_labelShader->bind();
+ m_labelShader->bind();
- // Set shader bindings
- MVPMatrix = projectionMatrix * viewMatrix * modelMatrixLabel;
- m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
+ // Set shader bindings
+ MVPMatrix = projectionMatrix * viewMatrix * modelMatrixLabel;
+ m_labelShader->setUniformValue(m_labelShader->MVP(), MVPMatrix);
- // Draw the object
- m_drawer->drawObject(m_labelShader, m_labelObj, m_labelItem.textureId());
+ // Draw the object
+ m_drawer->drawObject(m_labelShader, m_labelObj, m_labelItem.textureId());
- m_labelShader->release();
+ m_labelShader->release();
- // Disable textures
- glDisable(GL_TEXTURE_2D);
+ // Disable textures
+ glDisable(GL_TEXTURE_2D);
- // Disable transparency
- glDisable(GL_BLEND);
+ // Disable transparency
+ glDisable(GL_BLEND);
- // Depth test back to normal
- glEnable(GL_DEPTH_TEST);
- }
+ // Depth test back to normal
+ glEnable(GL_DEPTH_TEST);
}
void SelectionPointer::setPosition(QVector3D position)
@@ -204,6 +215,12 @@ void SelectionPointer::setScaling(QVector3D scaling)
m_scale = scaling;
}
+void SelectionPointer::updateSliceData(bool sliceActivated, GLfloat autoScaleAdjustment)
+{
+ m_cachedIsSlicingActivated = sliceActivated;
+ m_autoScaleAdjustment = autoScaleAdjustment;
+}
+
void SelectionPointer::setLabel(QString label)
{
m_label = label;