25#include <wx/datetime.h>
26#include <wx/dynarray.h>
28#include <wx/tokenzr.h>
39#include <wx/listimpl.cpp>
48 [](unsigned,
const unsigned *) { assert(
true); };
50RoutePoint::RoutePoint() {
84 m_GUID = pWayPointMan->CreateGUID(
this);
101 m_ScaMin = g_iWpt_ScaMin;
104 b_UseScamin = g_bUseWptScaMin;
107 m_bDrawDragHandle =
false;
108 m_dragIconTexture = 0;
109 m_draggingOffsetx = m_draggingOffsety = 0;
117 m_MarkName = orig->GetName();
134 SetShared(orig->IsShared());
143 m_ScaMin = orig->m_ScaMin;
144 m_ScaMax = orig->m_ScaMax;
146 m_IconName = orig->m_IconName;
151 m_GUID = pWayPointMan->CreateGUID(
this);
154 m_ManagerNode = NULL;
162 m_ScaMin = orig->m_ScaMin;
163 m_ScaMax = orig->m_ScaMax;
164 b_UseScamin = orig->b_UseScamin;
167 m_bDrawDragHandle =
false;
168 m_dragIconTexture = 0;
169 m_draggingOffsetx = m_draggingOffsety = 0;
172RoutePoint::RoutePoint(
double lat,
double lon,
const wxString &icon_ident,
173 const wxString &name,
const wxString &pGUID,
182 else if (m_lon > 180.)
208 m_bPreScaled =
false;
211 m_ManagerNode = NULL;
212 m_IconScaleFactor = 1.0;
213 m_ScaMin = MAX_INT_VAL;
220 if (!pGUID.IsEmpty())
223 m_GUID = pWayPointMan->CreateGUID(
this);
226 m_IconName = icon_ident;
233 if (bAddToList && NULL != pWayPointMan) pWayPointMan->
AddRoutePoint(
this);
238 SetWaypointArrivalRadius(g_n_arrival_circle_radius);
246 m_ScaMin = g_iWpt_ScaMin;
248 b_UseScamin = g_bUseWptScaMin;
251 m_bDrawDragHandle =
false;
252 m_dragIconTexture = 0;
253 m_draggingOffsetx = m_draggingOffsety = 0;
258RoutePoint::~RoutePoint() {
264 for (
auto it = list->begin(); it != list->end(); ++it)
delete *it;
279void RoutePoint::SetName(
const wxString &name) {
285 CalculateNameExtents();
288void RoutePoint::CalculateNameExtents() {
294 dc.GetTextExtent(m_MarkName, &w, &h, NULL, NULL,
m_pMarkFont);
304bool RoutePoint::IsVisibleSelectable(
double scale_val,
bool boverrideViz) {
314 if (g_bOverruleScaMin)
316 else if (scale_val >= (
double)(m_ScaMin + 1))
322bool RoutePoint::IsSharedInVisibleRoute() {
328 bool brp_viz =
false;
330 for (
unsigned int ir = 0; ir < proute_array->GetCount(); ir++) {
332 if (pr->IsVisible()) {
345void RoutePoint::SetPosition(
double lat,
double lon) {
350bool RoutePoint::IsSame(
RoutePoint *pOtherRP) {
353 if (this->m_MarkName == pOtherRP->m_MarkName) {
354 if (fabs(this->m_lat - pOtherRP->m_lat) < 1.e-6 &&
355 fabs(this->m_lon - pOtherRP->m_lon) < 1.e-6)
367 bool b_numeric =
false;
369 if (GetName().Len() >= 2) {
370 wxString substring = GetName().Left(2);
371 if (substring ==
"NM") {
372 substring = GetName().substr(2, 3);
374 substring = GetName().Left(3);
377 for (
unsigned int i = 0; i < substring.Len(); i++) {
378 if (b_numeric ==
true) {
379 b_numeric = wxIsdigit(substring[i]);
387double RoutePoint::GetWaypointArrivalRadius() {
389 SetWaypointArrivalRadius(g_n_arrival_circle_radius);
395int RoutePoint::GetWaypointRangeRingsNumber() {
397 return g_iWaypointRangeRingsNumber;
402float RoutePoint::GetWaypointRangeRingsStep() {
404 return g_fWaypointRangeRingsStep;
409int RoutePoint::GetWaypointRangeRingsStepUnits() {
411 return g_iWaypointRangeRingsStepUnits;
416void RoutePoint::SetScaMin(
long val) {
417 if (val < SCAMIN_MIN)
420 if (val < (
long)m_ScaMax * 5) val = (long)m_ScaMax * 5;
423void RoutePoint::SetScaMin(wxString str) {
425 if (!str.ToLong(&val)) val = MAX_INT_VAL;
429void RoutePoint::SetScaMax(
long val) {
430 if (val > (
int)m_ScaMin / 5)
431 m_ScaMax = (int)m_ScaMin /
434void RoutePoint::SetScaMax(wxString str) {
436 if (!str.ToLong(&val)) val = 0;
440void RoutePoint::SetPlannedSpeed(
double spd) {
441 if (spd >= 0.0 && spd <= 1000.0) m_PlannedSpeed = spd;
445 if (m_PlannedSpeed < 0.0001 &&
452 if (!s_vmg.ToDouble(&vmg)) {
454 SetPlannedSpeed(vmg);
457 return m_PlannedSpeed;
469 wxDateTime etd = wxInvalidDateTime;
473 const wxChar *parse_return = etd.ParseDateTime(s_etd);
475 wxString tz(parse_return);
477 if (tz.Find(
"UT") != wxNOT_FOUND) {
483 if (tz.Find(
"LMT") != wxNOT_FOUND) {
485 long lmt_offset = (long)((m_lon * 3600.) / 15.);
486 wxTimeSpan lmt(0, 0, (
int)lmt_offset, 0);
492 if (etd.IsValid() && (!
GetETA().IsValid() || etd >
GetETA())) {
502 return wxInvalidDateTime;
509 return wxInvalidDateTime;
516 return wxInvalidDateTime;
526void RoutePoint::SetETE(wxLongLong secs) {
m_seg_ete = secs; }
540 wxString::const_iterator end;
544 if (tmp.ParseISOCombined(ts)) {
547 }
else if (tmp.ParseDateTime(ts, &end)) {
Represents a waypoint or mark within the navigation system.
HyperlinkList * m_HyperlinkList
List of hyperlinks associated with this waypoint.
wxColour m_wxcWaypointRangeRingsColour
Color for the range rings display.
wxString m_MarkDescription
Description text for the waypoint.
int m_iWaypointRangeRingsNumber
Number of range rings to display around the waypoint.
int m_NameLocationOffsetX
Horizontal offset for waypoint name placement relative to the icon.
void SetCreateTime(wxDateTime dt)
Sets the create time of this RoutePoint in UTC.
static std::function< void(unsigned, const unsigned *)> delete_gl_textures
Horrible Hack (tm).
bool m_bRPIsBeingEdited
Flag indicating if this waypoint is currently being edited.
wxRect CurrentRect_in_DC
Current rectangle occupied by the waypoint in the display.
unsigned int m_iTextTexture
Texture identifier for rendered text.
wxString m_GUID
Globally Unique Identifier for the waypoint.
wxDateTime GetETD()
Retrieves the Estimated Time of Departure for this waypoint, in UTC.
wxDateTime m_CreateTimeX
Creation timestamp for the waypoint, in UTC.
int m_NameLocationOffsetY
Vertical offset for waypoint name placement relative to the icon.
bool m_bIsolatedMark
Flag indicating if the waypoint is a standalone mark.
bool m_pos_on_screen
Flag indicating if the waypoint is currently visible on screen.
bool m_bIsActive
Flag indicating if this waypoint is active for navigation.
wxDateTime GetManualETD()
Retrieves the manually set Estimated Time of Departure for this waypoint, in UTC.
wxDateTime m_seg_etd
Estimated Time of Departure from this waypoint, in UTC.
bool m_bIsInRoute
Flag indicating if this waypoint is part of a route.
bool m_IconIsDirty
Flag indicating if the waypoint icon needs to be reloaded or redrawn.
wxFont * m_pMarkFont
Font used for rendering the waypoint name.
double m_seg_len
Length of the leg from previous waypoint to this waypoint in nautical miles.
bool m_bShowName
Flag indicating if the waypoint name should be shown.
wxString GetETE()
Retrieves the Estimated Time En route as a formatted string.
wxString m_timestring
String representation of the waypoint creation time.
bool m_bBlink
Flag indicating if the waypoint should blink when displayed.
double GetPlannedSpeed()
Return the planned speed associated with this waypoint.
bool m_bPtIsSelected
Flag indicating if this waypoint is currently selected.
bool m_bIsVisible
Flag indicating if the waypoint should be drawn on the chart.
bool m_bIsInLayer
Flag indicating if the waypoint belongs to a layer.
double m_WaypointArrivalRadius
Arrival radius in nautical miles.
bool m_btemp
Flag indicating if this is a temporary waypoint.
bool m_manual_etd
Flag indicating whether the ETD has been manually set by the user.
double m_seg_vmg
Planned speed for traveling FROM this waypoint TO the next waypoint.
wxSize m_NameExtents
Size of the waypoint name text when rendered.
wxDateTime m_seg_eta
Estimated Time of Arrival at this waypoint, in UTC.
int m_LayerID
Layer identifier if the waypoint belongs to a layer.
int m_iWaypointRangeRingsStepUnits
Units for the range rings step (0=nm, 1=km).
wxDateTime GetCreateTime(void)
Returns the Create Time of this RoutePoint in UTC.
float m_fWaypointRangeRingsStep
Distance between consecutive range rings.
wxLongLong m_seg_ete
Estimated Time Enroute for the leg leading to this waypoint.
wxString m_TideStation
Associated tide station identifier.
bool m_bShowWaypointRangeRings
Flag indicating if range rings should be shown around the waypoint.
void SetETD(const wxDateTime &etd)
Sets the Estimated Time of Departure for this waypoint, in UTC.
wxDateTime GetETA()
Retrieves the Estimated Time of Arrival for this waypoint, in UTC.
bool m_bIsListed
Flag indicating if the waypoint should appear in the Route Manager dialog's waypoint list.
Represents a navigational route in the navigation system.
wxArrayPtrVoid * GetRouteArrayContaining(RoutePoint *pWP)
Find all routes that contain the given waypoint.
bool AddRoutePoint(RoutePoint *prp)
Add a point to list which owns it.
bool RemoveRoutePoint(RoutePoint *prp)
Remove a routepoint from list if present, deallocate it all cases.
Extern C linked utilities.
const wxChar * ParseGPXDateTime(wxDateTime &dt, const wxChar *datetime)
This function parses a string containing a GPX time representation and returns a wxDateTime containin...
Navigation Utility Functions without GUI dependencies.
wxColour g_colourWaypointRangeRingsColour
Global instance.
int g_LayerIdx
Global instance.
wxRect g_blink_rect
Global instance.
Waypoint or mark abstraction.
wxColour g_colourWaypointRangeRingsColour
Global instance.
Routeman * g_pRouteMan
Global instance.
Selected route, segment, waypoint, etc.