forked from OpenCPN/OpenCPN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
navutil.h
286 lines (225 loc) · 9.1 KB
/
navutil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/***************************************************************************
*
* Project: OpenCPN
* Purpose: Navigation Utility Functions
* Author: David Register
*
***************************************************************************
* Copyright (C) 2010 by David S. Register *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
**************************************************************************/
#ifndef __NAVUTIL__
#define __NAVUTIL__
#include <wx/config.h>
#include <wx/confbase.h>
#include <wx/fileconf.h>
#include <wx/sound.h>
#ifdef __WXMSW__
#include <wx/msw/regconf.h>
#include <wx/msw/iniconf.h>
#endif
#ifdef OCPN_USE_PORTAUDIO
#include "portaudio.h"
#endif
#include "bbox.h"
#include "chcanv.h"
#include "chartdbs.h"
#include "RoutePoint.h"
#include "vector2D.h"
#include "Route.h"
#include "SelectItem.h"
enum
{
DISTANCE_NMI = 0,
DISTANCE_MI,
DISTANCE_KM,
DISTANCE_M,
DISTANCE_FT,
DISTANCE_FA,
DISTANCE_IN,
DISTANCE_CM
};
enum
{
SPEED_KTS = 0,
SPEED_MPH,
SPEED_KMH,
SPEED_MS
};
extern bool LogMessageOnce(const wxString &msg);
extern double toUsrDistance( double nm_distance, int unit = -1 );
extern double fromUsrDistance( double usr_distance, int unit = -1 );
extern double toUsrSpeed( double kts_speed, int unit = -1 );
extern double fromUsrSpeed( double usr_speed, int unit = -1 );
extern wxString getUsrDistanceUnit( int unit = -1 );
extern wxString getUsrSpeedUnit( int unit = -1 );
extern wxString toSDMM(int NEflag, double a, bool hi_precision = true);
extern void AlphaBlending( ocpnDC& dc, int x, int y, int size_x, int size_y, float radius,
wxColour color, unsigned char transparency );
extern double fromDMM(wxString sdms);
extern double parseLatLon(wxString latlon);
class Route;
class NavObjectCollection;
class wxGenericProgressDialog;
class ocpnDC;
class NavObjectCollection1;
class NavObjectChanges;
class TrackPoint;
class TrackList;
//----------------------------------------------------------------------------
// Static XML Helpers
//----------------------------------------------------------------------------
//RoutePoint *LoadGPXWaypoint (GpxWptElement *wptnode, wxString def_symbol_name, bool b_fullviz = false );
//Route *LoadGPXRoute (GpxRteElement *rtenode, int routenum, bool b_fullviz = false );
//Route *LoadGPXTrack (GpxTrkElement *trknode, bool b_fullviz = false );
//void GPXLoadTrack ( GpxTrkElement *trknode, bool b_fullviz = false );
//void GPXLoadRoute ( GpxRteElement *rtenode, int routenum, bool b_fullviz = false );
//void InsertRoute(Route *pTentRoute, int routenum);
//void UpdateRoute(Route *pTentRoute);
//GpxWptElement *CreateGPXWpt ( RoutePoint *pr, char * waypoint_type, bool b_props_explicit = false, bool b_props_minimal = false );
//GpxRteElement *CreateGPXRte ( Route *pRoute );
//GpxTrkElement *CreateGPXTrk ( Route *pRoute );
bool WptIsInRouteList(RoutePoint *pr);
RoutePoint *WaypointExists( const wxString& name, double lat, double lon);
RoutePoint *WaypointExists( const wxString& guid);
Route *RouteExists( const wxString& guid);
Route *RouteExists( Route * pTentRoute );
Track *TrackExists( const wxString& guid );
const wxChar *ParseGPXDateTime( wxDateTime &dt, const wxChar *datetime );
//----------------------------------------------------------------------------
// Config
//----------------------------------------------------------------------------
class MyConfig:public wxFileConfig
{
public:
MyConfig(const wxString &appName, const wxString &vendorName,
const wxString &LocalFileName);
int LoadMyConfig();
void LoadS57Config();
void LoadNavObjects();
virtual void AddNewRoute(Route *pr);
virtual void UpdateRoute(Route *pr);
virtual void DeleteConfigRoute(Route *pr);
virtual void AddNewTrack(Track *pt);
virtual void UpdateTrack(Track *pt);
virtual void DeleteConfigTrack(Track *pt);
virtual void AddNewWayPoint(RoutePoint *pWP, int ConfigRouteNum = -1);
virtual void UpdateWayPoint(RoutePoint *pWP);
virtual void DeleteWayPoint(RoutePoint *pWP);
virtual void AddNewTrackPoint( TrackPoint *pWP, const wxString& parent_GUID );
virtual void CreateConfigGroups ( ChartGroupArray *pGroupArray );
virtual void DestroyConfigGroups ( void );
virtual void LoadConfigGroups ( ChartGroupArray *pGroupArray );
virtual bool UpdateChartDirs(ArrayOfCDI &dirarray);
virtual bool LoadChartDirArray(ArrayOfCDI &ChartDirArray);
virtual void UpdateSettings();
virtual void UpdateNavObj();
bool LoadLayers(wxString &path);
void ExportGPX(wxWindow* parent, bool bviz_only = false, bool blayer = false);
void UI_ImportGPX(wxWindow* parent, bool islayer = false, wxString dirpath = _T(""), bool isdirectory = true);
bool ExportGPXRoutes(wxWindow* parent, RouteList *pRoutes, const wxString suggestedName = _T("routes"));
bool ExportGPXTracks(wxWindow* parent, TrackList *pRoutes, const wxString suggestedName = _T("tracks"));
bool ExportGPXWaypoints(wxWindow* parent, RoutePointList *pRoutePoints, const wxString suggestedName = _T("waypoints"));
void CreateRotatingNavObjBackup();
double st_lat, st_lon, st_view_scale, st_rotation; // startup values
bool st_bFollow;
wxString m_gpx_path;
wxString m_sNavObjSetFile;
wxString m_sNavObjSetChangesFile;
NavObjectChanges *m_pNavObjectChangesSet;
NavObjectCollection1 *m_pNavObjectInputSet;
bool m_bSkipChangeSetUpdate;
// These members are set/reset in Options dialog
bool m_bShowMenuBar, m_bShowCompassWin;
};
void SwitchInlandEcdisMode( bool Switch );
/*
#include <wx/fontdlg.h>
class WXDLLEXPORT X11FontPicker : public wxGenericFontDialog
{
public:
X11FontPicker(wxFrame *parent);
~X11FontPicker();
virtual void CreateWidgets();
};
*/
/*
* X11FontPicker DIALOG
*/
#include <wx/fontdlg.h>
class wxChoice;
class WXDLLEXPORT wxText;
class wxCheckBox;
class WXDLLEXPORT MyFontPreviewer;
/*
enum
{
wxID_FONT_UNDERLINE = 3000,
wxID_FONT_STYLE,
wxID_FONT_WEIGHT,
wxID_FONT_FAMILY,
wxID_FONT_COLOUR,
wxID_FONT_SIZE
};
*/
class WXDLLEXPORT X11FontPicker : public wxFontDialogBase
{
public:
X11FontPicker() { Init(); }
X11FontPicker(wxWindow *parent, const wxFontData& data) : wxFontDialogBase(parent, data) { Init(); }
virtual ~X11FontPicker();
virtual int ShowModal();
// deprecated, for backwards compatibility only
// X11FontPicker(wxWindow *parent, const wxFontData *data)
// : wxFontDialogBase(parent, data) { Init(); }
// Internal functions
void OnCloseWindow(wxCloseEvent& event);
virtual void CreateWidgets();
virtual void InitializeFont();
void OnChangeFont(wxCommandEvent& event);
void OnChangeFace(wxCommandEvent& event);
protected:
// common part of all ctors
void Init();
virtual bool DoCreate(wxWindow *parent);
void InitializeAllAvailableFonts();
void SetChoiceOptionsFromFacename(const wxString &facename);
void DoFontChange(void);
wxFont dialogFont;
wxChoice *familyChoice;
wxChoice *styleChoice;
wxChoice *weightChoice;
wxChoice *colourChoice;
wxCheckBox *underLineCheckBox;
wxChoice *pointSizeChoice;
MyFontPreviewer *m_previewer;
bool m_useEvents;
wxArrayString *pFaceNameArray;
wxFont *pPreviewFont;
// static bool fontDialogCancelled;
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(X11FontPicker)
};
class GpxDocument
{
public:
static wxString GetUUID(void);
static void SeedRandom();
private:
static int GetRandomNumber(int min, int max);
};
#endif