RobotPosesPainter.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  RobotPosesPainter.cpp
00003  *
00004  *  (C) 2007 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  Additional information:
00008  *  $Id: $
00009  *******************************************************************************/
00010 
00011 #include "RobotPosesPainter.h"
00012 
00013 #include "Messages/FastRobotPoseM.h"
00014 
00015 #include <QtOpenGL>
00016 #include <GL/glut.h>
00017 
00018 #include "Architecture/Config/Config.h"
00019 
00020 #define THIS RobotPosesPainter
00021 
00022 THIS::THIS() : PainterPlugin( )
00023 {
00024   setName ( "Robot Poses (Hyper Particle Filter)" );
00025 }
00026 
00027 
00028 THIS::~THIS()
00029 {
00030 }
00031 
00032 
00033 void THIS::processMessage ( Message* newMessage )
00034 {
00035   PainterPlugin::processMessage ( newMessage );
00036   switch ( newMessage->getType() )
00037   {
00038     case MessageTypes::PARTICLE_DATA_M:
00039 
00040     {
00041       ParticleDataM* message = Message::castTo<ParticleDataM> ( newMessage );
00042       if ( message )
00043       {
00044         m_ParticleData = * ( message->getParticles() );
00045         requestRedraw();
00046       }
00047       break;
00048     }
00049 
00050     default:
00051       break;
00052 
00053   }
00054 }
00055 
00056 void THIS::paint ( float next2DLayer )
00057 {
00058   glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL );
00059   float t;
00060   glTranslatef ( 0.0, 0.0, next2DLayer );
00061   for ( unsigned int i = 0; i < m_ParticleData.size(); i++ )
00062   {
00063     if ( m_ParticleData[ i ].poseKind == ParticleDataM::Robot )
00064     {
00065       glPushMatrix();
00066       glTranslatef ( m_ParticleData[i].x, m_ParticleData[i].y, 0.0 );
00067       glRotatef ( m_ParticleData[i].theta * 180.0 / M_PI, 0.0, 0.0, 1.0 );
00068       t = float ( i ) / float ( m_ParticleData.size() );
00069       glColor3f ( 1.0 - t, 0, 0 );
00070 
00071       glBegin ( GL_POLYGON );
00072       glVertex3f ( -15.0,   0.0, 1.0 - t );
00073       glVertex3f ( -25.0,  15.0, 1.0 - t );
00074       glVertex3f ( 25.0,   0.0, 1.0 - t );
00075       glVertex3f ( -25.0, -15.0, 1.0 - t );
00076       glEnd();
00077 
00078       glPopMatrix();
00079     }
00080   }
00081 }
00082 
00083 
00084 
00085 #undef THIS


obj_rec_gui
Author(s): AGAS/agas@uni-koblenz.de
autogenerated on Mon Oct 6 2014 02:53:43