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 _T("UTC")
46#define RTE_TIME_DISP_PC _T("PC")
47#define RTE_TIME_DISP_LOCAL _T("LOCAL")
48#define RTE_UNDEF_DEPARTURE wxInvalidDateTime
49
50class WayPointman; // FIXME (leamas) why? routeman.h defines this.
51
52extern WayPointman *pWayPointMan;
53
54const wxString GpxxColorNames[] = {
55 _T("Black"), _T("DarkRed"), _T("DarkGreen"),
56 _T("DarkYellow"), _T("DarkBlue"), _T("DarkMagenta"),
57 _T("DarkCyan"), _T("LightGray"), _T("DarkGray"),
58 _T("Red"), _T("Green"), _T ("Yellow"),
59 _T("Blue"), _T("Magenta"), _T("Cyan"),
60 _T("White")}; // The last color defined by Garmin is transparent - we
61 // ignore it
62const wxColour GpxxColors[] = {
63 wxColour(0x00, 0x00, 0x00), wxColour(0x60, 0x00, 0x00),
64 wxColour(0x00, 0x60, 0x00), wxColour(0x80, 0x80, 0x00),
65 wxColour(0x00, 0x00, 0x60), wxColour(0x60, 0x00, 0x60),
66 wxColour(0x00, 0x80, 0x80), wxColour(0xC0, 0xC0, 0xC0),
67 wxColour(0x60, 0x60, 0x60), wxColour(0xFF, 0x00, 0x00),
68 wxColour(0x00, 0xFF, 0x00), wxColour(0xF0, 0xF0, 0x00),
69 wxColour(0x00, 0x00, 0xFF), wxColour(0xFE, 0x00, 0xFE),
70 wxColour(0x00, 0xFF, 0xFF), wxColour(0xFF, 0xFF, 0xFF)};
71const int StyleValues[] = {-1, wxSOLID, wxDOT,
72 wxLONG_DASH, wxSHORT_DASH, wxDOT_DASH};
73const int WidthValues[] = {-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
74
75class Route : public wxObject {
76 friend class RouteGui;
77
78public:
79 Route();
80 ~Route();
81
82 virtual int GetnPoints(void) { return pRoutePointList->GetCount(); }
83 wxString IsPointNameValid(RoutePoint *pRP, const wxString &name) const;
84
85 void AddPoint(RoutePoint *pNewPoint, bool b_rename_in_sequence = true,
86 bool b_deferBoxCalc = false);
87 void InsertPointAndSegment(RoutePoint *pNewPoint, int insert_after,
88 bool b_rename_in_sequence = true,
89 bool b_deferBoxCalc = false);
90 void AddPointAndSegment(RoutePoint *pNewPoint,
91 bool b_rename_in_sequence = true,
92 bool b_deferBoxCalc = false);
93 RoutePoint *GetPoint(int nPoint);
94 RoutePoint *GetPoint(const wxString &guid);
95 int GetIndexOf(RoutePoint *prp);
96 RoutePoint *InsertPointBefore(RoutePoint *pRP, double rlat, double rlon,
97 bool bRenamePoints = false);
98 RoutePoint *InsertPointAfter(RoutePoint *pRP, double rlat, double rlon,
99 bool bRenamePoints = false);
100
101 RoutePoint *GetLastPoint();
102 void DeletePoint(RoutePoint *rp, bool bRenamePoints = false);
103 void RemovePoint(RoutePoint *rp, bool bRenamePoints = false);
104 void DeSelectRoute();
105 void FinalizeForRendering();
106 void UpdateSegmentDistance(RoutePoint *prp0, RoutePoint *prp,
107 double planspeed = -1.0);
108 void UpdateSegmentDistances(double planspeed = -1.0);
109 LLBBox &GetBBox();
110 void SetHiLite(int width) { m_hiliteWidth = width; }
111 void Reverse(bool bRenamePoints = false);
112 void RebuildGUIDList(void);
113 void RenameRoutePoints();
114 void ReloadRoutePointIcons();
115 wxString GetNewMarkSequenced(void);
116 void AssembleRoute();
117 bool IsEqualTo(Route *ptargetroute);
118 void CloneRoute(Route *psourceroute, int start_nPoint, int end_nPoint,
119 const wxString &suffix,
120 const bool duplicate_first_point = false);
121 void ClearHighlights(void);
122
123 void SetVisible(bool visible = true, bool includeWpts = true);
124 void SetListed(bool visible = true);
125 bool IsVisible() { return m_bVisible; }
126 bool IsListed() { return m_bListed; }
127 bool IsActive() { return m_bRtIsActive; }
128 bool IsSelected() { return m_bRtIsSelected; }
129
130 bool ContainsSharedWP();
131 void SetSharedWPViz(bool sharedWPVIZ) { m_bsharedWPViz = sharedWPVIZ; }
132 bool GetSharedWPViz() { return m_bsharedWPViz; }
133
134 double GetRouteArrivalRadius(void) { return m_ArrivalRadius; }
135 void SetRouteArrivalRadius(double radius) { m_ArrivalRadius = radius; }
136 void SetDepartureDate(const wxDateTime &dt) {
137 if (dt.IsValid()) m_PlannedDeparture = dt;
138 }
139
140 wxString GetName() const { return m_RouteNameString; }
141 wxString GetTo() const { return m_RouteEndString; }
142 wxString GetGUID() const { return m_GUID; }
143 void ShowWaypointNames(bool bshow);
144 bool AreWaypointNamesVisible();
145
146 int m_ConfigRouteNum;
147 bool m_bRtIsSelected;
148 bool m_bRtIsActive;
149 RoutePoint *m_pRouteActivePoint;
150 bool m_bIsBeingCreated;
151 bool m_bIsBeingEdited;
152 double m_route_length;
153 double m_route_time;
154 wxString m_RouteNameString;
155 wxString m_RouteStartString;
156 wxString m_RouteEndString;
157 wxString m_RouteDescription;
158 bool m_bDeleteOnArrival;
159 wxString m_GUID;
160 bool m_bIsInLayer;
161 int m_LayerID;
162 int m_width;
163 wxPenStyle m_style;
164 int m_lastMousePointIndex;
165 bool m_NextLegGreatCircle;
166 double m_PlannedSpeed;
167 wxDateTime m_PlannedDeparture;
168 wxString m_TimeDisplayFormat;
169
170 RoutePointList *pRoutePointList;
171
172 wxRect active_pt_rect;
173 wxString m_Colour;
174 bool m_btemp;
175 int m_hiliteWidth;
176 HyperlinkList *m_HyperlinkList;
177
178private:
179 LLBBox RBBox;
180
181 int m_nm_sequence;
182 bool m_bVisible; // should this route be drawn?
183 bool m_bListed;
184 double m_ArrivalRadius;
185 bool m_bsharedWPViz;
186};
187
188WX_DECLARE_LIST(Route, RouteList); // establish class Route as list member
189
190#endif // _ROUTE_H__
Definition route.h:75