void FlarmTrafficControl::CalcAutoZoom() { bool warning_mode = WarningMode(); fixed zoom_dist = fixed_zero; for (unsigned i = 0; i < FLARM_STATE::FLARM_MAX_TRAFFIC; i++) { if (!data.FLARM_Traffic[i].defined()) continue; if (warning_mode && !data.FLARM_Traffic[i].HasAlarm()) continue; fixed dist = data.FLARM_Traffic[i].RelativeNorth * data.FLARM_Traffic[i].RelativeNorth + data.FLARM_Traffic[i].RelativeEast * data.FLARM_Traffic[i].RelativeEast; zoom_dist = max(dist, zoom_dist); } for (unsigned i = 0; i <= 4; i++) { if (i == 4 || fixed(GetZoomDistance(i) * GetZoomDistance(i)) >= zoom_dist) { SetZoom(i); break; } } }
void FlarmTrafficControl::CalcAutoZoom() { bool warning_mode = WarningMode(); RoughDistance zoom_dist = fixed(0); for (auto it = data.list.begin(), end = data.list.end(); it != end; ++it) { if (warning_mode && !it->HasAlarm()) continue; zoom_dist = std::max(it->distance, zoom_dist); } fixed zoom_dist2 = zoom_dist; for (unsigned i = 0; i <= 4; i++) { if (i == 4 || fixed(GetZoomDistance(i)) >= zoom_dist2) { SetZoom(i); break; } } }
void SetZoom(unsigned _zoom) { zoom = _zoom; SetDistance(fixed(GetZoomDistance(_zoom))); }