OpenCPN Partial API docs
Loading...
Searching...
No Matches
canvas_config.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2018 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#include <wx/wxprec.h>
25
26#ifndef WX_PRECOMP
27#include <wx/wx.h>
28#endif // precompiled headers
29
30#include "gl_headers.h"
31
32#include "canvas_config.h"
33#include "s52s57.h"
34
35//----------------------------------------------------------------------------
36// constants
37//----------------------------------------------------------------------------
38#ifndef PI
39#define PI 3.1415926535897931160E0 /* pi */
40#endif
41
42//------------------------------------------------------------------------------
43// canvasConfig Implementation
44//------------------------------------------------------------------------------
45
46canvasConfig::canvasConfig(int index) {
47 configIndex = index;
48 canvas = NULL;
49 GroupID = 0;
50 iLat = 0.;
51 iLon = 0.;
52 iScale = .0003; // decent initial value
53 iRotation = 0.;
54}
55
56canvasConfig::~canvasConfig() {}
57
59 bFollow = false;
60 bShowTides = false;
61 bShowCurrents = false;
62 bCourseUp = false;
63 bHeadUp = false;
64 bLookahead = false;
65 bShowAIS = true;
66 bAttenAIS = false;
67 bQuilt = true;
68 nENCDisplayCategory = (int)(enum _DisCat)OTHER;
69 bShowENCDataQuality = 0;
70 bShowENCBuoyLabels = 0;
71 bShowENCLightDescriptions = 1;
72}
73
74void canvasConfig::LoadFromLegacyConfig(wxConfigBase *conf) {
75 if (!conf) return;
76
77 bFollow = false;
78 bShowAIS = true;
79
80 // S52 stuff
81 conf->SetPath(_T ( "/Settings/GlobalState" ));
82 conf->Read(_T ( "bShowS57Text" ), &bShowENCText, 1);
83 conf->Read(_T ( "bShowLightDescription" ), &bShowENCLightDescriptions, 1);
84 conf->Read(_T ( "nDisplayCategory" ), &nENCDisplayCategory,
85 (enum _DisCat)OTHER);
86 conf->Read(_T ( "bShowSoundg" ), &bShowENCDepths, 1);
87 conf->Read(_T ( "bShowAtonText" ), &bShowENCBuoyLabels, 0);
88 bShowENCLights = true;
89 bShowENCVisibleSectorLights = false;
90 bShowENCAnchorInfo = false;
91 bShowENCDataQuality = false;
92
93 conf->SetPath(_T ( "/Settings/AIS" ));
94 conf->Read(_T ( "bShowScaledTargets" ), &bAttenAIS, 0);
95
96 conf->SetPath(_T ( "/Settings" ));
97 conf->Read(_T ( "ShowTide" ), &bShowTides, 0);
98 conf->Read(_T ( "ShowCurrent" ), &bShowCurrents, 0);
99 conf->Read(_T ( "CourseUpMode" ), &bCourseUp, 0);
100 conf->Read(_T ( "HeadUpMode" ), &bHeadUp, 0);
101 conf->Read(_T ( "LookAheadMode" ), &bLookahead, 0);
102
103 conf->Read(_T ( "ShowGrid" ), &bShowGrid, 0);
104 conf->Read(_T ( "ShowChartOutlines" ), &bShowOutlines, 1);
105 conf->Read(_T ( "ShowDepthUnits" ), &bShowDepthUnits, 1);
106 conf->Read(_T ( "ChartQuilting" ), &bQuilt, 1);
107
108 conf->Read(_T ( "ActiveChartGroup" ), &GroupID, 0);
109 conf->Read(_T ( "InitialdBIndex" ), &DBindex, -1);
110
111 conf->SetPath(_T ( "/Settings/GlobalState" ));
112 wxString st;
113 double st_view_scale, st_rotation;
114 if (conf->Read(wxString(_T ( "VPScale" )), &st)) {
115 sscanf(st.mb_str(wxConvUTF8), "%lf", &st_view_scale);
116 // Sanity check the scale
117 st_view_scale = fmax(st_view_scale, .001 / 32);
118 st_view_scale = fmin(st_view_scale, 4);
119 iScale = st_view_scale;
120 }
121
122 if (conf->Read(wxString(_T ( "VPRotation" )), &st)) {
123 sscanf(st.mb_str(wxConvUTF8), "%lf", &st_rotation);
124 // Sanity check the rotation
125 st_rotation = fmin(st_rotation, 360);
126 st_rotation = fmax(st_rotation, 0);
127 iRotation = st_rotation * PI / 180.;
128 }
129
130 wxString sll;
131 double lat, lon;
132 if (conf->Read(_T ( "VPLatLon" ), &sll)) {
133 sscanf(sll.mb_str(wxConvUTF8), "%lf,%lf", &lat, &lon);
134
135 // Sanity check the lat/lon...both have to be reasonable.
136 if (fabs(lon) < 360.) {
137 while (lon < -180.) lon += 360.;
138
139 while (lon > 180.) lon -= 360.;
140
141 iLon = lon;
142 }
143
144 if (fabs(lat) < 90.0) iLat = lat;
145 }
146}
Chart canvas configuration state
double iLat
Latitude of the center of the chart, in degrees.
bool bShowOutlines
Display chart outlines.
void Reset()
Resets all configuration options to default values.
bool bShowDepthUnits
Display depth unit indicators.
double iLon
Longitude of the center of the chart, in degrees.
double iRotation
Initial rotation angle in radians.
bool bCourseUp
Orient display to course up.
bool bQuilt
Enable chart quilting.
bool bFollow
Enable vessel following mode.
double iScale
Initial chart scale factor.
bool bShowENCText
Display ENC text elements.
bool bShowAIS
Display AIS targets.
bool bShowGrid
Display coordinate grid.
ChartCanvas * canvas
Pointer to associated chart canvas.
bool bShowCurrents
Display current information.
bool bShowTides
Display tide information.
bool bLookahead
Enable lookahead mode.
bool bHeadUp
Orient display to heading up.
bool bAttenAIS
Enable AIS target attenuation.
Platform independent GL includes.