summaryrefslogtreecommitdiffstats
path: root/src/datavis3d/utils
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-04-16 11:24:34 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-04-16 11:37:27 +0300
commit30bb9a571d9bccba1fb45f07277a014b91ac043c (patch)
treedde7607bd1c2be6b959f81723fe449ea158a440e /src/datavis3d/utils
parentb228ba755311b8cb28e0253d9dbd111ae95ae90b (diff)
Object drawing and label generation moved to their own class
Change-Id: I3721b201dd83b471cb6d55f0dd7def908c4ab0be Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavis3d/utils')
-rw-r--r--src/datavis3d/utils/camerahelper.cpp22
-rw-r--r--src/datavis3d/utils/camerahelper_p.h16
-rw-r--r--src/datavis3d/utils/meshloader_p.h2
-rw-r--r--src/datavis3d/utils/objecthelper.cpp38
-rw-r--r--src/datavis3d/utils/shaderhelper.cpp32
-rw-r--r--src/datavis3d/utils/shaderhelper_p.h10
-rw-r--r--src/datavis3d/utils/texturehelper.cpp16
-rw-r--r--src/datavis3d/utils/texturehelper_p.h8
-rw-r--r--src/datavis3d/utils/utils.cpp93
-rw-r--r--src/datavis3d/utils/utils_p.h16
-rw-r--r--src/datavis3d/utils/vertexindexer.cpp68
-rw-r--r--src/datavis3d/utils/vertexindexer_p.h56
12 files changed, 182 insertions, 195 deletions
diff --git a/src/datavis3d/utils/camerahelper.cpp b/src/datavis3d/utils/camerahelper.cpp
index 4b8830a1..bd0f09f8 100644
--- a/src/datavis3d/utils/camerahelper.cpp
+++ b/src/datavis3d/utils/camerahelper.cpp
@@ -77,17 +77,17 @@ void CameraHelper::setCameraRotation(const QPointF &rotation)
m_defaultYRotation = m_yRotation;
}
-void CameraHelper::setDefaultCameraOrientation(const QVector3D &defaultPosition
- , const QVector3D &defaultTarget
- , const QVector3D &defaultUp)
+void CameraHelper::setDefaultCameraOrientation(const QVector3D &defaultPosition,
+ const QVector3D &defaultTarget,
+ const QVector3D &defaultUp)
{
m_position = defaultPosition;
m_target = defaultTarget;
m_up = defaultUp;
}
-QMatrix4x4 CameraHelper::calculateViewMatrix(const QPoint &mousePos, int zoom
- , int screenWidth, int screenHeight)
+QMatrix4x4 CameraHelper::calculateViewMatrix(const QPoint &mousePos, int zoom,
+ int screenWidth, int screenHeight)
{
QMatrix4x4 viewMatrix;
@@ -108,11 +108,7 @@ QMatrix4x4 CameraHelper::calculateViewMatrix(const QPoint &mousePos, int zoom
m_yRotation = 0;
// Apply to view matrix
- viewMatrix.lookAt(
- m_position // Camera is here
- , m_target // and looks here
- , m_up // Head is up (set to 0,-1,0 to look upside-down)
- );
+ viewMatrix.lookAt(m_position, m_target, m_up);
// Compensate for translation (if m_target is off origin)
viewMatrix.translate(m_target.x(), m_target.y(), m_target.z());
// Apply rotations
@@ -154,9 +150,9 @@ QVector3D CameraHelper::calculateLightPosition(const QVector3D &lightPosition, f
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 isometrically)
- newLightPosition = QVector3D(-xPos + lightPosition.x()
- , yPos + lightPosition.y()
- , zPos + lightPosition.z());
+ newLightPosition = QVector3D(-xPos + lightPosition.x(),
+ yPos + lightPosition.y(),
+ zPos + lightPosition.z());
//qDebug() << newLightPosition << xAngle << yAngle << fixedRotation;
return newLightPosition;
}
diff --git a/src/datavis3d/utils/camerahelper_p.h b/src/datavis3d/utils/camerahelper_p.h
index a27bbc3b..94dacffd 100644
--- a/src/datavis3d/utils/camerahelper_p.h
+++ b/src/datavis3d/utils/camerahelper_p.h
@@ -64,7 +64,7 @@ QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
class CameraHelper
{
-public:
+ public:
// How fast camera rotates when mouse is dragged. Default is 100.
static void setRotationSpeed(int speed);
// Set camera rotation in degrees
@@ -72,16 +72,16 @@ public:
// Get camera rotations
static QPointF getCameraRotations();
// Set default camera orientation. Position's x and y should be 0.
- static void setDefaultCameraOrientation(const QVector3D &defaultPosition
- , const QVector3D &defaultTarget
- , const QVector3D &defaultUp);
+ static void setDefaultCameraOrientation(const QVector3D &defaultPosition,
+ const QVector3D &defaultTarget,
+ const QVector3D &defaultUp);
// Calculate view matrix based on rotation and zoom
- static QMatrix4x4 calculateViewMatrix(const QPoint &mousePos, int zoom
- , int screenWidth, int screenHeight);
+ static QMatrix4x4 calculateViewMatrix(const QPoint &mousePos, int zoom,
+ 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
- , float fixedRotation = 0.0f);
+ static QVector3D calculateLightPosition(const QVector3D &lightPosition,
+ float fixedRotation = 0.0f);
static void updateMousePos(const QPoint &mousePos);
static void setCameraPreset(Q3DBars::CameraPreset preset);
};
diff --git a/src/datavis3d/utils/meshloader_p.h b/src/datavis3d/utils/meshloader_p.h
index c8baa1ac..514ae5c6 100644
--- a/src/datavis3d/utils/meshloader_p.h
+++ b/src/datavis3d/utils/meshloader_p.h
@@ -61,7 +61,7 @@ QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
class MeshLoader
{
-public:
+ public:
static bool loadOBJ(const QString &path,
QVector<QVector3D> &out_vertices,
QVector<QVector2D> &out_uvs,
diff --git a/src/datavis3d/utils/objecthelper.cpp b/src/datavis3d/utils/objecthelper.cpp
index b7f2fa42..a86994e9 100644
--- a/src/datavis3d/utils/objecthelper.cpp
+++ b/src/datavis3d/utils/objecthelper.cpp
@@ -48,13 +48,13 @@
QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
ObjectHelper::ObjectHelper(const QString &objectFile)
- : m_objectFile(objectFile)
- , m_vertexbuffer(0)
- , m_normalbuffer(0)
- , m_uvbuffer(0)
- , m_elementbuffer(0)
- , m_indexCount(0)
- , m_meshDataLoaded(false)
+ : m_objectFile(objectFile),
+ m_vertexbuffer(0),
+ m_normalbuffer(0),
+ m_uvbuffer(0),
+ m_elementbuffer(0),
+ m_indexCount(0),
+ m_meshDataLoaded(false)
{
initializeOpenGLFunctions();
}
@@ -95,33 +95,33 @@ void ObjectHelper::load()
QVector<QVector3D> indexed_vertices;
QVector<QVector2D> indexed_uvs;
QVector<QVector3D> indexed_normals;
- VertexIndexer::indexVBO(vertices, uvs, normals, indices, indexed_vertices, indexed_uvs
- , indexed_normals);
+ VertexIndexer::indexVBO(vertices, uvs, normals, indices, indexed_vertices, indexed_uvs,
+ indexed_normals);
m_indexCount = indices.size();
//qDebug() << "index count" << m_indexCount;
glGenBuffers(1, &m_vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
- glBufferData(GL_ARRAY_BUFFER, indexed_vertices.size() * sizeof(QVector3D)
- , &indexed_vertices.at(0)
- , GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, indexed_vertices.size() * sizeof(QVector3D),
+ &indexed_vertices.at(0),
+ GL_STATIC_DRAW);
glGenBuffers(1, &m_normalbuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_normalbuffer);
- glBufferData(GL_ARRAY_BUFFER, indexed_normals.size() * sizeof(QVector3D)
- , &indexed_normals.at(0)
- , GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, indexed_normals.size() * sizeof(QVector3D),
+ &indexed_normals.at(0),
+ GL_STATIC_DRAW);
glGenBuffers(1, &m_uvbuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_uvbuffer);
- glBufferData(GL_ARRAY_BUFFER, indexed_uvs.size() * sizeof(QVector2D)
- , &indexed_uvs.at(0), GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, indexed_uvs.size() * sizeof(QVector2D),
+ &indexed_uvs.at(0), GL_STATIC_DRAW);
glGenBuffers(1, &m_elementbuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementbuffer);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned short)
- , &indices.at(0), GL_STATIC_DRAW);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned short),
+ &indices.at(0), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
diff --git a/src/datavis3d/utils/shaderhelper.cpp b/src/datavis3d/utils/shaderhelper.cpp
index 66bcafd4..50cc564d 100644
--- a/src/datavis3d/utils/shaderhelper.cpp
+++ b/src/datavis3d/utils/shaderhelper.cpp
@@ -45,17 +45,17 @@
QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
-ShaderHelper::ShaderHelper(QObject *parent
- , const QString &vertexShader
- , const QString &fragmentShader
- , const QString &texture
- , const QString &depthTexture)
- : m_caller(parent)
- , m_program(0)
- , m_vertexShaderFile(vertexShader)
- , m_fragmentShaderFile(fragmentShader)
- , m_textureFile(texture)
- , m_depthTextureFile(depthTexture)
+ShaderHelper::ShaderHelper(QObject *parent,
+ const QString &vertexShader,
+ const QString &fragmentShader,
+ const QString &texture,
+ const QString &depthTexture)
+ : m_caller(parent),
+ m_program(0),
+ m_vertexShaderFile(vertexShader),
+ m_fragmentShaderFile(fragmentShader),
+ m_textureFile(texture),
+ m_depthTextureFile(depthTexture)
{
}
@@ -64,15 +64,15 @@ ShaderHelper::~ShaderHelper()
delete m_program;
}
-void ShaderHelper::setShaders(const QString &vertexShader
- , const QString &fragmentShader)
+void ShaderHelper::setShaders(const QString &vertexShader,
+ const QString &fragmentShader)
{
m_vertexShaderFile = vertexShader;
m_fragmentShaderFile = fragmentShader;
}
-void ShaderHelper::setTextures(const QString &texture
- , const QString &depthTexture)
+void ShaderHelper::setTextures(const QString &texture,
+ const QString &depthTexture)
{
m_textureFile = texture;
m_depthTextureFile = depthTexture;
@@ -219,6 +219,4 @@ GLuint ShaderHelper::normalAtt()
return m_normalAttr;
}
-// TODO: Add texture stuff
-
QTCOMMERCIALDATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3d/utils/shaderhelper_p.h b/src/datavis3d/utils/shaderhelper_p.h
index 29e3583b..986ca826 100644
--- a/src/datavis3d/utils/shaderhelper_p.h
+++ b/src/datavis3d/utils/shaderhelper_p.h
@@ -62,11 +62,11 @@ QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
class ShaderHelper
{
public:
- ShaderHelper(QObject *parent
- , const QString &vertexShader = QString()
- , const QString &fragmentShader = QString()
- , const QString &texture = QString()
- , const QString &depthTexture = QString());
+ ShaderHelper(QObject *parent,
+ const QString &vertexShader = QString(),
+ const QString &fragmentShader = QString(),
+ const QString &texture = QString(),
+ const QString &depthTexture = QString());
~ShaderHelper();
void setShaders(const QString &vertexShader, const QString &fragmentShader);
diff --git a/src/datavis3d/utils/texturehelper.cpp b/src/datavis3d/utils/texturehelper.cpp
index 99a3e6bf..428359a7 100644
--- a/src/datavis3d/utils/texturehelper.cpp
+++ b/src/datavis3d/utils/texturehelper.cpp
@@ -63,11 +63,11 @@ GLuint TextureHelper::create2DTexture(const QImage &image, bool useTrilinearFilt
glBindTexture(GL_TEXTURE_2D, textureId);
if (convert) {
QImage glTexture = convertToGLFormat(image);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, glTexture.width(), glTexture.height()
- , 0, GL_RGBA, GL_UNSIGNED_BYTE, glTexture.bits());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, glTexture.width(), glTexture.height(),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, glTexture.bits());
} else {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height()
- , 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits());
}
if (useTrilinearFiltering) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -87,8 +87,8 @@ GLuint TextureHelper::createCubeMapTexture(const QImage &image, bool useTrilinea
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);
QImage glTexture = convertToGLFormat(image);
- glTexImage2D(GL_TEXTURE_CUBE_MAP, 0, GL_RGBA, glTexture.width(), glTexture.height()
- , 0, GL_RGBA, GL_UNSIGNED_BYTE, glTexture.bits());
+ glTexImage2D(GL_TEXTURE_CUBE_MAP, 0, GL_RGBA, glTexture.width(), glTexture.height(),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, glTexture.bits());
if (useTrilinearFiltering) {
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
@@ -108,8 +108,8 @@ QImage TextureHelper::convertToGLFormat(const QImage &srcImage)
return res;
}
-void TextureHelper::convertToGLFormatHelper(QImage &dstImage, const QImage &srcImage
- , GLenum texture_format)
+void TextureHelper::convertToGLFormatHelper(QImage &dstImage, const QImage &srcImage,
+ GLenum texture_format)
{
Q_ASSERT(dstImage.depth() == 32);
Q_ASSERT(srcImage.depth() == 32);
diff --git a/src/datavis3d/utils/texturehelper_p.h b/src/datavis3d/utils/texturehelper_p.h
index 541c79ee..7fa0816b 100644
--- a/src/datavis3d/utils/texturehelper_p.h
+++ b/src/datavis3d/utils/texturehelper_p.h
@@ -60,16 +60,16 @@ QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
class TextureHelper: protected QOpenGLFunctions
{
-public:
+ public:
TextureHelper();
~TextureHelper();
// Ownership of created texture is transferred to caller
- GLuint create2DTexture(const QImage &image, bool useTrilinearFiltering = false
- , bool convert = true);
+ GLuint create2DTexture(const QImage &image, bool useTrilinearFiltering = false,
+ bool convert = true);
GLuint createCubeMapTexture(const QImage &image, bool useTrilinearFiltering = false);
-private:
+ private:
QImage convertToGLFormat(const QImage &srcImage);
void convertToGLFormatHelper(QImage &dstImage, const QImage &srcImage, GLenum texture_format);
QRgb qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture_format);
diff --git a/src/datavis3d/utils/utils.cpp b/src/datavis3d/utils/utils.cpp
index 89068c01..c6a17eae 100644
--- a/src/datavis3d/utils/utils.cpp
+++ b/src/datavis3d/utils/utils.cpp
@@ -60,16 +60,11 @@ QVector3D Utils::vectorFromColor(const QColor &color)
return QVector3D(color.redF(), color.greenF(), color.blueF());
}
-void Utils::printText(QPainter *painter, const QString &text, const QSize &position
- , bool absoluteCoords, qreal rotation, qreal scale)
+void Utils::printText(QPainter *painter, const QString &text, const QSize &position,
+ bool absoluteCoords, qreal rotation, qreal scale)
{
painter->save();
painter->setCompositionMode(QPainter::CompositionMode_Source);
- // TODO: None of the commented-out stuff works..
- //painter->setBackgroundMode(Qt::OpaqueMode);
- //painter->setBackground(QBrush(d_ptr->m_textBackgroundColor));
- //painter->setBrush(QBrush(d_ptr->m_textBackgroundColor));
- //painter->setPen(d_ptr->m_textBackgroundColor);
painter->setPen(Qt::black); // TODO: Use black, as nothing works
QFont bgrFont = QFont(QStringLiteral("Arial"), 17);
QFont valueFont = QFont(QStringLiteral("Arial"), 11);
@@ -85,40 +80,38 @@ void Utils::printText(QPainter *painter, const QString &text, const QSize &posit
bgrStr.append(QStringLiteral("I"));
bgrStrLen = bgrFM.width(bgrStr);
} while (bgrStrLen <= (valueStrLen + 8));
- //int bgrLen = valueStrLen + 10;
- //painter->drawRoundedRect(data->d_ptr->position().x() - (bgrLen / 2)
- // , data->d_ptr->position().y() - 30
- // , bgrLen, 30, 10.0, 10.0);
#if 0
// Hack solution, as drawRect doesn't work
- painter->drawText(position.width() - (bgrStrLen / 2)
- , position.height() - bgrHeight
- , bgrStrLen, bgrHeight
- , Qt::AlignCenter | Qt::AlignVCenter
- , bgrStr);
+ painter->drawText(position.width() - (bgrStrLen / 2),
+ position.height() - bgrHeight,
+ bgrStrLen, bgrHeight,
+ Qt::AlignCenter | Qt::AlignVCenter,
+ bgrStr);
//painter->setPen(d_ptr->m_textColor);
painter->setPen(Qt::lightGray); // TODO: Use lightGray, as nothing works
painter->setFont(valueFont);
- painter->drawText(position.width() - (valueStrLen / 2)
- , position.height() - bgrHeight
- , valueStrLen, bgrHeight
- , Qt::AlignCenter | Qt::AlignVCenter
- , text);
+ painter->drawText(position.width() - (valueStrLen / 2),
+ position.height() - bgrHeight,
+ valueStrLen, bgrHeight,
+ Qt::AlignCenter | Qt::AlignVCenter,
+ text);
#else
//qDebug() << painter->window() << painter->viewport();
painter->scale(scale, scale);
if (absoluteCoords) {
// This assumes absolute screen coordinates
- painter->translate(position.width() - (((float)bgrStrLen / 2.0f) * cos(rotation * m_pi / 180.0f))
- + (((float)bgrHeight / 2.0f) * sin(rotation * m_pi / 180.0f))
- , position.height()
+ painter->translate(position.width() - (((float)bgrStrLen / 2.0f)
+ * cos(rotation * m_pi / 180.0f))
+ + (((float)bgrHeight / 2.0f) * sin(rotation * m_pi / 180.0f)),
+ position.height()
- ((((float)bgrHeight / 2.0f) * cos(rotation * m_pi / 180.0f))
+ (((float)bgrStrLen / 2.0f) * sin(rotation * m_pi / 180.0f))));
} else {
// This calculates y as a distance from screen bottom
- painter->translate(position.width() - (((float)bgrStrLen / 2) * cos(rotation * m_pi / 180.0f))
- + (((float)bgrHeight / 2.0f) * sin(rotation * m_pi / 180.0f))
- , painter->window().height() - position.height()
+ painter->translate(position.width() - (((float)bgrStrLen / 2.0f)
+ * cos(rotation * m_pi / 180.0f))
+ + (((float)bgrHeight / 2.0f) * sin(rotation * m_pi / 180.0f)),
+ painter->window().height() - position.height()
- ((((float)bgrHeight / 2.0f) * cos(rotation * m_pi / 180.0f))
+ (((float)bgrStrLen / 2.0f) * sin(rotation * m_pi / 180.0f))));
}
@@ -126,24 +119,24 @@ void Utils::printText(QPainter *painter, const QString &text, const QSize &posit
// - ((((float)bgrHeight / 2.0f) * cos(rotation * m_pi / 180.0f))
// + (((float)bgrStrLen / 2.0f) * sin(rotation * m_pi / 180.0f)));
painter->rotate(rotation);
- painter->drawText(0, 0
- , bgrStrLen, bgrHeight
- , Qt::AlignCenter | Qt::AlignVCenter
- , bgrStr);
+ painter->drawText(0, 0,
+ bgrStrLen, bgrHeight,
+ Qt::AlignCenter | Qt::AlignVCenter,
+ bgrStr);
painter->setPen(Qt::lightGray); // TODO: Use lightGray, as nothing works
painter->setFont(valueFont);
- painter->drawText(6, 0
- , valueStrLen, bgrHeight
- , Qt::AlignCenter | Qt::AlignVCenter
- , text);
+ painter->drawText(6, 0,
+ valueStrLen, bgrHeight,
+ Qt::AlignCenter | Qt::AlignVCenter,
+ text);
painter->resetTransform();
#endif
painter->restore();
}
-QImage Utils::printTextToImage(const QFont &font, const QString &text, const QColor &bgrColor
- , const QColor &txtColor
- , Q3DBars::LabelTransparency transparency)
+QImage Utils::printTextToImage(const QFont &font, const QString &text, const QColor &bgrColor,
+ const QColor &txtColor,
+ Q3DBars::LabelTransparency transparency)
{
// Calculate text dimensions
QFont valueFont = font;
@@ -171,10 +164,10 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo
{
painter.setFont(valueFont);
painter.setPen(txtColor);
- painter.drawText(0, 0
- , valueStrWidth, valueStrHeight
- , Qt::AlignCenter | Qt::AlignVCenter
- , text);
+ painter.drawText(0, 0,
+ valueStrWidth, valueStrHeight,
+ Qt::AlignCenter | Qt::AlignVCenter,
+ text);
break;
}
case Q3DBars::TransparencyFromTheme:
@@ -184,10 +177,10 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo
painter.drawRoundedRect(0, 0, labelSize.width(), labelSize.height(), 10.0, 10.0f);
painter.setFont(valueFont);
painter.setPen(txtColor);
- painter.drawText(15, 15
- , valueStrWidth, valueStrHeight
- , Qt::AlignCenter | Qt::AlignVCenter
- , text);
+ painter.drawText(15, 15,
+ valueStrWidth, valueStrHeight,
+ Qt::AlignCenter | Qt::AlignVCenter,
+ text);
break;
}
case Q3DBars::TransparencyNone:
@@ -197,10 +190,10 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo
painter.drawRect(0, 0, labelSize.width(), labelSize.height());
painter.setFont(valueFont);
painter.setPen(txtColor);
- painter.drawText(15, 15
- , valueStrWidth, valueStrHeight
- , Qt::AlignCenter | Qt::AlignVCenter
- , text);
+ painter.drawText(15, 15,
+ valueStrWidth, valueStrHeight,
+ Qt::AlignCenter | Qt::AlignVCenter,
+ text);
break;
}
}
diff --git a/src/datavis3d/utils/utils_p.h b/src/datavis3d/utils/utils_p.h
index 4d49c0d5..abe47621 100644
--- a/src/datavis3d/utils/utils_p.h
+++ b/src/datavis3d/utils/utils_p.h
@@ -66,15 +66,15 @@ QTCOMMERCIALDATAVIS3D_BEGIN_NAMESPACE
class Utils
{
-public:
+ public:
static QVector3D vectorFromColor(const QColor &color);
- static void printText(QPainter *painter, const QString &text, const QSize &position
- , bool absoluteCoords = true, qreal rotation = 0, qreal scale = 1.0f);
- static QImage printTextToImage(const QFont &font
- , const QString &text
- , const QColor &bgrColor
- , const QColor &txtColor
- , Q3DBars::LabelTransparency transparency);
+ static void printText(QPainter *painter, const QString &text, const QSize &position,
+ bool absoluteCoords = true, qreal rotation = 0, qreal scale = 1.0f);
+ static QImage printTextToImage(const QFont &font,
+ const QString &text,
+ const QColor &bgrColor,
+ const QColor &txtColor,
+ Q3DBars::LabelTransparency transparency);
static QVector3D getSelection(QPoint mousepos, int height);
};
diff --git a/src/datavis3d/utils/vertexindexer.cpp b/src/datavis3d/utils/vertexindexer.cpp
index d10d7903..432e3895 100644
--- a/src/datavis3d/utils/vertexindexer.cpp
+++ b/src/datavis3d/utils/vertexindexer.cpp
@@ -59,13 +59,13 @@ bool VertexIndexer::is_near(float v1, float v2)
// 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
- , const QVector3D &in_normal
- , QVector<QVector3D> &out_vertices
- , QVector<QVector2D> &out_uvs
- , QVector<QVector3D> &out_normals
- , unsigned short &result)
+bool VertexIndexer::getSimilarVertexIndex(const QVector3D &in_vertex,
+ const QVector2D &in_uv,
+ const QVector3D &in_normal,
+ QVector<QVector3D> &out_vertices,
+ QVector<QVector2D> &out_uvs,
+ QVector<QVector3D> &out_normals,
+ unsigned short &result)
{
// Lame linear search
for (int i = 0; i < out_vertices.size(); i++) {
@@ -86,9 +86,9 @@ bool VertexIndexer::getSimilarVertexIndex(const QVector3D &in_vertex
return false;
}
-bool VertexIndexer::getSimilarVertexIndex_fast(const PackedVertex &packed
- , QMap<PackedVertex, unsigned short> &VertexToOutIndex
- , unsigned short &result)
+bool VertexIndexer::getSimilarVertexIndex_fast(const PackedVertex &packed,
+ QMap<PackedVertex, unsigned short> &VertexToOutIndex,
+ unsigned short &result)
{
QMap<PackedVertex, unsigned short>::iterator it = VertexToOutIndex.find(packed);
if (it == VertexToOutIndex.end()) {
@@ -99,13 +99,13 @@ bool VertexIndexer::getSimilarVertexIndex_fast(const PackedVertex &packed
}
}
-void VertexIndexer::indexVBO(const QVector<QVector3D> &in_vertices
- , const QVector<QVector2D> &in_uvs
- , const QVector<QVector3D> &in_normals
- , QVector<unsigned short> &out_indices
- , QVector<QVector3D> &out_vertices
- , QVector<QVector2D> &out_uvs
- , QVector<QVector3D> &out_normals)
+void VertexIndexer::indexVBO(const QVector<QVector3D> &in_vertices,
+ const QVector<QVector2D> &in_uvs,
+ const QVector<QVector3D> &in_normals,
+ QVector<unsigned short> &out_indices,
+ QVector<QVector3D> &out_vertices,
+ QVector<QVector2D> &out_uvs,
+ QVector<QVector3D> &out_normals)
{
unique_vertices = 0;
QMap<PackedVertex, unsigned short> VertexToOutIndex;
@@ -118,9 +118,9 @@ void VertexIndexer::indexVBO(const QVector<QVector3D> &in_vertices
unsigned short index;
bool found = getSimilarVertexIndex_fast(packed, VertexToOutIndex, index);
- if (found) { // A similar vertex is already in the VBO, use it instead !
+ if (found) {
out_indices.append(index);
- } else { // If not, it needs to be added in the output data.
+ } else {
unique_vertices++;
out_vertices.append(in_vertices[i]);
out_uvs.append(in_uvs[i]);
@@ -133,17 +133,17 @@ void VertexIndexer::indexVBO(const QVector<QVector3D> &in_vertices
qDebug() << "unique vertices" << unique_vertices;
}
-void VertexIndexer::indexVBO_TBN(const QVector<QVector3D> &in_vertices
- , const QVector<QVector2D> &in_uvs
- , const QVector<QVector3D> &in_normals
- , const QVector<QVector3D> &in_tangents
- , const QVector<QVector3D> &in_bitangents
- , QVector<unsigned short> &out_indices
- , QVector<QVector3D> &out_vertices
- , QVector<QVector2D> &out_uvs
- , QVector<QVector3D> &out_normals
- , QVector<QVector3D> &out_tangents
- , QVector<QVector3D> &out_bitangents)
+void VertexIndexer::indexVBO_TBN(const QVector<QVector3D> &in_vertices,
+ const QVector<QVector2D> &in_uvs,
+ const QVector<QVector3D> &in_normals,
+ const QVector<QVector3D> &in_tangents,
+ const QVector<QVector3D> &in_bitangents,
+ QVector<unsigned short> &out_indices,
+ QVector<QVector3D> &out_vertices,
+ QVector<QVector2D> &out_uvs,
+ QVector<QVector3D> &out_normals,
+ QVector<QVector3D> &out_tangents,
+ QVector<QVector3D> &out_bitangents)
{
unique_vertices = 0;
// For each input vertex
@@ -151,16 +151,16 @@ void VertexIndexer::indexVBO_TBN(const QVector<QVector3D> &in_vertices
// Try to find a similar vertex in out_XXXX
unsigned short index;
- bool found = getSimilarVertexIndex(in_vertices[i], in_uvs[i], in_normals[i]
- , out_vertices, out_uvs, out_normals, index);
+ bool found = getSimilarVertexIndex(in_vertices[i], in_uvs[i], in_normals[i],
+ out_vertices, out_uvs, out_normals, index);
- if (found) { // A similar vertex is already in the VBO, use it instead !
+ if (found) {
out_indices.append(index);
// Average the tangents and the bitangents
out_tangents[index] += in_tangents[i];
out_bitangents[index] += in_bitangents[i];
- } else { // If not, it needs to be added in the output data.
+ } else {
unique_vertices++;
out_vertices.append(in_vertices[i]);
out_uvs.append(in_uvs[i]);
diff --git a/src/datavis3d/utils/vertexindexer_p.h b/src/datavis3d/utils/vertexindexer_p.h
index 13824b22..3ee908af 100644
--- a/src/datavis3d/utils/vertexindexer_p.h
+++ b/src/datavis3d/utils/vertexindexer_p.h
@@ -72,38 +72,38 @@ class VertexIndexer
}
};
- static void indexVBO(const QVector<QVector3D> &in_vertices
- , const QVector<QVector2D> &in_uvs
- , const QVector<QVector3D> &in_normals
- , QVector<unsigned short> &out_indices
- , QVector<QVector3D> &out_vertices
- , QVector<QVector2D> &out_uvs
- , QVector<QVector3D> &out_normals);
+ static void indexVBO(const QVector<QVector3D> &in_vertices,
+ const QVector<QVector2D> &in_uvs,
+ const QVector<QVector3D> &in_normals,
+ QVector<unsigned short> &out_indices,
+ QVector<QVector3D> &out_vertices,
+ QVector<QVector2D> &out_uvs,
+ QVector<QVector3D> &out_normals);
- static void indexVBO_TBN(const QVector<QVector3D> &in_vertices
- , const QVector<QVector2D> &in_uvs
- , const QVector<QVector3D> &in_normals
- , const QVector<QVector3D> &in_tangents
- , const QVector<QVector3D> &in_bitangents
- , QVector<unsigned short> &out_indices
- , QVector<QVector3D> &out_vertices
- , QVector<QVector2D> &out_uvs
- , QVector<QVector3D> &out_normals
- , QVector<QVector3D> &out_tangents
- , QVector<QVector3D> &out_bitangents);
+ static void indexVBO_TBN(const QVector<QVector3D> &in_vertices,
+ const QVector<QVector2D> &in_uvs,
+ const QVector<QVector3D> &in_normals,
+ const QVector<QVector3D> &in_tangents,
+ const QVector<QVector3D> &in_bitangents,
+ QVector<unsigned short> &out_indices,
+ QVector<QVector3D> &out_vertices,
+ QVector<QVector2D> &out_uvs,
+ QVector<QVector3D> &out_normals,
+ QVector<QVector3D> &out_tangents,
+ QVector<QVector3D> &out_bitangents);
private:
static bool is_near(float v1, float v2);
- static bool getSimilarVertexIndex(const QVector3D &in_vertex
- , const QVector2D &in_uv
- , const QVector3D &in_normal
- , QVector<QVector3D> &out_vertices
- , QVector<QVector2D> &out_uvs
- , QVector<QVector3D> &out_normals
- , unsigned short &result);
- static bool getSimilarVertexIndex_fast(const PackedVertex &packed
- , QMap<PackedVertex, unsigned short> &VertexToOutIndex
- , unsigned short &result);
+ static bool getSimilarVertexIndex(const QVector3D &in_vertex,
+ const QVector2D &in_uv,
+ const QVector3D &in_normal,
+ QVector<QVector3D> &out_vertices,
+ QVector<QVector2D> &out_uvs,
+ QVector<QVector3D> &out_normals,
+ unsigned short &result);
+ static bool getSimilarVertexIndex_fast(const PackedVertex &packed,
+ QMap<PackedVertex, unsigned short> &VertexToOutIndex,
+ unsigned short &result);
};
QTCOMMERCIALDATAVIS3D_END_NAMESPACE