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