1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Added currents rendering

This commit is contained in:
Martin Tůma 2023-03-25 13:31:15 +01:00
parent 66c951f38c
commit b80cd05d4b
5 changed files with 68 additions and 27 deletions

View File

@ -15,6 +15,7 @@
#define CATWAT 69 #define CATWAT 69
#define CATWRK 71 #define CATWRK 71
#define COMCHA 77 #define COMCHA 77
#define CURVEL 84
#define DRVAL1 87 #define DRVAL1 87
#define ELEVAT 90 #define ELEVAT 90
#define FUNCTN 94 #define FUNCTN 94

View File

@ -51,27 +51,28 @@ static QMap<uint,uint> orderMapInit()
map.insert(TYPE(WRECKS), 25); map.insert(TYPE(WRECKS), 25);
map.insert(TYPE(UWTROC), 26); map.insert(TYPE(UWTROC), 26);
map.insert(TYPE(WATTUR), 27); map.insert(TYPE(WATTUR), 27);
map.insert(TYPE(PILBOP), 28); map.insert(TYPE(CURENT), 28);
map.insert(TYPE(SISTAT), 29); map.insert(TYPE(PILBOP), 29);
map.insert(TYPE(I_SISTAT), 29); map.insert(TYPE(SISTAT), 30);
map.insert(TYPE(RDOCAL), 30); map.insert(TYPE(I_SISTAT), 30);
map.insert(TYPE(I_RDOCAL), 30); map.insert(TYPE(RDOCAL), 31);
map.insert(TYPE(I_TRNBSN), 31); map.insert(TYPE(I_RDOCAL), 31);
map.insert(TYPE(HRBFAC), 32); map.insert(TYPE(I_TRNBSN), 32);
map.insert(TYPE(I_HRBFAC), 32); map.insert(TYPE(HRBFAC), 33);
map.insert(TYPE(PILPNT), 33); map.insert(TYPE(I_HRBFAC), 33);
map.insert(TYPE(ACHBRT), 34); map.insert(TYPE(PILPNT), 34);
map.insert(TYPE(I_ACHBRT), 34); map.insert(TYPE(ACHBRT), 35);
map.insert(TYPE(CRANES), 35); map.insert(TYPE(I_ACHBRT), 35);
map.insert(TYPE(I_CRANES), 35); map.insert(TYPE(CRANES), 36);
map.insert(TYPE(I_WTWGAG), 36); map.insert(TYPE(I_CRANES), 36);
map.insert(TYPE(PYLONS), 37); map.insert(TYPE(I_WTWGAG), 37);
map.insert(TYPE(SLCONS), 38); map.insert(TYPE(PYLONS), 38);
map.insert(TYPE(LNDMRK), 39); map.insert(TYPE(SLCONS), 39);
map.insert(TYPE(SILTNK), 40); map.insert(TYPE(LNDMRK), 40);
map.insert(TYPE(LNDELV), 41); map.insert(TYPE(SILTNK), 41);
map.insert(TYPE(SMCFAC), 42); map.insert(TYPE(LNDELV), 42);
map.insert(TYPE(BUISGL), 43); map.insert(TYPE(SMCFAC), 43);
map.insert(TYPE(BUISGL), 44);
map.insert(TYPE(I_DISMAR), 0xFFFFFFFE); map.insert(TYPE(I_DISMAR), 0xFFFFFFFE);
map.insert(TYPE(SOUNDG), 0xFFFFFFFF); map.insert(TYPE(SOUNDG), 0xFFFFFFFF);
@ -250,11 +251,15 @@ MapData::Point::Point(uint type, const Coordinates &c, const QString &label,
if (type>>16 == I_DISMAR && params.size()) { if (type>>16 == I_DISMAR && params.size()) {
_label = hUnits((type>>8)&0xFF) + " " + QString::fromLatin1(params.at(0)); _label = hUnits((type>>8)&0xFF) + " " + QString::fromLatin1(params.at(0));
_type = SUBTYPE(I_DISMAR, type & 0xFF); _type = SUBTYPE(I_DISMAR, type & 0xFF);
} else if ((type == TYPE(I_RDOCAL) || type == TYPE(RDOCAL)) } else if ((type>>16 == I_RDOCAL || type>>16 == RDOCAL) && params.size() > 1) {
&& params.size() > 1) {
if (!params.at(1).isEmpty()) if (!params.at(1).isEmpty())
_label = QString("VHF ") + QString::fromLatin1(params.at(1)); _label = QString("VHF ") + QString::fromLatin1(params.at(1));
_param = QVariant(params.at(0).toDouble()); _param = QVariant(params.at(0).toDouble());
} else if (type>>16 == CURENT && params.size() > 1) {
if (!params.at(1).isEmpty())
_label = QString::fromLatin1(params.at(1))
+ QString::fromUtf8("\xE2\x80\x89kt");
_param = QVariant(params.at(0).toDouble());
} else if (type>>16 == I_SISTAT || type>>16 == SISTAT) { } else if (type>>16 == I_SISTAT || type>>16 == SISTAT) {
if (_label.isEmpty()) if (_label.isEmpty())
_label = sistat(type & 0xFF); _label = sistat(type & 0xFF);
@ -546,10 +551,12 @@ MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
if ((OBJL == I_DISMAR && key == I_WTWDIS) if ((OBJL == I_DISMAR && key == I_WTWDIS)
|| (OBJL == RDOCAL && key == ORIENT) || (OBJL == RDOCAL && key == ORIENT)
|| (OBJL == I_RDOCAL && key == ORIENT)) || (OBJL == I_RDOCAL && key == ORIENT)
|| (OBJL == CURENT && key == ORIENT))
params[0] = av.at(1).toByteArray(); params[0] = av.at(1).toByteArray();
if ((OBJL == I_RDOCAL && key == COMCHA) if ((OBJL == I_RDOCAL && key == COMCHA)
|| (OBJL == RDOCAL && key == COMCHA)) || (OBJL == RDOCAL && key == COMCHA)
|| (OBJL == CURENT && key == CURVEL))
params[1] = av.at(1).toByteArray(); params[1] = av.at(1).toByteArray();
} }

View File

@ -27,6 +27,7 @@
#define COALNE 30 #define COALNE 30
#define CONVYR 34 #define CONVYR 34
#define CRANES 35 #define CRANES 35
#define CURENT 36
#define DAMCON 38 #define DAMCON 38
#define DWRTPT 41 #define DWRTPT 41
#define DEPARE 42 #define DEPARE 42

View File

@ -12,6 +12,7 @@ using namespace ENC;
#define ICON_PADDING 2 #define ICON_PADDING 2
#define TSSLPT_SIZE 0.005 /* ll */ #define TSSLPT_SIZE 0.005 /* ll */
#define RDOCAL_SIZE 12 /* px */ #define RDOCAL_SIZE 12 /* px */
#define CURENT_SIZE 12 /* px */
class PointItem : public TextPointItem class PointItem : public TextPointItem
{ {
@ -122,6 +123,7 @@ static QImage *rdocalArrow(qreal angle)
QImage::Format_ARGB32_Premultiplied); QImage::Format_ARGB32_Premultiplied);
img->fill(Qt::transparent); img->fill(Qt::transparent);
QPainter p(img); QPainter p(img);
p.setRenderHint(QPainter::Antialiasing);
p.setPen(QPen(QColor("#eb49eb"), 1)); p.setPen(QPen(QColor("#eb49eb"), 1));
QPointF arrow[3]; QPointF arrow[3];
@ -141,10 +143,39 @@ static QImage *rdocalArrow(qreal angle)
return img; return img;
} }
static QImage *currentArrow(qreal angle)
{
QImage *img = new QImage(CURENT_SIZE*2, CURENT_SIZE*2,
QImage::Format_ARGB32_Premultiplied);
img->fill(Qt::transparent);
QPainter p(img);
p.setRenderHint(QPainter::Antialiasing);
p.setPen(QPen(Qt::black, 1));
QPointF arrow[3];
arrow[0] = QPointF(img->width()/2, img->height()/2);
arrow[1] = arrow[0] + QPointF(qSin(angle - M_PI/3) * CURENT_SIZE,
qCos(angle - M_PI/3) * CURENT_SIZE);
arrow[2] = arrow[0] + QPointF(qSin(angle - M_PI + M_PI/3) * CURENT_SIZE,
qCos(angle - M_PI + M_PI/3) * CURENT_SIZE);
QLineF l(arrow[1], arrow[2]);
QPointF pt(l.pointAt(0.5));
QLineF l2(arrow[0], pt);
p.translate(arrow[0] - pt);
p.drawPolyline(QPolygonF() << arrow[1] << arrow[0] << arrow[2]);
p.drawLine(arrow[0], l2.pointAt(2));
return img;
}
static QImage *image(uint type, const QVariant &param) static QImage *image(uint type, const QVariant &param)
{ {
if (type>>16 == RDOCAL || type>>16 == I_RDOCAL) if (type>>16 == RDOCAL || type>>16 == I_RDOCAL)
return rdocalArrow(deg2rad(90 - param.toDouble())); return rdocalArrow(deg2rad(90 - param.toDouble()));
else if (type>>16 == CURENT)
return currentArrow(deg2rad(90 - param.toDouble()));
else else
return 0; return 0;
} }

