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