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>
|
|
|
|
|
2014-01-14 13:11:06 +00:00
|
|
|
#include <Navaids/positioned.hxx>
|
2010-03-27 16:55:33 +00:00
|
|
|
#include <plib/pu.h>
|
|
|
|
|
2014-01-14 13:11:06 +00:00
|
|
|
#include "FGPUIDialog.hxx"
|
2010-03-27 16:55:33 +00:00
|
|
|
|
|
|
|
// forward decls
|
|
|
|
class FGRouteMgr;
|
|
|
|
class FGRunway;
|
2013-02-20 22:35:32 +00:00
|
|
|
class FGHelipad;
|
2010-03-27 16:55:33 +00:00
|
|
|
class FGAirport;
|
|
|
|
class FGNavRecord;
|
|
|
|
class FGFix;
|
|
|
|
class MapData;
|
|
|
|
class SGMagVar;
|
|
|
|
|
2014-01-14 13:11:06 +00:00
|
|
|
typedef std::vector<SGGeod> SGGeodVec;
|
|
|
|
|
|
|
|
class MapWidget : public puObject, public FGPUIDialog::ActiveWidget
|
2010-03-27 16:55:33 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MapWidget(int x, int y, int width, int height);
|
|
|
|
virtual ~MapWidget();
|
|
|
|
|
2014-01-14 13:11:06 +00:00
|
|
|
// puObject over-rides
|
2010-03-27 16:55:33 +00:00
|
|
|
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);
|
2014-01-14 13:11:06 +00:00
|
|
|
|
|
|
|
// PUIDialog::ActiveWidget over-rides
|
|
|
|
virtual void update();
|
|
|
|
|
2010-03-27 16:55:33 +00:00
|
|
|
private:
|
2013-06-30 15:41:05 +00:00
|
|
|
enum Projection {
|
|
|
|
PROJECTION_SAMSON_FLAMSTEED,
|
2014-06-29 20:45:18 +00:00
|
|
|
PROJECTION_AZIMUTHAL_EQUIDISTANT,
|
2013-06-30 15:41:05 +00:00
|
|
|
PROJECTION_ORTHO_AZIMUTH,
|
|
|
|
PROJECTION_SPHERICAL
|
|
|
|
};
|
|
|
|
|
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 drawAirport(FGAirport* apt);
|
2019-01-15 11:32:57 +00:00
|
|
|
void drawHeliport(FGAirport* apt);
|
2010-03-27 16:55:33 +00:00
|
|
|
int scoreAirportRunways(FGAirport* apt);
|
|
|
|
void drawRunwayPre(FGRunway* rwy);
|
|
|
|
void drawRunway(FGRunway* rwy);
|
2013-02-20 22:35:32 +00:00
|
|
|
void drawHelipad(FGHelipad* hp);
|
2010-03-27 16:55:33 +00:00
|
|
|
void drawILS(bool tuned, FGRunway* rwy);
|
|
|
|
|
2014-01-14 13:11:06 +00:00
|
|
|
void drawPositioned();
|
2010-03-27 16:55:33 +00:00
|
|
|
void drawNDB(bool tuned, FGNavRecord* nav);
|
|
|
|
void drawVOR(bool tuned, FGNavRecord* nav);
|
|
|
|
void drawFix(FGFix* fix);
|
2013-03-03 23:27:12 +00:00
|
|
|
|
2014-01-14 13:11:06 +00:00
|
|
|
void drawPOI(FGPositioned* rec);
|
|
|
|
|
2010-03-27 16:55:33 +00:00
|
|
|
void drawTraffic();
|
2014-01-14 13:11:06 +00:00
|
|
|
|
|
|
|
class DrawAIObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DrawAIObject(SGPropertyNode* model, const SGGeod& g);
|
|
|
|
|
|
|
|
SGPropertyNode* model;
|
|
|
|
bool boat;
|
|
|
|
SGGeod pos;
|
|
|
|
double heading;
|
|
|
|
int speedKts;
|
|
|
|
std::string label;
|
|
|
|
std::string legend;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<DrawAIObject> AIDrawVec;
|
|
|
|
AIDrawVec _aiDrawVec;
|
|
|
|
|
|
|
|
void updateAIObjects();
|
|
|
|
void drawAI(const DrawAIObject& dai);
|
2010-03-27 16:55:33 +00:00
|
|
|
|
|
|
|
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);
|
2013-03-10 17:18:45 +00:00
|
|
|
void squareAt(const SGVec2d& center, double r);
|
2010-03-27 16:55:33 +00:00
|
|
|
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;
|
2014-01-14 13:11:06 +00:00
|
|
|
bool _aircraftUp;
|
|
|
|
int _displayHeading;
|
|
|
|
|
2010-03-27 16:55:33 +00:00
|
|
|
SGGeod _projectionCenter;
|
2013-06-30 15:41:05 +00:00
|
|
|
Projection _projection;
|
2010-03-27 16:55:33 +00:00
|
|
|
SGGeod _aircraft;
|
|
|
|
SGGeod _clickGeod;
|
|
|
|
SGVec2d _hitLocation;
|
|
|
|
FGRouteMgr* _route;
|
|
|
|
SGPropertyNode_ptr _root;
|
|
|
|
SGPropertyNode_ptr _gps;
|
2014-01-14 13:11:06 +00:00
|
|
|
SGGeodVec _flightHistoryPath;
|
|
|
|
|
|
|
|
FGPositionedList _itemsToDraw;
|
|
|
|
|
2010-03-27 16:55:33 +00:00
|
|
|
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
|