mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-03-13 18:47:45 +01:00
Some more code cleanup
This commit is contained in:
parent
64b29f8aac
commit
39ed798a48
@ -226,11 +226,11 @@ static QRectF lightRect(const QPointF &pos, double range)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RasterTile::drawSectorLights(QPainter *painter,
|
void RasterTile::drawSectorLights(QPainter *painter,
|
||||||
const QList<SectorLight> &lights) const
|
const QMap<Coordinates, SectorLight> &lights) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < lights.size(); i++) {
|
for (auto it = lights.cbegin(); it != lights.cend(); ++it) {
|
||||||
const SectorLight &l = lights.at(i);
|
const SectorLight &l = it.value();
|
||||||
QPointF pos(ll2xy(l.pos));
|
QPointF pos(ll2xy(it.key()));
|
||||||
QRectF rect(lightRect(pos, (l.range == 0) ? 6 : l.range));
|
QRectF rect(lightRect(pos, (l.range == 0) ? 6 : l.range));
|
||||||
double a1 = -(l.end + 90);
|
double a1 = -(l.end + 90);
|
||||||
double a2 = -(l.start + 90);
|
double a2 = -(l.start + 90);
|
||||||
@ -264,10 +264,10 @@ void RasterTile::drawSectorLights(QPainter *painter,
|
|||||||
|
|
||||||
void RasterTile::processPoints(const QList<Data::Point> &points,
|
void RasterTile::processPoints(const QList<Data::Point> &points,
|
||||||
QList<TextItem*> &textItems, QList<TextItem*> &lights,
|
QList<TextItem*> &textItems, QList<TextItem*> &lights,
|
||||||
QList<SectorLight> §orLights, bool overZoom) const
|
QMap<Coordinates, SectorLight> §orLights, bool overZoom) const
|
||||||
{
|
{
|
||||||
QMap<Coordinates, Style::Color> lightsMap;
|
QMap<Coordinates, Style::Color> lightsMap;
|
||||||
QSet<Coordinates> signalsSet, sectorLightsSet;
|
QSet<Coordinates> signalsSet;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Lights & Signals */
|
/* Lights & Signals */
|
||||||
@ -281,10 +281,9 @@ void RasterTile::processPoints(const QList<Data::Point> &points,
|
|||||||
|
|
||||||
if (attr.contains(SECTR1)
|
if (attr.contains(SECTR1)
|
||||||
|| (range >= MAJOR_RANGE && !(point.type() & 0xFFFF))) {
|
|| (range >= MAJOR_RANGE && !(point.type() & 0xFFFF))) {
|
||||||
sectorLights.append(SectorLight(point.pos(), color,
|
sectorLights.insert(point.pos(), SectorLight(color,
|
||||||
attr.value(LITVIS).toUInt(), range,
|
attr.value(LITVIS).toUInt(), range,
|
||||||
attr.value(SECTR1).toDouble(), attr.value(SECTR2).toDouble()));
|
attr.value(SECTR1).toDouble(), attr.value(SECTR2).toDouble()));
|
||||||
sectorLightsSet.insert(point.pos());
|
|
||||||
} else
|
} else
|
||||||
lightsMap.insert(point.pos(), color);
|
lightsMap.insert(point.pos(), color);
|
||||||
} else if (point.type()>>16 == FOGSIG)
|
} else if (point.type()>>16 == FOGSIG)
|
||||||
@ -315,7 +314,7 @@ void RasterTile::processPoints(const QList<Data::Point> &points,
|
|||||||
|
|
||||||
TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
|
TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
|
||||||
color, hColor, 0, 2, rotate);
|
color, hColor, 0, 2, rotate);
|
||||||
if (item->isValid() && (sectorLightsSet.contains(point.pos())
|
if (item->isValid() && (sectorLights.contains(point.pos())
|
||||||
|| (point.polygon() && img) || !item->collides(textItems))) {
|
|| (point.polygon() && img) || !item->collides(textItems))) {
|
||||||
textItems.append(item);
|
textItems.append(item);
|
||||||
if (lightsMap.contains(point.pos()))
|
if (lightsMap.contains(point.pos()))
|
||||||
@ -357,7 +356,7 @@ void RasterTile::drawLevels(QPainter *painter, const QList<Level> &levels)
|
|||||||
{
|
{
|
||||||
for (int i = levels.size() - 1; i >= 0; i--) {
|
for (int i = levels.size() - 1; i >= 0; i--) {
|
||||||
QList<TextItem*> textItems, lights;
|
QList<TextItem*> textItems, lights;
|
||||||
QList<SectorLight> sectorLights;
|
QMap<Coordinates, SectorLight> sectorLights;
|
||||||
const Level &l = levels.at(i);
|
const Level &l = levels.at(i);
|
||||||
|
|
||||||
processPoints(l.points, textItems, lights, sectorLights, l.overZoom);
|
processPoints(l.points, textItems, lights, sectorLights, l.overZoom);
|
||||||
|
@ -39,11 +39,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
struct SectorLight
|
struct SectorLight
|
||||||
{
|
{
|
||||||
SectorLight(const Coordinates &pos, Style::Color color, uint visibility,
|
SectorLight(Style::Color color, uint visibility, double range,
|
||||||
double range, double start, double end) : pos(pos), color(color),
|
double start, double end) : color(color), visibility(visibility),
|
||||||
visibility(visibility), range(range), start(start), end(end) {}
|
range(range), start(start), end(end) {}
|
||||||
|
|
||||||
Coordinates pos;
|
|
||||||
Style::Color color;
|
Style::Color color;
|
||||||
uint visibility;
|
uint visibility;
|
||||||
double range;
|
double range;
|
||||||
@ -70,14 +69,15 @@ private:
|
|||||||
QPointF centroid(const QVector<Coordinates> &polygon) const;
|
QPointF centroid(const QVector<Coordinates> &polygon) const;
|
||||||
void processPoints(const QList<Data::Point> &points,
|
void processPoints(const QList<Data::Point> &points,
|
||||||
QList<TextItem*> &textItems, QList<TextItem *> &lights,
|
QList<TextItem*> &textItems, QList<TextItem *> &lights,
|
||||||
QList<SectorLight> §orLights, bool overZoom) const;
|
QMap<Coordinates, SectorLight> §orLights, bool overZoom) const;
|
||||||
void processLines(const QList<Data::Line> &lines,
|
void processLines(const QList<Data::Line> &lines,
|
||||||
QList<TextItem*> &textItems) const;
|
QList<TextItem*> &textItems) const;
|
||||||
void drawArrows(QPainter *painter, const QList<Data::Point> &points) const;
|
void drawArrows(QPainter *painter, const QList<Data::Point> &points) const;
|
||||||
void drawPolygons(QPainter *painter, const QList<Data::Poly> &polygons) const;
|
void drawPolygons(QPainter *painter, const QList<Data::Poly> &polygons) const;
|
||||||
void drawLines(QPainter *painter, const QList<Data::Line> &lines) const;
|
void drawLines(QPainter *painter, const QList<Data::Line> &lines) const;
|
||||||
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
|
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
|
||||||
void drawSectorLights(QPainter *painter, const QList<SectorLight> &lights) const;
|
void drawSectorLights(QPainter *painter,
|
||||||
|
const QMap<Coordinates, SectorLight> &lights) const;
|
||||||
bool showLabel(const QImage *img, int type) const;
|
bool showLabel(const QImage *img, int type) const;
|
||||||
void drawLevels(QPainter *painter, const QList<Level> &levels);
|
void drawLevels(QPainter *painter, const QList<Level> &levels);
|
||||||
QList<Level> fetchLevels();
|
QList<Level> fetchLevels();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user