1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 23:03:22 +02:00
GPXSee/src/GUI/mapview.h

220 lines
5.6 KiB
C
Raw Normal View History

#ifndef MAPVIEW_H
#define MAPVIEW_H
#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"
#include "map/projection.h"
2017-11-26 18:54:03 +01:00
#include "searchpointer.h"
#include "units.h"
#include "format.h"
#include "markerinfoitem.h"
2016-02-28 09:32:54 +01:00
#include "palette.h"
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;
class Track;
2016-08-09 01:16:19 +02:00
class Route;
class TrackItem;
2016-08-09 01:16:19 +02:00
class RouteItem;
2016-02-19 21:42:54 +01:00
class WaypointItem;
class ScaleItem;
class CoordinatesItem;
2016-09-19 00:56:10 +02:00
class PathItem;
class GraphItem;
2020-12-02 23:58:11 +01:00
class PlaneItem;
class MapItem;
2019-01-31 01:46:53 +01:00
class Area;
class GraphicsScene;
2020-05-20 21:00:36 +02:00
class QTimeZone;
class MapAction;
2021-12-04 15:05:30 +01:00
class CrosshairItem;
class MotionInfoItem;
class MapView : public QGraphicsView
{
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);
QList<PathItem *> loadData(const Data &data);
void loadMaps(const QList<MapAction*> &maps);
2021-09-23 22:44:21 +02:00
void loadDEMs(const QList<Area> &dems);
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);
void setMap(Map *map);
2021-12-04 15:05:30 +01:00
void setPositionSource(QGeoPositionInfoSource *source);
void setGraph(int index);
2020-09-27 00:34:38 +02:00
void plot(QPainter *painter, const QRectF &target, qreal scale,
PlotFlags flags);
2016-10-08 14:53:10 +02:00
void clear();
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);
void setCoordinatesFormat(CoordinatesFormat format);
void setTimeZone(const QTimeZone &zone);
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
2021-06-17 21:58:25 +02:00
void setOutputProjection(const Projection &proj);
void setInputProjection(const Projection &proj);
void clearMapCache();
void fitContentToSize();
2016-12-06 01:48:26 +01:00
2021-09-01 13:08:34 +02:00
RectC boundingRect() const;
2022-05-28 14:05:14 +02:00
#ifdef Q_OS_ANDROID
signals:
void clicked(const QPoint &pos);
#endif // Q_OS_ANDROID
public slots:
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);
void showTicks(bool show);
void showMarkers(bool show);
void showMarkerInfo(MarkerInfoItem::Type type);
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);
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);
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
private:
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
int fitMapZoom() const;
QPointF contentCenter() const;
void rescale();
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();}
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void drawBackground(QPainter *painter, const QRectF &rect);
void paintEvent(QPaintEvent *event);
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);
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;
QList<WaypointItem*> _waypoints;
2020-12-02 23:58:11 +01:00
QList<PlaneItem*> _areas;
POIHash _pois;
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
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;
Projection _outputProjection, _inputProjection;
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;
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;
2016-08-09 01:16:19 +02:00
2017-04-05 22:53:25 +02:00
int _digitalZoom;
bool _plot;
QCursor _cursor;
2018-08-18 21:06:36 +02:00
qreal _deviceRatio;
qreal _mapRatio;
bool _opengl;
2022-04-28 21:54:00 +02:00
int _pinchZoom;
int _wheelDelta;
};
#endif // MAPVIEW_H