-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCSiTRadar.h
526 lines (432 loc) · 13.8 KB
/
CSiTRadar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
#pragma once
#include "EuroScopePlugIn.h"
#include "SituPlugin.h"
#include <chrono>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <array>
#include <regex>
#include <math.h>
#include <gdiplus.h>
#include <deque>
#include "constants.h"
#include "wxRadar.h"
#include "CAsyncResponse.h"
#include <future>
#include <shared_mutex>
#include "CPopUpMenu.h"
#include "CAppWindows.h"
#include "HaloTool.h"
#include "constants.h"
#include "TopMenu.h"
#include "ACTag.h"
#include "PPS.h"
#include "CACList.h"
using namespace EuroScopePlugIn;
using namespace std;
struct SSquawkCodeManagement {
string squawk;
string fpcs;
int numCorrelatedRT{ 0 };
};
struct ACData {
bool hasVFRFP;
bool isADSB;
bool isRVSM;
bool isMedevac{ FALSE };
int tagType{ 0 };
bool isHandoff{ FALSE };
bool isHandoffToMe{ FALSE };
bool isJurisdictional{ FALSE };
bool isOnScreen{ FALSE };
bool isDestAprt{ FALSE };
bool isQuickLooked{ false };
int tagWidth{ 65 };
string CID;
bool extAlt{ FALSE };
int destLabelType{ 0 };
deque<CPosition> prevPosition;
bool pointOutToMe{ false };
bool pointOutFromMe{ false };
string POTarget{};
clock_t POAcceptTime{ clock() };
bool pointOutPendingApproval{ false };
bool directToLineOn{ false };
CPosition directToPendingPosition{};
string directToPendingFixName;
string POString{};
ACRoute acFPRoute;
bool multipleDiscrete{ false };
bool manualCorr{ false };
int follower{ 1 }; // 0 is light, 1 is med, 2 heavy, 3 super
};
struct SFocusItem {
bool m_focus_on;
STextField* m_focused_tf;
};
struct SFreeText {
int m_id{0};
CPosition m_pos;
string m_freetext_string;
};
struct buttonStates {
bool haloTool;
bool ptlTool;
bool showExtrapFP{ FALSE };
bool filterBypassAll{ FALSE };
int ptlLength{ 3 };
bool ptlAll{ FALSE };
bool ebPTL{ false };
bool wbPTL{ false };
int haloRad;
bool quickLook{ FALSE };
bool quickLookDelta{ false };
bool extAltToggle{ FALSE };
int numJurisdictionAC{ 0 };
bool setup{ false };
bool destAirport{ false };
bool crda{ false };
bool haloCursor{ false };
bool bigACID{ true };
int numHistoryDots{ 4 };
bool wxAll{ FALSE };
bool wxHigh{ FALSE };
bool wxOn{ FALSE };
bool mvaDisp{ false };
int numFreeText{ 0 };
set<string> activeArpt;
map<string, bool> nearbyCJS;
vector<SFreeText> freetext;
bool SFIMode{};
SFocusItem focusedItem;
bool handoffMode{};
deque<string> jurisdictionalAC{}; // AC under jurisdiction + active handoffs to jurisdiction
clock_t handoffModeStartTime{};
size_t jurisdictionIndex{ 0 };
bool destArptOn[5];
string destICAO[5];
bool destEST;
bool destVFR;
bool destDME;
int tbsHdg;
bool tbsMixed{ false };
vector<CSectorElement> activeRunways;
vector<CSectorElement> activeRunwaysList;
vector<inactiveRunway> inactiveRwyList;
map<string, string> arptAltimeterOld;
map<string, string> arptAtisLetterOld;
clock_t lastWxRefresh = 0;
clock_t lastMetarRefresh = 0;
clock_t lastAtisRefresh = 0;
bool bgM3Click{ false };
bool mouseMMB{ false };
bool MB3menu{ false };
POINT MB3clickedPt{ 0,0 };
RECT MB3hoverRect{};
RECT MB3primRect{};
bool MB3SecondaryMenuOn{ true };
bool MB3hoverOn{ false };
int MB3menuType{ 0 }; // 0 for AC, 1 for freetext, more if needed
int freetextselectedID{};
string MB3SecondaryMenuType{};
string SFIPrefString{};
string SFIPrefStringASRSetting{};
string SFIPrefStringDefault{ "ABCDEFGHIJ" };
vector<string> ctrlRemarkDefaults{};
void ResetSFIOptions() {
if (SFIPrefStringASRSetting.size() == 0) {
// default if not set via settings file
SFIPrefString = SFIPrefStringDefault;
}
else {
SFIPrefString = SFIPrefStringASRSetting;
}
};
void ExpandSFIOptions() { SFIPrefString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; };
map<int, CAppWindows> radarScrWindows;
map<int, CACList> radarScrLists;
vector<SSquawkCodeManagement> squawkCodes;
// mAcData garbage cleaning
vector<string> recentCallsignsSeen;
bool acListMaint;
clock_t lastAcListMaint{};
};
class CAircraftList {
public:
POINT m_p{ 0,0 };
bool m_collapsed = false;
int m_listType{};
int listType{};
CRadarScreen* radscr;
unordered_map<string, ACData>* acData{};
unordered_map<int, ACList> acLists;
CDC* dc;
CAircraftList()
: m_p({ 0,0 })
{}
void Draw()
{
int sDC = dc->SaveDC();
dc->SetTextColor(C_WHITE);
dc->SelectObject(CFontHelper::Euroscope14);
string header;
// Draw the heading
RECT listHeading{};
listHeading.left = m_p.x;
listHeading.top = m_p.y;
// Draw the arrow
HPEN targetPen = CreatePen(PS_SOLID, 1, C_WHITE);;
HBRUSH targetBrush = CreateSolidBrush(C_WHITE);
dc->SelectObject(targetPen);
dc->SelectObject(targetBrush);
bool collapsed{ false };
bool showArrow = false;
dc->RestoreDC(sDC);
DeleteObject(targetPen);
DeleteObject(targetBrush);
}
void Move(int x, int y)
{
m_p.x = x;
m_p.y = y;
}
void Collapse()
{
m_collapsed = true;
}
void Expand()
{
m_collapsed = false;
}
int GetListType()
{
return m_listType;
}
};
class CSiTRadar :
public EuroScopePlugIn::CRadarScreen
{
public:
CSiTRadar(void);
virtual ~CSiTRadar(void);
// Pointer back at screen
static CRadarScreen* m_pRadScr;
static unordered_map<string, ACData> mAcData;
static unordered_map<string, int> tempTagData;
static unordered_map<string, clock_t> hoAcceptedTime;
static map<string, bool> destAirportList;
static unordered_map<string, bool> acADSB;
static unordered_map<string, bool> acRVSM;
static buttonStates menuState;
double wxRadLat;
double wxRadLong;
int wxRadZL;
virtual void OnAsrContentLoaded(bool Loaded);
void OnAsrContentToBeSaved();
inline virtual void OnFlightPlanFlightPlanDataUpdate(CFlightPlan FlightPlan);
inline virtual void OnFlightPlanDisconnect(CFlightPlan FlightPlan);
static void updateActiveRunways(int i);
static void DisplayActiveRunways();
inline virtual void OnControllerPositionUpdate(CController Controller);
inline virtual void OnControllerDisconnect(CController Controller);
static CAppWindows* GetAppWindow(int winID);
static void RegisterButton(RECT rect) {
};
void OnRefresh(HDC hdc, int phase);
void CSiTRadar::OnButtonDownScreenObject(int ObjectType,
const char* sObjectId,
POINT Pt,
RECT Area,
int Button);
inline virtual void OnClickScreenObject(int ObjectType,
const char* sObjectId,
POINT Pt,
RECT Area,
int Button);
void CSiTRadar::OnMoveScreenObject(int ObjectType,
const char* sObjectId,
POINT Pt,
RECT Area,
bool Released);
inline virtual void OnOverScreenObject(int ObjectType,
const char* sObjectId,
POINT Pt,
RECT Area);
inline virtual void OnFlightPlanControllerAssignedDataUpdate(CFlightPlan FlightPlan,
int DataType);
void OnFunctionCall(int FunctionId, const char* sItemString, POINT Pt, RECT Area);
double RadRange(void)
{
RECT radarea = GetRadarArea();
POINT pl = CPoint((int)radarea.left, (int)radarea.top);
POINT pr = CPoint((int)radarea.right, (int)radarea.top);
CPosition posL = ConvertCoordFromPixelToPosition(pl);
CPosition posR = ConvertCoordFromPixelToPosition(pr);
double raddist = posL.DistanceTo(posR);
return raddist;
}
double PixelsPerNM(void)
{
RECT radarea = GetRadarArea();
POINT pl = CPoint((int)radarea.left, (int)radarea.top);
POINT pr = CPoint((int)radarea.right, (int)radarea.top);
CPosition posL = ConvertCoordFromPixelToPosition(pl);
CPosition posR = ConvertCoordFromPixelToPosition(pr);
double raddist = posL.DistanceTo(posR);
double rr = radarea.right;
double rl = radarea.left;
double radwidth = rr - rl;
double pixpernm = radwidth / raddist;
return pixpernm;
};
inline virtual void OnAsrContentToBeClosed(void) {
// saving settings to the ASR file
/*
const char* sv = radtype.c_str();
SaveDataToAsr("tagfamily", "Tag Family", sv);
*/
delete this;
};
static bool halfSecTick; // toggles on and off every half second
inline virtual void OnDoubleClickScreenObject(int ObjectType,
const char* sObjectId,
POINT Pt,
RECT Area,
int Button);
static bool ModifySFI(string c, CFlightPlan fp) {
string scratchpad;
string newstring;
scratchpad = fp.GetControllerAssignedData().GetScratchPadString();
if (!strcmp(c.c_str(), "EXP")) {
CSiTRadar::menuState.ExpandSFIOptions();
return false;
}
else if (!strcmp(c.c_str(), "CLR")) {
if (scratchpad.size() == 1) {
newstring = "";
}
else if (scratchpad.size() == 2 && scratchpad.at(0) == ' ') {
newstring = "";
}
else if (scratchpad.size() > 2) {
if (scratchpad.at(0) == ' ' && scratchpad.at(2) == ' ') {
newstring = scratchpad.substr(3);
}
else {
newstring = scratchpad;
}
}
}
else {
if (!scratchpad.empty()) {
if (scratchpad.size() == 1) {
newstring = " " + c + " " + scratchpad;
}
else if (scratchpad.size() == 2 && scratchpad.at(0) == ' ') {
newstring = scratchpad.replace(1, 1, c);
}
else if (scratchpad.size() > 2) {
if (scratchpad.at(0) == ' ' && scratchpad.at(2) == ' ') {
newstring = scratchpad.replace(1, 1, c);
}
else {
newstring = " " + c + " " + scratchpad;
}
}
}
else {
newstring = " " + c;
}
}
fp.GetControllerAssignedData().SetScratchPadString(newstring.c_str());
fp.GetFlightPlanData().AmendFlightPlan();
return true;
}
void ClearFocusedTextFields() {
for (auto& win : menuState.radarScrWindows) {
for (auto& tf : win.second.m_textfields_) {
tf.m_focused = false;
}
}
CSiTRadar::menuState.focusedItem.m_focus_on = false;
}
static void CloseWindow(int winID) {
if (menuState.radarScrWindows.count(winID) != 0) {
menuState.radarScrWindows.erase(winID);
}
}
static void SendPointOut(const char* target, const char* message, CFlightPlan* fp) {
fp->GetControllerAssignedData().SetFlightStripAnnotation(0, message);
fp->PushFlightStrip(CSiTRadar::m_pRadScr->GetPlugIn()->ControllerSelectByPositionId(target).GetCallsign());
}
static bool ModifyCtrlRemarks(string c, CFlightPlan fp) {
string scratchpad;
string newstring;
scratchpad = fp.GetControllerAssignedData().GetScratchPadString();
if (!scratchpad.empty()) {
if (scratchpad.size() == 1) {
newstring = c;
}
else if (scratchpad.size() == 2 && scratchpad.at(0) == ' ') {
newstring = scratchpad + " " + c;
}
else if (scratchpad.size() > 2) {
if (scratchpad.at(0) == ' ' && scratchpad.at(2) == ' ') {
newstring = scratchpad.substr(0, 3) + c;
}
else {
newstring = c;
}
}
}
else {
newstring = c;
}
fp.GetControllerAssignedData().SetScratchPadString(newstring.c_str());
fp.GetFlightPlanData().AmendFlightPlan();
return true;
}
inline virtual void OnFlightPlanFlightStripPushed(CFlightPlan FlightPlan,
const char* sSenderController,
const char* sTargetController);
protected:
void ButtonToScreen(CSiTRadar* radscr, const RECT& rect, const string& btext, int itemtype);
void DrawACList(POINT p, CDC* dc, unordered_map<string, ACData>& ac, int listType);
// helper functions
clock_t time = clock();
clock_t oldTime = clock();
// menu states
bool halotool = FALSE;
bool mousehalo = FALSE;
int menuLayer = 0;
bool altFilterOpts = FALSE;
bool altFilterOn = TRUE;
bool autoRefresh = FALSE;
bool pressed = FALSE;
int haloidx = 1; // default halo radius = 3, corresponds to index of the halooptions
clock_t halfSec = 0;
map<string, bool> hashalo;
map<string, bool> hasPTL;
map<string, bool> isBlinking;
map<string, bool> isHandOffHold;
map<string, string> ppsCJS;
// ADSB Radar Site
CPosition adsbSite;
// Tag Properties
unordered_map<string, POINT> rtagOffset;
unordered_map<string, POINT> fptagOffset;// the centre of the aircraft tag
unordered_map<string, POINT> connectorOrigin; // the Tag end of the connector, this flips from right side to left side
// menu functions
RECT rLLim = { 0, 0, 10, 10 };
RECT rHLim = { 0, 0, 10, 10 };
// menu settings
int altFilterLow = 0;
int altFilterHigh = 0;
double halorad = 3;
int haloOptions[6] = { 3,5,10,15,20,25 };
int ptlOptions[20] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,25,30,35,40 };
string controllerID;
string radtype;
};