OpenCPN Partial API docs
route_point.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 _ROUTEPOINT_H__
25 #define _ROUTEPOINT_H__
26 
27 #include <functional>
28 
29 #include <wx/bitmap.h>
30 #include <wx/colour.h>
31 #include <wx/datetime.h>
32 #include <wx/string.h>
33 
34 #include "model/hyperlink.h"
35 
36 #include "bbox.h"
37 
38 #define MAX_INT_VAL 2147483647 // max possible integer value before 'rollover'
39 
40 // minimal allowed ScaMin setting. prevents always hiding
41 #define SCAMIN_MIN 800
42 
43 #define ETA_FORMAT_STR "%x %H:%M"
44 //"%d/%m/%Y %H:%M" //"%Y-%m-%d %H:%M"
45 
46 // Default color, global state
47 extern wxColour g_colourWaypointRangeRingsColour;
48 
49 extern int g_LayerIdx;
50 
51 extern wxRect g_blink_rect;
52 
53 class RoutePoint {
54 friend class RoutePointGui;
55 
56 public:
57  RoutePoint(double lat, double lon, const wxString &icon_ident,
58  const wxString &name, const wxString &pGUID = wxEmptyString,
59  bool bAddToList = true);
60  RoutePoint(RoutePoint *orig);
61  RoutePoint();
62  virtual ~RoutePoint(void);
63 
70  static std::function<void(unsigned, const unsigned*)> delete_gl_textures;
71 
72  void ReLoadIcon() { m_IconIsDirty = true; }
73 
74  void SetPosition(double lat, double lon);
75  double GetLatitude() { return m_lat; };
76  double GetLongitude() { return m_lon; };
77  LLBBox &GetBBox() { return m_wpBBox; }
78 
79  bool IsSame(RoutePoint *pOtherRP); // toh, 2009.02.11
80  bool IsVisible() { return m_bIsVisible; }
81  bool IsListed() { return m_bIsListed; }
82  bool IsNameShown() { return m_bShowName; }
83 
84  bool IsShared() { return m_bsharedMark; }
85  void SetShared(bool bshared) { m_bsharedMark = bshared; }
86 
87  bool IsSharedInVisibleRoute(void);
88 
89  bool IsVisibleSelectable(double scale_val, bool boverrideViz = false);
90  void SetVisible(bool viz = true) { m_bIsVisible = viz; }
91  void SetListed(bool viz = true) { m_bIsListed = viz; }
92  void SetNameShown(bool viz = true) { m_bShowName = viz; }
93  bool GetNameShown() { return m_bShowName; }
94  virtual wxString GetName(void) { return m_MarkName; }
95  wxString GetDescription(void) { return m_MarkDescription; }
96 
97  wxDateTime GetCreateTime(void);
98  void SetCreateTime(wxDateTime dt);
99 
100  wxString GetIconName(void) { return m_IconName; }
101  void SetIconName(wxString name) { m_IconName = name; }
102 
103  void *GetSelectNode(void) { return m_SelectNode; }
104  void SetSelectNode(void *node) { m_SelectNode = node; }
105 
106  void *GetManagerListNode(void) { return m_ManagerNode; }
107  void SetManagerListNode(void *node) { m_ManagerNode = node; }
108 
109  void SetName(const wxString &name);
110  void CalculateNameExtents(void);
111 
112  void SetCourse(double course) { m_routeprop_course = course; };
113  double GetCourse() { return m_routeprop_course; };
114  void SetDistance(double distance) { m_routeprop_distance = distance; };
115  double GetDistance() { return m_routeprop_distance; };
116 
117  void SetWaypointArrivalRadius(double dArrivalDistance) {
118  m_WaypointArrivalRadius = dArrivalDistance;
119  };
120  void SetWaypointArrivalRadius(wxString wxArrivalDistance) {
121  wxArrivalDistance.ToDouble(&m_WaypointArrivalRadius);
122  };
123  double GetWaypointArrivalRadius();
124  bool GetShowWaypointRangeRings(void) { return m_bShowWaypointRangeRings; };
125  int GetWaypointRangeRingsNumber(void);
126  float GetWaypointRangeRingsStep(void);
127  int GetWaypointRangeRingsStepUnits(void);
128  void SetShowWaypointRangeRings(bool b_showWaypointRangeRings) {
129  m_bShowWaypointRangeRings = b_showWaypointRangeRings;
130  };
131  void SetWaypointRangeRingsNumber(int i_WaypointRangeRingsNumber) {
132  m_iWaypointRangeRingsNumber = i_WaypointRangeRingsNumber;
133  };
134  void SetWaypointRangeRingsStep(float f_WaypointRangeRingsStep) {
135  m_fWaypointRangeRingsStep = f_WaypointRangeRingsStep;
136  };
137  void SetWaypointRangeRingsStepUnits(int i_WaypointRangeRingsStepUnits) {
138  m_iWaypointRangeRingsStepUnits = i_WaypointRangeRingsStepUnits;
139  };
140  void SetWaypointRangeRingsColour(wxColour wxc_WaypointRangeRingsColour) {
141  m_wxcWaypointRangeRingsColour = wxc_WaypointRangeRingsColour;
142  };
143  void SetScaMin(wxString str);
144  void SetScaMin(long val);
145  long GetScaMin() { return m_ScaMin; };
146  void SetScaMax(wxString str);
147  void SetScaMax(long val);
148  long GetScaMax() { return m_ScaMax; };
149  bool GetUseSca() { return b_UseScamin; };
150  void SetUseSca(bool value) { b_UseScamin = value; };
151  bool IsDragHandleEnabled() { return m_bDrawDragHandle; }
152  void SetPlannedSpeed(double spd);
153  double GetPlannedSpeed();
154  wxDateTime GetETD();
155  wxDateTime GetManualETD();
156  void SetETD(const wxDateTime &etd);
157  bool SetETD(const wxString &ts);
158  wxDateTime GetETA();
159  wxString GetETE();
160  void SetETE(wxLongLong secs);
161 
162  double m_lat, m_lon;
163  double m_seg_len; // length in NMI to this point
164  // undefined for starting point
165  double m_seg_vmg;
166  wxDateTime m_seg_etd;
167  wxDateTime m_seg_eta;
168  wxLongLong m_seg_ete = 0;
169  bool m_manual_etd{false};
170 
171  bool m_bPtIsSelected;
172  bool m_bRPIsBeingEdited;
173 
174  bool m_bIsInRoute;
175  bool m_bIsolatedMark; // This is an isolated mark
176 
177  bool m_bIsVisible; // true if should be drawn, false if invisible
178  bool m_bIsListed;
179  bool m_bIsActive;
180  bool m_IconIsDirty;
181  wxString m_MarkDescription;
182  wxString m_GUID;
183 
184  wxString m_TideStation;
185 
186  wxFont *m_pMarkFont;
187  wxColour m_FontColor;
188 
189  wxSize m_NameExtents;
190 
191  bool m_bBlink;
192  bool m_bDynamicName;
193  bool m_bShowName, m_bShowNameData;
194  wxRect CurrentRect_in_DC;
195  int m_NameLocationOffsetX;
196  int m_NameLocationOffsetY;
197  bool m_bIsInLayer;
198  int m_LayerID;
199 
200  double m_routeprop_course; // course from this waypoint to the next waypoint
201  // if in a route.
202  double m_routeprop_distance; // distance from this waypoint to the next
203  // waypoint if in a route.
204 
205  bool m_btemp;
206 
207  bool m_bShowWaypointRangeRings;
208  int m_iWaypointRangeRingsNumber;
209 
210  float m_fWaypointRangeRingsStep;
211  int m_iWaypointRangeRingsStepUnits;
212  wxColour m_wxcWaypointRangeRingsColour;
213 
214  unsigned int m_iTextTexture;
215  int m_iTextTextureWidth, m_iTextTextureHeight;
216 
217  LLBBox m_wpBBox;
218  double m_wpBBox_view_scale_ppm, m_wpBBox_rotation;
219 
220  bool m_pos_on_screen;
221  wxPoint2DDouble m_screen_pos; // cached for arrows and points
222 
223  double m_WaypointArrivalRadius;
224  HyperlinkList *m_HyperlinkList;
225 
226  wxString m_timestring;
227 
228  wxDateTime m_CreateTimeX;
229 
230 private:
231 
232  wxString m_MarkName;
233  wxBitmap *m_pbmIcon;
234  wxString m_IconName;
235 
236  void *m_SelectNode;
237  void *m_ManagerNode;
238 
239  float m_IconScaleFactor;
240  wxBitmap m_ScaledBMP;
241  bool m_bPreScaled;
242  bool m_bDrawDragHandle;
243  wxBitmap m_dragIcon;
244  int m_drag_line_length_man, m_drag_icon_offset;
245  double m_dragHandleLat, m_dragHandleLon;
246  int m_draggingOffsetx, m_draggingOffsety;
247  bool b_UseScamin;
248  long m_ScaMin;
249  long m_ScaMax;
250  double m_PlannedSpeed;
251 
252  bool m_bsharedMark /*m_bKeepXRoute*/; // This is an isolated mark which is
253  // also part of a route. It should not
254  // be deleted with route.
255  unsigned int m_dragIconTexture;
256  int m_dragIconTextureWidth, m_dragIconTextureHeight;
257 };
258 
259 WX_DECLARE_LIST(RoutePoint, RoutePointList); // establish class as list member
260 
261 #endif // _ROUTEPOINT_H__
static std::function< void(unsigned, const unsigned *)> delete_gl_textures
Horrible Hack (tm).
Definition: route_point.h:70