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>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "common/rectc.h"
|
2018-11-02 20:01:19 +01:00
|
|
|
#include "common/config.h"
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "data/waypoint.h"
|
2019-05-14 23:01:24 +02:00
|
|
|
#include "data/polygon.h"
|
|
|
|
#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"
|
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
|
|
|
|
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;
|
2019-01-31 01:46:53 +01:00
|
|
|
class AreaItem;
|
|
|
|
class Area;
|
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:
|
2017-12-01 00:22:16 +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);
|
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);
|
|
|
|
|
2017-09-09 10:51:19 +02:00
|
|
|
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
|
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);
|
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);
|
2016-12-06 01:48:26 +01:00
|
|
|
|
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);
|
2016-08-09 01:16:19 +02:00
|
|
|
void setPOIOverlap(bool overlap);
|
|
|
|
void showWaypointLabels(bool show);
|
|
|
|
void showPOILabels(bool show);
|
|
|
|
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);
|
2019-02-16 12:39:23 +01:00
|
|
|
void showMarkers(bool show);
|
2019-02-17 20:20:20 +01:00
|
|
|
void showCoordinates(bool show);
|
2019-05-23 08:44:55 +02:00
|
|
|
void showTicks(bool show);
|
2017-10-04 23:15:39 +02:00
|
|
|
void clearMapCache();
|
2018-02-11 20:39:39 +01:00
|
|
|
void setCoordinatesFormat(CoordinatesFormat format);
|
2018-11-17 10:10:35 +01:00
|
|
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
2019-05-14 23:01:24 +02:00
|
|
|
void setProjection(int id);
|
2016-08-09 01:16:19 +02:00
|
|
|
|
2019-06-10 19:12:34 +02:00
|
|
|
void fitContentToSize();
|
|
|
|
|
2016-10-09 23:46:30 +02:00
|
|
|
private slots:
|
|
|
|
void updatePOI();
|
2017-10-04 23:15:39 +02:00
|
|
|
void reloadMap();
|
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);
|
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);
|
2018-05-03 19:11:55 +02:00
|
|
|
void zoom(int zoom, const QPoint &pos);
|
2017-04-05 22:53:25 +02:00
|
|
|
void digitalZoom(int zoom);
|
2016-10-08 14:53:10 +02:00
|
|
|
void updatePOIVisibility();
|
2019-01-31 01:46:53 +01:00
|
|
|
void skipColor() {_palette.nextColor();}
|
2016-02-11 20:58:52 +01:00
|
|
|
|
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);
|
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);
|
2017-01-16 09:54:12 +01:00
|
|
|
void scrollContentsBy(int dx, int dy);
|
2019-02-17 20:20:20 +01:00
|
|
|
void mouseMoveEvent(QMouseEvent *event);
|
|
|
|
void leaveEvent(QEvent *event);
|
2016-02-11 20:58:52 +01:00
|
|
|
|
|
|
|
QGraphicsScene *_scene;
|
2016-10-08 14:53:10 +02:00
|
|
|
ScaleItem *_mapScale;
|
2019-02-17 20:20:20 +01:00
|
|
|
CoordinatesItem *_coordinates;
|
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;
|
2019-01-31 01:46:53 +01:00
|
|
|
QList<AreaItem*> _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;
|
2019-01-31 01:46:53 +01:00
|
|
|
|
2016-03-02 09:34:39 +01:00
|
|
|
Palette _palette;
|
2016-07-25 19:32:36 +02:00
|
|
|
Units _units;
|
2018-02-11 20:39:39 +01:00
|
|
|
CoordinatesFormat _coordinatesFormat;
|
2019-01-31 01:46:53 +01:00
|
|
|
qreal _mapOpacity;
|
2019-05-14 23:01:24 +02:00
|
|
|
Projection _projection;
|
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,
|
2019-05-23 08:44:55 +02:00
|
|
|
_showMarkers, _showPathTicks;
|
2016-08-09 01:16:19 +02:00
|
|
|
bool _overlapPOIs;
|
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;
|
2016-05-19 01:10:40 +02:00
|
|
|
bool _plot;
|
2018-08-18 21:06:36 +02:00
|
|
|
|
|
|
|
#ifdef ENABLE_HIDPI
|
2018-11-17 10:10:35 +01:00
|
|
|
qreal _deviceRatio;
|
|
|
|
qreal _mapRatio;
|
2018-08-18 21:06:36 +02:00
|
|
|
#endif // ENABLE_HIDPI
|
2018-08-23 09:08:59 +02:00
|
|
|
bool _opengl;
|
2016-02-11 20:58:52 +01:00
|
|
|
};
|
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
#endif // MAPVIEW_H
|