mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-04-19 19:59:11 +02:00
Compare commits
No commits in common. "a9572d05fe1717b242bd608f7563e09742a591d8" and "db6e891c30e3fe4d96e6a10400d1e7a273c7731c" have entirely different histories.
a9572d05fe
...
db6e891c30
@ -226,11 +226,11 @@ static QRectF lightRect(const QPointF &pos, double range)
|
||||
}
|
||||
|
||||
void RasterTile::drawSectorLights(QPainter *painter,
|
||||
const QMultiMap<Coordinates, SectorLight> &lights) const
|
||||
const QList<SectorLight> &lights) const
|
||||
{
|
||||
for (auto it = lights.cbegin(); it != lights.cend(); ++it) {
|
||||
const SectorLight &l = it.value();
|
||||
QPointF pos(ll2xy(it.key()));
|
||||
for (int i = 0; i < lights.size(); i++) {
|
||||
const SectorLight &l = lights.at(i);
|
||||
QPointF pos(ll2xy(l.pos));
|
||||
QRectF rect(lightRect(pos, (l.range == 0) ? 6 : l.range));
|
||||
double a1 = -(l.end + 90);
|
||||
double a2 = -(l.start + 90);
|
||||
@ -263,11 +263,12 @@ void RasterTile::drawSectorLights(QPainter *painter,
|
||||
}
|
||||
|
||||
void RasterTile::processPoints(const QList<Data::Point> &points,
|
||||
QList<TextItem*> &textItems, QList<TextItem*> &lightItems,
|
||||
QMultiMap<Coordinates, SectorLight> §orLights, bool overZoom) const
|
||||
QList<TextItem*> &textItems, QList<TextItem*> &lights,
|
||||
QList<SectorLight> §orLights, bool overZoom) const
|
||||
{
|
||||
QMap<Coordinates, Style::Color> lights;
|
||||
QSet<Coordinates> sigs;
|
||||
LightMap lightsMap;
|
||||
SignalSet signalsSet;
|
||||
QSet<Coordinates> slMap;
|
||||
int i;
|
||||
|
||||
/* Lights & Signals */
|
||||
@ -281,13 +282,14 @@ void RasterTile::processPoints(const QList<Data::Point> &points,
|
||||
|
||||
if (attr.contains(SECTR1)
|
||||
|| (range >= MAJOR_RANGE && !(point.type() & 0xFFFF))) {
|
||||
sectorLights.insert(point.pos(), SectorLight(color,
|
||||
sectorLights.append(SectorLight(point.pos(), color,
|
||||
attr.value(LITVIS).toUInt(), range,
|
||||
attr.value(SECTR1).toDouble(), attr.value(SECTR2).toDouble()));
|
||||
slMap.insert(point.pos());
|
||||
} else
|
||||
lights.insert(point.pos(), color);
|
||||
lightsMap.insert(point.pos(), color);
|
||||
} else if (point.type()>>16 == FOGSIG)
|
||||
sigs.insert(point.pos());
|
||||
signalsSet.insert(point.pos());
|
||||
else
|
||||
break;
|
||||
}
|
||||
@ -314,14 +316,14 @@ void RasterTile::processPoints(const QList<Data::Point> &points,
|
||||
|
||||
TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
|
||||
color, hColor, 0, 2, rotate);
|
||||
if (item->isValid() && (sectorLights.contains(point.pos())
|
||||
if (item->isValid() && (slMap.contains(point.pos())
|
||||
|| (point.polygon() && img) || !item->collides(textItems))) {
|
||||
textItems.append(item);
|
||||
if (lights.contains(point.pos()))
|
||||
lightItems.append(new TextPointItem(pos + _style->lightOffset(),
|
||||
0, 0, _style->light(lights.value(point.pos())), 0, 0, 0, 0));
|
||||
if (sigs.contains(point.pos()))
|
||||
lightItems.append(new TextPointItem(pos + _style->signalOffset(),
|
||||
if (lightsMap.contains(point.pos()))
|
||||
lights.append(new TextPointItem(pos + _style->lightOffset(),
|
||||
0, 0, _style->light(lightsMap.value(point.pos())), 0, 0, 0, 0));
|
||||
if (signalsSet.contains(point.pos()))
|
||||
lights.append(new TextPointItem(pos + _style->signalOffset(),
|
||||
0, 0, _style->signal(), 0, 0, 0, 0));
|
||||
} else
|
||||
delete item;
|
||||
@ -355,23 +357,23 @@ void RasterTile::processLines(const QList<Data::Line> &lines,
|
||||
void RasterTile::drawLevels(QPainter *painter, const QList<Level> &levels)
|
||||
{
|
||||
for (int i = levels.size() - 1; i >= 0; i--) {
|
||||
QList<TextItem*> textItems, lightItems;
|
||||
QMultiMap<Coordinates, SectorLight> sectorLights;
|
||||
QList<TextItem*> textItems, lights;
|
||||
QList<SectorLight> sectorLights;
|
||||
const Level &l = levels.at(i);
|
||||
|
||||
processPoints(l.points, textItems, lightItems, sectorLights, l.overZoom);
|
||||
processPoints(l.points, textItems, lights, sectorLights, l.overZoom);
|
||||
processLines(l.lines, textItems);
|
||||
|
||||
drawPolygons(painter, l.polygons);
|
||||
drawLines(painter, l.lines);
|
||||
drawArrows(painter, l.points);
|
||||
|
||||
drawTextItems(painter, lightItems);
|
||||
drawTextItems(painter, lights);
|
||||
drawSectorLights(painter, sectorLights);
|
||||
drawTextItems(painter, textItems);
|
||||
|
||||
qDeleteAll(textItems);
|
||||
qDeleteAll(lightItems);
|
||||
qDeleteAll(lights);
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,7 +418,7 @@ QList<RasterTile::Level> RasterTile::fetchLevels()
|
||||
if (!level.isNull())
|
||||
list.append(level);
|
||||
|
||||
if (_data.size() > 1 && shape(level.polygons).contains(_rect))
|
||||
if (_data.size() > 0 && shape(level.polygons).contains(_rect))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,11 @@ public:
|
||||
private:
|
||||
struct SectorLight
|
||||
{
|
||||
SectorLight(Style::Color color, uint visibility, double range,
|
||||
double start, double end) : color(color), visibility(visibility),
|
||||
range(range), start(start), end(end) {}
|
||||
SectorLight(const Coordinates &pos, Style::Color color, uint visibility,
|
||||
double range, double start, double end) : pos(pos), color(color),
|
||||
visibility(visibility), range(range), start(start), end(end) {}
|
||||
|
||||
Coordinates pos;
|
||||
Style::Color color;
|
||||
uint visibility;
|
||||
double range;
|
||||
@ -60,6 +61,9 @@ private:
|
||||
{return lines.isEmpty() && polygons.isEmpty() && points.isEmpty();}
|
||||
};
|
||||
|
||||
typedef QMap<Coordinates, Style::Color> LightMap;
|
||||
typedef QSet<Coordinates> SignalSet;
|
||||
|
||||
QPointF ll2xy(const Coordinates &c) const
|
||||
{return _transform.proj2img(_proj.ll2xy(c));}
|
||||
QPainterPath painterPath(const Polygon &polygon) const;
|
||||
@ -68,16 +72,15 @@ private:
|
||||
QPolygonF tsslptArrow(const QPointF &p, qreal angle) const;
|
||||
QPointF centroid(const QVector<Coordinates> &polygon) const;
|
||||
void processPoints(const QList<Data::Point> &points,
|
||||
QList<TextItem*> &textItems, QList<TextItem*> &lightItems,
|
||||
QMultiMap<Coordinates, SectorLight> §orLights, bool overZoom) const;
|
||||
QList<TextItem*> &textItems, QList<TextItem *> &lights,
|
||||
QList<SectorLight> §orLights, bool overZoom) const;
|
||||
void processLines(const QList<Data::Line> &lines,
|
||||
QList<TextItem*> &textItems) const;
|
||||
void drawArrows(QPainter *painter, const QList<Data::Point> &points) const;
|
||||
void drawPolygons(QPainter *painter, const QList<Data::Poly> &polygons) const;
|
||||
void drawLines(QPainter *painter, const QList<Data::Line> &lines) const;
|
||||
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
|
||||
void drawSectorLights(QPainter *painter,
|
||||
const QMultiMap<Coordinates, SectorLight> &lights) const;
|
||||
void drawSectorLights(QPainter *painter, const QList<SectorLight> &lights) const;
|
||||
bool showLabel(const QImage *img, int type) const;
|
||||
void drawLevels(QPainter *painter, const QList<Level> &levels);
|
||||
QList<Level> fetchLevels();
|
||||
|
Loading…
x
Reference in New Issue
Block a user