Skip to content

Commit bb02f4b

Browse files
committed
Added predicted track line option to SRW
1 parent 9767935 commit bb02f4b

File tree

4 files changed

+78
-11
lines changed

4 files changed

+78
-11
lines changed

vSMR/Constant.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,17 @@ const int SRW_UPDATE_FILTER = 6030;
326326
const int SRW_UPDATE_RANGE = 6040;
327327
const int SRW_UPDATE_CENTERLINE = 6050;
328328
const int SRW_UPDATE_TICKSPACING = 6060;
329+
const int SRW_UPDATE_PREDICTEDLENGTH = 6070;
330+
const int SRW_UPDATE_PREDICTEDWIDTH = 6080;
329331

330332
const int TAG_FUNC_SRW_ZOOM_EDITOR = 6110;
331333
const int TAG_FUNC_SRW_ROTATE_EDITOR = 6120;
332334
const int TAG_FUNC_SRW_FILTER_EDITOR = 6130;
333335
const int TAG_FUNC_SRW_RANGE_EDITOR = 6140;
334336
const int TAG_FUNC_SRW_CENTERLINE_EDITOR = 6150;
335337
const int TAG_FUNC_SRW_TICKSPACING_EDITOR = 6160;
338+
const int TAG_FUNC_SRW_PREDICTEDLENGTH_EDITOR = 6170;
339+
const int TAG_FUNC_SRW_PREDICTEDWIDTH_EDITOR = 6180;
336340

337341

338342
// Brightness update

vSMR/InsetWindow.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,10 @@ void CInsetWindow::render(HDC hDC, CSMRRadar * radar_screen, Graphics* gdi, POIN
752752
CRect CenterlineRect = DrawToolbarButton(&dc, "C", TopBar, 55, mouseLocation);
753753
radar_screen->AddScreenObject(m_Id, "centerline", CenterlineRect, false, "");
754754

755+
// Predicted track line button
756+
CRect PredictedTrackLineRect = DrawToolbarButton(&dc, "P", TopBar, 68, mouseLocation);
757+
radar_screen->AddScreenObject(m_Id, "predictedtrackline", PredictedTrackLineRect, false, "");
758+
755759
dc.SetTextColor(oldTextColorC);
756760

757761
// Close

vSMR/InsetWindow.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ class CInsetWindow
2020
POINT m_Offset = { 0, 0 }, m_OffsetInit = { 0, 0 }, m_OffsetDrag = { 0, 0 };
2121
bool m_Grip = false;
2222
float m_Zoom = 20, m_Rotation = 0;
23-
int m_ExtendedLinesLength = 15;
24-
int m_ExtendedLinesTickSpacing = 1;
23+
int m_ExtendedLinesLength = 15, m_ExtendedLinesTickSpacing = 1;
24+
float m_PredictedTrackLineLength = 0.0f;
25+
int m_PredictedTrackLineWidth = 1;
2526

2627
map<string, double> m_TagAngles;
2728

vSMR/SMRRadar.cpp

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ void CSMRRadar::OnAsrContentLoaded(bool Loaded)
358358
if ((p_value = GetDataFromAsr(prefix + "ExtendedLinesTickSpacing")) != NULL)
359359
appWindows[i]->m_ExtendedLinesTickSpacing = atoi(p_value);
360360

361+
if ((p_value = GetDataFromAsr(prefix + "PredictedTrackLineLength")) != NULL)
362+
appWindows[i]->m_PredictedTrackLineLength = strtof(p_value, NULL);
363+
364+
if ((p_value = GetDataFromAsr(prefix + "PredictedTrackLineWidth")) != NULL)
365+
appWindows[i]->m_PredictedTrackLineWidth = atoi(p_value);
366+
361367
if ((p_value = GetDataFromAsr(prefix + "Display")) != NULL)
362368
appWindowDisplays[i] = atoi(p_value) == 1 ? true : false;
363369
}
@@ -439,6 +445,12 @@ void CSMRRadar::OnAsrContentToBeSaved()
439445
temp.format("%d", appWindows[i]->m_ExtendedLinesTickSpacing);
440446
SaveDataToAsr(prefix + "ExtendedLinesTickSpacing", prefix + " extended line tick spacing", temp);
441447

