glc_viewport.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 1.2.0, packaged on September 2009.
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_VIEWPORT_H_
00028 #define GLC_VIEWPORT_H_
00029 #include <QGLWidget>
00030 #include "glc_camera.h"
00031 #include "glc_imageplane.h"
00032 #include "../glc_boundingbox.h"
00033 
00034 
00035 // Define selection square
00036 #define SELECT_WIDTH 5.0
00037 
00038 #define SELECT_HEIGHT 5.0
00039 
00040 // end selection quare
00041 
00042 
00045 
00055 
00056 
00057 class GLC_Viewport
00058 {
00059 
00061 
00063 
00064 public:
00066 
00074         GLC_Viewport(QGLWidget *GLWidget);
00075 
00077         virtual ~GLC_Viewport();
00078 
00080 
00082 
00084 
00085 public:
00087         inline GLC_Camera* cameraHandle() const
00088         {return m_pViewCam;}
00089 
00091         inline int viewHSize() const
00092         { return m_nWinHSize;}
00093 
00095         inline int viewVSize() const
00096         { return m_nWinVSize;}
00097 
00099         inline double aspectRatio() const
00100         { return static_cast<double>(m_nWinHSize) / static_cast<double>(m_nWinVSize);}
00101 
00103         GLC_Vector4d mapPosMouse( GLdouble Posx, GLdouble Posy) const;
00104 
00106         inline double viewAngle() const
00107         { return m_dFov;}
00108 
00110         inline double viewTangent() const
00111         { return m_ViewTangent;}
00112 
00113 
00115         inline double nearClippingPlaneDist(void) const
00116         { return m_dCamDistMin;}
00117 
00119         inline double farClippingPlaneDist(void) const
00120         { return m_dCamDistMax;}
00121 
00123         inline QColor backgroundColor(void) const
00124         { return m_BackgroundColor;}
00125 
00127 
00129 
00131 
00132 public:
00134 
00135         void initGl();
00136 
00138         void glExecuteCam(void)
00139         {
00140                 m_pViewCam->glExecute();
00141                 glExecuteImagePlane();
00142         }
00144         void glExecute()
00145         {
00146         }
00147 
00149         void updateProjectionMat(void) const;
00150 
00152         void forceAspectRatio(double);
00154 
00156 
00158 
00159 private:
00160 
00162         void glExecuteImagePlane();
00163 
00165 
00167 
00169 
00170 public:
00171 
00173         void setWinGLSize(int HSize, int VSize);
00174 
00176 
00177         GLC_uint select(QGLWidget *pGLWidget, int x, int y);
00178 
00180         void loadBackGroundImage(const QString Image);
00181 
00183         void deleteBackGroundImage();
00184 
00186         void setViewAngle(double TargetFov)
00187         {
00188                 m_dFov= TargetFov;
00189                 m_ViewTangent= tan(m_dFov * glc::PI / 180.0);
00190                 updateProjectionMat();
00191         }
00192 
00194         bool setDistMin(double DistMin);
00195 
00197         bool setDistMax(double DistMax);
00198 
00200 
00201         void setDistMinAndMax(const GLC_BoundingBox& bBox);
00202 
00204         void setBackgroundColor(QColor setColor);
00205 
00207 
00208 
00211 //{@
00213 
00214         void reframe(const GLC_BoundingBox& box);
00215 
00217 
00218 
00219 
00221 // Private Members
00223 private:
00224 
00226         GLC_Camera *m_pViewCam;
00227 
00228         double m_dCamDistMax;           
00229         double m_dCamDistMin;           
00230         double m_dFov;                          
00231         double m_ViewTangent;           
00232 
00233 
00235         GLC_ImagePlane* m_pImagePlane;
00236 
00237         // OpenGL View Definition
00238         int m_nWinHSize;                        
00239         int m_nWinVSize;                        
00240 
00242         QGLWidget* m_pQGLWidget;
00243 
00245         QColor m_BackgroundColor;
00246 
00248         GLuint m_ImagePlaneListID;
00249 
00250 
00251 };
00252 
00253 #endif //GLC_VIEWPORT_H_

SourceForge.net Logo

©2005 Laurent Ribon