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  · 

QGLPickNode Class

The QGLPickNode class enables picking for objects in a 3D scene. More...

 #include <QGLPickNode>

Inherits: QObject.

This class was introduced in Qt 4.8.

Public Functions

QGLPickNode(QGLAbstractScene * parent = 0)
int id() const
void setId(int id)
void setTarget(QGLSceneNode * target)
QGLSceneNode * target() const
  • 31 public functions inherited from QObject

Signals

void clicked()
void doubleClicked()
void hoverChanged()
void pressed()
void released()

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 11 static public members inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

The QGLPickNode class enables picking for objects in a 3D scene.

QGLPickNode is a QObject sub-class, relatively light-weight, that can shadow QSceneObject instances and provide picking capability. The QGLPickNode instance receives events sent to it by picking views, such as the QGLView class, and emits relevant signals in response.

QGLSceneObjects wanting to support picking, should implement the methods

and also implement rendering such that the QGLPainter has the relevant pick id function called.

These functions are already implemented for the QGLSceneNode object type.

Picking can then be simply enabled by calling the QGLAbstractScene function setPickable() to turn on picking and generate pick nodes for the relevant scene objects.

In order to respond to picking, the view class should simply register the picknodes, and connect a relevant slot to the pick nodes signal.

For the QGLView class that code is simply:

 QList<QGLPickNode *>nodes = manager->pickNodes();
 foreach (QGLPickNode *node, nodes)
 {
     registerObject(node->id(), node);
     connect(node, SIGNAL(clicked()),
             this, SLOT(objectPicked()));
 }

The pick nodes should be unregistered with similar code for the QGLView if switching to a different scene.

To be able to recover the relevant QGLSceneNode inside the called slot, the object may be set onto the QGLPickNode with the setTarget() function, and recovered with target() inside the slot, since the QGLPickNode will be the sender() for the slot.

QGLSceneNode already sets itself as the target during the pick enable step.

See also QGLSceneNode and QGLView.

Member Function Documentation

QGLPickNode::QGLPickNode(QGLAbstractScene * parent = 0)

Construct a new QGLPickNode object managed by and parented onto the parent scene. The nextPickId() function will be called on parent to assign a pick id to this new node.

void QGLPickNode::clicked() [signal]

Signal emitted when the scene object for this node has the mouse pressed and then released while the cursor is on the object in the scene.

void QGLPickNode::doubleClicked() [signal]

Signal emitted when the scene object for this node has the mouse clicked twice in succession while the cursor is on the object in the scene.

void QGLPickNode::hoverChanged() [signal]

Signal emitted when the scene object for this node has the mouse moved into or out of this object in the scene.

int QGLPickNode::id() const

Returns the unique id for this node. This value is assigned by the parent scene for this node and should be different for every node in the scene. Returns -1 if the id has not been set yet.

See also setId().

void QGLPickNode::pressed() [signal]

Signal emitted when the scene object for this node has the mouse pressed while the cursor is on the object in the scene.

void QGLPickNode::released() [signal]

Signal emitted when the scene object for this node has the mouse released while the cursor is on the object in the scene.

void QGLPickNode::setId(int id)

Sets the unique id for this node. Generally this function should not be needed, since the constructor causes a unique id to be obtained from the parent scene. This function exists mainly for testing purposes.

See also id().

void QGLPickNode::setTarget(QGLSceneNode * target)

Sets the target for this pick node.

See also target().

QGLSceneNode * QGLPickNode::target() const

Returns the QGLSceneNode which is the target of this pick node; null if the target has not been set yet.

See also setTarget().

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