QGLPickNode ClassThe 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
Signals
Additional Inherited Members
Detailed DescriptionThe 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
|