diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-01-22 10:00:08 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-01-22 10:15:56 +0200 |
commit | 892bd7976b2980947adf216b8afc5c6f2a63ce65 (patch) | |
tree | f38a25d0ebffd164b713860d8ed6b3f365398280 /src/datavisualization/utils | |
parent | 072b7614c6b1a1f32a4baebb8260866d72ee9299 (diff) |
Made jira tasks of TODOs, part 2
+ commented-out code and qDebugs removed
Task-number: QTRD-2398
Change-Id: Iab13e3ae9d672c0a3bcb4735b3fd1931b2eb7d86
Change-Id: Iab13e3ae9d672c0a3bcb4735b3fd1931b2eb7d86
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavisualization/utils')
-rw-r--r-- | src/datavisualization/utils/abstractobjecthelper_p.h | 2 | ||||
-rw-r--r-- | src/datavisualization/utils/camerahelper.cpp | 28 | ||||
-rw-r--r-- | src/datavisualization/utils/camerahelper_p.h | 4 | ||||
-rw-r--r-- | src/datavisualization/utils/meshloader.cpp | 7 | ||||
-rw-r--r-- | src/datavisualization/utils/objecthelper.cpp | 2 | ||||
-rw-r--r-- | src/datavisualization/utils/surfaceobject.cpp | 11 | ||||
-rw-r--r-- | src/datavisualization/utils/surfaceobject_p.h | 3 | ||||
-rw-r--r-- | src/datavisualization/utils/utils.cpp | 22 | ||||
-rw-r--r-- | src/datavisualization/utils/utils_p.h | 1 | ||||
-rw-r--r-- | src/datavisualization/utils/vertexindexer.cpp | 15 | ||||
-rw-r--r-- | src/datavisualization/utils/vertexindexer_p.h | 4 |
11 files changed, 16 insertions, 83 deletions
diff --git a/src/datavisualization/utils/abstractobjecthelper_p.h b/src/datavisualization/utils/abstractobjecthelper_p.h index c3bf39a9..82352024 100644 --- a/src/datavisualization/utils/abstractobjecthelper_p.h +++ b/src/datavisualization/utils/abstractobjecthelper_p.h @@ -62,4 +62,4 @@ public: QT_END_NAMESPACE_DATAVISUALIZATION -#endif // ABSTRACTOBJECTHELPER_H +#endif diff --git a/src/datavisualization/utils/camerahelper.cpp b/src/datavisualization/utils/camerahelper.cpp index 7800dfd1..ae134fe0 100644 --- a/src/datavisualization/utils/camerahelper.cpp +++ b/src/datavisualization/utils/camerahelper.cpp @@ -42,8 +42,6 @@ CameraHelper::~CameraHelper() { } - -// FUNCTIONS void CameraHelper::setRotationSpeed(int speed) { // increase for faster rotation @@ -106,7 +104,6 @@ QMatrix4x4 CameraHelper::calculateViewMatrix(const QPoint &mousePos, int zoom, viewMatrix.scale((GLfloat)zoom / 100.0f); // Compensate for translation (if m_target is off origin) viewMatrix.translate(-m_target.x(), -m_target.y(), -m_target.z()); - //qDebug() << m_xRotation << m_yRotation; m_previousMousePos = mousePos; return viewMatrix; @@ -135,7 +132,6 @@ QVector3D CameraHelper::calculateLightPosition(const QVector3D &lightPosition, newLightPosition = QVector3D(-xPos + lightPosition.x(), yPos + lightPosition.y(), zPos + lightPosition.z()); - //qDebug() << newLightPosition << xAngle << yAngle << fixedRotation; return newLightPosition; } @@ -159,122 +155,98 @@ void CameraHelper::setCameraPreset(Q3DCamera::CameraPreset preset) { switch (preset) { case Q3DCamera::CameraPresetFrontLow: { - qDebug("CameraPresetFrontLow"); CameraHelper::setCameraRotation(QPointF(0.0f, 0.0f)); break; } case Q3DCamera::CameraPresetFront: { - qDebug("CameraPresetFront"); CameraHelper::setCameraRotation(QPointF(0.0f, 22.5f)); break; } case Q3DCamera::CameraPresetFrontHigh: { - qDebug("CameraPresetFrontHigh"); CameraHelper::setCameraRotation(QPointF(0.0f, 45.0f)); break; } case Q3DCamera::CameraPresetLeftLow: { - qDebug("CameraPresetLeftLow"); CameraHelper::setCameraRotation(QPointF(90.0f, 0.0f)); break; } case Q3DCamera::CameraPresetLeft: { - qDebug("CameraPresetLeft"); CameraHelper::setCameraRotation(QPointF(90.0f, 22.5f)); break; } case Q3DCamera::CameraPresetLeftHigh: { - qDebug("CameraPresetLeftHigh"); CameraHelper::setCameraRotation(QPointF(90.0f, 45.0f)); break; } case Q3DCamera::CameraPresetRightLow: { - qDebug("CameraPresetRightLow"); CameraHelper::setCameraRotation(QPointF(-90.0f, 0.0f)); break; } case Q3DCamera::CameraPresetRight: { - qDebug("CameraPresetRight"); CameraHelper::setCameraRotation(QPointF(-90.0f, 22.5f)); break; } case Q3DCamera::CameraPresetRightHigh: { - qDebug("CameraPresetRightHigh"); CameraHelper::setCameraRotation(QPointF(-90.0f, 45.0f)); break; } case Q3DCamera::CameraPresetBehindLow: { - qDebug("CameraPresetBehindLow"); CameraHelper::setCameraRotation(QPointF(180.0f, 0.0f)); break; } case Q3DCamera::CameraPresetBehind: { - qDebug("CameraPresetBehind"); CameraHelper::setCameraRotation(QPointF(180.0f, 22.5f)); break; } case Q3DCamera::CameraPresetBehindHigh: { - qDebug("CameraPresetBehindHigh"); CameraHelper::setCameraRotation(QPointF(180.0f, 45.0f)); break; } case Q3DCamera::CameraPresetIsometricLeft: { - qDebug("CameraPresetIsometricLeft"); CameraHelper::setCameraRotation(QPointF(45.0f, 22.5f)); break; } case Q3DCamera::CameraPresetIsometricLeftHigh: { - qDebug("CameraPresetIsometricLeftHigh"); CameraHelper::setCameraRotation(QPointF(45.0f, 45.0f)); break; } case Q3DCamera::CameraPresetIsometricRight: { - qDebug("CameraPresetIsometricRight"); CameraHelper::setCameraRotation(QPointF(-45.0f, 22.5f)); break; } case Q3DCamera::CameraPresetIsometricRightHigh: { - qDebug("CameraPresetIsometricRightHigh"); CameraHelper::setCameraRotation(QPointF(-45.0f, 45.0f)); break; } case Q3DCamera::CameraPresetDirectlyAbove: { - qDebug("CameraPresetDirectlyAbove"); CameraHelper::setCameraRotation(QPointF(0.0f, 90.0f)); break; } case Q3DCamera::CameraPresetDirectlyAboveCW45: { - qDebug("CameraPresetDirectlyAboveCW45"); CameraHelper::setCameraRotation(QPointF(-45.0f, 90.0f)); break; } case Q3DCamera::CameraPresetDirectlyAboveCCW45: { - qDebug("CameraPresetDirectlyAboveCCW45"); CameraHelper::setCameraRotation(QPointF(45.0f, 90.0f)); break; } case Q3DCamera::CameraPresetFrontBelow: { - qDebug("CameraPresetFrontBelow"); CameraHelper::setCameraRotation(QPointF(0.0f, -45.0f)); break; } case Q3DCamera::CameraPresetLeftBelow: { - qDebug("CameraPresetLeftBelow"); CameraHelper::setCameraRotation(QPointF(90.0f, -45.0f)); break; } case Q3DCamera::CameraPresetRightBelow: { - qDebug("CameraPresetRightBelow"); CameraHelper::setCameraRotation(QPointF(-90.0f, -45.0f)); break; } case Q3DCamera::CameraPresetBehindBelow: { - qDebug("CameraPresetBehindBelow"); CameraHelper::setCameraRotation(QPointF(180.0f, -45.0f)); break; } case Q3DCamera::CameraPresetDirectlyBelow: { - qDebug("CameraPresetDirectlyBelow"); CameraHelper::setCameraRotation(QPointF(0.0f, -90.0f)); break; } diff --git a/src/datavisualization/utils/camerahelper_p.h b/src/datavisualization/utils/camerahelper_p.h index f85164f7..9a86dc2d 100644 --- a/src/datavisualization/utils/camerahelper_p.h +++ b/src/datavisualization/utils/camerahelper_p.h @@ -26,8 +26,8 @@ // // We mean it. -#ifndef CAMERAPOSITIONER_P_H -#define CAMERAPOSITIONER_P_H +#ifndef CAMERAHELPER_P_H +#define CAMERAHELPER_P_H #include "datavisualizationglobal_p.h" #include "q3dcamera.h" diff --git a/src/datavisualization/utils/meshloader.cpp b/src/datavisualization/utils/meshloader.cpp index a5fb7880..1d03e77c 100644 --- a/src/datavisualization/utils/meshloader.cpp +++ b/src/datavisualization/utils/meshloader.cpp @@ -24,8 +24,6 @@ #include <QVector2D> #include <QVector3D> -#include <QDebug> - QT_BEGIN_NAMESPACE_DATAVISUALIZATION QString slashTag = QStringLiteral("/"); @@ -35,8 +33,6 @@ bool MeshLoader::loadOBJ(const QString &path, QVector<QVector2D> &out_uvs, QVector<QVector3D> &out_normals) { - //qDebug() << "Loading OBJ file" << path; - QVector<unsigned int> vertexIndices, uvIndices, normalIndices; QVector<QVector3D> temp_vertices; QVector<QVector2D> temp_uvs; @@ -96,9 +92,6 @@ bool MeshLoader::loadOBJ(const QString &path, normalIndices.append(normalIndex[1]); normalIndices.append(normalIndex[2]); } - else { - //qWarning("Line did not contain usable data"); - } } // For each vertex of each triangle diff --git a/src/datavisualization/utils/objecthelper.cpp b/src/datavisualization/utils/objecthelper.cpp index 5c1bc43e..63b183f5 100644 --- a/src/datavisualization/utils/objecthelper.cpp +++ b/src/datavisualization/utils/objecthelper.cpp @@ -21,8 +21,6 @@ #include "objecthelper_p.h" #include "abstractobjecthelper_p.h" -#include <QDebug> - QT_BEGIN_NAMESPACE_DATAVISUALIZATION ObjectHelper::ObjectHelper(const QString &objectFile) diff --git a/src/datavisualization/utils/surfaceobject.cpp b/src/datavisualization/utils/surfaceobject.cpp index 790ca3f8..706c42a0 100644 --- a/src/datavisualization/utils/surfaceobject.cpp +++ b/src/datavisualization/utils/surfaceobject.cpp @@ -22,8 +22,6 @@ #include <QVector3D> #include <QVector2D> -#include <QDebug> - QT_BEGIN_NAMESPACE_DATAVISUALIZATION SurfaceObject::SurfaceObject() @@ -74,7 +72,8 @@ void SurfaceObject::setUpSmoothData(const QSurfaceDataArray &dataArray, const QR float normalizedX = ((data.x() - xMin) / xNormalizer); float normalizedY = ((data.y() - yMin) / yNormalizer); float normalizedZ = ((data.z() - zMin) / zNormalizer); - m_vertices[totalIndex] = QVector3D(normalizedX - 1.0f, normalizedY - 1.0f, normalizedZ + 1.0f); + m_vertices[totalIndex] = QVector3D(normalizedX - 1.0f, normalizedY - 1.0f, + normalizedZ + 1.0f); if (changeGeometry) uvs[totalIndex] = QVector2D(GLfloat(j) * uvX, GLfloat(i) * uvY); totalIndex++; @@ -195,7 +194,8 @@ void SurfaceObject::updateSmoothItem(const QSurfaceDataArray &dataArray, int row float normalizedX = ((data.x() - xMin) / xNormalizer); float normalizedY = ((data.y() - yMin) / yNormalizer); float normalizedZ = ((data.z() - zMin) / zNormalizer); - m_vertices[row * m_columns + column] = QVector3D(normalizedX - 1.0f, normalizedY - 1.0f, normalizedZ + 1.0f); + m_vertices[row * m_columns + column] = QVector3D(normalizedX - 1.0f, normalizedY - 1.0f, + normalizedZ + 1.0f); // Create normals int startRow = row; @@ -354,7 +354,8 @@ void SurfaceObject::setUpData(const QSurfaceDataArray &dataArray, const QRect &s float normalizedX = ((data.x() - xMin) / xNormalizer); float normalizedY = ((data.y() - yMin) / yNormalizer); float normalizedZ = ((data.z() - zMin) / zNormalizer); - m_vertices[totalIndex] = QVector3D(normalizedX - 1.0f, normalizedY - 1.0f, normalizedZ + 1.0f); + m_vertices[totalIndex] = QVector3D(normalizedX - 1.0f, normalizedY - 1.0f, + normalizedZ + 1.0f); if (changeGeometry) uvs[totalIndex] = QVector2D(GLfloat(j) * uvX, GLfloat(i) * uvY); diff --git a/src/datavisualization/utils/surfaceobject_p.h b/src/datavisualization/utils/surfaceobject_p.h index 6abbb8d4..5651a3da 100644 --- a/src/datavisualization/utils/surfaceobject_p.h +++ b/src/datavisualization/utils/surfaceobject_p.h @@ -33,7 +33,6 @@ #include "abstractobjecthelper_p.h" #include "qsurfacedataproxy.h" -#include <QOpenGLFunctions> #include <QRect> QT_BEGIN_NAMESPACE_DATAVISUALIZATION @@ -87,4 +86,4 @@ private: QT_END_NAMESPACE_DATAVISUALIZATION -#endif // SURFACEOBJECT_P_H +#endif diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index 30291963..78978c3c 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -74,10 +74,8 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo if (maxLabelWidth) valueStrWidth = maxLabelWidth + paddingWidth / 2; labelSize = QSize(valueStrWidth + prePadding, valueStrHeight + prePadding); - //qDebug() << "label size before padding" << text << labelSize; labelSize.setWidth(getNearestPowerOfTwo(labelSize.width(), paddingWidth)); labelSize.setHeight(getNearestPowerOfTwo(labelSize.height(), paddingHeight)); - //qDebug() << "label size after padding" << labelSize << paddingWidth << paddingHeight; #else if (!labelBackground) labelSize = QSize(valueStrWidth, valueStrHeight); @@ -131,30 +129,12 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo QVector3D Utils::getSelection(QPoint mousepos, int height) { - //#if defined(QT_OPENGL_ES_2) - // This is the only one that works with ANGLE (ES 2.0) + // This is the only one that works with OpenGL ES 2.0, so we're forced to use it // Item count will be limited to 256*256*256 GLubyte pixel[4] = {255, 255, 255, 0}; glReadPixels(mousepos.x(), height - mousepos.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void *)pixel); - - //qDebug() << "rgba" << pixel[0] << pixel[1] << pixel[2] << pixel[3] << "mousepos:" << mousepos << "height:" << height; - - //#else - // These work with desktop OpenGL - // They offer a lot higher possible object count and a possibility to use object ids - //GLuint pixel[3]; - //glReadPixels(mousepos.x(), height - mousepos.y(), 1, 1, - // GL_RGB, GL_UNSIGNED_INT, (void *)pixel); - //qDebug() << "rgba" << pixel[0] << pixel[1] << pixel[2];// << pixel[3]; - - //GLfloat pixel3[3]; - //glReadPixels(mousepos.x(), height - mousepos.y(), 1, 1, - // GL_RGB, GL_FLOAT, (void *)pixel3); - //qDebug() << "rgba" << pixel3[0] << pixel3[1] << pixel3[2];// << pixel[3]; - //#endif QVector3D selectedColor(pixel[0], pixel[1], pixel[2]); - //qDebug() << selectedColor; return selectedColor; } diff --git a/src/datavisualization/utils/utils_p.h b/src/datavisualization/utils/utils_p.h index 18337e0b..b53a6718 100644 --- a/src/datavisualization/utils/utils_p.h +++ b/src/datavisualization/utils/utils_p.h @@ -30,7 +30,6 @@ #define UTILS_P_H #include "datavisualizationglobal_p.h" -#include "q3dbars.h" class QVector3D; class QColor; diff --git a/src/datavisualization/utils/vertexindexer.cpp b/src/datavisualization/utils/vertexindexer.cpp index cb5d3ffc..ba3d20f9 100644 --- a/src/datavisualization/utils/vertexindexer.cpp +++ b/src/datavisualization/utils/vertexindexer.cpp @@ -18,11 +18,8 @@ #include "vertexindexer_p.h" -#include <string.h> // for memcmp #include <qmath.h> -#include <QDebug> - QT_BEGIN_NAMESPACE_DATAVISUALIZATION int unique_vertices = 0; @@ -33,8 +30,7 @@ bool VertexIndexer::is_near(float v1, float v2) return qAbs(v1 - v2) < 0.01f; } -// Searches through all already exported vertices -// for a similar one. +// Searches through all already exported vertices for a similar one. // Similar = same position + same UVs + same normal bool VertexIndexer::getSimilarVertexIndex(const QVector3D &in_vertex, const QVector2D &in_uv, @@ -44,7 +40,7 @@ bool VertexIndexer::getSimilarVertexIndex(const QVector3D &in_vertex, QVector<QVector3D> &out_normals, unsigned short &result) { - // Lame linear search + // Linear search for (int i = 0; i < out_vertices.size(); i++) { if (is_near(in_vertex.x() , out_vertices[i].x()) && is_near(in_vertex.y() , out_vertices[i].y()) @@ -58,8 +54,7 @@ bool VertexIndexer::getSimilarVertexIndex(const QVector3D &in_vertex, return true; } } - // No other vertex could be used instead. - // Looks like we'll have to add it to the VBO. + // No other vertex could be used instead return false; } @@ -107,7 +102,6 @@ void VertexIndexer::indexVBO(const QVector<QVector3D> &in_vertices, VertexToOutIndex[packed] = newindex; } } - //qDebug() << "unique vertices" << unique_vertices; } void VertexIndexer::indexVBO_TBN(const QVector<QVector3D> &in_vertices, @@ -125,7 +119,6 @@ void VertexIndexer::indexVBO_TBN(const QVector<QVector3D> &in_vertices, unique_vertices = 0; // For each input vertex for (int i = 0; i < in_vertices.size(); i++) { - // Try to find a similar vertex in out_XXXX unsigned short index; bool found = getSimilarVertexIndex(in_vertices[i], in_uvs[i], in_normals[i], @@ -133,7 +126,6 @@ void VertexIndexer::indexVBO_TBN(const QVector<QVector3D> &in_vertices, if (found) { out_indices.append(index); - // Average the tangents and the bitangents out_tangents[index] += in_tangents[i]; out_bitangents[index] += in_bitangents[i]; @@ -147,7 +139,6 @@ void VertexIndexer::indexVBO_TBN(const QVector<QVector3D> &in_vertices, out_indices.append((unsigned short)out_vertices.size() - 1); } } - //qDebug() << "unique vertices" << unique_vertices; } QT_END_NAMESPACE_DATAVISUALIZATION diff --git a/src/datavisualization/utils/vertexindexer_p.h b/src/datavisualization/utils/vertexindexer_p.h index 250c7a1b..0c5602d5 100644 --- a/src/datavisualization/utils/vertexindexer_p.h +++ b/src/datavisualization/utils/vertexindexer_p.h @@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION class VertexIndexer { - public: +public: struct PackedVertex { QVector3D position; QVector2D uv; @@ -69,7 +69,7 @@ class VertexIndexer QVector<QVector3D> &out_tangents, QVector<QVector3D> &out_bitangents); - private: +private: static bool is_near(float v1, float v2); static bool getSimilarVertexIndex(const QVector3D &in_vertex, const QVector2D &in_uv, |