glc_settargetmover.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "glc_settargetmover.h"
00026 #include "glc_viewport.h"
00027 #include "glc_openglexception.h"
00028
00029
00030 GLC_SetTargetMover::GLC_SetTargetMover(GLC_Viewport* pViewport, const QList<GLC_RepMover*>& repsList)
00031 : GLC_Mover(pViewport, repsList)
00032 {
00033
00034
00035 }
00036
00037
00038 GLC_SetTargetMover::GLC_SetTargetMover(const GLC_SetTargetMover& mover)
00039 : GLC_Mover(mover)
00040 {
00041
00042
00043 }
00044
00045 GLC_SetTargetMover::~GLC_SetTargetMover()
00046 {
00047
00048 }
00049
00051
00053
00054
00055 GLC_Mover* GLC_SetTargetMover::clone() const
00056 {
00057 return new GLC_SetTargetMover(*this);
00058 }
00059
00061
00063
00064
00065 void GLC_SetTargetMover::init(QMouseEvent * e)
00066 {
00067
00068 GLfloat Depth;
00069
00070 glReadPixels(e->x(), m_pViewport->viewVSize() - e->y() , 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &Depth);
00071
00072
00073 if (!qFuzzyCompare(Depth, 1.0f))
00074 {
00075 const GLC_Point3d target(m_pViewport->unProject(e->x(), e->y()));
00076 m_pViewport->cameraHandle()->setTargetCam(target);
00077 }
00078 else
00079 {
00080
00081 const GLC_Point3d curPos(m_pViewport->mapPosMouse(e->x(), e->y()));
00082 const GLC_Point3d prevPos(m_pViewport->mapPosMouse(m_pViewport->viewHSize() / 2, m_pViewport->viewVSize() / 2));
00083 const GLC_Vector3d VectPan(curPos - prevPos);
00084
00085 m_pViewport->cameraHandle()->pan(VectPan);
00086 }
00087 }