1 #ifndef GUI_MAPWIDGET_HXX
2 #define GUI_MAPWIDGET_HXX
5 #include <simgear/compiler.h>
6 #include <simgear/math/SGMath.hxx>
7 #include <simgear/props/props.hxx>
9 #include <Navaids/positioned.hxx>
12 #include "FGPUIDialog.hxx"
24 typedef std::vector<SGGeod> SGGeodVec;
26 class MapWidget : public puObject, public FGPUIDialog::ActiveWidget
29 MapWidget(int x, int y, int width, int height);
32 // puObject over-rides
33 virtual void setSize(int width, int height);
34 virtual void doHit( int button, int updown, int x, int y ) ;
35 virtual void draw( int dx, int dy ) ;
36 virtual int checkKey(int key, int updown);
38 void setProperty(SGPropertyNode_ptr prop);
40 // PUIDialog::ActiveWidget over-rides
41 virtual void update();
45 PROJECTION_SAMSON_FLAMSTEED,
46 PROJECTION_AZIMUTHAL_EQUIDISTANT,
47 PROJECTION_ORTHO_AZIMUTH,
53 void handlePan(int x, int y);
55 void pan(const SGVec2d& delta);
59 void paintAircraftLocation(const SGGeod& aircraftPos);
62 void drawFlightHistory();
65 void drawNavRadio(SGPropertyNode_ptr radio);
66 void drawTunedLocalizer(SGPropertyNode_ptr radio);
68 void drawLatLonGrid();
69 SGVec2d gridPoint(int ix, int iy);
70 bool drawLineClipped(const SGVec2d& a, const SGVec2d& b);
72 void drawAirport(FGAirport* apt);
73 int scoreAirportRunways(FGAirport* apt);
74 void drawRunwayPre(FGRunway* rwy);
75 void drawRunway(FGRunway* rwy);
76 void drawHelipad(FGHelipad* hp);
77 void drawILS(bool tuned, FGRunway* rwy);
79 void drawPositioned();
80 void drawNDB(bool tuned, FGNavRecord* nav);
81 void drawVOR(bool tuned, FGNavRecord* nav);
82 void drawFix(FGFix* fix);
84 void drawPOI(FGPositioned* rec);
91 DrawAIObject(SGPropertyNode* model, const SGGeod& g);
93 SGPropertyNode* model;
102 typedef std::vector<DrawAIObject> AIDrawVec;
103 AIDrawVec _aiDrawVec;
105 void updateAIObjects();
106 void drawAI(const DrawAIObject& dai);
109 bool validDataForKey(void* key);
110 MapData* getOrCreateDataForKey(void* key);
111 MapData* createDataForKey(void* key);
112 void setAnchorForKey(void* key, const SGVec2d& anchor);
115 SGVec2d project(const SGGeod& geod) const;
116 SGGeod unproject(const SGVec2d& p) const;
117 double currentScale() const;
119 int displayHeading(double trueHeading) const;
121 void circleAt(const SGVec2d& center, int nSides, double r);
122 void circleAtAlt(const SGVec2d& center, int nSides, double r, double r2);
123 void squareAt(const SGVec2d& center, double r);
124 void drawLine(const SGVec2d& p1, const SGVec2d& p2);
125 void drawLegendBox(const SGVec2d& pos, const std::string& t);
130 double _upHeading; // true heading corresponding to +ve y-axis
131 bool _magneticHeadings;
136 SGGeod _projectionCenter;
137 Projection _projection;
140 SGVec2d _hitLocation;
142 SGPropertyNode_ptr _root;
143 SGPropertyNode_ptr _gps;
144 SGGeodVec _flightHistoryPath;
146 FGPositionedList _itemsToDraw;
148 typedef std::map<void*, MapData*> KeyDataMap;
150 std::vector<MapData*> _dataQueue;
154 typedef std::map<int, SGVec2d> GridPointCache;
155 GridPointCache _gridCache;
160 #endif // of GUI_MAPWIDGET_HXX