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  Version 2.0.0 Beta 1, packaged on April 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 General Public License as published by
00011  the Free Software Foundation; either version 2 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 General Public License for more details.
00018 
00019  You should have received a copy of the GNU 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 #ifndef GLC_MOVERCONTROLLER_H_
00028 #define GLC_MOVERCONTROLLER_H_
00029 
00030 #include "glc_mover.h"
00031 #include <QObject>
00032 #include <QHash>
00033 #include <QtDebug>
00034 
00035 #include "../glc_config.h"
00036 
00037 class QGLWidget;
00038 class QMouseEvent;
00039 
00042 
00043 
00044 class GLC_LIB_EXPORT GLC_MoverController : public QObject
00045 {
00046         Q_OBJECT
00047 public:
00049         typedef QHash<const int, GLC_Mover*> MoverHash;
00050 
00052         enum MoverType
00053         {
00054                 Pan= 1,
00055                 Zoom= 2,
00056                 TrackBall= 3,
00057                 Target= 4,
00058                 TurnTable= 5,
00059                 Fly= 6
00060         };
00061 
00062 public:
00064         GLC_MoverController();
00065 
00067         GLC_MoverController(const GLC_MoverController&);
00068 
00070         virtual ~GLC_MoverController();
00071 
00073 
00075 
00076 public:
00077 
00079         inline bool hasActiveMover() const
00080         { return (m_ActiveMoverId != 0);}
00081 
00083         inline int activeMoverId() const
00084         {return m_ActiveMoverId;}
00085 
00087         inline GLC_Mover* activeMover() const
00088         {return m_MoverHash.value(m_ActiveMoverId);}
00089 
00091 
00093 
00095 
00096 public:
00098         GLC_MoverController& operator = (const GLC_MoverController&);
00099 
00101         void addMover(GLC_Mover*, const int);
00102 
00104         void removeMover(const int);
00105 
00107         void setActiveMover(const int id, QMouseEvent * e);
00108 
00110         void setNoMover();
00111 
00113         inline bool move(QMouseEvent * e)
00114         {
00115                 Q_ASSERT(0 != m_ActiveMoverId);
00116                 return m_MoverHash.value(m_ActiveMoverId)->move(e);
00117         }
00118 
00120 
00122 
00124 
00125 public:
00127         inline void drawActiveMoverRep()
00128         {
00129                 if(0 != m_ActiveMoverId)
00130                 {
00131                         m_MoverHash.value(m_ActiveMoverId)->glExecute();
00132                 }
00133         }
00134 
00136 signals:
00138         void repaintNeeded();
00139 
00141 // Private Members
00143 private:
00145         int m_ActiveMoverId;
00146 
00148         MoverHash m_MoverHash;
00149 };
00150 
00151 #endif /* GLC_MOVERCONTROLLER_H_ */

SourceForge.net Logo

©2005 Laurent Ribon