Code cleanup
[GPXSee.git] / src / map / ozimap.h
blobcf03d48064ec1e71cb3f4d8d9f78e60128ef00e6
1 #ifndef OZIMAP_H
2 #define OZIMAP_H
4 #include "transform.h"
5 #include "projection.h"
6 #include "map.h"
8 class Tar;
9 class OZF;
10 class Image;
12 class OziMap : public Map
14 Q_OBJECT
16 public:
17 OziMap(const QString &fileName, QObject *parent = 0);
18 OziMap(const QString &fileName, Tar &tar, QObject *parent = 0);
19 ~OziMap();
21 QString name() const {return _name;}
23 QRectF bounds();
25 int zoom() const {return _zoom;}
26 void setZoom(int zoom) {_zoom = zoom;}
27 int zoomFit(const QSize &size, const RectC &rect);
28 int zoomIn();
29 int zoomOut();
31 QPointF ll2xy(const Coordinates &c);
32 Coordinates xy2ll(const QPointF &p);
34 void draw(QPainter *painter, const QRectF &rect, Flags flags);
36 void setDevicePixelRatio(qreal ratio);
37 void load();
38 void unload();
40 bool isValid() const {return _valid;}
41 QString errorString() const {return _errorString;}
43 PointD ll2pp(const Coordinates &c) const
44 {return _projection.ll2xy(c);}
45 PointD xy2pp(const QPointF &p) const
46 {return _transform.img2proj(p * _ratio);}
47 QPointF pp2xy(const PointD &p) const
48 {return _transform.proj2img(p) / _ratio;}
50 private:
51 struct ImageInfo {
52 QSize size;
53 QString path;
55 bool isValid() const {return size.isValid() && !path.isEmpty();}
58 bool setTileInfo(const QStringList &tiles, const QString &path = QString());
59 bool setImageInfo(const QString &path);
61 void drawTiled(QPainter *painter, const QRectF &rect) const;
62 void drawOZF(QPainter *painter, const QRectF &rect) const;
63 void drawImage(QPainter *painter, const QRectF &rect, Flags flags) const;
65 void rescale(int zoom);
67 QString _name;
68 Projection _projection;
69 Transform _transform;
70 Image *_img;
71 Tar *_tar;
72 OZF *_ozf;
73 ImageInfo _map, _tile;
74 int _zoom;
75 QPointF _scale;
76 qreal _ratio;
78 bool _valid;
79 QString _errorString;
82 #endif // OZIMAP_H