Debian Codegraph @

src/GUI/MapWidget.hxx

raw symbols SCIP
1 /*
2 * SPDX-FileCopyrightText: (C) 2010 James Turner <[email protected]>
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
6 #pragma once
7
8 #include <map>
9 #include <simgear/compiler.h>
10 #include <simgear/math/SGMath.hxx>
11 #include <simgear/props/props.hxx>
12
13 #include <Navaids/positioned.hxx>
14
15 #include "FGPUIDialog.hxx"
16
17 // forward decls
18 class FGRouteMgr;
19 class FGRunway;
20 class FGHelipad;
21 class FGAirport;
22 class FGNavRecord;
23 class FGFix;
24 class MapData;
25 class SGMagVar;
26
27 typedef std::vector<SGGeod> SGGeodVec;
28
29 class MapWidget : public puObject, public FGPUIDialog::ActiveWidget
30 {
31 public:
32 MapWidget(int x, int y, int width, int height);
33 virtual ~MapWidget();
34
35 // puObject over-rides
36 virtual void setSize(int width, int height);
37 virtual void doHit( int button, int updown, int x, int y ) ;
38 virtual void draw( int dx, int dy ) ;
39
40 // disable key handling for now
41 //virtual int checkKey(int key, int updown);
42
43 void setProperty(SGPropertyNode_ptr prop);
44
45 // PUIDialog::ActiveWidget over-rides
46 virtual void update();
47
48 private:
49 enum Projection {
50 PROJECTION_SAMSON_FLAMSTEED,
51 PROJECTION_AZIMUTHAL_EQUIDISTANT,
52 PROJECTION_ORTHO_AZIMUTH,
53 PROJECTION_SPHERICAL
54 };
55
56 int zoom() const;
57
58 void handlePan(int x, int y);
59
60 void pan(const SGVec2d& delta);
61 void zoomIn();
62 void zoomOut();
63
64 void paintAircraftLocation(const SGGeod& aircraftPos);
65 void paintRoute();
66 void paintRuler();
67 void drawFlightHistory();
68 void updateFlightHistory();
69
70 void drawGPSData();
71 void drawNavRadio(SGPropertyNode_ptr radio);
72 void drawTunedLocalizer(SGPropertyNode_ptr radio);
73
74 void drawLatLonGrid();
75 SGVec2d gridPoint(int ix, int iy);
76 bool drawLineClipped(const SGVec2d& a, const SGVec2d& b);
77
78 void drawAirport(FGAirport* apt);
79 void drawHeliport(FGAirport* apt);
80 int scoreAirportRunways(FGAirport* apt);
81 void drawRunwayPre(FGRunway* rwy);
82 void drawRunway(FGRunway* rwy);
83 void drawHelipad(FGHelipad* hp);
84 void drawILS(bool tuned, FGRunway* rwy);
85
86 void drawPositioned();
87 void drawNDB(bool tuned, FGNavRecord* nav);
88 void drawVOR(bool tuned, FGNavRecord* nav);
89 void drawFix(FGFix* fix);
90
91 void drawPOI(FGPositioned* rec);
92
93 void drawTraffic();
94
95 class DrawAIObject
96 {
97 public:
98 DrawAIObject(SGPropertyNode* model, const SGGeod& g);
99
100 SGPropertyNode* model;
101 bool boat;
102 SGGeod pos;
103 double heading;
104 int speedKts;
105 std::string label;
106 std::string legend;
107 };
108
109 typedef std::vector<DrawAIObject> AIDrawVec;
110 AIDrawVec _aiDrawVec;
111
112 void updateAIObjects();
113 void drawAI(const DrawAIObject& dai);
114
115 void drawData();
116 bool validDataForKey(void* key);
117 MapData* getOrCreateDataForKey(void* key);
118 MapData* createDataForKey(void* key);
119 void setAnchorForKey(void* key, const SGVec2d& anchor);
120 void clearData();
121
122 SGVec2d project(const SGGeod& geod) const;
123 SGGeod unproject(const SGVec2d& p) const;
124 double currentScale() const;
125
126 int displayHeading(double trueHeading) const;
127
128 void circleAt(const SGVec2d& center, int nSides, double r);
129 void circleAtAlt(const SGVec2d& center, int nSides, double r, double r2);
130 void squareAt(const SGVec2d& center, double r);
131 void drawLine(const SGVec2d& p1, const SGVec2d& p2);
132 void drawLegendBox(const SGVec2d& pos, const std::string& t);
133
134 int _width, _height;
135 int _cachedZoom;
136 double _drawRangeNm;
137 double _upHeading; // true heading corresponding to +ve y-axis
138 bool _magneticHeadings;
139 bool _hasPanned;
140 bool _aircraftUp;
141 int _displayHeading;
142 bool _drawAircraft;
143
144 SGGeod _projectionCenter;
145 Projection _projection;
146 SGGeod _aircraft;
147 SGGeod _clickGeod;
148 SGVec2d _hitLocation;
149 FGRouteMgr* _route;
150 SGPropertyNode_ptr _root;
151 SGPropertyNode_ptr _gps;
152 SGGeodVec _flightHistoryPath;
153
154 FGPositionedList _itemsToDraw;
155
156 typedef std::map<void*, MapData*> KeyDataMap;
157 KeyDataMap _mapData;
158 std::vector<MapData*> _dataQueue;
159
160 SGMagVar* _magVar;
161
162 typedef std::map<int, SGVec2d> GridPointCache;
163 GridPointCache _gridCache;
164 double _gridSpacing;
165 SGGeod _gridCenter;
166 };