GLC_Viewport Class Reference

GLC_Viewport : OpenGL Viewport. More...

#include <glc_viewport.h>

List of all members.

Public Member Functions

Constructor / Destructor

 GLC_Viewport (QGLWidget *GLWidget)
 Default constructor.
virtual ~GLC_Viewport ()
 Delete Camera, Image Plane and orbit circle.
Get Functions

GLC_CameracameraHandle () const
 Return the camera associate to this viewport.
int viewHSize () const
 Get this viewport Horizontal size.
int viewVSize () const
 Get this viewport Vertical size.
double aspectRatio () const
 Get this viewport ratio.
GLC_Vector3d mapPosMouse (GLdouble Posx, GLdouble Posy) const
 Map Screen position to OpenGL position (On image Plane) according to this viewport.
double viewAngle () const
 Get this viewport's camera's angle of view.
double viewTangent () const
 Get this viewport's camera's tangent value of view.
double nearClippingPlaneDist (void) const
 Get this viewport near clipping plane distance.
double farClippingPlaneDist (void) const
 Get this viewport far clipping plane distance.
QColor backgroundColor (void) const
 Get this viewportbackground Color.
GLsizei selectionSquareSize () const
 Return the selection square size of this viewport.
GLC_Matrix4x4 projectionMatrix () const
 Return this viewport's the projection matrix.
GLC_Matrix4x4 compositionMatrix () const
 Return the composition matrix between projection matrix and view matrix.
GLC_3DViewCollectionwidget3dCollectionHandle ()
 Return an handle to the widget 3D collection.
bool useOrtho () const
 Return true if this viewport use orthographic projection.
Set Functions

void setWinGLSize (int HSize, int VSize)
 Inform the viewport that the OpenGL window size has been modified.
GLC_uint renderAndSelect (int x, int y)
 Call the attached QGLWidgetSelect updateGL function and return the picking id.
GLC_uint selectOnPreviousRender (int x, int y)
 Return the picking id from the already render window.
GLC_uint selectBody (GLC_3DViewInstance *, int x, int y)
 Select a body inside a 3DViewInstance and return its UID.
QPair< int, GLC_uintselectPrimitive (GLC_3DViewInstance *, int x, int y)
 Select a primitive inside a 3DViewInstance and return its UID and its body index.
QSet< GLC_uintselectInsideSquare (int x1, int y1, int x2, int y2)
 Select objects inside specified square and return its UID in a set.
void loadBackGroundImage (const QString &imageFile)
 load background image from file in this viewport
void loadBackGroundImage (const QImage &image)
 load background image in this viewport
void deleteBackGroundImage ()
 delete background image of this viewport
void setViewAngle (double TargetFov)
 Set Camera's angle of view of this viewport.
bool setDistMin (double DistMin)
 Set near clipping distance of this viewport.
bool setDistMax (double DistMax)
 Set far clipping distance of this viewport.
void setDistMinAndMax (const GLC_BoundingBox &bBox)
 Set Near and Far clipping distance of this viewport.
void setBackgroundColor (QColor setColor)
 Set the Background color of this viewport.
void setSelectionSquareSize (GLsizei size)
 Set the selection square size of this viewport.
bool updateFrustum (GLC_Matrix4x4 *pMat=NULL)
 Update this viewport frustum (frustum cullin purpose).
void addClipPlane (GLenum planeGlEnum, GLC_Plane *pPlane)
 Add a clipping plane to this viewport.
void removeClipPlane (GLenum planeGlEnum)
 Remove the clipp plane cresponding to the given id.
void useClipPlane (bool flag)
 Set the clipping plane usage.
void add3DWidget (GLC_3DViewInstance &widget)
 Add 3DWidget to this viewport.
void clearBackground (const QColor &c) const
 Clear the background color with the specified color.
void setToOrtho (bool useOrtho)
 Set othographic usage to the given flag.
zoom Functions

void reframe (const GLC_BoundingBox &box)
 Set the viewport's camera in order to reframe on the current scene.

Private Member Functions

GLC_uint meaningfulIdInsideSquare (GLint x, GLint y, GLsizei width, GLsizei height)
 Return the meaningful color ID inside a square in screen coordinates.
