mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-07 16:02:51 +02:00
Compare commits
7 Commits
13.3
...
961061b643
Author | SHA1 | Date | |
---|---|---|---|
961061b643 | |||
8bebea53ad | |||
c3b484bb75 | |||
d6d43baec5 | |||
c6c3e0978c | |||
320b04c3fa | |||
ab7185bd25 |
@ -1,4 +1,4 @@
|
|||||||
version: 13.3.{build}
|
version: 13.4.{build}
|
||||||
|
|
||||||
configuration:
|
configuration:
|
||||||
- Release
|
- Release
|
||||||
|
@ -3,7 +3,7 @@ unix:!macx:!android {
|
|||||||
} else {
|
} else {
|
||||||
TARGET = GPXSee
|
TARGET = GPXSee
|
||||||
}
|
}
|
||||||
VERSION = 13.3
|
VERSION = 13.4
|
||||||
|
|
||||||
QT += core \
|
QT += core \
|
||||||
gui \
|
gui \
|
||||||
|
@ -198,6 +198,9 @@
|
|||||||
<file alias="building.png">icons/map/marine/building.png</file>
|
<file alias="building.png">icons/map/marine/building.png</file>
|
||||||
<file alias="fog-signal.png">icons/map/marine/fog-signal.png</file>
|
<file alias="fog-signal.png">icons/map/marine/fog-signal.png</file>
|
||||||
<file alias="construction.png">icons/map/marine/construction.png</file>
|
<file alias="construction.png">icons/map/marine/construction.png</file>
|
||||||
|
<file alias="radio-call.png">icons/map/marine/radio-call.png</file>
|
||||||
|
<file alias="current.png">icons/map/marine/current.png</file>
|
||||||
|
<file alias="rescue-station.png">icons/map/marine/rescue-station.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
|
||||||
<!-- Mapsforge rendertheme -->
|
<!-- Mapsforge rendertheme -->
|
||||||
|
BIN
icons/map/marine/current.png
Normal file
BIN
icons/map/marine/current.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 135 B |
BIN
icons/map/marine/radio-call.png
Normal file
BIN
icons/map/marine/radio-call.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 224 B |
BIN
icons/map/marine/rescue-station.png
Normal file
BIN
icons/map/marine/rescue-station.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 228 B |
@ -37,7 +37,7 @@ Unicode true
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "13.3"
|
!define VERSION "13.4"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||||
|
@ -23,6 +23,7 @@ static QMap<uint,uint> orderMapInit()
|
|||||||
map.insert(TYPE(FOGSIG), 0);
|
map.insert(TYPE(FOGSIG), 0);
|
||||||
|
|
||||||
map.insert(TYPE(CGUSTA), 1);
|
map.insert(TYPE(CGUSTA), 1);
|
||||||
|
map.insert(TYPE(RSCSTA), 1);
|
||||||
map.insert(SUBTYPE(BUAARE, 1), 2);
|
map.insert(SUBTYPE(BUAARE, 1), 2);
|
||||||
map.insert(SUBTYPE(BUAARE, 5), 3);
|
map.insert(SUBTYPE(BUAARE, 5), 3);
|
||||||
map.insert(SUBTYPE(BUAARE, 4), 4);
|
map.insert(SUBTYPE(BUAARE, 4), 4);
|
||||||
@ -264,6 +265,13 @@ MapData::Point::Point(uint type, const Coordinates &c, const QString &label,
|
|||||||
if (_label.isEmpty())
|
if (_label.isEmpty())
|
||||||
_label = sistat(type & 0xFF);
|
_label = sistat(type & 0xFF);
|
||||||
_type = TYPE(SISTAT);
|
_type = TYPE(SISTAT);
|
||||||
|
} else if (type>>16 == LNDELV && params.size()) {
|
||||||
|
if (_label.isEmpty())
|
||||||
|
_label = QString::fromLatin1(params.at(0))
|
||||||
|
+ QString::fromUtf8("\xE2\x80\x89m");
|
||||||
|
else
|
||||||
|
_label += "\n(" + QString::fromLatin1(params.at(0))
|
||||||
|
+ "\xE2\x80\x89m)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +560,8 @@ 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))
|
|| (OBJL == CURENT && key == ORIENT)
|
||||||
|
|| (OBJL == LNDELV && key == ELEVAT))
|
||||||
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)
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
#define RAILWY 106
|
#define RAILWY 106
|
||||||
#define RCRTCL 108
|
#define RCRTCL 108
|
||||||
#define RECTRC 109
|
#define RECTRC 109
|
||||||
|
#define RSCSTA 111
|
||||||
#define RESARE 112
|
#define RESARE 112
|
||||||
#define RIVERS 114
|
#define RIVERS 114
|
||||||
#define ROADWY 116
|
#define ROADWY 116
|
||||||
|
@ -10,15 +10,11 @@
|
|||||||
using namespace ENC;
|
using namespace ENC;
|
||||||
|
|
||||||
#define TEXT_EXTENT 160
|
#define TEXT_EXTENT 160
|
||||||
|
|
||||||
#define TSSLPT_SIZE 0.005 /* ll */
|
#define TSSLPT_SIZE 0.005 /* ll */
|
||||||
#define RDOCAL_SIZE 12 /* px */
|
|
||||||
#define CURENT_SIZE 12 /* px */
|
|
||||||
|
|
||||||
typedef QMap<Coordinates, const MapData::Point*> PointMap;
|
typedef QMap<Coordinates, const MapData::Point*> PointMap;
|
||||||
|
|
||||||
const float C1 = 0.866025f; /* sqrt(3)/2 */
|
static const float C1 = 0.866025f; /* sqrt(3)/2 */
|
||||||
|
|
||||||
static const QColor haloColor(Qt::white);
|
static const QColor haloColor(Qt::white);
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@ -105,67 +101,14 @@ static Coordinates centroid(const QVector<Coordinates> &polygon)
|
|||||||
return Coordinates(cx * factor, cy * factor);
|
return Coordinates(cx * factor, cy * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QImage *rdocalArrow(qreal angle)
|
static double angle(uint type, const QVariant ¶m)
|
||||||
{
|
|
||||||
QImage *img = new QImage(RDOCAL_SIZE*2, RDOCAL_SIZE*2,
|
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
|
||||||
img->fill(Qt::transparent);
|
|
||||||
QPainter p(img);
|
|
||||||
p.setRenderHint(QPainter::Antialiasing);
|
|
||||||
p.setPen(QPen(QColor("#eb49eb"), 1));
|
|
||||||
|
|
||||||
QPointF arrow[3];
|
|
||||||
arrow[0] = QPointF(img->width()/2, img->height()/2);
|
|
||||||
arrow[1] = arrow[0] + QPointF(qSin(angle - M_PI/3) * RDOCAL_SIZE,
|
|
||||||
qCos(angle - M_PI/3) * RDOCAL_SIZE);
|
|
||||||
arrow[2] = arrow[0] + QPointF(qSin(angle - M_PI + M_PI/3) * RDOCAL_SIZE,
|
|
||||||
qCos(angle - M_PI + M_PI/3) * RDOCAL_SIZE);
|
|
||||||
|
|
||||||
QLineF l(arrow[1], arrow[2]);
|
|
||||||
QPointF pt(l.pointAt(0.5));
|
|
||||||
|
|
||||||
p.translate(arrow[0] - pt);
|
|
||||||
p.drawPolyline(QPolygonF() << arrow[1] << arrow[0] << arrow[2]);
|
|
||||||
p.drawEllipse(pt, RDOCAL_SIZE/2, RDOCAL_SIZE/2);
|
|
||||||
|
|
||||||
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 ¶m)
|
|
||||||
{
|
{
|
||||||
if (type>>16 == RDOCAL || type>>16 == I_RDOCAL)
|
if (type>>16 == RDOCAL || type>>16 == I_RDOCAL)
|
||||||
return rdocalArrow(deg2rad(90 - param.toDouble()));
|
return 90 + param.toDouble();
|
||||||
else if (type>>16 == CURENT)
|
else if (type>>16 == CURENT)
|
||||||
return currentArrow(deg2rad(90 - param.toDouble()));
|
return 90 + param.toDouble();
|
||||||
else
|
else
|
||||||
return 0;
|
return NAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool showLabel(const QImage *img, const Range &range, int zoom, int type)
|
static bool showLabel(const QImage *img, const Range &range, int zoom, int type)
|
||||||
@ -186,9 +129,10 @@ QPainterPath RasterTile::painterPath(const Polygon &polygon) const
|
|||||||
for (int i = 0; i < polygon.size(); i++) {
|
for (int i = 0; i < polygon.size(); i++) {
|
||||||
const QVector<Coordinates> &subpath = polygon.at(i);
|
const QVector<Coordinates> &subpath = polygon.at(i);
|
||||||
|
|
||||||
path.moveTo(ll2xy(subpath.first()));
|
QVector<QPointF> p(subpath.size());
|
||||||
for (int j = 1; j < subpath.size(); j++)
|
for (int j = 0; j < subpath.size(); j++)
|
||||||
path.lineTo(ll2xy(subpath.at(j)));
|
p[j] = ll2xy(subpath.at(j));
|
||||||
|
path.addPolygon(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
@ -352,20 +296,19 @@ void RasterTile::processPoints(QList<MapData::Point*> &points,
|
|||||||
const Style::Point &style = s.point(point->type());
|
const Style::Point &style = s.point(point->type());
|
||||||
|
|
||||||
const QString *label = point->label().isEmpty() ? 0 : &(point->label());
|
const QString *label = point->label().isEmpty() ? 0 : &(point->label());
|
||||||
QImage *rimg = style.img().isNull()
|
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||||
? image(point->type(), point->param()) : 0;
|
|
||||||
const QImage *img = style.img().isNull() ? rimg : &style.img();
|
|
||||||
const QFont *fnt = showLabel(img, _data->zooms(), _zoom, point->type())
|
const QFont *fnt = showLabel(img, _data->zooms(), _zoom, point->type())
|
||||||
? font(style.textFontSize()) : 0;
|
? font(style.textFontSize()) : 0;
|
||||||
const QColor *color = &style.textColor();
|
const QColor *color = &style.textColor();
|
||||||
const QColor *hColor = style.haloColor().isValid()
|
const QColor *hColor = style.haloColor().isValid()
|
||||||
? &style.haloColor() : 0;
|
? &style.haloColor() : 0;
|
||||||
|
double rotate = angle(point->type(), point->param());
|
||||||
|
|
||||||
if ((!label || !fnt) && !img)
|
if ((!label || !fnt) && !img)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PointItem *item = new PointItem(pos, label, fnt, img, rimg, color,
|
TextPointItem *item = new TextPointItem(pos, label, fnt, img, color,
|
||||||
hColor);
|
hColor, 0, 2, rotate);
|
||||||
if (item->isValid() && !item->collides(textItems)) {
|
if (item->isValid() && !item->collides(textItems)) {
|
||||||
textItems.append(item);
|
textItems.append(item);
|
||||||
if (lightsMap.contains(point->pos()))
|
if (lightsMap.contains(point->pos()))
|
||||||
|
@ -28,19 +28,6 @@ public:
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PointItem : public TextPointItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PointItem(const QPoint &point, const QString *text, const QFont *font,
|
|
||||||
const QImage *img, const QImage *rimg, const QColor *color,
|
|
||||||
const QColor *haloColor) : TextPointItem(point, text, font, img, color,
|
|
||||||
haloColor, 0, 2), _rimg(rimg) {}
|
|
||||||
~PointItem() {delete _rimg;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const QImage *_rimg;
|
|
||||||
};
|
|
||||||
|
|
||||||
void fetchData(QList<MapData::Poly*> &polygons, QList<MapData::Line*> &lines,
|
void fetchData(QList<MapData::Poly*> &polygons, QList<MapData::Line*> &lines,
|
||||||
QList<MapData::Point*> &points);
|
QList<MapData::Point*> &points);
|
||||||
QPointF ll2xy(const Coordinates &c) const
|
QPointF ll2xy(const Coordinates &c) const
|
||||||
|
@ -248,6 +248,7 @@ void Style::pointStyle()
|
|||||||
_points[SUBTYPE(I_DISMAR, 3)] = _points[SUBTYPE(I_DISMAR, 2)];
|
_points[SUBTYPE(I_DISMAR, 3)] = _points[SUBTYPE(I_DISMAR, 2)];
|
||||||
_points[SUBTYPE(I_DISMAR, 4)] = _points[SUBTYPE(I_DISMAR, 2)];
|
_points[SUBTYPE(I_DISMAR, 4)] = _points[SUBTYPE(I_DISMAR, 2)];
|
||||||
_points[TYPE(CGUSTA)] = Point(QImage(":/marine/coast-guard.png"));
|
_points[TYPE(CGUSTA)] = Point(QImage(":/marine/coast-guard.png"));
|
||||||
|
_points[TYPE(RSCSTA)] = Point(QImage(":/marine/rescue-station.png"));
|
||||||
_points[TYPE(RDOSTA)] = Point(QImage(":/marine/radio.png"));
|
_points[TYPE(RDOSTA)] = Point(QImage(":/marine/radio.png"));
|
||||||
_points[TYPE(RADSTA)] = Point(QImage(":/marine/radar.png"));
|
_points[TYPE(RADSTA)] = Point(QImage(":/marine/radar.png"));
|
||||||
_points[TYPE(RTPBCN)] = Point(QImage(":/marine/radar-transponder.png"));
|
_points[TYPE(RTPBCN)] = Point(QImage(":/marine/radar-transponder.png"));
|
||||||
@ -255,7 +256,9 @@ void Style::pointStyle()
|
|||||||
_points[TYPE(I_TRNBSN)] = Point(QImage(":/marine/turning-basin.png"));
|
_points[TYPE(I_TRNBSN)] = Point(QImage(":/marine/turning-basin.png"));
|
||||||
_points[TYPE(I_TRNBSN)].setTextColor(QColor("#eb49eb"));
|
_points[TYPE(I_TRNBSN)].setTextColor(QColor("#eb49eb"));
|
||||||
_points[TYPE(I_WTWGAG)] = Point(QImage(":/marine/gauge.png"), Small);
|
_points[TYPE(I_WTWGAG)] = Point(QImage(":/marine/gauge.png"), Small);
|
||||||
|
_points[TYPE(RDOCAL)] = Point(QImage(":/marine/radio-call.png"));
|
||||||
_points[TYPE(RDOCAL)].setTextColor(QColor("#eb49eb"));
|
_points[TYPE(RDOCAL)].setTextColor(QColor("#eb49eb"));
|
||||||
|
_points[TYPE(I_RDOCAL)] = Point(QImage(":/marine/radio-call.png"));
|
||||||
_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"));
|
||||||
@ -265,6 +268,7 @@ void Style::pointStyle()
|
|||||||
_points[TYPE(PILBOP)] = Point(QImage(":/marine/boarding-place.png"));
|
_points[TYPE(PILBOP)] = Point(QImage(":/marine/boarding-place.png"));
|
||||||
_points[TYPE(SISTAT)] = Point(QImage(":/marine/pylon.png"));
|
_points[TYPE(SISTAT)] = Point(QImage(":/marine/pylon.png"));
|
||||||
_points[TYPE(SLCONS)] = Point(QImage(":/marine/construction.png"), Small);
|
_points[TYPE(SLCONS)] = Point(QImage(":/marine/construction.png"), Small);
|
||||||
|
_points[TYPE(CURENT)] = Point(QImage(":/marine/current.png"));
|
||||||
|
|
||||||
_points[SUBTYPE(SMCFAC, 7)] = Point(QImage(":/POI/restaurant-11.png"), Small);
|
_points[SUBTYPE(SMCFAC, 7)] = Point(QImage(":/POI/restaurant-11.png"), Small);
|
||||||
_points[SUBTYPE(SMCFAC, 11)] = Point(QImage(":/POI/pharmacy-11.png"), Small);
|
_points[SUBTYPE(SMCFAC, 11)] = Point(QImage(":/POI/pharmacy-11.png"), Small);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <cmath>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QCache>
|
#include <QCache>
|
||||||
#include "common/programpaths.h"
|
#include "common/programpaths.h"
|
||||||
@ -8,6 +9,8 @@ using namespace Mapsforge;
|
|||||||
|
|
||||||
#define TEXT_EXTENT 160
|
#define TEXT_EXTENT 160
|
||||||
|
|
||||||
|
static double limit = cos(deg2rad(170));
|
||||||
|
|
||||||
static qreal area(const QPainterPath &polygon)
|
static qreal area(const QPainterPath &polygon)
|
||||||
{
|
{
|
||||||
qreal area = 0;
|
qreal area = 0;
|
||||||
@ -55,6 +58,47 @@ static const QColor *haloColor(const Style::TextRender *ti)
|
|||||||
? &ti->strokeColor() : 0;
|
? &ti->strokeColor() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QPainterPath parallelPath(const QPainterPath &p, double dy)
|
||||||
|
{
|
||||||
|
int n = p.elementCount() - 1;
|
||||||
|
QVector<QPointF> u(n);
|
||||||
|
QPainterPath h;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||||
|
h.reserve(p.elementCount());
|
||||||
|
#endif // QT 5.13
|
||||||
|
|
||||||
|
for (int k = 0; k < n; k++) {
|
||||||
|
qreal c = p.elementAt(k + 1).x - p.elementAt(k).x;
|
||||||
|
qreal s = p.elementAt(k + 1).y - p.elementAt(k).y;
|
||||||
|
qreal l = sqrt(c * c + s * s);
|
||||||
|
|
||||||
|
u[k] = (l == 0) ? QPointF(0, 0) : QPointF(c / l, s / l);
|
||||||
|
|
||||||
|
if (k == 0)
|
||||||
|
continue;
|
||||||
|
if (u.at(k).x() * u.at(k-1).x() + u.at(k).y() * u.at(k-1).y() < limit)
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
h.moveTo(QPointF(p.elementAt(0).x - dy * u.at(0).y(),
|
||||||
|
p.elementAt(0).y + dy * u.at(0).x()));
|
||||||
|
|
||||||
|
for (int k = 1; k < n; k++) {
|
||||||
|
qreal l = dy / (1 + u.at(k).x() * u.at(k-1).x()
|
||||||
|
+ u.at(k).y() * u.at(k-1).y());
|
||||||
|
QPainterPath::Element e(p.elementAt(k));
|
||||||
|
|
||||||
|
h.lineTo(QPointF(e.x - l * (u.at(k).y() + u.at(k-1).y()),
|
||||||
|
e.y + l * (u.at(k).x() + u.at(k-1).x())));
|
||||||
|
}
|
||||||
|
|
||||||
|
h.lineTo(QPointF(p.elementAt(n).x - dy * u.at(n-1).y(),
|
||||||
|
p.elementAt(n).y + dy * u.at(n-1).x()));
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
void RasterTile::processPointLabels(const QList<MapData::Point> &points,
|
void RasterTile::processPointLabels(const QList<MapData::Point> &points,
|
||||||
QList<TextItem*> &textItems)
|
QList<TextItem*> &textItems)
|
||||||
{
|
{
|
||||||
@ -306,12 +350,16 @@ void RasterTile::drawPaths(QPainter *painter, const QList<MapData::Path> &paths,
|
|||||||
|
|
||||||
if (path) {
|
if (path) {
|
||||||
const Style::PathRender *ri = is.pathRender();
|
const Style::PathRender *ri = is.pathRender();
|
||||||
|
qreal dy = ri->dy(_zoom);
|
||||||
|
|
||||||
if (!path->pp.elementCount())
|
if (!path->pp.elementCount())
|
||||||
path->pp = painterPath(path->path->poly, ri->curve());
|
path->pp = painterPath(path->path->poly, ri->curve());
|
||||||
|
|
||||||
painter->setPen(ri->pen(_zoom));
|
painter->setPen(ri->pen(_zoom));
|
||||||
painter->setBrush(ri->brush());
|
painter->setBrush(ri->brush());
|
||||||
|
if (dy != 0)
|
||||||
|
painter->drawPath(parallelPath(path->pp, dy));
|
||||||
|
else
|
||||||
painter->drawPath(path->pp);
|
painter->drawPath(path->pp);
|
||||||
} else {
|
} else {
|
||||||
const Style::CircleRender *ri = is.circleRender();
|
const Style::CircleRender *ri = is.circleRender();
|
||||||
|
@ -245,6 +245,13 @@ void Style::line(QXmlStreamReader &reader, const Rule &rule)
|
|||||||
if (curve == "cubic")
|
if (curve == "cubic")
|
||||||
ri._curve = true;
|
ri._curve = true;
|
||||||
}
|
}
|
||||||
|
if (attr.hasAttribute("dy")) {
|
||||||
|
ri._dy = attr.value("dy").toDouble(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
reader.raiseError("invalid dy value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ri.rule()._type == Rule::AnyType || ri.rule()._type == Rule::WayType)
|
if (ri.rule()._type == Rule::AnyType || ri.rule()._type == Rule::WayType)
|
||||||
_paths.append(ri);
|
_paths.append(ri);
|
||||||
@ -689,6 +696,11 @@ QPen Style::PathRender::pen(int zoom) const
|
|||||||
return Qt::NoPen;
|
return Qt::NoPen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal Style::PathRender::dy(int zoom) const
|
||||||
|
{
|
||||||
|
return (_scale && zoom >= 12) ? pow(1.5, zoom - 12) * _dy : _dy;
|
||||||
|
}
|
||||||
|
|
||||||
qreal Style::CircleRender::radius(int zoom) const
|
qreal Style::CircleRender::radius(int zoom) const
|
||||||
{
|
{
|
||||||
return (_scale && zoom >= 12) ? pow(1.5, zoom - 12) * _radius : _radius;
|
return (_scale && zoom >= 12) ? pow(1.5, zoom - 12) * _radius : _radius;
|
||||||
|
@ -137,13 +137,14 @@ public:
|
|||||||
PathRender(const Rule &rule, int zOrder) : Render(rule),
|
PathRender(const Rule &rule, int zOrder) : Render(rule),
|
||||||
_zOrder(zOrder), _strokeWidth(0), _strokeCap(Qt::RoundCap),
|
_zOrder(zOrder), _strokeWidth(0), _strokeCap(Qt::RoundCap),
|
||||||
_strokeJoin(Qt::RoundJoin), _area(false), _curve(false),
|
_strokeJoin(Qt::RoundJoin), _area(false), _curve(false),
|
||||||
_scale(Stroke) {}
|
_scale(Stroke), _dy(0) {}
|
||||||
|
|
||||||
int zOrder() const {return _zOrder;}
|
int zOrder() const {return _zOrder;}
|
||||||
QPen pen(int zoom) const;
|
QPen pen(int zoom) const;
|
||||||
const QBrush &brush() const {return _brush;}
|
const QBrush &brush() const {return _brush;}
|
||||||
bool area() const {return _area;}
|
bool area() const {return _area;}
|
||||||
bool curve() const {return _curve;}
|
bool curve() const {return _curve;}
|
||||||
|
qreal dy(int zoom) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Style;
|
friend class Style;
|
||||||
@ -159,6 +160,7 @@ public:
|
|||||||
QBrush _brush;
|
QBrush _brush;
|
||||||
bool _area, _curve;
|
bool _area, _curve;
|
||||||
Scale _scale;
|
Scale _scale;
|
||||||
|
qreal _dy;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CircleRender : public Render
|
class CircleRender : public Render
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <cmath>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
@ -18,9 +19,9 @@ static void expand(QRectF &rect, int width)
|
|||||||
|
|
||||||
TextPointItem::TextPointItem(const QPoint &point, const QString *text,
|
TextPointItem::TextPointItem(const QPoint &point, const QString *text,
|
||||||
const QFont *font, const QImage *img, const QColor *color,
|
const QFont *font, const QImage *img, const QColor *color,
|
||||||
const QColor *haloColor, const QColor *bgColor, int padding)
|
const QColor *haloColor, const QColor *bgColor, int padding, double rotate)
|
||||||
: TextItem(font ? text : 0), _font(font), _img(img), _color(color),
|
: TextItem(font ? text : 0), _font(font), _img(img), _color(color),
|
||||||
_haloColor(haloColor), _bgColor(bgColor)
|
_haloColor(haloColor), _bgColor(bgColor), _rotate(rotate)
|
||||||
{
|
{
|
||||||
if (_text) {
|
if (_text) {
|
||||||
QFontMetrics fm(*_font);
|
QFontMetrics fm(*_font);
|
||||||
@ -58,8 +59,17 @@ void TextPointItem::paint(QPainter *painter) const
|
|||||||
{
|
{
|
||||||
if (_img && !_img->isNull()) {
|
if (_img && !_img->isNull()) {
|
||||||
QSizeF s(_img->size() / _img->devicePixelRatioF());
|
QSizeF s(_img->size() / _img->devicePixelRatioF());
|
||||||
|
if (std::isnan(_rotate))
|
||||||
painter->drawImage(QPointF(_rect.left(), _rect.center().y()
|
painter->drawImage(QPointF(_rect.left(), _rect.center().y()
|
||||||
- s.height()/2), *_img);
|
- s.height()/2), *_img);
|
||||||
|
else {
|
||||||
|
painter->save();
|
||||||
|
painter->translate(QPointF(_rect.left() + s.width()/2,
|
||||||
|
_rect.center().y()));
|
||||||
|
painter->rotate(_rotate);
|
||||||
|
painter->drawImage(QPointF(-s.width()/2, -s.height()/2), *_img);
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_text) {
|
if (_text) {
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
TextPointItem() : TextItem(0), _font(0), _img(0) {}
|
TextPointItem() : TextItem(0), _font(0), _img(0) {}
|
||||||
TextPointItem(const QPoint &point, const QString *text, const QFont *font,
|
TextPointItem(const QPoint &point, const QString *text, const QFont *font,
|
||||||
const QImage *img, const QColor *color, const QColor *haloColor,
|
const QImage *img, const QColor *color, const QColor *haloColor,
|
||||||
const QColor *bgColor = 0, int padding = 0);
|
const QColor *bgColor = 0, int padding = 0, double rotate = NAN);
|
||||||
|
|
||||||
bool isValid() const {return !_rect.isEmpty();}
|
bool isValid() const {return !_rect.isEmpty();}
|
||||||
|
|
||||||
@ -31,6 +31,7 @@ private:
|
|||||||
const QFont *_font;
|
const QFont *_font;
|
||||||
const QImage *_img;
|
const QImage *_img;
|
||||||
const QColor *_color, *_haloColor, *_bgColor;
|
const QColor *_color, *_haloColor, *_bgColor;
|
||||||
|
double _rotate;
|
||||||
QRectF _rect, _textRect;
|
QRectF _rect, _textRect;
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user