mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-28 12:09:15 +02:00
Added support for Mapsforge maps
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "bitstream.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
bool BitStream1::flush()
|
||||
{
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef BITSTREAM_H
|
||||
#define BITSTREAM_H
|
||||
#ifndef IMG_BITSTREAM_H
|
||||
#define IMG_BITSTREAM_H
|
||||
|
||||
#include "subfile.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class BitStream1 {
|
||||
public:
|
||||
BitStream1(const SubFile &file, SubFile::Handle &hdl, quint32 length)
|
||||
@ -128,4 +130,6 @@ bool BitStream4R::read(int bits, T &val)
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // BITSTREAM_H
|
||||
}
|
||||
|
||||
#endif // IMG_BITSTREAM_H
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "deltastream.h"
|
||||
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
static int bitSize(quint8 baseSize, bool variableSign, bool extraBit)
|
||||
{
|
||||
int bits = 2;
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef DELTASTREAM_H
|
||||
#define DELTASTREAM_H
|
||||
#ifndef IMG_DELTASTREAM_H
|
||||
#define IMG_DELTASTREAM_H
|
||||
|
||||
#include "bitstream.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class DeltaStream : public BitStream1 {
|
||||
public:
|
||||
DeltaStream(const SubFile &file, SubFile::Handle &hdl, quint32 length,
|
||||
@ -25,4 +27,6 @@ private:
|
||||
quint32 _lonBits, _latBits, _readBits;
|
||||
};
|
||||
|
||||
#endif // DELTASTREAM_H
|
||||
}
|
||||
|
||||
#endif // IMG_DELTASTREAM_H
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include <QDir>
|
||||
#include "vectortile.h"
|
||||
#include "gmap.h"
|
||||
#include "gmapdata.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
static SubFile::Type tileType(const QString &suffix)
|
||||
{
|
||||
@ -22,7 +23,7 @@ static SubFile::Type tileType(const QString &suffix)
|
||||
return SubFile::Unknown;
|
||||
}
|
||||
|
||||
void GMAP::subProduct(QXmlStreamReader &reader, QString &dataDir,
|
||||
void GMAPData::subProduct(QXmlStreamReader &reader, QString &dataDir,
|
||||
QString &baseMap)
|
||||
{
|
||||
while (reader.readNextStartElement()) {
|
||||
@ -35,7 +36,7 @@ void GMAP::subProduct(QXmlStreamReader &reader, QString &dataDir,
|
||||
}
|
||||
}
|
||||
|
||||
void GMAP::mapProduct(QXmlStreamReader &reader, QString &dataDir,
|
||||
void GMAPData::mapProduct(QXmlStreamReader &reader, QString &dataDir,
|
||||
QString &typFile, QString &baseMap)
|
||||
{
|
||||
while (reader.readNextStartElement()) {
|
||||
@ -50,7 +51,7 @@ void GMAP::mapProduct(QXmlStreamReader &reader, QString &dataDir,
|
||||
}
|
||||
}
|
||||
|
||||
bool GMAP::readXML(const QString &path, QString &dataDir, QString &typFile,
|
||||
bool GMAPData::readXML(const QString &path, QString &dataDir, QString &typFile,
|
||||
QString &baseMap)
|
||||
{
|
||||
QFile file(path);
|
||||
@ -74,7 +75,7 @@ bool GMAP::readXML(const QString &path, QString &dataDir, QString &typFile,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GMAP::loadTile(const QDir &dir, bool baseMap)
|
||||
bool GMAPData::loadTile(const QDir &dir, bool baseMap)
|
||||
{
|
||||
VectorTile *tile = new VectorTile();
|
||||
|
||||
@ -110,7 +111,7 @@ bool GMAP::loadTile(const QDir &dir, bool baseMap)
|
||||
return true;
|
||||
}
|
||||
|
||||
GMAP::GMAP(const QString &fileName) : _fileName(fileName)
|
||||
GMAPData::GMAPData(const QString &fileName) : _fileName(fileName)
|
||||
{
|
||||
QString dataDirPath, typFilePath, baseMapPath;
|
||||
if (!readXML(fileName, dataDirPath, typFilePath, baseMapPath))
|
||||
@ -146,12 +147,12 @@ GMAP::GMAP(const QString &fileName) : _fileName(fileName)
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
GMAP::~GMAP()
|
||||
GMAPData::~GMAPData()
|
||||
{
|
||||
qDeleteAll(_files);
|
||||
}
|
||||
|
||||
bool GMAP::isGMAP(const QString &path)
|
||||
bool GMAPData::isGMAP(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
|
@ -1,16 +1,18 @@
|
||||
#ifndef GMAP_H
|
||||
#define GMAP_H
|
||||
#ifndef IMG_GMAP_H
|
||||
#define IMG_GMAP_H
|
||||
|
||||
#include "mapdata.h"
|
||||
|
||||
class QXmlStreamReader;
|
||||
class QDir;
|
||||
|
||||
class GMAP : public MapData
|
||||
namespace IMG {
|
||||
|
||||
class GMAPData : public MapData
|
||||
{
|
||||
public:
|
||||
GMAP(const QString &fileName);
|
||||
~GMAP();
|
||||
GMAPData(const QString &fileName);
|
||||
~GMAPData();
|
||||
|
||||
const QString &fileName() const {return _fileName;}
|
||||
|
||||
@ -29,4 +31,6 @@ private:
|
||||
QList<const QString*> _files;
|
||||
};
|
||||
|
||||
#endif // GMAP_H
|
||||
}
|
||||
|
||||
#endif // IMG_GMAP_H
|
@ -1,6 +1,8 @@
|
||||
#include "rgnfile.h"
|
||||
#include "huffmanbuffer.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
bool HuffmanBuffer::load(const RGNFile *rgn, SubFile::Handle &rgnHdl)
|
||||
{
|
||||
quint32 recordSize, recordOffset = rgn->dictOffset();
|
||||
|
@ -1,9 +1,11 @@
|
||||
#ifndef HUFFMANBUFFER_H
|
||||
#define HUFFMANBUFFER_H
|
||||
#ifndef IMG_HUFFMANBUFFER_H
|
||||
#define IMG_HUFFMANBUFFER_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include "subfile.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class RGNFile;
|
||||
|
||||
class HuffmanBuffer : public QByteArray
|
||||
@ -18,4 +20,6 @@ private:
|
||||
quint8 _id;
|
||||
};
|
||||
|
||||
#endif // HUFFMANBUFFER_H
|
||||
}
|
||||
|
||||
#endif // IMG_HUFFMANBUFFER_H
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "huffmanstream.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
bool HuffmanStreamF::init(bool line)
|
||||
{
|
||||
if (line) {
|
||||
|
@ -1,9 +1,11 @@
|
||||
#ifndef HUFFMANSTREAM_H
|
||||
#define HUFFMANSTREAM_H
|
||||
#ifndef IMG_HUFFMANSTREAM_H
|
||||
#define IMG_HUFFMANSTREAM_H
|
||||
|
||||
#include "bitstream.h"
|
||||
#include "huffmantable.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
template <class BitStream>
|
||||
class HuffmanStream {
|
||||
public:
|
||||
@ -138,4 +140,6 @@ public:
|
||||
bool init(int lonSign, int latSign, quint32 data, quint32 dataSize);
|
||||
};
|
||||
|
||||
#endif // HUFFMANSTREAM_H
|
||||
}
|
||||
|
||||
#endif // IMG_HUFFMANSTREAM_H
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "huffmantable.h"
|
||||
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
static inline quint32 readVUint32(const quint8 *buffer, quint32 bytes)
|
||||
{
|
||||
quint32 val = 0;
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef HUFFMANTABLE_H
|
||||
#define HUFFMANTABLE_H
|
||||
#ifndef IMG_HUFFMANTABLE_H
|
||||
#define IMG_HUFFMANTABLE_H
|
||||
|
||||
#include "huffmanbuffer.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class RGNFile;
|
||||
|
||||
class HuffmanTable {
|
||||
@ -23,4 +25,6 @@ private:
|
||||
quint16 _s22;
|
||||
};
|
||||
|
||||
#endif // HUFFMANTABLE_H
|
||||
}
|
||||
|
||||
#endif // IMG_HUFFMANTABLE_H
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "subfile.h"
|
||||
#include "huffmantext.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
static inline quint32 readVUint32(const quint8 *buffer, quint32 bytes)
|
||||
{
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef HUFFMANTEXT_H
|
||||
#define HUFFMANTEXT_H
|
||||
#ifndef IMG_HUFFMANTEXT_H
|
||||
#define IMG_HUFFMANTEXT_H
|
||||
|
||||
#include "huffmanbuffer.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class HuffmanText
|
||||
{
|
||||
public:
|
||||
@ -32,4 +34,6 @@ private:
|
||||
quint8 *_bp4;
|
||||
};
|
||||
|
||||
#endif // HUFFMANTEXT_H
|
||||
}
|
||||
|
||||
#endif // IMG_HUFFMANTEXT_H
|
||||
|
@ -2,8 +2,9 @@
|
||||
#include <QtEndian>
|
||||
#include <QFile>
|
||||
#include "vectortile.h"
|
||||
#include "img.h"
|
||||
#include "imgdata.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
typedef QMap<QByteArray, VectorTile*> TileMap;
|
||||
|
||||
@ -25,7 +26,7 @@ static SubFile::Type tileType(const char str[3])
|
||||
return SubFile::Unknown;
|
||||
}
|
||||
|
||||
IMG::IMG(const QString &fileName) : _fileName(fileName)
|
||||
IMGData::IMGData(const QString &fileName) : _fileName(fileName)
|
||||
{
|
||||
#define CHECK(condition) \
|
||||
if (!(condition)) { \
|
||||
@ -182,7 +183,7 @@ IMG::IMG(const QString &fileName) : _fileName(fileName)
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
qint64 IMG::read(QFile &file, char *data, qint64 maxSize) const
|
||||
qint64 IMGData::read(QFile &file, char *data, qint64 maxSize) const
|
||||
{
|
||||
qint64 ret = file.read(data, maxSize);
|
||||
if (_key)
|
||||
@ -191,7 +192,7 @@ qint64 IMG::read(QFile &file, char *data, qint64 maxSize) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T> bool IMG::readValue(QFile &file, T &val) const
|
||||
template<class T> bool IMGData::readValue(QFile &file, T &val) const
|
||||
{
|
||||
T data;
|
||||
|
||||
@ -203,7 +204,7 @@ template<class T> bool IMG::readValue(QFile &file, T &val) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IMG::readBlock(QFile &file, int blockNum, char *data) const
|
||||
bool IMGData::readBlock(QFile &file, int blockNum, char *data) const
|
||||
{
|
||||
if (!file.seek((quint64)blockNum << _blockBits))
|
||||
return false;
|
@ -1,14 +1,16 @@
|
||||
#ifndef IMG_H
|
||||
#define IMG_H
|
||||
#ifndef IMG_IMGDATA_H
|
||||
#define IMG_IMGDATA_H
|
||||
|
||||
#include "mapdata.h"
|
||||
|
||||
class QFile;
|
||||
|
||||
class IMG : public MapData
|
||||
namespace IMG {
|
||||
|
||||
class IMGData : public MapData
|
||||
{
|
||||
public:
|
||||
IMG(const QString &fileName);
|
||||
IMGData(const QString &fileName);
|
||||
|
||||
const QString &fileName() const {return _fileName;}
|
||||
|
||||
@ -24,4 +26,6 @@ private:
|
||||
unsigned _blockBits;
|
||||
};
|
||||
|
||||
#endif // IMG_H
|
||||
}
|
||||
|
||||
#endif // IMG_IMGDATA_H
|
@ -1,43 +1,14 @@
|
||||
#ifndef LABEL_H
|
||||
#define LABEL_H
|
||||
#ifndef IMG_LABEL_H
|
||||
#define IMG_LABEL_H
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include "common/config.h"
|
||||
#include "shield.h"
|
||||
|
||||
#define FIRST_SHIELD Label::Shield::USInterstate
|
||||
#define LAST_SHIELD Label::Shield::Oval
|
||||
namespace IMG {
|
||||
|
||||
class Label {
|
||||
public:
|
||||
class Shield
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
None,
|
||||
USInterstate,
|
||||
USShield,
|
||||
USRound,
|
||||
Hbox,
|
||||
Box,
|
||||
Oval
|
||||
};
|
||||
|
||||
Shield() : _type(None) {}
|
||||
Shield(Type type, const QString &name) : _type(type), _text(name) {}
|
||||
|
||||
Type type() const {return _type;}
|
||||
const QString &text() const {return _text;}
|
||||
bool isValid() const {return _type > None && !_text.isEmpty();}
|
||||
|
||||
bool operator==(const Shield &other) const
|
||||
{return _type == other._type && _text == other._text;}
|
||||
|
||||
private:
|
||||
Type _type;
|
||||
QString _text;
|
||||
};
|
||||
|
||||
Label() {}
|
||||
Label(const QString &text, const Shield &shield = Shield())
|
||||
: _text(text), _shield(shield) {}
|
||||
@ -53,19 +24,10 @@ private:
|
||||
Shield _shield;
|
||||
};
|
||||
|
||||
inline HASH_T qHash(const Label::Shield &shield)
|
||||
{
|
||||
return qHash(shield.text()) ^ qHash(shield.type());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
inline QDebug operator<<(QDebug dbg, const Label::Shield &shield)
|
||||
{
|
||||
dbg.nospace() << "Shield(" << shield.type() << ", " << shield.text() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
inline QDebug operator<<(QDebug dbg, const Label &label)
|
||||
inline QDebug operator<<(QDebug dbg, const IMG::Label &label)
|
||||
{
|
||||
dbg.nospace() << "Label(";
|
||||
if (label.shield().isValid())
|
||||
@ -75,4 +37,4 @@ inline QDebug operator<<(QDebug dbg, const Label &label)
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // LABEL_H
|
||||
#endif // IMG_LABEL_H
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "rgnfile.h"
|
||||
#include "lblfile.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
enum Charset {Normal, Symbol, Special};
|
||||
|
||||
static quint8 NORMAL_CHARS[] = {
|
||||
@ -130,7 +132,7 @@ void LBLFile::clear()
|
||||
|
||||
Label LBLFile::label6b(Handle &hdl, quint32 offset, bool capitalize) const
|
||||
{
|
||||
Label::Shield::Type shieldType = Label::Shield::None;
|
||||
Shield::Type shieldType = Shield::None;
|
||||
QByteArray label, shieldLabel;
|
||||
QByteArray *bap = &label;
|
||||
Charset curCharSet = Normal;
|
||||
@ -149,8 +151,7 @@ Label LBLFile::label6b(Handle &hdl, quint32 offset, bool capitalize) const
|
||||
if (c[cpt] > 0x2f || (curCharSet == Normal && c[cpt] == 0x1d)) {
|
||||
QString text(QString::fromLatin1(label));
|
||||
return Label(capitalize && isAllUpperCase(text)
|
||||
? capitalized(text) : text, Label::Shield(shieldType,
|
||||
shieldLabel));
|
||||
? capitalized(text) : text, Shield(shieldType, shieldLabel));
|
||||
}
|
||||
switch (curCharSet) {
|
||||
case Normal:
|
||||
@ -159,8 +160,7 @@ Label LBLFile::label6b(Handle &hdl, quint32 offset, bool capitalize) const
|
||||
else if (c[cpt] == 0x1b)
|
||||
curCharSet = Special;
|
||||
else if (c[cpt] >= 0x2a && c[cpt] <= 0x2f) {
|
||||
shieldType = static_cast<Label::Shield::Type>
|
||||
(c[cpt] - 0x29);
|
||||
shieldType = static_cast<Shield::Type>(c[cpt] - 0x29);
|
||||
bap = &shieldLabel;
|
||||
} else if (bap == &shieldLabel
|
||||
&& NORMAL_CHARS[c[cpt]] == ' ')
|
||||
@ -183,7 +183,7 @@ Label LBLFile::label6b(Handle &hdl, quint32 offset, bool capitalize) const
|
||||
|
||||
Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize) const
|
||||
{
|
||||
Label::Shield::Type shieldType = Label::Shield::None;
|
||||
Shield::Type shieldType = Shield::None;
|
||||
QByteArray label, shieldLabel;
|
||||
QByteArray *bap = &label;
|
||||
|
||||
@ -201,7 +201,7 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize) const
|
||||
else
|
||||
bap->append(' ');
|
||||
} else if (c < 0x07) {
|
||||
shieldType = static_cast<Label::Shield::Type>(c);
|
||||
shieldType = static_cast<Shield::Type>(c);
|
||||
bap = &shieldLabel;
|
||||
} else if (bap == &shieldLabel && c == 0x20) {
|
||||
bap = &label;
|
||||
@ -212,7 +212,7 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize) const
|
||||
QString text(_codec.toString(label));
|
||||
|
||||
return Label(capitalize && isAllUpperCase(text) ? capitalized(text) : text,
|
||||
Label::Shield(shieldType, _codec.toString(shieldLabel)));
|
||||
Shield(shieldType, _codec.toString(shieldLabel)));
|
||||
}
|
||||
|
||||
Label LBLFile::label8b(Handle &hdl, quint32 offset, bool capitalize) const
|
||||
|
@ -1,18 +1,20 @@
|
||||
#ifndef LBLFILE_H
|
||||
#define LBLFILE_H
|
||||
#ifndef IMG_LBLFILE_H
|
||||
#define IMG_LBLFILE_H
|
||||
|
||||
#include <QPixmap>
|
||||
#include "common/textcodec.h"
|
||||
#include "subfile.h"
|
||||
#include "label.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class HuffmanText;
|
||||
class RGNFile;
|
||||
|
||||
class LBLFile : public SubFile
|
||||
{
|
||||
public:
|
||||
LBLFile(const IMG *img)
|
||||
LBLFile(const IMGData *img)
|
||||
: SubFile(img), _huffmanText(0), _table(0), _rasters(0), _offset(0),
|
||||
_size(0), _poiOffset(0), _poiSize(0), _imgOffsetIdSize(0),
|
||||
_poiMultiplier(0), _multiplier(0), _encoding(0) {}
|
||||
@ -65,4 +67,6 @@ private:
|
||||
quint8 _encoding;
|
||||
};
|
||||
|
||||
#endif // LBLFILE_H
|
||||
}
|
||||
|
||||
#endif // IMG_LBLFILE_H
|
||||
|
@ -4,40 +4,11 @@
|
||||
#include "mapdata.h"
|
||||
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
#define CACHED_SUBDIVS_COUNT 2048 // ~32MB for both caches together
|
||||
|
||||
struct PolyCTX
|
||||
{
|
||||
PolyCTX(const RectC &rect, int bits, bool baseMap,
|
||||
QList<MapData::Poly> *polygons, QList<MapData::Poly> *lines,
|
||||
QCache<const SubDiv*, MapData::Polys> *polyCache)
|
||||
: rect(rect), bits(bits), baseMap(baseMap), polygons(polygons),
|
||||
lines(lines), polyCache(polyCache) {}
|
||||
|
||||
const RectC ▭
|
||||
int bits;
|
||||
bool baseMap;
|
||||
QList<MapData::Poly> *polygons;
|
||||
QList<MapData::Poly> *lines;
|
||||
QCache<const SubDiv*, MapData::Polys> *polyCache;
|
||||
};
|
||||
|
||||
struct PointCTX
|
||||
{
|
||||
PointCTX(const RectC &rect, int bits, bool baseMap,
|
||||
QList<MapData::Point> *points,
|
||||
QCache<const SubDiv*, QList<MapData::Point> > *pointCache)
|
||||
: rect(rect), bits(bits), baseMap(baseMap), points(points),
|
||||
pointCache(pointCache) {}
|
||||
|
||||
const RectC ▭
|
||||
int bits;
|
||||
bool baseMap;
|
||||
QList<MapData::Point> *points;
|
||||
QCache<const SubDiv*, QList<MapData::Point> > *pointCache;
|
||||
};
|
||||
|
||||
inline bool polyCb(VectorTile *tile, void *context)
|
||||
bool MapData::polyCb(VectorTile *tile, void *context)
|
||||
{
|
||||
PolyCTX *ctx = (PolyCTX*)context;
|
||||
tile->polys(ctx->rect, ctx->bits, ctx->baseMap, ctx->polygons, ctx->lines,
|
||||
@ -45,7 +16,7 @@ inline bool polyCb(VectorTile *tile, void *context)
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool pointCb(VectorTile *tile, void *context)
|
||||
bool MapData::pointCb(VectorTile *tile, void *context)
|
||||
{
|
||||
PointCTX *ctx = (PointCTX*)context;
|
||||
tile->points(ctx->rect, ctx->bits, ctx->baseMap, ctx->points,
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef MAPDATA_H
|
||||
#define MAPDATA_H
|
||||
#ifndef IMG_MAPDATA_H
|
||||
#define IMG_MAPDATA_H
|
||||
|
||||
#include <QList>
|
||||
#include <QPointF>
|
||||
@ -11,6 +11,9 @@
|
||||
#include "label.h"
|
||||
#include "raster.h"
|
||||
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class Style;
|
||||
class SubDiv;
|
||||
class SubFile;
|
||||
@ -89,6 +92,40 @@ private:
|
||||
QList<Poly> lines;
|
||||
};
|
||||
|
||||
struct PolyCTX
|
||||
{
|
||||
PolyCTX(const RectC &rect, int bits, bool baseMap,
|
||||
QList<MapData::Poly> *polygons, QList<MapData::Poly> *lines,
|
||||
QCache<const SubDiv*, MapData::Polys> *polyCache)
|
||||
: rect(rect), bits(bits), baseMap(baseMap), polygons(polygons),
|
||||
lines(lines), polyCache(polyCache) {}
|
||||
|
||||
const RectC ▭
|
||||
int bits;
|
||||
bool baseMap;
|
||||
QList<MapData::Poly> *polygons;
|
||||
QList<MapData::Poly> *lines;
|
||||
QCache<const SubDiv*, MapData::Polys> *polyCache;
|
||||
};
|
||||
|
||||
struct PointCTX
|
||||
{
|
||||
PointCTX(const RectC &rect, int bits, bool baseMap,
|
||||
QList<MapData::Point> *points,
|
||||
QCache<const SubDiv*, QList<MapData::Point> > *pointCache)
|
||||
: rect(rect), bits(bits), baseMap(baseMap), points(points),
|
||||
pointCache(pointCache) {}
|
||||
|
||||
const RectC ▭
|
||||
int bits;
|
||||
bool baseMap;
|
||||
QList<MapData::Point> *points;
|
||||
QCache<const SubDiv*, QList<MapData::Point> > *pointCache;
|
||||
};
|
||||
|
||||
static bool polyCb(VectorTile *tile, void *context);
|
||||
static bool pointCb(VectorTile *tile, void *context);
|
||||
|
||||
QCache<const SubDiv*, Polys> _polyCache;
|
||||
QCache<const SubDiv*, QList<Point> > _pointCache;
|
||||
|
||||
@ -96,18 +133,20 @@ private:
|
||||
friend struct PolyCTX;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
inline QDebug operator<<(QDebug dbg, const MapData::Point &point)
|
||||
inline QDebug operator<<(QDebug dbg, const IMG::MapData::Point &point)
|
||||
{
|
||||
dbg.nospace() << "Point(" << point.type << ", " << point.label << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
inline QDebug operator<<(QDebug dbg, const MapData::Poly &poly)
|
||||
inline QDebug operator<<(QDebug dbg, const IMG::MapData::Poly &poly)
|
||||
{
|
||||
dbg.nospace() << "Poly(" << poly.type << ", " << poly.label << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // MAPDATA_H
|
||||
#endif // IMG_MAPDATA_H
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "rgnfile.h"
|
||||
#include "netfile.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
static bool readAdjCounts(BitStream4R &bs, QVector<quint16> &cnts, quint16 &mask)
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
#ifndef NETFILE_H
|
||||
#define NETFILE_H
|
||||
#ifndef IMG_NETFILE_H
|
||||
#define IMG_NETFILE_H
|
||||
|
||||
#include "subfile.h"
|
||||
#include "nodfile.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class LBLFile;
|
||||
class RGNFile;
|
||||
class SubDiv;
|
||||
@ -12,8 +14,9 @@ class HuffmanTable;
|
||||
class NETFile : public SubFile
|
||||
{
|
||||
public:
|
||||
NETFile(const IMG *img) : SubFile(img), _huffmanTable(0), _tp(0), _offset(0),
|
||||
_size(0), _linksOffset(0), _linksSize(0), _shift(0), _linksShift(0) {}
|
||||
NETFile(const IMGData *img) : SubFile(img), _huffmanTable(0), _tp(0),
|
||||
_offset(0), _size(0), _linksOffset(0), _linksSize(0), _shift(0),
|
||||
_linksShift(0) {}
|
||||
NETFile(const QString *path) : SubFile(path), _huffmanTable(0), _tp(0),
|
||||
_offset(0), _size(0), _linksOffset(0), _linksSize(0), _shift(0),
|
||||
_linksShift(0) {}
|
||||
@ -41,4 +44,6 @@ private:
|
||||
quint8 _shift, _linksShift;
|
||||
};
|
||||
|
||||
#endif // NETFILE_H
|
||||
}
|
||||
|
||||
#endif // IMG_NETFILE_H
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "bitstream.h"
|
||||
#include "nodfile.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
#define ARRAY_SIZE(array) \
|
||||
(sizeof(array) / sizeof(array[0]))
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef NODFILE_H
|
||||
#define NODFILE_H
|
||||
#ifndef IMG_NODFILE_H
|
||||
#define IMG_NODFILE_H
|
||||
|
||||
#include "subfile.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class NODFile : public SubFile
|
||||
{
|
||||
public:
|
||||
@ -53,7 +55,7 @@ public:
|
||||
bool eog;
|
||||
};
|
||||
|
||||
NODFile(const IMG *img) : SubFile(img), _indexOffset(0), _indexSize(0),
|
||||
NODFile(const IMGData *img) : SubFile(img), _indexOffset(0), _indexSize(0),
|
||||
_indexFlags(0), _blockOffset(0), _blockSize(0), _indexRecordSize(0),
|
||||
_blockRecordSize(0), _blockShift(0), _nodeShift(0), _indexIdSize(0) {}
|
||||
NODFile(const QString *path) : SubFile(path), _indexOffset(0), _indexSize(0),
|
||||
@ -95,4 +97,6 @@ private:
|
||||
quint8 _blockShift, _nodeShift, _indexIdSize;
|
||||
};
|
||||
|
||||
#endif // NETFILE_H
|
||||
}
|
||||
|
||||
#endif // IMG_NETFILE_H
|
||||
|
@ -1,11 +1,13 @@
|
||||
#ifndef RASTER_H
|
||||
#define RASTER_H
|
||||
#ifndef IMG_RASTER_H
|
||||
#define IMG_RASTER_H
|
||||
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
#include "common/rectc.h"
|
||||
#include "common/garmin.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class LBLFile;
|
||||
|
||||
class Raster {
|
||||
@ -29,12 +31,14 @@ private:
|
||||
QRect _rect;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
inline QDebug operator<<(QDebug dbg, const Raster &raster)
|
||||
inline QDebug operator<<(QDebug dbg, const IMG::Raster &raster)
|
||||
{
|
||||
dbg.nospace() << "Raster(" << raster.rect() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // RASTER_H
|
||||
#endif // IMG_RASTER_H
|
||||
|
@ -1,13 +1,14 @@
|
||||
#include <QFont>
|
||||
#include <QPainter>
|
||||
#include "map/imgmap.h"
|
||||
#include "textpathitem.h"
|
||||
#include "textpointitem.h"
|
||||
#include "map/textpathitem.h"
|
||||
#include "map/textpointitem.h"
|
||||
#include "bitmapline.h"
|
||||
#include "style.h"
|
||||
#include "lblfile.h"
|
||||
#include "rastertile.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
#define AREA(rect) \
|
||||
(rect.size().width() * rect.size().height())
|
||||
@ -90,34 +91,34 @@ static QFont *poiFont(Style::FontSize size = Style::Normal)
|
||||
}
|
||||
}
|
||||
|
||||
static const QColor *shieldBgColor(Label::Shield::Type type)
|
||||
static const QColor *shieldBgColor(Shield::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Label::Shield::USInterstate:
|
||||
case Label::Shield::Hbox:
|
||||
case Shield::USInterstate:
|
||||
case Shield::Hbox:
|
||||
return &shieldBgColor1;
|
||||
case Label::Shield::USShield:
|
||||
case Label::Shield::Box:
|
||||
case Shield::USShield:
|
||||
case Shield::Box:
|
||||
return &shieldBgColor2;
|
||||
case Label::Shield::USRound:
|
||||
case Label::Shield::Oval:
|
||||
case Shield::USRound:
|
||||
case Shield::Oval:
|
||||
return &shieldBgColor3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int minShieldZoom(Label::Shield::Type type)
|
||||
static int minShieldZoom(Shield::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Label::Shield::USInterstate:
|
||||
case Label::Shield::Hbox:
|
||||
case Shield::USInterstate:
|
||||
case Shield::Hbox:
|
||||
return 17;
|
||||
case Label::Shield::USShield:
|
||||
case Label::Shield::Box:
|
||||
case Shield::USShield:
|
||||
case Shield::Box:
|
||||
return 19;
|
||||
case Label::Shield::USRound:
|
||||
case Label::Shield::Oval:
|
||||
case Shield::USRound:
|
||||
case Shield::Oval:
|
||||
return 20;
|
||||
default:
|
||||
return 0;
|
||||
@ -378,15 +379,15 @@ void RasterTile::processShields(const QRect &tileRect,
|
||||
QList<TextItem*> &textItems)
|
||||
{
|
||||
for (int type = FIRST_SHIELD; type <= LAST_SHIELD; type++) {
|
||||
if (minShieldZoom(static_cast<Label::Shield::Type>(type)) > _zoom)
|
||||
if (minShieldZoom(static_cast<Shield::Type>(type)) > _zoom)
|
||||
continue;
|
||||
|
||||
QHash<Label::Shield, QPolygonF> shields;
|
||||
QHash<Label::Shield, const Label::Shield*> sp;
|
||||
QHash<Shield, QPolygonF> shields;
|
||||
QHash<Shield, const Shield*> sp;
|
||||
|
||||
for (int i = 0; i < _lines.size(); i++) {
|
||||
const MapData::Poly &poly = _lines.at(i);
|
||||
const Label::Shield &shield = poly.label.shield();
|
||||
const Shield &shield = poly.label.shield();
|
||||
if (!shield.isValid() || shield.type() != type
|
||||
|| !Style::isMajorRoad(poly.type))
|
||||
continue;
|
||||
@ -398,8 +399,8 @@ void RasterTile::processShields(const QRect &tileRect,
|
||||
sp.insert(shield, &shield);
|
||||
}
|
||||
|
||||
for (QHash<Label::Shield, QPolygonF>::const_iterator it
|
||||
= shields.constBegin(); it != shields.constEnd(); ++it) {
|
||||
for (QHash<Shield, QPolygonF>::const_iterator it = shields.constBegin();
|
||||
it != shields.constEnd(); ++it) {
|
||||
const QPolygonF &p = it.value();
|
||||
QRectF rect(p.boundingRect() & tileRect);
|
||||
if (AREA(rect) < AREA(QRect(0, 0, _img.width()/4, _img.width()/4)))
|
||||
|
@ -1,13 +1,16 @@
|
||||
#ifndef RASTERTILE_H
|
||||
#define RASTERTILE_H
|
||||
#ifndef IMG_RASTERTILE_H
|
||||
#define IMG_RASTERTILE_H
|
||||
|
||||
#include <QImage>
|
||||
#include "mapdata.h"
|
||||
|
||||
class QPainter;
|
||||
class TextItem;
|
||||
class Style;
|
||||
class IMGMap;
|
||||
class TextItem;
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class Style;
|
||||
|
||||
class RasterTile
|
||||
{
|
||||
@ -50,4 +53,6 @@ private:
|
||||
QList<MapData::Point> _points;
|
||||
};
|
||||
|
||||
#endif // RASTERTILE_H
|
||||
}
|
||||
|
||||
#endif // IMG_RASTERTILE_H
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "nodfile.h"
|
||||
#include "rgnfile.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
#define MASK(bits) ((2U << ((bits) - 1U)) - 1U)
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
#ifndef RGNFILE_H
|
||||
#define RGNFILE_H
|
||||
#ifndef IMG_RGNFILE_H
|
||||
#define IMG_RGNFILE_H
|
||||
|
||||
#include "subfile.h"
|
||||
#include "subdiv.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class LBLFile;
|
||||
class NETFile;
|
||||
class NODFile;
|
||||
@ -20,7 +22,7 @@ public:
|
||||
RoadReference = 0x10
|
||||
};
|
||||
|
||||
RGNFile(const IMG *img)
|
||||
RGNFile(const IMGData *img)
|
||||
: SubFile(img), _huffmanTable(0), _offset(0), _size(0), _polygonsOffset(0),
|
||||
_polygonsSize(0), _linesOffset(0), _linesSize(0), _pointsOffset(0),
|
||||
_pointsSize(0) {}
|
||||
@ -86,4 +88,6 @@ private:
|
||||
quint32 _pointsGblFlags;
|
||||
};
|
||||
|
||||
#endif // RGNFILE_H
|
||||
}
|
||||
|
||||
#endif // IMG_RGNFILE_H
|
||||
|
55
src/map/IMG/shield.h
Normal file
55
src/map/IMG/shield.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef IMG_SHIELD_H
|
||||
#define IMG_SHIELD_H
|
||||
|
||||
#include <QString>
|
||||
#include "common/config.h"
|
||||
|
||||
#define FIRST_SHIELD Shield::USInterstate
|
||||
#define LAST_SHIELD Shield::Oval
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class Shield
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
None,
|
||||
USInterstate,
|
||||
USShield,
|
||||
USRound,
|
||||
Hbox,
|
||||
Box,
|
||||
Oval
|
||||
};
|
||||
|
||||
Shield() : _type(None) {}
|
||||
Shield(Type type, const QString &name) : _type(type), _text(name) {}
|
||||
|
||||
Type type() const {return _type;}
|
||||
const QString &text() const {return _text;}
|
||||
bool isValid() const {return _type > None && !_text.isEmpty();}
|
||||
|
||||
bool operator==(const Shield &other) const
|
||||
{return _type == other._type && _text == other._text;}
|
||||
|
||||
private:
|
||||
Type _type;
|
||||
QString _text;
|
||||
};
|
||||
|
||||
inline HASH_T qHash(const IMG::Shield &shield)
|
||||
{
|
||||
return ::qHash(shield.text()) ^ ::qHash(shield.type());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
inline QDebug operator<<(QDebug dbg, const IMG::Shield &shield)
|
||||
{
|
||||
dbg.nospace() << "Shield(" << shield.type() << ", " << shield.text() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // IMG_SHIELD_H
|
@ -2,6 +2,7 @@
|
||||
#include <QPainter>
|
||||
#include "style.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
void Style::defaultPolygonStyle()
|
||||
{
|
||||
@ -238,137 +239,137 @@ void Style::defaultPointStyle()
|
||||
_points[TYPE(0x03)].setTextFontSize(Large);
|
||||
|
||||
// POI
|
||||
_points[0x2a00] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a01] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a02] = Point(QImage(":/restaurant-noodle-11.png"));
|
||||
_points[0x2a03] = Point(QImage(":/bbq-11.png"));
|
||||
_points[0x2a04] = Point(QImage(":/restaurant-noodle-11.png"));
|
||||
_points[0x2a05] = Point(QImage(":/bakery-11.png"));
|
||||
_points[0x2a06] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a07] = Point(QImage(":/fast-food-11.png"));
|
||||
_points[0x2a08] = Point(QImage(":/restaurant-pizza-11.png"));
|
||||
_points[0x2a09] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a0a] = Point(QImage(":/restaurant-pizza-11.png"));
|
||||
_points[0x2a0b] = Point(QImage(":/restaurant-seafood-11.png"));
|
||||
_points[0x2a0c] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a0d] = Point(QImage(":/bakery-11.png"));
|
||||
_points[0x2a0e] = Point(QImage(":/cafe-11.png"));
|
||||
_points[0x2a0f] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a10] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a11] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a12] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a13] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a00] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a01] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a02] = Point(QImage(":/POI/restaurant-noodle-11.png"));
|
||||
_points[0x2a03] = Point(QImage(":/POI/bbq-11.png"));
|
||||
_points[0x2a04] = Point(QImage(":/POI/restaurant-noodle-11.png"));
|
||||
_points[0x2a05] = Point(QImage(":/POI/bakery-11.png"));
|
||||
_points[0x2a06] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a07] = Point(QImage(":/POI/fast-food-11.png"));
|
||||
_points[0x2a08] = Point(QImage(":/POI/restaurant-pizza-11.png"));
|
||||
_points[0x2a09] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a0a] = Point(QImage(":/POI/restaurant-pizza-11.png"));
|
||||
_points[0x2a0b] = Point(QImage(":/POI/restaurant-seafood-11.png"));
|
||||
_points[0x2a0c] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a0d] = Point(QImage(":/POI/bakery-11.png"));
|
||||
_points[0x2a0e] = Point(QImage(":/POI/cafe-11.png"));
|
||||
_points[0x2a0f] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a10] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a11] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a12] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x2a13] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
|
||||
_points[0x2b01] = Point(QImage(":/lodging-11.png"));
|
||||
_points[0x2b02] = Point(QImage(":/lodging-11.png"));
|
||||
_points[0x2b03] = Point(QImage(":/campsite-11.png"));
|
||||
_points[0x2b04] = Point(QImage(":/village-11.png"));
|
||||
_points[0x2b06] = Point(QImage(":/shelter-11.png"));
|
||||
_points[0x2b01] = Point(QImage(":/POI/lodging-11.png"));
|
||||
_points[0x2b02] = Point(QImage(":/POI/lodging-11.png"));
|
||||
_points[0x2b03] = Point(QImage(":/POI/campsite-11.png"));
|
||||
_points[0x2b04] = Point(QImage(":/POI/village-11.png"));
|
||||
_points[0x2b06] = Point(QImage(":/POI/shelter-11.png"));
|
||||
|
||||
_points[0x2c01] = Point(QImage(":/amusement-park-11.png"));
|
||||
_points[0x2c02] = Point(QImage(":/museum-11.png"));
|
||||
_points[0x2c03] = Point(QImage(":/library-11.png"));
|
||||
_points[0x2c04] = Point(QImage(":/landmark-11.png"));
|
||||
_points[0x2c05] = Point(QImage(":/school-11.png"));
|
||||
_points[0x2c06] = Point(QImage(":/garden-11.png"));
|
||||
_points[0x2c07] = Point(QImage(":/zoo-11.png"));
|
||||
_points[0x2c08] = Point(QImage(":/soccer-11.png"));
|
||||
_points[0x2c0a] = Point(QImage(":/bar-11.png"));
|
||||
_points[0x2c0b] = Point(QImage(":/place-of-worship-11.png"));
|
||||
_points[0x2c0d] = Point(QImage(":/religious-muslim-11.png"));
|
||||
_points[0x2c0e] = Point(QImage(":/religious-christian-11.png"));
|
||||
_points[0x2c10] = Point(QImage(":/religious-jewish-11.png"));
|
||||
_points[0x2d01] = Point(QImage(":/theatre-11.png"));
|
||||
_points[0x2d02] = Point(QImage(":/bar-11.png"));
|
||||
_points[0x2d03] = Point(QImage(":/cinema-11.png"));
|
||||
_points[0x2d04] = Point(QImage(":/casino-11.png"));
|
||||
_points[0x2d05] = Point(QImage(":/golf-11.png"));
|
||||
_points[0x2d06] = Point(QImage(":/skiing-11.png"));
|
||||
_points[0x2d07] = Point(QImage(":/bowling-alley-11.png"));
|
||||
_points[0x2d09] = Point(QImage(":/swimming-11.png"));
|
||||
_points[0x2d0a] = Point(QImage(":/fitness-centre-11.png"));
|
||||
_points[0x2d0b] = Point(QImage(":/airfield-11.png"));
|
||||
_points[0x2c01] = Point(QImage(":/POI/amusement-park-11.png"));
|
||||
_points[0x2c02] = Point(QImage(":/POI/museum-11.png"));
|
||||
_points[0x2c03] = Point(QImage(":/POI/library-11.png"));
|
||||
_points[0x2c04] = Point(QImage(":/POI/landmark-11.png"));
|
||||
_points[0x2c05] = Point(QImage(":/POI/school-11.png"));
|
||||
_points[0x2c06] = Point(QImage(":/POI/garden-11.png"));
|
||||
_points[0x2c07] = Point(QImage(":/POI/zoo-11.png"));
|
||||
_points[0x2c08] = Point(QImage(":/POI/soccer-11.png"));
|
||||
_points[0x2c0a] = Point(QImage(":/POI/bar-11.png"));
|
||||
_points[0x2c0b] = Point(QImage(":/POI/place-of-worship-11.png"));
|
||||
_points[0x2c0d] = Point(QImage(":/POI/religious-muslim-11.png"));
|
||||
_points[0x2c0e] = Point(QImage(":/POI/religious-christian-11.png"));
|
||||
_points[0x2c10] = Point(QImage(":/POI/religious-jewish-11.png"));
|
||||
_points[0x2d01] = Point(QImage(":/POI/theatre-11.png"));
|
||||
_points[0x2d02] = Point(QImage(":/POI/bar-11.png"));
|
||||
_points[0x2d03] = Point(QImage(":/POI/cinema-11.png"));
|
||||
_points[0x2d04] = Point(QImage(":/POI/casino-11.png"));
|
||||
_points[0x2d05] = Point(QImage(":/POI/golf-11.png"));
|
||||
_points[0x2d06] = Point(QImage(":/POI/skiing-11.png"));
|
||||
_points[0x2d07] = Point(QImage(":/POI/bowling-alley-11.png"));
|
||||
_points[0x2d09] = Point(QImage(":/POI/swimming-11.png"));
|
||||
_points[0x2d0a] = Point(QImage(":/POI/fitness-centre-11.png"));
|
||||
_points[0x2d0b] = Point(QImage(":/POI/airfield-11.png"));
|
||||
|
||||
_points[0x2e02] = Point(QImage(":/grocery-11.png"));
|
||||
_points[0x2e03] = Point(QImage(":/shop-11.png"));
|
||||
_points[0x2e05] = Point(QImage(":/pharmacy-11.png"));
|
||||
_points[0x2e06] = Point(QImage(":/convenience-11.png"));
|
||||
_points[0x2e07] = Point(QImage(":/clothing-store-11.png"));
|
||||
_points[0x2e08] = Point(QImage(":/garden-centre-11.png"));
|
||||
_points[0x2e09] = Point(QImage(":/furniture-11.png"));
|
||||
_points[0x2e0a] = Point(QImage(":/shop-11.png"));
|
||||
_points[0x2e0c] = Point(QImage(":/shop-11.png"));
|
||||
_points[0x2e02] = Point(QImage(":/POI/grocery-11.png"));
|
||||
_points[0x2e03] = Point(QImage(":/POI/shop-11.png"));
|
||||
_points[0x2e05] = Point(QImage(":/POI/pharmacy-11.png"));
|
||||
_points[0x2e06] = Point(QImage(":/POI/convenience-11.png"));
|
||||
_points[0x2e07] = Point(QImage(":/POI/clothing-store-11.png"));
|
||||
_points[0x2e08] = Point(QImage(":/POI/garden-centre-11.png"));
|
||||
_points[0x2e09] = Point(QImage(":/POI/furniture-11.png"));
|
||||
_points[0x2e0a] = Point(QImage(":/POI/shop-11.png"));
|
||||
_points[0x2e0c] = Point(QImage(":/POI/shop-11.png"));
|
||||
|
||||
_points[0x2f01] = Point(QImage(":/fuel-11.png"));
|
||||
_points[0x2f02] = Point(QImage(":/car-rental-11.png"));
|
||||
_points[0x2f03] = Point(QImage(":/car-repair-11.png"));
|
||||
_points[0x2f04] = Point(QImage(":/airport-11.png"));
|
||||
_points[0x2f05] = Point(QImage(":/post-11.png"));
|
||||
_points[0x2f06] = Point(QImage(":/bank-11.png"));
|
||||
_points[0x2f07] = Point(QImage(":/car-11.png"));
|
||||
_points[0x2f08] = Point(QImage(":/bus-11.png"));
|
||||
_points[0x2f09] = Point(QImage(":/harbor-11.png"));
|
||||
_points[0x2f0b] = Point(QImage(":/parking-11.png"));
|
||||
_points[0x2f01] = Point(QImage(":/POI/fuel-11.png"));
|
||||
_points[0x2f02] = Point(QImage(":/POI/car-rental-11.png"));
|
||||
_points[0x2f03] = Point(QImage(":/POI/car-repair-11.png"));
|
||||
_points[0x2f04] = Point(QImage(":/POI/airport-11.png"));
|
||||
_points[0x2f05] = Point(QImage(":/POI/post-11.png"));
|
||||
_points[0x2f06] = Point(QImage(":/POI/bank-11.png"));
|
||||
_points[0x2f07] = Point(QImage(":/POI/car-11.png"));
|
||||
_points[0x2f08] = Point(QImage(":/POI/bus-11.png"));
|
||||
_points[0x2f09] = Point(QImage(":/POI/harbor-11.png"));
|
||||
_points[0x2f0b] = Point(QImage(":/POI/parking-11.png"));
|
||||
_points[0x2f0b].setTextFontSize(None);
|
||||
_points[0x2f0c] = Point(QImage(":/toilet-11.png"));
|
||||
_points[0x2f0c] = Point(QImage(":/POI/toilet-11.png"));
|
||||
_points[0x2f0c].setTextFontSize(None);
|
||||
_points[0x2f10] = Point(QImage(":/hairdresser-11.png"));
|
||||
_points[0x2f10] = Point(QImage(":/POI/hairdresser-11.png"));
|
||||
_points[0x2f12].setTextFontSize(None);
|
||||
_points[0x2f13] = Point(QImage(":/hardware-11.png"));
|
||||
_points[0x2f17] = Point(QImage(":/bus-11.png"));
|
||||
_points[0x2f13] = Point(QImage(":/POI/hardware-11.png"));
|
||||
_points[0x2f17] = Point(QImage(":/POI/bus-11.png"));
|
||||
|
||||
_points[0x3001] = Point(QImage(":/police-11.png"));
|
||||
_points[0x3002] = Point(QImage(":/hospital-11.png"));
|
||||
_points[0x3003] = Point(QImage(":/town-hall-11.png"));
|
||||
_points[0x3006] = Point(QImage(":/entrance-alt1-11.png"));
|
||||
_points[0x3007] = Point(QImage(":/town-hall-11.png"));
|
||||
_points[0x3008] = Point(QImage(":/fire-station-11.png"));
|
||||
_points[0x3001] = Point(QImage(":/POI/police-11.png"));
|
||||
_points[0x3002] = Point(QImage(":/POI/hospital-11.png"));
|
||||
_points[0x3003] = Point(QImage(":/POI/town-hall-11.png"));
|
||||
_points[0x3006] = Point(QImage(":/POI/entrance-alt1-11.png"));
|
||||
_points[0x3007] = Point(QImage(":/POI/town-hall-11.png"));
|
||||
_points[0x3008] = Point(QImage(":/POI/fire-station-11.png"));
|
||||
|
||||
_points[0x4000] = Point(QImage(":/golf-11.png"));
|
||||
_points[0x4300] = Point(QImage(":/harbor-11.png"));
|
||||
_points[0x4400] = Point(QImage(":/fuel-11.png"));
|
||||
_points[0x4500] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x4600] = Point(QImage(":/bar-11.png"));
|
||||
_points[0x4900] = Point(QImage(":/park-11.png"));
|
||||
_points[0x4a00] = Point(QImage(":/picnic-site-11.png"));
|
||||
_points[0x4c00] = Point(QImage(":/information-11.png"));
|
||||
_points[0x4800] = Point(QImage(":/campsite-11.png"));
|
||||
_points[0x4a00] = Point(QImage(":/picnic-site-11.png"));
|
||||
_points[0x4b00] = Point(QImage(":/hospital-11.png"));
|
||||
_points[0x4c00] = Point(QImage(":/information-11.png"));
|
||||
_points[0x4d00] = Point(QImage(":/parking-11.png"));
|
||||
_points[0x4000] = Point(QImage(":/POI/golf-11.png"));
|
||||
_points[0x4300] = Point(QImage(":/POI/harbor-11.png"));
|
||||
_points[0x4400] = Point(QImage(":/POI/fuel-11.png"));
|
||||
_points[0x4500] = Point(QImage(":/POI/restaurant-11.png"));
|
||||
_points[0x4600] = Point(QImage(":/POI/bar-11.png"));
|
||||
_points[0x4900] = Point(QImage(":/POI/park-11.png"));
|
||||
_points[0x4a00] = Point(QImage(":/POI/picnic-site-11.png"));
|
||||
_points[0x4c00] = Point(QImage(":/POI/information-11.png"));
|
||||
_points[0x4800] = Point(QImage(":/POI/campsite-11.png"));
|
||||
_points[0x4a00] = Point(QImage(":/POI/picnic-site-11.png"));
|
||||
_points[0x4b00] = Point(QImage(":/POI/hospital-11.png"));
|
||||
_points[0x4c00] = Point(QImage(":/POI/information-11.png"));
|
||||
_points[0x4d00] = Point(QImage(":/POI/parking-11.png"));
|
||||
_points[0x4d00].setTextFontSize(None);
|
||||
_points[0x4e00] = Point(QImage(":/toilet-11.png"));
|
||||
_points[0x4e00] = Point(QImage(":/POI/toilet-11.png"));
|
||||
_points[0x4e00].setTextFontSize(None);
|
||||
_points[0x5000] = Point(QImage(":/drinking-water-11.png"));
|
||||
_points[0x5000] = Point(QImage(":/POI/drinking-water-11.png"));
|
||||
_points[0x5000].setTextFontSize(None);
|
||||
_points[0x5100] = Point(QImage(":/telephone-11.png"));
|
||||
_points[0x5200] = Point(QImage(":/viewpoint-11.png"));
|
||||
_points[0x5300] = Point(QImage(":/skiing-11.png"));
|
||||
_points[0x5400] = Point(QImage(":/swimming-11.png"));
|
||||
_points[0x5500] = Point(QImage(":/dam-11.png"));
|
||||
_points[0x5700] = Point(QImage(":/danger-11.png"));
|
||||
_points[0x5800] = Point(QImage(":/roadblock-11.png"));
|
||||
_points[0x5900] = Point(QImage(":/airport-11.png"));
|
||||
_points[0x5901] = Point(QImage(":/airport-11.png"));
|
||||
_points[0x5904] = Point(QImage(":/heliport-11.png"));
|
||||
_points[0x5100] = Point(QImage(":/POI/telephone-11.png"));
|
||||
_points[0x5200] = Point(QImage(":/POI/viewpoint-11.png"));
|
||||
_points[0x5300] = Point(QImage(":/POI/skiing-11.png"));
|
||||
_points[0x5400] = Point(QImage(":/POI/swimming-11.png"));
|
||||
_points[0x5500] = Point(QImage(":/POI/dam-11.png"));
|
||||
_points[0x5700] = Point(QImage(":/POI/danger-11.png"));
|
||||
_points[0x5800] = Point(QImage(":/POI/roadblock-11.png"));
|
||||
_points[0x5900] = Point(QImage(":/POI/airport-11.png"));
|
||||
_points[0x5901] = Point(QImage(":/POI/airport-11.png"));
|
||||
_points[0x5904] = Point(QImage(":/POI/heliport-11.png"));
|
||||
|
||||
_points[0x6401] = Point(QImage(":/bridge-11.png"));
|
||||
_points[0x6402] = Point(QImage(":/building-alt1-11.png"));
|
||||
_points[0x6403] = Point(QImage(":/cemetery-11.png"));
|
||||
_points[0x6404] = Point(QImage(":/religious-christian-11.png"));
|
||||
_points[0x6407] = Point(QImage(":/dam-11.png"));
|
||||
_points[0x6408] = Point(QImage(":/hospital-11.png"));
|
||||
_points[0x6409] = Point(QImage(":/dam-11.png"));
|
||||
_points[0x640d] = Point(QImage(":/communications-tower-11.png"));
|
||||
_points[0x640e] = Point(QImage(":/park-11.png"));
|
||||
_points[0x640f] = Point(QImage(":/post-11.png"));
|
||||
_points[0x6411] = Point(QImage(":/communications-tower-11.png"));
|
||||
_points[0x6401] = Point(QImage(":/POI/bridge-11.png"));
|
||||
_points[0x6402] = Point(QImage(":/POI/building-alt1-11.png"));
|
||||
_points[0x6403] = Point(QImage(":/POI/cemetery-11.png"));
|
||||
_points[0x6404] = Point(QImage(":/POI/religious-christian-11.png"));
|
||||
_points[0x6407] = Point(QImage(":/POI/dam-11.png"));
|
||||
_points[0x6408] = Point(QImage(":/POI/hospital-11.png"));
|
||||
_points[0x6409] = Point(QImage(":/POI/dam-11.png"));
|
||||
_points[0x640d] = Point(QImage(":/POI/communications-tower-11.png"));
|
||||
_points[0x640e] = Point(QImage(":/POI/park-11.png"));
|
||||
_points[0x640f] = Point(QImage(":/POI/post-11.png"));
|
||||
_points[0x6411] = Point(QImage(":/POI/communications-tower-11.png"));
|
||||
|
||||
_points[0x6508] = Point(QImage(":/waterfall-11.png"));
|
||||
_points[0x6513] = Point(QImage(":/wetland-11.png"));
|
||||
_points[0x6604] = Point(QImage(":/beach-11.png"));
|
||||
_points[0x6616] = Point(QImage(":/mountain-11.png"));
|
||||
_points[0x6508] = Point(QImage(":/POI/waterfall-11.png"));
|
||||
_points[0x6513] = Point(QImage(":/POI/wetland-11.png"));
|
||||
_points[0x6604] = Point(QImage(":/POI/beach-11.png"));
|
||||
_points[0x6616] = Point(QImage(":/POI/mountain-11.png"));
|
||||
|
||||
|
||||
// NT types
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef STYLE_H
|
||||
#define STYLE_H
|
||||
#ifndef IMG_STYLE_H
|
||||
#define IMG_STYLE_H
|
||||
|
||||
#include <QPen>
|
||||
#include <QBrush>
|
||||
@ -8,6 +8,8 @@
|
||||
|
||||
#define TYPE(t) ((t)<<8)
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class Style
|
||||
{
|
||||
public:
|
||||
@ -173,10 +175,12 @@ private:
|
||||
QList<quint32> _drawOrder;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const Style::Polygon &polygon);
|
||||
QDebug operator<<(QDebug dbg, const Style::Line &line);
|
||||
QDebug operator<<(QDebug dbg, const Style::Point &point);
|
||||
QDebug operator<<(QDebug dbg, const IMG::Style::Polygon &polygon);
|
||||
QDebug operator<<(QDebug dbg, const IMG::Style::Line &line);
|
||||
QDebug operator<<(QDebug dbg, const IMG::Style::Point &point);
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // STYLE_H
|
||||
#endif // IMG_STYLE_H
|
||||
|
@ -1,10 +1,12 @@
|
||||
#ifndef SUBDIV_H
|
||||
#define SUBDIV_H
|
||||
#ifndef IMG_SUBDIV_H
|
||||
#define IMG_SUBDIV_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include "common/coordinates.h"
|
||||
#include "common/garmin.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class SubDiv {
|
||||
public:
|
||||
class Segment {
|
||||
@ -155,4 +157,6 @@ private:
|
||||
};
|
||||
};
|
||||
|
||||
#endif // SUBDIV_H
|
||||
}
|
||||
|
||||
#endif // IMG_SUBDIV_H
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include <cstring>
|
||||
#include "img.h"
|
||||
#include "imgdata.h"
|
||||
#include "subfile.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
#define mod2n(x, m) ((x) & ((m) - 1));
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
#ifndef SUBFILE_H
|
||||
#define SUBFILE_H
|
||||
#ifndef IMG_SUBFILE_H
|
||||
#define IMG_SUBFILE_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QFile>
|
||||
#include "img.h"
|
||||
#include "imgdata.h"
|
||||
|
||||
|
||||
#define BLOCK_BITS 12 /* 4096 bytes */
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class SubFile
|
||||
{
|
||||
public:
|
||||
@ -43,7 +45,7 @@ public:
|
||||
int _pos;
|
||||
};
|
||||
|
||||
SubFile(const IMG *img)
|
||||
SubFile(const IMGData *img)
|
||||
: _gmpOffset(0), _img(img), _blocks(new QVector<quint16>()), _path(0) {}
|
||||
SubFile(const SubFile *gmp, quint32 offset) : _gmpOffset(offset),
|
||||
_img(gmp->_img), _blocks(gmp->_blocks), _path(gmp->_path) {}
|
||||
@ -153,9 +155,11 @@ protected:
|
||||
quint32 _gmpOffset;
|
||||
|
||||
private:
|
||||
const IMG *_img;
|
||||
const IMGData *_img;
|
||||
QVector<quint16> *_blocks;
|
||||
const QString *_path;
|
||||
};
|
||||
|
||||
#endif // SUBFILE_H
|
||||
}
|
||||
|
||||
#endif // IMG_SUBFILE_H
|
||||
|
@ -1,17 +0,0 @@
|
||||
#include "textitem.h"
|
||||
|
||||
bool TextItem::collides(const QList<TextItem*> &list) const
|
||||
{
|
||||
QRectF r1(boundingRect());
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
const TextItem* other = list.at(i);
|
||||
QRectF r2(other->boundingRect());
|
||||
|
||||
if (!(r1.isEmpty() || r2.isEmpty() || !r1.intersects(r2)))
|
||||
if (other->shape().intersects(shape()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
#ifndef TEXTITEM_H
|
||||
#define TEXTITEM_H
|
||||
|
||||
#include <QList>
|
||||
#include <QRectF>
|
||||
#include <QPainterPath>
|
||||
|
||||
class QPainter;
|
||||
|
||||
class TextItem
|
||||
{
|
||||
public:
|
||||
TextItem(const QString *text) : _text(text) {}
|
||||
virtual ~TextItem() {}
|
||||
|
||||
virtual QPainterPath shape() const = 0;
|
||||
virtual QRectF boundingRect() const = 0;
|
||||
virtual void paint(QPainter *painter) const = 0;
|
||||
|
||||
const QString *text() const {return _text;}
|
||||
bool collides(const QList<TextItem*> &list) const;
|
||||
|
||||
protected:
|
||||
const QString *_text;
|
||||
};
|
||||
|
||||
#endif // TEXTITEM_H
|
@ -1,261 +0,0 @@
|
||||
#include <QFont>
|
||||
#include <QPainter>
|
||||
#include "textpathitem.h"
|
||||
|
||||
|
||||
#define MAX_TEXT_ANGLE 30
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
#define INTERSECTS intersect
|
||||
#else // QT 5.15
|
||||
#define INTERSECTS intersects
|
||||
#endif // QT 5.15
|
||||
|
||||
|
||||
static bool intersection(const QLineF &line, const QRectF &rect, QPointF *p)
|
||||
{
|
||||
if (line.INTERSECTS(QLineF(rect.topLeft(), rect.topRight()), p)
|
||||
== QLineF::BoundedIntersection)
|
||||
return true;
|
||||
if (line.INTERSECTS(QLineF(rect.topLeft(), rect.bottomLeft()), p)
|
||||
== QLineF::BoundedIntersection)
|
||||
return true;
|
||||
if (line.INTERSECTS(QLineF(rect.bottomRight(), rect.bottomLeft()), p)
|
||||
== QLineF::BoundedIntersection)
|
||||
return true;
|
||||
if (line.INTERSECTS(QLineF(rect.bottomRight(), rect.topRight()), p)
|
||||
== QLineF::BoundedIntersection)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool intersection(const QLineF &line, const QRectF &rect, QPointF *p1,
|
||||
QPointF *p2)
|
||||
{
|
||||
QPointF *p = p1;
|
||||
|
||||
if (line.INTERSECTS(QLineF(rect.topLeft(), rect.topRight()), p)
|
||||
== QLineF::BoundedIntersection)
|
||||
p = p2;
|
||||
if (line.INTERSECTS(QLineF(rect.topLeft(), rect.bottomLeft()), p)
|
||||
== QLineF::BoundedIntersection) {
|
||||
if (p == p2)
|
||||
return true;
|
||||
p = p2;
|
||||
}
|
||||
if (line.INTERSECTS(QLineF(rect.bottomRight(), rect.bottomLeft()), p)
|
||||
== QLineF::BoundedIntersection) {
|
||||
if (p == p2)
|
||||
return true;
|
||||
p = p2;
|
||||
}
|
||||
if (line.INTERSECTS(QLineF(rect.bottomRight(), rect.topRight()), p)
|
||||
== QLineF::BoundedIntersection) {
|
||||
if (p == p2)
|
||||
return true;
|
||||
}
|
||||
|
||||
Q_ASSERT(p != p2);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static QPainterPath subpath(const QList<QLineF> &lines, int start, int end,
|
||||
qreal cut)
|
||||
{
|
||||
qreal ss = 0, es = 0;
|
||||
int si = start, ei = end;
|
||||
|
||||
for (int i = start; i <= end; i++) {
|
||||
qreal len = lines.at(i).length();
|
||||
if (ss + len < cut / 2) {
|
||||
ss += len;
|
||||
si++;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
for (int i = end; i >= start; i--) {
|
||||
qreal len = lines.at(i).length();
|
||||
if (es + len < cut / 2) {
|
||||
es += len;
|
||||
ei--;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
QLineF sl(lines.at(si).p2(), lines.at(si).p1());
|
||||
sl.setLength(sl.length() - (cut / 2 - ss));
|
||||
QLineF el(lines.at(ei));
|
||||
el.setLength(el.length() - (cut / 2 - es));
|
||||
|
||||
QPainterPath p(sl.p2());
|
||||
for (int i = si; i <= ei; i++)
|
||||
p.lineTo(lines.at(i).p2());
|
||||
p.setElementPositionAt(p.elementCount() - 1, el.p2().x(), el.p2().y());
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static QList<QLineF> lineString(const QPolygonF &path,
|
||||
const QRectF &boundingRect)
|
||||
{
|
||||
QList<QLineF> lines;
|
||||
int start = -1, end = -1;
|
||||
|
||||
|
||||
for (int i = 0; i < path.count(); i++) {
|
||||
if (boundingRect.contains(path.at(i))) {
|
||||
start = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = path.count() - 1; i >= 0; i--) {
|
||||
if (boundingRect.contains(path.at(i))) {
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
QPointF p1, p2;
|
||||
|
||||
for (int i = 1; i < path.count(); i++) {
|
||||
QLineF l(path.at(i-1), path.at(i));
|
||||
if (intersection(l, boundingRect, &p1, &p2)) {
|
||||
lines.append(QLineF(p1, p2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QPointF p;
|
||||
|
||||
if (start > 0) {
|
||||
QLineF l(path.at(start-1), path.at(start));
|
||||
if (intersection(l, boundingRect, &p))
|
||||
lines.append(QLineF(p, path.at(start)));
|
||||
}
|
||||
for (int i = start + 1; i <= end; i++)
|
||||
lines.append(QLineF(path.at(i-1), path.at(i)));
|
||||
if (end < path.count() - 1) {
|
||||
QLineF l(path.at(end), path.at(end+1));
|
||||
if (intersection(l, boundingRect, &p))
|
||||
lines.append(QLineF(path.at(end), p));
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
static QPainterPath textPath(const QPolygonF &path, qreal textWidth,
|
||||
qreal charWidth, const QRectF &tileRect)
|
||||
{
|
||||
QList<QLineF> lines(lineString(path, tileRect));
|
||||
if (lines.isEmpty())
|
||||
return QPainterPath();
|
||||
qreal length = 0;
|
||||
qreal angle = lines.first().angle();
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
qreal sl = lines.at(i).length();
|
||||
qreal a = lines.at(i).angle();
|
||||
|
||||
if (!tileRect.contains(lines.at(i).p2()) || sl < charWidth
|
||||
|| qAbs(angle - a) > MAX_TEXT_ANGLE) {
|
||||
if (length > textWidth)
|
||||
return subpath(lines, last, i - 1, length - textWidth);
|
||||
last = i;
|
||||
length = 0;
|
||||
} else
|
||||
length += sl;
|
||||
|
||||
angle = a;
|
||||
}
|
||||
|
||||
return (length > textWidth)
|
||||
? subpath(lines, last, lines.size() - 1, length - textWidth)
|
||||
: QPainterPath();
|
||||
}
|
||||
|
||||
static bool reverse(const QPainterPath &path)
|
||||
{
|
||||
QLineF l(path.elementAt(0), path.elementAt(1));
|
||||
qreal angle = l.angle();
|
||||
return (angle > 90 && angle < 270) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
TextPathItem::TextPathItem(const QPolygonF &line, const QString *label,
|
||||
const QRect &tileRect, const QFont *font, const QColor *color)
|
||||
: TextItem(label), _font(font), _color(color)
|
||||
{
|
||||
qreal cw = font->pixelSize() * 0.6;
|
||||
qreal textWidth = _text->size() * cw;
|
||||
qreal mw = font->pixelSize() / 2;
|
||||
_path = textPath(line, textWidth, cw, tileRect.adjusted(mw, mw, -mw, -mw));
|
||||
if (_path.isEmpty())
|
||||
return;
|
||||
|
||||
if (reverse(_path))
|
||||
_path = _path.toReversed();
|
||||
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(font->pixelSize());
|
||||
s.setCapStyle(Qt::FlatCap);
|
||||
_shape = s.createStroke(_path).simplified();
|
||||
_rect = _shape.boundingRect();
|
||||
}
|
||||
|
||||
void TextPathItem::paint(QPainter *painter) const
|
||||
{
|
||||
QFontMetrics fm(*_font);
|
||||
int textWidth = fm.boundingRect(*_text).width();
|
||||
|
||||
qreal factor = (textWidth) / qMax(_path.length(), (qreal)textWidth);
|
||||
qreal percent = (1.0 - factor) / 2.0;
|
||||
|
||||
QTransform t = painter->transform();
|
||||
|
||||
painter->setFont(*_font);
|
||||
painter->setPen(Qt::white);
|
||||
|
||||
for (int i = 0; i < _text->size(); i++) {
|
||||
QPointF point = _path.pointAtPercent(percent);
|
||||
qreal angle = _path.angleAtPercent(percent);
|
||||
|
||||
painter->translate(point);
|
||||
painter->rotate(-angle);
|
||||
painter->drawText(QPoint(-1, fm.descent() - 1), _text->at(i));
|
||||
painter->drawText(QPoint(1, fm.descent() + 1), _text->at(i));
|
||||
painter->drawText(QPoint(-1, fm.descent() + 1), _text->at(i));
|
||||
painter->drawText(QPoint(1, fm.descent() -1), _text->at(i));
|
||||
painter->drawText(QPoint(0, fm.descent() - 1), _text->at(i));
|
||||
painter->drawText(QPoint(0, fm.descent() + 1), _text->at(i));
|
||||
painter->drawText(QPoint(-1, fm.descent()), _text->at(i));
|
||||
painter->drawText(QPoint(1, fm.descent()), _text->at(i));
|
||||
painter->setTransform(t);
|
||||
|
||||
int width = fm.horizontalAdvance(_text->at(i));
|
||||
percent += ((qreal)width / (qreal)textWidth) * factor;
|
||||
}
|
||||
percent = (1.0 - factor) / 2.0;
|
||||
|
||||
painter->setPen(_color ? *_color : Qt::black);
|
||||
for (int i = 0; i < _text->size(); i++) {
|
||||
QPointF point = _path.pointAtPercent(percent);
|
||||
qreal angle = _path.angleAtPercent(percent);
|
||||
|
||||
painter->translate(point);
|
||||
painter->rotate(-angle);
|
||||
painter->drawText(QPoint(0, fm.descent()), _text->at(i));
|
||||
painter->setTransform(t);
|
||||
|
||||
int width = fm.horizontalAdvance(_text->at(i));
|
||||
percent += ((qreal)width / (qreal)textWidth) * factor;
|
||||
}
|
||||
|
||||
//painter->setPen(Qt::red);
|
||||
//painter->drawPath(_shape);
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#ifndef TEXTPATHITEM_H
|
||||
#define TEXTPATHITEM_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QPainterPath>
|
||||
#include "textitem.h"
|
||||
|
||||
class TextPathItem : public TextItem
|
||||
{
|
||||
public:
|
||||
TextPathItem() : TextItem(0), _font(0), _color(0) {}
|
||||
TextPathItem(const QPolygonF &line, const QString *label,
|
||||
const QRect &tileRect, const QFont *font, const QColor *color);
|
||||
|
||||
bool isValid() const {return !_path.isEmpty();}
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _rect;}
|
||||
void paint(QPainter *painter) const;
|
||||
|
||||
private:
|
||||
const QFont *_font;
|
||||
const QColor *_color;
|
||||
QPainterPath _path;
|
||||
QRectF _rect;
|
||||
QPainterPath _shape;
|
||||
};
|
||||
|
||||
#endif // TEXTPATHITEM_H
|
@ -1,98 +0,0 @@
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include "textpointitem.h"
|
||||
|
||||
|
||||
#define FLAGS (Qt::AlignCenter | Qt::TextWordWrap | Qt::TextDontClip)
|
||||
#define MAX_TEXT_WIDTH 8
|
||||
#define MIN_BOX_WIDTH 2
|
||||
|
||||
|
||||
static void expand(QRect &rect, int width)
|
||||
{
|
||||
rect.adjust(-(width/2 - rect.width()/2), 0, width/2 - rect.width()/2, 0);
|
||||
}
|
||||
|
||||
TextPointItem::TextPointItem(const QPoint &point, const QString *text,
|
||||
const QFont *font, const QImage *img, const QColor *color,
|
||||
const QColor *bgColor) : TextItem(font ? text : 0), _font(font), _img(img),
|
||||
_color(color), _bgColor(bgColor)
|
||||
{
|
||||
if (_text) {
|
||||
QFontMetrics fm(*_font);
|
||||
int limit = _font->pixelSize() * MAX_TEXT_WIDTH;
|
||||
_textRect = fm.boundingRect(QRect(0, 0, limit, 0), FLAGS, *_text);
|
||||
_textRect.adjust(0, 0, 1, 1);
|
||||
|
||||
if (_bgColor && _textRect.width() < _font->pixelSize() * MIN_BOX_WIDTH)
|
||||
expand(_textRect, _font->pixelSize() * MIN_BOX_WIDTH);
|
||||
}
|
||||
|
||||
setPos(point);
|
||||
}
|
||||
|
||||
void TextPointItem::setPos(const QPoint &point)
|
||||
{
|
||||
QPainterPath shape;
|
||||
QRect iconRect;
|
||||
|
||||
if (_img) {
|
||||
iconRect = QRect(QPoint(point.x() - _img->width()/2, point.y()
|
||||
- _img->height()/2), _img->size());
|
||||
_textRect.moveTopLeft(QPoint(point.x() + _img->width(), point.y()
|
||||
- _textRect.height()/2));
|
||||
} else
|
||||
_textRect.moveCenter(point);
|
||||
|
||||
_rect = _textRect | iconRect;
|
||||
shape.addRect(_rect);
|
||||
_shape = shape;
|
||||
}
|
||||
|
||||
void TextPointItem::paint(QPainter *painter) const
|
||||
{
|
||||
if (_img)
|
||||
painter->drawImage(QPoint(_rect.left(), _rect.center().y()
|
||||
- _img->height()/2), *_img);
|
||||
|
||||
if (_text) {
|
||||
if (_bgColor) {
|
||||
painter->setPen(*_color);
|
||||
painter->setBrush(*_bgColor);
|
||||
painter->drawRect(_textRect);
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->setFont(*_font);
|
||||
painter->drawText(_textRect, FLAGS, *_text);
|
||||
} else {
|
||||
QImage img(_textRect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
img.fill(Qt::transparent);
|
||||
QPainter ip(&img);
|
||||
ip.setPen(Qt::white);
|
||||
ip.setFont(*_font);
|
||||
ip.drawText(img.rect(), FLAGS, *_text);
|
||||
|
||||
painter->drawImage(_textRect.x() - 1, _textRect.y() - 1, img);
|
||||
painter->drawImage(_textRect.x() + 1, _textRect.y() + 1, img);
|
||||
painter->drawImage(_textRect.x() - 1, _textRect.y() + 1, img);
|
||||
painter->drawImage(_textRect.x() + 1, _textRect.y() - 1, img);
|
||||
painter->drawImage(_textRect.x(), _textRect.y() - 1, img);
|
||||
painter->drawImage(_textRect.x(), _textRect.y() + 1, img);
|
||||
painter->drawImage(_textRect.x() - 1, _textRect.y(), img);
|
||||
painter->drawImage(_textRect.x() + 1, _textRect.y(), img);
|
||||
|
||||
if (_color) {
|
||||
painter->setFont(*_font);
|
||||
painter->setPen(*_color);
|
||||
painter->drawText(_textRect, FLAGS, *_text);
|
||||
} else {
|
||||
img.invertPixels();
|
||||
painter->drawImage(_textRect, img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//painter->setPen(Qt::red);
|
||||
//painter->drawRect(_rect);
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#ifndef TEXTPOINTITEM_H
|
||||
#define TEXTPOINTITEM_H
|
||||
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include "textitem.h"
|
||||
|
||||
class QPainter;
|
||||
class QFont;
|
||||
class QImage;
|
||||
class QColor;
|
||||
|
||||
class TextPointItem : public TextItem
|
||||
{
|
||||
public:
|
||||
TextPointItem() : TextItem(0), _font(0), _img(0) {}
|
||||
TextPointItem(const QPoint &point, const QString *text, const QFont *font,
|
||||
const QImage *img, const QColor *color, const QColor *bgColor = 0);
|
||||
|
||||
bool isValid() const {return !_rect.isEmpty();}
|
||||
|
||||
QRectF boundingRect() const {return _rect;}
|
||||
QPainterPath shape() const {return _shape;}
|
||||
void paint(QPainter *painter) const;
|
||||
|
||||
void setPos(const QPoint &point);
|
||||
|
||||
private:
|
||||
const QFont *_font;
|
||||
const QImage *_img;
|
||||
const QColor *_color, *_bgColor;
|
||||
QRect _rect, _textRect;
|
||||
QPainterPath _shape;
|
||||
};
|
||||
|
||||
#endif // TEXTPOINTITEM_H
|
@ -2,6 +2,7 @@
|
||||
#include "subdiv.h"
|
||||
#include "trefile.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
static inline double RB(qint32 val)
|
||||
{
|
||||
@ -329,12 +330,3 @@ QList<SubDiv*> TREFile::subdivs(const RectC &rect, int bits, bool baseMap)
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const TREFile::MapLevel &level)
|
||||
{
|
||||
dbg.nospace() << "MapLevel(" << level.level << ", " << level.bits << ", "
|
||||
<< level.subdivs << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef TREFILE_H
|
||||
#define TREFILE_H
|
||||
#ifndef IMG_TREFILE_H
|
||||
#define IMG_TREFILE_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
@ -8,12 +8,14 @@
|
||||
#include "common/rtree.h"
|
||||
#include "subfile.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class SubDiv;
|
||||
|
||||
class TREFile : public SubFile
|
||||
{
|
||||
public:
|
||||
TREFile(const IMG *img) : SubFile(img) {}
|
||||
TREFile(const IMGData *img) : SubFile(img) {}
|
||||
TREFile(const QString *path) : SubFile(path) {}
|
||||
TREFile(const SubFile *gmp, quint32 offset) : SubFile(gmp, offset) {}
|
||||
~TREFile();
|
||||
@ -49,8 +51,6 @@ private:
|
||||
int readExtEntry(Handle &hdl, quint32 &polygons, quint32 &lines,
|
||||
quint32 &points);
|
||||
|
||||
friend QDebug operator<<(QDebug dbg, const MapLevel &level);
|
||||
|
||||
RectC _bounds;
|
||||
QVector<MapLevel> _levels;
|
||||
quint32 _subdivOffset;
|
||||
@ -62,8 +62,6 @@ private:
|
||||
QMap<int, SubDivTree*> _subdivs;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const TREFile::MapLevel &level);
|
||||
#endif // QT_NO_DEBUG
|
||||
}
|
||||
|
||||
#endif // TREFILE_H
|
||||
#endif // IMG_TREFILE_H
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "vectortile.h"
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
static void copyPolys(const RectC &rect, QList<MapData::Poly> *src,
|
||||
QList<MapData::Poly> *dst)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef VECTORTILE_H
|
||||
#define VECTORTILE_H
|
||||
#ifndef IMG_VECTORTILE_H
|
||||
#define IMG_VECTORTILE_H
|
||||
|
||||
#include "trefile.h"
|
||||
#include "rgnfile.h"
|
||||
@ -7,6 +7,8 @@
|
||||
#include "netfile.h"
|
||||
#include "nodfile.h"
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class VectorTile {
|
||||
public:
|
||||
VectorTile()
|
||||
@ -82,8 +84,10 @@ private:
|
||||
int _loaded;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const VectorTile &tile);
|
||||
QDebug operator<<(QDebug dbg, const IMG::VectorTile &tile);
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // VECTORTILE_H
|
||||
#endif // IMG_VECTORTILE_H
|
||||
|
Reference in New Issue
Block a user