GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_settargetmover.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 
23 #include "glc_settargetmover.h"
24 #include "glc_viewport.h"
25 #include "glc_openglexception.h"
26 
27 // Default constructor
28 GLC_SetTargetMover::GLC_SetTargetMover(GLC_Viewport* pViewport, const QList<GLC_RepMover*>& repsList)
29 : GLC_Mover(pViewport, repsList)
30 {
31 
32 
33 }
34 
35 // Copy constructor
37 : GLC_Mover(mover)
38 {
39 
40 
41 }
42 
44 {
45 
46 }
47 
49 // Get Functions
51 
52 // Return a clone of the mover
54 {
55  return new GLC_SetTargetMover(*this);
56 }
57 
59 // Set Functions
61 
62 // Initialized the mover
64 {
65  // Z Buffer component of selected point between 0 and 1
66  GLfloat Depth;
67  // read selected point
68  glReadPixels(userInput.x(), m_pViewport->viewVSize() - userInput.y() , 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &Depth);
69 
70  // Test if there is geometry under picking point
71  if (!qFuzzyCompare(Depth, 1.0f))
72  { // Geometry find -> Update camera's target position
73  const GLC_Point3d target(m_pViewport->unProject(userInput.x(), userInput.y()));
75  }
76  else
77  { // Geometry not find -> panning
78 
79  const GLC_Point3d curPos(m_pViewport->mapPosMouse(userInput.x(), userInput.y()));
81  const GLC_Vector3d VectPan(curPos - prevPos); // panning vector
82  // pan camera
83  m_pViewport->cameraHandle()->pan(VectPan);
84  }
85 }

©2005-2013 Laurent Ribon