mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-13 06:30:49 +01:00
Sector lights rendering polishing
This commit is contained in:
parent
9059e6d30d
commit
e0000d7299
@ -31,6 +31,7 @@
|
|||||||
#define SECTR2 137
|
#define SECTR2 137
|
||||||
#define TRAFIC 172
|
#define TRAFIC 172
|
||||||
#define VALDCO 174
|
#define VALDCO 174
|
||||||
|
#define VALNMR 178
|
||||||
#define VERCLR 181
|
#define VERCLR 181
|
||||||
#define WATLEV 187
|
#define WATLEV 187
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ using namespace ENC;
|
|||||||
|
|
||||||
#define TEXT_EXTENT 160
|
#define TEXT_EXTENT 160
|
||||||
#define TSSLPT_SIZE 24
|
#define TSSLPT_SIZE 24
|
||||||
#define SECTOR_RADIUS 40
|
#define RANGE_FACTOR 4
|
||||||
|
|
||||||
static const float C1 = 0.866025f; /* sqrt(3)/2 */
|
static const float C1 = 0.866025f; /* sqrt(3)/2 */
|
||||||
static const QColor tsslptPen = QColor(0xeb, 0x49, 0xeb);
|
static const QColor tsslptPen = QColor(0xeb, 0x49, 0xeb);
|
||||||
@ -213,36 +213,46 @@ void RasterTile::drawTextItems(QPainter *painter,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QRectF lightRect(const QPointF &pos, double range)
|
||||||
|
{
|
||||||
|
return QRectF(pos.x() - range * RANGE_FACTOR, pos.y() - range * RANGE_FACTOR,
|
||||||
|
2*range * RANGE_FACTOR, 2*range * RANGE_FACTOR);
|
||||||
|
}
|
||||||
|
|
||||||
void RasterTile::drawSectorLights(QPainter *painter,
|
void RasterTile::drawSectorLights(QPainter *painter,
|
||||||
const QList<SectorLight> &lights) const
|
const QList<SectorLight> &lights) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < lights.size(); i++) {
|
for (int i = 0; i < lights.size(); i++) {
|
||||||
const SectorLight &l = lights.at(i);
|
const SectorLight &l = lights.at(i);
|
||||||
QPointF pos(ll2xy(l.pos));
|
QPointF pos(ll2xy(l.pos));
|
||||||
QRectF rect(pos.x() - SECTOR_RADIUS, pos.y() - SECTOR_RADIUS,
|
QRectF rect(lightRect(pos, (l.range == 0) ? 6 : l.range));
|
||||||
2*SECTOR_RADIUS, 2*SECTOR_RADIUS);
|
|
||||||
double a1 = -(l.end + 90);
|
double a1 = -(l.end + 90);
|
||||||
double a2 = -(l.start + 90);
|
double a2 = -(l.start + 90);
|
||||||
if (a1 > a2)
|
if (a1 > a2)
|
||||||
a2 += 360;
|
a2 += 360;
|
||||||
|
double as = (a2 - a1);
|
||||||
|
if (as == 0)
|
||||||
|
as = 360;
|
||||||
|
|
||||||
if (l.visibility == 3 || l.visibility >= 6)
|
if (l.visibility == 3 || l.visibility >= 6)
|
||||||
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
||||||
else {
|
else {
|
||||||
painter->setPen(QPen(Qt::black, 6, Qt::SolidLine, Qt::FlatCap));
|
painter->setPen(QPen(Qt::black, 6, Qt::SolidLine, Qt::FlatCap));
|
||||||
painter->drawArc(rect, a1 * 16, (a2 - a1) * 16);
|
painter->drawArc(rect, a1 * 16, as * 16);
|
||||||
painter->setPen(QPen(Style::color(l.color), 4, Qt::SolidLine,
|
painter->setPen(QPen(Style::color(l.color), 4, Qt::SolidLine,
|
||||||
Qt::FlatCap));
|
Qt::FlatCap));
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->drawArc(rect, a1 * 16, (a2 - a1) * 16);
|
painter->drawArc(rect, a1 * 16, as * 16);
|
||||||
|
|
||||||
QLineF ln(pos, QPointF(pos.x() + 2*SECTOR_RADIUS, pos.y()));
|
if (a2 - a1 != 0) {
|
||||||
ln.setAngle(a1);
|
QLineF ln(pos, QPointF(pos.x() + rect.width(), pos.y()));
|
||||||
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
ln.setAngle(a1);
|
||||||
painter->drawLine(ln);
|
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
||||||
ln.setAngle(a2);
|
painter->drawLine(ln);
|
||||||
painter->drawLine(ln);
|
ln.setAngle(a2);
|
||||||
|
painter->drawLine(ln);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +262,7 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
|||||||
{
|
{
|
||||||
LightMap lightsMap;
|
LightMap lightsMap;
|
||||||
SignalSet signalsSet;
|
SignalSet signalsSet;
|
||||||
|
QSet<Coordinates> slMap;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
std::sort(points.begin(), points.end());
|
std::sort(points.begin(), points.end());
|
||||||
@ -263,11 +274,14 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
|||||||
if (point.type()>>16 == LIGHTS) {
|
if (point.type()>>16 == LIGHTS) {
|
||||||
const MapData::Attributes &attr = point.attributes();
|
const MapData::Attributes &attr = point.attributes();
|
||||||
Style::Color color = (Style::Color)(attr.value(COLOUR).toUInt());
|
Style::Color color = (Style::Color)(attr.value(COLOUR).toUInt());
|
||||||
|
double range = attr.value(VALNMR).toDouble();
|
||||||
|
|
||||||
if (attr.contains(SECTR1)) {
|
if (attr.contains(SECTR1)
|
||||||
|
|| (range >= 6 && !(point.type() & 0xFFFF))) {
|
||||||
sectorLights.append(SectorLight(point.pos(), color,
|
sectorLights.append(SectorLight(point.pos(), color,
|
||||||
attr.value(LITVIS).toUInt(), attr.value(SECTR1).toDouble(),
|
attr.value(LITVIS).toUInt(), range,
|
||||||
attr.value(SECTR2).toDouble()));
|
attr.value(SECTR1).toDouble(), attr.value(SECTR2).toDouble()));
|
||||||
|
slMap.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)
|
||||||
@ -298,7 +312,8 @@ void RasterTile::processPoints(QList<MapData::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() && !item->collides(textItems)) {
|
if (item->isValid() && (slMap.contains(point.pos())
|
||||||
|
|| !item->collides(textItems))) {
|
||||||
textItems.append(item);
|
textItems.append(item);
|
||||||
if (lightsMap.contains(point.pos()))
|
if (lightsMap.contains(point.pos()))
|
||||||
lights.append(new TextPointItem(pos + _style->lightOffset(),
|
lights.append(new TextPointItem(pos + _style->lightOffset(),
|
||||||
|
@ -37,12 +37,13 @@ private:
|
|||||||
struct SectorLight
|
struct SectorLight
|
||||||
{
|
{
|
||||||
SectorLight(const Coordinates &pos, Style::Color color, uint visibility,
|
SectorLight(const Coordinates &pos, Style::Color color, uint visibility,
|
||||||
double start, double end) : pos(pos), color(color),
|
double range, double start, double end) : pos(pos), color(color),
|
||||||
visibility(visibility), start(start), end(end) {}
|
visibility(visibility), range(range), start(start), end(end) {}
|
||||||
|
|
||||||
Coordinates pos;
|
Coordinates pos;
|
||||||
Style::Color color;
|
Style::Color color;
|
||||||
uint visibility;
|
uint visibility;
|
||||||
|
double range;
|
||||||
double start;
|
double start;
|
||||||
double end;
|
double end;
|
||||||
};
|
};
|
||||||
|
@ -245,7 +245,7 @@ void RasterTile::drawSectorLights(QPainter *painter,
|
|||||||
const Lights::Sector &end = (j == p->lights.sectors.size() - 1)
|
const Lights::Sector &end = (j == p->lights.sectors.size() - 1)
|
||||||
? p->lights.sectors.at(0) : p->lights.sectors.at(j+1);
|
? p->lights.sectors.at(0) : p->lights.sectors.at(j+1);
|
||||||
|
|
||||||
if (start.color && start.range) {
|
if (start.color) {
|
||||||
double a1 = -(end.angle / 10.0 + 90.0);
|
double a1 = -(end.angle / 10.0 + 90.0);
|
||||||
double a2 = -(start.angle / 10.0 + 90.0);
|
double a2 = -(start.angle / 10.0 + 90.0);
|
||||||
if (a1 > a2)
|
if (a1 > a2)
|
||||||
@ -254,7 +254,7 @@ void RasterTile::drawSectorLights(QPainter *painter,
|
|||||||
if (as == 0)
|
if (as == 0)
|
||||||
as = 360;
|
as = 360;
|
||||||
|
|
||||||
QRect rect(lightRect(pos, start.range));
|
QRect rect(lightRect(pos, start.range ? start.range : 6));
|
||||||
|
|
||||||
painter->setPen(QPen(Qt::black, 6, Qt::SolidLine,
|
painter->setPen(QPen(Qt::black, 6, Qt::SolidLine,
|
||||||
Qt::FlatCap));
|
Qt::FlatCap));
|
||||||
@ -492,8 +492,8 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
|||||||
|
|
||||||
TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
|
TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
|
||||||
color, hcolor, 0, ICON_PADDING);
|
color, hcolor, 0, ICON_PADDING);
|
||||||
if (point.lights.isSectorLight()
|
if (item->isValid() && (point.lights.isSectorLight()
|
||||||
|| (item->isValid() && !item->collides(textItems))) {
|
|| !item->collides(textItems))) {
|
||||||
textItems.append(item);
|
textItems.append(item);
|
||||||
if (point.lights.color && !point.lights.isSectorLight())
|
if (point.lights.color && !point.lights.isSectorLight())
|
||||||
textItems.append(new TextPointItem(pos + style->lightOffset(),
|
textItems.append(new TextPointItem(pos + style->lightOffset(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user