12#include <QtCore/QVariant>
30 if (_displayMode == mode) {
41 qCDebug(Viewer3DManagerLog) <<
"Display mode changed to" << (mode ==
DisplayMode::View3D ?
"View3D" :
"Map");
45void Viewer3DManager::_onActiveVehicleChanged(
Vehicle *vehicle)
51 _activeVehicle = vehicle;
52 if (!_activeVehicle) {
53 if (_gpsRefSource == GpsRefSource::Vehicle) {
54 _gpsRefSource = GpsRefSource::None;
55 _gpsRef = QGeoCoordinate();
59 _onActiveVehicleCoordinateChanged(_activeVehicle->
coordinate());
63 _updateVehicleOutsideMapRegion();
66void Viewer3DManager::_onActiveVehicleCoordinateChanged(
const QGeoCoordinate &newCoordinate)
68 if (_gpsRefSource == GpsRefSource::None) {
69 if (newCoordinate.isValid()) {
70 _gpsRef = newCoordinate;
71 _gpsRef.setAltitude(0);
72 _gpsRefSource = GpsRefSource::Vehicle;
75 qCDebug(Viewer3DManagerLog) <<
"GPS ref set by vehicle:" << _gpsRef.latitude() << _gpsRef.longitude() << _gpsRef.altitude();
79 _updateVehicleOutsideMapRegion();
82void Viewer3DManager::_onGpsRefChanged(
const QGeoCoordinate &newGpsRef,
bool isRefSet)
86 _gpsRefSource = GpsRefSource::Map;
88 qCDebug(Viewer3DManagerLog) <<
"GPS ref set by map provider:" << _gpsRef.latitude() << _gpsRef.longitude() << _gpsRef.altitude();
90 if (_gpsRefSource != GpsRefSource::Map) {
94 _gpsRefSource = GpsRefSource::None;
95 if (_activeVehicle && _activeVehicle->
coordinate().isValid()) {
97 _gpsRef.setAltitude(0);
98 _gpsRefSource = GpsRefSource::Vehicle;
100 _gpsRef = QGeoCoordinate();
106void Viewer3DManager::_onEnabledChanged(
const QVariant &value)
108 if (!value.toBool()) {
115 if (!coordinate.isValid() || !bbMin.isValid() || !bbMax.isValid()) {
119 return (coordinate.latitude() >= bbMin.latitude()) && (coordinate.latitude() <= bbMax.latitude())
120 && (coordinate.longitude() >= bbMin.longitude()) && (coordinate.longitude() <= bbMax.longitude());
123void Viewer3DManager::_updateVehicleOutsideMapRegion()
125 bool outside =
false;
127 if (_mapProvider && _mapProvider->
mapLoaded() && _activeVehicle && _activeVehicle->
coordinate().isValid()) {
132 if (outside != _vehicleOutsideMapRegion) {
133 _vehicleOutsideMapRegion = outside;
137 qCWarning(Viewer3DManagerLog) <<
"Vehicle is outside the loaded OSM map region";
#define QGC_LOGGING_CATEGORY(name, categoryStr)
void rawValueChanged(const QVariant &value)
static MultiVehicleManager * instance()
void activeVehicleChanged(Vehicle *activeVehicle)
static SettingsManager * instance()
void coordinateChanged(QGeoCoordinate coordinate)
QGeoCoordinate coordinate()
static bool coordinateWithinRegion(const QGeoCoordinate &coordinate, const QGeoCoordinate &bbMin, const QGeoCoordinate &bbMax)
Returns true if the coordinate lies within the lat/lon bounding box. Invalid inputs return false.
void vehicleOutsideMapRegionChanged()
void displayModeChanged()
Q_INVOKABLE void setDisplayMode(DisplayMode mode)
virtual std::pair< QGeoCoordinate, QGeoCoordinate > mapBoundingBox() const =0
virtual bool mapLoaded() const =0
void gpsRefChanged(QGeoCoordinate newGpsRef, bool isRefSet)