OpenCPN Partial API docs
Loading...
Searching...
No Matches
route.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef _ROUTE_H_
25#define _ROUTE_H_
26
27#include <functional>
28#include <vector>
29
30#include <wx/colour.h>
31#include <wx/datetime.h>
32#include <wx/gdicmn.h>
33#include <wx/object.h>
34#include <wx/pen.h>
35#include <wx/string.h>
36
37#include "model/route_point.h"
38#include "model/routeman.h"
39#include "model/hyperlink.h"
40
41#include "bbox.h"
42
43#define WIDTH_UNDEFINED -1
44
45#define ROUTE_DEFAULT_SPEED 5.0
46#define RTE_TIME_DISP_UTC "UTC"
47#define RTE_TIME_DISP_PC "PC"
48#define RTE_TIME_DISP_LOCAL "LOCAL"
49#define RTE_TIME_DISP_GLOBAL "GLOBAL SETTING"
50#define RTE_UNDEF_DEPARTURE wxInvalidDateTime
51
52class WayPointman; // FIXME (leamas) why? routeman.h defines this.
53
54extern WayPointman *pWayPointMan;
55
56const wxString GpxxColorNames[] = {
57 _T("Black"), _T("DarkRed"), _T("DarkGreen"),
58 _T("DarkYellow"), _T("DarkBlue"), _T("DarkMagenta"),
59 _T("DarkCyan"), _T("LightGray"), _T("DarkGray"),
60 _T("Red"), _T("Green"), _T ("Yellow"),
61 _T("Blue"), _T("Magenta"), _T("Cyan"),
62 _T("White")}; // The last color defined by Garmin is transparent - we
63 // ignore it
64const wxColour GpxxColors[] = {
65 wxColour(0x00, 0x00, 0x00), wxColour(0x60, 0x00, 0x00),
66 wxColour(0x00, 0x60, 0x00), wxColour(0x80, 0x80, 0x00),
67 wxColour(0x00, 0x00, 0x60), wxColour(0x60, 0x00, 0x60),
68 wxColour(0x00, 0x80, 0x80), wxColour(0xC0, 0xC0, 0xC0),
69 wxColour(0x60, 0x60, 0x60), wxColour(0xFF, 0x00, 0x00),
70 wxColour(0x00, 0xFF, 0x00), wxColour(0xF0, 0xF0, 0x00),
71 wxColour(0x00, 0x00, 0xFF), wxColour(0xFE, 0x00, 0xFE),
72 wxColour(0x00, 0xFF, 0xFF), wxColour(0xFF, 0xFF, 0xFF)};
73const int StyleValues[] = {-1, wxSOLID, wxDOT,
74 wxLONG_DASH, wxSHORT_DASH, wxDOT_DASH};
75const int WidthValues[] = {-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
76
99class Route : public wxObject {
100 friend class RouteGui;
101
102public:
103 Route();
104 ~Route();
105
106 virtual int GetnPoints(void) { return pRoutePointList->size(); }
107 wxString IsPointNameValid(RoutePoint *pRP, const wxString &name) const;
108
109 void AddPoint(RoutePoint *pNewPoint, bool b_rename_in_sequence = true,
110 bool b_deferBoxCalc = false);
111 void InsertPointAndSegment(RoutePoint *pNewPoint, int insert_after,
112 bool b_rename_in_sequence = true,
113 bool b_deferBoxCalc = false);
114 void AddPointAndSegment(RoutePoint *pNewPoint,
115 bool b_rename_in_sequence = true,
116 bool b_deferBoxCalc = false);
117 RoutePoint *GetPoint(int nPoint);
118 RoutePoint *GetPoint(const wxString &guid);
119 int GetIndexOf(RoutePoint *prp);
120 RoutePoint *InsertPointBefore(RoutePoint *pRP, double rlat, double rlon,
121 bool bRenamePoints = false);
122 RoutePoint *InsertPointAfter(RoutePoint *pRP, double rlat, double rlon,
123 bool bRenamePoints = false);
124
125 RoutePoint *GetLastPoint();
126 void DeletePoint(RoutePoint *rp, bool bRenamePoints = false);
127 void RemovePoint(RoutePoint *rp, bool bRenamePoints = false);
128 void DeSelectRoute();
129 void FinalizeForRendering();
150 double planspeed = -1.0);
151 void UpdateSegmentDistances(double planspeed = -1.0);
152 LLBBox &GetBBox();
153 void SetHiLite(int width) { m_hiliteWidth = width; }
154 void Reverse(bool bRenamePoints = false);
155 void RebuildGUIDList(void);
156 void RenameRoutePoints();
157 void ReloadRoutePointIcons();
158 wxString GetNewMarkSequenced(void);
159 void AssembleRoute();
160 bool IsEqualTo(Route *ptargetroute);
161 void CloneRoute(Route *psourceroute, int start_nPoint, int end_nPoint,
162 const wxString &suffix,
163 const bool duplicate_first_point = false);
164 void ClearHighlights(void);
165
166 void SetVisible(bool visible = true, bool includeWpts = true);
167 void SetListed(bool visible = true);
168 bool IsVisible() { return m_bVisible; }
169 bool IsListed() { return m_bListed; }
170 bool IsActive() { return m_bRtIsActive; }
171 bool IsSelected() { return m_bRtIsSelected; }
172
173 bool ContainsSharedWP();
174 void SetSharedWPViz(bool sharedWPVIZ) { m_bsharedWPViz = sharedWPVIZ; }
175 bool GetSharedWPViz() { return m_bsharedWPViz; }
176
177 double GetRouteArrivalRadius(void) { return m_ArrivalRadius; }
178 void SetRouteArrivalRadius(double radius) { m_ArrivalRadius = radius; }
184 void SetDepartureDate(const wxDateTime &dt) {
185 if (dt.IsValid()) m_PlannedDeparture = dt;
186 }
187
188 wxString GetName() const { return m_RouteNameString; }
189 wxString GetTo() const { return m_RouteEndString; }
190 wxString GetGUID() const { return m_GUID; }
191 void ShowWaypointNames(bool bshow);
192 bool AreWaypointNamesVisible();
193
273 wxString m_GUID;
293 wxPenStyle m_style;
336 RoutePointList *pRoutePointList;
346 wxString m_Colour;
361 HyperlinkList *m_HyperlinkList;
362
363private:
364 LLBBox RBBox;
365
370 int m_nm_sequence;
375 bool m_bVisible;
380 bool m_bListed;
385 double m_ArrivalRadius;
390 bool m_bsharedWPViz;
391};
392
393using RouteList = std::vector<Route *>;
394
395#endif // _ROUTE_H__
Represents a waypoint or mark within the navigation system.
Definition route_point.h:71
Represents a navigational route in the navigation system.
Definition route.h:99
int m_hiliteWidth
Width in pixels for highlighting the route when selected.
Definition route.h:356
bool m_bRtIsSelected
Flag indicating whether this route is currently selected in the UI.
Definition route.h:203
double m_PlannedSpeed
Default planned speed for the route in knots.
Definition route.h:321
wxString m_RouteStartString
Name or description of the route's starting point.
Definition route.h:252
int m_ConfigRouteNum
Internal configuration/identification number for this route.
Definition route.h:198
wxString m_RouteDescription
Additional descriptive information about the route.
Definition route.h:262
bool m_bIsBeingCreated
Flag indicating that the route is currently being created by the user.
Definition route.h:219
void UpdateSegmentDistance(RoutePoint *prp0, RoutePoint *prp, double planspeed=-1.0)
Updates the navigation data for a single route segment between two waypoints.
Definition route.cpp:459
RoutePointList * pRoutePointList
Ordered list of waypoints (RoutePoints) that make up this route.
Definition route.h:336
double m_route_length
Total length of the route in nautical miles, calculated using rhumb line (Mercator) distances.
Definition route.h:237
bool m_bRtIsActive
Flag indicating whether this route is currently active for navigation.
Definition route.h:208
wxString m_Colour
Color name for rendering the route on the chart.
Definition route.h:346
bool m_bDeleteOnArrival
Flag indicating whether the route should be deleted once navigation reaches the end.
Definition route.h:268
wxString m_RouteEndString
Name or description of the route's ending point.
Definition route.h:257
RoutePoint * m_pRouteActivePoint
Pointer to the currently active waypoint within this route.
Definition route.h:214
bool m_btemp
Flag indicating if this is a temporary route.
Definition route.h:351
wxRect active_pt_rect
Bounding rectangle for the active point in screen coordinates.
Definition route.h:341
wxPenStyle m_style
Style of the route line when rendered on the chart.
Definition route.h:293
wxString m_TimeDisplayFormat
Format for displaying times in the UI.
Definition route.h:331
int m_width
Width of the route line in pixels when rendered on the chart.
Definition route.h:288
wxString m_RouteNameString
User-assigned name for the route.
Definition route.h:247
wxString m_GUID
Globally unique identifier for this route.
Definition route.h:273
wxDateTime m_PlannedDeparture
Planned departure time for the route, in UTC.
Definition route.h:326
bool m_bIsInLayer
Flag indicating whether this route belongs to a layer.
Definition route.h:278
double m_route_time
Total estimated time to complete the route in seconds.
Definition route.h:242
int m_lastMousePointIndex
Index of the most recently interacted with route point.
Definition route.h:298
void SetDepartureDate(const wxDateTime &dt)
Set the departure time of the route.
Definition route.h:184
HyperlinkList * m_HyperlinkList
List of hyperlinks associated with this route.
Definition route.h:361
bool m_bIsBeingEdited
Flag indicating that the route is currently being edited by the user.
Definition route.h:224
bool m_NextLegGreatCircle
Flag indicating whether the next leg should be calculated using great circle navigation or rhumb line...
Definition route.h:315
int m_LayerID
Identifier of the layer containing this route.
Definition route.h:283
Waypoint or mark abstraction.
Route Manager.