2010-03-27 16:55:33 +00:00
|
|
|
#ifndef GUI_MAPWIDGET_HXX
|
|
|
|
#define GUI_MAPWIDGET_HXX
|
|
|
|
|
2011-07-30 09:47:28 +00:00
|
|
|
#include <map>
|
2010-03-27 16:55:33 +00:00
|
|
|
#include <simgear/compiler.h>
|
|
|
|
#include <simgear/math/SGMath.hxx>
|
|
|
|
#include <simgear/props/props.hxx>
|
|
|
|
|
|
|
|
#include <plib/pu.h>
|
|
|
|
|
|
|
|
#include "dialog.hxx" // for GUI_ID
|
|
|
|
|
|
|
|
// forward decls
|
|
|
|
class FGRouteMgr;
|
|
|
|
class FGRunway;
|
|
|
|
class FGAirport;
|
|
|
|
class FGNavRecord;
|
|
|
|
class FGFix;
|
|
|
|
class MapData;
|
|
|
|
class SGMagVar;
|
|
|
|
|
|
|
|
class MapWidget : public puObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MapWidget(int x, int y, int width, int height);
|
|
|
|
virtual ~MapWidget();
|
|
|
|
|
|
|
|
virtual void setSize(int width, int height);
|
|
|
|
virtual void doHit( int button, int updown, int x, int y ) ;
|
|
|
|
virtual void draw( int dx, int dy ) ;
|
|
|
|
virtual int checkKey(int key, int updown);
|
|
|
|
|
|
|
|
void setProperty(SGPropertyNode_ptr prop);
|
|
|
|
private:
|
2011-09-18 11:53:40 +00:00
|
|
|
int zoom() const;
|
|
|
|
|
2010-03-27 16:55:33 +00:00
|
|
|
void handlePan(int x, int y);
|
|
|
|
|
|
|
|
void pan(const SGVec2d& delta);
|
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
|
|
|
|
|
|
|
void paintAircraftLocation(const SGGeod& aircraftPos);
|
|
|
|
void paintRoute();
|
|
|
|
void paintRuler();
|
2012-12-10 18:11:44 +00:00
|
|
|
void drawFlightHistory();
|
2010-03-27 16:55:33 +00:00
|
|
|
|
|
|
|
void drawGPSData();
|
|
|
|
void drawNavRadio(SGPropertyNode_ptr radio);
|
|
|
|
void drawTunedLocalizer(SGPropertyNode_ptr radio);
|
|
|
|
|
|
|
|
void drawLatLonGrid();
|
|
|
|
SGVec2d gridPoint(int ix, int iy);
|
|
|
|
bool drawLineClipped(const SGVec2d& a, const SGVec2d& b);
|
|
|
|
|
|
|
|
void drawAirports();
|
|
|
|
void drawAirport(FGAirport* apt);
|
|
|
|
int scoreAirportRunways(FGAirport* apt);
|
|
|
|
void drawRunwayPre(FGRunway* rwy);
|
|
|
|
void drawRunway(FGRunway* rwy);
|
|
|
|
void drawILS(bool tuned, FGRunway* rwy);
|
|
|
|
|
|
|
|
void drawNavaids();
|
|
|
|
void drawNDB(bool tuned, FGNavRecord* nav);
|
|
|
|
void drawVOR(bool tuned, FGNavRecord* nav);
|
|
|
|
void drawFix(FGFix* fix);
|
|
|
|
|
|
|
|
void drawTraffic();
|
|
|
|
void drawAIAircraft(const SGPropertyNode* model, const SGGeod& pos, double hdg);
|
|
|
|
void drawAIShip(const SGPropertyNode* model, const SGGeod& pos, double hdg);
|
|
|
|
|
|
|
|
void drawData();
|
|
|
|
bool validDataForKey(void* key);
|
|
|
|
MapData* getOrCreateDataForKey(void* key);
|
|
|
|
MapData* createDataForKey(void* key);
|
|
|
|
void setAnchorForKey(void* key, const SGVec2d& anchor);
|
2011-10-02 13:30:06 +00:00
|
|
|
void clearData();
|
2010-03-27 16:55:33 +00:00
|
|
|
|
|
|
|
SGVec2d project(const SGGeod& geod) const;
|
|
|
|
SGGeod unproject(const SGVec2d& p) const;
|
|
|
|
double currentScale() const;
|
|
|
|
|
2011-10-02 13:30:06 +00:00
|
|
|
int displayHeading(double trueHeading) const;
|
|
|
|
|
2010-03-27 16:55:33 +00:00
|
|
|
void circleAt(const SGVec2d& center, int nSides, double r);
|
|
|
|
void circleAtAlt(const SGVec2d& center, int nSides, double r, double r2);
|
|
|
|
void drawLine(const SGVec2d& p1, const SGVec2d& p2);
|
|
|
|
void drawLegendBox(const SGVec2d& pos, const std::string& t);
|
|
|
|
|
|
|
|
int _width, _height;
|
2011-09-18 11:53:40 +00:00
|
|
|
int _cachedZoom;
|
2010-03-27 16:55:33 +00:00
|
|
|
double _drawRangeNm;
|
|
|
|
double _upHeading; // true heading corresponding to +ve y-axis
|
|
|
|
bool _magneticHeadings;
|
2011-05-20 17:48:05 +00:00
|
|
|
bool _hasPanned;
|
2010-03-27 16:55:33 +00:00
|
|
|
|
|
|
|
SGGeod _projectionCenter;
|
2012-04-21 10:14:45 +00:00
|
|
|
bool _orthoAzimuthProject;
|
2010-03-27 16:55:33 +00:00
|
|
|
SGGeod _aircraft;
|
|
|
|
SGGeod _clickGeod;
|
|
|
|
SGVec2d _hitLocation;
|
|
|
|
FGRouteMgr* _route;
|
|
|
|
SGPropertyNode_ptr _root;
|
|
|
|
SGPropertyNode_ptr _gps;
|
|
|
|
|
|
|
|
typedef std::map<void*, MapData*> KeyDataMap;
|
|
|
|
KeyDataMap _mapData;
|
|
|
|
std::vector<MapData*> _dataQueue;
|
|
|
|
|
|
|
|
SGMagVar* _magVar;
|
|
|
|
|
|
|
|
typedef std::map<int, SGVec2d> GridPointCache;
|
|
|
|
GridPointCache _gridCache;
|
|
|
|
double _gridSpacing;
|
|
|
|
SGGeod _gridCenter;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // of GUI_MAPWIDGET_HXX
|