#include <qglvuwidget.h>
Inheritance diagram for QGLVUWidget::

Public Types | |
| enum | WorldNavMode { NAV_MODE_TRACKBALL, NAV_MODE_HYPERBALL, NAV_MODE_DRIVE, NAV_MODE_TRANSLATE, NAV_MODE_LOOK, NAV_MODE_NUM_MODES } |
| World Navigation Modes. See SetWorldNavMode(). | |
| enum | CameraID { CAMERA_ONE, CAMERA_TWO, CAMERA_THREE, CAMERA_FOUR, CAMERA_NUM_CAMS } |
| Camera IDs. There are 4 default Cameras in a QGLVUWidget. | |
Public Slots | |
| void | SelectCam (int whichCam) |
| void | AllCamsResetToOrig () |
| void | CyclePolygonMode () |
| int | SetWorldNavMode (WorldNavMode mode) |
| bool | ToggleCamDisplay (int whichCam) |
| bool | ToggleInOutMode () |
| bool | ToggleFaceCulling () |
| bool | ToggleLighting () |
| bool | ToggleMaterials () |
| bool | ToggleSmoothShading () |
| void | ToggleCullFace () |
Signals | |
| void | FPSUpdate (float rFPS) |
Public Methods | |
| QGLVUWidget (QGLFormat &format=QGLFormat::defaultFormat(), QWidget *parent=0, const char *name=0) | |
| virtual | ~QGLVUWidget () |
| virtual void | DoneCurrent () |
| void | MakeContextCurrent () |
| virtual void | BeginFrame () |
| virtual void | EndFrame () |
| void | SetCurrentCam (Camera *pNewCam) |
| Camera * | GetCurrentCam () |
| Camera * | GetCam (int whichCam) |
| void | SetOrigCam (Camera *pCam) |
| void | SetAllCams (Vec3f worldMin, Vec3f worldMax, Vec3f eye, Vec3f lookAtCntr, Vec3f viewup, float yFOV, float aspect, float nearFactor, float farFactor) |
| void | AllCamsPerspectiveChange (float yFOV, float aspect, float nearDist, float farDist) |
| void | AllCamsPerspectiveAspectChange (float aspect) |
| float * | GetModelviewMatrix (float *pMatrix) const |
| float * | GetProjectionMatrix (float *pMatrix) const |
| bool | GetInOutMode () const |
| void | SetInOutMode (bool bMode) |
| int | GetWorldNavMode () const |
| const Vec3f & | GetViewUp () const |
| const Vec3f & | GetWorldCenter () const |
| float | GetWorldRadius () const |
| void | SetViewUp (Vec3f viewup) |
| void | SetWorldCenter (const Vec3f ¢er) |
| void | SetWorldRadius (float newRadius) |
| bool | GetCamDisplayOn (int whichCam) const |
| bool | GetInertiaOn () const |
| bool | GetInertiaEnabled () const |
| int | GetInertiaDelay () const |
| void | SetInertiaOn (bool bEnable) |
| void | SetInertiaEnabled (bool bEnable) |
| void | SetInertiaDelay (int iMilliseconds) |
| int | GetInertiaMinMove () const |
| void | SetInertiaMinMove (int iAmount) |
| void | StartFPSClock () |
| void | StopFPSClock () |
| float | GetFPS () const |
| void | SetFPSIntegrateInterval (float rInterval) |
| void | UpdateFPS () |
| ButtonState | GetButtonState () const |
| void | GetMousePos (int &ix, int &iy) const |
| void | TranslateX (int iOldX, int iNewX, int iWW) |
| void | TranslateY (int iOldY, int iNewY, int iWH) |
| void | DriveY (int iOldY, int iNewY, int iWH) |
| void | LookX (int iOldX, int iNewX, int iWW) |
| void | LookY (int iOldY, int iNewY, int iWH) |
| void | TrackBallX (int iOldX, int iNewX, int iWW) |
| void | TrackBallY (int iOldY, int iNewY, int iWH) |
| void | HyperBall (int iOldX, int iOldY, int iNewX, int iNewY, int iWW, int iWH) |
| void | SnapShot () |
| void | ReportGLError (char *msg) |
| QPixmap * | CreateQGLVUPixmap () const |
| void | SetPathFilename (const char *pFilename) |
| void | StartRecording () |
| void | EndRecording () |
| void | StartPlayback () |
| void | EndPlayback () |
| void | StopRecordingPlayback () |
| void | SetInitializeGL (void(*f)(QGLVUWidget *)) |
| void | SetResizeGL (void(*f)(QGLVUWidget *, int, int)) |
| void | SetPaintGL (void(*f)(QGLVUWidget *)) |
Static Public Methods | |
| void | DefaultInitializeGL (QGLVUWidget *pGLVU) |
| void | DefaultResizeGL (QGLVUWidget *pGLVU, int iw, int ih) |
| void | DefaultPaintGL (QGLVUWidget *pGLVU) |
Protected Methods | |
| virtual void | initializeGL () |
| virtual void | resizeGL (int iw, int ih) |
| virtual void | paintGL () |
| virtual void | mousePressEvent (QMouseEvent *pEvent) |
| virtual void | mouseReleaseEvent (QMouseEvent *pEvent) |
| virtual void | mouseDoubleClickEvent (QMouseEvent *pEvent) |
| virtual void | mouseMoveEvent (QMouseEvent *pEvent) |
| virtual void | wheelEvent (QWheelEvent *pEvent) |
| virtual void | keyPressEvent (QKeyEvent *pEvent) |
| virtual void | keyReleaseEvent (QKeyEvent *pEvent) |
| virtual void | timerEvent (QTimerEvent *pEvent) |
| bool | _DoInertia () |
| virtual void | _Inertia (int x, int y) |
| void | _DoRecordAndPlayback () |
Protected Attributes | |
| Camera | _pCams [CAMERA_NUM_CAMS] |
| Camera * | _pCam |
| Camera | _origCam |
| bool | _pbCamDisplayOn [CAMERA_NUM_CAMS] |
| Vec3f | _worldCenter |
| float | _rWorldRadius |
| Vec3f | _viewUp |
| bool | _bInsideLookingOutMode |
| WorldNavMode | _eWorldNavMode |
| int | _iOldX |
| int | _iOldY |
| int | _iNewX |
| int | _iNewY |
| float | _rMoveSpeed |
| ButtonState | _buttonState |
| bool | _bInertiaOn |
| bool | _bInertiaEnabled |
| int | _iInertiaDelay |
| int | _iInertiaTimerID |
| int | _iInertiaMinMove |
| char * | _pPathFilename |
| bool | _bRecordingOn |
| bool | _bPlaybackOn |
| FILE * | _pPathFP |
| timeb | _lastFPSClock |
| bool | _bCalcFPS |
| float | _rLastFPS |
| int | _iLastFPSCount |
| int | _iFPSDelay |
| int | _iFPSTimerID |
| float | _rFPSIntegrateInterval |
| void(* | _pfInitializeGL )(QGLVUWidget *) |
| void(* | _pfResizeGL )(QGLVUWidget *, int, int) |
| void(* | _pfPaintGL )(QGLVUWidget *) |
Features include a full-featured Camera class [GetCamera()]; world navigation with multiple mouse control modes [SetWorldNavMode()] and "inertia" [SetInertiaEnabled()]; frame rate computation [GetFPS()]; screen capture [SnapShot()]; and a host of other features from view-frustum culling and object loading and rendering, via the auxiliary GLVU libraries.
To use a QGLVUWidget you have two options:
For the most control, you can subclass it and overridethe paintGL() method and optionally the initializeGL() and resizeGL() methods. You can also override the normal QWidget event methods, such as mouseMoveEvent() or timerEvent().
For an "EZ" way to get up and running with a QGLVUWidget, you can write your own stand alone paintGL() and/or initializeGL() and resizeGL() methods, following the interface of DefaultPaintGL(), DefaultInitializeGL(), and DefaultResizeGL(), respectively. Then pass then pass them to the QGLVUWidget via SetPaintGL(), SetInitializeGL(), and SetResizeGL().
|
|
Changes the aspect ratio of all cameras without affecting the other perspective parameters.
|
|
||||||||||||||||||||
|
Changes the frustum dimensions of all Cameras to the specified parameters. Does not affect position and orientation.
|
|
|
Resets all cameras to the original settings set with SetAllCams(). |
|
|
This function should be called before making any rendering calls in paintGL(). It does two things: First, it loads the projection and modelview matrices from the current Camera. Second, it updates the FPS counters. BeginFrame() is equivalent to the following code:
GLfloat M[16]; glMatrixMode(GL_PROJECTION); glLoadMatrixf( GetProjectionMatrix(M) ); glMatrixMode(GL_MODELVIEW); glLoadMatrixf( GetModelviewMatrix(M) ); UpdateFPS(); |
|
|
Creates the standard QGLVU logo as a 64x64 Pixmap, ideal for icons. |
|
|
Cycles the GL polygon mode between fill, wire, and point modes. The wire mode is by default set to disply front faces as wireframe, and back faces filled. |
|
|
The default implementation of initializeGL. Initially this is called by initializeGL(), but it can be overridden either by subclassing QGLVUWidget or by passing a function pointer to SetInitializeGL(). |
|
|
The default implementation of paintGL. Initially this is called by paintGL(), but it can be overridden either by subclassing QGLVUWidget or by passing a function pointer to SetPaintGL(). |
|
||||||||||||||||
|
The default implementation of resizeGL. Initially this is called by resizeGL(), but it can be overridden either by subclassing QGLVUWidget or by passing a function pointer to SetResizeGL(). |
|
|
Notifies the QGLVUWidget that it's context is no longer current. This is useful when using non-Qt created GL contexts, such as you might create using WGL or GLX calls (for example, when using pbuffers). Call this when you are done using the non-Qt context. This will cause the QGLVUWidget's context to be made current the next time one of initializeGL(), paintGL(), or resizeGL() is called. |
|
||||||||||||||||
|
Moves the active Camera forward or backward along its view axis based on mouse movement. |
|
|
This function should be called last in paintGL(), or after making any rendering calls. This base implementation simply displays camera frusta for Cameras that have their display flags set. (see ToggleCamDisplay()). |
|
|
Ends Camera path playback. |
|
|
Ends path recording and closes the path file. |
|
|
Returns the current state of mouse buttons. Updated by mousePressEvent() and mouseReleaseEvent(). |
|
|
Returns a pointer to the specified camera. |
|
|
Returns the display status of the specified Camera. |
|
|
Returns a pointer to the active camera. |
|
|
Returns the last calculated Frames Per Second measurement. |
|
|
Returns a boolean specifying whether the navigation mode is "inside looking out" (true) or "outside looking in" (false, the default). See SetInOutMode() and ToggleInOutMode(). |
|
|
Returns the current time delay (secs)between Inertia events when Inertia is active. |
|
|
Returns whether or not Inertia is enabled, i.e. whether a Camera can be moved by Inertia. |
|
|
Returns the minimum number of pixels the mouse must be moved (with LeftButton pressed) in order to invoke Inertia. |
|
|
Returns whether or not Inertia is currently "active", i.e. it is moving a Camera at the time of query. |
|
|
Returns the modelview matrix of the current Camera. |
|
||||||||||||
|
Returns the last position of the mouse when a button was pressed. In the base QGLVUWidget implementation, mouse position is only stored on mousePressEvents. |
|
|
Returns the projection matrix of the current Camera. |
|
|
Returns the global "up" vector, as set by SetViewUp() or SetAllCams(). |
|
|
Returns the global "center" of the world, as set by SetWorldCenter() or (indirectly) by SetAllCams(). |
|
|
Returns the current navigation mode. See SetWorldNavMode(). |
|
|
Returns the global "radius" of the world, as set by SetWorldRadius() or (indirectly) by SetAllCams(). |
|
||||||||||||||||||||||||||||
|
Implements the SGI "Hyperbolic Sheet" trackball mode to rotate the active Camera about the center of the world. |
|
||||||||||||||||
|
Rotates the active Camera about its Up axis (through its origin) based on mouse movement. |
|
||||||||||||||||
|
Rotates the active Camera about its side axis (through its origin) based on mouse movement. |
|
|
Simply calls DoneCurrent(), and then QGLWidget::makeCurrent(). Use this in cases when you are using a non-Qt context, and you don't have a chance to call DoneCurrent() before one of initializeGL(), paintGL(), or resizeGL() is called. |
|
|
A debugging method. Reports any current error in OpenGL, appending message to the end. |
|
|
Activates the specified Camera. |
|
||||||||||||||||||||||||||||||||||||||||
|
Sets all Cameras to the specified viewing parameters. Useful at application startup or reset. This stores a copy of the camera settings so it can be easily reset later with AllCamsResetToOrig().
|
|
|
Sets the active camera.
|
|
|
Sets the interval over which frame time is integrated and then averaged to calculate FPS. This sets how often the averaging and updates occur. |
|
|
Sets the navigation mode to either "inside looking out" (true) or "outside looking in" (false, the default). See SetInOutMode() and ToggleInOutMode(). |
|
|
Sets the time delay (secs) between Inertia events. |
|
|
Enables or disables Inertia functionality. |
|
|
Sets the minimum number of pixels the mouse must be moved (with LeftButton pressed) in order to invoke Inertia. |
|
|
Activates Inertia. Normally only called internally in response to mouse action. |
|
|
Sets the active initializeGL function to the function pointed to by f. By default initializeGL() calls DefaultInitializeGL(). |
|
|
Stores a copy of pCam so that Cameras can be reset to its parameters at a later time using AllCamsResetToOrig(). |
|
|
Sets the active paintGL function to the function pointed to by f. By default paintGL() calls DefaultPaintGL(). |
|
|
Sets the filename to be used for path recording and playback to pFilename |
|
|
Sets the active resizeGL function to the function pointed to by f. By default resizeGL() calls DefaultResizeGL(). |
|
|
Sets the global "up" vector. |
|
|
Sets the global "center" of the world. |
|
|
Sets the current World Navigation mode. mode may be one of:
|
|
|
Sets the global "radius" of the world. |
|
|
Captures the current front GL draw buffer, and stores it as a PNG image. The image will have a filename of the form "snapNNNN.png", where "NNNN" is a zero-padded integer starting at 0000 and incrementing to avoid overwriting existing files. |
|
|
Starts the frame timer and resets the frame counter. |
|
|
Begins path playback from the path file specified via SetPathFilename(). Updates the positions and orientations of all four Cameras. |
|
|
Begins path recording. Records the position and orientation of all four Cameras to the file specified with SetPathFilename(), or to "path0.dat" if none is specified. |
|
|
Stops the frame timer. |
|
|
Stops both Camera path recording and playback if either is active. |
|
|
Toggle the display flag for the camera specified in whichCam |
|
|
Toggles culling between front and back face culling. |
|
|
Toggles face culling on and off. |
|
|
Toggles the display mode between "inside looking out" and "outside looking in". |
|
|
Toggles lighting on and off. |
|
|
Enables and disables "GL_COLOR_MATERIAL". |
|
|
Toggles between smooth and flat shading. |
|
||||||||||||||||
|
Rotates the active Camera about the center of the world around either the world "up" vector or the Camera "up" vector, depending on whether or not the navigation mode is set to "Inside Looking Out" mode (ToggleInOutMode()). Motion is based on mouse movement. |
|
||||||||||||||||
|
Rotates the active Camera about the center of the world around its side axis based on mouse movement. |
|
||||||||||||||||
|
Translates the active camera in the X direction based on mouse movement. |
|
||||||||||||||||
|
Translates the active camera in the Y direction based on mouse movement. |
|
|
If FPS calculation is enabled (StartFPSClock()), then this function updates the current Frames Per Second calculation. Call only if you are not using the default implementation of BeginFrame(). |
|
|
Calls the inertia function using temporary copies of the mouse position. Returns false if inertia is disabled, true otherwise. |
|
|
Writes all Cameras to the path file if recording is on. Reads all Cameras from the path file if playback is on. |
|
||||||||||||
|
This function can be reimplemented in a subclass to perform custom inertia behavior. Sends a fake mouse event when called. Used by the inertia system to move objects when they are "flung" with the mouse. |
|
|
This virtual function is called one time before the first call to paintGL() or resizeGL(), and then one time whenever the widget has been assigned a new QGLContext. Reimplement it in a subclass. This function should take care of setting any required OpenGL context rendering flags, defining display lists, etc. There is no need to call makeCurrent() because this has already been done when this function is called. QGLVU EXCEPTION: If you are using non-Qt GL contexts, such as with pbuffers, you will want to call DoneCurrent() after using the outside context and before initializeGL() is called. Otherwise you can call MakeContextCurrent() inside initializeGL(). |
|
|
This event handler can be reimplemented in a subclass to receive key press events for the widget. A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event. If you reimplement this handler, it is very important that you ignore() the event if you do not understand it, so that the widget's parent can interpret it. The default implementation closes popup widgets if you hit escape. Otherwise the event is ignored. See also keyReleaseEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event() and QKeyEvent. |
|
|
This event handler can be reimplemented in a subclass to receive key release events for the widget. A widget must accept focus initially and have focus in order to receive a key release event. If you reimplement this handler, it is very important that you ignore() the release if you do not understand it, so that the widget's parent can interpret it. The default implementation ignores the event. See also keyPressEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event() and QKeyEvent. |
|
|
This event handler can be reimplemented in a subclass to receive mouse double click events for the widget. The default implementation (which this calls) generates a normal mouse press event. Note that the widgets gets a mousePressEvent() and a mouseReleaseEvent() before the mouseDoubleClickEvent(). See also mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and QMouseEvent. |
|
|
This event handler can be reimplemented in a subclass to receive mouse move events for the widget. If mouse tracking is switched off, mouse move events only occur if a mouse button is down while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is down. QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user moves and clicks the mouse fast. This is a feature of the underlying window system, not Qt. In QGLVUWidget, this method updates the old and new mouse (pressed) positions if a button is pressed, and if the button is the left button, it performs Camera movement based on the active WorldNavMode (SetWorldNavMode()). See also setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), and QMouseEvent. |
|
|
This event handler can be reimplemented in a subclass to receive mouse press events for the widget. Currently this event stores the button state and the previous and new mouse positions. If the button is the left button, it deactivates inertia. See also mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), and QMouseEvent |
|
|
This event handler can be reimplemented in a subclass to receive mouse press events for the widget. Currently this event measures the amount of movement between the last two events if the left button was pressed, and if it is greater than the inertia movement threshold, it activates inertia. If this is the case, it stores the button state before the event. If it is false or the right button was pressed, it stores the button state after the event. See also mousePressEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), and QMouseEvent |
|
|
This virtual function is called whenever the widget needs to be painted. Reimplement it in a subclass. There is no need to call makeCurrent() because this has already been done when this function is called. QGLVU EXCEPTION: If you are using non-Qt GL contexts, such as with pbuffers, you will want to call DoneCurrent() after using the outside context and before paintGL() is called. Otherwise you can call MakeContextCurrent() inside paintGL(). |
|
||||||||||||
|
This virtual function is called whenever the widget has been resized. Reimplement it in a subclass. There is no need to call makeCurrent() because this has already been done when this function is called. QGLVU EXCEPTION: If you are using non-Qt GL contexts, such as with pbuffers, you will want to call DoneCurrent() after using the outside context and before resizeGL() is called. Otherwise you can call MakeContextCurrent() inside resizeGL(). |
|
|
This event handler can be reimplemented in a subclass to receive timer events for the object. This default timerEvent processes inertia and camera recording and playback. QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. See also startTimer(), killTimer(), killTimers() and event(). |
|
|
This event handler can be reimplemented in a subclass to receive wheel events for the widget. If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it. The default implementation ignores the event. See also QWheelEvent::ignore(), QWheelEvent::accept(), event() and QWheelEvent. |
1.2.10 written by Dimitri van Heesch,
© 1997-2001