#include <Airports/runways.hxx>
#include <Main/fg_os.hxx> // fgGetKeyModifiers()
#include <Navaids/routePath.hxx>
+#include <Aircraft/FlightHistory.hxx>
const char* RULER_LEGEND_KEY = "ruler-legend";
_root->setIntValue("max-zoom", MAX_ZOOM);
_root->setBoolValue("centre-on-aircraft", true);
_root->setBoolValue("draw-data", false);
+ _root->setBoolValue("draw-flight-history", false);
_root->setBoolValue("magnetic-headings", true);
}
void MapWidget::draw(int dx, int dy)
{
- _aircraft = SGGeod::fromDeg(fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg"));
+ _aircraft = globals->get_aircraft_position();
bool mag = _root->getBoolValue("magnetic-headings");
if (mag != _magneticHeadings) {
drawNavRadio(fgGetNode("/instrumentation/nav[0]", false));
drawNavRadio(fgGetNode("/instrumentation/nav[1]", false));
paintAircraftLocation(_aircraft);
+ drawFlightHistory();
paintRoute();
paintRuler();
} // of second waypoint iteration
}
+void MapWidget::drawFlightHistory()
+{
+ FGFlightHistory* history = (FGFlightHistory*) globals->get_subsystem("history");
+ if (!history || !_root->getBoolValue("draw-flight-history")) {
+ return;
+ }
+
+ // first pass, draw the actual lines
+ glLineWidth(2.0);
+
+ SGGeodVec gv(history->pathForHistory());
+ glColor4f(0.0, 0.0, 1.0, 0.7);
+
+ glBegin(GL_LINE_STRIP);
+ for (unsigned int i=0; i<gv.size(); ++i) {
+ SGVec2d p = project(gv[i]);
+ glVertex2d(p.x(), p.y());
+ }
+
+ glEnd();
+}
+
/**
* Round a SGGeod to an arbitrary precision.
* For example, passing precision of 0.5 will round to the nearest 0.5 of
void MapWidget::drawAirports()
{
MapAirportFilter af(_root);
- FGPositioned::List apts = FGPositioned::findWithinRange(_projectionCenter, _drawRangeNm, &af);
+ bool partial = false;
+ FGPositioned::List apts = FGPositioned::findWithinRangePartial(_projectionCenter, _drawRangeNm, &af, partial);
for (unsigned int i=0; i<apts.size(); ++i) {
drawAirport((FGAirport*) apts[i].get());
}
}
virtual FGPositioned::Type minType() const {
- return _fixes ? FGPositioned::FIX : FGPositioned::VOR;
+ return _fixes ? FGPositioned::FIX : FGPositioned::NDB;
}
virtual FGPositioned::Type maxType() const {
- return _navaids ? FGPositioned::NDB : FGPositioned::FIX;
+ return _navaids ? FGPositioned::VOR : FGPositioned::FIX;
}
private:
// identify the tuned station - unfortunately we don't get lat/lon directly,
// need to do the frequency search again
double mhz = radio->getDoubleValue("frequencies/selected-mhz", 0.0);
- FGNavRecord* nav = globals->get_navlist()->findByFreq(mhz, _aircraft);
+
+ FGNavRecord* nav = FGNavList::findByFreq(mhz, _aircraft,
+ FGNavList::navFilter());
if (!nav || (nav->ident() != radio->getStringValue("nav-id"))) {
// mismatch between navradio selection logic and ours!
return;
void MapWidget::drawTunedLocalizer(SGPropertyNode_ptr radio)
{
double mhz = radio->getDoubleValue("frequencies/selected-mhz", 0.0);
- FGNavRecord* loc = globals->get_loclist()->findByFreq(mhz, _aircraft);
+ FGNavRecord* loc = FGNavList::findByFreq(mhz, _aircraft, FGNavList::locFilter());
if (!loc || (loc->ident() != radio->getStringValue("nav-id"))) {
// mismatch between navradio selection logic and ours!
return;