47#include <wx/bmpcbox.h>
49#include "wx/dirctrl.h"
50#include <wx/filename.h>
51#include <wx/graphics.h>
53#include <wx/listbook.h>
54#include <wx/listimpl.cpp>
55#include <wx/progdlg.h>
56#include <wx/sstream.h>
58#include <wx/timectrl.h>
59#include <wx/tokenzr.h>
61#include "o_sound/o_sound.h"
69#include "model/geodesic.h"
74#include "model/nav_object_database.h"
105#include "snd_config.h"
108#include "user_colors.h"
115#include "androidUTIL.h"
119static bool g_bLayersLoaded;
126static const long long lNaN = 0xfff8000000000000;
127#define NAN (*(double *)&lNaN)
132wxArrayString *pMessageOnceArray;
134void InitGlobals() { pMessageOnceArray =
new wxArrayString(); }
136void DeinitGlobals() {
137 delete pMessageOnceArray;
138 pMessageOnceArray =
nullptr;
145wxString GetLayerName(
int id) {
146 wxString name(
"unknown layer");
147 if (
id <= 0)
return (name);
148 LayerList::iterator it;
150 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
152 if (lay->m_LayerID ==
id)
return (lay->m_LayerName);
158void appendOSDirSlash(wxString *pString);
165MyConfig::MyConfig(
const wxString &LocalFileName)
166 : wxFileConfig(
"",
"", LocalFileName,
"", wxCONFIG_USE_LOCAL_FILE) {}
168MyConfig::~MyConfig() {}
170unsigned MyConfig::ReadUnsigned(
const wxString &key,
unsigned default_val) {
172 unsigned long value = 0;
173 if (!
Read(key, &s))
return default_val;
175 value = std::stoul(s.ToStdString());
176 }
catch (std::logic_error &) {
179 if (value < 0 || value > std::numeric_limits<unsigned>::max())
181 return static_cast<unsigned>(value);
184int MyConfig::LoadMyConfig() {
185 int display_width, display_height;
191 g_TalkerIdText =
"EC";
192 g_maxWPNameLength = 6;
193 g_NMEAAPBPrecision = 3;
196 g_GLOptions.m_bUseAcceleratedPanning =
true;
197 g_GLOptions.m_GLPolygonSmoothing =
true;
198 g_GLOptions.m_GLLineSmoothing =
true;
199 g_GLOptions.m_iTextureDimension = 512;
200 g_GLOptions.m_iTextureMemorySize = 128;
202 g_GLOptions.m_iTextureMemorySize =
203 wxMax(128, g_GLOptions.m_iTextureMemorySize);
204 g_GLOptions.m_bTextureCompressionCaching =
205 g_GLOptions.m_bTextureCompression;
209 g_maintoolbar_orient = wxTB_HORIZONTAL;
210 g_iENCToolbarPosX = -1;
211 g_iENCToolbarPosY = -1;
212 g_restore_dbindex = -1;
213 g_ChartNotRenderScaleFactor = 1.5;
214 g_detailslider_dialog_x = 200L;
215 g_detailslider_dialog_y = 200L;
216 g_SENC_LOD_pixels = 2;
217 g_SkewCompUpdatePeriod = 10;
219 g_bShowStatusBar = 1;
220 g_bShowCompassWin = 1;
221 g_iSoundDeviceIndex = -1;
222 g_bFullscreenToolbar = 1;
223 g_bTransparentToolbar = 0;
225 g_bShowDepthUnits = 1;
226 g_bShowActiveRouteHighway = 1;
228 g_defaultBoatSpeed = 6.0;
229 g_ownship_predictor_minutes = 5;
230 g_cog_predictor_style = 105;
231 g_cog_predictor_color =
"rgb(255,0,0)";
232 g_cog_predictor_endmarker = 1;
233 g_ownship_HDTpredictor_style = 105;
234 g_ownship_HDTpredictor_color =
"rgb(255,0,0)";
235 g_ownship_HDTpredictor_endmarker = 1;
236 g_ownship_HDTpredictor_width = 0;
237 g_cog_predictor_width = 3;
238 g_ownship_HDTpredictor_miles = 1;
239 g_n_ownship_min_mm = 2;
240 g_bFullScreenQuilt = 1;
241 g_track_rotate_time_type = TIME_TYPE_COMPUTER;
242 g_bHighliteTracks = 1;
243 g_bPreserveScaleOnX = 1;
245 g_benableAISNameCache =
true;
246 g_n_arrival_circle_radius = 0.05;
247 g_plus_minus_zoom_factor = 2.0;
248 g_mouse_zoom_sensitivity = 1.5;
251 g_AISShowTracks_Mins = 20;
252 g_AISShowTracks_Limit = 300.0;
253 g_ShowScaled_Num = 10;
254 g_ScaledNumWeightSOG = 50;
255 g_ScaledNumWeightCPA = 60;
256 g_ScaledNumWeightTCPA = 25;
257 g_ScaledSizeMinimal = 50;
258 g_ScaledNumWeightRange = 75;
259 g_ScaledNumWeightSizeOfT = 25;
260 g_Show_Target_Name_Scale = 250000;
261 g_bWplUsePosition = 0;
263 g_ais_cog_predictor_width = 3;
264 g_ais_alert_dialog_sx = 200;
265 g_ais_alert_dialog_sy = 200;
266 g_ais_alert_dialog_x = 200;
267 g_ais_alert_dialog_y = 200;
268 g_ais_query_dialog_x = 200;
269 g_ais_query_dialog_y = 200;
270 g_AisTargetList_range = 40;
271 g_AisTargetList_sortColumn = 2;
272 g_S57_dialog_sx = 400;
273 g_S57_dialog_sy = 400;
274 g_S57_extradialog_sx = 400;
275 g_S57_extradialog_sy = 400;
284 g_iNavAidRadarRingsNumberVisible = 0;
285 g_bNavAidRadarRingsShown =
false;
286 g_fNavAidRadarRingsStep = 1.0;
287 g_pNavAidRadarRingsStepUnits = 0;
288 g_colourOwnshipRangeRingsColour = *wxRED;
289 g_iWaypointRangeRingsNumber = 0;
290 g_fWaypointRangeRingsStep = 1.0;
291 g_iWaypointRangeRingsStepUnits = 0;
293 g_bConfirmObjectDelete =
true;
295 g_TrackIntervalSeconds = 60.0;
296 g_TrackDeltaDistance = 0.10;
297 g_route_line_width = 2;
298 g_track_line_width = 2;
299 g_colourTrackLineColour = wxColour(243, 229, 47);
302 g_default_wp_icon =
"triangle";
303 g_default_routepoint_icon =
"diamond";
307 g_ObjQFileExt =
"txt,rtf,png,html,gif,tif,jpg";
310 int ret_Val = LoadMyConfigRaw();
315 g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor);
316 g_ShipScaleFactorExp =
317 g_Platform->GetChartScaleFactorExp(g_ShipScaleFactor);
318 g_MarkScaleFactorExp =
319 g_Platform->GetMarkScaleFactorExp(g_ChartScaleFactor);
321 g_COGFilterSec = wxMin(g_COGFilterSec, kMaxCogsogFilterSeconds);
322 g_COGFilterSec = wxMax(g_COGFilterSec, 1);
323 g_SOGFilterSec = g_COGFilterSec;
325 if (!g_bShowTrue && !g_bShowMag) g_bShowTrue =
true;
329 if (g_bInlandEcdis) g_bLookAhead = 1;
331 if (g_bdisable_opengl) g_bopengl =
false;
335 g_GLOptions.m_iTextureMemorySize =
336 wxMax(128, g_GLOptions.m_iTextureMemorySize);
337 g_GLOptions.m_bTextureCompressionCaching =
338 g_GLOptions.m_bTextureCompression;
342 g_chart_zoom_modifier_raster = wxMin(g_chart_zoom_modifier_raster, 5);
343 g_chart_zoom_modifier_raster = wxMax(g_chart_zoom_modifier_raster, -5);
344 g_chart_zoom_modifier_vector = wxMin(g_chart_zoom_modifier_vector, 5);
345 g_chart_zoom_modifier_vector = wxMax(g_chart_zoom_modifier_vector, -5);
346 g_cm93_zoom_factor = wxMin(g_cm93_zoom_factor, CM93_ZOOM_FACTOR_MAX_RANGE);
348 wxMax(g_cm93_zoom_factor, (-CM93_ZOOM_FACTOR_MAX_RANGE));
350 g_tile_basemap_zoom_factor = 4.0;
352 if ((g_detailslider_dialog_x < 0) ||
353 (g_detailslider_dialog_x > display_width))
354 g_detailslider_dialog_x = 5;
355 if ((g_detailslider_dialog_y < 0) ||
356 (g_detailslider_dialog_y > display_height))
357 g_detailslider_dialog_y = 5;
359 g_defaultBoatSpeedUserUnit = toUsrSpeed(g_defaultBoatSpeed, -1);
360 g_n_ownship_min_mm = wxMax(g_n_ownship_min_mm, 2);
362 if (g_navobjbackups > 99) g_navobjbackups = 99;
363 if (g_navobjbackups < 0) g_navobjbackups = 0;
364 g_n_arrival_circle_radius = wxClip(g_n_arrival_circle_radius, 0.001, 0.6);
366 g_selection_radius_mm = wxMax(g_selection_radius_mm, 0.5);
367 g_selection_radius_touch_mm = wxMax(g_selection_radius_touch_mm, 1.0);
369 g_Show_Target_Name_Scale = wxMax(5000, g_Show_Target_Name_Scale);
371 if ((g_ais_alert_dialog_x < 0) || (g_ais_alert_dialog_x > display_width))
372 g_ais_alert_dialog_x = 5;
373 if ((g_ais_alert_dialog_y < 0) || (g_ais_alert_dialog_y > display_height))
374 g_ais_alert_dialog_y = 5;
375 if ((g_ais_query_dialog_x < 0) || (g_ais_query_dialog_x > display_width))
376 g_ais_query_dialog_x = 5;
377 if ((g_ais_query_dialog_y < 0) || (g_ais_query_dialog_y > display_height))
378 g_ais_query_dialog_y = 5;
380 SwitchInlandEcdisMode(g_bInlandEcdis);
382 global_color_scheme =
383 GLOBAL_COLOR_SCHEME_DUSK;
392int MyConfig::LoadMyConfigRaw(
bool bAsTemplate) {
396 int display_width, display_height;
401 SetPath(
"/Settings");
402 Read(
"ActiveRoute", &g_active_route);
403 Read(
"PersistActiveRoute", &g_persist_active_route);
405 Read(
"LastAppliedTemplate", &g_lastAppliedTemplateGUID);
406 Read(
"CompatOS", &g_compatOS);
407 Read(
"CompatOsVersion", &g_compatOsVersion);
410 Read(
"ConfigVersionString", &g_config_version_string);
411 Read(
"CmdSoundString", &g_CmdSoundString, wxString(OCPN_SOUND_CMD));
412 if (wxIsEmpty(g_CmdSoundString)) g_CmdSoundString = wxString(OCPN_SOUND_CMD);
413 Read(
"NavMessageShown", &n_NavMessageShown);
415 Read(
"AndroidVersionCode", &g_AndroidVersionCode);
417 Read(
"UIexpert", &g_bUIexpert);
419 Read(
"UIStyle", &g_uiStyle);
421 Read(
"NCacheLimit", &g_nCacheLimit);
427 Read(
"SpaceDropMark", &g_bSpaceDropMark);
430 Read(
"MEMCacheLimit", &mem_limit);
432 g_memCacheLimit = mem_limit * 1024;
434 Read(
"UseModernUI5", &g_useMUI);
436 Read(
"NCPUCount", &g_nCPUCount);
438 Read(
"DebugGDAL", &g_bGDAL_Debug);
439 Read(
"DebugNMEA", &g_nNMEADebug);
440 Read(
"AnchorWatchDefault", &g_nAWDefault);
441 Read(
"AnchorWatchMax", &g_nAWMax);
442 Read(
"GPSDogTimeout", &gps_watchdog_timeout_ticks);
443 Read(
"DebugCM93", &g_bDebugCM93);
446 Read(
"DebugBSBImg", &g_BSBImgDebug);
447 Read(
"DebugGPSD", &g_bDebugGPSD);
448 Read(
"MaxZoomScale", &g_maxzoomin);
449 g_maxzoomin = wxMax(g_maxzoomin, 50);
451 Read(
"DefaultFontSize", &g_default_font_size);
454 Read(
"UseGreenShipIcon", &g_bUseGreenShip);
456 Read(
"AutoHideToolbar", &g_bAutoHideToolbar);
457 Read(
"AutoHideToolbarSecs", &g_nAutoHideToolbar);
459 Read(
"UseSimplifiedScalebar", &g_bsimplifiedScalebar);
461 Read(
"ShowCurrent", &g_bShowCurrent);
464 Read(
"DisplaySizeMM", &size_mm);
466 Read(
"SelectionRadiusMM", &g_selection_radius_mm);
467 Read(
"SelectionRadiusTouchMM", &g_selection_radius_touch_mm);
471 wxStringTokenizer tokenizer(size_mm,
",");
472 while (tokenizer.HasMoreTokens()) {
473 wxString token = tokenizer.GetNextToken();
476 size = std::stoi(token.ToStdString());
477 }
catch (std::invalid_argument &e) {
480 if (size > 100 && size < 2000) {
486 Read(
"DisplaySizeManual", &g_config_display_size_manual);
489 Read(
"GUIScaleFactor", &g_GUIScaleFactor);
491 Read(
"ChartObjectScaleFactor", &g_ChartScaleFactor);
492 Read(
"ShipScaleFactor", &g_ShipScaleFactor);
493 Read(
"ENCSoundingScaleFactor", &g_ENCSoundingScaleFactor);
494 Read(
"ENCTextScaleFactor", &g_ENCTextScaleFactor);
495 Read(
"ObjQueryAppendFilesExt", &g_ObjQFileExt);
498 Read(
"CatalogCustomURL", &g_catalog_custom_url);
499 Read(
"CatalogChannel", &g_catalog_channel);
501 Read(
"NetmaskBits", &g_netmask_bits);
505 Read(
"FilterNMEA_Avg", &g_bfilter_cogsog);
506 Read(
"FilterNMEA_Sec", &g_COGFilterSec);
507 Read(
"GPSIdent", &g_GPS_Ident);
508 Read(
"UseGarminHostUpload", &g_bGarminHostUpload);
509 Read(
"UseNMEA_GLL", &g_bUseGLL);
510 Read(
"UseMagAPB", &g_bMagneticAPB);
511 Read(
"TrackContinuous", &g_btrackContinuous,
false);
512 Read(
"FilterTrackDropLargeJump", &g_trackFilterMax, 1000);
515 Read(
"ShowTrue", &g_bShowTrue);
516 Read(
"ShowMag", &g_bShowMag);
519 Read(
"UserMagVariation", &umv);
520 if (umv.Len()) umv.ToDouble(&g_UserVar);
522 Read(
"ScreenBrightness", &g_nbrightness);
524 Read(
"MemFootprintTargetMB", &g_MemFootMB);
526 Read(
"WindowsComPortMax", &g_nCOMPortCheck);
528 Read(
"ChartQuilting", &g_bQuiltEnable);
529 Read(
"ChartQuiltingInitial", &g_bQuiltStart);
531 Read(
"CourseUpMode", &g_bCourseUp);
533 Read(
"LookAheadMode", &g_bLookAhead);
534 Read(
"SkewToNorthUp", &g_bskew_comp);
535 Read(
"TenHzUpdate", &g_btenhertz, 0);
536 Read(
"DeclutterAnchorage", &g_declutter_anchorage, 0);
538 Read(
"NMEAAPBPrecision", &g_NMEAAPBPrecision);
540 Read(
"TalkerIdText", &g_TalkerIdText);
541 Read(
"MaxWaypointNameLength", &g_maxWPNameLength);
542 Read(
"MbtilesMaxLayers", &g_mbtilesMaxLayers);
544 Read(
"ShowTrackPointTime", &g_bShowTrackPointTime,
true);
548 Read(
"OpenGLExpert", &g_bGLexpert,
false);
549 Read(
"UseAcceleratedPanning", &g_GLOptions.m_bUseAcceleratedPanning,
true);
550 Read(
"GPUTextureCompression", &g_GLOptions.m_bTextureCompression);
551 Read(
"GPUTextureCompressionCaching",
552 &g_GLOptions.m_bTextureCompressionCaching);
553 Read(
"PolygonSmoothing", &g_GLOptions.m_GLPolygonSmoothing);
554 Read(
"LineSmoothing", &g_GLOptions.m_GLLineSmoothing);
555 Read(
"GPUTextureDimension", &g_GLOptions.m_iTextureDimension);
556 Read(
"GPUTextureMemSize", &g_GLOptions.m_iTextureMemorySize);
557 Read(
"DebugOpenGL", &g_bDebugOGL);
558 Read(
"OpenGL", &g_bopengl);
559 Read(
"OpenGLFinishNeeded", &g_b_needFinish);
560 Read(
"SoftwareGL", &g_bSoftwareGL);
566 Read(
"ToolbarX", &g_maintoolbar_x);
567 Read(
"ToolbarY", &g_maintoolbar_y);
568 Read(
"ToolbarOrient", &g_maintoolbar_orient);
569 Read(
"GlobalToolbarConfig", &g_toolbarConfig);
571 Read(
"iENCToolbarX", &g_iENCToolbarPosX);
572 Read(
"iENCToolbarY", &g_iENCToolbarPosY);
574 Read(
"AnchorWatch1GUID", &g_AW1GUID);
575 Read(
"AnchorWatch2GUID", &g_AW2GUID);
577 Read(
"InitialStackIndex", &g_restore_stackindex);
578 Read(
"InitialdBIndex", &g_restore_dbindex);
580 Read(
"ChartNotRenderScaleFactor", &g_ChartNotRenderScaleFactor);
582 Read(
"MobileTouch", &g_btouch);
587 g_bresponsive =
true;
589 g_bresponsive =
false;
594 Read(
"ZoomDetailFactor", &g_chart_zoom_modifier_raster);
595 Read(
"ZoomDetailFactorVector", &g_chart_zoom_modifier_vector);
596 Read(
"PlusMinusZoomFactor", &g_plus_minus_zoom_factor, 2.0);
597 Read(
"MouseZoomSensitivity", &g_mouse_zoom_sensitivity, 1.3);
598 g_mouse_zoom_sensitivity_ui =
600 Read(
"CM93DetailFactor", &g_cm93_zoom_factor);
601 Read(
"TileBasemapZoomFactor", &g_tile_basemap_zoom_factor);
603 Read(
"CM93DetailZoomPosX", &g_detailslider_dialog_x);
604 Read(
"CM93DetailZoomPosY", &g_detailslider_dialog_y);
605 Read(
"ShowCM93DetailSlider", &g_bShowDetailSlider);
607 Read(
"SENC_LOD_Pixels", &g_SENC_LOD_pixels);
609 Read(
"SkewCompUpdatePeriod", &g_SkewCompUpdatePeriod);
611 Read(
"SetSystemTime", &s_bSetSystemTime);
612 Read(
"EnableKioskStartup", &g_kiosk_startup);
613 Read(
"DisableNotifications", &g_disableNotifications, 0);
614 Read(
"ShowStatusBar", &g_bShowStatusBar);
616 Read(
"ShowMenuBar", &g_bShowMenuBar);
618 Read(
"Fullscreen", &g_bFullscreen);
619 Read(
"ShowCompassWindow", &g_bShowCompassWin);
621 Read(
"PlayShipsBells", &g_bPlayShipsBells);
622 Read(
"SoundDeviceIndex", &g_iSoundDeviceIndex);
623 Read(
"FullscreenToolbar", &g_bFullscreenToolbar);
624 Read(
"PermanentMOBIcon", &g_bPermanentMOBIcon);
625 Read(
"ShowLayers", &g_bShowLayers);
626 Read(
"ShowDepthUnits", &g_bShowDepthUnits);
627 Read(
"AutoAnchorDrop", &g_bAutoAnchorMark);
628 Read(
"ShowChartOutlines", &g_bShowOutlines);
629 Read(
"ShowActiveRouteHighway", &g_bShowActiveRouteHighway);
630 Read(
"ShowActiveRouteTotal", &g_bShowRouteTotal);
631 Read(
"MostRecentGPSUploadConnection", &g_uploadConnection);
632 Read(
"ShowChartBar", &g_bShowChartBar);
637 Read(
"DistanceFormat",
642 Read(
"WindSpeedFormat",
643 &g_iWindSpeedFormat);
648 Read(
"LiveETA", &g_bShowLiveETA);
649 Read(
"DefaultBoatSpeed", &g_defaultBoatSpeed);
651 Read(
"OwnshipCOGPredictorMinutes", &g_ownship_predictor_minutes);
652 Read(
"OwnshipCOGPredictorStyle", &g_cog_predictor_style);
653 Read(
"OwnshipCOGPredictorColor", &g_cog_predictor_color);
654 Read(
"OwnshipCOGPredictorEndmarker", &g_cog_predictor_endmarker);
655 Read(
"OwnshipCOGPredictorWidth", &g_cog_predictor_width);
656 Read(
"OwnshipHDTPredictorStyle", &g_ownship_HDTpredictor_style);
657 Read(
"OwnshipHDTPredictorColor", &g_ownship_HDTpredictor_color);
658 Read(
"OwnshipHDTPredictorEndmarker", &g_ownship_HDTpredictor_endmarker);
659 Read(
"OwnshipHDTPredictorWidth", &g_ownship_HDTpredictor_width);
660 Read(
"OwnshipHDTPredictorMiles", &g_ownship_HDTpredictor_miles);
662 Read(
"OwnShipMMSINumber", &mmsi);
664 Read(
"OwnShipIconType", &g_OwnShipIconType);
665 Read(
"OwnShipLength", &g_n_ownship_length_meters);
666 Read(
"OwnShipWidth", &g_n_ownship_beam_meters);
667 Read(
"OwnShipGPSOffsetX", &g_n_gps_antenna_offset_x);
668 Read(
"OwnShipGPSOffsetY", &g_n_gps_antenna_offset_y);
669 Read(
"OwnShipMinSize", &g_n_ownship_min_mm);
670 Read(
"ShowDirectRouteLine", &g_bShowShipToActive);
671 Read(
"DirectRouteLineStyle", &g_shipToActiveStyle);
672 Read(
"DirectRouteLineColor", &g_shipToActiveColor);
675 Read(
"RouteArrivalCircleRadius", &racr);
676 if (racr.Len()) racr.ToDouble(&g_n_arrival_circle_radius);
678 Read(
"FullScreenQuilt", &g_bFullScreenQuilt);
680 Read(
"StartWithTrackActive", &g_bTrackCarryOver);
681 Read(
"AutomaticDailyTracks", &g_bTrackDaily);
682 Read(
"TrackRotateAt", &g_track_rotate_time);
683 Read(
"TrackRotateTimeType", &g_track_rotate_time_type);
684 Read(
"HighlightTracks", &g_bHighliteTracks);
689 Read(
"PlanSpeed", &stps);
690 if (!stps.IsEmpty()) stps.ToDouble(&g_PlanSpeed);
692 Read(
"VisibleLayers", &g_VisibleLayers);
693 Read(
"InvisibleLayers", &g_InvisibleLayers);
694 Read(
"VisNameInLayers", &g_VisiNameinLayers);
695 Read(
"InvisNameInLayers", &g_InVisiNameinLayers);
697 Read(
"PreserveScaleOnX", &g_bPreserveScaleOnX);
699 Read(
"ShowMUIZoomButtons", &g_bShowMuiZoomButtons);
701 Read(
"Locale", &g_locale);
702 Read(
"LocaleOverride", &g_localeOverride);
705 Read(
"KeepNavobjBackups", &g_navobjbackups);
709 Read(
"LegacyInputCOMPortFilterBehaviour", &g_b_legacy_input_filter_behaviour);
712 Read(
"AdvanceRouteWaypointOnArrivalOnly",
713 &g_bAdvanceRouteWaypointOnArrivalOnly);
714 Read(
"EnableRootMenuDebug", &g_enable_root_menu_debug);
716 Read(
"EnableRotateKeys", &g_benable_rotate);
717 Read(
"EmailCrashReport", &g_bEmailCrashReport);
719 g_benableAISNameCache =
true;
720 Read(
"EnableAISNameCache", &g_benableAISNameCache);
722 Read(
"EnableUDPNullHeader", &g_benableUDPNullHeader);
724 SetPath(
"/Settings/GlobalState");
726 Read(
"FrameWinX", &g_nframewin_x);
727 Read(
"FrameWinY", &g_nframewin_y);
728 Read(
"FrameWinPosX", &g_nframewin_posx);
729 Read(
"FrameWinPosY", &g_nframewin_posy);
730 Read(
"FrameMax", &g_bframemax);
732 Read(
"ClientPosX", &g_lastClientRectx);
733 Read(
"ClientPosY", &g_lastClientRecty);
734 Read(
"ClientSzX", &g_lastClientRectw);
735 Read(
"ClientSzY", &g_lastClientRecth);
737 Read(
"RoutePropSizeX", &g_route_prop_sx);
738 Read(
"RoutePropSizeY", &g_route_prop_sy);
739 Read(
"RoutePropPosX", &g_route_prop_x);
740 Read(
"RoutePropPosY", &g_route_prop_y);
742 Read(
"AllowArbitrarySystemPlugins", &g_allow_arb_system_plugin);
745 Read(
"S52_DEPTH_UNIT_SHOW", &read_int);
747 read_int = wxMax(read_int, 0);
748 read_int = wxMin(read_int, 2);
753 SetPath(
"/Settings/Audio");
756 wxString sound_dir = g_Platform->GetSharedDataDir();
757 sound_dir.Append(
"sounds");
758 sound_dir.Append(wxFileName::GetPathSeparator());
760 g_AIS_sound_file = sound_dir +
"beep_ssl.wav";
761 g_DSC_sound_file = sound_dir +
"phonering1.wav";
762 g_SART_sound_file = sound_dir +
"beep3.wav";
763 g_anchorwatch_sound_file = sound_dir +
"beep1.wav";
765 Read(
"AISAlertSoundFile", &g_AIS_sound_file);
766 Read(
"DSCAlertSoundFile", &g_DSC_sound_file);
767 Read(
"SARTAlertSoundFile", &g_SART_sound_file);
768 Read(
"AnchorAlarmSoundFile", &g_anchorwatch_sound_file);
770 Read(
"bAIS_GCPA_AlertAudio", &g_bAIS_GCPA_Alert_Audio);
771 Read(
"bAIS_SART_AlertAudio", &g_bAIS_SART_Alert_Audio);
772 Read(
"bAIS_DSC_AlertAudio", &g_bAIS_DSC_Alert_Audio);
773 Read(
"bAnchorAlertAudio", &g_bAnchor_Alert_Audio);
777 SetPath(
"/Settings/AIS");
779 g_bUseOnlyConfirmedAISName =
false;
780 Read(
"UseOnlyConfirmedAISName", &g_bUseOnlyConfirmedAISName);
782 Read(
"bNoCPAMax", &g_bCPAMax);
784 Read(
"NoCPAMaxNMi", &s);
785 s.ToDouble(&g_CPAMax_NM);
787 Read(
"bCPAWarn", &g_bCPAWarn);
789 Read(
"CPAWarnNMi", &s);
790 s.ToDouble(&g_CPAWarn_NM);
792 Read(
"bTCPAMax", &g_bTCPA_Max);
794 Read(
"TCPAMaxMinutes", &s);
795 s.ToDouble(&g_TCPA_Max);
797 Read(
"bMarkLostTargets", &g_bMarkLost);
799 Read(
"MarkLost_Minutes", &s);
800 s.ToDouble(&g_MarkLost_Mins);
802 Read(
"bRemoveLostTargets", &g_bRemoveLost);
804 Read(
"RemoveLost_Minutes", &s);
805 s.ToDouble(&g_RemoveLost_Mins);
807 Read(
"bShowCOGArrows", &g_bShowCOG);
809 Read(
"bSyncCogPredictors", &g_bSyncCogPredictors);
811 Read(
"CogArrowMinutes", &s);
812 s.ToDouble(&g_ShowCOG_Mins);
814 Read(
"bShowTargetTracks", &g_bAISShowTracks);
816 if (
Read(
"TargetTracksLimit", &s)) {
817 s.ToDouble(&g_AISShowTracks_Limit);
818 g_AISShowTracks_Limit = wxMax(300.0, g_AISShowTracks_Limit);
820 if (
Read(
"TargetTracksMinutes", &s)) {
821 s.ToDouble(&g_AISShowTracks_Mins);
822 g_AISShowTracks_Mins = wxMax(1.0, g_AISShowTracks_Mins);
823 g_AISShowTracks_Mins = wxMin(g_AISShowTracks_Limit, g_AISShowTracks_Mins);
826 Read(
"bHideMooredTargets", &g_bHideMoored);
827 if (
Read(
"MooredTargetMaxSpeedKnots", &s)) s.ToDouble(&g_ShowMoored_Kts);
829 g_SOGminCOG_kts = 0.2;
830 if (
Read(
"SOGMinimumForCOGDisplay", &s)) s.ToDouble(&g_SOGminCOG_kts);
832 Read(
"bShowScaledTargets", &g_bAllowShowScaled);
833 Read(
"AISScaledNumber", &g_ShowScaled_Num);
834 Read(
"AISScaledNumberWeightSOG", &g_ScaledNumWeightSOG);
835 Read(
"AISScaledNumberWeightCPA", &g_ScaledNumWeightCPA);
836 Read(
"AISScaledNumberWeightTCPA", &g_ScaledNumWeightTCPA);
837 Read(
"AISScaledNumberWeightRange", &g_ScaledNumWeightRange);
838 Read(
"AISScaledNumberWeightSizeOfTarget", &g_ScaledNumWeightSizeOfT);
839 Read(
"AISScaledSizeMinimal", &g_ScaledSizeMinimal);
840 Read(
"AISShowScaled", &g_bShowScaled);
842 Read(
"bShowAreaNotices", &g_bShowAreaNotices);
843 Read(
"bDrawAISSize", &g_bDrawAISSize);
844 Read(
"bDrawAISRealtime", &g_bDrawAISRealtime);
845 Read(
"bShowAISName", &g_bShowAISName);
846 Read(
"AISRealtimeMinSpeedKnots", &g_AIS_RealtPred_Kts, 0.7);
847 Read(
"bAISAlertDialog", &g_bAIS_CPA_Alert);
848 Read(
"ShowAISTargetNameScale", &g_Show_Target_Name_Scale);
849 Read(
"bWplIsAprsPositionReport", &g_bWplUsePosition);
850 Read(
"WplSelAction", &g_WplAction);
851 Read(
"AISCOGPredictorWidth", &g_ais_cog_predictor_width);
853 Read(
"bAISAlertAudio", &g_bAIS_CPA_Alert_Audio);
854 Read(
"AISAlertAudioFile", &g_sAIS_Alert_Sound_File);
855 Read(
"bAISAlertSuppressMoored", &g_bAIS_CPA_Alert_Suppress_Moored);
857 Read(
"bAISAlertAckTimeout", &g_bAIS_ACK_Timeout);
858 if (
Read(
"AlertAckTimeoutMinutes", &s)) s.ToDouble(&g_AckTimeout_Mins);
860 Read(
"AlertDialogSizeX", &g_ais_alert_dialog_sx);
861 Read(
"AlertDialogSizeY", &g_ais_alert_dialog_sy);
862 Read(
"AlertDialogPosX", &g_ais_alert_dialog_x);
863 Read(
"AlertDialogPosY", &g_ais_alert_dialog_y);
864 Read(
"QueryDialogPosX", &g_ais_query_dialog_x);
865 Read(
"QueryDialogPosY", &g_ais_query_dialog_y);
867 Read(
"AISTargetListPerspective", &g_AisTargetList_perspective);
868 Read(
"AISTargetListRange", &g_AisTargetList_range);
869 Read(
"AISTargetListSortColumn", &g_AisTargetList_sortColumn);
870 Read(
"bAISTargetListSortReverse", &g_bAisTargetList_sortReverse);
871 Read(
"AISTargetListColumnSpec", &g_AisTargetList_column_spec);
872 Read(
"AISTargetListColumnOrder", &g_AisTargetList_column_order);
874 Read(
"bAISRolloverShowClass", &g_bAISRolloverShowClass);
875 Read(
"bAISRolloverShowCOG", &g_bAISRolloverShowCOG);
876 Read(
"bAISRolloverShowCPA", &g_bAISRolloverShowCPA);
877 Read(
"AISAlertDelay", &g_AIS_alert_delay);
879 Read(
"S57QueryDialogSizeX", &g_S57_dialog_sx);
880 Read(
"S57QueryDialogSizeY", &g_S57_dialog_sy);
881 Read(
"S57QueryExtraDialogSizeX", &g_S57_extradialog_sx);
882 Read(
"S57QueryExtraDialogSizeY", &g_S57_extradialog_sy);
884 wxString strpres(
"PresentationLibraryData");
886 SetPath(
"/Directories");
887 Read(strpres, &valpres);
888 if (!valpres.IsEmpty()) g_UserPresLibData = valpres;
890 wxString strs(
"SENCFileLocation");
891 SetPath(
"/Directories");
894 if (!vals.IsEmpty()) g_SENCPrefix = vals;
896 SetPath(
"/Directories");
898 Read(
"InitChartDir", &vald);
900 wxString dirnamed(vald);
901 if (!dirnamed.IsEmpty()) {
902 if (pInit_Chart_Dir->IsEmpty())
904 pInit_Chart_Dir->Clear();
905 pInit_Chart_Dir->Append(vald);
909 Read(
"GPXIODir", &g_gpx_path);
910 Read(
"TCDataDir", &g_TCData_Dir);
911 Read(
"BasemapDir", &gWorldMapLocation);
912 Read(
"BaseShapefileDir", &gWorldShapefileLocation);
914 wxLogMessage(
"winPluginDir, read from ini file: %s",
917 SetPath(
"/Settings/GlobalState");
919 if (
Read(
"nColorScheme", &read_int))
920 global_color_scheme = (ColorScheme)read_int;
923 SetPath(
"/Settings/NMEADataSource");
925 TheConnectionParams().clear();
926 wxString connectionconfigs;
927 Read(
"DataConnections", &connectionconfigs);
928 if (!connectionconfigs.IsEmpty()) {
929 wxArrayString confs = wxStringTokenize(connectionconfigs,
"|");
930 for (
size_t i = 0; i < confs.Count(); i++) {
933 wxLogMessage(
"Skipped invalid DataStream config");
937 TheConnectionParams().push_back(prm);
942 SetPath(
"/Settings/GlobalState");
945 double st_lat, st_lon;
946 if (
Read(
"VPLatLon", &st)) {
947 sscanf(st.mb_str(wxConvUTF8),
"%lf,%lf", &st_lat, &st_lon);
950 if (fabs(st_lon) < 360.) {
951 while (st_lon < -180.) st_lon += 360.;
953 while (st_lon > 180.) st_lon -= 360.;
958 if (fabs(st_lat) < 90.0)
vLat = st_lat;
960 s.Printf(
"Setting Viewpoint Lat/Lon %g, %g",
vLat,
vLon);
964 double st_view_scale, st_rotation;
965 if (
Read(wxString(
"VPScale"), &st)) {
966 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_view_scale);
968 st_view_scale = fmax(st_view_scale, .001 / 32);
969 st_view_scale = fmin(st_view_scale, 4);
972 if (
Read(wxString(
"VPRotation"), &st)) {
973 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_rotation);
975 st_rotation = fmin(st_rotation, 360);
976 st_rotation = fmax(st_rotation, 0);
981 if (
Read(
"OwnShipLatLon", &sll)) {
982 sscanf(sll.mb_str(wxConvUTF8),
"%lf,%lf", &lat, &lon);
985 if (fabs(lon) < 360.) {
986 while (lon < -180.) lon += 360.;
988 while (lon > 180.) lon -= 360.;
993 if (fabs(lat) < 90.0)
gLat = lat;
995 s.Printf(
"Setting Ownship Lat/Lon %g, %g",
gLat,
gLon);
1002 SetPath(
"/Settings/AuxFontKeys");
1007 bool bContk = GetFirstEntry(strk, dummyk);
1008 bool bNewKey =
false;
1011 bNewKey = FontMgr::Get().
AddAuxKey(kval);
1012 if (!bAsTemplate && !bNewKey) {
1016 bContk = GetNextEntry(strk, dummyk);
1020 SetPath(
"/Settings/X11Fonts");
1024 SetPath(
"/Settings/GTKFonts");
1028 SetPath(
"/Settings/MSWFonts");
1032 SetPath(
"/Settings/MacFonts");
1036 SetPath(
"/Settings/QTFonts");
1042 wxArrayString deleteList;
1044 bool bCont = GetFirstEntry(str, dummy);
1048 if (str.StartsWith(
"Font")) {
1051 deleteList.Add(str);
1052 wxString oldKey = pval.BeforeFirst(_T(
':'));
1056 if (pval.IsEmpty() || pval.StartsWith(
":")) {
1057 deleteList.Add(str);
1061 bCont = GetNextEntry(str, dummy);
1064 for (
unsigned int i = 0; i < deleteList.Count(); i++) {
1065 DeleteEntry(deleteList[i]);
1070 SetPath(
"/TideCurrentDataSources");
1071 if (GetNumberOfEntries()) {
1072 TideCurrentDataSet.clear();
1075 bool bCont = GetFirstEntry(str, dummy);
1082 if (std::find(TideCurrentDataSet.begin(), TideCurrentDataSet.end(),
1083 val.ToStdString()) == TideCurrentDataSet.end()) {
1084 TideCurrentDataSet.push_back(val.ToStdString());
1086 bCont = GetNextEntry(str, dummy);
1096 SetPath(
"/Settings/Others");
1099 Read(
"RadarRingsNumberVisible", &val);
1100 if (val.Length() > 0) g_iNavAidRadarRingsNumberVisible = atoi(val.mb_str());
1101 g_bNavAidRadarRingsShown = g_iNavAidRadarRingsNumberVisible > 0;
1103 Read(
"RadarRingsStep", &val);
1104 if (val.Length() > 0) g_fNavAidRadarRingsStep = atof(val.mb_str());
1106 Read(
"RadarRingsStepUnits", &g_pNavAidRadarRingsStepUnits);
1108 wxString l_wxsOwnshipRangeRingsColour;
1109 Read(
"RadarRingsColour", &l_wxsOwnshipRangeRingsColour);
1110 if (l_wxsOwnshipRangeRingsColour.Length())
1111 g_colourOwnshipRangeRingsColour.Set(l_wxsOwnshipRangeRingsColour);
1114 Read(
"WaypointRangeRingsNumber", &val);
1115 if (val.Length() > 0) g_iWaypointRangeRingsNumber = atoi(val.mb_str());
1117 Read(
"WaypointRangeRingsStep", &val);
1118 if (val.Length() > 0) g_fWaypointRangeRingsStep = atof(val.mb_str());
1120 Read(
"WaypointRangeRingsStepUnits", &g_iWaypointRangeRingsStepUnits);
1122 wxString l_wxsWaypointRangeRingsColour;
1123 Read(
"WaypointRangeRingsColour", &l_wxsWaypointRangeRingsColour);
1126 if (!
Read(
"WaypointUseScaMin", &g_bUseWptScaMin)) g_bUseWptScaMin =
false;
1127 if (!
Read(
"WaypointScaMinValue", &g_iWpt_ScaMin)) g_iWpt_ScaMin = 2147483646;
1128 if (!
Read(
"WaypointScaMaxValue", &g_iWpt_ScaMax)) g_iWpt_ScaMax = 0;
1129 if (!
Read(
"WaypointUseScaMinOverrule", &g_bOverruleScaMin))
1130 g_bOverruleScaMin =
false;
1131 if (!
Read(
"WaypointsShowName", &g_bShowWptName)) g_bShowWptName =
true;
1132 if (!
Read(
"UserIconsFirst", &g_bUserIconsFirst)) g_bUserIconsFirst =
true;
1135 bool b300RadarRings =
true;
1136 if (
Read(
"ShowRadarRings", &b300RadarRings)) {
1137 if (!b300RadarRings) g_iNavAidRadarRingsNumberVisible = 0;
1140 Read(
"ConfirmObjectDeletion", &g_bConfirmObjectDelete);
1143 g_bWayPointPreventDragging =
false;
1144 Read(
"WaypointPreventDragging", &g_bWayPointPreventDragging);
1146 g_bEnableZoomToCursor =
false;
1147 Read(
"EnableZoomToCursor", &g_bEnableZoomToCursor);
1150 Read(
"TrackIntervalSeconds", &val);
1151 if (val.Length() > 0) {
1152 double tval = atof(val.mb_str());
1153 if (tval >= 2.) g_TrackIntervalSeconds = tval;
1157 Read(
"TrackDeltaDistance", &val);
1158 if (val.Length() > 0) {
1159 double tval = atof(val.mb_str());
1160 if (tval >= 0.05) g_TrackDeltaDistance = tval;
1163 Read(
"TrackPrecision", &g_nTrackPrecision);
1165 Read(
"RouteLineWidth", &g_route_line_width);
1166 Read(
"TrackLineWidth", &g_track_line_width);
1168 wxString l_wxsTrackLineColour;
1169 if (
Read(
"TrackLineColour", &l_wxsTrackLineColour))
1170 g_colourTrackLineColour.Set(l_wxsTrackLineColour);
1172 Read(
"TideCurrentWindowScale", &g_tcwin_scale);
1173 Read(
"DefaultWPIcon", &g_default_wp_icon);
1175 Read(
"DefaultRPIcon", &g_default_routepoint_icon);
1177 SetPath(
"/MmsiProperties");
1178 int iPMax = GetNumberOfEntries();
1183 bool bCont =
pConfig->GetFirstEntry(str, dummy);
1190 bCont =
pConfig->GetNextEntry(str, dummy);
1194 SetPath(
"/DataMonitor");
1195 g_dm_ok = ReadUnsigned(
"colors.ok", kUndefinedColor);
1196 g_dm_dropped = ReadUnsigned(
"colors.dropped", kUndefinedColor);
1197 g_dm_filtered = ReadUnsigned(
"colors.filtered", kUndefinedColor);
1198 g_dm_input = ReadUnsigned(
"colors.input", kUndefinedColor);
1199 g_dm_output = ReadUnsigned(
"colors.output", kUndefinedColor);
1200 g_dm_not_ok = ReadUnsigned(
"colors.not-ok", kUndefinedColor);
1205void MyConfig::LoadS57Config() {
1206 if (!ps52plib)
return;
1210 SetPath(
"/Settings/GlobalState");
1212 Read(
"bShowS57Text", &read_int, 1);
1213 ps52plib->SetShowS57Text(!(read_int == 0));
1215 Read(
"bShowS57ImportantTextOnly", &read_int, 0);
1216 ps52plib->SetShowS57ImportantTextOnly(!(read_int == 0));
1218 Read(
"bShowLightDescription", &read_int, 0);
1219 ps52plib->SetShowLdisText(!(read_int == 0));
1221 Read(
"bExtendLightSectors", &read_int, 0);
1222 ps52plib->SetExtendLightSectors(!(read_int == 0));
1224 Read(
"nDisplayCategory", &read_int, (
enum _DisCat)STANDARD);
1225 ps52plib->SetDisplayCategory((
enum _DisCat)read_int);
1227 Read(
"nSymbolStyle", &read_int, (
enum _LUPname)PAPER_CHART);
1228 ps52plib->m_nSymbolStyle = (LUPname)read_int;
1230 Read(
"nBoundaryStyle", &read_int, PLAIN_BOUNDARIES);
1231 ps52plib->m_nBoundaryStyle = (LUPname)read_int;
1233 Read(
"bShowSoundg", &read_int, 1);
1234 ps52plib->m_bShowSoundg = !(read_int == 0);
1236 Read(
"bShowMeta", &read_int, 0);
1237 ps52plib->m_bShowMeta = !(read_int == 0);
1239 Read(
"bUseSCAMIN", &read_int, 1);
1240 ps52plib->m_bUseSCAMIN = !(read_int == 0);
1242 Read(
"bUseSUPER_SCAMIN", &read_int, 0);
1243 ps52plib->m_bUseSUPER_SCAMIN = !(read_int == 0);
1245 Read(
"bShowAtonText", &read_int, 1);
1246 ps52plib->m_bShowAtonText = !(read_int == 0);
1248 Read(
"bDeClutterText", &read_int, 0);
1249 ps52plib->m_bDeClutterText = !(read_int == 0);
1251 Read(
"bShowNationalText", &read_int, 0);
1252 ps52plib->m_bShowNationalTexts = !(read_int == 0);
1254 Read(
"ENCSoundingScaleFactor", &read_int, 0);
1255 ps52plib->m_nSoundingFactor = read_int;
1257 Read(
"ENCTextScaleFactor", &read_int, 0);
1258 ps52plib->m_nTextFactor = read_int;
1260 if (
Read(
"S52_MAR_SAFETY_CONTOUR", &dval, 3.0)) {
1261 S52_setMarinerParam(S52_MAR_SAFETY_CONTOUR, dval);
1262 S52_setMarinerParam(S52_MAR_SAFETY_DEPTH,
1266 if (
Read(
"S52_MAR_SHALLOW_CONTOUR", &dval, 2.0))
1267 S52_setMarinerParam(S52_MAR_SHALLOW_CONTOUR, dval);
1269 if (
Read(
"S52_MAR_DEEP_CONTOUR", &dval, 6.0))
1270 S52_setMarinerParam(S52_MAR_DEEP_CONTOUR, dval);
1272 if (
Read(
"S52_MAR_TWO_SHADES", &dval, 0.0))
1273 S52_setMarinerParam(S52_MAR_TWO_SHADES, dval);
1275 ps52plib->UpdateMarinerParams();
1277 SetPath(
"/Settings/GlobalState");
1278 Read(
"S52_DEPTH_UNIT_SHOW", &read_int, 1);
1279 read_int = wxMax(read_int, 0);
1280 read_int = wxMin(read_int, 2);
1281 ps52plib->m_nDepthUnitDisplay = read_int;
1288 SetPath(
"/Settings/ObjectFilter");
1290 int iOBJMax = GetNumberOfEntries();
1298 bool bCont =
pConfig->GetFirstEntry(str, dummy);
1302 bool bNeedNew =
true;
1304 if (str.StartsWith(
"viz", &sObj)) {
1305 for (
unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
1307 pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
1308 if (!strncmp(pOLE->OBJLName, sObj.mb_str(), 6)) {
1316 pOLE = (OBJLElement *)calloc(
sizeof(OBJLElement), 1);
1317 memcpy(pOLE->OBJLName, sObj.mb_str(), OBJL_NAME_LEN);
1320 ps52plib->pOBJLArray->Add((
void *)pOLE);
1323 bCont =
pConfig->GetNextEntry(str, dummy);
1328bool MyConfig::LoadLayers(wxString &path) {
1329 wxArrayString file_array;
1333 if (dir.IsOpened()) {
1335 bool cont = dir.GetFirst(&filename);
1338 filename.Prepend(wxFileName::GetPathSeparator());
1339 filename.Prepend(path);
1340 wxFileName f(filename);
1342 if (f.GetExt().IsSameAs(
"gpx"))
1343 file_array.Add(filename);
1345 if (wxDir::Exists(filename)) {
1346 wxDir dir(filename);
1347 if (dir.IsOpened()) {
1348 nfiles = dir.GetAllFiles(filename, &file_array,
1354 if (file_array.GetCount()) {
1357 l->m_LayerFileName = file_array[0];
1358 if (file_array.GetCount() <= 1)
1359 wxFileName::SplitPath(file_array[0], NULL, NULL, &(l->m_LayerName),
1362 wxFileName::SplitPath(filename, NULL, NULL, &(l->m_LayerName), NULL,
1365 bool bLayerViz = g_bShowLayers;
1367 if (g_VisibleLayers.Contains(l->m_LayerName)) bLayerViz =
true;
1368 if (g_InvisibleLayers.Contains(l->m_LayerName)) bLayerViz =
false;
1370 l->m_bHasVisibleNames = wxCHK_UNDETERMINED;
1371 if (g_VisiNameinLayers.Contains(l->m_LayerName))
1372 l->m_bHasVisibleNames = wxCHK_CHECKED;
1373 if (g_InVisiNameinLayers.Contains(l->m_LayerName))
1374 l->m_bHasVisibleNames = wxCHK_UNCHECKED;
1376 l->m_bIsVisibleOnChart = bLayerViz;
1379 laymsg.Printf(
"New layer %d: %s", l->m_LayerID, l->m_LayerName.c_str());
1380 wxLogMessage(laymsg);
1382 pLayerList->insert(pLayerList->begin(), l);
1386 for (
unsigned int i = 0; i < file_array.GetCount(); i++) {
1387 wxString file_path = file_array[i];
1389 if (::wxFileExists(file_path)) {
1393 wxLogMessage(
"Error loading GPX file " + file_path);
1396 _(
"Error loading GPX file %s, %s at character %d"),
1397 file_path, result.description(), result.offset),
1398 _(
"Import GPX File"));
1401 long nItems = pSet->LoadAllGPXObjectsAsLayer(
1402 l->m_LayerID, bLayerViz, l->m_bHasVisibleNames);
1403 l->m_NoOfItems += nItems;
1404 l->m_LayerType = _(
"Persistent");
1407 objmsg.Printf(
"Loaded GPX file %s with %ld items.",
1408 file_path.c_str(), nItems);
1409 wxLogMessage(objmsg);
1416 cont = dir.GetNext(&filename);
1419 g_bLayersLoaded =
true;
1424bool MyConfig::LoadChartDirArray(ArrayOfCDI &ChartDirArray) {
1426 SetPath(
"/ChartDirectories");
1427 int iDirMax = GetNumberOfEntries();
1429 ChartDirArray.Empty();
1432 int nAdjustChartDirs = 0;
1434 bool bCont =
pConfig->GetFirstEntry(str, dummy);
1438 wxString dirname(val);
1439 if (!dirname.IsEmpty()) {
1454 if (dirname.Find(
"SampleCharts") ==
1460 wxString new_dir = dirname.Mid(dirname.Find(
"SampleCharts"));
1461 new_dir.Prepend(g_Platform->GetSharedDataDir());
1466 cdi.fullpath = dirname.BeforeFirst(
'^');
1467 cdi.magic_number = dirname.AfterFirst(
'^');
1469 ChartDirArray.Add(cdi);
1473 bCont =
pConfig->GetNextEntry(str, dummy);
1476 if (nAdjustChartDirs)
pConfig->UpdateChartDirs(ChartDirArray);
1482bool MyConfig::UpdateChartDirs(ArrayOfCDI &dir_array) {
1486 SetPath(
"/ChartDirectories");
1487 int iDirMax = GetNumberOfEntries();
1491 for (
int i = 0; i < iDirMax; i++) {
1492 GetFirstEntry(key, dummy);
1493 DeleteEntry(key,
false);
1497 iDirMax = dir_array.GetCount();
1499 for (
int iDir = 0; iDir < iDirMax; iDir++) {
1502 wxString dirn = cdi.fullpath;
1504 dirn.Append(cdi.magic_number);
1506 str_buf.Printf(
"ChartDir%d", iDir + 1);
1508 Write(str_buf, dirn);
1520void MyConfig::CreateConfigGroups(ChartGroupArray *pGroupArray) {
1521 if (!pGroupArray)
return;
1524 Write(
"GroupCount", (
int)pGroupArray->GetCount());
1526 for (
unsigned int i = 0; i < pGroupArray->GetCount(); i++) {
1529 s.Printf(
"Group%d", i + 1);
1530 s.Prepend(
"/Groups/");
1533 Write(
"GroupName", pGroup->m_group_name);
1534 Write(
"GroupItemCount", (
int)pGroup->m_element_array.size());
1536 for (
unsigned int j = 0; j < pGroup->m_element_array.size(); j++) {
1538 sg.Printf(
"Group%d/Item%d", i + 1, j);
1539 sg.Prepend(
"/Groups/");
1541 Write(
"IncludeItem", pGroup->m_element_array[j].m_element_name);
1544 wxArrayString u = pGroup->m_element_array[j].m_missing_name_array;
1546 for (
unsigned int k = 0; k < u.GetCount(); k++) {
1550 Write(
"ExcludeItems", t);
1556void MyConfig::DestroyConfigGroups() {
1557 DeleteGroup(
"/Groups");
1560void MyConfig::LoadConfigGroups(ChartGroupArray *pGroupArray) {
1562 unsigned int group_count;
1563 Read(
"GroupCount", (
int *)&group_count, 0);
1565 for (
unsigned int i = 0; i < group_count; i++) {
1568 s.Printf(
"Group%d", i + 1);
1569 s.Prepend(
"/Groups/");
1573 Read(
"GroupName", &t);
1574 pGroup->m_group_name = t;
1576 unsigned int item_count;
1577 Read(
"GroupItemCount", (
int *)&item_count);
1578 for (
unsigned int j = 0; j < item_count; j++) {
1580 sg.Printf(
"Group%d/Item%d", i + 1, j);
1581 sg.Prepend(
"/Groups/");
1585 Read(
"IncludeItem", &v);
1589 if (
Read(
"ExcludeItems", &u)) {
1591 wxStringTokenizer tk(u,
";");
1592 while (tk.HasMoreTokens()) {
1593 wxString token = tk.GetNextToken();
1594 pelement.m_missing_name_array.Add(token);
1598 pGroup->m_element_array.push_back(std::move(pelement));
1600 pGroupArray->Add(pGroup);
1604void MyConfig::LoadCanvasConfigs(
bool bApplyAsTemplate) {
1607 auto &config_array = ConfigMgr::Get().GetCanvasConfigArray();
1612 if (!HasEntry(
"CanvasConfig")) {
1614 pcc->LoadFromLegacyConfig(
this);
1615 config_array.Add(pcc);
1620 Read(
"CanvasConfig", (
int *)&g_canvasConfig, 0);
1623 if (config_array.GetCount() == 0) {
1624 s.Printf(
"/Canvas/CanvasConfig%d", 1);
1627 LoadConfigCanvas(pcca, bApplyAsTemplate);
1628 config_array.Add(pcca);
1630 s.Printf(
"/Canvas/CanvasConfig%d", 2);
1633 LoadConfigCanvas(pcca, bApplyAsTemplate);
1634 config_array.Add(pcca);
1637 s.Printf(
"/Canvas/CanvasConfig%d", 1);
1639 LoadConfigCanvas(pcca, bApplyAsTemplate);
1641 if (config_array.GetCount() > 1) {
1643 s.Printf(
"/Canvas/CanvasConfig%d", 2);
1645 LoadConfigCanvas(pcca, bApplyAsTemplate);
1647 s.Printf(
"/Canvas/CanvasConfig%d", 2);
1650 LoadConfigCanvas(pcca, bApplyAsTemplate);
1651 config_array.Add(pcca);
1656void MyConfig::LoadConfigCanvas(
canvasConfig *cConfig,
bool bApplyAsTemplate) {
1658 double st_lat, st_lon;
1660 if (!bApplyAsTemplate) {
1662 cConfig->
iLat = START_LAT;
1663 cConfig->
iLon = START_LON;
1665 if (
Read(
"canvasVPLatLon", &st)) {
1666 sscanf(st.mb_str(wxConvUTF8),
"%lf,%lf", &st_lat, &st_lon);
1669 if (fabs(st_lon) < 360.) {
1670 while (st_lon < -180.) st_lon += 360.;
1672 while (st_lon > 180.) st_lon -= 360.;
1674 cConfig->
iLon = st_lon;
1677 if (fabs(st_lat) < 90.0) cConfig->
iLat = st_lat;
1683 double st_view_scale;
1684 if (
Read(wxString(
"canvasVPScale"), &st)) {
1685 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_view_scale);
1687 st_view_scale = fmax(st_view_scale, .001 / 32);
1688 st_view_scale = fmin(st_view_scale, 4);
1689 cConfig->
iScale = st_view_scale;
1693 if (
Read(wxString(
"canvasVPRotation"), &st)) {
1694 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_rotation);
1696 st_rotation = fmin(st_rotation, 360);
1697 st_rotation = fmax(st_rotation, 0);
1698 cConfig->
iRotation = st_rotation * PI / 180.;
1701 Read(
"canvasInitialdBIndex", &cConfig->DBindex, 0);
1709 Read(
"ActiveChartGroup", &cConfig->GroupID, 0);
1712 if (cConfig->GroupID && bApplyAsTemplate) {
1713 if (cConfig->GroupID > (
int)
g_pGroupArray->GetCount()) cConfig->GroupID = 0;
1719 Read(
"canvasEnableBasemapTile", &cConfig->bEnableBasemapTile, 1);
1731 Read(
"canvasENCDisplayCategory", &cConfig->nENCDisplayCategory, STANDARD);
1732 Read(
"canvasENCShowDepths", &cConfig->bShowENCDepths, 1);
1733 Read(
"canvasENCShowBuoyLabels", &cConfig->bShowENCBuoyLabels, 1);
1734 Read(
"canvasENCShowLightDescriptions", &cConfig->bShowENCLightDescriptions,
1736 Read(
"canvasENCShowLights", &cConfig->bShowENCLights, 1);
1737 Read(
"canvasENCShowVisibleSectorLights",
1738 &cConfig->bShowENCVisibleSectorLights, 0);
1739 Read(
"canvasENCShowAnchorInfo", &cConfig->bShowENCAnchorInfo, 0);
1740 Read(
"canvasENCShowDataQuality", &cConfig->bShowENCDataQuality, 0);
1743 Read(
"canvasSizeX", &sx, 0);
1744 Read(
"canvasSizeY", &sy, 0);
1748void MyConfig::SaveCanvasConfigs() {
1749 auto &config_array = ConfigMgr::Get().GetCanvasConfigArray();
1752 Write(
"CanvasConfig", (
int)g_canvasConfig);
1757 switch (g_canvasConfig) {
1761 s.Printf(
"/Canvas/CanvasConfig%d", 1);
1764 if (config_array.GetCount() > 0) {
1765 pcc = config_array.Item(0);
1767 SaveConfigCanvas(pcc);
1774 if (config_array.GetCount() > 1) {
1775 s.Printf(
"/Canvas/CanvasConfig%d", 1);
1777 pcc = config_array.Item(0);
1779 SaveConfigCanvas(pcc);
1782 s.Printf(
"/Canvas/CanvasConfig%d", 2);
1784 pcc = config_array.Item(1);
1786 SaveConfigCanvas(pcc);
1793void MyConfig::SaveConfigCanvas(
canvasConfig *cConfig) {
1800 st1.Printf(
"%10.4f,%10.4f", vp.
clat, vp.
clon);
1801 Write(
"canvasVPLatLon", st1);
1803 Write(
"canvasVPScale", st1);
1804 st1.Printf(
"%i", ((
int)(vp.
rotation * 180 / PI)) % 360);
1805 Write(
"canvasVPRotation", st1);
1808 int restore_dbindex = 0;
1810 if (pcs) restore_dbindex = pcs->GetCurrentEntrydbIndex();
1811 if (cConfig->
canvas->GetQuiltMode())
1812 restore_dbindex = cConfig->
canvas->GetQuiltReferenceChartIndex();
1813 Write(
"canvasInitialdBIndex", restore_dbindex);
1815 Write(
"canvasbFollow", cConfig->
canvas->m_bFollow);
1816 Write(
"ActiveChartGroup", cConfig->
canvas->m_groupIndex);
1818 Write(
"canvasQuilt", cConfig->
canvas->GetQuiltMode());
1819 Write(
"canvasShowGrid", cConfig->
canvas->GetShowGrid());
1820 Write(
"canvasShowOutlines", cConfig->
canvas->GetShowOutlines());
1821 Write(
"canvasShowDepthUnits", cConfig->
canvas->GetShowDepthUnits());
1823 Write(
"canvasShowAIS", cConfig->
canvas->GetShowAIS());
1824 Write(
"canvasAttenAIS", cConfig->
canvas->GetAttenAIS());
1826 Write(
"canvasShowTides", cConfig->
canvas->GetbShowTide());
1827 Write(
"canvasShowCurrents", cConfig->
canvas->GetbShowCurrent());
1829 Write(
"canvasEnableBasemapTile", cConfig->
canvas->GetbEnableBasemapTile());
1832 Write(
"canvasShowENCText", cConfig->
canvas->GetShowENCText());
1833 Write(
"canvasENCDisplayCategory", cConfig->
canvas->GetENCDisplayCategory());
1834 Write(
"canvasENCShowDepths", cConfig->
canvas->GetShowENCDepth());
1835 Write(
"canvasENCShowBuoyLabels", cConfig->
canvas->GetShowENCBuoyLabels());
1836 Write(
"canvasENCShowLightDescriptions",
1837 cConfig->
canvas->GetShowENCLightDesc());
1838 Write(
"canvasENCShowLights", cConfig->
canvas->GetShowENCLights());
1839 Write(
"canvasENCShowVisibleSectorLights",
1840 cConfig->
canvas->GetShowVisibleSectors());
1841 Write(
"canvasENCShowAnchorInfo", cConfig->
canvas->GetShowENCAnchor());
1842 Write(
"canvasENCShowDataQuality", cConfig->
canvas->GetShowENCDataQual());
1843 Write(
"canvasCourseUp", cConfig->
canvas->GetUpMode() == COURSE_UP_MODE);
1844 Write(
"canvasHeadUp", cConfig->
canvas->GetUpMode() == HEAD_UP_MODE);
1845 Write(
"canvasLookahead", cConfig->
canvas->GetLookahead());
1847 int width = cConfig->
canvas->GetSize().x;
1855 Write(
"canvasSizeX", width);
1856 Write(
"canvasSizeY", cConfig->
canvas->GetSize().y);
1860void MyConfig::UpdateSettings() {
1868 SetPath(
"/Settings");
1870 Write(
"LastAppliedTemplate", g_lastAppliedTemplateGUID);
1871 Write(
"CompatOS", g_compatOS);
1872 Write(
"CompatOsVersion", g_compatOsVersion);
1873 Write(
"ConfigVersionString", g_config_version_string);
1874 if (wxIsEmpty(g_CmdSoundString)) g_CmdSoundString = wxString(OCPN_SOUND_CMD);
1875 Write(
"CmdSoundString", g_CmdSoundString);
1876 Write(
"NavMessageShown", n_NavMessageShown);
1877 Write(
"InlandEcdis", g_bInlandEcdis);
1879 Write(
"AndroidVersionCode", g_AndroidVersionCode);
1881 Write(
"UIexpert", g_bUIexpert);
1882 Write(
"SpaceDropMark", g_bSpaceDropMark);
1886 Write(
"ShowStatusBar", g_bShowStatusBar);
1888 Write(
"ShowMenuBar", g_bShowMenuBar);
1890 Write(
"DefaultFontSize", g_default_font_size);
1893 Write(
"Fullscreen", g_bFullscreen);
1894 Write(
"ShowCompassWindow", g_bShowCompassWin);
1895 Write(
"SetSystemTime", s_bSetSystemTime);
1897 Write(
"PlayShipsBells", g_bPlayShipsBells);
1898 Write(
"SoundDeviceIndex", g_iSoundDeviceIndex);
1899 Write(
"FullscreenToolbar", g_bFullscreenToolbar);
1900 Write(
"TransparentToolbar", g_bTransparentToolbar);
1901 Write(
"PermanentMOBIcon", g_bPermanentMOBIcon);
1902 Write(
"ShowLayers", g_bShowLayers);
1903 Write(
"AutoAnchorDrop", g_bAutoAnchorMark);
1904 Write(
"ShowChartOutlines", g_bShowOutlines);
1905 Write(
"ShowActiveRouteTotal", g_bShowRouteTotal);
1906 Write(
"ShowActiveRouteHighway", g_bShowActiveRouteHighway);
1907 Write(
"SDMMFormat", g_iSDMMFormat);
1908 Write(
"MostRecentGPSUploadConnection", g_uploadConnection);
1909 Write(
"ShowChartBar", g_bShowChartBar);
1911 Write(
"GUIScaleFactor", g_GUIScaleFactor);
1912 Write(
"ChartObjectScaleFactor", g_ChartScaleFactor);
1913 Write(
"ShipScaleFactor", g_ShipScaleFactor);
1914 Write(
"ENCSoundingScaleFactor", g_ENCSoundingScaleFactor);
1915 Write(
"ENCTextScaleFactor", g_ENCTextScaleFactor);
1916 Write(
"ObjQueryAppendFilesExt", g_ObjQFileExt);
1919 Write(
"CatalogCustomURL", g_catalog_custom_url);
1920 Write(
"CatalogChannel", g_catalog_channel);
1922 Write(
"NetmaskBits", g_netmask_bits);
1923 Write(
"FilterNMEA_Avg", g_bfilter_cogsog);
1924 Write(
"FilterNMEA_Sec", g_COGFilterSec);
1926 Write(
"TrackContinuous", g_btrackContinuous);
1928 Write(
"ShowTrue", g_bShowTrue);
1929 Write(
"ShowMag", g_bShowMag);
1930 Write(
"UserMagVariation", wxString::Format(
"%.2f", g_UserVar));
1932 Write(
"CM93DetailFactor", g_cm93_zoom_factor);
1933 Write(
"CM93DetailZoomPosX", g_detailslider_dialog_x);
1934 Write(
"CM93DetailZoomPosY", g_detailslider_dialog_y);
1935 Write(
"ShowCM93DetailSlider", g_bShowDetailSlider);
1937 Write(
"SkewToNorthUp", g_bskew_comp);
1938 if (!g_bdisable_opengl) {
1940 Write(
"OpenGL", g_bopengl);
1942 Write(
"SoftwareGL", g_bSoftwareGL);
1944 Write(
"ZoomDetailFactor", g_chart_zoom_modifier_raster);
1945 Write(
"ZoomDetailFactorVector", g_chart_zoom_modifier_vector);
1947 Write(
"FogOnOverzoom", g_fog_overzoom);
1948 Write(
"OverzoomVectorScale", g_oz_vector_scale);
1949 Write(
"OverzoomEmphasisBase", g_overzoom_emphasis_base);
1950 Write(
"PlusMinusZoomFactor", g_plus_minus_zoom_factor);
1951 Write(
"MouseZoomSensitivity",
1953 Write(
"ShowMUIZoomButtons", g_bShowMuiZoomButtons);
1957 Write(
"UseAcceleratedPanning", g_GLOptions.m_bUseAcceleratedPanning);
1959 Write(
"GPUTextureCompression", g_GLOptions.m_bTextureCompression);
1960 Write(
"GPUTextureCompressionCaching",
1961 g_GLOptions.m_bTextureCompressionCaching);
1962 Write(
"GPUTextureDimension", g_GLOptions.m_iTextureDimension);
1963 Write(
"GPUTextureMemSize", g_GLOptions.m_iTextureMemorySize);
1964 Write(
"PolygonSmoothing", g_GLOptions.m_GLPolygonSmoothing);
1965 Write(
"LineSmoothing", g_GLOptions.m_GLLineSmoothing);
1969 Write(
"CourseUpMode", g_bCourseUp);
1970 if (!g_bInlandEcdis)
Write(
"LookAheadMode", g_bLookAhead);
1971 Write(
"TenHzUpdate", g_btenhertz);
1974 Write(
"UseMagAPB", g_bMagneticAPB);
1976 Write(
"OwnshipCOGPredictorMinutes", g_ownship_predictor_minutes);
1977 Write(
"OwnshipCOGPredictorStyle", g_cog_predictor_style);
1978 Write(
"OwnshipCOGPredictorColor", g_cog_predictor_color);
1979 Write(
"OwnshipCOGPredictorEndmarker", g_cog_predictor_endmarker);
1980 Write(
"OwnshipCOGPredictorWidth", g_cog_predictor_width);
1981 Write(
"OwnshipHDTPredictorStyle", g_ownship_HDTpredictor_style);
1982 Write(
"OwnshipHDTPredictorColor", g_ownship_HDTpredictor_color);
1983 Write(
"OwnshipHDTPredictorEndmarker", g_ownship_HDTpredictor_endmarker);
1985 Write(
"OwnshipHDTPredictorWidth", g_ownship_HDTpredictor_width);
1986 Write(
"OwnshipHDTPredictorMiles", g_ownship_HDTpredictor_miles);
1988 Write(
"OwnShipIconType", g_OwnShipIconType);
1989 Write(
"OwnShipLength", g_n_ownship_length_meters);
1990 Write(
"OwnShipWidth", g_n_ownship_beam_meters);
1991 Write(
"OwnShipGPSOffsetX", g_n_gps_antenna_offset_x);
1992 Write(
"OwnShipGPSOffsetY", g_n_gps_antenna_offset_y);
1993 Write(
"OwnShipMinSize", g_n_ownship_min_mm);
1994 Write(
"ShowDirectRouteLine", g_bShowShipToActive);
1995 Write(
"DirectRouteLineStyle", g_shipToActiveStyle);
1996 Write(
"DirectRouteLineColor", g_shipToActiveColor);
2001 Write(
"RouteArrivalCircleRadius",
2002 wxString::Format(
"%.2f", g_n_arrival_circle_radius));
2004 Write(
"ChartQuilting", g_bQuiltEnable);
2006 Write(
"PreserveScaleOnX", g_bPreserveScaleOnX);
2008 Write(
"StartWithTrackActive", g_bTrackCarryOver);
2009 Write(
"AutomaticDailyTracks", g_bTrackDaily);
2010 Write(
"TrackRotateAt", g_track_rotate_time);
2011 Write(
"TrackRotateTimeType", g_track_rotate_time_type);
2012 Write(
"HighlightTracks", g_bHighliteTracks);
2015 Write(
"InitialStackIndex", g_restore_stackindex);
2016 Write(
"InitialdBIndex", g_restore_dbindex);
2018 Write(
"NMEAAPBPrecision", g_NMEAAPBPrecision);
2020 Write(
"TalkerIdText", g_TalkerIdText);
2021 Write(
"ShowTrackPointTime", g_bShowTrackPointTime);
2023 Write(
"AnchorWatch1GUID", g_AW1GUID);
2024 Write(
"AnchorWatch2GUID", g_AW2GUID);
2026 Write(
"ToolbarX", g_maintoolbar_x);
2027 Write(
"ToolbarY", g_maintoolbar_y);
2030 Write(
"iENCToolbarX", g_iENCToolbarPosX);
2031 Write(
"iENCToolbarY", g_iENCToolbarPosY);
2033 if (!g_bInlandEcdis) {
2034 Write(
"GlobalToolbarConfig", g_toolbarConfig);
2037 Write(
"WindSpeedFormat", g_iWindSpeedFormat);
2038 Write(
"ShowDepthUnits", g_bShowDepthUnits);
2042 Write(
"GPSIdent", g_GPS_Ident);
2043 Write(
"ActiveRoute", g_active_route);
2044 Write(
"PersistActiveRoute", g_persist_active_route);
2047 Write(
"UseGarminHostUpload", g_bGarminHostUpload);
2049 Write(
"MobileTouch", g_btouch);
2050 Write(
"ResponsiveGraphics", g_bresponsive);
2053 Write(
"AutoHideToolbar", g_bAutoHideToolbar);
2054 Write(
"AutoHideToolbarSecs", g_nAutoHideToolbar);
2058 st0.Append(wxString::Format(
"%zu,", mm));
2061 Write(
"DisplaySizeMM", st0);
2062 Write(
"DisplaySizeManual", g_config_display_size_manual);
2064 Write(
"SelectionRadiusMM", g_selection_radius_mm);
2065 Write(
"SelectionRadiusTouchMM", g_selection_radius_touch_mm);
2067 st0.Printf(
"%g", g_PlanSpeed);
2068 Write(
"PlanSpeed", st0);
2070 if (g_bLayersLoaded) {
2071 wxString vis, invis, visnames, invisnames;
2072 LayerList::iterator it;
2074 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
2076 if (lay->IsVisibleOnChart())
2077 vis += (lay->m_LayerName) +
";";
2079 invis += (lay->m_LayerName) +
";";
2081 if (lay->HasVisibleNames() == wxCHK_CHECKED) {
2082 visnames += (lay->m_LayerName) +
";";
2083 }
else if (lay->HasVisibleNames() == wxCHK_UNCHECKED) {
2084 invisnames += (lay->m_LayerName) +
";";
2087 Write(
"VisibleLayers", vis);
2088 Write(
"InvisibleLayers", invis);
2089 Write(
"VisNameInLayers", visnames);
2090 Write(
"InvisNameInLayers", invisnames);
2092 Write(
"Locale", g_locale);
2093 Write(
"LocaleOverride", g_localeOverride);
2095 Write(
"KeepNavobjBackups", g_navobjbackups);
2096 Write(
"LegacyInputCOMPortFilterBehaviour", g_b_legacy_input_filter_behaviour);
2097 Write(
"AdvanceRouteWaypointOnArrivalOnly",
2098 g_bAdvanceRouteWaypointOnArrivalOnly);
2099 Write(
"EnableRootMenuDebug", g_enable_root_menu_debug);
2102 Write(
"LiveETA", g_bShowLiveETA);
2103 Write(
"DefaultBoatSpeed", g_defaultBoatSpeed);
2107 SetPath(
"/Settings/ObjectFilter");
2110 for (
unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
2112 OBJLElement *pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
2114 wxString st1(
"viz");
2116 strncpy(name, pOLE->OBJLName, 6);
2118 st1.Append(wxString(name, wxConvUTF8));
2119 Write(st1, pOLE->nViz);
2125 SetPath(
"/Settings/GlobalState");
2142 st1.Printf(
"%10.4f, %10.4f",
gLat,
gLon);
2143 Write(
"OwnShipLatLon", st1);
2146 SetPath(
"/Settings/GlobalState");
2147 if (!g_bInlandEcdis)
2148 Write(
"nColorScheme", (
int)user_colors::GetColorScheme());
2150 Write(
"FrameWinX", g_nframewin_x);
2151 Write(
"FrameWinY", g_nframewin_y);
2152 Write(
"FrameWinPosX", g_nframewin_posx);
2153 Write(
"FrameWinPosY", g_nframewin_posy);
2154 Write(
"FrameMax", g_bframemax);
2156 Write(
"ClientPosX", g_lastClientRectx);
2157 Write(
"ClientPosY", g_lastClientRecty);
2158 Write(
"ClientSzX", g_lastClientRectw);
2159 Write(
"ClientSzY", g_lastClientRecth);
2163 Write(
"RoutePropSizeX", g_route_prop_sx);
2164 Write(
"RoutePropSizeY", g_route_prop_sy);
2165 Write(
"RoutePropPosX", g_route_prop_x);
2166 Write(
"RoutePropPosY", g_route_prop_y);
2169 SetPath(
"/Settings/Audio");
2170 Write(
"AISAlertSoundFile", g_AIS_sound_file);
2171 Write(
"DSCAlertSoundFile", g_DSC_sound_file);
2172 Write(
"SARTAlertSoundFile", g_SART_sound_file);
2173 Write(
"AnchorAlarmSoundFile", g_anchorwatch_sound_file);
2175 Write(
"bAIS_GCPA_AlertAudio", g_bAIS_GCPA_Alert_Audio);
2176 Write(
"bAIS_SART_AlertAudio", g_bAIS_SART_Alert_Audio);
2177 Write(
"bAIS_DSC_AlertAudio", g_bAIS_DSC_Alert_Audio);
2178 Write(
"bAnchorAlertAudio", g_bAnchor_Alert_Audio);
2181 SetPath(
"/Settings/AIS");
2183 Write(
"bNoCPAMax", g_bCPAMax);
2184 Write(
"NoCPAMaxNMi", g_CPAMax_NM);
2185 Write(
"bCPAWarn", g_bCPAWarn);
2186 Write(
"CPAWarnNMi", g_CPAWarn_NM);
2187 Write(
"bTCPAMax", g_bTCPA_Max);
2188 Write(
"TCPAMaxMinutes", g_TCPA_Max);
2189 Write(
"bMarkLostTargets", g_bMarkLost);
2190 Write(
"MarkLost_Minutes", g_MarkLost_Mins);
2191 Write(
"bRemoveLostTargets", g_bRemoveLost);
2192 Write(
"RemoveLost_Minutes", g_RemoveLost_Mins);
2193 Write(
"bShowCOGArrows", g_bShowCOG);
2194 Write(
"bSyncCogPredictors", g_bSyncCogPredictors);
2195 Write(
"CogArrowMinutes", g_ShowCOG_Mins);
2196 Write(
"bShowTargetTracks", g_bAISShowTracks);
2197 Write(
"TargetTracksMinutes", g_AISShowTracks_Mins);
2199 Write(
"bHideMooredTargets", g_bHideMoored);
2200 Write(
"MooredTargetMaxSpeedKnots", g_ShowMoored_Kts);
2202 Write(
"bAISAlertDialog", g_bAIS_CPA_Alert);
2203 Write(
"bAISAlertAudio", g_bAIS_CPA_Alert_Audio);
2205 Write(
"AISAlertAudioFile", g_sAIS_Alert_Sound_File);
2206 Write(
"bAISAlertSuppressMoored", g_bAIS_CPA_Alert_Suppress_Moored);
2207 Write(
"bShowAreaNotices", g_bShowAreaNotices);
2208 Write(
"bDrawAISSize", g_bDrawAISSize);
2209 Write(
"bDrawAISRealtime", g_bDrawAISRealtime);
2210 Write(
"AISRealtimeMinSpeedKnots", g_AIS_RealtPred_Kts);
2211 Write(
"bShowAISName", g_bShowAISName);
2212 Write(
"ShowAISTargetNameScale", g_Show_Target_Name_Scale);
2213 Write(
"bWplIsAprsPositionReport", g_bWplUsePosition);
2214 Write(
"WplSelAction", g_WplAction);
2215 Write(
"AISCOGPredictorWidth", g_ais_cog_predictor_width);
2216 Write(
"bShowScaledTargets", g_bAllowShowScaled);
2217 Write(
"AISScaledNumber", g_ShowScaled_Num);
2218 Write(
"AISScaledNumberWeightSOG", g_ScaledNumWeightSOG);
2219 Write(
"AISScaledNumberWeightCPA", g_ScaledNumWeightCPA);
2220 Write(
"AISScaledNumberWeightTCPA", g_ScaledNumWeightTCPA);
2221 Write(
"AISScaledNumberWeightRange", g_ScaledNumWeightRange);
2222 Write(
"AISScaledNumberWeightSizeOfTarget", g_ScaledNumWeightSizeOfT);
2223 Write(
"AISScaledSizeMinimal", g_ScaledSizeMinimal);
2224 Write(
"AISShowScaled", g_bShowScaled);
2226 Write(
"AlertDialogSizeX", g_ais_alert_dialog_sx);
2227 Write(
"AlertDialogSizeY", g_ais_alert_dialog_sy);
2228 Write(
"AlertDialogPosX", g_ais_alert_dialog_x);
2229 Write(
"AlertDialogPosY", g_ais_alert_dialog_y);
2230 Write(
"QueryDialogPosX", g_ais_query_dialog_x);
2231 Write(
"QueryDialogPosY", g_ais_query_dialog_y);
2232 Write(
"AISTargetListPerspective", g_AisTargetList_perspective);
2233 Write(
"AISTargetListRange", g_AisTargetList_range);
2234 Write(
"AISTargetListSortColumn", g_AisTargetList_sortColumn);
2235 Write(
"bAISTargetListSortReverse", g_bAisTargetList_sortReverse);
2236 Write(
"AISTargetListColumnSpec", g_AisTargetList_column_spec);
2237 Write(
"AISTargetListColumnOrder", g_AisTargetList_column_order);
2239 Write(
"S57QueryDialogSizeX", g_S57_dialog_sx);
2240 Write(
"S57QueryDialogSizeY", g_S57_dialog_sy);
2241 Write(
"S57QueryExtraDialogSizeX", g_S57_extradialog_sx);
2242 Write(
"S57QueryExtraDialogSizeY", g_S57_extradialog_sy);
2244 Write(
"bAISRolloverShowClass", g_bAISRolloverShowClass);
2245 Write(
"bAISRolloverShowCOG", g_bAISRolloverShowCOG);
2246 Write(
"bAISRolloverShowCPA", g_bAISRolloverShowCPA);
2248 Write(
"bAISAlertAckTimeout", g_bAIS_ACK_Timeout);
2249 Write(
"AlertAckTimeoutMinutes", g_AckTimeout_Mins);
2251 SetPath(
"/Settings/GlobalState");
2253 Write(
"bShowS57Text", ps52plib->GetShowS57Text());
2254 Write(
"bShowS57ImportantTextOnly", ps52plib->GetShowS57ImportantTextOnly());
2255 if (!g_bInlandEcdis)
2256 Write(
"nDisplayCategory", (
long)ps52plib->GetDisplayCategory());
2257 Write(
"nSymbolStyle", (
int)ps52plib->m_nSymbolStyle);
2258 Write(
"nBoundaryStyle", (
int)ps52plib->m_nBoundaryStyle);
2260 Write(
"bShowSoundg", ps52plib->m_bShowSoundg);
2261 Write(
"bShowMeta", ps52plib->m_bShowMeta);
2262 Write(
"bUseSCAMIN", ps52plib->m_bUseSCAMIN);
2263 Write(
"bUseSUPER_SCAMIN", ps52plib->m_bUseSUPER_SCAMIN);
2264 Write(
"bShowAtonText", ps52plib->m_bShowAtonText);
2265 Write(
"bShowLightDescription", ps52plib->m_bShowLdisText);
2266 Write(
"bExtendLightSectors", ps52plib->m_bExtendLightSectors);
2267 Write(
"bDeClutterText", ps52plib->m_bDeClutterText);
2268 Write(
"bShowNationalText", ps52plib->m_bShowNationalTexts);
2270 Write(
"S52_MAR_SAFETY_CONTOUR",
2271 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
2272 Write(
"S52_MAR_SHALLOW_CONTOUR",
2273 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
2274 Write(
"S52_MAR_DEEP_CONTOUR", S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
2275 Write(
"S52_MAR_TWO_SHADES", S52_getMarinerParam(S52_MAR_TWO_SHADES));
2276 Write(
"S52_DEPTH_UNIT_SHOW", ps52plib->m_nDepthUnitDisplay);
2277 Write(
"ENCSoundingScaleFactor", g_ENCSoundingScaleFactor);
2278 Write(
"ENCTextScaleFactor", g_ENCTextScaleFactor);
2280 SetPath(
"/Directories");
2281 Write(
"S57DataLocation",
"");
2284 SetPath(
"/Directories");
2285 Write(
"InitChartDir", *pInit_Chart_Dir);
2286 Write(
"GPXIODir", g_gpx_path);
2287 Write(
"TCDataDir", g_TCData_Dir);
2288 Write(
"BasemapDir", g_Platform->NormalizePath(gWorldMapLocation));
2289 if (gWorldShapefileLocation.Length())
2290 Write(
"BaseShapefileDir",
2291 g_Platform->NormalizePath(gWorldShapefileLocation));
2294 SetPath(
"/Settings/NMEADataSource");
2295 wxString connectionconfigs;
2296 for (
size_t i = 0; i < TheConnectionParams().size(); i++) {
2297 if (i > 0) connectionconfigs.Append(
"|");
2298 connectionconfigs.Append(TheConnectionParams()[i]->Serialize());
2300 Write(
"DataConnections", connectionconfigs);
2305 SetPath(
"/Settings/AuxFontKeys");
2308 for (
unsigned int i = 0; i < keyArray.GetCount(); i++) {
2310 key.Printf(
"Key%i", i);
2311 wxString keyval = keyArray[i];
2317 font_path = (
"/Settings/X11Fonts");
2321 font_path = (
"/Settings/GTKFonts");
2325 font_path = (
"/Settings/MSWFonts");
2329 font_path = (
"/Settings/MacFonts");
2333 font_path = (
"/Settings/QTFonts");
2336 if (HasEntry(font_path)) DeleteGroup(font_path);
2342 for (
int i = 0; i < nFonts; i++) {
2343 wxString cfstring(FontMgr::Get().GetConfigString(i));
2345 Write(cfstring, valstring);
2349 if (HasGroup(
"/TideCurrentDataSources"))
2350 DeleteGroup(
"/TideCurrentDataSources");
2351 SetPath(
"/TideCurrentDataSources");
2352 unsigned int id = 0;
2353 for (
auto val : TideCurrentDataSet) {
2355 key.Printf(
"tcds%d",
id);
2356 Write(key, wxString(val));
2360 SetPath(
"/Settings/Others");
2363 Write(
"ShowRadarRings",
2364 (
bool)(g_iNavAidRadarRingsNumberVisible > 0));
2365 Write(
"RadarRingsNumberVisible", g_iNavAidRadarRingsNumberVisible);
2366 Write(
"RadarRingsStep", g_fNavAidRadarRingsStep);
2367 Write(
"RadarRingsStepUnits", g_pNavAidRadarRingsStepUnits);
2368 Write(
"RadarRingsColour",
2369 g_colourOwnshipRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
2370 Write(
"WaypointUseScaMin", g_bUseWptScaMin);
2371 Write(
"WaypointScaMinValue", g_iWpt_ScaMin);
2372 Write(
"WaypointScaMaxValue", g_iWpt_ScaMax);
2373 Write(
"WaypointUseScaMinOverrule", g_bOverruleScaMin);
2374 Write(
"WaypointsShowName", g_bShowWptName);
2375 Write(
"UserIconsFirst", g_bUserIconsFirst);
2378 Write(
"WaypointRangeRingsNumber", g_iWaypointRangeRingsNumber);
2379 Write(
"WaypointRangeRingsStep", g_fWaypointRangeRingsStep);
2380 Write(
"WaypointRangeRingsStepUnits", g_iWaypointRangeRingsStepUnits);
2381 Write(
"WaypointRangeRingsColour",
2384 Write(
"ConfirmObjectDeletion", g_bConfirmObjectDelete);
2387 Write(
"WaypointPreventDragging", g_bWayPointPreventDragging);
2389 Write(
"EnableZoomToCursor", g_bEnableZoomToCursor);
2391 Write(
"TrackIntervalSeconds", g_TrackIntervalSeconds);
2392 Write(
"TrackDeltaDistance", g_TrackDeltaDistance);
2393 Write(
"TrackPrecision", g_nTrackPrecision);
2395 Write(
"RouteLineWidth", g_route_line_width);
2396 Write(
"TrackLineWidth", g_track_line_width);
2397 Write(
"TrackLineColour",
2398 g_colourTrackLineColour.GetAsString(wxC2S_HTML_SYNTAX));
2399 Write(
"DefaultWPIcon", g_default_wp_icon);
2401 Write(
"DefaultRPIcon", g_default_routepoint_icon);
2403 DeleteGroup(
"/MmsiProperties");
2404 SetPath(
"/MmsiProperties");
2407 p.Printf(
"Props%d", i);
2410 SetPath(
"/DataMonitor");
2411 Write(
"colors.ok", g_dm_ok);
2412 Write(
"colors.dropped", g_dm_dropped);
2413 Write(
"colors.filtered", g_dm_filtered);
2414 Write(
"colors.input", g_dm_input);
2415 Write(
"colors.output", g_dm_output);
2416 Write(
"colors.not-ok", g_dm_not_ok);
2418 SaveCanvasConfigs();
2421 SendMessageToAllPlugins(
"GLOBAL_SETTINGS_UPDATED",
"{\"updated\":\"1\"}");
2425 if (top_frame::Get()) top_frame::Get()->SendGlJsonConfigMsg();
2430static wxFileName exportFileName(wxWindow *parent,
2431 const wxString suggestedName) {
2434 wxString valid_name = SanitizeFileName(suggestedName);
2437 if (!valid_name.EndsWith(
".gpx")) {
2438 wxFileName fn(valid_name);
2441 valid_name = fn.GetFullName();
2444 int response = g_Platform->DoFileSelectorDialog(
2445 parent, &path, _(
"Export GPX file"), g_gpx_path, valid_name,
"*.gpx");
2447 if (response == wxID_OK) {
2448 wxFileName fn(path);
2449 g_gpx_path = fn.GetPath();
2450 if (!fn.GetExt().StartsWith(
"gpx")) fn.SetExt(
"gpx");
2452#if defined(__WXMSW__) || defined(__WXGTK__)
2453 if (wxFileExists(fn.GetFullPath())) {
2454 int answer = OCPNMessageBox(NULL, _(
"Overwrite existing file?"),
2455 "Confirm", wxICON_QUESTION | wxYES_NO);
2456 if (answer != wxID_YES)
return ret;
2464int BackupDatabase(wxWindow *parent) {
2465 bool backupResult =
false;
2466 wxDateTime tm = wxDateTime::Now();
2467 wxString proposedName = tm.Format(
"navobj-%Y-%m-%d_%H_%M");
2468 wxString acceptedName;
2471 g_Platform->DoFileSelectorDialog(parent, &acceptedName, _(
"Backup"),
2472 wxStandardPaths::Get().GetDocumentsDir(),
2473 proposedName,
"*.bkp")) {
2474 wxFileName fileName(acceptedName);
2475 if (fileName.IsOk()) {
2476#if defined(__WXMSW__) || defined(__WXGTK__)
2477 if (fileName.FileExists()) {
2478 if (wxID_YES != OCPNMessageBox(NULL, _(
"Overwrite existing file?"),
2479 "Confirm", wxICON_QUESTION | wxYES_NO)) {
2486 wxString secureFileName = androidGetCacheDir() +
2487 wxFileName::GetPathSeparator() +
2488 fileName.GetFullName();
2489 backupResult = NavObj_dB::GetInstance().Backup(secureFileName);
2490 AndroidSecureCopyFile(secureFileName, fileName.GetFullPath());
2492 backupResult = NavObj_dB::GetInstance().Backup(fileName.GetFullPath());
2495 return backupResult ? wxID_YES : wxID_NO;
2500bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes,
2501 const wxString suggestedName) {
2503 wxFileName fn = exportFileName(parent, suggestedName);
2506 pgpx->AddGPXRoutesList(pRoutes);
2507 pgpx->SaveFile(fn.GetFullPath());
2513 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2514 suggestedName +
".gpx";
2516 pgpx->AddGPXRoutesList(pRoutes);
2517 pgpx->SaveFile(fns);
2522 int response = g_Platform->DoFileSelectorDialog(
2523 parent, &path, _(
"Export GPX file"), g_gpx_path, suggestedName +
".gpx",
2529 wxCopyFile(fns, path);
2537bool ExportGPXTracks(wxWindow *parent, std::vector<Track *> *pTracks,
2538 const wxString suggestedName) {
2540 wxFileName fn = exportFileName(parent, suggestedName);
2543 pgpx->AddGPXTracksList(pTracks);
2544 pgpx->SaveFile(fn.GetFullPath());
2550 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2551 suggestedName +
".gpx";
2553 pgpx->AddGPXTracksList(pTracks);
2554 pgpx->SaveFile(fns);
2559 int response = g_Platform->DoFileSelectorDialog(
2560 parent, &path, _(
"Export GPX file"), g_gpx_path, suggestedName +
".gpx",
2566 wxCopyFile(fns, path);
2573bool ExportGPXWaypoints(wxWindow *parent, RoutePointList *pRoutePoints,
2574 const wxString suggestedName) {
2576 wxFileName fn = exportFileName(parent, suggestedName);
2579 pgpx->AddGPXPointsList(pRoutePoints);
2580 pgpx->SaveFile(fn.GetFullPath());
2586 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2587 suggestedName +
".gpx";
2589 pgpx->AddGPXPointsList(pRoutePoints);
2590 pgpx->SaveFile(fns);
2595 int response = g_Platform->DoFileSelectorDialog(
2596 parent, &path, _(
"Export GPX file"), g_gpx_path, suggestedName +
".gpx",
2602 wxCopyFile(fns, path);
2610void ExportGPX(wxWindow *parent,
bool bviz_only,
bool blayer) {
2615 wxFileName fn = exportFileName(parent,
"userobjects.gpx");
2616 if (!fn.IsOk())
return;
2617 fns = fn.GetFullPath();
2621 androidGetCacheDir() + wxFileName::GetPathSeparator() +
"userobjects.gpx";
2624 ::wxBeginBusyCursor();
2626 wxGenericProgressDialog *pprog =
nullptr;
2627 int count = pWayPointMan->GetWaypointList()->size();
2628 int progStep = count / 32;
2630 pprog =
new wxGenericProgressDialog(
2631 _(
"Export GPX file"),
"0/0", count, NULL,
2632 wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
2633 wxPD_REMAINING_TIME);
2634 pprog->SetSize(400, wxDefaultCoord);
2641 for (
RoutePoint *pr : *pWayPointMan->GetWaypointList()) {
2642 if (pprog && !(ic % progStep)) {
2644 msg.Printf(
"%d/%d", ic, count);
2645 pprog->Update(ic, msg);
2650 if (bviz_only && !pr->m_bIsVisible) b_add =
false;
2652 if (pr->m_bIsInLayer && !blayer) b_add =
false;
2654 if (pr->IsShared() || !WptIsInRouteList(pr)) pgpx->AddGPXWaypoint(pr);
2660 if (bviz_only && !pRoute->IsVisible()) b_add =
false;
2661 if (pRoute->m_bIsInLayer && !blayer) b_add =
false;
2663 if (b_add) pgpx->AddGPXRoute(pRoute);
2669 if (bviz_only && !pTrack->IsVisible()) b_add =
false;
2671 if (pTrack->m_bIsInLayer && !blayer) b_add =
false;
2673 if (b_add) pgpx->AddGPXTrack(pTrack);
2676 pgpx->SaveFile(fns);
2682 g_Platform->DoFileSelectorDialog(parent, &path, _(
"Export GPX file"),
2683 g_gpx_path,
"userobjects.gpx",
"*.gpx");
2687 wxCopyFile(fns, path);
2691 ::wxEndBusyCursor();
2695void UI_ImportGPX(wxWindow *parent,
bool islayer, wxString dirpath,
2696 bool isdirectory,
bool isPersistent) {
2697 int response = wxID_CANCEL;
2698 wxArrayString file_array;
2700 if (!islayer || dirpath.IsSameAs(
"")) {
2705 wxFileDialog *popenDialog =
2706 new wxFileDialog(NULL, _(
"Import GPX file"), g_gpx_path,
"",
2707 "GPX files (*.gpx)|*.gpx|All files (*.*)|*.*",
2708 wxFD_OPEN | wxFD_MULTIPLE);
2710 if (g_bresponsive && parent)
2711 popenDialog = g_Platform->AdjustFileDialogFont(parent, popenDialog);
2713 popenDialog->Centre();
2716 if (parent) parent->HideWithEffect(wxSHOW_EFFECT_BLEND);
2719 response = popenDialog->ShowModal();
2722 if (parent) parent->ShowWithEffect(wxSHOW_EFFECT_BLEND);
2725 if (response == wxID_OK) {
2726 popenDialog->GetPaths(file_array);
2729 if (file_array.GetCount()) {
2730 wxFileName fn(file_array[0]);
2731 g_gpx_path = fn.GetPath();
2737 response = g_Platform->DoFileSelectorDialog(
2738 NULL, &path, _(
"Import GPX file"), g_gpx_path,
"",
"*.gpx");
2740 wxFileName fn(path);
2741 g_gpx_path = fn.GetPath();
2742 if (path.IsEmpty()) {
2743 PrepareImportAndroid(islayer, isPersistent);
2746 file_array.Add(path);
2751 if (wxDir::GetAllFiles(dirpath, &file_array,
"*.gpx")) response = wxID_OK;
2753 file_array.Add(dirpath);
2758 if (response == wxID_OK) {
2759 ImportFileArray(file_array, islayer, isPersistent, dirpath);
2763void ImportFileArray(
const wxArrayString &file_array,
bool islayer,
2764 bool isPersistent, wxString dirpath) {
2770 l->m_LayerFileName = file_array[0];
2771 if (file_array.GetCount() <= 1)
2772 wxFileName::SplitPath(file_array[0], NULL, NULL, &(l->m_LayerName), NULL,
2775 if (dirpath.IsSameAs(
""))
2776 wxFileName::SplitPath(g_gpx_path, NULL, NULL, &(l->m_LayerName), NULL,
2779 wxFileName::SplitPath(dirpath, NULL, NULL, &(l->m_LayerName), NULL,
2783 bool bLayerViz = g_bShowLayers;
2784 if (g_VisibleLayers.Contains(l->m_LayerName)) bLayerViz =
true;
2785 if (g_InvisibleLayers.Contains(l->m_LayerName)) bLayerViz =
false;
2786 l->m_bIsVisibleOnChart = bLayerViz;
2789 l->m_bHasVisibleNames = wxCHK_CHECKED;
2792 laymsg.Printf(
"New layer %d: %s", l->m_LayerID, l->m_LayerName.c_str());
2793 wxLogMessage(laymsg);
2795 pLayerList->insert(pLayerList->begin(), l);
2798 for (
unsigned int i = 0; i < file_array.GetCount(); i++) {
2799 wxString path = file_array[i];
2801 if (::wxFileExists(path)) {
2805 wxLogMessage(
"Error loading GPX file " + path);
2807 wxString::Format(_(
"Error loading GPX file %s, %s at character %d"),
2808 path, result.description(), result.offset),
2809 _(
"Import GPX File"));
2816 l->m_NoOfItems = pSet->LoadAllGPXObjectsAsLayer(
2817 l->m_LayerID, l->m_bIsVisibleOnChart, l->m_bHasVisibleNames);
2818 l->m_LayerType = isPersistent ? _(
"Persistent") : _(
"Temporary");
2823 wxString destf, f, name, ext;
2824 f = l->m_LayerFileName;
2825 wxFileName::SplitPath(f, NULL, NULL, &name, &ext);
2827 appendOSDirSlash(&destf);
2828 destf.Append(
"layers");
2829 appendOSDirSlash(&destf);
2830 if (!wxDirExists(destf)) {
2831 if (!wxMkdir(destf, wxS_DIR_DEFAULT))
2832 wxLogMessage(
"Error creating layer directory");
2835 destf << name <<
"." << ext;
2837 if (wxCopyFile(f, destf,
true))
2838 msg.Printf(
"File: %s.%s also added to persistent layers", name,
2841 msg.Printf(
"Failed adding %s.%s to persistent layers", name, ext);
2846 pSet->LoadAllGPXObjects(
2853 wxString::Format(
"%d " + _(
"duplicate waypoints detected "
2854 "during import and ignored."),
2856 _(
"OpenCPN Info"), wxICON_INFORMATION | wxOK, 10);
2868void SwitchInlandEcdisMode(
bool Switch) {
2870 wxLogMessage(
"Switch InlandEcdis mode On");
2877 if (ps52plib) ps52plib->SetDisplayCategory(STANDARD);
2878 g_bDrawAISSize =
false;
2879 if (top_frame::Get()) top_frame::Get()->RequestNewToolbars(
true);
2881 wxLogMessage(
"Switch InlandEcdis mode Off");
2884 pConfig->SetPath(
"/Settings");
2885 pConfig->Read(
"GlobalToolbarConfig", &g_toolbarConfig);
2888 pConfig->Read(
"ShowDepthUnits", &g_bShowDepthUnits, 1);
2891 pConfig->Read(
"nDisplayCategory", &read_int, (
enum _DisCat)STANDARD);
2892 if (ps52plib) ps52plib->SetDisplayCategory((
enum _DisCat)read_int);
2893 pConfig->SetPath(
"/Settings/AIS");
2894 pConfig->Read(
"bDrawAISSize", &g_bDrawAISSize);
2895 pConfig->Read(
"bDrawAISRealtime", &g_bDrawAISRealtime);
2897 if (top_frame::Get()) top_frame::Get()->RequestNewToolbars(
true);
2909wxString FormatGPXDateTime(wxDateTime dt) {
2911 return dt.Format(
"%Y-%m-%dT%H:%M:%SZ");
2918bool LogMessageOnce(
const wxString &msg) {
2921 for (
unsigned int i = 0; i < navutil::pMessageOnceArray->GetCount(); i++) {
2922 if (msg.IsSameAs(navutil::pMessageOnceArray->Item(i)))
return false;
2926 navutil::pMessageOnceArray->Add(msg);
2939 if (!ts.IsValid()) {
2942 int effective_format = format;
2956 switch (effective_format) {
2958 if (std::isnan(lon)) {
2959 dt = wxInvalidDateTime;
2962 ts.Add(wxTimeSpan(wxTimeSpan(0, 0, wxLongLong(lon * 3600. / 15.))));
2979 if (!ts.IsValid()) {
2982 int effective_format = format;
2996 switch (effective_format) {
2998 if (std::isnan(lon)) {
2999 dt = wxInvalidDateTime;
3001 dt = ts.Subtract(wxTimeSpan(0, 0, wxLongLong(lon * 3600. / 15.)));
3018double fromUsrSpeed(
double usr_speed,
int unit) {
3026 ret = usr_speed / 1.15078;
3029 ret = usr_speed / 1.852;
3032 ret = usr_speed / 0.514444444;
3040double fromUsrWindSpeed(
double usr_wspeed,
int unit) {
3042 if (
unit == -1)
unit = g_iWindSpeedFormat;
3048 ret = usr_wspeed / 0.514444444;
3051 ret = usr_wspeed / 1.15078;
3054 ret = usr_wspeed / 1.852;
3063double fromUsrTemp(
double usr_temp,
int unit) {
3071 ret = (usr_temp - 32) * 5.0 / 9.0;
3074 ret = usr_temp - 273.15;
3080wxString formatAngle(
double angle) {
3082 if (g_bShowMag && g_bShowTrue) {
3083 out.Printf(
"%03.0f %cT (%.0f %cM)", angle, 0x00B0, toMagnetic(angle),
3085 }
else if (g_bShowTrue) {
3086 out.Printf(
"%03.0f %cT", angle, 0x00B0);
3088 out.Printf(
"%03.0f %cM", toMagnetic(angle), 0x00B0);
3094void AlphaBlending(
ocpnDC &dc,
int x,
int y,
int size_x,
int size_y,
3095 float radius, wxColour color,
unsigned char transparency) {
3096 wxDC *pdc = dc.GetDC();
3099 wxBitmap obm(size_x, size_y);
3101 mdc1.SelectObject(obm);
3102 mdc1.Blit(0, 0, size_x, size_y, pdc, x, y);
3103 mdc1.SelectObject(wxNullBitmap);
3104 wxImage oim = obm.ConvertToImage();
3107 wxBitmap olbm(size_x, size_y);
3108 wxMemoryDC oldc(olbm);
3109 if (!oldc.IsOk())
return;
3111 oldc.SetBackground(*wxBLACK_BRUSH);
3112 oldc.SetBrush(*wxWHITE_BRUSH);
3115 if (radius > 0.0) oldc.DrawRoundedRectangle(0, 0, size_x, size_y, radius);
3117 wxImage dest = olbm.ConvertToImage();
3118 unsigned char *dest_data =
3119 (
unsigned char *)malloc(size_x * size_y * 3 *
sizeof(
unsigned char));
3120 unsigned char *bg = oim.GetData();
3121 unsigned char *box = dest.GetData();
3122 unsigned char *d = dest_data;
3129 float alpha = 1.0 - (float)transparency / 255.0;
3130 int sb = size_x * size_y;
3131 for (
int i = 0; i < sb; i++) {
3133 if (*box == 0 && radius > 0.0) a = 1.0;
3134 int r = ((*bg++) * a) + (1.0 - a) * color.Red();
3137 int g = ((*bg++) * a) + (1.0 - a) * color.Green();
3140 int b = ((*bg++) * a) + (1.0 - a) * color.Blue();
3145 dest.SetData(dest_data);
3149 dc.DrawBitmap(dbm, x, y,
false);
3153 dc.CalcBoundingBox(x, y);
3154 dc.CalcBoundingBox(x + size_x, y + size_y);
3159 float radMod = wxMax(radius, 2.0);
3160 wxColour c(color.Red(), color.Green(), color.Blue(), transparency);
3161 dc.SetBrush(wxBrush(c));
3162 dc.SetPen(wxPen(c, 1));
3163 dc.DrawRoundedRectangle(x, y, size_x, size_y, radMod);
3165 glDisable(GL_BLEND);
3171void DimeControl(wxWindow *ctrl) {
3177 if (wxPlatformInfo::Get().CheckOSVersion(10, 14)) {
3185 if (wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW).Red() <
3192 if (NULL == ctrl)
return;
3194 wxColour col, window_back_color, gridline, uitext, udkrd, ctrl_back_color,
3196 col = GetGlobalColor(
"DILG0");
3197 window_back_color = GetGlobalColor(
"DILG1");
3198 ctrl_back_color = GetGlobalColor(
"DILG1");
3199 text_color = GetGlobalColor(
"DILG3");
3200 uitext = GetGlobalColor(
"UITX1");
3201 udkrd = GetGlobalColor(
"UDKRD");
3202 gridline = GetGlobalColor(
"GREY2");
3204 DimeControl(ctrl, col, window_back_color, ctrl_back_color, text_color, uitext,
3208void DimeControl(wxWindow *ctrl, wxColour col, wxColour window_back_color,
3209 wxColour ctrl_back_color, wxColour text_color, wxColour uitext,
3210 wxColour udkrd, wxColour gridline) {
3216 if (wxPlatformInfo::Get().CheckOSVersion(10, 14)) {
3221 ColorScheme cs = global_color_scheme;
3225 (cs == GLOBAL_COLOR_SCHEME_DUSK || cs == GLOBAL_COLOR_SCHEME_NIGHT);
3227 static int depth = 0;
3233 window_back_color = wxNullColour;
3235 window_back_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
3237 col = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
3238 uitext = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
3241 ctrl->SetBackgroundColour(window_back_color);
3242 if (darkMode) ctrl->SetForegroundColour(text_color);
3245 wxWindowList kids = ctrl->GetChildren();
3246 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
3247 wxWindowListNode *node = kids.Item(i);
3248 wxWindow *win = node->GetData();
3250 if (
dynamic_cast<wxListBox *
>(win) ||
dynamic_cast<wxListCtrl *
>(win) ||
3251 dynamic_cast<wxTextCtrl *
>(win) ||
3252 dynamic_cast<wxTimePickerCtrl *
>(win)) {
3253 win->SetBackgroundColour(col);
3254 }
else if (
dynamic_cast<wxStaticText *
>(win) ||
3255 dynamic_cast<wxCheckBox *
>(win) ||
3256 dynamic_cast<wxRadioButton *
>(win)) {
3257 win->SetForegroundColour(uitext);
3264 else if (
dynamic_cast<wxBitmapComboBox *
>(win) ||
3265 dynamic_cast<wxChoice *
>(win) ||
dynamic_cast<wxComboBox *
>(win) ||
3266 dynamic_cast<wxTreeCtrl *
>(win)) {
3267 win->SetBackgroundColour(col);
3270 else if (
dynamic_cast<wxScrolledWindow *
>(win) ||
3271 dynamic_cast<wxGenericDirCtrl *
>(win) ||
3272 dynamic_cast<wxListbook *
>(win) ||
dynamic_cast<wxButton *
>(win) ||
3273 dynamic_cast<wxToggleButton *
>(win)) {
3274 win->SetBackgroundColour(window_back_color);
3277 else if (
dynamic_cast<wxNotebook *
>(win)) {
3278 win->SetBackgroundColour(window_back_color);
3279 win->SetForegroundColour(text_color);
3283 else if (
dynamic_cast<wxHtmlWindow *
>(win)) {
3284 if (cs != GLOBAL_COLOR_SCHEME_DAY && cs != GLOBAL_COLOR_SCHEME_RGB)
3285 win->SetBackgroundColour(ctrl_back_color);
3287 win->SetBackgroundColour(wxNullColour);
3290 else if (
dynamic_cast<wxGrid *
>(win)) {
3291 dynamic_cast<wxGrid *
>(win)->SetDefaultCellBackgroundColour(
3293 dynamic_cast<wxGrid *
>(win)->SetDefaultCellTextColour(uitext);
3294 dynamic_cast<wxGrid *
>(win)->SetLabelBackgroundColour(col);
3295 dynamic_cast<wxGrid *
>(win)->SetLabelTextColour(uitext);
3296 dynamic_cast<wxGrid *
>(win)->SetGridLineColour(gridline);
3299 if (win->GetChildren().GetCount() > 0) {
3302 DimeControl(w, col, window_back_color, ctrl_back_color, text_color,
3303 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.
wxString g_dm_logfile
Last Data Monitor log file.
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.
Abstract gFrame/MyFrame interface.
std::vector< Track * > g_TrackList
Global instance.
Recorded track abstraction.