QSet< GLC_uintlistOfIdInsideSquare (GLint x, GLint y, GLsizei width, GLsizei height)
 Return the Set of ID inside a square in screen coordinate.

Private Attributes

GLC_Cameram_pViewCam
 Viewport's camera.
double m_dCamDistMax
 Camera Maximum distance (far clipping plane).
double m_dCamDistMin
 Camera Minimum distance (near clipping plane).
double m_dFov
 Camera angle of view.
double m_ViewTangent
 Camera angle tangent.
GLC_ImagePlanem_pImagePlane
 Image plane (Background image).
int m_nWinHSize
 Horizontal OpenGL viewport size.
int m_nWinVSize
 Vertical OpenGL viewport size.
double m_AspectRatio
 View AspectRatio.
QGLWidget * m_pQGLWidget
 The QGLWidget attached to the viewport (rendering context).
QColor m_BackgroundColor
 Viewport Background color.
GLsizei m_SelectionSquareSize
 The selection square size.
GLC_Matrix4x4 m_ProjectionMatrix
 The projection matrix.
GLC_Frustum m_Frustum
 The frustum associated to the viewport.
QHash< GLenum, GLC_Plane * > m_ClipPlane
 The list of additionnal clipping plane.
bool m_UseClipPlane
 Flag to know if clipping plane must be used.
GLC_3DViewCollection m_3DWidget
 The collection wich contains 3D widget.
bool m_UseOrtho
 Flag to know if the viewport use orthographic projection.

OpenGL Functions



void initGl ()
 Initialize OpenGL with default values.
void glExecuteCam (void)
 Load camera's transformation Matrix and display image if necessary.
void updateProjectionMat (void)
 Update this viewport OpenGL projection matrix.
void forceAspectRatio (double)
 Force the aspect ratio of this viewport.
void updateAspectRatio ()
 Update the aspect ratio of this viewport.
const GLC_Frustumfrustum () const
 Return the frustum associated to this viewport.
GLC_Frustum selectionFrustum (int, int) const
 Return the frustum associated to a selection coordinate.
GLC_Point3d unProject (int, int) const
 Return the world 3d point from the given screen coordinate.
QList< GLC_Point3dunproject (const QList< int > &) const
 Return the list af world 3d point form the givne list af screen coordinates.
QGLWidget * qGLWidgetHandle ()
 Return an handle of the QGLWidget of this viewport.
void render3DWidget ()
 Render viewport 3D widget.
void glExecuteImagePlane ()
 Render this viewport's image plane.

Detailed Description

GLC_Viewport : OpenGL Viewport.

An GLC_Viewport define Viewport with these specification

Definition at line 55 of file glc_viewport.h.


Constructor & Destructor Documentation

GLC_Viewport::GLC_Viewport ( QGLWidget *  GLWidget  ) 

Default constructor.

Construct Viewport with these specifications :

  • Default GLC_Camera
  • Max distance of view : 500
  • Min distance of view : 0.01
  • Angle of view : 35
  • Maximum zoom factor : 3.0

Definition at line 42 of file glc_viewport.cpp.

GLC_Viewport::~GLC_Viewport (  )  [virtual]

Delete Camera, Image Plane and orbit circle.

Definition at line 68 of file glc_viewport.cpp.

References deleteBackGroundImage(), m_ClipPlane, and m_pViewCam.


Member Function Documentation

void GLC_Viewport::add3DWidget ( GLC_3DViewInstance widget  )  [inline]

Add 3DWidget to this viewport.

Definition at line 276 of file glc_viewport.h.

void GLC_Viewport::addClipPlane ( GLenum  planeGlEnum,
GLC_Plane pPlane 
)

Add a clipping plane to this viewport.

Definition at line 637 of file glc_viewport.cpp.

References m_ClipPlane.

double GLC_Viewport::aspectRatio (  )  const [inline]

Get this viewport ratio.

Definition at line 96 of file glc_viewport.h.

QColor GLC_Viewport::backgroundColor ( void   )  const [inline]

Get this viewportbackground Color.

Definition at line 120 of file glc_viewport.h.

