Commit dedaa377 authored by hengli's avatar hengli

Minor clean-ups to imagery code.

parent 97ea3189
......@@ -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<float,float> 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);
......
......@@ -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;
}
......
......@@ -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<QImage>(new QImage);
image.reset(new QImage);
}
*image = QGLWidget::convertToGLFormat(tempImage);
}
......
......@@ -42,7 +42,7 @@ public:
private:
State state;
QString sourceURL;
QSharedPointer<QImage> image;
QScopedPointer<QImage> image;
uint64_t lastReference;
bool syncFlag;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment