OpenCPN Partial API docs
Loading...
Searching...
No Matches
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
47extern wxColour g_colourWaypointRangeRingsColour;
48
49extern int g_LayerIdx;
51extern wxRect g_blink_rect;
52
71 friend class RoutePointGui;
72
73public:
74 RoutePoint(double lat, double lon, const wxString &icon_ident,
75 const wxString &name, const wxString &pGUID = wxEmptyString,
76 bool bAddToList = true);
78 RoutePoint();
79 virtual ~RoutePoint(void);
80
87 static std::function<void(unsigned, const unsigned *)> delete_gl_textures;
88
89 void ReLoadIcon() { m_IconIsDirty = true; }
90
91 void SetPosition(double lat, double lon);
92 double GetLatitude() { return m_lat; };
93 double GetLongitude() { return m_lon; };
94 LLBBox &GetBBox() { return m_wpBBox; }
95
96 bool IsSame(RoutePoint *pOtherRP); // toh, 2009.02.11
97 bool IsVisible() { return m_bIsVisible; }
98 bool IsListed() { return m_bIsListed; }
99 bool IsNameShown() { return m_bShowName; }
100 bool IsNameDynamic();
101
102 bool IsShared() { return m_bsharedMark; }
103 void SetShared(bool bshared) { m_bsharedMark = bshared; }
104
105 bool IsSharedInVisibleRoute(void);
106
107 bool IsVisibleSelectable(double scale_val, bool boverrideViz = false);
108 void SetVisible(bool viz = true) { m_bIsVisible = viz; }
109 void SetListed(bool viz = true) { m_bIsListed = viz; }
110 void SetNameShown(bool viz = true) { m_bShowName = viz; }
111 bool GetNameShown() { return m_bShowName; }
112 virtual wxString GetName(void) { return m_MarkName; }
113 wxString GetDescription(void) { return m_MarkDescription; }
114
116 wxDateTime GetCreateTime(void);
118 void SetCreateTime(wxDateTime dt);
119
120 wxString GetIconName(void) { return m_IconName; }
121 void SetIconName(wxString name) { m_IconName = name; }
122
123 void *GetSelectNode(void) { return m_SelectNode; }
124 void SetSelectNode(void *node) { m_SelectNode = node; }
125
126 void *GetManagerListNode(void) { return m_ManagerNode; }
127 void SetManagerListNode(void *node) { m_ManagerNode = node; }
128
129 void SetName(const wxString &name);
130 void CalculateNameExtents(void);
131
132 void SetCourse(double course) { m_routeprop_course = course; };
133 double GetCourse() { return m_routeprop_course; };
134 void SetDistance(double distance) { m_routeprop_distance = distance; };
135 double GetDistance() { return m_routeprop_distance; };
136
137 void SetWaypointArrivalRadius(double dArrivalDistance) {
138 m_WaypointArrivalRadius = dArrivalDistance;
139 };
140 void SetWaypointArrivalRadius(wxString wxArrivalDistance) {
141 wxArrivalDistance.ToDouble(&m_WaypointArrivalRadius);
142 };
143 double GetWaypointArrivalRadius();
144 bool GetShowWaypointRangeRings(void) { return m_bShowWaypointRangeRings; };
145 int GetWaypointRangeRingsNumber(void);
146 float GetWaypointRangeRingsStep(void);
147 int GetWaypointRangeRingsStepUnits(void);
148 void SetShowWaypointRangeRings(bool b_showWaypointRangeRings) {
149 m_bShowWaypointRangeRings = b_showWaypointRangeRings;
150 };
151 void SetWaypointRangeRingsNumber(int i_WaypointRangeRingsNumber) {
152 m_iWaypointRangeRingsNumber = i_WaypointRangeRingsNumber;
153 };
154 void SetWaypointRangeRingsStep(float f_WaypointRangeRingsStep) {
155 m_fWaypointRangeRingsStep = f_WaypointRangeRingsStep;
156 };
157 void SetWaypointRangeRingsStepUnits(int i_WaypointRangeRingsStepUnits) {
158 m_iWaypointRangeRingsStepUnits = i_WaypointRangeRingsStepUnits;
159 };
160 void SetWaypointRangeRingsColour(wxColour wxc_WaypointRangeRingsColour) {
161 m_wxcWaypointRangeRingsColour = wxc_WaypointRangeRingsColour;
162 };
163 void SetTideStation(wxString TideStation) { m_TideStation = TideStation; };
164 void SetScaMin(wxString str);
165 void SetScaMin(long val);
166 long GetScaMin() { return m_ScaMin; };
167 void SetScaMax(wxString str);
168 void SetScaMax(long val);
169 long GetScaMax() { return m_ScaMax; };
170 bool GetUseSca() { return b_UseScamin; };
171 void SetUseSca(bool value) { b_UseScamin = value; };
172 bool IsDragHandleEnabled() { return m_bDrawDragHandle; }
173 void SetPlannedSpeed(double spd);
188 double GetPlannedSpeed();
199 wxDateTime GetETD();
216 wxDateTime GetManualETD();
226 void SetETD(const wxDateTime &etd);
246 bool SetETD(const wxString &ts);
272 wxDateTime GetETA();
283 wxString GetETE();
284 void SetETE(wxLongLong secs);
285
286 double m_lat, m_lon;
292 double m_seg_len;
293
308 double m_seg_vmg;
327 wxDateTime m_seg_etd;
328
351 wxDateTime m_seg_eta;
365 wxLongLong m_seg_ete = 0;
374 bool m_manual_etd{false};
375
396
423 wxString m_GUID;
431 wxFont *m_pMarkFont;
436 wxColour m_FontColor;
512 unsigned int m_iTextTexture;
525 LLBBox m_wpBBox;
526 double m_wpBBox_view_scale_ppm, m_wpBBox_rotation;
536 wxPoint2DDouble m_screen_pos;
545 HyperlinkList *m_HyperlinkList;
549 wxString m_timestring;
553 wxDateTime m_CreateTimeX;
554
555private:
559 wxString m_MarkName;
560 wxBitmap *m_pbmIcon;
561 wxString m_IconName;
562
563 void *m_SelectNode;
564 void *m_ManagerNode;
565
566 float m_IconScaleFactor;
567 wxBitmap m_ScaledBMP;
568 bool m_bPreScaled;
569 bool m_bDrawDragHandle;
570 wxBitmap m_dragIcon;
571 int m_drag_line_length_man, m_drag_icon_offset;
572 double m_dragHandleLat, m_dragHandleLon;
573 int m_draggingOffsetx, m_draggingOffsety;
577 bool b_UseScamin;
582 long m_ScaMin;
587 long m_ScaMax;
602 double m_PlannedSpeed;
603
608 bool m_bsharedMark /*m_bKeepXRoute*/;
609 unsigned int m_dragIconTexture;
610 int m_dragIconTextureWidth, m_dragIconTextureHeight;
611};
612
613WX_DECLARE_LIST(RoutePoint, RoutePointList); // establish class as list member
614
615#endif // _ROUTEPOINT_H__
Represents a waypoint or mark within the navigation system.
Definition route_point.h:70
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:50
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.