GLC_Camera* GLC_Viewport::cameraHandle (  )  const [inline]
void GLC_Viewport::clearBackground ( const QColor &  c  )  const [inline]

Clear the background color with the specified color.

Definition at line 280 of file glc_viewport.h.

GLC_Matrix4x4 GLC_Viewport::compositionMatrix (  )  const [inline]

Return the composition matrix between projection matrix and view matrix.

Definition at line 361 of file glc_viewport.h.

References m_ProjectionMatrix, m_pViewCam, GLC_Camera::modelViewMatrix(), and projectionMatrix().

Referenced by GLC_3DWidgetManagerHandle::render(), and updateFrustum().

void GLC_Viewport::deleteBackGroundImage (  ) 

delete background image of this viewport

Definition at line 510 of file glc_viewport.cpp.

References m_pImagePlane.

Referenced by ~GLC_Viewport().

double GLC_Viewport::farClippingPlaneDist ( void   )  const [inline]

Get this viewport far clipping plane distance.

Definition at line 116 of file glc_viewport.h.

void GLC_Viewport::forceAspectRatio ( double  ratio  ) 

Force the aspect ratio of this viewport.

Definition at line 164 of file glc_viewport.cpp.

References m_AspectRatio, and updateProjectionMat().

const GLC_Frustum& GLC_Viewport::frustum (  )  const [inline]

Return the frustum associated to this viewport.

Definition at line 166 of file glc_viewport.h.

Referenced by GLC_3DViewCollection::updateInstanceViewableState().

void GLC_Viewport::glExecuteCam ( void   ) 

Load camera's transformation Matrix and display image if necessary.

Definition at line 127 of file glc_viewport.cpp.

References GLC_Camera::glExecute(), glExecuteImagePlane(), and m_pViewCam.

Referenced by selectBody(), and selectPrimitive().

void GLC_Viewport::glExecuteImagePlane (  )  [private]

Render this viewport's image plane.

Definition at line 264 of file glc_viewport.cpp.

References GLC_State::isInSelectionMode(), m_pImagePlane, and GLC_ImagePlane::render().

Referenced by glExecuteCam().

void GLC_Viewport::initGl (  ) 

Initialize OpenGL with default values.

Glew initialisation is made here

Definition at line 112 of file glc_viewport.cpp.

References GLC_State::init(), m_BackgroundColor, and m_pQGLWidget.

QSet< GLC_uint > GLC_Viewport::listOfIdInsideSquare ( GLint  x,
GLint  y,
GLsizei  width,
GLsizei  height 
) [private]

Return the Set of ID inside a square in screen coordinate.

Definition at line 474 of file glc_viewport.cpp.

References glc::decodeRgbId(), m_BackgroundColor, and m_pQGLWidget.

Referenced by selectInsideSquare().

void GLC_Viewport::loadBackGroundImage ( const QImage &  image  ) 

load background image in this viewport

Definition at line 504 of file glc_viewport.cpp.

References m_pImagePlane, and m_pQGLWidget.

void GLC_Viewport::loadBackGroundImage ( const QString &  imageFile  ) 

load background image from file in this viewport

Definition at line 498 of file glc_viewport.cpp.

References m_pImagePlane, and m_pQGLWidget.

GLC_Vector3d GLC_Viewport::mapPosMouse ( GLdouble  Posx,
GLdouble  Posy 
) const

Map Screen position to OpenGL position (On image Plane) according to this viewport.

Definition at line 88 of file glc_viewport.cpp.

References GLC_Camera::distEyeTarget(), m_nWinHSize, m_nWinVSize, m_pViewCam, and m_ViewTangent.

Referenced by GLC_SetTargetMover::init(), GLC_PanMover::init(), and GLC_PanMover::move().

GLC_uint GLC_Viewport::meaningfulIdInsideSquare ( GLint  x,
GLint  y,
GLsizei  width,
GLsizei  height 
) [private]

Return the meaningful color ID inside a square in screen coordinates.

Definition at line 427 of file glc_viewport.cpp.

References glc::decodeRgbId(), m_BackgroundColor, and m_pQGLWidget.

Referenced by selectBody(), selectOnPreviousRender(), and selectPrimitive().

