Skip to content

Commit

Permalink
Vertical angle now shown in procedure legs in flight plan and procedu…
Browse files Browse the repository at this point in the history
…re search.

Added tooltips for procedure search header.
#803
  • Loading branch information
albar965 committed Oct 19, 2021
1 parent 367c9bb commit 5a9989f
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 42 deletions.
1 change: 1 addition & 0 deletions src/common/mapflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace map {
/* Value for invalid/not found distances */
Q_DECL_CONSTEXPR static float INVALID_COURSE_VALUE = std::numeric_limits<float>::max();
Q_DECL_CONSTEXPR static float INVALID_HEADING_VALUE = INVALID_COURSE_VALUE;
Q_DECL_CONSTEXPR static float INVALID_ANGLE_VALUE = INVALID_COURSE_VALUE;
Q_DECL_CONSTEXPR static float INVALID_DISTANCE_VALUE = std::numeric_limits<float>::max();
Q_DECL_CONSTEXPR static float INVALID_ALTITUDE_VALUE = std::numeric_limits<float>::max();
Q_DECL_CONSTEXPR static float INVALID_SPEED_VALUE = std::numeric_limits<float>::max();
Expand Down
15 changes: 15 additions & 0 deletions src/common/proctypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,21 @@ QString procedureLegRemarks(proc::ProcedureLegType type)
return approachLegRemarkStr.value(type);
}

QString restrictionText(const MapProcedureLeg& procedureLeg)
{
QStringList restrictions;
if(procedureLeg.altRestriction.isValid())
restrictions.append(proc::altRestrictionTextShort(procedureLeg.altRestriction));

if(procedureLeg.speedRestriction.isValid())
restrictions.append(proc::speedRestrictionTextShort(procedureLeg.speedRestriction));

if(procedureLeg.verticalAngle < map::INVALID_ANGLE_VALUE)
restrictions.append(QObject::tr("%L1°").arg(procedureLeg.verticalAngle, 0, 'g', 3));

return restrictions.join(QObject::tr("/"));
}

