2015-11-23 02:33:01 +01:00
|
|
|
#ifndef MAP_H
|
|
|
|
#define MAP_H
|
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QRectF>
|
2018-08-23 20:26:10 +02:00
|
|
|
#include <QFlags>
|
2020-12-13 19:40:09 +01:00
|
|
|
#include "common/rectc.h"
|
2021-01-17 19:33:06 +01:00
|
|
|
#include "common/util.h"
|
2015-11-26 00:21:11 +01:00
|
|
|
|
2019-05-14 23:01:24 +02:00
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
class QPainter;
|
2019-05-14 23:01:24 +02:00
|
|
|
class Projection;
|
2017-02-07 23:36:06 +01:00
|
|
|
|
2015-11-23 02:33:01 +01:00
|
|
|
class Map : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-08-23 20:26:10 +02:00
|
|
|
enum Flag {
|
|
|
|
NoFlags = 0,
|
|
|
|
Block = 1,
|
|
|
|
OpenGL = 2
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(Flags, Flag)
|
|
|
|
|
2020-12-02 23:58:11 +01:00
|
|
|
Map(const QString &path, QObject *parent = 0)
|
|
|
|
: QObject(parent), _path(path) {}
|
2018-03-08 00:57:09 +01:00
|
|
|
virtual ~Map() {}
|
2015-11-23 02:33:01 +01:00
|
|
|
|
2020-12-02 23:58:11 +01:00
|
|
|
const QString &path() const {return _path;}
|
2021-01-17 19:33:06 +01:00
|
|
|
virtual QString name() const {return Util::file2name(path());}
|
2016-04-01 19:25:34 +02:00
|
|
|
|
2020-12-13 19:40:09 +01:00
|
|
|
virtual RectC llBounds();
|
2018-07-13 09:51:41 +02:00
|
|
|
virtual QRectF bounds() = 0;
|
2018-06-30 12:14:58 +02:00
|
|
|
virtual qreal resolution(const QRectF &rect);
|
2015-11-23 02:33:01 +01:00
|
|
|
|
2018-09-10 21:22:57 +02:00
|
|
|
virtual int zoom() const {return 0;}
|
|
|
|
virtual void setZoom(int) {}
|
|
|
|
virtual int zoomFit(const QSize &, const RectC &) {return 0;}
|
|
|
|
virtual int zoomIn() {return 0;}
|
|
|
|
virtual int zoomOut() {return 0;}
|
2015-11-23 02:33:01 +01:00
|
|
|
|
2017-04-30 00:19:53 +02:00
|
|
|
virtual QPointF ll2xy(const Coordinates &c) = 0;
|
|
|
|
virtual Coordinates xy2ll(const QPointF &p) = 0;
|
2016-05-19 01:10:40 +02:00
|
|
|
|
2018-08-23 20:26:10 +02:00
|
|
|
virtual void draw(QPainter *painter, const QRectF &rect, Flags flags) = 0;
|
2016-05-19 01:10:40 +02:00
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
virtual void clearCache() {}
|
|
|
|
virtual void load() {}
|
|
|
|
virtual void unload() {}
|
2018-11-17 10:10:35 +01:00
|
|
|
virtual void setDevicePixelRatio(qreal, qreal) {}
|
2020-12-24 16:33:17 +01:00
|
|
|
virtual void setOutputProjection(const Projection &) {}
|
|
|
|
virtual void setInputProjection(const Projection &) {}
|
2017-02-07 23:36:06 +01:00
|
|
|
|
2018-02-20 23:37:19 +01:00
|
|
|
virtual bool isValid() const {return true;}
|
2020-03-17 21:06:51 +01:00
|
|
|
virtual bool isReady() const {return true;}
|
2018-02-20 23:37:19 +01:00
|
|
|
virtual QString errorString() const {return QString();}
|
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
signals:
|
2020-03-17 21:06:51 +01:00
|
|
|
void tilesLoaded();
|
|
|
|
void mapLoaded();
|
2020-12-02 23:58:11 +01:00
|
|
|
|
|
|
|
private:
|
2020-12-13 19:40:09 +01:00
|
|
|
void growLeft(const QPointF &p, RectC &rect);
|
|
|
|
void growRight(const QPointF &p, RectC &rect);
|
|
|
|
void growTop(const QPointF &p, RectC &rect);
|
|
|
|
void growBottom(const QPointF &p, RectC &rect);
|
|
|
|
|
2020-12-02 23:58:11 +01:00
|
|
|
QString _path;
|
2015-11-23 02:33:01 +01:00
|
|
|
};
|
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
Q_DECLARE_METATYPE(Map*)
|
2018-08-23 20:26:10 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Map::Flags)
|
|
|
|
|
2015-11-23 02:33:01 +01:00
|
|
|
#endif // MAP_H
|