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