1
0
Fork 0
flightgear/src/GUI/MapWidget.hxx

162 lines
4 KiB
C++
Raw Normal View History

2010-03-27 16:55:33 +00:00
#ifndef GUI_MAPWIDGET_HXX
#define GUI_MAPWIDGET_HXX
#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 <Navaids/positioned.hxx>
2010-03-27 16:55:33 +00:00
#include <plib/pu.h>
#include "FGPUIDialog.hxx"
2010-03-27 16:55:33 +00:00
// forward decls
class FGRouteMgr;
class FGRunway;
class FGHelipad;
2010-03-27 16:55:33 +00:00
class FGAirport;
class FGNavRecord;
class FGFix;
class MapData;
class SGMagVar;
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();
// 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);
// PUIDialog::ActiveWidget over-rides
virtual void update();
2010-03-27 16:55:33 +00:00
private:
enum Projection {
PROJECTION_SAMSON_FLAMSTEED,
PROJECTION_AZIMUTHAL_EQUIDISTANT,
PROJECTION_ORTHO_AZIMUTH,
PROJECTION_SPHERICAL
};
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();
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);
void drawHeliport(FGAirport* apt);
2010-03-27 16:55:33 +00:00
int scoreAirportRunways(FGAirport* apt);
void drawRunwayPre(FGRunway* rwy);
void drawRunway(FGRunway* rwy);
void drawHelipad(FGHelipad* hp);
2010-03-27 16:55:33 +00:00
void drawILS(bool tuned, FGRunway* rwy);
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);
void drawPOI(FGPositioned* rec);
2010-03-27 16:55:33 +00:00
void drawTraffic();
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);
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;
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 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;
int _cachedZoom;
2010-03-27 16:55:33 +00:00
double _drawRangeNm;
double _upHeading; // true heading corresponding to +ve y-axis
bool _magneticHeadings;
bool _hasPanned;
bool _aircraftUp;
int _displayHeading;
2010-03-27 16:55:33 +00:00
SGGeod _projectionCenter;
Projection _projection;
2010-03-27 16:55:33 +00:00
SGGeod _aircraft;
SGGeod _clickGeod;
SGVec2d _hitLocation;
FGRouteMgr* _route;
SGPropertyNode_ptr _root;
SGPropertyNode_ptr _gps;
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