2019-05-10 18:56:19 +02:00
|
|
|
#ifndef TREFILE_H
|
|
|
|
#define TREFILE_H
|
|
|
|
|
|
|
|
#include <QVector>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QRect>
|
|
|
|
#include "common/rectc.h"
|
|
|
|
#include "common/rtree.h"
|
|
|
|
#include "subfile.h"
|
|
|
|
|
|
|
|
class SubDiv;
|
|
|
|
|
|
|
|
class TREFile : public SubFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TREFile(IMG *img, quint32 size) : SubFile(img, size) {}
|
|
|
|
~TREFile();
|
|
|
|
|
|
|
|
bool init();
|
2019-07-04 18:18:03 +02:00
|
|
|
void clear();
|
2019-05-10 18:56:19 +02:00
|
|
|
|
|
|
|
const RectC &bounds() const {return _bounds;}
|
2019-07-04 09:05:30 +02:00
|
|
|
QList<SubDiv*> subdivs(const RectC &rect, int bits);
|
2019-05-10 18:56:19 +02:00
|
|
|
|
|
|
|
private:
|
2019-07-16 22:08:23 +02:00
|
|
|
struct MapLevel {
|
|
|
|
quint8 level;
|
|
|
|
quint8 bits;
|
|
|
|
quint16 subdivs;
|
|
|
|
};
|
|
|
|
struct Extended {
|
|
|
|
quint32 offset;
|
|
|
|
quint32 size;
|
|
|
|
quint16 itemSize;
|
|
|
|
|
|
|
|
Extended() : offset(0), size(0), itemSize(0) {}
|
|
|
|
};
|
2019-05-10 18:56:19 +02:00
|
|
|
typedef RTree<SubDiv*, double, 2> SubDivTree;
|
|
|
|
|
2019-07-16 22:08:23 +02:00
|
|
|
bool load(int idx);
|
2019-07-04 09:05:30 +02:00
|
|
|
int level(int bits);
|
2019-05-10 18:56:19 +02:00
|
|
|
bool parsePoly(Handle hdl, quint32 pos, const QMap<int, int> &level2bits,
|
|
|
|
QMap<quint32, int> &map);
|
|
|
|
bool parsePoints(Handle hdl, quint32 pos, const QMap<int, int> &level2bits);
|
|
|
|
|
2019-07-16 22:08:23 +02:00
|
|
|
friend QDebug operator<<(QDebug dbg, const MapLevel &level);
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
RectC _bounds;
|
2019-07-16 22:08:23 +02:00
|
|
|
QVector<MapLevel> _levels;
|
|
|
|
quint32 _subdivOffset;
|
|
|
|
Extended _extended;
|
|
|
|
int _firstLevel;
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
QMap<int, SubDivTree*> _subdivs;
|
|
|
|
};
|
|
|
|
|
2019-07-16 22:08:23 +02:00
|
|
|
#ifndef QT_NO_DEBUG
|
|
|
|
QDebug operator<<(QDebug dbg, const TREFile::MapLevel &level);
|
|
|
|
#endif // QT_NO_DEBUG
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
#endif // TREFILE_H
|