double GLC_Viewport::nearClippingPlaneDist ( void   )  const [inline]

Get this viewport near clipping plane distance.

Definition at line 112 of file glc_viewport.h.

GLC_Matrix4x4 GLC_Viewport::projectionMatrix (  )  const [inline]

Return this viewport's the projection matrix.

Definition at line 128 of file glc_viewport.h.

Referenced by compositionMatrix().

QGLWidget* GLC_Viewport::qGLWidgetHandle (  )  [inline]

Return an handle of the QGLWidget of this viewport.

Definition at line 180 of file glc_viewport.h.

Referenced by GLC_RepFlyMover::glDraw().

void GLC_Viewport::reframe ( const GLC_BoundingBox box  ) 

Set the viewport's camera in order to reframe on the current scene.

box shouldn't be empty

Definition at line 526 of file glc_viewport.cpp.

References GLC_BoundingBox::boundingSphereRadius(), GLC_BoundingBox::center(), GLC_BoundingBox::isEmpty(), m_pViewCam, m_ViewTangent, GLC_Camera::setDistEyeTarget(), GLC_Camera::target(), and GLC_Camera::translate().

void GLC_Viewport::removeClipPlane ( GLenum  planeGlEnum  ) 

Remove the clipp plane cresponding to the given id.

Definition at line 647 of file glc_viewport.cpp.

References m_ClipPlane.

void GLC_Viewport::render3DWidget (  ) 

Render viewport 3D widget.

Definition at line 276 of file glc_viewport.cpp.

References m_3DWidget, GLC_3DViewCollection::render(), glc::TransparentRenderFlag, and glc::WireRenderFlag.

GLC_uint GLC_Viewport::renderAndSelect ( int  x,
int  y 
)

Call the attached QGLWidgetSelect updateGL function and return the picking id.

Return UID of the nearest picked object

Definition at line 304 of file glc_viewport.cpp.

References m_pQGLWidget, selectOnPreviousRender(), and GLC_State::setSelectionMode().

GLC_uint GLC_Viewport::selectBody ( GLC_3DViewInstance pInstance,
int  x,
int  y 
)

Select a body inside a 3DViewInstance and return its UID.

Return UID of the nearest picked body

Definition at line 327 of file glc_viewport.cpp.

References glExecuteCam(), m_pQGLWidget, meaningfulIdInsideSquare(), GLC_3DViewInstance::renderForBodySelection(), and GLC_State::setSelectionMode().

QSet< GLC_uint > GLC_Viewport::selectInsideSquare ( int  x1,
int  y1,
int  x2,
int  y2 
)

Select objects inside specified square and return its UID in a set.

Definition at line 397 of file glc_viewport.cpp.

References listOfIdInsideSquare(), m_pQGLWidget, and GLC_State::setSelectionMode().

GLC_Frustum GLC_Viewport::selectionFrustum ( int  x,
int  y 
) const

Return the frustum associated to a selection coordinate.

Definition at line 175 of file glc_viewport.cpp.

References GLC_Camera::eye(), m_Frustum, m_pViewCam, m_SelectionSquareSize, and unproject().

GLsizei GLC_Viewport::selectionSquareSize (  )  const [inline]

Return the selection square size of this viewport.

Definition at line 124 of file glc_viewport.h.

GLC_uint GLC_Viewport::selectOnPreviousRender ( int  x,
int  y 
)

Return the picking id from the already render window.

Definition at line 316 of file glc_viewport.cpp.

References m_pQGLWidget, m_SelectionSquareSize, and meaningfulIdInsideSquare().

Referenced by renderAndSelect(), and GLC_3DWidgetManagerHandle::select().

QPair< int, GLC_uint > GLC_Viewport::selectPrimitive ( GLC_3DViewInstance pInstance,
int  x,
int  y 
)

Select a primitive inside a 3DViewInstance and return its UID and its body index.

Return UID of the nearest picked primitive

Definition at line 354 of file glc_viewport.cpp.

References glExecuteCam(), m_pQGLWidget, meaningfulIdInsideSquare(), GLC_3DViewInstance::renderForBodySelection(), GLC_3DViewInstance::renderForPrimitiveSelection(), and GLC_State::setSelectionMode().

