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