PersonPainter.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  PersonPainter.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 "PersonPainter.h"
00012 
00013 #include "Messages/TrackedPeopleM.h"
00014 #include "Messages/FollowingStateM.h"
00015 
00016 
00017 #include <QtOpenGL>
00018 #include <GL/glut.h>
00019 
00020 #include "Architecture/Config/Config.h"
00021 
00022 #define THIS PersonPainter
00023 
00024 THIS::THIS() : PainterPlugin( )
00025 {
00026   setName ( "Person Tracking & Following" );
00027         m_PersonModel = SceneGraph ( "config/Person.xml" );
00028 }
00029 
00030 
00031 THIS::~THIS()
00032 {
00033 }
00034 
00035 
00036 void THIS::processMessage ( Message* newMessage )
00037 {
00038   PainterPlugin::processMessage ( newMessage );
00039   switch ( newMessage->getType() )
00040   {
00041     case MessageTypes::FOLLOWING_STATE_M:
00042     {
00043       if ( FollowingStateM* message = Message::castTo<FollowingStateM> ( newMessage ) )
00044       {
00045         m_Operator = message->getOperator(); 
00046         requestRedraw();
00047       }
00048       break;
00049     }
00050 
00051     case MessageTypes::TRACKED_PEOPLE_M:
00052     {
00053       if ( TrackedPeopleM* message = Message::castTo<TrackedPeopleM> ( newMessage ) )
00054       {
00055         m_TrackedPeople = message->getTrackedPeople(); 
00056         requestRedraw();
00057       }
00058       break;
00059     }
00060 
00061     default:
00062       break;
00063 
00064   }
00065 }
00066 
00067 void THIS::paint ( float next2DLayer )
00068 {
00069   if ( m_Operator.getRadius() != 0.0 )
00070   {
00071     glPushMatrix();
00072                 glTranslatef( 0,0,next2DLayer );
00073 
00074     glColor4f ( 1.0, 0.0, 0.0, 0.5 );
00075     glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL );
00076     glEnable ( GL_BLEND );
00077     glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
00078     glColor4f ( 1.0, 0.0, 0.0, 0.5 );
00079 
00080     glPushMatrix();
00081     glTranslatef ( m_Operator.getCenter().x(), m_Operator.getCenter().y(), 0.0 );
00082     glBegin ( GL_POLYGON );
00083     for ( float alpha = 0; alpha < 2 * M_PI; alpha += M_PI / 32 )
00084     {
00085       glVertex3f ( m_Operator.getRadius() * sin ( alpha ), m_Operator.getRadius() * cos ( alpha ), 0.0 );
00086     }
00087     glEnd();
00088     glLineWidth ( 3.0 );
00089     glBegin ( GL_LINES );
00090     glVertex3f ( 0.0, 0.0, 0.0 );
00091     glVertex3f ( 0.0, 0.0, 500.0 );
00092     glEnd();
00093     glLineWidth ( 1.0 );
00094     glPopMatrix();
00095 
00096     glColor4f ( 1.0, 1.0, 0.0, 0.5 );
00097     glBegin ( GL_LINES );
00098     glVertex3f ( 0.0, 0.0, 0.0 );
00099     glVertex3f ( m_Operator.getCenter().x(), m_Operator.getCenter().y(), 0.0 );
00100     glEnd();
00101 
00102     glDisable ( GL_BLEND );
00103     glPopMatrix();
00104   }
00105 
00106 
00107   for ( unsigned i=0; i<m_TrackedPeople.size(); i++ )
00108   {
00109     Point2D center = m_TrackedPeople[i].getCenter();
00110                 
00111                 BaseLib::Math::Vec3d position;
00112                 position.x = center.x();
00113                 position.y = center.y();
00114                 m_PersonModel.setTranslationMatrix("Person.position",position);
00115                 m_PersonModel.paintGl();
00116                 
00117                 
00118     glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL );
00119                 
00120                 if ( m_TrackedPeople[i].isValid() )
00121                 {
00122                         glColor4f ( 1.0, 1.0, 0.0, 0.5 );
00123                 }
00124                 else
00125                 {
00126                         glColor4f ( 0.5, 0.5, 0.5, 0.5 );
00127                 }
00128 
00129     float radius = m_TrackedPeople[i].getRadius() / 2.0;
00130 
00131     glPushMatrix();
00132 
00133     glTranslatef( center.x(), center.y(), 0.0 );
00134       glutSolidCone( radius, 300, 36, 1 );
00135     glPopMatrix();
00136   }
00137 }
00138 
00139 
00140 
00141 #undef THIS


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