448+
temp.format("%f", appWindows[i]->m_PredictedTrackLineLength);
449+
SaveDataToAsr(prefix + "PredictedTrackLineLength", prefix + " predicted track line length", temp);
450+
451+
temp.format("%d", appWindows[i]->m_PredictedTrackLineWidth);
452+
SaveDataToAsr(prefix + "PredictedTrackLineWidth", prefix + " predicted track line width", temp);
453+
442454
CBString to_save = "0";
443455
if (appWindowDisplays[i])
444456
to_save = "1";
@@ -623,7 +635,14 @@ void CSMRRadar::OnClickScreenObject(int ObjectType, const char * sObjectId, POIN
623635
CBString tickSpacing = *bformat("Tick spacing: %d", appWindows[appWindowId]->m_ExtendedLinesTickSpacing);
624636
GetPlugIn()->AddPopupListElement(length, "", SRW_UPDATE_CENTERLINE + appWindowId);
625637
GetPlugIn()->AddPopupListElement(tickSpacing, "", SRW_UPDATE_TICKSPACING + appWindowId);
638+
}
639+
else if (strcmp(sObjectId, "predictedtrackline") == 0) {
640+
GetPlugIn()->OpenPopupList(Area, "SRW Predicted Track Line", 1);
626641

642+
CBString length = *bformat("Length: %.1f", appWindows[appWindowId]->m_PredictedTrackLineLength);
643+
CBString width = *bformat("Width: %d", appWindows[appWindowId]->m_PredictedTrackLineWidth);
644+
GetPlugIn()->AddPopupListElement(length, "", SRW_UPDATE_PREDICTEDLENGTH + appWindowId);
645+
GetPlugIn()->AddPopupListElement(width, "", SRW_UPDATE_PREDICTEDWIDTH + appWindowId);
627646
}
628647
}
629648

@@ -1186,13 +1205,22 @@ void CSMRRadar::OnFunctionCall(int FunctionId, const char * sItemString, POINT P
11861205
onFunctionCallDoubleCallHack = true;
11871206
break;
11881207
}
1189-
11901208
else if (FunctionId == SRW_UPDATE_TICKSPACING + id) {
11911209
GetPlugIn()->OpenPopupEdit(Area, TAG_FUNC_SRW_TICKSPACING_EDITOR + id, bstr2cstr(bformat("%d", appWindows[id]->m_ExtendedLinesTickSpacing), ' '));
11921210
onFunctionCallDoubleCallHack = true;
11931211
break;
11941212
}
1195-
1213+
else if (FunctionId == SRW_UPDATE_PREDICTEDLENGTH + id) {
1214+
GetPlugIn()->OpenPopupEdit(Area, TAG_FUNC_SRW_PREDICTEDLENGTH_EDITOR + id, bstr2cstr(bformat("%.1f", appWindows[id]->m_PredictedTrackLineLength), ' '));
1215+
onFunctionCallDoubleCallHack = true;
1216+
break;
1217+
}
1218+
else if (FunctionId == SRW_UPDATE_PREDICTEDWIDTH + id) {
1219+
GetPlugIn()->OpenPopupEdit(Area, TAG_FUNC_SRW_PREDICTEDWIDTH_EDITOR + id, bstr2cstr(bformat("%d", appWindows[id]->m_PredictedTrackLineWidth), ' '));
1220+
onFunctionCallDoubleCallHack = true;
1221+
break;
1222+
}
1223+
11961224
else if (FunctionId == TAG_FUNC_SRW_ZOOM_EDITOR + id) {
11971225
if (onFunctionCallDoubleCallHack) {
11981226
appWindows[id]->m_Zoom = strtof(sItemString, NULL);
@@ -1235,6 +1263,20 @@ void CSMRRadar::OnFunctionCall(int FunctionId, const char * sItemString, POINT P
12351263
}
12361264
break;
12371265
}
1266+
else if (FunctionId == TAG_FUNC_SRW_PREDICTEDLENGTH_EDITOR + id) {
1267+
if (onFunctionCallDoubleCallHack) {
1268+
appWindows[id]->m_PredictedTrackLineLength = strtof(sItemString, NULL);
1269+
onFunctionCallDoubleCallHack = false;
1270+
}
1271+
break;
1272+
}
1273+
else if (FunctionId == TAG_FUNC_SRW_PREDICTEDWIDTH_EDITOR + id) {
1274+
if (onFunctionCallDoubleCallHack) {
1275+
appWindows[id]->m_PredictedTrackLineWidth = atoi(sItemString);
1276+
onFunctionCallDoubleCallHack = false;
1277+
}
1278+
break;
1279+
}
12381280

12391281
}
12401282