void GLC_Viewport::setBackgroundColor ( QColor  setColor  ) 

Set the Background color of this viewport.

Definition at line 631 of file glc_viewport.cpp.

References m_BackgroundColor, and m_pQGLWidget.

bool GLC_Viewport::setDistMax ( double  DistMax  ) 

Set far clipping distance of this viewport.

Definition at line 562 of file glc_viewport.cpp.

References m_dCamDistMax, m_dCamDistMin, and updateProjectionMat().

bool GLC_Viewport::setDistMin ( double  DistMin  ) 

Set near clipping distance of this viewport.

Definition at line 543 of file glc_viewport.cpp.

References m_dCamDistMax, m_dCamDistMin, and updateProjectionMat().

void GLC_Viewport::setDistMinAndMax ( const GLC_BoundingBox bBox  ) 

Set Near and Far clipping distance of this viewport.

box shouldn't be empty

Definition at line 581 of file glc_viewport.cpp.

References GLC_Camera::distEyeTarget(), GLC_Camera::eye(), GLC_BoundingBox::isEmpty(), m_dCamDistMax, m_dCamDistMin, m_pViewCam, GLC_Camera::modelViewMatrix(), and updateProjectionMat().

void GLC_Viewport::setSelectionSquareSize ( GLsizei  size  )  [inline]

Set the selection square size of this viewport.

Definition at line 259 of file glc_viewport.h.

void GLC_Viewport::setToOrtho ( bool  useOrtho  ) 

Set othographic usage to the given flag.

Definition at line 516 of file glc_viewport.cpp.

References m_UseOrtho, and updateProjectionMat().

void GLC_Viewport::setViewAngle ( double  TargetFov  )  [inline]

Set Camera's angle of view of this viewport.

Definition at line 238 of file glc_viewport.h.

References glc::toRadian().

void GLC_Viewport::setWinGLSize ( int  HSize,
int  VSize 
)

Inform the viewport that the OpenGL window size has been modified.

Definition at line 285 of file glc_viewport.cpp.

References m_nWinHSize, m_nWinVSize, updateAspectRatio(), and updateProjectionMat().

QList< GLC_Point3d > GLC_Viewport::unproject ( const QList< int > &  list  )  const

Return the list af world 3d point form the givne list af screen coordinates.

The size of the given list must be a multiple of 2

Definition at line 231 of file glc_viewport.cpp.

References GLC_Matrix4x4::data(), m_nWinVSize, m_ProjectionMatrix, m_pViewCam, and GLC_Camera::modelViewMatrix().

Referenced by selectionFrustum().

GLC_Point3d GLC_Viewport::unProject ( int  x,
int  y 
) const

Return the world 3d point from the given screen coordinate.

Definition at line 212 of file glc_viewport.cpp.

References GLC_Matrix4x4::data(), m_nWinVSize, m_ProjectionMatrix, m_pViewCam, and GLC_Camera::modelViewMatrix().

Referenced by GLC_SetTargetMover::init(), GLC_FlyMover::init(), GLC_FlyMover::move(), and GLC_3DWidgetManagerHandle::select().

void GLC_Viewport::updateAspectRatio (  ) 

Update the aspect ratio of this viewport.

Definition at line 170 of file glc_viewport.cpp.

References m_AspectRatio, m_nWinHSize, and m_nWinVSize.

Referenced by setWinGLSize().

bool GLC_Viewport::updateFrustum ( GLC_Matrix4x4 pMat = NULL  )  [inline]

Update this viewport frustum (frustum cullin purpose).

Return true if the frustum has changed

Definition at line 373 of file glc_viewport.h.

References compositionMatrix(), m_Frustum, and GLC_Frustum::update().

Referenced by GLC_3DViewCollection::updateInstanceViewableState().

void GLC_Viewport::updateProjectionMat ( void   ) 
void GLC_Viewport::useClipPlane ( bool  flag  ) 

Set the clipping plane usage.

Definition at line 660 of file glc_viewport.cpp.

References GLC_Plane::data(), m_ClipPlane, and m_UseClipPlane.

bool GLC_Viewport::useOrtho (  )  const [inline]

