43#include <wx/bmpcbox.h>
45#include <wx/filename.h>
46#include <wx/graphics.h>
48#include <wx/listbook.h>
49#include <wx/listimpl.cpp>
50#include <wx/progdlg.h>
51#include <wx/sstream.h>
53#include <wx/timectrl.h>
54#include <wx/tokenzr.h>
56#include "ais_decoder.h"
58#include "CanvasConfig.h"
63#include "config_vars.h"
64#include "conn_params.h"
72#include "multiplexer.h"
73#include "nav_object_database.h"
74#include "navutil_base.h"
77#include "NMEALogWindow.h"
79#include "ocpn_frame.h"
80#include "OCPNPlatform.h"
81#include "OCPN_Sound.h"
93#include "glChartCanvas.h"
97#include "androidUTIL.h"
105extern double g_ChartNotRenderScaleFactor;
106extern int g_restore_stackindex;
107extern int g_restore_dbindex;
108extern RouteList *pRouteList;
109extern std::vector<Track*> g_TrackList;
110extern LayerList *pLayerList;
111extern int g_LayerIdx;
113extern double vLat, vLon;
114extern double kLat, kLon;
115extern double initial_scale_ppm, initial_rotation;
116extern ColorScheme global_color_scheme;
117extern int g_nbrightness;
118extern bool g_bShowTrue, g_bShowMag;
119extern bool g_bShowStatusBar;
120extern bool g_bUIexpert;
121extern bool g_bFullscreen;
122extern int g_nDepthUnitDisplay;
123extern wxString g_winPluginDir;
125extern wxString g_SENCPrefix;
126extern wxString g_UserPresLibData;
128extern wxString *pInit_Chart_Dir;
129extern wxString gWorldMapLocation;
132extern bool s_bSetSystemTime;
133extern bool g_bDisplayGrid;
134extern bool g_bPlayShipsBells;
135extern int g_iSoundDeviceIndex;
136extern bool g_bFullscreenToolbar;
137extern bool g_bShowLayers;
138extern bool g_bTransparentToolbar;
139extern bool g_bPermanentMOBIcon;
141extern bool g_bShowDepthUnits;
142extern bool g_bAutoAnchorMark;
143extern bool g_bskew_comp;
144extern bool g_bopengl;
145extern bool g_bdisable_opengl;
146extern bool g_bSoftwareGL;
147extern bool g_bShowFPS;
148extern bool g_bsmoothpanzoom;
149extern bool g_fog_overzoom;
150extern double g_overzoom_emphasis_base;
151extern bool g_oz_vector_scale;
152extern double g_plus_minus_zoom_factor;
153extern bool g_bShowOutlines;
154extern bool g_bShowActiveRouteHighway;
155extern bool g_bShowRouteTotal;
156extern int g_nAWDefault;
158extern int g_nTrackPrecision;
160extern int g_iSDMMFormat;
161extern int g_iDistanceFormat;
162extern int g_iSpeedFormat;
163extern int g_iTempFormat;
165extern int g_nframewin_x;
166extern int g_nframewin_y;
167extern int g_nframewin_posx;
168extern int g_nframewin_posy;
169extern bool g_bframemax;
171extern double g_PlanSpeed;
172extern wxString g_VisibleLayers;
173extern wxString g_InvisibleLayers;
174extern wxString g_VisiNameinLayers;
175extern wxString g_InVisiNameinLayers;
177extern wxArrayString *pMessageOnceArray;
180extern bool g_bShowLiveETA;
181extern double g_defaultBoatSpeed;
182extern double g_defaultBoatSpeedUserUnit;
185extern bool g_bCPAMax;
186extern double g_CPAMax_NM;
187extern bool g_bCPAWarn;
188extern double g_CPAWarn_NM;
189extern bool g_bTCPA_Max;
190extern double g_TCPA_Max;
191extern bool g_bMarkLost;
192extern double g_MarkLost_Mins;
193extern bool g_bRemoveLost;
194extern double g_RemoveLost_Mins;
195extern bool g_bShowCOG;
196extern bool g_bSyncCogPredictors;
197extern double g_ShowCOG_Mins;
198extern bool g_bAISShowTracks;
199extern bool g_bTrackCarryOver;
200extern bool g_bTrackDaily;
201extern int g_track_rotate_time;
202extern int g_track_rotate_time_type;
203extern double g_AISShowTracks_Mins;
204extern double g_AISShowTracks_Limit;
205extern bool g_bHideMoored;
206extern double g_ShowMoored_Kts;
207extern bool g_bAllowShowScaled;
208extern bool g_bShowScaled;
209extern int g_ShowScaled_Num;
210extern bool g_bAIS_CPA_Alert;
211extern bool g_bAIS_CPA_Alert_Audio;
212extern int g_ais_alert_dialog_x, g_ais_alert_dialog_y;
213extern int g_ais_alert_dialog_sx, g_ais_alert_dialog_sy;
214extern int g_ais_query_dialog_x, g_ais_query_dialog_y;
215extern wxString g_sAIS_Alert_Sound_File;
216extern wxString g_anchorwatch_sound_file;
217extern wxString g_DSC_sound_file;
218extern wxString g_SART_sound_file;
219extern wxString g_AIS_sound_file;
220extern bool g_bAIS_GCPA_Alert_Audio;
221extern bool g_bAIS_SART_Alert_Audio;
222extern bool g_bAIS_DSC_Alert_Audio;
223extern bool g_bAnchor_Alert_Audio;
225extern bool g_bAIS_CPA_Alert_Suppress_Moored;
226extern bool g_bAIS_ACK_Timeout;
227extern double g_AckTimeout_Mins;
228extern wxString g_AisTargetList_perspective;
229extern int g_AisTargetList_range;
230extern int g_AisTargetList_sortColumn;
231extern bool g_bAisTargetList_sortReverse;
232extern wxString g_AisTargetList_column_spec;
233extern wxString g_AisTargetList_column_order;
234extern bool g_bShowAreaNotices;
235extern bool g_bDrawAISSize;
236extern bool g_bDrawAISRealtime;
237extern double g_AIS_RealtPred_Kts;
238extern bool g_bShowAISName;
239extern int g_Show_Target_Name_Scale;
240extern int g_WplAction;
241extern bool g_benableAISNameCache;
242extern bool g_bUseOnlyConfirmedAISName;
243extern int g_ScaledNumWeightSOG;
244extern int g_ScaledNumWeightCPA;
245extern int g_ScaledNumWeightTCPA;
246extern int g_ScaledNumWeightRange;
247extern int g_ScaledNumWeightSizeOfT;
248extern int g_ScaledSizeMinimal;
250extern int g_S57_dialog_sx, g_S57_dialog_sy;
251int g_S57_extradialog_sx, g_S57_extradialog_sy;
253extern int g_iNavAidRadarRingsNumberVisible;
254extern float g_fNavAidRadarRingsStep;
255extern int g_pNavAidRadarRingsStepUnits;
256extern int g_iWaypointRangeRingsNumber;
257extern float g_fWaypointRangeRingsStep;
258extern int g_iWaypointRangeRingsStepUnits;
259extern wxColour g_colourWaypointRangeRingsColour;
260extern bool g_bWayPointPreventDragging;
261extern bool g_bConfirmObjectDelete;
262extern wxColour g_colourOwnshipRangeRingsColour;
263extern int g_iWpt_ScaMin;
264extern bool g_bUseWptScaMin;
265extern bool g_bOverruleScaMin;
266extern bool g_bShowWptName;
268extern bool g_bEnableZoomToCursor;
269extern wxString g_toolbarConfig;
270extern double g_TrackIntervalSeconds;
271extern double g_TrackDeltaDistance;
273extern int g_nCacheLimit;
274extern int g_memCacheLimit;
276extern bool g_bGDAL_Debug;
277extern bool g_bDebugCM93;
278extern bool g_bDebugS57;
280extern double g_ownship_predictor_minutes;
281extern double g_ownship_HDTpredictor_miles;
283extern bool g_own_ship_sog_cog_calc;
284extern int g_own_ship_sog_cog_calc_damp_sec;
286extern bool g_bShowMenuBar;
287extern bool g_bShowCompassWin;
289extern s52plib *ps52plib;
291extern int g_cm93_zoom_factor;
292extern bool g_b_legacy_input_filter_behaviour;
293extern bool g_bShowDetailSlider;
294extern int g_detailslider_dialog_x, g_detailslider_dialog_y;
296extern bool g_bUseGreenShip;
298extern int g_OwnShipIconType;
299extern double g_n_ownship_length_meters;
300extern double g_n_ownship_beam_meters;
301extern double g_n_gps_antenna_offset_y;
302extern double g_n_gps_antenna_offset_x;
303extern int g_n_ownship_min_mm;
304extern double g_n_arrival_circle_radius;
305extern int g_maxzoomin;
307extern bool g_bShowShipToActive;
308extern int g_shipToActiveStyle;
309extern int g_shipToActiveColor;
311extern bool g_bPreserveScaleOnX;
312extern bool g_bsimplifiedScalebar;
314extern bool g_bUseGLL;
316extern wxString g_locale;
317extern wxString g_localeOverride;
319extern bool g_bCourseUp;
320extern bool g_bLookAhead;
321extern int g_COGAvgSec;
322extern bool g_bMagneticAPB;
323extern bool g_bShowChartBar;
325extern int g_MemFootMB;
327extern int g_nCOMPortCheck;
329extern wxString g_AW1GUID;
330extern wxString g_AW2GUID;
331extern int g_BSBImgDebug;
333extern int n_NavMessageShown;
334extern wxString g_config_version_string;
336extern wxString g_CmdSoundString;
338extern bool g_bAISRolloverShowClass;
339extern bool g_bAISRolloverShowCOG;
340extern bool g_bAISRolloverShowCPA;
342extern bool g_bDebugGPSD;
344extern bool g_bfilter_cogsog;
345extern int g_COGFilterSec;
346extern int g_SOGFilterSec;
350extern bool g_bQuiltEnable;
351extern bool g_bFullScreenQuilt;
352extern bool g_bQuiltStart;
354extern int g_SkewCompUpdatePeriod;
356extern int g_maintoolbar_x;
357extern int g_maintoolbar_y;
358extern long g_maintoolbar_orient;
360extern int g_lastClientRectx;
361extern int g_lastClientRecty;
362extern int g_lastClientRectw;
363extern int g_lastClientRecth;
365extern bool g_bHighliteTracks;
366extern int g_cog_predictor_width;
367extern int g_ais_cog_predictor_width;
369extern int g_route_line_width;
370extern int g_track_line_width;
371extern wxColour g_colourTrackLineColour;
372extern wxString g_default_wp_icon;
373extern wxString g_default_routepoint_icon;
375extern ChartGroupArray *g_pGroupArray;
377extern bool g_bDebugOGL;
378extern int g_tcwin_scale;
379extern wxString g_uploadConnection;
382extern wxArrayString TideCurrentDataSet;
383extern wxString g_TCData_Dir;
386extern bool g_bresponsive;
388extern bool g_bGLexpert;
390extern int g_SENC_LOD_pixels;
391extern ArrayOfMmsiProperties g_MMSI_Props_Array;
393extern int g_chart_zoom_modifier_raster;
394extern int g_chart_zoom_modifier_vector;
396extern int g_NMEAAPBPrecision;
398extern bool g_bShowTrackPointTime;
400extern bool g_bAdvanceRouteWaypointOnArrivalOnly;
401extern double g_display_size_mm;
402extern double g_config_display_size_mm;
403extern bool g_config_display_size_manual;
405extern float g_selection_radius_mm;
406extern float g_selection_radius_touch_mm;
408extern bool g_benable_rotate;
409extern bool g_bEmailCrashReport;
411extern int g_default_font_size;
412extern wxString g_default_font_facename;
414extern bool g_bAutoHideToolbar;
415extern int g_nAutoHideToolbar;
416extern int g_GUIScaleFactor;
417extern int g_ChartScaleFactor;
418extern float g_ChartScaleFactorExp;
419extern float g_MarkScaleFactorExp;
421extern int g_ShipScaleFactor;
422extern float g_ShipScaleFactorExp;
423extern int g_ENCSoundingScaleFactor;
424extern int g_ENCTextScaleFactor;
426extern bool g_bInlandEcdis;
427extern int g_iENCToolbarPosX;
428extern int g_iENCToolbarPosY;
429extern bool g_bRollover;
431extern bool g_bSpaceDropMark;
433extern bool g_bShowTide;
434extern bool g_bShowCurrent;
436extern bool g_benableUDPNullHeader;
438extern wxString g_uiStyle;
439extern bool g_btrackContinuous;
444extern unsigned int g_canvasConfig;
445extern arrayofCanvasConfigPtr g_canvasConfigArray;
446extern wxString g_lastAppliedTemplateGUID;
448extern int g_route_prop_x, g_route_prop_y;
449extern int g_route_prop_sx, g_route_prop_sy;
450extern int g_AndroidVersionCode;
452extern wxString g_compatOS;
453extern wxString g_compatOsVersion;
454extern wxString g_ObjQFileExt;
458bool g_bShowMuiZoomButtons =
true;
460wxString g_catalog_custom_url;
461wxString g_catalog_channel;
464double g_mouse_zoom_sensitivity;
465int g_mouse_zoom_sensitivity_ui;
472static const long long lNaN = 0xfff8000000000000;
473#define NAN (*(double *)&lNaN)
478wxString GetLayerName(
int id) {
479 wxString name(_T(
"unknown layer"));
480 if (
id <= 0)
return (name);
481 LayerList::iterator it;
483 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
485 if (lay->m_LayerID ==
id)
return (lay->m_LayerName);
491void appendOSDirSlash(wxString *pString);
498MyConfig::MyConfig(
const wxString &LocalFileName)
499 : wxFileConfig(_T (
""), _T (
""), LocalFileName, _T (
""),
500 wxCONFIG_USE_LOCAL_FILE) {
502 wxFileName config_file(LocalFileName);
504 config_file.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
505 m_sNavObjSetFile += _T (
"navobj.xml" );
506 m_sNavObjSetChangesFile = m_sNavObjSetFile + _T (
".changes" );
508 m_pNavObjectInputSet = NULL;
509 m_pNavObjectChangesSet = NULL;
513void MyConfig::CreateRotatingNavObjBackup() {
515#ifdef __OCPN__ANDROID__
523 if (g_navobjbackups > 0) {
525 wxString oldname = m_sNavObjSetFile;
526 wxString newname = wxString::Format(_T(
"%s.1"), m_sNavObjSetFile.c_str());
528 wxFileOffset s_diff = 1;
529 if (::wxFileExists(newname)) {
530 if (f.Open(oldname)) {
535 if (f.Open(newname)) {
536 s_diff -= f.Length();
542 for (
int i = g_navobjbackups - 1; i >= 1; i--) {
543 oldname = wxString::Format(_T(
"%s.%d"), m_sNavObjSetFile.c_str(), i);
545 wxString::Format(_T(
"%s.%d"), m_sNavObjSetFile.c_str(), i + 1);
546 if (wxFile::Exists(oldname)) wxCopyFile(oldname, newname);
549 if (wxFile::Exists(m_sNavObjSetFile)) {
550 newname = wxString::Format(_T(
"%s.1"), m_sNavObjSetFile.c_str());
551 wxCopyFile(m_sNavObjSetFile, newname);
557 for (
int i = g_navobjbackups + 1; i <= 99; i++)
559 wxString::Format(_T(
"%s.%d"), m_sNavObjSetFile.c_str(), i)))
560 wxRemoveFile(wxString::Format(_T(
"%s.%d"), m_sNavObjSetFile.c_str(), i));
565int MyConfig::LoadMyConfig() {
566 int display_width, display_height;
567 wxDisplaySize(&display_width, &display_height);
571 g_TalkerIdText = _T(
"EC");
572 g_maxWPNameLength = 6;
573 g_NMEAAPBPrecision = 3;
576 g_GLOptions.m_bUseAcceleratedPanning =
true;
577 g_GLOptions.m_GLPolygonSmoothing =
true;
578 g_GLOptions.m_GLLineSmoothing =
true;
579 g_GLOptions.m_iTextureDimension = 512;
580 g_GLOptions.m_iTextureMemorySize = 128;
582 g_GLOptions.m_iTextureMemorySize =
583 wxMax(128, g_GLOptions.m_iTextureMemorySize);
584 g_GLOptions.m_bTextureCompressionCaching =
585 g_GLOptions.m_bTextureCompression;
589 g_maintoolbar_orient = wxTB_HORIZONTAL;
590 g_iENCToolbarPosX = -1;
591 g_iENCToolbarPosY = -1;
592 g_restore_dbindex = -1;
593 g_ChartNotRenderScaleFactor = 1.5;
594 g_detailslider_dialog_x = 200L;
595 g_detailslider_dialog_y = 200L;
596 g_SENC_LOD_pixels = 2;
597 g_SkewCompUpdatePeriod = 10;
599 g_bShowStatusBar = 1;
600 g_bShowCompassWin = 1;
601 g_iSoundDeviceIndex = -1;
602 g_bFullscreenToolbar = 1;
603 g_bTransparentToolbar = 0;
605 g_bShowDepthUnits = 1;
606 g_bShowActiveRouteHighway = 1;
608 g_defaultBoatSpeed = 6.0;
609 g_ownship_predictor_minutes = 5;
610 g_cog_predictor_width = 3;
611 g_ownship_HDTpredictor_miles = 1;
612 g_n_ownship_min_mm = 2;
613 g_own_ship_sog_cog_calc_damp_sec = 1;
614 g_bFullScreenQuilt = 1;
615 g_track_rotate_time_type = TIME_TYPE_COMPUTER;
616 g_bHighliteTracks = 1;
617 g_bPreserveScaleOnX = 1;
619 g_benableAISNameCache =
true;
620 g_n_arrival_circle_radius = 0.05;
621 g_plus_minus_zoom_factor = 2.0;
622 g_mouse_zoom_sensitivity = 1.5;
624 g_AISShowTracks_Mins = 20;
625 g_AISShowTracks_Limit = 300.0;
626 g_ShowScaled_Num = 10;
627 g_ScaledNumWeightSOG = 50;
628 g_ScaledNumWeightCPA = 60;
629 g_ScaledNumWeightTCPA = 25;
630 g_ScaledNumWeightRange = 75;
631 g_ScaledNumWeightSizeOfT = 25;
632 g_ScaledSizeMinimal = 50;
633 g_Show_Target_Name_Scale = 250000;
634 g_bWplUsePosition = 0;
636 g_ais_cog_predictor_width = 3;
637 g_ais_alert_dialog_sx = 200;
638 g_ais_alert_dialog_sy = 200;
639 g_ais_alert_dialog_x = 200;
640 g_ais_alert_dialog_y = 200;
641 g_ais_query_dialog_x = 200;
642 g_ais_query_dialog_y = 200;
643 g_AisTargetList_range = 40;
644 g_AisTargetList_sortColumn = 2;
645 g_S57_dialog_sx = 400;
646 g_S57_dialog_sy = 400;
647 g_S57_extradialog_sx = 400;
648 g_S57_extradialog_sy = 400;
655 initial_scale_ppm = .0003;
656 initial_rotation = 0;
659 g_iNavAidRadarRingsNumberVisible = 0;
660 g_fNavAidRadarRingsStep = 1.0;
661 g_pNavAidRadarRingsStepUnits = 0;
662 g_colourOwnshipRangeRingsColour = *wxRED;
663 g_iWaypointRangeRingsNumber = 0;
664 g_fWaypointRangeRingsStep = 1.0;
665 g_iWaypointRangeRingsStepUnits = 0;
666 g_colourWaypointRangeRingsColour = wxColour(*wxRED);
667 g_bConfirmObjectDelete =
true;
669 g_TrackIntervalSeconds = 60.0;
670 g_TrackDeltaDistance = 0.10;
671 g_route_line_width = 2;
672 g_track_line_width = 2;
673 g_colourTrackLineColour = wxColour(243, 229, 47);
676 g_default_wp_icon = _T(
"triangle");
677 g_default_routepoint_icon = _T(
"diamond");
681 g_ObjQFileExt = _T(
"txt,rtf,png,html,gif,tif");
684 int ret_Val = LoadMyConfigRaw();
688 g_ChartScaleFactorExp =
689 g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor);
690 g_ShipScaleFactorExp =
691 g_Platform->GetChartScaleFactorExp(g_ShipScaleFactor);
692 g_MarkScaleFactorExp =
693 g_Platform->GetMarkScaleFactorExp(g_ChartScaleFactor);
695 g_COGFilterSec = wxMin(g_COGFilterSec, MAX_COGSOG_FILTER_SECONDS);
696 g_COGFilterSec = wxMax(g_COGFilterSec, 1);
697 g_SOGFilterSec = g_COGFilterSec;
699 if (!g_bShowTrue && !g_bShowMag) g_bShowTrue =
true;
701 wxMin(g_COGAvgSec, MAX_COG_AVERAGE_SECONDS);
703 if (g_bInlandEcdis) g_bLookAhead = 1;
705 if (g_bdisable_opengl) g_bopengl =
false;
709 g_GLOptions.m_iTextureMemorySize =
710 wxMax(128, g_GLOptions.m_iTextureMemorySize);
711 g_GLOptions.m_bTextureCompressionCaching =
712 g_GLOptions.m_bTextureCompression;
716 g_chart_zoom_modifier_raster = wxMin(g_chart_zoom_modifier_raster, 5);
717 g_chart_zoom_modifier_raster = wxMax(g_chart_zoom_modifier_raster, -5);
718 g_chart_zoom_modifier_vector = wxMin(g_chart_zoom_modifier_vector, 5);
719 g_chart_zoom_modifier_vector = wxMax(g_chart_zoom_modifier_vector, -5);
720 g_cm93_zoom_factor = wxMin(g_cm93_zoom_factor, CM93_ZOOM_FACTOR_MAX_RANGE);
722 wxMax(g_cm93_zoom_factor, (-CM93_ZOOM_FACTOR_MAX_RANGE));
724 if ((g_detailslider_dialog_x < 0) ||
725 (g_detailslider_dialog_x > display_width))
726 g_detailslider_dialog_x = 5;
727 if ((g_detailslider_dialog_y < 0) ||
728 (g_detailslider_dialog_y > display_height))
729 g_detailslider_dialog_y = 5;
731 g_defaultBoatSpeedUserUnit = toUsrSpeed(g_defaultBoatSpeed, -1);
732 g_n_ownship_min_mm = wxMax(g_n_ownship_min_mm, 2);
734 if (g_navobjbackups > 99) g_navobjbackups = 99;
735 if (g_navobjbackups < 0) g_navobjbackups = 0;
736 g_n_arrival_circle_radius = wxClip(g_n_arrival_circle_radius, 0.001, 0.6);
738 g_selection_radius_mm = wxMax(g_selection_radius_mm, 0.5);
739 g_selection_radius_touch_mm = wxMax(g_selection_radius_touch_mm, 1.0);
741 g_Show_Target_Name_Scale = wxMax(5000, g_Show_Target_Name_Scale);
743 if ((g_ais_alert_dialog_x < 0) || (g_ais_alert_dialog_x > display_width))
744 g_ais_alert_dialog_x = 5;
745 if ((g_ais_alert_dialog_y < 0) || (g_ais_alert_dialog_y > display_height))
746 g_ais_alert_dialog_y = 5;
747 if ((g_ais_query_dialog_x < 0) || (g_ais_query_dialog_x > display_width))
748 g_ais_query_dialog_x = 5;
749 if ((g_ais_query_dialog_y < 0) || (g_ais_query_dialog_y > display_height))
750 g_ais_query_dialog_y = 5;
752 SwitchInlandEcdisMode(g_bInlandEcdis);
754 global_color_scheme =
755 GLOBAL_COLOR_SCHEME_DUSK;
764int MyConfig::LoadMyConfigRaw(
bool bAsTemplate) {
768 int display_width, display_height;
769 wxDisplaySize(&display_width, &display_height);
772 SetPath(_T (
"/Settings" ));
774 Read(_T (
"LastAppliedTemplate" ), &g_lastAppliedTemplateGUID);
775 Read(_T (
"CompatOS" ), &g_compatOS);
776 Read(_T (
"CompatOsVersion" ), &g_compatOsVersion);
779 Read(_T (
"ConfigVersionString" ), &g_config_version_string);
780 Read(_T(
"CmdSoundString"), &g_CmdSoundString, wxString(OCPN_SOUND_CMD));
781 if (wxIsEmpty(g_CmdSoundString))
782 g_CmdSoundString = wxString(OCPN_SOUND_CMD);
783 Read(_T (
"NavMessageShown" ), &n_NavMessageShown);
785 Read(_T (
"AndroidVersionCode" ), &g_AndroidVersionCode);
787 Read(_T (
"UIexpert" ), &g_bUIexpert);
789 Read(_T (
"UIStyle" ), &g_uiStyle);
791 Read(_T (
"NCacheLimit" ), &g_nCacheLimit);
793 Read(_T (
"InlandEcdis" ),
797 Read(_T(
"SpaceDropMark" ), &g_bSpaceDropMark);
800 Read(_T (
"MEMCacheLimit" ), &mem_limit);
802 g_memCacheLimit = mem_limit * 1024;
804 Read(_T (
"UseModernUI5" ), &g_useMUI);
806 Read(_T(
"NCPUCount" ), &g_nCPUCount);
808 Read(_T (
"DebugGDAL" ), &g_bGDAL_Debug);
809 Read(_T (
"DebugNMEA" ), &g_nNMEADebug);
810 Read(_T (
"AnchorWatchDefault" ), &g_nAWDefault);
811 Read(_T (
"AnchorWatchMax" ), &g_nAWMax);
812 Read(_T (
"GPSDogTimeout" ), &gps_watchdog_timeout_ticks);
813 Read(_T (
"DebugCM93" ), &g_bDebugCM93);
814 Read(_T (
"DebugS57" ),
816 Read(_T (
"DebugBSBImg" ), &g_BSBImgDebug);
817 Read(_T (
"DebugGPSD" ), &g_bDebugGPSD);
818 Read(_T (
"MaxZoomScale" ), &g_maxzoomin);
819 g_maxzoomin = wxMax(g_maxzoomin, 50);
821 Read(_T (
"DefaultFontSize"), &g_default_font_size);
822 Read(_T (
"DefaultFontFacename"), &g_default_font_facename);
824 Read(_T (
"UseGreenShipIcon" ), &g_bUseGreenShip);
826 Read(_T (
"AutoHideToolbar" ), &g_bAutoHideToolbar);
827 Read(_T (
"AutoHideToolbarSecs" ), &g_nAutoHideToolbar);
829 Read(_T (
"UseSimplifiedScalebar" ), &g_bsimplifiedScalebar);
830 Read(_T (
"ShowTide" ), &g_bShowTide);
831 Read(_T (
"ShowCurrent" ), &g_bShowCurrent);
834 Read(_T (
"DisplaySizeMM" ), &size_mm);
836 Read(_T (
"SelectionRadiusMM" ), &g_selection_radius_mm);
837 Read(_T (
"SelectionRadiusTouchMM" ), &g_selection_radius_touch_mm);
841 g_config_display_size_mm = size_mm;
842 if ((size_mm > 100) && (size_mm < 2000)) {
843 g_display_size_mm = size_mm;
846 Read(_T (
"DisplaySizeManual" ), &g_config_display_size_manual);
849 Read(_T (
"GUIScaleFactor" ), &g_GUIScaleFactor);
851 Read(_T (
"ChartObjectScaleFactor" ), &g_ChartScaleFactor);
852 Read(_T (
"ShipScaleFactor" ), &g_ShipScaleFactor);
853 Read(_T (
"ENCSoundingScaleFactor" ), &g_ENCSoundingScaleFactor);
854 Read(_T (
"ENCTextScaleFactor" ), &g_ENCTextScaleFactor);
855 Read(_T (
"ObjQueryAppendFilesExt" ), &g_ObjQFileExt);
858 Read(
"CatalogCustomURL", &g_catalog_custom_url);
859 Read(
"CatalogChannel", &g_catalog_channel);
863 Read(_T (
"FilterNMEA_Avg" ), &g_bfilter_cogsog);
864 Read(_T (
"FilterNMEA_Sec" ), &g_COGFilterSec);
865 Read(_T (
"GPSIdent" ), &g_GPS_Ident);
866 Read(_T (
"UseGarminHostUpload" ), &g_bGarminHostUpload);
867 Read(_T (
"UseNMEA_GLL" ), &g_bUseGLL);
868 Read(_T (
"UseMagAPB" ), &g_bMagneticAPB);
869 Read(_T (
"TrackContinuous" ), &g_btrackContinuous,
false);
870 Read(_T (
"FilterTrackDropLargeJump" ), &g_trackFilterMax, 0);
873 Read(_T (
"ShowTrue" ), &g_bShowTrue);
874 Read(_T (
"ShowMag" ), &g_bShowMag);
877 Read(_T (
"UserMagVariation" ), &umv);
878 if (umv.Len()) umv.ToDouble(&g_UserVar);
880 Read(_T (
"ScreenBrightness" ), &g_nbrightness);
882 Read(_T (
"MemFootprintTargetMB" ), &g_MemFootMB);
884 Read(_T (
"WindowsComPortMax" ), &g_nCOMPortCheck);
886 Read(_T (
"ChartQuilting" ), &g_bQuiltEnable);
887 Read(_T (
"ChartQuiltingInitial" ), &g_bQuiltStart);
889 Read(_T (
"CourseUpMode" ), &g_bCourseUp);
890 Read(_T (
"COGUPAvgSeconds" ), &g_COGAvgSec);
891 Read(_T (
"LookAheadMode" ), &g_bLookAhead);
892 Read(_T (
"SkewToNorthUp" ), &g_bskew_comp);
894 Read(_T (
"ShowFPS" ), &g_bShowFPS);
896 Read(_T(
"NMEAAPBPrecision" ), &g_NMEAAPBPrecision);
898 Read(_T(
"TalkerIdText" ), &g_TalkerIdText);
899 Read(_T(
"MaxWaypointNameLength" ), &g_maxWPNameLength);
901 Read(_T(
"ShowTrackPointTime" ), &g_bShowTrackPointTime,
true);
905 Read(_T (
"OpenGLExpert" ), &g_bGLexpert,
false);
906 Read(_T (
"UseAcceleratedPanning" ), &g_GLOptions.m_bUseAcceleratedPanning,
908 Read(_T (
"GPUTextureCompression" ), &g_GLOptions.m_bTextureCompression);
909 Read(_T (
"GPUTextureCompressionCaching" ),
910 &g_GLOptions.m_bTextureCompressionCaching);
911 Read(_T (
"PolygonSmoothing" ), &g_GLOptions.m_GLPolygonSmoothing);
912 Read(_T (
"LineSmoothing" ), &g_GLOptions.m_GLLineSmoothing);
913 Read(_T (
"GPUTextureDimension" ), &g_GLOptions.m_iTextureDimension);
914 Read(_T (
"GPUTextureMemSize" ), &g_GLOptions.m_iTextureMemorySize);
915 Read(_T (
"DebugOpenGL" ), &g_bDebugOGL);
916 Read(_T (
"OpenGL" ), &g_bopengl);
917 Read(_T (
"SoftwareGL" ), &g_bSoftwareGL);
921 Read(_T (
"SmoothPanZoom" ), &g_bsmoothpanzoom);
923 Read(_T (
"ToolbarX"), &g_maintoolbar_x);
924 Read(_T (
"ToolbarY" ), &g_maintoolbar_y);
925 Read(_T (
"ToolbarOrient" ), &g_maintoolbar_orient);
926 Read(_T (
"GlobalToolbarConfig" ), &g_toolbarConfig);
928 Read(_T (
"iENCToolbarX"), &g_iENCToolbarPosX);
929 Read(_T (
"iENCToolbarY"), &g_iENCToolbarPosY);
931 Read(_T (
"AnchorWatch1GUID" ), &g_AW1GUID);
932 Read(_T (
"AnchorWatch2GUID" ), &g_AW2GUID);
934 Read(_T (
"InitialStackIndex" ), &g_restore_stackindex);
935 Read(_T (
"InitialdBIndex" ), &g_restore_dbindex);
937 Read(_T (
"ChartNotRenderScaleFactor" ), &g_ChartNotRenderScaleFactor);
939 Read(_T (
"MobileTouch" ), &g_btouch);
943#ifdef __OCPN__ANDROID__
944 g_bresponsive =
true;
946 g_bresponsive =
false;
949 Read(_T (
"EnableRolloverBlock" ), &g_bRollover);
951 Read(_T (
"ZoomDetailFactor" ), &g_chart_zoom_modifier_raster);
952 Read(_T (
"ZoomDetailFactorVector" ), &g_chart_zoom_modifier_vector);
953 Read(_T (
"PlusMinusZoomFactor" ), &g_plus_minus_zoom_factor, 2.0);
954 Read(
"MouseZoomSensitivity", &g_mouse_zoom_sensitivity, 1.3);
955 g_mouse_zoom_sensitivity_ui =
957 Read(_T (
"CM93DetailFactor" ), &g_cm93_zoom_factor);
959 Read(_T (
"CM93DetailZoomPosX" ), &g_detailslider_dialog_x);
960 Read(_T (
"CM93DetailZoomPosY" ), &g_detailslider_dialog_y);
961 Read(_T (
"ShowCM93DetailSlider" ), &g_bShowDetailSlider);
963 Read(_T (
"SENC_LOD_Pixels" ), &g_SENC_LOD_pixels);
965 Read(_T (
"SkewCompUpdatePeriod" ), &g_SkewCompUpdatePeriod);
967 Read(_T (
"SetSystemTime" ), &s_bSetSystemTime);
968 Read(_T (
"ShowStatusBar" ), &g_bShowStatusBar);
970 Read(_T (
"ShowMenuBar" ), &g_bShowMenuBar);
972 Read(_T (
"Fullscreen" ), &g_bFullscreen);
973 Read(_T (
"ShowCompassWindow" ), &g_bShowCompassWin);
974 Read(_T (
"ShowGrid" ), &g_bDisplayGrid);
975 Read(_T (
"PlayShipsBells" ), &g_bPlayShipsBells);
976 Read(_T (
"SoundDeviceIndex" ), &g_iSoundDeviceIndex);
977 Read(_T (
"FullscreenToolbar" ), &g_bFullscreenToolbar);
978 Read(_T (
"PermanentMOBIcon" ), &g_bPermanentMOBIcon);
979 Read(_T (
"ShowLayers" ), &g_bShowLayers);
980 Read(_T (
"ShowDepthUnits" ), &g_bShowDepthUnits);
981 Read(_T (
"AutoAnchorDrop" ), &g_bAutoAnchorMark);
982 Read(_T (
"ShowChartOutlines" ), &g_bShowOutlines);
983 Read(_T (
"ShowActiveRouteHighway" ), &g_bShowActiveRouteHighway);
984 Read(_T (
"ShowActiveRouteTotal" ), &g_bShowRouteTotal);
985 Read(_T (
"MostRecentGPSUploadConnection" ), &g_uploadConnection);
986 Read(_T (
"ShowChartBar" ), &g_bShowChartBar);
987 Read(_T (
"SDMMFormat" ),
991 Read(_T (
"DistanceFormat" ),
994 Read(_T (
"SpeedFormat" ),
996 Read(_T (
"TemperatureFormat"), &g_iTempFormat);
999 Read(_T (
"LiveETA" ), &g_bShowLiveETA);
1000 Read(_T (
"DefaultBoatSpeed" ), &g_defaultBoatSpeed);
1002 Read(_T (
"OwnshipCOGPredictorMinutes" ), &g_ownship_predictor_minutes);
1003 Read(_T (
"OwnshipCOGPredictorWidth" ), &g_cog_predictor_width);
1004 Read(_T (
"OwnshipHDTPredictorMiles" ), &g_ownship_HDTpredictor_miles);
1006 Read(_T (
"OwnShipIconType" ), &g_OwnShipIconType);
1007 Read(_T (
"OwnShipLength" ), &g_n_ownship_length_meters);
1008 Read(_T (
"OwnShipWidth" ), &g_n_ownship_beam_meters);
1009 Read(_T (
"OwnShipGPSOffsetX" ), &g_n_gps_antenna_offset_x);
1010 Read(_T (
"OwnShipGPSOffsetY" ), &g_n_gps_antenna_offset_y);
1011 Read(_T (
"OwnShipMinSize" ), &g_n_ownship_min_mm);
1012 Read(_T (
"OwnShipSogCogCalc" ), &g_own_ship_sog_cog_calc);
1013 Read(_T (
"OwnShipSogCogCalcDampSec"), &g_own_ship_sog_cog_calc_damp_sec);
1014 Read(_T (
"ShowDirectRouteLine"), &g_bShowShipToActive);
1015 Read(_T (
"DirectRouteLineStyle"), &g_shipToActiveStyle);
1016 Read(_T(
"DirectRouteLineColor" ), &g_shipToActiveColor);
1019 Read(_T (
"RouteArrivalCircleRadius" ), &racr);
1020 if (racr.Len()) racr.ToDouble(&g_n_arrival_circle_radius);
1022 Read(_T (
"FullScreenQuilt" ), &g_bFullScreenQuilt);
1024 Read(_T (
"StartWithTrackActive" ), &g_bTrackCarryOver);
1025 Read(_T (
"AutomaticDailyTracks" ), &g_bTrackDaily);
1026 Read(_T (
"TrackRotateAt" ), &g_track_rotate_time);
1027 Read(_T (
"TrackRotateTimeType" ), &g_track_rotate_time_type);
1028 Read(_T (
"HighlightTracks" ), &g_bHighliteTracks);
1031 Read(_T (
"PlanSpeed" ), &stps);
1032 if (!stps.IsEmpty()) stps.ToDouble(&g_PlanSpeed);
1034 Read(_T (
"VisibleLayers" ), &g_VisibleLayers);
1035 Read(_T (
"InvisibleLayers" ), &g_InvisibleLayers);
1036 Read(_T (
"VisNameInLayers" ), &g_VisiNameinLayers);
1037 Read(_T (
"InvisNameInLayers" ), &g_InVisiNameinLayers);
1039 Read(_T (
"PreserveScaleOnX" ), &g_bPreserveScaleOnX);
1041 Read(_T (
"ShowMUIZoomButtons" ), &g_bShowMuiZoomButtons);
1043 Read(_T (
"Locale" ), &g_locale);
1044 Read(_T (
"LocaleOverride" ), &g_localeOverride);
1047 Read(_T (
"KeepNavobjBackups" ), &g_navobjbackups);
1049 NMEALogWindow::Get().SetSize(Read(_T(
"NMEALogWindowSizeX"), 600L),
1050 Read(_T(
"NMEALogWindowSizeY"), 400L));
1051 NMEALogWindow::Get().SetPos(Read(_T(
"NMEALogWindowPosX"), 10L),
1052 Read(_T(
"NMEALogWindowPosY"), 10L));
1053 NMEALogWindow::Get().CheckPos(display_width, display_height);
1057 Read(_T (
"LegacyInputCOMPortFilterBehaviour" ),
1058 &g_b_legacy_input_filter_behaviour);
1061 Read(_T(
"AdvanceRouteWaypointOnArrivalOnly" ),
1062 &g_bAdvanceRouteWaypointOnArrivalOnly);
1064 Read(_T (
"EnableRotateKeys" ), &g_benable_rotate);
1065 Read(_T (
"EmailCrashReport" ), &g_bEmailCrashReport);
1067 g_benableAISNameCache =
true;
1068 Read(_T (
"EnableAISNameCache" ), &g_benableAISNameCache);
1070 Read(_T (
"EnableUDPNullHeader" ), &g_benableUDPNullHeader);
1072 SetPath(_T (
"/Settings/GlobalState" ));
1074 Read(_T (
"FrameWinX" ), &g_nframewin_x);
1075 Read(_T (
"FrameWinY" ), &g_nframewin_y);
1076 Read(_T (
"FrameWinPosX" ), &g_nframewin_posx);
1077 Read(_T (
"FrameWinPosY" ), &g_nframewin_posy);
1078 Read(_T (
"FrameMax" ), &g_bframemax);
1080 Read(_T (
"ClientPosX" ), &g_lastClientRectx);
1081 Read(_T (
"ClientPosY" ), &g_lastClientRecty);
1082 Read(_T (
"ClientSzX" ), &g_lastClientRectw);
1083 Read(_T (
"ClientSzY" ), &g_lastClientRecth);
1085 Read(_T(
"RoutePropSizeX" ), &g_route_prop_sx);
1086 Read(_T(
"RoutePropSizeY" ), &g_route_prop_sy);
1087 Read(_T(
"RoutePropPosX" ), &g_route_prop_x);
1088 Read(_T(
"RoutePropPosY" ), &g_route_prop_y);
1091 Read(_T (
"S52_DEPTH_UNIT_SHOW" ), &read_int);
1092 if (read_int >= 0) {
1093 read_int = wxMax(read_int, 0);
1094 read_int = wxMin(read_int, 2);
1095 g_nDepthUnitDisplay = read_int;
1099 SetPath(_T (
"/Settings/Audio" ));
1102 wxString sound_dir = g_Platform->GetSharedDataDir();
1103 sound_dir.Append(_T(
"sounds"));
1104 sound_dir.Append(wxFileName::GetPathSeparator());
1106 g_AIS_sound_file = sound_dir + _T(
"beep_ssl.wav");
1107 g_DSC_sound_file = sound_dir + _T(
"phonering1.wav");
1108 g_SART_sound_file = sound_dir + _T(
"beep3.wav");
1109 g_anchorwatch_sound_file = sound_dir + _T(
"beep1.wav");
1111 Read(_T (
"AISAlertSoundFile" ), &g_AIS_sound_file);
1112 Read(_T (
"DSCAlertSoundFile" ), &g_DSC_sound_file);
1113 Read(_T (
"SARTAlertSoundFile" ), &g_SART_sound_file);
1114 Read(_T (
"AnchorAlarmSoundFile" ), &g_anchorwatch_sound_file);
1116 Read(_T (
"bAIS_GCPA_AlertAudio" ), &g_bAIS_GCPA_Alert_Audio);
1117 Read(_T (
"bAIS_SART_AlertAudio" ), &g_bAIS_SART_Alert_Audio);
1118 Read(_T (
"bAIS_DSC_AlertAudio" ), &g_bAIS_DSC_Alert_Audio);
1119 Read(_T (
"bAnchorAlertAudio" ), &g_bAnchor_Alert_Audio);
1123 SetPath(_T (
"/Settings/AIS" ));
1125 g_bUseOnlyConfirmedAISName =
false;
1126 Read(_T (
"UseOnlyConfirmedAISName" ), &g_bUseOnlyConfirmedAISName);
1128 Read(_T (
"bNoCPAMax" ), &g_bCPAMax);
1130 Read(_T (
"NoCPAMaxNMi" ), &s);
1131 s.ToDouble(&g_CPAMax_NM);
1133 Read(_T (
"bCPAWarn" ), &g_bCPAWarn);
1135 Read(_T (
"CPAWarnNMi" ), &s);
1136 s.ToDouble(&g_CPAWarn_NM);
1138 Read(_T (
"bTCPAMax" ), &g_bTCPA_Max);
1140 Read(_T (
"TCPAMaxMinutes" ), &s);
1141 s.ToDouble(&g_TCPA_Max);
1143 Read(_T (
"bMarkLostTargets" ), &g_bMarkLost);
1145 Read(_T (
"MarkLost_Minutes" ), &s);
1146 s.ToDouble(&g_MarkLost_Mins);
1148 Read(_T (
"bRemoveLostTargets" ), &g_bRemoveLost);
1150 Read(_T (
"RemoveLost_Minutes" ), &s);
1151 s.ToDouble(&g_RemoveLost_Mins);
1153 Read(_T (
"bShowCOGArrows" ), &g_bShowCOG);
1155 Read(_T (
"bSyncCogPredictors"), &g_bSyncCogPredictors);
1157 Read(_T (
"CogArrowMinutes" ), &s);
1158 s.ToDouble(&g_ShowCOG_Mins);
1160 Read(_T (
"bShowTargetTracks" ), &g_bAISShowTracks);
1162 if (Read(_T (
"TargetTracksLimit" ), &s)) {
1163 s.ToDouble(&g_AISShowTracks_Limit);
1164 g_AISShowTracks_Limit = wxMax(300.0, g_AISShowTracks_Limit);
1166 if (Read(_T (
"TargetTracksMinutes" ), &s)) {
1167 s.ToDouble(&g_AISShowTracks_Mins);
1168 g_AISShowTracks_Mins = wxMax(1.0, g_AISShowTracks_Mins);
1169 g_AISShowTracks_Mins = wxMin(g_AISShowTracks_Limit, g_AISShowTracks_Mins);
1172 Read(_T (
"bHideMooredTargets" ), &g_bHideMoored);
1173 if (Read(_T (
"MooredTargetMaxSpeedKnots" ), &s))
1174 s.ToDouble(&g_ShowMoored_Kts);
1176 Read(_T (
"bShowScaledTargets"), &g_bAllowShowScaled);
1177 Read(_T (
"AISScaledNumber" ), &g_ShowScaled_Num);
1178 Read(_T (
"AISScaledNumberWeightSOG" ), &g_ScaledNumWeightSOG);
1179 Read(_T (
"AISScaledNumberWeightCPA" ), &g_ScaledNumWeightCPA);
1180 Read(_T (
"AISScaledNumberWeightTCPA" ), &g_ScaledNumWeightTCPA);
1181 Read(_T (
"AISScaledNumberWeightRange" ), &g_ScaledNumWeightRange);
1182 Read(_T (
"AISScaledNumberWeightSizeOfTarget" ), &g_ScaledNumWeightSizeOfT);
1183 Read(_T (
"AISScaledSizeMinimal" ), &g_ScaledSizeMinimal);
1184 Read(_T(
"AISShowScaled"), &g_bShowScaled);
1186 Read(_T (
"bShowAreaNotices" ), &g_bShowAreaNotices);
1187 Read(_T (
"bDrawAISSize" ), &g_bDrawAISSize);
1188 Read(_T (
"bDrawAISRealtime" ), &g_bDrawAISRealtime);
1189 Read(_T (
"bShowAISName" ), &g_bShowAISName);
1190 Read(_T (
"AISRealtimeMinSpeedKnots" ), &g_AIS_RealtPred_Kts, 0.7);
1191 Read(_T (
"bAISAlertDialog" ), &g_bAIS_CPA_Alert);
1192 Read(_T (
"ShowAISTargetNameScale" ), &g_Show_Target_Name_Scale);
1193 Read(_T (
"bWplIsAprsPositionReport" ), &g_bWplUsePosition);
1194 Read(_T (
"WplSelAction"), &g_WplAction);
1195 Read(_T (
"AISCOGPredictorWidth" ), &g_ais_cog_predictor_width);
1197 Read(_T (
"bAISAlertAudio" ), &g_bAIS_CPA_Alert_Audio);
1198 Read(_T (
"AISAlertAudioFile" ), &g_sAIS_Alert_Sound_File);
1199 Read(_T (
"bAISAlertSuppressMoored" ), &g_bAIS_CPA_Alert_Suppress_Moored);
1201 Read(_T (
"bAISAlertAckTimeout" ), &g_bAIS_ACK_Timeout);
1202 if (Read(_T (
"AlertAckTimeoutMinutes" ), &s)) s.ToDouble(&g_AckTimeout_Mins);
1204 Read(_T (
"AlertDialogSizeX" ), &g_ais_alert_dialog_sx);
1205 Read(_T (
"AlertDialogSizeY" ), &g_ais_alert_dialog_sy);
1206 Read(_T (
"AlertDialogPosX" ), &g_ais_alert_dialog_x);
1207 Read(_T (
"AlertDialogPosY" ), &g_ais_alert_dialog_y);
1208 Read(_T (
"QueryDialogPosX" ), &g_ais_query_dialog_x);
1209 Read(_T (
"QueryDialogPosY" ), &g_ais_query_dialog_y);
1211 Read(_T (
"AISTargetListPerspective" ), &g_AisTargetList_perspective);
1212 Read(_T (
"AISTargetListRange" ), &g_AisTargetList_range);
1213 Read(_T (
"AISTargetListSortColumn" ), &g_AisTargetList_sortColumn);
1214 Read(_T (
"bAISTargetListSortReverse" ), &g_bAisTargetList_sortReverse);
1215 Read(_T (
"AISTargetListColumnSpec" ), &g_AisTargetList_column_spec);
1216 Read(_T (
"AISTargetListColumnOrder"), &g_AisTargetList_column_order);
1218 Read(_T (
"bAISRolloverShowClass" ), &g_bAISRolloverShowClass);
1219 Read(_T (
"bAISRolloverShowCOG" ), &g_bAISRolloverShowCOG);
1220 Read(_T (
"bAISRolloverShowCPA" ), &g_bAISRolloverShowCPA);
1222 Read(_T (
"S57QueryDialogSizeX" ), &g_S57_dialog_sx);
1223 Read(_T (
"S57QueryDialogSizeY" ), &g_S57_dialog_sy);
1224 Read(_T (
"S57QueryExtraDialogSizeX" ), &g_S57_extradialog_sx);
1225 Read(_T (
"S57QueryExtraDialogSizeY" ), &g_S57_extradialog_sy);
1227 wxString strpres(_T (
"PresentationLibraryData" ));
1229 SetPath(_T (
"/Directories" ));
1230 Read(strpres, &valpres);
1231 if (!valpres.IsEmpty()) g_UserPresLibData = valpres;
1233 wxString strs(_T (
"SENCFileLocation" ));
1234 SetPath(_T (
"/Directories" ));
1237 if (!vals.IsEmpty()) g_SENCPrefix = vals;
1239 SetPath(_T (
"/Directories" ));
1241 Read(_T (
"InitChartDir" ), &vald);
1243 wxString dirnamed(vald);
1244 if (!dirnamed.IsEmpty()) {
1245 if (pInit_Chart_Dir->IsEmpty())
1247 pInit_Chart_Dir->Clear();
1248 pInit_Chart_Dir->Append(vald);
1252 Read(_T (
"GPXIODir" ), &g_gpx_path);
1253 Read(_T (
"TCDataDir" ), &g_TCData_Dir);
1254 Read(_T (
"BasemapDir"), &gWorldMapLocation);
1255 Read(_T (
"pluginInstallDir"), &g_winPluginDir);
1256 wxLogMessage(
"winPluginDir, read from ini file: %s",
1257 g_winPluginDir.mb_str().data());
1259 SetPath(_T (
"/Settings/GlobalState" ));
1261 if (Read(_T (
"nColorScheme" ), &read_int))
1262 global_color_scheme = (ColorScheme)read_int;
1265 SetPath(_T (
"/Settings/NMEADataSource" ));
1267 wxString connectionconfigs;
1268 Read(_T(
"DataConnections" ), &connectionconfigs);
1269 if (!connectionconfigs.IsEmpty()) {
1270 wxArrayString confs = wxStringTokenize(connectionconfigs, _T(
"|"));
1271 TheConnectionParams()->Clear();
1272 for (
size_t i = 0; i < confs.Count(); i++) {
1275 wxLogMessage(_T(
"Skipped invalid DataStream config"));
1279 TheConnectionParams()->Add(prm);
1284 SetPath(_T (
"/Settings/GlobalState" ));
1287 double st_lat, st_lon;
1288 if (Read(_T (
"VPLatLon" ), &st)) {
1289 sscanf(st.mb_str(wxConvUTF8),
"%lf,%lf", &st_lat, &st_lon);
1292 if (fabs(st_lon) < 360.) {
1293 while (st_lon < -180.) st_lon += 360.;
1295 while (st_lon > 180.) st_lon -= 360.;
1300 if (fabs(st_lat) < 90.0) vLat = st_lat;
1302 s.Printf(_T (
"Setting Viewpoint Lat/Lon %g, %g" ), vLat, vLon);
1306 double st_view_scale, st_rotation;
1307 if (Read(wxString(_T (
"VPScale" )), &st)) {
1308 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_view_scale);
1310 st_view_scale = fmax(st_view_scale, .001 / 32);
1311 st_view_scale = fmin(st_view_scale, 4);
1312 initial_scale_ppm = st_view_scale;
1315 if (Read(wxString(_T (
"VPRotation" )), &st)) {
1316 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_rotation);
1318 st_rotation = fmin(st_rotation, 360);
1319 st_rotation = fmax(st_rotation, 0);
1320 initial_rotation = st_rotation * PI / 180.;
1325 if (Read(_T (
"OwnShipLatLon" ), &sll)) {
1326 sscanf(sll.mb_str(wxConvUTF8),
"%lf,%lf", &lat, &lon);
1329 if (fabs(lon) < 360.) {
1330 while (lon < -180.) lon += 360.;
1332 while (lon > 180.) lon -= 360.;
1337 if (fabs(lat) < 90.0) gLat = lat;
1339 s.Printf(_T (
"Setting Ownship Lat/Lon %g, %g" ), gLat, gLon);
1346 SetPath(_T (
"/Settings/AuxFontKeys" ));
1351 bool bContk = GetFirstEntry(strk, dummyk);
1352 bool bNewKey =
false;
1355 bNewKey = FontMgr::Get().AddAuxKey(kval);
1356 if (!bAsTemplate && !bNewKey) {
1360 bContk = GetNextEntry(strk, dummyk);
1364 SetPath(_T (
"/Settings/X11Fonts" ));
1368 SetPath(_T (
"/Settings/GTKFonts" ));
1372 SetPath(_T (
"/Settings/MSWFonts" ));
1376 SetPath(_T (
"/Settings/MacFonts" ));
1380 SetPath(_T (
"/Settings/QTFonts" ));
1385 wxString *pval =
new wxString;
1386 wxArrayString deleteList;
1388 bool bCont = GetFirstEntry(str, dummy);
1392 if (str.StartsWith(_T(
"Font"))) {
1395 deleteList.Add(str);
1396 wxString oldKey = pval->BeforeFirst(_T(
':'));
1397 str = FontMgr::GetFontConfigKey(oldKey);
1400 if (pval->IsEmpty() || pval->StartsWith(_T(
":"))) {
1401 deleteList.Add(str);
1403 FontMgr::Get().LoadFontNative(&str, pval);
1405 bCont = GetNextEntry(str, dummy);
1408 for (
unsigned int i = 0; i < deleteList.Count(); i++) {
1409 DeleteEntry(deleteList[i]);
1415 SetPath(_T (
"/TideCurrentDataSources" ));
1416 if (GetNumberOfEntries()) {
1417 TideCurrentDataSet.Clear();
1420 bool bCont = GetFirstEntry(str, dummy);
1423 TideCurrentDataSet.Add(val);
1424 bCont = GetNextEntry(str, dummy);
1429 LoadConfigGroups(g_pGroupArray);
1434 SetPath(_T (
"/Settings/Others" ));
1437 Read(_T (
"RadarRingsNumberVisible" ), &val);
1438 if (val.Length() > 0) g_iNavAidRadarRingsNumberVisible = atoi(val.mb_str());
1440 Read(_T (
"RadarRingsStep" ), &val);
1441 if (val.Length() > 0) g_fNavAidRadarRingsStep = atof(val.mb_str());
1443 Read(_T (
"RadarRingsStepUnits" ), &g_pNavAidRadarRingsStepUnits);
1445 wxString l_wxsOwnshipRangeRingsColour;
1446 Read(_T (
"RadarRingsColour" ), &l_wxsOwnshipRangeRingsColour);
1447 if (l_wxsOwnshipRangeRingsColour.Length())
1448 g_colourOwnshipRangeRingsColour.Set(l_wxsOwnshipRangeRingsColour);
1451 Read(_T (
"WaypointRangeRingsNumber" ), &val);
1452 if (val.Length() > 0) g_iWaypointRangeRingsNumber = atoi(val.mb_str());
1454 Read(_T (
"WaypointRangeRingsStep" ), &val);
1455 if (val.Length() > 0) g_fWaypointRangeRingsStep = atof(val.mb_str());
1457 Read(_T (
"WaypointRangeRingsStepUnits" ), &g_iWaypointRangeRingsStepUnits);
1459 wxString l_wxsWaypointRangeRingsColour;
1460 Read(_T(
"WaypointRangeRingsColour" ), &l_wxsWaypointRangeRingsColour);
1461 g_colourWaypointRangeRingsColour.Set(l_wxsWaypointRangeRingsColour);
1463 if (!Read(_T(
"WaypointUseScaMin"), &g_bUseWptScaMin)) g_bUseWptScaMin =
false;
1464 if (!Read(_T(
"WaypointScaMinValue"), &g_iWpt_ScaMin))
1465 g_iWpt_ScaMin = 2147483646;
1466 if (!Read(_T(
"WaypointUseScaMinOverrule"), &g_bOverruleScaMin))
1467 g_bOverruleScaMin =
false;
1468 if (!Read(_T(
"WaypointsShowName"), &g_bShowWptName)) g_bShowWptName =
true;
1471 bool b300RadarRings =
true;
1472 if (Read(_T (
"ShowRadarRings" ), &b300RadarRings)) {
1473 if (!b300RadarRings) g_iNavAidRadarRingsNumberVisible = 0;
1476 Read(_T (
"ConfirmObjectDeletion" ), &g_bConfirmObjectDelete);
1479 g_bWayPointPreventDragging =
false;
1480 Read(_T (
"WaypointPreventDragging" ), &g_bWayPointPreventDragging);
1482 g_bEnableZoomToCursor =
false;
1483 Read(_T (
"EnableZoomToCursor" ), &g_bEnableZoomToCursor);
1486 Read(_T (
"TrackIntervalSeconds" ), &val);
1487 if (val.Length() > 0) {
1488 double tval = atof(val.mb_str());
1489 if (tval >= 2.) g_TrackIntervalSeconds = tval;
1493 Read(_T (
"TrackDeltaDistance" ), &val);
1494 if (val.Length() > 0) {
1495 double tval = atof(val.mb_str());
1496 if (tval >= 0.05) g_TrackDeltaDistance = tval;
1499 Read(_T (
"TrackPrecision" ), &g_nTrackPrecision);
1501 Read(_T (
"NavObjectFileName" ), m_sNavObjSetFile);
1503 Read(_T (
"RouteLineWidth" ), &g_route_line_width);
1504 Read(_T (
"TrackLineWidth" ), &g_track_line_width);
1506 wxString l_wxsTrackLineColour;
1507 if (Read(_T(
"TrackLineColour" ), &l_wxsTrackLineColour))
1508 g_colourTrackLineColour.Set(l_wxsTrackLineColour);
1510 Read(_T (
"TideCurrentWindowScale" ), &g_tcwin_scale);
1511 Read(_T (
"DefaultWPIcon" ), &g_default_wp_icon);
1512 Read(_T (
"DefaultRPIcon" ), &g_default_routepoint_icon);
1514 SetPath(_T (
"/MmsiProperties" ));
1515 int iPMax = GetNumberOfEntries();
1517 g_MMSI_Props_Array.Empty();
1520 bool bCont = pConfig->GetFirstEntry(str, dummy);
1522 pConfig->Read(str, &val);
1525 g_MMSI_Props_Array.Add(pProps);
1527 bCont = pConfig->GetNextEntry(str, dummy);
1534void MyConfig::LoadS57Config() {
1535 if (!ps52plib)
return;
1539 SetPath(_T (
"/Settings/GlobalState" ));
1541 Read(_T (
"bShowS57Text" ), &read_int, 1);
1542 ps52plib->SetShowS57Text(!(read_int == 0));
1544 Read(_T (
"bShowS57ImportantTextOnly" ), &read_int, 0);
1545 ps52plib->SetShowS57ImportantTextOnly(!(read_int == 0));
1547 Read(_T (
"bShowLightDescription" ), &read_int, 0);
1548 ps52plib->SetShowLdisText(!(read_int == 0));
1550 Read(_T (
"bExtendLightSectors" ), &read_int, 0);
1551 ps52plib->SetExtendLightSectors(!(read_int == 0));
1553 Read(_T (
"nDisplayCategory" ), &read_int, (
enum _DisCat)STANDARD);
1554 ps52plib->SetDisplayCategory((
enum _DisCat)read_int);
1556 Read(_T (
"nSymbolStyle" ), &read_int, (
enum _LUPname)PAPER_CHART);
1557 ps52plib->m_nSymbolStyle = (LUPname)read_int;
1559 Read(_T (
"nBoundaryStyle" ), &read_int, PLAIN_BOUNDARIES);
1560 ps52plib->m_nBoundaryStyle = (LUPname)read_int;
1562 Read(_T (
"bShowSoundg" ), &read_int, 1);
1563 ps52plib->m_bShowSoundg = !(read_int == 0);
1565 Read(_T (
"bShowMeta" ), &read_int, 0);
1566 ps52plib->m_bShowMeta = !(read_int == 0);
1568 Read(_T (
"bUseSCAMIN" ), &read_int, 1);
1569 ps52plib->m_bUseSCAMIN = !(read_int == 0);
1571 Read(_T (
"bUseSUPER_SCAMIN" ), &read_int, 0);
1572 ps52plib->m_bUseSUPER_SCAMIN = !(read_int == 0);
1574 Read(_T (
"bShowAtonText" ), &read_int, 1);
1575 ps52plib->m_bShowAtonText = !(read_int == 0);
1577 Read(_T (
"bDeClutterText" ), &read_int, 0);
1578 ps52plib->m_bDeClutterText = !(read_int == 0);
1580 Read(_T (
"bShowNationalText" ), &read_int, 0);
1581 ps52plib->m_bShowNationalTexts = !(read_int == 0);
1583 Read(_T (
"ENCSoundingScaleFactor" ), &read_int, 0);
1584 ps52plib->m_nSoundingFactor = read_int;
1586 Read(_T (
"ENCTextScaleFactor" ), &read_int, 0);
1587 ps52plib->m_nTextFactor = read_int;
1589 if (Read(_T (
"S52_MAR_SAFETY_CONTOUR" ), &dval, 3.0)) {
1590 S52_setMarinerParam(S52_MAR_SAFETY_CONTOUR, dval);
1591 S52_setMarinerParam(S52_MAR_SAFETY_DEPTH,
1595 if (Read(_T (
"S52_MAR_SHALLOW_CONTOUR" ), &dval, 2.0))
1596 S52_setMarinerParam(S52_MAR_SHALLOW_CONTOUR, dval);
1598 if (Read(_T (
"S52_MAR_DEEP_CONTOUR" ), &dval, 6.0))
1599 S52_setMarinerParam(S52_MAR_DEEP_CONTOUR, dval);
1601 if (Read(_T (
"S52_MAR_TWO_SHADES" ), &dval, 0.0))
1602 S52_setMarinerParam(S52_MAR_TWO_SHADES, dval);
1604 ps52plib->UpdateMarinerParams();
1606 SetPath(_T (
"/Settings/GlobalState" ));
1607 Read(_T (
"S52_DEPTH_UNIT_SHOW" ), &read_int, 1);
1608 read_int = wxMax(read_int, 0);
1609 read_int = wxMin(read_int, 2);
1610 ps52plib->m_nDepthUnitDisplay = read_int;
1611 g_nDepthUnitDisplay = read_int;
1617 SetPath(_T (
"/Settings/ObjectFilter" ));
1619 int iOBJMax = GetNumberOfEntries();
1627 bool bCont = pConfig->GetFirstEntry(str, dummy);
1629 pConfig->Read(str, &val);
1631 bool bNeedNew =
true;
1633 if (str.StartsWith(_T (
"viz" ), &sObj)) {
1634 for (
unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
1636 pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
1637 if (!strncmp(pOLE->OBJLName, sObj.mb_str(), 6)) {
1645 pOLE = (OBJLElement *)calloc(
sizeof(OBJLElement), 1);
1646 memcpy(pOLE->OBJLName, sObj.mb_str(), OBJL_NAME_LEN);
1649 ps52plib->pOBJLArray->Add((
void *)pOLE);
1652 bCont = pConfig->GetNextEntry(str, dummy);
1658static bool ReloadPendingChanges(
const wxString& changes_path) {
1659 wxULongLong size = wxFileName::GetSize(changes_path);
1664 auto pNavObjectChangesSet = NavObjectChanges::getTempInstance();
1665 pNavObjectChangesSet->Init(changes_path);
1666 pNavObjectChangesSet->load_file(changes_path.fn_str());
1671 if (::wxFileExists(changes_path))
1672 ::wxRemoveFile(changes_path);
1674 if (size == 0)
return false;
1676 wxLogMessage(_T(
"Applying NavObjChanges"));
1677 pNavObjectChangesSet->ApplyChanges();
1681void MyConfig::LoadNavObjects() {
1683 wxLogMessage(_T(
"Loading navobjects from navobj.xml"));
1684 CreateRotatingNavObjBackup();
1686 if (NULL == m_pNavObjectInputSet)
1690 if (::wxFileExists(m_sNavObjSetFile) &&
1691 m_pNavObjectInputSet->load_file(m_sNavObjSetFile.fn_str()))
1692 m_pNavObjectInputSet->LoadAllGPXObjects(
false, wpt_dups);
1694 wxLogMessage(_T(
"Done loading navobjects, %d duplicate waypoints ignored"),
1696 delete m_pNavObjectInputSet;
1698 m_pNavObjectChangesSet = NavObjectChanges::getInstance();
1700 if (::wxFileExists(m_sNavObjSetChangesFile)) {
1701 if (ReloadPendingChanges(m_sNavObjSetChangesFile)) {
1705 m_pNavObjectChangesSet->Init(m_sNavObjSetChangesFile);
1708bool MyConfig::LoadLayers(wxString &path) {
1709 wxArrayString file_array;
1713 if (dir.IsOpened()) {
1715 bool cont = dir.GetFirst(&filename);
1718 filename.Prepend(wxFileName::GetPathSeparator());
1719 filename.Prepend(path);
1720 wxFileName f(filename);
1722 if (f.GetExt().IsSameAs(wxT(
"gpx")))
1723 file_array.Add(filename);
1725 if (wxDir::Exists(filename)) {
1726 wxDir dir(filename);
1727 if (dir.IsOpened()) {
1728 nfiles = dir.GetAllFiles(filename, &file_array,
1734 if (file_array.GetCount()) {
1736 l->m_LayerID = ++g_LayerIdx;
1737 l->m_LayerFileName = file_array[0];
1738 if (file_array.GetCount() <= 1)
1739 wxFileName::SplitPath(file_array[0], NULL, NULL, &(l->m_LayerName),
1742 wxFileName::SplitPath(filename, NULL, NULL, &(l->m_LayerName), NULL,
1745 bool bLayerViz = g_bShowLayers;
1747 if (g_VisibleLayers.Contains(l->m_LayerName)) bLayerViz =
true;
1748 if (g_InvisibleLayers.Contains(l->m_LayerName)) bLayerViz =
false;
1750 l->m_bHasVisibleNames = wxCHK_UNDETERMINED;
1751 if (g_VisiNameinLayers.Contains(l->m_LayerName))
1752 l->m_bHasVisibleNames = wxCHK_CHECKED;
1753 if (g_InVisiNameinLayers.Contains(l->m_LayerName))
1754 l->m_bHasVisibleNames = wxCHK_UNCHECKED;
1756 l->m_bIsVisibleOnChart = bLayerViz;
1759 laymsg.Printf(wxT(
"New layer %d: %s"), l->m_LayerID,
1760 l->m_LayerName.c_str());
1761 wxLogMessage(laymsg);
1763 pLayerList->Insert(l);
1767 for (
unsigned int i = 0; i < file_array.GetCount(); i++) {
1768 wxString file_path = file_array[i];
1770 if (::wxFileExists(file_path)) {
1772 pSet->load_file(file_path.fn_str());
1773 long nItems = pSet->LoadAllGPXObjectsAsLayer(
1774 l->m_LayerID, bLayerViz, l->m_bHasVisibleNames);
1775 l->m_NoOfItems += nItems;
1776 l->m_LayerType = _(
"Persistent");
1779 objmsg.Printf(wxT(
"Loaded GPX file %s with %ld items."),
1780 file_path.c_str(), nItems);
1781 wxLogMessage(objmsg);
1788 cont = dir.GetNext(&filename);
1791 g_bLayersLoaded =
true;
1796bool MyConfig::LoadChartDirArray(ArrayOfCDI &ChartDirArray) {
1798 SetPath(_T (
"/ChartDirectories" ));
1799 int iDirMax = GetNumberOfEntries();
1801 ChartDirArray.Empty();
1804 int nAdjustChartDirs = 0;
1806 bool bCont = pConfig->GetFirstEntry(str, dummy);
1808 pConfig->Read(str, &val);
1810 wxString dirname(val);
1811 if (!dirname.IsEmpty()) {
1826 if (dirname.Find(_T (
"SampleCharts" )) ==
1831 pConfig->DeleteEntry(str);
1832 wxString new_dir = dirname.Mid(dirname.Find(_T (
"SampleCharts" )));
1833 new_dir.Prepend(g_Platform->GetSharedDataDir());
1838 cdi.fullpath = dirname.BeforeFirst(
'^');
1839 cdi.magic_number = dirname.AfterFirst(
'^');
1841 ChartDirArray.Add(cdi);
1845 bCont = pConfig->GetNextEntry(str, dummy);
1848 if (nAdjustChartDirs) pConfig->UpdateChartDirs(ChartDirArray);
1854void MyConfig::AddNewRoute(
Route *r) {
1855 m_pNavObjectChangesSet->AddNewRoute(r);
1858void MyConfig::UpdateRoute(
Route *r) {
1859 m_pNavObjectChangesSet->UpdateRoute(r);
1862void MyConfig::DeleteConfigRoute(
Route *pr) {
1863 m_pNavObjectChangesSet->DeleteConfigRoute(pr);
1866void MyConfig::AddNewTrack(
Track *pt) {
1867 m_pNavObjectChangesSet->AddNewTrack(pt);
1870void MyConfig::UpdateTrack(
Track *pt) {
1871 m_pNavObjectChangesSet->UpdateTrack(pt);
1874void MyConfig::DeleteConfigTrack(
Track *pt) {
1875 m_pNavObjectChangesSet->DeleteConfigTrack(pt);
1878void MyConfig::AddNewWayPoint(
RoutePoint *pWP,
int crm) {
1879 m_pNavObjectChangesSet->AddNewWayPoint(pWP);
1882void MyConfig::UpdateWayPoint(
RoutePoint *pWP) {
1883 m_pNavObjectChangesSet->UpdateWayPoint(pWP);
1886void MyConfig::DeleteWayPoint(
RoutePoint *pWP) {
1887 m_pNavObjectChangesSet->DeleteWayPoint(pWP);
1890void MyConfig::AddNewTrackPoint(
TrackPoint *pWP,
1891 const wxString &parent_GUID) {
1892 m_pNavObjectChangesSet->AddNewTrackPoint(pWP, parent_GUID);
1895bool MyConfig::UpdateChartDirs(ArrayOfCDI &dir_array) {
1899 SetPath(_T (
"/ChartDirectories" ));
1900 int iDirMax = GetNumberOfEntries();
1904 for (
int i = 0; i < iDirMax; i++) {
1905 GetFirstEntry(key, dummy);
1906 DeleteEntry(key,
false);
1910 iDirMax = dir_array.GetCount();
1912 for (
int iDir = 0; iDir < iDirMax; iDir++) {
1915 wxString dirn = cdi.fullpath;
1916 dirn.Append(_T(
"^"));
1917 dirn.Append(cdi.magic_number);
1919 str_buf.Printf(_T (
"ChartDir%d" ), iDir + 1);
1921 Write(str_buf, dirn);
1925#ifdef __OCPN__ANDROID__
1933void MyConfig::CreateConfigGroups(ChartGroupArray *pGroupArray) {
1934 if (!pGroupArray)
return;
1936 SetPath(_T (
"/Groups" ));
1937 Write(_T (
"GroupCount" ), (
int)pGroupArray->GetCount());
1939 for (
unsigned int i = 0; i < pGroupArray->GetCount(); i++) {
1942 s.Printf(_T(
"Group%d"), i + 1);
1943 s.Prepend(_T (
"/Groups/" ));
1946 Write(_T (
"GroupName" ), pGroup->m_group_name);
1947 Write(_T (
"GroupItemCount" ), (
int)pGroup->m_element_array.size());
1949 for (
unsigned int j = 0; j < pGroup->m_element_array.size(); j++) {
1951 sg.Printf(_T(
"Group%d/Item%d"), i + 1, j);
1952 sg.Prepend(_T (
"/Groups/" ));
1954 Write(_T (
"IncludeItem" ), pGroup->m_element_array[j].m_element_name);
1957 wxArrayString u = pGroup->m_element_array[j].m_missing_name_array;
1959 for (
unsigned int k = 0; k < u.GetCount(); k++) {
1963 Write(_T (
"ExcludeItems" ), t);
1969void MyConfig::DestroyConfigGroups(
void) {
1970 DeleteGroup(_T (
"/Groups" ));
1973void MyConfig::LoadConfigGroups(ChartGroupArray *pGroupArray) {
1974 SetPath(_T (
"/Groups" ));
1975 unsigned int group_count;
1976 Read(_T (
"GroupCount" ), (
int *)&group_count, 0);
1978 for (
unsigned int i = 0; i < group_count; i++) {
1981 s.Printf(_T(
"Group%d"), i + 1);
1982 s.Prepend(_T (
"/Groups/" ));
1986 Read(_T (
"GroupName" ), &t);
1987 pGroup->m_group_name = t;
1989 unsigned int item_count;
1990 Read(_T (
"GroupItemCount" ), (
int *)&item_count);
1991 for (
unsigned int j = 0; j < item_count; j++) {
1993 sg.Printf(_T(
"Group%d/Item%d"), i + 1, j);
1994 sg.Prepend(_T (
"/Groups/" ));
1998 Read(_T (
"IncludeItem" ), &v);
2002 if (Read(_T (
"ExcludeItems" ), &u)) {
2004 wxStringTokenizer tk(u, _T(
";"));
2005 while (tk.HasMoreTokens()) {
2006 wxString token = tk.GetNextToken();
2007 pelement.m_missing_name_array.Add(token);
2011 pGroup->m_element_array.push_back(std::move(pelement));
2013 pGroupArray->Add(pGroup);
2017void MyConfig::LoadCanvasConfigs(
bool bApplyAsTemplate) {
2021 SetPath(_T (
"/Canvas" ));
2024 if (!HasEntry(_T (
"CanvasConfig" ))) {
2026 pcc->LoadFromLegacyConfig(
this);
2027 g_canvasConfigArray.Add(pcc);
2032 Read(_T (
"CanvasConfig" ), (
int *)&g_canvasConfig, 0);
2035 if (g_canvasConfigArray.GetCount() ==
2037 s.Printf(_T(
"/Canvas/CanvasConfig%d"), 1);
2040 LoadConfigCanvas(pcca, bApplyAsTemplate);
2041 g_canvasConfigArray.Add(pcca);
2043 s.Printf(_T(
"/Canvas/CanvasConfig%d"), 2);
2046 LoadConfigCanvas(pcca, bApplyAsTemplate);
2047 g_canvasConfigArray.Add(pcca);
2050 s.Printf(_T(
"/Canvas/CanvasConfig%d"), 1);
2052 LoadConfigCanvas(pcca, bApplyAsTemplate);
2054 if (g_canvasConfigArray.GetCount() > 1) {
2056 s.Printf(_T(
"/Canvas/CanvasConfig%d"), 2);
2058 LoadConfigCanvas(pcca, bApplyAsTemplate);
2060 s.Printf(_T(
"/Canvas/CanvasConfig%d"), 2);
2063 LoadConfigCanvas(pcca, bApplyAsTemplate);
2064 g_canvasConfigArray.Add(pcca);
2069void MyConfig::LoadConfigCanvas(
canvasConfig *cConfig,
bool bApplyAsTemplate) {
2071 double st_lat, st_lon;
2073 if (!bApplyAsTemplate) {
2075 cConfig->iLat = START_LAT;
2076 cConfig->iLon = START_LON;
2078 if (Read(_T (
"canvasVPLatLon" ), &st)) {
2079 sscanf(st.mb_str(wxConvUTF8),
"%lf,%lf", &st_lat, &st_lon);
2082 if (fabs(st_lon) < 360.) {
2083 while (st_lon < -180.) st_lon += 360.;
2085 while (st_lon > 180.) st_lon -= 360.;
2087 cConfig->iLon = st_lon;
2090 if (fabs(st_lat) < 90.0) cConfig->iLat = st_lat;
2093 cConfig->iScale = .0003;
2094 cConfig->iRotation = 0;
2096 double st_view_scale;
2097 if (Read(wxString(_T (
"canvasVPScale" )), &st)) {
2098 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_view_scale);
2100 st_view_scale = fmax(st_view_scale, .001 / 32);
2101 st_view_scale = fmin(st_view_scale, 4);
2102 cConfig->iScale = st_view_scale;
2106 if (Read(wxString(_T (
"canvasVPRotation" )), &st)) {
2107 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_rotation);
2109 st_rotation = fmin(st_rotation, 360);
2110 st_rotation = fmax(st_rotation, 0);
2111 cConfig->iRotation = st_rotation * PI / 180.;
2114 Read(_T (
"canvasInitialdBIndex" ), &cConfig->DBindex, 0);
2115 Read(_T (
"canvasbFollow" ), &cConfig->bFollow, 0);
2117 Read(_T (
"canvasCourseUp" ), &cConfig->bCourseUp, 0);
2118 Read(_T (
"canvasHeadUp" ), &cConfig->bHeadUp, 0);
2119 Read(_T (
"canvasLookahead" ), &cConfig->bLookahead, 0);
2122 Read(_T (
"ActiveChartGroup" ), &cConfig->GroupID, 0);
2125 if (cConfig->GroupID && bApplyAsTemplate) {
2126 if (cConfig->GroupID > (
int)g_pGroupArray->GetCount()) cConfig->GroupID = 0;
2129 Read(_T (
"canvasShowTides" ), &cConfig->bShowTides, 0);
2130 Read(_T (
"canvasShowCurrents" ), &cConfig->bShowCurrents, 0);
2132 Read(_T (
"canvasQuilt" ), &cConfig->bQuilt, 1);
2133 Read(_T (
"canvasShowGrid" ), &cConfig->bShowGrid, 0);
2134 Read(_T (
"canvasShowOutlines" ), &cConfig->bShowOutlines, 0);
2135 Read(_T (
"canvasShowDepthUnits" ), &cConfig->bShowDepthUnits, 0);
2137 Read(_T (
"canvasShowAIS" ), &cConfig->bShowAIS, 1);
2138 Read(_T (
"canvasAttenAIS" ), &cConfig->bAttenAIS, 0);
2141 Read(_T (
"canvasShowENCText" ), &cConfig->bShowENCText, 1);
2142 Read(_T (
"canvasENCDisplayCategory" ), &cConfig->nENCDisplayCategory,
2144 Read(_T (
"canvasENCShowDepths" ), &cConfig->bShowENCDepths, 1);
2145 Read(_T (
"canvasENCShowBuoyLabels" ), &cConfig->bShowENCBuoyLabels, 1);
2146 Read(_T (
"canvasENCShowLightDescriptions" ),
2147 &cConfig->bShowENCLightDescriptions, 1);
2148 Read(_T (
"canvasENCShowLights" ), &cConfig->bShowENCLights, 1);
2149 Read(_T (
"canvasENCShowVisibleSectorLights" ),
2150 &cConfig->bShowENCVisibleSectorLights, 0);
2151 Read(_T (
"canvasENCShowAnchorInfo" ), &cConfig->bShowENCAnchorInfo, 0);
2154 Read(_T (
"canvasSizeX" ), &sx, 0);
2155 Read(_T (
"canvasSizeY" ), &sy, 0);
2156 cConfig->canvasSize = wxSize(sx, sy);
2159void MyConfig::SaveCanvasConfigs() {
2160 SetPath(_T (
"/Canvas" ));
2161 Write(_T (
"CanvasConfig" ), (
int)g_canvasConfig);
2166 switch (g_canvasConfig) {
2170 s.Printf(_T(
"/Canvas/CanvasConfig%d"), 1);
2173 if (g_canvasConfigArray.GetCount() > 0) {
2174 pcc = g_canvasConfigArray.Item(0);
2176 SaveConfigCanvas(pcc);
2183 if (g_canvasConfigArray.GetCount() > 1) {
2184 s.Printf(_T(
"/Canvas/CanvasConfig%d"), 1);
2186 pcc = g_canvasConfigArray.Item(0);
2188 SaveConfigCanvas(pcc);
2191 s.Printf(_T(
"/Canvas/CanvasConfig%d"), 2);
2193 pcc = g_canvasConfigArray.Item(1);
2195 SaveConfigCanvas(pcc);
2202void MyConfig::SaveConfigCanvas(
canvasConfig *cConfig) {
2205 if (cConfig->canvas) {
2206 ViewPort vp = cConfig->canvas->GetVP();
2209 st1.Printf(_T (
"%10.4f,%10.4f" ), vp.clat, vp.clon);
2210 Write(_T (
"canvasVPLatLon" ), st1);
2211 st1.Printf(_T (
"%g" ), vp.view_scale_ppm);
2212 Write(_T (
"canvasVPScale" ), st1);
2213 st1.Printf(_T (
"%i" ), ((
int)(vp.rotation * 180 / PI)) % 360);
2214 Write(_T (
"canvasVPRotation" ), st1);
2217 int restore_dbindex = 0;
2218 ChartStack *pcs = cConfig->canvas->GetpCurrentStack();
2219 if (pcs) restore_dbindex = pcs->GetCurrentEntrydbIndex();
2220 if (cConfig->canvas->GetQuiltMode())
2221 restore_dbindex = cConfig->canvas->GetQuiltReferenceChartIndex();
2222 Write(_T (
"canvasInitialdBIndex" ), restore_dbindex);
2224 Write(_T (
"canvasbFollow" ), cConfig->canvas->m_bFollow);
2225 Write(_T (
"ActiveChartGroup" ), cConfig->canvas->m_groupIndex);
2227 Write(_T (
"canvasToolbarConfig" ),
2228 cConfig->canvas->GetToolbarConfigString());
2229 Write(_T (
"canvasShowToolbar" ),
2232 Write(_T (
"canvasQuilt" ), cConfig->canvas->GetQuiltMode());
2233 Write(_T (
"canvasShowGrid" ), cConfig->canvas->GetShowGrid());
2234 Write(_T (
"canvasShowOutlines" ), cConfig->canvas->GetShowOutlines());
2235 Write(_T (
"canvasShowDepthUnits" ), cConfig->canvas->GetShowDepthUnits());
2237 Write(_T (
"canvasShowAIS" ), cConfig->canvas->GetShowAIS());
2238 Write(_T (
"canvasAttenAIS" ), cConfig->canvas->GetAttenAIS());
2240 Write(_T (
"canvasShowTides" ), cConfig->canvas->GetbShowTide());
2241 Write(_T (
"canvasShowCurrents" ), cConfig->canvas->GetbShowCurrent());
2244 Write(_T (
"canvasShowENCText" ), cConfig->canvas->GetShowENCText());
2245 Write(_T (
"canvasENCDisplayCategory" ),
2246 cConfig->canvas->GetENCDisplayCategory());
2247 Write(_T (
"canvasENCShowDepths" ), cConfig->canvas->GetShowENCDepth());
2248 Write(_T (
"canvasENCShowBuoyLabels" ),
2249 cConfig->canvas->GetShowENCBuoyLabels());
2250 Write(_T (
"canvasENCShowLightDescriptions" ),
2251 cConfig->canvas->GetShowENCLightDesc());
2252 Write(_T (
"canvasENCShowLights" ), cConfig->canvas->GetShowENCLights());
2253 Write(_T (
"canvasENCShowVisibleSectorLights" ),
2254 cConfig->canvas->GetShowVisibleSectors());
2255 Write(_T (
"canvasENCShowAnchorInfo" ),
2256 cConfig->canvas->GetShowENCAnchor());
2258 Write(_T (
"canvasCourseUp" ),
2259 cConfig->canvas->GetUpMode() == COURSE_UP_MODE);
2260 Write(_T (
"canvasHeadUp" ), cConfig->canvas->GetUpMode() == HEAD_UP_MODE);
2261 Write(_T (
"canvasLookahead" ), cConfig->canvas->GetLookahead());
2263 int width = cConfig->canvas->GetSize().x;
2271 Write(_T (
"canvasSizeX" ), width);
2272 Write(_T (
"canvasSizeY" ), cConfig->canvas->GetSize().y);
2276void MyConfig::UpdateSettings() {
2279#ifdef __OCPN__ANDROID__
2284 SetPath(_T (
"/Settings" ));
2286 Write(_T (
"LastAppliedTemplate" ), g_lastAppliedTemplateGUID);
2287 Write(_T (
"CompatOS" ), g_compatOS);
2288 Write(_T (
"CompatOsVersion" ), g_compatOsVersion);
2289 Write(_T (
"ConfigVersionString" ), g_config_version_string);
2290 if (wxIsEmpty(g_CmdSoundString))
2291 g_CmdSoundString = wxString(OCPN_SOUND_CMD);
2292 Write(_T(
"CmdSoundString" ), g_CmdSoundString);
2293 Write(_T (
"NavMessageShown" ), n_NavMessageShown);
2294 Write(_T (
"InlandEcdis" ), g_bInlandEcdis);
2296 Write(_T (
"AndroidVersionCode" ), g_AndroidVersionCode);
2298 Write(_T (
"UIexpert" ), g_bUIexpert);
2299 Write(_T(
"SpaceDropMark" ), g_bSpaceDropMark);
2303 Write(_T (
"ShowStatusBar" ), g_bShowStatusBar);
2305 Write(_T (
"ShowMenuBar" ), g_bShowMenuBar);
2307 Write(_T (
"DefaultFontSize" ), g_default_font_size);
2308 Write(_T (
"DefaultFontFacename" ), g_default_font_facename);
2310 Write(_T (
"Fullscreen" ), g_bFullscreen);
2311 Write(_T (
"ShowCompassWindow" ), g_bShowCompassWin);
2312 Write(_T (
"SetSystemTime" ), s_bSetSystemTime);
2313 Write(_T (
"ShowGrid" ), g_bDisplayGrid);
2314 Write(_T (
"PlayShipsBells" ), g_bPlayShipsBells);
2315 Write(_T (
"SoundDeviceIndex" ), g_iSoundDeviceIndex);
2316 Write(_T (
"FullscreenToolbar" ), g_bFullscreenToolbar);
2317 Write(_T (
"TransparentToolbar" ), g_bTransparentToolbar);
2318 Write(_T (
"PermanentMOBIcon" ), g_bPermanentMOBIcon);
2319 Write(_T (
"ShowLayers" ), g_bShowLayers);
2320 Write(_T (
"AutoAnchorDrop" ), g_bAutoAnchorMark);
2321 Write(_T (
"ShowChartOutlines" ), g_bShowOutlines);
2322 Write(_T (
"ShowActiveRouteTotal" ), g_bShowRouteTotal);
2323 Write(_T (
"ShowActiveRouteHighway" ), g_bShowActiveRouteHighway);
2324 Write(_T (
"SDMMFormat" ), g_iSDMMFormat);
2325 Write(_T (
"MostRecentGPSUploadConnection" ), g_uploadConnection);
2326 Write(_T (
"ShowChartBar" ), g_bShowChartBar);
2328 Write(_T (
"GUIScaleFactor" ), g_GUIScaleFactor);
2329 Write(_T (
"ChartObjectScaleFactor" ), g_ChartScaleFactor);
2330 Write(_T (
"ShipScaleFactor" ), g_ShipScaleFactor);
2331 Write(_T (
"ENCSoundingScaleFactor" ), g_ENCSoundingScaleFactor);
2332 Write(_T (
"ENCTextScaleFactor" ), g_ENCTextScaleFactor);
2333 Write(_T (
"ObjQueryAppendFilesExt" ), g_ObjQFileExt);
2336 Write(_T(
"CatalogCustomURL"), g_catalog_custom_url);
2337 Write(_T(
"CatalogChannel"), g_catalog_channel);
2339 Write(_T (
"FilterNMEA_Avg" ), g_bfilter_cogsog);
2340 Write(_T (
"FilterNMEA_Sec" ), g_COGFilterSec);
2342 Write(_T (
"TrackContinuous" ), g_btrackContinuous);
2344 Write(_T (
"ShowTrue" ), g_bShowTrue);
2345 Write(_T (
"ShowMag" ), g_bShowMag);
2346 Write(_T (
"UserMagVariation" ), wxString::Format(_T(
"%.2f"), g_UserVar));
2348 Write(_T (
"CM93DetailFactor" ), g_cm93_zoom_factor);
2349 Write(_T (
"CM93DetailZoomPosX" ), g_detailslider_dialog_x);
2350 Write(_T (
"CM93DetailZoomPosY" ), g_detailslider_dialog_y);
2351 Write(_T (
"ShowCM93DetailSlider" ), g_bShowDetailSlider);
2353 Write(_T (
"SkewToNorthUp" ), g_bskew_comp);
2354 Write(_T (
"OpenGL" ), g_bopengl);
2355 Write(_T (
"SoftwareGL" ), g_bSoftwareGL);
2356 Write(_T (
"ShowFPS" ), g_bShowFPS);
2358 Write(_T (
"ZoomDetailFactor" ), g_chart_zoom_modifier_raster);
2359 Write(_T (
"ZoomDetailFactorVector" ), g_chart_zoom_modifier_vector);
2361 Write(_T (
"FogOnOverzoom" ), g_fog_overzoom);
2362 Write(_T (
"OverzoomVectorScale" ), g_oz_vector_scale);
2363 Write(_T (
"OverzoomEmphasisBase" ), g_overzoom_emphasis_base);
2364 Write(_T (
"PlusMinusZoomFactor" ), g_plus_minus_zoom_factor);
2365 Write(
"MouseZoomSensitivity",
2367 Write(_T (
"ShowMUIZoomButtons" ), g_bShowMuiZoomButtons);
2371 Write(_T (
"UseAcceleratedPanning" ), g_GLOptions.m_bUseAcceleratedPanning);
2373 Write(_T (
"GPUTextureCompression" ), g_GLOptions.m_bTextureCompression);
2374 Write(_T (
"GPUTextureCompressionCaching" ),
2375 g_GLOptions.m_bTextureCompressionCaching);
2376 Write(_T (
"GPUTextureDimension" ), g_GLOptions.m_iTextureDimension);
2377 Write(_T (
"GPUTextureMemSize" ), g_GLOptions.m_iTextureMemorySize);
2378 Write(_T (
"PolygonSmoothing" ), g_GLOptions.m_GLPolygonSmoothing);
2379 Write(_T (
"LineSmoothing" ), g_GLOptions.m_GLLineSmoothing);
2381 Write(_T (
"SmoothPanZoom" ), g_bsmoothpanzoom);
2383 Write(_T (
"CourseUpMode" ), g_bCourseUp);
2384 if (!g_bInlandEcdis) Write(_T (
"LookAheadMode" ), g_bLookAhead);
2385 Write(_T (
"COGUPAvgSeconds" ), g_COGAvgSec);
2386 Write(_T (
"UseMagAPB" ), g_bMagneticAPB);
2388 Write(_T (
"OwnshipCOGPredictorMinutes" ), g_ownship_predictor_minutes);
2389 Write(_T (
"OwnshipCOGPredictorWidth" ), g_cog_predictor_width);
2390 Write(_T (
"OwnshipHDTPredictorMiles" ), g_ownship_HDTpredictor_miles);
2391 Write(_T (
"OwnShipIconType" ), g_OwnShipIconType);
2392 Write(_T (
"OwnShipLength" ), g_n_ownship_length_meters);
2393 Write(_T (
"OwnShipWidth" ), g_n_ownship_beam_meters);
2394 Write(_T (
"OwnShipGPSOffsetX" ), g_n_gps_antenna_offset_x);
2395 Write(_T (
"OwnShipGPSOffsetY" ), g_n_gps_antenna_offset_y);
2396 Write(_T (
"OwnShipMinSize" ), g_n_ownship_min_mm);
2397 Write(_T (
"OwnShipSogCogCalc" ), g_own_ship_sog_cog_calc);
2398 Write(_T (
"OwnShipSogCogCalcDampSec"), g_own_ship_sog_cog_calc_damp_sec);
2399 Write(_T (
"ShowDirectRouteLine"), g_bShowShipToActive);
2400 Write(_T (
"DirectRouteLineStyle"), g_shipToActiveStyle);
2401 Write(_T (
"DirectRouteLineColor" ), g_shipToActiveColor);
2406 Write(_T (
"RouteArrivalCircleRadius" ),
2407 wxString::Format(_T(
"%.2f"), g_n_arrival_circle_radius));
2409 Write(_T (
"ChartQuilting" ), g_bQuiltEnable);
2411 Write(_T (
"NMEALogWindowSizeX" ), NMEALogWindow::Get().GetSizeW());
2412 Write(_T (
"NMEALogWindowSizeY" ), NMEALogWindow::Get().GetSizeH());
2413 Write(_T (
"NMEALogWindowPosX" ), NMEALogWindow::Get().GetPosX());
2414 Write(_T (
"NMEALogWindowPosY" ), NMEALogWindow::Get().GetPosY());
2416 Write(_T (
"PreserveScaleOnX" ), g_bPreserveScaleOnX);
2418 Write(_T (
"StartWithTrackActive" ), g_bTrackCarryOver);
2419 Write(_T (
"AutomaticDailyTracks" ), g_bTrackDaily);
2420 Write(_T (
"TrackRotateAt" ), g_track_rotate_time);
2421 Write(_T (
"TrackRotateTimeType" ), g_track_rotate_time_type);
2422 Write(_T (
"HighlightTracks" ), g_bHighliteTracks);
2424 Write(_T (
"InitialStackIndex" ), g_restore_stackindex);
2425 Write(_T (
"InitialdBIndex" ), g_restore_dbindex);
2427 Write(_T(
"NMEAAPBPrecision" ), g_NMEAAPBPrecision);
2429 Write(_T(
"TalkerIdText"), g_TalkerIdText);
2430 Write(_T(
"ShowTrackPointTime"), g_bShowTrackPointTime);
2432 Write(_T (
"AnchorWatch1GUID" ), g_AW1GUID);
2433 Write(_T (
"AnchorWatch2GUID" ), g_AW2GUID);
2435 Write(_T (
"ToolbarX" ), g_maintoolbar_x);
2436 Write(_T (
"ToolbarY" ), g_maintoolbar_y);
2439 Write(_T (
"iENCToolbarX" ), g_iENCToolbarPosX);
2440 Write(_T (
"iENCToolbarY" ), g_iENCToolbarPosY);
2442 if (!g_bInlandEcdis) {
2443 Write(_T (
"GlobalToolbarConfig" ), g_toolbarConfig);
2444 Write(_T (
"DistanceFormat" ), g_iDistanceFormat);
2445 Write(_T (
"SpeedFormat" ), g_iSpeedFormat);
2446 Write(_T (
"ShowDepthUnits" ), g_bShowDepthUnits);
2447 Write(_T (
"TemperatureFormat" ), g_iTempFormat);
2449 Write(_T (
"GPSIdent" ), g_GPS_Ident);
2450 Write(_T (
"UseGarminHostUpload" ), g_bGarminHostUpload);
2452 Write(_T (
"MobileTouch" ), g_btouch);
2453 Write(_T (
"ResponsiveGraphics" ), g_bresponsive);
2454 Write(_T (
"EnableRolloverBlock" ), g_bRollover);
2456 Write(_T (
"AutoHideToolbar" ), g_bAutoHideToolbar);
2457 Write(_T (
"AutoHideToolbarSecs" ), g_nAutoHideToolbar);
2459 Write(_T (
"DisplaySizeMM" ), g_config_display_size_mm);
2460 Write(_T (
"DisplaySizeManual" ), g_config_display_size_manual);
2462 Write(_T (
"SelectionRadiusMM" ), g_selection_radius_mm);
2463 Write(_T (
"SelectionRadiusTouchMM" ), g_selection_radius_touch_mm);
2466 st0.Printf(_T (
"%g" ), g_PlanSpeed);
2467 Write(_T (
"PlanSpeed" ), st0);
2469 if (g_bLayersLoaded) {
2470 wxString vis, invis, visnames, invisnames;
2471 LayerList::iterator it;
2473 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
2475 if (lay->IsVisibleOnChart())
2476 vis += (lay->m_LayerName) + _T(
";");
2478 invis += (lay->m_LayerName) + _T(
";");
2480 if (lay->HasVisibleNames() == wxCHK_CHECKED) {
2481 visnames += (lay->m_LayerName) + _T(
";");
2482 }
else if (lay->HasVisibleNames() == wxCHK_UNCHECKED) {
2483 invisnames += (lay->m_LayerName) + _T(
";");
2486 Write(_T (
"VisibleLayers" ), vis);
2487 Write(_T (
"InvisibleLayers" ), invis);
2488 Write(_T (
"VisNameInLayers" ), visnames);
2489 Write(_T (
"InvisNameInLayers" ), invisnames);
2491 Write(_T (
"Locale" ), g_locale);
2492 Write(_T (
"LocaleOverride" ), g_localeOverride);
2494 Write(_T (
"KeepNavobjBackups" ), g_navobjbackups);
2495 Write(_T (
"LegacyInputCOMPortFilterBehaviour" ),
2496 g_b_legacy_input_filter_behaviour);
2497 Write(_T(
"AdvanceRouteWaypointOnArrivalOnly" ),
2498 g_bAdvanceRouteWaypointOnArrivalOnly);
2501 Write(_T(
"LiveETA" ), g_bShowLiveETA);
2502 Write(_T(
"DefaultBoatSpeed" ), g_defaultBoatSpeed);
2506 SetPath(_T (
"/Settings/ObjectFilter" ));
2509 for (
unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
2511 OBJLElement *pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
2513 wxString st1(_T (
"viz" ));
2515 strncpy(name, pOLE->OBJLName, 6);
2517 st1.Append(wxString(name, wxConvUTF8));
2518 Write(st1, pOLE->nViz);
2524 SetPath(_T (
"/Settings/GlobalState" ));
2541 st1.Printf(_T (
"%10.4f, %10.4f" ), gLat, gLon);
2542 Write(_T (
"OwnShipLatLon" ), st1);
2545 SetPath(_T (
"/Settings/GlobalState" ));
2546 if (!g_bInlandEcdis)
2547 Write(_T (
"nColorScheme" ), (
int)gFrame->GetColorScheme());
2549 Write(_T (
"FrameWinX" ), g_nframewin_x);
2550 Write(_T (
"FrameWinY" ), g_nframewin_y);
2551 Write(_T (
"FrameWinPosX" ), g_nframewin_posx);
2552 Write(_T (
"FrameWinPosY" ), g_nframewin_posy);
2553 Write(_T (
"FrameMax" ), g_bframemax);
2555 Write(_T (
"ClientPosX" ), g_lastClientRectx);
2556 Write(_T (
"ClientPosY" ), g_lastClientRecty);
2557 Write(_T (
"ClientSzX" ), g_lastClientRectw);
2558 Write(_T (
"ClientSzY" ), g_lastClientRecth);
2560 Write(_T (
"S52_DEPTH_UNIT_SHOW" ), g_nDepthUnitDisplay);
2562 Write(_T(
"RoutePropSizeX" ), g_route_prop_sx);
2563 Write(_T(
"RoutePropSizeY" ), g_route_prop_sy);
2564 Write(_T(
"RoutePropPosX" ), g_route_prop_x);
2565 Write(_T(
"RoutePropPosY" ), g_route_prop_y);
2568 SetPath(_T (
"/Settings/Audio" ));
2569 Write(_T (
"AISAlertSoundFile" ), g_AIS_sound_file);
2570 Write(_T (
"DSCAlertSoundFile" ), g_DSC_sound_file);
2571 Write(_T (
"SARTAlertSoundFile" ), g_SART_sound_file);
2572 Write(_T (
"AnchorAlarmSoundFile" ), g_anchorwatch_sound_file);
2574 Write(_T (
"bAIS_GCPA_AlertAudio" ), g_bAIS_GCPA_Alert_Audio);
2575 Write(_T (
"bAIS_SART_AlertAudio" ), g_bAIS_SART_Alert_Audio);
2576 Write(_T (
"bAIS_DSC_AlertAudio" ), g_bAIS_DSC_Alert_Audio);
2577 Write(_T (
"bAnchorAlertAudio" ), g_bAnchor_Alert_Audio);
2580 SetPath(_T (
"/Settings/AIS" ));
2582 Write(_T (
"bNoCPAMax" ), g_bCPAMax);
2583 Write(_T (
"NoCPAMaxNMi" ), g_CPAMax_NM);
2584 Write(_T (
"bCPAWarn" ), g_bCPAWarn);
2585 Write(_T (
"CPAWarnNMi" ), g_CPAWarn_NM);
2586 Write(_T (
"bTCPAMax" ), g_bTCPA_Max);
2587 Write(_T (
"TCPAMaxMinutes" ), g_TCPA_Max);
2588 Write(_T (
"bMarkLostTargets" ), g_bMarkLost);
2589 Write(_T (
"MarkLost_Minutes" ), g_MarkLost_Mins);
2590 Write(_T (
"bRemoveLostTargets" ), g_bRemoveLost);
2591 Write(_T (
"RemoveLost_Minutes" ), g_RemoveLost_Mins);
2592 Write(_T (
"bShowCOGArrows" ), g_bShowCOG);
2593 Write(_T (
"bSyncCogPredictors" ), g_bSyncCogPredictors);
2594 Write(_T (
"CogArrowMinutes" ), g_ShowCOG_Mins);
2595 Write(_T (
"bShowTargetTracks" ), g_bAISShowTracks);
2596 Write(_T (
"TargetTracksMinutes" ), g_AISShowTracks_Mins);
2598 Write(_T (
"bHideMooredTargets" ), g_bHideMoored);
2599 Write(_T (
"MooredTargetMaxSpeedKnots" ), g_ShowMoored_Kts);
2601 Write(_T (
"bAISAlertDialog" ), g_bAIS_CPA_Alert);
2602 Write(_T (
"bAISAlertAudio" ), g_bAIS_CPA_Alert_Audio);
2604 Write(_T (
"AISAlertAudioFile" ), g_sAIS_Alert_Sound_File);
2605 Write(_T (
"bAISAlertSuppressMoored" ), g_bAIS_CPA_Alert_Suppress_Moored);
2606 Write(_T (
"bShowAreaNotices" ), g_bShowAreaNotices);
2607 Write(_T (
"bDrawAISSize" ), g_bDrawAISSize);
2608 Write(_T (
"bDrawAISRealtime" ), g_bDrawAISRealtime);
2609 Write(_T (
"AISRealtimeMinSpeedKnots" ), g_AIS_RealtPred_Kts);
2610 Write(_T (
"bShowAISName" ), g_bShowAISName);
2611 Write(_T (
"ShowAISTargetNameScale" ), g_Show_Target_Name_Scale);
2612 Write(_T (
"bWplIsAprsPositionReport" ), g_bWplUsePosition);
2613 Write(_T (
"WplSelAction" ), g_WplAction);
2614 Write(_T (
"AISCOGPredictorWidth" ), g_ais_cog_predictor_width);
2615 Write(_T (
"bShowScaledTargets" ), g_bAllowShowScaled);
2616 Write(_T (
"AISScaledNumber" ), g_ShowScaled_Num);
2617 Write(_T (
"AISScaledNumberWeightSOG" ), g_ScaledNumWeightSOG);
2618 Write(_T (
"AISScaledNumberWeightCPA" ), g_ScaledNumWeightCPA);
2619 Write(_T (
"AISScaledNumberWeightTCPA" ), g_ScaledNumWeightTCPA);
2620 Write(_T (
"AISScaledNumberWeightRange" ), g_ScaledNumWeightRange);
2621 Write(_T (
"AISScaledNumberWeightSizeOfTarget" ), g_ScaledNumWeightSizeOfT);
2622 Write(_T (
"AISScaledSizeMinimal" ), g_ScaledSizeMinimal);
2623 Write(_T (
"AISShowScaled"), g_bShowScaled);
2625 Write(_T (
"AlertDialogSizeX" ), g_ais_alert_dialog_sx);
2626 Write(_T (
"AlertDialogSizeY" ), g_ais_alert_dialog_sy);
2627 Write(_T (
"AlertDialogPosX" ), g_ais_alert_dialog_x);
2628 Write(_T (
"AlertDialogPosY" ), g_ais_alert_dialog_y);
2629 Write(_T (
"QueryDialogPosX" ), g_ais_query_dialog_x);
2630 Write(_T (
"QueryDialogPosY" ), g_ais_query_dialog_y);
2631 Write(_T (
"AISTargetListPerspective" ), g_AisTargetList_perspective);
2632 Write(_T (
"AISTargetListRange" ), g_AisTargetList_range);
2633 Write(_T (
"AISTargetListSortColumn" ), g_AisTargetList_sortColumn);
2634 Write(_T (
"bAISTargetListSortReverse" ), g_bAisTargetList_sortReverse);
2635 Write(_T (
"AISTargetListColumnSpec" ), g_AisTargetList_column_spec);
2636 Write(_T (
"AISTargetListColumnOrder"), g_AisTargetList_column_order);
2638 Write(_T (
"S57QueryDialogSizeX" ), g_S57_dialog_sx);
2639 Write(_T (
"S57QueryDialogSizeY" ), g_S57_dialog_sy);
2640 Write(_T (
"S57QueryExtraDialogSizeX" ), g_S57_extradialog_sx);
2641 Write(_T (
"S57QueryExtraDialogSizeY" ), g_S57_extradialog_sy);
2643 Write(_T (
"bAISRolloverShowClass" ), g_bAISRolloverShowClass);
2644 Write(_T (
"bAISRolloverShowCOG" ), g_bAISRolloverShowCOG);
2645 Write(_T (
"bAISRolloverShowCPA" ), g_bAISRolloverShowCPA);
2647 Write(_T (
"bAISAlertAckTimeout" ), g_bAIS_ACK_Timeout);
2648 Write(_T (
"AlertAckTimeoutMinutes" ), g_AckTimeout_Mins);
2650 SetPath(_T (
"/Settings/GlobalState" ));
2652 Write(_T (
"bShowS57Text" ), ps52plib->GetShowS57Text());
2653 Write(_T (
"bShowS57ImportantTextOnly" ),
2654 ps52plib->GetShowS57ImportantTextOnly());
2655 if (!g_bInlandEcdis)
2656 Write(_T (
"nDisplayCategory" ), (
long)ps52plib->GetDisplayCategory());
2657 Write(_T (
"nSymbolStyle" ), (
int)ps52plib->m_nSymbolStyle);
2658 Write(_T (
"nBoundaryStyle" ), (
int)ps52plib->m_nBoundaryStyle);
2660 Write(_T (
"bShowSoundg" ), ps52plib->m_bShowSoundg);
2661 Write(_T (
"bShowMeta" ), ps52plib->m_bShowMeta);
2662 Write(_T (
"bUseSCAMIN" ), ps52plib->m_bUseSCAMIN);
2663 Write(_T (
"bUseSUPER_SCAMIN" ), ps52plib->m_bUseSUPER_SCAMIN);
2664 Write(_T (
"bShowAtonText" ), ps52plib->m_bShowAtonText);
2665 Write(_T (
"bShowLightDescription" ), ps52plib->m_bShowLdisText);
2666 Write(_T (
"bExtendLightSectors" ), ps52plib->m_bExtendLightSectors);
2667 Write(_T (
"bDeClutterText" ), ps52plib->m_bDeClutterText);
2668 Write(_T (
"bShowNationalText" ), ps52plib->m_bShowNationalTexts);
2670 Write(_T (
"S52_MAR_SAFETY_CONTOUR" ),
2671 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
2672 Write(_T (
"S52_MAR_SHALLOW_CONTOUR" ),
2673 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
2674 Write(_T (
"S52_MAR_DEEP_CONTOUR" ),
2675 S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
2676 Write(_T (
"S52_MAR_TWO_SHADES" ), S52_getMarinerParam(S52_MAR_TWO_SHADES));
2677 Write(_T (
"S52_DEPTH_UNIT_SHOW" ), ps52plib->m_nDepthUnitDisplay);
2678 Write(_T (
"ENCSoundingScaleFactor" ), g_ENCSoundingScaleFactor);
2679 Write(_T (
"ENCTextScaleFactor" ), g_ENCTextScaleFactor);
2681 SetPath(_T (
"/Directories" ));
2682 Write(_T (
"S57DataLocation" ), _T(
""));
2685 SetPath(_T (
"/Directories" ));
2686 Write(_T (
"InitChartDir" ), *pInit_Chart_Dir);
2687 Write(_T (
"GPXIODir" ), g_gpx_path);
2688 Write(_T (
"TCDataDir" ), g_TCData_Dir);
2689 Write(_T (
"BasemapDir" ), g_Platform->NormalizePath(gWorldMapLocation));
2690 Write(_T (
"pluginInstallDir" ), g_Platform->NormalizePath(g_winPluginDir));
2692 SetPath(_T (
"/Settings/NMEADataSource" ));
2693 wxString connectionconfigs;
2694 for (
size_t i = 0; i < TheConnectionParams()->Count(); i++) {
2695 if (i > 0) connectionconfigs.Append(_T(
"|"));
2696 connectionconfigs.Append(TheConnectionParams()->Item(i)->Serialize());
2698 Write(_T (
"DataConnections" ), connectionconfigs);
2703 SetPath(_T (
"/Settings/AuxFontKeys" ));
2705 wxArrayString keyArray = FontMgr::Get().GetAuxKeyArray();
2706 for (
unsigned int i = 0; i < keyArray.GetCount(); i++) {
2708 key.Printf(_T(
"Key%i"), i);
2709 wxString keyval = keyArray[i];
2715 font_path = (_T (
"/Settings/X11Fonts" ));
2719 font_path = (_T (
"/Settings/GTKFonts" ));
2723 font_path = (_T (
"/Settings/MSWFonts" ));
2727 font_path = (_T (
"/Settings/MacFonts" ));
2731 font_path = (_T (
"/Settings/QTFonts" ));
2734 DeleteGroup(font_path);
2738 int nFonts = FontMgr::Get().GetNumFonts();
2740 for (
int i = 0; i < nFonts; i++) {
2741 wxString cfstring(FontMgr::Get().GetConfigString(i));
2742 wxString valstring = FontMgr::Get().GetFullConfigDesc(i);
2743 Write(cfstring, valstring);
2747 DeleteGroup(_T (
"/TideCurrentDataSources" ));
2748 SetPath(_T (
"/TideCurrentDataSources" ));
2749 unsigned int iDirMax = TideCurrentDataSet.Count();
2750 for (
unsigned int id = 0;
id < iDirMax;
id++) {
2752 key.Printf(_T(
"tcds%d"),
id);
2753 Write(key, TideCurrentDataSet[
id]);
2756 SetPath(_T (
"/Settings/Others" ));
2759 Write(_T (
"ShowRadarRings" ),
2760 (
bool)(g_iNavAidRadarRingsNumberVisible > 0));
2761 Write(_T (
"RadarRingsNumberVisible" ), g_iNavAidRadarRingsNumberVisible);
2762 Write(_T (
"RadarRingsStep" ), g_fNavAidRadarRingsStep);
2763 Write(_T (
"RadarRingsStepUnits" ), g_pNavAidRadarRingsStepUnits);
2764 Write(_T (
"RadarRingsColour" ),
2765 g_colourOwnshipRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
2766 Write(_T(
"WaypointUseScaMin" ), g_bUseWptScaMin);
2767 Write(_T(
"WaypointScaMinValue" ), g_iWpt_ScaMin);
2768 Write(_T(
"WaypointUseScaMinOverrule" ), g_bOverruleScaMin);
2769 Write(_T(
"WaypointsShowName"), g_bShowWptName);
2772 Write(_T (
"WaypointRangeRingsNumber" ), g_iWaypointRangeRingsNumber);
2773 Write(_T (
"WaypointRangeRingsStep" ), g_fWaypointRangeRingsStep);
2774 Write(_T (
"WaypointRangeRingsStepUnits" ), g_iWaypointRangeRingsStepUnits);
2775 Write(_T (
"WaypointRangeRingsColour" ),
2776 g_colourWaypointRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
2778 Write(_T (
"ConfirmObjectDeletion" ), g_bConfirmObjectDelete);
2781 Write(_T (
"WaypointPreventDragging" ), g_bWayPointPreventDragging);
2783 Write(_T (
"EnableZoomToCursor" ), g_bEnableZoomToCursor);
2785 Write(_T (
"TrackIntervalSeconds" ), g_TrackIntervalSeconds);
2786 Write(_T (
"TrackDeltaDistance" ), g_TrackDeltaDistance);
2787 Write(_T (
"TrackPrecision" ), g_nTrackPrecision);
2789 Write(_T (
"RouteLineWidth" ), g_route_line_width);
2790 Write(_T (
"TrackLineWidth" ), g_track_line_width);
2791 Write(_T (
"TrackLineColour" ),
2792 g_colourTrackLineColour.GetAsString(wxC2S_HTML_SYNTAX));
2793 Write(_T (
"DefaultWPIcon" ), g_default_wp_icon);
2794 Write(_T (
"DefaultRPIcon" ), g_default_routepoint_icon);
2796 DeleteGroup(_T (
"/MmsiProperties" ));
2797 SetPath(_T (
"/MmsiProperties" ));
2798 for (
unsigned int i = 0; i < g_MMSI_Props_Array.GetCount(); i++) {
2800 p.Printf(_T(
"Props%d"), i);
2801 Write(p, g_MMSI_Props_Array[i]->Serialize());
2804 SaveCanvasConfigs();
2809void MyConfig::UpdateNavObj(
bool bRecreate) {
2813 pNavObjectSet->CreateAllGPXObjects();
2814 pNavObjectSet->SaveFile(m_sNavObjSetFile);
2816 delete pNavObjectSet;
2818 if (m_pNavObjectChangesSet->m_changes_file)
2819 fclose(m_pNavObjectChangesSet->m_changes_file);
2821 if (::wxFileExists(m_sNavObjSetChangesFile)) {
2823 wxRemoveFile(m_sNavObjSetChangesFile);
2827 m_pNavObjectChangesSet->Init(m_sNavObjSetChangesFile);
2829 m_pNavObjectChangesSet->reset();
2830 m_pNavObjectChangesSet->load_file(m_sNavObjSetChangesFile.fn_str());
2834static wxFileName exportFileName(wxWindow *parent,
2835 const wxString suggestedName) {
2838 wxString validName{suggestedName};
2841 validName.Replace(_T(
"/"), _T(
"-"));
2842 validName.Replace(_T(
":"), _T(
"_"));
2843 int response = g_Platform->DoFileSelectorDialog(
2844 parent, &path, _(
"Export GPX file"), g_gpx_path, validName, wxT(
"*.gpx"));
2846 if (response == wxID_OK) {
2847 wxFileName fn(path);
2848 g_gpx_path = fn.GetPath();
2849 fn.SetExt(_T(
"gpx"));
2852 if (wxFileExists(fn.GetFullPath())) {
2854 OCPNMessageBox(NULL, _(
"Overwrite existing file?"), _T(
"Confirm"),
2855 wxICON_QUESTION | wxYES_NO | wxCANCEL);
2856 if (answer != wxID_YES)
return ret;
2864bool MyConfig::IsChangesFileDirty() {
2865 if (m_pNavObjectChangesSet) {
2866 return m_pNavObjectChangesSet->IsDirty();
2872bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes,
2873 const wxString suggestedName) {
2874 wxFileName fn = exportFileName(parent, suggestedName);
2877 pgpx->AddGPXRoutesList(pRoutes);
2879#ifdef __OCPN__ANDROID__
2880 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2882 pgpx->SaveFile(fns);
2883 AndroidSecureCopyFile(fns, fn.GetFullPath());
2885 pgpx->SaveFile(fn.GetFullPath());
2896bool ExportGPXTracks(wxWindow *parent, std::vector<Track*> *pTracks,
2897 const wxString suggestedName) {
2898 wxFileName fn = exportFileName(parent, suggestedName);
2901 pgpx->AddGPXTracksList(pTracks);
2902#ifdef __OCPN__ANDROID__
2903 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2905 pgpx->SaveFile(fns);
2906 AndroidSecureCopyFile(fns, fn.GetFullPath());
2908 pgpx->SaveFile(fn.GetFullPath());
2917bool ExportGPXWaypoints(wxWindow *parent, RoutePointList *pRoutePoints,
2918 const wxString suggestedName) {
2919 wxFileName fn = exportFileName(parent, suggestedName);
2922 pgpx->AddGPXPointsList(pRoutePoints);
2924#ifdef __OCPN__ANDROID__
2925 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2927 pgpx->SaveFile(fns);
2928 AndroidSecureCopyFile(fns, fn.GetFullPath());
2930 pgpx->SaveFile(fn.GetFullPath());
2940void ExportGPX(wxWindow *parent,
bool bviz_only,
bool blayer) {
2941 wxFileName fn = exportFileName(parent, _T(
"userobjects.gpx"));
2943 ::wxBeginBusyCursor();
2947 wxGenericProgressDialog *pprog =
nullptr;
2948 int count = pWayPointMan->GetWaypointList()->GetCount();
2949 int progStep = count / 32;
2951 pprog =
new wxGenericProgressDialog(
2952 _(
"Export GPX file"), _T(
"0/0"), count, NULL,
2953 wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME |
2954 wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
2955 pprog->SetSize(400, wxDefaultCoord);
2962 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
2965 if (pprog && !(ic % progStep)) {
2967 msg.Printf(_T(
"%d/%d"), ic, count);
2968 pprog->Update(ic, msg);
2972 pr = node->GetData();
2976 if (bviz_only && !pr->m_bIsVisible) b_add =
false;
2978 if (pr->m_bIsInLayer && !blayer) b_add =
false;
2980 if (pr->IsShared() || !WptIsInRouteList(pr)) pgpx->AddGPXWaypoint(pr);
2983 node = node->GetNext();
2986 wxRouteListNode *node1 = pRouteList->GetFirst();
2988 Route *pRoute = node1->GetData();
2992 if (bviz_only && !pRoute->IsVisible()) b_add =
false;
2994 if (pRoute->m_bIsInLayer && !blayer) b_add =
false;
2996 if (b_add) pgpx->AddGPXRoute(pRoute);
2998 node1 = node1->GetNext();
3001 for (
Track* pTrack : g_TrackList) {
3004 if (bviz_only && !pTrack->IsVisible()) b_add =
false;
3006 if (pTrack->m_bIsInLayer && !blayer) b_add =
false;
3008 if (b_add) pgpx->AddGPXTrack(pTrack);
3014#ifdef __OCPN__ANDROID__
3015 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
3017 pgpx->SaveFile(fns);
3018 AndroidSecureCopyFile(fns, fn.GetFullPath());
3020 pgpx->SaveFile(fn.GetFullPath());
3024 ::wxEndBusyCursor();
3030void UI_ImportGPX(wxWindow *parent,
bool islayer, wxString dirpath,
3031 bool isdirectory,
bool isPersistent) {
3032 int response = wxID_CANCEL;
3033 wxArrayString file_array;
3036 if (!islayer || dirpath.IsSameAs(_T(
""))) {
3040#ifndef __OCPN__ANDROID__
3041 wxFileDialog *popenDialog =
3042 new wxFileDialog(NULL, _(
"Import GPX file"), g_gpx_path, wxT(
""),
3043 wxT(
"GPX files (*.gpx)|*.gpx|All files (*.*)|*.*"),
3044 wxFD_OPEN | wxFD_MULTIPLE);
3046 if (g_bresponsive && parent)
3047 popenDialog = g_Platform->AdjustFileDialogFont(parent, popenDialog);
3049 popenDialog->Centre();
3052 if (parent) parent->HideWithEffect(wxSHOW_EFFECT_BLEND);
3055 response = popenDialog->ShowModal();
3058 if (parent) parent->ShowWithEffect(wxSHOW_EFFECT_BLEND);
3061 if (response == wxID_OK) {
3062 popenDialog->GetPaths(file_array);
3065 if (file_array.GetCount()) {
3066 wxFileName fn(file_array[0]);
3067 g_gpx_path = fn.GetPath();
3073 response = g_Platform->DoFileSelectorDialog(
3074 NULL, &path, _(
"Import GPX file"), g_gpx_path, _T(
""), wxT(
"*.gpx"));
3076 file_array.Add(path);
3077 wxFileName fn(path);
3078 g_gpx_path = fn.GetPath();
3084 if (wxDir::GetAllFiles(dirpath, &file_array, wxT(
"*.gpx")))
3087 file_array.Add(dirpath);
3092 if (response == wxID_OK) {
3095 l->m_LayerID = ++g_LayerIdx;
3096 l->m_LayerFileName = file_array[0];
3097 if (file_array.GetCount() <= 1)
3098 wxFileName::SplitPath(file_array[0], NULL, NULL, &(l->m_LayerName),
3101 if (dirpath.IsSameAs(_T(
"")))
3102 wxFileName::SplitPath(g_gpx_path, NULL, NULL, &(l->m_LayerName), NULL,
3105 wxFileName::SplitPath(dirpath, NULL, NULL, &(l->m_LayerName), NULL,
3109 bool bLayerViz = g_bShowLayers;
3110 if (g_VisibleLayers.Contains(l->m_LayerName)) bLayerViz =
true;
3111 if (g_InvisibleLayers.Contains(l->m_LayerName)) bLayerViz =
false;
3112 l->m_bIsVisibleOnChart = bLayerViz;
3115 l->m_bHasVisibleNames = wxCHK_CHECKED;
3118 laymsg.Printf(wxT(
"New layer %d: %s"), l->m_LayerID,
3119 l->m_LayerName.c_str());
3120 wxLogMessage(laymsg);
3122 pLayerList->Insert(l);
3125 for (
unsigned int i = 0; i < file_array.GetCount(); i++) {
3126 wxString path = file_array[i];
3128 if (::wxFileExists(path)) {
3130 pSet->load_file(path.fn_str());
3133 l->m_NoOfItems = pSet->LoadAllGPXObjectsAsLayer(
3134 l->m_LayerID, l->m_bIsVisibleOnChart, l->m_bHasVisibleNames);
3135 l->m_LayerType = isPersistent ? _(
"Persistent") : _(
"Temporary");
3140 wxString destf, f, name, ext;
3141 f = l->m_LayerFileName;
3142 wxFileName::SplitPath(f, NULL, NULL, &name, &ext);
3143 destf = g_Platform->GetPrivateDataDir();
3144 appendOSDirSlash(&destf);
3145 destf.Append(_T(
"layers"));
3146 appendOSDirSlash(&destf);
3147 if (!wxDirExists(destf)) {
3148 if (!wxMkdir(destf, wxS_DIR_DEFAULT))
3149 wxLogMessage(_T(
"Error creating layer directory"));
3152 destf << name << _T(
".") << ext;
3154 if (wxCopyFile(f, destf,
true))
3155 msg.Printf(_T(
"File: %s.%s also added to persistent layers"),
3158 msg.Printf(_T(
"Failed adding %s.%s to persistent layers"), name,
3164 pSet->LoadAllGPXObjects(
3170 wxString::Format(_T(
"%d ") + _(
"duplicate waypoints detected "
3171 "during import and ignored."),
3173 _(
"OpenCPN Info"), wxICON_INFORMATION | wxOK, 10);
3185void SwitchInlandEcdisMode(
bool Switch) {
3187 wxLogMessage(_T(
"Switch InlandEcdis mode On"));
3191 g_iDistanceFormat = 2;
3194 if (ps52plib) ps52plib->SetDisplayCategory(STANDARD);
3195 g_bDrawAISSize =
false;
3196 if (gFrame) gFrame->RequestNewToolbars(
true);
3198 wxLogMessage(_T(
"Switch InlandEcdis mode Off"));
3201 pConfig->SetPath(_T (
"/Settings" ));
3202 pConfig->Read(_T (
"GlobalToolbarConfig" ), &g_toolbarConfig);
3203 pConfig->Read(_T (
"DistanceFormat" ), &g_iDistanceFormat);
3204 pConfig->Read(_T (
"SpeedFormat" ), &g_iSpeedFormat);
3205 pConfig->Read(_T (
"ShowDepthUnits" ), &g_bShowDepthUnits, 1);
3207 pConfig->Read(_T (
"nDisplayCategory" ), &read_int,
3208 (
enum _DisCat)STANDARD);
3209 if (ps52plib) ps52plib->SetDisplayCategory((
enum _DisCat)read_int);
3210 pConfig->SetPath(_T (
"/Settings/AIS" ));
3211 pConfig->Read(_T (
"bDrawAISSize" ), &g_bDrawAISSize);
3212 pConfig->Read(_T (
"bDrawAISRealtime" ), &g_bDrawAISRealtime);
3214 if (gFrame) gFrame->RequestNewToolbars(
true);
3226wxString FormatGPXDateTime(wxDateTime dt) {
3228 return dt.Format(wxT(
"%Y-%m-%dT%H:%M:%SZ"));
3235bool LogMessageOnce(
const wxString &msg) {
3238 for (
unsigned int i = 0; i < pMessageOnceArray->GetCount(); i++) {
3239 if (msg.IsSameAs(pMessageOnceArray->Item(i)))
return false;
3243 pMessageOnceArray->Add(msg);
3257double fromUsrDistance(
double usr_distance,
int unit) {
3259 if (
unit == -1)
unit = g_iDistanceFormat;
3265 ret = usr_distance / 1.15078;
3268 ret = usr_distance / 1.852;
3271 ret = usr_distance / 1852;
3274 ret = usr_distance / 6076.12;
3282double fromUsrSpeed(
double usr_speed,
int unit) {
3284 if (
unit == -1)
unit = g_iSpeedFormat;
3290 ret = usr_speed / 1.15078;
3293 ret = usr_speed / 1.852;
3296 ret = usr_speed / 0.514444444;
3304double toUsrTemp(
double cel_temp,
int unit) {
3306 if (
unit == -1)
unit = g_iTempFormat;
3312 ret = (cel_temp * 9.0 / 5.0) + 32;
3315 ret = cel_temp + 273.15;
3324double fromUsrTemp(
double usr_temp,
int unit) {
3326 if (
unit == -1)
unit = g_iTempFormat;
3332 ret = (usr_temp - 32) * 5.0 / 9.0;
3335 ret = usr_temp - 273.15;
3344wxString getUsrTempUnit(
int unit) {
3346 if (
unit == -1)
unit = g_iTempFormat;
3361wxString formatAngle(
double angle) {
3363 if (g_bShowMag && g_bShowTrue) {
3364 out.Printf(wxT(
"%03.0f %cT (%.0f %cM)"), angle, 0x00B0,
3365 gFrame->GetMag(angle), 0x00B0);
3366 }
else if (g_bShowTrue) {
3367 out.Printf(wxT(
"%03.0f %cT"), angle, 0x00B0);
3369 out.Printf(wxT(
"%03.0f %cM"), gFrame->GetMag(angle), 0x00B0);
3375void AlphaBlending(
ocpnDC &dc,
int x,
int y,
int size_x,
int size_y,
3376 float radius, wxColour color,
unsigned char transparency) {
3377 wxDC *pdc = dc.GetDC();
3380 wxBitmap obm(size_x, size_y);
3382 mdc1.SelectObject(obm);
3383 mdc1.Blit(0, 0, size_x, size_y, pdc, x, y);
3384 mdc1.SelectObject(wxNullBitmap);
3385 wxImage oim = obm.ConvertToImage();
3388 wxBitmap olbm(size_x, size_y);
3389 wxMemoryDC oldc(olbm);
3390 if (!oldc.IsOk())
return;
3392 oldc.SetBackground(*wxBLACK_BRUSH);
3393 oldc.SetBrush(*wxWHITE_BRUSH);
3396 if (radius > 0.0) oldc.DrawRoundedRectangle(0, 0, size_x, size_y, radius);
3398 wxImage dest = olbm.ConvertToImage();
3399 unsigned char *dest_data =
3400 (
unsigned char *)malloc(size_x * size_y * 3 *
sizeof(
unsigned char));
3401 unsigned char *bg = oim.GetData();
3402 unsigned char *box = dest.GetData();
3403 unsigned char *d = dest_data;
3410 float alpha = 1.0 - (float)transparency / 255.0;
3411 int sb = size_x * size_y;
3412 for (
int i = 0; i < sb; i++) {
3414 if (*box == 0 && radius > 0.0) a = 1.0;
3415 int r = ((*bg++) * a) + (1.0 - a) * color.Red();
3418 int g = ((*bg++) * a) + (1.0 - a) * color.Green();
3421 int b = ((*bg++) * a) + (1.0 - a) * color.Blue();
3426 dest.SetData(dest_data);
3430 dc.DrawBitmap(dbm, x, y,
false);
3434 dc.CalcBoundingBox(x, y);
3435 dc.CalcBoundingBox(x + size_x, y + size_y);
3440 float radMod = wxMax(radius, 2.0);
3441 wxColour c(color.Red(), color.Green(), color.Blue(), transparency);
3442 dc.SetBrush(wxBrush(c));
3443 dc.SetPen(wxPen(c, 1));
3444 dc.DrawRoundedRectangle(x, y, size_x, size_y, radMod);
3446 glDisable(GL_BLEND);
3452void GpxDocument::SeedRandom() {
3456 wxDateTime x = wxDateTime::UNow();
3457 long seed = x.GetMillisecond();
3458 seed *= x.GetTicks();
3462void DimeControl(wxWindow *ctrl) {
3468 if (wxPlatformInfo::Get().CheckOSVersion(10, 14)) {
3476 if (NULL == ctrl)
return;
3478 wxColour col, window_back_color, gridline, uitext, udkrd, ctrl_back_color,
3480 col = GetGlobalColor(_T(
"DILG0"));
3481 window_back_color = GetGlobalColor(_T(
"DILG1"));
3482 ctrl_back_color = GetGlobalColor(_T(
"DILG1"));
3483 text_color = GetGlobalColor(_T(
"DILG3"));
3484 uitext = GetGlobalColor(_T(
"UITX1"));
3485 udkrd = GetGlobalColor(_T(
"UDKRD"));
3486 gridline = GetGlobalColor(_T(
"GREY2"));
3488 DimeControl(ctrl, col, window_back_color, ctrl_back_color, text_color, uitext,
3492void DimeControl(wxWindow *ctrl, wxColour col, wxColour window_back_color,
3493 wxColour ctrl_back_color, wxColour text_color, wxColour uitext,
3494 wxColour udkrd, wxColour gridline) {
3500 if (wxPlatformInfo::Get().CheckOSVersion(10, 14)) {
3505 ColorScheme cs = global_color_scheme;
3509 (cs == GLOBAL_COLOR_SCHEME_DUSK || cs == GLOBAL_COLOR_SCHEME_NIGHT);
3511 static int depth = 0;
3517 window_back_color = wxNullColour;
3519 window_back_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
3521 col = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
3522 uitext = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
3525 ctrl->SetBackgroundColour(window_back_color);
3526 if (darkMode) ctrl->SetForegroundColour(text_color);
3529 wxWindowList kids = ctrl->GetChildren();
3530 for (
unsigned int i = 0; i < kids.GetCount(); i++) {
3531 wxWindowListNode *node = kids.Item(i);
3532 wxWindow *win = node->GetData();
3534 if (win->IsKindOf(CLASSINFO(wxListBox)) ||
3535 win->IsKindOf(CLASSINFO(wxListCtrl)) ||
3536 win->IsKindOf(CLASSINFO(wxTextCtrl))
3537 || win->IsKindOf(CLASSINFO(wxTimePickerCtrl))
3539 win->SetBackgroundColour(col);
3540 }
else if (win->IsKindOf(CLASSINFO(wxStaticText)) ||
3541 win->IsKindOf(CLASSINFO(wxCheckBox)) ||
3542 win->IsKindOf(CLASSINFO(wxRadioButton))) {
3543 win->SetForegroundColour(uitext);
3550 else if (win->IsKindOf(CLASSINFO(wxBitmapComboBox)) ||
3551 win->IsKindOf(CLASSINFO(wxChoice)) ||
3552 win->IsKindOf(CLASSINFO(wxComboBox)) ||
3553 win->IsKindOf(CLASSINFO(wxTreeCtrl))) {
3554 win->SetBackgroundColour(col);
3557 else if (win->IsKindOf(CLASSINFO(wxScrolledWindow)) ||
3558 win->IsKindOf(CLASSINFO(wxGenericDirCtrl)) ||
3559 win->IsKindOf(CLASSINFO(wxListbook)) ||
3560 win->IsKindOf(CLASSINFO(wxButton)) ||
3561 win->IsKindOf(CLASSINFO(wxToggleButton))) {
3562 win->SetBackgroundColour(window_back_color);
3565 else if (win->IsKindOf(CLASSINFO(wxNotebook))) {
3566 ((wxNotebook *)win)->SetBackgroundColour(window_back_color);
3567 ((wxNotebook *)win)->SetForegroundColour(text_color);
3571 else if (win->IsKindOf(CLASSINFO(wxHtmlWindow))) {
3572 if (cs != GLOBAL_COLOR_SCHEME_DAY && cs != GLOBAL_COLOR_SCHEME_RGB)
3573 ((wxPanel *)win)->SetBackgroundColour(ctrl_back_color);
3575 ((wxPanel *)win)->SetBackgroundColour(wxNullColour);
3578 else if (win->IsKindOf(CLASSINFO(wxGrid))) {
3579 ((wxGrid *)win)->SetDefaultCellBackgroundColour(window_back_color);
3580 ((wxGrid *)win)->SetDefaultCellTextColour(uitext);
3581 ((wxGrid *)win)->SetLabelBackgroundColour(col);
3582 ((wxGrid *)win)->SetLabelTextColour(uitext);
3583#if !wxCHECK_VERSION(3, 0, 0)
3584 ((wxGrid *)win)->SetDividerPen(wxPen(col));
3586 ((wxGrid *)win)->SetGridLineColour(gridline);
3589 if (win->GetChildren().GetCount() > 0) {
3592 DimeControl(w, col, window_back_color, ctrl_back_color, text_color,
3593 uitext, udkrd, gridline);
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.