@@ -2403,17 +2445,33 @@ void CSMRRadar::DrawTargets(Graphics* graphics, CDC* dc, CInsetWindow* insetWind
24032445
}
24042446

24052447
// Predicted Track Line
2406-
CPen predictTrackPen(PS_SOLID, predictedTrackWidth, ColorManager->get_corrected_color("symbol", Gdiplus::Color::White).ToCOLORREF());
2407-
dc->SelectObject(&predictTrackPen);
2408-
2409-
if (reportedGS > 50) {
2410-
double d = double(rt.GetPosition().GetReportedGS()*0.514444) * (predictedTrackLength * 60.0);
2448+
if (insetWindow == nullptr) {
2449+
CPen predictTrackPen(PS_SOLID, predictedTrackWidth, ColorManager->get_corrected_color("symbol", Gdiplus::Color::White).ToCOLORREF());
2450+
dc->SelectObject(&predictTrackPen);
2451+
2452+
if (reportedGS > 50) {
2453+
double d = double(rt.GetPosition().GetReportedGS()*0.514444) * (predictedTrackLength * 60.0);
2454+
CPosition PredictedEnd = BetterHarversine(rt.GetPosition().GetPosition(), rt.GetTrackHeading(), d);
2455+
2456+
dc->MoveTo(ConvertCoordFromPositionToPixel(rt.GetPosition().GetPosition()));
2457+
dc->LineTo(ConvertCoordFromPositionToPixel(PredictedEnd));
2458+
}
2459+
}
2460+
else {
2461+
CPen predictTrackPen(PS_SOLID, insetWindow->m_PredictedTrackLineWidth, ColorManager->get_corrected_color("symbol", Gdiplus::Color::White).ToCOLORREF());
2462+
dc->SelectObject(&predictTrackPen);
2463+
2464+
double d = double(rt.GetPosition().GetReportedGS()*0.514444) * (insetWindow->m_PredictedTrackLineLength * 60.0);
24112465
CPosition PredictedEnd = BetterHarversine(rt.GetPosition().GetPosition(), rt.GetTrackHeading(), d);
24122466

2413-
dc->MoveTo(ConvertCoordFromPositionToPixel(rt.GetPosition().GetPosition()));
2414-
dc->LineTo(ConvertCoordFromPositionToPixel(PredictedEnd));
2467+
POINT startPoint = insetWindow->projectPoint(rt.GetPosition().GetPosition(), AirportPositions[ActiveAirport]);
2468+
POINT endPoint = insetWindow->projectPoint(PredictedEnd, AirportPositions[ActiveAirport]);
2469+
2470+
dc->MoveTo(startPoint);
2471+
dc->LineTo(endPoint);
24152472
}
24162473

2474+
// Mouseover symbol
24172475
if (mouseWithin({ acPosPix.x - 5, acPosPix.y - 5, acPosPix.x + 5, acPosPix.y + 5 })) {
24182476
dc->MoveTo(acPosPix.x, acPosPix.y - 8);
24192477
dc->LineTo(acPosPix.x - 6, acPosPix.y - 12);

0 commit comments

Comments
 (0)