QString altRestrictionText(const MapAltRestriction& restriction)
{
switch(restriction.descriptor)
Expand Down
6 changes: 5 additions & 1 deletion src/common/proctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ struct MapProcedureLeg
time /* Only for holds in minutes */,
theta /* magnetic course to recommended navaid */,
rho /* distance to recommended navaid in NM */,
magvar /* from navaid or airport */;
magvar /* from navaid or airport */,
verticalAngle = map::INVALID_ANGLE_VALUE /* degrees or INVALID_ANGLE_VALUE if not available */;

bool missed = false, flyover = false, trueCourse = false,
intercept = false, /* Leg was modified by a previous intercept */
Expand Down Expand Up @@ -627,6 +628,9 @@ QString procedureLegTypeFullStr(ProcedureLegType type);
QString procedureLegRemarks(proc::ProcedureLegType);
QString altRestrictionText(const MapAltRestriction& restriction);

/* Slash separated list of all restrictions, altitude, speed and angle */
QString restrictionText(const MapProcedureLeg& procedureLeg);

/* true if leg has fix at the start */
bool procedureLegFixAtStart(proc::ProcedureLegType type);

Expand Down
8 changes: 4 additions & 4 deletions src/profile/profilewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,12 @@ void ProfileWidget::calcLeftMargin()
// Calculate departure altitude text size
float departAlt = legList->route.getDepartureAirportLeg().getPosition().getAltitude();
if(departAlt < map::INVALID_ALTITUDE_VALUE / 2.f)
left = std::max(metrics.width(Unit::altFeet(departAlt)), left);
left = std::max(metrics.horizontalAdvance(Unit::altFeet(departAlt)), left);

// Calculate destination altitude text size
float destAlt = legList->route.getDestinationAirportLeg().getPosition().getAltitude();
if(destAlt < map::INVALID_ALTITUDE_VALUE / 2.f)
left = std::max(metrics.width(Unit::altFeet(destAlt)), left);
left = std::max(metrics.horizontalAdvance(Unit::altFeet(destAlt)), left);
left += 8;
left = std::max(left, 30);
}
Expand Down Expand Up @@ -1137,7 +1137,7 @@ void ProfileWidget::paintEvent(QPaintEvent *)
const RouteLeg& departureLeg = route.getDepartureAirportLeg();
if(departureLeg.getMapObjectType() == map::AIRPORT)
{
int textW = painter.fontMetrics().width(departureLeg.getDisplayIdent());
int textW = painter.fontMetrics().horizontalAdvance(departureLeg.getDisplayIdent());
symPainter.drawAirportSymbol(&painter,
departureLeg.getAirport(), left, flightplanY, airportSize, false, false, false);
symPainter.drawAirportText(&painter, departureLeg.getAirport(), left - textW / 2, flightplanTextY,
Expand All @@ -1148,7 +1148,7 @@ void ProfileWidget::paintEvent(QPaintEvent *)
const RouteLeg& destinationLeg = route.getDestinationAirportLeg();
if(destinationLeg.getMapObjectType() == map::AIRPORT)
{
int textW = painter.fontMetrics().width(destinationLeg.getDisplayIdent());
int textW = painter.fontMetrics().horizontalAdvance(destinationLeg.getDisplayIdent());
symPainter.drawAirportSymbol(&painter, destinationLeg.getAirport(), left + w, flightplanY, airportSize, false,
false, false);
symPainter.drawAirportText(&painter, destinationLeg.getAirport(), left + w - textW / 2, flightplanTextY,
Expand Down
5 changes: 5 additions & 0 deletions src/query/procedurequery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ void ProcedureQuery::buildLegEntry(atools::sql::SqlQuery *query, proc::MapProced
leg.speedRestriction.speed = 0.f;
}

if(query->hasField("vertical_angle") && !query->isNull("vertical_angle"))
leg.verticalAngle = query->valueFloat("vertical_angle");
else
leg.verticalAngle = map::INVALID_ANGLE_VALUE;

leg.magvar = map::INVALID_MAGVAR;

// Use fix position if present - otherwise use airport position to get nearest fix
Expand Down
32 changes: 12 additions & 20 deletions src/route/routecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ RouteController::RouteController(QMainWindow *parentWindow, QTableView *tableVie
QObject::tr("Name"),
QObject::tr("Procedure"),
QObject::tr("Airway or\nProcedure"),
QObject::tr("Restriction\n%alt%/%speed%"),
QObject::tr("Restriction\n%alt%/%speed%/angle"),
QObject::tr("Type"),
QObject::tr("Freq.\nMHz/kHz/Cha."),
QObject::tr("Range\n%dist%"),
Expand All @@ -159,12 +159,12 @@ RouteController::RouteController(QMainWindow *parentWindow, QTableView *tableVie
{
QObject::tr("ICAO ident of the navaid or airport."),
QObject::tr("Two letter region code of a navaid."),
QObject::tr("Name of airport or radio navaid."),
QObject::tr("Name of airport or navaid."),
QObject::tr("Either SID, SID transition, STAR, STAR transition, transition, "
"approach or missed plus the name of the procedure."),
QObject::tr("Contains the airway name for en route legs or procedure instruction."),
QObject::tr("Either minimum altitude for en route airway segment, "
"procedure altitude restriction or procedure speed limit."),
QObject::tr("Minimum and maximum altitude for en route airway segments."
"Procedure altitude restriction, speed limit or vertical angle."),
QObject::tr("Type of a radio navaid. Shows ILS or LOC for\n"
"localizer approaches on the last runway leg."),
QObject::tr("Frequency or channel of a radio navaid.\n"
Expand Down Expand Up @@ -3978,12 +3978,13 @@ void RouteController::updateTableModel()
for(int i = 0; i < route.size(); i++)
{
const RouteLeg& leg = route.value(i);
const proc::MapProcedureLeg& procedureLeg = leg.getProcedureLeg();

// Ident ===========================================
QString identStr;
if(leg.isAnyProcedure())
// Get ident with IAF, FAF or other indication
identStr = proc::procedureLegFixStr(leg.getProcedureLeg());
identStr = proc::procedureLegFixStr(procedureLeg);
else
identStr = leg.getDisplayIdent();

Expand Down Expand Up @@ -4030,8 +4031,7 @@ void RouteController::updateTableModel()
#endif

awname.removeAll(QString());
itemRow[rcol::RESTRICTION] =
new QStandardItem(map::airwayAltTextShort(airway, false /* addUnit */, false /* narrow */));
itemRow[rcol::RESTRICTION] = new QStandardItem(map::airwayAltTextShort(airway, false /* addUnit */, false /* narrow */));
}

itemRow[rcol::AIRWAY_OR_LEGTYPE] = new QStandardItem(awname.join(tr(" / ")));
Expand All @@ -4041,21 +4041,13 @@ void RouteController::updateTableModel()
{
// Procedure ========================
itemRow[rcol::AIRWAY_OR_LEGTYPE] =
new QStandardItem(atools::strJoin({leg.getFlightplanEntry().getAirway(),
proc::procedureLegTypeStr(leg.getProcedureLegType())}, tr(",")));

QString restrictions;
if(leg.getProcedureLegAltRestr().isValid())
restrictions.append(proc::altRestrictionTextShort(leg.getProcedureLegAltRestr()));
if(leg.getProcedureLeg().speedRestriction.isValid())
restrictions.append(tr("/") + proc::speedRestrictionTextShort(leg.getProcedureLeg().speedRestriction));

itemRow[rcol::RESTRICTION] = new QStandardItem(restrictions);
new QStandardItem(atools::strJoin({leg.getFlightplanEntry().getAirway(), proc::procedureLegTypeStr(procedureLeg.type)}, tr(",")));
itemRow[rcol::RESTRICTION] = new QStandardItem(proc::restrictionText(procedureLeg));
}

// Get ILS for approach runway if it marks the end of an ILS or localizer approach procedure
QStringList ilsTypeTexts, ilsFreqTexts;
if(leg.getProcedureLeg().isApproach() && leg.getRunwayEnd().isValid())
if(procedureLeg.isApproach() && leg.getRunwayEnd().isValid())
{
// Build string for ILS type
for(const map::MapIls& ils : route.getDestRunwayIlsRecommended())
Expand Down Expand Up @@ -4108,7 +4100,7 @@ void RouteController::updateTableModel()
cumulatedDistance += leg.getDistanceTo();
itemRow[rcol::DIST] = new QStandardItem(Unit::distNm(leg.getDistanceTo(), false));

if(!leg.getProcedureLeg().isMissed() && !leg.isAlternate())
if(!procedureLeg.isMissed() && !leg.isAlternate())
{
float remaining = totalDistance - cumulatedDistance;
if(remaining < 0.f)
Expand All @@ -4123,7 +4115,7 @@ void RouteController::updateTableModel()

QString remarks;
if(leg.isAnyProcedure())
remarks = proc::procedureLegRemark(leg.getProcedureLeg());
remarks = proc::procedureLegRemark(procedureLeg);
else
remarks = leg.getFlightplanEntry().getComment();

Expand Down
37 changes: 20 additions & 17 deletions src/search/proceduresearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ void ProcedureSearch::updateFilterBoxes()
runways.insert(atools::fs::util::runwayBestFit(recApp.valueStr("runway_name"), runwayNames));

// Sort list of runways
QList<QString> runwaylist = runways.toList();
QList<QString> runwaylist = runways.values();
std::sort(runwaylist.begin(), runwaylist.end());

for(const QString& rw : runwaylist)
Expand Down Expand Up @@ -491,7 +491,7 @@ void ProcedureSearch::fillApproachTreeWidget()
// Resolve parallel runway assignments
QString allRunwayText = tr("All");
QStringList sidStarArincNames, sidStarRunways;
if((type& proc::PROCEDURE_SID) || (type & proc::PROCEDURE_STAR))
if((type & proc::PROCEDURE_SID) || (type & proc::PROCEDURE_STAR))
{
// arinc_name - added with database minor version 8
QString arincName = recApp.valueStr("arinc_name", QString());
Expand Down Expand Up @@ -553,7 +553,7 @@ void ProcedureSearch::fillApproachTreeWidget()
recApp.setValue("sid_star_runways", sidStarRunways);

recApp.appendField("sid_star_arinc_name", QVariant::String);
if(((type& proc::PROCEDURE_SID) || (type & proc::PROCEDURE_STAR)) && rwname.isEmpty())
if(((type & proc::PROCEDURE_SID) || (type & proc::PROCEDURE_STAR)) && rwname.isEmpty())
recApp.setValue("sid_star_arinc_name", sidStarArincNames.join("/"));

sorted.append(recApp);
Expand Down Expand Up @@ -667,11 +667,22 @@ void ProcedureSearch::updateTreeHeader()
QTreeWidgetItem *header = new QTreeWidgetItem();

header->setText(COL_DESCRIPTION, tr("Description"));
header->setToolTip(COL_DESCRIPTION, tr("Procedure instruction."));

header->setText(COL_IDENT, tr("Ident"));
header->setText(COL_RESTR, tr("Restriction\n%1/%2").arg(Unit::getUnitAltStr()).arg(Unit::getUnitSpeedStr()));
header->setToolTip(COL_IDENT, tr("ICAO ident of the navaid,"));

header->setText(COL_RESTR, tr("Restriction\n%1/%2/angle").arg(Unit::getUnitAltStr()).arg(Unit::getUnitSpeedStr()));
header->setToolTip(COL_RESTR, tr("Altitude restriction, speed limit or vertical angle."));

header->setText(COL_COURSE, tr("Course\n°M"));
header->setToolTip(COL_COURSE, tr("Magnetic course to fly."));

header->setText(COL_DISTANCE, tr("Dist./Time\n%1/min").arg(Unit::getUnitDistStr()));
header->setToolTip(COL_DISTANCE, tr("Distance to fly in %1 or flying time in minutes.").arg(Unit::getUnitDistStr()));

header->setText(COL_REMARKS, tr("Remarks"));
header->setToolTip(COL_REMARKS, tr("Turn instructions, flyover or related navaid for procedure legs."));

for(int col = COL_DESCRIPTION; col <= COL_REMARKS; col++)
header->setTextAlignment(col, Qt::AlignCenter);
Expand Down Expand Up @@ -1004,10 +1015,10 @@ void ProcedureSearch::contextMenu(const QPoint& pos)
const QTreeWidgetItem *root = treeWidget->invisibleRootItem();
for(int i = 0; i < root->childCount(); ++i)
{
QTreeWidgetItem *item = root->child(i);
item->setExpanded(true);
for(int j = 0; j < item->childCount(); ++j)
item->child(j)->setExpanded(true);
QTreeWidgetItem *itm = root->child(i);
itm->setExpanded(true);
for(int j = 0; j < itm->childCount(); ++j)
itm->child(j)->setExpanded(true);
}

if(errors)
Expand Down Expand Up @@ -1357,21 +1368,13 @@ QTreeWidgetItem *ProcedureSearch::buildLegItem(const MapProcedureLeg& leg)
texts << proc::procedureLegTypeStr(leg.type);
texts << proc::procedureLegFixStr(leg);

QString restrictions;
if(leg.altRestriction.isValid())
restrictions.append(proc::altRestrictionTextShort(leg.altRestriction));
if(leg.speedRestriction.isValid())
restrictions.append("/" + proc::speedRestrictionTextShort(leg.speedRestriction));
texts << proc::restrictionText(leg) << proc::procedureLegCourse(leg) << proc::procedureLegDistance(leg);

QString remarkStr = proc::procedureLegRemark(leg);

#ifdef DEBUG_INFORMATION
remarkStr += QString(" | leg_id = %1 approach_id = %2 transition_id = %3 nav_id = %4").
arg(leg.legId).arg(leg.approachId).arg(leg.transitionId).arg(leg.navId);
#endif

texts << restrictions << proc::procedureLegCourse(leg) << proc::procedureLegDistance(leg);

texts << remarkStr;

QTreeWidgetItem *item = new QTreeWidgetItem(texts, itemIndex.size() - 1);
Expand Down

0 comments on commit 5a9989f

Please sign in to comment.