OpenCPN Partial API docs
Loading...
Searching...
No Matches
config_mgr.cpp
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2018 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, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#include "gl_headers.h" // Must be included before anything using GL stuff
25
26#ifdef __MINGW32__
27#undef IPV6STRICT // mingw FTBS fix: missing struct ip_mreq
28#include <windows.h>
29#endif
30
31#include <algorithm>
32#include <list>
33#include <locale>
34#include <stdlib.h>
35
36#include <time.h>
37
38#include <wx/colour.h>
39#include <wx/fileconf.h>
40#include <wx/filename.h>
41#include <wx/log.h>
42#include <wx/statline.h>
43#include <wx/string.h>
44
45#include "model/ais_decoder.h"
47#include "model/config_vars.h"
48#include "model/gui_vars.h"
49#include "model/georef.h"
50#include "model/multiplexer.h"
51#include "model/route_point.h"
52
53#include "ais.h"
54#include "chartdb.h"
55#include "chcanv.h"
56#include "config_mgr.h"
57#include "font_mgr.h"
58#include "layer.h"
59#include "navutil.h"
60#include "ocpn_gl_options.h"
61#include "ocpn_platform.h"
62#include "ocpn_plugin.h"
63#include "route_prop_dlg_impl.h"
64#include "s52plib.h"
65#include "s52utils.h"
66#include "user_colors.h"
67
68extern s52plib *ps52plib; // In a library...
69
70#if !defined(NAN)
71static const long long lNaN = 0xfff8000000000000;
72#define NAN (*(double *)&lNaN)
73#endif
74
75ConfigMgr *ConfigMgr::instance = NULL;
76
77//--------------------------------------------------------------------------
78//
79// Utility functions
80//
81//--------------------------------------------------------------------------
82int GetRandomNumber(int range_min, int range_max) {
83 long u = (long)wxRound(
84 ((double)rand() / ((double)(RAND_MAX) + 1) * (range_max - range_min)) +
85 range_min);
86 return (int)u;
87}
88
89// Helper conditional file name dir slash
90void appendOSDirSlash(wxString *pString);
91
93public:
96
97 OCPNConfigObject(int canvas_config);
98
99 void Init();
100 wxPanel *GetSettingsPanel();
101
102 int m_canvasConfig;
103 wxString m_GUID;
104 wxString templateFileName;
105 wxString m_title;
106 wxString m_description;
107};
108
109OCPNConfigObject::OCPNConfigObject() { Init(); }
110
111OCPNConfigObject::OCPNConfigObject(int canvas_config) {
112 Init();
113 m_canvasConfig = canvas_config;
114}
115
116OCPNConfigObject::~OCPNConfigObject() {}
117
118void OCPNConfigObject::Init() { m_canvasConfig = 0; }
119
120//--------------------------------------------------------------------
121// Private ( XML encoded ) catalog of available configurations
122//--------------------------------------------------------------------
123
125public:
128
129 bool AddConfig(OCPNConfigObject *config, unsigned int flags);
130 bool RemoveConfig(wxString GUID);
131
132 void SetRootConfigNode();
133 bool IsOpenCPN();
134 bool SaveFile(const wxString filename);
135 bool LoadFile(const wxString filename);
136
137 pugi::xml_node m_config_root;
138};
139
140OCPNConfigCatalog::OCPNConfigCatalog() : pugi::xml_document() {}
141
142OCPNConfigCatalog::~OCPNConfigCatalog() {}
143
144void OCPNConfigCatalog::SetRootConfigNode() {
145 if (!strlen(m_config_root.name())) {
146 m_config_root = append_child("configs");
147 m_config_root.append_attribute("version") = "1.0";
148 m_config_root.append_attribute("creator") = "OpenCPN";
149 m_config_root.append_attribute("xmlns:xsi") =
150 "http://www.w3.org/2001/XMLSchema-instance";
151 m_config_root.append_attribute("xmlns") =
152 "http://www.topografix.com/GPX/1/1";
153 m_config_root.append_attribute("xmlns:gpxx") =
154 "http://www.garmin.com/xmlschemas/GpxExtensions/v3";
155 m_config_root.append_attribute("xsi:schemaLocation") =
156 "http://www.topografix.com/GPX/1/1 "
157 "http://www.topografix.com/GPX/1/1/gpx.xsd";
158 m_config_root.append_attribute("xmlns:opencpn") = "http://www.opencpn.org";
159 }
160}
161
162bool OCPNConfigCatalog::IsOpenCPN() {
163 for (pugi::xml_attribute attr = root().first_child().first_attribute(); attr;
164 attr = attr.next_attribute())
165 if (!strcmp(attr.name(), "creator") && !strcmp(attr.value(), "OpenCPN"))
166 return true;
167 return false;
168}
169
170bool OCPNConfigCatalog::SaveFile(const wxString filename) {
171 save_file(filename.fn_str(), " ");
172 return true;
173}
174
175bool OCPNConfigCatalog::LoadFile(const wxString filename) {
176 load_file(filename.fn_str());
177 m_config_root = this->child("configs");
178 return true;
179}
180
181bool OCPNConfigCatalog::AddConfig(OCPNConfigObject *config,
182 unsigned int flags) {
183 pugi::xml_node node = m_config_root.append_child("config");
184
185 node.append_attribute("GUID") = config->m_GUID.mb_str();
186
187 // Handle non-ASCII characters as UTF8
188 wxCharBuffer abuf = config->m_title.ToUTF8();
189 if (abuf.data())
190 node.append_attribute("title") = abuf.data();
191 else
192 node.append_attribute("title") = "Substitute Title";
193
194 abuf = config->m_description.ToUTF8();
195 if (abuf.data())
196 node.append_attribute("description") = abuf.data();
197 else
198 node.append_attribute("description") = "Substitute Description";
199
200 node.append_attribute("templateFile") = config->templateFileName.mb_str();
201
202 return true;
203}
204
205bool OCPNConfigCatalog::RemoveConfig(wxString GUID) {
206 for (pugi::xml_node child = m_config_root.first_child(); child;) {
207 pugi::xml_node next = child.next_sibling();
208 const char *guid = child.attribute("GUID").value();
209
210 if (!strcmp(guid, GUID.mb_str())) {
211 child.parent().remove_child(child);
212 return true;
213 }
214
215 child = next;
216 }
217
218 return false;
219}
220
221//--------------------------------------------------------------------
222// ConfigPanel implementation
223//--------------------------------------------------------------------
224
225ConfigPanel::ConfigPanel(OCPNConfigObject *config, wxWindow *parent,
226 wxWindowID id, const wxPoint &pos, const wxSize &size)
227 : wxPanel(parent, id, pos, size, wxSIMPLE_BORDER)
228
229{
230 m_config = config;
231 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
232 SetSizer(mainSizer);
233
234 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Title")));
235 mainSizer->Add(new wxStaticText(this, wxID_ANY, config->m_title));
236
237 mainSizer->Add(new wxStaticLine(this, wxID_ANY), 0, wxEXPAND | wxALL, 1);
238
239 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Description")));
240 mainSizer->Add(new wxStaticText(this, wxID_ANY, config->m_description));
241
242 SetMinSize(wxSize(-1, 6 * GetCharHeight()));
243
244 SetBackgroundColour(
245 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW));
246 // Connect(wxEVT_LEFT_DOWN,
247 // wxMouseEventHandler(ConfigPanel::OnConfigPanelMouseSelected), NULL, this);
248}
249
250ConfigPanel::~ConfigPanel() {}
251
252void ConfigPanel::OnConfigPanelMouseSelected(wxMouseEvent &event) {
253 // SetBackgroundColour(*wxRED);
254 // event.Skip();
255}
256
257wxString ConfigPanel::GetConfigGUID() { return m_config->m_GUID; }
258
259//--------------------------------------------------------------------
260// ConfigMgr implementation
261// Singleton Pattern
262//--------------------------------------------------------------------
263
264ConfigMgr &ConfigMgr::Get() {
265 if (!instance) instance = new ConfigMgr;
266 return *instance;
267}
268
269void ConfigMgr::Shutdown() {
270 if (instance) {
271 delete instance;
272 instance = NULL;
273 }
274}
275
276ConfigMgr::ConfigMgr() {
277 Init();
278
279 // Load any existing configs from the catalog
280 LoadCatalog();
281}
282
283ConfigMgr::~ConfigMgr() {
284 configList->clear();
285 delete configList;
286}
287
288void ConfigMgr::Init() {
289 m_configDir = g_Platform->GetPrivateDataDir();
290 appendOSDirSlash(&m_configDir);
291 m_configDir.append("Configs");
292 appendOSDirSlash(&m_configDir);
293 if (!wxFileName::DirExists(m_configDir)) {
294 wxFileName::Mkdir(m_configDir);
295 }
296
297 m_configCatalogName = g_Platform->GetPrivateDataDir();
298 appendOSDirSlash(&m_configCatalogName);
299 m_configCatalogName.append("Configs");
300 appendOSDirSlash(&m_configCatalogName);
301 m_configCatalogName.append("configs.xml");
302
303 // Create the catalog, if necessary
304 if (!wxFileExists(m_configCatalogName)) {
305 wxLogMessage("Creating new Configs catalog: " + m_configCatalogName);
306
308 cat->SetRootConfigNode();
309 cat->SaveFile(m_configCatalogName);
310 delete cat;
311 }
312
313 m_configCatalog = new OCPNConfigCatalog();
314
315 configList = new ConfigObjectList;
316
317 // Add the default "Recovery" template
318 wxString t_title = _("Recovery Template");
319 wxString t_desc =
320 _("Apply this template to return to a known safe configuration");
321 CreateNamedConfig(t_title, t_desc, "11111111-1111-1111-1111-111111111111");
322}
323
324bool ConfigMgr::LoadCatalog() {
325 wxLogMessage("Loading Configs catalog: " + m_configCatalogName);
326 m_configCatalog->LoadFile(m_configCatalogName);
327
328 // Parse the config catalog
329 pugi::xml_node objects = m_configCatalog->child("configs");
330
331 // pugi::xml_node node = m_config_root.append_child("config");
332
333 // node.append_attribute("GUID") = config->m_GUID.mb_str();
334 // node.append_attribute("title") = config->m_title.mb_str();
335 // node.append_attribute("description") = config->m_description.mb_str();
336 // node.append_attribute("templateFile") = config->templateFileName.mb_str();
337
338 for (pugi::xml_node object = objects.first_child(); object;
339 object = object.next_sibling()) {
340 if (!strcmp(object.name(), "config")) {
341 // Check the GUID for duplicates
342 wxString testGUID =
343 wxString::FromUTF8(object.attribute("GUID").as_string());
344
345 bool bFound = false;
346 for (auto it = configList->begin(); it != configList->end(); ++it) {
347 OCPNConfigObject *look = *it;
348 if (look->m_GUID == testGUID) {
349 bFound = true;
350 break;
351 }
352 }
353
354 if (!bFound) {
355 OCPNConfigObject *newConfig = new OCPNConfigObject;
356
357 newConfig->m_GUID =
358 wxString::FromUTF8(object.attribute("GUID").as_string());
359 newConfig->m_title =
360 wxString::FromUTF8(object.attribute("title").as_string());
361 newConfig->m_description =
362 wxString::FromUTF8(object.attribute("description").as_string());
363 newConfig->templateFileName =
364 wxString::FromUTF8(object.attribute("templateFile").as_string());
365
366 // Add to the class list of configs
367 configList->push_back(newConfig);
368 }
369 }
370 }
371
372 return true;
373}
374
375bool ConfigMgr::SaveCatalog() {
376 m_configCatalog->SaveFile(m_configCatalogName);
377
378 return true;
379}
380
381wxString ConfigMgr::CreateNamedConfig(const wxString &title,
382 const wxString &description,
383 wxString UUID) {
384 wxString GUID;
385
386 // Must have title
387 if (title.IsEmpty()) return GUID;
388
390
391 // If no UUID is passed, then create a new GUID for this config
392 if (UUID.IsEmpty())
393 GUID = GetUUID();
394 else
395 GUID = UUID;
396
397 pConfig->m_GUID = GUID;
398 pConfig->m_title = title;
399 pConfig->m_description = description;
400
401 if (UUID.IsEmpty()) {
402 // create template file name
403 pConfig->templateFileName = "OCPNTemplate-" + GUID + ".conf";
404
405 // Save the template contents
406 wxString templateFullFileName = GetConfigDir() + pConfig->templateFileName;
407 if (!SaveTemplate(templateFullFileName)) {
408 wxLogMessage("Unable to save template titled: " + title +
409 " as file: " + templateFullFileName);
410 delete pConfig;
411 return "";
412 }
413 }
414
415 // Add this config to the catalog
416 if (!m_configCatalog->AddConfig(pConfig, 0)) {
417 wxLogMessage("Unable to add config to catalog...Title: " + title);
418 delete pConfig;
419 return "";
420 }
421
422 // Add to the class list of configs
423 configList->push_back(pConfig);
424
425 if (UUID.IsEmpty()) SaveCatalog();
426
427 return GUID;
428}
429
430bool ConfigMgr::DeleteConfig(wxString GUID) {
431 OCPNConfigObject *cfg = GetConfig(GUID);
432 if (!cfg) return false;
433
434 // Find and delete the template file
435 wxString templateFullFileName = GetConfigDir() + cfg->templateFileName;
436 if (wxFileExists(templateFullFileName)) wxRemoveFile(templateFullFileName);
437
438 // Remove the config from the catalog
439 bool rv = m_configCatalog->RemoveConfig(GUID);
440
441 if (rv) SaveCatalog();
442
443 // Remove the config from the member list without deleting it
444 auto found = std::find(configList->begin(), configList->end(), cfg);
445 if (found != configList->end()) configList->erase(found);
446
447 return rv;
448}
449
450wxPanel *ConfigMgr::GetConfigPanel(wxWindow *parent, wxString GUID) {
451 wxPanel *retPanel = NULL;
452
453 // Find the GUID-matching config in the member list
454 OCPNConfigObject *config = GetConfig(GUID);
455
456 // Found it?
457 if (config) {
458 retPanel = new ConfigPanel(config, parent);
459 }
460
461 return retPanel;
462}
463
464OCPNConfigObject *ConfigMgr::GetConfig(wxString GUID) {
465 // Find the GUID-matching config in the member list
466 for (auto it = configList->begin(); it != configList->end(); ++it) {
467 OCPNConfigObject *look = *it;
468 if (look->m_GUID == GUID) {
469 return look;
470 break;
471 }
472 }
473 return NULL;
474}
475
476wxString ConfigMgr::GetTemplateTitle(wxString GUID) {
477 for (auto it = configList->begin(); it != configList->end(); ++it) {
478 OCPNConfigObject *look = *it;
479 if (look->m_GUID == GUID) {
480 return look->m_title;
481 break;
482 }
483 }
484 return wxEmptyString;
485}
486
487wxArrayString ConfigMgr::GetConfigGUIDArray() {
488 wxArrayString ret_val;
489
490 for (auto it = configList->begin(); it != configList->end(); ++it) {
491 OCPNConfigObject *look = *it;
492 ret_val.Add(look->m_GUID);
493 }
494 return ret_val;
495}
496
497bool ConfigMgr::ApplyConfigGUID(wxString GUID) {
498 // Find the GUID-matching config in the member list
499 OCPNConfigObject *config = GetConfig(GUID);
500
501 // Found it?
502 if (config) {
503 wxString thisConfig = GetConfigDir() + config->templateFileName;
504
505 // Special case for Recovery template
506 if (GUID.StartsWith("11111111")) {
507 thisConfig =
508 *GetpSharedDataLocation() + "configs/OCPNTemplate-Recovery.conf";
509 }
510
511 MyConfig fconf(thisConfig);
512
513 // Load the template contents, without resetting defaults
514 fconf.LoadMyConfigRaw(true);
515
516 // Load Canvas configs, applying only the "templateable" items
517 fconf.LoadCanvasConfigs(true);
518
519 if (ps52plib && ps52plib->m_bOK) fconf.LoadS57Config();
520
521 return true;
522 }
523
524 return false;
525}
526
527// RFC4122 version 4 compliant random UUIDs generator.
528wxString ConfigMgr::GetUUID() {
529 wxString str;
530 struct {
531 int time_low;
532 int time_mid;
533 int time_hi_and_version;
534 int clock_seq_hi_and_rsv;
535 int clock_seq_low;
536 int node_hi;
537 int node_low;
538 } uuid;
539
540 uuid.time_low = GetRandomNumber(
541 0, 2147483647); // FIXME: the max should be set to something like
542 // MAXINT32, but it doesn't compile un gcc...
543 uuid.time_mid = GetRandomNumber(0, 65535);
544 uuid.time_hi_and_version = GetRandomNumber(0, 65535);
545 uuid.clock_seq_hi_and_rsv = GetRandomNumber(0, 255);
546 uuid.clock_seq_low = GetRandomNumber(0, 255);
547 uuid.node_hi = GetRandomNumber(0, 65535);
548 uuid.node_low = GetRandomNumber(0, 2147483647);
549
550 /* Set the two most significant bits (bits 6 and 7) of the
551 * clock_seq_hi_and_rsv to zero and one, respectively. */
552 uuid.clock_seq_hi_and_rsv = (uuid.clock_seq_hi_and_rsv & 0x3F) | 0x80;
553
554 /* Set the four most significant bits (bits 12 through 15) of the
555 * time_hi_and_version field to 4 */
556 uuid.time_hi_and_version = (uuid.time_hi_and_version & 0x0fff) | 0x4000;
557
558 str.Printf("%08x-%04x-%04x-%02x%02x-%04x%08x", uuid.time_low, uuid.time_mid,
559 uuid.time_hi_and_version, uuid.clock_seq_hi_and_rsv,
560 uuid.clock_seq_low, uuid.node_hi, uuid.node_low);
561
562 return str;
563}
564
565bool ConfigMgr::SaveTemplate(wxString fileName) {
566 // Assuming the file exists, and is empty....
567
568 // Create a private wxFileConfig object
569 MyConfig *conf = new MyConfig(fileName);
570
571// Write out all the elements of a config template....
572
573// Temporarily suppress logging of trivial non-fatal wxLogSysError() messages
574// provoked by Android security...
575#ifdef __ANDROID__
576 wxLogNull logNo;
577#endif
578
579 // Global options and settings
580 conf->SetPath("/Settings");
581
582 conf->Write("InlandEcdis", g_bInlandEcdis);
583 conf->Write("UIexpert", g_bUIexpert);
584 conf->Write("SpaceDropMark", g_bSpaceDropMark);
585
586 conf->Write("ShowStatusBar", g_bShowStatusBar);
587#ifndef __WXOSX__
588 conf->Write("ShowMenuBar", g_bShowMenuBar);
589#endif
590 conf->Write("DefaultFontSize", g_default_font_size);
591
592 conf->Write("Fullscreen", g_bFullscreen);
593 conf->Write("ShowCompassWindow", g_bShowCompassWin);
594 conf->Write("SetSystemTime", s_bSetSystemTime);
595 conf->Write("ShowGrid", g_bDisplayGrid);
596 conf->Write("PlayShipsBells", g_bPlayShipsBells);
597 conf->Write("SoundDeviceIndex", g_iSoundDeviceIndex);
598 conf->Write("FullscreenToolbar", g_bFullscreenToolbar);
599 // conf->Write( "TransparentToolbar", g_bTransparentToolbar );
600 conf->Write("PermanentMOBIcon", g_bPermanentMOBIcon);
601 conf->Write("ShowLayers", g_bShowLayers);
602 conf->Write("AutoAnchorDrop", g_bAutoAnchorMark);
603 conf->Write("ShowChartOutlines", g_bShowOutlines);
604 conf->Write("ShowActiveRouteTotal", g_bShowRouteTotal);
605 conf->Write("ShowActiveRouteHighway", g_bShowActiveRouteHighway);
606 conf->Write("SDMMFormat", g_iSDMMFormat);
607 conf->Write("ShowChartBar", g_bShowChartBar);
608
609 conf->Write("GUIScaleFactor", g_GUIScaleFactor);
610 conf->Write("ChartObjectScaleFactor", g_ChartScaleFactor);
611 conf->Write("ShipScaleFactor", g_ShipScaleFactor);
612
613 conf->Write("ShowTrue", g_bShowTrue);
614 conf->Write("ShowMag", g_bShowMag);
615 conf->Write("UserMagVariation", wxString::Format("%.2f", g_UserVar));
616
617 conf->Write("CM93DetailFactor", g_cm93_zoom_factor);
618 conf->Write("CM93DetailZoomPosX", g_detailslider_dialog_x);
619 conf->Write("CM93DetailZoomPosY", g_detailslider_dialog_y);
620 conf->Write("ShowCM93DetailSlider", g_bShowDetailSlider);
621
622 conf->Write("SkewToNorthUp", g_bskew_comp);
623
624 conf->Write("ZoomDetailFactor", g_chart_zoom_modifier_raster);
625 conf->Write("ZoomDetailFactorVector", g_chart_zoom_modifier_vector);
626
627 conf->Write("SmoothPanZoom", g_bsmoothpanzoom);
628
629 conf->Write("CourseUpMode", g_bCourseUp);
630 if (!g_bInlandEcdis) conf->Write("LookAheadMode", g_bLookAhead);
631 conf->Write("TenHzUpdate", g_btenhertz);
632
633 conf->Write("COGUPAvgSeconds", g_COGAvgSec);
634 conf->Write("UseMagAPB", g_bMagneticAPB);
635
636 conf->Write("OwnshipCOGPredictorMinutes", g_ownship_predictor_minutes);
637 conf->Write("OwnshipCOGPredictorWidth", g_cog_predictor_width);
638 conf->Write("OwnshipHDTPredictorMiles", g_ownship_HDTpredictor_miles);
639 conf->Write("OwnShipIconType", g_OwnShipIconType);
640 conf->Write("OwnShipLength", g_n_ownship_length_meters);
641 conf->Write("OwnShipWidth", g_n_ownship_beam_meters);
642 conf->Write("OwnShipGPSOffsetX", g_n_gps_antenna_offset_x);
643 conf->Write("OwnShipGPSOffsetY", g_n_gps_antenna_offset_y);
644 conf->Write("OwnShipMinSize", g_n_ownship_min_mm);
645
646 conf->Write("RouteArrivalCircleRadius",
647 wxString::Format("%.3f", g_n_arrival_circle_radius));
648 conf->Write("ChartQuilting", g_bQuiltEnable);
649
650 conf->Write("StartWithTrackActive", g_bTrackCarryOver);
651 conf->Write("AutomaticDailyTracks", g_bTrackDaily);
652 conf->Write("TrackRotateAt", g_track_rotate_time);
653 conf->Write("TrackRotateTimeType", g_track_rotate_time_type);
654 conf->Write("HighlightTracks", g_bHighliteTracks);
655
656 conf->Write("DateTimeFormat", g_datetime_format);
657
658 conf->Write("InitialStackIndex", g_restore_stackindex);
659 conf->Write("InitialdBIndex", g_restore_dbindex);
660
661 conf->Write("AnchorWatch1GUID", g_AW1GUID);
662 conf->Write("AnchorWatch2GUID", g_AW2GUID);
663
664 conf->Write("ToolbarX", g_maintoolbar_x);
665 conf->Write("ToolbarY", g_maintoolbar_y);
666 conf->Write("ToolbarOrient", g_maintoolbar_orient);
667
668 conf->Write("iENCToolbarX", g_iENCToolbarPosX);
669 conf->Write("iENCToolbarY", g_iENCToolbarPosY);
670
671 if (!g_bInlandEcdis) {
672 conf->Write("GlobalToolbarConfig", g_toolbarConfig);
673 conf->Write("DistanceFormat", g_iDistanceFormat);
674 conf->Write("SpeedFormat", g_iSpeedFormat);
675 conf->Write("WindSpeedFormat", g_iWindSpeedFormat);
676 conf->Write("ShowDepthUnits", g_bShowDepthUnits);
677 }
678
679 conf->Write("MobileTouch", g_btouch);
680 conf->Write("ResponsiveGraphics", g_bresponsive);
681
682 conf->Write("AutoHideToolbar", g_bAutoHideToolbar);
683 conf->Write("AutoHideToolbarSecs", g_nAutoHideToolbar);
684
685 wxString st0;
686 for (const auto &mm : g_config_display_size_mm) {
687 st0.Append(wxString::Format("%zu,", mm));
688 }
689 st0.RemoveLast(); // Strip last comma
690 conf->Write("DisplaySizeMM", st0);
691 conf->Write("DisplaySizeManual", g_config_display_size_manual);
692
693 conf->Write("PlanSpeed", wxString::Format("%.2f", g_PlanSpeed));
694
695#if 0
696 wxString vis, invis;
697 LayerList::iterator it;
698 int index = 0;
699 for( it = ( *pLayerList ).begin(); it != ( *pLayerList ).end(); ++it, ++index ) {
700 Layer *lay = (Layer *) ( *it );
701 if( lay->IsVisibleOnChart() ) vis += ( lay->m_LayerName ) + ";";
702 else
703 invis += ( lay->m_LayerName ) + ";";
704 }
705 conf->Write( "VisibleLayers", vis );
706 conf->Write( "InvisibleLayers", invis );
707#endif
708
709 conf->Write("Locale", g_locale);
710 conf->Write("LocaleOverride", g_localeOverride);
711
712 // LIVE ETA OPTION
713 conf->Write("LiveETA", g_bShowLiveETA);
714 conf->Write("DefaultBoatSpeed", g_defaultBoatSpeed);
715
716 // S57 Object Filter Settings
717 conf->SetPath("/Settings/ObjectFilter");
718
719 if (ps52plib) {
720 for (unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
721 iPtr++) {
722 OBJLElement *pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
723
724 wxString st1("viz");
725 char name[7];
726 strncpy(name, pOLE->OBJLName, 6);
727 name[6] = 0;
728 st1.Append(wxString(name, wxConvUTF8));
729 conf->Write(st1, pOLE->nViz);
730 }
731 }
732
733 // Global State
734
735 conf->SetPath("/Settings/GlobalState");
736
737 // Various Options
738 if (!g_bInlandEcdis)
739 conf->Write("nColorScheme", (int)user_colors::GetColorScheme());
740
741 // AIS
742 conf->SetPath("/Settings/AIS");
743
744 conf->Write("bNoCPAMax", g_bCPAMax);
745 conf->Write("NoCPAMaxNMi", g_CPAMax_NM);
746 conf->Write("bCPAWarn", g_bCPAWarn);
747 conf->Write("CPAWarnNMi", g_CPAWarn_NM);
748 conf->Write("bTCPAMax", g_bTCPA_Max);
749 conf->Write("TCPAMaxMinutes", g_TCPA_Max);
750 conf->Write("bMarkLostTargets", g_bMarkLost);
751 conf->Write("MarkLost_Minutes", g_MarkLost_Mins);
752 conf->Write("bRemoveLostTargets", g_bRemoveLost);
753 conf->Write("RemoveLost_Minutes", g_RemoveLost_Mins);
754 conf->Write("bShowCOGArrows", g_bShowCOG);
755 conf->Write("CogArrowMinutes", g_ShowCOG_Mins);
756 conf->Write("bShowTargetTracks", g_bAISShowTracks);
757 conf->Write("TargetTracksMinutes", g_AISShowTracks_Mins);
758
759 conf->Write("bHideMooredTargets", g_bHideMoored);
760 conf->Write("MooredTargetMaxSpeedKnots", g_ShowMoored_Kts);
761
762 conf->Write("bAISAlertDialog", g_bAIS_CPA_Alert);
763 conf->Write("bAISAlertAudio", g_bAIS_CPA_Alert_Audio);
764 conf->Write("AISAlertAudioFile", g_sAIS_Alert_Sound_File);
765 conf->Write("bAISAlertSuppressMoored", g_bAIS_CPA_Alert_Suppress_Moored);
766 conf->Write("bShowAreaNotices", g_bShowAreaNotices);
767 conf->Write("bDrawAISSize", g_bDrawAISSize);
768 conf->Write("bDrawAISRealtime", g_bDrawAISRealtime);
769 conf->Write("AISRealtimeMinSpeedKnots", g_AIS_RealtPred_Kts);
770 conf->Write("bShowAISName", g_bShowAISName);
771 conf->Write("ShowAISTargetNameScale", g_Show_Target_Name_Scale);
772 conf->Write("bWplIsAprsPositionReport", g_bWplUsePosition);
773 conf->Write("WplSelAction", g_WplAction);
774 conf->Write("AISCOGPredictorWidth", g_ais_cog_predictor_width);
775 conf->Write("bShowScaledTargets", g_bAllowShowScaled);
776 conf->Write("AISScaledNumber", g_ShowScaled_Num);
777 conf->Write("AISScaledNumberWeightSOG", g_ScaledNumWeightSOG);
778 conf->Write("AISScaledNumberWeightCPA", g_ScaledNumWeightCPA);
779 conf->Write("AISScaledNumberWeightTCPA", g_ScaledNumWeightTCPA);
780 conf->Write("AISScaledNumberWeightRange", g_ScaledNumWeightRange);
781 conf->Write("AISScaledNumberWeightSizeOfTarget", g_ScaledNumWeightSizeOfT);
782 conf->Write("AISScaledSizeMinimal", g_ScaledSizeMinimal);
783 conf->Write("AISShowScaled", g_bShowScaled);
784
785 conf->Write("AlertDialogSizeX", g_ais_alert_dialog_sx);
786 conf->Write("AlertDialogSizeY", g_ais_alert_dialog_sy);
787 conf->Write("AlertDialogPosX", g_ais_alert_dialog_x);
788 conf->Write("AlertDialogPosY", g_ais_alert_dialog_y);
789 conf->Write("QueryDialogPosX", g_ais_query_dialog_x);
790 conf->Write("QueryDialogPosY", g_ais_query_dialog_y);
791 conf->Write("AISTargetListPerspective", g_AisTargetList_perspective);
792 conf->Write("AISTargetListRange", g_AisTargetList_range);
793 conf->Write("AISTargetListSortColumn", g_AisTargetList_sortColumn);
794 conf->Write("bAISTargetListSortReverse", g_bAisTargetList_sortReverse);
795 conf->Write("AISTargetListColumnSpec", g_AisTargetList_column_spec);
796 conf->Write("AISTargetListColumnOrder", g_AisTargetList_column_order);
797 conf->Write("S57QueryDialogSizeX", g_S57_dialog_sx);
798 conf->Write("S57QueryDialogSizeY", g_S57_dialog_sy);
799 conf->Write("bAISRolloverShowClass", g_bAISRolloverShowClass);
800 conf->Write("bAISRolloverShowCOG", g_bAISRolloverShowCOG);
801 conf->Write("bAISRolloverShowCPA", g_bAISRolloverShowCPA);
802 conf->Write("bAISAlertAckTimeout", g_bAIS_ACK_Timeout);
803 conf->Write("AlertAckTimeoutMinutes", g_AckTimeout_Mins);
804
805 conf->SetPath("/Settings/GlobalState");
806 if (ps52plib) {
807 conf->Write("bShowS57Text", ps52plib->GetShowS57Text());
808 conf->Write("bShowS57ImportantTextOnly",
809 ps52plib->GetShowS57ImportantTextOnly());
810 if (!g_bInlandEcdis)
811 conf->Write("nDisplayCategory", (long)ps52plib->GetDisplayCategory());
812 conf->Write("nSymbolStyle", (int)ps52plib->m_nSymbolStyle);
813 conf->Write("nBoundaryStyle", (int)ps52plib->m_nBoundaryStyle);
814
815 conf->Write("bShowSoundg", ps52plib->m_bShowSoundg);
816 conf->Write("bShowMeta", ps52plib->m_bShowMeta);
817 conf->Write("bUseSCAMIN", ps52plib->m_bUseSCAMIN);
818 conf->Write("bUseSUPER_SCAMIN", ps52plib->m_bUseSUPER_SCAMIN);
819 conf->Write("bShowAtonText", ps52plib->m_bShowAtonText);
820 conf->Write("bShowLightDescription", ps52plib->m_bShowLdisText);
821 conf->Write("bExtendLightSectors", ps52plib->m_bExtendLightSectors);
822 conf->Write("bDeClutterText", ps52plib->m_bDeClutterText);
823 conf->Write("bShowNationalText", ps52plib->m_bShowNationalTexts);
824
825 conf->Write("S52_MAR_SAFETY_CONTOUR",
826 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
827 conf->Write("S52_MAR_SHALLOW_CONTOUR",
828 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
829 conf->Write("S52_MAR_DEEP_CONTOUR",
830 S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
831 conf->Write("S52_MAR_TWO_SHADES", S52_getMarinerParam(S52_MAR_TWO_SHADES));
832 conf->Write("S52_DEPTH_UNIT_SHOW", ps52plib->m_nDepthUnitDisplay);
833 }
834
835 conf->SetPath("/Settings/Others");
836
837 // Radar rings
838 conf->Write("ShowRadarRings", (bool)(g_iNavAidRadarRingsNumberVisible >
839 0)); // 3.0.0 config support
840 conf->Write("RadarRingsNumberVisible", g_iNavAidRadarRingsNumberVisible);
841 g_bNavAidRadarRingsShown = g_iNavAidRadarRingsNumberVisible > 0;
842 conf->Write("RadarRingsStep", g_fNavAidRadarRingsStep);
843 conf->Write("RadarRingsStepUnits", g_pNavAidRadarRingsStepUnits);
844 conf->Write("RadarRingsColour",
845 g_colourOwnshipRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
846
847 // Waypoint Radar rings
848 conf->Write("WaypointRangeRingsNumber", g_iWaypointRangeRingsNumber);
849 conf->Write("WaypointRangeRingsStep", g_fWaypointRangeRingsStep);
850 conf->Write("WaypointRangeRingsStepUnits", g_iWaypointRangeRingsStepUnits);
851 conf->Write("WaypointRangeRingsColour",
852 g_colourWaypointRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
853
854 conf->Write("ConfirmObjectDeletion", g_bConfirmObjectDelete);
855
856 // Waypoint dragging with mouse
857 conf->Write("WaypointPreventDragging", g_bWayPointPreventDragging);
858
859 conf->Write("EnableZoomToCursor", g_bEnableZoomToCursor);
860
861 conf->Write("TrackIntervalSeconds", g_TrackIntervalSeconds);
862 conf->Write("TrackDeltaDistance", g_TrackDeltaDistance);
863 conf->Write("TrackPrecision", g_nTrackPrecision);
864
865 conf->Write("RouteLineWidth", g_route_line_width);
866 conf->Write("TrackLineWidth", g_track_line_width);
867 conf->Write("TrackLineColour",
868 g_colourTrackLineColour.GetAsString(wxC2S_HTML_SYNTAX));
869 conf->Write("DefaultWPIcon", g_default_wp_icon);
870
871 // Fonts
872
873 // Store the persistent Auxiliary Font descriptor Keys
874 conf->SetPath("/Settings/AuxFontKeys");
875
876 wxArrayString keyArray = FontMgr::Get().GetAuxKeyArray();
877 for (unsigned int i = 0; i < keyArray.GetCount(); i++) {
878 wxString key;
879 key.Printf("Key%i", i);
880 wxString keyval = keyArray[i];
881 conf->Write(key, keyval);
882 }
883
884 wxString font_path;
885#ifdef __WXX11__
886 font_path = ("/Settings/X11Fonts");
887#endif
888
889#ifdef __WXGTK__
890 font_path = ("/Settings/GTKFonts");
891#endif
892
893#ifdef __WXMSW__
894 font_path = ("/Settings/MSWFonts");
895#endif
896
897#ifdef __WXMAC__
898 font_path = ("/Settings/MacFonts");
899#endif
900
901#ifdef __WXQT__
902 font_path = ("/Settings/QTFonts");
903#endif
904
905 conf->DeleteGroup(font_path);
906
907 conf->SetPath(font_path);
908
909 int nFonts = FontMgr::Get().GetNumFonts();
910
911 for (int i = 0; i < nFonts; i++) {
912 wxString cfstring(FontMgr::Get().GetConfigString(i));
913 wxString valstring = FontMgr::Get().GetFullConfigDesc(i);
914 conf->Write(cfstring, valstring);
915 }
916
917 // Save the per-canvas config options
918 conf->SaveCanvasConfigs();
919
920 conf->Flush();
921
922 delete conf;
923
924 return true;
925}
926
927bool ConfigMgr::CheckTemplateGUID(wxString GUID) {
928 bool rv = false;
929
930 OCPNConfigObject *config = GetConfig(GUID);
931 if (config) {
932 rv = CheckTemplate(GetConfigDir() + config->templateFileName);
933 }
934
935 return rv;
936}
937
938#define CHECK_INT(s, t) \
939 read_int = *t; \
940 if (!conf.Read(s, &read_int)) wxLogMessage(s); \
941 if ((int)*t != read_int) return false;
942
943#define CHECK_STR(s, t) \
944 val = t; \
945 conf.Read(s, &val); \
946 if (!t.IsSameAs(val)) return false;
947
948#define CHECK_STRP(s, t) \
949 conf.Read(s, &val); \
950 if (!t->IsSameAs(val)) return false;
951
952#define CHECK_FLT(s, t, eps) \
953 conf.Read(s, &val); \
954 val.ToDouble(&dval); \
955 if (fabs(dval - *t) > eps) return false;
956
957bool ConfigMgr::CheckTemplate(wxString fileName) {
958 bool rv = true;
959
960 int read_int;
961 wxString val;
962 double dval;
963
964 MyConfig conf(fileName);
965
966 // Global options and settings
967 conf.SetPath("/Settings");
968
969 CHECK_INT("UIexpert", &g_bUIexpert);
970
972
973 CHECK_INT("InlandEcdis", &g_bInlandEcdis);
974
975 CHECK_INT("SpaceDropMark", &g_bSpaceDropMark);
976
978
979#if 0
980 CHECK_INT( "DebugGDAL", &g_bGDAL_Debug );
981 CHECK_INT( "DebugNMEA", &g_nNMEADebug );
982 CHECK_INT( "DebugOpenGL", &g_bDebugOGL );
986 CHECK_INT( "DebugCM93", &g_bDebugCM93 );
987 CHECK_INT( "DebugS57", &g_bDebugS57 ); // Show LUP and Feature info in object query
988 CHECK_INT( "DebugBSBImg", &g_BSBImgDebug );
989 CHECK_INT( "DebugGPSD", &g_bDebugGPSD );
990#endif
991
992 CHECK_INT("DefaultFontSize", &g_default_font_size);
993
994 // Read( "GPSIdent", &g_GPS_Ident );
995 CHECK_INT("UseGarminHostUpload", &g_bGarminHostUpload);
996
997 CHECK_INT("UseNMEA_GLL", &g_bUseGLL);
998
999 CHECK_INT("AutoHideToolbar", &g_bAutoHideToolbar);
1000 CHECK_INT("AutoHideToolbarSecs", &g_nAutoHideToolbar);
1001
1002 CHECK_INT("UseSimplifiedScalebar", &g_bsimplifiedScalebar);
1003
1004 CHECK_INT("DisplaySizeMM", &g_display_size_mm);
1005 CHECK_INT("DisplaySizeManual", &g_config_display_size_manual);
1006
1007 CHECK_INT("GUIScaleFactor", &g_GUIScaleFactor);
1008
1009 CHECK_INT("ChartObjectScaleFactor", &g_ChartScaleFactor);
1010 CHECK_INT("ShipScaleFactor", &g_ShipScaleFactor);
1011
1012 CHECK_INT("FilterNMEA_Avg", &g_bfilter_cogsog);
1013 CHECK_INT("FilterNMEA_Sec", &g_COGFilterSec);
1014
1015 CHECK_INT("ShowTrue", &g_bShowTrue);
1016 CHECK_INT("ShowMag", &g_bShowMag);
1017
1018 CHECK_FLT("UserMagVariation", &g_UserVar, 0.1)
1019
1020 CHECK_INT("UseMagAPB", &g_bMagneticAPB);
1021
1022 CHECK_INT("ScreenBrightness", &g_nbrightness);
1023
1024 CHECK_INT("MemFootprintTargetMB", &g_MemFootMB);
1025
1026 CHECK_INT("WindowsComPortMax", &g_nCOMPortCheck);
1027
1028 CHECK_INT("ChartQuilting", &g_bQuiltEnable);
1029 CHECK_INT("ChartQuiltingInitial", &g_bQuiltStart);
1030
1031 CHECK_INT("CourseUpMode", &g_bCourseUp);
1032 CHECK_INT("COGUPAvgSeconds", &g_COGAvgSec);
1033 // CHECK_INT( "LookAheadMode", &g_bLookAhead );
1034 // CHECK_INT( "SkewToNorthUp", &g_bskew_comp );
1035 CHECK_INT("OpenGL", &g_bopengl);
1036 CHECK_INT("SoftwareGL", &g_bSoftwareGL);
1037
1038 CHECK_INT("NMEAAPBPrecision", &g_NMEAAPBPrecision);
1039
1040 CHECK_STR("TalkerIdText", g_TalkerIdText);
1041 CHECK_INT("MaxWaypointNameLength", &g_maxWPNameLength);
1042 CHECK_INT("MbtilesMaxLayers", &g_mbtilesMaxLayers);
1043
1044 /* opengl options */
1045#ifdef ocpnUSE_GL
1046 CHECK_INT("OpenGLExpert", &g_bGLexpert);
1047 CHECK_INT("UseAcceleratedPanning", &g_GLOptions.m_bUseAcceleratedPanning);
1048 CHECK_INT("GPUTextureCompression", &g_GLOptions.m_bTextureCompression);
1049 CHECK_INT("GPUTextureCompressionCaching",
1050 &g_GLOptions.m_bTextureCompressionCaching);
1051 CHECK_INT("PolygonSmoothing", &g_GLOptions.m_GLPolygonSmoothing);
1052 CHECK_INT("LineSmoothing", &g_GLOptions.m_GLLineSmoothing);
1053 CHECK_INT("GPUTextureDimension", &g_GLOptions.m_iTextureDimension);
1054 CHECK_INT("GPUTextureMemSize", &g_GLOptions.m_iTextureMemorySize);
1055
1056#endif
1057 CHECK_INT("SmoothPanZoom", &g_bsmoothpanzoom);
1058
1059 CHECK_INT("ToolbarX", &g_maintoolbar_x);
1060 CHECK_INT("ToolbarY", &g_maintoolbar_y);
1061 CHECK_INT("ToolbarOrient", &g_maintoolbar_orient);
1062 CHECK_STR("GlobalToolbarConfig", g_toolbarConfig);
1063
1064 CHECK_INT("iENCToolbarX", &g_iENCToolbarPosX);
1065 CHECK_INT("iENCToolbarY", &g_iENCToolbarPosY);
1066
1067 CHECK_STR("AnchorWatch1GUID", g_AW1GUID);
1068 CHECK_STR("AnchorWatch2GUID", g_AW2GUID);
1069
1070 CHECK_INT("MobileTouch", &g_btouch);
1071 CHECK_INT("ResponsiveGraphics", &g_bresponsive);
1072
1073 CHECK_INT("ZoomDetailFactor", &g_chart_zoom_modifier_raster);
1074 CHECK_INT("ZoomDetailFactorVector", &g_chart_zoom_modifier_vector);
1075
1076 CHECK_INT("CM93DetailFactor", &g_cm93_zoom_factor);
1077 CHECK_INT("CM93DetailZoomPosX", &g_detailslider_dialog_x);
1078 CHECK_INT("CM93DetailZoomPosY", &g_detailslider_dialog_y);
1079 CHECK_INT("ShowCM93DetailSlider", &g_bShowDetailSlider);
1080
1081 CHECK_INT("SENC_LOD_Pixels", &g_SENC_LOD_pixels);
1082
1083 CHECK_INT("SkewCompUpdatePeriod", &g_SkewCompUpdatePeriod);
1084
1085 CHECK_INT("ShowStatusBar", &g_bShowStatusBar);
1086#ifndef __WXOSX__
1087 CHECK_INT("ShowMenuBar", &g_bShowMenuBar);
1088#endif
1089 CHECK_INT("Fullscreen", &g_bFullscreen);
1090 CHECK_INT("ShowCompassWindow", &g_bShowCompassWin);
1091 CHECK_INT("PlayShipsBells", &g_bPlayShipsBells);
1092 CHECK_INT("SoundDeviceIndex", &g_iSoundDeviceIndex);
1093 CHECK_INT("FullscreenToolbar", &g_bFullscreenToolbar);
1094 // CHECK_INT( "TransparentToolbar", &g_bTransparentToolbar );
1095 CHECK_INT("PermanentMOBIcon", &g_bPermanentMOBIcon);
1096 CHECK_INT("ShowLayers", &g_bShowLayers);
1097 CHECK_INT("ShowDepthUnits", &g_bShowDepthUnits);
1098 CHECK_INT("AutoAnchorDrop", &g_bAutoAnchorMark);
1099 CHECK_INT("ShowActiveRouteHighway", &g_bShowActiveRouteHighway);
1100 CHECK_INT("ShowActiveRouteTotal", &g_bShowRouteTotal);
1101 CHECK_STR("MostRecentGPSUploadConnection", g_uploadConnection);
1102 CHECK_INT("ShowChartBar", &g_bShowChartBar);
1103 CHECK_INT("SDMMFormat",
1104 &g_iSDMMFormat); // 0 = "Degrees, Decimal minutes"), 1 = "Decimal
1105 // degrees", 2 = "Degrees,Minutes, Seconds"
1106
1107 CHECK_INT("DistanceFormat",
1108 &g_iDistanceFormat); // 0 = "Nautical miles"), 1 = "Statute miles",
1109 // 2 = "Kilometers", 3 = "Meters"
1110 CHECK_INT("SpeedFormat",
1111 &g_iSpeedFormat); // 0 = "kts"), 1 = "mph", 2 = "km/h", 3 = "m/s"
1112 CHECK_INT(
1113 "WindSpeedFormat",
1114 &g_iWindSpeedFormat); // 0 = "knots"), 1 = "m/s", 2 = "Mph", 3 = "km/h"
1115
1116 // LIVE ETA OPTION
1117 CHECK_INT("LiveETA", &g_bShowLiveETA);
1118 CHECK_INT("DefaultBoatSpeed", &g_defaultBoatSpeed);
1119
1120 CHECK_INT("OwnshipCOGPredictorMinutes", &g_ownship_predictor_minutes);
1121 CHECK_INT("OwnshipCOGPredictorWidth", &g_cog_predictor_width);
1122 CHECK_INT("OwnshipHDTPredictorMiles", &g_ownship_HDTpredictor_miles);
1123
1124 CHECK_INT("OwnShipIconType", &g_OwnShipIconType);
1125 CHECK_FLT("OwnShipLength", &g_n_ownship_length_meters, 0.1);
1126 CHECK_FLT("OwnShipWidth", &g_n_ownship_beam_meters, 0.1);
1127 CHECK_FLT("OwnShipGPSOffsetX", &g_n_gps_antenna_offset_x, 0.1);
1128 CHECK_FLT("OwnShipGPSOffsetY", &g_n_gps_antenna_offset_y, 0.1);
1129 CHECK_INT("OwnShipMinSize", &g_n_ownship_min_mm);
1130
1131 CHECK_FLT("RouteArrivalCircleRadius", &g_n_arrival_circle_radius, .01);
1132
1133 CHECK_INT("FullScreenQuilt", &g_bFullScreenQuilt);
1134
1135 CHECK_INT("StartWithTrackActive", &g_bTrackCarryOver);
1136 CHECK_INT("AutomaticDailyTracks", &g_bTrackDaily);
1137 CHECK_INT("TrackRotateAt", &g_track_rotate_time);
1138 CHECK_INT("TrackRotateTimeType", &g_track_rotate_time_type);
1139 CHECK_INT("HighlightTracks", &g_bHighliteTracks);
1140
1141 CHECK_STR("DateTimeFormat", g_datetime_format);
1142
1143 CHECK_FLT("PlanSpeed", &g_PlanSpeed, 0.1)
1144
1145
1147
1148 CHECK_INT("PreserveScaleOnX", &g_bPreserveScaleOnX);
1149
1150 CHECK_STR("Locale", g_locale);
1151 CHECK_STR("LocaleOverride", g_localeOverride);
1152
1153 // We allow 0-99 backups ov navobj.xml
1154 CHECK_INT("KeepNavobjBackups", &g_navobjbackups);
1155
1156 // NMEALogWindow::Get().SetSize(Read("NMEALogWindowSizeX", 600L),
1157 // Read("NMEALogWindowSizeY", 400L));
1158 // NMEALogWindow::Get().SetPos(Read("NMEALogWindowPosX", 10L),
1159 // Read("NMEALogWindowPosY", 10L));
1160 // NMEALogWindow::Get().CheckPos(display_width, display_height);
1161
1162 // Boolean to cater for legacy Input COM Port filer behaviour, i.e. show msg
1163 // filtered but put msg on bus.
1164 CHECK_INT("LegacyInputCOMPortFilterBehaviour",
1165 &g_b_legacy_input_filter_behaviour);
1166
1167 CHECK_INT("AdvanceRouteWaypointOnArrivalOnly",
1168 &g_bAdvanceRouteWaypointOnArrivalOnly);
1169
1170 CHECK_INT("EnableRotateKeys", &g_benable_rotate);
1171 CHECK_INT("EmailCrashReport", &g_bEmailCrashReport);
1172
1173 CHECK_INT("EnableAISNameCache", &g_benableAISNameCache);
1174
1175 CHECK_INT("EnableUDPNullHeader", &g_benableUDPNullHeader);
1176
1177 conf.SetPath("/Settings/GlobalState");
1178
1179 CHECK_INT("FrameWinX", &g_nframewin_x);
1180 CHECK_INT("FrameWinY", &g_nframewin_y);
1181 CHECK_INT("FrameWinPosX", &g_nframewin_posx);
1182 CHECK_INT("FrameWinPosY", &g_nframewin_posy);
1183 CHECK_INT("FrameMax", &g_bframemax);
1184
1185 CHECK_INT("ClientPosX", &g_lastClientRectx);
1186 CHECK_INT("ClientPosY", &g_lastClientRecty);
1187 CHECK_INT("ClientSzX", &g_lastClientRectw);
1188 CHECK_INT("ClientSzY", &g_lastClientRecth);
1189
1190 CHECK_INT("RoutePropSizeX", &g_route_prop_sx);
1191 CHECK_INT("RoutePropSizeY", &g_route_prop_sy);
1192 CHECK_INT("RoutePropPosX", &g_route_prop_x);
1193 CHECK_INT("RoutePropPosY", &g_route_prop_y);
1194
1195 CHECK_INT("S52_DEPTH_UNIT_SHOW",
1196 &g_nDepthUnitDisplay); // default is metres
1197
1198 // AIS
1199 conf.SetPath("/Settings/AIS");
1200 CHECK_INT("bNoCPAMax", &g_bCPAMax);
1201 CHECK_FLT("NoCPAMaxNMi", &g_CPAMax_NM, .01)
1202 CHECK_INT("bCPAWarn", &g_bCPAWarn);
1203 CHECK_FLT("CPAWarnNMi", &g_CPAWarn_NM, .01)
1204 CHECK_INT("bTCPAMax", &g_bTCPA_Max);
1205 CHECK_FLT("TCPAMaxMinutes", &g_TCPA_Max, 1)
1206 CHECK_INT("bMarkLostTargets", &g_bMarkLost);
1207 CHECK_FLT("MarkLost_Minutes", &g_MarkLost_Mins, 1)
1208 CHECK_INT("bRemoveLostTargets", &g_bRemoveLost);
1209 CHECK_FLT("RemoveLost_Minutes", &g_RemoveLost_Mins, 1)
1210 CHECK_INT("bShowCOGArrows", &g_bShowCOG);
1211 CHECK_INT("bSyncCogPredictors", &g_bSyncCogPredictors);
1212 CHECK_FLT("CogArrowMinutes", &g_ShowCOG_Mins, 1);
1213 CHECK_INT("bShowTargetTracks", &g_bAISShowTracks);
1214 CHECK_FLT("TargetTracksMinutes", &g_AISShowTracks_Mins, 1)
1215 CHECK_FLT("TargetTracksLimit", &g_AISShowTracks_Limit, 300)
1216 CHECK_INT("bHideMooredTargets", &g_bHideMoored)
1217 CHECK_FLT("MooredTargetMaxSpeedKnots", &g_ShowMoored_Kts, .1)
1218 CHECK_INT("bShowScaledTargets", &g_bAllowShowScaled);
1219 CHECK_INT("AISScaledNumber", &g_ShowScaled_Num);
1220 CHECK_INT("AISScaledNumberWeightSOG", &g_ScaledNumWeightSOG);
1221 CHECK_INT("AISScaledNumberWeightCPA", &g_ScaledNumWeightCPA);
1222 CHECK_INT("AISScaledNumberWeightTCPA", &g_ScaledNumWeightTCPA);
1223 CHECK_INT("AISScaledNumberWeightRange", &g_ScaledNumWeightRange);
1224 CHECK_INT("AISScaledNumberWeightSizeOfTarget", &g_ScaledNumWeightSizeOfT);
1225 CHECK_INT("AISScaledSizeMinimal", &g_ScaledSizeMinimal);
1226 CHECK_INT("AISShowScaled", &g_bShowScaled);
1227 CHECK_INT("bShowAreaNotices", &g_bShowAreaNotices);
1228 CHECK_INT("bDrawAISSize", &g_bDrawAISSize);
1229 CHECK_INT("bDrawAISRealtime", &g_bDrawAISRealtime);
1230 CHECK_FLT("AISRealtimeMinSpeedKnots", &g_AIS_RealtPred_Kts, .1);
1231 CHECK_INT("bShowAISName", &g_bShowAISName);
1232 CHECK_INT("bAISAlertDialog", &g_bAIS_CPA_Alert);
1233 CHECK_INT("ShowAISTargetNameScale", &g_Show_Target_Name_Scale);
1234 CHECK_INT("bWplIsAprsPositionReport", &g_bWplUsePosition);
1235 CHECK_INT("WplSelAction", &g_WplAction);
1236 CHECK_INT("AISCOGPredictorWidth", &g_ais_cog_predictor_width);
1237 CHECK_INT("bAISAlertAudio", &g_bAIS_CPA_Alert_Audio);
1238 CHECK_STR("AISAlertAudioFile", g_sAIS_Alert_Sound_File);
1239 CHECK_INT("bAISAlertSuppressMoored", &g_bAIS_CPA_Alert_Suppress_Moored);
1240 CHECK_INT("bAISAlertAckTimeout", &g_bAIS_ACK_Timeout);
1241 CHECK_FLT("AlertAckTimeoutMinutes", &g_AckTimeout_Mins, 1)
1242 CHECK_STR("AISTargetListPerspective", g_AisTargetList_perspective);
1243 CHECK_INT("AISTargetListRange", &g_AisTargetList_range);
1244 CHECK_INT("AISTargetListSortColumn", &g_AisTargetList_sortColumn);
1245 CHECK_INT("bAISTargetListSortReverse", &g_bAisTargetList_sortReverse);
1246 CHECK_STR("AISTargetListColumnSpec", g_AisTargetList_column_spec);
1247 CHECK_STR("AISTargetListColumnOrder", g_AisTargetList_column_order);
1248 CHECK_INT("bAISRolloverShowClass", &g_bAISRolloverShowClass);
1249 CHECK_INT("bAISRolloverShowCOG", &g_bAISRolloverShowCOG);
1250 CHECK_INT("bAISRolloverShowCPA", &g_bAISRolloverShowCPA);
1251
1252 CHECK_INT("S57QueryDialogSizeX", &g_S57_dialog_sx);
1253 CHECK_INT("S57QueryDialogSizeY", &g_S57_dialog_sy);
1254 CHECK_INT("AlertDialogSizeX", &g_ais_alert_dialog_sx);
1255 CHECK_INT("AlertDialogSizeY", &g_ais_alert_dialog_sy);
1256 CHECK_INT("AlertDialogPosX", &g_ais_alert_dialog_x);
1257 CHECK_INT("AlertDialogPosY", &g_ais_alert_dialog_y);
1258 CHECK_INT("QueryDialogPosX", &g_ais_query_dialog_x);
1259 CHECK_INT("QueryDialogPosY", &g_ais_query_dialog_y);
1260
1261 conf.SetPath("/Directories");
1262 CHECK_STR("PresentationLibraryData", g_UserPresLibData)
1264
1265 CHECK_STR("SENCFileLocation", g_SENCPrefix)
1266
1267 CHECK_STR("GPXIODir", g_gpx_path); // Get the Directory name
1268 CHECK_STR("TCDataDir", g_TCData_Dir); // Get the Directory name
1269 CHECK_STR("BasemapDir", gWorldMapLocation);
1270 CHECK_STR("BaseShapefileDir", gWorldShapefileLocation);
1271
1272 // Fonts
1273
1274#if 0
1275 // Load the persistent Auxiliary Font descriptor Keys
1276 conf.SetPath ( "/Settings/AuxFontKeys" );
1277
1278 wxString strk;
1279 long dummyk;
1280 wxString kval;
1281 bool bContk = conf,GetFirstEntry( strk, dummyk );
1282 bool bNewKey = false;
1283 while( bContk ) {
1284 Read( strk, &kval );
1285 bNewKey = FontMgr::Get().AddAuxKey(kval);
1286 if(!bNewKey) {
1287 DeleteEntry( strk );
1288 dummyk--;
1289 }
1290 bContk = GetNextEntry( strk, dummyk );
1291 }
1292#endif
1293
1294#ifdef __WXX11__
1295 conf.SetPath("/Settings/X11Fonts");
1296#endif
1297
1298#ifdef __WXGTK__
1299 conf.SetPath("/Settings/GTKFonts");
1300#endif
1301
1302#ifdef __WXMSW__
1303 conf.SetPath("/Settings/MSWFonts");
1304#endif
1305
1306#ifdef __WXMAC__
1307 conf.SetPath("/Settings/MacFonts");
1308#endif
1309
1310#ifdef __WXQT__
1311 conf.SetPath("/Settings/QTFonts");
1312#endif
1313
1314 conf.SetPath("/Settings/Others");
1315
1316 // Radar rings
1317 CHECK_INT("RadarRingsNumberVisible", &g_iNavAidRadarRingsNumberVisible)
1318 CHECK_INT("RadarRingsStep", &g_fNavAidRadarRingsStep)
1319
1320 CHECK_INT("RadarRingsStepUnits", &g_pNavAidRadarRingsStepUnits);
1321
1322 // wxString l_wxsOwnshipRangeRingsColour;
1323 // CHECK_STR( "RadarRingsColour", &l_wxsOwnshipRangeRingsColour );
1324 // if(l_wxsOwnshipRangeRingsColour.Length())
1325 // g_colourOwnshipRangeRingsColour.Set( l_wxsOwnshipRangeRingsColour );
1326
1327 // Waypoint Radar rings
1328 CHECK_INT("WaypointRangeRingsNumber", &g_iWaypointRangeRingsNumber)
1329
1330 CHECK_FLT("WaypointRangeRingsStep", &g_fWaypointRangeRingsStep, .1)
1331
1332 CHECK_INT("WaypointRangeRingsStepUnits", &g_iWaypointRangeRingsStepUnits);
1333
1334 // wxString l_wxsWaypointRangeRingsColour;
1335 // CHECK_STR( "WaypointRangeRingsColour",
1336 // &l_wxsWaypointRangeRingsColour ); g_colourWaypointRangeRingsColour.Set(
1337 // l_wxsWaypointRangeRingsColour );
1338
1339 CHECK_INT("ConfirmObjectDeletion", &g_bConfirmObjectDelete);
1340
1341 // Waypoint dragging with mouse
1342 CHECK_INT("WaypointPreventDragging", &g_bWayPointPreventDragging);
1343
1344 CHECK_INT("EnableZoomToCursor", &g_bEnableZoomToCursor);
1345
1346 CHECK_FLT("TrackIntervalSeconds", &g_TrackIntervalSeconds, 1)
1347
1348 CHECK_FLT("TrackDeltaDistance", &g_TrackDeltaDistance, .1)
1349
1350 CHECK_INT("TrackPrecision", &g_nTrackPrecision);
1351
1352 // CHECK_STR( "NavObjectFileName", m_sNavObjSetFile );
1353
1354 CHECK_INT("RouteLineWidth", &g_route_line_width);
1355 CHECK_INT("TrackLineWidth", &g_track_line_width);
1356
1357 // wxString l_wxsTrackLineColour;
1358 // CHECK_STR( "TrackLineColour", l_wxsTrackLineColour )
1359 // g_colourTrackLineColour.Set( l_wxsTrackLineColour );
1360
1361 CHECK_STR("DefaultWPIcon", g_default_wp_icon)
1362
1363 // S57 template items
1364
1365#define CHECK_BFN(s, t) \
1366 conf.Read(s, &read_int); \
1367 bval = t; \
1368 bval0 = read_int != 0; \
1369 if (bval != bval0) return false;
1370
1371#define CHECK_IFN(s, t) \
1372 conf.Read(s, &read_int); \
1373 if (read_int != t) return false;
1374
1375#define CHECK_FFN(s, t) \
1376 conf.Read(s, &dval); \
1377 if (fabs(dval - t) > 0.1) return false;
1378
1379 if (ps52plib) {
1380 int read_int;
1381 double dval;
1382 bool bval, bval0;
1383
1384 conf.SetPath("/Settings/GlobalState");
1385
1386 CHECK_BFN("bShowS57Text", ps52plib->GetShowS57Text());
1387
1388 CHECK_BFN("bShowS57ImportantTextOnly",
1389 ps52plib->GetShowS57ImportantTextOnly());
1390 CHECK_BFN("bShowLightDescription", ps52plib->m_bShowLdisText);
1391 CHECK_BFN("bExtendLightSectors", ps52plib->m_bExtendLightSectors);
1392 CHECK_BFN("bShowSoundg", ps52plib->m_bShowSoundg);
1393 CHECK_BFN("bShowMeta", ps52plib->m_bShowMeta);
1394 CHECK_BFN("bUseSCAMIN", ps52plib->m_bUseSCAMIN);
1395 CHECK_BFN("bUseSUPERSCAMIN", ps52plib->m_bUseSUPER_SCAMIN);
1396 CHECK_BFN("bShowAtonText", ps52plib->m_bShowAtonText);
1397 CHECK_BFN("bDeClutterText", ps52plib->m_bDeClutterText);
1398 CHECK_BFN("bShowNationalText", ps52plib->m_bShowNationalTexts);
1399 CHECK_IFN("nDisplayCategory", ps52plib->GetDisplayCategory());
1400 CHECK_IFN("nSymbolStyle", ps52plib->m_nSymbolStyle);
1401 CHECK_IFN("nBoundaryStyle", ps52plib->m_nBoundaryStyle);
1402 CHECK_FFN("S52_MAR_SAFETY_CONTOUR",
1403 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
1404 CHECK_FFN("S52_MAR_SHALLOW_CONTOUR",
1405 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
1406 CHECK_FFN("S52_MAR_DEEP_CONTOUR",
1407 S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
1408 CHECK_FFN("S52_MAR_TWO_SHADES", S52_getMarinerParam(S52_MAR_TWO_SHADES));
1409 CHECK_INT("S52_DEPTH_UNIT_SHOW", &g_nDepthUnitDisplay);
1410
1411 // S57 Object Class Visibility
1412
1413 OBJLElement *pOLE;
1414
1415 conf.SetPath("/Settings/ObjectFilter");
1416
1417 unsigned int iOBJMax = conf.GetNumberOfEntries();
1418
1419 if (iOBJMax != ps52plib->pOBJLArray->GetCount()) return false;
1420
1421 if (iOBJMax) {
1422 wxString str, sObj;
1423 long val;
1424 long dummy;
1425
1426 bool bCont = conf.GetFirstEntry(str, dummy);
1427 while (bCont) {
1428 conf.Read(str, &val); // Get an Object Viz
1429
1430 // scan for the same key in the global list
1431 bool bfound = false;
1432 if (str.StartsWith("viz", &sObj)) {
1433 for (unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
1434 iPtr++) {
1435 pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
1436 if (!strncmp(pOLE->OBJLName, sObj.mb_str(), 6)) {
1437 bfound = true;
1438 if (pOLE->nViz != val) {
1439 return false;
1440 }
1441 }
1442 }
1443
1444 if (!bfound) return false;
1445 }
1446 bCont = conf.GetNextEntry(str, dummy);
1447 }
1448 }
1449 }
1450
1451 conf.SetPath("/MmsiProperties");
1452 int iPMax = conf.GetNumberOfEntries();
1453 if (iPMax) {
1454 wxString str, val;
1455 long dummy;
1456
1457 bool bCont = conf.GetFirstEntry(str, dummy);
1458 while (bCont) {
1459 conf.Read(str, &val); // Get an entry
1460
1461 bool bfound = false;
1462 for (unsigned int j = 0; j < g_MMSI_Props_Array.GetCount(); j++) {
1463 MmsiProperties *pProps = g_MMSI_Props_Array.Item(j);
1464 if (pProps->Serialize().IsSameAs(val)) {
1465 bfound = true;
1466 break;
1467 }
1468 }
1469 if (!bfound) return false;
1470
1471 bCont = conf.GetNextEntry(str, dummy);
1472 }
1473 }
1474
1475 return rv;
1476}
ArrayOfMmsiProperties g_MMSI_Props_Array
Global instance.
Class AisDecoder and helpers.
Global state for AIS decoder.
Charts database management
Generic Chart canvas base.
wxString & GetPrivateDataDir()
Return dir path for opencpn.log, etc., respecting -c cli option.
Manages the user configuration matrix.
Definition config_mgr.h:47
Represents a panel for displaying and editing a configuration.
Definition config_mgr.h:92
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
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
Process incoming AIS messages.
Definition ais_decoder.h:74
Config file user configuration interface.
wxString g_datetime_format
Date/time format to use when formatting date/time strings.
bool g_bsmoothpanzoom
Controls how the chart panning and zooming smoothing is done during user interactions.
int g_nDepthUnitDisplay
User-selected depth (below surface) unit format for display and input.
int g_COGAvgSec
COG average period for Course Up Mode (sec)
int g_iSpeedFormat
User-selected speed unit format for display and input.
std::vector< size_t > g_config_display_size_mm
Size of pysical screen in millimeters.
int g_iDistanceFormat
User-selected distance (horizontal) unit format for display and input.
bool g_bDisplayGrid
Should lat/lon grid be displayed ?
double g_display_size_mm
Physical display width (mm)
Global variables stored in configuration file.
NavmsgFilter Read(const std::string &name)
Read filter with given name from disk.
Font list manager.
OpenCPN Georef utility.
Platform independent GL includes.
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
Chart object layer.
Multiplexer class and helpers.
MyConfig * pConfig
Global instance.
Definition navutil.cpp:118
Utility functions.
OpenGL runtime options.
OpenCPN Platform specific support utilities.
PlugIn Object Definition/API.
wxString * GetpSharedDataLocation()
Gets shared application data location.
wxColour g_colourWaypointRangeRingsColour
Global instance.
Waypoint or mark abstraction.
Route properties dialog.