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#ifdef __MINGW32__
25#undef IPV6STRICT // mingw FTBS fix: missing struct ip_mreq
26#include <windows.h>
27#endif
28
29#include <algorithm>
30#include <list>
31#include <locale>
32#include <stdlib.h>
33
34#include <time.h>
35
36#include <wx/colour.h>
37#include <wx/fileconf.h>
38#include <wx/filename.h>
39#include <wx/log.h>
40#include <wx/statline.h>
41#include <wx/string.h>
42
43#include "model/ais_decoder.h"
45#include "model/config_vars.h"
46#include "model/gui_vars.h"
47#include "model/georef.h"
48#include "model/multiplexer.h"
49#include "model/route_point.h"
50
51#include "ais.h"
52#include "chartdb.h"
53#include "chcanv.h"
54#include "config_mgr.h"
55#include "font_mgr.h"
56#include "layer.h"
57#include "navutil.h"
58#include "ocpn_frame.h"
59#include "ocpn_gl_options.h"
60#include "ocpn_platform.h"
61#include "ocpn_plugin.h"
62#include "route_prop_dlg_impl.h"
63#include "s52plib.h"
64#include "s52utils.h"
65
66extern s52plib *ps52plib; // In a library...
67
68#if !defined(NAN)
69static const long long lNaN = 0xfff8000000000000;
70#define NAN (*(double *)&lNaN)
71#endif
72
73ConfigMgr *ConfigMgr::instance = NULL;
74
75//--------------------------------------------------------------------------
76//
77// Utility functions
78//
79//--------------------------------------------------------------------------
80int GetRandomNumber(int range_min, int range_max) {
81 long u = (long)wxRound(
82 ((double)rand() / ((double)(RAND_MAX) + 1) * (range_max - range_min)) +
83 range_min);
84 return (int)u;
85}
86
87// Helper conditional file name dir slash
88void appendOSDirSlash(wxString *pString);
89
91public:
94
95 OCPNConfigObject(int canvas_config);
96
97 void Init();
98 wxPanel *GetSettingsPanel();
99
100 int m_canvasConfig;
101 wxString m_GUID;
102 wxString templateFileName;
103 wxString m_title;
104 wxString m_description;
105};
106
107OCPNConfigObject::OCPNConfigObject() { Init(); }
108
109OCPNConfigObject::OCPNConfigObject(int canvas_config) {
110 Init();
111 m_canvasConfig = canvas_config;
112}
113
114OCPNConfigObject::~OCPNConfigObject() {}
115
116void OCPNConfigObject::Init() { m_canvasConfig = 0; }
117
118//--------------------------------------------------------------------
119// Private ( XML encoded ) catalog of available configurations
120//--------------------------------------------------------------------
121
123public:
126
127 bool AddConfig(OCPNConfigObject *config, unsigned int flags);
128 bool RemoveConfig(wxString GUID);
129
130 void SetRootConfigNode();
131 bool IsOpenCPN();
132 bool SaveFile(const wxString filename);
133 bool LoadFile(const wxString filename);
134
135 pugi::xml_node m_config_root;
136};
137
138OCPNConfigCatalog::OCPNConfigCatalog() : pugi::xml_document() {}
139
140OCPNConfigCatalog::~OCPNConfigCatalog() {}
141
142void OCPNConfigCatalog::SetRootConfigNode() {
143 if (!strlen(m_config_root.name())) {
144 m_config_root = append_child("configs");
145 m_config_root.append_attribute("version") = "1.0";
146 m_config_root.append_attribute("creator") = "OpenCPN";
147 m_config_root.append_attribute("xmlns:xsi") =
148 "http://www.w3.org/2001/XMLSchema-instance";
149 m_config_root.append_attribute("xmlns") =
150 "http://www.topografix.com/GPX/1/1";
151 m_config_root.append_attribute("xmlns:gpxx") =
152 "http://www.garmin.com/xmlschemas/GpxExtensions/v3";
153 m_config_root.append_attribute("xsi:schemaLocation") =
154 "http://www.topografix.com/GPX/1/1 "
155 "http://www.topografix.com/GPX/1/1/gpx.xsd";
156 m_config_root.append_attribute("xmlns:opencpn") = "http://www.opencpn.org";
157 }
158}
159
160bool OCPNConfigCatalog::IsOpenCPN() {
161 for (pugi::xml_attribute attr = root().first_child().first_attribute(); attr;
162 attr = attr.next_attribute())
163 if (!strcmp(attr.name(), "creator") && !strcmp(attr.value(), "OpenCPN"))
164 return true;
165 return false;
166}
167
168bool OCPNConfigCatalog::SaveFile(const wxString filename) {
169 save_file(filename.fn_str(), " ");
170 return true;
171}
172
173bool OCPNConfigCatalog::LoadFile(const wxString filename) {
174 load_file(filename.fn_str());
175 m_config_root = this->child("configs");
176 return true;
177}
178
179bool OCPNConfigCatalog::AddConfig(OCPNConfigObject *config,
180 unsigned int flags) {
181 pugi::xml_node node = m_config_root.append_child("config");
182
183 node.append_attribute("GUID") = config->m_GUID.mb_str();
184
185 // Handle non-ASCII characters as UTF8
186 wxCharBuffer abuf = config->m_title.ToUTF8();
187 if (abuf.data())
188 node.append_attribute("title") = abuf.data();
189 else
190 node.append_attribute("title") = "Substitute Title";
191
192 abuf = config->m_description.ToUTF8();
193 if (abuf.data())
194 node.append_attribute("description") = abuf.data();
195 else
196 node.append_attribute("description") = "Substitute Description";
197
198 node.append_attribute("templateFile") = config->templateFileName.mb_str();
199
200 return true;
201}
202
203bool OCPNConfigCatalog::RemoveConfig(wxString GUID) {
204 for (pugi::xml_node child = m_config_root.first_child(); child;) {
205 pugi::xml_node next = child.next_sibling();
206 const char *guid = child.attribute("GUID").value();
207
208 if (!strcmp(guid, GUID.mb_str())) {
209 child.parent().remove_child(child);
210 return true;
211 }
212
213 child = next;
214 }
215
216 return false;
217}
218
219//--------------------------------------------------------------------
220// ConfigPanel implementation
221//--------------------------------------------------------------------
222
223ConfigPanel::ConfigPanel(OCPNConfigObject *config, wxWindow *parent,
224 wxWindowID id, const wxPoint &pos, const wxSize &size)
225 : wxPanel(parent, id, pos, size, wxSIMPLE_BORDER)
226
227{
228 m_config = config;
229 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
230 SetSizer(mainSizer);
231
232 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Title")));
233 mainSizer->Add(new wxStaticText(this, wxID_ANY, config->m_title));
234
235 mainSizer->Add(new wxStaticLine(this, wxID_ANY), 0, wxEXPAND | wxALL, 1);
236
237 mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Description")));
238 mainSizer->Add(new wxStaticText(this, wxID_ANY, config->m_description));
239
240 SetMinSize(wxSize(-1, 6 * GetCharHeight()));
241
242 SetBackgroundColour(
243 wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW));
244 // Connect(wxEVT_LEFT_DOWN,
245 // wxMouseEventHandler(ConfigPanel::OnConfigPanelMouseSelected), NULL, this);
246}
247
248ConfigPanel::~ConfigPanel() {}
249
250void ConfigPanel::OnConfigPanelMouseSelected(wxMouseEvent &event) {
251 // SetBackgroundColour(*wxRED);
252 // event.Skip();
253}
254
255wxString ConfigPanel::GetConfigGUID() { return m_config->m_GUID; }
256
257//--------------------------------------------------------------------
258// ConfigMgr implementation
259// Singleton Pattern
260//--------------------------------------------------------------------
261
262ConfigMgr &ConfigMgr::Get() {
263 if (!instance) instance = new ConfigMgr;
264 return *instance;
265}
266
267void ConfigMgr::Shutdown() {
268 if (instance) {
269 delete instance;
270 instance = NULL;
271 }
272}
273
274ConfigMgr::ConfigMgr() {
275 Init();
276
277 // Load any existing configs from the catalog
278 LoadCatalog();
279}
280
281ConfigMgr::~ConfigMgr() {
282 configList->clear();
283 delete configList;
284}
285
286void ConfigMgr::Init() {
287 m_configDir = g_Platform->GetPrivateDataDir();
288 appendOSDirSlash(&m_configDir);
289 m_configDir.append("Configs");
290 appendOSDirSlash(&m_configDir);
291 if (!wxFileName::DirExists(m_configDir)) {
292 wxFileName::Mkdir(m_configDir);
293 }
294
295 m_configCatalogName = g_Platform->GetPrivateDataDir();
296 appendOSDirSlash(&m_configCatalogName);
297 m_configCatalogName.append("Configs");
298 appendOSDirSlash(&m_configCatalogName);
299 m_configCatalogName.append("configs.xml");
300
301 // Create the catalog, if necessary
302 if (!wxFileExists(m_configCatalogName)) {
303 wxLogMessage("Creating new Configs catalog: " + m_configCatalogName);
304
306 cat->SetRootConfigNode();
307 cat->SaveFile(m_configCatalogName);
308 delete cat;
309 }
310
311 m_configCatalog = new OCPNConfigCatalog();
312
313 configList = new ConfigObjectList;
314
315 // Add the default "Recovery" template
316 wxString t_title = _("Recovery Template");
317 wxString t_desc =
318 _("Apply this template to return to a known safe configuration");
319 CreateNamedConfig(t_title, t_desc, "11111111-1111-1111-1111-111111111111");
320}
321
322bool ConfigMgr::LoadCatalog() {
323 wxLogMessage("Loading Configs catalog: " + m_configCatalogName);
324 m_configCatalog->LoadFile(m_configCatalogName);
325
326 // Parse the config catalog
327 pugi::xml_node objects = m_configCatalog->child("configs");
328
329 // pugi::xml_node node = m_config_root.append_child("config");
330
331 // node.append_attribute("GUID") = config->m_GUID.mb_str();
332 // node.append_attribute("title") = config->m_title.mb_str();
333 // node.append_attribute("description") = config->m_description.mb_str();
334 // node.append_attribute("templateFile") = config->templateFileName.mb_str();
335
336 for (pugi::xml_node object = objects.first_child(); object;
337 object = object.next_sibling()) {
338 if (!strcmp(object.name(), "config")) {
339 // Check the GUID for duplicates
340 wxString testGUID =
341 wxString::FromUTF8(object.attribute("GUID").as_string());
342
343 bool bFound = false;
344 for (auto it = configList->begin(); it != configList->end(); ++it) {
345 OCPNConfigObject *look = *it;
346 if (look->m_GUID == testGUID) {
347 bFound = true;
348 break;
349 }
350 }
351
352 if (!bFound) {
353 OCPNConfigObject *newConfig = new OCPNConfigObject;
354
355 newConfig->m_GUID =
356 wxString::FromUTF8(object.attribute("GUID").as_string());
357 newConfig->m_title =
358 wxString::FromUTF8(object.attribute("title").as_string());
359 newConfig->m_description =
360 wxString::FromUTF8(object.attribute("description").as_string());
361 newConfig->templateFileName =
362 wxString::FromUTF8(object.attribute("templateFile").as_string());
363
364 // Add to the class list of configs
365 configList->push_back(newConfig);
366 }
367 }
368 }
369
370 return true;
371}
372
373bool ConfigMgr::SaveCatalog() {
374 m_configCatalog->SaveFile(m_configCatalogName);
375
376 return true;
377}
378
379wxString ConfigMgr::CreateNamedConfig(const wxString &title,
380 const wxString &description,
381 wxString UUID) {
382 wxString GUID;
383
384 // Must have title
385 if (title.IsEmpty()) return GUID;
386
387 OCPNConfigObject *pConfig = new OCPNConfigObject;
388
389 // If no UUID is passed, then create a new GUID for this config
390 if (UUID.IsEmpty())
391 GUID = GetUUID();
392 else
393 GUID = UUID;
394
395 pConfig->m_GUID = GUID;
396 pConfig->m_title = title;
397 pConfig->m_description = description;
398
399 if (UUID.IsEmpty()) {
400 // create template file name
401 pConfig->templateFileName = "OCPNTemplate-" + GUID + ".conf";
402
403 // Save the template contents
404 wxString templateFullFileName = GetConfigDir() + pConfig->templateFileName;
405 if (!SaveTemplate(templateFullFileName)) {
406 wxLogMessage("Unable to save template titled: " + title +
407 " as file: " + templateFullFileName);
408 delete pConfig;
409 return "";
410 }
411 }
412
413 // Add this config to the catalog
414 if (!m_configCatalog->AddConfig(pConfig, 0)) {
415 wxLogMessage("Unable to add config to catalog...Title: " + title);
416 delete pConfig;
417 return "";
418 }
419
420 // Add to the class list of configs
421 configList->push_back(pConfig);
422
423 if (UUID.IsEmpty()) SaveCatalog();
424
425 return GUID;
426}
427
428bool ConfigMgr::DeleteConfig(wxString GUID) {
429 OCPNConfigObject *cfg = GetConfig(GUID);
430 if (!cfg) return false;
431
432 // Find and delete the template file
433 wxString templateFullFileName = GetConfigDir() + cfg->templateFileName;
434 if (wxFileExists(templateFullFileName)) wxRemoveFile(templateFullFileName);
435
436 // Remove the config from the catalog
437 bool rv = m_configCatalog->RemoveConfig(GUID);
438
439 if (rv) SaveCatalog();
440
441 // Remove the config from the member list without deleting it
442 auto found = std::find(configList->begin(), configList->end(), cfg);
443 if (found != configList->end()) configList->erase(found);
444
445 return rv;
446}
447
448wxPanel *ConfigMgr::GetConfigPanel(wxWindow *parent, wxString GUID) {
449 wxPanel *retPanel = NULL;
450
451 // Find the GUID-matching config in the member list
452 OCPNConfigObject *config = GetConfig(GUID);
453
454 // Found it?
455 if (config) {
456 retPanel = new ConfigPanel(config, parent);
457 }
458
459 return retPanel;
460}
461
462OCPNConfigObject *ConfigMgr::GetConfig(wxString GUID) {
463 // Find the GUID-matching config in the member list
464 for (auto it = configList->begin(); it != configList->end(); ++it) {
465 OCPNConfigObject *look = *it;
466 if (look->m_GUID == GUID) {
467 return look;
468 break;
469 }
470 }
471 return NULL;
472}
473
474wxString ConfigMgr::GetTemplateTitle(wxString GUID) {
475 for (auto it = configList->begin(); it != configList->end(); ++it) {
476 OCPNConfigObject *look = *it;
477 if (look->m_GUID == GUID) {
478 return look->m_title;
479 break;
480 }
481 }
482 return wxEmptyString;
483}
484
485wxArrayString ConfigMgr::GetConfigGUIDArray() {
486 wxArrayString ret_val;
487
488 for (auto it = configList->begin(); it != configList->end(); ++it) {
489 OCPNConfigObject *look = *it;
490 ret_val.Add(look->m_GUID);
491 }
492 return ret_val;
493}
494
495bool ConfigMgr::ApplyConfigGUID(wxString GUID) {
496 // Find the GUID-matching config in the member list
497 OCPNConfigObject *config = GetConfig(GUID);
498
499 // Found it?
500 if (config) {
501 wxString thisConfig = GetConfigDir() + config->templateFileName;
502
503 // Special case for Recovery template
504 if (GUID.StartsWith("11111111")) {
505 thisConfig =
506 *GetpSharedDataLocation() + "configs/OCPNTemplate-Recovery.conf";
507 }
508
509 MyConfig fconf(thisConfig);
510
511 // Load the template contents, without resetting defaults
512 fconf.LoadMyConfigRaw(true);
513
514 // Load Canvas configs, applying only the "templateable" items
515 fconf.LoadCanvasConfigs(true);
516
517 if (ps52plib && ps52plib->m_bOK) fconf.LoadS57Config();
518
519 return true;
520 }
521
522 return false;
523}
524
525// RFC4122 version 4 compliant random UUIDs generator.
526wxString ConfigMgr::GetUUID() {
527 wxString str;
528 struct {
529 int time_low;
530 int time_mid;
531 int time_hi_and_version;
532 int clock_seq_hi_and_rsv;
533 int clock_seq_low;
534 int node_hi;
535 int node_low;
536 } uuid;
537
538 uuid.time_low = GetRandomNumber(
539 0, 2147483647); // FIXME: the max should be set to something like
540 // MAXINT32, but it doesn't compile un gcc...
541 uuid.time_mid = GetRandomNumber(0, 65535);
542 uuid.time_hi_and_version = GetRandomNumber(0, 65535);
543 uuid.clock_seq_hi_and_rsv = GetRandomNumber(0, 255);
544 uuid.clock_seq_low = GetRandomNumber(0, 255);
545 uuid.node_hi = GetRandomNumber(0, 65535);
546 uuid.node_low = GetRandomNumber(0, 2147483647);
547
548 /* Set the two most significant bits (bits 6 and 7) of the
549 * clock_seq_hi_and_rsv to zero and one, respectively. */
550 uuid.clock_seq_hi_and_rsv = (uuid.clock_seq_hi_and_rsv & 0x3F) | 0x80;
551
552 /* Set the four most significant bits (bits 12 through 15) of the
553 * time_hi_and_version field to 4 */
554 uuid.time_hi_and_version = (uuid.time_hi_and_version & 0x0fff) | 0x4000;
555
556 str.Printf("%08x-%04x-%04x-%02x%02x-%04x%08x", uuid.time_low, uuid.time_mid,
557 uuid.time_hi_and_version, uuid.clock_seq_hi_and_rsv,
558 uuid.clock_seq_low, uuid.node_hi, uuid.node_low);
559
560 return str;
561}
562
563bool ConfigMgr::SaveTemplate(wxString fileName) {
564 // Assuming the file exists, and is empty....
565
566 // Create a private wxFileConfig object
567 MyConfig *conf = new MyConfig(fileName);
568
569// Write out all the elements of a config template....
570
571// Temporarily suppress logging of trivial non-fatal wxLogSysError() messages
572// provoked by Android security...
573#ifdef __ANDROID__
574 wxLogNull logNo;
575#endif
576
577 // Global options and settings
578 conf->SetPath("/Settings");
579
580 conf->Write("InlandEcdis", g_bInlandEcdis);
581 conf->Write("UIexpert", g_bUIexpert);
582 conf->Write("SpaceDropMark", g_bSpaceDropMark);
583
584 conf->Write("ShowStatusBar", g_bShowStatusBar);
585#ifndef __WXOSX__
586 conf->Write("ShowMenuBar", g_bShowMenuBar);
587#endif
588 conf->Write("DefaultFontSize", g_default_font_size);
589
590 conf->Write("Fullscreen", g_bFullscreen);
591 conf->Write("ShowCompassWindow", g_bShowCompassWin);
592 conf->Write("SetSystemTime", s_bSetSystemTime);
593 conf->Write("ShowGrid", g_bDisplayGrid);
594 conf->Write("PlayShipsBells", g_bPlayShipsBells);
595 conf->Write("SoundDeviceIndex", g_iSoundDeviceIndex);
596 conf->Write("FullscreenToolbar", g_bFullscreenToolbar);
597 // conf->Write( "TransparentToolbar", g_bTransparentToolbar );
598 conf->Write("PermanentMOBIcon", g_bPermanentMOBIcon);
599 conf->Write("ShowLayers", g_bShowLayers);
600 conf->Write("AutoAnchorDrop", g_bAutoAnchorMark);
601 conf->Write("ShowChartOutlines", g_bShowOutlines);
602 conf->Write("ShowActiveRouteTotal", g_bShowRouteTotal);
603 conf->Write("ShowActiveRouteHighway", g_bShowActiveRouteHighway);
604 conf->Write("SDMMFormat", g_iSDMMFormat);
605 conf->Write("ShowChartBar", g_bShowChartBar);
606
607 conf->Write("GUIScaleFactor", g_GUIScaleFactor);
608 conf->Write("ChartObjectScaleFactor", g_ChartScaleFactor);
609 conf->Write("ShipScaleFactor", g_ShipScaleFactor);
610
611 conf->Write("ShowTrue", g_bShowTrue);
612 conf->Write("ShowMag", g_bShowMag);
613 conf->Write("UserMagVariation", wxString::Format("%.2f", g_UserVar));
614
615 conf->Write("CM93DetailFactor", g_cm93_zoom_factor);
616 conf->Write("CM93DetailZoomPosX", g_detailslider_dialog_x);
617 conf->Write("CM93DetailZoomPosY", g_detailslider_dialog_y);
618 conf->Write("ShowCM93DetailSlider", g_bShowDetailSlider);
619
620 conf->Write("SkewToNorthUp", g_bskew_comp);
621
622 conf->Write("ZoomDetailFactor", g_chart_zoom_modifier_raster);
623 conf->Write("ZoomDetailFactorVector", g_chart_zoom_modifier_vector);
624
625 conf->Write("SmoothPanZoom", g_bsmoothpanzoom);
626
627 conf->Write("CourseUpMode", g_bCourseUp);
628 if (!g_bInlandEcdis) conf->Write("LookAheadMode", g_bLookAhead);
629 conf->Write("TenHzUpdate", g_btenhertz);
630
631 conf->Write("COGUPAvgSeconds", g_COGAvgSec);
632 conf->Write("UseMagAPB", g_bMagneticAPB);
633
634 conf->Write("OwnshipCOGPredictorMinutes", g_ownship_predictor_minutes);
635 conf->Write("OwnshipCOGPredictorWidth", g_cog_predictor_width);
636 conf->Write("OwnshipHDTPredictorMiles", g_ownship_HDTpredictor_miles);
637 conf->Write("OwnShipIconType", g_OwnShipIconType);
638 conf->Write("OwnShipLength", g_n_ownship_length_meters);
639 conf->Write("OwnShipWidth", g_n_ownship_beam_meters);
640 conf->Write("OwnShipGPSOffsetX", g_n_gps_antenna_offset_x);
641 conf->Write("OwnShipGPSOffsetY", g_n_gps_antenna_offset_y);
642 conf->Write("OwnShipMinSize", g_n_ownship_min_mm);
643 conf->Write("OwnShipSogCogCalc", g_own_ship_sog_cog_calc);
644 conf->Write("OwnShipSogCogCalcDampSec", g_own_ship_sog_cog_calc_damp_sec);
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)gFrame->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 CHECK_INT("OwnShipSogCogCalc", &g_own_ship_sog_cog_calc);
1131 CHECK_INT("OwnShipSogCogCalcDampSec", &g_own_ship_sog_cog_calc_damp_sec);
1132
1133 CHECK_FLT("RouteArrivalCircleRadius", &g_n_arrival_circle_radius, .01);
1134
1135 CHECK_INT("FullScreenQuilt", &g_bFullScreenQuilt);
1136
1137 CHECK_INT("StartWithTrackActive", &g_bTrackCarryOver);
1138 CHECK_INT("AutomaticDailyTracks", &g_bTrackDaily);
1139 CHECK_INT("TrackRotateAt", &g_track_rotate_time);
1140 CHECK_INT("TrackRotateTimeType", &g_track_rotate_time_type);
1141 CHECK_INT("HighlightTracks", &g_bHighliteTracks);
1142
1143 CHECK_STR("DateTimeFormat", g_datetime_format);
1144
1145 CHECK_FLT("PlanSpeed", &g_PlanSpeed, 0.1)
1146
1147
1149
1150 CHECK_INT("PreserveScaleOnX", &g_bPreserveScaleOnX);
1151
1152 CHECK_STR("Locale", g_locale);
1153 CHECK_STR("LocaleOverride", g_localeOverride);
1154
1155 // We allow 0-99 backups ov navobj.xml
1156 CHECK_INT("KeepNavobjBackups", &g_navobjbackups);
1157
1158 // NMEALogWindow::Get().SetSize(Read("NMEALogWindowSizeX", 600L),
1159 // Read("NMEALogWindowSizeY", 400L));
1160 // NMEALogWindow::Get().SetPos(Read("NMEALogWindowPosX", 10L),
1161 // Read("NMEALogWindowPosY", 10L));
1162 // NMEALogWindow::Get().CheckPos(display_width, display_height);
1163
1164 // Boolean to cater for legacy Input COM Port filer behaviour, i.e. show msg
1165 // filtered but put msg on bus.
1166 CHECK_INT("LegacyInputCOMPortFilterBehaviour",
1167 &g_b_legacy_input_filter_behaviour);
1168
1169 CHECK_INT("AdvanceRouteWaypointOnArrivalOnly",
1170 &g_bAdvanceRouteWaypointOnArrivalOnly);
1171
1172 CHECK_INT("EnableRotateKeys", &g_benable_rotate);
1173 CHECK_INT("EmailCrashReport", &g_bEmailCrashReport);
1174
1175 CHECK_INT("EnableAISNameCache", &g_benableAISNameCache);
1176
1177 CHECK_INT("EnableUDPNullHeader", &g_benableUDPNullHeader);
1178
1179 conf.SetPath("/Settings/GlobalState");
1180
1181 CHECK_INT("FrameWinX", &g_nframewin_x);
1182 CHECK_INT("FrameWinY", &g_nframewin_y);
1183 CHECK_INT("FrameWinPosX", &g_nframewin_posx);
1184 CHECK_INT("FrameWinPosY", &g_nframewin_posy);
1185 CHECK_INT("FrameMax", &g_bframemax);
1186
1187 CHECK_INT("ClientPosX", &g_lastClientRectx);
1188 CHECK_INT("ClientPosY", &g_lastClientRecty);
1189 CHECK_INT("ClientSzX", &g_lastClientRectw);
1190 CHECK_INT("ClientSzY", &g_lastClientRecth);
1191
1192 CHECK_INT("RoutePropSizeX", &g_route_prop_sx);
1193 CHECK_INT("RoutePropSizeY", &g_route_prop_sy);
1194 CHECK_INT("RoutePropPosX", &g_route_prop_x);
1195 CHECK_INT("RoutePropPosY", &g_route_prop_y);
1196
1197 CHECK_INT("S52_DEPTH_UNIT_SHOW",
1198 &g_nDepthUnitDisplay); // default is metres
1199
1200 // AIS
1201 conf.SetPath("/Settings/AIS");
1202 CHECK_INT("bNoCPAMax", &g_bCPAMax);
1203 CHECK_FLT("NoCPAMaxNMi", &g_CPAMax_NM, .01)
1204 CHECK_INT("bCPAWarn", &g_bCPAWarn);
1205 CHECK_FLT("CPAWarnNMi", &g_CPAWarn_NM, .01)
1206 CHECK_INT("bTCPAMax", &g_bTCPA_Max);
1207 CHECK_FLT("TCPAMaxMinutes", &g_TCPA_Max, 1)
1208 CHECK_INT("bMarkLostTargets", &g_bMarkLost);
1209 CHECK_FLT("MarkLost_Minutes", &g_MarkLost_Mins, 1)
1210 CHECK_INT("bRemoveLostTargets", &g_bRemoveLost);
1211 CHECK_FLT("RemoveLost_Minutes", &g_RemoveLost_Mins, 1)
1212 CHECK_INT("bShowCOGArrows", &g_bShowCOG);
1213 CHECK_INT("bSyncCogPredictors", &g_bSyncCogPredictors);
1214 CHECK_FLT("CogArrowMinutes", &g_ShowCOG_Mins, 1);
1215 CHECK_INT("bShowTargetTracks", &g_bAISShowTracks);
1216 CHECK_FLT("TargetTracksMinutes", &g_AISShowTracks_Mins, 1)
1217 CHECK_FLT("TargetTracksLimit", &g_AISShowTracks_Limit, 300)
1218 CHECK_INT("bHideMooredTargets", &g_bHideMoored)
1219 CHECK_FLT("MooredTargetMaxSpeedKnots", &g_ShowMoored_Kts, .1)
1220 CHECK_INT("bShowScaledTargets", &g_bAllowShowScaled);
1221 CHECK_INT("AISScaledNumber", &g_ShowScaled_Num);
1222 CHECK_INT("AISScaledNumberWeightSOG", &g_ScaledNumWeightSOG);
1223 CHECK_INT("AISScaledNumberWeightCPA", &g_ScaledNumWeightCPA);
1224 CHECK_INT("AISScaledNumberWeightTCPA", &g_ScaledNumWeightTCPA);
1225 CHECK_INT("AISScaledNumberWeightRange", &g_ScaledNumWeightRange);
1226 CHECK_INT("AISScaledNumberWeightSizeOfTarget", &g_ScaledNumWeightSizeOfT);
1227 CHECK_INT("AISScaledSizeMinimal", &g_ScaledSizeMinimal);
1228 CHECK_INT("AISShowScaled", &g_bShowScaled);
1229 CHECK_INT("bShowAreaNotices", &g_bShowAreaNotices);
1230 CHECK_INT("bDrawAISSize", &g_bDrawAISSize);
1231 CHECK_INT("bDrawAISRealtime", &g_bDrawAISRealtime);
1232 CHECK_FLT("AISRealtimeMinSpeedKnots", &g_AIS_RealtPred_Kts, .1);
1233 CHECK_INT("bShowAISName", &g_bShowAISName);
1234 CHECK_INT("bAISAlertDialog", &g_bAIS_CPA_Alert);
1235 CHECK_INT("ShowAISTargetNameScale", &g_Show_Target_Name_Scale);
1236 CHECK_INT("bWplIsAprsPositionReport", &g_bWplUsePosition);
1237 CHECK_INT("WplSelAction", &g_WplAction);
1238 CHECK_INT("AISCOGPredictorWidth", &g_ais_cog_predictor_width);
1239 CHECK_INT("bAISAlertAudio", &g_bAIS_CPA_Alert_Audio);
1240 CHECK_STR("AISAlertAudioFile", g_sAIS_Alert_Sound_File);
1241 CHECK_INT("bAISAlertSuppressMoored", &g_bAIS_CPA_Alert_Suppress_Moored);
1242 CHECK_INT("bAISAlertAckTimeout", &g_bAIS_ACK_Timeout);
1243 CHECK_FLT("AlertAckTimeoutMinutes", &g_AckTimeout_Mins, 1)
1244 CHECK_STR("AISTargetListPerspective", g_AisTargetList_perspective);
1245 CHECK_INT("AISTargetListRange", &g_AisTargetList_range);
1246 CHECK_INT("AISTargetListSortColumn", &g_AisTargetList_sortColumn);
1247 CHECK_INT("bAISTargetListSortReverse", &g_bAisTargetList_sortReverse);
1248 CHECK_STR("AISTargetListColumnSpec", g_AisTargetList_column_spec);
1249 CHECK_STR("AISTargetListColumnOrder", g_AisTargetList_column_order);
1250 CHECK_INT("bAISRolloverShowClass", &g_bAISRolloverShowClass);
1251 CHECK_INT("bAISRolloverShowCOG", &g_bAISRolloverShowCOG);
1252 CHECK_INT("bAISRolloverShowCPA", &g_bAISRolloverShowCPA);
1253
1254 CHECK_INT("S57QueryDialogSizeX", &g_S57_dialog_sx);
1255 CHECK_INT("S57QueryDialogSizeY", &g_S57_dialog_sy);
1256 CHECK_INT("AlertDialogSizeX", &g_ais_alert_dialog_sx);
1257 CHECK_INT("AlertDialogSizeY", &g_ais_alert_dialog_sy);
1258 CHECK_INT("AlertDialogPosX", &g_ais_alert_dialog_x);
1259 CHECK_INT("AlertDialogPosY", &g_ais_alert_dialog_y);
1260 CHECK_INT("QueryDialogPosX", &g_ais_query_dialog_x);
1261 CHECK_INT("QueryDialogPosY", &g_ais_query_dialog_y);
1262
1263 conf.SetPath("/Directories");
1264 CHECK_STR("PresentationLibraryData", g_UserPresLibData)
1266
1267 CHECK_STR("SENCFileLocation", g_SENCPrefix)
1268
1269 CHECK_STR("GPXIODir", g_gpx_path); // Get the Directory name
1270 CHECK_STR("TCDataDir", g_TCData_Dir); // Get the Directory name
1271 CHECK_STR("BasemapDir", gWorldMapLocation);
1272 CHECK_STR("BaseShapefileDir", gWorldShapefileLocation);
1273
1274 // Fonts
1275
1276#if 0
1277 // Load the persistent Auxiliary Font descriptor Keys
1278 conf.SetPath ( "/Settings/AuxFontKeys" );
1279
1280 wxString strk;
1281 long dummyk;
1282 wxString kval;
1283 bool bContk = conf,GetFirstEntry( strk, dummyk );
1284 bool bNewKey = false;
1285 while( bContk ) {
1286 Read( strk, &kval );
1287 bNewKey = FontMgr::Get().AddAuxKey(kval);
1288 if(!bNewKey) {
1289 DeleteEntry( strk );
1290 dummyk--;
1291 }
1292 bContk = GetNextEntry( strk, dummyk );
1293 }
1294#endif
1295
1296#ifdef __WXX11__
1297 conf.SetPath("/Settings/X11Fonts");
1298#endif
1299
1300#ifdef __WXGTK__
1301 conf.SetPath("/Settings/GTKFonts");
1302#endif
1303
1304#ifdef __WXMSW__
1305 conf.SetPath("/Settings/MSWFonts");
1306#endif
1307
1308#ifdef __WXMAC__
1309 conf.SetPath("/Settings/MacFonts");
1310#endif
1311
1312#ifdef __WXQT__
1313 conf.SetPath("/Settings/QTFonts");
1314#endif
1315
1316 conf.SetPath("/Settings/Others");
1317
1318 // Radar rings
1319 CHECK_INT("RadarRingsNumberVisible", &g_iNavAidRadarRingsNumberVisible)
1320 CHECK_INT("RadarRingsStep", &g_fNavAidRadarRingsStep)
1321
1322 CHECK_INT("RadarRingsStepUnits", &g_pNavAidRadarRingsStepUnits);
1323
1324 // wxString l_wxsOwnshipRangeRingsColour;
1325 // CHECK_STR( "RadarRingsColour", &l_wxsOwnshipRangeRingsColour );
1326 // if(l_wxsOwnshipRangeRingsColour.Length())
1327 // g_colourOwnshipRangeRingsColour.Set( l_wxsOwnshipRangeRingsColour );
1328
1329 // Waypoint Radar rings
1330 CHECK_INT("WaypointRangeRingsNumber", &g_iWaypointRangeRingsNumber)
1331
1332 CHECK_FLT("WaypointRangeRingsStep", &g_fWaypointRangeRingsStep, .1)
1333
1334 CHECK_INT("WaypointRangeRingsStepUnits", &g_iWaypointRangeRingsStepUnits);
1335
1336 // wxString l_wxsWaypointRangeRingsColour;
1337 // CHECK_STR( "WaypointRangeRingsColour",
1338 // &l_wxsWaypointRangeRingsColour ); g_colourWaypointRangeRingsColour.Set(
1339 // l_wxsWaypointRangeRingsColour );
1340
1341 CHECK_INT("ConfirmObjectDeletion", &g_bConfirmObjectDelete);
1342
1343 // Waypoint dragging with mouse
1344 CHECK_INT("WaypointPreventDragging", &g_bWayPointPreventDragging);
1345
1346 CHECK_INT("EnableZoomToCursor", &g_bEnableZoomToCursor);
1347
1348 CHECK_FLT("TrackIntervalSeconds", &g_TrackIntervalSeconds, 1)
1349
1350 CHECK_FLT("TrackDeltaDistance", &g_TrackDeltaDistance, .1)
1351
1352 CHECK_INT("TrackPrecision", &g_nTrackPrecision);
1353
1354 // CHECK_STR( "NavObjectFileName", m_sNavObjSetFile );
1355
1356 CHECK_INT("RouteLineWidth", &g_route_line_width);
1357 CHECK_INT("TrackLineWidth", &g_track_line_width);
1358
1359 // wxString l_wxsTrackLineColour;
1360 // CHECK_STR( "TrackLineColour", l_wxsTrackLineColour )
1361 // g_colourTrackLineColour.Set( l_wxsTrackLineColour );
1362
1363 CHECK_STR("DefaultWPIcon", g_default_wp_icon)
1364
1365 // S57 template items
1366
1367#define CHECK_BFN(s, t) \
1368 conf.Read(s, &read_int); \
1369 bval = t; \
1370 bval0 = read_int != 0; \
1371 if (bval != bval0) return false;
1372
1373#define CHECK_IFN(s, t) \
1374 conf.Read(s, &read_int); \
1375 if (read_int != t) return false;
1376
1377#define CHECK_FFN(s, t) \
1378 conf.Read(s, &dval); \
1379 if (fabs(dval - t) > 0.1) return false;
1380
1381 if (ps52plib) {
1382 int read_int;
1383 double dval;
1384 bool bval, bval0;
1385
1386 conf.SetPath("/Settings/GlobalState");
1387
1388 CHECK_BFN("bShowS57Text", ps52plib->GetShowS57Text());
1389
1390 CHECK_BFN("bShowS57ImportantTextOnly",
1391 ps52plib->GetShowS57ImportantTextOnly());
1392 CHECK_BFN("bShowLightDescription", ps52plib->m_bShowLdisText);
1393 CHECK_BFN("bExtendLightSectors", ps52plib->m_bExtendLightSectors);
1394 CHECK_BFN("bShowSoundg", ps52plib->m_bShowSoundg);
1395 CHECK_BFN("bShowMeta", ps52plib->m_bShowMeta);
1396 CHECK_BFN("bUseSCAMIN", ps52plib->m_bUseSCAMIN);
1397 CHECK_BFN("bUseSUPERSCAMIN", ps52plib->m_bUseSUPER_SCAMIN);
1398 CHECK_BFN("bShowAtonText", ps52plib->m_bShowAtonText);
1399 CHECK_BFN("bDeClutterText", ps52plib->m_bDeClutterText);
1400 CHECK_BFN("bShowNationalText", ps52plib->m_bShowNationalTexts);
1401 CHECK_IFN("nDisplayCategory", ps52plib->GetDisplayCategory());
1402 CHECK_IFN("nSymbolStyle", ps52plib->m_nSymbolStyle);
1403 CHECK_IFN("nBoundaryStyle", ps52plib->m_nBoundaryStyle);
1404 CHECK_FFN("S52_MAR_SAFETY_CONTOUR",
1405 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
1406 CHECK_FFN("S52_MAR_SHALLOW_CONTOUR",
1407 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
1408 CHECK_FFN("S52_MAR_DEEP_CONTOUR",
1409 S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
1410 CHECK_FFN("S52_MAR_TWO_SHADES", S52_getMarinerParam(S52_MAR_TWO_SHADES));
1411 CHECK_INT("S52_DEPTH_UNIT_SHOW", &g_nDepthUnitDisplay);
1412
1413 // S57 Object Class Visibility
1414
1415 OBJLElement *pOLE;
1416
1417 conf.SetPath("/Settings/ObjectFilter");
1418
1419 unsigned int iOBJMax = conf.GetNumberOfEntries();
1420
1421 if (iOBJMax != ps52plib->pOBJLArray->GetCount()) return false;
1422
1423 if (iOBJMax) {
1424 wxString str, sObj;
1425 long val;
1426 long dummy;
1427
1428 bool bCont = conf.GetFirstEntry(str, dummy);
1429 while (bCont) {
1430 conf.Read(str, &val); // Get an Object Viz
1431
1432 // scan for the same key in the global list
1433 bool bfound = false;
1434 if (str.StartsWith("viz", &sObj)) {
1435 for (unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
1436 iPtr++) {
1437 pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
1438 if (!strncmp(pOLE->OBJLName, sObj.mb_str(), 6)) {
1439 bfound = true;
1440 if (pOLE->nViz != val) {
1441 return false;
1442 }
1443 }
1444 }
1445
1446 if (!bfound) return false;
1447 }
1448 bCont = conf.GetNextEntry(str, dummy);
1449 }
1450 }
1451 }
1452
1453 conf.SetPath("/MmsiProperties");
1454 int iPMax = conf.GetNumberOfEntries();
1455 if (iPMax) {
1456 wxString str, val;
1457 long dummy;
1458
1459 bool bCont = conf.GetFirstEntry(str, dummy);
1460 while (bCont) {
1461 conf.Read(str, &val); // Get an entry
1462
1463 bool bfound = false;
1464 for (unsigned int j = 0; j < g_MMSI_Props_Array.GetCount(); j++) {
1465 MmsiProperties *pProps = g_MMSI_Props_Array.Item(j);
1466 if (pProps->Serialize().IsSameAs(val)) {
1467 bfound = true;
1468 break;
1469 }
1470 }
1471 if (!bfound) return false;
1472
1473 bCont = conf.GetNextEntry(str, dummy);
1474 }
1475 }
1476
1477 return rv;
1478}
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:358
bool AddAuxKey(wxString key)
Adds new plugin-defined font configuration key.
Definition font_mgr.cpp:651
int GetNumFonts(void) const
Gets the total number of font configurations currently loaded.
Definition font_mgr.cpp:320
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_iSpeedFormat
User-selected speed unit format for display and input.
int g_COGAvgSec
COG average period for Course Up Mode (sec)
int g_iDistanceFormat
User-selected distance (horizontal) unit format for display and input.
std::vector< size_t > g_config_display_size_mm
Size of pysical screen in millimeters.
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.
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
Chart object layer.
Multiplexer class and helpers.
Utility functions.
OpenCPN top window.
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.