32#include <wx/fileconf.h>
34#include "CanvasConfig.h"
35#include "ocpn_plugin.h"
41#define PI 3.1415926535897931160E0
48canvasConfig::canvasConfig(
int index) {
58canvasConfig::~canvasConfig() {}
60void canvasConfig::Reset(
void) {
63 bShowCurrents =
false;
70 nENCDisplayCategory = (int)(
enum _DisCat)STANDARD;
73void canvasConfig::LoadFromLegacyConfig(wxFileConfig *conf) {
80 conf->SetPath(_T (
"/Settings/GlobalState" ));
81 conf->Read(_T (
"bShowS57Text" ), &bShowENCText, 1);
82 conf->Read(_T (
"bShowLightDescription" ), &bShowENCLightDescriptions, 0);
83 conf->Read(_T (
"nDisplayCategory" ), &nENCDisplayCategory,
84 (
enum _DisCat)STANDARD);
85 conf->Read(_T (
"bShowSoundg" ), &bShowENCDepths, 1);
86 conf->Read(_T (
"bShowAtonText" ), &bShowENCBuoyLabels, 1);
87 bShowENCLights =
true;
89 conf->SetPath(_T (
"/Settings/AIS" ));
90 conf->Read(_T (
"bShowScaledTargets" ), &bAttenAIS, 0);
92 conf->SetPath(_T (
"/Settings" ));
93 conf->Read(_T (
"ShowTide" ), &bShowTides, 0);
94 conf->Read(_T (
"ShowCurrent" ), &bShowCurrents, 0);
95 conf->Read(_T (
"CourseUpMode" ), &bCourseUp, 0);
96 conf->Read(_T (
"HeadUpMode" ), &bHeadUp, 0);
97 conf->Read(_T (
"LookAheadMode" ), &bLookahead, 0);
99 conf->Read(_T (
"ShowGrid" ), &bShowGrid, 0);
100 conf->Read(_T (
"ShowChartOutlines" ), &bShowOutlines, 1);
101 conf->Read(_T (
"ShowDepthUnits" ), &bShowDepthUnits, 1);
102 conf->Read(_T (
"ChartQuilting" ), &bQuilt, 1);
104 conf->Read(_T (
"ActiveChartGroup" ), &GroupID, 0);
105 conf->Read(_T (
"InitialdBIndex" ), &DBindex, -1);
107 conf->SetPath(_T (
"/Settings/GlobalState" ));
109 double st_view_scale, st_rotation;
110 if (conf->Read(wxString(_T (
"VPScale" )), &st)) {
111 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_view_scale);
113 st_view_scale = fmax(st_view_scale, .001 / 32);
114 st_view_scale = fmin(st_view_scale, 4);
115 iScale = st_view_scale;
118 if (conf->Read(wxString(_T (
"VPRotation" )), &st)) {
119 sscanf(st.mb_str(wxConvUTF8),
"%lf", &st_rotation);
121 st_rotation = fmin(st_rotation, 360);
122 st_rotation = fmax(st_rotation, 0);
123 iRotation = st_rotation * PI / 180.;
128 if (conf->Read(_T (
"VPLatLon" ), &sll)) {
129 sscanf(sll.mb_str(wxConvUTF8),
"%lf,%lf", &lat, &lon);
132 if (fabs(lon) < 360.) {
133 while (lon < -180.) lon += 360.;
135 while (lon > 180.) lon -= 360.;
140 if (fabs(lat) < 90.0) iLat = lat;