dispmap/svpointcloudviewer.cpp

47 lines
1.2 KiB
C++
Raw Normal View History

2014-07-25 11:32:00 +04:00
#include "svpointcloudviewer.h"
2014-07-28 00:04:18 +04:00
#include <QtGui/QOpenGLShaderProgram>
#include <QtGui/QOpenGLContext>
2014-07-25 11:32:00 +04:00
SvPointCloudViewer::SvPointCloudViewer(QQuickItem *parent) :
2014-07-28 00:04:18 +04:00
QQuickPaintedItem(parent)
2014-07-25 11:32:00 +04:00
{
2014-07-28 00:04:18 +04:00
setRenderTarget(QQuickPaintedItem::FramebufferObject);
2014-07-25 11:32:00 +04:00
}
2014-07-28 00:04:18 +04:00
void SvPointCloudViewer::paint(QPainter *painter)
2014-07-25 11:32:00 +04:00
{
2014-07-28 20:25:39 +04:00
if (!m_pointCloud) {
qDebug() << "point cloud not set!";
return;
2014-07-25 11:32:00 +04:00
}
2014-07-28 20:25:39 +04:00
painter->beginNativePainting();
2014-07-28 00:04:18 +04:00
2014-07-28 20:25:39 +04:00
glViewport(0, 0, width(), height());
glClearColor(0, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT/* | GL_DEPTH_BUFFER_BIT*/);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, height(), -400.0f);
glScalef(0.1f, 0.1f, 0.1f);
glColor3f(1.0f, 0.0f, 0.0f);
glPointSize(3.0f);
glBegin(GL_POINTS);
for (int y = 0; y < m_pointCloud->getHeight(); y++) {
for (int x = 0; x < m_pointCloud->getWidth(); x++) {
SvPoint *p = m_pointCloud->point(x, y);
if (p) {
glColor3ub(qRed(p->color()),qGreen(p->color()), qBlue(p->color()));
glVertex3i(x, y, 0);
}
}
}
glEnd();
2014-07-28 00:04:18 +04:00
painter->endNativePainting();
2014-07-25 11:32:00 +04:00
}
2014-07-28 00:04:18 +04:00