Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

CJ4 Reactivate Map Alt Constraints #1066

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CJ4_FMC_DsplMenuPage {
const intersectionsActive = fmc._templateRenderer.renderSwitch(["INTERS"], (CJ4_MapSymbols.hasSymbol(CJ4_MapSymbol.INTERSECTS) - 1));
const airportsActive = fmc._templateRenderer.renderSwitch(["APTS"], (CJ4_MapSymbols.hasSymbol(CJ4_MapSymbol.AIRPORTS) - 1));
const altitudeActive = fmc._templateRenderer.renderSwitch(["ALTITUDE"], (CJ4_MapSymbols.hasSymbol(CJ4_MapSymbol.CONSTRAINTS) - 1));
//console.log("altitudeActive " + CJ4_MapSymbols.hasSymbol(CJ4_MapSymbol.CONSTRAINTS));
const termWptsActive = fmc._templateRenderer.renderSwitch(["TERM WPTS"], (CJ4_MapSymbols.hasSymbol(CJ4_MapSymbol.TERMWPTS) - 1));
const vnavWindowSwitch = fmc._templateRenderer.renderSwitch(["OFF", "ON", "VNAV"], WTDataStore.get("WT_CJ4_MFD_DATA_WINDOW", 1));
const missedActive = fmc._templateRenderer.renderSwitch(["MISSEDAPPR"], (CJ4_MapSymbols.hasSymbol(CJ4_MapSymbol.MISSEDAPPR) - 1));
Expand All @@ -30,11 +31,11 @@ class CJ4_FMC_DsplMenuPage {
};

// TODO: disabled because of errors with mapinstrument
// fmc.onRightInput[2] = () => {
// this.toggleSymbol(CJ4_MapSymbol.CONSTRAINTS).then(() => {
// CJ4_FMC_DsplMenuPage.ShowPage1(fmc);
// });
// };
fmc.onRightInput[2] = () => {
CJ4_MapSymbols.toggleSymbol(CJ4_MapSymbol.CONSTRAINTS).then(() => {
CJ4_FMC_DsplMenuPage.ShowPage1(fmc);
});
};

fmc.onRightInput[3] = () => {
CJ4_MapSymbols.toggleSymbol(CJ4_MapSymbol.AIRPORTS).then(() => {
Expand Down Expand Up @@ -65,7 +66,7 @@ class CJ4_FMC_DsplMenuPage {
[""],
["HI NAVAIDS[s-text disabled]", "SPEED[s-text disabled]"],
[""],
[loNavaidsActive, altitudeActive + "[disabled s-text]"],
[loNavaidsActive, altitudeActive],
[""],
[intersectionsActive, airportsActive],
[""],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4905,7 +4905,7 @@ class CJ4_PopupMenu_LOWER extends CJ4_PopupMenu_Handler {
this.endSection();
this.beginSection();
{
//this.addCheckbox("CONSTRAINTS", this.textSize, [CJ4_PopupMenu_Key.MAP_SYMBOL_CONSTRAINTS]);
this.addCheckbox("CONSTRAINTS", this.textSize, [CJ4_PopupMenu_Key.MAP_SYMBOL_CONSTRAINTS]);
this.addCheckbox("GEO-POL", this.textSize, null);
this.addCheckbox("AIRSPACE", this.textSize, [CJ4_PopupMenu_Key.MAP_SYMBOL_AIRSPACES]);
this.addCheckbox("AIRWAYS", this.textSize, [CJ4_PopupMenu_Key.MAP_SYMBOL_AIRWAYS]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ class MapInstrument extends ISvgMapRootElement {
this.flightPlanManager.updateFlightPlan();

if (!this.showConstraints && this.constraints && this.constraints.length > 0) {
console.log("this.showConstraints " + this.showConstraints);
this.constraints = [];
}
if (this.drawCounter === 45 || (this.showConstraints && (!this.constraints || this.constraints.length === 0))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class SvgConstraintElement extends SvgMapElement {
let text = "CSTR";
let speedText = "";
if (this.source) {
text = (this.source.legAltitude1 / 10).toFixed(0) + "0";
text = this.parseConstraints(this.source);
console.log(this.source.ident + " " + text);

//text = (this.source.legAltitude1 / 10).toFixed(0) + "0";
}
if (this.source.speedConstraint > 10) {
speedText = this.source.speedConstraint.toFixed(0) + "KT";
Expand Down Expand Up @@ -75,7 +78,7 @@ class SvgConstraintElement extends SvgMapElement {
context.fillStyle = "black";
context.fillRect(0, 0, this._textWidth + map.config.waypointLabelBackgroundPaddingLeft + map.config.waypointLabelBackgroundPaddingRight, this._textHeight + map.config.waypointLabelBackgroundPaddingTop + map.config.waypointLabelBackgroundPaddingBottom);
}
context.fillStyle = "magenta";
context.fillStyle = "#11d011";
context.font = fontSize + "px " + map.config.waypointLabelFontFamily;
context.fillText(text, map.config.waypointLabelBackgroundPaddingLeft, this._textHeight + map.config.waypointLabelBackgroundPaddingTop);
if (this.source.speedConstraint > 0) {
Expand Down Expand Up @@ -144,7 +147,32 @@ class SvgConstraintElement extends SvgMapElement {
}
}
}
}
parseConstraints(waypoint) {
let constraintText = "";
const formatConstraints = (value) => {
if (value >= 18000) {
return "FL" + (value / 100).toFixed(0);
} else {
return value.toFixed(0);
}
};
console.log(waypoint.ident + " " + waypoint.legAltitudeDescription);
switch (waypoint.legAltitudeDescription) {
case 1:
constraintText = "/" + formatConstraints(Math.floor(waypoint.legAltitude1)) + "";
break;
case 2:
constraintText = "/" + formatConstraints(Math.floor(waypoint.legAltitude1)) + "A";
break;
case 3:
constraintText = "/" + formatConstraints(Math.floor(waypoint.legAltitude1)) + "B";
break;
case 4:
constraintText = "/" + formatConstraints(Math.floor(waypoint.legAltitude2)) + "A" + formatConstraints(Math.floor(waypoint.legAltitude1)) + "B";
break;
}
return constraintText;
}}
SvgConstraintElement._ID = 0;
class SvgTopOfXElement extends SvgMapElement {
constructor(name, imageName) {
Expand Down
11 changes: 10 additions & 1 deletion src/wtsdk/src/flightplanning/FlightPlanManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,16 @@ export class FlightPlanManager {
* Gets the waypoints for the current flight plan with altitude constraints.
*/
public getWaypointsWithAltitudeConstraints(): WayPoint[] {
return this._flightPlans[this._currentFlightPlanIndex].waypoints;
const waypointsWithConstraints = [];
const activeWaypointIndex = this.getActiveWaypointIndex();

for (let i = activeWaypointIndex - 1; i < this._flightPlans[this._currentFlightPlanIndex].waypoints.length; i++) {
if (this._flightPlans[this._currentFlightPlanIndex].waypoints[i].legAltitudeDescription > 0) {
waypointsWithConstraints.push(this._flightPlans[this._currentFlightPlanIndex].waypoints[i]);
}

}
return waypointsWithConstraints;
}

/**
Expand Down