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
48extern bool LogMessageOnce(const wxString &msg);
49extern double fromUsrDistance(double usr_distance, int unit = -1);
50extern double fromUsrSpeed(double usr_speed, int unit = -1);
51extern double fromUsrWindSpeed(double usr_wspeed, int unit = -1);
52extern double fromUsrTemp(double usr_temp, int unit = -1);
53extern wxString getUsrTempUnit();
54extern wxString formatAngle(double angle);
55
56// User date formats
57#define UTCINPUT 0
58#define LTINPUT 1
59#define LMTINPUT 2
60#define GLOBAL_SETTINGS_INPUT \
61 3
62
78wxDateTime toUsrDateTime(const wxDateTime ts, const int format,
79 const double lon = INFINITY - INFINITY);
94wxDateTime fromUsrDateTime(const wxDateTime ts, const int format,
95 const double lon = INFINITY - INFINITY);
96
97extern void AlphaBlending(ocpnDC &dc, int x, int y, int size_x, int size_y,
98 float radius, wxColour color,
99 unsigned char transparency);
100
101// Central dimmer...
102void DimeControl(wxWindow *ctrl);
103void DimeControl(wxWindow *ctrl, wxColour col, wxColour col1,
104 wxColour back_color, wxColour text_color, wxColour uitext,
105 wxColour udkrd, wxColour gridline);
106wxColor GetDimedColor(const wxColor &c);
107
108class Route;
109class NavObjectCollection;
110class wxGenericProgressDialog;
111class ocpnDC;
113class NavObjectChanges;
114class TrackPoint;
115class RouteList;
116class canvasConfig;
117class RoutePointList;
118class RoutePoint;
119class Track;
120
121//----------------------------------------------------------------------------
122// Static XML Helpers
123//----------------------------------------------------------------------------
124
125// RoutePoint *LoadGPXWaypoint (GpxWptElement *wptnode, wxString
126// def_symbol_name, bool b_fullviz = false ); Route *LoadGPXRoute (GpxRteElement
127// *rtenode, int routenum, bool b_fullviz = false ); Route *LoadGPXTrack
128// (GpxTrkElement *trknode, bool b_fullviz = false ); void GPXLoadTrack (
129// GpxTrkElement *trknode, bool b_fullviz = false ); void GPXLoadRoute (
130// GpxRteElement *rtenode, int routenum, bool b_fullviz = false ); void
131// InsertRoute(Route *pTentRoute, int routenum); void UpdateRoute(Route
132// *pTentRoute);
133
134// GpxWptElement *CreateGPXWpt ( RoutePoint *pr, char * waypoint_type, bool
135// b_props_explicit = false, bool b_props_minimal = false ); GpxRteElement
136// *CreateGPXRte ( Route *pRoute ); GpxTrkElement *CreateGPXTrk ( Route *pRoute
137// );
138
139bool WptIsInRouteList(RoutePoint *pr);
140RoutePoint *WaypointExists(const wxString &name, double lat, double lon);
141RoutePoint *WaypointExists(const wxString &guid);
142Route *RouteExists(const wxString &guid);
143Route *RouteExists(Route *pTentRoute);
144Track *TrackExists(const wxString &guid);
145
146void ExportGPX(wxWindow *parent, bool bviz_only = false, bool blayer = false);
147void UI_ImportGPX(wxWindow *parent, bool islayer = false,
148 wxString dirpath = _T(""), bool isdirectory = true,
149 bool isPersistent = false);
150
151bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes,
152 const wxString suggestedName = _T("routes"));
153bool ExportGPXTracks(wxWindow *parent, std::vector<Track *> *pRoutes,
154 const wxString suggestedName = _T("tracks"));
155bool ExportGPXWaypoints(wxWindow *parent, RoutePointList *pRoutePoints,
156 const wxString suggestedName = _T("waypoints"));
157
159public:
161 static double ui_to_config(int slider_pos) {
162 return (2.0 / 100) * static_cast<double>(slider_pos) + 1.02;
163 }
164
166 static int config_to_ui(double value) {
167 return std::round((100.0 * (static_cast<double>(value) - 1.02)) / 2.0);
168 }
169};
170
171//----------------------------------------------------------------------------
172// Config
173//----------------------------------------------------------------------------
174class MyConfig : public wxFileConfig {
175public:
176 MyConfig(const wxString &LocalFileName);
177 ~MyConfig();
178
179 int LoadMyConfig();
180 void LoadS57Config();
181 wxString FindNewestUsableBackup() const;
182 void LoadNavObjects();
183 virtual void AddNewRoute(Route *pr);
184 virtual void UpdateRoute(Route *pr);
185 virtual void DeleteConfigRoute(Route *pr);
186
187 virtual void AddNewTrack(Track *pt);
188 virtual void UpdateTrack(Track *pt);
189 virtual void DeleteConfigTrack(Track *pt);
190
191 virtual void AddNewWayPoint(RoutePoint *pWP, int ConfigRouteNum = -1);
192 virtual void UpdateWayPoint(RoutePoint *pWP);
193 virtual void DeleteWayPoint(RoutePoint *pWP);
194 virtual void AddNewTrackPoint(TrackPoint *pWP, const wxString &parent_GUID);
195
196 virtual void CreateConfigGroups(ChartGroupArray *pGroupArray);
197 virtual void DestroyConfigGroups(void);
198 virtual void LoadConfigGroups(ChartGroupArray *pGroupArray);
199
200 virtual void LoadCanvasConfigs(bool bApplyAsTemplate = false);
201 virtual void LoadConfigCanvas(canvasConfig *cConfig, bool bApplyAsTemplate);
202
203 virtual void SaveCanvasConfigs();
204 virtual void SaveConfigCanvas(canvasConfig *cc);
205
206 virtual bool UpdateChartDirs(ArrayOfCDI &dirarray);
207 virtual bool LoadChartDirArray(ArrayOfCDI &ChartDirArray);
208 virtual void UpdateSettings();
209 virtual void UpdateNavObj(bool bRecreate = false);
210 virtual void UpdateNavObjOnly();
211 virtual bool IsChangesFileDirty();
212
213 bool LoadLayers(wxString &path);
214 int LoadMyConfigRaw(bool bAsTemplate = false);
215
216 void CreateRotatingNavObjBackup();
217
218 wxString m_sNavObjSetFile;
219 wxString m_sNavObjSetChangesFile;
220
221 NavObjectChanges *m_pNavObjectChangesSet;
222 NavObjectCollection1 *m_pNavObjectInputSet;
223};
224
225void SwitchInlandEcdisMode(bool Switch);
226
227#endif
static int config_to_ui(double value)
Convert configuration 1.02..3.0 value to slider scale 1..100.
Definition navutil.h:166
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:161
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:53
Represents a track, which is a series of connected track points.
Definition track.h:111
Encapsulates persistent canvas configuration.
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:64