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