2019-05-10 18:56:19 +02:00
|
|
|
#include <QImage>
|
2020-02-17 19:21:36 +01:00
|
|
|
#include <QPainter>
|
2019-05-10 18:56:19 +02:00
|
|
|
#include "style.h"
|
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
using namespace IMG;
|
2019-05-10 18:56:19 +02:00
|
|
|
|
|
|
|
void Style::defaultPolygonStyle()
|
|
|
|
{
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[TYPE(0x01)] = Polygon(QBrush("#dfd3b5"));
|
|
|
|
_polygons[TYPE(0x02)] = Polygon(QBrush("#dfd3b5"));
|
|
|
|
_polygons[TYPE(0x03)] = Polygon(QBrush("#dfd3b5"));
|
|
|
|
_polygons[TYPE(0x04)] = Polygon(QBrush("#ff4040", Qt::BDiagPattern));
|
|
|
|
_polygons[TYPE(0x05)] = Polygon(QBrush("#d6d4ce"));
|
|
|
|
_polygons[TYPE(0x06)] = Polygon(QBrush("#d6d4ce"));
|
|
|
|
_polygons[TYPE(0x07)] = Polygon(QBrush("#d6d4ce"));
|
|
|
|
_polygons[TYPE(0x08)] = Polygon(QBrush("#d6d4ce"));
|
|
|
|
_polygons[TYPE(0x09)] = Polygon(QBrush("#d6d4ce"));
|
|
|
|
_polygons[TYPE(0x0a)] = Polygon(QBrush("#d6d4ce"));
|
|
|
|
_polygons[TYPE(0x0b)] = Polygon(QBrush("#d6d4ce"));
|
|
|
|
_polygons[TYPE(0x0c)] = Polygon(QBrush("#d6d4ce"));
|
|
|
|
_polygons[TYPE(0x0d)] = Polygon(QBrush("#f8e3be"));
|
|
|
|
_polygons[TYPE(0x0e)] = Polygon(QBrush("#ffffff"));
|
|
|
|
_polygons[TYPE(0x0f)] = Polygon(QBrush("#e6e2d9"));
|
|
|
|
_polygons[TYPE(0x10)] = Polygon(QBrush("#e6e2d9"));
|
|
|
|
_polygons[TYPE(0x11)] = Polygon(QBrush("#e6e2d9"));
|
|
|
|
_polygons[TYPE(0x12)] = Polygon(QBrush("#e6e2d9"));
|
|
|
|
_polygons[TYPE(0x13)] = Polygon(QBrush("#dbd0b6"),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#cdccc4"), 1));
|
2020-04-15 22:48:02 +02:00
|
|
|
_polygons[TYPE(0x14)] = Polygon(QBrush("#cadfaf"));
|
|
|
|
_polygons[TYPE(0x15)] = Polygon(QBrush("#cadfaf"));
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[TYPE(0x16)] = Polygon(QBrush(QColor("#9ac269"),
|
2019-05-11 00:24:31 +02:00
|
|
|
Qt::BDiagPattern));
|
2020-04-15 22:48:02 +02:00
|
|
|
_polygons[TYPE(0x17)] = Polygon(QBrush("#e4efcf"));
|
|
|
|
_polygons[TYPE(0x18)] = Polygon(QBrush("#e3edc6"));
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[TYPE(0x19)] = Polygon(QBrush("#e3edc6"), QPen("#c9d3a5"));
|
|
|
|
_polygons[TYPE(0x1a)] = Polygon(QBrush("#000000", Qt::Dense6Pattern),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#cdccc4"), 1));
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[TYPE(0x1e)] = Polygon(QBrush(QColor("#9ac269"),
|
2019-05-11 00:24:31 +02:00
|
|
|
Qt::BDiagPattern));
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[TYPE(0x1f)] = Polygon(QBrush(QColor("#9ac269"),
|
2019-05-11 00:24:31 +02:00
|
|
|
Qt::BDiagPattern));
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[TYPE(0x28)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x32)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x3c)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x3d)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x3e)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x3f)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x40)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x41)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x42)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x43)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x44)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x46)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x47)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x48)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x49)] = Polygon(QBrush("#9fc4e1"));
|
|
|
|
_polygons[TYPE(0x4a)] = Polygon(QBrush("#f1f0e5"), QPen("#f1f0e5"));
|
2020-10-16 00:03:26 +02:00
|
|
|
_polygons[TYPE(0x4b)] = Polygon(QBrush("#f1f0e5"), QPen("#f1f0e5"));
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[TYPE(0x4c)] = Polygon(QBrush("#9fc4e1", Qt::Dense6Pattern));
|
|
|
|
_polygons[TYPE(0x4d)] = Polygon(QBrush("#ddf1fd"));
|
2020-04-08 00:00:43 +02:00
|
|
|
_polygons[TYPE(0x4e)] = Polygon(QBrush("#f8f8f8"));
|
2020-04-15 22:48:02 +02:00
|
|
|
_polygons[TYPE(0x4f)] = Polygon(QBrush("#e4efcf"));
|
|
|
|
_polygons[TYPE(0x50)] = Polygon(QBrush("#cadfaf"));
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[TYPE(0x51)] = Polygon(QBrush("#9fc4e1", Qt::Dense4Pattern));
|
2020-04-15 22:48:02 +02:00
|
|
|
_polygons[TYPE(0x52)] = Polygon(QBrush("#cadfaf"));
|
2019-05-10 18:56:19 +02:00
|
|
|
|
2020-10-16 00:03:26 +02:00
|
|
|
// NT types
|
|
|
|
_polygons[0x10800] = _polygons[TYPE(0x01)];
|
|
|
|
_polygons[0x10801] = _polygons[TYPE(0x02)];
|
|
|
|
_polygons[0x10802] = _polygons[TYPE(0x03)];
|
|
|
|
_polygons[0x10901] = _polygons[TYPE(0x04)];
|
|
|
|
_polygons[0x10902] = _polygons[TYPE(0x05)];
|
|
|
|
_polygons[0x10903] = _polygons[TYPE(0x06)];
|
|
|
|
_polygons[0x10904] = _polygons[TYPE(0x07)];
|
|
|
|
_polygons[0x10905] = _polygons[TYPE(0x08)];
|
|
|
|
_polygons[0x10906] = _polygons[TYPE(0x09)];
|
|
|
|
_polygons[0x10907] = _polygons[TYPE(0x0a)];
|
|
|
|
_polygons[0x10908] = _polygons[TYPE(0x0b)];
|
|
|
|
_polygons[0x10909] = _polygons[TYPE(0x0c)];
|
|
|
|
_polygons[0x1090a] = _polygons[TYPE(0x0d)];
|
|
|
|
_polygons[0x1090b] = _polygons[TYPE(0x0e)];
|
|
|
|
_polygons[0x10900] = _polygons[TYPE(0x13)];
|
|
|
|
_polygons[0x10a01] = _polygons[TYPE(0x14)];
|
|
|
|
_polygons[0x10a02] = _polygons[TYPE(0x15)];
|
|
|
|
_polygons[0x10a03] = _polygons[TYPE(0x16)];
|
|
|
|
_polygons[0x10a04] = _polygons[TYPE(0x17)];
|
|
|
|
_polygons[0x1090c] = _polygons[TYPE(0x18)];
|
|
|
|
_polygons[0x1090d] = _polygons[TYPE(0x19)];
|
|
|
|
_polygons[0x1090e] = _polygons[TYPE(0x1a)];
|
|
|
|
_polygons[0x10a05] = _polygons[TYPE(0x1e)];
|
|
|
|
_polygons[0x10a06] = _polygons[TYPE(0x1f)];
|
|
|
|
_polygons[0x10b01] = _polygons[TYPE(0x28)];
|
|
|
|
_polygons[0x10b02] = _polygons[TYPE(0x32)];
|
|
|
|
_polygons[0x10b03] = _polygons[TYPE(0x3c)];
|
|
|
|
_polygons[0x10b04] = _polygons[TYPE(0x3d)];
|
|
|
|
_polygons[0x10b05] = _polygons[TYPE(0x3e)];
|
|
|
|
_polygons[0x10b06] = _polygons[TYPE(0x3f)];
|
|
|
|
_polygons[0x10b07] = _polygons[TYPE(0x40)];
|
|
|
|
_polygons[0x10b08] = _polygons[TYPE(0x41)];
|
|
|
|
_polygons[0x10b09] = _polygons[TYPE(0x42)];
|
|
|
|
_polygons[0x10b0a] = _polygons[TYPE(0x43)];
|
|
|
|
_polygons[0x10b0b] = _polygons[TYPE(0x44)];
|
|
|
|
_polygons[0x10b0c] = _polygons[TYPE(0x46)];
|
|
|
|
_polygons[0x10b0d] = _polygons[TYPE(0x47)];
|
|
|
|
_polygons[0x10b0e] = _polygons[TYPE(0x48)];
|
|
|
|
_polygons[0x10b0f] = _polygons[TYPE(0x49)];
|
|
|
|
_polygons[0x10d01] = _polygons[TYPE(0x4b)];
|
|
|
|
_polygons[0x10b10] = _polygons[TYPE(0x4c)];
|
|
|
|
_polygons[0x10c00] = _polygons[TYPE(0x4d)];
|
|
|
|
_polygons[0x10c01] = _polygons[TYPE(0x4e)];
|
|
|
|
_polygons[0x10c02] = _polygons[TYPE(0x4f)];
|
|
|
|
_polygons[0x10c03] = _polygons[TYPE(0x50)];
|
|
|
|
_polygons[0x10c04] = _polygons[TYPE(0x51)];
|
|
|
|
_polygons[0x10c05] = _polygons[TYPE(0x52)];
|
|
|
|
|
|
|
|
// Draw order
|
2021-01-25 21:37:07 +01:00
|
|
|
_drawOrder
|
|
|
|
<< TYPE(0x4b) << 0x10d01 << 0x10613 << TYPE(0x4a) << TYPE(0x01) << 0x10800
|
2020-10-16 00:03:26 +02:00
|
|
|
<< TYPE(0x02) << 0x10801 << TYPE(0x03) << 0x10802 << TYPE(0x17) << 0x10a04
|
|
|
|
<< TYPE(0x18) << 0x1090c << TYPE(0x1a) << 0x1090e << TYPE(0x28) << 0x10b01
|
|
|
|
<< TYPE(0x32) << 0x10b02 << TYPE(0x3c) << 0x10b03 << TYPE(0x3d) << 0x10b04
|
|
|
|
<< TYPE(0x3e) << 0x10b05 << TYPE(0x3f) << 0x10b06 << TYPE(0x40) << 0x10b07
|
|
|
|
<< TYPE(0x41) << 0x10b08 << TYPE(0x42) << 0x10b09 << TYPE(0x43) << 0x10b0a
|
|
|
|
<< TYPE(0x44) << 0x10b0b << TYPE(0x46) << 0x10b0c << TYPE(0x47) << 0x10b0d
|
|
|
|
<< TYPE(0x48) << 0x10b0e << TYPE(0x49) << 0x10b0f << TYPE(0x4c) << 0x10b10
|
|
|
|
<< TYPE(0x4d) << 0x10c00 << TYPE(0x4e) << 0x10c01 << TYPE(0x4f) << 0x10c02
|
|
|
|
<< TYPE(0x50) << 0x10c03 << TYPE(0x51) << 0x10c04 << TYPE(0x52) << 0x10c05
|
|
|
|
<< TYPE(0x14) << 0x10a01 << TYPE(0x15) << 0x10a02 << TYPE(0x16) << 0x10a03
|
|
|
|
<< TYPE(0x1e) << 0x10a05 << TYPE(0x1f) << 0x10a06 << TYPE(0x04) << 0x10901
|
|
|
|
<< TYPE(0x05) << 0x10902 << TYPE(0x06) << 0x10903 << TYPE(0x07) << 0x10904
|
|
|
|
<< TYPE(0x08) << 0x10905 << TYPE(0x09) << 0x10906 << TYPE(0x0a) << 0x10907
|
|
|
|
<< TYPE(0x0b) << 0x10908 << TYPE(0x0c) << 0x10909 << TYPE(0x0d) << 0x1090a
|
|
|
|
<< TYPE(0x0e) << 0x1090b << TYPE(0x0f) << TYPE(0x10) << TYPE(0x11)
|
|
|
|
<< TYPE(0x12) << TYPE(0x19) << 0x1090d << TYPE(0x13) << 0x10900;
|
2019-05-10 18:56:19 +02:00
|
|
|
}
|
|
|
|
|
2020-02-17 19:21:36 +01:00
|
|
|
static QImage railroad()
|
2019-05-10 18:56:19 +02:00
|
|
|
{
|
2020-02-17 19:21:36 +01:00
|
|
|
QImage img(16, 4, QImage::Format_ARGB32_Premultiplied);
|
|
|
|
img.fill(QColor("#717171"));
|
|
|
|
QPainter p(&img);
|
|
|
|
p.setPen(QPen(Qt::white, 2));
|
|
|
|
p.drawLine(9, 2, 15, 2);
|
|
|
|
|
|
|
|
return img;
|
|
|
|
}
|
2019-05-10 18:56:19 +02:00
|
|
|
|
2020-02-17 19:21:36 +01:00
|
|
|
void Style::defaultLineStyle()
|
|
|
|
{
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x01)] = Line(QPen(QColor("#9bd772"), 2, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#72a35a"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x02)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x03)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x04)] = Line(QPen(QColor("#faef75"), 3, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#dbd27b"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x05)] = Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x06)] = Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x07)] = Line(QPen(QColor("#ffffff"), 2, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#d5cdc0"), 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x08)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x09)] = Line(QPen(QColor("#9bd772"), 2, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#72a35a"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x0a)] = Line(QPen(QColor("#aba083"), 1, Qt::DashLine));
|
|
|
|
_lines[TYPE(0x0b)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x0c)] = Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-02-17 19:21:36 +01:00
|
|
|
_lines[TYPE(0x14)] = Line(railroad());
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x16)] = Line(QPen(QColor("#aba083"), 1, Qt::DotLine));
|
|
|
|
_lines[TYPE(0x18)] = Line(QPen(QColor("#9fc4e1"), 2, Qt::SolidLine));
|
2019-05-10 18:56:19 +02:00
|
|
|
_lines[TYPE(0x18)].setTextColor(QColor("#9fc4e1"));
|
2020-01-24 19:44:19 +01:00
|
|
|
//_lines[TYPE(0x1a)] = Line(QPen(QColor("#7697b7"), 1, Qt::DashLine));
|
|
|
|
_lines[TYPE(0x1b)] = Line(QPen(QColor("#7697b7"), 1, Qt::DashLine));
|
2020-02-16 20:31:09 +01:00
|
|
|
_lines[TYPE(0x1c)] = Line(QPen(QColor("#505145"), 1, Qt::DashLine));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x1e)] = Line(QPen(QColor("#505145"), 2, Qt::DashDotLine));
|
|
|
|
_lines[TYPE(0x1f)] = Line(QPen(QColor("#9fc4e1"), 3, Qt::SolidLine));
|
2019-05-10 18:56:19 +02:00
|
|
|
_lines[TYPE(0x1f)].setTextColor(QColor("#9fc4e1"));
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[TYPE(0x20)] = Line(QPen(QColor("#cfcfcf"), 1, Qt::SolidLine));
|
|
|
|
_lines[TYPE(0x20)].setTextFontSize(None);
|
|
|
|
_lines[TYPE(0x21)] = Line(QPen(QColor("#bfbfbf"), 1, Qt::SolidLine));
|
|
|
|
_lines[TYPE(0x21)].setTextColor(QColor("#666666"));
|
|
|
|
_lines[TYPE(0x21)].setTextFontSize(Small);
|
|
|
|
_lines[TYPE(0x22)] = Line(QPen(QColor("#afafaf"), 1, Qt::SolidLine));
|
|
|
|
_lines[TYPE(0x22)].setTextColor(QColor("#666666"));
|
|
|
|
_lines[TYPE(0x22)].setTextFontSize(Small);
|
|
|
|
_lines[TYPE(0x23)] = Line(QPen(QColor("#55aaff"), 1, Qt::SolidLine));
|
|
|
|
_lines[TYPE(0x23)].setTextFontSize(None);
|
|
|
|
_lines[TYPE(0x24)] = Line(QPen(QColor("#659aef"), 1, Qt::SolidLine));
|
|
|
|
_lines[TYPE(0x24)].setTextColor(QColor("#558adf"));
|
|
|
|
_lines[TYPE(0x24)].setTextFontSize(Small);
|
|
|
|
_lines[TYPE(0x25)] = Line(QPen(QColor("#558adf"), 1, Qt::SolidLine));
|
|
|
|
_lines[TYPE(0x25)].setTextColor(QColor("#558adf"));
|
|
|
|
_lines[TYPE(0x25)].setTextFontSize(Small);
|
|
|
|
_lines[TYPE(0x26)] = Line(QPen(QColor("#9fc4e1"), 2, Qt::DotLine));
|
|
|
|
_lines[TYPE(0x27)] = Line(QPen(QColor("#ffffff"), 4, Qt::SolidLine),
|
2019-05-10 18:56:19 +02:00
|
|
|
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
2020-01-24 19:44:19 +01:00
|
|
|
//_lines[TYPE(0x28)] = Line(QPen(QColor("#5a5a5a"), 1, Qt::SolidLine));
|
|
|
|
_lines[TYPE(0x29)] = Line(QPen(QColor("#5a5a5a"), 1, Qt::SolidLine));
|
|
|
|
_lines[TYPE(0x29)].setTextFontSize(None);
|
2020-10-16 00:03:26 +02:00
|
|
|
|
|
|
|
// NT types
|
|
|
|
_lines[0x10c00] = _lines[TYPE(0x14)];
|
|
|
|
_lines[0x10a00] = _lines[TYPE(0x18)];
|
|
|
|
_lines[0x10b04] = _lines[TYPE(0x1e)];
|
|
|
|
_lines[0x10a01] = _lines[TYPE(0x1f)];
|
|
|
|
_lines[0x10900] = _lines[TYPE(0x20)];
|
|
|
|
_lines[0x10901] = _lines[TYPE(0x21)];
|
|
|
|
_lines[0x10902] = _lines[TYPE(0x22)];
|
|
|
|
_lines[0x10903] = _lines[TYPE(0x23)];
|
|
|
|
_lines[0x10904] = _lines[TYPE(0x24)];
|
|
|
|
_lines[0x10905] = _lines[TYPE(0x25)];
|
|
|
|
_lines[0x10a02] = _lines[TYPE(0x26)];
|
|
|
|
_lines[0x10c02] = _lines[TYPE(0x27)];
|
|
|
|
//_lines[0x10c03] = _lines[TYPE(0x28)];
|
|
|
|
_lines[0x10c04] = _lines[TYPE(0x29)];
|
2019-05-10 18:56:19 +02:00
|
|
|
}
|
|
|
|
|
2019-07-04 21:38:57 +02:00
|
|
|
void Style::defaultPointStyle()
|
2019-06-07 09:37:10 +02:00
|
|
|
{
|
2020-02-16 12:57:40 +01:00
|
|
|
// Countries
|
2020-02-16 20:31:09 +01:00
|
|
|
_points[TYPE(0x14)].setTextColor(QColor("#505145"));
|
2020-02-16 12:57:40 +01:00
|
|
|
_points[TYPE(0x14)].setTextFontSize(Small);
|
2020-02-16 20:31:09 +01:00
|
|
|
_points[TYPE(0x15)].setTextColor(QColor("#505145"));
|
2020-02-16 12:57:40 +01:00
|
|
|
_points[TYPE(0x15)].setTextFontSize(Small);
|
|
|
|
|
|
|
|
// Regions
|
2020-02-16 20:31:09 +01:00
|
|
|
_points[TYPE(0x1e)].setTextColor(QColor("#505145"));
|
|
|
|
_points[TYPE(0x1e)].setTextFontSize(ExtraSmall);
|
2020-02-16 12:57:40 +01:00
|
|
|
_points[TYPE(0x28)].setTextFontSize(Small);
|
|
|
|
|
2019-07-04 21:38:57 +02:00
|
|
|
// Cities
|
2020-01-24 19:44:19 +01:00
|
|
|
_points[TYPE(0x01)].setTextFontSize(Large);
|
|
|
|
_points[TYPE(0x02)].setTextFontSize(Large);
|
|
|
|
_points[TYPE(0x03)].setTextFontSize(Large);
|
2019-07-04 21:38:57 +02:00
|
|
|
|
|
|
|
// POI
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
_points[0x2f0b].setTextFontSize(None);
|
2021-04-10 15:27:40 +02:00
|
|
|
_points[0x2f0c] = Point(QImage(":/POI/toilet-11.png"));
|
2019-06-07 09:37:10 +02:00
|
|
|
_points[0x2f0c].setTextFontSize(None);
|
2021-04-10 15:27:40 +02:00
|
|
|
_points[0x2f10] = Point(QImage(":/POI/hairdresser-11.png"));
|
2019-06-07 09:37:10 +02:00
|
|
|
_points[0x2f12].setTextFontSize(None);
|
2021-04-10 15:27:40 +02:00
|
|
|
_points[0x2f13] = Point(QImage(":/POI/hardware-11.png"));
|
|
|
|
_points[0x2f17] = Point(QImage(":/POI/bus-11.png"));
|
2019-06-07 09:37:10 +02:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
_points[0x4d00].setTextFontSize(None);
|
2021-04-10 15:27:40 +02:00
|
|
|
_points[0x4e00] = Point(QImage(":/POI/toilet-11.png"));
|
2019-06-07 09:37:10 +02:00
|
|
|
_points[0x4e00].setTextFontSize(None);
|
2021-04-10 15:27:40 +02:00
|
|
|
_points[0x5000] = Point(QImage(":/POI/drinking-water-11.png"));
|
2019-06-07 09:37:10 +02:00
|
|
|
_points[0x5000].setTextFontSize(None);
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2019-06-07 09:37:10 +02:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
_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"));
|
2020-10-16 00:03:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
// NT types
|
|
|
|
_points[0x11401] = _points[TYPE(0x01)];
|
|
|
|
_points[0x11402] = _points[TYPE(0x02)];
|
|
|
|
_points[0x11403] = _points[TYPE(0x03)];
|
|
|
|
_points[0x10b00] = _points[0x2a00];
|
|
|
|
_points[0x10b01] = _points[0x2a01];
|
|
|
|
_points[0x10b02] = _points[0x2a02];
|
|
|
|
_points[0x10b03] = _points[0x2a03];
|
|
|
|
_points[0x10b04] = _points[0x2a04];
|
|
|
|
_points[0x10b05] = _points[0x2a05];
|
|
|
|
_points[0x10b06] = _points[0x2a06];
|
|
|
|
_points[0x10b07] = _points[0x2a07];
|
|
|
|
_points[0x10b08] = _points[0x2a08];
|
|
|
|
_points[0x10b09] = _points[0x2a09];
|
|
|
|
_points[0x10b0a] = _points[0x2a0a];
|
|
|
|
_points[0x10b0b] = _points[0x2a0b];
|
|
|
|
_points[0x10b0c] = _points[0x2a0c];
|
|
|
|
_points[0x10b0d] = _points[0x2a0d];
|
|
|
|
_points[0x10b0e] = _points[0x2a0e];
|
|
|
|
_points[0x10b0f] = _points[0x2a0f];
|
|
|
|
_points[0x10b10] = _points[0x2a10];
|
|
|
|
_points[0x10b11] = _points[0x2a11];
|
|
|
|
_points[0x10c01] = _points[0x2b01];
|
|
|
|
_points[0x10c02] = _points[0x2b02];
|
|
|
|
_points[0x10c03] = _points[0x2b03];
|
|
|
|
_points[0x10c04] = _points[0x2b04];
|
|
|
|
_points[0x10d01] = _points[0x2c01];
|
|
|
|
_points[0x10d02] = _points[0x2c02];
|
|
|
|
_points[0x10d03] = _points[0x2c03];
|
|
|
|
_points[0x10d04] = _points[0x2c04];
|
|
|
|
_points[0x10d05] = _points[0x2c05];
|
|
|
|
_points[0x10d06] = _points[0x2c06];
|
|
|
|
_points[0x10d07] = _points[0x2c07];
|
|
|
|
_points[0x10d08] = _points[0x2c08];
|
|
|
|
_points[0x10d0a] = _points[0x2c0a];
|
|
|
|
_points[0x10d0b] = _points[0x2c0b];
|
|
|
|
_points[0x10d0d] = _points[0x2c0d];
|
|
|
|
_points[0x10d0e] = _points[0x2c0e];
|
|
|
|
_points[0x10d10] = _points[0x2c10];
|
|
|
|
_points[0x10e01] = _points[0x2d01];
|
|
|
|
_points[0x10e02] = _points[0x2d02];
|
|
|
|
_points[0x10e03] = _points[0x2d03];
|
|
|
|
_points[0x10e04] = _points[0x2d04];
|
|
|
|
_points[0x10e05] = _points[0x2d05];
|
|
|
|
_points[0x10e06] = _points[0x2d06];
|
|
|
|
_points[0x10e07] = _points[0x2d07];
|
|
|
|
_points[0x10e08] = _points[0x2d08];
|
|
|
|
_points[0x10e09] = _points[0x2d09];
|
|
|
|
_points[0x10e0a] = _points[0x2d0a];
|
|
|
|
_points[0x10e0b] = _points[0x2d0b];
|
|
|
|
_points[0x10f02] = _points[0x2e02];
|
2020-10-16 22:45:51 +02:00
|
|
|
_points[0x10f03] = _points[0x2e03];
|
2020-10-16 00:03:26 +02:00
|
|
|
_points[0x10f05] = _points[0x2e05];
|
2020-10-16 22:45:51 +02:00
|
|
|
_points[0x10f06] = _points[0x2e06];
|
2020-10-16 00:03:26 +02:00
|
|
|
_points[0x10f07] = _points[0x2e07];
|
|
|
|
_points[0x10f08] = _points[0x2e08];
|
|
|
|
_points[0x10f09] = _points[0x2e09];
|
2020-10-16 22:45:51 +02:00
|
|
|
_points[0x10f0a] = _points[0x2e0a];
|
2020-10-16 00:03:26 +02:00
|
|
|
_points[0x11001] = _points[0x2f01];
|
|
|
|
_points[0x11002] = _points[0x2f02];
|
|
|
|
_points[0x11003] = _points[0x2f03];
|
|
|
|
_points[0x11004] = _points[0x2f04];
|
|
|
|
_points[0x11005] = _points[0x2f05];
|
|
|
|
_points[0x11006] = _points[0x2f06];
|
|
|
|
_points[0x11007] = _points[0x2f07];
|
|
|
|
_points[0x11008] = _points[0x2f08];
|
|
|
|
_points[0x11009] = _points[0x2f09];
|
|
|
|
_points[0x1100b] = _points[0x2f0b];
|
|
|
|
_points[0x1100c] = _points[0x2f0c];
|
|
|
|
_points[0x11010] = _points[0x2f10];
|
|
|
|
_points[0x11012] = _points[0x2f12];
|
|
|
|
_points[0x11013] = _points[0x2f13];
|
|
|
|
_points[0x11017] = _points[0x2f17];
|
|
|
|
_points[0x11101] = _points[0x3001];
|
|
|
|
_points[0x11102] = _points[0x3002];
|
|
|
|
_points[0x11103] = _points[0x3003];
|
|
|
|
_points[0x11106] = _points[0x3006];
|
|
|
|
_points[0x11107] = _points[0x3007];
|
|
|
|
_points[0x11108] = _points[0x3008];
|
2019-06-07 09:37:10 +02:00
|
|
|
}
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
static bool readBitmap(SubFile *file, SubFile::Handle &hdl, QImage &img,
|
|
|
|
int bpp)
|
|
|
|
{
|
|
|
|
if (!bpp)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
for (int y = 0; y < img.height(); y++) {
|
|
|
|
for (int x = 0; x < img.width(); x += 8/bpp) {
|
|
|
|
quint8 color;
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!file->readByte(hdl, &color))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
for (int i = 0; i < 8/bpp && x + i < img.width(); i++) {
|
|
|
|
int value = (i > 0) ? (color >>= bpp) : color;
|
|
|
|
|
|
|
|
if (bpp == 4)
|
|
|
|
value = value & 0xf;
|
|
|
|
else if (bpp == 2)
|
|
|
|
value = value & 0x3;
|
|
|
|
else if (bpp == 1)
|
|
|
|
value = value & 0x1;
|
|
|
|
|
|
|
|
img.setPixel(x + i, y, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool readColor(SubFile *file, SubFile::Handle &hdl, QColor &color)
|
|
|
|
{
|
|
|
|
quint8 b, g, r;
|
|
|
|
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readByte(hdl, &b) && file->readByte(hdl, &g)
|
|
|
|
&& file->readByte(hdl, &r)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
color = qRgb(r, g, b);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-12-26 14:45:38 +01:00
|
|
|
static bool skipLabel(SubFile *file, SubFile::Handle &hdl)
|
2019-05-10 18:56:19 +02:00
|
|
|
{
|
2020-12-26 14:30:18 +01:00
|
|
|
quint32 len;
|
2019-05-10 18:56:19 +02:00
|
|
|
|
2020-12-26 14:30:18 +01:00
|
|
|
if (!file->readVUInt32(hdl, len))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
2020-08-26 17:58:21 +02:00
|
|
|
if (!file->seek(hdl, file->pos(hdl) + len))
|
2019-05-11 19:11:00 +02:00
|
|
|
return false;
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Style::itemInfo(SubFile *file, SubFile::Handle &hdl,
|
|
|
|
const Section §ion, ItemInfo &info)
|
|
|
|
{
|
|
|
|
quint16 t16_1, t16_2;
|
|
|
|
quint8 t8;
|
|
|
|
|
|
|
|
if (section.arrayItemSize == 5) {
|
|
|
|
if (!(file->readUInt16(hdl, t16_1) && file->readUInt16(hdl, t16_2)
|
2021-02-01 20:06:05 +01:00
|
|
|
&& file->readByte(hdl, &t8)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
info.offset = t16_2 | (t8<<16);
|
|
|
|
} else if (section.arrayItemSize == 4) {
|
|
|
|
if (!(file->readUInt16(hdl, t16_1) && file->readUInt16(hdl, t16_2)))
|
|
|
|
return false;
|
|
|
|
info.offset = t16_2;
|
|
|
|
} else if (section.arrayItemSize == 3) {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readUInt16(hdl, t16_1) && file->readByte(hdl, &t8)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
info.offset = t8;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
t16_2 = (t16_1 >> 5) | (( t16_1 & 0x1f) << 11);
|
|
|
|
info.type = t16_2 & 0x7F;
|
|
|
|
info.subtype = t16_1 & 0x1F;
|
|
|
|
info.extended = t16_1 & 0x2000;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl,
|
|
|
|
const Section §ion)
|
|
|
|
{
|
2019-06-22 20:32:37 +02:00
|
|
|
if (!section.arrayItemSize)
|
|
|
|
return section.arraySize ? false : true;
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
for (quint32 i = 0; i < section.arraySize / section.arrayItemSize; i++) {
|
|
|
|
if (!file->seek(hdl, section.arrayOffset + i * section.arrayItemSize))
|
|
|
|
return false;
|
|
|
|
ItemInfo info;
|
|
|
|
if (!itemInfo(file, hdl, section, info))
|
|
|
|
return false;
|
|
|
|
quint32 type = info.extended
|
|
|
|
? 0x10000 | (info.type << 8) | info.subtype : (info.type << 8);
|
|
|
|
|
|
|
|
quint8 t8, flags;
|
|
|
|
if (!(file->seek(hdl, section.offset + info.offset)
|
2021-02-01 20:06:05 +01:00
|
|
|
&& file->readByte(hdl, &t8)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
flags = t8 & 0x0F;
|
|
|
|
|
|
|
|
QColor c1, c2, c3, c4;
|
|
|
|
QImage img(32, 32, QImage::Format_Indexed8);
|
|
|
|
|
|
|
|
switch (flags) {
|
|
|
|
case 0x01:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)
|
|
|
|
&& readColor(file, hdl, c3) && readColor(file, hdl, c4)))
|
|
|
|
return false;
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[type] = Polygon(QBrush(c1), QPen(c3, 2));
|
2019-05-10 18:56:19 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x06:
|
|
|
|
case 0x07:
|
|
|
|
if (!readColor(file, hdl, c1))
|
|
|
|
return false;
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[type] = Polygon(QBrush(c1));
|
2019-05-10 18:56:19 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x08:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, c2.rgb());
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[type] = Polygon(QBrush(img));
|
2019-05-10 18:56:19 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x09:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)
|
|
|
|
&& readColor(file, hdl, c3) && readColor(file, hdl, c4)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, c2.rgb());
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[type] = Polygon(QBrush(img));
|
2019-05-10 18:56:19 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0B:
|
|
|
|
case 0x0D:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)
|
|
|
|
&& readColor(file, hdl, c3)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, (flags == 0x0B) ? qRgba(255, 255, 255, 0)
|
|
|
|
: c2.rgb());
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[type] = Polygon(QBrush(img));
|
2019-05-10 18:56:19 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0E:
|
|
|
|
if (!readColor(file, hdl, c1))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, qRgba(255, 255, 255, 0));
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[type] = Polygon(QBrush(img));
|
2019-05-10 18:56:19 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0F:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, qRgba(255, 255, 255, 0));
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_polygons[type] = Polygon(QBrush(img));
|
2019-05-10 18:56:19 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Style::parseLines(SubFile *file, SubFile::Handle &hdl,
|
|
|
|
const Section §ion)
|
|
|
|
{
|
2019-06-22 20:32:37 +02:00
|
|
|
if (!section.arrayItemSize)
|
|
|
|
return section.arraySize ? false : true;
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
for (quint32 i = 0; i < section.arraySize / section.arrayItemSize; i++) {
|
|
|
|
if (!file->seek(hdl, section.arrayOffset + i * section.arrayItemSize))
|
|
|
|
return false;
|
|
|
|
ItemInfo info;
|
|
|
|
if (!itemInfo(file, hdl, section, info))
|
|
|
|
return false;
|
|
|
|
quint32 type = info.extended
|
|
|
|
? 0x10000 | (info.type << 8) | info.subtype : (info.type << 8);
|
|
|
|
|
|
|
|
quint8 t8_1, t8_2, flags, rows;
|
|
|
|
if (!(file->seek(hdl, section.offset + info.offset)
|
2021-02-01 20:06:05 +01:00
|
|
|
&& file->readByte(hdl, &t8_1) && file->readByte(hdl, &t8_2)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
flags = t8_1 & 0x07;
|
|
|
|
rows = t8_1 >> 3;
|
2020-12-26 14:45:38 +01:00
|
|
|
bool label = t8_2 & 0x01;
|
|
|
|
bool fontInfo = t8_2 & 0x04;
|
2019-05-10 18:56:19 +02:00
|
|
|
|
|
|
|
QColor c1, c2, c3, c4;
|
|
|
|
quint8 w1, w2;
|
|
|
|
|
|
|
|
switch (flags) {
|
|
|
|
case 0x00:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (rows) {
|
|
|
|
QImage img(32, rows, QImage::Format_Indexed8);
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, c2.rgb());
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(img);
|
2019-05-10 18:56:19 +02:00
|
|
|
} else {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readByte(hdl, &w1) && file->readByte(hdl, &w2)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
_lines[type] = (w2 > w1)
|
2020-01-24 19:44:19 +01:00
|
|
|
? Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap,
|
|
|
|
Qt::RoundJoin))
|
2020-01-24 19:44:19 +01:00
|
|
|
: Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundJoin));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x01:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)
|
|
|
|
&& readColor(file, hdl, c3) && readColor(file, hdl, c4)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (rows) {
|
|
|
|
QImage img(32, rows, QImage::Format_Indexed8);
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, c2.rgb());
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(img);
|
2019-05-10 18:56:19 +02:00
|
|
|
} else {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readByte(hdl, &w1) && file->readByte(hdl, &w2)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
_lines[type] = (w2 > w1)
|
2020-01-24 19:44:19 +01:00
|
|
|
? Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap,
|
|
|
|
Qt::RoundJoin))
|
2020-01-24 19:44:19 +01:00
|
|
|
: Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundJoin));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x03:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)
|
|
|
|
&& readColor(file, hdl, c3)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (rows) {
|
|
|
|
QImage img(32, rows, QImage::Format_Indexed8);
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, qRgba(255, 255, 255, 0));
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(img);
|
2019-05-10 18:56:19 +02:00
|
|
|
} else {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readByte(hdl, &w1) && file->readByte(hdl, &w2)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(QPen(c1, w1, Qt::SolidLine,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundCap, Qt::RoundJoin));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x05:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)
|
|
|
|
&& readColor(file, hdl, c3)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (rows) {
|
|
|
|
QImage img(32, rows, QImage::Format_Indexed8);
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, c2.rgb());
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(img);
|
2019-05-10 18:56:19 +02:00
|
|
|
} else {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readByte(hdl, &w1) && file->readByte(hdl, &w2)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
_lines[type] = (w2 > w1)
|
2020-01-24 19:44:19 +01:00
|
|
|
? Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap,
|
|
|
|
Qt::RoundJoin))
|
2020-01-24 19:44:19 +01:00
|
|
|
: Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundJoin));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x06:
|
|
|
|
if (!readColor(file, hdl, c1))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (rows) {
|
|
|
|
QImage img(32, rows, QImage::Format_Indexed8);
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, qRgba(255, 255, 255, 0));
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(img);
|
2019-05-10 18:56:19 +02:00
|
|
|
} else {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!file->readByte(hdl, &w1))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(QPen(c1, w1, Qt::SolidLine,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundCap, Qt::RoundJoin));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x07:
|
|
|
|
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (rows) {
|
|
|
|
QImage img(32, rows, QImage::Format_Indexed8);
|
|
|
|
img.setColorCount(2);
|
|
|
|
img.setColor(0, qRgba(255,255,255,0));
|
|
|
|
img.setColor(1, c1.rgb());
|
|
|
|
if (!readBitmap(file, hdl, img, 1))
|
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(img);
|
2019-05-10 18:56:19 +02:00
|
|
|
} else {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!file->readByte(hdl, &w1))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
2020-01-24 19:44:19 +01:00
|
|
|
_lines[type] = Line(QPen(c1, w1, Qt::SolidLine,
|
2019-05-10 18:56:19 +02:00
|
|
|
Qt::RoundCap, Qt::RoundJoin));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isContourLine(type)) {
|
|
|
|
Line &l = _lines[type];
|
|
|
|
l.setTextColor(l.foreground().color());
|
|
|
|
l.setTextFontSize(Small);
|
|
|
|
}
|
|
|
|
|
2020-12-26 14:45:38 +01:00
|
|
|
if (label && !skipLabel(file, hdl))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
2020-12-26 14:45:38 +01:00
|
|
|
if (fontInfo) {
|
2019-05-10 18:56:19 +02:00
|
|
|
quint8 labelFlags;
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!file->readByte(hdl, &labelFlags))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
if (labelFlags & 0x08) {
|
|
|
|
if (!readColor(file, hdl, c1))
|
|
|
|
return false;
|
|
|
|
_lines[type].setTextColor(c1);
|
|
|
|
}
|
|
|
|
_lines[type].setTextFontSize((FontSize)(labelFlags & 0x07));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int colors2bpp(quint8 colors, quint8 flags)
|
|
|
|
{
|
|
|
|
switch (flags) {
|
|
|
|
case 0x00:
|
|
|
|
if (colors < 3)
|
|
|
|
return colors;
|
|
|
|
else if (colors == 3)
|
|
|
|
return 2;
|
|
|
|
else if (colors < 16)
|
|
|
|
return 4;
|
|
|
|
else
|
|
|
|
return 8;
|
|
|
|
case 0x10:
|
|
|
|
if (colors == 0)
|
|
|
|
return 1;
|
|
|
|
else if (colors < 3)
|
|
|
|
return 2;
|
|
|
|
else if (colors < 15)
|
|
|
|
return 4;
|
|
|
|
else
|
|
|
|
return 8;
|
|
|
|
case 0x20:
|
|
|
|
if (colors == 0)
|
|
|
|
return -1;
|
|
|
|
else if (colors < 3)
|
|
|
|
return colors;
|
|
|
|
else if (colors < 4)
|
|
|
|
return 2;
|
|
|
|
else if (colors < 16)
|
|
|
|
return 4;
|
|
|
|
else
|
|
|
|
return 8;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool readColorTable(SubFile *file, SubFile::Handle &hdl, QImage& img,
|
|
|
|
int colors, int bpp, bool transparent)
|
|
|
|
{
|
|
|
|
img.setColorCount(colors);
|
|
|
|
|
|
|
|
if (transparent) {
|
|
|
|
quint8 byte;
|
|
|
|
quint32 bits = 0, reg = 0, mask = 0x000000FF;
|
|
|
|
|
|
|
|
for (int i = 0; i < colors; i++) {
|
|
|
|
while (bits < 28) {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!file->readByte(hdl, &byte))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
mask = 0x000000FF << bits;
|
|
|
|
reg = reg & (~mask);
|
|
|
|
reg = reg | (byte << bits);
|
|
|
|
bits += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
img.setColor(i, qRgba((reg >> 16) & 0x0FF, (reg >> 8) & 0x0FF,
|
|
|
|
reg & 0x0FF, ~((reg >> 24) & 0x0F) << 4));
|
|
|
|
|
|
|
|
reg = reg >> 28;
|
|
|
|
bits -= 28;
|
|
|
|
}
|
|
|
|
for (int i = colors; i < 1<<bpp; i++)
|
|
|
|
img.setColor(i, qRgba(0, 0, 0, 0));
|
|
|
|
} else {
|
|
|
|
QColor color;
|
|
|
|
|
|
|
|
for (int i = 0; i < colors; i++) {
|
|
|
|
if (!readColor(file, hdl, color))
|
|
|
|
return false;
|
|
|
|
img.setColor(i, color.rgb());
|
|
|
|
}
|
|
|
|
for (int i = colors; i < 1<<bpp; i++)
|
|
|
|
img.setColor(i, qRgba(0, 0, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Style::parsePoints(SubFile *file, SubFile::Handle &hdl,
|
|
|
|
const Section §ion)
|
|
|
|
{
|
2019-06-22 20:32:37 +02:00
|
|
|
if (!section.arrayItemSize)
|
|
|
|
return section.arraySize ? false : true;
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
for (quint32 i = 0; i < section.arraySize / section.arrayItemSize; i++) {
|
|
|
|
if (!file->seek(hdl, section.arrayOffset + i * section.arrayItemSize))
|
|
|
|
return false;
|
|
|
|
ItemInfo info;
|
|
|
|
if (!itemInfo(file, hdl, section, info))
|
|
|
|
return false;
|
|
|
|
quint32 type = info.extended
|
|
|
|
? 0x10000 | (info.type << 8) | info.subtype
|
|
|
|
: (info.type << 8) | info.subtype;
|
|
|
|
|
|
|
|
quint8 t8_1, width, height, numColors, imgType;
|
|
|
|
if (!(file->seek(hdl, section.offset + info.offset)
|
2021-02-01 20:06:05 +01:00
|
|
|
&& file->readByte(hdl, &t8_1) && file->readByte(hdl, &width)
|
|
|
|
&& file->readByte(hdl, &height) && file->readByte(hdl, &numColors)
|
|
|
|
&& file->readByte(hdl, &imgType)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
2020-12-26 14:45:38 +01:00
|
|
|
bool label = t8_1 & 0x04;
|
|
|
|
bool fontInfo = t8_1 & 0x08;
|
2019-05-10 18:56:19 +02:00
|
|
|
|
|
|
|
int bpp = colors2bpp(numColors, imgType);
|
2019-05-11 19:11:00 +02:00
|
|
|
if (bpp <= 0)
|
2019-05-10 18:56:19 +02:00
|
|
|
continue;
|
|
|
|
QImage img(width, height, QImage::Format_Indexed8);
|
|
|
|
if (!readColorTable(file, hdl, img, numColors, bpp, imgType == 0x20))
|
|
|
|
return false;
|
|
|
|
if (!readBitmap(file, hdl, img, bpp))
|
|
|
|
return false;
|
|
|
|
_points[type] = Point(img);
|
|
|
|
|
2019-05-11 19:11:00 +02:00
|
|
|
if (t8_1 == 0x03) {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readByte(hdl, &numColors)
|
|
|
|
&& file->readByte(hdl, &imgType)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
if ((bpp = colors2bpp(numColors, imgType)) < 0)
|
|
|
|
continue;
|
|
|
|
if (!readColorTable(file, hdl, img, numColors, bpp, imgType == 0x20))
|
|
|
|
return false;
|
|
|
|
if (!readBitmap(file, hdl, img, bpp))
|
|
|
|
return false;
|
2019-05-11 19:11:00 +02:00
|
|
|
} else if (t8_1 == 0x02) {
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readByte(hdl, &numColors)
|
|
|
|
&& file->readByte(hdl, &imgType)))
|
2019-05-11 19:11:00 +02:00
|
|
|
return false;
|
|
|
|
if ((bpp = colors2bpp(numColors, imgType)) < 0)
|
|
|
|
continue;
|
|
|
|
if (!readColorTable(file, hdl, img, numColors, bpp, imgType == 0x20))
|
|
|
|
return false;
|
2019-05-10 18:56:19 +02:00
|
|
|
}
|
|
|
|
|
2020-12-26 14:45:38 +01:00
|
|
|
if (label && !skipLabel(file, hdl))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
2020-12-26 14:45:38 +01:00
|
|
|
if (fontInfo) {
|
2019-05-10 18:56:19 +02:00
|
|
|
quint8 labelFlags;
|
|
|
|
QColor color;
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!file->readByte(hdl, &labelFlags))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
if (labelFlags & 0x08) {
|
|
|
|
if (!readColor(file, hdl, color))
|
|
|
|
return false;
|
|
|
|
_points[type].setTextColor(color);
|
|
|
|
}
|
|
|
|
_points[type].setTextFontSize((FontSize)(labelFlags & 0x07));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Style::parseDrawOrder(SubFile *file, SubFile::Handle &hdl,
|
|
|
|
const Section &order)
|
|
|
|
{
|
|
|
|
QList<quint32> drawOrder;
|
|
|
|
|
2019-06-22 20:32:37 +02:00
|
|
|
if (!order.arrayItemSize)
|
|
|
|
return order.arraySize ? false : true;
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
if (!file->seek(hdl, order.arrayOffset))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (quint32 i = 0; i < order.arraySize / order.arrayItemSize; i++) {
|
|
|
|
quint8 type;
|
|
|
|
quint32 subtype;
|
|
|
|
|
2021-02-01 20:06:05 +01:00
|
|
|
if (!(file->readByte(hdl, &type) && file->readUInt32(hdl, subtype)))
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!subtype)
|
|
|
|
drawOrder.append(((quint32)type) << 8);
|
|
|
|
else {
|
|
|
|
for (int j = 0; j < 32; j++) {
|
|
|
|
quint32 mask = 1 << j;
|
|
|
|
if (subtype & mask)
|
|
|
|
drawOrder.append(0x010000 | (((quint32)type) << 8) | j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_drawOrder = drawOrder;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Style::parseTYPFile(SubFile *file)
|
|
|
|
{
|
2020-02-09 23:24:48 +01:00
|
|
|
SubFile::Handle hdl(file);
|
2019-05-10 18:56:19 +02:00
|
|
|
Section points, lines, polygons, order;
|
|
|
|
quint16 tmp16, codepage;
|
|
|
|
|
|
|
|
if (!(file->seek(hdl, 0x15) && file->readUInt16(hdl, codepage)
|
|
|
|
&& file->readUInt32(hdl, points.offset)
|
|
|
|
&& file->readUInt32(hdl, points.size)
|
|
|
|
&& file->readUInt32(hdl, lines.offset)
|
|
|
|
&& file->readUInt32(hdl, lines.size)
|
|
|
|
&& file->readUInt32(hdl, polygons.offset)
|
|
|
|
&& file->readUInt32(hdl, polygons.size)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!(file->readUInt16(hdl, tmp16) && file->readUInt16(hdl, tmp16)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!(file->readUInt32(hdl, points.arrayOffset)
|
|
|
|
&& file->readUInt16(hdl, points.arrayItemSize)
|
|
|
|
&& file->readUInt32(hdl, points.arraySize)
|
|
|
|
&& file->readUInt32(hdl, lines.arrayOffset)
|
|
|
|
&& file->readUInt16(hdl, lines.arrayItemSize)
|
|
|
|
&& file->readUInt32(hdl, lines.arraySize)
|
|
|
|
&& file->readUInt32(hdl, polygons.arrayOffset)
|
|
|
|
&& file->readUInt16(hdl, polygons.arrayItemSize)
|
|
|
|
&& file->readUInt32(hdl, polygons.arraySize)
|
|
|
|
&& file->readUInt32(hdl, order.arrayOffset)
|
|
|
|
&& file->readUInt16(hdl, order.arrayItemSize)
|
|
|
|
&& file->readUInt32(hdl, order.arraySize)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!(parsePoints(file, hdl, points) && parseLines(file, hdl, lines)
|
|
|
|
&& parsePolygons(file, hdl, polygons)
|
|
|
|
&& parseDrawOrder(file, hdl, order))) {
|
|
|
|
qWarning("%s: Invalid TYP file, using default style",
|
2019-05-16 20:23:37 +02:00
|
|
|
qPrintable(file->fileName()));
|
2019-05-10 18:56:19 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Style::Style(SubFile *typ)
|
|
|
|
{
|
|
|
|
defaultLineStyle();
|
|
|
|
defaultPolygonStyle();
|
2019-07-04 21:38:57 +02:00
|
|
|
defaultPointStyle();
|
2019-05-10 18:56:19 +02:00
|
|
|
|
2019-09-05 22:31:13 +02:00
|
|
|
if (typ)
|
2019-05-10 18:56:19 +02:00
|
|
|
parseTYPFile(typ);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Style::Line &Style::line(quint32 type) const
|
|
|
|
{
|
|
|
|
static Line null;
|
|
|
|
|
|
|
|
QMap<quint32, Line>::const_iterator it = _lines.find(type);
|
|
|
|
return (it == _lines.constEnd()) ? null : *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Style::Polygon &Style::polygon(quint32 type) const
|
|
|
|
{
|
|
|
|
static Polygon null;
|
|
|
|
|
|
|
|
QMap<quint32, Polygon>::const_iterator it = _polygons.find(type);
|
|
|
|
return (it == _polygons.constEnd()) ? null : *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Style::Point &Style::point(quint32 type) const
|
|
|
|
{
|
|
|
|
static Point null;
|
|
|
|
|
2019-12-09 22:50:19 +01:00
|
|
|
QMap<quint32, Point>::const_iterator it = _points.find(type);
|
2019-05-10 18:56:19 +02:00
|
|
|
return (it == _points.constEnd()) ? null : *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_DEBUG
|
|
|
|
static QString penColor(const QPen &pen)
|
|
|
|
{
|
|
|
|
return (pen == Qt::NoPen) ? "None" : pen.color().name();
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString brushColor(const QBrush &brush)
|
|
|
|
{
|
|
|
|
return (brush == Qt::NoBrush) ? "None" : brush.color().name();
|
|
|
|
}
|
|
|
|
|
|
|
|
QDebug operator<<(QDebug dbg, const Style::Polygon &polygon)
|
|
|
|
{
|
|
|
|
dbg.nospace() << "Polygon(" << brushColor(polygon.brush()) << ", "
|
|
|
|
<< penColor(polygon.pen()) << ")";
|
|
|
|
return dbg.space();
|
|
|
|
}
|
|
|
|
|
|
|
|
QDebug operator<<(QDebug dbg, const Style::Line &line)
|
|
|
|
{
|
|
|
|
dbg.nospace() << "Line(" << penColor(line.foreground()) << ", "
|
|
|
|
<< penColor(line.background()) << ", " << !line.img().isNull() << ")";
|
|
|
|
return dbg.space();
|
|
|
|
}
|
2020-01-21 21:50:13 +01:00
|
|
|
|
|
|
|
QDebug operator<<(QDebug dbg, const Style::Point &point)
|
|
|
|
{
|
|
|
|
dbg.nospace() << "Point(" << point.textFontSize() << ", "
|
|
|
|
<< point.textColor() << ", " << !point.img().isNull() << ")";
|
|
|
|
return dbg.space();
|
|
|
|
}
|
2019-05-10 18:56:19 +02:00
|
|
|
#endif // QT_NO_DEBUG
|