summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/utils/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/utils/utils.cpp')
-rw-r--r--src/datavisualization/utils/utils.cpp32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp
index e6f33032..482fc831 100644
--- a/src/datavisualization/utils/utils.cpp
+++ b/src/datavisualization/utils/utils.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc
+** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
@@ -26,7 +26,7 @@
#include <QRegExp>
#include <qmath.h>
-QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_DATAVISUALIZATION
#define NUM_IN_POWER(y, x) for (;y<x;y<<=1)
#define MIN_POWER 2
@@ -66,7 +66,7 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo
valueStrWidth += paddingWidth / 2; // Fix clipping problem with skewed fonts (italic or italic-style)
QSize labelSize;
-#if defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
// Android can't handle textures with dimensions not in power of 2. Resize labels accordingly.
// Add some padding before converting to power of two to avoid too tight fit
GLuint prePadding = 5;
@@ -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);
@@ -97,7 +95,7 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo
painter.setFont(valueFont);
if (!labelBackground) {
painter.setPen(txtColor);
-#if defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
painter.drawText((labelSize.width() - valueStrWidth) / 2.0f,
(labelSize.height() - valueStrHeight) / 2.0f,
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;
}
@@ -239,4 +219,4 @@ float Utils::wrapValue(float value, float min, float max)
return value;
}
-QT_DATAVISUALIZATION_END_NAMESPACE
+QT_END_NAMESPACE_DATAVISUALIZATION