2019-03-02 16:51:14 +01:00
|
|
|
#ifndef RMAP_H
|
|
|
|
#define RMAP_H
|
|
|
|
|
2019-03-03 09:36:57 +01:00
|
|
|
#include <QFile>
|
2019-03-07 22:58:43 +01:00
|
|
|
#include <QColor>
|
2019-03-02 16:51:14 +01:00
|
|
|
#include "map.h"
|
|
|
|
#include "transform.h"
|
|
|
|
#include "projection.h"
|
|
|
|
|
|
|
|
class RMap : public Map
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
RMap(const QString &fileName, QObject *parent = 0);
|
|
|
|
|
|
|
|
QRectF bounds();
|
|
|
|
|
|
|
|
int zoom() const {return _zoom;}
|
|
|
|
void setZoom(int zoom) {_zoom = zoom;}
|
|
|
|
int zoomFit(const QSize &size, const RectC &rect);
|
|
|
|
int zoomIn();
|
|
|
|
int zoomOut();
|
|
|
|
|
|
|
|
QPointF ll2xy(const Coordinates &c);
|
|
|
|
Coordinates xy2ll(const QPointF &p);
|
|
|
|
|
2019-03-03 21:17:57 +01:00
|
|
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
2019-03-02 16:51:14 +01:00
|
|
|
void load();
|
|
|
|
void unload();
|
|
|
|
|
|
|
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
|
|
|
|
|
|
|
bool isValid() const {return _valid;}
|
|
|
|
QString errorString() const {return _errorString;}
|
|
|
|
|
|
|
|
private:
|
2021-07-01 22:18:45 +02:00
|
|
|
struct Header {
|
|
|
|
quint32 type;
|
|
|
|
quint32 width;
|
|
|
|
quint32 height;
|
|
|
|
quint32 bpp;
|
|
|
|
quint32 unknown;
|
|
|
|
quint32 tileWidth;
|
|
|
|
quint32 tileHeight;
|
|
|
|
quint32 paletteSize;
|
|
|
|
quint64 IMPOffset;
|
|
|
|
};
|
|
|
|
|
2019-03-02 16:51:14 +01:00
|
|
|
struct Zoom {
|
|
|
|
QSize size;
|
|
|
|
QSize dim;
|
|
|
|
QPointF scale;
|
|
|
|
QVector<quint64> tiles;
|
|
|
|
};
|
|
|
|
|
2021-07-01 22:18:45 +02:00
|
|
|
bool readHeader(QDataStream &stream, Header &hdr);
|
|
|
|
bool readPalette(QDataStream &stream, quint32 paletteSize);
|
|
|
|
bool readZooms(QDataStream &stream, const QSize &imageSize);
|
|
|
|
bool readZoomLevel(quint64 offset, const QSize &imageSize);
|
|
|
|
QByteArray readIMP(quint64 IMPOffset);
|
2019-03-02 16:51:14 +01:00
|
|
|
bool parseIMP(const QByteArray &data);
|
|
|
|
QPixmap tile(int x, int y);
|
|
|
|
|
|
|
|
QList<Zoom> _zooms;
|
|
|
|
Projection _projection;
|
|
|
|
Transform _transform;
|
|
|
|
QSize _tileSize;
|
|
|
|
QFile _file;
|
2019-03-03 21:17:57 +01:00
|
|
|
qreal _mapRatio;
|
2019-03-02 16:51:14 +01:00
|
|
|
int _zoom;
|
2019-03-07 22:58:43 +01:00
|
|
|
QVector<QRgb> _palette;
|
2019-03-02 16:51:14 +01:00
|
|
|
|
|
|
|
bool _valid;
|
|
|
|
QString _errorString;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RMAP_H
|