Browse Source

Minor clean-ups to imagery code.

QGC4.4
hengli 15 years ago
parent
commit
dedaa3776c
  1. 15
      src/ui/map3D/QMap3DWidget.cc
  2. 48
      src/ui/map3D/Texture.cc
  3. 4
      src/ui/map3D/WebImage.cc
  4. 2
      src/ui/map3D/WebImage.h

15
src/ui/map3D/QMap3DWidget.cc

@ -234,13 +234,20 @@ QMap3DWidget::displayHandler(void)
drawLegend(); drawLegend();
// display pose information // display pose information
glColor4f(0.0f, 0.0f, 0.0f, 0.5f); glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
glVertex2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glVertex2f(0.0f, 45.0f); glVertex2f(0.0f, 30.0f);
glVertex2f(getWindowWidth(), 45.0f); glVertex2f(getWindowWidth(), 30.0f);
glVertex2f(getWindowWidth(), 0.0f); glVertex2f(getWindowWidth(), 0.0f);
glEnd(); 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<float,float> mouseWorldCoords = std::pair<float,float> mouseWorldCoords =
getPositionIn3DMode(getMouseX(), getMouseY()); getPositionIn3DMode(getMouseX(), getMouseY());
@ -253,7 +260,7 @@ QMap3DWidget::displayHandler(void)
painter.setRenderHint(QPainter::HighQualityAntialiasing, true); 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), 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), QColor(255, 255, 255),
12, 11,
5, 5,
5, 5,
&painter); &painter);

48
src/ui/map3D/Texture.cc

@ -68,52 +68,7 @@ void
Texture::draw(float x1, float y1, float x2, float y2, Texture::draw(float x1, float y1, float x2, float y2,
bool smoothInterpolation) const bool smoothInterpolation) const
{ {
if (state == REQUESTED) draw(x1, y1, x2, y1, x2, y2, x1, y2, smoothInterpolation);
{
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);
} }
void void
@ -130,6 +85,7 @@ Texture::draw(float x1, float y1, float x2, float y2,
glVertex2f(x3, y3); glVertex2f(x3, y3);
glVertex2f(x4, y4); glVertex2f(x4, y4);
glEnd(); glEnd();
return; return;
} }

4
src/ui/map3D/WebImage.cc

@ -16,7 +16,7 @@ WebImage::WebImage()
void void
WebImage::clear(void) WebImage::clear(void)
{ {
image.clear(); image.reset();
sourceURL.clear(); sourceURL.clear();
state = WebImage::UNINITIALIZED; state = WebImage::UNINITIALIZED;
lastReference = 0; lastReference = 0;
@ -60,7 +60,7 @@ WebImage::setData(const QByteArray& data)
{ {
if (image.isNull()) if (image.isNull())
{ {
image = QSharedPointer<QImage>(new QImage); image.reset(new QImage);
} }
*image = QGLWidget::convertToGLFormat(tempImage); *image = QGLWidget::convertToGLFormat(tempImage);
} }

2
src/ui/map3D/WebImage.h

@ -42,7 +42,7 @@ public:
private: private:
State state; State state;
QString sourceURL; QString sourceURL;
QSharedPointer<QImage> image; QScopedPointer<QImage> image;
uint64_t lastReference; uint64_t lastReference;
bool syncFlag; bool syncFlag;
}; };

Loading…
Cancel
Save