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