ParticlePainter.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  ParticlePainter.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 "ParticlePainter.h"
00012 
00013 
00014 #include <QtOpenGL>
00015 #include <GL/glut.h>
00016 #include <cmath>
00017 
00018 
00019 #define THIS ParticlePainter
00020 
00021 THIS::THIS() : PainterPlugin( )
00022 {
00023   setName ( "Particle Arrows" );
00024 }
00025 
00026 
00027 THIS::~THIS()
00028 {
00029 }
00030 
00031 
00032 void THIS::processMessage ( Message* newMessage )
00033 {
00034   PainterPlugin::processMessage ( newMessage );
00035   switch ( newMessage->getType() )
00036   {
00037     case MessageTypes::PARTICLE_DATA_M:
00038 
00039     {
00040       ParticleDataM* message = Message::castTo<ParticleDataM> ( newMessage );
00041       if ( message )
00042       {
00043         m_ParticleData = * ( message->getParticles() );
00044         requestRedraw();
00045       }
00046       break;
00047     }
00048 
00049     default:
00050       break;
00051 
00052   }
00053 }
00054 
00055 void THIS::paint ( float next2DLayer )
00056 {
00057   glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE );
00058   glLineWidth ( 1.0 );
00059   float t;
00060   glTranslatef ( 0.0, 0.0, next2DLayer );
00061 
00062   for ( unsigned int i = 0; i < m_ParticleData.size(); i++ )
00063   {
00064     glPushMatrix();
00065 
00066     glTranslatef ( m_ParticleData[i].x, m_ParticleData[i].y, 0.0 );
00067 
00068     glRotatef ( m_ParticleData[i].theta * 180.0 / M_PI, 0.0, 0.0, 1.0 );
00069     t = float ( i ) / float ( m_ParticleData.size() );
00070     glScalef ( 1.5 - t, 1.5 - t, 1.5 - t );
00071     glColor3f ( 1.0 - t, 1.0 - t, 1.0 - t ); // color coding the index of the particle
00072 
00073     // arrow
00074     glBegin ( GL_POLYGON );
00075     glVertex3f ( -15.0,  0.0, 1.0 - t );
00076     glVertex3f ( -25.0,  5.0, 1.0 - t );
00077     glVertex3f ( 25.0,  0.0, 1.0 - t );
00078     glVertex3f ( -25.0, -5.0, 1.0 - t );
00079     glEnd();
00080 
00081     glPopMatrix();
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