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 TrackPoint;
114class RouteList;
115class canvasConfig;
116class RoutePointList;
117class RoutePoint;
118class Track;
119
120//----------------------------------------------------------------------------
121// Static XML Helpers
122//----------------------------------------------------------------------------
123
124// RoutePoint *LoadGPXWaypoint (GpxWptElement *wptnode, wxString
125// def_symbol_name, bool b_fullviz = false ); Route *LoadGPXRoute (GpxRteElement
126// *rtenode, int routenum, bool b_fullviz = false ); Route *LoadGPXTrack
127// (GpxTrkElement *trknode, bool b_fullviz = false ); void GPXLoadTrack (
128// GpxTrkElement *trknode, bool b_fullviz = false ); void GPXLoadRoute (
129// GpxRteElement *rtenode, int routenum, bool b_fullviz = false ); void
130// InsertRoute(Route *pTentRoute, int routenum); void UpdateRoute(Route
131// *pTentRoute);
132
133// GpxWptElement *CreateGPXWpt ( RoutePoint *pr, char * waypoint_type, bool
134// b_props_explicit = false, bool b_props_minimal = false ); GpxRteElement
135// *CreateGPXRte ( Route *pRoute ); GpxTrkElement *CreateGPXTrk ( Route *pRoute
136// );
137
138bool WptIsInRouteList(RoutePoint *pr);
139RoutePoint *WaypointExists(const wxString &name, double lat, double lon);
140RoutePoint *WaypointExists(const wxString &guid);
141Route *RouteExists(const wxString &guid);
142Route *RouteExists(Route *pTentRoute);
143Track *TrackExists(const wxString &guid);
144
145void ExportGPX(wxWindow *parent, bool bviz_only = false, bool blayer = false);
146void UI_ImportGPX(wxWindow *parent, bool islayer = false,
147 wxString dirpath = _T(""), bool isdirectory = true,
148 bool isPersistent = false);
149
150bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes,
151 const wxString suggestedName = _T("routes"));
152bool ExportGPXTracks(wxWindow *parent, std::vector<Track *> *pRoutes,
153 const wxString suggestedName = _T("tracks"));
154bool ExportGPXWaypoints(wxWindow *parent, RoutePointList *pRoutePoints,
155 const wxString suggestedName = _T("waypoints"));
156
158public:
160 static double ui_to_config(int slider_pos) {
161 return (2.0 / 100) * static_cast<double>(slider_pos) + 1.02;
162 }
163
165 static int config_to_ui(double value) {
166 return std::round((100.0 * (static_cast<double>(value) - 1.02)) / 2.0);
167 }
168};
169
170//----------------------------------------------------------------------------
171// Config
172//----------------------------------------------------------------------------
173class MyConfig : public wxFileConfig {
174public:
175 MyConfig(const wxString &LocalFileName);
176 ~MyConfig();
177
178 int LoadMyConfig();
179 void LoadS57Config();
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
195 bool LoadLayers(wxString &path);
196 int LoadMyConfigRaw(bool bAsTemplate = false);
197
198private:
199};
200
201void SwitchInlandEcdisMode(bool Switch);
202
203#endif
static int config_to_ui(double value)
Convert configuration 1.02..3.0 value to slider scale 1..100.
Definition navutil.h:165
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:160
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