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("/Settings/GlobalState");
82 conf->Read("bShowS57Text", &bShowENCText, 1);
83 conf->Read("bShowLightDescription", &bShowENCLightDescriptions, 1);
84 conf->Read("nDisplayCategory", &nENCDisplayCategory, (enum _DisCat)OTHER);
85 conf->Read("bShowSoundg", &bShowENCDepths, 1);
86 conf->Read("bShowAtonText", &bShowENCBuoyLabels, 0);
87 bShowENCLights = true;
88 bShowENCVisibleSectorLights = false;
89 bShowENCAnchorInfo = false;
90 bShowENCDataQuality = false;
91
92 conf->SetPath("/Settings/AIS");
93 conf->Read("bShowScaledTargets", &bAttenAIS, 0);
94
95 conf->SetPath("/Settings");
96 conf->Read("ShowTide", &bShowTides, 0);
97 conf->Read("ShowCurrent", &bShowCurrents, 0);
98 conf->Read("CourseUpMode", &bCourseUp, 0);
99 conf->Read("HeadUpMode", &bHeadUp, 0);
100 conf->Read("LookAheadMode", &bLookahead, 0);
101
102 conf->Read("ShowGrid", &bShowGrid, 0);
103 conf->Read("ShowChartOutlines", &bShowOutlines, 1);
104 conf->Read("ShowDepthUnits", &bShowDepthUnits, 1);
105 conf->Read("ChartQuilting", &bQuilt, 1);
106
107 conf->Read("ActiveChartGroup", &GroupID, 0);
108 conf->Read("InitialdBIndex", &DBindex, -1);
109
110 conf->SetPath("/Settings/GlobalState");
111 wxString st;
112 double st_view_scale, st_rotation;
113 if (conf->Read(wxString("VPScale"), &st)) {
114 sscanf(st.mb_str(wxConvUTF8), "%lf", &st_view_scale);
115 // Sanity check the scale
116 st_view_scale = fmax(st_view_scale, .001 / 32);
117 st_view_scale = fmin(st_view_scale, 4);
118 iScale = st_view_scale;
119 }
120
121 if (conf->Read(wxString("VPRotation"), &st)) {
122 sscanf(st.mb_str(wxConvUTF8), "%lf", &st_rotation);
123 // Sanity check the rotation
124 st_rotation = fmin(st_rotation, 360);
125 st_rotation = fmax(st_rotation, 0);
126 iRotation = st_rotation * PI / 180.;
127 }
128
129 wxString sll;
130 double lat, lon;
131 if (conf->Read("VPLatLon", &sll)) {
132 sscanf(sll.mb_str(wxConvUTF8), "%lf,%lf", &lat, &lon);
133
134 // Sanity check the lat/lon...both have to be reasonable.
135 if (fabs(lon) < 360.) {
136 while (lon < -180.) lon += 360.;
137
138 while (lon > 180.) lon -= 360.;
139
140 iLon = lon;
141 }
142
143 if (fabs(lat) < 90.0) iLat = lat;
144 }
145}
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.