mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Improved area labels layout
This commit is contained in:
parent
6493d10930
commit
6ca1e3b67c
@ -16,6 +16,13 @@ using namespace Mapsforge;
|
|||||||
|
|
||||||
static double LIMIT = cos(deg2rad(170));
|
static double LIMIT = cos(deg2rad(170));
|
||||||
|
|
||||||
|
static bool rectNearPolygon(const QPainterPath &path, const QRectF &rect)
|
||||||
|
{
|
||||||
|
return (path.boundingRect().contains(rect)
|
||||||
|
&& (path.contains(rect.topLeft()) || path.contains(rect.topRight())
|
||||||
|
|| path.contains(rect.bottomLeft()) || path.contains(rect.bottomRight())));
|
||||||
|
}
|
||||||
|
|
||||||
static QPointF centroid(const QPainterPath &polygon)
|
static QPointF centroid(const QPainterPath &polygon)
|
||||||
{
|
{
|
||||||
qreal area = 0;
|
qreal area = 0;
|
||||||
@ -208,6 +215,7 @@ void RasterTile::processAreaLabels(const QVector<PainterPath> &paths,
|
|||||||
PointItem *item = new PointItem(pos.toPoint(), p.lbl, font, img, color,
|
PointItem *item = new PointItem(pos.toPoint(), p.lbl, font, img, color,
|
||||||
hColor);
|
hColor);
|
||||||
if (item->isValid() && _rect.contains(item->boundingRect().toRect())
|
if (item->isValid() && _rect.contains(item->boundingRect().toRect())
|
||||||
|
&& rectNearPolygon(p.p->pp, item->boundingRect())
|
||||||
&& !item->collides(textItems)) {
|
&& !item->collides(textItems)) {
|
||||||
textItems.append(item);
|
textItems.append(item);
|
||||||
if (p.ti && p.lbl)
|
if (p.ti && p.lbl)
|
||||||
|
Loading…
Reference in New Issue
Block a user