Skip to content

Commit

Permalink
Added airport MSA (minimum sector altitude) display to map (symbols w…
Browse files Browse the repository at this point in the history
…ith all sectors), tooltip, map context menu for show information and information display.

#498
  • Loading branch information
albar965 committed Oct 26, 2021
1 parent 2e99961 commit 35a368b
Show file tree
Hide file tree
Showing 38 changed files with 1,338 additions and 600 deletions.
2 changes: 2 additions & 0 deletions littlenavmap.pro
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ SOURCES += \
src/mappainter/mappainteraltitude.cpp \
src/mappainter/mappainterils.cpp \
src/mappainter/mappaintermark.cpp \
src/mappainter/mappaintermsa.cpp \
src/mappainter/mappainternav.cpp \
src/mappainter/mappainterroute.cpp \
src/mappainter/mappaintership.cpp \
Expand Down Expand Up @@ -471,6 +472,7 @@ HEADERS += \
src/mappainter/mappainteraltitude.h \
src/mappainter/mappainterils.h \
src/mappainter/mappaintermark.h \
src/mappainter/mappaintermsa.h \
src/mappainter/mappainternav.h \
src/mappainter/mappainterroute.h \
src/mappainter/mappaintership.h \
Expand Down
1 change: 1 addition & 0 deletions littlenavmap.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,6 @@
<file>resources/icons/userpoint_Other.svg</file>
<file>resources/icons/gls.svg</file>
<file>resources/icons/enroutehold.svg</file>
<file>resources/icons/msa.svg</file>
</qresource>
</RCC>
212 changes: 212 additions & 0 deletions resources/icons/msa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions src/common/htmlinfobuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <QSize>
#include <QUrl>
#include <QFileInfo>
#include <QToolTip>

// Use % to concatenate strings faster than +
#include <QStringBuilder>
Expand Down Expand Up @@ -1727,6 +1728,73 @@ void HtmlInfoBuilder::weatherText(const map::WeatherContext& context, const MapA
} // if(info)
}

void HtmlInfoBuilder::airportMsaText(const map::MapAirportMsa& msa, atools::util::HtmlBuilder& html) const
{
html.img(QIcon(":/littlenavmap/resources/icons/msa.svg"), QString(), QString(), symbolSizeTitle);
html.nbsp().nbsp();

QString title;
if(msa.navType == map::AIRPORT)
title.append(tr("%1 %2").arg(tr("Airport")).arg(msa.navIdent));
else
{
if(!msa.navIdent.isEmpty())
{
if(msa.navType == map::WAYPOINT)
title.append(tr("%1 %2").arg(tr("Waypoint")).arg(msa.navIdent));
else if(msa.navType == map::VOR)
title.append(tr("%1 %2").arg(map::vorType(msa.vorDmeOnly, msa.vorHasDme, msa.vorTacan, msa.vorVortac)).arg(msa.navIdent));
else if(msa.navType == map::NDB)
title.append(tr("%1 %2").arg(tr("NDB")).arg(msa.navIdent));
else if(msa.navType == map::RUNWAYEND)
title.append(tr("%1 %2").arg(tr("Runway")).arg(msa.navIdent));
}

if(!msa.airportIdent.isEmpty())
title.append(tr(" (%1 %2)").arg(tr("Airport")).arg(msa.airportIdent));
}

navaidTitle(html, tr("MSA %1at %2").arg(msa.multipleCode % tr(" ")).arg(title));

if(info)
{
// Add map link if not tooltip
html.nbsp().nbsp();
html.a(tr("Map"), QString("lnm://show?lonx=%1&laty=%2").
arg(msa.position.getLonX()).arg(msa.position.getLatY()), ahtml::BOLD | ahtml::LINK_NO_UL);
}
html.table();
html.row2(tr("Radius:"), Unit::distNm(msa.radius));
html.row2(tr("Bearing and alt. units:"), msa.trueBearing ? tr("°T, ") : tr("°M, ") % Unit::getUnitAltStr());
if(info)
html.row2(tr("Magnetic declination:"), map::magvarText(msa.magvar));
if(msa.altitudes.size() == 0)
html.row2(tr("No altitude"));
else if(msa.altitudes.size() == 1)
html.row2(tr("Minimum altitude:"), Unit::altFeet(msa.altitudes.at(0)));
html.tableEnd();

if(verbose)
{
if(msa.altitudes.size() > 1)
{
QFont font;
if(info)
font = NavApp::getTextBrowserInfoFont();
else
font = QToolTip::font();

int actualSize = 0;
float sizeFactor = info ? (msa.altitudes.size() > 1 ? 5. : 2.) : (msa.altitudes.size() > 1 ? 4. : 2.);
QIcon icon = SymbolPainter().createAirportMsaIcon(msa, QToolTip::font(), sizeFactor, &actualSize);
html.p().img(icon, QString(), QString(), QSize(actualSize, actualSize)).pEnd();
}
}

if(info)
html.br();
}

