]> git.mxchange.org Git - flightgear.git/blob - src/GUI/MapWidget.hxx
Fix windows build
[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   int zoom() const;
36   
37   void handlePan(int x, int y);
38   
39   void pan(const SGVec2d& delta);
40   void zoomIn();
41   void zoomOut();
42   
43   void paintAircraftLocation(const SGGeod& aircraftPos);
44   void paintRoute();
45   void paintRuler();
46   void drawFlightHistory();
47   
48   void drawGPSData();
49   void drawNavRadio(SGPropertyNode_ptr radio);
50   void drawTunedLocalizer(SGPropertyNode_ptr radio);
51   
52   void drawLatLonGrid();
53   SGVec2d gridPoint(int ix, int iy);
54   bool drawLineClipped(const SGVec2d& a, const SGVec2d& b);
55   
56   void drawAirports();
57   void drawAirport(FGAirport* apt);
58   int scoreAirportRunways(FGAirport* apt);
59   void drawRunwayPre(FGRunway* rwy);
60   void drawRunway(FGRunway* rwy);
61   void drawILS(bool tuned, FGRunway* rwy);
62   
63   void drawNavaids();
64   void drawNDB(bool tuned, FGNavRecord* nav);
65   void drawVOR(bool tuned, FGNavRecord* nav);
66   void drawFix(FGFix* fix);
67   
68   void drawTraffic();
69   void drawAIAircraft(const SGPropertyNode* model, const SGGeod& pos, double hdg);
70   void drawAIShip(const SGPropertyNode* model, const SGGeod& pos, double hdg);
71   
72   void drawData();
73   bool validDataForKey(void* key);
74   MapData* getOrCreateDataForKey(void* key);
75   MapData* createDataForKey(void* key);
76   void setAnchorForKey(void* key, const SGVec2d& anchor);
77   void clearData();
78   
79   SGVec2d project(const SGGeod& geod) const;
80   SGGeod unproject(const SGVec2d& p) const;
81   double currentScale() const;
82   
83   int displayHeading(double trueHeading) const;
84   
85   void circleAt(const SGVec2d& center, int nSides, double r);
86   void circleAtAlt(const SGVec2d& center, int nSides, double r, double r2);
87   void drawLine(const SGVec2d& p1, const SGVec2d& p2);
88   void drawLegendBox(const SGVec2d& pos, const std::string& t);
89   
90   int _width, _height;
91   int _cachedZoom;
92   double _drawRangeNm;
93   double _upHeading; // true heading corresponding to +ve y-axis
94   bool _magneticHeadings;
95   bool _hasPanned;
96   
97   SGGeod _projectionCenter;
98   bool _orthoAzimuthProject;
99   SGGeod _aircraft;
100   SGGeod _clickGeod;
101   SGVec2d _hitLocation;
102   FGRouteMgr* _route;
103   SGPropertyNode_ptr _root;
104   SGPropertyNode_ptr _gps;
105   
106   typedef std::map<void*, MapData*> KeyDataMap;
107   KeyDataMap _mapData;
108   std::vector<MapData*> _dataQueue;
109   
110   SGMagVar* _magVar;
111   
112   typedef std::map<int, SGVec2d> GridPointCache;
113   GridPointCache _gridCache;
114   double _gridSpacing;
115   SGGeod _gridCenter;
116 };
117
118 #endif // of GUI_MAPWIDGET_HXX