void GlueMapWindow::DrawThermalBand(Canvas &canvas, const PixelRect &rc) const { if (Calculated().task_stats.total.solution_remaining.IsOk() && Calculated().task_stats.total.solution_remaining.altitude_difference > fixed(50) && GetDisplayMode() == DisplayMode::FINAL_GLIDE) return; PixelRect tb_rect; tb_rect.left = rc.left; tb_rect.right = rc.left+Layout::Scale(20); tb_rect.top = Layout::Scale(2); tb_rect.bottom = (rc.bottom-rc.top)/5 - Layout::Scale(2); const ThermalBandRenderer &renderer = thermal_band_renderer; if (task != nullptr) { ProtectedTaskManager::Lease task_manager(*task); renderer.DrawThermalBand(Basic(), Calculated(), GetComputerSettings(), canvas, tb_rect, GetComputerSettings().task, true, &task_manager->GetOrderedTask().GetOrderedTaskSettings()); } else { renderer.DrawThermalBand(Basic(), Calculated(), GetComputerSettings(), canvas, tb_rect, GetComputerSettings().task, true); } }
void GlueMapWindow::DrawFinalGlide(Canvas &canvas, const PixelRect &rc) const { if (GetMapSettings().final_glide_bar_display_mode==FinalGlideBarDisplayMode::OFF) return; if (GetMapSettings().final_glide_bar_display_mode==FinalGlideBarDisplayMode::AUTO) { const TaskStats &task_stats = Calculated().task_stats; const ElementStat &total = task_stats.total; const GlideResult &solution = total.solution_remaining; const GlideResult &solution_mc0 = total.solution_mc0; const GlideSettings &glide_settings= GetComputerSettings().task.glide; if (!task_stats.task_valid || !solution.IsOk() || !solution_mc0.IsDefined()) return; if (solution_mc0.SelectAltitudeDifference(glide_settings) < fixed(-1000) && solution.SelectAltitudeDifference(glide_settings) < fixed(-1000)) return; } final_glide_bar_renderer.Draw(canvas, rc, Calculated(), GetComputerSettings().task.glide, GetMapSettings().final_glide_bar_mc0_enabled); }
bool GlueMapWindow::ShowMapItems(const GeoPoint &location, bool show_empty_message) const { fixed range = visible_projection.DistancePixelsToMeters(Layout::GetHitRadius()); MapItemList list; MapItemListBuilder builder(list, location, range); builder.AddLocation(Basic(), terrain); if (route_planner) builder.AddArrivalAltitudes(*route_planner, terrain, GetComputerSettings().task.safety_height_arrival); if (Basic().location_available) builder.AddSelfIfNear(Basic().location, Calculated().heading); if (task) builder.AddTaskOZs(*task); const Airspaces *airspace_database = airspace_renderer.GetAirspaces(); if (airspace_database) builder.AddVisibleAirspace(*airspace_database, airspace_renderer.GetWarningManager(), GetComputerSettings().airspace, GetMapSettings().airspace, Basic(), Calculated()); if (marks && render_projection.GetMapScale() <= fixed_int_constant(30000)) builder.AddMarkers(*marks); if (render_projection.GetMapScale() <= fixed_int_constant(4000)) builder.AddThermals(Calculated().thermal_locator, Basic(), Calculated()); if (waypoints) builder.AddWaypoints(*waypoints); if (Basic().flarm.available) builder.AddTraffic(Basic().flarm); // Sort the list of map items list.Sort(); // Show the list dialog if (list.empty()) { if (show_empty_message) ShowMessageBox(_("There is nothing interesting near this location."), _("Map elements at this location"), MB_OK | MB_ICONINFORMATION); return false; } ShowMapItemListDialog(UIGlobals::GetMainWindow(), list, UIGlobals::GetDialogLook(), look, traffic_look, final_glide_bar_renderer.GetLook(), GetMapSettings(), glide_computer != NULL ? &glide_computer->GetAirspaceWarnings() : NULL); return true; }
void MapWindow::DrawWaypoints(Canvas &canvas) { waypoint_renderer.render(canvas, label_block, render_projection, GetMapSettings().waypoint, GetComputerSettings().polar, GetComputerSettings().task, Basic(), Calculated(), task, route_planner); }
void ActionInterface::SendGetComputerSettings() { assert(calculation_thread != NULL); main_window.SetComputerSettings(GetComputerSettings()); calculation_thread->SetComputerSettings(GetComputerSettings()); calculation_thread->SetScreenDistanceMeters(main_window.GetProjection().GetScreenDistanceMeters()); }
void TargetMapWindow::DrawWaypoints(Canvas &canvas) { const MapSettings &settings_map = GetMapSettings(); WaypointRendererSettings settings = settings_map.waypoint; settings.display_text_type = WaypointRendererSettings::DisplayTextType::NAME; way_point_renderer.render(canvas, label_block, projection, settings, GetComputerSettings().polar, GetComputerSettings().task, Basic(), Calculated(), task, nullptr); }
/** * Process slow calculations. Called by the CalculationThread. */ void GlideComputer::ProcessIdle(bool exhaustive) { // Log GPS fixes for internal usage // (snail trail, stats, olc, ...) stats_computer.DoLogging(Basic(), Calculated()); log_computer.Run(Basic(), Calculated(), GetComputerSettings().logger); task_computer.ProcessIdle(Basic(), SetCalculated(), GetComputerSettings(), exhaustive); if (time_advanced()) warning_computer.Update(GetComputerSettings(), Basic(), LastBasic(), Calculated(), SetCalculated().airspace_warnings); }
void ActionInterface::SetMacCready(fixed mc, bool to_devices) { /* update interface settings */ GlidePolar &polar = SetComputerSettings().glide_polar_task; polar.SetMC(mc); /* update InfoBoxes (that might show the MacCready setting) */ InfoBoxManager::SetDirty(); /* send to calculation thread and trigger recalculation */ if (protected_task_manager != NULL) protected_task_manager->SetGlidePolar(polar); if (calculation_thread != NULL) { calculation_thread->SetComputerSettings(GetComputerSettings()); calculation_thread->Trigger(); } /* send to external devices */ if (to_devices) device_blackboard->SetMC(mc); }
void GlueMapWindow::DrawFinalGlide(Canvas &canvas, const PixelRect &rc) const { final_glide_bar_renderer.Draw(canvas, rc, Calculated(), GetComputerSettings().task.glide, MapSettings().final_glide_bar_mc0_enabled); }
void GlideComputer::CalculateTeammateBearingRange() { const TeamCodeSettings &settings = GetComputerSettings().team_code; const NMEAInfo &basic = Basic(); TeamInfo &teamcode_info = SetCalculated(); // No reference waypoint for teamcode calculation chosen -> cancel if (!DetermineTeamCodeRefLocation()) return; if (settings.team_flarm_tracking) { ComputeFlarmTeam(basic.location, team_code_ref_location, basic.flarm.traffic, settings.team_flarm_id, teamcode_info); } else if (settings.team_code_valid) { teamcode_info.flarm_teammate_code_available = false; ComputeTeamCode(basic.location, team_code_ref_location, settings.team_code, teamcode_info); } else { teamcode_info.teammate_available = false; teamcode_info.flarm_teammate_code_available = false; } }
void GlideComputer::CalculateWorkingBand() { const MoreData &basic = Basic(); DerivedInfo &calculated = SetCalculated(); const ComputerSettings &settings = GetComputerSettings(); calculated.common_stats.height_min_working = stats_computer.GetFlightStats().GetMinWorkingHeight(); if (calculated.terrain_base_valid) { calculated.common_stats.height_min_working = std::max(calculated.common_stats.height_min_working, calculated.GetTerrainBaseFallback()+settings.task.safety_height_arrival); } calculated.common_stats.height_max_working = std::max(calculated.common_stats.height_min_working, stats_computer.GetFlightStats().GetMaxWorkingHeight()); calculated.common_stats.height_fraction_working = 1; // fallback; if (basic.NavAltitudeAvailable()) { calculated.common_stats.height_max_working = std::max(calculated.common_stats.height_max_working, basic.nav_altitude); calculated.common_stats.height_fraction_working = calculated.CalculateWorkingFraction(basic.nav_altitude, settings.task.safety_height_arrival); } }
void XCSoarInterface::ExchangeDeviceBlackboard() { ScopeLock protect(device_blackboard->mutex); device_blackboard->ReadComputerSettings(GetComputerSettings()); }
void GlideComputer::OnTakeoff() { // reset stats on takeoff air_data_computer.ResetFlight(SetCalculated(), GetComputerSettings()); // save stats in case we never finish SaveFinish(); }
/** * Is called by the CalculationThread and processes the received GPS data in Basic() */ bool GlideComputer::ProcessGPS(bool force) { const MoreData &basic = Basic(); DerivedInfo &calculated = SetCalculated(); const ComputerSettings &settings = GetComputerSettings(); const bool last_flying = calculated.flight.flying; calculated.date_time_local = basic.date_time_utc + settings.utc_offset; calculated.Expire(basic.clock); // Process basic information air_data_computer.ProcessBasic(Basic(), SetCalculated(), GetComputerSettings()); // Process basic task information task_computer.ProcessBasicTask(basic, LastBasic(), calculated, GetComputerSettings(), force); task_computer.ProcessMoreTask(basic, calculated, GetComputerSettings()); // Check if everything is okay with the gps time and process it if (!air_data_computer.FlightTimes(Basic(), LastBasic(), SetCalculated(), GetComputerSettings())) return false; TakeoffLanding(last_flying); if (!time_retreated()) task_computer.ProcessAutoTask(basic, calculated); // Process extended information air_data_computer.ProcessVertical(Basic(), LastBasic(), SetCalculated(), GetComputerSettings()); if (!time_retreated()) stats_computer.ProcessClimbEvents(calculated); // Calculate the team code CalculateOwnTeamCode(); // Calculate the bearing and range of the teammate CalculateTeammateBearingRange(); vegavoice.Update(basic, Calculated(), GetComputerSettings().voice); // update basic trace history if (time_advanced()) calculated.trace_history.append(basic); // Update the ConditionMonitors ConditionMonitorsUpdate(Basic(), Calculated(), settings); return idle_clock.CheckUpdate(500); }
void GlueMapWindow::DrawVario(Canvas &canvas, const PixelRect &rc) const { if (!GetMapSettings().vario_bar_enabled) return; vario_bar_renderer.Draw(canvas, rc, Basic(), Calculated(), GetComputerSettings().polar.glide_polar_task, true); //NOTE: AVG enabled for now, make it configurable ; }
void LiveBlackboard::BroadcastComputerSettingsUpdate() { calling_listeners = true; for (BlackboardListener *listener : listeners) listener->OnComputerSettingsUpdate(GetComputerSettings()); calling_listeners = false; }
/** * Resets the GlideComputer data * @param full Reset all data? */ void GlideComputer::ResetFlight(const bool full) { GlideComputerBlackboard::ResetFlight(full); air_data_computer.ResetFlight(SetCalculated(), GetComputerSettings(), full); task_computer.ResetFlight(full); stats_computer.ResetFlight(full); cu_computer.Reset(); warning_computer.Reset(Basic(), Calculated()); }
/** * Process slow calculations. Called by the CalculationThread. */ void GlideComputer::ProcessIdle(bool exhaustive) { const MoreData &basic = Basic(); DerivedInfo &calculated = SetCalculated(); // Log GPS fixes for internal usage // (snail trail, stats, olc, ...) stats_computer.DoLogging(basic, calculated); log_computer.Run(basic, calculated, GetComputerSettings().logger); task_computer.ProcessIdle(basic, calculated, GetComputerSettings(), exhaustive); warning_computer.Update(GetComputerSettings(), basic, calculated, calculated.airspace_warnings); // Calculate summary of flight if (basic.location_available) retrospective.UpdateSample(basic.location); }
void XCSoarInterface::ReceiveCalculated() { { ScopeLock protect(device_blackboard->mutex); ReadBlackboardCalculated(device_blackboard->Calculated()); device_blackboard->ReadComputerSettings(GetComputerSettings()); } BroadcastCalculatedUpdate(); }
void TargetMapWindow::RenderAirspace(Canvas &canvas) { if (GetMapSettings().airspace.enable) airspace_renderer.Draw(canvas, #ifndef ENABLE_OPENGL buffer_canvas, stencil_canvas, #endif projection, Basic(), Calculated(), GetComputerSettings(), GetMapSettings()); }
void GlideComputer::CalculateVarioScale() { DerivedInfo &calculated = SetCalculated(); const GlidePolar &glide_polar = GetComputerSettings().polar.glide_polar_task; calculated.common_stats.vario_scale_positive = std::max(stats_computer.GetFlightStats().GetVarioScalePositive(), glide_polar.GetMC()); calculated.common_stats.vario_scale_negative = std::min(stats_computer.GetFlightStats().GetVarioScaleNegative(), -glide_polar.GetSBestLD()); }
void TargetMapWindow::DrawWaypoints(Canvas &canvas) { const MapSettings &settings_map = GetMapSettings(); WaypointRendererSettings settings = settings_map.waypoint; settings.display_text_type = DISPLAYNAME; way_point_renderer.render(canvas, label_block, projection, settings, GetComputerSettings().task, task, NULL); }
void MapWindow::RenderAirspace(Canvas &canvas) { if (GetMapSettings().airspace.enable) { airspace_renderer.Draw(canvas, #ifndef ENABLE_OPENGL buffer_canvas, #endif render_projection, Basic(), Calculated(), GetComputerSettings().airspace, GetMapSettings().airspace); airspace_label_renderer.Draw(canvas, #ifndef ENABLE_OPENGL buffer_canvas, #endif render_projection, Basic(), Calculated(), GetComputerSettings().airspace, GetMapSettings().airspace); } }
bool GlideComputer::DetermineTeamCodeRefLocation() { const TeamCodeSettings &settings = GetComputerSettings().team_code; if (settings.team_code_reference_waypoint < 0) return false; if (settings.team_code_reference_waypoint == team_code_ref_id) return team_code_ref_found; team_code_ref_id = settings.team_code_reference_waypoint; const Waypoint *wp = waypoints.LookupId(team_code_ref_id); if (wp == NULL) return team_code_ref_found = false; team_code_ref_location = wp->location; return team_code_ref_found = true; }
void XCSoarInterface::AfterStartup() { LogStartUp(_T("ProgramStarted = 3")); StartupLogFreeRamAndStorage(); status_messages.Startup(true); if (is_simulator()) { LogStartUp(_T("GCE_STARTUP_SIMULATOR")); InputEvents::processGlideComputer(GCE_STARTUP_SIMULATOR); } else { LogStartUp(_T("GCE_STARTUP_REAL")); InputEvents::processGlideComputer(GCE_STARTUP_REAL); } OrderedTask *defaultTask = protected_task_manager->TaskCreateDefault( &way_points, GetComputerSettings().task.task_type_default); if (defaultTask) { { ScopeSuspendAllThreads suspend; defaultTask->CheckDuplicateWaypoints(way_points); way_points.Optimise(); } protected_task_manager->TaskCommit(*defaultTask); delete defaultTask; } task_manager->Resume(); main_window.Fullscreen(); InfoBoxManager::SetDirty(); TriggerGPSUpdate(); status_messages.Startup(false); }
const GlidePolar &GetGlidePolar() const { return GetComputerSettings().polar.glide_polar_task; }
void GaugeVario::RenderBugs(Canvas &canvas) { static int last_bugs = -1; static PixelRect label_rect = {-1,-1,-1,-1}; static PixelRect value_rect = {-1,-1,-1,-1}; static RasterPoint label_pos = {-1,-1}; static RasterPoint value_pos = {-1,-1}; if (!bugs_initialised) { const PixelRect rc = GetClientRect(); PixelSize tSize; label_pos.x = 1; label_pos.y = rc.bottom - 2 - look.text_font->GetCapitalHeight() - look.text_font->GetAscentHeight(); value_pos.x = 1; value_pos.y = rc.bottom - 1 - look.text_font->GetAscentHeight(); label_rect.left = label_pos.x; label_rect.top = label_pos.y + look.text_font->GetAscentHeight() - look.text_font->GetCapitalHeight(); value_rect.left = value_pos.x; value_rect.top = value_pos.y + look.text_font->GetAscentHeight() - look.text_font->GetCapitalHeight(); canvas.Select(*look.text_font); tSize = canvas.CalcTextSize(TEXT_BUG); label_rect.right = label_rect.left + tSize.cx; label_rect.bottom = label_rect.top + look.text_font->GetCapitalHeight() + look.text_font->GetHeight() - look.text_font->GetAscentHeight(); tSize = canvas.CalcTextSize(_T("100%")); value_rect.right = value_rect.left + tSize.cx; value_rect.bottom = value_rect.top + look.text_font->GetCapitalHeight(); bugs_initialised = true; } int bugs = iround((fixed(1) - GetComputerSettings().polar.bugs) * 100); if (!IsPersistent() || bugs != last_bugs) { canvas.Select(*look.text_font); if (IsPersistent()) canvas.SetBackgroundColor(look.background_color); else canvas.SetBackgroundTransparent(); if (IsPersistent() || last_bugs < 1 || bugs < 1) { if (bugs > 0) { canvas.SetTextColor(look.dimmed_text_color); if (IsPersistent()) canvas.DrawOpaqueText(label_pos.x, label_pos.y, label_rect, TEXT_BUG); else canvas.DrawText(label_pos.x, label_pos.y, TEXT_BUG); } else if (IsPersistent()) canvas.DrawFilledRectangle(label_rect, look.background_color); } if (bugs > 0) { TCHAR buffer[18]; _stprintf(buffer, _T("%d%%"), bugs); canvas.SetTextColor(look.text_color); if (IsPersistent()) canvas.DrawOpaqueText(value_pos.x, value_pos.y, value_rect, buffer); else canvas.DrawText(value_pos.x, value_pos.y, buffer); } else if (IsPersistent()) canvas.DrawFilledRectangle(value_rect, look.background_color); if (IsPersistent()) last_bugs = bugs; } }
void GaugeVario::OnPaintBuffer(Canvas &canvas) { const PixelRect rc = GetClientRect(); const unsigned width = rc.right - rc.left; const unsigned height = rc.bottom - rc.top; if (!IsPersistent() || !layout_initialised) { unsigned value_height = 4 + look.value_font->GetCapitalHeight() + look.text_font->GetCapitalHeight(); middle_position.y = offset.y - value_height / 2; middle_position.x = rc.right; top_position.y = middle_position.y - value_height; top_position.x = rc.right; bottom_position.y = middle_position.y + value_height; bottom_position.x = rc.right; canvas.Stretch(rc.left, rc.top, width, height, look.background_bitmap, look.background_x, 0, 58, 120); layout_initialised = true; } if (Settings().show_average) { // JMW averager now displays netto average if not circling if (!Calculated().circling) { RenderValue(canvas, top_position.x, top_position.y, &value_top, &label_top, Units::ToUserVSpeed(Calculated().netto_average), _T("NetAvg")); } else { RenderValue(canvas, top_position.x, top_position.y, &value_top, &label_top, Units::ToUserVSpeed(Calculated().average), _T("Avg")); } } if (Settings().show_mc) { fixed mc = Units::ToUserVSpeed(GetGlidePolar().GetMC()); RenderValue(canvas, bottom_position.x, bottom_position.y, &value_bottom, &label_bottom, mc, GetComputerSettings().task.auto_mc ? _T("Auto MC") : _T("MC")); } if (Settings().show_speed_to_fly) RenderSpeedToFly(canvas, rc.right - 11, (rc.top + rc.bottom) / 2); else RenderClimb(canvas); if (Settings().show_ballast) RenderBallast(canvas); if (Settings().show_bugs) RenderBugs(canvas); dirty = false; int ival, sval, ival_av = 0; static int vval_last = 0; static int sval_last = 0; static int ival_last = 0; fixed vval = Basic().brutto_vario; ival = ValueToNeedlePos(fixed(vval)); sval = ValueToNeedlePos(Calculated().sink_rate); if (Settings().show_average_needle) { if (!Calculated().circling) ival_av = ValueToNeedlePos(Calculated().netto_average); else ival_av = ValueToNeedlePos(Calculated().average); } // clear items first if (Settings().show_average_needle) { if (!IsPersistent() || ival_av != ival_last) RenderNeedle(canvas, ival_last, true, true); ival_last = ival_av; } if (!IsPersistent() || (sval != sval_last) || (ival != vval_last)) RenderVarioLine(canvas, vval_last, sval_last, true); sval_last = sval; if (!IsPersistent() || ival != vval_last) RenderNeedle(canvas, vval_last, false, true); vval_last = ival; // now draw items RenderVarioLine(canvas, ival, sval, false); if (Settings().show_average_needle) RenderNeedle(canvas, ival_av, true, false); RenderNeedle(canvas, ival, false, false); if (Settings().show_gross) { fixed vvaldisplay = Clamp(Units::ToUserVSpeed(vval), fixed(-99.9), fixed(99.9)); RenderValue(canvas, middle_position.x, middle_position.y, &value_middle, &label_middle, vvaldisplay, _T("Gross")); } RenderZero(canvas); }
bool ButtonLabel::ExpandMacros(const TCHAR *In, TCHAR *OutBuffer, size_t Size) { // ToDo, check Buffer Size bool invalid = false; CopyString(OutBuffer, In, Size); if (_tcsstr(OutBuffer, _T("$(")) == NULL) return false; if (_tcsstr(OutBuffer, _T("$(CheckAirspace)"))) { if (airspace_database.empty()) invalid = true; ReplaceInString(OutBuffer, _T("$(CheckAirspace)"), _T(""), Size); } invalid |= ExpandTaskMacros(OutBuffer, Size, Calculated(), GetComputerSettings()); ExpandTrafficMacros(OutBuffer, Size); if (_tcsstr(OutBuffer, _T("$(CheckFLARM)"))) { if (!Basic().flarm.status.available) invalid = true; ReplaceInString(OutBuffer, _T("$(CheckFLARM)"), _T(""), Size); } if (_tcsstr(OutBuffer, _T("$(CheckCircling)"))) { if (!Calculated().circling) invalid = true; ReplaceInString(OutBuffer, _T("$(CheckCircling)"), _T(""), Size); } if (_tcsstr(OutBuffer, _T("$(CheckVega)"))) { if (devVarioFindVega()== NULL) invalid = true; ReplaceInString(OutBuffer, _T("$(CheckVega)"), _T(""), Size); } if (_tcsstr(OutBuffer, _T("$(CheckReplay)"))) { if (CommonInterface::MovementDetected()) invalid = true; ReplaceInString(OutBuffer, _T("$(CheckReplay)"), _T(""), Size); } if (_tcsstr(OutBuffer, _T("$(CheckWaypointFile)"))) { invalid |= way_points.IsEmpty(); ReplaceInString(OutBuffer, _T("$(CheckWaypointFile)"), _T(""), Size); } if (_tcsstr(OutBuffer, _T("$(CheckLogger)"))) { invalid |= Basic().gps.replay; ReplaceInString(OutBuffer, _T("$(CheckLogger)"), _T(""), Size); } if (_tcsstr(OutBuffer, _T("$(CheckNet)"))) { #ifndef HAVE_HTTP invalid = true; #endif ReplaceInString(OutBuffer, _T("$(CheckNet)"), _T(""), Size); } if (_tcsstr(OutBuffer, _T("$(CheckTerrain)"))) { if (!Calculated().terrain_valid) invalid = true; ReplaceInString(OutBuffer, _T("$(CheckTerrain)"), _T(""), Size); } CondReplaceInString(logger != nullptr && logger->IsLoggerActive(), OutBuffer, _T("$(LoggerActive)"), _("Stop"), _("Start"), Size); if (_tcsstr(OutBuffer, _T("$(SnailTrailToggleName)"))) { switch (GetMapSettings().trail.length) { case TrailSettings::Length::OFF: ReplaceInString(OutBuffer, _T("$(SnailTrailToggleName)"), _("Long"), Size); break; case TrailSettings::Length::LONG: ReplaceInString(OutBuffer, _T("$(SnailTrailToggleName)"), _("Short"), Size); break; case TrailSettings::Length::SHORT: ReplaceInString(OutBuffer, _T("$(SnailTrailToggleName)"), _("Full"), Size); break; case TrailSettings::Length::FULL: ReplaceInString(OutBuffer, _T("$(SnailTrailToggleName)"), _("Off"), Size); break; } } if (_tcsstr(OutBuffer, _T("$(AirSpaceToggleName)"))) { ReplaceInString(OutBuffer, _T("$(AirSpaceToggleName)"), GetMapSettings().airspace.enable ? _("Off") : _("On"), Size); } if (_tcsstr(OutBuffer, _T("$(TerrainTopologyToggleName)"))) { char val = 0; if (GetMapSettings().topography_enabled) val++; if (GetMapSettings().terrain.enable) val += (char)2; switch (val) { case 0: ReplaceInString(OutBuffer, _T("$(TerrainTopologyToggleName)"), _("Topography On"), Size); break; case 1: ReplaceInString(OutBuffer, _T("$(TerrainTopologyToggleName)"), _("Terrain On"), Size); break; case 2: ReplaceInString(OutBuffer, _T("$(TerrainTopologyToggleName)"), _("Terrain + Topography"), Size); break; case 3: ReplaceInString(OutBuffer, _T("$(TerrainTopologyToggleName)"), _("Terrain Off"), Size); break; } } if (_tcsstr(OutBuffer, _T("$(TerrainTopographyToggleName)"))) { char val = 0; if (GetMapSettings().topography_enabled) val++; if (GetMapSettings().terrain.enable) val += (char)2; switch (val) { case 0: ReplaceInString(OutBuffer, _T("$(TerrainTopographyToggleName)"), _("Topography On"), Size); break; case 1: ReplaceInString(OutBuffer, _T("$(TerrainTopographyToggleName)"), _("Terrain On"), Size); break; case 2: ReplaceInString(OutBuffer, _T("$(TerrainTopographyToggleName)"), _("Terrain + Topography"), Size); break; case 3: ReplaceInString(OutBuffer, _T("$(TerrainTopographyToggleName)"), _("Terrain Off"), Size); break; } } CondReplaceInString(CommonInterface::main_window->GetFullScreen(), OutBuffer, _T("$(FullScreenToggleActionName)"), _("Off"), _("On"), Size); CondReplaceInString(GetMapSettings().auto_zoom_enabled, OutBuffer, _T("$(ZoomAutoToggleActionName)"), _("Manual"), _("Auto"), Size); CondReplaceInString(GetMapSettings().topography_enabled, OutBuffer, _T("$(TopologyToggleActionName)"), _("Off"), _("On"), Size); CondReplaceInString(GetMapSettings().topography_enabled, OutBuffer, _T("$(TopographyToggleActionName)"), _("Off"), _("On"), Size); CondReplaceInString(GetMapSettings().terrain.enable, OutBuffer, _T("$(TerrainToggleActionName)"), _("Off"), _("On"), Size); CondReplaceInString(GetMapSettings().airspace.enable, OutBuffer, _T("$(AirspaceToggleActionName)"), _("Off"), _("On"), Size); if (_tcsstr(OutBuffer, _T("$(MapLabelsToggleActionName)"))) { static const TCHAR *const labels[] = { N_("All"), N_("Task & Landables"), N_("Task"), N_("None") }; static constexpr unsigned int n = ARRAY_SIZE(labels); unsigned int i = (unsigned)GetMapSettings().waypoint.label_selection; ReplaceInString(OutBuffer, _T("$(MapLabelsToggleActionName)"), gettext(labels[(i + 1) % n]), Size); } CondReplaceInString(GetComputerSettings().task.auto_mc, OutBuffer, _T("$(MacCreadyToggleActionName)"), _("Manual"), _("Auto"), Size); CondReplaceInString(GetUIState().auxiliary_enabled, OutBuffer, _T("$(AuxInfoToggleActionName)"), _("Off"), _("On"), Size); CondReplaceInString(GetUIState().force_display_mode == DisplayMode::CIRCLING, OutBuffer, _T("$(DispModeClimbShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetUIState().force_display_mode == DisplayMode::CRUISE, OutBuffer, _T("$(DispModeCruiseShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetUIState().force_display_mode == DisplayMode::NONE, OutBuffer, _T("$(DispModeAutoShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetUIState().force_display_mode == DisplayMode::FINAL_GLIDE, OutBuffer, _T("$(DispModeFinalShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::ALLON, OutBuffer, _T("$(AirspaceModeAllShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::CLIP, OutBuffer, _T("$(AirspaceModeClipShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::AUTO, OutBuffer, _T("$(AirspaceModeAutoShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::ALLBELOW, OutBuffer, _T("$(AirspaceModeBelowShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().airspace.altitude_mode == AirspaceDisplayMode::ALLOFF, OutBuffer, _T("$(AirspaceModeAllOffIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().trail.length == TrailSettings::Length::OFF, OutBuffer, _T("$(SnailTrailOffShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().trail.length == TrailSettings::Length::SHORT, OutBuffer, _T("$(SnailTrailShortShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().trail.length == TrailSettings::Length::LONG, OutBuffer, _T("$(SnailTrailLongShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().trail.length == TrailSettings::Length::FULL, OutBuffer, _T("$(SnailTrailFullShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(!GetMapSettings().airspace.enable, OutBuffer, _T("$(AirSpaceOffShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(GetMapSettings().airspace.enable, OutBuffer, _T("$(AirSpaceOnShortIndicator)"), _T("(*)"), _T(""), Size); CondReplaceInString(CommonInterface::GetUISettings().traffic.enable_gauge, OutBuffer, _T("$(FlarmDispToggleActionName)"), _("Off"), _("On"), Size); CondReplaceInString(GetMapSettings().auto_zoom_enabled, OutBuffer, _T("$(ZoomAutoToggleActionName)"), _("Manual"), _("Auto"), Size); if (_tcsstr(OutBuffer, _T("$(NextPageName)"))) { TCHAR label[30]; const PageLayout &page = CommonInterface::GetUISettings().pages.pages[Pages::NextIndex()]; page.MakeTitle(CommonInterface::GetUISettings().info_boxes, label, true); ReplaceInString(OutBuffer, _T("$(NextPageName)"), label, Size); } return invalid; }
/** * "Boots" up XCSoar * @param hInstance Instance handle * @param lpCmdLine Command line string * @return True if bootup successful, False otherwise */ bool XCSoarInterface::Startup() { VerboseOperationEnvironment operation; // Set the application title to "XCSoar" TCHAR szTitle[] = _T("XCSoar"); //If "XCSoar" is already running, stop this instance if (MainWindow::find(szTitle)) return false; LogStartUp(_T("Display dpi=%u,%u"), Display::GetXDPI(), Display::GetYDPI()); // Creates the main window LogStartUp(_T("Create main window")); TopWindowStyle style; if (CommandLine::full_screen) style.FullScreen(); if (CommandLine::resizable) style.Resizable(); main_window.Set(szTitle, SystemWindowSize(), style); if (!main_window.IsDefined()) return false; #ifdef ENABLE_OPENGL LogStartUp(_T("OpenGL: " #ifdef HAVE_EGL "egl=%d " #endif "npot=%d vbo=%d fbo=%d"), #ifdef HAVE_EGL OpenGL::egl, #endif OpenGL::texture_non_power_of_two, OpenGL::vertex_buffer_object, OpenGL::frame_buffer_object); #endif main_window.Initialise(); #ifdef SIMULATOR_AVAILABLE // prompt for simulator if not set by command line argument "-simulator" or "-fly" if (!sim_set_in_cmd_line_flag) { DialogLook white_look; white_look.Initialise(Fonts::map_bold, Fonts::map, Fonts::map_label, Fonts::map_bold, Fonts::map_bold); white_look.SetBackgroundColor(COLOR_WHITE); SetXMLDialogLook(white_look); SimulatorPromptResult result = dlgSimulatorPromptShowModal(); switch (result) { case SPR_QUIT: return false; case SPR_FLY: global_simulator_flag = false; break; case SPR_SIMULATOR: global_simulator_flag = true; break; } } #endif SetXMLDialogLook(main_window.GetLook().dialog); SetSystemSettings().SetDefaults(); SetComputerSettings().SetDefaults(); SetUISettings().SetDefaults(); SetUIState().Clear(); if (!LoadProfile()) return false; operation.SetText(_("Initialising")); /* create XCSoarData on the first start */ CreateDataPath(); Display::LoadOrientation(operation); main_window.InitialiseConfigured(); TCHAR path[MAX_PATH]; LocalPath(path, _T("cache")); file_cache = new FileCache(path); ReadLanguageFile(); status_messages.LoadFile(); InputEvents::readFile(); // Initialize DeviceBlackboard device_blackboard = new DeviceBlackboard(); DeviceListInitialise(); // Initialize Markers marks = new Markers(); protected_marks = new ProtectedMarkers(*marks); #ifdef HAVE_AYGSHELL_DLL const AYGShellDLL &ayg = main_window.ayg_shell_dll; ayg.SHSetAppKeyWndAssoc(VK_APP1, main_window); ayg.SHSetAppKeyWndAssoc(VK_APP2, main_window); ayg.SHSetAppKeyWndAssoc(VK_APP3, main_window); ayg.SHSetAppKeyWndAssoc(VK_APP4, main_window); // Typical Record Button // Why you can't always get this to work // http://forums.devbuzz.com/m_1185/mpage_1/key_/tm.htm // To do with the fact it is a global hotkey, but you can with code above // Also APPA is record key on some systems ayg.SHSetAppKeyWndAssoc(VK_APP5, main_window); ayg.SHSetAppKeyWndAssoc(VK_APP6, main_window); #endif // Initialize main blackboard data task_manager = new TaskManager(GetComputerSettings().task, way_points); task_manager->SetTaskEvents(task_events); task_manager->Reset(); protected_task_manager = new ProtectedTaskManager(*task_manager, XCSoarInterface::GetComputerSettings().task); // Read the terrain file operation.SetText(_("Loading Terrain File...")); LogStartUp(_T("OpenTerrain")); terrain = RasterTerrain::OpenTerrain(file_cache, operation); glide_computer = new GlideComputer(way_points, airspace_database, *protected_task_manager, task_events); glide_computer->ReadComputerSettings(GetComputerSettings()); glide_computer->SetTerrain(terrain); glide_computer->SetLogger(&logger); glide_computer->Initialise(); replay = new Replay(&logger, *protected_task_manager); // Load the EGM96 geoid data EGM96::Load(); GlidePolar &gp = SetComputerSettings().polar.glide_polar_task; gp = GlidePolar(fixed_zero); gp.SetMC(GetComputerSettings().task.safety_mc); gp.SetBugs(GetComputerSettings().polar.degradation_factor); PlaneGlue::FromProfile(SetComputerSettings().plane); PlaneGlue::Synchronize(GetComputerSettings().plane, SetComputerSettings(), gp); task_manager->SetGlidePolar(gp); // Read the topography file(s) topography = new TopographyStore(); LoadConfiguredTopography(*topography, operation); // Read the waypoint files WaypointGlue::LoadWaypoints(way_points, terrain, operation); // Read and parse the airfield info file WaypointDetails::ReadFileFromProfile(way_points, operation); // Set the home waypoint WaypointGlue::SetHome(way_points, terrain, SetComputerSettings(), device_blackboard, false); // ReSynchronise the blackboards here since SetHome touches them device_blackboard->Merge(); ReadBlackboardBasic(device_blackboard->Basic()); // Scan for weather forecast LogStartUp(_T("RASP load")); RASP.ScanAll(Basic().location, operation); // Reads the airspace files ReadAirspace(airspace_database, terrain, GetComputerSettings().pressure, operation); { const AircraftState aircraft_state = ToAircraftState(device_blackboard->Basic(), device_blackboard->Calculated()); ProtectedAirspaceWarningManager::ExclusiveLease lease(glide_computer->GetAirspaceWarnings()); lease->Reset(aircraft_state); lease->SetConfig(CommonInterface::GetComputerSettings().airspace.warnings); } #ifdef HAVE_NET noaa_store = new NOAAStore(); noaa_store->LoadFromProfile(); #endif AudioVarioGlue::Initialise(); AudioVarioGlue::Configure(GetComputerSettings().sound); // Start the device thread(s) operation.SetText(_("Starting devices")); devStartup(); /* -- Reset polar in case devices need the data LogStartUp(_T("GlidePolar::UpdatePolar")); GlidePolar::UpdatePolar(true, GetComputerSettings()); This should be done inside devStartup if it is really required */ operation.SetText(_("Initialising display")); GlueMapWindow *map_window = main_window.GetMap(); if (map_window != NULL) { map_window->SetWaypoints(&way_points); map_window->SetTask(protected_task_manager); map_window->SetRoutePlanner(&glide_computer->GetProtectedRoutePlanner()); map_window->SetGlideComputer(glide_computer); map_window->SetAirspaces(&airspace_database); map_window->SetTopography(topography); map_window->SetTerrain(terrain); map_window->SetWeather(&RASP); map_window->SetMarks(protected_marks); map_window->SetLogger(&logger); /* show map at home waypoint until GPS fix becomes available */ if (GetComputerSettings().poi.home_location_available) map_window->SetLocation(GetComputerSettings().poi.home_location); } // Finally ready to go.. all structures must be present before this. // Create the drawing thread #ifndef ENABLE_OPENGL LogStartUp(_T("CreateDrawingThread")); draw_thread = new DrawThread(*map_window); draw_thread->Start(true); #endif // Show the infoboxes LogStartUp(_T("ShowInfoBoxes")); InfoBoxManager::Show(); // Create the calculation thread LogStartUp(_T("CreateCalculationThread")); CreateCalculationThread(); // Find unique ID of this PDA ReadAssetNumber(); glide_computer_events.Reset(); GetLiveBlackboard().AddListener(glide_computer_events); if (CommonInterface::GetComputerSettings().logger.enable_flight_logger) { flight_logger = new GlueFlightLogger(GetLiveBlackboard()); LocalPath(path, _T("flights.log")); flight_logger->SetPath(path); } if (CommonInterface::GetComputerSettings().logger.enable_nmea_logger) NMEALogger::enabled = true; LogStartUp(_T("ProgramStarted")); // Give focus to the map main_window.SetDefaultFocus(); Pages::Initialise(GetUISettings().pages); // Start calculation thread merge_thread->Start(); calculation_thread->Start(); #ifdef HAVE_TRACKING tracking = new TrackingGlue(); tracking->SetSettings(GetComputerSettings().tracking); #endif globalRunningEvent.Signal(); AfterStartup(); operation.Hide(); main_window.ResumeThreads(); return true; }