glc_movercontroller.h

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 #ifndef GLC_MOVERCONTROLLER_H_
00026 #define GLC_MOVERCONTROLLER_H_
00027 
00028 #include "glc_mover.h"
00029 #include <QObject>
00030 #include <QHash>
00031 #include <QtDebug>
00032 
00033 #include "../glc_config.h"
00034 #include "glc_userinput.h"
00035 
00036 class QGLWidget;
00037 
00040 
00041 
00042 class GLC_LIB_EXPORT GLC_MoverController : public QObject
00043 {
00044         Q_OBJECT
00045 public:
00047         typedef QHash<const int, GLC_Mover*> MoverHash;
00048 
00050         enum MoverType
00051         {
00052                 Pan= 1,
00053                 Zoom= 2,
00054                 TrackBall= 3,
00055                 Target= 4,
00056                 TurnTable= 5,
00057                 Fly= 6,
00058                 TSR= 7
00059         };
00060 
00061 public:
00063         GLC_MoverController();
00064 
00066         GLC_MoverController(const GLC_MoverController&);
00067 
00069         virtual ~GLC_MoverController();
00070 
00072 
00074 
00075 public:
00076 
00078         inline bool hasActiveMover() const
00079         { return (m_ActiveMoverId != 0);}
00080 
00082         inline int activeMoverId() const
00083         {return m_ActiveMoverId;}
00084 
00086         inline GLC_Mover* activeMover() const
00087         {return m_MoverHash.value(m_ActiveMoverId);}
00088 
00090         inline GLC_Mover* getMover(const int id) const
00091         {return m_MoverHash.value(id);}
00092 
00094 
00096 
00098 
00099 public:
00101         GLC_MoverController& operator = (const GLC_MoverController&);
00102 
00104         void addMover(GLC_Mover*, const int);
00105 
00107         void removeMover(const int);
00108 
00110         void setActiveMover(const int id, const GLC_UserInput& userInput);
00111 
00113         void setNoMover();
00114 
00116         inline bool move(const GLC_UserInput& userInput)
00117         {
00118                 Q_ASSERT(0 != m_ActiveMoverId);
00119                 return m_MoverHash.value(m_ActiveMoverId)->move(userInput);
00120         }
00121 
00123 
00125 
00127 
00128 public:
00130         inline void drawActiveMoverRep()
00131         {
00132                 if(0 != m_ActiveMoverId)
00133                 {
00134                         m_MoverHash.value(m_ActiveMoverId)->renderRepresentation();
00135                 }
00136         }
00137 
00139 signals:
00141         void repaintNeeded();
00142 
00144 // Private Members
00146 private:
00148         int m_ActiveMoverId;
00149 
00151         MoverHash m_MoverHash;
00152 };
00153 
00154 #endif /* GLC_MOVERCONTROLLER_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon