From dedaa3776cc2c2bfb6e9d3ef807f7782ef8f7ec8 Mon Sep 17 00:00:00 2001 From: hengli Date: Wed, 20 Oct 2010 12:29:42 +0200 Subject: [PATCH] Minor clean-ups to imagery code. --- src/ui/map3D/QMap3DWidget.cc | 15 ++++++++--- src/ui/map3D/Texture.cc | 48 ++---------------------------------- src/ui/map3D/WebImage.cc | 4 +-- src/ui/map3D/WebImage.h | 2 +- 4 files changed, 16 insertions(+), 53 deletions(-) diff --git a/src/ui/map3D/QMap3DWidget.cc b/src/ui/map3D/QMap3DWidget.cc index 831afc85a..e57db0536 100644 --- a/src/ui/map3D/QMap3DWidget.cc +++ b/src/ui/map3D/QMap3DWidget.cc @@ -234,13 +234,20 @@ QMap3DWidget::displayHandler(void) drawLegend(); // display pose information - glColor4f(0.0f, 0.0f, 0.0f, 0.5f); + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glBegin(GL_POLYGON); glVertex2f(0.0f, 0.0f); - glVertex2f(0.0f, 45.0f); - glVertex2f(getWindowWidth(), 45.0f); + glVertex2f(0.0f, 30.0f); + glVertex2f(getWindowWidth(), 30.0f); glVertex2f(getWindowWidth(), 0.0f); glEnd(); + glColor4f(0.1f, 0.1f, 0.1f, 1.0f); + glBegin(GL_POLYGON); + glVertex2f(0.0f, getWindowHeight()); + glVertex2f(0.0f, getWindowHeight() - 25.0f); + glVertex2f(getWindowWidth(), getWindowHeight() - 25.0f); + glVertex2f(getWindowWidth(), getWindowHeight()); + glEnd(); std::pair mouseWorldCoords = getPositionIn3DMode(getMouseX(), getMouseY()); @@ -253,7 +260,7 @@ QMap3DWidget::displayHandler(void) painter.setRenderHint(QPainter::HighQualityAntialiasing, true); paintText(QString("x = %1 y = %2 z = %3 r = %4 p = %5 y = %6 Cursor [%7 %8]").arg(robotX, 0, 'f', 2).arg(robotY, 0, 'f', 2).arg(robotZ, 0, 'f', 2).arg(robotRoll, 0, 'f', 2).arg(robotPitch, 0, 'f', 2).arg(robotYaw, 0, 'f', 2).arg( mouseWorldCoords.first + robotX, 0, 'f', 2).arg( mouseWorldCoords.second + robotY, 0, 'f', 2), QColor(255, 255, 255), - 12, + 11, 5, 5, &painter); diff --git a/src/ui/map3D/Texture.cc b/src/ui/map3D/Texture.cc index 62f59d0b5..82574bb15 100644 --- a/src/ui/map3D/Texture.cc +++ b/src/ui/map3D/Texture.cc @@ -68,52 +68,7 @@ void Texture::draw(float x1, float y1, float x2, float y2, bool smoothInterpolation) const { - if (state == REQUESTED) - { - glBegin(GL_LINE_LOOP); - glColor3f(0.0f, 0.0f, 1.0f); - glVertex2f(x1, y1); - glVertex2f(x2, y1); - glVertex2f(x2, y2); - glVertex2f(x1, y2); - glEnd(); - return; - } - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, id); - - float dx, dy; - if (smoothInterpolation) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - dx = 1.0f / (2.0f * textureWidth); - dy = 1.0f / (2.0f * textureHeight); - } - else - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - dx = 0.0f; - dy = 0.0f; - } - - glColor3f(1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - - glTexCoord2f(dx, maxV - dy); - glVertex2f(x1, y1); - glTexCoord2f(maxU - dx, maxV - dy); - glVertex2f(x2, y1); - glTexCoord2f(maxU - dx, dy); - glVertex2f(x2, y2); - glTexCoord2f(dx, dy); - glVertex2f(x1, y2); - - glEnd(); - - glDisable(GL_TEXTURE_2D); + draw(x1, y1, x2, y1, x2, y2, x1, y2, smoothInterpolation); } void @@ -130,6 +85,7 @@ Texture::draw(float x1, float y1, float x2, float y2, glVertex2f(x3, y3); glVertex2f(x4, y4); glEnd(); + return; } diff --git a/src/ui/map3D/WebImage.cc b/src/ui/map3D/WebImage.cc index e915c154f..bfcdc9cf6 100644 --- a/src/ui/map3D/WebImage.cc +++ b/src/ui/map3D/WebImage.cc @@ -16,7 +16,7 @@ WebImage::WebImage() void WebImage::clear(void) { - image.clear(); + image.reset(); sourceURL.clear(); state = WebImage::UNINITIALIZED; lastReference = 0; @@ -60,7 +60,7 @@ WebImage::setData(const QByteArray& data) { if (image.isNull()) { - image = QSharedPointer(new QImage); + image.reset(new QImage); } *image = QGLWidget::convertToGLFormat(tempImage); } diff --git a/src/ui/map3D/WebImage.h b/src/ui/map3D/WebImage.h index 15fec65ca..279687895 100644 --- a/src/ui/map3D/WebImage.h +++ b/src/ui/map3D/WebImage.h @@ -42,7 +42,7 @@ public: private: State state; QString sourceURL; - QSharedPointer image; + QScopedPointer image; uint64_t lastReference; bool syncFlag; }; -- 2.22.0