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

SourceForge.net Logo

©2005-2010 Laurent Ribon