mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-19 21:34:24 +02:00
Use generic icon rotate instead of special icon draw functions
This commit is contained in:
@ -10,15 +10,11 @@
|
||||
using namespace ENC;
|
||||
|
||||
#define TEXT_EXTENT 160
|
||||
|
||||
#define TSSLPT_SIZE 0.005 /* ll */
|
||||
#define RDOCAL_SIZE 12 /* px */
|
||||
#define CURENT_SIZE 12 /* px */
|
||||
|
||||
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 struct {
|
||||
@ -105,67 +101,14 @@ static Coordinates centroid(const QVector<Coordinates> &polygon)
|
||||
return Coordinates(cx * factor, cy * factor);
|
||||
}
|
||||
|
||||
static QImage *rdocalArrow(qreal angle)
|
||||
{
|
||||
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)
|
||||
static double angle(uint type, const QVariant ¶m)
|
||||
{
|
||||
if (type>>16 == RDOCAL || type>>16 == I_RDOCAL)
|
||||
return rdocalArrow(deg2rad(90 - param.toDouble()));
|
||||
return 90 + param.toDouble();
|
||||
else if (type>>16 == CURENT)
|
||||
return currentArrow(deg2rad(90 - param.toDouble()));
|
||||
return 90 + param.toDouble();
|
||||
else
|
||||
return 0;
|
||||
return NAN;
|
||||
}
|
||||
|
||||
static bool showLabel(const QImage *img, const Range &range, int zoom, int type)
|
||||
@ -352,20 +295,19 @@ void RasterTile::processPoints(QList<MapData::Point*> &points,
|
||||
const Style::Point &style = s.point(point->type());
|
||||
|
||||
const QString *label = point->label().isEmpty() ? 0 : &(point->label());
|
||||
QImage *rimg = style.img().isNull()
|
||||
? image(point->type(), point->param()) : 0;
|
||||
const QImage *img = style.img().isNull() ? rimg : &style.img();
|
||||
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||
const QFont *fnt = showLabel(img, _data->zooms(), _zoom, point->type())
|
||||
? font(style.textFontSize()) : 0;
|
||||
const QColor *color = &style.textColor();
|
||||
const QColor *hColor = style.haloColor().isValid()
|
||||
? &style.haloColor() : 0;
|
||||
double rotate = angle(point->type(), point->param());
|
||||
|
||||
if ((!label || !fnt) && !img)
|
||||
continue;
|
||||
|
||||
PointItem *item = new PointItem(pos, label, fnt, img, rimg, color,
|
||||
hColor);
|
||||
TextPointItem *item = new TextPointItem(pos, label, fnt, img, color,
|
||||
hColor, 0, 2, rotate);
|
||||
if (item->isValid() && !item->collides(textItems)) {
|
||||
textItems.append(item);
|
||||
if (lightsMap.contains(point->pos()))
|
||||
|
@ -28,19 +28,6 @@ public:
|
||||
void render();
|
||||
|
||||
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,
|
||||
QList<MapData::Point*> &points);
|
||||
QPointF ll2xy(const Coordinates &c) const
|
||||
|
@ -255,7 +255,9 @@ void Style::pointStyle()
|
||||
_points[TYPE(I_TRNBSN)] = Point(QImage(":/marine/turning-basin.png"));
|
||||
_points[TYPE(I_TRNBSN)].setTextColor(QColor("#eb49eb"));
|
||||
_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(I_RDOCAL)] = Point(QImage(":/marine/radio-call.png"));
|
||||
_points[TYPE(I_RDOCAL)].setTextColor(QColor("#eb49eb"));
|
||||
_points[TYPE(PYLONS)] = Point(QImage(":/marine/pylon.png"));
|
||||
_points[SUBTYPE(I_BERTHS, 6)] = Point(QImage(":/marine/fleeting-area.png"));
|
||||
@ -265,6 +267,7 @@ void Style::pointStyle()
|
||||
_points[TYPE(PILBOP)] = Point(QImage(":/marine/boarding-place.png"));
|
||||
_points[TYPE(SISTAT)] = Point(QImage(":/marine/pylon.png"));
|
||||
_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, 11)] = Point(QImage(":/POI/pharmacy-11.png"), Small);
|
||||
|
Reference in New Issue
Block a user