summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Walters <ian.walters@nokia.com>2009-05-06 06:54:58 (GMT)
committerIan Walters <ian.walters@nokia.com>2009-05-06 06:54:58 (GMT)
commitcef84f75ec56c7ebced81faaf12d5f9bc809f4ca (patch)
tree2f7a8941bb977384db9cb135bff801b0e5b3063a
parent05fce71fbbd9b70f19f8a7cb37cd85651533cd62 (diff)
parent8b6dd696ca99d928e44c7ed706cc9c348f2024ec (diff)
downloadQt-cef84f75ec56c7ebced81faaf12d5f9bc809f4ca.zip
Qt-cef84f75ec56c7ebced81faaf12d5f9bc809f4ca.tar.gz
Qt-cef84f75ec56c7ebced81faaf12d5f9bc809f4ca.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/boxes/boxes.pro3
-rw-r--r--demos/boxes/glbuffers.cpp26
-rw-r--r--demos/boxes/glbuffers.h8
-rw-r--r--demos/boxes/qtbox.cpp33
-rw-r--r--demos/boxes/qtbox.h8
-rw-r--r--demos/boxes/roundedbox.cpp21
-rw-r--r--demos/boxes/roundedbox.h9
-rw-r--r--demos/boxes/scene.cpp86
-rw-r--r--demos/boxes/scene.h6
-rw-r--r--demos/boxes/trackball.cpp50
-rw-r--r--demos/boxes/trackball.h17
-rw-r--r--demos/boxes/vector.h602
-rw-r--r--doc/src/declarative/focus.qdoc4
-rw-r--r--doc/src/declarative/qmlviewer.qdoc (renamed from doc/src/qmlviewer.qdoc)6
-rw-r--r--doc/src/declarative/qtprogrammers.qdoc2
-rw-r--r--src/declarative/debugger/debugger.pri3
-rw-r--r--src/declarative/debugger/qmldebugger.cpp243
-rw-r--r--src/declarative/debugger/qmldebugger.h82
-rw-r--r--src/declarative/declarative.pro1
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp11
-rw-r--r--src/declarative/extra/qmlxmllistmodel.h2
-rw-r--r--src/declarative/fx/qfxpathview.cpp6
-rw-r--r--src/declarative/fx/qfxwebview.cpp28
-rw-r--r--src/declarative/qml/qmlboundsignal.cpp1
-rw-r--r--src/declarative/qml/qmlcompiler.cpp9
-rw-r--r--src/declarative/qml/qmlcomponent.cpp5
-rw-r--r--src/declarative/qml/qmlcontext.cpp2
-rw-r--r--src/declarative/qml/qmlcontext_p.h3
-rw-r--r--src/declarative/qml/qmlinstruction_p.h1
-rw-r--r--src/declarative/qml/qmlparser.cpp2
-rw-r--r--src/declarative/qml/qmlparser_p.h3
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp5
-rw-r--r--src/declarative/util/qfxview.cpp10
-rw-r--r--src/declarative/util/qmllistmodel.cpp59
-rw-r--r--src/declarative/util/qmlopenmetaobject.cpp1
-rw-r--r--src/opengl/qglshaderprogram.cpp302
-rw-r--r--src/opengl/qglshaderprogram.h67
-rw-r--r--src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp2
38 files changed, 869 insertions, 860 deletions
diff --git a/demos/boxes/boxes.pro b/demos/boxes/boxes.pro
index a7b19a3..33f1f14 100644
--- a/demos/boxes/boxes.pro
+++ b/demos/boxes/boxes.pro
@@ -15,8 +15,7 @@ HEADERS += 3rdparty/fbm.h \
qtbox.h \
roundedbox.h \
scene.h \
- trackball.h \
- vector.h
+ trackball.h
SOURCES += 3rdparty/fbm.c \
glbuffers.cpp \
glextensions.cpp \
diff --git a/demos/boxes/glbuffers.cpp b/demos/boxes/glbuffers.cpp
index b2a594e..a25a425 100644
--- a/demos/boxes/glbuffers.cpp
+++ b/demos/boxes/glbuffers.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "glbuffers.h"
+#include <QtGui/qmatrix4x4.h>
//============================================================================//
// GLTexture //
@@ -346,7 +347,7 @@ void GLRenderTargetCube::end()
m_fbo.setAsRenderTarget(false);
}
-void GLRenderTargetCube::getViewMatrix(gfx::Matrix4x4f& mat, int face)
+void GLRenderTargetCube::getViewMatrix(QMatrix4x4& mat, int face)
{
if (face < 0 || face >= 6) {
qWarning("GLRenderTargetCube::getViewMatrix: 'face' must be in the range [0, 6). (face == %d)", face);
@@ -371,20 +372,21 @@ void GLRenderTargetCube::getViewMatrix(gfx::Matrix4x4f& mat, int face)
{-1.0f, -1.0f, +1.0f},
};
- memset(mat.bits(), 0, sizeof(float) * 16);
+ memset(mat.data(), 0, sizeof(float) * 16);
for (int i = 0; i < 3; ++i)
- mat(perm[face][i], i) = signs[face][i];
+ mat(i, perm[face][i]) = signs[face][i];
mat(3, 3) = 1.0f;
}
-void GLRenderTargetCube::getProjectionMatrix(gfx::Matrix4x4f& mat, float nearZ, float farZ)
+void GLRenderTargetCube::getProjectionMatrix(QMatrix4x4& mat, float nearZ, float farZ)
{
- float proj[] = {
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, (nearZ+farZ)/(nearZ-farZ), -1.0f,
- 0.0f, 0.0f, 2.0f*nearZ*farZ/(nearZ-farZ), 0.0f,
- };
-
- memcpy(mat.bits(), proj, sizeof(float) * 16);
+ static const QMatrix4x4 reference(
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, -1.0f, 0.0f);
+
+ mat = reference;
+ mat(2, 2) = (nearZ+farZ)/(nearZ-farZ);
+ mat(2, 3) = 2.0f*nearZ*farZ/(nearZ-farZ);
}
diff --git a/demos/boxes/glbuffers.h b/demos/boxes/glbuffers.h
index 88de4e8..392924e 100644
--- a/demos/boxes/glbuffers.h
+++ b/demos/boxes/glbuffers.h
@@ -48,8 +48,6 @@
#include <QtGui>
#include <QtOpenGL>
-#include "vector.h"
-
#define BUFFER_OFFSET(i) ((char*)0 + (i))
#define SIZE_OF_MEMBER(cls, member) sizeof(static_cast<cls *>(0)->member)
@@ -60,6 +58,8 @@ if (m_failed || !(assertion)) {
returnStatement; \
}
+class QMatrix4x4;
+
class GLTexture
{
public:
@@ -135,8 +135,8 @@ public:
void end();
virtual bool failed() {return m_failed || m_fbo.failed();}
- static void getViewMatrix(gfx::Matrix4x4f& mat, int face);
- static void getProjectionMatrix(gfx::Matrix4x4f& mat, float nearZ, float farZ);
+ static void getViewMatrix(QMatrix4x4& mat, int face);
+ static void getProjectionMatrix(QMatrix4x4& mat, float nearZ, float farZ);
private:
GLFrameBufferObject m_fbo;
};
diff --git a/demos/boxes/qtbox.cpp b/demos/boxes/qtbox.cpp
index 0607698..ba9f95d 100644
--- a/demos/boxes/qtbox.cpp
+++ b/demos/boxes/qtbox.cpp
@@ -269,19 +269,20 @@ bool ItemBase::isInResizeArea(const QPointF &pos)
QtBox::QtBox(int size, int x, int y) : ItemBase(size, x, y), m_texture(0)
{
for (int i = 0; i < 8; ++i) {
- m_vertices[i][0] = (i & 1 ? 0.5f : -0.5f);
- m_vertices[i][1] = (i & 2 ? 0.5f : -0.5f);
- m_vertices[i][2] = (i & 4 ? 0.5f : -0.5f);
+ m_vertices[i].setX(i & 1 ? 0.5f : -0.5f);
+ m_vertices[i].setY(i & 2 ? 0.5f : -0.5f);
+ m_vertices[i].setZ(i & 4 ? 0.5f : -0.5f);
}
for (int i = 0; i < 4; ++i) {
- m_texCoords[i][0] = (i & 1 ? 1.0f : 0.0f);
- m_texCoords[i][1] = (i & 2 ? 1.0f : 0.0f);
- }
- memset(m_normals, 0, sizeof(m_normals));
- for (int i = 0; i < 3; ++i) {
- m_normals[2 * i + 0][i] = -1.0f;
- m_normals[2 * i + 1][i] = 1.0f;
+ m_texCoords[i].setX(i & 1 ? 1.0f : 0.0f);
+ m_texCoords[i].setY(i & 2 ? 1.0f : 0.0f);
}
+ m_normals[0] = QVector3D(-1.0f, 0.0f, 0.0f);
+ m_normals[1] = QVector3D(1.0f, 0.0f, 0.0f);
+ m_normals[2] = QVector3D(0.0f, -1.0f, 0.0f);
+ m_normals[3] = QVector3D(0.0f, 1.0f, 0.0f);
+ m_normals[4] = QVector3D(0.0f, 0.0f, -1.0f);
+ m_normals[5] = QVector3D(0.0f, 0.0f, 1.0f);
}
QtBox::~QtBox()
@@ -351,21 +352,21 @@ void QtBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
glColor4f(1.0f, 1.0f, 1.0f, 1.0);
glBegin(GL_TRIANGLE_STRIP);
- glNormal3fv(m_normals[2 * dir + 0].bits());
+ glNormal3fv(reinterpret_cast<float *>(&m_normals[2 * dir + 0]));
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) {
- glTexCoord2fv(m_texCoords[(j << 1) | i].bits());
- glVertex3fv(m_vertices[(i << ((dir + 2) % 3)) | (j << ((dir + 1) % 3))].bits());
+ glTexCoord2fv(reinterpret_cast<float *>(&m_texCoords[(j << 1) | i]));
+ glVertex3fv(reinterpret_cast<float *>(&m_vertices[(i << ((dir + 2) % 3)) | (j << ((dir + 1) % 3))]));
}
}
glEnd();
glBegin(GL_TRIANGLE_STRIP);
- glNormal3fv(m_normals[2 * dir + 1].bits());
+ glNormal3fv(reinterpret_cast<float *>(&m_normals[2 * dir + 1]));
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) {
- glTexCoord2fv(m_texCoords[(j << 1) | i].bits());
- glVertex3fv(m_vertices[(1 << dir) | (i << ((dir + 1) % 3)) | (j << ((dir + 2) % 3))].bits());
+ glTexCoord2fv(reinterpret_cast<float *>(&m_texCoords[(j << 1) | i]));
+ glVertex3fv(reinterpret_cast<float *>(&m_vertices[(1 << dir) | (i << ((dir + 1) % 3)) | (j << ((dir + 2) % 3))]));
}
}
glEnd();
diff --git a/demos/boxes/qtbox.h b/demos/boxes/qtbox.h
index aae8256..5042077 100644
--- a/demos/boxes/qtbox.h
+++ b/demos/boxes/qtbox.h
@@ -44,7 +44,7 @@
#include <QtGui>
-#include "vector.h"
+#include <QtGui/qvector3d.h>
#include "glbuffers.h"
class ItemBase : public QObject, public QGraphicsItem
@@ -85,9 +85,9 @@ public:
protected:
virtual ItemBase *createNew(int size, int x, int y);
private:
- gfx::Vector3f m_vertices[8];
- gfx::Vector2f m_texCoords[4];
- gfx::Vector3f m_normals[6];
+ QVector3D m_vertices[8];
+ QVector3D m_texCoords[4];
+ QVector3D m_normals[6];
GLTexture *m_texture;
};
diff --git a/demos/boxes/roundedbox.cpp b/demos/boxes/roundedbox.cpp
index f238da2..93ebce7 100644
--- a/demos/boxes/roundedbox.cpp
+++ b/demos/boxes/roundedbox.cpp
@@ -46,9 +46,10 @@
//============================================================================//
VertexDescription P3T2N3Vertex::description[] = {
- {VertexDescription::Position, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, position) / sizeof(float), offsetof(P3T2N3Vertex, position), 0},
- {VertexDescription::TexCoord, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, texCoord) / sizeof(float), offsetof(P3T2N3Vertex, texCoord), 0},
- {VertexDescription::Normal, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, normal) / sizeof(float), offsetof(P3T2N3Vertex, normal), 0},
+ {VertexDescription::Position, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, position) / sizeof(float), 0, 0},
+ {VertexDescription::TexCoord, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, texCoord) / sizeof(float), sizeof(QVector3D), 0},
+ {VertexDescription::Normal, GL_FLOAT, SIZE_OF_MEMBER(P3T2N3Vertex, normal) / sizeof(float), sizeof(QVector3D) + sizeof(QVector2D), 0},
+
{VertexDescription::Null, 0, 0, 0, 0},
};
@@ -78,10 +79,9 @@ GLRoundedBox::GLRoundedBox(float r, float scale, int n)
}
for (int corner = 0; corner < 8; ++corner) {
- gfx::Vector3f centre;
- centre[0] = (corner & 1 ? 1.0f : -1.0f);
- centre[1] = (corner & 2 ? 1.0f : -1.0f);
- centre[2] = (corner & 4 ? 1.0f : -1.0f);
+ QVector3D centre(corner & 1 ? 1.0f : -1.0f,
+ corner & 2 ? 1.0f : -1.0f,
+ corner & 4 ? 1.0f : -1.0f);
int winding = (corner & 1) ^ ((corner >> 1) & 1) ^ (corner >> 2);
int offsX = ((corner ^ 1) - corner) * vertexCountPerCorner;
int offsY = ((corner ^ 2) - corner) * vertexCountPerCorner;
@@ -129,12 +129,13 @@ GLRoundedBox::GLRoundedBox(float r, float scale, int n)
}
for (int j = 0; j <= i; ++j) {
- gfx::Vector3f normal = gfx::Vector3f::vector(i - j, j, n + 1 - i).normalized();
- gfx::Vector3f pos = centre * (0.5f - r + r * normal);
+ QVector3D normal = QVector3D(i - j, j, n + 1 - i).normalized();
+ QVector3D offset(0.5f - r, 0.5f - r, 0.5f - r);
+ QVector3D pos = centre * (offset + r * normal);
vp[vidx].position = scale * pos;
vp[vidx].normal = centre * normal;
- vp[vidx].texCoord = gfx::Vector2f::vector(pos[0], pos[1]) + 0.5f;
+ vp[vidx].texCoord = QVector2D(pos.x() + 0.5f, pos.y() + 0.5f);
// Corner polygons
if (i < n + 1) {
diff --git a/demos/boxes/roundedbox.h b/demos/boxes/roundedbox.h
index b934ade..65b545e 100644
--- a/demos/boxes/roundedbox.h
+++ b/demos/boxes/roundedbox.h
@@ -49,14 +49,15 @@
#include <QtOpenGL>
#include "gltrianglemesh.h"
-#include "vector.h"
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector2d.h>
#include "glbuffers.h"
struct P3T2N3Vertex
{
- gfx::Vector3f position;
- gfx::Vector2f texCoord;
- gfx::Vector3f normal;
+ QVector3D position;
+ QVector2D texCoord;
+ QVector3D normal;
static VertexDescription description[];
};
diff --git a/demos/boxes/scene.cpp b/demos/boxes/scene.cpp
index 5f1fe14..e2aa16b 100644
--- a/demos/boxes/scene.cpp
+++ b/demos/boxes/scene.cpp
@@ -39,7 +39,10 @@
**
****************************************************************************/
+#include <QDebug>
#include "scene.h"
+#include <QtGui/qmatrix4x4.h>
+#include <QtGui/qvector3d.h>
#include "3rdparty/fbm.h"
@@ -484,9 +487,9 @@ Scene::Scene(int width, int height, int maxTextureSize)
{
setSceneRect(0, 0, width, height);
- m_trackBalls[0] = TrackBall(0.0005f, gfx::Vector3f::vector(0, 1, 0), TrackBall::Sphere);
- m_trackBalls[1] = TrackBall(0.0001f, gfx::Vector3f::vector(0, 0, 1), TrackBall::Sphere);
- m_trackBalls[2] = TrackBall(0.0f, gfx::Vector3f::vector(0, 1, 0), TrackBall::Plane);
+ m_trackBalls[0] = TrackBall(0.05f, QVector3D(0, 1, 0), TrackBall::Sphere);
+ m_trackBalls[1] = TrackBall(0.005f, QVector3D(0, 0, 1), TrackBall::Sphere);
+ m_trackBalls[2] = TrackBall(0.0f, QVector3D(0, 1, 0), TrackBall::Plane);
m_renderOptions = new RenderOptionsDialog;
m_renderOptions->move(20, 120);
@@ -620,11 +623,11 @@ void Scene::initGL()
if (!program->link()) {
qWarning("Failed to compile and link shader program");
qWarning("Vertex shader log:");
- qWarning() << m_vertexShader->errors();
+ qWarning() << m_vertexShader->log();
qWarning() << "Fragment shader log ( file =" << file.absoluteFilePath() << "):";
- qWarning() << shader->errors();
+ qWarning() << shader->log();
qWarning("Shader program log:");
- qWarning() << program->errors();
+ qWarning() << program->log();
delete shader;
delete program;
@@ -648,9 +651,9 @@ void Scene::initGL()
// If one of the boxes should not be rendered, set excludeBox to its index.
// If the main box should not be rendered, set excludeBox to -1.
-void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox)
+void Scene::renderBoxes(const QMatrix4x4 &view, int excludeBox)
{
- gfx::Matrix4x4f invView = view.inverse();
+ QMatrix4x4 invView = view.inverted();
// If multi-texturing is supported, use three saplers.
if (glActiveTexture) {
@@ -666,11 +669,11 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox)
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
- gfx::Matrix4x4f viewRotation(view);
+ QMatrix4x4 viewRotation(view);
viewRotation(3, 0) = viewRotation(3, 1) = viewRotation(3, 2) = 0.0f;
viewRotation(0, 3) = viewRotation(1, 3) = viewRotation(2, 3) = 0.0f;
viewRotation(3, 3) = 1.0f;
- glLoadMatrixf(viewRotation.bits());
+ glLoadMatrixf(viewRotation.data());
glScalef(20.0f, 20.0f, 20.0f);
// Don't render the environment if the environment texture can't be set for the correct sampler.
@@ -685,7 +688,7 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox)
m_environment->unbind();
}
- glLoadMatrixf(view.bits());
+ glLoadMatrixf(view.data());
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
@@ -695,9 +698,11 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox)
continue;
glPushMatrix();
- gfx::Matrix4x4f m;
- m_trackBalls[1].rotation().matrix(m);
- glMultMatrixf(m.bits());
+ QMatrix4x4 m;
+ m.rotate(m_trackBalls[1].rotation());
+ m = m.transposed();
+
+ glMultMatrixf(m.data());
glRotatef(360.0f * i / m_programs.size(), 0.0f, 0.0f, 1.0f);
glTranslatef(2.0f, 0.0f, 0.0f);
@@ -713,12 +718,8 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox)
m_programs[i]->setUniformValue("tex", GLint(0));
m_programs[i]->setUniformValue("env", GLint(1));
m_programs[i]->setUniformValue("noise", GLint(2));
- QMatrix4x4 mview;
- QMatrix4x4 minvview;
- memcpy(mview.data(), view.bits(), sizeof(float) * 16);
- memcpy(minvview.data(), invView.bits(), sizeof(float) * 16);
- m_programs[i]->setUniformValue("view", mview);
- m_programs[i]->setUniformValue("invView", minvview);
+ m_programs[i]->setUniformValue("view", view);
+ m_programs[i]->setUniformValue("invView", invView);
m_box->draw();
m_programs[i]->disable();
@@ -732,9 +733,10 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox)
}
if (-1 != excludeBox) {
- gfx::Matrix4x4f m;
- m_trackBalls[0].rotation().matrix(m);
- glMultMatrixf(m.bits());
+ QMatrix4x4 m;
+ m.rotate(m_trackBalls[0].rotation());
+ m = m.transposed();
+ glMultMatrixf(m.data());
if (glActiveTexture) {
if (m_dynamicCubemap)
@@ -747,12 +749,8 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox)
m_programs[m_currentShader]->setUniformValue("tex", GLint(0));
m_programs[m_currentShader]->setUniformValue("env", GLint(1));
m_programs[m_currentShader]->setUniformValue("noise", GLint(2));
- QMatrix4x4 mview;
- QMatrix4x4 minvview;
- memcpy(mview.data(), view.bits(), sizeof(float) * 16);
- memcpy(minvview.data(), invView.bits(), sizeof(float) * 16);
- m_programs[m_currentShader]->setUniformValue("view", mview);
- m_programs[m_currentShader]->setUniformValue("invView", minvview);
+ m_programs[m_currentShader]->setUniformValue("view", view);
+ m_programs[m_currentShader]->setUniformValue("invView", invView);
m_box->draw();
m_programs[m_currentShader]->disable();
@@ -839,31 +837,32 @@ void Scene::renderCubemaps()
// To speed things up, only update the cubemaps for the small cubes every N frames.
const int N = (m_updateAllCubemaps ? 1 : 3);
- gfx::Matrix4x4f mat;
+ QMatrix4x4 mat;
GLRenderTargetCube::getProjectionMatrix(mat, 0.1f, 100.0f);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
- glLoadMatrixf(mat.bits());
+ glLoadMatrixf(mat.data());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- gfx::Vector3f center;
+ QVector3D center;
for (int i = m_frame % N; i < m_cubemaps.size(); i += N) {
if (0 == m_cubemaps[i])
continue;
float angle = 2.0f * PI * i / m_cubemaps.size();
- center = m_trackBalls[1].rotation().transform(gfx::Vector3f::vector(cos(angle), sin(angle), 0));
+
+ center = m_trackBalls[1].rotation().rotateVector(QVector3D(cos(angle), sin(angle), 0.0f));
for (int face = 0; face < 6; ++face) {
m_cubemaps[i]->begin(face);
GLRenderTargetCube::getViewMatrix(mat, face);
- gfx::Vector4f v = gfx::Vector4f::vector(-center[0], -center[1], -center[2], 1.0);
- mat[3] = v * mat;
+ QVector4D v = QVector4D(-center.x(), -center.y(), -center.z(), 1.0);
+ mat.setColumn(3, v * mat);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderBoxes(mat, i);
@@ -907,12 +906,9 @@ void Scene::drawBackground(QPainter *painter, const QRectF &)
glMatrixMode(GL_MODELVIEW);
- //gfx::Matrix4x4f view = gfx::Matrix4x4f::identity();
- //view(3, 2) -= 2.0f * exp(m_distExp / 1200.0f);
-
- gfx::Matrix4x4f view;
- m_trackBalls[2].rotation().matrix(view);
- view(3, 2) -= 2.0f * exp(m_distExp / 1200.0f);
+ QMatrix4x4 view;
+ view.rotate(m_trackBalls[2].rotation());
+ view(2, 3) -= 2.0f * exp(m_distExp / 1200.0f);
renderBoxes(view);
defaultStates();
@@ -946,10 +942,10 @@ void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
if (event->buttons() & Qt::MidButton) {
- m_trackBalls[2].move(pixelPosToViewPos(event->scenePos()), gfx::Quaternionf::identity());
+ m_trackBalls[2].move(pixelPosToViewPos(event->scenePos()), QQuaternion());
event->accept();
} else {
- m_trackBalls[2].release(pixelPosToViewPos(event->scenePos()), gfx::Quaternionf::identity());
+ m_trackBalls[2].release(pixelPosToViewPos(event->scenePos()), QQuaternion());
}
}
@@ -970,7 +966,7 @@ void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
if (event->buttons() & Qt::MidButton) {
- m_trackBalls[2].push(pixelPosToViewPos(event->scenePos()), gfx::Quaternionf::identity());
+ m_trackBalls[2].push(pixelPosToViewPos(event->scenePos()), QQuaternion());
event->accept();
}
}
@@ -992,7 +988,7 @@ void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
if (event->button() == Qt::MidButton) {
- m_trackBalls[2].release(pixelPosToViewPos(event->scenePos()), gfx::Quaternionf::identity());
+ m_trackBalls[2].release(pixelPosToViewPos(event->scenePos()), QQuaternion());
event->accept();
}
}
diff --git a/demos/boxes/scene.h b/demos/boxes/scene.h
index c056739..48ecaba 100644
--- a/demos/boxes/scene.h
+++ b/demos/boxes/scene.h
@@ -50,13 +50,13 @@
#include "roundedbox.h"
#include "gltrianglemesh.h"
-#include "vector.h"
#include "trackball.h"
#include "glbuffers.h"
#include "qtbox.h"
#define PI 3.14159265358979
+class QMatrix4x4;
class ParameterEdit : public QWidget
{
public:
@@ -194,7 +194,7 @@ public slots:
void setFloatParameter(const QString &name, float value);
void newItem(ItemDialog::ItemType type);
protected:
- void renderBoxes(const gfx::Matrix4x4f &view, int excludeBox = -2);
+ void renderBoxes(const QMatrix4x4 &view, int excludeBox = -2);
void setStates();
void setLights();
void defaultStates();
@@ -237,6 +237,4 @@ private:
QGLShaderProgram *m_environmentProgram;
};
-
-
#endif
diff --git a/demos/boxes/trackball.cpp b/demos/boxes/trackball.cpp
index 980f6ed..a8bfe44 100644
--- a/demos/boxes/trackball.cpp
+++ b/demos/boxes/trackball.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "trackball.h"
+#include "scene.h"
//============================================================================//
// TrackBall //
@@ -51,23 +52,23 @@ TrackBall::TrackBall(TrackMode mode)
, m_pressed(false)
, m_mode(mode)
{
- m_axis = gfx::Vector3f::vector(0, 1, 0);
- m_rotation = gfx::Quaternionf::quaternion(1.0f, 0.0f, 0.0f, 0.0f);
+ m_axis = QVector3D(0, 1, 0);
+ m_rotation = QQuaternion();
m_lastTime = QTime::currentTime();
}
-TrackBall::TrackBall(float angularVelocity, const gfx::Vector3f& axis, TrackMode mode)
+TrackBall::TrackBall(float angularVelocity, const QVector3D& axis, TrackMode mode)
: m_axis(axis)
, m_angularVelocity(angularVelocity)
, m_paused(false)
, m_pressed(false)
, m_mode(mode)
{
- m_rotation = gfx::Quaternionf::quaternion(1.0f, 0.0f, 0.0f, 0.0f);
+ m_rotation = QQuaternion();
m_lastTime = QTime::currentTime();
}
-void TrackBall::push(const QPointF& p, const gfx::Quaternionf &)
+void TrackBall::push(const QPointF& p, const QQuaternion &)
{
m_rotation = rotation();
m_pressed = true;
@@ -76,7 +77,7 @@ void TrackBall::push(const QPointF& p, const gfx::Quaternionf &)
m_angularVelocity = 0.0f;
}
-void TrackBall::move(const QPointF& p, const gfx::Quaternionf &transformation)
+void TrackBall::move(const QPointF& p, const QQuaternion &transformation)
{
if (!m_pressed)
return;
@@ -90,44 +91,45 @@ void TrackBall::move(const QPointF& p, const gfx::Quaternionf &transformation)
case Plane:
{
QLineF delta(m_lastPos, p);
- m_angularVelocity = delta.length() / msecs;
- m_axis = gfx::Vector3f::vector(delta.dy(), -delta.dx(), 0.0f).normalized();
- m_axis = transformation.transform(m_axis);
- m_rotation *= gfx::Quaternionf::rotation(delta.length(), m_axis);
+ m_angularVelocity = 180*delta.length() / (PI*msecs);
+ m_axis = QVector3D(delta.dy(), -delta.dx(), 0.0f).normalized();
+ m_axis = transformation.rotateVector(m_axis);
+ m_rotation *= QQuaternion::fromAxisAndAngle(m_axis, delta.length());
}
break;
case Sphere:
{
- gfx::Vector3f lastPos3D = gfx::Vector3f::vector(m_lastPos.x(), m_lastPos.y(), 0);
- float sqrZ = 1 - lastPos3D.sqrNorm();
+ QVector3D lastPos3D = QVector3D(m_lastPos.x(), m_lastPos.y(), 0.0f);
+ float sqrZ = 1 - QVector3D::dotProduct(lastPos3D, lastPos3D);
if (sqrZ > 0)
- lastPos3D[2] = sqrt(sqrZ);
+ lastPos3D.setZ(sqrt(sqrZ));
else
lastPos3D.normalize();
- gfx::Vector3f currentPos3D = gfx::Vector3f::vector(p.x(), p.y(), 0);
- sqrZ = 1 - currentPos3D.sqrNorm();
+ QVector3D currentPos3D = QVector3D(p.x(), p.y(), 0.0f);
+ sqrZ = 1 - QVector3D::dotProduct(currentPos3D, currentPos3D);
if (sqrZ > 0)
- currentPos3D[2] = sqrt(sqrZ);
+ currentPos3D.setZ(sqrt(sqrZ));
else
currentPos3D.normalize();
- m_axis = gfx::Vector3f::cross(currentPos3D, lastPos3D);
- float angle = asin(sqrt(m_axis.sqrNorm()));
+ m_axis = QVector3D::crossProduct(currentPos3D, lastPos3D);
+ float angle = asin(sqrt(QVector3D::dotProduct(m_axis, m_axis)));
- m_angularVelocity = angle / msecs;
+ m_angularVelocity = 180*angle / (PI*msecs);
m_axis.normalize();
- m_axis = transformation.transform(m_axis);
- m_rotation *= gfx::Quaternionf::rotation(angle, m_axis);
+ m_axis = transformation.rotateVector(m_axis);
+ m_rotation *= QQuaternion::fromAxisAndAngle(m_axis, angle);
}
break;
}
+
m_lastPos = p;
m_lastTime = currentTime;
}
-void TrackBall::release(const QPointF& p, const gfx::Quaternionf &transformation)
+void TrackBall::release(const QPointF& p, const QQuaternion &transformation)
{
// Calling move() caused the rotation to stop if the framerate was too low.
move(p, transformation);
@@ -146,13 +148,13 @@ void TrackBall::stop()
m_paused = true;
}
-gfx::Quaternionf TrackBall::rotation() const
+QQuaternion TrackBall::rotation() const
{
if (m_paused || m_pressed)
return m_rotation;
QTime currentTime = QTime::currentTime();
float angle = m_angularVelocity * m_lastTime.msecsTo(currentTime);
- return m_rotation * gfx::Quaternionf::rotation(angle, m_axis);
+ return m_rotation * QQuaternion::fromAxisAndAngle(m_axis, angle);
}
diff --git a/demos/boxes/trackball.h b/demos/boxes/trackball.h
index 5e3f40c..66e9b68 100644
--- a/demos/boxes/trackball.h
+++ b/demos/boxes/trackball.h
@@ -44,7 +44,8 @@
#include <QtGui>
-#include "vector.h"
+#include <QtGui/qvector3d.h>
+#include <QtGui/qquaternion.h>
class TrackBall
{
@@ -55,17 +56,17 @@ public:
Sphere,
};
TrackBall(TrackMode mode = Sphere);
- TrackBall(float angularVelocity, const gfx::Vector3f& axis, TrackMode mode = Sphere);
+ TrackBall(float angularVelocity, const QVector3D& axis, TrackMode mode = Sphere);
// coordinates in [-1,1]x[-1,1]
- void push(const QPointF& p, const gfx::Quaternionf &transformation);
- void move(const QPointF& p, const gfx::Quaternionf &transformation);
- void release(const QPointF& p, const gfx::Quaternionf &transformation);
+ void push(const QPointF& p, const QQuaternion &transformation);
+ void move(const QPointF& p, const QQuaternion &transformation);
+ void release(const QPointF& p, const QQuaternion &transformation);
void start(); // starts clock
void stop(); // stops clock
- gfx::Quaternionf rotation() const;
+ QQuaternion rotation() const;
private:
- gfx::Quaternionf m_rotation;
- gfx::Vector3f m_axis;
+ QQuaternion m_rotation;
+ QVector3D m_axis;
float m_angularVelocity;
QPointF m_lastPos;
diff --git a/demos/boxes/vector.h b/demos/boxes/vector.h
deleted file mode 100644
index bb24531..0000000
--- a/demos/boxes/vector.h
+++ /dev/null
@@ -1,602 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef VECTOR_H
-#define VECTOR_H
-
-#include <cassert>
-#include <cmath>
-#include <iostream>
-
-namespace gfx
-{
-
-template<class T, int n>
-struct Vector
-{
- // Keep the Vector struct a plain old data (POD) struct by avoiding constructors
-
- static Vector vector(T x)
- {
- Vector result;
- for (int i = 0; i < n; ++i)
- result.v[i] = x;
- return result;
- }
-
- // Use only for 2D vectors
- static Vector vector(T x, T y)
- {
- assert(n == 2);
- Vector result;
- result.v[0] = x;
- result.v[1] = y;
- return result;
- }
-
- // Use only for 3D vectors
- static Vector vector(T x, T y, T z)
- {
- assert(n == 3);
- Vector result;
- result.v[0] = x;
- result.v[1] = y;
- result.v[2] = z;
- return result;
- }
-
- // Use only for 4D vectors
- static Vector vector(T x, T y, T z, T w)
- {
- assert(n == 4);
- Vector result;
- result.v[0] = x;
- result.v[1] = y;
- result.v[2] = z;
- result.v[3] = w;
- return result;
- }
-
- // Pass 'n' arguments to this function.
- static Vector vector(T *v)
- {
- Vector result;
- for (int i = 0; i < n; ++i)
- result.v[i] = v[i];
- return result;
- }
-
- T &operator [] (int i) {return v[i];}
- T operator [] (int i) const {return v[i];}
-
-#define VECTOR_BINARY_OP(op, arg, rhs) \
- Vector operator op (arg) const \
- { \
- Vector result; \
- for (int i = 0; i < n; ++i) \
- result.v[i] = v[i] op rhs; \
- return result; \
- }
-
- VECTOR_BINARY_OP(+, const Vector &u, u.v[i])
- VECTOR_BINARY_OP(-, const Vector &u, u.v[i])
- VECTOR_BINARY_OP(*, const Vector &u, u.v[i])
- VECTOR_BINARY_OP(/, const Vector &u, u.v[i])
- VECTOR_BINARY_OP(+, T s, s)
- VECTOR_BINARY_OP(-, T s, s)
- VECTOR_BINARY_OP(*, T s, s)
- VECTOR_BINARY_OP(/, T s, s)
-#undef VECTOR_BINARY_OP
-
- Vector operator - () const
- {
- Vector result;
- for (int i = 0; i < n; ++i)
- result.v[i] = -v[i];
- return result;
- }
-
-#define VECTOR_ASSIGN_OP(op, arg, rhs) \
- Vector &operator op (arg) \
- { \
- for (int i = 0; i < n; ++i) \
- v[i] op rhs; \
- return *this; \
- }
-
- VECTOR_ASSIGN_OP(+=, const Vector &u, u.v[i])
- VECTOR_ASSIGN_OP(-=, const Vector &u, u.v[i])
- VECTOR_ASSIGN_OP(=, T s, s)
- VECTOR_ASSIGN_OP(*=, T s, s)
- VECTOR_ASSIGN_OP(/=, T s, s)
-#undef VECTOR_ASSIGN_OP
-
- static T dot(const Vector &u, const Vector &v)
- {
- T sum(0);
- for (int i = 0; i < n; ++i)
- sum += u.v[i] * v.v[i];
- return sum;
- }
-
- static Vector cross(const Vector &u, const Vector &v)
- {
- assert(n == 3);
- return vector(u.v[1] * v.v[2] - u.v[2] * v.v[1],
- u.v[2] * v.v[0] - u.v[0] * v.v[2],
- u.v[0] * v.v[1] - u.v[1] * v.v[0]);
- }
-
- T sqrNorm() const
- {
- return dot(*this, *this);
- }
-
- // requires floating point type T
- void normalize()
- {
- T s = sqrNorm();
- if (s != 0)
- *this /= sqrt(s);
- }
-
- // requires floating point type T
- Vector normalized() const
- {
- T s = sqrNorm();
- if (s == 0)
- return *this;
- return *this / sqrt(s);
- }
-
- T *bits() {return v;}
- const T *bits() const {return v;}
-
- T v[n];
-};
-
-#define SCALAR_VECTOR_BINARY_OP(op) \
-template<class T, int n> \
-Vector<T, n> operator op (T s, const Vector<T, n>& u) \
-{ \
- Vector<T, n> result; \
- for (int i = 0; i < n; ++i) \
- result[i] = s op u[i]; \
- return result; \
-}
-
-SCALAR_VECTOR_BINARY_OP(+)
-SCALAR_VECTOR_BINARY_OP(-)
-SCALAR_VECTOR_BINARY_OP(*)
-SCALAR_VECTOR_BINARY_OP(/)
-#undef SCALAR_VECTOR_BINARY_OP
-
-template<class T, int n>
-std::ostream &operator << (std::ostream &os, const Vector<T, n> &v)
-{
- assert(n > 0);
- os << "[" << v[0];
- for (int i = 1; i < n; ++i)
- os << ", " << v[i];
- os << "]";
- return os;
-}
-
-typedef Vector<float, 2> Vector2f;
-typedef Vector<float, 3> Vector3f;
-typedef Vector<float, 4> Vector4f;
-
-template<class T, int rows, int cols>
-struct Matrix
-{
- // Keep the Matrix struct a plain old data (POD) struct by avoiding constructors
-
- static Matrix matrix(T x)
- {
- Matrix result;
- for (int i = 0; i < rows; ++i) {
- for (int j = 0; j < cols; ++j)
- result.v[i][j] = x;
- }
- return result;
- }
-
- static Matrix matrix(T *m)
- {
- Matrix result;
- for (int i = 0; i < rows; ++i) {
- for (int j = 0; j < cols; ++j) {
- result.v[i][j] = *m;
- ++m;
- }
- }
- return result;
- }
-
- T &operator () (int i, int j) {return v[i][j];}
- T operator () (int i, int j) const {return v[i][j];}
- Vector<T, cols> &operator [] (int i) {return v[i];}
- const Vector<T, cols> &operator [] (int i) const {return v[i];}
-
- // TODO: operators, methods
-
- Vector<T, rows> operator * (const Vector<T, cols> &u) const
- {
- Vector<T, rows> result;
- for (int i = 0; i < rows; ++i)
- result[i] = Vector<T, cols>::dot(v[i], u);
- return result;
- }
-
- template<int k>
- Matrix<T, rows, k> operator * (const Matrix<T, cols, k> &m)
- {
- Matrix<T, rows, k> result;
- for (int i = 0; i < rows; ++i)
- result[i] = v[i] * m;
- return result;
- }
-
- T* bits() {return reinterpret_cast<T *>(this);}
- const T* bits() const {return reinterpret_cast<const T *>(this);}
-
- // Simple Gauss elimination.
- // TODO: Optimize and improve stability.
- Matrix inverse(bool *ok = 0) const
- {
- assert(rows == cols);
- Matrix rhs = identity();
- Matrix lhs(*this);
- T temp;
- // Down
- for (int i = 0; i < rows; ++i) {
- // Pivoting
- int pivot = i;
- for (int j = i; j < rows; ++j) {
- if (qAbs(lhs(j, i)) > lhs(pivot, i))
- pivot = j;
- }
- // TODO: fuzzy compare.
- if (lhs(pivot, i) == T(0)) {
- if (ok)
- *ok = false;
- return rhs;
- }
- if (pivot != i) {
- for (int j = i; j < cols; ++j) {
- temp = lhs(pivot, j);
- lhs(pivot, j) = lhs(i, j);
- lhs(i, j) = temp;
- }
- for (int j = 0; j < cols; ++j) {
- temp = rhs(pivot, j);
- rhs(pivot, j) = rhs(i, j);
- rhs(i, j) = temp;
- }
- }
-
- // Normalize i-th row
- rhs[i] /= lhs(i, i);
- for (int j = cols - 1; j > i; --j)
- lhs(i, j) /= lhs(i, i);
-
- // Eliminate non-zeros in i-th column below the i-th row.
- for (int j = i + 1; j < rows; ++j) {
- rhs[j] -= lhs(j, i) * rhs[i];
- for (int k = i + 1; k < cols; ++k)
- lhs(j, k) -= lhs(j, i) * lhs(i, k);
- }
- }
- // Up
- for (int i = rows - 1; i > 0; --i) {
- for (int j = i - 1; j >= 0; --j)
- rhs[j] -= lhs(j, i) * rhs[i];
- }
- if (ok)
- *ok = true;
- return rhs;
- }
-
- Matrix<T, cols, rows> transpose() const
- {
- Matrix<T, cols, rows> result;
- for (int i = 0; i < rows; ++i) {
- for (int j = 0; j < cols; ++j)
- result.v[j][i] = v[i][j];
- }
- return result;
- }
-
- static Matrix identity()
- {
- Matrix result = matrix(T(0));
- for (int i = 0; i < rows && i < cols; ++i)
- result.v[i][i] = T(1);
- return result;
- }
-
- Vector<T, cols> v[rows];
-};
-
-template<class T, int rows, int cols>
-Vector<T, cols> operator * (const Vector<T, rows> &u, const Matrix<T, rows, cols> &m)
-{
- Vector<T, cols> result = Vector<T, cols>::vector(T(0));
- for (int i = 0; i < rows; ++i)
- result += m[i] * u[i];
- return result;
-}
-
-template<class T, int rows, int cols>
-std::ostream &operator << (std::ostream &os, const Matrix<T, rows, cols> &m)
-{
- assert(rows > 0);
- os << "[" << m[0];
- for (int i = 1; i < rows; ++i)
- os << ", " << m[i];
- os << "]";
- return os;
-}
-
-
-typedef Matrix<float, 2, 2> Matrix2x2f;
-typedef Matrix<float, 3, 3> Matrix3x3f;
-typedef Matrix<float, 4, 4> Matrix4x4f;
-
-template<class T>
-struct Quaternion
-{
- // Keep the Quaternion struct a plain old data (POD) struct by avoiding constructors
-
- static Quaternion quaternion(T s, T x, T y, T z)
- {
- Quaternion result;
- result.scalar = s;
- result.vector[0] = x;
- result.vector[1] = y;
- result.vector[2] = z;
- return result;
- }
-
- static Quaternion quaternion(T s, const Vector<T, 3> &v)
- {
- Quaternion result;
- result.scalar = s;
- result.vector = v;
- return result;
- }
-
- static Quaternion identity()
- {
- return quaternion(T(1), T(0), T(0), T(0));
- }
-
- // assumes that all the elements are packed tightly
- T& operator [] (int i) {return reinterpret_cast<T *>(this)[i];}
- T operator [] (int i) const {return reinterpret_cast<const T *>(this)[i];}
-
-#define QUATERNION_BINARY_OP(op, arg, rhs) \
- Quaternion operator op (arg) const \
- { \
- Quaternion result; \
- for (int i = 0; i < 4; ++i) \
- result[i] = (*this)[i] op rhs; \
- return result; \
- }
-
- QUATERNION_BINARY_OP(+, const Quaternion &q, q[i])
- QUATERNION_BINARY_OP(-, const Quaternion &q, q[i])
- QUATERNION_BINARY_OP(*, T s, s)
- QUATERNION_BINARY_OP(/, T s, s)
-#undef QUATERNION_BINARY_OP
-
- Quaternion operator - () const
- {
- return Quaternion(-scalar, -vector);
- }
-
- Quaternion operator * (const Quaternion &q) const
- {
- Quaternion result;
- result.scalar = scalar * q.scalar - Vector<T, 3>::dot(vector, q.vector);
- result.vector = scalar * q.vector + vector * q.scalar + Vector<T, 3>::cross(vector, q.vector);
- return result;
- }
-
- Quaternion operator * (const Vector<T, 3> &v) const
- {
- Quaternion result;
- result.scalar = -Vector<T, 3>::dot(vector, v);
- result.vector = scalar * v + Vector<T, 3>::cross(vector, v);
- return result;
- }
-
- friend Quaternion operator * (const Vector<T, 3> &v, const Quaternion &q)
- {
- Quaternion result;
- result.scalar = -Vector<T, 3>::dot(v, q.vector);
- result.vector = v * q.scalar + Vector<T, 3>::cross(v, q.vector);
- return result;
- }
-
-#define QUATERNION_ASSIGN_OP(op, arg, rhs) \
- Quaternion &operator op (arg) \
- { \
- for (int i = 0; i < 4; ++i) \
- (*this)[i] op rhs; \
- return *this; \
- }
-
- QUATERNION_ASSIGN_OP(+=, const Quaternion &q, q[i])
- QUATERNION_ASSIGN_OP(-=, const Quaternion &q, q[i])
- QUATERNION_ASSIGN_OP(=, T s, s)
- QUATERNION_ASSIGN_OP(*=, T s, s)
- QUATERNION_ASSIGN_OP(/=, T s, s)
-#undef QUATERNION_ASSIGN_OP
-
- Quaternion& operator *= (const Quaternion &q)
- {
- Quaternion result;
- result.scalar = scalar * q.scalar - Vector<T, 3>::dot(vector, q.vector);
- result.vector = scalar * q.vector + vector * q.scalar + Vector<T, 3>::cross(vector, q.vector);
- return (*this = result);
- }
-
- Quaternion& operator *= (const Vector<T, 3> &v)
- {
- Quaternion result;
- result.scalar = -Vector<T, 3>::dot(vector, v);
- result.vector = scalar * v + Vector<T, 3>::cross(vector, v);
- return (*this = result);
- }
-
- Quaternion conjugate() const
- {
- return quaternion(scalar, -vector);
- }
-
- T sqrNorm() const
- {
- return scalar * scalar + vector.sqrNorm();
- }
-
- Quaternion inverse() const
- {
- return conjugate() / sqrNorm();
- }
-
- // requires floating point type T
- Quaternion normalized() const
- {
- T s = sqrNorm();
- if (s == 0)
- return *this;
- return *this / sqrt(s);
- }
-
- void matrix(Matrix<T, 3, 3>& m) const
- {
- T bb = vector[0] * vector[0];
- T cc = vector[1] * vector[1];
- T dd = vector[2] * vector[2];
- T diag = scalar * scalar - bb - cc - dd;
- T ab = scalar * vector[0];
- T ac = scalar * vector[1];
- T ad = scalar * vector[2];
- T bc = vector[0] * vector[1];
- T cd = vector[1] * vector[2];
- T bd = vector[2] * vector[0];
- m(0, 0) = diag + 2 * bb;
- m(0, 1) = 2 * (bc - ad);
- m(0, 2) = 2 * (ac + bd);
- m(1, 0) = 2 * (ad + bc);
- m(1, 1) = diag + 2 * cc;
- m(1, 2) = 2 * (cd - ab);
- m(2, 0) = 2 * (bd - ac);
- m(2, 1) = 2 * (ab + cd);
- m(2, 2) = diag + 2 * dd;
- }
-
- void matrix(Matrix<T, 4, 4>& m) const
- {
- T bb = vector[0] * vector[0];
- T cc = vector[1] * vector[1];
- T dd = vector[2] * vector[2];
- T diag = scalar * scalar - bb - cc - dd;
- T ab = scalar * vector[0];
- T ac = scalar * vector[1];
- T ad = scalar * vector[2];
- T bc = vector[0] * vector[1];
- T cd = vector[1] * vector[2];
- T bd = vector[2] * vector[0];
- m(0, 0) = diag + 2 * bb;
- m(0, 1) = 2 * (bc - ad);
- m(0, 2) = 2 * (ac + bd);
- m(0, 3) = 0;
- m(1, 0) = 2 * (ad + bc);
- m(1, 1) = diag + 2 * cc;
- m(1, 2) = 2 * (cd - ab);
- m(1, 3) = 0;
- m(2, 0) = 2 * (bd - ac);
- m(2, 1) = 2 * (ab + cd);
- m(2, 2) = diag + 2 * dd;
- m(2, 3) = 0;
- m(3, 0) = 0;
- m(3, 1) = 0;
- m(3, 2) = 0;
- m(3, 3) = 1;
- }
-
- // assumes that 'this' is normalized
- Vector<T, 3> transform(const Vector<T, 3> &v) const
- {
- Matrix<T, 3, 3> m;
- matrix(m);
- return v * m;
- }
-
- // assumes that all the elements are packed tightly
- T* bits() {return reinterpret_cast<T *>(this);}
- const T* bits() const {return reinterpret_cast<const T *>(this);}
-
- // requires floating point type T
- static Quaternion rotation(T angle, const Vector<T, 3> &unitAxis)
- {
- T s = sin(angle / 2);
- T c = cos(angle / 2);
- return quaternion(c, unitAxis * s);
- }
-
- T scalar;
- Vector<T, 3> vector;
-};
-
-template<class T>
-Quaternion<T> operator * (T s, const Quaternion<T>& q)
-{
- return Quaternion<T>::quaternion(s * q.scalar, s * q.vector);
-}
-
-typedef Quaternion<float> Quaternionf;
-
-} // end namespace gfx
-
-#endif
diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc
index bb54852..e5c181d 100644
--- a/doc/src/declarative/focus.qdoc
+++ b/doc/src/declarative/focus.qdoc
@@ -50,7 +50,7 @@ An \l Item requests focus by setting the \c {Item::focus} property to true.
For very simple cases simply setting the \c {Item::focus} property is sometimes
sufficient. If we run the following example in the \c qmlviewer, we see that
-the \c {<KeyActions/>} element has \e {active focus} and pressing the
+the \c {KeyActions} element has \e {active focus} and pressing the
\e A, \e B, or \e C keys modifies the text appropriately.
\table
@@ -244,7 +244,7 @@ property. As the \l ListView is a \e {focus realm}, this doesn't effect the
rest of the application. However, if the \l ListView itself has
\e {active focus} this causes the delegate itself to receive \e {active focus}.
In this example, the root element of the delegate is also a \e {focus realm},
-which in turn gives \e {active focus} to the \c {<KeyActions/>} element that
+which in turn gives \e {active focus} to the \c {KeyActions} element that
actually performs the work of handling the \e {Return} key.
All of the fluid UI view classes, such as \l PathView and \l GridView, behave
diff --git a/doc/src/qmlviewer.qdoc b/doc/src/declarative/qmlviewer.qdoc
index e8fdec4..8228737 100644
--- a/doc/src/qmlviewer.qdoc
+++ b/doc/src/declarative/qmlviewer.qdoc
@@ -68,11 +68,7 @@
that is a qreal from 0 to 86400 representing the number of seconds since
midnight, dummy data for this could be provided by \c dummydata/clock.qml:
\code
- <Object>
- <properties>
- <Property name="time" value="12345"/>
- </properties>
- </Object>
+ Object { property real time: 12345 }
\endcode
Any QML can be used in the dummy data files. You could even animate the
fictional data!
diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc
index b63ebbb..a79c671 100644
--- a/doc/src/declarative/qtprogrammers.qdoc
+++ b/doc/src/declarative/qtprogrammers.qdoc
@@ -18,7 +18,7 @@ QML provides direct access to the following concepts from Qt:
\o QObject signals and slots - available as functions to call in JavaScript
\o QObject properties - available as variables in JavaScript
\o QWidget - QFxView is a QML-displaying widget
- \o Qt models - used directly in data binding (currently only next generation QListModelInterface)
+ \o Qt models - used directly in data binding (QAbstractItemModel and next generation QListModelInterface)
\endlist
Qt knowledge is \e required for \l {cppitem}{writing elements in C++}.
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri
new file mode 100644
index 0000000..ea5219a
--- /dev/null
+++ b/src/declarative/debugger/debugger.pri
@@ -0,0 +1,3 @@
+SOURCES += debugger/qmldebugger.cpp
+
+HEADERS += debugger/qmldebugger.h
diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp
new file mode 100644
index 0000000..1f7fd68
--- /dev/null
+++ b/src/declarative/debugger/qmldebugger.cpp
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmldebugger.h"
+#include <QtGui/qtreewidget.h>
+#include <QtGui/qboxlayout.h>
+#include <QtGui/qplaintextedit.h>
+#include <QtDeclarative/qmlbindablevalue.h>
+#include <private/qmlboundsignal_p.h>
+#include <private/qmlcontext_p.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qurl.h>
+#include <QtGui/qsplitter.h>
+#include <QtGui/qpushbutton.h>
+#include <QtGui/qevent.h>
+
+QmlDebugger::QmlDebugger(QWidget *parent)
+: QWidget(parent), m_tree(0)
+{
+ QHBoxLayout *layout = new QHBoxLayout;
+ setLayout(layout);
+ QSplitter *splitter = new QSplitter(this);
+ layout->addWidget(splitter);
+
+ QWidget *treeWid = new QWidget(this);
+ QVBoxLayout *vlayout = new QVBoxLayout;
+ vlayout->setContentsMargins(0, 0, 0, 0);
+ treeWid->setLayout(vlayout);
+ splitter->addWidget(treeWid);
+
+ m_tree = new QTreeWidget(treeWid);
+ m_tree->setHeaderHidden(true);
+ QObject::connect(m_tree, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this, SLOT(itemPressed(QTreeWidgetItem *)));
+ vlayout->addWidget(m_tree);
+
+ QPushButton *pb = new QPushButton("Refresh", treeWid);
+ QObject::connect(pb, SIGNAL(clicked()), this, SLOT(refresh()));
+ vlayout->addWidget(pb);
+
+ m_text = new QPlainTextEdit(this);
+ m_text->setReadOnly(true);
+ splitter->addWidget(m_text);
+ splitter->setStretchFactor(1, 2);
+}
+
+class QmlDebuggerItem : public QTreeWidgetItem
+{
+public:
+ QmlDebuggerItem(QTreeWidget *wid)
+ : QTreeWidgetItem(wid), startLine(-1), endLine(-1)
+ {
+ }
+
+ QmlDebuggerItem(QTreeWidgetItem *item)
+ : QTreeWidgetItem(item), startLine(-1), endLine(-1)
+ {
+ }
+
+ int startLine;
+ int endLine;
+ QUrl url;
+};
+
+void QmlDebugger::itemPressed(QTreeWidgetItem *i)
+{
+ QmlDebuggerItem *item = static_cast<QmlDebuggerItem *>(i);
+
+ if(item->url.scheme() == QLatin1String("file")) {
+ QString f = item->url.toLocalFile();
+ QFile file(f);
+ file.open(QIODevice::ReadOnly);
+ QByteArray ba = file.readAll();
+ QTextStream stream(ba, QIODevice::ReadOnly);
+ const QString code = stream.readAll();
+
+ m_text->setPlainText(code);
+
+ if(item->startLine != -1) {
+ QTextDocument *document = m_text->document();
+ QTextCharFormat format;
+ format.setForeground(Qt::lightGray);
+ {
+ QTextCursor cursor(document);
+ cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor, item->startLine - 1);
+ cursor.setCharFormat(format);
+ }
+
+ {
+ QTextCursor cursor(document);
+ cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, item->endLine);
+ cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
+ cursor.setCharFormat(format);
+ }
+
+ {
+ QTextCursor cursor(document);
+ cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
+ cursor.setCharFormat(QTextCharFormat());
+ }
+
+ {
+ QTextCursor cursor(document);
+ cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
+ cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, item->startLine - 1);
+ m_text->setTextCursor(cursor);
+ m_text->centerCursor();
+ }
+ }
+
+ }
+}
+
+static bool makeItem(QObject *obj, QmlDebuggerItem *item)
+{
+ bool rv = true;
+
+ QString text;
+
+ if(QmlBindableValue *bv = qobject_cast<QmlBindableValue *>(obj)) {
+ text = bv->property().name() + ": " + bv->expression();
+ item->setForeground(0, Qt::green);
+ } else if(QmlBoundSignal *bs = qobject_cast<QmlBoundSignal *>(obj)) {
+ QMetaMethod method = obj->parent()->metaObject()->method(bs->index());
+ QByteArray sig = method.signature();
+ if(!sig.isEmpty())
+ text = sig + ": ";
+ text += bs->expression();
+ item->setForeground(0, Qt::blue);
+ rv = false;
+ } else {
+ QmlContext *context = qmlContext(obj);
+ QmlContext *parentContext = qmlContext(obj->parent());
+
+ text = QLatin1String(obj->metaObject()->className());
+
+ if(context && context != parentContext) {
+ QmlContextPrivate *p = static_cast<QmlContextPrivate *>(QObjectPrivate::get(context));
+
+ QString toolTipString;
+ if(!p->url.toString().isEmpty()) {
+ item->url = p->url;
+ toolTipString = "URL: " + p->url.toString();
+ }
+
+ if(!p->typeName.isEmpty()) {
+ if(!toolTipString.isEmpty())
+ toolTipString.prepend("\n");
+ toolTipString.prepend("Root type: " + text);
+ text = p->typeName;
+ }
+
+ if(!toolTipString.isEmpty())
+ item->setToolTip(0, toolTipString);
+
+ item->setForeground(0, QColor("orange"));
+
+ if(p->startLine != -1) {
+ item->startLine = p->startLine;
+ item->endLine = p->endLine;
+ }
+
+ } else {
+ item->setExpanded(true);
+ }
+ }
+
+ item->setText(0, text);
+
+ return rv;
+}
+
+static void buildTree(QObject *obj, QmlDebuggerItem *parent)
+{
+ QObjectList children = obj->children();
+
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QmlDebuggerItem *item = new QmlDebuggerItem(parent);
+ if(makeItem(children.at(ii), item))
+ buildTree(children.at(ii), item);
+ }
+}
+
+void QmlDebugger::refresh()
+{
+ setDebugObject(m_object);
+}
+
+void QmlDebugger::setDebugObject(QObject *obj)
+{
+ m_tree->clear();
+
+ m_object = obj;
+ if(!obj)
+ return;
+
+ QmlDebuggerItem *item = new QmlDebuggerItem(m_tree);
+ makeItem(obj, item);
+ buildTree(obj, item);
+ item->setExpanded(true);
+ setGeometry(0, 100, 800, 600);
+}
+
diff --git a/src/declarative/debugger/qmldebugger.h b/src/declarative/debugger/qmldebugger.h
new file mode 100644
index 0000000..943abef
--- /dev/null
+++ b/src/declarative/debugger/qmldebugger.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLDEBUGGER_H
+#define QMLDEBUGGER_H
+
+#include <QtCore/qpointer.h>
+#include <QtGui/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QTreeWidget;
+class QTreeWidgetItem;
+class QPlainTextEdit;
+class QmlDebugger : public QWidget
+{
+Q_OBJECT
+public:
+ QmlDebugger(QWidget *parent = 0);
+
+ void setDebugObject(QObject *);
+
+public slots:
+ void refresh();
+
+private slots:
+ void itemPressed(QTreeWidgetItem *);
+
+private:
+ QTreeWidget *m_tree;
+ QPlainTextEdit *m_text;
+ QPointer<QObject> m_object;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMLDEBUGGER_H
+
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index 30704d0..1e8e82b 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -21,5 +21,6 @@ include(timeline/timeline.pri)
include(extra/extra.pri)
include(widgets/widgets.pri)
include(test/test.pri)
+include(debugger/debugger.pri)
contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1):include(opengl/opengl.pri)
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index badc6fb..af72ecc 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -239,12 +239,15 @@ void QmlXmlListModel::classComplete()
void QmlXmlListModel::fetch()
{
Q_D(QmlXmlListModel);
+
+ //clear existing data
+ d->size = 0;
+ int count = d->data.count();
+ d->data.clear();
+ emit itemsRemoved(0, count);
+
if (d->src.isEmpty()) {
qWarning() << "Can't fetch empty src string";
- //clear existing data?
- //int count = d->data.count();
- //d->data.clear();
- //emit itemsRemoved(0, count);
return;
}
diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h
index d06cabf..acc54a9 100644
--- a/src/declarative/extra/qmlxmllistmodel.h
+++ b/src/declarative/extra/qmlxmllistmodel.h
@@ -116,6 +116,8 @@ public:
void setNamespaceDeclarations(const QString&);
virtual void classComplete();
+
+public Q_SLOTS:
void fetch();
protected:
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 810a359..ca6379f 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -699,6 +699,12 @@ void QFxPathView::itemsRemoved(int modelIndex, int count)
d->regenerate();
}
+ if (d->model->count() == 0) {
+ d->currentIndex == -1;
+ d->moveOffset.setValue(0);
+ return;
+ }
+
// make sure the current item is still at the snap position
if (d->currentIndex >= d->model->count())
d->currentIndex = d->model->count() - 1;
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index 3f05846..7998711 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -848,20 +848,20 @@ QWebPage *QFxWebView::page() const
// The QObject interface to settings().
/*!
- \qmlproperty bool WebView::settings::autoLoadImages
- \qmlproperty bool WebView::settings::javascriptEnabled
- \qmlproperty bool WebView::settings::javaEnabled
- \qmlproperty bool WebView::settings::pluginsEnabled
- \qmlproperty bool WebView::settings::privateBrowsingEnabled
- \qmlproperty bool WebView::settings::javascriptCanOpenWindows
- \qmlproperty bool WebView::settings::javascriptCanAccessClipboard
- \qmlproperty bool WebView::settings::developerExtrasEnabled
- \qmlproperty bool WebView::settings::linksIncludedInFocusChain
- \qmlproperty bool WebView::settings::zoomTextOnly
- \qmlproperty bool WebView::settings::printElementBackgrounds
- \qmlproperty bool WebView::settings::offlineStorageDatabaseEnabled
- \qmlproperty bool WebView::settings::offlineWebApplicationCacheEnabled
- \qmlproperty bool WebView::settings::localStorageDatabaseEnabled
+ \qmlproperty bool WebView::settings.autoLoadImages
+ \qmlproperty bool WebView::settings.javascriptEnabled
+ \qmlproperty bool WebView::settings.javaEnabled
+ \qmlproperty bool WebView::settings.pluginsEnabled
+ \qmlproperty bool WebView::settings.privateBrowsingEnabled
+ \qmlproperty bool WebView::settings.javascriptCanOpenWindows
+ \qmlproperty bool WebView::settings.javascriptCanAccessClipboard
+ \qmlproperty bool WebView::settings.developerExtrasEnabled
+ \qmlproperty bool WebView::settings.linksIncludedInFocusChain
+ \qmlproperty bool WebView::settings.zoomTextOnly
+ \qmlproperty bool WebView::settings.printElementBackgrounds
+ \qmlproperty bool WebView::settings.offlineStorageDatabaseEnabled
+ \qmlproperty bool WebView::settings.offlineWebApplicationCacheEnabled
+ \qmlproperty bool WebView::settings.localStorageDatabaseEnabled
These properties give access to the settings controlling the web view.
diff --git a/src/declarative/qml/qmlboundsignal.cpp b/src/declarative/qml/qmlboundsignal.cpp
index 67e3dcf..5815dc6 100644
--- a/src/declarative/qml/qmlboundsignal.cpp
+++ b/src/declarative/qml/qmlboundsignal.cpp
@@ -99,6 +99,7 @@ QmlBoundSignalParameters::QmlBoundSignalParameters(const QMetaMethod &method,
// ### Ensure only supported types are allowed, otherwise it might crash
QMetaObjectBuilder mob;
mob.setSuperClass(&QmlBoundSignalParameters::staticMetaObject);
+ mob.setClassName("QmlBoundSignalParameters");
QList<QByteArray> paramTypes = method.parameterTypes();
QList<QByteArray> paramNames = method.parameterNames();
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 67a0a04..9ae1278 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -60,6 +60,7 @@
#include <qmlmetatype.h>
#include <QtCore/qdebug.h>
#include "private/qmlcustomparser_p_p.h"
+#include <private/qmlcontext_p.h>
#include "qmlscriptparser_p.h"
@@ -675,6 +676,7 @@ bool QmlCompiler::compileComponentFromRoot(Object *obj, int ctxt)
QmlInstruction &create = output->bytecode.last();
create.type = QmlInstruction::CreateComponent;
create.line = obj->line;
+ create.createComponent.endLine = obj->endLine;
int count = output->bytecode.count();
QmlInstruction init;
@@ -1468,7 +1470,12 @@ QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt) const
QmlEngine::setContextForObject(rv, ctxt);
return rv;
} else if (component) {
- return component->create(ctxt);
+ QObject *rv = component->create(ctxt);
+ QmlContext *ctxt = qmlContext(rv);
+ if(ctxt) {
+ static_cast<QmlContextPrivate *>(QObjectPrivate::get(ctxt))->typeName = className;
+ }
+ return rv;
} else {
return 0;
}
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index b257d5f..027c2a8 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -462,6 +462,11 @@ QObject *QmlComponent::beginCreate(QmlContext *context)
QmlContext *ctxt =
new QmlContext(context, 0);
static_cast<QmlContextPrivate*>(ctxt->d_ptr)->url = d->cc->url;
+ if(d->start != -1) {
+ // ### FIXME
+ static_cast<QmlContextPrivate*>(ctxt->d_ptr)->startLine = d->cc->bytecode.at(d->start - 1).line;
+ static_cast<QmlContextPrivate*>(ctxt->d_ptr)->endLine = d->cc->bytecode.at(d->start - 1).createComponent.endLine;
+ }
ctxt->activate();
QmlVME vme;
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index cf33610..dfcf413 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -53,7 +53,7 @@
QT_BEGIN_NAMESPACE
QmlContextPrivate::QmlContextPrivate()
- : parent(0), engine(0), highPriorityCount(0)
+ : parent(0), engine(0), highPriorityCount(0), startLine(-1), endLine(-1)
{
}
diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h
index 40848fb..d7c6d29 100644
--- a/src/declarative/qml/qmlcontext_p.h
+++ b/src/declarative/qml/qmlcontext_p.h
@@ -70,6 +70,9 @@ public:
QScriptValueList scopeChain;
QUrl url;
+ QByteArray typeName;
+ int startLine;
+ int endLine;
void init();
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 01bdfdd..e9c81d6 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -275,6 +275,7 @@ public:
} assignSignalObject;
struct {
int count;
+ int endLine;
} createComponent;
struct {
int id;
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp
index d68eb68..a6cb2ca 100644
--- a/src/declarative/qml/qmlparser.cpp
+++ b/src/declarative/qml/qmlparser.cpp
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
using namespace QmlParser;
QmlParser::Object::Object()
-: type(-1), metatype(0), extObjectData(0), defaultProperty(0), line(-1), column(-1)
+: type(-1), metatype(0), extObjectData(0), defaultProperty(0), line(-1), column(-1), endLine(-1), endColumn(-1)
{
}
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
index 2c9b0f1..aa22928 100644
--- a/src/declarative/qml/qmlparser_p.h
+++ b/src/declarative/qml/qmlparser_p.h
@@ -106,6 +106,9 @@ namespace QmlParser
qint64 line;
qint64 column;
+ qint64 endLine;
+ qint64 endColumn;
+
struct DynamicProperty {
DynamicProperty();
DynamicProperty(const DynamicProperty &);
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index aed17d6..8be0e5a 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -235,6 +235,11 @@ Object *ProcessAST::defineObjectBinding_helper(int line,
_scope.removeLast();
obj->line = line;
+ if(initializer) {
+ obj->endLine = initializer->rbraceToken.startLine;
+ obj->endColumn = initializer->rbraceToken.startColumn;
+ }
+
if (propertyCount) {
Property *prop = currentProperty();
Value *v = new Value;
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 1315f19..ea2719d 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -60,10 +60,12 @@
#include "qfxview.h"
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcontext.h>
+#include <QtDeclarative/qmldebugger.h>
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(itemTreeDump, ITEMTREE_DUMP);
+DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER);
static QVariant stringToPixmap(const QString &str)
{
@@ -324,6 +326,14 @@ void QFxView::continueExecute()
if (itemTreeDump())
item->dump();
+ if(qmlDebugger()) {
+ QmlDebugger *debugger = new QmlDebugger;
+ debugger->setDebugObject(item);
+ debugger->show();
+ raise();
+ debugger->raise();
+ }
+
QPerformanceLog::displayData();
QPerformanceLog::clear();
d->root = item;
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index 6ad0cb9..1cd2f69 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -72,24 +72,25 @@ Q_DECLARE_METATYPE(QListModelInterface *);
\qmlclass ListModel
\brief The ListModel element defines a free-form list data source.
- The ListModel is a simple XML heirarchy of items containing data roles.
+ The ListModel is a simple heirarchy of items containing data roles.
For example:
\code
- <ListModel id="FruitModel">
- <Fruit>
- <name>Apple</name>
- <cost>2.45</cost>
- <Fruit>
- <Fruit>
- <name>Orange</name>
- <cost>3.25</cost>
- </Fruit>
- <Fruit>
- <name>Banana</name>
- <cost>1.95</cost>
- </Fruit>
- </ListModel>
+ ListModel {
+ id: FruitModel
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ }
+ ListElement {
+ name: "Orange"
+ cost: 3.25
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ }
+ }
\endcode
Elements beginning with a capital are items. Elements beginning
@@ -98,14 +99,26 @@ Q_DECLARE_METATYPE(QListModelInterface *);
The defined model can be used in views such as ListView:
\code
- <Component id="FruitDelegate">
- <Item width="200" height="50">
- <Text text="{name}"/>
- <Text text="{'$'+cost}" anchors.right="{parent.right}"/>
- </Item>
- </Component>
-
- <ListView model="{FruitModel}" delegate="{FruitDelegate}" anchors.fill="{parent}"/>
+ Component {
+ id: FruitDelegate
+ Item {
+ width: 200
+ height: 50
+ Text {
+ text: name
+ }
+ Text {
+ text: '$'+cost
+ anchors.right: parent.right
+ }
+ }
+ }
+
+ ListView {
+ model: FruitModel
+ delegate: FruitDelegate
+ anchors.fill: parent
+ }
\endcode
*/
diff --git a/src/declarative/util/qmlopenmetaobject.cpp b/src/declarative/util/qmlopenmetaobject.cpp
index 87d8f4d..fc20fa9 100644
--- a/src/declarative/util/qmlopenmetaobject.cpp
+++ b/src/declarative/util/qmlopenmetaobject.cpp
@@ -48,6 +48,7 @@ QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, bool automatic)
: autoCreate(automatic), parent(0), mem(0), _object(obj)
{
mob.setSuperClass(obj->metaObject());
+ mob.setClassName(obj->metaObject()->className());
mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
QObjectPrivate *op = QObjectPrivate::get(obj);
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index cc91e55..d74b930 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -1,11 +1,41 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtOpenGL module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -19,7 +49,7 @@
QT_BEGIN_NAMESPACE
-#if !defined(QT_OPENGL_ES_1_CL)
+#if !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
/*!
\class QGLShaderProgram
@@ -231,7 +261,7 @@ public:
bool compiled;
bool isPartial;
bool hasPartialSource;
- QString errors;
+ QString log;
QByteArray partialSource;
bool create();
@@ -279,12 +309,12 @@ bool QGLShaderPrivate::compile()
value = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &value);
if (!compiled && value > 1) {
- char *log = new char [value];
+ char *logbuf = new char [value];
GLint len;
- glGetShaderInfoLog(shader, value, &len, log);
- errors = QString::fromLatin1(log);
- qWarning() << "QGLShader::compile:" << errors;
- delete [] log;
+ glGetShaderInfoLog(shader, value, &len, logbuf);
+ log = QString::fromLatin1(logbuf);
+ qWarning() << "QGLShader::compile:" << log;
+ delete [] logbuf;
}
return compiled;
}
@@ -543,9 +573,6 @@ bool QGLShader::setSourceCode(const QString& source)
*/
bool QGLShader::setSourceCodeFile(const QString& fileName)
{
- if (!d->shader)
- return false;
-
QFile file(fileName);
if (!file.open(QFile::ReadOnly)) {
qWarning() << "QGLShader: Unable to open file" << fileName;
@@ -669,13 +696,13 @@ bool QGLShader::isCompiled() const
}
/*!
- Returns the errors that occurred during the last compile.
+ Returns the errors and warnings that occurred during the last compile.
\sa setSourceCode()
*/
-QString QGLShader::errors() const
+QString QGLShader::log() const
{
- return d->errors;
+ return d->log;
}
/*!
@@ -719,7 +746,7 @@ public:
bool linked;
bool inited;
bool hasPartialShaders;
- QString errors;
+ QString log;
QList<QGLShader *> shaders;
QList<QGLShader *> anonShaders;
QGLShader *vertexShader;
@@ -819,13 +846,16 @@ bool QGLShaderProgram::addShader(QGLShader *shader)
return false;
if (d->shaders.contains(shader))
return true; // Already added to this shader program.
- if (d->program && shader && shader->d->shader) {
+ if (d->program && shader) {
if (!shader->d->compiled)
return false;
- if (!shader->d->isPartial)
+ if (!shader->d->isPartial) {
+ if (!shader->d->shader)
+ return false;
glAttachShader(d->program, shader->d->shader);
- else
+ } else {
d->hasPartialShaders = true;
+ }
d->linked = false; // Program needs to be relinked.
d->shaders.append(shader);
return true;
@@ -838,13 +868,13 @@ bool QGLShaderProgram::addShader(QGLShader *shader)
Compiles \a source as a shader of the specified \a type and
adds it to this shader program. Returns true if compilation
was successful, false otherwise. The compilation errors
- will be made available via errors().
+ and warnings will be made available via log().
This function is intended to be a short-cut for quickly
adding vertex and fragment shaders to a shader program without
creating an instance of QGLShader first.
- \sa removeShader(), link(), errors(), removeAllShaders()
+ \sa removeShader(), link(), log(), removeAllShaders()
*/
bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source)
{
@@ -852,7 +882,7 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source)
return false;
QGLShader *shader = new QGLShader(type, this);
if (!shader->setSourceCode(source)) {
- d->errors = shader->errors();
+ d->log = shader->log();
delete shader;
return false;
}
@@ -866,13 +896,13 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source)
Compiles \a source as a shader of the specified \a type and
adds it to this shader program. Returns true if compilation
was successful, false otherwise. The compilation errors
- will be made available via errors().
+ and warnings will be made available via log().
This function is intended to be a short-cut for quickly
adding vertex and fragment shaders to a shader program without
creating an instance of QGLShader first.
- \sa removeShader(), link(), errors(), removeAllShaders()
+ \sa removeShader(), link(), log(), removeAllShaders()
*/
bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QByteArray& source)
{
@@ -885,13 +915,13 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QByteArray& s
Compiles \a source as a shader of the specified \a type and
adds it to this shader program. Returns true if compilation
was successful, false otherwise. The compilation errors
- will be made available via errors().
+ and warnings will be made available via log().
This function is intended to be a short-cut for quickly
adding vertex and fragment shaders to a shader program without
creating an instance of QGLShader first.
- \sa removeShader(), link(), errors(), removeAllShaders()
+ \sa removeShader(), link(), log(), removeAllShaders()
*/
bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QString& source)
{
@@ -1022,14 +1052,14 @@ bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary)
d->linked = (value != 0);
value = 0;
glGetProgramiv(d->program, GL_INFO_LOG_LENGTH, &value);
- d->errors = QString();
+ d->log = QString();
if (value > 1) {
- char *log = new char [value];
+ char *logbuf = new char [value];
GLint len;
- glGetProgramInfoLog(d->program, value, &len, log);
- d->errors = QString::fromLatin1(log);
- qWarning() << "QGLShaderProgram::setProgramBinary:" << d->errors;
- delete [] log;
+ glGetProgramInfoLog(d->program, value, &len, logbuf);
+ d->log = QString::fromLatin1(logbuf);
+ qWarning() << "QGLShaderProgram::setProgramBinary:" << d->log;
+ delete [] logbuf;
}
return d->linked;
#else
@@ -1043,7 +1073,7 @@ bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary)
Returns the list of program binary formats that are accepted by
this system for use with setProgramBinary().
- \sa programBinary, setProgramBinary()
+ \sa programBinary(), setProgramBinary()
*/
QList<int> QGLShaderProgram::programBinaryFormats()
{
@@ -1065,7 +1095,7 @@ QList<int> QGLShaderProgram::programBinaryFormats()
Links together the shaders that were added to this program with
addShader(). Returns true if the link was successful or
false otherwise. If the link failed, the error messages can
- be retrieved with errors().
+ be retrieved with log().
Subclasses can override this function to initialize attributes
and uniform variables for use in specific shader programs.
@@ -1073,7 +1103,7 @@ QList<int> QGLShaderProgram::programBinaryFormats()
If the shader program was already linked, calling this
function again will force it to be re-linked.
- \sa addShader(), errors()
+ \sa addShader(), log()
*/
bool QGLShaderProgram::link()
{
@@ -1101,7 +1131,7 @@ bool QGLShaderProgram::link()
new QGLShader(QGLShader::VertexShader, this);
}
if (!d->vertexShader->setSourceCode(vertexSource)) {
- d->errors = d->vertexShader->errors();
+ d->log = d->vertexShader->log();
return false;
}
glAttachShader(d->program, d->vertexShader->d->shader);
@@ -1118,7 +1148,7 @@ bool QGLShaderProgram::link()
new QGLShader(QGLShader::FragmentShader, this);
}
if (!d->fragmentShader->setSourceCode(fragmentSource)) {
- d->errors = d->fragmentShader->errors();
+ d->log = d->fragmentShader->log();
return false;
}
glAttachShader(d->program, d->fragmentShader->d->shader);
@@ -1130,14 +1160,14 @@ bool QGLShaderProgram::link()
d->linked = (value != 0);
value = 0;
glGetProgramiv(d->program, GL_INFO_LOG_LENGTH, &value);
- d->errors = QString();
+ d->log = QString();
if (value > 1) {
- char *log = new char [value];
+ char *logbuf = new char [value];
GLint len;
- glGetProgramInfoLog(d->program, value, &len, log);
- d->errors = QString::fromLatin1(log);
- qWarning() << "QGLShaderProgram::link:" << d->errors;
- delete [] log;
+ glGetProgramInfoLog(d->program, value, &len, logbuf);
+ d->log = QString::fromLatin1(logbuf);
+ qWarning() << "QGLShaderProgram::link:" << d->log;
+ delete [] logbuf;
}
return d->linked;
}
@@ -1153,14 +1183,14 @@ bool QGLShaderProgram::isLinked() const
}
/*!
- Returns the errors that occurred during the last link()
+ Returns the errors and warnings that occurred during the last link()
or addShader() with explicitly specified source code.
\sa link()
*/
-QString QGLShaderProgram::errors() const
+QString QGLShaderProgram::log() const
{
- return d->errors;
+ return d->log;
}
/*!
@@ -1181,8 +1211,11 @@ bool QGLShaderProgram::enable()
return true;
}
+#undef ctx
+#define ctx QGLContext::currentContext()
+
/*!
- Disables this shader program in the currently active QGLContext.
+ Disables the active shader program in the current QGLContext.
This is equivalent to calling \c{glUseProgram(0)}.
\sa enable()
@@ -1197,6 +1230,9 @@ void QGLShaderProgram::disable()
#endif
}
+#undef ctx
+#define ctx d->context
+
/*!
Returns the OpenGL identifier associated with this shader program.
@@ -1782,7 +1818,6 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat value)
/*!
Sets the uniform variable at \a location in the current context to \a value.
- This function must be used when setting sampler values.
\sa setAttributeValue()
*/
@@ -1796,7 +1831,7 @@ void QGLShaderProgram::setUniformValue(int location, GLint value)
\overload
Sets the uniform variable called \a name in the current context
- to \a value. This function must be used when setting sampler values.
+ to \a value.
\sa setAttributeValue()
*/
@@ -1806,6 +1841,31 @@ void QGLShaderProgram::setUniformValue(const char *name, GLint value)
}
/*!
+ Sets the uniform variable at \a location in the current context to \a value.
+ This function should be used when setting sampler values.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(int location, GLuint value)
+{
+ if (location != -1)
+ glUniform1i(location, value);
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable called \a name in the current context
+ to \a value. This function should be used when setting sampler values.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(const char *name, GLuint value)
+{
+ setUniformValue(uniformLocation(name), value);
+}
+
+/*!
Sets the uniform variable at \a location in the current context to
the 2D vector (\a x, \a y).
@@ -1990,6 +2050,114 @@ void QGLShaderProgram::setUniformValue(const char *name, const QColor& color)
}
/*!
+ Sets the uniform variable at \a location in the current context to
+ the x and y coordinates of \a point.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(int location, const QPoint& point)
+{
+ if (location != -1) {
+ GLfloat values[4] = {point.x(), point.y()};
+ glUniform2fv(location, 1, values);
+ }
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable associated with \a name in the current
+ context to the x and y coordinates of \a point.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(const char *name, const QPoint& point)
+{
+ setUniformValue(uniformLocation(name), point);
+}
+
+/*!
+ Sets the uniform variable at \a location in the current context to
+ the x and y coordinates of \a point.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(int location, const QPointF& point)
+{
+ if (location != -1) {
+ GLfloat values[4] = {point.x(), point.y()};
+ glUniform2fv(location, 1, values);
+ }
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable associated with \a name in the current
+ context to the x and y coordinates of \a point.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(const char *name, const QPointF& point)
+{
+ setUniformValue(uniformLocation(name), point);
+}
+
+/*!
+ Sets the uniform variable at \a location in the current context to
+ the width and height of the given \a size.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(int location, const QSize& size)
+{
+ if (location != -1) {
+ GLfloat values[4] = {size.width(), size.width()};
+ glUniform2fv(location, 1, values);
+ }
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable associated with \a name in the current
+ context to the width and height of the given \a size.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(const char *name, const QSize& size)
+{
+ setUniformValue(uniformLocation(name), size);
+}
+
+/*!
+ Sets the uniform variable at \a location in the current context to
+ the width and height of the given \a size.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(int location, const QSizeF& size)
+{
+ if (location != -1) {
+ GLfloat values[4] = {size.width(), size.height()};
+ glUniform2fv(location, 1, values);
+ }
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable associated with \a name in the current
+ context to the width and height of the given \a size.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size)
+{
+ setUniformValue(uniformLocation(name), size);
+}
+
+/*!
Sets the uniform variable at \a location in the current context
to a 2x2 matrix \a value.
@@ -2351,8 +2519,7 @@ void QGLShaderProgram::setUniformValue
/*!
Sets the uniform variable array at \a location in the current
- context to the \a count elements of \a values. This overload
- must be used when setting an array of sampler values.
+ context to the \a count elements of \a values.
\sa setAttributeValue()
*/
@@ -2366,8 +2533,7 @@ void QGLShaderProgram::setUniformValueArray(int location, const GLint *values, i
\overload
Sets the uniform variable array called \a name in the current
- context to the \a count elements of \a values. This overload
- must be used when setting an array of sampler values.
+ context to the \a count elements of \a values.
\sa setAttributeValue()
*/
@@ -2379,6 +2545,34 @@ void QGLShaderProgram::setUniformValueArray
/*!
Sets the uniform variable array at \a location in the current
+ context to the \a count elements of \a values. This overload
+ should be used when setting an array of sampler values.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count)
+{
+ if (location != -1)
+ glUniform1iv(location, count, reinterpret_cast<const GLint *>(values));
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable array called \a name in the current
+ context to the \a count elements of \a values. This overload
+ should be used when setting an array of sampler values.
+
+ \sa setAttributeValue()
+*/
+void QGLShaderProgram::setUniformValueArray
+ (const char *name, const GLuint *values, int count)
+{
+ setUniformValueArray(uniformLocation(name), values, count);
+}
+
+/*!
+ Sets the uniform variable array at \a location in the current
context to the \a count elements of \a values. Each element
has \a size components. The \a size must be 1, 2, 3, or 4.
diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h
index 047bb3c..b69d28e 100644
--- a/src/opengl/qglshaderprogram.h
+++ b/src/opengl/qglshaderprogram.h
@@ -1,28 +1,47 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtOpenGL module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGLSHADERPROGRAM_H
#define QGLSHADERPROGRAM_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
#include <QtOpenGL/qgl.h>
#include <QtGui/qvector2d.h>
#include <QtGui/qvector3d.h>
@@ -35,7 +54,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(OpenGL)
-#if !defined(QT_OPENGL_ES_1_CL) && !defined(QT_GL_FIXED_PREFERRED)
+#if !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
class QGLShaderProgram;
class QGLShaderPrivate;
@@ -77,7 +96,7 @@ public:
QByteArray sourceCode() const;
bool isCompiled() const;
- QString errors() const;
+ QString log() const;
GLuint shaderId() const;
@@ -117,10 +136,10 @@ public:
virtual bool link();
bool isLinked() const;
- QString errors() const;
+ QString log() const;
bool enable();
- void disable();
+ static void disable();
GLuint programId() const;
@@ -177,6 +196,7 @@ public:
void setUniformValue(int location, GLfloat value);
void setUniformValue(int location, GLint value);
+ void setUniformValue(int location, GLuint value);
void setUniformValue(int location, GLfloat x, GLfloat y);
void setUniformValue(int location, GLfloat x, GLfloat y, GLfloat z);
void setUniformValue(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
@@ -184,6 +204,10 @@ public:
void setUniformValue(int location, const QVector3D& value);
void setUniformValue(int location, const QVector4D& value);
void setUniformValue(int location, const QColor& color);
+ void setUniformValue(int location, const QPoint& point);
+ void setUniformValue(int location, const QPointF& point);
+ void setUniformValue(int location, const QSize& size);
+ void setUniformValue(int location, const QSizeF& size);
void setUniformValue(int location, const QMatrix2x2& value);
void setUniformValue(int location, const QMatrix2x3& value);
void setUniformValue(int location, const QMatrix2x4& value);
@@ -198,6 +222,7 @@ public:
void setUniformValue(const char *name, GLfloat value);
void setUniformValue(const char *name, GLint value);
+ void setUniformValue(const char *name, GLuint value);
void setUniformValue(const char *name, GLfloat x, GLfloat y);
void setUniformValue(const char *name, GLfloat x, GLfloat y, GLfloat z);
void setUniformValue(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
@@ -205,6 +230,10 @@ public:
void setUniformValue(const char *name, const QVector3D& value);
void setUniformValue(const char *name, const QVector4D& value);
void setUniformValue(const char *name, const QColor& color);
+ void setUniformValue(const char *name, const QPoint& point);
+ void setUniformValue(const char *name, const QPointF& point);
+ void setUniformValue(const char *name, const QSize& size);
+ void setUniformValue(const char *name, const QSizeF& size);
void setUniformValue(const char *name, const QMatrix2x2& value);
void setUniformValue(const char *name, const QMatrix2x3& value);
void setUniformValue(const char *name, const QMatrix2x4& value);
@@ -219,6 +248,7 @@ public:
void setUniformValueArray(int location, const GLfloat *values, int count, int size);
void setUniformValueArray(int location, const GLint *values, int count);
+ void setUniformValueArray(int location, const GLuint *values, int count);
void setUniformValueArray(int location, const QVector2D *values, int count);
void setUniformValueArray(int location, const QVector3D *values, int count);
void setUniformValueArray(int location, const QVector4D *values, int count);
@@ -234,6 +264,7 @@ public:
void setUniformValueArray(const char *name, const GLfloat *values, int count, int size);
void setUniformValueArray(const char *name, const GLint *values, int count);
+ void setUniformValueArray(const char *name, const GLuint *values, int count);
void setUniformValueArray(const char *name, const QVector2D *values, int count);
void setUniformValueArray(const char *name, const QVector3D *values, int count);
void setUniformValueArray(const char *name, const QVector4D *values, int count);
diff --git a/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp b/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp
index 4a5c219..9bd4425 100644
--- a/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp
+++ b/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp
@@ -111,7 +111,7 @@ QNetworkReply *AccelTreeResourceLoader::load(const QUrl &uri,
networkLoop.connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(error(QNetworkReply::NetworkError)));
networkLoop.connect(reply, SIGNAL(finished()), SLOT(finished()));
- if(networkLoop.exec())
+ if(networkLoop.exec(QEventLoop::ExcludeUserInputEvents))
{
const QString errorMessage(escape(reply->errorString()));