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_panmover.h" 00026 #include "glc_viewport.h" 00027 #include "QMouseEvent" 00028 00029 // Default constructor 00030 GLC_PanMover::GLC_PanMover(GLC_Viewport* pViewport, const QList<GLC_RepMover*>& repsList) 00031 : GLC_Mover(pViewport, repsList) 00032 { 00033 00034 } 00035 00036 // Copy constructor 00037 GLC_PanMover::GLC_PanMover(const GLC_PanMover& panMover) 00038 : GLC_Mover(panMover) 00039 { 00040 00041 } 00042 00043 00044 GLC_PanMover::~GLC_PanMover() 00045 { 00046 00047 } 00048 00050 // Get Functions 00052 00053 // Return a clone of the mover 00054 GLC_Mover* GLC_PanMover::clone() const 00055 { 00056 return new GLC_PanMover(*this); 00057 } 00058 00059 00061 // Set Functions 00063 00064 // Initialized the mover 00065 void GLC_PanMover::init(const GLC_UserInput& userInput) 00066 { 00067 m_PreviousVector= m_pViewport->mapPosMouse(static_cast<double>(userInput.x()), static_cast<double>(userInput.y())); 00068 } 00069 00070 // Move the camera 00071 bool GLC_PanMover::move(const GLC_UserInput& userInput) 00072 { 00073 const GLC_Vector3d VectCur(m_pViewport->mapPosMouse(static_cast<double>(userInput.x()), static_cast<double>(userInput.y()))); 00074 const GLC_Vector3d VectPan= VectCur - m_PreviousVector; // moving Vector 00075 00076 // Pan the camera 00077 m_pViewport->cameraHandle()->pan(-VectPan); 00078 m_PreviousVector= VectCur; 00079 return true; 00080 } 00081