OpenCPN Partial API docs
Loading...
Searching...
No Matches
navutil.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: Navigation Utility Functions
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2010 by David S. Register *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 **************************************************************************/
25
26#ifndef __NAVUTIL__
27#define __NAVUTIL__
28
29#include <wx/config.h>
30#include <wx/confbase.h>
31#include <wx/fileconf.h>
32#include <wx/sound.h>
33
34#ifdef __WXMSW__
35#include <wx/msw/regconf.h>
36#include <wx/msw/iniconf.h>
37#endif
38
39#include "bbox.h"
40//#include "chcanv.h"
41#include "chartdbs.h"
42// nclude "RoutePoint.h"
43#include "vector2D.h"
44#include "select_item.h"
45#include "ocpndc.h"
46#include "navutil_base.h"
47
48
49enum { TEMPERATURE_C = 0, TEMPERATURE_F = 1, TEMPERATURE_K = 2 };
50
51
52extern bool LogMessageOnce(const wxString &msg);
53extern double fromUsrDistance(double usr_distance, int unit = -1);
54extern double fromUsrSpeed(double usr_speed, int unit = -1);
55extern double toUsrTemp(double cel_temp, int unit = -1);
56extern double fromUsrTemp(double usr_temp, int unit = -1);
57extern wxString getUsrTempUnit(int unit = -1);
58extern wxString formatAngle(double angle);
59
60extern void AlphaBlending(ocpnDC &dc, int x, int y, int size_x, int size_y,
61 float radius, wxColour color,
62 unsigned char transparency);
63
64// Central dimmer...
65void DimeControl(wxWindow *ctrl);
66void DimeControl(wxWindow *ctrl, wxColour col, wxColour col1,
67 wxColour back_color, wxColour text_color, wxColour uitext,
68 wxColour udkrd, wxColour gridline);
69
70
71class Route;
72class NavObjectCollection;
73class wxGenericProgressDialog;
74class ocpnDC;
77class TrackPoint;
78class RouteList;
79class canvasConfig;
80class RoutePointList;
81class RoutePoint;
82class Track;
83
84//----------------------------------------------------------------------------
85// Static XML Helpers
86//----------------------------------------------------------------------------
87
88// RoutePoint *LoadGPXWaypoint (GpxWptElement *wptnode, wxString
89// def_symbol_name, bool b_fullviz = false ); Route *LoadGPXRoute (GpxRteElement
90// *rtenode, int routenum, bool b_fullviz = false ); Route *LoadGPXTrack
91// (GpxTrkElement *trknode, bool b_fullviz = false ); void GPXLoadTrack (
92// GpxTrkElement *trknode, bool b_fullviz = false ); void GPXLoadRoute (
93// GpxRteElement *rtenode, int routenum, bool b_fullviz = false ); void
94// InsertRoute(Route *pTentRoute, int routenum); void UpdateRoute(Route
95// *pTentRoute);
96
97// GpxWptElement *CreateGPXWpt ( RoutePoint *pr, char * waypoint_type, bool
98// b_props_explicit = false, bool b_props_minimal = false ); GpxRteElement
99// *CreateGPXRte ( Route *pRoute ); GpxTrkElement *CreateGPXTrk ( Route *pRoute
100// );
101
102bool WptIsInRouteList(RoutePoint *pr);
103RoutePoint *WaypointExists(const wxString &name, double lat, double lon);
104RoutePoint *WaypointExists(const wxString &guid);
105Route *RouteExists(const wxString &guid);
106Route *RouteExists(Route *pTentRoute);
107Track *TrackExists(const wxString &guid);
108
109void ExportGPX(wxWindow *parent, bool bviz_only = false, bool blayer = false);
110void UI_ImportGPX(wxWindow *parent, bool islayer = false,
111 wxString dirpath = _T(""), bool isdirectory = true,
112 bool isPersistent = false);
113
114bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes,
115 const wxString suggestedName = _T("routes"));
116bool ExportGPXTracks(wxWindow *parent, std::vector<Track*> *pRoutes,
117 const wxString suggestedName = _T("tracks"));
118bool ExportGPXWaypoints(wxWindow *parent, RoutePointList *pRoutePoints,
119 const wxString suggestedName = _T("waypoints"));
120
121
123public:
124
126 static double ui_to_config(int slider_pos) {
127 return (2.0/100) * static_cast<double>(slider_pos) + 1.02;
128 }
129
131 static int config_to_ui(double value) {
132 return std::round((100.0 * (static_cast<double>(value) - 1.02)) / 2.0);
133 }
134};
135
136
137//----------------------------------------------------------------------------
138// Config
139//----------------------------------------------------------------------------
140class MyConfig : public wxFileConfig {
141public:
142 MyConfig(const wxString &LocalFileName);
143
144 int LoadMyConfig();
145 void LoadS57Config();
146 void LoadNavObjects();
147 virtual void AddNewRoute(Route *pr);
148 virtual void UpdateRoute(Route *pr);
149 virtual void DeleteConfigRoute(Route *pr);
150
151 virtual void AddNewTrack(Track *pt);
152 virtual void UpdateTrack(Track *pt);
153 virtual void DeleteConfigTrack(Track *pt);
154
155 virtual void AddNewWayPoint(RoutePoint *pWP, int ConfigRouteNum = -1);
156 virtual void UpdateWayPoint(RoutePoint *pWP);
157 virtual void DeleteWayPoint(RoutePoint *pWP);
158 virtual void AddNewTrackPoint(TrackPoint *pWP, const wxString &parent_GUID);
159
160 virtual void CreateConfigGroups(ChartGroupArray *pGroupArray);
161 virtual void DestroyConfigGroups(void);
162 virtual void LoadConfigGroups(ChartGroupArray *pGroupArray);
163
164 virtual void LoadCanvasConfigs(bool bApplyAsTemplate = false);
165 virtual void LoadConfigCanvas(canvasConfig *cConfig, bool bApplyAsTemplate);
166
167 virtual void SaveCanvasConfigs();
168 virtual void SaveConfigCanvas(canvasConfig *cc);
169
170 virtual bool UpdateChartDirs(ArrayOfCDI &dirarray);
171 virtual bool LoadChartDirArray(ArrayOfCDI &ChartDirArray);
172 virtual void UpdateSettings();
173 virtual void UpdateNavObj(bool bRecreate = false);
174 virtual bool IsChangesFileDirty();
175
176 bool LoadLayers(wxString &path);
177 int LoadMyConfigRaw(bool bAsTemplate = false);
178
179 void CreateRotatingNavObjBackup();
180
181 wxString m_sNavObjSetFile;
182 wxString m_sNavObjSetChangesFile;
183
184 NavObjectChanges *m_pNavObjectChangesSet;
185 NavObjectCollection1 *m_pNavObjectInputSet;
186};
187
188void SwitchInlandEcdisMode(bool Switch);
189
190
191#endif
static int config_to_ui(double value)
Convert configuration 1.02..3.0 value to slider scale 1..100.
Definition: navutil.h:131
static double ui_to_config(int slider_pos)
Convert a slider scale 1-100 value to configuration value 1.02..3.0.
Definition: navutil.h:126
Definition: route.h:70
Definition: track.h:79
Definition: ocpndc.h:55