#include <QGLViewer.h>
Inheritance diagram for QGLViewer:
Public Types | |
parallel | |
perspective | |
CurrentCam = 1 | |
HomeCam = 2 | |
BothCams = 3 | |
STEREO_ON | |
STEREO_OFF | |
STEREO_SIMULATE | |
MONO | |
STEREO_LEFT | |
STEREO_RIGHT | |
enum | ProjectionMode { parallel, perspective } |
enum | CameraType { CurrentCam = 1, HomeCam = 2, BothCams = 3 } |
enum | StereoMode { STEREO_ON, STEREO_OFF, STEREO_SIMULATE } |
enum | StereoBuffer { MONO, STEREO_LEFT, STEREO_RIGHT } |
Public Slots | |
virtual void | sltUpdateView () |
virtual void | sltToggleStereo () |
virtual void | sltViewAll () |
Signals | |
void | sigProjModeToggled () |
void | sigRenderModeChanged () |
void | sigSelected (QMouseEvent *pqEvent) |
void | sigReleased (QMouseEvent *pqEvent) |
void | sigMoved (QMouseEvent *pqEvent) |
void | sigInitGL () |
void | sigRedrawGL () |
void | sigResizeGL (int nWidth, int nHeight) |
void | sigRatioChanged (double rdRatio) |
void | sigFovyChanged (double rdFovy) |
Public Member Functions | |
QGLViewer (QWidget *parent=0, const char *name=0, const QGLWidget *shareWidget=0, WFlags f=0, bool viewertype=true, const QGLFormat &format=QGLFormat::defaultFormat()) | |
QGLViewer (const CCamera &homecam, QWidget *parent=0, const char *name=0, const QGLWidget *shareWidget=0, WFlags f=0, bool viewertype=true, const QGLFormat &format=QGLFormat::defaultFormat()) | |
QGLViewer (const CBoundingBox3D &bbox, QWidget *parent=0, const char *name=0, const QGLWidget *shareWidget=0, WFlags f=0, bool viewertype=true, const QGLFormat &format=QGLFormat::defaultFormat()) | |
virtual | ~QGLViewer () |
void | setRefreshRate (int nFramesPerSecond) |
int | getRefreshRate () |
virtual void | setBoundingBox (const CBoundingBox3D &cBBox, bool fUpdate=false) |
virtual void | setCamera (const CCamera &cCamera, CameraType which=CurrentCam) |
CCamera & | getCamera () |
CCamera * | getCameraPtr () |
virtual ProjectionMode | getProjectionMode () |
virtual void | setFullViewer (bool state) |
bool | isFullViewer () |
QGLSignalWidget * | getDrawArea () |
void | makeCurrent () |
virtual void | enableMouseEvents (bool fFlag) |
GLenum | getRenderMode () |
QPopupMenu * | getMainMenu () |
int | insertItem (const QString &text, const QObject *receiver, const char *member) |
int | insertItem (const QIconSet &icon, const QString &text, const QObject *receiver, const char *member) |
int | insertItem (const QPixmap &pixmap, const QString &text, const QObject *receiver, const char *member) |
int | insertItem (const QString &text, QPopupMenu *pqPopup) |
int | insertItem (const QPixmap &pixmap, QPopupMenu *pqPopup) |
bool | isItemEnabled (int nID) |
void | setItemEnabled (int nID, bool fEnable) |
bool | isItemChecked (int nID) |
void | setItemChecked (int nID, bool fCheck) |
void | allowStereoSimulation (bool flag) |
StereoMode | getStereoMode () |
Protected Slots | |
virtual void | sltSetProjectionMode () |
virtual void | sltSetHome () |
virtual void | sltGoHome () |
virtual void | sltToggleProjectionMode () |
virtual void | sltToggleRenderMode () |
virtual void | sltManageDrop (QDropEvent *pqEvent) |
virtual void | sltManageDragEnter (QDragEnterEvent *pqEvent) |
virtual void | sltManageDragLeave (QDragLeaveEvent *pqEvent) |
Protected Member Functions | |
virtual void | initQFrame (const char *name, const QGLWidget *shareWidget, WFlags f, const QGLFormat &format=QGLFormat::defaultFormat()) |
QFrame * | getQFrame () |
void | setFrustum (StereoBuffer buffer=QGLViewer::MONO) |
void | setFrustumMono () |
void | setFrustumStereoLeft () |
void | setFrustumStereoRight () |
void | setLookAt () |
virtual void | ManageMouseMove (QMouseEvent *) |
virtual void | ManageMousePress (QMouseEvent *) |
virtual void | ManageMouseRelease (QMouseEvent *) |
virtual void | mousePressEvent (QMouseEvent *pqEvent) |
virtual void | timerEvent (QTimerEvent *pqEvent) |
Protected Attributes | |
CCamera | m_cCurrentCamera |
CCamera | m_cHomeCamera |
GLenum | m_eRenderMode |
bool | m_fFullViewer |
QFrame * | m_pQFrame |
QGLSignalWidget * | m_pQGLWidget |
QHBoxLayout * | m_pQHBoxLayout |
QPopupMenu * | m_pqPopupMenu |
QBitmap | m_qMovePix |
QBitmap | m_qSelectPix |
QBitmap | m_qMoveMaskPix |
QBitmap | m_qSelectMaskPix |
QCursor * | m_pqMoveCursor |
QCursor * | m_pqSelectCursor |
StereoMode | m_stereoMode |
bool | m_fAllowStereoSimulation |
QStereoCtrl * | m_pStereoCtrl |
Private Slots | |
void | sltResizeGL (int w, int h) |
void | sltPaintGL () |
void | sltSwitchMousePress (QMouseEvent *event) |
void | sltSwitchMouseRelease (QMouseEvent *event) |
void | sltSwitchMouseMove (QMouseEvent *event) |
void | sltPopMenu (QMouseEvent *pqEvent) |
Private Member Functions | |
void | initCursors () |
void | initPopupMenu () |
void | initConnects () |
virtual void | setVPRes (int nWidth, int nHeight) |
Private Attributes | |
bool | m_fRefresh |
bool | m_fHandleMouseEvents |
int | m_nRefreshRate |
int | m_nTimerID |
This is an abstract class which defines the interface for any derived OpenGL-viewers.
QGLViewer::QGLViewer | ( | QWidget * | parent = 0 , |
|
const char * | name = 0 , |
|||
const QGLWidget * | shareWidget = 0 , |
|||
WFlags | f = 0 , |
|||
bool | viewertype = true , |
|||
const QGLFormat & | format = QGLFormat::defaultFormat() | |||
) |
Default Constructor.
QGLViewer::QGLViewer | ( | const CCamera & | homecam, | |
QWidget * | parent = 0 , |
|||
const char * | name = 0 , |
|||
const QGLWidget * | shareWidget = 0 , |
|||
WFlags | f = 0 , |
|||
bool | viewertype = true , |
|||
const QGLFormat & | format = QGLFormat::defaultFormat() | |||
) |
Constructor including a camera for the home position box of the scene.
QGLViewer::QGLViewer | ( | const CBoundingBox3D & | bbox, | |
QWidget * | parent = 0 , |
|||
const char * | name = 0 , |
|||
const QGLWidget * | shareWidget = 0 , |
|||
WFlags | f = 0 , |
|||
bool | viewertype = true , |
|||
const QGLFormat & | format = QGLFormat::defaultFormat() | |||
) |
Constructor including a boundingbox of the scene.
virtual QGLViewer::~QGLViewer | ( | ) | [inline, virtual] |
Default Destructor.
void QGLViewer::allowStereoSimulation | ( | bool | flag | ) | [inline] |
Enables or disables stereo simulation.
virtual void QGLViewer::enableMouseEvents | ( | bool | fFlag | ) | [inline, virtual] |
Disables/enables mouse events over the draw area if fFlag = false/true.
Reimplemented in QGLExaminerViewer.
CCamera& QGLViewer::getCamera | ( | ) | [inline] |
The currently valid viewing camera is returned.
CCamera* QGLViewer::getCameraPtr | ( | ) | [inline] |
The the pointer to the currently valid viewing camera is returned.
QGLSignalWidget* QGLViewer::getDrawArea | ( | ) | [inline] |
Returns a pointer to the OpenGL drawing-area.
QPopupMenu* QGLViewer::getMainMenu | ( | ) | [inline] |
Returns the pointer to the popup menu.
virtual ProjectionMode QGLViewer::getProjectionMode | ( | ) | [inline, virtual] |
Returns the currently active projection mode.
QFrame* QGLViewer::getQFrame | ( | ) | [inline, protected] |
Get pointer to QFrame. This is necessary for the viewers derived from this abstract viewer class. Since this class does only provide a member QGLWidget placed in a QFrame but no layout. The viewer derived from this class is responsable for the layout.
int QGLViewer::getRefreshRate | ( | ) | [inline] |
Returns the current refresh rate in frames per second.
GLenum QGLViewer::getRenderMode | ( | ) | [inline] |
Returns the current rendermode. The initial value is GL_RENDER.
StereoMode QGLViewer::getStereoMode | ( | ) | [inline] |
Return the state of the stereo mode.
void QGLViewer::initConnects | ( | ) | [private] |
Makes all necessary connects.
void QGLViewer::initCursors | ( | ) | [private] |
Initializes the two possible mousecursors over the drawarea. The files for the pixmaps are loaded from the directory where the enviromentvariable QGLVIEWER_PIX point to. if nothing is found one standardcursor is used.
void QGLViewer::initPopupMenu | ( | ) | [private] |
Initializes the popup menu.
void QGLViewer::initQFrame | ( | const char * | name, | |
const QGLWidget * | shareWidget, | |||
WFlags | f, | |||
const QGLFormat & | format = QGLFormat::defaultFormat() | |||
) | [protected, virtual] |
Instantiates the QGLSignalWidget and place it in a QFrame. The pointer of the QFrame can be read with the function getQFrame(), see below.
int QGLViewer::insertItem | ( | const QPixmap & | pixmap, | |
QPopupMenu * | pqPopup | |||
) | [inline] |
Same as above but with pixmap.
int QGLViewer::insertItem | ( | const QString & | text, | |
QPopupMenu * | pqPopup | |||
) | [inline] |
Add a submenu to the popup menu.
int QGLViewer::insertItem | ( | const QPixmap & | pixmap, | |
const QString & | text, | |||
const QObject * | receiver, | |||
const char * | member | |||
) | [inline] |
Same as above but with support for pixmaps.
int QGLViewer::insertItem | ( | const QIconSet & | icon, | |
const QString & | text, | |||
const QObject * | receiver, | |||
const char * | member | |||
) | [inline] |
Same as above but with support for icons.
int QGLViewer::insertItem | ( | const QString & | text, | |
const QObject * | receiver, | |||
const char * | member | |||
) | [inline] |
Adds a menu entry to the popup menu.
bool QGLViewer::isFullViewer | ( | ) | [inline] |
Returns the the value of the flag.
bool QGLViewer::isItemChecked | ( | int | nID | ) | [inline] |
Returns 'true' if the item with identifier 'nID' is checked or 'false' if it is not.
bool QGLViewer::isItemEnabled | ( | int | nID | ) | [inline] |
Returns 'true' if the item with identifier 'nID' is enabled or 'false' if it is disabled.
void QGLViewer::makeCurrent | ( | ) | [inline] |
Makes this viewer the current viewer for OpenGL operations.
virtual void QGLViewer::ManageMouseMove | ( | QMouseEvent * | ) | [inline, protected, virtual] |
Has to be implemented in the derived class if you want to handle any mousemovementevents over the QGLSignalWidget.
Reimplemented in QGLExaminerViewer.
virtual void QGLViewer::ManageMousePress | ( | QMouseEvent * | ) | [inline, protected, virtual] |
Has to be implemented in derived class if you want to handle any mousebutton press-events over the QGLSignalWidget.
Reimplemented in QGLExaminerViewer.
virtual void QGLViewer::ManageMouseRelease | ( | QMouseEvent * | ) | [inline, protected, virtual] |
Has to be implemented in derived class if you want to handle any mousebutton release-events over the QGLSignalWidget.
Reimplemented in QGLExaminerViewer.
void QGLViewer::mousePressEvent | ( | QMouseEvent * | pqEvent | ) | [protected, virtual] |
Reimplements the mouse-press event function inherited from QWidget.
void QGLViewer::setBoundingBox | ( | const CBoundingBox3D & | cBBox, | |
bool | fUpdate = false | |||
) | [virtual] |
Sets boundingbox of the entire scene and fits the scene to the view area if 'fUpdate' is set to 'true'. It also sets the given boundingbox to both cameras so you don't have to do that explicitly. This method should be used whenever the scene changes (in size).
void QGLViewer::setCamera | ( | const CCamera & | cCamera, | |
CameraType | which = CurrentCam | |||
) | [virtual] |
Sets the specified camera(s) and updates the view if necessary.
void QGLViewer::setFrustum | ( | StereoBuffer | buffer = QGLViewer::MONO |
) | [protected] |
Sets the frustum in the current OpenGL context. It automatically recognizes if mono view or stereo simulation is switched on.
void QGLViewer::setFrustumMono | ( | ) | [protected] |
Sets the frustum for mono view.
void QGLViewer::setFrustumStereoLeft | ( | ) | [protected] |
Sets the left frustum for stereo simulation.
void QGLViewer::setFrustumStereoRight | ( | ) | [protected] |
Sets the right frustum for stereo simulation.
virtual void QGLViewer::setFullViewer | ( | bool | state | ) | [inline, virtual] |
Sets the flag that identifies the viewer as "full viewer" or not. It should be reimplemented in the derived class for full functionality. A "full viewer" is a viewer that have some buttons, slider or other things for manipulating the camera. If it is not a "full viewer" it only have a QGLWidget for the output.
Reimplemented in QGLExaminerViewer.
void QGLViewer::setItemChecked | ( | int | nID, | |
bool | fCheck | |||
) | [inline] |
Checks the menu item with identifier 'nID' if 'fCheck' is 'true', or unchecks the item if 'fEnable' is 'false'.
void QGLViewer::setItemEnabled | ( | int | nID, | |
bool | fEnable | |||
) | [inline] |
Enables the menu item with identifier 'nID' if 'fEnable' is 'true', or disables the item if 'fEnable' is 'false'.
void QGLViewer::setLookAt | ( | ) | [protected] |
Sets the 'LookAt' parameters just like the OpenGL command 'gluLookAt(...)'. But before setting it 'glLoadIdentity()' for the model view matrix is called.
void QGLViewer::setRefreshRate | ( | int | nFramesPerSecond | ) |
Sets the refresh rate of the context. If there are more refresh calls like sltUpdateView() do they were dropped.
void QGLViewer::setVPRes | ( | int | nWidth, | |
int | nHeight | |||
) | [private, virtual] |
Sets the viewplane resolution of the current- and homecamera according to the resolution of the viewport.
void QGLViewer::sigFovyChanged | ( | double | rdFovy | ) | [signal] |
This signal is emitted if the fovy angle of the current camera has changed by the viewer. The new fovy angle is passed by the parameter.
void QGLViewer::sigInitGL | ( | ) | [signal] |
This signal is once emitted if the widget will be showed and before any drawing were done. It comes originally from the QGLSignalWidget inside the viewer and is just passed through.
void QGLViewer::sigMoved | ( | QMouseEvent * | pqEvent | ) | [signal] |
This signal is ONLY emitted if the viewer is in GL_SELECT-mode and the mouse was moveed. Similar to sigSelected( int, int).
NOTE: For other things implement the ManageMouseMove()-method in your class derived from the QGLViewer-class which will be called in GL_RENDER-mode !!!
void QGLViewer::sigProjModeToggled | ( | ) | [signal] |
This signal is emitted if the projectionmode has changed.
void QGLViewer::sigRatioChanged | ( | double | rdRatio | ) | [signal] |
This signal is emitted if the ratio of the current camera has changed by the viewer. The new ratio is passed by the parameter.
void QGLViewer::sigRedrawGL | ( | ) | [signal] |
This signal is emitted if the scene should be redrawed. It comes originally from the QGLSignalWidget inside the viewer and is just passed through.
void QGLViewer::sigReleased | ( | QMouseEvent * | pqEvent | ) | [signal] |
This signal is ONLY emitted if the viewer is in GL_SELECT-mode and any mousebutton was released. Similar to sigSelected( int, int).
NOTE: For other things implement the ManageMouseRelease()-method in your class derived from the QGLViewer-class which will be called in GL_RENDER-mode !!!
void QGLViewer::sigRenderModeChanged | ( | ) | [signal] |
This signal is emitted if the rendermode has changed so that the application knows that it should render the scene again but in the new rendermode.
void QGLViewer::sigResizeGL | ( | int | nWidth, | |
int | nHeight | |||
) | [signal] |
This signal is emitted if the widget was resized and the scene should be redrawed. It comes originally from the QGLSignalWidget inside the viewer and is just passed through.
void QGLViewer::sigSelected | ( | QMouseEvent * | pqEvent | ) | [signal] |
This signal is ONLY emitted if the viewer is in GL_SELECT-mode and any mousebutton was pressed. It should be used to transfer object selections over the viewer to the application. For that connect this signal to a slot of your application which does all the stuff to get selected object(s).
NOTE: For other things implement the ManageMousePress()-method in your class derived from the QGLViewer-class which will be called in GL_RENDER-mode !!!
void QGLViewer::sltGoHome | ( | ) | [protected, virtual, slot] |
Current viewing position is replaced by home viewing position.
Reimplemented in QGLExaminerViewer.
void QGLViewer::sltManageDragEnter | ( | QDragEnterEvent * | pqEvent | ) | [protected, virtual, slot] |
This slot is for managing drag-enter events over the signal widget. The original implementation only calls 'accept()' if the dragged was of 'class QCameraDrag'.
void QGLViewer::sltManageDragLeave | ( | QDragLeaveEvent * | pqEvent | ) | [protected, virtual, slot] |
This slot is for managing drag-enter events over the signal widget. The original implementation does nothing.
void QGLViewer::sltManageDrop | ( | QDropEvent * | pqEvent | ) | [protected, virtual, slot] |
This slot is for managing drop events over the signal widget. The original implementation only magages dropped 'QCameraDrag'-classes by setting the current camera.
void QGLViewer::sltPaintGL | ( | ) | [private, slot] |
Does some initial stuff (especially sets the projection matrix) before calling the 'PaintGl()' function of the application by sending a 'sigRedrawGL()' signal.
void QGLViewer::sltPopMenu | ( | QMouseEvent * | pqEvent | ) | [private, slot] |
Pops up the menu.
void QGLViewer::sltResizeGL | ( | int | w, | |
int | h | |||
) | [private, slot] |
Does some initial stuff (especially sets the viewport size and the projection matrix) before calling the 'ResizeGl()' function of the application by sending a 'sigResizeGL()' signal.
void QGLViewer::sltSetHome | ( | ) | [protected, virtual, slot] |
Set home position The current camera is copied to the home camera.
void QGLViewer::sltSetProjectionMode | ( | ) | [protected, virtual, slot] |
Sets up the PROJECTION matrix depending on the projectionmode.
void QGLViewer::sltSwitchMouseMove | ( | QMouseEvent * | event | ) | [inline, private, slot] |
Switches the mousereleaseevents between the two rendermodes.
void QGLViewer::sltSwitchMousePress | ( | QMouseEvent * | event | ) | [inline, private, slot] |
Switches the mousepressevents between the two rendermodes.
void QGLViewer::sltSwitchMouseRelease | ( | QMouseEvent * | event | ) | [inline, private, slot] |
Switches the mousereleaseevents between the two rendermodes.
void QGLViewer::sltToggleProjectionMode | ( | ) | [protected, virtual, slot] |
Viewing can be toggled between parallel or perspective projection.
void QGLViewer::sltToggleRenderMode | ( | ) | [protected, virtual, slot] |
Toggles the current rendermode between GL_RENDER and GL_SELECT and sets the right mousecursor. The initial value is GL_RENDER.
Reimplemented in QGLExaminerViewer.
void QGLViewer::sltToggleStereo | ( | ) | [virtual, slot] |
Toggles between stereo on and off (if available). Initially stereo is disabled
Reimplemented in QGLExaminerViewer.
virtual void QGLViewer::sltUpdateView | ( | ) | [inline, virtual, slot] |
Makes a redraw of the scene. (It also calls the paint function that is connected with the signal 'sigRedrawGL()' of the viewer.)
void QGLViewer::sltViewAll | ( | ) | [virtual, slot] |
Modify camera that the entire scene resides within the currently defined view frustum.
virtual void QGLViewer::timerEvent | ( | QTimerEvent * | pqEvent | ) | [inline, protected, virtual] |
This method is called by the timer and makes an redraw if there are any pending updates.
CCamera QGLViewer::m_cCurrentCamera [protected] |
CCamera QGLViewer::m_cHomeCamera [protected] |
GLenum QGLViewer::m_eRenderMode [protected] |
bool QGLViewer::m_fAllowStereoSimulation [protected] |
bool QGLViewer::m_fFullViewer [protected] |
bool QGLViewer::m_fHandleMouseEvents [private] |
bool QGLViewer::m_fRefresh [private] |
int QGLViewer::m_nRefreshRate [private] |
int QGLViewer::m_nTimerID [private] |
QFrame* QGLViewer::m_pQFrame [protected] |
QGLSignalWidget* QGLViewer::m_pQGLWidget [protected] |
QHBoxLayout* QGLViewer::m_pQHBoxLayout [protected] |
QCursor* QGLViewer::m_pqMoveCursor [protected] |
QPopupMenu* QGLViewer::m_pqPopupMenu [protected] |
QCursor * QGLViewer::m_pqSelectCursor [protected] |
QStereoCtrl* QGLViewer::m_pStereoCtrl [protected] |
QBitmap QGLViewer::m_qMoveMaskPix [protected] |
QBitmap QGLViewer::m_qMovePix [protected] |
QBitmap QGLViewer::m_qSelectMaskPix [protected] |
QBitmap QGLViewer::m_qSelectPix [protected] |
StereoMode QGLViewer::m_stereoMode [protected] |