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