OpenCPN Partial API docs
Loading...
Searching...
No Matches
navutil.cpp
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2010 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19
25
26#include "gl_headers.h" // Must be included before anything using GL stuff
27
28#include <wx/wxprec.h>
29
30#ifdef __MINGW32__
31#undef IPV6STRICT // mingw FTBS fix: missing struct ip_mreq
32#include <windows.h>
33#endif
34
35#include <algorithm>
36#include <stdlib.h>
37#include <time.h>
38#include <locale>
39#include <list>
40#include <limits>
41#include <string>
42
43#ifndef WX_PRECOMP
44#include <wx/wx.h>
45#endif // precompiled headers
46
47#include <wx/bmpcbox.h>
48#include <wx/dir.h>
49#include "wx/dirctrl.h"
50#include <wx/filename.h>
51#include <wx/graphics.h>
52#include <wx/image.h>
53#include <wx/listbook.h>
54#include <wx/listimpl.cpp>
55#include <wx/progdlg.h>
56#include <wx/sstream.h>
57#include <wx/tglbtn.h>
58#include <wx/timectrl.h>
59#include <wx/tokenzr.h>
60
62#include "o_sound/o_sound.h"
63
64#include "model/ais_decoder.h"
66#include "model/cmdline.h"
67#include "model/config_vars.h"
68#include "model/conn_params.h"
69#include "model/cutil.h"
70#include "model/geodesic.h"
71#include "model/georef.h"
72#include "model/gui_vars.h"
73#include "model/idents.h"
74#include "model/multiplexer.h"
75#include "model/nav_object_database.h"
76#include "model/navutil_base.h"
77#include "model/navobj_db.h"
78#include "model/own_ship.h"
79#include "model/plugin_comm.h"
80#include "model/route.h"
81#include "model/routeman.h"
82#include "model/select.h"
83#include "model/track.h"
84
85#include "ais.h"
86#include "canvas_config.h"
87#include "chartbase.h"
88#include "chartdb.h"
89#include "chcanv.h"
90#include "cm93.h"
91#include "config.h"
92#include "config_mgr.h"
93#include "displays.h"
94#include "dychart.h"
95#include "font_mgr.h"
96#include "layer.h"
97#include "navutil.h"
98#include "nmea0183.h"
99#include "ocpndc.h"
100#include "ocpn_plugin.h"
101#include "ocpn_platform.h"
102#include "s52plib.h"
103#include "s52utils.h"
104#include "s57_load.h"
105#include "snd_config.h"
106#include "styles.h"
107#include "top_frame.h"
108#include "user_colors.h"
109
110#ifdef ocpnUSE_GL
111#include "gl_chart_canvas.h"
112#endif
113
114#ifdef __ANDROID__
115#include "androidUTIL.h"
116#endif
117
119static bool g_bLayersLoaded;
120
121#ifdef ocpnUSE_GL
122extern ocpnGLOptions g_GLOptions;
123#endif
124
125#if !defined(NAN)
126static const long long lNaN = 0xfff8000000000000;
127#define NAN (*(double *)&lNaN)
128#endif
129
130namespace navutil {
131
132wxArrayString *pMessageOnceArray;
133
134void InitGlobals() { pMessageOnceArray = new wxArrayString(); }
135
136void DeinitGlobals() {
137 delete pMessageOnceArray;
138 pMessageOnceArray = nullptr;
139}
140
141} // namespace navutil
142
143// Layer helper function
144
145wxString GetLayerName(int id) {
146 wxString name("unknown layer");
147 if (id <= 0) return (name);
148 LayerList::iterator it;
149 int index = 0;
150 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
151 Layer *lay = (Layer *)(*it);
152 if (lay->m_LayerID == id) return (lay->m_LayerName);
153 }
154 return (name);
155}
156
157// Helper conditional file name dir slash
158void appendOSDirSlash(wxString *pString);
159
160//-----------------------------------------------------------------------------
161// MyConfig Implementation
162//-----------------------------------------------------------------------------
163//
164
165MyConfig::MyConfig(const wxString &LocalFileName)
166 : wxFileConfig("", "", LocalFileName, "", wxCONFIG_USE_LOCAL_FILE) {}
167
168MyConfig::~MyConfig() {}
169
170unsigned MyConfig::ReadUnsigned(const wxString &key, unsigned default_val) {
171 wxString s;
172 unsigned long value = 0;
173 if (!Read(key, &s)) return default_val;
174 try {
175 value = std::stoul(s.ToStdString());
176 } catch (std::logic_error &) {
177 return default_val;
178 }
179 if (value < 0 || value > std::numeric_limits<unsigned>::max())
180 return default_val;
181 return static_cast<unsigned>(value);
182}
183
184int MyConfig::LoadMyConfig() {
185 int display_width, display_height;
186 display_width = g_monitor_info[g_current_monitor].width;
187 display_height = g_monitor_info[g_current_monitor].height;
188
189 // Set up any defaults not set elsewhere
190 g_useMUI = true;
191 g_TalkerIdText = "EC";
192 g_maxWPNameLength = 6;
193 g_NMEAAPBPrecision = 3;
194
195#ifdef ocpnUSE_GL
196 g_GLOptions.m_bUseAcceleratedPanning = true;
197 g_GLOptions.m_GLPolygonSmoothing = true;
198 g_GLOptions.m_GLLineSmoothing = true;
199 g_GLOptions.m_iTextureDimension = 512;
200 g_GLOptions.m_iTextureMemorySize = 128;
201 if (!g_bGLexpert) {
202 g_GLOptions.m_iTextureMemorySize =
203 wxMax(128, g_GLOptions.m_iTextureMemorySize);
204 g_GLOptions.m_bTextureCompressionCaching =
205 g_GLOptions.m_bTextureCompression;
206 }
207#endif
208
209 g_maintoolbar_orient = wxTB_HORIZONTAL;
210 g_iENCToolbarPosX = -1;
211 g_iENCToolbarPosY = -1;
212 g_restore_dbindex = -1;
213 g_ChartNotRenderScaleFactor = 1.5;
214 g_detailslider_dialog_x = 200L;
215 g_detailslider_dialog_y = 200L;
216 g_SENC_LOD_pixels = 2;
217 g_SkewCompUpdatePeriod = 10;
218
219 g_bShowStatusBar = 1;
220 g_bShowCompassWin = 1;
221 g_iSoundDeviceIndex = -1;
222 g_bFullscreenToolbar = 1;
223 g_bTransparentToolbar = 0;
224 g_bShowLayers = 1;
225 g_bShowDepthUnits = 1;
226 g_bShowActiveRouteHighway = 1;
227 g_bShowChartBar = 1;
228 g_defaultBoatSpeed = 6.0;
229 g_ownship_predictor_minutes = 5;
230 g_cog_predictor_style = 105;
231 g_cog_predictor_color = "rgb(255,0,0)";
232 g_cog_predictor_endmarker = 1;
233 g_ownship_HDTpredictor_style = 105;
234 g_ownship_HDTpredictor_color = "rgb(255,0,0)";
235 g_ownship_HDTpredictor_endmarker = 1;
236 g_ownship_HDTpredictor_width = 0;
237 g_cog_predictor_width = 3;
238 g_ownship_HDTpredictor_miles = 1;
239 g_n_ownship_min_mm = 2;
240 g_bFullScreenQuilt = 1;
241 g_track_rotate_time_type = TIME_TYPE_COMPUTER;
242 g_bHighliteTracks = 1;
243 g_bPreserveScaleOnX = 1;
244 g_navobjbackups = 5;
245 g_benableAISNameCache = true;
246 g_n_arrival_circle_radius = 0.05;
247 g_plus_minus_zoom_factor = 2.0;
248 g_mouse_zoom_sensitivity = 1.5;
249 g_datetime_format = "UTC";
250
251 g_AISShowTracks_Mins = 20;
252 g_AISShowTracks_Limit = 300.0;
253 g_ShowScaled_Num = 10;
254 g_ScaledNumWeightSOG = 50;
255 g_ScaledNumWeightCPA = 60;
256 g_ScaledNumWeightTCPA = 25;
257 g_ScaledSizeMinimal = 50;
258 g_ScaledNumWeightRange = 75;
259 g_ScaledNumWeightSizeOfT = 25;
260 g_Show_Target_Name_Scale = 250000;
261 g_bWplUsePosition = 0;
262 g_WplAction = 0;
263 g_ais_cog_predictor_width = 3;
264 g_ais_alert_dialog_sx = 200;
265 g_ais_alert_dialog_sy = 200;
266 g_ais_alert_dialog_x = 200;
267 g_ais_alert_dialog_y = 200;
268 g_ais_query_dialog_x = 200;
269 g_ais_query_dialog_y = 200;
270 g_AisTargetList_range = 40;
271 g_AisTargetList_sortColumn = 2; // Column #2 is MMSI
272 g_S57_dialog_sx = 400;
273 g_S57_dialog_sy = 400;
274 g_S57_extradialog_sx = 400;
275 g_S57_extradialog_sy = 400;
276
277 // Reasonable starting point
278 vLat = START_LAT; // display viewpoint
279 vLon = START_LON;
280 gLat = START_LAT; // GPS position, as default
281 gLon = START_LON;
282 g_maxzoomin = 800;
283
284 g_iNavAidRadarRingsNumberVisible = 0;
285 g_bNavAidRadarRingsShown = false;
286 g_fNavAidRadarRingsStep = 1.0;
287 g_pNavAidRadarRingsStepUnits = 0;
288 g_colourOwnshipRangeRingsColour = *wxRED;
289 g_iWaypointRangeRingsNumber = 0;
290 g_fWaypointRangeRingsStep = 1.0;
291 g_iWaypointRangeRingsStepUnits = 0;
292 g_colourWaypointRangeRingsColour = wxColour(*wxRED);
293 g_bConfirmObjectDelete = true;
294
295 g_TrackIntervalSeconds = 60.0;
296 g_TrackDeltaDistance = 0.10;
297 g_route_line_width = 2;
298 g_track_line_width = 2;
299 g_colourTrackLineColour = wxColour(243, 229, 47); // Yellow
300
301 g_tcwin_scale = 100;
302 g_default_wp_icon = "triangle";
303 g_default_routepoint_icon = "diamond";
304
305 g_nAWDefault = 50;
306 g_nAWMax = 1852;
307 g_ObjQFileExt = "txt,rtf,png,html,gif,tif,jpg";
308 g_OwnShipmmsi = 0;
309
310 // Load the raw value, with no defaults, and no processing
311 int ret_Val = LoadMyConfigRaw();
312
313 // Perform any required post processing and validation
314 if (!ret_Val) {
316 g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor);
317 g_ShipScaleFactorExp =
318 g_Platform->GetChartScaleFactorExp(g_ShipScaleFactor);
319 g_MarkScaleFactorExp =
320 g_Platform->GetMarkScaleFactorExp(g_ChartScaleFactor);
321
322 g_COGFilterSec = wxMin(g_COGFilterSec, kMaxCogsogFilterSeconds);
323 g_COGFilterSec = wxMax(g_COGFilterSec, 1);
324 g_SOGFilterSec = g_COGFilterSec;
325
326 if (!g_bShowTrue && !g_bShowMag) g_bShowTrue = true;
328 wxMin(g_COGAvgSec, kMaxCogAverageSeconds); // Bound the array size
329
330 if (g_bInlandEcdis) g_bLookAhead = 1;
331
332 if (g_bdisable_opengl) g_bopengl = false;
333
334#ifdef ocpnUSE_GL
335 if (!g_bGLexpert) {
336 g_GLOptions.m_iTextureMemorySize =
337 wxMax(128, g_GLOptions.m_iTextureMemorySize);
338 g_GLOptions.m_bTextureCompressionCaching =
339 g_GLOptions.m_bTextureCompression;
340 }
341#endif
342
343 g_chart_zoom_modifier_raster = wxMin(g_chart_zoom_modifier_raster, 5);
344 g_chart_zoom_modifier_raster = wxMax(g_chart_zoom_modifier_raster, -5);
345 g_chart_zoom_modifier_vector = wxMin(g_chart_zoom_modifier_vector, 5);
346 g_chart_zoom_modifier_vector = wxMax(g_chart_zoom_modifier_vector, -5);
347 g_cm93_zoom_factor = wxMin(g_cm93_zoom_factor, CM93_ZOOM_FACTOR_MAX_RANGE);
348 g_cm93_zoom_factor =
349 wxMax(g_cm93_zoom_factor, (-CM93_ZOOM_FACTOR_MAX_RANGE));
350
351 if ((g_detailslider_dialog_x < 0) ||
352 (g_detailslider_dialog_x > display_width))
353 g_detailslider_dialog_x = 5;
354 if ((g_detailslider_dialog_y < 0) ||
355 (g_detailslider_dialog_y > display_height))
356 g_detailslider_dialog_y = 5;
357
358 g_defaultBoatSpeedUserUnit = toUsrSpeed(g_defaultBoatSpeed, -1);
359 g_n_ownship_min_mm = wxMax(g_n_ownship_min_mm, 2);
360
361 if (g_navobjbackups > 99) g_navobjbackups = 99;
362 if (g_navobjbackups < 0) g_navobjbackups = 0;
363 g_n_arrival_circle_radius = wxClip(g_n_arrival_circle_radius, 0.001, 0.6);
364
365 g_selection_radius_mm = wxMax(g_selection_radius_mm, 0.5);
366 g_selection_radius_touch_mm = wxMax(g_selection_radius_touch_mm, 1.0);
367
368 g_Show_Target_Name_Scale = wxMax(5000, g_Show_Target_Name_Scale);
369
370 if ((g_ais_alert_dialog_x < 0) || (g_ais_alert_dialog_x > display_width))
371 g_ais_alert_dialog_x = 5;
372 if ((g_ais_alert_dialog_y < 0) || (g_ais_alert_dialog_y > display_height))
373 g_ais_alert_dialog_y = 5;
374 if ((g_ais_query_dialog_x < 0) || (g_ais_query_dialog_x > display_width))
375 g_ais_query_dialog_x = 5;
376 if ((g_ais_query_dialog_y < 0) || (g_ais_query_dialog_y > display_height))
377 g_ais_query_dialog_y = 5;
378
379 SwitchInlandEcdisMode(g_bInlandEcdis);
380 if (g_bInlandEcdis)
381 global_color_scheme =
382 GLOBAL_COLOR_SCHEME_DUSK; // startup in duskmode if inlandEcdis
383
384 // Multicanvas Settings
385 LoadCanvasConfigs();
386 }
387
388 return ret_Val;
389}
390
391int MyConfig::LoadMyConfigRaw(bool bAsTemplate) {
392 int read_int;
393 wxString val;
394
395 int display_width, display_height;
396 display_width = g_monitor_info[g_current_monitor].width;
397 display_height = g_monitor_info[g_current_monitor].height;
398
399 // Global options and settings
400 SetPath("/Settings");
401 Read("ActiveRoute", &g_active_route);
402 Read("PersistActiveRoute", &g_persist_active_route);
403 Read("AlwaysSendRmbRmc", &g_always_send_rmb_rmc);
404 Read("LastAppliedTemplate", &g_lastAppliedTemplateGUID);
405 Read("CompatOS", &g_compatOS);
406 Read("CompatOsVersion", &g_compatOsVersion);
407
408 // Some undocumented values
409 Read("ConfigVersionString", &g_config_version_string);
410 Read("CmdSoundString", &g_CmdSoundString, wxString(OCPN_SOUND_CMD));
411 if (wxIsEmpty(g_CmdSoundString)) g_CmdSoundString = wxString(OCPN_SOUND_CMD);
412 Read("NavMessageShown", &n_NavMessageShown);
413
414 Read("AndroidVersionCode", &g_AndroidVersionCode);
415
416 Read("UIexpert", &g_bUIexpert);
417
418 Read("UIStyle", &g_uiStyle);
419
420 Read("NCacheLimit", &g_nCacheLimit);
421
422 Read("InlandEcdis",
423 &g_bInlandEcdis); // First read if in iENC mode as this will override
424 // some config settings
425
426 Read("SpaceDropMark", &g_bSpaceDropMark);
427
428 int mem_limit = 0;
429 Read("MEMCacheLimit", &mem_limit);
430 if (mem_limit > 0)
431 g_memCacheLimit = mem_limit * 1024; // convert from MBytes to kBytes
432
433 Read("UseModernUI5", &g_useMUI);
434
435 Read("NCPUCount", &g_nCPUCount);
436
437 Read("DebugGDAL", &g_bGDAL_Debug);
438 Read("DebugNMEA", &g_nNMEADebug);
439 Read("AnchorWatchDefault", &g_nAWDefault);
440 Read("AnchorWatchMax", &g_nAWMax);
441 Read("GPSDogTimeout", &gps_watchdog_timeout_ticks);
442 Read("DebugCM93", &g_bDebugCM93);
443 Read("DebugS57",
444 &g_bDebugS57); // Show LUP and Feature info in object query
445 Read("DebugBSBImg", &g_BSBImgDebug);
446 Read("DebugGPSD", &g_bDebugGPSD);
447 Read("MaxZoomScale", &g_maxzoomin);
448 g_maxzoomin = wxMax(g_maxzoomin, 50);
449
450 Read("DefaultFontSize", &g_default_font_size);
451 Read("DefaultFontFacename", &g_default_font_facename);
452
453 Read("UseGreenShipIcon", &g_bUseGreenShip);
454
455 Read("AutoHideToolbar", &g_bAutoHideToolbar);
456 Read("AutoHideToolbarSecs", &g_nAutoHideToolbar);
457
458 Read("UseSimplifiedScalebar", &g_bsimplifiedScalebar);
459 Read("ShowTide", &g_bShowTide);
460 Read("ShowCurrent", &g_bShowCurrent);
461
462 wxString size_mm;
463 Read("DisplaySizeMM", &size_mm);
464
465 Read("SelectionRadiusMM", &g_selection_radius_mm);
466 Read("SelectionRadiusTouchMM", &g_selection_radius_touch_mm);
467
468 if (!bAsTemplate) {
470 wxStringTokenizer tokenizer(size_mm, ",");
471 while (tokenizer.HasMoreTokens()) {
472 wxString token = tokenizer.GetNextToken();
473 int size;
474 try {
475 size = std::stoi(token.ToStdString());
476 } catch (std::invalid_argument &e) {
477 size = 0;
478 }
479 if (size > 100 && size < 2000) {
480 g_config_display_size_mm.push_back(size);
481 } else {
482 g_config_display_size_mm.push_back(0);
483 }
484 }
485 Read("DisplaySizeManual", &g_config_display_size_manual);
486 }
487
488 Read("GUIScaleFactor", &g_GUIScaleFactor);
489
490 Read("ChartObjectScaleFactor", &g_ChartScaleFactor);
491 Read("ShipScaleFactor", &g_ShipScaleFactor);
492 Read("ENCSoundingScaleFactor", &g_ENCSoundingScaleFactor);
493 Read("ENCTextScaleFactor", &g_ENCTextScaleFactor);
494 Read("ObjQueryAppendFilesExt", &g_ObjQFileExt);
495
496 // Plugin catalog handler persistent variables.
497 Read("CatalogCustomURL", &g_catalog_custom_url);
498 Read("CatalogChannel", &g_catalog_channel);
499
500 Read("NetmaskBits", &g_netmask_bits);
501
502 // NMEA connection options.
503 if (!bAsTemplate) {
504 Read("FilterNMEA_Avg", &g_bfilter_cogsog);
505 Read("FilterNMEA_Sec", &g_COGFilterSec);
506 Read("GPSIdent", &g_GPS_Ident);
507 Read("UseGarminHostUpload", &g_bGarminHostUpload);
508 Read("UseNMEA_GLL", &g_bUseGLL);
509 Read("UseMagAPB", &g_bMagneticAPB);
510 Read("TrackContinuous", &g_btrackContinuous, false);
511 Read("FilterTrackDropLargeJump", &g_trackFilterMax, 1000);
512 }
513
514 Read("ShowTrue", &g_bShowTrue);
515 Read("ShowMag", &g_bShowMag);
516
517 wxString umv;
518 Read("UserMagVariation", &umv);
519 if (umv.Len()) umv.ToDouble(&g_UserVar);
520
521 Read("ScreenBrightness", &g_nbrightness);
522
523 Read("MemFootprintTargetMB", &g_MemFootMB);
524
525 Read("WindowsComPortMax", &g_nCOMPortCheck);
526
527 Read("ChartQuilting", &g_bQuiltEnable);
528 Read("ChartQuiltingInitial", &g_bQuiltStart);
529
530 Read("CourseUpMode", &g_bCourseUp);
531 Read("COGUPAvgSeconds", &g_COGAvgSec);
532 Read("LookAheadMode", &g_bLookAhead);
533 Read("SkewToNorthUp", &g_bskew_comp);
534 Read("TenHzUpdate", &g_btenhertz, 0);
535 Read("DeclutterAnchorage", &g_declutter_anchorage, 0);
536
537 Read("NMEAAPBPrecision", &g_NMEAAPBPrecision);
538
539 Read("TalkerIdText", &g_TalkerIdText);
540 Read("MaxWaypointNameLength", &g_maxWPNameLength);
541 Read("MbtilesMaxLayers", &g_mbtilesMaxLayers);
542
543 Read("ShowTrackPointTime", &g_bShowTrackPointTime, true);
544 /* opengl options */
545#ifdef ocpnUSE_GL
546 if (!bAsTemplate) {
547 Read("OpenGLExpert", &g_bGLexpert, false);
548 Read("UseAcceleratedPanning", &g_GLOptions.m_bUseAcceleratedPanning, true);
549 Read("GPUTextureCompression", &g_GLOptions.m_bTextureCompression);
550 Read("GPUTextureCompressionCaching",
551 &g_GLOptions.m_bTextureCompressionCaching);
552 Read("PolygonSmoothing", &g_GLOptions.m_GLPolygonSmoothing);
553 Read("LineSmoothing", &g_GLOptions.m_GLLineSmoothing);
554 Read("GPUTextureDimension", &g_GLOptions.m_iTextureDimension);
555 Read("GPUTextureMemSize", &g_GLOptions.m_iTextureMemorySize);
556 Read("DebugOpenGL", &g_bDebugOGL);
557 Read("OpenGL", &g_bopengl);
558 Read("OpenGLFinishNeeded", &g_b_needFinish);
559 Read("SoftwareGL", &g_bSoftwareGL);
560 }
561#endif
562
563 Read("SmoothPanZoom", &g_bsmoothpanzoom);
564
565 Read("ToolbarX", &g_maintoolbar_x);
566 Read("ToolbarY", &g_maintoolbar_y);
567 Read("ToolbarOrient", &g_maintoolbar_orient);
568 Read("GlobalToolbarConfig", &g_toolbarConfig);
569
570 Read("iENCToolbarX", &g_iENCToolbarPosX);
571 Read("iENCToolbarY", &g_iENCToolbarPosY);
572
573 Read("AnchorWatch1GUID", &g_AW1GUID);
574 Read("AnchorWatch2GUID", &g_AW2GUID);
575
576 Read("InitialStackIndex", &g_restore_stackindex);
577 Read("InitialdBIndex", &g_restore_dbindex);
578
579 Read("ChartNotRenderScaleFactor", &g_ChartNotRenderScaleFactor);
580
581 Read("MobileTouch", &g_btouch);
582
583// "Responsive graphics" option deprecated in O58+
584// Read("ResponsiveGraphics", &g_bresponsive);
585#ifdef __ANDROID__
586 g_bresponsive = true;
587#else
588 g_bresponsive = false;
589#endif
590
591 Read("EnableRolloverBlock", &g_bRollover);
592
593 Read("ZoomDetailFactor", &g_chart_zoom_modifier_raster);
594 Read("ZoomDetailFactorVector", &g_chart_zoom_modifier_vector);
595 Read("PlusMinusZoomFactor", &g_plus_minus_zoom_factor, 2.0);
596 Read("MouseZoomSensitivity", &g_mouse_zoom_sensitivity, 1.3);
597 g_mouse_zoom_sensitivity_ui =
598 MouseZoom::config_to_ui(g_mouse_zoom_sensitivity);
599 Read("CM93DetailFactor", &g_cm93_zoom_factor);
600 Read("TileBasemapZoomFactor", &g_tile_basemap_zoom_factor);
601
602 Read("CM93DetailZoomPosX", &g_detailslider_dialog_x);
603 Read("CM93DetailZoomPosY", &g_detailslider_dialog_y);
604 Read("ShowCM93DetailSlider", &g_bShowDetailSlider);
605
606 Read("SENC_LOD_Pixels", &g_SENC_LOD_pixels);
607
608 Read("SkewCompUpdatePeriod", &g_SkewCompUpdatePeriod);
609
610 Read("SetSystemTime", &s_bSetSystemTime);
611 Read("EnableKioskStartup", &g_kiosk_startup);
612 Read("DisableNotifications", &g_disableNotifications, 0);
613 Read("ShowStatusBar", &g_bShowStatusBar);
614#ifndef __WXOSX__
615 Read("ShowMenuBar", &g_bShowMenuBar);
616#endif
617 Read("Fullscreen", &g_bFullscreen);
618 Read("ShowCompassWindow", &g_bShowCompassWin);
619 Read("ShowGrid", &g_bDisplayGrid);
620 Read("PlayShipsBells", &g_bPlayShipsBells);
621 Read("SoundDeviceIndex", &g_iSoundDeviceIndex);
622 Read("FullscreenToolbar", &g_bFullscreenToolbar);
623 Read("PermanentMOBIcon", &g_bPermanentMOBIcon);
624 Read("ShowLayers", &g_bShowLayers);
625 Read("ShowDepthUnits", &g_bShowDepthUnits);
626 Read("AutoAnchorDrop", &g_bAutoAnchorMark);
627 Read("ShowChartOutlines", &g_bShowOutlines);
628 Read("ShowActiveRouteHighway", &g_bShowActiveRouteHighway);
629 Read("ShowActiveRouteTotal", &g_bShowRouteTotal);
630 Read("MostRecentGPSUploadConnection", &g_uploadConnection);
631 Read("ShowChartBar", &g_bShowChartBar);
632 Read("SDMMFormat",
633 &g_iSDMMFormat); // 0 = "Degrees, Decimal minutes"), 1 = "Decimal
634 // degrees", 2 = "Degrees,Minutes, Seconds"
635
636 Read("DistanceFormat",
637 &g_iDistanceFormat); // 0 = "Nautical miles"), 1 = "Statute miles", 2 =
638 // "Kilometers", 3 = "Meters"
639 Read("SpeedFormat",
640 &g_iSpeedFormat); // 0 = "kts"), 1 = "mph", 2 = "km/h", 3 = "m/s"
641 Read("WindSpeedFormat",
642 &g_iWindSpeedFormat); // 0 = "knots"), 1 = "m/s", 2 = "Mph", 3 = "km/h"
643 Read("TemperatureFormat", &g_iTempFormat); // 0 = C, 1 = F, 2 = K
644 Read("HeightFormat", &g_iHeightFormat); // 0 = M, 1 = FT
645
646 // LIVE ETA OPTION
647 Read("LiveETA", &g_bShowLiveETA);
648 Read("DefaultBoatSpeed", &g_defaultBoatSpeed);
649
650 Read("OwnshipCOGPredictorMinutes", &g_ownship_predictor_minutes);
651 Read("OwnshipCOGPredictorStyle", &g_cog_predictor_style);
652 Read("OwnshipCOGPredictorColor", &g_cog_predictor_color);
653 Read("OwnshipCOGPredictorEndmarker", &g_cog_predictor_endmarker);
654 Read("OwnshipCOGPredictorWidth", &g_cog_predictor_width);
655 Read("OwnshipHDTPredictorStyle", &g_ownship_HDTpredictor_style);
656 Read("OwnshipHDTPredictorColor", &g_ownship_HDTpredictor_color);
657 Read("OwnshipHDTPredictorEndmarker", &g_ownship_HDTpredictor_endmarker);
658 Read("OwnshipHDTPredictorWidth", &g_ownship_HDTpredictor_width);
659 Read("OwnshipHDTPredictorMiles", &g_ownship_HDTpredictor_miles);
660 int mmsi = 0;
661 Read("OwnShipMMSINumber", &mmsi);
662 g_OwnShipmmsi = mmsi >= 0 ? static_cast<unsigned>(mmsi) : 0;
663 Read("OwnShipIconType", &g_OwnShipIconType);
664 Read("OwnShipLength", &g_n_ownship_length_meters);
665 Read("OwnShipWidth", &g_n_ownship_beam_meters);
666 Read("OwnShipGPSOffsetX", &g_n_gps_antenna_offset_x);
667 Read("OwnShipGPSOffsetY", &g_n_gps_antenna_offset_y);
668 Read("OwnShipMinSize", &g_n_ownship_min_mm);
669 Read("ShowDirectRouteLine", &g_bShowShipToActive);
670 Read("DirectRouteLineStyle", &g_shipToActiveStyle);
671 Read("DirectRouteLineColor", &g_shipToActiveColor);
672
673 wxString racr;
674 Read("RouteArrivalCircleRadius", &racr);
675 if (racr.Len()) racr.ToDouble(&g_n_arrival_circle_radius);
676
677 Read("FullScreenQuilt", &g_bFullScreenQuilt);
678
679 Read("StartWithTrackActive", &g_bTrackCarryOver);
680 Read("AutomaticDailyTracks", &g_bTrackDaily);
681 Read("TrackRotateAt", &g_track_rotate_time);
682 Read("TrackRotateTimeType", &g_track_rotate_time_type);
683 Read("HighlightTracks", &g_bHighliteTracks);
684
685 Read("DateTimeFormat", &g_datetime_format);
686
687 wxString stps;
688 Read("PlanSpeed", &stps);
689 if (!stps.IsEmpty()) stps.ToDouble(&g_PlanSpeed);
690
691 Read("VisibleLayers", &g_VisibleLayers);
692 Read("InvisibleLayers", &g_InvisibleLayers);
693 Read("VisNameInLayers", &g_VisiNameinLayers);
694 Read("InvisNameInLayers", &g_InVisiNameinLayers);
695
696 Read("PreserveScaleOnX", &g_bPreserveScaleOnX);
697
698 Read("ShowMUIZoomButtons", &g_bShowMuiZoomButtons);
699
700 Read("Locale", &g_locale);
701 Read("LocaleOverride", &g_localeOverride);
702
703 // We allow 0-99 backups ov navobj.xml
704 Read("KeepNavobjBackups", &g_navobjbackups);
705
706 // Boolean to cater for legacy Input COM Port filer behaviour, i.e. show msg
707 // filtered but put msg on bus.
708 Read("LegacyInputCOMPortFilterBehaviour", &g_b_legacy_input_filter_behaviour);
709
710 // Boolean to cater for sailing when not approaching waypoint
711 Read("AdvanceRouteWaypointOnArrivalOnly",
712 &g_bAdvanceRouteWaypointOnArrivalOnly);
713 Read("EnableRootMenuDebug", &g_enable_root_menu_debug);
714
715 Read("EnableRotateKeys", &g_benable_rotate);
716 Read("EmailCrashReport", &g_bEmailCrashReport);
717
718 g_benableAISNameCache = true;
719 Read("EnableAISNameCache", &g_benableAISNameCache);
720
721 Read("EnableUDPNullHeader", &g_benableUDPNullHeader);
722
723 SetPath("/Settings/GlobalState");
724 Read("EnableHiconColorScheme", &g_hicon_colors, 0);
725
726 Read("FrameWinX", &g_nframewin_x);
727 Read("FrameWinY", &g_nframewin_y);
728 Read("FrameWinPosX", &g_nframewin_posx);
729 Read("FrameWinPosY", &g_nframewin_posy);
730 Read("FrameMax", &g_bframemax);
731
732 Read("ClientPosX", &g_lastClientRectx);
733 Read("ClientPosY", &g_lastClientRecty);
734 Read("ClientSzX", &g_lastClientRectw);
735 Read("ClientSzY", &g_lastClientRecth);
736
737 Read("RoutePropSizeX", &g_route_prop_sx);
738 Read("RoutePropSizeY", &g_route_prop_sy);
739 Read("RoutePropPosX", &g_route_prop_x);
740 Read("RoutePropPosY", &g_route_prop_y);
741
742 Read("AllowArbitrarySystemPlugins", &g_allow_arb_system_plugin);
743
744 read_int = -1;
745 Read("S52_DEPTH_UNIT_SHOW", &read_int); // default is metres
746 if (read_int >= 0) {
747 read_int = wxMax(read_int, 0); // qualify value
748 read_int = wxMin(read_int, 2);
749 g_nDepthUnitDisplay = read_int;
750 }
751
752 // Sounds
753 SetPath("/Settings/Audio");
754
755 // Set reasonable defaults
756 wxString sound_dir = g_Platform->GetSharedDataDir();
757 sound_dir.Append("sounds");
758 sound_dir.Append(wxFileName::GetPathSeparator());
759
760 g_AIS_sound_file = sound_dir + "beep_ssl.wav";
761 g_DSC_sound_file = sound_dir + "phonering1.wav";
762 g_SART_sound_file = sound_dir + "beep3.wav";
763 g_anchorwatch_sound_file = sound_dir + "beep1.wav";
764
765 Read("AISAlertSoundFile", &g_AIS_sound_file);
766 Read("DSCAlertSoundFile", &g_DSC_sound_file);
767 Read("SARTAlertSoundFile", &g_SART_sound_file);
768 Read("AnchorAlarmSoundFile", &g_anchorwatch_sound_file);
769
770 Read("bAIS_GCPA_AlertAudio", &g_bAIS_GCPA_Alert_Audio);
771 Read("bAIS_SART_AlertAudio", &g_bAIS_SART_Alert_Audio);
772 Read("bAIS_DSC_AlertAudio", &g_bAIS_DSC_Alert_Audio);
773 Read("bAnchorAlertAudio", &g_bAnchor_Alert_Audio);
774
775 // AIS
776 wxString s;
777 SetPath("/Settings/AIS");
778
779 g_bUseOnlyConfirmedAISName = false;
780 Read("UseOnlyConfirmedAISName", &g_bUseOnlyConfirmedAISName);
781
782 Read("bNoCPAMax", &g_bCPAMax);
783
784 Read("NoCPAMaxNMi", &s);
785 s.ToDouble(&g_CPAMax_NM);
786
787 Read("bCPAWarn", &g_bCPAWarn);
788
789 Read("CPAWarnNMi", &s);
790 s.ToDouble(&g_CPAWarn_NM);
791
792 Read("bTCPAMax", &g_bTCPA_Max);
793
794 Read("TCPAMaxMinutes", &s);
795 s.ToDouble(&g_TCPA_Max);
796
797 Read("bMarkLostTargets", &g_bMarkLost);
798
799 Read("MarkLost_Minutes", &s);
800 s.ToDouble(&g_MarkLost_Mins);
801
802 Read("bRemoveLostTargets", &g_bRemoveLost);
803
804 Read("RemoveLost_Minutes", &s);
805 s.ToDouble(&g_RemoveLost_Mins);
806
807 Read("bShowCOGArrows", &g_bShowCOG);
808
809 Read("bSyncCogPredictors", &g_bSyncCogPredictors);
810
811 Read("CogArrowMinutes", &s);
812 s.ToDouble(&g_ShowCOG_Mins);
813
814 Read("bShowTargetTracks", &g_bAISShowTracks);
815
816 if (Read("TargetTracksLimit", &s)) {
817 s.ToDouble(&g_AISShowTracks_Limit);
818 g_AISShowTracks_Limit = wxMax(300.0, g_AISShowTracks_Limit);
819 }
820 if (Read("TargetTracksMinutes", &s)) {
821 s.ToDouble(&g_AISShowTracks_Mins);
822 g_AISShowTracks_Mins = wxMax(1.0, g_AISShowTracks_Mins);
823 g_AISShowTracks_Mins = wxMin(g_AISShowTracks_Limit, g_AISShowTracks_Mins);
824 }
825
826 Read("bHideMooredTargets", &g_bHideMoored);
827 if (Read("MooredTargetMaxSpeedKnots", &s)) s.ToDouble(&g_ShowMoored_Kts);
828
829 g_SOGminCOG_kts = 0.2;
830 if (Read("SOGMinimumForCOGDisplay", &s)) s.ToDouble(&g_SOGminCOG_kts);
831
832 Read("bShowScaledTargets", &g_bAllowShowScaled);
833 Read("AISScaledNumber", &g_ShowScaled_Num);
834 Read("AISScaledNumberWeightSOG", &g_ScaledNumWeightSOG);
835 Read("AISScaledNumberWeightCPA", &g_ScaledNumWeightCPA);
836 Read("AISScaledNumberWeightTCPA", &g_ScaledNumWeightTCPA);
837 Read("AISScaledNumberWeightRange", &g_ScaledNumWeightRange);
838 Read("AISScaledNumberWeightSizeOfTarget", &g_ScaledNumWeightSizeOfT);
839 Read("AISScaledSizeMinimal", &g_ScaledSizeMinimal);
840 Read("AISShowScaled", &g_bShowScaled);
841
842 Read("bShowAreaNotices", &g_bShowAreaNotices);
843 Read("bDrawAISSize", &g_bDrawAISSize);
844 Read("bDrawAISRealtime", &g_bDrawAISRealtime);
845 Read("bShowAISName", &g_bShowAISName);
846 Read("AISRealtimeMinSpeedKnots", &g_AIS_RealtPred_Kts, 0.7);
847 Read("bAISAlertDialog", &g_bAIS_CPA_Alert);
848 Read("ShowAISTargetNameScale", &g_Show_Target_Name_Scale);
849 Read("bWplIsAprsPositionReport", &g_bWplUsePosition);
850 Read("WplSelAction", &g_WplAction);
851 Read("AISCOGPredictorWidth", &g_ais_cog_predictor_width);
852
853 Read("bAISAlertAudio", &g_bAIS_CPA_Alert_Audio);
854 Read("AISAlertAudioFile", &g_sAIS_Alert_Sound_File);
855 Read("bAISAlertSuppressMoored", &g_bAIS_CPA_Alert_Suppress_Moored);
856
857 Read("bAISAlertAckTimeout", &g_bAIS_ACK_Timeout);
858 if (Read("AlertAckTimeoutMinutes", &s)) s.ToDouble(&g_AckTimeout_Mins);
859
860 Read("AlertDialogSizeX", &g_ais_alert_dialog_sx);
861 Read("AlertDialogSizeY", &g_ais_alert_dialog_sy);
862 Read("AlertDialogPosX", &g_ais_alert_dialog_x);
863 Read("AlertDialogPosY", &g_ais_alert_dialog_y);
864 Read("QueryDialogPosX", &g_ais_query_dialog_x);
865 Read("QueryDialogPosY", &g_ais_query_dialog_y);
866
867 Read("AISTargetListPerspective", &g_AisTargetList_perspective);
868 Read("AISTargetListRange", &g_AisTargetList_range);
869 Read("AISTargetListSortColumn", &g_AisTargetList_sortColumn);
870 Read("bAISTargetListSortReverse", &g_bAisTargetList_sortReverse);
871 Read("AISTargetListColumnSpec", &g_AisTargetList_column_spec);
872 Read("AISTargetListColumnOrder", &g_AisTargetList_column_order);
873
874 Read("bAISRolloverShowClass", &g_bAISRolloverShowClass);
875 Read("bAISRolloverShowCOG", &g_bAISRolloverShowCOG);
876 Read("bAISRolloverShowCPA", &g_bAISRolloverShowCPA);
877 Read("AISAlertDelay", &g_AIS_alert_delay);
878
879 Read("S57QueryDialogSizeX", &g_S57_dialog_sx);
880 Read("S57QueryDialogSizeY", &g_S57_dialog_sy);
881 Read("S57QueryExtraDialogSizeX", &g_S57_extradialog_sx);
882 Read("S57QueryExtraDialogSizeY", &g_S57_extradialog_sy);
883
884 wxString strpres("PresentationLibraryData");
885 wxString valpres;
886 SetPath("/Directories");
887 Read(strpres, &valpres); // Get the File name
888 if (!valpres.IsEmpty()) g_UserPresLibData = valpres;
889
890 wxString strs("SENCFileLocation");
891 SetPath("/Directories");
892 wxString vals;
893 Read(strs, &vals); // Get the Directory name
894 if (!vals.IsEmpty()) g_SENCPrefix = vals;
895
896 SetPath("/Directories");
897 wxString vald;
898 Read("InitChartDir", &vald); // Get the Directory name
899
900 wxString dirnamed(vald);
901 if (!dirnamed.IsEmpty()) {
902 if (pInit_Chart_Dir->IsEmpty()) // on second pass, don't overwrite
903 {
904 pInit_Chart_Dir->Clear();
905 pInit_Chart_Dir->Append(vald);
906 }
907 }
908
909 Read("GPXIODir", &g_gpx_path); // Get the Directory name
910 Read("TCDataDir", &g_TCData_Dir); // Get the Directory name
911 Read("BasemapDir", &gWorldMapLocation);
912 Read("BaseShapefileDir", &gWorldShapefileLocation);
913 Read("pluginInstallDir", &g_winPluginDir);
914 wxLogMessage("winPluginDir, read from ini file: %s",
915 g_winPluginDir.mb_str().data());
916
917 SetPath("/Settings/GlobalState");
918
919 Read("EnableHiconColorScheme", &g_hicon_colors, false);
920
921 if (Read("nColorScheme", &read_int)) {
922 global_color_scheme = (ColorScheme)read_int;
923
924 // Force to a color in the correct hi/lo family
925 // if necessary.
926 if (g_hicon_colors) {
927 if ((global_color_scheme != GLOBAL_COLOR_SCHEME_DAY_HICON) &&
928 (global_color_scheme != GLOBAL_COLOR_SCHEME_NIGHT_HICON))
929 global_color_scheme = GLOBAL_COLOR_SCHEME_DAY_HICON;
930 } else {
931 if ((global_color_scheme != GLOBAL_COLOR_SCHEME_DAY) &&
932 (global_color_scheme != GLOBAL_COLOR_SCHEME_NIGHT) &&
933 (global_color_scheme != GLOBAL_COLOR_SCHEME_DUSK))
934 global_color_scheme = GLOBAL_COLOR_SCHEME_DAY;
935 }
936 }
937
938 if (!bAsTemplate) {
939 SetPath("/Settings/NMEADataSource");
940
941 TheConnectionParams().clear();
942 wxString connectionconfigs;
943 Read("DataConnections", &connectionconfigs);
944 if (!connectionconfigs.IsEmpty()) {
945 wxArrayString confs = wxStringTokenize(connectionconfigs, "|");
946 for (size_t i = 0; i < confs.Count(); i++) {
947 ConnectionParams *prm = new ConnectionParams(confs[i]);
948 if (!prm->is_valid) {
949 wxLogMessage("Skipped invalid DataStream config");
950 delete prm;
951 continue;
952 }
953 TheConnectionParams().push_back(prm);
954 }
955 }
956 }
957
958 SetPath("/Settings/GlobalState");
959 wxString st;
960
961 double st_lat, st_lon;
962 if (Read("VPLatLon", &st)) {
963 sscanf(st.mb_str(wxConvUTF8), "%lf,%lf", &st_lat, &st_lon);
964
965 // Sanity check the lat/lon...both have to be reasonable.
966 if (fabs(st_lon) < 360.) {
967 while (st_lon < -180.) st_lon += 360.;
968
969 while (st_lon > 180.) st_lon -= 360.;
970
971 vLon = st_lon;
972 }
973
974 if (fabs(st_lat) < 90.0) vLat = st_lat;
975
976 s.Printf("Setting Viewpoint Lat/Lon %g, %g", vLat, vLon);
977 wxLogMessage(s);
978 }
979
980 double st_view_scale, st_rotation;
981 if (Read(wxString("VPScale"), &st)) {
982 sscanf(st.mb_str(wxConvUTF8), "%lf", &st_view_scale);
983 // Sanity check the scale
984 st_view_scale = fmax(st_view_scale, .001 / 32);
985 st_view_scale = fmin(st_view_scale, 4);
986 }
987
988 if (Read(wxString("VPRotation"), &st)) {
989 sscanf(st.mb_str(wxConvUTF8), "%lf", &st_rotation);
990 // Sanity check the rotation
991 st_rotation = fmin(st_rotation, 360);
992 st_rotation = fmax(st_rotation, 0);
993 }
994
995 wxString sll;
996 double lat, lon;
997 if (Read("OwnShipLatLon", &sll)) {
998 sscanf(sll.mb_str(wxConvUTF8), "%lf,%lf", &lat, &lon);
999
1000 // Sanity check the lat/lon...both have to be reasonable.
1001 if (fabs(lon) < 360.) {
1002 while (lon < -180.) lon += 360.;
1003
1004 while (lon > 180.) lon -= 360.;
1005
1006 gLon = lon;
1007 }
1008
1009 if (fabs(lat) < 90.0) gLat = lat;
1010
1011 s.Printf("Setting Ownship Lat/Lon %g, %g", gLat, gLon);
1012 wxLogMessage(s);
1013 }
1014
1015 // Fonts
1016
1017 // Load the persistent Auxiliary Font descriptor Keys
1018 SetPath("/Settings/AuxFontKeys");
1019
1020 wxString strk;
1021 long dummyk;
1022 wxString kval;
1023 bool bContk = GetFirstEntry(strk, dummyk);
1024 bool bNewKey = false;
1025 while (bContk) {
1026 Read(strk, &kval);
1027 bNewKey = FontMgr::Get().AddAuxKey(kval);
1028 if (!bAsTemplate && !bNewKey) {
1029 DeleteEntry(strk);
1030 dummyk--;
1031 }
1032 bContk = GetNextEntry(strk, dummyk);
1033 }
1034
1035#ifdef __WXX11__
1036 SetPath("/Settings/X11Fonts");
1037#endif
1038
1039#ifdef __WXGTK__
1040 SetPath("/Settings/GTKFonts");
1041#endif
1042
1043#ifdef __WXMSW__
1044 SetPath("/Settings/MSWFonts");
1045#endif
1046
1047#ifdef __WXMAC__
1048 SetPath("/Settings/MacFonts");
1049#endif
1050
1051#ifdef __WXQT__
1052 SetPath("/Settings/QTFonts");
1053#endif
1054
1055 wxString str;
1056 long dummy;
1057 wxString pval;
1058 wxArrayString deleteList;
1059
1060 bool bCont = GetFirstEntry(str, dummy);
1061 while (bCont) {
1062 pval = Read(str);
1063
1064 if (str.StartsWith("Font")) {
1065 // Convert pre 3.1 setting. Can't delete old entries from inside the
1066 // GetNextEntry() loop, so we need to save those and delete outside.
1067 deleteList.Add(str);
1068 wxString oldKey = pval.BeforeFirst(_T(':'));
1069 str = FontMgr::GetFontConfigKey(oldKey);
1070 }
1071
1072 if (pval.IsEmpty() || pval.StartsWith(":")) {
1073 deleteList.Add(str);
1074 } else
1075 FontMgr::Get().LoadFontNative(&str, &pval);
1076
1077 bCont = GetNextEntry(str, dummy);
1078 }
1079
1080 for (unsigned int i = 0; i < deleteList.Count(); i++) {
1081 DeleteEntry(deleteList[i]);
1082 }
1083 deleteList.Clear();
1084
1085 // Tide/Current Data Sources
1086 SetPath("/TideCurrentDataSources");
1087 if (GetNumberOfEntries()) {
1088 TideCurrentDataSet.clear();
1089 wxString str, val;
1090 long dummy;
1091 bool bCont = GetFirstEntry(str, dummy);
1092 while (bCont) {
1093 Read(str, &val); // Get a file name and add it to the list just in case
1094 // it is not repeated
1095 // We have seen duplication of dataset entries in
1096 // https://github.com/OpenCPN/OpenCPN/issues/3042, this effectively gets
1097 // rid of them.
1098 if (std::find(TideCurrentDataSet.begin(), TideCurrentDataSet.end(),
1099 val.ToStdString()) == TideCurrentDataSet.end()) {
1100 TideCurrentDataSet.push_back(val.ToStdString());
1101 }
1102 bCont = GetNextEntry(str, dummy);
1103 }
1104 }
1105
1106 // Groups
1107 LoadConfigGroups(g_pGroupArray);
1108
1109 // // Multicanvas Settings
1110 // LoadCanvasConfigs();
1111
1112 SetPath("/Settings/Others");
1113
1114 // Radar rings
1115 Read("RadarRingsNumberVisible", &val);
1116 if (val.Length() > 0) g_iNavAidRadarRingsNumberVisible = atoi(val.mb_str());
1117 g_bNavAidRadarRingsShown = g_iNavAidRadarRingsNumberVisible > 0;
1118
1119 Read("RadarRingsStep", &val);
1120 if (val.Length() > 0) g_fNavAidRadarRingsStep = atof(val.mb_str());
1121
1122 Read("RadarRingsStepUnits", &g_pNavAidRadarRingsStepUnits);
1123
1124 wxString l_wxsOwnshipRangeRingsColour;
1125 Read("RadarRingsColour", &l_wxsOwnshipRangeRingsColour);
1126 if (l_wxsOwnshipRangeRingsColour.Length())
1127 g_colourOwnshipRangeRingsColour.Set(l_wxsOwnshipRangeRingsColour);
1128
1129 // Waypoint Radar rings
1130 Read("WaypointRangeRingsNumber", &val);
1131 if (val.Length() > 0) g_iWaypointRangeRingsNumber = atoi(val.mb_str());
1132
1133 Read("WaypointRangeRingsStep", &val);
1134 if (val.Length() > 0) g_fWaypointRangeRingsStep = atof(val.mb_str());
1135
1136 Read("WaypointRangeRingsStepUnits", &g_iWaypointRangeRingsStepUnits);
1137
1138 wxString l_wxsWaypointRangeRingsColour;
1139 Read("WaypointRangeRingsColour", &l_wxsWaypointRangeRingsColour);
1140 g_colourWaypointRangeRingsColour.Set(l_wxsWaypointRangeRingsColour);
1141
1142 if (!Read("WaypointUseScaMin", &g_bUseWptScaMin)) g_bUseWptScaMin = false;
1143 if (!Read("WaypointScaMinValue", &g_iWpt_ScaMin)) g_iWpt_ScaMin = 2147483646;
1144 if (!Read("WaypointScaMaxValue", &g_iWpt_ScaMax)) g_iWpt_ScaMax = 0;
1145 if (!Read("WaypointUseScaMinOverrule", &g_bOverruleScaMin))
1146 g_bOverruleScaMin = false;
1147 if (!Read("WaypointsShowName", &g_bShowWptName)) g_bShowWptName = true;
1148 if (!Read("UserIconsFirst", &g_bUserIconsFirst)) g_bUserIconsFirst = true;
1149
1150 // Support Version 3.0 and prior config setting for Radar Rings
1151 bool b300RadarRings = true;
1152 if (Read("ShowRadarRings", &b300RadarRings)) {
1153 if (!b300RadarRings) g_iNavAidRadarRingsNumberVisible = 0;
1154 }
1155
1156 Read("ConfirmObjectDeletion", &g_bConfirmObjectDelete);
1157
1158 // Waypoint dragging with mouse
1159 g_bWayPointPreventDragging = false;
1160 Read("WaypointPreventDragging", &g_bWayPointPreventDragging);
1161
1162 g_bEnableZoomToCursor = false;
1163 Read("EnableZoomToCursor", &g_bEnableZoomToCursor);
1164
1165 val.Clear();
1166 Read("TrackIntervalSeconds", &val);
1167 if (val.Length() > 0) {
1168 double tval = atof(val.mb_str());
1169 if (tval >= 2.) g_TrackIntervalSeconds = tval;
1170 }
1171
1172 val.Clear();
1173 Read("TrackDeltaDistance", &val);
1174 if (val.Length() > 0) {
1175 double tval = atof(val.mb_str());
1176 if (tval >= 0.05) g_TrackDeltaDistance = tval;
1177 }
1178
1179 Read("TrackPrecision", &g_nTrackPrecision);
1180
1181 Read("RouteLineWidth", &g_route_line_width);
1182 Read("TrackLineWidth", &g_track_line_width);
1183
1184 wxString l_wxsTrackLineColour;
1185 if (Read("TrackLineColour", &l_wxsTrackLineColour))
1186 g_colourTrackLineColour.Set(l_wxsTrackLineColour);
1187
1188 Read("TideCurrentWindowScale", &g_tcwin_scale);
1189 Read("DefaultWPIcon", &g_default_wp_icon);
1190 Read("DataMonitorLogfile", &g_dm_logfile);
1191 Read("DefaultRPIcon", &g_default_routepoint_icon);
1192
1193 SetPath("/MmsiProperties");
1194 int iPMax = GetNumberOfEntries();
1195 if (iPMax) {
1196 g_MMSI_Props_Array.Empty();
1197 wxString str, val;
1198 long dummy;
1199 bool bCont = pConfig->GetFirstEntry(str, dummy);
1200 while (bCont) {
1201 pConfig->Read(str, &val); // Get an entry
1202
1203 MmsiProperties *pProps = new MmsiProperties(val);
1204 g_MMSI_Props_Array.Add(pProps);
1205
1206 bCont = pConfig->GetNextEntry(str, dummy);
1207 }
1208 }
1209
1210 SetPath("/DataMonitor");
1211 g_dm_ok = ReadUnsigned("colors.ok", kUndefinedColor);
1212 g_dm_dropped = ReadUnsigned("colors.dropped", kUndefinedColor);
1213 g_dm_filtered = ReadUnsigned("colors.filtered", kUndefinedColor);
1214 g_dm_input = ReadUnsigned("colors.input", kUndefinedColor);
1215 g_dm_output = ReadUnsigned("colors.output", kUndefinedColor);
1216 g_dm_not_ok = ReadUnsigned("colors.not-ok", kUndefinedColor);
1217
1218 return 0;
1219}
1220
1221void MyConfig::LoadS57Config() {
1222 if (!ps52plib) return;
1223
1224 int read_int;
1225 double dval;
1226 SetPath("/Settings/GlobalState");
1227
1228 Read("bShowS57Text", &read_int, 1);
1229 ps52plib->SetShowS57Text(!(read_int == 0));
1230
1231 Read("bShowS57ImportantTextOnly", &read_int, 0);
1232 ps52plib->SetShowS57ImportantTextOnly(!(read_int == 0));
1233
1234 Read("bShowLightDescription", &read_int, 0);
1235 ps52plib->SetShowLdisText(!(read_int == 0));
1236
1237 Read("bExtendLightSectors", &read_int, 0);
1238 ps52plib->SetExtendLightSectors(!(read_int == 0));
1239
1240 Read("nDisplayCategory", &read_int, (enum _DisCat)STANDARD);
1241 ps52plib->SetDisplayCategory((enum _DisCat)read_int);
1242
1243 Read("nSymbolStyle", &read_int, (enum _LUPname)PAPER_CHART);
1244 ps52plib->m_nSymbolStyle = (LUPname)read_int;
1245
1246 Read("nBoundaryStyle", &read_int, PLAIN_BOUNDARIES);
1247 ps52plib->m_nBoundaryStyle = (LUPname)read_int;
1248
1249 Read("bShowSoundg", &read_int, 1);
1250 ps52plib->m_bShowSoundg = !(read_int == 0);
1251
1252 Read("bShowMeta", &read_int, 0);
1253 ps52plib->m_bShowMeta = !(read_int == 0);
1254
1255 Read("bUseSCAMIN", &read_int, 1);
1256 ps52plib->m_bUseSCAMIN = !(read_int == 0);
1257
1258 Read("bUseSUPER_SCAMIN", &read_int, 0);
1259 ps52plib->m_bUseSUPER_SCAMIN = !(read_int == 0);
1260
1261 Read("bShowAtonText", &read_int, 1);
1262 ps52plib->m_bShowAtonText = !(read_int == 0);
1263
1264 Read("bDeClutterText", &read_int, 0);
1265 ps52plib->m_bDeClutterText = !(read_int == 0);
1266
1267 Read("bShowNationalText", &read_int, 0);
1268 ps52plib->m_bShowNationalTexts = !(read_int == 0);
1269
1270 Read("ENCSoundingScaleFactor", &read_int, 0);
1271 ps52plib->m_nSoundingFactor = read_int;
1272
1273 Read("ENCTextScaleFactor", &read_int, 0);
1274 ps52plib->m_nTextFactor = read_int;
1275
1276 if (Read("S52_MAR_SAFETY_CONTOUR", &dval, 3.0)) {
1277 S52_setMarinerParam(S52_MAR_SAFETY_CONTOUR, dval);
1278 S52_setMarinerParam(S52_MAR_SAFETY_DEPTH,
1279 dval); // Set safety_contour and safety_depth the same
1280 }
1281
1282 if (Read("S52_MAR_SHALLOW_CONTOUR", &dval, 2.0))
1283 S52_setMarinerParam(S52_MAR_SHALLOW_CONTOUR, dval);
1284
1285 if (Read("S52_MAR_DEEP_CONTOUR", &dval, 6.0))
1286 S52_setMarinerParam(S52_MAR_DEEP_CONTOUR, dval);
1287
1288 if (Read("S52_MAR_TWO_SHADES", &dval, 0.0))
1289 S52_setMarinerParam(S52_MAR_TWO_SHADES, dval);
1290
1291 ps52plib->UpdateMarinerParams();
1292
1293 SetPath("/Settings/GlobalState");
1294 Read("S52_DEPTH_UNIT_SHOW", &read_int, 1); // default is metres
1295 read_int = wxMax(read_int, 0); // qualify value
1296 read_int = wxMin(read_int, 2);
1297 ps52plib->m_nDepthUnitDisplay = read_int;
1298 g_nDepthUnitDisplay = read_int;
1299
1300 // S57 Object Class Visibility
1301
1302 OBJLElement *pOLE;
1303
1304 SetPath("/Settings/ObjectFilter");
1305
1306 int iOBJMax = GetNumberOfEntries();
1307 if (iOBJMax) {
1308 wxString str;
1309 long val;
1310 long dummy;
1311
1312 wxString sObj;
1313
1314 bool bCont = pConfig->GetFirstEntry(str, dummy);
1315 while (bCont) {
1316 pConfig->Read(str, &val); // Get an Object Viz
1317
1318 bool bNeedNew = true;
1319
1320 if (str.StartsWith("viz", &sObj)) {
1321 for (unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
1322 iPtr++) {
1323 pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
1324 if (!strncmp(pOLE->OBJLName, sObj.mb_str(), 6)) {
1325 pOLE->nViz = val;
1326 bNeedNew = false;
1327 break;
1328 }
1329 }
1330
1331 if (bNeedNew) {
1332 pOLE = (OBJLElement *)calloc(sizeof(OBJLElement), 1);
1333 memcpy(pOLE->OBJLName, sObj.mb_str(), OBJL_NAME_LEN);
1334 pOLE->nViz = 1;
1335
1336 ps52plib->pOBJLArray->Add((void *)pOLE);
1337 }
1338 }
1339 bCont = pConfig->GetNextEntry(str, dummy);
1340 }
1341 }
1342}
1343
1344bool MyConfig::LoadLayers(wxString &path) {
1345 wxArrayString file_array;
1346 wxDir dir;
1347 Layer *l;
1348 dir.Open(path);
1349 if (dir.IsOpened()) {
1350 wxString filename;
1351 bool cont = dir.GetFirst(&filename);
1352 while (cont) {
1353 file_array.Clear();
1354 filename.Prepend(wxFileName::GetPathSeparator());
1355 filename.Prepend(path);
1356 wxFileName f(filename);
1357 size_t nfiles = 0;
1358 if (f.GetExt().IsSameAs("gpx"))
1359 file_array.Add(filename); // single-gpx-file layer
1360 else {
1361 if (wxDir::Exists(filename)) {
1362 wxDir dir(filename);
1363 if (dir.IsOpened()) {
1364 nfiles = dir.GetAllFiles(filename, &file_array,
1365 "*.gpx"); // layers subdirectory set
1366 }
1367 }
1368 }
1369
1370 if (file_array.GetCount()) {
1371 l = new Layer();
1372 l->m_LayerID = ++g_LayerIdx;
1373 l->m_LayerFileName = file_array[0];
1374 if (file_array.GetCount() <= 1)
1375 wxFileName::SplitPath(file_array[0], NULL, NULL, &(l->m_LayerName),
1376 NULL, NULL);
1377 else
1378 wxFileName::SplitPath(filename, NULL, NULL, &(l->m_LayerName), NULL,
1379 NULL);
1380
1381 bool bLayerViz = g_bShowLayers;
1382
1383 if (g_VisibleLayers.Contains(l->m_LayerName)) bLayerViz = true;
1384 if (g_InvisibleLayers.Contains(l->m_LayerName)) bLayerViz = false;
1385
1386 l->m_bHasVisibleNames = wxCHK_UNDETERMINED;
1387 if (g_VisiNameinLayers.Contains(l->m_LayerName))
1388 l->m_bHasVisibleNames = wxCHK_CHECKED;
1389 if (g_InVisiNameinLayers.Contains(l->m_LayerName))
1390 l->m_bHasVisibleNames = wxCHK_UNCHECKED;
1391
1392 l->m_bIsVisibleOnChart = bLayerViz;
1393
1394 wxString laymsg;
1395 laymsg.Printf("New layer %d: %s", l->m_LayerID, l->m_LayerName.c_str());
1396 wxLogMessage(laymsg);
1397
1398 pLayerList->insert(pLayerList->begin(), l);
1399
1400 // Load the entire file array as a single layer
1401
1402 for (unsigned int i = 0; i < file_array.GetCount(); i++) {
1403 wxString file_path = file_array[i];
1404
1405 if (::wxFileExists(file_path)) {
1406 NavObjectCollection1 *pSet = new NavObjectCollection1;
1407 pugi::xml_parse_result result = pSet->load_file(file_path.fn_str());
1408 if (!result) {
1409 wxLogMessage("Error loading GPX file " + file_path);
1410 wxMessageBox(
1411 wxString::Format(
1412 _("Error loading GPX file %s, %s at character %d"),
1413 file_path, result.description(), result.offset),
1414 _("Import GPX File"));
1415 pSet->reset();
1416 }
1417 long nItems = pSet->LoadAllGPXObjectsAsLayer(
1418 l->m_LayerID, bLayerViz, l->m_bHasVisibleNames);
1419 l->m_NoOfItems += nItems;
1420 l->m_LayerType = _("Persistent");
1421
1422 wxString objmsg;
1423 objmsg.Printf("Loaded GPX file %s with %ld items.",
1424 file_path.c_str(), nItems);
1425 wxLogMessage(objmsg);
1426
1427 delete pSet;
1428 }
1429 }
1430 }
1431
1432 cont = dir.GetNext(&filename);
1433 }
1434 }
1435 g_bLayersLoaded = true;
1436
1437 return true;
1438}
1439
1440bool MyConfig::LoadChartDirArray(ArrayOfCDI &ChartDirArray) {
1441 // Chart Directories
1442 SetPath("/ChartDirectories");
1443 int iDirMax = GetNumberOfEntries();
1444 if (iDirMax) {
1445 ChartDirArray.Empty();
1446 wxString str, val;
1447 long dummy;
1448 int nAdjustChartDirs = 0;
1449 int iDir = 0;
1450 bool bCont = pConfig->GetFirstEntry(str, dummy);
1451 while (bCont) {
1452 pConfig->Read(str, &val); // Get a Directory name
1453
1454 wxString dirname(val);
1455 if (!dirname.IsEmpty()) {
1456 /* Special case for first time run after Windows install with sample
1457 chart data... We desire that the sample configuration file opencpn.ini
1458 should not contain any installation dependencies, so... Detect and
1459 update the sample [ChartDirectories] entries to point to the Shared
1460 Data directory For instance, if the (sample) opencpn.ini file should
1461 contain shortcut coded entries like:
1462
1463 [ChartDirectories]
1464 ChartDir1=SampleCharts\\MaptechRegion7
1465
1466 then this entry will be updated to be something like:
1467 ChartDir1=c:\Program Files\opencpn\SampleCharts\\MaptechRegion7
1468
1469 */
1470 if (dirname.Find("SampleCharts") ==
1471 0) // only update entries starting with "SampleCharts"
1472 {
1473 nAdjustChartDirs++;
1474
1475 pConfig->DeleteEntry(str);
1476 wxString new_dir = dirname.Mid(dirname.Find("SampleCharts"));
1477 new_dir.Prepend(g_Platform->GetSharedDataDir());
1478 dirname = new_dir;
1479 }
1480
1481 ChartDirInfo cdi;
1482 cdi.fullpath = dirname.BeforeFirst('^');
1483 cdi.magic_number = dirname.AfterFirst('^');
1484
1485 ChartDirArray.Add(cdi);
1486 iDir++;
1487 }
1488
1489 bCont = pConfig->GetNextEntry(str, dummy);
1490 }
1491
1492 if (nAdjustChartDirs) pConfig->UpdateChartDirs(ChartDirArray);
1493 }
1494
1495 return true;
1496}
1497
1498bool MyConfig::UpdateChartDirs(ArrayOfCDI &dir_array) {
1499 wxString key, dir;
1500 wxString str_buf;
1501
1502 SetPath("/ChartDirectories");
1503 int iDirMax = GetNumberOfEntries();
1504 if (iDirMax) {
1505 long dummy;
1506
1507 for (int i = 0; i < iDirMax; i++) {
1508 GetFirstEntry(key, dummy);
1509 DeleteEntry(key, false);
1510 }
1511 }
1512
1513 iDirMax = dir_array.GetCount();
1514
1515 for (int iDir = 0; iDir < iDirMax; iDir++) {
1516 ChartDirInfo cdi = dir_array[iDir];
1517
1518 wxString dirn = cdi.fullpath;
1519 dirn.Append("^");
1520 dirn.Append(cdi.magic_number);
1521
1522 str_buf.Printf("ChartDir%d", iDir + 1);
1523
1524 Write(str_buf, dirn);
1525 }
1526
1527// Avoid nonsense log errors...
1528#ifdef __ANDROID__
1529 wxLogNull logNo;
1530#endif
1531
1532 Flush();
1533 return true;
1534}
1535
1536void MyConfig::CreateConfigGroups(ChartGroupArray *pGroupArray) {
1537 if (!pGroupArray) return;
1538
1539 SetPath("/Groups");
1540 Write("GroupCount", (int)pGroupArray->GetCount());
1541
1542 for (unsigned int i = 0; i < pGroupArray->GetCount(); i++) {
1543 ChartGroup *pGroup = pGroupArray->Item(i);
1544 wxString s;
1545 s.Printf("Group%d", i + 1);
1546 s.Prepend("/Groups/");
1547 SetPath(s);
1548
1549 Write("GroupName", pGroup->m_group_name);
1550 Write("GroupItemCount", (int)pGroup->m_element_array.size());
1551
1552 for (unsigned int j = 0; j < pGroup->m_element_array.size(); j++) {
1553 wxString sg;
1554 sg.Printf("Group%d/Item%d", i + 1, j);
1555 sg.Prepend("/Groups/");
1556 SetPath(sg);
1557 Write("IncludeItem", pGroup->m_element_array[j].m_element_name);
1558
1559 wxString t;
1560 wxArrayString u = pGroup->m_element_array[j].m_missing_name_array;
1561 if (u.GetCount()) {
1562 for (unsigned int k = 0; k < u.GetCount(); k++) {
1563 t += u[k];
1564 t += ";";
1565 }
1566 Write("ExcludeItems", t);
1567 }
1568 }
1569 }
1570}
1571
1572void MyConfig::DestroyConfigGroups() {
1573 DeleteGroup("/Groups"); // zap
1574}
1575
1576void MyConfig::LoadConfigGroups(ChartGroupArray *pGroupArray) {
1577 SetPath("/Groups");
1578 unsigned int group_count;
1579 Read("GroupCount", (int *)&group_count, 0);
1580
1581 for (unsigned int i = 0; i < group_count; i++) {
1582 ChartGroup *pGroup = new ChartGroup;
1583 wxString s;
1584 s.Printf("Group%d", i + 1);
1585 s.Prepend("/Groups/");
1586 SetPath(s);
1587
1588 wxString t;
1589 Read("GroupName", &t);
1590 pGroup->m_group_name = t;
1591
1592 unsigned int item_count;
1593 Read("GroupItemCount", (int *)&item_count);
1594 for (unsigned int j = 0; j < item_count; j++) {
1595 wxString sg;
1596 sg.Printf("Group%d/Item%d", i + 1, j);
1597 sg.Prepend("/Groups/");
1598 SetPath(sg);
1599
1600 wxString v;
1601 Read("IncludeItem", &v);
1602
1603 ChartGroupElement pelement{v};
1604 wxString u;
1605 if (Read("ExcludeItems", &u)) {
1606 if (!u.IsEmpty()) {
1607 wxStringTokenizer tk(u, ";");
1608 while (tk.HasMoreTokens()) {
1609 wxString token = tk.GetNextToken();
1610 pelement.m_missing_name_array.Add(token);
1611 }
1612 }
1613 }
1614 pGroup->m_element_array.push_back(std::move(pelement));
1615 }
1616 pGroupArray->Add(pGroup);
1617 }
1618}
1619
1620void MyConfig::LoadCanvasConfigs(bool bApplyAsTemplate) {
1621 wxString s;
1622 canvasConfig *pcc;
1623 auto &config_array = ConfigMgr::Get().GetCanvasConfigArray();
1624
1625 SetPath("/Canvas");
1626
1627 // If the canvas config has never been set/persisted, use the global settings
1628 if (!HasEntry("CanvasConfig")) {
1629 pcc = new canvasConfig(0);
1630 pcc->LoadFromLegacyConfig(this);
1631 config_array.Add(pcc);
1632
1633 return;
1634 }
1635
1636 Read("CanvasConfig", (int *)&g_canvasConfig, 0);
1637
1638 // Do not recreate canvasConfigs when applying config dynamically
1639 if (config_array.GetCount() == 0) { // This is initial load from startup
1640 s.Printf("/Canvas/CanvasConfig%d", 1);
1641 SetPath(s);
1642 canvasConfig *pcca = new canvasConfig(0);
1643 LoadConfigCanvas(pcca, bApplyAsTemplate);
1644 config_array.Add(pcca);
1645
1646 s.Printf("/Canvas/CanvasConfig%d", 2);
1647 SetPath(s);
1648 pcca = new canvasConfig(1);
1649 LoadConfigCanvas(pcca, bApplyAsTemplate);
1650 config_array.Add(pcca);
1651 } else { // This is a dynamic (i.e. Template) load
1652 canvasConfig *pcca = config_array[0];
1653 s.Printf("/Canvas/CanvasConfig%d", 1);
1654 SetPath(s);
1655 LoadConfigCanvas(pcca, bApplyAsTemplate);
1656
1657 if (config_array.GetCount() > 1) {
1658 canvasConfig *pcca = config_array[1];
1659 s.Printf("/Canvas/CanvasConfig%d", 2);
1660 SetPath(s);
1661 LoadConfigCanvas(pcca, bApplyAsTemplate);
1662 } else {
1663 s.Printf("/Canvas/CanvasConfig%d", 2);
1664 SetPath(s);
1665 pcca = new canvasConfig(1);
1666 LoadConfigCanvas(pcca, bApplyAsTemplate);
1667 config_array.Add(pcca);
1668 }
1669 }
1670}
1671
1672void MyConfig::LoadConfigCanvas(canvasConfig *cConfig, bool bApplyAsTemplate) {
1673 wxString st;
1674 double st_lat, st_lon;
1675
1676 if (!bApplyAsTemplate) {
1677 // Reasonable starting point
1678 cConfig->iLat = START_LAT; // display viewpoint
1679 cConfig->iLon = START_LON;
1680
1681 if (Read("canvasVPLatLon", &st)) {
1682 sscanf(st.mb_str(wxConvUTF8), "%lf,%lf", &st_lat, &st_lon);
1683
1684 // Sanity check the lat/lon...both have to be reasonable.
1685 if (fabs(st_lon) < 360.) {
1686 while (st_lon < -180.) st_lon += 360.;
1687
1688 while (st_lon > 180.) st_lon -= 360.;
1689
1690 cConfig->iLon = st_lon;
1691 }
1692
1693 if (fabs(st_lat) < 90.0) cConfig->iLat = st_lat;
1694 }
1695
1696 cConfig->iScale = .0003; // decent initial value
1697 cConfig->iRotation = 0;
1698
1699 double st_view_scale;
1700 if (Read(wxString("canvasVPScale"), &st)) {
1701 sscanf(st.mb_str(wxConvUTF8), "%lf", &st_view_scale);
1702 // Sanity check the scale
1703 st_view_scale = fmax(st_view_scale, .001 / 32);
1704 st_view_scale = fmin(st_view_scale, 4);
1705 cConfig->iScale = st_view_scale;
1706 }
1707
1708 double st_rotation;
1709 if (Read(wxString("canvasVPRotation"), &st)) {
1710 sscanf(st.mb_str(wxConvUTF8), "%lf", &st_rotation);
1711 // Sanity check the rotation
1712 st_rotation = fmin(st_rotation, 360);
1713 st_rotation = fmax(st_rotation, 0);
1714 cConfig->iRotation = st_rotation * PI / 180.;
1715 }
1716
1717 Read("canvasInitialdBIndex", &cConfig->DBindex, 0);
1718 Read("canvasbFollow", &cConfig->bFollow, 0);
1719
1720 Read("canvasCourseUp", &cConfig->bCourseUp, 0);
1721 Read("canvasHeadUp", &cConfig->bHeadUp, 0);
1722 Read("canvasLookahead", &cConfig->bLookahead, 0);
1723 }
1724
1725 Read("ActiveChartGroup", &cConfig->GroupID, 0);
1726
1727 // Special check for group selection when applied as template
1728 if (cConfig->GroupID && bApplyAsTemplate) {
1729 if (cConfig->GroupID > (int)g_pGroupArray->GetCount()) cConfig->GroupID = 0;
1730 }
1731
1732 Read("canvasShowTides", &cConfig->bShowTides, 0);
1733 Read("canvasShowCurrents", &cConfig->bShowCurrents, 0);
1734
1735 Read("canvasEnableBasemapTile", &cConfig->bEnableBasemapTile, 1);
1736
1737 Read("canvasQuilt", &cConfig->bQuilt, 1);
1738 Read("canvasShowGrid", &cConfig->bShowGrid, 0);
1739 Read("canvasShowOutlines", &cConfig->bShowOutlines, 0);
1740 Read("canvasShowDepthUnits", &cConfig->bShowDepthUnits, 0);
1741
1742 Read("canvasShowAIS", &cConfig->bShowAIS, 1);
1743 Read("canvasAttenAIS", &cConfig->bAttenAIS, 0);
1744
1745 // ENC options
1746 Read("canvasShowENCText", &cConfig->bShowENCText, 1);
1747 Read("canvasENCDisplayCategory", &cConfig->nENCDisplayCategory, STANDARD);
1748 Read("canvasENCShowDepths", &cConfig->bShowENCDepths, 1);
1749 Read("canvasENCShowBuoyLabels", &cConfig->bShowENCBuoyLabels, 1);
1750 Read("canvasENCShowLightDescriptions", &cConfig->bShowENCLightDescriptions,
1751 1);
1752 Read("canvasENCShowLights", &cConfig->bShowENCLights, 1);
1753 Read("canvasENCShowVisibleSectorLights",
1754 &cConfig->bShowENCVisibleSectorLights, 0);
1755 Read("canvasENCShowAnchorInfo", &cConfig->bShowENCAnchorInfo, 0);
1756 Read("canvasENCShowDataQuality", &cConfig->bShowENCDataQuality, 0);
1757
1758 int sx, sy;
1759 Read("canvasSizeX", &sx, 0);
1760 Read("canvasSizeY", &sy, 0);
1761 cConfig->canvasSize = wxSize(sx, sy);
1762}
1763
1764void MyConfig::SaveCanvasConfigs() {
1765 auto &config_array = ConfigMgr::Get().GetCanvasConfigArray();
1766
1767 SetPath("/Canvas");
1768 Write("CanvasConfig", (int)g_canvasConfig);
1769
1770 wxString s;
1771 canvasConfig *pcc;
1772
1773 switch (g_canvasConfig) {
1774 case 0:
1775 default:
1776
1777 s.Printf("/Canvas/CanvasConfig%d", 1);
1778 SetPath(s);
1779
1780 if (config_array.GetCount() > 0) {
1781 pcc = config_array.Item(0);
1782 if (pcc) {
1783 SaveConfigCanvas(pcc);
1784 }
1785 }
1786 break;
1787
1788 case 1:
1789
1790 if (config_array.GetCount() > 1) {
1791 s.Printf("/Canvas/CanvasConfig%d", 1);
1792 SetPath(s);
1793 pcc = config_array.Item(0);
1794 if (pcc) {
1795 SaveConfigCanvas(pcc);
1796 }
1797
1798 s.Printf("/Canvas/CanvasConfig%d", 2);
1799 SetPath(s);
1800 pcc = config_array.Item(1);
1801 if (pcc) {
1802 SaveConfigCanvas(pcc);
1803 }
1804 }
1805 break;
1806 }
1807}
1808
1809void MyConfig::SaveConfigCanvas(canvasConfig *cConfig) {
1810 wxString st1;
1811
1812 if (cConfig->canvas) {
1813 ViewPort vp = cConfig->canvas->GetVP();
1814
1815 if (vp.IsValid()) {
1816 st1.Printf("%10.4f,%10.4f", vp.clat, vp.clon);
1817 Write("canvasVPLatLon", st1);
1818 st1.Printf("%g", vp.view_scale_ppm);
1819 Write("canvasVPScale", st1);
1820 st1.Printf("%i", ((int)(vp.rotation * 180 / PI)) % 360);
1821 Write("canvasVPRotation", st1);
1822 }
1823
1824 int restore_dbindex = 0;
1825 ChartStack *pcs = cConfig->canvas->GetpCurrentStack();
1826 if (pcs) restore_dbindex = pcs->GetCurrentEntrydbIndex();
1827 if (cConfig->canvas->GetQuiltMode())
1828 restore_dbindex = cConfig->canvas->GetQuiltReferenceChartIndex();
1829 Write("canvasInitialdBIndex", restore_dbindex);
1830
1831 Write("canvasbFollow", cConfig->canvas->m_bFollow);
1832 Write("ActiveChartGroup", cConfig->canvas->m_groupIndex);
1833
1834 Write("canvasQuilt", cConfig->canvas->GetQuiltMode());
1835 Write("canvasShowGrid", cConfig->canvas->GetShowGrid());
1836 Write("canvasShowOutlines", cConfig->canvas->GetShowOutlines());
1837 Write("canvasShowDepthUnits", cConfig->canvas->GetShowDepthUnits());
1838
1839 Write("canvasShowAIS", cConfig->canvas->GetShowAIS());
1840 Write("canvasAttenAIS", cConfig->canvas->GetAttenAIS());
1841
1842 Write("canvasShowTides", cConfig->canvas->GetbShowTide());
1843 Write("canvasShowCurrents", cConfig->canvas->GetbShowCurrent());
1844
1845 Write("canvasEnableBasemapTile", cConfig->canvas->GetbEnableBasemapTile());
1846
1847 // ENC options
1848 Write("canvasShowENCText", cConfig->canvas->GetShowENCText());
1849 Write("canvasENCDisplayCategory", cConfig->canvas->GetENCDisplayCategory());
1850 Write("canvasENCShowDepths", cConfig->canvas->GetShowENCDepth());
1851 Write("canvasENCShowBuoyLabels", cConfig->canvas->GetShowENCBuoyLabels());
1852 Write("canvasENCShowLightDescriptions",
1853 cConfig->canvas->GetShowENCLightDesc());
1854 Write("canvasENCShowLights", cConfig->canvas->GetShowENCLights());
1855 Write("canvasENCShowVisibleSectorLights",
1856 cConfig->canvas->GetShowVisibleSectors());
1857 Write("canvasENCShowAnchorInfo", cConfig->canvas->GetShowENCAnchor());
1858 Write("canvasENCShowDataQuality", cConfig->canvas->GetShowENCDataQual());
1859 Write("canvasCourseUp", cConfig->canvas->GetUpMode() == COURSE_UP_MODE);
1860 Write("canvasHeadUp", cConfig->canvas->GetUpMode() == HEAD_UP_MODE);
1861 Write("canvasLookahead", cConfig->canvas->GetLookahead());
1862
1863 int width = cConfig->canvas->GetSize().x;
1864 // if(cConfig->canvas->IsPrimaryCanvas()){
1865 // width = wxMax(width, gFrame->GetClientSize().x / 10);
1866 // }
1867 // else{
1868 // width = wxMin(width, gFrame->GetClientSize().x * 9 / 10);
1869 // }
1870
1871 Write("canvasSizeX", width);
1872 Write("canvasSizeY", cConfig->canvas->GetSize().y);
1873 }
1874}
1875
1876void MyConfig::UpdateSettings() {
1877 // Temporarily suppress logging of trivial non-fatal wxLogSysError() messages
1878 // provoked by Android security...
1879#ifdef __ANDROID__
1880 wxLogNull logNo;
1881#endif
1882
1883 // Global options and settings
1884 SetPath("/Settings");
1885
1886 Write("LastAppliedTemplate", g_lastAppliedTemplateGUID);
1887 Write("CompatOS", g_compatOS);
1888 Write("CompatOsVersion", g_compatOsVersion);
1889 Write("ConfigVersionString", g_config_version_string);
1890 if (wxIsEmpty(g_CmdSoundString)) g_CmdSoundString = wxString(OCPN_SOUND_CMD);
1891 Write("CmdSoundString", g_CmdSoundString);
1892 Write("NavMessageShown", n_NavMessageShown);
1893 Write("InlandEcdis", g_bInlandEcdis);
1894
1895 Write("AndroidVersionCode", g_AndroidVersionCode);
1896
1897 Write("UIexpert", g_bUIexpert);
1898 Write("SpaceDropMark", g_bSpaceDropMark);
1899 // Write( "UIStyle", g_StyleManager->GetStyleNextInvocation() );
1900 // //Not desired for O5 MUI
1901
1902 Write("ShowStatusBar", g_bShowStatusBar);
1903#ifndef __WXOSX__
1904 Write("ShowMenuBar", g_bShowMenuBar);
1905#endif
1906 Write("DefaultFontSize", g_default_font_size);
1907 Write("DefaultFontFacename", g_default_font_facename);
1908
1909 Write("Fullscreen", g_bFullscreen);
1910 Write("ShowCompassWindow", g_bShowCompassWin);
1911 Write("SetSystemTime", s_bSetSystemTime);
1912 Write("ShowGrid", g_bDisplayGrid);
1913 Write("PlayShipsBells", g_bPlayShipsBells);
1914 Write("SoundDeviceIndex", g_iSoundDeviceIndex);
1915 Write("FullscreenToolbar", g_bFullscreenToolbar);
1916 Write("TransparentToolbar", g_bTransparentToolbar);
1917 Write("PermanentMOBIcon", g_bPermanentMOBIcon);
1918 Write("ShowLayers", g_bShowLayers);
1919 Write("AutoAnchorDrop", g_bAutoAnchorMark);
1920 Write("ShowChartOutlines", g_bShowOutlines);
1921 Write("ShowActiveRouteTotal", g_bShowRouteTotal);
1922 Write("ShowActiveRouteHighway", g_bShowActiveRouteHighway);
1923 Write("SDMMFormat", g_iSDMMFormat);
1924 Write("MostRecentGPSUploadConnection", g_uploadConnection);
1925 Write("ShowChartBar", g_bShowChartBar);
1926
1927 Write("GUIScaleFactor", g_GUIScaleFactor);
1928 Write("ChartObjectScaleFactor", g_ChartScaleFactor);
1929 Write("ShipScaleFactor", g_ShipScaleFactor);
1930 Write("ENCSoundingScaleFactor", g_ENCSoundingScaleFactor);
1931 Write("ENCTextScaleFactor", g_ENCTextScaleFactor);
1932 Write("ObjQueryAppendFilesExt", g_ObjQFileExt);
1933
1934 // Plugin catalog persistent values.
1935 Write("CatalogCustomURL", g_catalog_custom_url);
1936 Write("CatalogChannel", g_catalog_channel);
1937
1938 Write("NetmaskBits", g_netmask_bits);
1939 Write("FilterNMEA_Avg", g_bfilter_cogsog);
1940 Write("FilterNMEA_Sec", g_COGFilterSec);
1941
1942 Write("TrackContinuous", g_btrackContinuous);
1943
1944 Write("ShowTrue", g_bShowTrue);
1945 Write("ShowMag", g_bShowMag);
1946 Write("UserMagVariation", wxString::Format("%.2f", g_UserVar));
1947
1948 Write("CM93DetailFactor", g_cm93_zoom_factor);
1949 Write("CM93DetailZoomPosX", g_detailslider_dialog_x);
1950 Write("CM93DetailZoomPosY", g_detailslider_dialog_y);
1951 Write("ShowCM93DetailSlider", g_bShowDetailSlider);
1952
1953 Write("SkewToNorthUp", g_bskew_comp);
1954 if (!g_bdisable_opengl) { // Only modify the saved value if OpenGL is not
1955 // force-disabled from the command line
1956 Write("OpenGL", g_bopengl);
1957 }
1958 Write("SoftwareGL", g_bSoftwareGL);
1959
1960 Write("ZoomDetailFactor", g_chart_zoom_modifier_raster);
1961 Write("ZoomDetailFactorVector", g_chart_zoom_modifier_vector);
1962
1963 Write("FogOnOverzoom", g_fog_overzoom);
1964 Write("OverzoomVectorScale", g_oz_vector_scale);
1965 Write("OverzoomEmphasisBase", g_overzoom_emphasis_base);
1966 Write("PlusMinusZoomFactor", g_plus_minus_zoom_factor);
1967 Write("MouseZoomSensitivity",
1968 MouseZoom::ui_to_config(g_mouse_zoom_sensitivity_ui));
1969 Write("ShowMUIZoomButtons", g_bShowMuiZoomButtons);
1970
1971#ifdef ocpnUSE_GL
1972 /* opengl options */
1973 Write("UseAcceleratedPanning", g_GLOptions.m_bUseAcceleratedPanning);
1974
1975 Write("GPUTextureCompression", g_GLOptions.m_bTextureCompression);
1976 Write("GPUTextureCompressionCaching",
1977 g_GLOptions.m_bTextureCompressionCaching);
1978 Write("GPUTextureDimension", g_GLOptions.m_iTextureDimension);
1979 Write("GPUTextureMemSize", g_GLOptions.m_iTextureMemorySize);
1980 Write("PolygonSmoothing", g_GLOptions.m_GLPolygonSmoothing);
1981 Write("LineSmoothing", g_GLOptions.m_GLLineSmoothing);
1982#endif
1983 Write("SmoothPanZoom", g_bsmoothpanzoom);
1984
1985 Write("CourseUpMode", g_bCourseUp);
1986 if (!g_bInlandEcdis) Write("LookAheadMode", g_bLookAhead);
1987 Write("TenHzUpdate", g_btenhertz);
1988
1989 Write("COGUPAvgSeconds", g_COGAvgSec);
1990 Write("UseMagAPB", g_bMagneticAPB);
1991
1992 Write("OwnshipCOGPredictorMinutes", g_ownship_predictor_minutes);
1993 Write("OwnshipCOGPredictorStyle", g_cog_predictor_style);
1994 Write("OwnshipCOGPredictorColor", g_cog_predictor_color);
1995 Write("OwnshipCOGPredictorEndmarker", g_cog_predictor_endmarker);
1996 Write("OwnshipCOGPredictorWidth", g_cog_predictor_width);
1997 Write("OwnshipHDTPredictorStyle", g_ownship_HDTpredictor_style);
1998 Write("OwnshipHDTPredictorColor", g_ownship_HDTpredictor_color);
1999 Write("OwnshipHDTPredictorEndmarker", g_ownship_HDTpredictor_endmarker);
2000 Write("OwnShipMMSINumber", g_OwnShipmmsi);
2001 Write("OwnshipHDTPredictorWidth", g_ownship_HDTpredictor_width);
2002 Write("OwnshipHDTPredictorMiles", g_ownship_HDTpredictor_miles);
2003
2004 Write("OwnShipIconType", g_OwnShipIconType);
2005 Write("OwnShipLength", g_n_ownship_length_meters);
2006 Write("OwnShipWidth", g_n_ownship_beam_meters);
2007 Write("OwnShipGPSOffsetX", g_n_gps_antenna_offset_x);
2008 Write("OwnShipGPSOffsetY", g_n_gps_antenna_offset_y);
2009 Write("OwnShipMinSize", g_n_ownship_min_mm);
2010 Write("ShowDirectRouteLine", g_bShowShipToActive);
2011 Write("DirectRouteLineStyle", g_shipToActiveStyle);
2012 Write("DirectRouteLineColor", g_shipToActiveColor);
2013
2014 wxString racr;
2015 // racr.Printf( "%g", g_n_arrival_circle_radius );
2016 // Write( "RouteArrivalCircleRadius", racr );
2017 Write("RouteArrivalCircleRadius",
2018 wxString::Format("%.2f", g_n_arrival_circle_radius));
2019
2020 Write("ChartQuilting", g_bQuiltEnable);
2021
2022 Write("PreserveScaleOnX", g_bPreserveScaleOnX);
2023
2024 Write("StartWithTrackActive", g_bTrackCarryOver);
2025 Write("AutomaticDailyTracks", g_bTrackDaily);
2026 Write("TrackRotateAt", g_track_rotate_time);
2027 Write("TrackRotateTimeType", g_track_rotate_time_type);
2028 Write("HighlightTracks", g_bHighliteTracks);
2029
2030 Write("DateTimeFormat", g_datetime_format);
2031 Write("InitialStackIndex", g_restore_stackindex);
2032 Write("InitialdBIndex", g_restore_dbindex);
2033
2034 Write("NMEAAPBPrecision", g_NMEAAPBPrecision);
2035
2036 Write("TalkerIdText", g_TalkerIdText);
2037 Write("ShowTrackPointTime", g_bShowTrackPointTime);
2038
2039 Write("AnchorWatch1GUID", g_AW1GUID);
2040 Write("AnchorWatch2GUID", g_AW2GUID);
2041
2042 Write("ToolbarX", g_maintoolbar_x);
2043 Write("ToolbarY", g_maintoolbar_y);
2044 // Write( "ToolbarOrient", g_maintoolbar_orient );
2045
2046 Write("iENCToolbarX", g_iENCToolbarPosX);
2047 Write("iENCToolbarY", g_iENCToolbarPosY);
2048
2049 if (!g_bInlandEcdis) {
2050 Write("GlobalToolbarConfig", g_toolbarConfig);
2051 Write("DistanceFormat", g_iDistanceFormat);
2052 Write("SpeedFormat", g_iSpeedFormat);
2053 Write("WindSpeedFormat", g_iWindSpeedFormat);
2054 Write("ShowDepthUnits", g_bShowDepthUnits);
2055 Write("TemperatureFormat", g_iTempFormat);
2056 Write("HeightFormat", g_iHeightFormat);
2057 }
2058 Write("GPSIdent", g_GPS_Ident);
2059 Write("ActiveRoute", g_active_route);
2060 Write("PersistActiveRoute", g_persist_active_route);
2061 Write("AlwaysSendRmbRmc", g_always_send_rmb_rmc);
2062
2063 Write("UseGarminHostUpload", g_bGarminHostUpload);
2064
2065 Write("MobileTouch", g_btouch);
2066 Write("ResponsiveGraphics", g_bresponsive);
2067 Write("EnableRolloverBlock", g_bRollover);
2068
2069 Write("AutoHideToolbar", g_bAutoHideToolbar);
2070 Write("AutoHideToolbarSecs", g_nAutoHideToolbar);
2071
2072 wxString st0;
2073 for (const auto &mm : g_config_display_size_mm) {
2074 st0.Append(wxString::Format("%zu,", mm));
2075 }
2076 st0.RemoveLast(); // Strip last comma
2077 Write("DisplaySizeMM", st0);
2078 Write("DisplaySizeManual", g_config_display_size_manual);
2079
2080 Write("SelectionRadiusMM", g_selection_radius_mm);
2081 Write("SelectionRadiusTouchMM", g_selection_radius_touch_mm);
2082
2083 st0.Printf("%g", g_PlanSpeed);
2084 Write("PlanSpeed", st0);
2085
2086 if (g_bLayersLoaded) {
2087 wxString vis, invis, visnames, invisnames;
2088 LayerList::iterator it;
2089 int index = 0;
2090 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
2091 Layer *lay = (Layer *)(*it);
2092 if (lay->IsVisibleOnChart())
2093 vis += (lay->m_LayerName) + ";";
2094 else
2095 invis += (lay->m_LayerName) + ";";
2096
2097 if (lay->HasVisibleNames() == wxCHK_CHECKED) {
2098 visnames += (lay->m_LayerName) + ";";
2099 } else if (lay->HasVisibleNames() == wxCHK_UNCHECKED) {
2100 invisnames += (lay->m_LayerName) + ";";
2101 }
2102 }
2103 Write("VisibleLayers", vis);
2104 Write("InvisibleLayers", invis);
2105 Write("VisNameInLayers", visnames);
2106 Write("InvisNameInLayers", invisnames);
2107 }
2108 Write("Locale", g_locale);
2109 Write("LocaleOverride", g_localeOverride);
2110
2111 Write("KeepNavobjBackups", g_navobjbackups);
2112 Write("LegacyInputCOMPortFilterBehaviour", g_b_legacy_input_filter_behaviour);
2113 Write("AdvanceRouteWaypointOnArrivalOnly",
2114 g_bAdvanceRouteWaypointOnArrivalOnly);
2115 Write("EnableRootMenuDebug", g_enable_root_menu_debug);
2116
2117 // LIVE ETA OPTION
2118 Write("LiveETA", g_bShowLiveETA);
2119 Write("DefaultBoatSpeed", g_defaultBoatSpeed);
2120
2121 // S57 Object Filter Settings
2122
2123 SetPath("/Settings/ObjectFilter");
2124
2125 if (ps52plib) {
2126 for (unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
2127 iPtr++) {
2128 OBJLElement *pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
2129
2130 wxString st1("viz");
2131 char name[7];
2132 strncpy(name, pOLE->OBJLName, 6);
2133 name[6] = 0;
2134 st1.Append(wxString(name, wxConvUTF8));
2135 Write(st1, pOLE->nViz);
2136 }
2137 }
2138
2139 // Global State
2140
2141 SetPath("/Settings/GlobalState");
2142
2143 wxString st1;
2144
2145 // if( cc1 ) {
2146 // ViewPort vp = cc1->GetVP();
2147 //
2148 // if( vp.IsValid() ) {
2149 // st1.Printf( "%10.4f,%10.4f", vp.clat, vp.clon );
2150 // Write( "VPLatLon", st1 );
2151 // st1.Printf( "%g", vp.view_scale_ppm );
2152 // Write( "VPScale", st1 );
2153 // st1.Printf( "%i", ((int)(vp.rotation * 180 / PI)) % 360
2154 // ); Write( "VPRotation", st1 );
2155 // }
2156 // }
2157
2158 st1.Printf("%10.4f, %10.4f", gLat, gLon);
2159 Write("OwnShipLatLon", st1);
2160
2161 // Various Options
2162 SetPath("/Settings/GlobalState");
2163 if (!g_bInlandEcdis)
2164 Write("nColorScheme", (int)user_colors::GetColorScheme());
2165
2166 Write("EnableHiconColorScheme", g_hicon_colors);
2167
2168 Write("FrameWinX", g_nframewin_x);
2169 Write("FrameWinY", g_nframewin_y);
2170 Write("FrameWinPosX", g_nframewin_posx);
2171 Write("FrameWinPosY", g_nframewin_posy);
2172 Write("FrameMax", g_bframemax);
2173
2174 Write("ClientPosX", g_lastClientRectx);
2175 Write("ClientPosY", g_lastClientRecty);
2176 Write("ClientSzX", g_lastClientRectw);
2177 Write("ClientSzY", g_lastClientRecth);
2178
2179 Write("S52_DEPTH_UNIT_SHOW", g_nDepthUnitDisplay);
2180
2181 Write("RoutePropSizeX", g_route_prop_sx);
2182 Write("RoutePropSizeY", g_route_prop_sy);
2183 Write("RoutePropPosX", g_route_prop_x);
2184 Write("RoutePropPosY", g_route_prop_y);
2185
2186 // Sounds
2187 SetPath("/Settings/Audio");
2188 Write("AISAlertSoundFile", g_AIS_sound_file);
2189 Write("DSCAlertSoundFile", g_DSC_sound_file);
2190 Write("SARTAlertSoundFile", g_SART_sound_file);
2191 Write("AnchorAlarmSoundFile", g_anchorwatch_sound_file);
2192
2193 Write("bAIS_GCPA_AlertAudio", g_bAIS_GCPA_Alert_Audio);
2194 Write("bAIS_SART_AlertAudio", g_bAIS_SART_Alert_Audio);
2195 Write("bAIS_DSC_AlertAudio", g_bAIS_DSC_Alert_Audio);
2196 Write("bAnchorAlertAudio", g_bAnchor_Alert_Audio);
2197
2198 // AIS
2199 SetPath("/Settings/AIS");
2200
2201 Write("bNoCPAMax", g_bCPAMax);
2202 Write("NoCPAMaxNMi", g_CPAMax_NM);
2203 Write("bCPAWarn", g_bCPAWarn);
2204 Write("CPAWarnNMi", g_CPAWarn_NM);
2205 Write("bTCPAMax", g_bTCPA_Max);
2206 Write("TCPAMaxMinutes", g_TCPA_Max);
2207 Write("bMarkLostTargets", g_bMarkLost);
2208 Write("MarkLost_Minutes", g_MarkLost_Mins);
2209 Write("bRemoveLostTargets", g_bRemoveLost);
2210 Write("RemoveLost_Minutes", g_RemoveLost_Mins);
2211 Write("bShowCOGArrows", g_bShowCOG);
2212 Write("bSyncCogPredictors", g_bSyncCogPredictors);
2213 Write("CogArrowMinutes", g_ShowCOG_Mins);
2214 Write("bShowTargetTracks", g_bAISShowTracks);
2215 Write("TargetTracksMinutes", g_AISShowTracks_Mins);
2216
2217 Write("bHideMooredTargets", g_bHideMoored);
2218 Write("MooredTargetMaxSpeedKnots", g_ShowMoored_Kts);
2219
2220 Write("bAISAlertDialog", g_bAIS_CPA_Alert);
2221 Write("bAISAlertAudio", g_bAIS_CPA_Alert_Audio);
2222
2223 Write("AISAlertAudioFile", g_sAIS_Alert_Sound_File);
2224 Write("bAISAlertSuppressMoored", g_bAIS_CPA_Alert_Suppress_Moored);
2225 Write("bShowAreaNotices", g_bShowAreaNotices);
2226 Write("bDrawAISSize", g_bDrawAISSize);
2227 Write("bDrawAISRealtime", g_bDrawAISRealtime);
2228 Write("AISRealtimeMinSpeedKnots", g_AIS_RealtPred_Kts);
2229 Write("bShowAISName", g_bShowAISName);
2230 Write("ShowAISTargetNameScale", g_Show_Target_Name_Scale);
2231 Write("bWplIsAprsPositionReport", g_bWplUsePosition);
2232 Write("WplSelAction", g_WplAction);
2233 Write("AISCOGPredictorWidth", g_ais_cog_predictor_width);
2234 Write("bShowScaledTargets", g_bAllowShowScaled);
2235 Write("AISScaledNumber", g_ShowScaled_Num);
2236 Write("AISScaledNumberWeightSOG", g_ScaledNumWeightSOG);
2237 Write("AISScaledNumberWeightCPA", g_ScaledNumWeightCPA);
2238 Write("AISScaledNumberWeightTCPA", g_ScaledNumWeightTCPA);
2239 Write("AISScaledNumberWeightRange", g_ScaledNumWeightRange);
2240 Write("AISScaledNumberWeightSizeOfTarget", g_ScaledNumWeightSizeOfT);
2241 Write("AISScaledSizeMinimal", g_ScaledSizeMinimal);
2242 Write("AISShowScaled", g_bShowScaled);
2243
2244 Write("AlertDialogSizeX", g_ais_alert_dialog_sx);
2245 Write("AlertDialogSizeY", g_ais_alert_dialog_sy);
2246 Write("AlertDialogPosX", g_ais_alert_dialog_x);
2247 Write("AlertDialogPosY", g_ais_alert_dialog_y);
2248 Write("QueryDialogPosX", g_ais_query_dialog_x);
2249 Write("QueryDialogPosY", g_ais_query_dialog_y);
2250 Write("AISTargetListPerspective", g_AisTargetList_perspective);
2251 Write("AISTargetListRange", g_AisTargetList_range);
2252 Write("AISTargetListSortColumn", g_AisTargetList_sortColumn);
2253 Write("bAISTargetListSortReverse", g_bAisTargetList_sortReverse);
2254 Write("AISTargetListColumnSpec", g_AisTargetList_column_spec);
2255 Write("AISTargetListColumnOrder", g_AisTargetList_column_order);
2256
2257 Write("S57QueryDialogSizeX", g_S57_dialog_sx);
2258 Write("S57QueryDialogSizeY", g_S57_dialog_sy);
2259 Write("S57QueryExtraDialogSizeX", g_S57_extradialog_sx);
2260 Write("S57QueryExtraDialogSizeY", g_S57_extradialog_sy);
2261
2262 Write("bAISRolloverShowClass", g_bAISRolloverShowClass);
2263 Write("bAISRolloverShowCOG", g_bAISRolloverShowCOG);
2264 Write("bAISRolloverShowCPA", g_bAISRolloverShowCPA);
2265
2266 Write("bAISAlertAckTimeout", g_bAIS_ACK_Timeout);
2267 Write("AlertAckTimeoutMinutes", g_AckTimeout_Mins);
2268
2269 SetPath("/Settings/GlobalState");
2270 if (ps52plib) {
2271 Write("bShowS57Text", ps52plib->GetShowS57Text());
2272 Write("bShowS57ImportantTextOnly", ps52plib->GetShowS57ImportantTextOnly());
2273 if (!g_bInlandEcdis)
2274 Write("nDisplayCategory", (long)ps52plib->GetDisplayCategory());
2275 Write("nSymbolStyle", (int)ps52plib->m_nSymbolStyle);
2276 Write("nBoundaryStyle", (int)ps52plib->m_nBoundaryStyle);
2277
2278 Write("bShowSoundg", ps52plib->m_bShowSoundg);
2279 Write("bShowMeta", ps52plib->m_bShowMeta);
2280 Write("bUseSCAMIN", ps52plib->m_bUseSCAMIN);
2281 Write("bUseSUPER_SCAMIN", ps52plib->m_bUseSUPER_SCAMIN);
2282 Write("bShowAtonText", ps52plib->m_bShowAtonText);
2283 Write("bShowLightDescription", ps52plib->m_bShowLdisText);
2284 Write("bExtendLightSectors", ps52plib->m_bExtendLightSectors);
2285 Write("bDeClutterText", ps52plib->m_bDeClutterText);
2286 Write("bShowNationalText", ps52plib->m_bShowNationalTexts);
2287
2288 Write("S52_MAR_SAFETY_CONTOUR",
2289 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
2290 Write("S52_MAR_SHALLOW_CONTOUR",
2291 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
2292 Write("S52_MAR_DEEP_CONTOUR", S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
2293 Write("S52_MAR_TWO_SHADES", S52_getMarinerParam(S52_MAR_TWO_SHADES));
2294 Write("S52_DEPTH_UNIT_SHOW", ps52plib->m_nDepthUnitDisplay);
2295 Write("ENCSoundingScaleFactor", g_ENCSoundingScaleFactor);
2296 Write("ENCTextScaleFactor", g_ENCTextScaleFactor);
2297 }
2298 SetPath("/Directories");
2299 Write("S57DataLocation", "");
2300 // Write( "SENCFileLocation", "" );
2301
2302 SetPath("/Directories");
2303 Write("InitChartDir", *pInit_Chart_Dir);
2304 Write("GPXIODir", g_gpx_path);
2305 Write("TCDataDir", g_TCData_Dir);
2306 Write("BasemapDir", g_Platform->NormalizePath(gWorldMapLocation));
2307 if (gWorldShapefileLocation.Length())
2308 Write("BaseShapefileDir",
2309 g_Platform->NormalizePath(gWorldShapefileLocation));
2310 Write("pluginInstallDir", g_Platform->NormalizePath(g_winPluginDir));
2311
2312 SetPath("/Settings/NMEADataSource");
2313 wxString connectionconfigs;
2314 for (size_t i = 0; i < TheConnectionParams().size(); i++) {
2315 if (i > 0) connectionconfigs.Append("|");
2316 connectionconfigs.Append(TheConnectionParams()[i]->Serialize());
2317 }
2318 Write("DataConnections", connectionconfigs);
2319
2320 // Fonts
2321
2322 // Store the persistent Auxiliary Font descriptor Keys
2323 SetPath("/Settings/AuxFontKeys");
2324
2325 wxArrayString keyArray = FontMgr::Get().GetAuxKeyArray();
2326 for (unsigned int i = 0; i < keyArray.GetCount(); i++) {
2327 wxString key;
2328 key.Printf("Key%i", i);
2329 wxString keyval = keyArray[i];
2330 Write(key, keyval);
2331 }
2332
2333 wxString font_path;
2334#ifdef __WXX11__
2335 font_path = ("/Settings/X11Fonts");
2336#endif
2337
2338#ifdef __WXGTK__
2339 font_path = ("/Settings/GTKFonts");
2340#endif
2341
2342#ifdef __WXMSW__
2343 font_path = ("/Settings/MSWFonts");
2344#endif
2345
2346#ifdef __WXMAC__
2347 font_path = ("/Settings/MacFonts");
2348#endif
2349
2350#ifdef __WXQT__
2351 font_path = ("/Settings/QTFonts");
2352#endif
2353
2354 if (HasEntry(font_path)) DeleteGroup(font_path);
2355
2356 SetPath(font_path);
2357
2358 int nFonts = FontMgr::Get().GetNumFonts();
2359
2360 for (int i = 0; i < nFonts; i++) {
2361 wxString cfstring(FontMgr::Get().GetConfigString(i));
2362 wxString valstring = FontMgr::Get().GetFullConfigDesc(i);
2363 Write(cfstring, valstring);
2364 }
2365
2366 // Tide/Current Data Sources
2367 if (HasGroup("/TideCurrentDataSources"))
2368 DeleteGroup("/TideCurrentDataSources");
2369 SetPath("/TideCurrentDataSources");
2370 unsigned int id = 0;
2371 for (auto val : TideCurrentDataSet) {
2372 wxString key;
2373 key.Printf("tcds%d", id);
2374 Write(key, wxString(val));
2375 ++id;
2376 }
2377
2378 SetPath("/Settings/Others");
2379
2380 // Radar rings
2381 Write("ShowRadarRings",
2382 (bool)(g_iNavAidRadarRingsNumberVisible > 0)); // 3.0.0 config support
2383 Write("RadarRingsNumberVisible", g_iNavAidRadarRingsNumberVisible);
2384 Write("RadarRingsStep", g_fNavAidRadarRingsStep);
2385 Write("RadarRingsStepUnits", g_pNavAidRadarRingsStepUnits);
2386 Write("RadarRingsColour",
2387 g_colourOwnshipRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
2388 Write("WaypointUseScaMin", g_bUseWptScaMin);
2389 Write("WaypointScaMinValue", g_iWpt_ScaMin);
2390 Write("WaypointScaMaxValue", g_iWpt_ScaMax);
2391 Write("WaypointUseScaMinOverrule", g_bOverruleScaMin);
2392 Write("WaypointsShowName", g_bShowWptName);
2393 Write("UserIconsFirst", g_bUserIconsFirst);
2394
2395 // Waypoint Radar rings
2396 Write("WaypointRangeRingsNumber", g_iWaypointRangeRingsNumber);
2397 Write("WaypointRangeRingsStep", g_fWaypointRangeRingsStep);
2398 Write("WaypointRangeRingsStepUnits", g_iWaypointRangeRingsStepUnits);
2399 Write("WaypointRangeRingsColour",
2400 g_colourWaypointRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
2401
2402 Write("ConfirmObjectDeletion", g_bConfirmObjectDelete);
2403
2404 // Waypoint dragging with mouse; toh, 2009.02.24
2405 Write("WaypointPreventDragging", g_bWayPointPreventDragging);
2406
2407 Write("EnableZoomToCursor", g_bEnableZoomToCursor);
2408
2409 Write("TrackIntervalSeconds", g_TrackIntervalSeconds);
2410 Write("TrackDeltaDistance", g_TrackDeltaDistance);
2411 Write("TrackPrecision", g_nTrackPrecision);
2412
2413 Write("RouteLineWidth", g_route_line_width);
2414 Write("TrackLineWidth", g_track_line_width);
2415 Write("TrackLineColour",
2416 g_colourTrackLineColour.GetAsString(wxC2S_HTML_SYNTAX));
2417 Write("DefaultWPIcon", g_default_wp_icon);
2418 Write("DataMonitorLogfile", g_dm_logfile);
2419 Write("DefaultRPIcon", g_default_routepoint_icon);
2420
2421 DeleteGroup("/MmsiProperties");
2422 SetPath("/MmsiProperties");
2423 for (unsigned int i = 0; i < g_MMSI_Props_Array.GetCount(); i++) {
2424 wxString p;
2425 p.Printf("Props%d", i);
2426 Write(p, g_MMSI_Props_Array[i]->Serialize());
2427 }
2428 SetPath("/DataMonitor");
2429 Write("colors.ok", g_dm_ok);
2430 Write("colors.dropped", g_dm_dropped);
2431 Write("colors.filtered", g_dm_filtered);
2432 Write("colors.input", g_dm_input);
2433 Write("colors.output", g_dm_output);
2434 Write("colors.not-ok", g_dm_not_ok);
2435
2436 SaveCanvasConfigs();
2437
2438 Flush();
2439 SendMessageToAllPlugins("GLOBAL_SETTINGS_UPDATED", "{\"updated\":\"1\"}");
2440
2441#ifdef ocpnUSE_GL
2442 if (g_bopengl) {
2443 if (top_frame::Get()) top_frame::Get()->SendGlJsonConfigMsg();
2444 }
2445#endif
2446}
2447
2448static wxFileName exportFileName(wxWindow *parent,
2449 const wxString suggestedName) {
2450 wxFileName ret;
2451 wxString path;
2452 wxString valid_name = SanitizeFileName(suggestedName);
2453
2454#ifdef __ANDROID__
2455 if (!valid_name.EndsWith(".gpx")) {
2456 wxFileName fn(valid_name);
2457 fn.ClearExt();
2458 fn.SetExt("gpx");
2459 valid_name = fn.GetFullName();
2460 }
2461#endif
2462 int response = g_Platform->DoFileSelectorDialog(
2463 parent, &path, _("Export GPX file"), g_gpx_path, valid_name, "*.gpx");
2464
2465 if (response == wxID_OK) {
2466 wxFileName fn(path);
2467 g_gpx_path = fn.GetPath();
2468 if (!fn.GetExt().StartsWith("gpx")) fn.SetExt("gpx");
2469
2470#if defined(__WXMSW__) || defined(__WXGTK__)
2471 if (wxFileExists(fn.GetFullPath())) {
2472 int answer = OCPNMessageBox(NULL, _("Overwrite existing file?"),
2473 "Confirm", wxICON_QUESTION | wxYES_NO);
2474 if (answer != wxID_YES) return ret;
2475 }
2476#endif
2477 ret = fn;
2478 }
2479 return ret;
2480}
2481
2482int BackupDatabase(wxWindow *parent) {
2483 bool backupResult = false;
2484 wxDateTime tm = wxDateTime::Now();
2485 wxString proposedName = tm.Format("navobj-%Y-%m-%d_%H_%M");
2486 wxString acceptedName;
2487
2488 if (wxID_OK ==
2489 g_Platform->DoFileSelectorDialog(parent, &acceptedName, _("Backup"),
2490 wxStandardPaths::Get().GetDocumentsDir(),
2491 proposedName, "*.bkp")) {
2492 wxFileName fileName(acceptedName);
2493 if (fileName.IsOk()) {
2494#if defined(__WXMSW__) || defined(__WXGTK__)
2495 if (fileName.FileExists()) {
2496 if (wxID_YES != OCPNMessageBox(NULL, _("Overwrite existing file?"),
2497 "Confirm", wxICON_QUESTION | wxYES_NO)) {
2498 return wxID_ABORT; // We've decided not to overwrite a file, aborting
2499 }
2500 }
2501#endif
2502
2503#ifdef __ANDROID__
2504 wxString secureFileName = androidGetCacheDir() +
2505 wxFileName::GetPathSeparator() +
2506 fileName.GetFullName();
2507 backupResult = NavObj_dB::GetInstance().Backup(secureFileName);
2508 AndroidSecureCopyFile(secureFileName, fileName.GetFullPath());
2509#else
2510 backupResult = NavObj_dB::GetInstance().Backup(fileName.GetFullPath());
2511#endif
2512 }
2513 return backupResult ? wxID_YES : wxID_NO;
2514 }
2515 return wxID_ABORT; // Cancelled the file open dialog, aborting
2516}
2517
2518bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes,
2519 const wxString suggestedName) {
2520#ifndef __ANDROID__
2521 wxFileName fn = exportFileName(parent, suggestedName);
2522 if (fn.IsOk()) {
2524 pgpx->AddGPXRoutesList(pRoutes);
2525 pgpx->SaveFile(fn.GetFullPath());
2526 delete pgpx;
2527 return true;
2528 }
2529#else
2530 // Create the .GPX file, saving it in the OCPN Android cache directory
2531 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2532 suggestedName + ".gpx";
2534 pgpx->AddGPXRoutesList(pRoutes);
2535 pgpx->SaveFile(fns);
2536 delete pgpx;
2537
2538 AndroidExportSAF(parent, suggestedName + ".gpx");
2539 return true;
2540#endif
2541
2542 return false;
2543}
2544
2545bool ExportGPXTracks(wxWindow *parent, std::vector<Track *> *pTracks,
2546 const wxString suggestedName) {
2547#ifndef __ANDROID__
2548 wxFileName fn = exportFileName(parent, suggestedName);
2549 if (fn.IsOk()) {
2551 pgpx->AddGPXTracksList(pTracks);
2552 pgpx->SaveFile(fn.GetFullPath());
2553 delete pgpx;
2554 return true;
2555 }
2556#else
2557 // Create the .GPX file, saving it in the OCPN Android cache directory
2558 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2559 suggestedName + ".gpx";
2561 pgpx->AddGPXTracksList(pTracks);
2562 pgpx->SaveFile(fns);
2563 delete pgpx;
2564
2565 AndroidExportSAF(parent, suggestedName + ".gpx");
2566 return true;
2567#endif
2568
2569 return false;
2570}
2571
2572bool ExportGPXWaypoints(wxWindow *parent, RoutePointList *pRoutePoints,
2573 const wxString suggestedName) {
2574#ifndef __ANDROID__
2575 wxFileName fn = exportFileName(parent, suggestedName);
2576 if (fn.IsOk()) {
2578 pgpx->AddGPXPointsList(pRoutePoints);
2579 pgpx->SaveFile(fn.GetFullPath());
2580 delete pgpx;
2581 return true;
2582 }
2583#else
2584 // Create the .GPX file, saving it in the OCPN Android cache directory
2585 wxString fns = androidGetCacheDir() + wxFileName::GetPathSeparator() +
2586 suggestedName + ".gpx";
2588 pgpx->AddGPXPointsList(pRoutePoints);
2589 pgpx->SaveFile(fns);
2590 delete pgpx;
2591
2592 AndroidExportSAF(parent, suggestedName + ".gpx");
2593 return true;
2594#endif
2595
2596 return false;
2597}
2598
2599void ExportGPX(wxWindow *parent, bool bviz_only, bool blayer) {
2601 wxString fns;
2602
2603#ifndef __ANDROID__
2604 wxFileName fn = exportFileName(parent, "userobjects.gpx");
2605 if (!fn.IsOk()) return;
2606 fns = fn.GetFullPath();
2607#else
2608 // Create the .GPX file, saving it in the OCPN Android cache directory
2609 fns =
2610 androidGetCacheDir() + wxFileName::GetPathSeparator() + "userobjects.gpx";
2611
2612#endif
2613 ::wxBeginBusyCursor();
2614
2615 wxGenericProgressDialog *pprog = nullptr;
2616 int count = pWayPointMan->GetWaypointList()->size();
2617 int progStep = count / 32;
2618 if (count > 200) {
2619 pprog = new wxGenericProgressDialog(
2620 _("Export GPX file"), "0/0", count, NULL,
2621 wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
2622 wxPD_REMAINING_TIME);
2623 pprog->SetSize(400, wxDefaultCoord);
2624 pprog->Centre();
2625 }
2626
2627 // WPTs
2628 int ic = 1;
2629
2630 for (RoutePoint *pr : *pWayPointMan->GetWaypointList()) {
2631 if (pprog && !(ic % progStep)) {
2632 wxString msg;
2633 msg.Printf("%d/%d", ic, count);
2634 pprog->Update(ic, msg);
2635 }
2636 ic++;
2637
2638 bool b_add = true;
2639 if (bviz_only && !pr->m_bIsVisible) b_add = false;
2640
2641 if (pr->m_bIsInLayer && !blayer) b_add = false;
2642 if (b_add) {
2643 if (pr->IsShared() || !WptIsInRouteList(pr)) pgpx->AddGPXWaypoint(pr);
2644 }
2645 }
2646 // RTEs and TRKs
2647 for (Route *pRoute : *pRouteList) {
2648 bool b_add = true;
2649 if (bviz_only && !pRoute->IsVisible()) b_add = false;
2650 if (pRoute->m_bIsInLayer && !blayer) b_add = false;
2651
2652 if (b_add) pgpx->AddGPXRoute(pRoute);
2653 }
2654
2655 for (Track *pTrack : g_TrackList) {
2656 bool b_add = true;
2657
2658 if (bviz_only && !pTrack->IsVisible()) b_add = false;
2659
2660 if (pTrack->m_bIsInLayer && !blayer) b_add = false;
2661
2662 if (b_add) pgpx->AddGPXTrack(pTrack);
2663 }
2664
2665 pgpx->SaveFile(fns);
2666
2667#ifdef __ANDROID__
2668 AndroidExportSAF(parent, "userobjects.gpx");
2669 return;
2670#endif
2671
2672 delete pgpx;
2673 ::wxEndBusyCursor();
2674 delete pprog;
2675}
2676
2677void UI_ImportGPX(wxWindow *parent, bool islayer, wxString dirpath,
2678 bool isdirectory, bool isPersistent) {
2679 int response = wxID_CANCEL;
2680 wxArrayString file_array;
2681
2682 if (!islayer || dirpath.IsSameAs("")) {
2683 // Platform DoFileSelectorDialog method does not properly handle multiple
2684 // selections So use native method if not Android, which means Android gets
2685 // single selection only.
2686#ifndef __ANDROID__
2687 wxFileDialog *popenDialog =
2688 new wxFileDialog(NULL, _("Import GPX file"), g_gpx_path, "",
2689 "GPX files (*.gpx)|*.gpx|All files (*.*)|*.*",
2690 wxFD_OPEN | wxFD_MULTIPLE);
2691
2692 if (g_bresponsive && parent)
2693 popenDialog = g_Platform->AdjustFileDialogFont(parent, popenDialog);
2694
2695 popenDialog->Centre();
2696
2697#ifdef __WXOSX__
2698 if (parent) parent->HideWithEffect(wxSHOW_EFFECT_BLEND);
2699#endif
2700
2701 response = popenDialog->ShowModal();
2702
2703#ifdef __WXOSX__
2704 if (parent) parent->ShowWithEffect(wxSHOW_EFFECT_BLEND);
2705#endif
2706
2707 if (response == wxID_OK) {
2708 popenDialog->GetPaths(file_array);
2709
2710 // Record the currently selected directory for later use
2711 if (file_array.GetCount()) {
2712 wxFileName fn(file_array[0]);
2713 g_gpx_path = fn.GetPath();
2714 }
2715 }
2716 delete popenDialog;
2717#else // Android
2718 if (!androidCheckSAFPermission("primary:Documents")) {
2719 AndroidDoSAFPermissions();
2720 return;
2721 }
2722
2723 wxString path;
2724 response = g_Platform->DoFileSelectorDialog(
2725 NULL, &path, _("Import GPX file"), g_gpx_path, "", "*.gpx");
2726
2727 wxFileName fn(path);
2728 if (path.IsEmpty()) { // Return from SAF processing, expecting callback
2729 PrepareImportAndroid(islayer, isPersistent);
2730 return;
2731 } else
2732 file_array.Add(path); // Return from safe app arena access
2733
2734#endif
2735 } else {
2736 if (isdirectory) {
2737 if (wxDir::GetAllFiles(dirpath, &file_array, "*.gpx")) response = wxID_OK;
2738 } else {
2739 file_array.Add(dirpath);
2740 response = wxID_OK;
2741 }
2742 }
2743
2744 if (response == wxID_OK) {
2745 ImportFileArray(file_array, islayer, isPersistent, dirpath);
2746 }
2747}
2748
2749void ImportFileArray(const wxArrayString &file_array, bool islayer,
2750 bool isPersistent, wxString dirpath) {
2751 Layer *l = NULL;
2752
2753 if (islayer) {
2754 l = new Layer();
2755 l->m_LayerID = ++g_LayerIdx;
2756 l->m_LayerFileName = file_array[0];
2757 if (file_array.GetCount() <= 1)
2758 wxFileName::SplitPath(file_array[0], NULL, NULL, &(l->m_LayerName), NULL,
2759 NULL);
2760 else {
2761 if (dirpath.IsSameAs(""))
2762 wxFileName::SplitPath(g_gpx_path, NULL, NULL, &(l->m_LayerName), NULL,
2763 NULL);
2764 else
2765 wxFileName::SplitPath(dirpath, NULL, NULL, &(l->m_LayerName), NULL,
2766 NULL);
2767 }
2768
2769 bool bLayerViz = g_bShowLayers;
2770 if (g_VisibleLayers.Contains(l->m_LayerName)) bLayerViz = true;
2771 if (g_InvisibleLayers.Contains(l->m_LayerName)) bLayerViz = false;
2772 l->m_bIsVisibleOnChart = bLayerViz;
2773
2774 // Default for new layers is "Names visible"
2775 l->m_bHasVisibleNames = wxCHK_CHECKED;
2776
2777 wxString laymsg;
2778 laymsg.Printf("New layer %d: %s", l->m_LayerID, l->m_LayerName.c_str());
2779 wxLogMessage(laymsg);
2780
2781 pLayerList->insert(pLayerList->begin(), l);
2782 }
2783
2784 for (unsigned int i = 0; i < file_array.GetCount(); i++) {
2785 wxString path = file_array[i];
2786
2787 if (::wxFileExists(path)) {
2789 pugi::xml_parse_result result = pSet->load_file(path.fn_str());
2790 if (!result) {
2791 wxLogMessage("Error loading GPX file " + path);
2792 wxMessageBox(
2793 wxString::Format(_("Error loading GPX file %s, %s at character %d"),
2794 path, result.description(), result.offset),
2795 _("Import GPX File"));
2796 pSet->reset();
2797 delete pSet;
2798 continue;
2799 }
2800
2801 if (islayer) {
2802 l->m_NoOfItems = pSet->LoadAllGPXObjectsAsLayer(
2803 l->m_LayerID, l->m_bIsVisibleOnChart, l->m_bHasVisibleNames);
2804 l->m_LayerType = isPersistent ? _("Persistent") : _("Temporary");
2805
2806 if (isPersistent) {
2807 // If this is a persistent layer also copy the file to config file
2808 // dir /layers
2809 wxString destf, f, name, ext;
2810 f = l->m_LayerFileName;
2811 wxFileName::SplitPath(f, NULL, NULL, &name, &ext);
2812 destf = g_Platform->GetPrivateDataDir();
2813 appendOSDirSlash(&destf);
2814 destf.Append("layers");
2815 appendOSDirSlash(&destf);
2816 if (!wxDirExists(destf)) {
2817 if (!wxMkdir(destf, wxS_DIR_DEFAULT))
2818 wxLogMessage("Error creating layer directory");
2819 }
2820
2821 destf << name << "." << ext;
2822 wxString msg;
2823 if (wxCopyFile(f, destf, true))
2824 msg.Printf("File: %s.%s also added to persistent layers", name,
2825 ext);
2826 else
2827 msg.Printf("Failed adding %s.%s to persistent layers", name, ext);
2828 wxLogMessage(msg);
2829 }
2830 } else {
2831 int wpt_dups;
2832 pSet->LoadAllGPXObjects(
2833 !pSet->IsOpenCPN(),
2834 wpt_dups); // Import with full visibility of names and objects
2835#ifndef __ANDROID__
2836 if (wpt_dups > 0) {
2837 OCPNMessageBox(
2838 NULL,
2839 wxString::Format("%d " + _("duplicate waypoints detected "
2840 "during import and ignored."),
2841 wpt_dups),
2842 _("OpenCPN Info"), wxICON_INFORMATION | wxOK, 10);
2843 }
2844#endif
2845 }
2846 delete pSet;
2847 }
2848 }
2849}
2850
2851//-------------------------------------------------------------------------
2852// Static Routine Switch to Inland Ecdis Mode
2853//-------------------------------------------------------------------------
2854void SwitchInlandEcdisMode(bool Switch) {
2855 if (Switch) {
2856 wxLogMessage("Switch InlandEcdis mode On");
2857 LoadS57();
2858 // Overrule some settings to comply with InlandEcdis
2859 // g_toolbarConfig = ".....XXXX.X...XX.XXXXXXXXXXXX";
2860 g_iDistanceFormat = 2; // 0 = "Nautical miles"), 1 = "Statute miles", 2 =
2861 // "Kilometers", 3 = "Meters"
2862 g_iSpeedFormat = 2; // 0 = "kts"), 1 = "mph", 2 = "km/h", 3 = "m/s"
2863 if (ps52plib) ps52plib->SetDisplayCategory(STANDARD);
2864 g_bDrawAISSize = false;
2865 if (top_frame::Get()) top_frame::Get()->RequestNewToolbars(true);
2866 } else {
2867 wxLogMessage("Switch InlandEcdis mode Off");
2868 // reread the settings overruled by inlandEcdis
2869 if (pConfig) {
2870 pConfig->SetPath("/Settings");
2871 pConfig->Read("GlobalToolbarConfig", &g_toolbarConfig);
2872 pConfig->Read("DistanceFormat", &g_iDistanceFormat);
2873 pConfig->Read("SpeedFormat", &g_iSpeedFormat);
2874 pConfig->Read("ShowDepthUnits", &g_bShowDepthUnits, 1);
2875 pConfig->Read("HeightFormat", &g_iHeightFormat);
2876 int read_int;
2877 pConfig->Read("nDisplayCategory", &read_int, (enum _DisCat)STANDARD);
2878 if (ps52plib) ps52plib->SetDisplayCategory((enum _DisCat)read_int);
2879 pConfig->SetPath("/Settings/AIS");
2880 pConfig->Read("bDrawAISSize", &g_bDrawAISSize);
2881 pConfig->Read("bDrawAISRealtime", &g_bDrawAISRealtime);
2882 }
2883 if (top_frame::Get()) top_frame::Get()->RequestNewToolbars(true);
2884 }
2885}
2886
2887//-------------------------------------------------------------------------
2888//
2889// Static GPX Support Routines
2890//
2891//-------------------------------------------------------------------------
2892// This function formats the input date/time into a valid GPX ISO 8601
2893// time string specified in the UTC time zone.
2894
2895wxString FormatGPXDateTime(wxDateTime dt) {
2896 // return dt.Format("%Y-%m-%dT%TZ", wxDateTime::GMT0);
2897 return dt.Format("%Y-%m-%dT%H:%M:%SZ");
2898}
2899
2900/**************************************************************************/
2901/* LogMessageOnce */
2902/**************************************************************************/
2903
2904bool LogMessageOnce(const wxString &msg) {
2905 // Search the array for a match
2906
2907 for (unsigned int i = 0; i < navutil::pMessageOnceArray->GetCount(); i++) {
2908 if (msg.IsSameAs(navutil::pMessageOnceArray->Item(i))) return false;
2909 }
2910
2911 // Not found, so add to the array
2912 navutil::pMessageOnceArray->Add(msg);
2913
2914 // And print it
2915 wxLogMessage(msg);
2916 return true;
2917}
2918
2919/**************************************************************************/
2920/* Some assorted utilities */
2921/**************************************************************************/
2922
2923wxDateTime toUsrDateTime(const wxDateTime ts, const int format,
2924 const double lon) {
2925 if (!ts.IsValid()) {
2926 return ts;
2927 }
2928 int effective_format = format;
2929 if (effective_format == GLOBAL_SETTINGS_INPUT) {
2930 if (::g_datetime_format == "UTC") {
2931 effective_format = UTCINPUT;
2932 } else if (::g_datetime_format == "LMT") {
2933 effective_format = LMTINPUT;
2934 } else if (::g_datetime_format == "Local Time") {
2935 effective_format = LTINPUT;
2936 } else {
2937 // Default to UTC
2938 effective_format = UTCINPUT;
2939 }
2940 }
2941 wxDateTime dt;
2942 switch (effective_format) {
2943 case LMTINPUT: // LMT@Location
2944 if (std::isnan(lon)) {
2945 dt = wxInvalidDateTime;
2946 } else {
2947 dt =
2948 ts.Add(wxTimeSpan(wxTimeSpan(0, 0, wxLongLong(lon * 3600. / 15.))));
2949 }
2950 break;
2951 case LTINPUT: // Local@PC
2952 // Convert date/time from UTC to local time.
2953 dt = ts.FromUTC();
2954 break;
2955 case UTCINPUT: // UTC
2956 // The date/time is already in UTC.
2957 dt = ts;
2958 break;
2959 }
2960 return dt;
2961}
2962
2963wxDateTime fromUsrDateTime(const wxDateTime ts, const int format,
2964 const double lon) {
2965 if (!ts.IsValid()) {
2966 return ts;
2967 }
2968 int effective_format = format;
2969 if (effective_format == GLOBAL_SETTINGS_INPUT) {
2970 if (::g_datetime_format == "UTC") {
2971 effective_format = UTCINPUT;
2972 } else if (::g_datetime_format == "LMT") {
2973 effective_format = LMTINPUT;
2974 } else if (::g_datetime_format == "Local Time") {
2975 effective_format = LTINPUT;
2976 } else {
2977 // Default to UTC
2978 effective_format = UTCINPUT;
2979 }
2980 }
2981 wxDateTime dt;
2982 switch (effective_format) {
2983 case LMTINPUT: // LMT@Location
2984 if (std::isnan(lon)) {
2985 dt = wxInvalidDateTime;
2986 } else {
2987 dt = ts.Subtract(wxTimeSpan(0, 0, wxLongLong(lon * 3600. / 15.)));
2988 }
2989 break;
2990 case LTINPUT: // Local@PC
2991 // The input date/time is in local time, so convert it to UTC.
2992 dt = ts.ToUTC();
2993 break;
2994 case UTCINPUT: // UTC
2995 dt = ts;
2996 break;
2997 }
2998 return dt;
2999}
3000
3001/**************************************************************************/
3002/* Converts the speed from the units selected by user to knots */
3003/**************************************************************************/
3004double fromUsrSpeed(double usr_speed, int unit) {
3005 double ret = NAN;
3006 if (unit == -1) unit = g_iSpeedFormat;
3007 switch (unit) {
3008 case SPEED_KTS: // kts
3009 ret = usr_speed;
3010 break;
3011 case SPEED_MPH: // mph
3012 ret = usr_speed / 1.15078;
3013 break;
3014 case SPEED_KMH: // km/h
3015 ret = usr_speed / 1.852;
3016 break;
3017 case SPEED_MS: // m/s
3018 ret = usr_speed / 0.514444444;
3019 break;
3020 }
3021 return ret;
3022}
3023/**************************************************************************/
3024/* Converts the wind speed from the units selected by user to knots */
3025/**************************************************************************/
3026double fromUsrWindSpeed(double usr_wspeed, int unit) {
3027 double ret = NAN;
3028 if (unit == -1) unit = g_iWindSpeedFormat;
3029 switch (unit) {
3030 case WSPEED_KTS: // kts
3031 ret = usr_wspeed;
3032 break;
3033 case WSPEED_MS: // m/s
3034 ret = usr_wspeed / 0.514444444;
3035 break;
3036 case WSPEED_MPH: // mph
3037 ret = usr_wspeed / 1.15078;
3038 break;
3039 case WSPEED_KMH: // km/h
3040 ret = usr_wspeed / 1.852;
3041 break;
3042 }
3043 return ret;
3044}
3045
3046/**************************************************************************/
3047/* Converts the temperature from the units selected by user to Celsius */
3048/**************************************************************************/
3049double fromUsrTemp(double usr_temp, int unit) {
3050 double ret = NAN;
3051 if (unit == -1) unit = g_iTempFormat;
3052 switch (unit) {
3053 case TEMPERATURE_C: // C
3054 ret = usr_temp;
3055 break;
3056 case TEMPERATURE_F: // F
3057 ret = (usr_temp - 32) * 5.0 / 9.0;
3058 break;
3059 case TEMPERATURE_K: // K
3060 ret = usr_temp - 273.15;
3061 break;
3062 }
3063 return ret;
3064}
3065
3066wxString formatAngle(double angle) {
3067 wxString out;
3068 if (g_bShowMag && g_bShowTrue) {
3069 out.Printf("%03.0f %cT (%.0f %cM)", angle, 0x00B0, toMagnetic(angle),
3070 0x00B0);
3071 } else if (g_bShowTrue) {
3072 out.Printf("%03.0f %cT", angle, 0x00B0);
3073 } else {
3074 out.Printf("%03.0f %cM", toMagnetic(angle), 0x00B0);
3075 }
3076 return out;
3077}
3078
3079/* render a rectangle at a given color and transparency */
3080void AlphaBlending(ocpnDC &dc, int x, int y, int size_x, int size_y,
3081 float radius, wxColour color, unsigned char transparency) {
3082 wxDC *pdc = dc.GetDC();
3083 if (pdc) {
3084 // Get wxImage of area of interest
3085 wxBitmap obm(size_x, size_y);
3086 wxMemoryDC mdc1;
3087 mdc1.SelectObject(obm);
3088 mdc1.Blit(0, 0, size_x, size_y, pdc, x, y);
3089 mdc1.SelectObject(wxNullBitmap);
3090 wxImage oim = obm.ConvertToImage();
3091
3092 // Create destination image
3093 wxBitmap olbm(size_x, size_y);
3094 wxMemoryDC oldc(olbm);
3095 if (!oldc.IsOk()) return;
3096
3097 oldc.SetBackground(*wxBLACK_BRUSH);
3098 oldc.SetBrush(*wxWHITE_BRUSH);
3099 oldc.Clear();
3100
3101 if (radius > 0.0) oldc.DrawRoundedRectangle(0, 0, size_x, size_y, radius);
3102
3103 wxImage dest = olbm.ConvertToImage();
3104 unsigned char *dest_data =
3105 (unsigned char *)malloc(size_x * size_y * 3 * sizeof(unsigned char));
3106 unsigned char *bg = oim.GetData();
3107 unsigned char *box = dest.GetData();
3108 unsigned char *d = dest_data;
3109
3110 // Sometimes, on Windows, the destination image is corrupt...
3111 if (NULL == box) {
3112 free(d);
3113 return;
3114 }
3115 float alpha = 1.0 - (float)transparency / 255.0;
3116 int sb = size_x * size_y;
3117 for (int i = 0; i < sb; i++) {
3118 float a = alpha;
3119 if (*box == 0 && radius > 0.0) a = 1.0;
3120 int r = ((*bg++) * a) + (1.0 - a) * color.Red();
3121 *d++ = r;
3122 box++;
3123 int g = ((*bg++) * a) + (1.0 - a) * color.Green();
3124 *d++ = g;
3125 box++;
3126 int b = ((*bg++) * a) + (1.0 - a) * color.Blue();
3127 *d++ = b;
3128 box++;
3129 }
3130
3131 dest.SetData(dest_data);
3132
3133 // Convert destination to bitmap and draw it
3134 wxBitmap dbm(dest);
3135 dc.DrawBitmap(dbm, x, y, false);
3136
3137 // on MSW, the dc Bounding box is not updated on DrawBitmap() method.
3138 // Do it explicitely here for all platforms.
3139 dc.CalcBoundingBox(x, y);
3140 dc.CalcBoundingBox(x + size_x, y + size_y);
3141 } else {
3142#ifdef ocpnUSE_GL
3143 glEnable(GL_BLEND);
3144
3145 float radMod = wxMax(radius, 2.0);
3146 wxColour c(color.Red(), color.Green(), color.Blue(), transparency);
3147 dc.SetBrush(wxBrush(c));
3148 dc.SetPen(wxPen(c, 1));
3149 dc.DrawRoundedRectangle(x, y, size_x, size_y, radMod);
3150
3151 glDisable(GL_BLEND);
3152
3153#endif
3154 }
3155}
3156
3157void DimeControl(wxWindow *ctrl) {
3158#ifdef __WXOSX__
3159 // On macOS 10.14+, we use the native colours in both light mode and dark
3160 // mode, and do not need to do anything else. Dark mode is toggled at the
3161 // application level in `SetAndApplyColorScheme`, and is also respected if it
3162 // is enabled system-wide.
3163 if (wxPlatformInfo::Get().CheckOSVersion(10, 14)) {
3164 return;
3165 }
3166#elif defined(__WXQT__)
3167 return; // this is seriously broken on wxqt
3168#elif defined(__WXGTK__)
3169 return; // trust the native Dark/Light setting
3170#endif
3171
3172 if (wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW).Red() <
3173 128) {
3174 // Dark system color themes usually do better job than we do on diming UI
3175 // controls, do not fight with them
3176 return;
3177 }
3178
3179 if (NULL == ctrl) return;
3180
3181 wxColour col, window_back_color, gridline, uitext, udkrd, ctrl_back_color,
3182 text_color;
3183 col = GetGlobalColor("DILG0"); // Dialog Background white
3184 window_back_color = GetGlobalColor("DILG1"); // Dialog Background
3185 ctrl_back_color = GetGlobalColor("DILG1"); // Control Background
3186 text_color = GetGlobalColor("DILG3"); // Text
3187 uitext = GetGlobalColor("UITX1"); // Menu Text, derived from UINFF
3188 udkrd = GetGlobalColor("UDKRD");
3189 gridline = GetGlobalColor("GREY2");
3190
3191 DimeControl(ctrl, col, window_back_color, ctrl_back_color, text_color, uitext,
3192 udkrd, gridline);
3193}
3194
3195void DimeControl(wxWindow *ctrl, wxColour col, wxColour window_back_color,
3196 wxColour ctrl_back_color, wxColour text_color, wxColour uitext,
3197 wxColour udkrd, wxColour gridline) {
3198#ifdef __WXOSX__
3199 // On macOS 10.14+, we use the native colours in both light mode and dark
3200 // mode, and do not need to do anything else. Dark mode is toggled at the
3201 // application level in `SetAndApplyColorScheme`, and is also respected if it
3202 // is enabled system-wide.
3203 if (wxPlatformInfo::Get().CheckOSVersion(10, 14)) {
3204 return;
3205 }
3206#endif
3207
3208 ColorScheme cs = global_color_scheme;
3209
3210 // Are we in dusk or night mode? (Used below in several places.)
3211 bool darkMode =
3212 (cs == GLOBAL_COLOR_SCHEME_DUSK || cs == GLOBAL_COLOR_SCHEME_NIGHT ||
3213 cs == GLOBAL_COLOR_SCHEME_NIGHT_HICON);
3214
3215 static int depth = 0; // recursion count
3216 if (depth == 0) { // only for the window root, not for every child
3217 // If the color scheme is DAY or RGB, use the default platform native colour
3218 // for backgrounds
3219 if (!darkMode) {
3220#ifdef _WIN32
3221 window_back_color = wxNullColour;
3222#else
3223 window_back_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
3224#endif
3225 col = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
3226 uitext = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
3227 }
3228
3229 ctrl->SetBackgroundColour(window_back_color);
3230 if (darkMode) ctrl->SetForegroundColour(text_color);
3231 }
3232
3233 wxWindowList kids = ctrl->GetChildren();
3234 for (unsigned int i = 0; i < kids.GetCount(); i++) {
3235 wxWindowList::compatibility_iterator node = kids.Item(i);
3236 wxWindow *win = node->GetData();
3237
3238 if (dynamic_cast<wxListBox *>(win) || dynamic_cast<wxListCtrl *>(win) ||
3239 dynamic_cast<wxTextCtrl *>(win) ||
3240 dynamic_cast<wxTimePickerCtrl *>(win)) {
3241 win->SetBackgroundColour(col);
3242 } else if (dynamic_cast<wxStaticText *>(win) ||
3243 dynamic_cast<wxCheckBox *>(win) ||
3244 dynamic_cast<wxRadioButton *>(win)) {
3245 win->SetForegroundColour(uitext);
3246 }
3247#ifndef __WXOSX__
3248 // On macOS most controls can't be styled, and trying to do so only creates
3249 // weird coloured boxes around them. Fortunately, however, many of them
3250 // inherit a colour or tint from the background of their parent.
3251
3252 else if (dynamic_cast<wxBitmapComboBox *>(win) ||
3253 dynamic_cast<wxChoice *>(win) || dynamic_cast<wxComboBox *>(win) ||
3254 dynamic_cast<wxTreeCtrl *>(win)) {
3255 win->SetBackgroundColour(col);
3256 }
3257
3258 else if (dynamic_cast<wxScrolledWindow *>(win) ||
3259 dynamic_cast<wxGenericDirCtrl *>(win) ||
3260 dynamic_cast<wxListbook *>(win) || dynamic_cast<wxButton *>(win) ||
3261 dynamic_cast<wxToggleButton *>(win)) {
3262 win->SetBackgroundColour(window_back_color);
3263 }
3264
3265 else if (dynamic_cast<wxNotebook *>(win)) {
3266 win->SetBackgroundColour(window_back_color);
3267 win->SetForegroundColour(text_color);
3268 }
3269#endif
3270
3271 else if (dynamic_cast<wxHtmlWindow *>(win)) {
3272 if (cs != GLOBAL_COLOR_SCHEME_DAY && cs != GLOBAL_COLOR_SCHEME_RGB)
3273 win->SetBackgroundColour(ctrl_back_color);
3274 else
3275 win->SetBackgroundColour(wxNullColour);
3276 }
3277
3278 else if (dynamic_cast<wxGrid *>(win)) {
3279 dynamic_cast<wxGrid *>(win)->SetDefaultCellBackgroundColour(
3280 window_back_color);
3281 dynamic_cast<wxGrid *>(win)->SetDefaultCellTextColour(uitext);
3282 dynamic_cast<wxGrid *>(win)->SetLabelBackgroundColour(col);
3283 dynamic_cast<wxGrid *>(win)->SetLabelTextColour(uitext);
3284 dynamic_cast<wxGrid *>(win)->SetGridLineColour(gridline);
3285 }
3286
3287 if (win->GetChildren().GetCount() > 0) {
3288 depth++;
3289 wxWindow *w = win;
3290 DimeControl(w, col, window_back_color, ctrl_back_color, text_color,
3291 uitext, udkrd, gridline);
3292 depth--;
3293 }
3294 }
3295}
ArrayOfMmsiProperties g_MMSI_Props_Array
Global instance.
unsigned g_OwnShipmmsi
Global instance.
Class AisDecoder and helpers.
Global state for AIS decoder.
Chart canvas configuration state
General chart base definitions.
Charts database management
ChartGroupArray * g_pGroupArray
Global instance.
Definition chartdbs.cpp:61
Generic Chart canvas base.
wxString GetFullConfigDesc(int i) const
Gets description of font at index i.
Definition font_mgr.cpp:360
bool AddAuxKey(wxString key)
Adds new plugin-defined font configuration key.
Definition font_mgr.cpp:653
void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc)
Loads font settings from a string descriptor.
Definition font_mgr.cpp:387
static wxString GetFontConfigKey(const wxString &description)
Creates configuration key from UI element name by combining locale with hash.
Definition font_mgr.cpp:125
int GetNumFonts(void) const
Gets the total number of font configurations currently loaded.
Definition font_mgr.cpp:322
wxArrayString & GetAuxKeyArray()
Gets array of plugin-defined font configuration keys.
Definition font_mgr.h:200
Represents a layer of chart objects in OpenCPN.
Definition layer.h:44
static int config_to_ui(double value)
Convert configuration 1.02..3.0 value to slider scale 1..100.
Definition navutil.h:162
static double ui_to_config(int slider_pos)
Convert a slider scale 1-100 value to configuration value 1.02..3.0.
Definition navutil.h:157
Represents a waypoint or mark within the navigation system.
Definition route_point.h:71
Represents a navigational route in the navigation system.
Definition route.h:99
Represents a track, which is a series of connected track points.
Definition track.h:117
double view_scale_ppm
Requested view scale in physical pixels per meter (ppm), before applying projections.
Definition viewport.h:204
double rotation
Rotation angle of the viewport in radians.
Definition viewport.h:214
double clon
Center longitude of the viewport in degrees.
Definition viewport.h:199
double clat
Center latitude of the viewport in degrees.
Definition viewport.h:197
Encapsulates persistent canvas configuration.
double iLat
Latitude of the center of the chart, in degrees.
bool bShowOutlines
Display chart outlines.
wxSize canvasSize
Canvas dimensions.
bool bShowDepthUnits
Display depth unit indicators.
double iLon
Longitude of the center of the chart, in degrees.
double iRotation
Initial rotation angle in radians.
bool bCourseUp
Orient display to course up.
bool bQuilt
Enable chart quilting.
bool bFollow
Enable vessel following mode.
double iScale
Initial chart scale factor.
bool bShowENCText
Display ENC text elements.
bool bShowAIS
Display AIS targets.
bool bShowGrid
Display coordinate grid.
ChartCanvas * canvas
Pointer to associated chart canvas.
bool bShowCurrents
Display current information.
bool bShowTides
Display tide information.
bool bLookahead
Enable lookahead mode.
bool bHeadUp
Orient display to heading up.
bool bAttenAIS
Enable AIS target attenuation.
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:60
Class cm93chart and helpers – CM93 chart state.
Global variables reflecting command line options and arguments.
Config file user configuration interface.
int g_iTempFormat
User-selected temperature unit format for display and input.
bool g_bsmoothpanzoom
Controls how the chart panning and zooming smoothing is done during user interactions.
int g_iHeightFormat
User-selected height (vertical, above reference datum) unit format for display and input.
bool g_always_send_rmb_rmc
Always send RMB and RMC n0183 messages even if there is no active route.
int g_nDepthUnitDisplay
User-selected depth (below surface) unit format for display and input.
wxString g_winPluginDir
Base plugin directory on Windows.
wxString g_dm_logfile
Last Data Monitor log file.
bool g_bRollover
enable/disable mouse rollover GUI effects
bool g_bShowTide
not used
int g_iSpeedFormat
User-selected speed unit format for display and input.
int g_COGAvgSec
COG average period for Course Up Mode (sec).
wxString g_default_font_facename
Default font size for user interface elements such as menus, dialogs, etc.
int g_iDistanceFormat
User-selected distance (horizontal) unit format for display and input.
wxString g_datetime_format
Date/time format to use when formatting date/time strings.
std::vector< size_t > g_config_display_size_mm
Size of pysical screen in millimeters.
bool g_bDisplayGrid
Should lat/lon grid be displayed ?
Global variables stored in configuration file.
std::vector< ConnectionParams * > & TheConnectionParams()
Return global list of connections.
Connection parameters.
Extern C linked utilities.
std::vector< OCPN_MonitorInfo > g_monitor_info
Information about the monitors connected to the system.
Definition displays.cpp:45
Display utilities.
NavmsgFilter Read(const std::string &name)
Read filter with given name from disk.
bool Write(const NavmsgFilter &filter, const std::string &name)
Write contents for given filter to disk.
Font list manager.
OpenCPN Georef utility.
OpenGL chart rendering canvas.
Platform independent GL includes.
Global variables Listen()/Notify() wrapper.
size_t g_current_monitor
Current monitor displaying main application frame.
Definition gui_vars.cpp:75
double vLat
Virtual lat from chcanv popup.
Definition gui_vars.cpp:72
double vLon
Virtual lon from chcanv popup.
Definition gui_vars.cpp:73
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
GUI constant definitions.
Chart object layer.
LayerList * pLayerList
Global instance.
Definition layer.cpp:23
Multiplexer class and helpers.
MySQL based storage for routes, tracks, etc.
MyConfig * pConfig
Global instance.
Definition navutil.cpp:118
wxDateTime toUsrDateTime(const wxDateTime ts, const int format, const double lon)
Converts a timestamp from UTC to the user's preferred time format.
Definition navutil.cpp:2923
wxDateTime fromUsrDateTime(const wxDateTime ts, const int format, const double lon)
Converts a timestamp from a user's preferred time format to UTC.
Definition navutil.cpp:2963
Utility functions.
MyConfig * pConfig
Global instance.
Definition navutil.cpp:118
Navigation Utility Functions without GUI dependencies.
OCPNPlatform * g_Platform
Global instance.
OpenCPN Platform specific support utilities.
PlugIn Object Definition/API.
Layer to use wxDC or opengl.
double gLat
Vessel's current latitude in decimal degrees.
Definition own_ship.cpp:26
double gLon
Vessel's current longitude in decimal degrees.
Definition own_ship.cpp:27
Position, course, speed, etc.
Tools to send data to plugins.
Route abstraction.
wxColour g_colourWaypointRangeRingsColour
Global instance.
int g_LayerIdx
Global instance.
#define LMTINPUT
Format date/time using the remote location LMT time.
#define GLOBAL_SETTINGS_INPUT
Format date/time according to global OpenCPN settings.
#define UTCINPUT
Format date/time in UTC.
#define LTINPUT
Format date/time using timezone configured in the operating system.
RouteList * pRouteList
Global instance.
Definition routeman.cpp:66
float g_ChartScaleFactorExp
Global instance.
Definition routeman.cpp:68
Route Manager.
Selected route, segment, waypoint, etc.
Chart Symbols.
Abstract gFrame/MyFrame interface.
std::vector< Track * > g_TrackList
Global instance.
Definition track.cpp:97
Recorded track abstraction.