Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QGLView Class

The QGLView class extends QGLWidget with support for 3D viewing. More...

 #include <QGLView>

Inherits: QWindow.

This class was introduced in Qt 4.8.

Public Types

enum Option { ObjectPicking, ShowPicking, CameraNavigation, FOVZoom }
flags Options
enum StereoType { Hardware, RedCyanAnaglyph, LeftRight, RightLeft, ..., StretchedBottomTop }
enum SurfaceClass { Window }
enum SurfaceType { RasterSurface, OpenGLSurface }

Public Functions

QGLView(QWindow * parent = 0)
QGLView(const QSurfaceFormat & format, QWindow * parent = 0)
~QGLView()
virtual ~QSurface()
QGLCamera * camera() const
QOpenGLContext * context()
void deregisterObject(int objectId)
virtual QSurfaceFormat format() const = 0
bool isVisible() const
QVector3D mapPoint(const QPoint & point) const
QObject * objectForPoint(const QPoint & point)
QGLView::Options options() const
void registerObject(int objectId, QObject * object)
void setCamera(QGLCamera * value)
void setOption(QGLView::Option option, bool value)
void setOptions(QGLView::Options value)
void setStereoType(QGLView::StereoType type)
virtual QSize size() const = 0
QGLView::StereoType stereoType() const
SurfaceClass surfaceClass() const
virtual QPlatformSurface * surfaceHandle() const = 0
virtual SurfaceType surfaceType() const = 0
  • 69 public functions inherited from QWindow
  • 31 public functions inherited from QObject

Public Slots

void update()
  • 15 public slots inherited from QWindow
  • 1 public slot inherited from QObject

Signals

void quit()

Protected Functions

QSurface(SurfaceClass type)
virtual void earlyPaintGL(QGLPainter * painter)
virtual void initializeGL(QGLPainter * painter)
virtual void paintGL(QGLPainter * painter)
QPointF viewDelta(int deltax, int deltay) const
QPointF viewDelta(const QPoint & delta) const

Reimplemented Protected Functions

virtual void exposeEvent(QExposeEvent * e)
virtual void hideEvent(QHideEvent * e)
virtual void keyPressEvent(QKeyEvent * e)
virtual void mouseDoubleClickEvent(QMouseEvent * e)
virtual void mouseMoveEvent(QMouseEvent * e)
virtual void mousePressEvent(QMouseEvent * e)
virtual void mouseReleaseEvent(QMouseEvent * e)
virtual void resizeEvent(QResizeEvent * e)
virtual void showEvent(QShowEvent * e)
virtual void wheelEvent(QWheelEvent * e)
  • 17 protected functions inherited from QWindow
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 10 properties inherited from QWindow
  • 1 property inherited from QObject
  • 11 static public members inherited from QObject

Detailed Description

The QGLView class extends QGLWidget with support for 3D viewing.

Navigating

Navigation in 3D space is possible under keyboard and mouse control.

Holding down the left mouse button and dragging it will rotate the camera() position around the object being viewed. Holding down the left mouse button and the Shift key pans the view in a plane without rotating the viewed object.

Using the mouse wheel, the view can be zoomed in or out. If the system does not have a mouse wheel, then holding down the left mouse button and the Control key and moving the mouse up and down will also zoom in and out.

On the keyboard, the left, right, up, and down keys can also be used to shift the camera() position around the object being viewed. Shift and Control modify keys the same way they modify the left mouse button above.

Stereo viewing support

Note - Stereo viewing is experimental and unsupported.

If the hardware supports stereo buffers, then each time the scene needs to be painted, QGLView renders it twice: first from the perspective of the left eye, and then from the perspective of the right eye. The separation between the eye positions is specified by QGLCamera::eyeSeparation(). If the eye separation is zero, then stereo viewing is disabled and only a single image will be rendered per frame.

Three kinds of stereo viewing are possible: hardware stereo, anaglyph stereo, and double image stereo.

Hardware stereo relies upon specialized hardware that can render the left and right eye images into separate buffers and then show them independently to each eye through the use of polarized glasses or similar technology. Hardware stereo is used if the -stereo-hw command-line option is supplied or if the user explicitly requests stereo buffers when the QGLView is constructed:

 QGLFormat format(QGLFormat::defaultFormat());
 format.setOption(QGL::StereoBuffers);
 QGLView view(format);

Anaglyph stereo is used when the hardware doesn't have specialized stereo buffer support. The left eye image is masked by a red filter and the right eye image is masked by a cyan filter. This makes the resulting images suitable for viewing with standard red-cyan anaglyph glasses.

When using red-cyan anaglyphs, it is recommended that the scene use non-primary object colors. Pure primary colors such as red, green, and blue will only appear to one of the viewer's eyes and will inhibit the 3D effect. Non-primary colors or grayscale should be used to get the best effects.

