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
96class Route : public wxObject {
97 friend class RouteGui;
98
99public:
100 Route();
101 ~Route();
102
103 virtual int GetnPoints(void) { return pRoutePointList->GetCount(); }
104 wxString IsPointNameValid(RoutePoint *pRP, const wxString &name) const;
105
106 void AddPoint(RoutePoint *pNewPoint, bool b_rename_in_sequence = true,
107 bool b_deferBoxCalc = false);
108 void InsertPointAndSegment(RoutePoint *pNewPoint, int insert_after,
109 bool b_rename_in_sequence = true,
110 bool b_deferBoxCalc = false);
111 void AddPointAndSegment(RoutePoint *pNewPoint,
112 bool b_rename_in_sequence = true,
113 bool b_deferBoxCalc = false);
114 RoutePoint *GetPoint(int nPoint);
115 RoutePoint *GetPoint(const wxString &guid);
116 int GetIndexOf(RoutePoint *prp);
117 RoutePoint *InsertPointBefore(RoutePoint *pRP, double rlat, double rlon,
118 bool bRenamePoints = false);
119 RoutePoint *InsertPointAfter(RoutePoint *pRP, double rlat, double rlon,
120 bool bRenamePoints = false);
121
122 RoutePoint *GetLastPoint();
123 void DeletePoint(RoutePoint *rp, bool bRenamePoints = false);
124 void RemovePoint(RoutePoint *rp, bool bRenamePoints = false);
125 void DeSelectRoute();
126 void FinalizeForRendering();
147 double planspeed = -1.0);
148 void UpdateSegmentDistances(double planspeed = -1.0);
149 LLBBox &GetBBox();
150 void SetHiLite(int width) { m_hiliteWidth = width; }
151 void Reverse(bool bRenamePoints = false);
152 void RebuildGUIDList(void);
153 void RenameRoutePoints();
154 void ReloadRoutePointIcons();
155 wxString GetNewMarkSequenced(void);
156 void AssembleRoute();
157 bool IsEqualTo(Route *ptargetroute);
158 void CloneRoute(Route *psourceroute, int start_nPoint, int end_nPoint,
159 const wxString &suffix,
160 const bool duplicate_first_point = false);
161 void ClearHighlights(void);
162
163 void SetVisible(bool visible = true, bool includeWpts = true);
164 void SetListed(bool visible = true);
165 bool IsVisible() { return m_bVisible; }
166 bool IsListed() { return m_bListed; }
167 bool IsActive() { return m_bRtIsActive; }
168 bool IsSelected() { return m_bRtIsSelected; }
169
170 bool ContainsSharedWP();
171 void SetSharedWPViz(bool sharedWPVIZ) { m_bsharedWPViz = sharedWPVIZ; }
172 bool GetSharedWPViz() { return m_bsharedWPViz; }
173
174 double GetRouteArrivalRadius(void) { return m_ArrivalRadius; }
175 void SetRouteArrivalRadius(double radius) { m_ArrivalRadius = radius; }
181 void SetDepartureDate(const wxDateTime &dt) {
182 if (dt.IsValid()) m_PlannedDeparture = dt;
183 }
184
185 wxString GetName() const { return m_RouteNameString; }
186 wxString GetTo() const { return m_RouteEndString; }
187 wxString GetGUID() const { return m_GUID; }
188 void ShowWaypointNames(bool bshow);
189 bool AreWaypointNamesVisible();
190
191 int m_ConfigRouteNum;
192 bool m_bRtIsSelected;
193 bool m_bRtIsActive;
194 RoutePoint *m_pRouteActivePoint;
195 bool m_bIsBeingCreated;
196 bool m_bIsBeingEdited;
197 double m_route_length;
198 double m_route_time;
199 wxString m_RouteNameString;
200 wxString m_RouteStartString;
201 wxString m_RouteEndString;
202 wxString m_RouteDescription;
203 bool m_bDeleteOnArrival;
204 wxString m_GUID;
205 bool m_bIsInLayer;
206 int m_LayerID;
207 int m_width;
208 wxPenStyle m_style;
209 int m_lastMousePointIndex;
210 bool m_NextLegGreatCircle;
211 double m_PlannedSpeed;
214 wxString m_TimeDisplayFormat;
215
216 RoutePointList *pRoutePointList;
217
218 wxRect active_pt_rect;
219 wxString m_Colour;
220 bool m_btemp;
221 int m_hiliteWidth;
222 HyperlinkList *m_HyperlinkList;
223
224private:
225 LLBBox RBBox;
226
227 int m_nm_sequence;
228 bool m_bVisible; // should this route be drawn?
229 bool m_bListed;
230 double m_ArrivalRadius;
231 bool m_bsharedWPViz;
232};
233
234WX_DECLARE_LIST(Route, RouteList); // establish class Route as list member
235
236#endif // _ROUTE_H__
Represents a waypoint or mark within the navigation system.
Definition route_point.h:68
Represents a navigational route in the navigation system.
Definition route.h:96
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
wxDateTime m_PlannedDeparture
The departure time of the route, in UTC.
Definition route.h:213
void SetDepartureDate(const wxDateTime &dt)
Set the departure time of the route.
Definition route.h:181