glc_mover.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021  *****************************************************************************/
00022 
00024 
00025 #include "glc_mover.h"
00026 #include "glc_viewport.h"
00027 
00028 GLC_Mover::GLC_Mover(GLC_Viewport* pViewport, const QList<GLC_RepMover*>& repsList)
00029 : QObject()
00030 , m_RepMoverList(repsList)
00031 , m_PreviousVector()
00032 , m_pViewport(pViewport)
00033 , m_MoverInfo()
00034 {
00035         const int size= m_RepMoverList.size();
00036         for (int i= 0; i < size; ++i)
00037         {
00038                 m_RepMoverList[i]->setRepMoverInfo(&m_MoverInfo);
00039         }
00040 }
00041 
00042 // Copy constructor
00043 GLC_Mover::GLC_Mover(const GLC_Mover& mover)
00044 : QObject()
00045 , m_RepMoverList()
00046 , m_PreviousVector(mover.m_PreviousVector)
00047 , m_pViewport(mover.m_pViewport)
00048 , m_MoverInfo(mover.m_MoverInfo)
00049 {
00050         const int size= mover.m_RepMoverList.size();
00051         for (int i= 0; i < size; ++i)
00052         {
00053                 m_RepMoverList.append(mover.m_RepMoverList.at(i)->clone());
00054                 m_RepMoverList.last()->setRepMoverInfo(&m_MoverInfo);
00055         }
00056 }
00057 
00058 GLC_Mover::~GLC_Mover()
00059 {
00060         clearMoverRepresentation();
00061 }
00062 
00064 // Set Functions
00066 
00067 // Set the mover representation list
00068 void GLC_Mover::setRepresentationsList(const QList<GLC_RepMover*>& listOfRep)
00069 {
00070         qDebug() << "GLC_Mover::setRepresentationsList";
00071         clearMoverRepresentation();
00072         m_RepMoverList= listOfRep;
00073         const int size= m_RepMoverList.size();
00074         for (int i= 0; i < size; ++i)
00075         {
00076                 m_RepMoverList[i]->setRepMoverInfo(&m_MoverInfo);
00077         }
00078 }
00079 
00080 // Update representation
00081 void GLC_Mover::initRepresentation()
00082 {
00083         const int size= m_RepMoverList.size();
00084         for (int i= 0; i < size; ++i)
00085         {
00086                 m_RepMoverList[i]->init();
00087         }
00088 }
00089 
00090 // Update representation
00091 void GLC_Mover::updateRepresentation()
00092 {
00093         const int size= m_RepMoverList.size();
00094         for (int i= 0; i < size; ++i)
00095         {
00096                 m_RepMoverList[i]->update();
00097         }
00098 
00099 }
00100 
00102 // OpenGL Functions
00104 
00105 // Mover representations list display
00106 void GLC_Mover::renderRepresentation()
00107 {
00108         const int size= m_RepMoverList.size();
00109         for (int i= 0; i < size; ++i)
00110         {
00111                 m_RepMoverList[i]->render();
00112         }
00113 }
00114 
00116 // Private services Functions
00118 
00119 // Clear mover representation
00120 void GLC_Mover::clearMoverRepresentation()
00121 {
00122         // Delete mover representations
00123         const int size= m_RepMoverList.size();
00124         for (int i= 0; i < size; ++i)
00125         {
00126                 delete m_RepMoverList.at(i);
00127         }
00128 }
00129 
00130 

SourceForge.net Logo

©2005-2011 Laurent Ribon