45#include <wx/bmpcbox.h>
47#include "wx/dirctrl.h"
48#include <wx/filename.h>
49#include <wx/graphics.h>
51#include <wx/listbook.h>
52#include <wx/listimpl.cpp>
53#include <wx/progdlg.h>
54#include <wx/sstream.h>
56#include <wx/timectrl.h>
57#include <wx/tokenzr.h>
59#include "o_sound/o_sound.h"
67#include "model/geodesic.h"
72#include "model/nav_object_database.h"
102#include "snd_config.h"
110#include "androidUTIL.h"
114static bool g_bLayersLoaded;
121static const long long lNaN = 0xfff8000000000000;
122#define NAN (*(double *)&lNaN)
127wxArrayString *pMessageOnceArray;
129void InitGlobals() { pMessageOnceArray =
new wxArrayString(); }
131void DeinitGlobals() {
132 delete pMessageOnceArray;
133 pMessageOnceArray =
nullptr;
140wxString GetLayerName(
int id) {
141 wxString name(
"unknown layer");
142 if (
id <= 0)
return (name);
143 LayerList::iterator it;
145 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
147 if (lay->m_LayerID ==
id)
return (lay->m_LayerName);
153void appendOSDirSlash(wxString *pString);
160MyConfig::MyConfig(
const wxString &LocalFileName)
161 : wxFileConfig(
"",
"", LocalFileName,
"", wxCONFIG_USE_LOCAL_FILE) {}
163MyConfig::~MyConfig() {}
165int MyConfig::LoadMyConfig() {
166 int display_width, display_height;
172 g_TalkerIdText =
"EC";
173 g_maxWPNameLength = 6;
174 g_NMEAAPBPrecision = 3;
177 g_GLOptions.m_bUseAcceleratedPanning =
true;
178 g_GLOptions.m_GLPolygonSmoothing =
true;
179 g_GLOptions.m_GLLineSmoothing =
true;
180 g_GLOptions.m_iTextureDimension = 512;
181 g_GLOptions.m_iTextureMemorySize = 128;
183 g_GLOptions.m_iTextureMemorySize =
184 wxMax(128, g_GLOptions.m_iTextureMemorySize);
185 g_GLOptions.m_bTextureCompressionCaching =
186 g_GLOptions.m_bTextureCompression;
190 g_maintoolbar_orient = wxTB_HORIZONTAL;
191 g_iENCToolbarPosX = -1;
192 g_iENCToolbarPosY = -1;
193 g_restore_dbindex = -1;
194 g_ChartNotRenderScaleFactor = 1.5;
195 g_detailslider_dialog_x = 200L;
196 g_detailslider_dialog_y = 200L;
197 g_SENC_LOD_pixels = 2;
198 g_SkewCompUpdatePeriod = 10;
200 g_bShowStatusBar = 1;
201 g_bShowCompassWin = 1;
202 g_iSoundDeviceIndex = -1;
203 g_bFullscreenToolbar = 1;
204 g_bTransparentToolbar = 0;
206 g_bShowDepthUnits = 1;
207 g_bShowActiveRouteHighway = 1;
209 g_defaultBoatSpeed = 6.0;
210 g_ownship_predictor_minutes = 5;
211 g_cog_predictor_style = 105;
212 g_cog_predictor_color =
"rgb(255,0,0)";
213 g_cog_predictor_endmarker = 1;
214 g_ownship_HDTpredictor_style = 105;
215 g_ownship_HDTpredictor_color =
"rgb(255,0,0)";
216 g_ownship_HDTpredictor_endmarker = 1;
217 g_ownship_HDTpredictor_width = 0;
218 g_cog_predictor_width = 3;
219 g_ownship_HDTpredictor_miles = 1;
220 g_n_ownship_min_mm = 2;
221 g_own_ship_sog_cog_calc_damp_sec = 1;
222 g_bFullScreenQuilt = 1;
223 g_track_rotate_time_type = TIME_TYPE_COMPUTER;
224 g_bHighliteTracks = 1;
225 g_bPreserveScaleOnX = 1;
227 g_benableAISNameCache =
true;
228 g_n_arrival_circle_radius = 0.05;
229 g_plus_minus_zoom_factor = 2.0;
230 g_mouse_zoom_sensitivity = 1.5;
233 g_AISShowTracks_Mins = 20;
234 g_AISShowTracks_Limit = 300.0;
235 g_ShowScaled_Num = 10;
236 g_ScaledNumWeightSOG = 50;
237 g_ScaledNumWeightCPA = 60;
238 g_ScaledNumWeightTCPA = 25;
239 g_ScaledSizeMinimal = 50;
240 g_ScaledNumWeightRange = 75;
241 g_ScaledNumWeightSizeOfT = 25;
242 g_Show_Target_Name_Scale = 250000;
243 g_bWplUsePosition = 0;
245 g_ais_cog_predictor_width = 3;
246 g_ais_alert_dialog_sx = 200;
247 g_ais_alert_dialog_sy = 200;
248 g_ais_alert_dialog_x = 200;
249 g_ais_alert_dialog_y = 200;
250 g_ais_query_dialog_x = 200;
251 g_ais_query_dialog_y = 200;
252 g_AisTargetList_range = 40;
253 g_AisTargetList_sortColumn = 2;
254 g_S57_dialog_sx = 400;
255 g_S57_dialog_sy = 400;
256 g_S57_extradialog_sx = 400;
257 g_S57_extradialog_sy = 400;
266 g_iNavAidRadarRingsNumberVisible = 0;
267 g_bNavAidRadarRingsShown =
false;
268 g_fNavAidRadarRingsStep = 1.0;
269 g_pNavAidRadarRingsStepUnits = 0;
270 g_colourOwnshipRangeRingsColour = *wxRED;
271 g_iWaypointRangeRingsNumber = 0;
272 g_fWaypointRangeRingsStep = 1.0;
273 g_iWaypointRangeRingsStepUnits = 0;
275 g_bConfirmObjectDelete =
true;
277 g_TrackIntervalSeconds = 60.0;
278 g_TrackDeltaDistance = 0.10;
279 g_route_line_width = 2;
280 g_track_line_width = 2;
281 g_colourTrackLineColour = wxColour(243, 229, 47);
284 g_default_wp_icon =
"triangle";
285 g_default_routepoint_icon =
"diamond";
289 g_ObjQFileExt =
"txt,rtf,png,html,gif,tif,jpg";
292 int ret_Val = LoadMyConfigRaw();
297 g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor);
298 g_ShipScaleFactorExp =
299 g_Platform->GetChartScaleFactorExp(g_ShipScaleFactor);
300 g_MarkScaleFactorExp =
301 g_Platform->GetMarkScaleFactorExp(g_ChartScaleFactor);
303 g_COGFilterSec = wxMin(g_COGFilterSec, MAX_COGSOG_FILTER_SECONDS);
304 g_COGFilterSec = wxMax(g_COGFilterSec, 1);
305 g_SOGFilterSec = g_COGFilterSec;
307 if (!g_bShowTrue && !g_bShowMag) g_bShowTrue =
true;
311 if (g_bInlandEcdis) g_bLookAhead = 1;
313 if (g_bdisable_opengl) g_bopengl =
false;
317 g_GLOptions.m_iTextureMemorySize =
318 wxMax(128, g_GLOptions.m_iTextureMemorySize);
319 g_GLOptions.m_bTextureCompressionCaching =
320 g_GLOptions.m_bTextureCompression;
324 g_chart_zoom_modifier_raster = wxMin(g_chart_zoom_modifier_raster, 5);
325 g_chart_zoom_modifier_raster = wxMax(g_chart_zoom_modifier_raster, -5);
326 g_chart_zoom_modifier_vector = wxMin(g_chart_zoom_modifier_vector, 5);
327 g_chart_zoom_modifier_vector = wxMax(g_chart_zoom_modifier_vector, -5);
328 g_cm93_zoom_factor = wxMin(g_cm93_zoom_factor, CM93_ZOOM_FACTOR_MAX_RANGE);
330 wxMax(g_cm93_zoom_factor, (-CM93_ZOOM_FACTOR_MAX_RANGE));
332 if ((g_detailslider_dialog_x < 0) ||
333 (g_detailslider_dialog_x > display_width))
334 g_detailslider_dialog_x = 5;
335 if ((g_detailslider_dialog_y < 0) ||
336 (g_detailslider_dialog_y > display_height))
337 g_detailslider_dialog_y = 5;
339 g_defaultBoatSpeedUserUnit = toUsrSpeed(g_defaultBoatSpeed, -1);
340 g_n_ownship_min_mm = wxMax(g_n_ownship_min_mm, 2);
342 if (g_navobjbackups > 99) g_navobjbackups = 99;
343 if (g_navobjbackups < 0) g_navobjbackups = 0;
344 g_n_arrival_circle_radius = wxClip(g_n_arrival_circle_radius, 0.001, 0.6);
346 g_selection_radius_mm = wxMax(g_selection_radius_mm, 0.5);
347 g_selection_radius_touch_mm = wxMax(g_selection_radius_touch_mm, 1.0);
349 g_Show_Target_Name_Scale = wxMax(5000, g_Show_Target_Name_Scale);
351 if ((g_ais_alert_dialog_x < 0) || (g_ais_alert_dialog_x > display_width))
352 g_ais_alert_dialog_x = 5;
353 if ((g_ais_alert_dialog_y < 0) || (g_ais_alert_dialog_y > display_height))
354 g_ais_alert_dialog_y = 5;
355 if ((g_ais_query_dialog_x < 0) || (g_ais_query_dialog_x > display_width))
356 g_ais_query_dialog_x = 5;
357 if ((g_ais_query_dialog_y < 0) || (g_ais_query_dialog_y > display_height))
358 g_ais_query_dialog_y = 5;
360 SwitchInlandEcdisMode(g_bInlandEcdis);
362 global_color_scheme =
363 GLOBAL_COLOR_SCHEME_DUSK;
372int MyConfig::LoadMyConfigRaw(
bool bAsTemplate) {
376 int display_width, display_height;
381 SetPath(
"/Settings");
382 Read(
"ActiveRoute", &g_active_route);
383 Read(
"PersistActiveRoute", &g_persist_active_route);
385 Read(
"LastAppliedTemplate", &g_lastAppliedTemplateGUID);
386 Read(
"CompatOS", &g_compatOS);
387 Read(
"CompatOsVersion", &g_compatOsVersion);
390 Read(
"ConfigVersionString", &g_config_version_string);
391 Read(
"CmdSoundString", &g_CmdSoundString, wxString(OCPN_SOUND_CMD));
392 if (wxIsEmpty(g_CmdSoundString)) g_CmdSoundString = wxString(OCPN_SOUND_CMD);
393 Read(
"NavMessageShown", &n_NavMessageShown);
395 Read(
"AndroidVersionCode", &g_AndroidVersionCode);
397 Read(
"UIexpert", &g_bUIexpert);
399 Read(
"UIStyle", &g_uiStyle);
401 Read(
"NCacheLimit", &g_nCacheLimit);
407 Read(
"SpaceDropMark", &g_bSpaceDropMark);
410 Read(
"MEMCacheLimit", &mem_limit);
412 g_memCacheLimit = mem_limit * 1024;
414 Read(
"UseModernUI5", &g_useMUI);
416 Read(
"NCPUCount", &g_nCPUCount);
418 Read(
"DebugGDAL", &g_bGDAL_Debug);
419 Read(
"DebugNMEA", &g_nNMEADebug);
420 Read(
"AnchorWatchDefault", &g_nAWDefault);
421 Read(
"AnchorWatchMax", &g_nAWMax);
422 Read(
"GPSDogTimeout", &gps_watchdog_timeout_ticks);
423 Read(
"DebugCM93", &g_bDebugCM93);
426 Read(
"DebugBSBImg", &g_BSBImgDebug);
427 Read(
"DebugGPSD", &g_bDebugGPSD);
428 Read(
"MaxZoomScale", &g_maxzoomin);
429 g_maxzoomin = wxMax(g_maxzoomin, 50);
431 Read(
"DefaultFontSize", &g_default_font_size);
434 Read(
"UseGreenShipIcon", &g_bUseGreenShip);
436 Read(
"AutoHideToolbar", &g_bAutoHideToolbar);
437 Read(
"AutoHideToolbarSecs", &g_nAutoHideToolbar);
439 Read(
"UseSimplifiedScalebar", &g_bsimplifiedScalebar);
441 Read(
"ShowCurrent", &g_bShowCurrent);
444 Read(
"DisplaySizeMM", &size_mm);
446 Read(
"SelectionRadiusMM", &g_selection_radius_mm);
447 Read(
"SelectionRadiusTouchMM", &g_selection_radius_touch_mm);
451 wxStringTokenizer tokenizer(size_mm,
",");
452 while (tokenizer.HasMoreTokens()) {
453 wxString token = tokenizer.GetNextToken();
456 size = std::stoi(token.ToStdString());
457 }
catch (std::invalid_argument &e) {
460 if (size > 100 && size < 2000) {
466 Read(
"DisplaySizeManual", &g_config_display_size_manual);
469 Read(
"GUIScaleFactor", &g_GUIScaleFactor);
471 Read(
"ChartObjectScaleFactor", &g_ChartScaleFactor);
472 Read(
"ShipScaleFactor", &g_ShipScaleFactor);
473 Read(
"ENCSoundingScaleFactor", &g_ENCSoundingScaleFactor);
474 Read(
"ENCTextScaleFactor", &g_ENCTextScaleFactor);
475 Read(
"ObjQueryAppendFilesExt", &g_ObjQFileExt);
478 Read(
"CatalogCustomURL", &g_catalog_custom_url);
479 Read(
"CatalogChannel", &g_catalog_channel);
481 Read(
"NetmaskBits", &g_netmask_bits);
485 Read(
"FilterNMEA_Avg", &g_bfilter_cogsog);
486 Read(
"FilterNMEA_Sec", &g_COGFilterSec);
487 Read(
"GPSIdent", &g_GPS_Ident);
488 Read(
"UseGarminHostUpload", &g_bGarminHostUpload);
489 Read(
"UseNMEA_GLL", &g_bUseGLL);
490 Read(
"UseMagAPB", &g_bMagneticAPB);
491 Read(
"TrackContinuous", &g_btrackContinuous,
false);
492 Read(
"FilterTrackDropLargeJump", &g_trackFilterMax, 1000);
495 Read(
"ShowTrue", &g_bShowTrue);
496 Read(
"ShowMag", &g_bShowMag);
499 Read(
"UserMagVariation", &umv);
500 if (umv.Len()) umv.ToDouble(&g_UserVar);
502 Read(
"ScreenBrightness", &g_nbrightness);
504 Read(
"MemFootprintTargetMB", &g_MemFootMB);
506 Read(
"WindowsComPortMax", &g_nCOMPortCheck);
508 Read(
"ChartQuilting", &g_bQuiltEnable);
509 Read(
"ChartQuiltingInitial", &g_bQuiltStart);
511 Read(
"CourseUpMode", &g_bCourseUp);
513 Read(
"LookAheadMode", &g_bLookAhead);
514 Read(
"SkewToNorthUp", &g_bskew_comp);
515 Read(
"TenHzUpdate", &g_btenhertz, 0);
516 Read(
"DeclutterAnchorage", &g_declutter_anchorage, 0);
518 Read(
"NMEAAPBPrecision", &g_NMEAAPBPrecision);
520 Read(
"TalkerIdText", &g_TalkerIdText);
521 Read(
"MaxWaypointNameLength", &g_maxWPNameLength);
522 Read(
"MbtilesMaxLayers", &g_mbtilesMaxLayers);
524 Read(
"ShowTrackPointTime", &g_bShowTrackPointTime,
true);
528 Read(
"OpenGLExpert", &g_bGLexpert,
false);
529 Read(
"UseAcceleratedPanning", &g_GLOptions.m_bUseAcceleratedPanning,
true);
530 Read(
"GPUTextureCompression", &g_GLOptions.m_bTextureCompression);
531 Read(
"GPUTextureCompressionCaching",
532 &g_GLOptions.m_bTextureCompressionCaching);
533 Read(
"PolygonSmoothing", &g_GLOptions.m_GLPolygonSmoothing);
534 Read(
"LineSmoothing", &g_GLOptions.m_GLLineSmoothing);
535 Read(
"GPUTextureDimension", &g_GLOptions.m_iTextureDimension);
536 Read(
"GPUTextureMemSize", &g_GLOptions.m_iTextureMemorySize);
537 Read(
"DebugOpenGL", &g_bDebugOGL);
538 Read(
"OpenGL", &g_bopengl);
539 Read(
"SoftwareGL", &g_bSoftwareGL);
545 Read(
"ToolbarX", &g_maintoolbar_x);
546 Read(
"ToolbarY", &g_maintoolbar_y);
547 Read(
"ToolbarOrient", &g_maintoolbar_orient);
548 Read(
"GlobalToolbarConfig", &g_toolbarConfig);
550 Read(
"iENCToolbarX", &g_iENCToolbarPosX);
551 Read(
"iENCToolbarY", &g_iENCToolbarPosY);
553 Read(
"AnchorWatch1GUID", &g_AW1GUID);
554 Read(
"AnchorWatch2GUID", &g_AW2GUID);
556 Read(
"InitialStackIndex", &g_restore_stackindex);
557 Read(
"InitialdBIndex", &g_restore_dbindex);
559 Read(
"ChartNotRenderScaleFactor", &g_ChartNotRenderScaleFactor);
561 Read(
"MobileTouch", &g_btouch);
566 g_bresponsive =
true;
568 g_bresponsive =
false;
573 Read(
"ZoomDetailFactor", &g_chart_zoom_modifier_raster);
574 Read(
"ZoomDetailFactorVector", &g_chart_zoom_modifier_vector);
575 Read(
"PlusMinusZoomFactor", &g_plus_minus_zoom_factor, 2.0);
576 Read(
"MouseZoomSensitivity", &g_mouse_zoom_sensitivity, 1.3);
577 g_mouse_zoom_sensitivity_ui =
579 Read(
"CM93DetailFactor", &g_cm93_zoom_factor);
581 Read(
"CM93DetailZoomPosX", &g_detailslider_dialog_x);
582 Read(
"CM93DetailZoomPosY", &g_detailslider_dialog_y);
583 Read(
"ShowCM93DetailSlider", &g_bShowDetailSlider);
585 Read(
"SENC_LOD_Pixels", &g_SENC_LOD_pixels);
587 Read(
"SkewCompUpdatePeriod", &g_SkewCompUpdatePeriod);
589 Read(
"SetSystemTime", &s_bSetSystemTime);
590 Read(
"EnableKioskStartup", &g_kiosk_startup);
591 Read(
"ShowStatusBar", &g_bShowStatusBar);
593 Read(
"ShowMenuBar", &g_bShowMenuBar);
595 Read(
"Fullscreen", &g_bFullscreen);
596 Read(
"ShowCompassWindow", &g_bShowCompassWin);
598 Read(
"PlayShipsBells", &g_bPlayShipsBells);
599 Read(
"SoundDeviceIndex", &g_iSoundDeviceIndex);
600 Read(
"FullscreenToolbar", &g_bFullscreenToolbar);
601 Read(
"PermanentMOBIcon", &g_bPermanentMOBIcon);
602 Read(
"ShowLayers", &g_bShowLayers);
603 Read(
"ShowDepthUnits", &g_bShowDepthUnits);
604 Read(
"AutoAnchorDrop", &g_bAutoAnchorMark);
605 Read(
"ShowChartOutlines", &g_bShowOutlines);
606 Read(
"ShowActiveRouteHighway", &g_bShowActiveRouteHighway);
607 Read(
"ShowActiveRouteTotal", &g_bShowRouteTotal);
608 Read(
"MostRecentGPSUploadConnection", &g_uploadConnection);
609 Read(
"ShowChartBar", &g_bShowChartBar);
614 Read(
"DistanceFormat",
619 Read(
"WindSpeedFormat",
620 &g_iWindSpeedFormat);
625 Read(
"LiveETA", &g_bShowLiveETA);
626 Read(
"DefaultBoatSpeed", &g_defaultBoatSpeed);
628 Read(
"OwnshipCOGPredictorMinutes", &g_ownship_predictor_minutes);
629 Read(
"OwnshipCOGPredictorStyle", &g_cog_predictor_style);
630 Read(
"OwnshipCOGPredictorColor", &g_cog_predictor_color);
631 Read(
"OwnshipCOGPredictorEndmarker", &g_cog_predictor_endmarker);
632 Read(
"OwnshipCOGPredictorWidth", &g_cog_predictor_width);
633 Read(
"OwnshipHDTPredictorStyle", &g_ownship_HDTpredictor_style);
634 Read(
"OwnshipHDTPredictorColor", &g_ownship_HDTpredictor_color);
635 Read(
"OwnshipHDTPredictorEndmarker", &g_ownship_HDTpredictor_endmarker);
636 Read(
"OwnshipHDTPredictorWidth", &g_ownship_HDTpredictor_width);
637 Read(
"OwnshipHDTPredictorMiles", &g_ownship_HDTpredictor_miles);
639 Read(
"OwnShipMMSINumber", &mmsi);
641 Read(
"OwnShipIconType", &g_OwnShipIconType);
642 Read(
"OwnShipLength", &g_n_ownship_length_meters);
643 Read(
"OwnShipWidth", &g_n_ownship_beam_meters);
644 Read(
"OwnShipGPSOffsetX", &g_n_gps_antenna_offset_x);
645 Read(
"OwnShipGPSOffsetY", &g_n_gps_antenna_offset_y);
646 Read(
"OwnShipMinSize", &g_n_ownship_min_mm);
647 Read(
"OwnShipSogCogCalc", &g_own_ship_sog_cog_calc);
648 Read(
"OwnShipSogCogCalcDampSec", &g_own_ship_sog_cog_calc_damp_sec);
649 Read(
"ShowDirectRouteLine", &g_bShowShipToActive);
650 Read(
"DirectRouteLineStyle", &g_shipToActiveStyle);
651 Read(
"DirectRouteLineColor", &g_shipToActiveColor);
654 Read(
"RouteArrivalCircleRadius", &racr);
655 if (racr.Len()) racr.ToDouble(&g_n_arrival_circle_radius);
657 Read(
"FullScreenQuilt", &g_bFullScreenQuilt);
659 Read(
"StartWithTrackActive", &g_bTrackCarryOver);
660 Read(
"AutomaticDailyTracks", &g_bTrackDaily);
661 Read(
"TrackRotateAt", &g_track_rotate_time);
662 Read(
"TrackRotateTimeType", &g_track_rotate_time_type);
663 Read(
"HighlightTracks", &g_bHighliteTracks);
668 Read(
"PlanSpeed", &stps);
669 if (!stps.IsEmpty()) stps.ToDouble(&g_PlanSpeed);
671 Read(
"VisibleLayers", &g_VisibleLayers);
672 Read(
"InvisibleLayers", &g_InvisibleLayers);
673 Read(
"VisNameInLayers", &g_VisiNameinLayers);
674 Read(
"InvisNameInLayers", &g_InVisiNameinLayers);
676 Read(
"PreserveScaleOnX", &g_bPreserveScaleOnX);
678 Read(
"ShowMUIZoomButtons", &g_bShowMuiZoomButtons);
680 Read(
"Locale", &g_locale);
681 Read(
"LocaleOverride", &g_localeOverride);
684 Read(
"KeepNavobjBackups", &g_navobjbackups);
688 Read(
"LegacyInputCOMPortFilterBehaviour", &g_b_legacy_input_filter_behaviour);
691 Read(
"AdvanceRouteWaypointOnArrivalOnly",
692 &g_bAdvanceRouteWaypointOnArrivalOnly);
693 Read(
"EnableRootMenuDebug", &g_enable_root_menu_debug);
695 Read(
"EnableRotateKeys", &g_benable_rotate);
696 Read(
"EmailCrashReport", &g_bEmailCrashReport);
698 g_benableAISNameCache =
true;
699 Read(
"EnableAISNameCache", &g_benableAISNameCache);
701 Read(
"EnableUDPNullHeader", &g_benableUDPNullHeader);
703 SetPath(
"/Settings/GlobalState");
705 Read(
"FrameWinX", &g_nframewin_x);
706 Read(
"FrameWinY", &g_nframewin_y);
707 Read(
"FrameWinPosX", &g_nframewin_posx);
708 Read(
"FrameWinPosY", &g_nframewin_posy);
709 Read(
"FrameMax", &g_bframemax);
711 Read(
"ClientPosX", &g_lastClientRectx);
712 Read(
"ClientPosY", &g_lastClientRecty);
713 Read(
"ClientSzX", &g_lastClientRectw);
714 Read(
"ClientSzY", &g_lastClientRecth);
716 Read(
"RoutePropSizeX", &g_route_prop_sx);
717 Read(
"RoutePropSizeY", &g_route_prop_sy);
718 Read(
"RoutePropPosX", &g_route_prop_x);
719 Read(
"RoutePropPosY", &g_route_prop_y);
721 Read(
"AllowArbitrarySystemPlugins", &g_allow_arb_system_plugin);
724 Read(
"S52_DEPTH_UNIT_SHOW", &read_int);
726 read_int = wxMax(read_int, 0);
727 read_int = wxMin(read_int, 2);
732 SetPath(
"/Settings/Audio");
735 wxString sound_dir = g_Platform->GetSharedDataDir();
736 sound_dir.Append(
"sounds");
737 sound_dir.Append(wxFileName::GetPathSeparator());
739 g_AIS_sound_file = sound_dir +
"beep_ssl.wav";
740 g_DSC_sound_file = sound_dir +
"phonering1.wav";
741 g_SART_sound_file = sound_dir +
"beep3.wav";
742 g_anchorwatch_sound_file = sound_dir +
"beep1.wav";
744 Read(
"AISAlertSoundFile", &g_AIS_sound_file);
745 Read(
"DSCAlertSoundFile", &g_DSC_sound_file);
746 Read(
"SARTAlertSoundFile", &g_SART_sound_file);
747 Read(
"AnchorAlarmSoundFile", &g_anchorwatch_sound_file);
749 Read(
"bAIS_GCPA_AlertAudio", &g_bAIS_GCPA_Alert_Audio);
750 Read(
"bAIS_SART_AlertAudio", &g_bAIS_SART_Alert_Audio);
751 Read(
"bAIS_DSC_AlertAudio", &g_bAIS_DSC_Alert_Audio);
752 Read(
"bAnchorAlertAudio", &g_bAnchor_Alert_Audio);
756 SetPath(
"/Settings/AIS");
758 g_bUseOnlyConfirmedAISName =
false;
759 Read(
"UseOnlyConfirmedAISName", &g_bUseOnlyConfirmedAISName);
761 Read(
"bNoCPAMax", &g_bCPAMax);
763 Read(
"NoCPAMaxNMi", &s);
764 s.ToDouble(&g_CPAMax_NM);
766 Read(
"bCPAWarn", &g_bCPAWarn);
768 Read(
"CPAWarnNMi", &s);
769 s.ToDouble(&g_CPAWarn_NM);
771 Read(
"bTCPAMax", &g_bTCPA_Max);
773 Read(
"TCPAMaxMinutes", &s);
774 s.ToDouble(&g_TCPA_Max);
776 Read(
"bMarkLostTargets", &g_bMarkLost);
778 Read(
"MarkLost_Minutes", &s);
779 s.ToDouble(&g_MarkLost_Mins);
781 Read(
"bRemoveLostTargets", &g_bRemoveLost);
783 Read(
"RemoveLost_Minutes", &s);
784 s.ToDouble(&g_RemoveLost_Mins);
786 Read(
"bShowCOGArrows", &g_bShowCOG);
788 Read(
"bSyncCogPredictors", &g_bSyncCogPredictors);
790 Read(
"CogArrowMinutes", &s);
791 s.ToDouble(&g_ShowCOG_Mins);
793 Read(
"bShowTargetTracks", &g_bAISShowTracks);
795 if (
Read(
"TargetTracksLimit", &s)) {
796 s.ToDouble(&g_AISShowTracks_Limit);
797 g_AISShowTracks_Limit = wxMax(300.0, g_AISShowTracks_Limit);
799 if (
Read(
"TargetTracksMinutes", &s)) {
800 s.ToDouble(&g_AISShowTracks_Mins);
801 g_AISShowTracks_Mins = wxMax(1.0, g_AISShowTracks_Mins);
802 g_AISShowTracks_Mins = wxMin(g_AISShowTracks_Limit, g_AISShowTracks_Mins);
805 Read(
"bHideMooredTargets", &g_bHideMoored);
806 if (
Read(
"MooredTargetMaxSpeedKnots", &s)) s.ToDouble(&g_ShowMoored_Kts);
808 g_SOGminCOG_kts = 0.2;
809 if (
Read(
"SOGMinimumForCOGDisplay", &s)) s.ToDouble(&g_SOGminCOG_kts);
811 Read(
"bShowScaledTargets", &g_bAllowShowScaled);
812 Read(
"AISScaledNumber", &g_ShowScaled_Num);
813 Read(
"AISScaledNumberWeightSOG", &g_ScaledNumWeightSOG);
814 Read(
"AISScaledNumberWeightCPA", &g_ScaledNumWeightCPA);
815 Read(
"AISScaledNumberWeightTCPA", &g_ScaledNumWeightTCPA);
816 Read(
"AISScaledNumberWeightRange", &g_ScaledNumWeightRange);
817 Read(
"AISScaledNumberWeightSizeOfTarget", &g_ScaledNumWeightSizeOfT);
818 Read(
"AISScaledSizeMinimal", &g_ScaledSizeMinimal);
819 Read(
"AISShowScaled", &g_bShowScaled);
821 Read(
"bShowAreaNotices", &g_bShowAreaNotices);
822 Read(
"bDrawAISSize", &g_bDrawAISSize);
823 Read(
"bDrawAISRealtime", &g_bDrawAISRealtime);
824 Read(
"bShowAISName", &g_bShowAISName);
825 Read(
"AISRealtimeMinSpeedKnots", &g_AIS_RealtPred_Kts, 0.7);
826 Read(
"bAISAlertDialog", &g_bAIS_CPA_Alert);
827 Read(
"ShowAISTargetNameScale", &g_Show_Target_Name_Scale);
828 Read(
"bWplIsAprsPositionReport", &g_bWplUsePosition);
829 Read(
"WplSelAction", &g_WplAction);
830 Read(
"AISCOGPredictorWidth", &g_ais_cog_predictor_width);
832 Read(
"bAISAlertAudio", &g_bAIS_CPA_Alert_Audio);
833 Read(
"AISAlertAudioFile", &g_sAIS_Alert_Sound_File);
834 Read(
"bAISAlertSuppressMoored", &g_bAIS_CPA_Alert_Suppress_Moored);
836 Read(
"bAISAlertAckTimeout", &g_bAIS_ACK_Timeout);
837 if (
Read(
"AlertAckTimeoutMinutes", &s)) s.ToDouble(&g_AckTimeout_Mins);
839 Read(
"AlertDialogSizeX", &g_ais_alert_dialog_sx);
840 Read(
"AlertDialogSizeY", &g_ais_alert_dialog_sy);
841 Read(
"AlertDialogPosX", &g_ais_alert_dialog_x);
842 Read(
"AlertDialogPosY", &g_ais_alert_dialog_y);
843 Read(
"QueryDialogPosX", &g_ais_query_dialog_x);
844 Read(
"QueryDialogPosY", &g_ais_query_dialog_y);
846 Read(
"AISTargetListPerspective", &g_AisTargetList_perspective);
847 Read(
"AISTargetListRange", &g_AisTargetList_range);
848 Read(
"AISTargetListSortColumn", &g_AisTargetList_sortColumn);
849 Read(
"bAISTargetListSortReverse", &g_bAisTargetList_sortReverse);
850 Read(
"AISTargetListColumnSpec", &g_AisTargetList_column_spec);
851 Read(
"AISTargetListColumnOrder", &g_AisTargetList_column_order);
853 Read(
"bAISRolloverShowClass", &g_bAISRolloverShowClass);
854 Read(
"bAISRolloverShowCOG", &g_bAISRolloverShowCOG);
855 Read(
"bAISRolloverShowCPA", &g_bAISRolloverShowCPA);
856 Read(
"AISAlertDelay", &g_AIS_alert_delay);
858 Read(
"S57QueryDialogSizeX", &g_S57_dialog_sx);
859 Read(
"S57QueryDialogSizeY", &g_S57_dialog_sy);
860 Read(
"S57QueryExtraDialogSizeX", &g_S57_extradialog_sx);
861 Read(
"S57QueryExtraDialogSizeY", &g_S57_extradialog_sy);
863 wxString strpres(
"PresentationLibraryData");
865 SetPath(
"/Directories");
866 Read(strpres, &valpres);
867 if (!valpres.IsEmpty()) g_UserPresLibData = valpres;
869 wxString strs(
"SENCFileLocation");
870 SetPath(
"/Directories");
873 if (!vals.IsEmpty()) g_SENCPrefix = vals;
875 SetPath(
"/Directories");
877 Read(
"InitChartDir", &vald);
879 wxString dirnamed(vald);
880 if (!dirnamed.IsEmpty()) {
881 if (pInit_Chart_Dir->IsEmpty())
883 pInit_Chart_Dir->Clear();
884 pInit_Chart_Dir->Append(vald);
888 Read(
"GPXIODir", &g_gpx_path);
889 Read(
"TCDataDir", &g_TCData_Dir);
890 Read(
"BasemapDir", &gWorldMapLocation);
891 Read(
"BaseShapefileDir", &gWorldShapefileLocation);
893 wxLogMessage(
"winPluginDir, read from ini file: %s",
896 SetPath(
"/Settings/GlobalState");
898 if (
Read(
"nColorScheme", &read_int))
899 global_color_scheme = (ColorScheme)read_int;
902 SetPath(
"/Settings/NMEADataSource");
904 TheConnectionParams().clear();
905 wxString connectionconfigs;
906 Read(
"DataConnections", &connectionconfigs);
907 if (!connectionconfigs.IsEmpty()) {
908 wxArrayString confs = wxStringTokenize(connectionconfigs,
"|");
909 for (
size_t i = 0; i < confs.Count(); i++) {
912 wxLogMessage(
"Skipped invalid DataStream config");
916 TheConnectionParams().push_back(prm);
921 SetPath(
"/Settings/GlobalState");
924 double st_lat, st_lon;
925 if (
Read(
"VPLatLon", &st)) {
926 sscanf(st.mb_str(wxConvUTF8),
"%lf,%lf", &st_lat, &st_lon);
929 if (fabs(st_lon) < 360.) {
930 while (st_lon < -180.) st_lon += 360.;
932 while (st_lon > 180.) st_lon -= 360.;
937 if (fabs(st_lat) < 90.0)
vLat = st_lat;
939 s.Printf(
"Setting Viewpoint Lat/Lon %g, %g",
vLat,
vLon);
943 double st_view_scale, st_rotation;
944 if (
Read(wxString(
"VPScale"), &st)) {
945 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_view_scale);
947 st_view_scale = fmax(st_view_scale, .001 / 32);
948 st_view_scale = fmin(st_view_scale, 4);
951 if (
Read(wxString(
"VPRotation"), &st)) {
952 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_rotation);
954 st_rotation = fmin(st_rotation, 360);
955 st_rotation = fmax(st_rotation, 0);
960 if (
Read(
"OwnShipLatLon", &sll)) {
961 sscanf(sll.mb_str(wxConvUTF8),
"%lf,%lf", &lat, &lon);
964 if (fabs(lon) < 360.) {
965 while (lon < -180.) lon += 360.;
967 while (lon > 180.) lon -= 360.;
972 if (fabs(lat) < 90.0)
gLat = lat;
974 s.Printf(
"Setting Ownship Lat/Lon %g, %g",
gLat,
gLon);
981 SetPath(
"/Settings/AuxFontKeys");
986 bool bContk = GetFirstEntry(strk, dummyk);
987 bool bNewKey =
false;
990 bNewKey = FontMgr::Get().
AddAuxKey(kval);
991 if (!bAsTemplate && !bNewKey) {
995 bContk = GetNextEntry(strk, dummyk);
999 SetPath(
"/Settings/X11Fonts");
1003 SetPath(
"/Settings/GTKFonts");
1007 SetPath(
"/Settings/MSWFonts");
1011 SetPath(
"/Settings/MacFonts");
1015 SetPath(
"/Settings/QTFonts");
1021 wxArrayString deleteList;
1023 bool bCont = GetFirstEntry(str, dummy);
1027 if (str.StartsWith(
"Font")) {
1030 deleteList.Add(str);
1031 wxString oldKey = pval.BeforeFirst(_T(
':'));
1035 if (pval.IsEmpty() || pval.StartsWith(
":")) {
1036 deleteList.Add(str);
1040 bCont = GetNextEntry(str, dummy);
1043 for (
unsigned int i = 0; i < deleteList.Count(); i++) {
1044 DeleteEntry(deleteList[i]);
1049 SetPath(
"/TideCurrentDataSources");
1050 if (GetNumberOfEntries()) {
1051 TideCurrentDataSet.clear();
1054 bool bCont = GetFirstEntry(str, dummy);
1061 if (std::find(TideCurrentDataSet.begin(), TideCurrentDataSet.end(),
1062 val.ToStdString()) == TideCurrentDataSet.end()) {
1063 TideCurrentDataSet.push_back(val.ToStdString());
1065 bCont = GetNextEntry(str, dummy);
1075 SetPath(
"/Settings/Others");
1078 Read(
"RadarRingsNumberVisible", &val);
1079 if (val.Length() > 0) g_iNavAidRadarRingsNumberVisible = atoi(val.mb_str());
1080 g_bNavAidRadarRingsShown = g_iNavAidRadarRingsNumberVisible > 0;
1082 Read(
"RadarRingsStep", &val);
1083 if (val.Length() > 0) g_fNavAidRadarRingsStep = atof(val.mb_str());
1085 Read(
"RadarRingsStepUnits", &g_pNavAidRadarRingsStepUnits);
1087 wxString l_wxsOwnshipRangeRingsColour;
1088 Read(
"RadarRingsColour", &l_wxsOwnshipRangeRingsColour);
1089 if (l_wxsOwnshipRangeRingsColour.Length())
1090 g_colourOwnshipRangeRingsColour.Set(l_wxsOwnshipRangeRingsColour);
1093 Read(
"WaypointRangeRingsNumber", &val);
1094 if (val.Length() > 0) g_iWaypointRangeRingsNumber = atoi(val.mb_str());
1096 Read(
"WaypointRangeRingsStep", &val);
1097 if (val.Length() > 0) g_fWaypointRangeRingsStep = atof(val.mb_str());
1099 Read(
"WaypointRangeRingsStepUnits", &g_iWaypointRangeRingsStepUnits);
1101 wxString l_wxsWaypointRangeRingsColour;
1102 Read(
"WaypointRangeRingsColour", &l_wxsWaypointRangeRingsColour);
1105 if (!
Read(
"WaypointUseScaMin", &g_bUseWptScaMin)) g_bUseWptScaMin =
false;
1106 if (!
Read(
"WaypointScaMinValue", &g_iWpt_ScaMin)) g_iWpt_ScaMin = 2147483646;
1107 if (!
Read(
"WaypointUseScaMinOverrule", &g_bOverruleScaMin))
1108 g_bOverruleScaMin =
false;
1109 if (!
Read(
"WaypointsShowName", &g_bShowWptName)) g_bShowWptName =
true;
1110 if (!
Read(
"UserIconsFirst", &g_bUserIconsFirst)) g_bUserIconsFirst =
true;
1113 bool b300RadarRings =
true;
1114 if (
Read(
"ShowRadarRings", &b300RadarRings)) {
1115 if (!b300RadarRings) g_iNavAidRadarRingsNumberVisible = 0;
1118 Read(
"ConfirmObjectDeletion", &g_bConfirmObjectDelete);
1121 g_bWayPointPreventDragging =
false;
1122 Read(
"WaypointPreventDragging", &g_bWayPointPreventDragging);
1124 g_bEnableZoomToCursor =
false;
1125 Read(
"EnableZoomToCursor", &g_bEnableZoomToCursor);
1128 Read(
"TrackIntervalSeconds", &val);
1129 if (val.Length() > 0) {
1130 double tval = atof(val.mb_str());
1131 if (tval >= 2.) g_TrackIntervalSeconds = tval;
1135 Read(
"TrackDeltaDistance", &val);
1136 if (val.Length() > 0) {
1137 double tval = atof(val.mb_str());
1138 if (tval >= 0.05) g_TrackDeltaDistance = tval;
1141 Read(
"TrackPrecision", &g_nTrackPrecision);
1143 Read(
"RouteLineWidth", &g_route_line_width);
1144 Read(
"TrackLineWidth", &g_track_line_width);
1146 wxString l_wxsTrackLineColour;
1147 if (
Read(
"TrackLineColour", &l_wxsTrackLineColour))
1148 g_colourTrackLineColour.Set(l_wxsTrackLineColour);
1150 Read(
"TideCurrentWindowScale", &g_tcwin_scale);
1151 Read(
"DefaultWPIcon", &g_default_wp_icon);
1152 Read(
"DefaultRPIcon", &g_default_routepoint_icon);
1154 SetPath(
"/MmsiProperties");
1155 int iPMax = GetNumberOfEntries();
1160 bool bCont =
pConfig->GetFirstEntry(str, dummy);
1167 bCont =
pConfig->GetNextEntry(str, dummy);
1174void MyConfig::LoadS57Config() {
1175 if (!ps52plib)
return;
1179 SetPath(
"/Settings/GlobalState");
1181 Read(
"bShowS57Text", &read_int, 1);
1182 ps52plib->SetShowS57Text(!(read_int == 0));
1184 Read(
"bShowS57ImportantTextOnly", &read_int, 0);
1185 ps52plib->SetShowS57ImportantTextOnly(!(read_int == 0));
1187 Read(
"bShowLightDescription", &read_int, 0);
1188 ps52plib->SetShowLdisText(!(read_int == 0));
1190 Read(
"bExtendLightSectors", &read_int, 0);
1191 ps52plib->SetExtendLightSectors(!(read_int == 0));
1193 Read(
"nDisplayCategory", &read_int, (
enum _DisCat)STANDARD);
1194 ps52plib->SetDisplayCategory((
enum _DisCat)read_int);
1196 Read(
"nSymbolStyle", &read_int, (
enum _LUPname)PAPER_CHART);
1197 ps52plib->m_nSymbolStyle = (LUPname)read_int;
1199 Read(
"nBoundaryStyle", &read_int, PLAIN_BOUNDARIES);
1200 ps52plib->m_nBoundaryStyle = (LUPname)read_int;
1202 Read(
"bShowSoundg", &read_int, 1);
1203 ps52plib->m_bShowSoundg = !(read_int == 0);
1205 Read(
"bShowMeta", &read_int, 0);
1206 ps52plib->m_bShowMeta = !(read_int == 0);
1208 Read(
"bUseSCAMIN", &read_int, 1);
1209 ps52plib->m_bUseSCAMIN = !(read_int == 0);
1211 Read(
"bUseSUPER_SCAMIN", &read_int, 0);
1212 ps52plib->m_bUseSUPER_SCAMIN = !(read_int == 0);
1214 Read(
"bShowAtonText", &read_int, 1);
1215 ps52plib->m_bShowAtonText = !(read_int == 0);
1217 Read(
"bDeClutterText", &read_int, 0);
1218 ps52plib->m_bDeClutterText = !(read_int == 0);
1220 Read(
"bShowNationalText", &read_int, 0);
1221 ps52plib->m_bShowNationalTexts = !(read_int == 0);
1223 Read(
"ENCSoundingScaleFactor", &read_int, 0);
1224 ps52plib->m_nSoundingFactor = read_int;
1226 Read(
"ENCTextScaleFactor", &read_int, 0);
1227 ps52plib->m_nTextFactor = read_int;
1229 if (
Read(
"S52_MAR_SAFETY_CONTOUR", &dval, 3.0)) {
1230 S52_setMarinerParam(S52_MAR_SAFETY_CONTOUR, dval);
1231 S52_setMarinerParam(S52_MAR_SAFETY_DEPTH,
1235 if (
Read(
"S52_MAR_SHALLOW_CONTOUR", &dval, 2.0))
1236 S52_setMarinerParam(S52_MAR_SHALLOW_CONTOUR, dval);
1238 if (
Read(
"S52_MAR_DEEP_CONTOUR", &dval, 6.0))
1239 S52_setMarinerParam(S52_MAR_DEEP_CONTOUR, dval);
1241 if (
Read(
"S52_MAR_TWO_SHADES", &dval, 0.0))
1242 S52_setMarinerParam(S52_MAR_TWO_SHADES, dval);
1244 ps52plib->UpdateMarinerParams();
1246 SetPath(
"/Settings/GlobalState");
1247 Read(
"S52_DEPTH_UNIT_SHOW", &read_int, 1);
1248 read_int = wxMax(read_int, 0);
1249 read_int = wxMin(read_int, 2);
1250 ps52plib->m_nDepthUnitDisplay = read_int;
1257 SetPath(
"/Settings/ObjectFilter");
1259 int iOBJMax = GetNumberOfEntries();
1267 bool bCont =
pConfig->GetFirstEntry(str, dummy);
1271 bool bNeedNew =
true;
1273 if (str.StartsWith(
"viz", &sObj)) {
1274 for (
unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
1276 pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
1277 if (!strncmp(pOLE->OBJLName, sObj.mb_str(), 6)) {
1285 pOLE = (OBJLElement *)calloc(
sizeof(OBJLElement), 1);
1286 memcpy(pOLE->OBJLName, sObj.mb_str(), OBJL_NAME_LEN);
1289 ps52plib->pOBJLArray->Add((
void *)pOLE);
1292 bCont =
pConfig->GetNextEntry(str, dummy);
1297bool MyConfig::LoadLayers(wxString &path) {
1298 wxArrayString file_array;
1302 if (dir.IsOpened()) {
1304 bool cont = dir.GetFirst(&filename);
1307 filename.Prepend(wxFileName::GetPathSeparator());
1308 filename.Prepend(path);
1309 wxFileName f(filename);
1311 if (f.GetExt().IsSameAs(
"gpx"))
1312 file_array.Add(filename);
1314 if (wxDir::Exists(filename)) {
1315 wxDir dir(filename);
1316 if (dir.IsOpened()) {
1317 nfiles = dir.GetAllFiles(filename, &file_array,
1323 if (file_array.GetCount()) {
1326 l->m_LayerFileName = file_array[0];
1327 if (file_array.GetCount() <= 1)
1328 wxFileName::SplitPath(file_array[0], NULL, NULL, &(l->m_LayerName),
1331 wxFileName::SplitPath(filename, NULL, NULL, &(l->m_LayerName), NULL,
1334 bool bLayerViz = g_bShowLayers;
1336 if (g_VisibleLayers.Contains(l->m_LayerName)) bLayerViz =
true;
1337 if (g_InvisibleLayers.Contains(l->m_LayerName)) bLayerViz =
false;
1339 l->m_bHasVisibleNames = wxCHK_UNDETERMINED;
1340 if (g_VisiNameinLayers.Contains(l->m_LayerName))
1341 l->m_bHasVisibleNames = wxCHK_CHECKED;
1342 if (g_InVisiNameinLayers.Contains(l->m_LayerName))
1343 l->m_bHasVisibleNames = wxCHK_UNCHECKED;
1345 l->m_bIsVisibleOnChart = bLayerViz;
1348 laymsg.Printf(
"New layer %d: %s", l->m_LayerID, l->m_LayerName.c_str());
1349 wxLogMessage(laymsg);
1351 pLayerList->insert(pLayerList->begin(), l);
1355 for (
unsigned int i = 0; i < file_array.GetCount(); i++) {
1356 wxString file_path = file_array[i];
1358 if (::wxFileExists(file_path)) {
1360 if (pSet->load_file(file_path.fn_str()).status !=
1361 pugi::xml_parse_status::status_ok) {
1362 wxLogMessage(
"Error loading GPX file " + file_path);
1365 long nItems = pSet->LoadAllGPXObjectsAsLayer(
1366 l->m_LayerID, bLayerViz, l->m_bHasVisibleNames);
1367 l->m_NoOfItems += nItems;
1368 l->m_LayerType = _(
"Persistent");
1371 objmsg.Printf(
"Loaded GPX file %s with %ld items.",
1372 file_path.c_str(), nItems);
1373 wxLogMessage(objmsg);
1380 cont = dir.GetNext(&filename);
1383 g_bLayersLoaded =
true;
1388bool MyConfig::LoadChartDirArray(ArrayOfCDI &ChartDirArray) {
1390 SetPath(
"/ChartDirectories");
1391 int iDirMax = GetNumberOfEntries();
1393 ChartDirArray.Empty();
1396 int nAdjustChartDirs = 0;
1398 bool bCont =
pConfig->GetFirstEntry(str, dummy);
1402 wxString dirname(val);
1403 if (!dirname.IsEmpty()) {
1418 if (dirname.Find(
"SampleCharts") ==
1424 wxString new_dir = dirname.Mid(dirname.Find(
"SampleCharts"));
1425 new_dir.Prepend(g_Platform->GetSharedDataDir());
1430 cdi.fullpath = dirname.BeforeFirst(
'^');
1431 cdi.magic_number = dirname.AfterFirst(
'^');
1433 ChartDirArray.Add(cdi);
1437 bCont =
pConfig->GetNextEntry(str, dummy);
1440 if (nAdjustChartDirs)
pConfig->UpdateChartDirs(ChartDirArray);
1446bool MyConfig::UpdateChartDirs(ArrayOfCDI &dir_array) {
1450 SetPath(
"/ChartDirectories");
1451 int iDirMax = GetNumberOfEntries();
1455 for (
int i = 0; i < iDirMax; i++) {
1456 GetFirstEntry(key, dummy);
1457 DeleteEntry(key,
false);
1461 iDirMax = dir_array.GetCount();
1463 for (
int iDir = 0; iDir < iDirMax; iDir++) {
1466 wxString dirn = cdi.fullpath;
1468 dirn.Append(cdi.magic_number);
1470 str_buf.Printf(
"ChartDir%d", iDir + 1);
1472 Write(str_buf, dirn);
1484void MyConfig::CreateConfigGroups(ChartGroupArray *pGroupArray) {
1485 if (!pGroupArray)
return;
1488 Write(
"GroupCount", (
int)pGroupArray->GetCount());
1490 for (
unsigned int i = 0; i < pGroupArray->GetCount(); i++) {
1493 s.Printf(
"Group%d", i + 1);
1494 s.Prepend(
"/Groups/");
1497 Write(
"GroupName", pGroup->m_group_name);
1498 Write(
"GroupItemCount", (
int)pGroup->m_element_array.size());
1500 for (
unsigned int j = 0; j < pGroup->m_element_array.size(); j++) {
1502 sg.Printf(
"Group%d/Item%d", i + 1, j);
1503 sg.Prepend(
"/Groups/");
1505 Write(
"IncludeItem", pGroup->m_element_array[j].m_element_name);
1508 wxArrayString u = pGroup->m_element_array[j].m_missing_name_array;
1510 for (
unsigned int k = 0; k < u.GetCount(); k++) {
1514 Write(
"ExcludeItems", t);
1520void MyConfig::DestroyConfigGroups() {
1521 DeleteGroup(
"/Groups");
1524void MyConfig::LoadConfigGroups(ChartGroupArray *pGroupArray) {
1526 unsigned int group_count;
1527 Read(
"GroupCount", (
int *)&group_count, 0);
1529 for (
unsigned int i = 0; i < group_count; i++) {
1532 s.Printf(
"Group%d", i + 1);
1533 s.Prepend(
"/Groups/");
1537 Read(
"GroupName", &t);
1538 pGroup->m_group_name = t;
1540 unsigned int item_count;
1541 Read(
"GroupItemCount", (
int *)&item_count);
1542 for (
unsigned int j = 0; j < item_count; j++) {
1544 sg.Printf(
"Group%d/Item%d", i + 1, j);
1545 sg.Prepend(
"/Groups/");
1549 Read(
"IncludeItem", &v);
1553 if (
Read(
"ExcludeItems", &u)) {
1555 wxStringTokenizer tk(u,
";");
1556 while (tk.HasMoreTokens()) {
1557 wxString token = tk.GetNextToken();
1558 pelement.m_missing_name_array.Add(token);
1562 pGroup->m_element_array.push_back(std::move(pelement));
1564 pGroupArray->Add(pGroup);
1568void MyConfig::LoadCanvasConfigs(
bool bApplyAsTemplate) {
1571 auto &config_array = ConfigMgr::Get().GetCanvasConfigArray();
1576 if (!HasEntry(
"CanvasConfig")) {
1578 pcc->LoadFromLegacyConfig(
this);
1579 config_array.Add(pcc);
1584 Read(
"CanvasConfig", (
int *)&g_canvasConfig, 0);
1587 if (config_array.GetCount() == 0) {
1588 s.Printf(
"/Canvas/CanvasConfig%d", 1);
1591 LoadConfigCanvas(pcca, bApplyAsTemplate);
1592 config_array.Add(pcca);
1594 s.Printf(
"/Canvas/CanvasConfig%d", 2);
1597 LoadConfigCanvas(pcca, bApplyAsTemplate);
1598 config_array.Add(pcca);
1601 s.Printf(
"/Canvas/CanvasConfig%d", 1);
1603 LoadConfigCanvas(pcca, bApplyAsTemplate);
1605 if (config_array.GetCount() > 1) {
1607 s.Printf(
"/Canvas/CanvasConfig%d", 2);
1609 LoadConfigCanvas(pcca, bApplyAsTemplate);
1611 s.Printf(
"/Canvas/CanvasConfig%d", 2);
1614 LoadConfigCanvas(pcca, bApplyAsTemplate);
1615 config_array.Add(pcca);
1620void MyConfig::LoadConfigCanvas(
canvasConfig *cConfig,
bool bApplyAsTemplate) {
1622 double st_lat, st_lon;
1624 if (!bApplyAsTemplate) {
1626 cConfig->
iLat = START_LAT;
1627 cConfig->
iLon = START_LON;
1629 if (
Read(
"canvasVPLatLon", &st)) {
1630 sscanf(st.mb_str(wxConvUTF8),
"%lf,%lf", &st_lat, &st_lon);
1633 if (fabs(st_lon) < 360.) {
1634 while (st_lon < -180.) st_lon += 360.;
1636 while (st_lon > 180.) st_lon -= 360.;
1638 cConfig->
iLon = st_lon;
1641 if (fabs(st_lat) < 90.0) cConfig->
iLat = st_lat;
1647 double st_view_scale;
1648 if (
Read(wxString(
"canvasVPScale"), &st)) {
1649 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_view_scale);
1651 st_view_scale = fmax(st_view_scale, .001 / 32);
1652 st_view_scale = fmin(st_view_scale, 4);
1653 cConfig->
iScale = st_view_scale;
1657 if (
Read(wxString(
"canvasVPRotation"), &st)) {
1658 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_rotation);
1660 st_rotation = fmin(st_rotation, 360);
1661 st_rotation = fmax(st_rotation, 0);
1662 cConfig->
iRotation = st_rotation * PI / 180.;
1665 Read(
"canvasInitialdBIndex", &cConfig->DBindex, 0);
1673 Read(
"ActiveChartGroup", &cConfig->GroupID, 0);
1676 if (cConfig->GroupID && bApplyAsTemplate) {
1677 if (cConfig->GroupID > (
int)
g_pGroupArray->GetCount()) cConfig->GroupID = 0;
1693 Read(
"canvasENCDisplayCategory", &cConfig->nENCDisplayCategory, STANDARD);
1694 Read(
"canvasENCShowDepths", &cConfig->bShowENCDepths, 1);
1695 Read(
"canvasENCShowBuoyLabels", &cConfig->bShowENCBuoyLabels, 1);
1696 Read(
"canvasENCShowLightDescriptions", &cConfig->bShowENCLightDescriptions,
1698 Read(
"canvasENCShowLights", &cConfig->bShowENCLights, 1);
1699 Read(
"canvasENCShowVisibleSectorLights",
1700 &cConfig->bShowENCVisibleSectorLights, 0);
1701 Read(
"canvasENCShowAnchorInfo", &cConfig->bShowENCAnchorInfo, 0);
1702 Read(
"canvasENCShowDataQuality", &cConfig->bShowENCDataQuality, 0);
1705 Read(
"canvasSizeX", &sx, 0);
1706 Read(
"canvasSizeY", &sy, 0);
1710void MyConfig::SaveCanvasConfigs() {
1711 auto &config_array = ConfigMgr::Get().GetCanvasConfigArray();
1714 Write(
"CanvasConfig", (
int)g_canvasConfig);
1719 switch (g_canvasConfig) {
1723 s.Printf(
"/Canvas/CanvasConfig%d", 1);
1726 if (config_array.GetCount() > 0) {
1727 pcc = config_array.Item(0);
1729 SaveConfigCanvas(pcc);
1736 if (config_array.GetCount() > 1) {
1737 s.Printf(
"/Canvas/CanvasConfig%d", 1);
1739 pcc = config_array.Item(0);
1741 SaveConfigCanvas(pcc);
1744 s.Printf(
"/Canvas/CanvasConfig%d", 2);
1746 pcc = config_array.Item(1);
1748 SaveConfigCanvas(pcc);
1755void MyConfig::SaveConfigCanvas(
canvasConfig *cConfig) {
1762 st1.Printf(
"%10.4f,%10.4f", vp.
clat, vp.
clon);
1763 Write(
"canvasVPLatLon", st1);
1765 Write(
"canvasVPScale", st1);
1766 st1.Printf(
"%i", ((
int)(vp.
rotation * 180 / PI)) % 360);
1767 Write(
"canvasVPRotation", st1);
1770 int restore_dbindex = 0;
1772 if (pcs) restore_dbindex = pcs->GetCurrentEntrydbIndex();
1773 if (cConfig->
canvas->GetQuiltMode())
1774 restore_dbindex = cConfig->
canvas->GetQuiltReferenceChartIndex();
1775 Write(
"canvasInitialdBIndex", restore_dbindex);
1777 Write(
"canvasbFollow", cConfig->
canvas->m_bFollow);
1778 Write(
"ActiveChartGroup", cConfig->
canvas->m_groupIndex);
1780 Write(
"canvasQuilt", cConfig->
canvas->GetQuiltMode());
1781 Write(
"canvasShowGrid", cConfig->
canvas->GetShowGrid());
1782 Write(
"canvasShowOutlines", cConfig->
canvas->GetShowOutlines());
1783 Write(
"canvasShowDepthUnits", cConfig->
canvas->GetShowDepthUnits());
1785 Write(
"canvasShowAIS", cConfig->
canvas->GetShowAIS());
1786 Write(
"canvasAttenAIS", cConfig->
canvas->GetAttenAIS());
1788 Write(
"canvasShowTides", cConfig->
canvas->GetbShowTide());
1789 Write(
"canvasShowCurrents", cConfig->
canvas->GetbShowCurrent());
1792 Write(
"canvasShowENCText", cConfig->
canvas->GetShowENCText());
1793 Write(
"canvasENCDisplayCategory", cConfig->
canvas->GetENCDisplayCategory());
1794 Write(
"canvasENCShowDepths", cConfig->
canvas->GetShowENCDepth());
1795 Write(
"canvasENCShowBuoyLabels", cConfig->
canvas->GetShowENCBuoyLabels());
1796 Write(
"canvasENCShowLightDescriptions",
1797 cConfig->
canvas->GetShowENCLightDesc());
1798 Write(
"canvasENCShowLights", cConfig->
canvas->GetShowENCLights());
1799 Write(
"canvasENCShowVisibleSectorLights",
1800 cConfig->
canvas->GetShowVisibleSectors());
1801 Write(
"canvasENCShowAnchorInfo", cConfig->
canvas->GetShowENCAnchor());
1802 Write(
"canvasENCShowDataQuality", cConfig->
canvas->GetShowENCDataQual());
1803 Write(
"canvasCourseUp", cConfig->
canvas->GetUpMode() == COURSE_UP_MODE);
1804 Write(
"canvasHeadUp", cConfig->
canvas->GetUpMode() == HEAD_UP_MODE);
1805 Write(
"canvasLookahead", cConfig->
canvas->GetLookahead());
1807 int width = cConfig->
canvas->GetSize().x;
1815 Write(
"canvasSizeX", width);
1816 Write(
"canvasSizeY", cConfig->
canvas->GetSize().y);
1820void MyConfig::UpdateSettings() {
1828 SetPath(
"/Settings");
1830 Write(
"LastAppliedTemplate", g_lastAppliedTemplateGUID);
1831 Write(
"CompatOS", g_compatOS);
1832 Write(
"CompatOsVersion", g_compatOsVersion);
1833 Write(
"ConfigVersionString", g_config_version_string);
1834 if (wxIsEmpty(g_CmdSoundString)) g_CmdSoundString = wxString(OCPN_SOUND_CMD);
1835 Write(
"CmdSoundString", g_CmdSoundString);
1836 Write(
"NavMessageShown", n_NavMessageShown);
1837 Write(
"InlandEcdis", g_bInlandEcdis);
1839 Write(
"AndroidVersionCode", g_AndroidVersionCode);
1841 Write(
"UIexpert", g_bUIexpert);
1842 Write(
"SpaceDropMark", g_bSpaceDropMark);
1846 Write(
"ShowStatusBar", g_bShowStatusBar);
1848 Write(
"ShowMenuBar", g_bShowMenuBar);
1850 Write(
"DefaultFontSize", g_default_font_size);
1853 Write(
"Fullscreen", g_bFullscreen);
1854 Write(
"ShowCompassWindow", g_bShowCompassWin);
1855 Write(
"SetSystemTime", s_bSetSystemTime);
1857 Write(
"PlayShipsBells", g_bPlayShipsBells);
1858 Write(
"SoundDeviceIndex", g_iSoundDeviceIndex);
1859 Write(
"FullscreenToolbar", g_bFullscreenToolbar);
1860 Write(
"TransparentToolbar", g_bTransparentToolbar);
1861 Write(
"PermanentMOBIcon", g_bPermanentMOBIcon);
1862 Write(
"ShowLayers", g_bShowLayers);
1863 Write(
"AutoAnchorDrop", g_bAutoAnchorMark);
1864 Write(
"ShowChartOutlines", g_bShowOutlines);
1865 Write(
"ShowActiveRouteTotal", g_bShowRouteTotal);
1866 Write(
"ShowActiveRouteHighway", g_bShowActiveRouteHighway);
1867 Write(
"SDMMFormat", g_iSDMMFormat);
1868 Write(
"MostRecentGPSUploadConnection", g_uploadConnection);
1869 Write(
"ShowChartBar", g_bShowChartBar);
1871 Write(
"GUIScaleFactor", g_GUIScaleFactor);
1872 Write(
"ChartObjectScaleFactor", g_ChartScaleFactor);
1873 Write(
"ShipScaleFactor", g_ShipScaleFactor);
1874 Write(
"ENCSoundingScaleFactor", g_ENCSoundingScaleFactor);
1875 Write(
"ENCTextScaleFactor", g_ENCTextScaleFactor);
1876 Write(
"ObjQueryAppendFilesExt", g_ObjQFileExt);
1879 Write(
"CatalogCustomURL", g_catalog_custom_url);
1880 Write(
"CatalogChannel", g_catalog_channel);
1882 Write(
"NetmaskBits", g_netmask_bits);
1883 Write(
"FilterNMEA_Avg", g_bfilter_cogsog);
1884 Write(
"FilterNMEA_Sec", g_COGFilterSec);
1886 Write(
"TrackContinuous", g_btrackContinuous);
1888 Write(
"ShowTrue", g_bShowTrue);
1889 Write(
"ShowMag", g_bShowMag);
1890 Write(
"UserMagVariation", wxString::Format(
"%.2f", g_UserVar));
1892 Write(
"CM93DetailFactor", g_cm93_zoom_factor);
1893 Write(
"CM93DetailZoomPosX", g_detailslider_dialog_x);
1894 Write(
"CM93DetailZoomPosY", g_detailslider_dialog_y);
1895 Write(
"ShowCM93DetailSlider", g_bShowDetailSlider);
1897 Write(
"SkewToNorthUp", g_bskew_comp);
1898 if (!g_bdisable_opengl) {
1900 Write(
"OpenGL", g_bopengl);
1902 Write(
"SoftwareGL", g_bSoftwareGL);
1904 Write(
"ZoomDetailFactor", g_chart_zoom_modifier_raster);
1905 Write(
"ZoomDetailFactorVector", g_chart_zoom_modifier_vector);
1907 Write(
"FogOnOverzoom", g_fog_overzoom);
1908 Write(
"OverzoomVectorScale", g_oz_vector_scale);
1909 Write(
"OverzoomEmphasisBase", g_overzoom_emphasis_base);
1910 Write(
"PlusMinusZoomFactor", g_plus_minus_zoom_factor);
1911 Write(
"MouseZoomSensitivity",
1913 Write(
"ShowMUIZoomButtons", g_bShowMuiZoomButtons);
1917 Write(
"UseAcceleratedPanning", g_GLOptions.m_bUseAcceleratedPanning);
1919 Write(
"GPUTextureCompression", g_GLOptions.m_bTextureCompression);
1920 Write(
"GPUTextureCompressionCaching",
1921 g_GLOptions.m_bTextureCompressionCaching);
1922 Write(
"GPUTextureDimension", g_GLOptions.m_iTextureDimension);
1923 Write(
"GPUTextureMemSize", g_GLOptions.m_iTextureMemorySize);
1924 Write(
"PolygonSmoothing", g_GLOptions.m_GLPolygonSmoothing);
1925 Write(
"LineSmoothing", g_GLOptions.m_GLLineSmoothing);
1929 Write(
"CourseUpMode", g_bCourseUp);
1930 if (!g_bInlandEcdis)
Write(
"LookAheadMode", g_bLookAhead);
1931 Write(
"TenHzUpdate", g_btenhertz);
1934 Write(
"UseMagAPB", g_bMagneticAPB);
1936 Write(
"OwnshipCOGPredictorMinutes", g_ownship_predictor_minutes);
1937 Write(
"OwnshipCOGPredictorStyle", g_cog_predictor_style);
1938 Write(
"OwnshipCOGPredictorColor", g_cog_predictor_color);
1939 Write(
"OwnshipCOGPredictorEndmarker", g_cog_predictor_endmarker);
1940 Write(
"OwnshipCOGPredictorWidth", g_cog_predictor_width);
1941 Write(
"OwnshipHDTPredictorStyle", g_ownship_HDTpredictor_style);
1942 Write(
"OwnshipHDTPredictorColor", g_ownship_HDTpredictor_color);
1943 Write(
"OwnshipHDTPredictorEndmarker", g_ownship_HDTpredictor_endmarker);
1945 Write(
"OwnshipHDTPredictorWidth", g_ownship_HDTpredictor_width);
1946 Write(
"OwnshipHDTPredictorMiles", g_ownship_HDTpredictor_miles);
1948 Write(
"OwnShipIconType", g_OwnShipIconType);
1949 Write(
"OwnShipLength", g_n_ownship_length_meters);
1950 Write(
"OwnShipWidth", g_n_ownship_beam_meters);
1951 Write(
"OwnShipGPSOffsetX", g_n_gps_antenna_offset_x);
1952 Write(
"OwnShipGPSOffsetY", g_n_gps_antenna_offset_y);
1953 Write(
"OwnShipMinSize", g_n_ownship_min_mm);
1954 Write(
"OwnShipSogCogCalc", g_own_ship_sog_cog_calc);
1955 Write(
"OwnShipSogCogCalcDampSec", g_own_ship_sog_cog_calc_damp_sec);
1956 Write(
"ShowDirectRouteLine", g_bShowShipToActive);
1957 Write(
"DirectRouteLineStyle", g_shipToActiveStyle);
1958 Write(
"DirectRouteLineColor", g_shipToActiveColor);
1963 Write(
"RouteArrivalCircleRadius",
1964 wxString::Format(
"%.2f", g_n_arrival_circle_radius));
1966 Write(
"ChartQuilting", g_bQuiltEnable);
1968 Write(
"PreserveScaleOnX", g_bPreserveScaleOnX);
1970 Write(
"StartWithTrackActive", g_bTrackCarryOver);
1971 Write(
"AutomaticDailyTracks", g_bTrackDaily);
1972 Write(
"TrackRotateAt", g_track_rotate_time);
1973 Write(
"TrackRotateTimeType", g_track_rotate_time_type);
1974 Write(
"HighlightTracks", g_bHighliteTracks);
1977 Write(
"InitialStackIndex", g_restore_stackindex);
1978 Write(
"InitialdBIndex", g_restore_dbindex);
1980 Write(
"NMEAAPBPrecision", g_NMEAAPBPrecision);
1982 Write(
"TalkerIdText", g_TalkerIdText);
1983 Write(
"ShowTrackPointTime", g_bShowTrackPointTime);
1985 Write(
"AnchorWatch1GUID", g_AW1GUID);
1986 Write(
"AnchorWatch2GUID", g_AW2GUID);
1988 Write(
"ToolbarX", g_maintoolbar_x);
1989 Write(
"ToolbarY", g_maintoolbar_y);
1992 Write(
"iENCToolbarX", g_iENCToolbarPosX);
1993 Write(
"iENCToolbarY", g_iENCToolbarPosY);
1995 if (!g_bInlandEcdis) {
1996 Write(
"GlobalToolbarConfig", g_toolbarConfig);
1999 Write(
"WindSpeedFormat", g_iWindSpeedFormat);
2000 Write(
"ShowDepthUnits", g_bShowDepthUnits);
2004 Write(
"GPSIdent", g_GPS_Ident);
2005 Write(
"ActiveRoute", g_active_route);
2006 Write(
"PersistActiveRoute", g_persist_active_route);
2009 Write(
"UseGarminHostUpload", g_bGarminHostUpload);
2011 Write(
"MobileTouch", g_btouch);
2012 Write(
"ResponsiveGraphics", g_bresponsive);
2015 Write(
"AutoHideToolbar", g_bAutoHideToolbar);
2016 Write(
"AutoHideToolbarSecs", g_nAutoHideToolbar);
2020 st0.Append(wxString::Format(
"%zu,", mm));
2023 Write(
"DisplaySizeMM", st0);
2024 Write(
"DisplaySizeManual", g_config_display_size_manual);
2026 Write(
"SelectionRadiusMM", g_selection_radius_mm);
2027 Write(
"SelectionRadiusTouchMM", g_selection_radius_touch_mm);
2029 st0.Printf(
"%g", g_PlanSpeed);
2030 Write(
"PlanSpeed", st0);
2032 if (g_bLayersLoaded) {
2033 wxString vis, invis, visnames, invisnames;
2034 LayerList::iterator it;
2036 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
2038 if (lay->IsVisibleOnChart())
2039 vis += (lay->m_LayerName) +
";";
2041 invis += (lay->m_LayerName) +
";";
2043 if (lay->HasVisibleNames() == wxCHK_CHECKED) {
2044 visnames += (lay->m_LayerName) +
";";
2045 }
else if (lay->HasVisibleNames() == wxCHK_UNCHECKED) {
2046 invisnames += (lay->m_LayerName) +
";";
2049 Write(
"VisibleLayers", vis);
2050 Write(
"InvisibleLayers", invis);
2051 Write(
"VisNameInLayers", visnames);
2052 Write(
"InvisNameInLayers", invisnames);
2054 Write(
"Locale", g_locale);
2055 Write(
"LocaleOverride", g_localeOverride);
2057 Write(
"KeepNavobjBackups", g_navobjbackups);
2058 Write(
"LegacyInputCOMPortFilterBehaviour", g_b_legacy_input_filter_behaviour);
2059 Write(
"AdvanceRouteWaypointOnArrivalOnly",
2060 g_bAdvanceRouteWaypointOnArrivalOnly);
2061 Write(
"EnableRootMenuDebug", g_enable_root_menu_debug);
2064 Write(
"LiveETA", g_bShowLiveETA);
2065 Write(
"DefaultBoatSpeed", g_defaultBoatSpeed);
2069 SetPath(
"/Settings/ObjectFilter");
2072 for (
unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
2074 OBJLElement *pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
2076 wxString st1(
"viz");
2078 strncpy(name, pOLE->OBJLName, 6);
2080 st1.Append(wxString(name, wxConvUTF8));
2081 Write(st1, pOLE->nViz);
2087 SetPath(
"/Settings/GlobalState");
2104 st1.Printf(
"%10.4f, %10.4f",
gLat,
gLon);
2105 Write(
"OwnShipLatLon", st1);
2108 SetPath(
"/Settings/GlobalState");
2109 if (!g_bInlandEcdis)
Write(
"nColorScheme", (
int)gFrame->GetColorScheme());
2111 Write(
"FrameWinX", g_nframewin_x);
2112 Write(
"FrameWinY", g_nframewin_y);
2113 Write(
"FrameWinPosX", g_nframewin_posx);
2114 Write(
"FrameWinPosY", g_nframewin_posy);
2115 Write(
"FrameMax", g_bframemax);
2117 Write(
"ClientPosX", g_lastClientRectx);
2118 Write(
"ClientPosY", g_lastClientRecty);
2119 Write(
"ClientSzX", g_lastClientRectw);
2120 Write(
"ClientSzY", g_lastClientRecth);
2124 Write(
"RoutePropSizeX", g_route_prop_sx);
2125 Write(
"RoutePropSizeY", g_route_prop_sy);
2126 Write(
"RoutePropPosX", g_route_prop_x);
2127 Write(
"RoutePropPosY", g_route_prop_y);
2130 SetPath(
"/Settings/Audio");
2131 Write(
"AISAlertSoundFile", g_AIS_sound_file);
2132 Write(
"DSCAlertSoundFile", g_DSC_sound_file);
2133 Write(
"SARTAlertSoundFile", g_SART_sound_file);
2134 Write(
"AnchorAlarmSoundFile", g_anchorwatch_sound_file);
2136 Write(
"bAIS_GCPA_AlertAudio", g_bAIS_GCPA_Alert_Audio);
2137 Write(
"bAIS_SART_AlertAudio", g_bAIS_SART_Alert_Audio);
2138 Write(
"bAIS_DSC_AlertAudio", g_bAIS_DSC_Alert_Audio);
2139 Write(
"bAnchorAlertAudio", g_bAnchor_Alert_Audio);
2142 SetPath(
"/Settings/AIS");
2144 Write(
"bNoCPAMax", g_bCPAMax);
2145 Write(
"NoCPAMaxNMi", g_CPAMax_NM);
2146 Write(
"bCPAWarn", g_bCPAWarn);
2147 Write(
"CPAWarnNMi", g_CPAWarn_NM);
2148 Write(
"bTCPAMax", g_bTCPA_Max);
2149 Write(
"TCPAMaxMinutes", g_TCPA_Max);
2150 Write(
"bMarkLostTargets", g_bMarkLost);
2151 Write(
"MarkLost_Minutes", g_MarkLost_Mins);
2152 Write(
"bRemoveLostTargets", g_bRemoveLost);
2153 Write(
"RemoveLost_Minutes", g_RemoveLost_Mins);
2154 Write(
"bShowCOGArrows", g_bShowCOG);
2155 Write(
"bSyncCogPredictors", g_bSyncCogPredictors);
2156 Write(
"CogArrowMinutes", g_ShowCOG_Mins);
2157 Write(
"bShowTargetTracks", g_bAISShowTracks);
2158 Write(
"TargetTracksMinutes", g_AISShowTracks_Mins);
2160 Write(
"bHideMooredTargets", g_bHideMoored);
2161 Write(
"MooredTargetMaxSpeedKnots", g_ShowMoored_Kts);
2163 Write(
"bAISAlertDialog", g_bAIS_CPA_Alert);
2164 Write(
"bAISAlertAudio", g_bAIS_CPA_Alert_Audio);
2166 Write(
"AISAlertAudioFile", g_sAIS_Alert_Sound_File);
2167 Write(
"bAISAlertSuppressMoored", g_bAIS_CPA_Alert_Suppress_Moored);
2168 Write(
"bShowAreaNotices", g_bShowAreaNotices);
2169 Write(
"bDrawAISSize", g_bDrawAISSize);
2170 Write(
"bDrawAISRealtime", g_bDrawAISRealtime);
2171 Write(
"AISRealtimeMinSpeedKnots", g_AIS_RealtPred_Kts);
2172 Write(
"bShowAISName", g_bShowAISName);
2173 Write(
"ShowAISTargetNameScale", g_Show_Target_Name_Scale);
2174 Write(
"bWplIsAprsPositionReport", g_bWplUsePosition);
2175 Write(
"WplSelAction", g_WplAction);
2176 Write(
"AISCOGPredictorWidth", g_ais_cog_predictor_width);
2177 Write(
"bShowScaledTargets", g_bAllowShowScaled);
2178 Write(
"AISScaledNumber", g_ShowScaled_Num);
2179 Write(
"AISScaledNumberWeightSOG", g_ScaledNumWeightSOG);
2180 Write(
"AISScaledNumberWeightCPA", g_ScaledNumWeightCPA);
2181 Write(
"AISScaledNumberWeightTCPA", g_ScaledNumWeightTCPA);
2182 Write(
"AISScaledNumberWeightRange", g_ScaledNumWeightRange);
2183 Write(
"AISScaledNumberWeightSizeOfTarget", g_ScaledNumWeightSizeOfT);
2184 Write(
"AISScaledSizeMinimal", g_ScaledSizeMinimal);
2185 Write(
"AISShowScaled", g_bShowScaled);
2187 Write(
"AlertDialogSizeX", g_ais_alert_dialog_sx);
2188 Write(
"AlertDialogSizeY", g_ais_alert_dialog_sy);
2189 Write(
"AlertDialogPosX", g_ais_alert_dialog_x);
2190 Write(
"AlertDialogPosY", g_ais_alert_dialog_y);
2191 Write(
"QueryDialogPosX", g_ais_query_dialog_x);
2192 Write(
"QueryDialogPosY", g_ais_query_dialog_y);
2193 Write(
"AISTargetListPerspective", g_AisTargetList_perspective);
2194 Write(
"AISTargetListRange", g_AisTargetList_range);
2195 Write(
"AISTargetListSortColumn", g_AisTargetList_sortColumn);
2196 Write(
"bAISTargetListSortReverse", g_bAisTargetList_sortReverse);
2197 Write(
"AISTargetListColumnSpec", g_AisTargetList_column_spec);
2198 Write(
"AISTargetListColumnOrder", g_AisTargetList_column_order);
2200 Write(
"S57QueryDialogSizeX", g_S57_dialog_sx);
2201 Write(
"S57QueryDialogSizeY", g_S57_dialog_sy);
2202 Write(
"S57QueryExtraDialogSizeX", g_S57_extradialog_sx);
2203 Write(
"S57QueryExtraDialogSizeY", g_S57_extradialog_sy);
2205 Write(
"bAISRolloverShowClass", g_bAISRolloverShowClass);
2206 Write(
"bAISRolloverShowCOG", g_bAISRolloverShowCOG);
2207 Write(
"bAISRolloverShowCPA", g_bAISRolloverShowCPA);
2209 Write(
"bAISAlertAckTimeout", g_bAIS_ACK_Timeout);
2210 Write(
"AlertAckTimeoutMinutes", g_AckTimeout_Mins);
2212 SetPath(
"/Settings/GlobalState");
2214 Write(
"bShowS57Text", ps52plib->GetShowS57Text());
2215 Write(
"bShowS57ImportantTextOnly", ps52plib->GetShowS57ImportantTextOnly());
2216 if (!g_bInlandEcdis)
2217 Write(
"nDisplayCategory", (
long)ps52plib->GetDisplayCategory());
2218 Write(
"nSymbolStyle", (
int)ps52plib->m_nSymbolStyle);
2219 Write(
"nBoundaryStyle", (
int)ps52plib->m_nBoundaryStyle);
2221 Write(
"bShowSoundg", ps52plib->m_bShowSoundg);
2222 Write(
"bShowMeta", ps52plib->m_bShowMeta);
2223 Write(
"bUseSCAMIN", ps52plib->m_bUseSCAMIN);
2224 Write(
"bUseSUPER_SCAMIN", ps52plib->m_bUseSUPER_SCAMIN);
2225 Write(
"bShowAtonText", ps52plib->m_bShowAtonText);
2226 Write(
"bShowLightDescription", ps52plib->m_bShowLdisText);
2227 Write(
"bExtendLightSectors", ps52plib->m_bExtendLightSectors);
2228 Write(
"bDeClutterText", ps52plib->m_bDeClutterText);
2229 Write(
"bShowNationalText", ps52plib->m_bShowNationalTexts);
2231 Write(
"S52_MAR_SAFETY_CONTOUR",
2232 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
2233 Write(
"S52_MAR_SHALLOW_CONTOUR",
2234 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
2235 Write(
"S52_MAR_DEEP_CONTOUR", S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
2236 Write(
"S52_MAR_TWO_SHADES", S52_getMarinerParam(S52_MAR_TWO_SHADES));
2237 Write(
"S52_DEPTH_UNIT_SHOW", ps52plib->m_nDepthUnitDisplay);
2238 Write(
"ENCSoundingScaleFactor", g_ENCSoundingScaleFactor);
2239 Write(
"ENCTextScaleFactor", g_ENCTextScaleFactor);
2241 SetPath(
"/Directories");
2242 Write(
"S57DataLocation",
"");
2245 SetPath(
"/Directories");
2246 Write(
"InitChartDir", *pInit_Chart_Dir);
2247 Write(
"GPXIODir", g_gpx_path);
2248 Write(
"TCDataDir", g_TCData_Dir);
2249 Write(
"BasemapDir", g_Platform->NormalizePath(gWorldMapLocation));
2250 Write(
"BaseShapefileDir", g_Platform->NormalizePath(gWorldShapefileLocation));
2253 SetPath(
"/Settings/NMEADataSource");
2254 wxString connectionconfigs;
2255 for (
size_t i = 0; i < TheConnectionParams().size(); i++) {
2256 if (i > 0) connectionconfigs.Append(
"|");
2257 connectionconfigs.Append(TheConnectionParams()[i]->Serialize());
2259 Write(
"DataConnections", connectionconfigs);
2264 SetPath(
"/Settings/AuxFontKeys");
2267 for (
unsigned int i = 0; i < keyArray.GetCount(); i++) {
2269 key.Printf(
"Key%i", i);
2270 wxString keyval = keyArray[i];
2276 font_path = (
"/Settings/X11Fonts");
2280 font_path = (
"/Settings/GTKFonts");
2284 font_path = (
"/Settings/MSWFonts");
2288 font_path = (
"/Settings/MacFonts");
2292 font_path = (
"/Settings/QTFonts");
2295 if (HasEntry(font_path)) DeleteGroup(font_path);
2301 for (
int i = 0; i < nFonts; i++) {
2302 wxString cfstring(FontMgr::Get().GetConfigString(i));
2304 Write(cfstring, valstring);
2308 if (HasGroup(
"/TideCurrentDataSources"))
2309 DeleteGroup(
"/TideCurrentDataSources");
2310 SetPath(
"/TideCurrentDataSources");
2311 unsigned int id = 0;
2312 for (
auto val : TideCurrentDataSet) {
2314 key.Printf(
"tcds%d",
id);
2315 Write(key, wxString(val));
2319 SetPath(
"/Settings/Others");
2322 Write(
"ShowRadarRings",
2323 (
bool)(g_iNavAidRadarRingsNumberVisible > 0));
2324 Write(
"RadarRingsNumberVisible", g_iNavAidRadarRingsNumberVisible);
2325 Write(
"RadarRingsStep", g_fNavAidRadarRingsStep);
2326 Write(
"RadarRingsStepUnits", g_pNavAidRadarRingsStepUnits);
2327 Write(
"RadarRingsColour",
2328 g_colourOwnshipRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
2329 Write(
"WaypointUseScaMin", g_bUseWptScaMin);
2330 Write(
"WaypointScaMinValue", g_iWpt_ScaMin);
2331 Write(
"WaypointUseScaMinOverrule", g_bOverruleScaMin);
2332 Write(
"WaypointsShowName", g_bShowWptName);
2333 Write(
"UserIconsFirst", g_bUserIconsFirst);
2336 Write(
"WaypointRangeRingsNumber", g_iWaypointRangeRingsNumber);
2337 Write(
"WaypointRangeRingsStep", g_fWaypointRangeRingsStep);
2338 Write(
"WaypointRangeRingsStepUnits", g_iWaypointRangeRingsStepUnits);
2339 Write(
"WaypointRangeRingsColour",
2342 Write(
"ConfirmObjectDeletion", g_bConfirmObjectDelete);
2345 Write(
"WaypointPreventDragging", g_bWayPointPreventDragging);
2347 Write(
"EnableZoomToCursor", g_bEnableZoomToCursor);
2349 Write(
"TrackIntervalSeconds", g_TrackIntervalSeconds);
2350 Write(
"TrackDeltaDistance", g_TrackDeltaDistance);
2351 Write(
"TrackPrecision", g_nTrackPrecision);
2353 Write(
"RouteLineWidth", g_route_line_width);
2354 Write(
"TrackLineWidth", g_track_line_width);
2355 Write(
"TrackLineColour",
2356 g_colourTrackLineColour.GetAsString(wxC2S_HTML_SYNTAX));
2357 Write(
"DefaultWPIcon", g_default_wp_icon);
2358 Write(
"DefaultRPIcon", g_default_routepoint_icon);
2360 DeleteGroup(
"/MmsiProperties");
2361 SetPath(
"/MmsiProperties");
2364 p.Printf(
"Props%d", i);
2368 SaveCanvasConfigs();
2371 SendMessageToAllPlugins(
"GLOBAL_SETTINGS_UPDATED",
"{\"updated\":\"1\"}");
2374static wxFileName exportFileName(wxWindow *parent,
2375 const wxString suggestedName) {
2378 wxString valid_name = SanitizeFileName(suggestedName);
2381 if (!valid_name.EndsWith(
".gpx")) {
2382 wxFileName fn(valid_name);
2385 valid_name = fn.GetFullName();
2388 int response = g_Platform->DoFileSelectorDialog(
2389 parent, &path, _(
"Export GPX file"), g_gpx_path, valid_name,
"*.gpx");
2391 if (response == wxID_OK) {
2392 wxFileName fn(path);
2393 g_gpx_path = fn.GetPath();
2394 if (!fn.GetExt().StartsWith(
"gpx")) fn.SetExt(
"gpx");
2396#if defined(__WXMSW__) || defined(__WXGTK__)
2397 if (wxFileExists(fn.GetFullPath())) {
2398 int answer = OCPNMessageBox(NULL, _(
"Overwrite existing file?"),
2399 "Confirm", wxICON_QUESTION | wxYES_NO);
2400 if (answer != wxID_YES)
return ret;
2408int BackupDatabase(wxWindow *parent) {
2409 bool backupResult =
false;
2410 wxDateTime tm = wxDateTime::Now();
2411 wxString proposedName = tm.Format(
"navobj-%Y-%m-%d_%H_%M");
2412 wxString acceptedName;
2415 g_Platform->DoFileSelectorDialog(parent, &acceptedName, _(
"Backup"),
2416 wxStandardPaths::Get().GetDocumentsDir(),
2417 proposedName,
"*.bkp")) {
2418 wxFileName fileName(acceptedName);
2419 if (fileName.IsOk()) {
2420#if defined(__WXMSW__) || defined(__WXGTK__)
2421 if (fileName.FileExists()) {
2422 if (wxID_YES != OCPNMessageBox(NULL, _(
"Overwrite existing file?"),
2423 "Confirm", wxICON_QUESTION | wxYES_NO)) {
2430 wxString secureFileName = androidGetCacheDir() +
2431 wxFileName::GetPathSeparator() +
2432 fileName.GetFullName();
2433 backupResult = NavObj_dB::GetInstance().Backup(secureFileName);
2434 AndroidSecureCopyFile(secureFileName, fileName.GetFullPath());
2436 backupResult = NavObj_dB::GetInstance().Backup(fileName.GetFullPath());
2439 return backupResult ? wxID_YES : wxID_NO;
2444bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes,
2445 const wxString suggestedName) {
2447 wxFileName fn = exportFileName(parent, suggestedName);
2450 pgpx->AddGPXRoutesList(pRoutes);
2451 pgpx->SaveFile(fn.GetFullPath());
2457 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2458 suggestedName +
".gpx";
2460 pgpx->AddGPXRoutesList(pRoutes);
2461 pgpx->SaveFile(fns);
2466 int response = g_Platform->DoFileSelectorDialog(
2467 parent, &path, _(
"Export GPX file"), g_gpx_path, suggestedName +
".gpx",
2473 wxCopyFile(fns, path);
2481bool ExportGPXTracks(wxWindow *parent, std::vector<Track *> *pTracks,
2482 const wxString suggestedName) {
2484 wxFileName fn = exportFileName(parent, suggestedName);
2487 pgpx->AddGPXTracksList(pTracks);
2488 pgpx->SaveFile(fn.GetFullPath());
2494 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2495 suggestedName +
".gpx";
2497 pgpx->AddGPXTracksList(pTracks);
2498 pgpx->SaveFile(fns);
2503 int response = g_Platform->DoFileSelectorDialog(
2504 parent, &path, _(
"Export GPX file"), g_gpx_path, suggestedName +
".gpx",
2510 wxCopyFile(fns, path);
2517bool ExportGPXWaypoints(wxWindow *parent, RoutePointList *pRoutePoints,
2518 const wxString suggestedName) {
2520 wxFileName fn = exportFileName(parent, suggestedName);
2523 pgpx->AddGPXPointsList(pRoutePoints);
2524 pgpx->SaveFile(fn.GetFullPath());
2530 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2531 suggestedName +
".gpx";
2533 pgpx->AddGPXPointsList(pRoutePoints);
2534 pgpx->SaveFile(fns);
2539 int response = g_Platform->DoFileSelectorDialog(
2540 parent, &path, _(
"Export GPX file"), g_gpx_path, suggestedName +
".gpx",
2546 wxCopyFile(fns, path);
2554void ExportGPX(wxWindow *parent,
bool bviz_only,
bool blayer) {
2559 wxFileName fn = exportFileName(parent,
"userobjects.gpx");
2560 if (!fn.IsOk())
return;
2561 fns = fn.GetFullPath();
2565 androidGetCacheDir() + wxFileName::GetPathSeparator() +
"userobjects.gpx";
2568 ::wxBeginBusyCursor();
2570 wxGenericProgressDialog *pprog =
nullptr;
2571 int count = pWayPointMan->GetWaypointList()->size();
2572 int progStep = count / 32;
2574 pprog =
new wxGenericProgressDialog(
2575 _(
"Export GPX file"),
"0/0", count, NULL,
2576 wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
2577 wxPD_REMAINING_TIME);
2578 pprog->SetSize(400, wxDefaultCoord);
2585 for (
RoutePoint *pr : *pWayPointMan->GetWaypointList()) {
2586 if (pprog && !(ic % progStep)) {
2588 msg.Printf(
"%d/%d", ic, count);
2589 pprog->Update(ic, msg);
2594 if (bviz_only && !pr->m_bIsVisible) b_add =
false;
2596 if (pr->m_bIsInLayer && !blayer) b_add =
false;
2598 if (pr->IsShared() || !WptIsInRouteList(pr)) pgpx->AddGPXWaypoint(pr);
2604 if (bviz_only && !pRoute->IsVisible()) b_add =
false;
2605 if (pRoute->m_bIsInLayer && !blayer) b_add =
false;
2607 if (b_add) pgpx->AddGPXRoute(pRoute);
2613 if (bviz_only && !pTrack->IsVisible()) b_add =
false;
2615 if (pTrack->m_bIsInLayer && !blayer) b_add =
false;
2617 if (b_add) pgpx->AddGPXTrack(pTrack);
2620 pgpx->SaveFile(fns);
2626 g_Platform->DoFileSelectorDialog(parent, &path, _(
"Export GPX file"),
2627 g_gpx_path,
"userobjects.gpx",
"*.gpx");
2631 wxCopyFile(fns, path);
2635 ::wxEndBusyCursor();
2639void UI_ImportGPX(wxWindow *parent,
bool islayer, wxString dirpath,
2640 bool isdirectory,
bool isPersistent) {
2641 int response = wxID_CANCEL;
2642 wxArrayString file_array;
2644 if (!islayer || dirpath.IsSameAs(
"")) {
2649 wxFileDialog *popenDialog =
2650 new wxFileDialog(NULL, _(
"Import GPX file"), g_gpx_path,
"",
2651 "GPX files (*.gpx)|*.gpx|All files (*.*)|*.*",
2652 wxFD_OPEN | wxFD_MULTIPLE);
2654 if (g_bresponsive && parent)
2655 popenDialog = g_Platform->AdjustFileDialogFont(parent, popenDialog);
2657 popenDialog->Centre();
2660 if (parent) parent->HideWithEffect(wxSHOW_EFFECT_BLEND);
2663 response = popenDialog->ShowModal();
2666 if (parent) parent->ShowWithEffect(wxSHOW_EFFECT_BLEND);
2669 if (response == wxID_OK) {
2670 popenDialog->GetPaths(file_array);
2673 if (file_array.GetCount()) {
2674 wxFileName fn(file_array[0]);
2675 g_gpx_path = fn.GetPath();
2681 response = g_Platform->DoFileSelectorDialog(
2682 NULL, &path, _(
"Import GPX file"), g_gpx_path,
"",
"*.gpx");
2684 wxFileName fn(path);
2685 g_gpx_path = fn.GetPath();
2686 if (path.IsEmpty()) {
2687 PrepareImportAndroid(islayer, isPersistent);
2690 file_array.Add(path);
2695 if (wxDir::GetAllFiles(dirpath, &file_array,
"*.gpx")) response = wxID_OK;
2697 file_array.Add(dirpath);
2702 if (response == wxID_OK) {
2703 ImportFileArray(file_array, islayer, isPersistent, dirpath);
2707void ImportFileArray(
const wxArrayString &file_array,
bool islayer,
2708 bool isPersistent, wxString dirpath) {
2714 l->m_LayerFileName = file_array[0];
2715 if (file_array.GetCount() <= 1)
2716 wxFileName::SplitPath(file_array[0], NULL, NULL, &(l->m_LayerName), NULL,
2719 if (dirpath.IsSameAs(
""))
2720 wxFileName::SplitPath(g_gpx_path, NULL, NULL, &(l->m_LayerName), NULL,
2723 wxFileName::SplitPath(dirpath, NULL, NULL, &(l->m_LayerName), NULL,
2727 bool bLayerViz = g_bShowLayers;
2728 if (g_VisibleLayers.Contains(l->m_LayerName)) bLayerViz =
true;
2729 if (g_InvisibleLayers.Contains(l->m_LayerName)) bLayerViz =
false;
2730 l->m_bIsVisibleOnChart = bLayerViz;
2733 l->m_bHasVisibleNames = wxCHK_CHECKED;
2736 laymsg.Printf(
"New layer %d: %s", l->m_LayerID, l->m_LayerName.c_str());
2737 wxLogMessage(laymsg);
2739 pLayerList->insert(pLayerList->begin(), l);
2742 for (
unsigned int i = 0; i < file_array.GetCount(); i++) {
2743 wxString path = file_array[i];
2745 if (::wxFileExists(path)) {
2747 if (pSet->load_file(path.fn_str()).status !=
2748 pugi::xml_parse_status::status_ok) {
2749 wxLogMessage(
"Error loading GPX file " + path);
2756 l->m_NoOfItems = pSet->LoadAllGPXObjectsAsLayer(
2757 l->m_LayerID, l->m_bIsVisibleOnChart, l->m_bHasVisibleNames);
2758 l->m_LayerType = isPersistent ? _(
"Persistent") : _(
"Temporary");
2763 wxString destf, f, name, ext;
2764 f = l->m_LayerFileName;
2765 wxFileName::SplitPath(f, NULL, NULL, &name, &ext);
2767 appendOSDirSlash(&destf);
2768 destf.Append(
"layers");
2769 appendOSDirSlash(&destf);
2770 if (!wxDirExists(destf)) {
2771 if (!wxMkdir(destf, wxS_DIR_DEFAULT))
2772 wxLogMessage(
"Error creating layer directory");
2775 destf << name <<
"." << ext;
2777 if (wxCopyFile(f, destf,
true))
2778 msg.Printf(
"File: %s.%s also added to persistent layers", name,
2781 msg.Printf(
"Failed adding %s.%s to persistent layers", name, ext);
2786 pSet->LoadAllGPXObjects(
2793 wxString::Format(
"%d " + _(
"duplicate waypoints detected "
2794 "during import and ignored."),
2796 _(
"OpenCPN Info"), wxICON_INFORMATION | wxOK, 10);
2808void SwitchInlandEcdisMode(
bool Switch) {
2810 wxLogMessage(
"Switch InlandEcdis mode On");
2817 if (ps52plib) ps52plib->SetDisplayCategory(STANDARD);
2818 g_bDrawAISSize =
false;
2819 if (gFrame) gFrame->RequestNewToolbars(
true);
2821 wxLogMessage(
"Switch InlandEcdis mode Off");
2824 pConfig->SetPath(
"/Settings");
2825 pConfig->Read(
"GlobalToolbarConfig", &g_toolbarConfig);
2828 pConfig->Read(
"ShowDepthUnits", &g_bShowDepthUnits, 1);
2831 pConfig->Read(
"nDisplayCategory", &read_int, (
enum _DisCat)STANDARD);
2832 if (ps52plib) ps52plib->SetDisplayCategory((
enum _DisCat)read_int);
2833 pConfig->SetPath(
"/Settings/AIS");
2834 pConfig->Read(
"bDrawAISSize", &g_bDrawAISSize);
2835 pConfig->Read(
"bDrawAISRealtime", &g_bDrawAISRealtime);
2837 if (gFrame) gFrame->RequestNewToolbars(
true);
2849wxString FormatGPXDateTime(wxDateTime dt) {
2851 return dt.Format(
"%Y-%m-%dT%H:%M:%SZ");
2858bool LogMessageOnce(
const wxString &msg) {
2861 for (
unsigned int i = 0; i < navutil::pMessageOnceArray->GetCount(); i++) {
2862 if (msg.IsSameAs(navutil::pMessageOnceArray->Item(i)))
return false;
2866 navutil::pMessageOnceArray->Add(msg);
2879 if (!ts.IsValid()) {
2882 int effective_format = format;
2896 switch (effective_format) {
2898 if (std::isnan(lon)) {
2899 dt = wxInvalidDateTime;
2902 ts.Add(wxTimeSpan(wxTimeSpan(0, 0, wxLongLong(lon * 3600. / 15.))));
2919 if (!ts.IsValid()) {
2922 int effective_format = format;
2936 switch (effective_format) {
2938 if (std::isnan(lon)) {
2939 dt = wxInvalidDateTime;
2941 dt = ts.Subtract(wxTimeSpan(0, 0, wxLongLong(lon * 3600. / 15.)));
2958double fromUsrSpeed(
double usr_speed,
int unit) {
2966 ret = usr_speed / 1.15078;
2969 ret = usr_speed / 1.852;
2972 ret = usr_speed / 0.514444444;
2980double fromUsrWindSpeed(
double usr_wspeed,
int unit) {
2982 if (
unit == -1)
unit = g_iWindSpeedFormat;
2988 ret = usr_wspeed / 0.514444444;
2991 ret = usr_wspeed / 1.15078;
2994 ret = usr_wspeed / 1.852;
3003double fromUsrTemp(
double usr_temp,
int unit) {
3011 ret = (usr_temp - 32) * 5.0 / 9.0;
3014 ret = usr_temp - 273.15;
3020wxString formatAngle(
double angle) {
3022 if (g_bShowMag && g_bShowTrue) {
3023 out.Printf(
"%03.0f %cT (%.0f %cM)", angle, 0x00B0, toMagnetic(angle),
3025 }
else if (g_bShowTrue) {
3026 out.Printf(
"%03.0f %cT", angle, 0x00B0);
3028 out.Printf(
"%03.0f %cM", toMagnetic(angle), 0x00B0);
3034void AlphaBlending(
ocpnDC &dc,
int x,
int y,
int size_x,
int size_y,
3035 float radius, wxColour color,
unsigned char transparency) {
3036 wxDC *pdc = dc.GetDC();
3039 wxBitmap obm(size_x, size_y);
3041 mdc1.SelectObject(obm);
3042 mdc1.Blit(0, 0, size_x, size_y, pdc, x, y);
3043 mdc1.SelectObject(wxNullBitmap);
3044 wxImage oim = obm.ConvertToImage();
3047 wxBitmap olbm(size_x, size_y);
3048 wxMemoryDC oldc(olbm);
3049 if (!oldc.IsOk())
return;
3051 oldc.SetBackground(*wxBLACK_BRUSH);
3052 oldc.SetBrush(*wxWHITE_BRUSH);
3055 if (radius > 0.0) oldc.DrawRoundedRectangle(0, 0, size_x, size_y, radius);
3057 wxImage dest = olbm.ConvertToImage();
3058 unsigned char *dest_data =
3059 (
unsigned char *)malloc(size_x * size_y * 3 *
sizeof(
unsigned char));
3060 unsigned char *bg = oim.GetData();
3061 unsigned char *box = dest.GetData();
3062 unsigned char *d = dest_data;
3069 float alpha = 1.0 - (float)transparency / 255.0;
3070 int sb = size_x * size_y;
3071 for (
int i = 0; i < sb; i++) {
3073 if (*box == 0 && radius > 0.0) a = 1.0;
3074 int r = ((*bg++) * a) + (1.0 - a) * color.Red();
3077 int g = ((*bg++) * a) + (1.0 - a) * color.Green();
3080 int b = ((*bg++) * a) + (1.0 - a) * color.Blue();
3085 dest.SetData(dest_data);
3089 dc.DrawBitmap(dbm, x, y,
false);
3093 dc.CalcBoundingBox(x, y);
3094 dc.CalcBoundingBox(x + size_x, y + size_y);
3099 float radMod = wxMax(radius, 2.0);
3100 wxColour c(color.Red(), color.Green(), color.Blue(), transparency);
3101 dc.SetBrush(wxBrush(c));
3102 dc.SetPen(wxPen(c, 1));
3103 dc.DrawRoundedRectangle(x, y, size_x, size_y, radMod);
3105 glDisable(GL_BLEND);
3111void DimeControl(wxWindow *ctrl) {
3117 if (wxPlatformInfo::Get().CheckOSVersion(10, 14)) {
3125 if (wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW).Red() <
3132 if (NULL == ctrl)
return;
3134 wxColour col, window_back_color, gridline, uitext, udkrd, ctrl_back_color,
3136 col = GetGlobalColor(
"DILG0");
3137 window_back_color = GetGlobalColor(
"DILG1");
3138 ctrl_back_color = GetGlobalColor(
"DILG1");
3139 text_color = GetGlobalColor(
"DILG3");
3140 uitext = GetGlobalColor(
"UITX1");
3141 udkrd = GetGlobalColor(
"UDKRD");
3142 gridline = GetGlobalColor(
"GREY2");
3144 DimeControl(ctrl, col, window_back_color, ctrl_back_color, text_color, uitext,
3148void DimeControl(wxWindow *ctrl, wxColour col, wxColour window_back_color,
3149 wxColour ctrl_back_color, wxColour text_color, wxColour uitext,
3150 wxColour udkrd, wxColour gridline) {
3156 if (wxPlatformInfo::Get().CheckOSVersion(10, 14)) {
3161 ColorScheme cs = global_color_scheme;
3165 (cs == GLOBAL_COLOR_SCHEME_DUSK || cs == GLOBAL_COLOR_SCHEME_NIGHT);
3167 static int depth = 0;
3173 window_back_color = wxNullColour;
3175 window_back_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
3177 col = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
3178 uitext = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
3181 ctrl->SetBackgroundColour(window_back_color);
3182 if (darkMode) ctrl->SetForegroundColour(text_color);
3185 wxWindowList kids = ctrl->GetChildren();
3186 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
3187 wxWindowListNode *node = kids.Item(i);
3188 wxWindow *win = node->GetData();
3190 if (
dynamic_cast<wxListBox *
>(win) ||
dynamic_cast<wxListCtrl *
>(win) ||
3191 dynamic_cast<wxTextCtrl *
>(win) ||
3192 dynamic_cast<wxTimePickerCtrl *
>(win)) {
3193 win->SetBackgroundColour(col);
3194 }
else if (
dynamic_cast<wxStaticText *
>(win) ||
3195 dynamic_cast<wxCheckBox *
>(win) ||
3196 dynamic_cast<wxRadioButton *
>(win)) {
3197 win->SetForegroundColour(uitext);
3204 else if (
dynamic_cast<wxBitmapComboBox *
>(win) ||
3205 dynamic_cast<wxChoice *
>(win) ||
dynamic_cast<wxComboBox *
>(win) ||
3206 dynamic_cast<wxTreeCtrl *
>(win)) {
3207 win->SetBackgroundColour(col);
3210 else if (
dynamic_cast<wxScrolledWindow *
>(win) ||
3211 dynamic_cast<wxGenericDirCtrl *
>(win) ||
3212 dynamic_cast<wxListbook *
>(win) ||
dynamic_cast<wxButton *
>(win) ||
3213 dynamic_cast<wxToggleButton *
>(win)) {
3214 win->SetBackgroundColour(window_back_color);
3217 else if (
dynamic_cast<wxNotebook *
>(win)) {
3218 win->SetBackgroundColour(window_back_color);
3219 win->SetForegroundColour(text_color);
3223 else if (
dynamic_cast<wxHtmlWindow *
>(win)) {
3224 if (cs != GLOBAL_COLOR_SCHEME_DAY && cs != GLOBAL_COLOR_SCHEME_RGB)
3225 win->SetBackgroundColour(ctrl_back_color);
3227 win->SetBackgroundColour(wxNullColour);
3230 else if (
dynamic_cast<wxGrid *
>(win)) {
3231 dynamic_cast<wxGrid *
>(win)->SetDefaultCellBackgroundColour(
3233 dynamic_cast<wxGrid *
>(win)->SetDefaultCellTextColour(uitext);
3234 dynamic_cast<wxGrid *
>(win)->SetLabelBackgroundColour(col);
3235 dynamic_cast<wxGrid *
>(win)->SetLabelTextColour(uitext);
3236 dynamic_cast<wxGrid *
>(win)->SetGridLineColour(gridline);
3239 if (win->GetChildren().GetCount() > 0) {
3242 DimeControl(w, col, window_back_color, ctrl_back_color, text_color,
3243 uitext, udkrd, gridline);
ArrayOfMmsiProperties g_MMSI_Props_Array
Global instance.
unsigned g_OwnShipmmsi
Global instance.
Class AisDecoder and helpers.
Global state for AIS decoder.
Chart canvas configuration state
General chart base definitions.
Charts database management
ChartGroupArray * g_pGroupArray
Global instance.
Generic Chart canvas base.
Represents an individual component within a ChartGroup.
Represents a user-defined collection of logically related charts.
wxString GetFullConfigDesc(int i) const
Gets description of font at index i.
bool AddAuxKey(wxString key)
Adds new plugin-defined font configuration key.
void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc)
Loads font settings from a string descriptor.
static wxString GetFontConfigKey(const wxString &description)
Creates configuration key from UI element name by combining locale with hash.
int GetNumFonts(void) const
Gets the total number of font configurations currently loaded.
wxArrayString & GetAuxKeyArray()
Gets array of plugin-defined font configuration keys.
Represents a layer of chart objects in OpenCPN.
Process incoming AIS messages.
static int config_to_ui(double value)
Convert configuration 1.02..3.0 value to slider scale 1..100.
static double ui_to_config(int slider_pos)
Convert a slider scale 1-100 value to configuration value 1.02..3.0.
Represents a waypoint or mark within the navigation system.
Represents a navigational route in the navigation system.
Represents a track, which is a series of connected track points.
ViewPort - Core geographic projection and coordinate transformation engine.
double view_scale_ppm
Requested view scale in physical pixels per meter (ppm), before applying projections.
double rotation
Rotation angle of the viewport in radians.
double clon
Center longitude of the viewport in degrees.
double clat
Center latitude of the viewport in degrees.
Encapsulates persistent canvas configuration.
double iLat
Latitude of the center of the chart, in degrees.
bool bShowOutlines
Display chart outlines.
wxSize canvasSize
Canvas dimensions.
bool bShowDepthUnits
Display depth unit indicators.
double iLon
Longitude of the center of the chart, in degrees.
double iRotation
Initial rotation angle in radians.
bool bCourseUp
Orient display to course up.
bool bQuilt
Enable chart quilting.
bool bFollow
Enable vessel following mode.
double iScale
Initial chart scale factor.
bool bShowENCText
Display ENC text elements.
bool bShowAIS
Display AIS targets.
bool bShowGrid
Display coordinate grid.
ChartCanvas * canvas
Pointer to associated chart canvas.
bool bShowCurrents
Display current information.
bool bShowTides
Display tide information.
bool bLookahead
Enable lookahead mode.
bool bHeadUp
Orient display to heading up.
bool bAttenAIS
Enable AIS target attenuation.
Device context class that can use either wxDC or OpenGL for drawing.
Class cm93chart and helpers – CM93 chart state.
Global variables reflecting command line options and arguments.
Config file user configuration interface.
wxString g_datetime_format
Date/time format to use when formatting date/time strings.
bool g_always_send_rmb_rmc
Always send RMB and RMC n0183 messages even if there is no active route.
bool g_bsmoothpanzoom
Controls how the chart panning and zooming smoothing is done during user interactions.
int g_iTempFormat
User-selected temperature unit format for display and input.
int g_nDepthUnitDisplay
User-selected depth (below surface) unit format for display and input.
wxString g_default_font_facename
Default font size for user interface elements such as menus, dialogs, etc.
wxString g_winPluginDir
Base plugin directory on Windows.
bool g_bRollover
enable/disable mouse rollover GUI effects
int g_COGAvgSec
COG average period for Course Up Mode (sec)
int g_iSpeedFormat
User-selected speed unit format for display and input.
int g_iHeightFormat
User-selected height (vertical, above reference datum) unit format for display and input.
std::vector< size_t > g_config_display_size_mm
Size of pysical screen in millimeters.
int g_iDistanceFormat
User-selected distance (horizontal) unit format for display and input.
bool g_bDisplayGrid
Should lat/lon grid be displayed ?
Global variables stored in configuration file.
Extern C linked utilities.
std::vector< OCPN_MonitorInfo > g_monitor_info
Information about the monitors connected to the system.
NavmsgFilter Read(const std::string &name)
Read filter with given name from disk.
bool Write(const NavmsgFilter &filter, const std::string &name)
Write contents for given filter to disk.
OpenGL chart rendering canvas.
size_t g_current_monitor
Current monitor displaying main application frame.
double vLat
Virtual lat from chcanv popup.
double vLon
Virtual lon from chcanv popup.
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
GUI constant definitions.
Multiplexer class and helpers.
MySQL based storage for routes, tracks, etc.
MyConfig * pConfig
Global instance.
wxDateTime toUsrDateTime(const wxDateTime ts, const int format, const double lon)
Converts a timestamp from UTC to the user's preferred time format.
wxDateTime fromUsrDateTime(const wxDateTime ts, const int format, const double lon)
Converts a timestamp from a user's preferred time format to UTC.
MyConfig * pConfig
Global instance.
Navigation Utility Functions without GUI dependencies.
Global variables Listen()/Notify() wrapper.
PlugIn Object Definition/API.
Layer to use wxDC or opengl.
double gLat
Vessel's current latitude in decimal degrees.
double gLon
Vessel's current longitude in decimal degrees.
Position, course, speed, etc.
Tools to send data to plugins.
wxColour g_colourWaypointRangeRingsColour
Global instance.
int g_LayerIdx
Global instance.
#define LMTINPUT
Format date/time using the remote location LMT time.
#define GLOBAL_SETTINGS_INPUT
Format date/time according to global OpenCPN settings.
#define UTCINPUT
Format date/time in UTC.
#define LTINPUT
Format date/time using timezone configured in the operating system./*#end#*/.
RouteList * pRouteList
Global instance.
float g_ChartScaleFactorExp
Global instance.
Selected route, segment, waypoint, etc.
std::vector< Track * > g_TrackList
Global instance.
Recorded track abstraction.