2017-12-01 00:22:16 +01:00
|
|
|
#ifndef MAPVIEW_H
|
|
|
|
#define MAPVIEW_H
|
2016-02-11 20:58:52 +01:00
|
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QHash>
|
|
|
|
#include <QList>
|
2020-09-27 00:34:38 +02:00
|
|
|
#include <QFlags>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "common/rectc.h"
|
|
|
|
#include "data/waypoint.h"
|
2019-05-14 23:01:24 +02:00
|
|
|
#include "map/projection.h"
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "searchpointer.h"
|
2016-02-11 20:58:52 +01:00
|
|
|
#include "units.h"
|
2018-02-11 20:39:39 +01:00
|
|
|
#include "format.h"
|
2021-02-12 22:41:38 +01:00
|
|
|
#include "markerinfoitem.h"
|
2016-02-28 09:32:54 +01:00
|
|
|
#include "palette.h"
|
2019-05-14 23:01:24 +02:00
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2021-12-04 15:05:30 +01:00
|
|
|
class QGeoPositionInfoSource;
|
|
|
|
class QGeoPositionInfo;
|
2022-04-28 21:54:00 +02:00
|
|
|
class QGestureEvent;
|
|
|
|
class QPinchGesture;
|
2016-10-23 11:09:20 +02:00
|
|
|
class Data;
|
2016-02-12 10:23:14 +01:00
|
|
|
class POI;
|
2016-02-12 10:09:17 +01:00
|
|
|
class Map;
|
2016-07-28 00:23:22 +02:00
|
|
|
class Track;
|
2016-08-09 01:16:19 +02:00
|
|
|
class Route;
|
2016-07-28 00:23:22 +02:00
|
|
|
class TrackItem;
|
2016-08-09 01:16:19 +02:00
|
|
|
class RouteItem;
|
2016-02-19 21:42:54 +01:00
|
|
|
class WaypointItem;
|
2016-02-11 20:58:52 +01:00
|
|
|
class ScaleItem;
|
2019-02-17 20:20:20 +01:00
|
|
|
class CoordinatesItem;
|
2016-09-19 00:56:10 +02:00
|
|
|
class PathItem;
|
2018-05-04 19:36:37 +02:00
|
|
|
class GraphItem;
|
2020-12-02 23:58:11 +01:00
|
|
|
class PlaneItem;
|
|
|
|
class MapItem;
|
2019-01-31 01:46:53 +01:00
|
|
|
class Area;
|
2019-10-15 23:59:15 +02:00
|
|
|
class GraphicsScene;
|
2020-05-20 21:00:36 +02:00
|
|
|
class QTimeZone;
|
2020-12-09 23:07:05 +01:00
|
|
|
class MapAction;
|
2021-12-04 15:05:30 +01:00
|
|
|
class CrosshairItem;
|
|
|
|
class MotionInfoItem;
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
class MapView : public QGraphicsView
|
2016-02-11 20:58:52 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-09-27 00:34:38 +02:00
|
|
|
enum Flag {
|
|
|
|
NoFlags = 0,
|
|
|
|
HiRes = 1,
|
|
|
|
Expand = 2
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(PlotFlags, Flag)
|
|
|
|
|
2023-02-04 23:59:47 +01:00
|
|
|
MapView(Map *map, POI *poi, QWidget *parent = 0);
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2018-05-04 19:36:37 +02:00
|
|
|
QList<PathItem *> loadData(const Data &data);
|
2020-12-09 23:07:05 +01:00
|
|
|
void loadMaps(const QList<MapAction*> &maps);
|
2021-09-23 22:44:21 +02:00
|
|
|
void loadDEMs(const QList<Area> &dems);
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2016-12-06 01:48:26 +01:00
|
|
|
void setPalette(const Palette &palette);
|
2016-10-08 14:53:10 +02:00
|
|
|
void setPOI(POI *poi);
|
2016-02-11 20:58:52 +01:00
|
|
|
void setMap(Map *map);
|
2021-12-04 15:05:30 +01:00
|
|
|
void setPositionSource(QGeoPositionInfoSource *source);
|
2021-01-17 16:02:37 +01:00
|
|
|
void setGraph(int index);
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
void plot(QPainter *painter, const QRectF &target, qreal scale,
|
|
|
|
PlotFlags flags);
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2016-10-08 14:53:10 +02:00
|
|
|
void clear();
|
|
|
|
|
2018-02-11 20:39:39 +01:00
|
|
|
void setUnits(Units units);
|
|
|
|
void setMarkerColor(const QColor &color);
|
2021-12-04 15:05:30 +01:00
|
|
|
void setCrosshairColor(const QColor &color);
|
|
|
|
void setInfoColor(const QColor &color);
|
|
|
|
void drawInfoBackground(bool draw);
|
2017-09-15 00:07:09 +02:00
|
|
|
void setTrackWidth(int width);
|
|
|
|
void setRouteWidth(int width);
|
2019-01-31 01:46:53 +01:00
|
|
|
void setAreaWidth(int width);
|
2017-09-15 00:07:09 +02:00
|
|
|
void setTrackStyle(Qt::PenStyle style);
|
|
|
|
void setRouteStyle(Qt::PenStyle style);
|
2019-01-31 01:46:53 +01:00
|
|
|
void setAreaStyle(Qt::PenStyle style);
|
|
|
|
void setAreaOpacity(int opacity);
|
2017-09-15 00:07:09 +02:00
|
|
|
void setWaypointSize(int size);
|
|
|
|
void setWaypointColor(const QColor &color);
|
|
|
|
void setPOISize(int size);
|
|
|
|
void setPOIColor(const QColor &color);
|
|
|
|
void setMapOpacity(int opacity);
|
|
|
|
void setBackgroundColor(const QColor &color);
|
2016-12-06 01:48:26 +01:00
|
|
|
void useOpenGL(bool use);
|
2017-09-15 00:07:09 +02:00
|
|
|
void useAntiAliasing(bool use);
|
2021-01-17 16:02:37 +01:00
|
|
|
void setCoordinatesFormat(CoordinatesFormat format);
|
|
|
|
void setTimeZone(const QTimeZone &zone);
|
2023-05-04 09:38:35 +02:00
|
|
|
void setMapConfig(const Projection &in, const Projection &out, bool hidpi);
|
|
|
|
void setDevicePixelRatio(qreal ratio);
|
2021-01-17 16:02:37 +01:00
|
|
|
void clearMapCache();
|
|
|
|
void fitContentToSize();
|
2016-12-06 01:48:26 +01:00
|
|
|
|
2021-09-01 13:08:34 +02:00
|
|
|
RectC boundingRect() const;
|
2021-08-30 20:31:33 +02:00
|
|
|
|
2022-05-28 14:05:14 +02:00
|
|
|
#ifdef Q_OS_ANDROID
|
|
|
|
signals:
|
|
|
|
void clicked(const QPoint &pos);
|
|
|
|
#endif // Q_OS_ANDROID
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
public slots:
|
2017-03-18 01:30:31 +01:00
|
|
|
void showMap(bool show);
|
2016-10-08 14:53:10 +02:00
|
|
|
void showPOI(bool show);
|
2021-12-04 15:05:30 +01:00
|
|
|
void showPosition(bool show);
|
2016-08-09 01:16:19 +02:00
|
|
|
void showPOILabels(bool show);
|
2021-10-10 08:38:38 +02:00
|
|
|
void showPOIIcons(bool show);
|
2021-12-04 15:05:30 +01:00
|
|
|
void showCursorCoordinates(bool show);
|
|
|
|
void showPositionCoordinates(bool show);
|
2021-01-17 16:02:37 +01:00
|
|
|
void showTicks(bool show);
|
|
|
|
void showMarkers(bool show);
|
2021-02-12 22:41:38 +01:00
|
|
|
void showMarkerInfo(MarkerInfoItem::Type type);
|
2021-01-17 16:02:37 +01:00
|
|
|
void showOverlappedPOIs(bool show);
|
|
|
|
void showWaypointLabels(bool show);
|
2021-10-10 08:38:38 +02:00
|
|
|
void showWaypointIcons(bool show);
|
2016-08-09 01:16:19 +02:00
|
|
|
void showTracks(bool show);
|
|
|
|
void showRoutes(bool show);
|
2019-01-31 01:46:53 +01:00
|
|
|
void showAreas(bool show);
|
2016-08-09 01:16:19 +02:00
|
|
|
void showWaypoints(bool show);
|
2016-08-09 10:47:49 +02:00
|
|
|
void showRouteWaypoints(bool show);
|
2021-01-17 16:02:37 +01:00
|
|
|
void setMarkerPosition(qreal pos);
|
2021-12-04 15:05:30 +01:00
|
|
|
void followPosition(bool follow);
|
|
|
|
void showMotionInfo(bool show);
|
2022-09-25 02:15:24 +02:00
|
|
|
void useStyles(bool use);
|
2019-06-10 19:12:34 +02:00
|
|
|
|
2016-10-09 23:46:30 +02:00
|
|
|
private slots:
|
|
|
|
void updatePOI();
|
2017-10-04 23:15:39 +02:00
|
|
|
void reloadMap();
|
2021-12-04 15:05:30 +01:00
|
|
|
void updatePosition(const QGeoPositionInfo &pos);
|
2016-10-09 23:46:30 +02:00
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
private:
|
2019-08-01 08:36:58 +02:00
|
|
|
typedef QHash<SearchPointer<Waypoint>, WaypointItem*> POIHash;
|
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
PathItem *addTrack(const Track &track);
|
|
|
|
PathItem *addRoute(const Route &route);
|
2020-12-10 22:02:09 +01:00
|
|
|
MapItem *addMap(MapAction *map);
|
2019-01-31 01:46:53 +01:00
|
|
|
void addArea(const Area &area);
|
2019-01-18 00:17:28 +01:00
|
|
|
void addWaypoints(const QVector<Waypoint> &waypoints);
|
2017-11-26 18:54:03 +01:00
|
|
|
void addPOI(const QList<Waypoint> &waypoints);
|
2016-10-08 14:53:10 +02:00
|
|
|
void loadPOI();
|
|
|
|
void clearPOI();
|
2016-03-15 01:20:24 +01:00
|
|
|
|
2018-03-30 10:25:05 +02:00
|
|
|
int fitMapZoom() const;
|
2017-03-18 01:30:31 +01:00
|
|
|
QPointF contentCenter() const;
|
|
|
|
void rescale();
|
2017-09-17 14:10:37 +02:00
|
|
|
void centerOn(const QPointF &pos);
|
2020-12-29 18:36:23 +01:00
|
|
|
void zoom(int zoom, const QPoint &pos, bool shift);
|
2017-04-05 22:53:25 +02:00
|
|
|
void digitalZoom(int zoom);
|
2016-10-08 14:53:10 +02:00
|
|
|
void updatePOIVisibility();
|
2022-04-28 21:54:00 +02:00
|
|
|
bool gestureEvent(QGestureEvent *event);
|
|
|
|
void pinchGesture(QPinchGesture *gesture);
|
2019-01-31 01:46:53 +01:00
|
|
|
void skipColor() {_palette.nextColor();}
|
2023-05-04 09:38:35 +02:00
|
|
|
void setHidpi(bool hidpi);
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2020-11-13 20:15:17 +01:00
|
|
|
void mouseMoveEvent(QMouseEvent *event);
|
|
|
|
void mousePressEvent(QMouseEvent *event);
|
2016-10-29 21:22:26 +02:00
|
|
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
2016-02-11 20:58:52 +01:00
|
|
|
void wheelEvent(QWheelEvent *event);
|
2016-07-21 22:39:53 +02:00
|
|
|
void keyPressEvent(QKeyEvent *event);
|
2020-11-13 20:15:17 +01:00
|
|
|
void keyReleaseEvent(QKeyEvent *event);
|
2016-02-11 20:58:52 +01:00
|
|
|
void drawBackground(QPainter *painter, const QRectF &rect);
|
2016-10-29 21:22:26 +02:00
|
|
|
void paintEvent(QPaintEvent *event);
|
2019-02-17 20:20:20 +01:00
|
|
|
void leaveEvent(QEvent *event);
|
2022-05-28 14:05:14 +02:00
|
|
|
|
2022-04-28 21:54:00 +02:00
|
|
|
bool event(QEvent *event);
|
|
|
|
void scrollContentsBy(int dx, int dy);
|
2016-02-11 20:58:52 +01:00
|
|
|
|
2019-10-15 23:59:15 +02:00
|
|
|
GraphicsScene *_scene;
|
2016-10-08 14:53:10 +02:00
|
|
|
ScaleItem *_mapScale;
|
2021-12-04 15:05:30 +01:00
|
|
|
CoordinatesItem *_cursorCoordinates, *_positionCoordinates;
|
|
|
|
CrosshairItem *_crosshair;
|
|
|
|
MotionInfoItem *_motionInfo;
|
2016-08-09 01:16:19 +02:00
|
|
|
QList<TrackItem*> _tracks;
|
|
|
|
QList<RouteItem*> _routes;
|
2016-07-28 00:23:22 +02:00
|
|
|
QList<WaypointItem*> _waypoints;
|
2020-12-02 23:58:11 +01:00
|
|
|
QList<PlaneItem*> _areas;
|
2019-08-01 08:36:58 +02:00
|
|
|
POIHash _pois;
|
2016-03-17 20:56:40 +01:00
|
|
|
|
2019-01-31 01:46:53 +01:00
|
|
|
RectC _tr, _rr, _wr, _ar;
|
2017-01-16 09:54:12 +01:00
|
|
|
qreal _res;
|
2016-11-11 17:58:18 +01:00
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
Map *_map;
|
2016-10-08 14:53:10 +02:00
|
|
|
POI *_poi;
|
2021-12-04 15:05:30 +01:00
|
|
|
QGeoPositionInfoSource *_positionSource;
|
2019-01-31 01:46:53 +01:00
|
|
|
|
2016-03-02 09:34:39 +01:00
|
|
|
Palette _palette;
|
2019-01-31 01:46:53 +01:00
|
|
|
qreal _mapOpacity;
|
2020-12-24 16:33:17 +01:00
|
|
|
Projection _outputProjection, _inputProjection;
|
2017-09-10 12:42:49 +02:00
|
|
|
|
2019-01-31 01:46:53 +01:00
|
|
|
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
2019-02-16 12:39:23 +01:00
|
|
|
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
2021-12-04 15:05:30 +01:00
|
|
|
_showMarkers, _showPathTicks, _showPOIIcons, _showWaypointIcons,
|
|
|
|
_showPosition, _showPositionCoordinates, _showMotionInfo;
|
2021-02-12 22:41:38 +01:00
|
|
|
MarkerInfoItem::Type _markerInfoType;
|
2021-12-04 15:05:30 +01:00
|
|
|
bool _overlapPOIs, _followPosition;
|
2019-01-31 01:46:53 +01:00
|
|
|
int _trackWidth, _routeWidth, _areaWidth;
|
|
|
|
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
|
|
|
int _waypointSize, _poiSize;
|
|
|
|
QColor _backgroundColor, _waypointColor, _poiColor, _markerColor;
|
|
|
|
qreal _areaOpacity;
|
2023-08-19 11:01:12 +02:00
|
|
|
bool _infoBackground;
|
2016-08-09 01:16:19 +02:00
|
|
|
|
2017-04-05 22:53:25 +02:00
|
|
|
int _digitalZoom;
|
2016-05-19 01:10:40 +02:00
|
|
|
bool _plot;
|
2020-11-13 20:15:17 +01:00
|
|
|
QCursor _cursor;
|
2018-08-18 21:06:36 +02:00
|
|
|
|
2018-11-17 10:10:35 +01:00
|
|
|
qreal _deviceRatio;
|
2023-05-04 09:38:35 +02:00
|
|
|
bool _hidpi;
|
2018-08-23 09:08:59 +02:00
|
|
|
bool _opengl;
|
2022-04-28 21:54:00 +02:00
|
|
|
|
|
|
|
int _pinchZoom;
|
|
|
|
int _wheelDelta;
|
2016-02-11 20:58:52 +01:00
|
|
|
};
|
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
#endif // MAPVIEW_H
|