void HtmlInfoBuilder::decodedMetars(HtmlBuilder& html, const atools::fs::weather::MetarResult& metar,
const map::MapAirport& airport, const QString& name, bool mapDisplay) const
{
Expand Down Expand Up @@ -2256,6 +2324,11 @@ void HtmlInfoBuilder::trafficPatternText(const TrafficPattern& pattern, atools::
html.br();
}

void HtmlInfoBuilder::userpointTextInfo(const MapUserpoint& userpoint, HtmlBuilder& html) const
{
userpointText(userpoint, html);
}

bool HtmlInfoBuilder::userpointText(MapUserpoint userpoint, HtmlBuilder& html) const
{
if(!userpoint.isValid())
Expand Down Expand Up @@ -2337,6 +2410,11 @@ bool HtmlInfoBuilder::userpointText(MapUserpoint userpoint, HtmlBuilder& html) c
}
}

void HtmlInfoBuilder::logEntryTextInfo(const MapLogbookEntry& logEntry, HtmlBuilder& html) const
{
logEntryText(logEntry, html);
}

bool HtmlInfoBuilder::logEntryText(MapLogbookEntry logEntry, HtmlBuilder& html) const
{
if(!logEntry.isValid())
Expand Down
11 changes: 11 additions & 0 deletions src/common/htmlinfobuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class QFileInfo;

namespace map {
struct MapAirport;
struct MapAirportMsa;
struct MapVor;
struct MapNdb;
struct MapWaypoint;
Expand Down Expand Up @@ -168,6 +169,14 @@ class HtmlInfoBuilder
void weatherText(const map::WeatherContext& context, const map::MapAirport& airport,
atools::util::HtmlBuilder& html) const;

/*
* Creates a HTML description for a VOR station.
* @param vor
* @param html Result containing HTML snippet
* @param background Background color for icons
*/
void airportMsaText(const map::MapAirportMsa& msa, atools::util::HtmlBuilder& html) const;

/*
* Creates a HTML description for a VOR station.
* @param vor
Expand Down Expand Up @@ -199,9 +208,11 @@ class HtmlInfoBuilder

/* Description for user defined points */
bool userpointText(map::MapUserpoint userpoint, atools::util::HtmlBuilder& html) const;
void userpointTextInfo(const map::MapUserpoint& userpoint, atools::util::HtmlBuilder& html) const;

/* Description for logbook entries */
bool logEntryText(map::MapLogbookEntry logEntry, atools::util::HtmlBuilder& html) const;
void logEntryTextInfo(const map::MapLogbookEntry& logEntry, atools::util::HtmlBuilder& html) const;

/*
* Creates a HTML description of an airway. For info this includes all waypoints.
Expand Down
8 changes: 8 additions & 0 deletions src/common/mapcolors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ QColor glsTextColor(20, 20, 20);
QPen glsCenterPen(Qt::darkGray, 1.5, Qt::DashLine);
QColor glsSymbolColor(Qt::darkGray);

QColor msaFillColor("#d0ffffff");
QColor msaTextColor(Qt::darkGray);
QColor msaSymbolColor(Qt::darkGray);

QColor waypointSymbolColor(200, 0, 200);

QColor airwayVictorColor("#969696"); // 1.
Expand Down Expand Up @@ -639,6 +643,10 @@ void syncColors()
syncColor(colorSettings, "GlsTextColor", glsTextColor);
syncPen(colorSettings, "GlsCenterPen", glsCenterPen);

syncColor(colorSettings, "MsaTextColor", msaTextColor);
syncColorArgb(colorSettings, "MsaFillColor", msaFillColor);
syncColor(colorSettings, "MsaSymbolColor", msaSymbolColor);

syncColor(colorSettings, "WaypointColor", waypointSymbolColor);
syncColor(colorSettings, "HoldingColor", holdingColor);
colorSettings.endGroup();
Expand Down
Loading

0 comments on commit 35a368b

Please sign in to comment.