Return true if this viewport use orthographic projection.

Definition at line 139 of file glc_viewport.h.

Referenced by GLC_AbstractManipulator::manipulate().

double GLC_Viewport::viewAngle (  )  const [inline]

Get this viewport's camera's angle of view.

Definition at line 103 of file glc_viewport.h.

Referenced by GLC_RepCrossMover::glDraw().

int GLC_Viewport::viewHSize (  )  const [inline]
double GLC_Viewport::viewTangent (  )  const [inline]

Get this viewport's camera's tangent value of view.

Definition at line 107 of file glc_viewport.h.

Referenced by GLC_3DViewInstance::choseLod().

int GLC_Viewport::viewVSize (  )  const [inline]
GLC_3DViewCollection* GLC_Viewport::widget3dCollectionHandle (  )  [inline]

Return an handle to the widget 3D collection.

Definition at line 135 of file glc_viewport.h.


Member Data Documentation

The collection wich contains 3D widget.

Definition at line 355 of file glc_viewport.h.

Referenced by render3DWidget().

double GLC_Viewport::m_AspectRatio [private]

View AspectRatio.

Definition at line 331 of file glc_viewport.h.

Referenced by forceAspectRatio(), updateAspectRatio(), and updateProjectionMat().

Viewport Background color.

Definition at line 337 of file glc_viewport.h.

Referenced by initGl(), listOfIdInsideSquare(), meaningfulIdInsideSquare(), and setBackgroundColor().

QHash<GLenum, GLC_Plane*> GLC_Viewport::m_ClipPlane [private]

The list of additionnal clipping plane.

Definition at line 349 of file glc_viewport.h.

Referenced by addClipPlane(), removeClipPlane(), useClipPlane(), and ~GLC_Viewport().

double GLC_Viewport::m_dCamDistMax [private]

Camera Maximum distance (far clipping plane).

Definition at line 317 of file glc_viewport.h.

Referenced by setDistMax(), setDistMin(), setDistMinAndMax(), and updateProjectionMat().

double GLC_Viewport::m_dCamDistMin [private]

Camera Minimum distance (near clipping plane).

Definition at line 318 of file glc_viewport.h.

Referenced by setDistMax(), setDistMin(), setDistMinAndMax(), and updateProjectionMat().

double GLC_Viewport::m_dFov [private]

Camera angle of view.

Definition at line 319 of file glc_viewport.h.

Referenced by updateProjectionMat().

The frustum associated to the viewport.

Definition at line 346 of file glc_viewport.h.

Referenced by selectionFrustum(), and updateFrustum().

Horizontal OpenGL viewport size.

Definition at line 327 of file glc_viewport.h.

Referenced by mapPosMouse(), setWinGLSize(), and updateAspectRatio().

Vertical OpenGL viewport size.

Definition at line 328 of file glc_viewport.h.

Referenced by mapPosMouse(), setWinGLSize(), unproject(), unProject(), and updateAspectRatio().

Image plane (Background image).

Definition at line 324 of file glc_viewport.h.

Referenced by deleteBackGroundImage(), glExecuteImagePlane(), and loadBackGroundImage().

QGLWidget* GLC_Viewport::m_pQGLWidget [private]

The projection matrix.

Definition at line 343 of file glc_viewport.h.

Referenced by compositionMatrix(), unproject(), unProject(), and updateProjectionMat().

The selection square size.

Definition at line 340 of file glc_viewport.h.

Referenced by selectionFrustum(), and selectOnPreviousRender().

Flag to know if clipping plane must be used.

Definition at line 352 of file glc_viewport.h.

Referenced by useClipPlane().

bool GLC_Viewport::m_UseOrtho [private]

Flag to know if the viewport use orthographic projection.

Definition at line 358 of file glc_viewport.h.

Referenced by setToOrtho(), and updateProjectionMat().

double GLC_Viewport::m_ViewTangent [private]

Camera angle tangent.

Definition at line 320 of file glc_viewport.h.

Referenced by mapPosMouse(), reframe(), and updateProjectionMat().


The documentation for this class was generated from the following files:

SourceForge.net Logo

©2005 Laurent Ribon