IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QObjectPicker Class

The QObjectPicker class instantiates a component that can be used to interact with a QEntity by a process known as picking.

This class was introduced in Qt 5.6.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QObjectPicker Class

  • Header: QObjectPicker

  • Since: Qt 5.6

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS 3drender)

    target_link_libraries(mytarget PRIVATE Qt6::3drender)

  • qmake: QT += 3drender

  • Inherited By:

  • Instantiated By: qml-qt3d-render-objectpicker.xml

  • Inherits: Qt3DCore::QComponent

Detailed Description

For every combination of viewport and camera, picking casts a ray through the scene to find entities who's bounding volume intersects the ray. The bounding volume is computed using the values in the attribute buffer specified by the boundingVolumePositionAttribute of the geometry.

The signals pressed(), released(), clicked(), moved(), entered(), and exited() are emitted when the bounding volume defined by the pickAttribute property intersects with a ray.

Most signals carry a QPickEvent instance. If QPickingSettings::pickMode() is set to QPickingSettings::TrianglePicking, the actual type of the pick parameter will be QPickTriangleEvent.

Pick queries are performed on mouse press and mouse release. If drag is enabled, queries also happen on each mouse move while any button is pressed. If hover is enabled, queries happen on every mouse move even if no button is pressed.

For generalised ray casting queries, see Qt3DRender::QRayCaster and Qt3DRender::QScreenRayCaster.

Instances of this component shouldn't be shared, not respecting that condition will most likely result in undefined behavior.

The camera far plane value affects picking and produces incorrect results due to floating-point precision if it is greater than ~100 000.

See Also

Property Documentation

 

[read-only] containsMouse : const bool

Specifies if the object picker currently contains the mouse

Access functions:

Notifier signal:

  • void containsMouseChanged(bool containsMouse)

dragEnabled : bool

Specifies if drag is enabled

Access functions:

Notifier signal:

  • void dragEnabledChanged(bool dragEnabled)

hoverEnabled : bool

Specifies if hover is enabled

Access functions:

Notifier signal:

  • void hoverEnabledChanged(bool hoverEnabled)

[read-only] pressed : const bool

Specifies if the object picker is currently pressed

Access functions:

  • bool isPressed() const

Notifier signal:

  • void pressedChanged(bool pressed)

priority : int

The priority to be used when filtering pick results by priority when QPickingSettings::pickResultMode is set to QPickingSettings::NearestPriorityPick.

Access functions:

Notifier signal:

  • void priorityChanged(int priority)

Member Function Documentation

 

void QObjectPicker::clicked(Qt3DRender::QPickEvent *pick)

This signal is emitted when the bounding volume defined by the pickAttribute property intersects with a ray on a mouse click the QPickEvent pick contains details of the event.

bool QObjectPicker::containsMouse() const

Returns true if the object picker currently contains the mouse

Getter function for property containsMouse.

void QObjectPicker::entered()

This signal is emitted when the bounding volume defined by the pickAttribute property intersects with a ray on the mouse entering the volume.

void QObjectPicker::exited()

This signal is emitted when the bounding volume defined by the pickAttribute property intersects with a ray on the ray exiting the volume.

bool QObjectPicker::isDragEnabled() const

Returns true if dragging is enabled

Getter function for property dragEnabled.

bool QObjectPicker::isHoverEnabled() const

Returns true if hover enabled

Getter function for property hoverEnabled.

void QObjectPicker::moved(Qt3DRender::QPickEvent *pick)

This signal is emitted when the bounding volume defined by the pickAttribute property intersects with a ray on a mouse move with a button pressed the QPickEvent pick contains details of the event.

void QObjectPicker::pressed(Qt3DRender::QPickEvent *pick)

This signal is emitted when the bounding volume defined by the pickAttribute property intersects with a ray on a mouse press the QPickEvent pick contains details of the event.

void QObjectPicker::released(Qt3DRender::QPickEvent *pick)

This signal is emitted when the bounding volume defined by the pickAttribute property intersects with a ray on a mouse release the QPickEvent pick contains details of the event.

void QObjectPicker::setDragEnabled(bool dragEnabled)

Sets the dragEnabled Property to dragEnabled

Setter function for property dragEnabled.

See Also

See also isDragEnabled()

void QObjectPicker::setHoverEnabled(bool hoverEnabled)

Sets the hoverEnabled Property to hoverEnabled

Setter function for property hoverEnabled.

See Also

See also isHoverEnabled()

[since 5.13] void QObjectPicker::setPriority(int priority)

Sets the picker's priority to priority. This is used when the pick result mode on QPickingSettings is set to QPickingSettings::NearestPriorityPick. Picking results are sorted by highest priority and shortest picking distance.

Setter function for property priority.

This function was introduced in Qt 5.13.

See Also

See also priority()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+