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

149 lines
3.3 KiB
C
Raw Normal View History

#ifndef MAPVIEW_H
#define MAPVIEW_H
#include <QGraphicsView>
#include <QVector>
#include <QHash>
#include <QList>
2017-11-26 18:54:03 +01:00
#include "common/rectc.h"
#include "data/waypoint.h"
#include "searchpointer.h"
#include "units.h"
#include "format.h"
2016-02-28 09:32:54 +01:00
#include "palette.h"
2018-08-18 21:06:36 +02:00
#include "config.h"
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;
2016-09-19 00:56:10 +02:00
class PathItem;
class GraphItem;
class MapView : public QGraphicsView
{
Q_OBJECT
public:
MapView(Map *map, POI *poi, QWidget *parent = 0);
QList<PathItem *> loadData(const Data &data);
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);
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
2016-10-08 14:53:10 +02:00
void clear();
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);
void setTrackStyle(Qt::PenStyle style);
void setRouteStyle(Qt::PenStyle style);
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
public slots:
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);
void showWaypoints(bool show);
2016-08-09 10:47:49 +02:00
void showRouteWaypoints(bool show);
2017-10-04 23:15:39 +02:00
void clearMapCache();
void setCoordinatesFormat(CoordinatesFormat format);
2018-08-18 21:06:36 +02:00
void updateDevicePixelRatio();
2016-08-09 01:16:19 +02:00
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
private:
2016-09-19 00:56:10 +02:00
PathItem *addTrack(const Track &track);
PathItem *addRoute(const Route &route);
2016-03-15 01:20:24 +01:00
void addWaypoints(const QList<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);
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();
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
void drawBackground(QPainter *painter, const QRectF &rect);
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event);
2017-01-16 09:54:12 +01:00
void scrollContentsBy(int dx, int dy);
QGraphicsScene *_scene;
2016-10-08 14:53:10 +02:00
ScaleItem *_mapScale;
2016-08-09 01:16:19 +02:00
QList<TrackItem*> _tracks;
QList<RouteItem*> _routes;
QList<WaypointItem*> _waypoints;
QHash<SearchPointer<Waypoint>, WaypointItem*> _pois;
RectC _tr, _rr, _wr;
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;
2016-03-02 09:34:39 +01:00
Palette _palette;
2016-07-25 19:32:36 +02:00
Units _units;
CoordinatesFormat _coordinatesFormat;
qreal _opacity;
2017-09-15 00:07:09 +02:00
QColor _backgroundColor;
bool _showMap;
2016-08-09 01:16:19 +02:00
bool _showTracks;
bool _showRoutes;
bool _showWaypoints;
bool _showWaypointLabels;
2016-10-08 14:53:10 +02:00
bool _showPOI;
2016-08-09 01:16:19 +02:00
bool _showPOILabels;
bool _overlapPOIs;
2016-08-09 10:47:49 +02:00
bool _showRouteWaypoints;
2016-12-06 01:48:26 +01:00
int _trackWidth;
int _routeWidth;
Qt::PenStyle _trackStyle;
Qt::PenStyle _routeStyle;
int _waypointSize;
int _poiSize;
QColor _waypointColor;
QColor _poiColor;
2017-12-03 00:36:52 +01:00
QColor _markerColor;
2016-08-09 01:16:19 +02:00
2017-04-05 22:53:25 +02:00
int _digitalZoom;
bool _plot;
2018-08-18 21:06:36 +02:00
#ifdef ENABLE_HIDPI
qreal _ratio;
#endif // ENABLE_HIDPI
bool _opengl;
};
#endif // MAPVIEW_H