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_ORTHO_AZIMUTH,
52 void handlePan(int x, int y);
54 void pan(const SGVec2d& delta);
58 void paintAircraftLocation(const SGGeod& aircraftPos);
61 void drawFlightHistory();
64 void drawNavRadio(SGPropertyNode_ptr radio);
65 void drawTunedLocalizer(SGPropertyNode_ptr radio);
67 void drawLatLonGrid();
68 SGVec2d gridPoint(int ix, int iy);
69 bool drawLineClipped(const SGVec2d& a, const SGVec2d& b);
71 void drawAirport(FGAirport* apt);
72 int scoreAirportRunways(FGAirport* apt);
73 void drawRunwayPre(FGRunway* rwy);
74 void drawRunway(FGRunway* rwy);
75 void drawHelipad(FGHelipad* hp);
76 void drawILS(bool tuned, FGRunway* rwy);
78 void drawPositioned();
79 void drawNDB(bool tuned, FGNavRecord* nav);
80 void drawVOR(bool tuned, FGNavRecord* nav);
81 void drawFix(FGFix* fix);
83 void drawPOI(FGPositioned* rec);
90 DrawAIObject(SGPropertyNode* model, const SGGeod& g);
92 SGPropertyNode* model;
101 typedef std::vector<DrawAIObject> AIDrawVec;
102 AIDrawVec _aiDrawVec;
104 void updateAIObjects();
105 void drawAI(const DrawAIObject& dai);
108 bool validDataForKey(void* key);
109 MapData* getOrCreateDataForKey(void* key);
110 MapData* createDataForKey(void* key);
111 void setAnchorForKey(void* key, const SGVec2d& anchor);
114 SGVec2d project(const SGGeod& geod) const;
115 SGGeod unproject(const SGVec2d& p) const;
116 double currentScale() const;
118 int displayHeading(double trueHeading) const;
120 void circleAt(const SGVec2d& center, int nSides, double r);
121 void circleAtAlt(const SGVec2d& center, int nSides, double r, double r2);
122 void squareAt(const SGVec2d& center, double r);
123 void drawLine(const SGVec2d& p1, const SGVec2d& p2);
124 void drawLegendBox(const SGVec2d& pos, const std::string& t);
129 double _upHeading; // true heading corresponding to +ve y-axis
130 bool _magneticHeadings;
135 SGGeod _projectionCenter;
136 Projection _projection;
139 SGVec2d _hitLocation;
141 SGPropertyNode_ptr _root;
142 SGPropertyNode_ptr _gps;
143 SGGeodVec _flightHistoryPath;
145 FGPositionedList _itemsToDraw;
147 typedef std::map<void*, MapData*> KeyDataMap;
149 std::vector<MapData*> _dataQueue;
153 typedef std::map<int, SGVec2d> GridPointCache;
154 GridPointCache _gridCache;
159 #endif // of GUI_MAPWIDGET_HXX