]> git.mxchange.org Git - flightgear.git/blob - src/GUI/MapWidget.hxx
Merge branch 'ehofman/atc-sound' into next
[flightgear.git] / src / GUI / MapWidget.hxx
1 #ifndef GUI_MAPWIDGET_HXX
2 #define GUI_MAPWIDGET_HXX
3
4 #include <simgear/compiler.h>
5 #include <simgear/math/SGMath.hxx>
6 #include <simgear/props/props.hxx>
7
8 #include <plib/pu.h>
9
10 #include "dialog.hxx" // for GUI_ID
11
12 // forward decls
13 class FGRouteMgr;
14 class FGRunway;
15 class FGAirport;
16 class FGNavRecord;
17 class FGFix;
18 class MapData;
19 class SGMagVar;
20
21 class MapWidget : public puObject
22 {
23 public:
24   MapWidget(int x, int y, int width, int height);
25   virtual ~MapWidget();
26   
27   virtual void setSize(int width, int height);
28   virtual void doHit( int button, int updown, int x, int y ) ;
29   virtual void draw( int dx, int dy ) ;
30   virtual int checkKey(int key, int updown);
31     
32   void setProperty(SGPropertyNode_ptr prop);
33 private:
34   void handlePan(int x, int y);
35   
36   void pan(const SGVec2d& delta);
37   void zoomIn();
38   void zoomOut();
39   
40   void paintAircraftLocation(const SGGeod& aircraftPos);
41   void paintRoute();
42   void paintRuler();
43   
44   void drawGPSData();
45   void drawNavRadio(SGPropertyNode_ptr radio);
46   void drawTunedLocalizer(SGPropertyNode_ptr radio);
47   
48   void drawLatLonGrid();
49   SGVec2d gridPoint(int ix, int iy);
50   bool drawLineClipped(const SGVec2d& a, const SGVec2d& b);
51   
52   void drawAirports();
53   void drawAirport(FGAirport* apt);
54   int scoreAirportRunways(FGAirport* apt);
55   void drawRunwayPre(FGRunway* rwy);
56   void drawRunway(FGRunway* rwy);
57   void drawILS(bool tuned, FGRunway* rwy);
58   
59   void drawNavaids();
60   void drawNDB(bool tuned, FGNavRecord* nav);
61   void drawVOR(bool tuned, FGNavRecord* nav);
62   void drawFix(FGFix* fix);
63   
64   void drawTraffic();
65   void drawAIAircraft(const SGPropertyNode* model, const SGGeod& pos, double hdg);
66   void drawAIShip(const SGPropertyNode* model, const SGGeod& pos, double hdg);
67   
68   void drawData();
69   bool validDataForKey(void* key);
70   MapData* getOrCreateDataForKey(void* key);
71   MapData* createDataForKey(void* key);
72   void setAnchorForKey(void* key, const SGVec2d& anchor);
73   
74   SGVec2d project(const SGGeod& geod) const;
75   SGGeod unproject(const SGVec2d& p) const;
76   double currentScale() const;
77   
78   void circleAt(const SGVec2d& center, int nSides, double r);
79   void circleAtAlt(const SGVec2d& center, int nSides, double r, double r2);
80   void drawLine(const SGVec2d& p1, const SGVec2d& p2);
81   void drawLegendBox(const SGVec2d& pos, const std::string& t);
82   
83   int _width, _height;
84   int _zoom;
85   double _drawRangeNm;
86   double _upHeading; // true heading corresponding to +ve y-axis
87   bool _magneticHeadings;
88   
89   SGGeod _projectionCenter;
90   SGGeod _aircraft;
91   SGGeod _clickGeod;
92   SGVec2d _hitLocation;
93   FGRouteMgr* _route;
94   SGPropertyNode_ptr _root;
95   SGPropertyNode_ptr _gps;
96   
97   typedef std::map<void*, MapData*> KeyDataMap;
98   KeyDataMap _mapData;
99   std::vector<MapData*> _dataQueue;
100   
101   SGMagVar* _magVar;
102   
103   typedef std::map<int, SGVec2d> GridPointCache;
104   GridPointCache _gridCache;
105   double _gridSpacing;
106   SGGeod _gridCenter;
107 };
108
109 #endif // of GUI_MAPWIDGET_HXX