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