GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_panmover.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  *****************************************************************************/
22 
24 
25 #include "glc_panmover.h"
26 #include "glc_viewport.h"
27 #include "QMouseEvent"
28 
29 // Default constructor
30 GLC_PanMover::GLC_PanMover(GLC_Viewport* pViewport, const QList<GLC_RepMover*>& repsList)
31 : GLC_Mover(pViewport, repsList)
32 {
33 
34 }
35 
36 // Copy constructor
38 : GLC_Mover(panMover)
39 {
40 
41 }
42 
43 
45 {
46 
47 }
48 
50 // Get Functions
52 
53 // Return a clone of the mover
55 {
56  return new GLC_PanMover(*this);
57 }
58 
59 
61 // Set Functions
63 
64 // Initialized the mover
65 void GLC_PanMover::init(const GLC_UserInput& userInput)
66 {
67  m_PreviousVector= m_pViewport->mapPosMouse(static_cast<double>(userInput.x()), static_cast<double>(userInput.y()));
68 }
69 
70 // Move the camera
71 bool GLC_PanMover::move(const GLC_UserInput& userInput)
72 {
73  const GLC_Vector3d VectCur(m_pViewport->mapPosMouse(static_cast<double>(userInput.x()), static_cast<double>(userInput.y())));
74  const GLC_Vector3d VectPan= VectCur - m_PreviousVector; // moving Vector
75 
76  // Pan the camera
77  m_pViewport->cameraHandle()->pan(-VectPan);
78  m_PreviousVector= VectCur;
79  return true;
80 }
81 

©2005-2013 Laurent Ribon