Red-cyan anaglyphs can be disorienting to some viewers. If hardware stereo is not available and stereo viewing is not critical to the application, then stereo can be disabled by setting QGLCamera::eyeSeparation() to zero.

Double image stereo involves drawing the left and right eye images in a double-wide or double-high window, with the hardware combining the images. Four different configurations are available: LeftRight, RightLeft, TopBottom, and BottomTop, according to the layout of the eye images. Double image stereo is selected by calling setStereoType(). It is the responsibility of the application to resize the window to twice its normal size to accommodate the images.

Ctrl-Left and Ctrl-Right can be used to make the eye separation smaller or larger under keyboard control.

A number of command-line options are available to select the stereo mode of the QGLView so that the application does not need to select the mode itself:

-stereo-hwHardware.
-stereo-lrLeftRight.
-stereo-rlRightLeft.
-stereo-tbTopBottom.
-stereo-btBottomTop.
-stereo-stretched-lrStretchedLeftRight.
-stereo-stretched-rlStretchedRightLeft.
-stereo-stretched-tbStretchedTopBottom.
-stereo-stretched-btStretchedBottomTop.

The option can also be supplied in the QT3D_OPTIONS environment variable:

 $ QT3D_OPTIONS="-stereo-lr" ./cubehouse

If the application sets the stereo type with setStereoType(), that will be used. Next is the command-line setting, and finally the contents of the environment variable.

Member Type Documentation

enum QGLView::Option
flags QGLView::Options

This enum defines an option for QGLView.

ConstantValueDescription
QGLView::ObjectPicking0x0001Object picking is enabled. Disabled by default.
QGLView::ShowPicking0x0002Objects are rendered with their pick colors instead of their normal colors and materials. This can help debug problems with object picking. Disabled by default.
QGLView::CameraNavigation0x0004Camera navigation using the keyboard and mouse is enabled. Enabled by default.
QGLView::FOVZoom0x0010Enables zooming by changing field of view instead of physically moving the camera.

The Options type is a typedef for QFlags<Option>. It stores an OR combination of Option values.

enum QGLView::StereoType

This enum defines the type of stereo viewing technology being used by QGLView.

ConstantValueDescription
QGLView::Hardware0Specialized stereo hardware is being used.
QGLView::RedCyanAnaglyph1Stereo is being simulated for viewing by red-cyan anaglyph classes.
QGLView::LeftRight2The view is double-wide with the left eye image on the left of the window.
QGLView::RightLeft3The view is double-wide with the left eye image on the right of the window.
QGLView::TopBottom4The view is double-high with the left eye image on the top of the window.
QGLView::BottomTop5The view is double-high with the left eye image on the bottom of the window.
QGLView::StretchedLeftRight6Same as LeftRight, but with the left and right eye images stretched to double their width.
QGLView::StretchedRightLeft7Same as RightLeft, but with the left and right eye images stretched to double their width.
QGLView::StretchedTopBottom8Same as TopBottom, but with the left and right eye images stretched to double their height.
QGLView::StretchedBottomTop9Same as BottomTop, but with the left and right eye images stretched to double their height.

Member Function Documentation

QGLView::QGLView(QWindow * parent = 0)

Constructs a new view widget and attaches it to parent.

This constructor will request a stereo rendering context if the hardware supports it (and the -stereo-hw option is set).

QGLView::QGLView(const QSurfaceFormat & format, QWindow * parent = 0)

Constructs a new view widget and attaches it to parent. The format argument specifies the desired QGLFormat rendering options.

If format does not include the stereo option, then a stereo viewing context will not be requested.

The format will be set onto the window, and also onto the underlying OpenGL context.

QGLView::~QGLView()

Destroys this view widget.

QGLCamera * QGLView::camera() const

Returns the camera parameters. The camera defines the projection to apply to convert eye co-ordinates into window co-ordinates, and the position and orientation of the viewer's eye.

See also setCamera().

QOpenGLContext * QGLView::context()

Returns the OpenGL context object associated with this view, or null if one has not been associated yet. The default is null.

void QGLView::deregisterObject(int objectId)

Deregisters the object associated with objectId.

See also registerObject().

void QGLView::earlyPaintGL(QGLPainter * painter) [virtual protected]

Performs early painting operations just after painter is initialized but before the camera is set up. The default implementation clears the color buffer and depth buffer.

This function is typically overridden to draw scene backdrops on the color buffer before the rest of the scene is drawn by paintGL().

See also paintGL().

void QGLView::exposeEvent(QExposeEvent * e) [virtual protected]

void QGLView::hideEvent(QHideEvent * e) [virtual protected]

