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_frame.h"
61#include "ocpn_gl_options.h"
62#include "ocpn_platform.h"
63#include "ocpn_plugin.h"
64#include "route_prop_dlg_impl.h"
65#include "s52plib.h"
66#include "s52utils.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
389 OCPNConfigObject *pConfig = new OCPNConfigObject;
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 conf->Write("OwnShipSogCogCalc", g_own_ship_sog_cog_calc);
646 conf->Write("OwnShipSogCogCalcDampSec", g_own_ship_sog_cog_calc_damp_sec);
647
648 conf->Write("RouteArrivalCircleRadius",
649 wxString::Format("%.3f", g_n_arrival_circle_radius));
650 conf->Write("ChartQuilting", g_bQuiltEnable);
651
652 conf->Write("StartWithTrackActive", g_bTrackCarryOver);
653 conf->Write("AutomaticDailyTracks", g_bTrackDaily);
654 conf->Write("TrackRotateAt", g_track_rotate_time);
655 conf->Write("TrackRotateTimeType", g_track_rotate_time_type);
656 conf->Write("HighlightTracks", g_bHighliteTracks);
657
658 conf->Write("DateTimeFormat", g_datetime_format);
659
660 conf->Write("InitialStackIndex", g_restore_stackindex);
661 conf->Write("InitialdBIndex", g_restore_dbindex);
662
663 conf->Write("AnchorWatch1GUID", g_AW1GUID);
664 conf->Write("AnchorWatch2GUID", g_AW2GUID);
665
666 conf->Write("ToolbarX", g_maintoolbar_x);
667 conf->Write("ToolbarY", g_maintoolbar_y);
668 conf->Write("ToolbarOrient", g_maintoolbar_orient);
669
670 conf->Write("iENCToolbarX", g_iENCToolbarPosX);
671 conf->Write("iENCToolbarY", g_iENCToolbarPosY);
672
673 if (!g_bInlandEcdis) {
674 conf->Write("GlobalToolbarConfig", g_toolbarConfig);
675 conf->Write("DistanceFormat", g_iDistanceFormat);
676 conf->Write("SpeedFormat", g_iSpeedFormat);
677 conf->Write("WindSpeedFormat", g_iWindSpeedFormat);
678 conf->Write("ShowDepthUnits", g_bShowDepthUnits);
679 }
680
681 conf->Write("MobileTouch", g_btouch);
682 conf->Write("ResponsiveGraphics", g_bresponsive);
683
684 conf->Write("AutoHideToolbar", g_bAutoHideToolbar);
685 conf->Write("AutoHideToolbarSecs", g_nAutoHideToolbar);
686
687 wxString st0;
688 for (const auto &mm : g_config_display_size_mm) {
689 st0.Append(wxString::Format("%zu,", mm));
690 }
691 st0.RemoveLast(); // Strip last comma
692 conf->Write("DisplaySizeMM", st0);
693 conf->Write("DisplaySizeManual", g_config_display_size_manual);
694
695 conf->Write("PlanSpeed", wxString::Format("%.2f", g_PlanSpeed));
696
697#if 0
698 wxString vis, invis;
699 LayerList::iterator it;
700 int index = 0;
701 for( it = ( *pLayerList ).begin(); it != ( *pLayerList ).end(); ++it, ++index ) {
702 Layer *lay = (Layer *) ( *it );
703 if( lay->IsVisibleOnChart() ) vis += ( lay->m_LayerName ) + ";";
704 else
705 invis += ( lay->m_LayerName ) + ";";
706 }
707 conf->Write( "VisibleLayers", vis );
708 conf->Write( "InvisibleLayers", invis );
709#endif
710
711 conf->Write("Locale", g_locale);
712 conf->Write("LocaleOverride", g_localeOverride);
713
714 // LIVE ETA OPTION
715 conf->Write("LiveETA", g_bShowLiveETA);
716 conf->Write("DefaultBoatSpeed", g_defaultBoatSpeed);
717
718 // S57 Object Filter Settings
719 conf->SetPath("/Settings/ObjectFilter");
720
721 if (ps52plib) {
722 for (unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
723 iPtr++) {
724 OBJLElement *pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
725
726 wxString st1("viz");
727 char name[7];
728 strncpy(name, pOLE->OBJLName, 6);
729 name[6] = 0;
730 st1.Append(wxString(name, wxConvUTF8));
731 conf->Write(st1, pOLE->nViz);
732 }
733 }
734
735 // Global State
736
737 conf->SetPath("/Settings/GlobalState");
738
739 // Various Options
740 if (!g_bInlandEcdis)
741 conf->Write("nColorScheme", (int)gFrame->GetColorScheme());
742
743 // AIS
744 conf->SetPath("/Settings/AIS");
745
746 conf->Write("bNoCPAMax", g_bCPAMax);
747 conf->Write("NoCPAMaxNMi", g_CPAMax_NM);
748 conf->Write("bCPAWarn", g_bCPAWarn);
749 conf->Write("CPAWarnNMi", g_CPAWarn_NM);
750 conf->Write("bTCPAMax", g_bTCPA_Max);
751 conf->Write("TCPAMaxMinutes", g_TCPA_Max);
752 conf->Write("bMarkLostTargets", g_bMarkLost);
753 conf->Write("MarkLost_Minutes", g_MarkLost_Mins);
754 conf->Write("bRemoveLostTargets", g_bRemoveLost);
755 conf->Write("RemoveLost_Minutes", g_RemoveLost_Mins);
756 conf->Write("bShowCOGArrows", g_bShowCOG);
757 conf->Write("CogArrowMinutes", g_ShowCOG_Mins);
758 conf->Write("bShowTargetTracks", g_bAISShowTracks);
759 conf->Write("TargetTracksMinutes", g_AISShowTracks_Mins);
760
761 conf->Write("bHideMooredTargets", g_bHideMoored);
762 conf->Write("MooredTargetMaxSpeedKnots", g_ShowMoored_Kts);
763
764 conf->Write("bAISAlertDialog", g_bAIS_CPA_Alert);
765 conf->Write("bAISAlertAudio", g_bAIS_CPA_Alert_Audio);
766 conf->Write("AISAlertAudioFile", g_sAIS_Alert_Sound_File);
767 conf->Write("bAISAlertSuppressMoored", g_bAIS_CPA_Alert_Suppress_Moored);
768 conf->Write("bShowAreaNotices", g_bShowAreaNotices);
769 conf->Write("bDrawAISSize", g_bDrawAISSize);
770 conf->Write("bDrawAISRealtime", g_bDrawAISRealtime);
771 conf->Write("AISRealtimeMinSpeedKnots", g_AIS_RealtPred_Kts);
772 conf->Write("bShowAISName", g_bShowAISName);
773 conf->Write("ShowAISTargetNameScale", g_Show_Target_Name_Scale);
774 conf->Write("bWplIsAprsPositionReport", g_bWplUsePosition);
775 conf->Write("WplSelAction", g_WplAction);
776 conf->Write("AISCOGPredictorWidth", g_ais_cog_predictor_width);
777 conf->Write("bShowScaledTargets", g_bAllowShowScaled);
778 conf->Write("AISScaledNumber", g_ShowScaled_Num);
779 conf->Write("AISScaledNumberWeightSOG", g_ScaledNumWeightSOG);
780 conf->Write("AISScaledNumberWeightCPA", g_ScaledNumWeightCPA);
781 conf->Write("AISScaledNumberWeightTCPA", g_ScaledNumWeightTCPA);
782 conf->Write("AISScaledNumberWeightRange", g_ScaledNumWeightRange);
783 conf->Write("AISScaledNumberWeightSizeOfTarget", g_ScaledNumWeightSizeOfT);
784 conf->Write("AISScaledSizeMinimal", g_ScaledSizeMinimal);
785 conf->Write("AISShowScaled", g_bShowScaled);
786
787 conf->Write("AlertDialogSizeX", g_ais_alert_dialog_sx);
788 conf->Write("AlertDialogSizeY", g_ais_alert_dialog_sy);
789 conf->Write("AlertDialogPosX", g_ais_alert_dialog_x);
790 conf->Write("AlertDialogPosY", g_ais_alert_dialog_y);
791 conf->Write("QueryDialogPosX", g_ais_query_dialog_x);
792 conf->Write("QueryDialogPosY", g_ais_query_dialog_y);
793 conf->Write("AISTargetListPerspective", g_AisTargetList_perspective);
794 conf->Write("AISTargetListRange", g_AisTargetList_range);
795 conf->Write("AISTargetListSortColumn", g_AisTargetList_sortColumn);
796 conf->Write("bAISTargetListSortReverse", g_bAisTargetList_sortReverse);
797 conf->Write("AISTargetListColumnSpec", g_AisTargetList_column_spec);
798 conf->Write("AISTargetListColumnOrder", g_AisTargetList_column_order);
799 conf->Write("S57QueryDialogSizeX", g_S57_dialog_sx);
800 conf->Write("S57QueryDialogSizeY", g_S57_dialog_sy);
801 conf->Write("bAISRolloverShowClass", g_bAISRolloverShowClass);
802 conf->Write("bAISRolloverShowCOG", g_bAISRolloverShowCOG);
803 conf->Write("bAISRolloverShowCPA", g_bAISRolloverShowCPA);
804 conf->Write("bAISAlertAckTimeout", g_bAIS_ACK_Timeout);
805 conf->Write("AlertAckTimeoutMinutes", g_AckTimeout_Mins);
806
807 conf->SetPath("/Settings/GlobalState");
808 if (ps52plib) {
809 conf->Write("bShowS57Text", ps52plib->GetShowS57Text());
810 conf->Write("bShowS57ImportantTextOnly",
811 ps52plib->GetShowS57ImportantTextOnly());
812 if (!g_bInlandEcdis)
813 conf->Write("nDisplayCategory", (long)ps52plib->GetDisplayCategory());
814 conf->Write("nSymbolStyle", (int)ps52plib->m_nSymbolStyle);
815 conf->Write("nBoundaryStyle", (int)ps52plib->m_nBoundaryStyle);
816
817 conf->Write("bShowSoundg", ps52plib->m_bShowSoundg);
818 conf->Write("bShowMeta", ps52plib->m_bShowMeta);
819 conf->Write("bUseSCAMIN", ps52plib->m_bUseSCAMIN);
820 conf->Write("bUseSUPER_SCAMIN", ps52plib->m_bUseSUPER_SCAMIN);
821 conf->Write("bShowAtonText", ps52plib->m_bShowAtonText);
822 conf->Write("bShowLightDescription", ps52plib->m_bShowLdisText);
823 conf->Write("bExtendLightSectors", ps52plib->m_bExtendLightSectors);
824 conf->Write("bDeClutterText", ps52plib->m_bDeClutterText);
825 conf->Write("bShowNationalText", ps52plib->m_bShowNationalTexts);
826
827 conf->Write("S52_MAR_SAFETY_CONTOUR",
828 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
829 conf->Write("S52_MAR_SHALLOW_CONTOUR",
830 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
831 conf->Write("S52_MAR_DEEP_CONTOUR",
832 S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
833 conf->Write("S52_MAR_TWO_SHADES", S52_getMarinerParam(S52_MAR_TWO_SHADES));
834 conf->Write("S52_DEPTH_UNIT_SHOW", ps52plib->m_nDepthUnitDisplay);
835 }
836
837 conf->SetPath("/Settings/Others");
838
839 // Radar rings
840 conf->Write("ShowRadarRings", (bool)(g_iNavAidRadarRingsNumberVisible >
841 0)); // 3.0.0 config support
842 conf->Write("RadarRingsNumberVisible", g_iNavAidRadarRingsNumberVisible);
843 g_bNavAidRadarRingsShown = g_iNavAidRadarRingsNumberVisible > 0;
844 conf->Write("RadarRingsStep", g_fNavAidRadarRingsStep);
845 conf->Write("RadarRingsStepUnits", g_pNavAidRadarRingsStepUnits);
846 conf->Write("RadarRingsColour",
847 g_colourOwnshipRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
848
849 // Waypoint Radar rings
850 conf->Write("WaypointRangeRingsNumber", g_iWaypointRangeRingsNumber);
851 conf->Write("WaypointRangeRingsStep", g_fWaypointRangeRingsStep);
852 conf->Write("WaypointRangeRingsStepUnits", g_iWaypointRangeRingsStepUnits);
853 conf->Write("WaypointRangeRingsColour",
854 g_colourWaypointRangeRingsColour.GetAsString(wxC2S_HTML_SYNTAX));
855
856 conf->Write("ConfirmObjectDeletion", g_bConfirmObjectDelete);
857
858 // Waypoint dragging with mouse
859 conf->Write("WaypointPreventDragging", g_bWayPointPreventDragging);
860
861 conf->Write("EnableZoomToCursor", g_bEnableZoomToCursor);
862
863 conf->Write("TrackIntervalSeconds", g_TrackIntervalSeconds);
864 conf->Write("TrackDeltaDistance", g_TrackDeltaDistance);
865 conf->Write("TrackPrecision", g_nTrackPrecision);
866
867 conf->Write("RouteLineWidth", g_route_line_width);
868 conf->Write("TrackLineWidth", g_track_line_width);
869 conf->Write("TrackLineColour",
870 g_colourTrackLineColour.GetAsString(wxC2S_HTML_SYNTAX));
871 conf->Write("DefaultWPIcon", g_default_wp_icon);
872
873 // Fonts
874
875 // Store the persistent Auxiliary Font descriptor Keys
876 conf->SetPath("/Settings/AuxFontKeys");
877
878 wxArrayString keyArray = FontMgr::Get().GetAuxKeyArray();
879 for (unsigned int i = 0; i < keyArray.GetCount(); i++) {
880 wxString key;
881 key.Printf("Key%i", i);
882 wxString keyval = keyArray[i];
883 conf->Write(key, keyval);
884 }
885
886 wxString font_path;
887#ifdef __WXX11__
888 font_path = ("/Settings/X11Fonts");
889#endif
890
891#ifdef __WXGTK__
892 font_path = ("/Settings/GTKFonts");
893#endif
894
895#ifdef __WXMSW__
896 font_path = ("/Settings/MSWFonts");
897#endif
898
899#ifdef __WXMAC__
900 font_path = ("/Settings/MacFonts");
901#endif
902
903#ifdef __WXQT__
904 font_path = ("/Settings/QTFonts");
905#endif
906
907 conf->DeleteGroup(font_path);
908
909 conf->SetPath(font_path);
910
911 int nFonts = FontMgr::Get().GetNumFonts();
912
913 for (int i = 0; i < nFonts; i++) {
914 wxString cfstring(FontMgr::Get().GetConfigString(i));
915 wxString valstring = FontMgr::Get().GetFullConfigDesc(i);
916 conf->Write(cfstring, valstring);
917 }
918
919 // Save the per-canvas config options
920 conf->SaveCanvasConfigs();
921
922 conf->Flush();
923
924 delete conf;
925
926 return true;
927}
928
929bool ConfigMgr::CheckTemplateGUID(wxString GUID) {
930 bool rv = false;
931
932 OCPNConfigObject *config = GetConfig(GUID);
933 if (config) {
934 rv = CheckTemplate(GetConfigDir() + config->templateFileName);
935 }
936
937 return rv;
938}
939
940#define CHECK_INT(s, t) \
941 read_int = *t; \
942 if (!conf.Read(s, &read_int)) wxLogMessage(s); \
943 if ((int)*t != read_int) return false;
944
945#define CHECK_STR(s, t) \
946 val = t; \
947 conf.Read(s, &val); \
948 if (!t.IsSameAs(val)) return false;
949
950#define CHECK_STRP(s, t) \
951 conf.Read(s, &val); \
952 if (!t->IsSameAs(val)) return false;
953
954#define CHECK_FLT(s, t, eps) \
955 conf.Read(s, &val); \
956 val.ToDouble(&dval); \
957 if (fabs(dval - *t) > eps) return false;
958
959bool ConfigMgr::CheckTemplate(wxString fileName) {
960 bool rv = true;
961
962 int read_int;
963 wxString val;
964 double dval;
965
966 MyConfig conf(fileName);
967
968 // Global options and settings
969 conf.SetPath("/Settings");
970
971 CHECK_INT("UIexpert", &g_bUIexpert);
972
974
975 CHECK_INT("InlandEcdis", &g_bInlandEcdis);
976
977 CHECK_INT("SpaceDropMark", &g_bSpaceDropMark);
978
980
981#if 0
982 CHECK_INT( "DebugGDAL", &g_bGDAL_Debug );
983 CHECK_INT( "DebugNMEA", &g_nNMEADebug );
984 CHECK_INT( "DebugOpenGL", &g_bDebugOGL );
988 CHECK_INT( "DebugCM93", &g_bDebugCM93 );
989 CHECK_INT( "DebugS57", &g_bDebugS57 ); // Show LUP and Feature info in object query
990 CHECK_INT( "DebugBSBImg", &g_BSBImgDebug );
991 CHECK_INT( "DebugGPSD", &g_bDebugGPSD );
992#endif
993
994 CHECK_INT("DefaultFontSize", &g_default_font_size);
995
996 // Read( "GPSIdent", &g_GPS_Ident );
997 CHECK_INT("UseGarminHostUpload", &g_bGarminHostUpload);
998
999 CHECK_INT("UseNMEA_GLL", &g_bUseGLL);
1000
1001 CHECK_INT("AutoHideToolbar", &g_bAutoHideToolbar);
1002 CHECK_INT("AutoHideToolbarSecs", &g_nAutoHideToolbar);
1003
1004 CHECK_INT("UseSimplifiedScalebar", &g_bsimplifiedScalebar);
1005
1006 CHECK_INT("DisplaySizeMM", &g_display_size_mm);
1007 CHECK_INT("DisplaySizeManual", &g_config_display_size_manual);
1008
1009 CHECK_INT("GUIScaleFactor", &g_GUIScaleFactor);
1010
1011 CHECK_INT("ChartObjectScaleFactor", &g_ChartScaleFactor);
1012 CHECK_INT("ShipScaleFactor", &g_ShipScaleFactor);
1013
1014 CHECK_INT("FilterNMEA_Avg", &g_bfilter_cogsog);
1015 CHECK_INT("FilterNMEA_Sec", &g_COGFilterSec);
1016
1017 CHECK_INT("ShowTrue", &g_bShowTrue);
1018 CHECK_INT("ShowMag", &g_bShowMag);
1019
1020 CHECK_FLT("UserMagVariation", &g_UserVar, 0.1)
1021
1022 CHECK_INT("UseMagAPB", &g_bMagneticAPB);
1023
1024 CHECK_INT("ScreenBrightness", &g_nbrightness);
1025
1026 CHECK_INT("MemFootprintTargetMB", &g_MemFootMB);
1027
1028 CHECK_INT("WindowsComPortMax", &g_nCOMPortCheck);
1029
1030 CHECK_INT("ChartQuilting", &g_bQuiltEnable);
1031 CHECK_INT("ChartQuiltingInitial", &g_bQuiltStart);
1032
1033 CHECK_INT("CourseUpMode", &g_bCourseUp);
1034 CHECK_INT("COGUPAvgSeconds", &g_COGAvgSec);
1035 // CHECK_INT( "LookAheadMode", &g_bLookAhead );
1036 // CHECK_INT( "SkewToNorthUp", &g_bskew_comp );
1037 CHECK_INT("OpenGL", &g_bopengl);
1038 CHECK_INT("SoftwareGL", &g_bSoftwareGL);
1039
1040 CHECK_INT("NMEAAPBPrecision", &g_NMEAAPBPrecision);
1041
1042 CHECK_STR("TalkerIdText", g_TalkerIdText);
1043 CHECK_INT("MaxWaypointNameLength", &g_maxWPNameLength);
1044 CHECK_INT("MbtilesMaxLayers", &g_mbtilesMaxLayers);
1045
1046 /* opengl options */
1047#ifdef ocpnUSE_GL
1048 CHECK_INT("OpenGLExpert", &g_bGLexpert);
1049 CHECK_INT("UseAcceleratedPanning", &g_GLOptions.m_bUseAcceleratedPanning);
1050 CHECK_INT("GPUTextureCompression", &g_GLOptions.m_bTextureCompression);
1051 CHECK_INT("GPUTextureCompressionCaching",
1052 &g_GLOptions.m_bTextureCompressionCaching);
1053 CHECK_INT("PolygonSmoothing", &g_GLOptions.m_GLPolygonSmoothing);
1054 CHECK_INT("LineSmoothing", &g_GLOptions.m_GLLineSmoothing);
1055 CHECK_INT("GPUTextureDimension", &g_GLOptions.m_iTextureDimension);
1056 CHECK_INT("GPUTextureMemSize", &g_GLOptions.m_iTextureMemorySize);
1057
1058#endif
1059 CHECK_INT("SmoothPanZoom", &g_bsmoothpanzoom);
1060
1061 CHECK_INT("ToolbarX", &g_maintoolbar_x);
1062 CHECK_INT("ToolbarY", &g_maintoolbar_y);
1063 CHECK_INT("ToolbarOrient", &g_maintoolbar_orient);
1064 CHECK_STR("GlobalToolbarConfig", g_toolbarConfig);
1065
1066 CHECK_INT("iENCToolbarX", &g_iENCToolbarPosX);
1067 CHECK_INT("iENCToolbarY", &g_iENCToolbarPosY);
1068
1069 CHECK_STR("AnchorWatch1GUID", g_AW1GUID);
1070 CHECK_STR("AnchorWatch2GUID", g_AW2GUID);
1071
1072 CHECK_INT("MobileTouch", &g_btouch);
1073 CHECK_INT("ResponsiveGraphics", &g_bresponsive);
1074
1075 CHECK_INT("ZoomDetailFactor", &g_chart_zoom_modifier_raster);
1076 CHECK_INT("ZoomDetailFactorVector", &g_chart_zoom_modifier_vector);
1077
1078 CHECK_INT("CM93DetailFactor", &g_cm93_zoom_factor);
1079 CHECK_INT("CM93DetailZoomPosX", &g_detailslider_dialog_x);
1080 CHECK_INT("CM93DetailZoomPosY", &g_detailslider_dialog_y);
1081 CHECK_INT("ShowCM93DetailSlider", &g_bShowDetailSlider);
1082
1083 CHECK_INT("SENC_LOD_Pixels", &g_SENC_LOD_pixels);
1084
1085 CHECK_INT("SkewCompUpdatePeriod", &g_SkewCompUpdatePeriod);
1086
1087 CHECK_INT("ShowStatusBar", &g_bShowStatusBar);
1088#ifndef __WXOSX__
1089 CHECK_INT("ShowMenuBar", &g_bShowMenuBar);
1090#endif
1091 CHECK_INT("Fullscreen", &g_bFullscreen);
1092 CHECK_INT("ShowCompassWindow", &g_bShowCompassWin);
1093 CHECK_INT("PlayShipsBells", &g_bPlayShipsBells);
1094 CHECK_INT("SoundDeviceIndex", &g_iSoundDeviceIndex);
1095 CHECK_INT("FullscreenToolbar", &g_bFullscreenToolbar);
1096 // CHECK_INT( "TransparentToolbar", &g_bTransparentToolbar );
1097 CHECK_INT("PermanentMOBIcon", &g_bPermanentMOBIcon);
1098 CHECK_INT("ShowLayers", &g_bShowLayers);
1099 CHECK_INT("ShowDepthUnits", &g_bShowDepthUnits);
1100 CHECK_INT("AutoAnchorDrop", &g_bAutoAnchorMark);
1101 CHECK_INT("ShowActiveRouteHighway", &g_bShowActiveRouteHighway);
1102 CHECK_INT("ShowActiveRouteTotal", &g_bShowRouteTotal);
1103 CHECK_STR("MostRecentGPSUploadConnection", g_uploadConnection);
1104 CHECK_INT("ShowChartBar", &g_bShowChartBar);
1105 CHECK_INT("SDMMFormat",
1106 &g_iSDMMFormat); // 0 = "Degrees, Decimal minutes"), 1 = "Decimal
1107 // degrees", 2 = "Degrees,Minutes, Seconds"
1108
1109 CHECK_INT("DistanceFormat",
1110 &g_iDistanceFormat); // 0 = "Nautical miles"), 1 = "Statute miles",
1111 // 2 = "Kilometers", 3 = "Meters"
1112 CHECK_INT("SpeedFormat",
1113 &g_iSpeedFormat); // 0 = "kts"), 1 = "mph", 2 = "km/h", 3 = "m/s"
1114 CHECK_INT(
1115 "WindSpeedFormat",
1116 &g_iWindSpeedFormat); // 0 = "knots"), 1 = "m/s", 2 = "Mph", 3 = "km/h"
1117
1118 // LIVE ETA OPTION
1119 CHECK_INT("LiveETA", &g_bShowLiveETA);
1120 CHECK_INT("DefaultBoatSpeed", &g_defaultBoatSpeed);
1121
1122 CHECK_INT("OwnshipCOGPredictorMinutes", &g_ownship_predictor_minutes);
1123 CHECK_INT("OwnshipCOGPredictorWidth", &g_cog_predictor_width);
1124 CHECK_INT("OwnshipHDTPredictorMiles", &g_ownship_HDTpredictor_miles);
1125
1126 CHECK_INT("OwnShipIconType", &g_OwnShipIconType);
1127 CHECK_FLT("OwnShipLength", &g_n_ownship_length_meters, 0.1);
1128 CHECK_FLT("OwnShipWidth", &g_n_ownship_beam_meters, 0.1);
1129 CHECK_FLT("OwnShipGPSOffsetX", &g_n_gps_antenna_offset_x, 0.1);
1130 CHECK_FLT("OwnShipGPSOffsetY", &g_n_gps_antenna_offset_y, 0.1);
1131 CHECK_INT("OwnShipMinSize", &g_n_ownship_min_mm);
1132 CHECK_INT("OwnShipSogCogCalc", &g_own_ship_sog_cog_calc);
1133 CHECK_INT("OwnShipSogCogCalcDampSec", &g_own_ship_sog_cog_calc_damp_sec);
1134
1135 CHECK_FLT("RouteArrivalCircleRadius", &g_n_arrival_circle_radius, .01);
1136
1137 CHECK_INT("FullScreenQuilt", &g_bFullScreenQuilt);
1138
1139 CHECK_INT("StartWithTrackActive", &g_bTrackCarryOver);
1140 CHECK_INT("AutomaticDailyTracks", &g_bTrackDaily);
1141 CHECK_INT("TrackRotateAt", &g_track_rotate_time);
1142 CHECK_INT("TrackRotateTimeType", &g_track_rotate_time_type);
1143 CHECK_INT("HighlightTracks", &g_bHighliteTracks);
1144
1145 CHECK_STR("DateTimeFormat", g_datetime_format);
1146
1147 CHECK_FLT("PlanSpeed", &g_PlanSpeed, 0.1)
1148
1149
1151
1152 CHECK_INT("PreserveScaleOnX", &g_bPreserveScaleOnX);
1153
1154 CHECK_STR("Locale", g_locale);
1155 CHECK_STR("LocaleOverride", g_localeOverride);
1156
1157 // We allow 0-99 backups ov navobj.xml
1158 CHECK_INT("KeepNavobjBackups", &g_navobjbackups);
1159
1160 // NMEALogWindow::Get().SetSize(Read("NMEALogWindowSizeX", 600L),
1161 // Read("NMEALogWindowSizeY", 400L));
1162 // NMEALogWindow::Get().SetPos(Read("NMEALogWindowPosX", 10L),
1163 // Read("NMEALogWindowPosY", 10L));
1164 // NMEALogWindow::Get().CheckPos(display_width, display_height);
1165
1166 // Boolean to cater for legacy Input COM Port filer behaviour, i.e. show msg
1167 // filtered but put msg on bus.
1168 CHECK_INT("LegacyInputCOMPortFilterBehaviour",
1169 &g_b_legacy_input_filter_behaviour);
1170
1171 CHECK_INT("AdvanceRouteWaypointOnArrivalOnly",
1172 &g_bAdvanceRouteWaypointOnArrivalOnly);
1173
1174 CHECK_INT("EnableRotateKeys", &g_benable_rotate);
1175 CHECK_INT("EmailCrashReport", &g_bEmailCrashReport);
1176
1177 CHECK_INT("EnableAISNameCache", &g_benableAISNameCache);
1178
1179 CHECK_INT("EnableUDPNullHeader", &g_benableUDPNullHeader);
1180
1181 conf.SetPath("/Settings/GlobalState");
1182
1183 CHECK_INT("FrameWinX", &g_nframewin_x);
1184 CHECK_INT("FrameWinY", &g_nframewin_y);
1185 CHECK_INT("FrameWinPosX", &g_nframewin_posx);
1186 CHECK_INT("FrameWinPosY", &g_nframewin_posy);
1187 CHECK_INT("FrameMax", &g_bframemax);
1188
1189 CHECK_INT("ClientPosX", &g_lastClientRectx);
1190 CHECK_INT("ClientPosY", &g_lastClientRecty);
1191 CHECK_INT("ClientSzX", &g_lastClientRectw);
1192 CHECK_INT("ClientSzY", &g_lastClientRecth);
1193
1194 CHECK_INT("RoutePropSizeX", &g_route_prop_sx);
1195 CHECK_INT("RoutePropSizeY", &g_route_prop_sy);
1196 CHECK_INT("RoutePropPosX", &g_route_prop_x);
1197 CHECK_INT("RoutePropPosY", &g_route_prop_y);
1198
1199 CHECK_INT("S52_DEPTH_UNIT_SHOW",
1200 &g_nDepthUnitDisplay); // default is metres
1201
1202 // AIS
1203 conf.SetPath("/Settings/AIS");
1204 CHECK_INT("bNoCPAMax", &g_bCPAMax);
1205 CHECK_FLT("NoCPAMaxNMi", &g_CPAMax_NM, .01)
1206 CHECK_INT("bCPAWarn", &g_bCPAWarn);
1207 CHECK_FLT("CPAWarnNMi", &g_CPAWarn_NM, .01)
1208 CHECK_INT("bTCPAMax", &g_bTCPA_Max);
1209 CHECK_FLT("TCPAMaxMinutes", &g_TCPA_Max, 1)
1210 CHECK_INT("bMarkLostTargets", &g_bMarkLost);
1211 CHECK_FLT("MarkLost_Minutes", &g_MarkLost_Mins, 1)
1212 CHECK_INT("bRemoveLostTargets", &g_bRemoveLost);
1213 CHECK_FLT("RemoveLost_Minutes", &g_RemoveLost_Mins, 1)
1214 CHECK_INT("bShowCOGArrows", &g_bShowCOG);
1215 CHECK_INT("bSyncCogPredictors", &g_bSyncCogPredictors);
1216 CHECK_FLT("CogArrowMinutes", &g_ShowCOG_Mins, 1);
1217 CHECK_INT("bShowTargetTracks", &g_bAISShowTracks);
1218 CHECK_FLT("TargetTracksMinutes", &g_AISShowTracks_Mins, 1)
1219 CHECK_FLT("TargetTracksLimit", &g_AISShowTracks_Limit, 300)
1220 CHECK_INT("bHideMooredTargets", &g_bHideMoored)
1221 CHECK_FLT("MooredTargetMaxSpeedKnots", &g_ShowMoored_Kts, .1)
1222 CHECK_INT("bShowScaledTargets", &g_bAllowShowScaled);
1223 CHECK_INT("AISScaledNumber", &g_ShowScaled_Num);
1224 CHECK_INT("AISScaledNumberWeightSOG", &g_ScaledNumWeightSOG);
1225 CHECK_INT("AISScaledNumberWeightCPA", &g_ScaledNumWeightCPA);
1226 CHECK_INT("AISScaledNumberWeightTCPA", &g_ScaledNumWeightTCPA);
1227 CHECK_INT("AISScaledNumberWeightRange", &g_ScaledNumWeightRange);
1228 CHECK_INT("AISScaledNumberWeightSizeOfTarget", &g_ScaledNumWeightSizeOfT);
1229 CHECK_INT("AISScaledSizeMinimal", &g_ScaledSizeMinimal);
1230 CHECK_INT("AISShowScaled", &g_bShowScaled);
1231 CHECK_INT("bShowAreaNotices", &g_bShowAreaNotices);
1232 CHECK_INT("bDrawAISSize", &g_bDrawAISSize);
1233 CHECK_INT("bDrawAISRealtime", &g_bDrawAISRealtime);
1234 CHECK_FLT("AISRealtimeMinSpeedKnots", &g_AIS_RealtPred_Kts, .1);
1235 CHECK_INT("bShowAISName", &g_bShowAISName);
1236 CHECK_INT("bAISAlertDialog", &g_bAIS_CPA_Alert);
1237 CHECK_INT("ShowAISTargetNameScale", &g_Show_Target_Name_Scale);
1238 CHECK_INT("bWplIsAprsPositionReport", &g_bWplUsePosition);
1239 CHECK_INT("WplSelAction", &g_WplAction);
1240 CHECK_INT("AISCOGPredictorWidth", &g_ais_cog_predictor_width);
1241 CHECK_INT("bAISAlertAudio", &g_bAIS_CPA_Alert_Audio);
1242 CHECK_STR("AISAlertAudioFile", g_sAIS_Alert_Sound_File);
1243 CHECK_INT("bAISAlertSuppressMoored", &g_bAIS_CPA_Alert_Suppress_Moored);
1244 CHECK_INT("bAISAlertAckTimeout", &g_bAIS_ACK_Timeout);
1245 CHECK_FLT("AlertAckTimeoutMinutes", &g_AckTimeout_Mins, 1)
1246 CHECK_STR("AISTargetListPerspective", g_AisTargetList_perspective);
1247 CHECK_INT("AISTargetListRange", &g_AisTargetList_range);
1248 CHECK_INT("AISTargetListSortColumn", &g_AisTargetList_sortColumn);
1249 CHECK_INT("bAISTargetListSortReverse", &g_bAisTargetList_sortReverse);
1250 CHECK_STR("AISTargetListColumnSpec", g_AisTargetList_column_spec);
1251 CHECK_STR("AISTargetListColumnOrder", g_AisTargetList_column_order);
1252 CHECK_INT("bAISRolloverShowClass", &g_bAISRolloverShowClass);
1253 CHECK_INT("bAISRolloverShowCOG", &g_bAISRolloverShowCOG);
1254 CHECK_INT("bAISRolloverShowCPA", &g_bAISRolloverShowCPA);
1255
1256 CHECK_INT("S57QueryDialogSizeX", &g_S57_dialog_sx);
1257 CHECK_INT("S57QueryDialogSizeY", &g_S57_dialog_sy);
1258 CHECK_INT("AlertDialogSizeX", &g_ais_alert_dialog_sx);
1259 CHECK_INT("AlertDialogSizeY", &g_ais_alert_dialog_sy);
1260 CHECK_INT("AlertDialogPosX", &g_ais_alert_dialog_x);
1261 CHECK_INT("AlertDialogPosY", &g_ais_alert_dialog_y);
1262 CHECK_INT("QueryDialogPosX", &g_ais_query_dialog_x);
1263 CHECK_INT("QueryDialogPosY", &g_ais_query_dialog_y);
1264
1265 conf.SetPath("/Directories");
1266 CHECK_STR("PresentationLibraryData", g_UserPresLibData)
1268
1269 CHECK_STR("SENCFileLocation", g_SENCPrefix)
1270
1271 CHECK_STR("GPXIODir", g_gpx_path); // Get the Directory name
1272 CHECK_STR("TCDataDir", g_TCData_Dir); // Get the Directory name
1273 CHECK_STR("BasemapDir", gWorldMapLocation);
1274 CHECK_STR("BaseShapefileDir", gWorldShapefileLocation);
1275
1276 // Fonts
1277
1278#if 0
1279 // Load the persistent Auxiliary Font descriptor Keys
1280 conf.SetPath ( "/Settings/AuxFontKeys" );
1281
1282 wxString strk;
1283 long dummyk;
1284 wxString kval;
1285 bool bContk = conf,GetFirstEntry( strk, dummyk );
1286 bool bNewKey = false;
1287 while( bContk ) {
1288 Read( strk, &kval );
1289 bNewKey = FontMgr::Get().AddAuxKey(kval);
1290 if(!bNewKey) {
1291 DeleteEntry( strk );
1292 dummyk--;
1293 }
1294 bContk = GetNextEntry( strk, dummyk );
1295 }
1296#endif
1297
1298#ifdef __WXX11__
1299 conf.SetPath("/Settings/X11Fonts");
1300#endif
1301
1302#ifdef __WXGTK__
1303 conf.SetPath("/Settings/GTKFonts");
1304#endif
1305
1306#ifdef __WXMSW__
1307 conf.SetPath("/Settings/MSWFonts");
1308#endif
1309
1310#ifdef __WXMAC__
1311 conf.SetPath("/Settings/MacFonts");
1312#endif
1313
1314#ifdef __WXQT__
1315 conf.SetPath("/Settings/QTFonts");
1316#endif
1317
1318 conf.SetPath("/Settings/Others");
1319
1320 // Radar rings
1321 CHECK_INT("RadarRingsNumberVisible", &g_iNavAidRadarRingsNumberVisible)
1322 CHECK_INT("RadarRingsStep", &g_fNavAidRadarRingsStep)
1323
1324 CHECK_INT("RadarRingsStepUnits", &g_pNavAidRadarRingsStepUnits);
1325
1326 // wxString l_wxsOwnshipRangeRingsColour;
1327 // CHECK_STR( "RadarRingsColour", &l_wxsOwnshipRangeRingsColour );
1328 // if(l_wxsOwnshipRangeRingsColour.Length())
1329 // g_colourOwnshipRangeRingsColour.Set( l_wxsOwnshipRangeRingsColour );
1330
1331 // Waypoint Radar rings
1332 CHECK_INT("WaypointRangeRingsNumber", &g_iWaypointRangeRingsNumber)
1333
1334 CHECK_FLT("WaypointRangeRingsStep", &g_fWaypointRangeRingsStep, .1)
1335
1336 CHECK_INT("WaypointRangeRingsStepUnits", &g_iWaypointRangeRingsStepUnits);
1337
1338 // wxString l_wxsWaypointRangeRingsColour;
1339 // CHECK_STR( "WaypointRangeRingsColour",
1340 // &l_wxsWaypointRangeRingsColour ); g_colourWaypointRangeRingsColour.Set(
1341 // l_wxsWaypointRangeRingsColour );
1342
1343 CHECK_INT("ConfirmObjectDeletion", &g_bConfirmObjectDelete);
1344
1345 // Waypoint dragging with mouse
1346 CHECK_INT("WaypointPreventDragging", &g_bWayPointPreventDragging);
1347
1348 CHECK_INT("EnableZoomToCursor", &g_bEnableZoomToCursor);
1349
1350 CHECK_FLT("TrackIntervalSeconds", &g_TrackIntervalSeconds, 1)
1351
1352 CHECK_FLT("TrackDeltaDistance", &g_TrackDeltaDistance, .1)
1353
1354 CHECK_INT("TrackPrecision", &g_nTrackPrecision);
1355
1356 // CHECK_STR( "NavObjectFileName", m_sNavObjSetFile );
1357
1358 CHECK_INT("RouteLineWidth", &g_route_line_width);
1359 CHECK_INT("TrackLineWidth", &g_track_line_width);
1360
1361 // wxString l_wxsTrackLineColour;
1362 // CHECK_STR( "TrackLineColour", l_wxsTrackLineColour )
1363 // g_colourTrackLineColour.Set( l_wxsTrackLineColour );
1364
1365 CHECK_STR("DefaultWPIcon", g_default_wp_icon)
1366
1367 // S57 template items
1368
1369#define CHECK_BFN(s, t) \
1370 conf.Read(s, &read_int); \
1371 bval = t; \
1372 bval0 = read_int != 0; \
1373 if (bval != bval0) return false;
1374
1375#define CHECK_IFN(s, t) \
1376 conf.Read(s, &read_int); \
1377 if (read_int != t) return false;
1378
1379#define CHECK_FFN(s, t) \
1380 conf.Read(s, &dval); \
1381 if (fabs(dval - t) > 0.1) return false;
1382
1383 if (ps52plib) {
1384 int read_int;
1385 double dval;
1386 bool bval, bval0;
1387
1388 conf.SetPath("/Settings/GlobalState");
1389
1390 CHECK_BFN("bShowS57Text", ps52plib->GetShowS57Text());
1391
1392 CHECK_BFN("bShowS57ImportantTextOnly",
1393 ps52plib->GetShowS57ImportantTextOnly());
1394 CHECK_BFN("bShowLightDescription", ps52plib->m_bShowLdisText);
1395 CHECK_BFN("bExtendLightSectors", ps52plib->m_bExtendLightSectors);
1396 CHECK_BFN("bShowSoundg", ps52plib->m_bShowSoundg);
1397 CHECK_BFN("bShowMeta", ps52plib->m_bShowMeta);
1398 CHECK_BFN("bUseSCAMIN", ps52plib->m_bUseSCAMIN);
1399 CHECK_BFN("bUseSUPERSCAMIN", ps52plib->m_bUseSUPER_SCAMIN);
1400 CHECK_BFN("bShowAtonText", ps52plib->m_bShowAtonText);
1401 CHECK_BFN("bDeClutterText", ps52plib->m_bDeClutterText);
1402 CHECK_BFN("bShowNationalText", ps52plib->m_bShowNationalTexts);
1403 CHECK_IFN("nDisplayCategory", ps52plib->GetDisplayCategory());
1404 CHECK_IFN("nSymbolStyle", ps52plib->m_nSymbolStyle);
1405 CHECK_IFN("nBoundaryStyle", ps52plib->m_nBoundaryStyle);
1406 CHECK_FFN("S52_MAR_SAFETY_CONTOUR",
1407 S52_getMarinerParam(S52_MAR_SAFETY_CONTOUR));
1408 CHECK_FFN("S52_MAR_SHALLOW_CONTOUR",
1409 S52_getMarinerParam(S52_MAR_SHALLOW_CONTOUR));
1410 CHECK_FFN("S52_MAR_DEEP_CONTOUR",
1411 S52_getMarinerParam(S52_MAR_DEEP_CONTOUR));
1412 CHECK_FFN("S52_MAR_TWO_SHADES", S52_getMarinerParam(S52_MAR_TWO_SHADES));
1413 CHECK_INT("S52_DEPTH_UNIT_SHOW", &g_nDepthUnitDisplay);
1414
1415 // S57 Object Class Visibility
1416
1417 OBJLElement *pOLE;
1418
1419 conf.SetPath("/Settings/ObjectFilter");
1420
1421 unsigned int iOBJMax = conf.GetNumberOfEntries();
1422
1423 if (iOBJMax != ps52plib->pOBJLArray->GetCount()) return false;
1424
1425 if (iOBJMax) {
1426 wxString str, sObj;
1427 long val;
1428 long dummy;
1429
1430 bool bCont = conf.GetFirstEntry(str, dummy);
1431 while (bCont) {
1432 conf.Read(str, &val); // Get an Object Viz
1433
1434 // scan for the same key in the global list
1435 bool bfound = false;
1436 if (str.StartsWith("viz", &sObj)) {
1437 for (unsigned int iPtr = 0; iPtr < ps52plib->pOBJLArray->GetCount();
1438 iPtr++) {
1439 pOLE = (OBJLElement *)(ps52plib->pOBJLArray->Item(iPtr));
1440 if (!strncmp(pOLE->OBJLName, sObj.mb_str(), 6)) {
1441 bfound = true;
1442 if (pOLE->nViz != val) {
1443 return false;
1444 }
1445 }
1446 }
1447
1448 if (!bfound) return false;
1449 }
1450 bCont = conf.GetNextEntry(str, dummy);
1451 }
1452 }
1453 }
1454
1455 conf.SetPath("/MmsiProperties");
1456 int iPMax = conf.GetNumberOfEntries();
1457 if (iPMax) {
1458 wxString str, val;
1459 long dummy;
1460
1461 bool bCont = conf.GetFirstEntry(str, dummy);
1462 while (bCont) {
1463 conf.Read(str, &val); // Get an entry
1464
1465 bool bfound = false;
1466 for (unsigned int j = 0; j < g_MMSI_Props_Array.GetCount(); j++) {
1467 MmsiProperties *pProps = g_MMSI_Props_Array.Item(j);
1468 if (pProps->Serialize().IsSameAs(val)) {
1469 bfound = true;
1470 break;
1471 }
1472 }
1473 if (!bfound) return false;
1474
1475 bCont = conf.GetNextEntry(str, dummy);
1476 }
1477 }
1478
1479 return rv;
1480}
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.
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.