View File

@ -253,6 +253,7 @@ void Style::pointStyle()
_points[TYPE(SILTNK)] = Point(QImage(":/marine/silo.png")); _points[TYPE(SILTNK)] = Point(QImage(":/marine/silo.png"));
_points[TYPE(I_TRNBSN)] = Point(QImage(":/marine/turning-basin.png")); _points[TYPE(I_TRNBSN)] = Point(QImage(":/marine/turning-basin.png"));
_points[TYPE(I_WTWGAG)] = Point(QImage(":/marine/gauge.png"), Small); _points[TYPE(I_WTWGAG)] = Point(QImage(":/marine/gauge.png"), Small);
_points[TYPE(RDOCAL)].setTextColor(QColor("#eb49eb"));
_points[TYPE(I_RDOCAL)].setTextColor(QColor("#eb49eb")); _points[TYPE(I_RDOCAL)].setTextColor(QColor("#eb49eb"));
_points[TYPE(PYLONS)] = Point(QImage(":/marine/pylon.png")); _points[TYPE(PYLONS)] = Point(QImage(":/marine/pylon.png"));
_points[SUBTYPE(I_BERTHS, 6)] = Point(QImage(":/marine/fleeting-area.png")); _points[SUBTYPE(I_BERTHS, 6)] = Point(QImage(":/marine/fleeting-area.png"));