void QGLView::initializeGL(QGLPainter * painter) [virtual protected]

Initializes the current GL context represented by painter.

See also paintGL().

bool QGLView::isVisible() const

Returns true if the view is visible, that is its show event has been called and was not followed by a hide event. Note that this cannot be relied apon for the visibility of the window, as it depends on whether hide and show events are triggered, which is platform dependent.

void QGLView::keyPressEvent(QKeyEvent * e) [virtual protected]

Reimplemented from QWindow::keyPressEvent().

Processes the key press event e.

QVector3D QGLView::mapPoint(const QPoint & point) const

Maps point from viewport co-ordinates to eye co-ordinates.

The returned vector will have its x and y components set to the position of the point on the near plane, and the z component set to the inverse of the camera's near plane.

This function is used for converting a mouse event's position into eye co-ordinates within the current camera view.

See also QGLCamera::mapPoint().

void QGLView::mouseDoubleClickEvent(QMouseEvent * e) [virtual protected]

Reimplemented from QWindow::mouseDoubleClickEvent().

Processes the mouse double click event e.

void QGLView::mouseMoveEvent(QMouseEvent * e) [virtual protected]

Reimplemented from QWindow::mouseMoveEvent().

Processes the mouse move event e.

void QGLView::mousePressEvent(QMouseEvent * e) [virtual protected]

Reimplemented from QWindow::mousePressEvent().

Processes the mouse press event e.

void QGLView::mouseReleaseEvent(QMouseEvent * e) [virtual protected]

Reimplemented from QWindow::mouseReleaseEvent().

Processes the mouse release event e.

QObject * QGLView::objectForPoint(const QPoint & point)

Returns the registered object that is under the mouse position specified by point. This function may need to regenerate the contents of the pick buffer by repainting the scene with paintGL().

See also registerObject().

QGLView::Options QGLView::options() const

Returns the options for this view. The default value is CameraNavigation.

See also setOptions() and setOption().

void QGLView::paintGL(QGLPainter * painter) [virtual protected]

Paints the scene onto painter. The color and depth buffers will have already been cleared, and the camera() position set.

If QGLPainter::isPicking() is set for painter, then the function should paint the scene onto painter in "object picking mode". The scene will be rendered into a background buffer using flat colors so that mouse events can determine which object lies under the mouse pointer.

The default implementation of picking will typically just render the scene normally. However, some applications may wish to render a simpler scene that omits unselectable objects and uses simpler meshes for the selectable objects.

The base default implementation does nothing. Sub-classes should re-implement this function to paint GL content.

See also earlyPaintGL().

void QGLView::quit() [signal]

void QGLView::registerObject(int objectId, QObject * object)

Registers an object with this view to be notified when objectId is selected with the mouse. The object must persist for the lifetime of the QGLView, or until deregisterObject() is called for objectId.

See also deregisterObject() and objectForPoint().

void QGLView::resizeEvent(QResizeEvent * e) [virtual protected]

void QGLView::setCamera(QGLCamera * value)

Sets the camera parameters to value. The camera defines the projection to apply to convert eye co-ordinates into window co-ordinates, and the position and orientation of the viewer's eye.

If value is null, then the default camera object will be used.

This function will call update() to force the view to update with the new camera parameters upon the next event loop.

See also camera().

void QGLView::setOption(QGLView::Option option, bool value)

Enables or disables option according to value.

See also options() and setOptions().

void QGLView::setOptions(QGLView::Options value)

Sets the options for this view to value.

See also options() and setOption().

void QGLView::setStereoType(QGLView::StereoType type)

Sets the type of stereo viewing technology that is in use. The request takes effect at the next repaint.

The request is ignored stereoType() or type is Hardware, because hardware stereo can only be enabled if the hardware supports it, and then it can never be disabled.

See also stereoType().

void QGLView::showEvent(QShowEvent * e) [virtual protected]

QGLView::StereoType QGLView::stereoType() const

Returns the type of stereo viewing technology that is in use.

See also setStereoType().

void QGLView::update() [slot]

QPointF QGLView::viewDelta(int deltax, int deltay) const [protected]

Converts deltax and deltay into percentages of the view width and height. Returns a QPointF containing the percentage values, typically between -1 and 1.

This function is typically used by subclasses to convert a change in mouse position into a relative distance travelled across the field of view.

The returned value is corrected for the camera() screen rotation and view size.

QPointF QGLView::viewDelta(const QPoint & delta) const [protected]

This is an overloaded function.

Converts the x and y components of delta into percentages of the view width and height. Returns a QPointF containing the percentage values, typically between -1 and 1.

void QGLView::wheelEvent(QWheelEvent * e) [virtual protected]

Reimplemented from QWindow::wheelEvent().

Processes the wheel event e.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web