Added zooming on double clicks
[GPXSee.git] / src / pathview.h
blob062e2b357f0257763047ad0f3ada92f1319f1bec
1 #ifndef TRACKVIEW_H
2 #define TRACKVIEW_H
4 #include <QGraphicsView>
5 #include <QVector>
6 #include <QHash>
7 #include <QList>
8 #include "units.h"
9 #include "palette.h"
10 #include "waypoint.h"
12 class Data;
13 class POI;
14 class Map;
15 class Track;
16 class Route;
17 class TrackItem;
18 class RouteItem;
19 class WaypointItem;
20 class ScaleItem;
21 class PathItem;
23 class PathView : public QGraphicsView
25 Q_OBJECT
27 public:
28 PathView(QWidget *parent = 0);
29 ~PathView();
31 QList<PathItem*> loadData(const Data &data);
33 void setPOI(POI *poi);
34 void setMap(Map *map);
35 void setUnits(enum Units units);
37 void plot(QPainter *painter, const QRectF &target);
39 int trackCount() const {return _tracks.count();}
40 int routeCount() const {return _routes.count();}
41 int waypointCount() const {return _waypoints.count();}
43 void clear();
45 public slots:
46 void redraw();
48 void showPOI(bool show);
49 void setPOIOverlap(bool overlap);
50 void showWaypointLabels(bool show);
51 void showPOILabels(bool show);
52 void showTracks(bool show);
53 void showRoutes(bool show);
54 void showWaypoints(bool show);
55 void showRouteWaypoints(bool show);
57 private slots:
58 void updatePOI();
60 private:
61 PathItem *addTrack(const Track &track);
62 PathItem *addRoute(const Route &route);
63 void addWaypoints(const QList<Waypoint> &waypoints);
64 void addPOI(const QVector<Waypoint> &waypoints);
65 void loadPOI();
66 void clearPOI();
68 QRectF trackBoundingRect() const;
69 QRectF routeBoundingRect() const;
70 QRectF waypointBoundingRect() const;
71 qreal trackScale() const;
72 qreal routeScale() const;
73 qreal waypointScale() const;
74 qreal mapScale(int zoom) const;
75 void rescale(qreal scale);
76 void rescale();
77 void zoom(int z, const QPoint &pos);
78 void updatePOIVisibility();
80 void mouseDoubleClickEvent(QMouseEvent *event);
81 void wheelEvent(QWheelEvent *event);
82 void keyPressEvent(QKeyEvent *event);
83 void drawBackground(QPainter *painter, const QRectF &rect);
84 void resizeEvent(QResizeEvent *event);
85 void paintEvent(QPaintEvent *event);
87 QGraphicsScene *_scene;
88 ScaleItem *_mapScale;
89 QList<TrackItem*> _tracks;
90 QList<RouteItem*> _routes;
91 QList<WaypointItem*> _waypoints;
92 QHash<Waypoint, WaypointItem*> _pois;
94 Map *_map;
95 POI *_poi;
97 Palette _palette;
99 qreal _scale;
100 int _zoom;
102 Units _units;
104 bool _showTracks;
105 bool _showRoutes;
106 bool _showWaypoints;
107 bool _showWaypointLabels;
108 bool _showPOI;
109 bool _showPOILabels;
110 bool _overlapPOIs;
111 bool _showRouteWaypoints;
113 bool _plot;
116 #endif // TRACKVIEW_H