|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <Viewer3DCameraController.h>
Inheritance diagram for Viewer3DCameraController:
Collaboration diagram for Viewer3DCameraController:Signals | |
| void | orbitCenterChanged () |
| void | headingChanged () |
| void | tiltChanged () |
| void | distanceChanged () |
| void | viewportSizeChanged () |
| void | fieldOfViewChanged () |
Public Member Functions | |
| Viewer3DCameraController (QObject *parent=nullptr) | |
| QVector3D | orbitCenter () const |
| void | setOrbitCenter (const QVector3D ¢er) |
| qreal | heading () const |
| void | setHeading (qreal heading) |
| qreal | tilt () const |
| void | setTilt (qreal tilt) |
| qreal | distance () const |
| void | setDistance (qreal distance) |
| QSizeF | viewportSize () const |
| void | setViewportSize (const QSizeF &size) |
| qreal | fieldOfView () const |
| void | setFieldOfView (qreal fov) |
| Q_INVOKABLE void | reset () |
| Restore the default pose (center origin, heading 0, tilt 0, default distance) | |
| Q_INVOKABLE void | lookAt (const QVector3D ¢er, qreal heading, qreal tilt, qreal distance) |
| Set the full pose in one call. tilt/distance are clamped. | |
| Q_INVOKABLE void | beginPan (const QPointF &screenPos) |
| Start a pan gesture at the given screen position (pixels) | |
| Q_INVOKABLE void | panTo (const QPointF &screenPos) |
| Continue a pan gesture: the ground point picked at beginPan stays under the cursor. | |
| Q_INVOKABLE void | beginOrbit (const QPointF &screenPos) |
| Start an orbit gesture at the given screen position (pixels) | |
| Q_INVOKABLE void | orbitTo (const QPointF &screenPos) |
| Q_INVOKABLE void | rotateBy (qreal degrees, const QPointF &screenPos) |
| Q_INVOKABLE void | tiltBy (qreal degrees, const QPointF &screenPos) |
| Q_INVOKABLE void | zoom (qreal amount, const QPointF &screenPos) |
| Q_INVOKABLE void | zoomBy (qreal factor, const QPointF &screenPos) |
| Q_INVOKABLE qreal | sceneUnitsPerPixel () const |
| QVector3D | cameraPosition () const |
| Derived camera position in scene space. | |
| std::optional< QVector3D > | screenToGround (const QPointF &screenPos) const |
Static Public Attributes | |
| static constexpr qreal | kMinDistance = 50.0 |
| static constexpr qreal | kMaxDistance = 50000.0 |
| static constexpr qreal | kMinTilt = 0.0 |
| static constexpr qreal | kMaxTilt = 85.0 |
| static constexpr qreal | kDefaultDistance = 1500.0 |
| static constexpr qreal | kDefaultFieldOfView = 60.0 |
Friends | |
| class | Viewer3DCameraControllerTest |
Gazebo-style orbit camera controller for the 3D viewer.
Owns the camera pose as (orbitCenter, heading, tilt, distance) and implements cursor-anchored pan, orbit and zoom: the ground point under the cursor at gesture start stays under the cursor for the duration of the gesture.
Coordinate conventions (scene space, z-up): cameraPosition = orbitCenter + distance * (sin(tilt)sin(heading), -sin(tilt)cos(heading), cos(tilt)) tilt 0 = top-down, tilt 90 = horizontal. Angles in degrees.
Definition at line 28 of file Viewer3DCameraController.h.
|
explicit |
Definition at line 34 of file Viewer3DCameraController.cc.
| void Viewer3DCameraController::beginOrbit | ( | const QPointF & | screenPos | ) |
Start an orbit gesture at the given screen position (pixels)
Definition at line 128 of file Viewer3DCameraController.cc.
References screenToGround().
| void Viewer3DCameraController::beginPan | ( | const QPointF & | screenPos | ) |
Start a pan gesture at the given screen position (pixels)
Definition at line 105 of file Viewer3DCameraController.cc.
References screenToGround().
| QVector3D Viewer3DCameraController::cameraPosition | ( | ) | const |
Derived camera position in scene space.
Definition at line 246 of file Viewer3DCameraController.cc.
Referenced by screenToGround().
|
inline |
Definition at line 63 of file Viewer3DCameraController.h.
Referenced by lookAt(), and setDistance().
|
signal |
Referenced by setDistance().
|
inline |
Definition at line 71 of file Viewer3DCameraController.h.
|
signal |
Referenced by setFieldOfView().
|
inline |
Definition at line 55 of file Viewer3DCameraController.h.
Referenced by lookAt(), and setHeading().
|
signal |
Referenced by setHeading().
| void Viewer3DCameraController::lookAt | ( | const QVector3D & | center, |
| qreal | heading, | ||
| qreal | tilt, | ||
| qreal | distance | ||
| ) |
Set the full pose in one call. tilt/distance are clamped.
Definition at line 97 of file Viewer3DCameraController.cc.
References distance(), heading(), setDistance(), setHeading(), setOrbitCenter(), setTilt(), and tilt().
Referenced by reset().
|
inline |
Definition at line 51 of file Viewer3DCameraController.h.
|
signal |
Referenced by setOrbitCenter().
| void Viewer3DCameraController::orbitTo | ( | const QPointF & | screenPos | ) |
Continue an orbit gesture: rotate rigidly about the ground point picked at beginOrbit. Full viewport width of drag = 360 deg yaw, full height = 180 deg tilt (Gazebo behavior).
Definition at line 141 of file Viewer3DCameraController.cc.
| void Viewer3DCameraController::panTo | ( | const QPointF & | screenPos | ) |
Continue a pan gesture: the ground point picked at beginPan stays under the cursor.
Definition at line 114 of file Viewer3DCameraController.cc.
References screenToGround(), and setOrbitCenter().
| void Viewer3DCameraController::reset | ( | ) |
Restore the default pose (center origin, heading 0, tilt 0, default distance)
Definition at line 92 of file Viewer3DCameraController.cc.
References kDefaultDistance, and lookAt().
| void Viewer3DCameraController::rotateBy | ( | qreal | degrees, |
| const QPointF & | screenPos | ||
| ) |
Rotate the camera rigidly by degrees about the ground point under screenPos (positive = counterclockwise heading change). The anchored scene point stays put on screen. Used for two-finger twist gestures.
Definition at line 156 of file Viewer3DCameraController.cc.
References screenToGround().
| qreal Viewer3DCameraController::sceneUnitsPerPixel | ( | ) | const |
Scene units spanned by one horizontal pixel on the ground plane at screen center. Returns 0 when the viewport size is not set.
Definition at line 235 of file Viewer3DCameraController.cc.
| std::optional< QVector3D > Viewer3DCameraController::screenToGround | ( | const QPointF & | screenPos | ) | const |
Intersect the pick ray through screenPos (pixels) with the ground plane z=0. Returns std::nullopt when the ray misses (at/above the horizon) or the viewport is not set.
Definition at line 251 of file Viewer3DCameraController.cc.
References cameraPosition().
Referenced by beginOrbit(), beginPan(), panTo(), rotateBy(), tiltBy(), and zoomBy().
| void Viewer3DCameraController::setDistance | ( | qreal | distance | ) |
Definition at line 64 of file Viewer3DCameraController.cc.
References distance(), distanceChanged(), kMaxDistance, and kMinDistance.
| void Viewer3DCameraController::setFieldOfView | ( | qreal | fov | ) |
Definition at line 83 of file Viewer3DCameraController.cc.
References fieldOfViewChanged().
| void Viewer3DCameraController::setHeading | ( | qreal | heading | ) |
Definition at line 45 of file Viewer3DCameraController.cc.
References heading(), and headingChanged().
Referenced by lookAt().
| void Viewer3DCameraController::setOrbitCenter | ( | const QVector3D & | center | ) |
Definition at line 36 of file Viewer3DCameraController.cc.
References orbitCenterChanged().
| void Viewer3DCameraController::setTilt | ( | qreal | tilt | ) |
Definition at line 54 of file Viewer3DCameraController.cc.
References kMaxTilt, kMinTilt, tilt(), and tiltChanged().
Referenced by lookAt().
| void Viewer3DCameraController::setViewportSize | ( | const QSizeF & | size | ) |
Definition at line 74 of file Viewer3DCameraController.cc.
References viewportSizeChanged().
|
inline |
Definition at line 59 of file Viewer3DCameraController.h.
| void Viewer3DCameraController::tiltBy | ( | qreal | degrees, |
| const QPointF & | screenPos | ||
| ) |
Tilt the camera rigidly by degrees (clamped) about the ground point under screenPos. The anchored scene point stays put on screen. Used for two-finger vertical swipe gestures.
Definition at line 166 of file Viewer3DCameraController.cc.
References screenToGround().
|
signal |
Referenced by setTilt().
|
inline |
Definition at line 67 of file Viewer3DCameraController.h.
|
signal |
Referenced by setViewportSize().
| void Viewer3DCameraController::zoom | ( | qreal | amount, |
| const QPointF & | screenPos | ||
| ) |
Zoom toward/away from the ground point under screenPos. amount is in wheel angleDelta units (positive = zoom in). Distance is clamped.
Definition at line 203 of file Viewer3DCameraController.cc.
References kMaxDistance, kMinDistance, and zoomBy().
| void Viewer3DCameraController::zoomBy | ( | qreal | factor, |
| const QPointF & | screenPos | ||
| ) |
Scale the camera distance by factor (e.g. 0.5 halves the distance), keeping the ground point under screenPos fixed on screen. Used for pinch gestures.
Definition at line 215 of file Viewer3DCameraController.cc.
References kMaxDistance, kMinDistance, screenToGround(), setDistance(), and setOrbitCenter().
Referenced by zoom().
|
friend |
Definition at line 39 of file Viewer3DCameraController.h.
|
staticconstexpr |
Definition at line 48 of file Viewer3DCameraController.h.
Referenced by reset().
|
staticconstexpr |
Definition at line 49 of file Viewer3DCameraController.h.
|
staticconstexpr |
Definition at line 45 of file Viewer3DCameraController.h.
Referenced by setDistance(), zoom(), and zoomBy().
|
staticconstexpr |
Definition at line 47 of file Viewer3DCameraController.h.
Referenced by setTilt().
|
staticconstexpr |
Definition at line 44 of file Viewer3DCameraController.h.
Referenced by setDistance(), zoom(), and zoomBy().
|
staticconstexpr |
Definition at line 46 of file Viewer3DCameraController.h.
Referenced by setTilt().