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 "model/select_item.h"
45#include "ocpndc.h"
46#include "model/navutil_base.h"
47
48class MyConfig; // forward
49extern MyConfig *pConfig;
51extern bool LogMessageOnce(const wxString &msg);
52extern double fromUsrDistance(double usr_distance, int unit = -1);
53extern double fromUsrSpeed(double usr_speed, int unit = -1);
54extern double fromUsrWindSpeed(double usr_wspeed, int unit = -1);
55extern double fromUsrTemp(double usr_temp, int unit = -1);
56extern wxString getUsrTempUnit();
57extern wxString formatAngle(double angle);
58extern wxString GetLayerName(int id);
59
60// User date formats
61#define UTCINPUT 0
62#define LTINPUT 1
63#define LMTINPUT 2
64#define GLOBAL_SETTINGS_INPUT \
65 3
66
82wxDateTime toUsrDateTime(const wxDateTime ts, const int format,
83 const double lon = INFINITY - INFINITY);
98wxDateTime fromUsrDateTime(const wxDateTime ts, const int format,
99 const double lon = INFINITY - INFINITY);
100
101extern void AlphaBlending(ocpnDC &dc, int x, int y, int size_x, int size_y,
102 float radius, wxColour color,
103 unsigned char transparency);
104
105// Central dimmer...
106void DimeControl(wxWindow *ctrl);
107void DimeControl(wxWindow *ctrl, wxColour col, wxColour col1,
108 wxColour back_color, wxColour text_color, wxColour uitext,
109 wxColour udkrd, wxColour gridline);
110wxColor GetDimedColor(const wxColor &c);
111
112class Route;
113class NavObjectCollection;
114class wxGenericProgressDialog;
115class ocpnDC;
117class TrackPoint;
118class RouteList;
119class canvasConfig;
120class RoutePointList;
121class RoutePoint;
122class Track;
123
124//----------------------------------------------------------------------------
125// Static XML Helpers
126//----------------------------------------------------------------------------
127
128// RoutePoint *LoadGPXWaypoint (GpxWptElement *wptnode, wxString
129// def_symbol_name, bool b_fullviz = false ); Route *LoadGPXRoute (GpxRteElement
130// *rtenode, int routenum, bool b_fullviz = false ); Route *LoadGPXTrack
131// (GpxTrkElement *trknode, bool b_fullviz = false ); void GPXLoadTrack (
132// GpxTrkElement *trknode, bool b_fullviz = false ); void GPXLoadRoute (
133// GpxRteElement *rtenode, int routenum, bool b_fullviz = false ); void
134// InsertRoute(Route *pTentRoute, int routenum); void UpdateRoute(Route
135// *pTentRoute);
136
137// GpxWptElement *CreateGPXWpt ( RoutePoint *pr, char * waypoint_type, bool
138// b_props_explicit = false, bool b_props_minimal = false ); GpxRteElement
139// *CreateGPXRte ( Route *pRoute ); GpxTrkElement *CreateGPXTrk ( Route *pRoute
140// );
141
142bool WptIsInRouteList(RoutePoint *pr);
143RoutePoint *WaypointExists(const wxString &name, double lat, double lon);
144RoutePoint *WaypointExists(const wxString &guid);
145Route *RouteExists(const wxString &guid);
146Route *RouteExists(Route *pTentRoute);
147Track *TrackExists(const wxString &guid);
148int BackupDatabase(wxWindow *parent);
149void ExportGPX(wxWindow *parent, bool bviz_only = false, bool blayer = false);
150void UI_ImportGPX(wxWindow *parent, bool islayer = false,
151 wxString dirpath = _T(""), bool isdirectory = true,
152 bool isPersistent = false);
153
154bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes,
155 const wxString suggestedName = _T("routes"));
156bool ExportGPXTracks(wxWindow *parent, std::vector<Track *> *pRoutes,
157 const wxString suggestedName = _T("tracks"));
158bool ExportGPXWaypoints(wxWindow *parent, RoutePointList *pRoutePoints,
159 const wxString suggestedName = _T("waypoints"));
160void ImportFileArray(const wxArrayString &file_array, bool islayer,
161 bool isPersistent, wxString dirpath);
162
164public:
166 static double ui_to_config(int slider_pos) {
167 return (2.0 / 100) * static_cast<double>(slider_pos) + 1.02;
168 }
169
171 static int config_to_ui(double value) {
172 return std::round((100.0 * (static_cast<double>(value) - 1.02)) / 2.0);
173 }
174};
175
176//----------------------------------------------------------------------------
177// Config
178//----------------------------------------------------------------------------
179class MyConfig : public wxFileConfig {
180public:
181 MyConfig(const wxString &LocalFileName);
182 ~MyConfig();
183
184 int LoadMyConfig();
185 void LoadS57Config();
186
187 virtual void CreateConfigGroups(ChartGroupArray *pGroupArray);
188 virtual void DestroyConfigGroups(void);
189 virtual void LoadConfigGroups(ChartGroupArray *pGroupArray);
190
191 virtual void LoadCanvasConfigs(bool bApplyAsTemplate = false);
192 virtual void LoadConfigCanvas(canvasConfig *cConfig, bool bApplyAsTemplate);
193
194 virtual void SaveCanvasConfigs();
195 virtual void SaveConfigCanvas(canvasConfig *cc);
196
197 virtual bool UpdateChartDirs(ArrayOfCDI &dirarray);
198 virtual bool LoadChartDirArray(ArrayOfCDI &ChartDirArray);
199 virtual void UpdateSettings();
200
201 bool LoadLayers(wxString &path);
202 int LoadMyConfigRaw(bool bAsTemplate = false);
203
204private:
205};
206
207void SwitchInlandEcdisMode(bool Switch);
208
209#endif
Basic chart info storage.
static int config_to_ui(double value)
Convert configuration 1.02..3.0 value to slider scale 1..100.
Definition navutil.h:171
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:166
Represents a waypoint or mark within the navigation system.
Definition route_point.h:70
Represents a navigational route in the navigation system.
Definition route.h:98
Represents a single point in a track.
Definition track.h:56
Represents a track, which is a series of connected track points.
Definition track.h:114
Encapsulates persistent canvas configuration.
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:60