OpenCPN Partial API docs
Loading...
Searching...
No Matches
route_point.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef ROUTEPOINT_H_
25#define ROUTEPOINT_H_
26
27#include <functional>
28#include <vector>
29
30#include <wx/bitmap.h>
31#include <wx/colour.h>
32#include <wx/datetime.h>
33#include <wx/string.h>
34
35#include "model/hyperlink.h"
36
37#include "bbox.h"
38
39#define MAX_INT_VAL 2147483647 // max possible integer value before 'rollover'
40
41// minimal allowed ScaMin setting. prevents always hiding
42#define SCAMIN_MIN 800
43
44#define ETA_FORMAT_STR "%x %H:%M"
45//"%d/%m/%Y %H:%M" //"%Y-%m-%d %H:%M"
46
47// Default color, global state
50extern int g_LayerIdx;
52extern wxRect g_blink_rect;
72 friend class RoutePointGui;
73
74public:
75 RoutePoint(double lat, double lon, const wxString &icon_ident,
76 const wxString &name, const wxString &pGUID = wxEmptyString,
77 bool bAddToList = true);
79 RoutePoint();
80 virtual ~RoutePoint(void);
81
88 static std::function<void(unsigned, const unsigned *)> delete_gl_textures;
89
90 void ReLoadIcon() { m_IconIsDirty = true; }
91
92 void SetPosition(double lat, double lon);
93 double GetLatitude() { return m_lat; };
94 double GetLongitude() { return m_lon; };
95 LLBBox &GetBBox() { return m_wpBBox; }
96
97 bool IsSame(RoutePoint *pOtherRP); // toh, 2009.02.11
98 bool IsVisible() { return m_bIsVisible; }
99 bool IsListed() { return m_bIsListed; }
100 bool IsNameShown() { return m_bShowName; }
101 bool IsNameDynamic();
102
103 bool IsShared() { return m_bsharedMark; }
104 void SetShared(bool bshared) { m_bsharedMark = bshared; }
105
106 bool IsSharedInVisibleRoute(void);
107
108 bool IsVisibleSelectable(double scale_val, bool boverrideViz = false);
109 void SetVisible(bool viz = true) { m_bIsVisible = viz; }
110 void SetListed(bool viz = true) { m_bIsListed = viz; }
111 void SetNameShown(bool viz = true) { m_bShowName = viz; }
112 bool GetNameShown() { return m_bShowName; }
113 virtual wxString GetName(void) { return m_MarkName; }
114 wxString GetDescription(void) { return m_MarkDescription; }
115
117 wxDateTime GetCreateTime(void);
119 void SetCreateTime(wxDateTime dt);
120
121 wxString GetIconName(void) { return m_IconName; }
122 void SetIconName(wxString name) { m_IconName = name; }
123
124 void *GetSelectNode(void) { return m_SelectNode; }
125 void SetSelectNode(void *node) { m_SelectNode = node; }
126
127 void *GetManagerListNode(void) { return m_ManagerNode; }
128 void SetManagerListNode(void *node) { m_ManagerNode = node; }
129
130 void SetName(const wxString &name);
131 void CalculateNameExtents(void);
132
133 void SetCourse(double course) { m_routeprop_course = course; };
134 double GetCourse() { return m_routeprop_course; };
135 void SetDistance(double distance) { m_routeprop_distance = distance; };
136 double GetDistance() { return m_routeprop_distance; };
137
138 void SetWaypointArrivalRadius(double dArrivalDistance) {
139 m_WaypointArrivalRadius = dArrivalDistance;
140 };
141 void SetWaypointArrivalRadius(wxString wxArrivalDistance) {
142 wxArrivalDistance.ToDouble(&m_WaypointArrivalRadius);
143 };
144 double GetWaypointArrivalRadius();
145 bool GetShowWaypointRangeRings(void) { return m_bShowWaypointRangeRings; };
146 int GetWaypointRangeRingsNumber(void);
147 float GetWaypointRangeRingsStep(void);
148 int GetWaypointRangeRingsStepUnits(void);
149 void SetShowWaypointRangeRings(bool b_showWaypointRangeRings) {
150 m_bShowWaypointRangeRings = b_showWaypointRangeRings;
151 };
152 void SetWaypointRangeRingsNumber(int i_WaypointRangeRingsNumber) {
153 m_iWaypointRangeRingsNumber = i_WaypointRangeRingsNumber;
154 };
155 void SetWaypointRangeRingsStep(float f_WaypointRangeRingsStep) {
156 m_fWaypointRangeRingsStep = f_WaypointRangeRingsStep;
157 };
158 void SetWaypointRangeRingsStepUnits(int i_WaypointRangeRingsStepUnits) {
159 m_iWaypointRangeRingsStepUnits = i_WaypointRangeRingsStepUnits;
160 };
161 void SetWaypointRangeRingsColour(wxColour wxc_WaypointRangeRingsColour) {
162 m_wxcWaypointRangeRingsColour = wxc_WaypointRangeRingsColour;
163 };
164 void SetTideStation(wxString TideStation) { m_TideStation = TideStation; };
165 void SetScaMin(wxString str);
166 void SetScaMin(long val);
167 long GetScaMin() { return m_ScaMin; };
168 void SetScaMax(wxString str);
169 void SetScaMax(long val);
170 long GetScaMax() { return m_ScaMax; };
171 bool GetUseSca() { return b_UseScamin; };
172 void SetUseSca(bool value) { b_UseScamin = value; };
173 bool IsDragHandleEnabled() { return m_bDrawDragHandle; }
174 void SetPlannedSpeed(double spd);
189 double GetPlannedSpeed();
200 wxDateTime GetETD();
217 wxDateTime GetManualETD();
227 void SetETD(const wxDateTime &etd);
247 bool SetETD(const wxString &ts);
273 wxDateTime GetETA();
284 wxString GetETE();
285 void SetETE(wxLongLong secs);
286
287 double m_lat, m_lon;
293 double m_seg_len;
294
309 double m_seg_vmg;
328 wxDateTime m_seg_etd;
329
352 wxDateTime m_seg_eta;
366 wxLongLong m_seg_ete = 0;
375 bool m_manual_etd{false};
376
397
424 wxString m_GUID;
432 wxFont *m_pMarkFont;
437 wxColour m_FontColor;
513 unsigned int m_iTextTexture;
526 LLBBox m_wpBBox;
527 double m_wpBBox_view_scale_ppm, m_wpBBox_rotation;
537 wxPoint2DDouble m_screen_pos;
546 HyperlinkList *m_HyperlinkList;
550 wxString m_timestring;
554 wxDateTime m_CreateTimeX;
555
556private:
560 wxString m_MarkName;
561 wxBitmap *m_pbmIcon;
562 wxString m_IconName;
563
564 void *m_SelectNode;
565 void *m_ManagerNode;
566
567 float m_IconScaleFactor;
568 wxBitmap m_ScaledBMP;
569 bool m_bPreScaled;
570 bool m_bDrawDragHandle;
571 wxBitmap m_dragIcon;
572 int m_drag_line_length_man, m_drag_icon_offset;
573 double m_dragHandleLat, m_dragHandleLon;
574 int m_draggingOffsetx, m_draggingOffsety;
578 bool b_UseScamin;
583 long m_ScaMin;
588 long m_ScaMax;
603 double m_PlannedSpeed;
604
609 bool m_bsharedMark /*m_bKeepXRoute*/;
610 unsigned int m_dragIconTexture;
611 int m_dragIconTextureWidth, m_dragIconTextureHeight;
612};
613
614using RoutePointList = std::vector<RoutePoint *>;
615
616#endif // ROUTEPOINT_H_
Represents a waypoint or mark within the navigation system.
Definition route_point.h:71
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.
LLBBox m_wpBBox
Bounding box 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).
Definition route_point.h:47
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 IsNameDynamic()
bool m_bIsolatedMark
Flag indicating if the waypoint is a standalone mark.
double m_routeprop_distance
Distance from this waypoint to the next waypoint, in nautical miles.
bool m_bShowNameData
Flag indicating if waypoint data should be shown with the name.
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.
int m_iTextTextureHeight
Height of the text texture in pixels.
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_routeprop_course
Course from this waypoint to the next waypoint, in degrees.
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.
int m_iTextTextureWidth
Width of the text texture in pixels.
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.
wxColour m_FontColor
Color used for rendering the waypoint name.
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.
wxPoint2DDouble m_screen_pos
Cached screen position of the waypoint for drawing arrows and points.
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.
wxColour g_colourWaypointRangeRingsColour
Global instance.
int g_LayerIdx
Global instance.
wxRect g_blink_rect
Global instance.