summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-04-09 07:54:31 +0300
committerMika Salmela <mika.salmela@digia.com>2013-04-09 09:34:15 +0300
commit19ad20b9f5f8ee6fe11fdcc6391f45afba8300bc (patch)
treed1f4361e39438b8db3d4bbd4b2230d9b4e7ea6c8 /src
parentea7a56dfd964e1dd8990973fb26601a0e97d4e8e (diff)
Disallowed rotating the zoom scene
Change-Id: I540a7718eb7652069eabb60747098001d79d6914 Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavis3d/engine/q3dbars.cpp33
-rw-r--r--src/datavis3d/engine/qdatarow.cpp4
-rw-r--r--src/datavis3d/engine/qdataset.cpp4
-rw-r--r--src/datavis3d/global/qdatavis3dglobal.h6
-rw-r--r--src/datavis3d/utils/camerahelper.cpp18
-rw-r--r--src/datavis3d/utils/camerahelper_p.h3
6 files changed, 45 insertions, 23 deletions
diff --git a/src/datavis3d/engine/q3dbars.cpp b/src/datavis3d/engine/q3dbars.cpp
index ad01785a..4485c491 100644
--- a/src/datavis3d/engine/q3dbars.cpp
+++ b/src/datavis3d/engine/q3dbars.cpp
@@ -218,8 +218,9 @@ void Q3DBars::drawZoomScene()
float barPosX = 0;
int startBar = 0;
- int stopBar = 0;
- int stepBar = 0;
+ int stopBar = d_ptr->m_zoomSelection->d_ptr->row().size();
+ int stepBar = 1;
+ QVector3D lightPos;
// Specify viewport
glViewport(d_ptr->m_zoomViewPort.x(), d_ptr->m_zoomViewPort.y()
@@ -230,25 +231,36 @@ void Q3DBars::drawZoomScene()
projectionMatrix.perspective(45.0f, (float)d_ptr->m_zoomViewPort.width()
/ (float)d_ptr->m_zoomViewPort.height(), 0.1f, 100.0f);
+#ifdef ROTATE_ZOOM_SELECTION
// Calculate view matrix
QMatrix4x4 viewMatrix = CameraHelper::calculateViewMatrix(d_ptr->m_mousePos
, d_ptr->m_zoomLevel
, d_ptr->m_zoomViewPort.width()
, d_ptr->m_zoomViewPort.height());
- if (viewMatrix.row(0).z() > 0) {
- startBar = 0;
- stopBar = d_ptr->m_zoomSelection->d_ptr->row().size();
- stepBar = 1;
- }
- else {
+ // Get light position (rotate light with camera, a bit above it (as set in defaultLightPos))
+ lightPos = CameraHelper::calculateLightPosition(defaultLightPos);
+
+ if (viewMatrix.row(0).z() <= 0) {
startBar = d_ptr->m_zoomSelection->d_ptr->row().size() - 1;
stopBar = -1;
stepBar = -1;
}
+#else
+ // Set view matrix
+ QMatrix4x4 viewMatrix;
+ viewMatrix.lookAt(QVector3D(0.0f, 0.0f, 6.0f + zComp)
+ , QVector3D(0.0f, 0.0f, zComp)
+ , QVector3D(0.0f, 1.0f, 0.0f));
- // Get light position (rotate light with camera, a bit above it (as set in defaultLightPos))
- QVector3D lightPos = CameraHelper::calculateLightPosition(defaultLightPos);
+ // Set light position a bit above the camera (depends on do we have row or column zoom)
+ if (ZoomColumn == d_ptr->m_selectionMode) {
+ lightPos = CameraHelper::calculateLightPosition(defaultLightPos, -85.0f);
+ }
+ else {
+ lightPos = CameraHelper::calculateLightPosition(defaultLightPos, 5.0f);
+ }
+#endif
// Bind bar shader
d_ptr->m_barShader->bind();
@@ -256,7 +268,6 @@ void Q3DBars::drawZoomScene()
// Draw bars
// bool barSelectionFound = false;
// Draw the selected row / column
- qDebug() << d_ptr->m_zoomSelection->d_ptr->row().size();
for (int bar = startBar; bar != stopBar; bar += stepBar) {
QDataItem *item = d_ptr->m_zoomSelection->d_ptr->getItem(bar);
if (!item)
diff --git a/src/datavis3d/engine/qdatarow.cpp b/src/datavis3d/engine/qdatarow.cpp
index 696f79e8..c18e86fe 100644
--- a/src/datavis3d/engine/qdatarow.cpp
+++ b/src/datavis3d/engine/qdatarow.cpp
@@ -51,12 +51,12 @@ QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
QDataRow::QDataRow(const QString &label)
: d_ptr(new QDataRowPrivate(this, label))
{
- qDebug("QDataRow");
+ //qDebug("QDataRow");
}
QDataRow::~QDataRow()
{
- qDebug("~QDataRow");
+ //qDebug("~QDataRow");
}
void QDataRow::setLabel(const QString &label)
diff --git a/src/datavis3d/engine/qdataset.cpp b/src/datavis3d/engine/qdataset.cpp
index 9fe42f9f..62c36fd2 100644
--- a/src/datavis3d/engine/qdataset.cpp
+++ b/src/datavis3d/engine/qdataset.cpp
@@ -52,12 +52,12 @@ QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
QDataSet::QDataSet()
: d_ptr(new QDataSetPrivate(this))
{
- qDebug("QDataSet");
+ //qDebug("QDataSet");
}
QDataSet::~QDataSet()
{
- qDebug("~QDataSet");
+ //qDebug("~QDataSet");
}
void QDataSet::setLabels(const QString &xAxis
diff --git a/src/datavis3d/global/qdatavis3dglobal.h b/src/datavis3d/global/qdatavis3dglobal.h
index 1a8bebc1..ac9a7f91 100644
--- a/src/datavis3d/global/qdatavis3dglobal.h
+++ b/src/datavis3d/global/qdatavis3dglobal.h
@@ -23,11 +23,13 @@
#include <qglobal.h>
-#define QTCOMMERCIALDATAVIS3D_VERSION_STR "1.2.0"
+//#define ROTATE_ZOOM_SELECTION
+
+#define QTCOMMERCIALDATAVIS3D_VERSION_STR "0.0.1"
/*
QTCOMMERCIALDATAVIS3D_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QTCOMMERCIALDATAVIS3D_VERSION 0x010200
+#define QTCOMMERCIALDATAVIS3D_VERSION 0x000001
/*
can be used like #if (QTCOMMERCIALDATAVIS3D_VERSION >= QTCOMMERCIALDATAVIS3D_VERSION_CHECK(1, 1, 0))
*/
diff --git a/src/datavis3d/utils/camerahelper.cpp b/src/datavis3d/utils/camerahelper.cpp
index 53fa57b4..d7f59b63 100644
--- a/src/datavis3d/utils/camerahelper.cpp
+++ b/src/datavis3d/utils/camerahelper.cpp
@@ -137,22 +137,30 @@ QMatrix4x4 CameraHelper::calculateViewMatrix(const QPoint &mousePos, int zoom
return viewMatrix;
}
-QVector3D CameraHelper::calculateLightPosition(const QVector3D &lightPosition)
+QVector3D CameraHelper::calculateLightPosition(const QVector3D &lightPosition, float fixedRotation)
{
// Move light with camera
QVector3D newLightPosition;
+ float xAngle;
+ float yAngle;
+ if (!fixedRotation) {
+ xAngle = m_xRotation * m_pi / 180;
+ yAngle = m_yRotation * m_pi / 180;
+ }
+ else {
+ xAngle = fixedRotation * m_pi / 180;
+ yAngle = 0;
+ }
float radius = lightPosition.y() * 2.0f; // set radius to match the highest height of the light
- float xAngle = m_xRotation * m_pi / 180;
- float yAngle = m_yRotation * m_pi / 180;
float zPos = radius * cos(xAngle) * cos(yAngle);
float xPos = radius * sin(xAngle) * cos(yAngle);
float yPos = lightPosition.y() * sin(yAngle);
// Keep light in the set position in relation to camera
- // TODO: Does not work perfectly yet; Light seems wrong when viewing scene from sides (or isometricly)
+ // TODO: Does not work perfectly yet; Light seems wrong when viewing scene from sides (or isometrically)
newLightPosition = QVector3D(-xPos + lightPosition.x()
, yPos + lightPosition.y()
, zPos + lightPosition.z());
- //qDebug() << newLightPosition << xAngle << yAngle;
+ //qDebug() << newLightPosition << xAngle << yAngle << fixedRotation;
return newLightPosition;
}
diff --git a/src/datavis3d/utils/camerahelper_p.h b/src/datavis3d/utils/camerahelper_p.h
index f6153def..d5b1e206 100644
--- a/src/datavis3d/utils/camerahelper_p.h
+++ b/src/datavis3d/utils/camerahelper_p.h
@@ -67,7 +67,8 @@ public:
, int screenWidth, int screenHeight);
// Calcluate light position based on rotation. Call after calling calculateViewMatrix to get
// up-to-date position
- static QVector3D calculateLightPosition(const QVector3D &lightPosition);
+ static QVector3D calculateLightPosition(const QVector3D &lightPosition
+ , float fixedRotation = 0.0f);
static void updateMousePos(const QPoint &mousePos);
};