42#include "model/nav_object_database.h"
59static bool ConfirmDeleteAisMob() {
60 int r = OCPNMessageBox(NULL,
61 _(
"You are trying to delete an active AIS MOB "
62 "route, are you REALLY sure?"),
63 _(
"OpenCPN Warning"), wxYES_NO);
70 ctx.confirm_delete_ais_mob = []() {
return ConfirmDeleteAisMob(); };
71 ctx.get_global_colour = [](wxString c) {
return GetGlobalColor(c); };
72 ctx.show_with_fresh_fonts = [] {
73 if (
console && !g_bhide_route_console)
console->ShowWithFreshFonts();
75 ctx.clear_console_background = []() {
76 console->GetCDI()->ClearBackground();
79 ctx.route_mgr_dlg_update_list_ctrl = []() {
80 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
81 pRouteManagerDialog->UpdateRouteListCtrl();
86bool RoutemanGui::UpdateProgress() {
87 bool bret_val =
false;
89 if (m_routeman.pActiveRoute) {
95 toSM(m_routeman.pActivePoint->m_lat, m_routeman.pActivePoint->m_lon,
gLat,
97 double a = atan(north / east);
98 if (fabs(m_routeman.pActivePoint->m_lon -
gLon) < 180.) {
99 if (m_routeman.pActivePoint->m_lon >=
gLon)
100 m_routeman.CurrentBrgToActivePoint = 90. - (a * 180 / PI);
102 m_routeman.CurrentBrgToActivePoint = 270. - (a * 180 / PI);
104 if (m_routeman.pActivePoint->m_lon >=
gLon)
105 m_routeman.CurrentBrgToActivePoint = 270. - (a * 180 / PI);
107 m_routeman.CurrentBrgToActivePoint = 90. - (a * 180 / PI);
112 double d5 = DistGreatCircle(
gLat,
gLon, m_routeman.pActivePoint->m_lat,
113 m_routeman.pActivePoint->m_lon);
114 m_routeman.CurrentRngToActivePoint = d5;
119 double brg1, dist1, brg2, dist2;
120 DistanceBearingMercator(
121 m_routeman.pActivePoint->m_lat, m_routeman.pActivePoint->m_lon,
122 m_routeman.pActiveRouteSegmentBeginPoint->m_lat,
123 m_routeman.pActiveRouteSegmentBeginPoint->m_lon, &brg1, &dist1);
124 vb.x = dist1 * sin(brg1 * PI / 180.);
125 vb.y = dist1 * cos(brg1 * PI / 180.);
127 DistanceBearingMercator(m_routeman.pActivePoint->m_lat,
128 m_routeman.pActivePoint->m_lon,
gLat,
gLon, &brg2,
130 va.x = dist2 * sin(brg2 * PI / 180.);
131 va.y = dist2 * cos(brg2 * PI / 180.);
133 double sdelta = vGetLengthOfNormal(&va, &vb, &vn);
134 m_routeman.CurrentXTEToActivePoint = sdelta;
139 vector2D vToArriveNormal;
140 vSubtractVectors(&va, &vn, &vToArriveNormal);
142 m_routeman.CurrentRangeToActiveNormalCrossing =
143 vVectorMagnitude(&vToArriveNormal);
147 double x1, y1, x2, y2;
148 toSM(m_routeman.pActiveRouteSegmentBeginPoint->m_lat,
149 m_routeman.pActiveRouteSegmentBeginPoint->m_lon,
150 m_routeman.pActiveRouteSegmentBeginPoint->m_lat,
151 m_routeman.pActiveRouteSegmentBeginPoint->m_lon, &x1, &y1);
153 toSM(m_routeman.pActivePoint->m_lat, m_routeman.pActivePoint->m_lon,
154 m_routeman.pActiveRouteSegmentBeginPoint->m_lat,
155 m_routeman.pActiveRouteSegmentBeginPoint->m_lon, &x2, &y2);
157 double e1 = atan2((x2 - x1), (y2 - y1));
158 m_routeman.CurrentSegmentCourse = e1 * 180 / PI;
159 if (m_routeman.CurrentSegmentCourse < 0)
160 m_routeman.CurrentSegmentCourse += 360;
163 double h = atan(vn.y / vn.x);
165 m_routeman.CourseToRouteSegment = 90. - (h * 180 / PI);
167 m_routeman.CourseToRouteSegment = 270. - (h * 180 / PI);
169 h = m_routeman.CurrentBrgToActivePoint - m_routeman.CourseToRouteSegment;
170 if (h < 0) h = h + 360;
173 m_routeman.XTEDir = 1;
175 m_routeman.XTEDir = -1;
179 if (g_bShowShipToActive) {
180 if (m_routeman.pActiveRoute->GetIndexOf(m_routeman.pActivePoint) == 1)
181 g_bAllowShipToActive =
true;
186 ll_gc_ll(
gLat,
gLon, m_routeman.CourseToRouteSegment,
187 (m_routeman.CurrentXTEToActivePoint / 1.852), &tlat, &tlon);
191 sqrt(pow((
double)(r1.x - r.x), 2) + pow((
double)(r1.y - r.y), 2));
193 double xtemm = xtepix / gFrame->GetFocusCanvas()->
GetPixPerMM();
195 g_bAllowShipToActive = (xtemm > 3.0) ?
true : false;
201 bool bDidArrival =
false;
204 if (isnan(m_routeman.CurrentRangeToActiveNormalCrossing)) {
205 m_routeman.CurrentRangeToActiveNormalCrossing =
206 m_routeman.CurrentRngToActivePoint;
211 if (m_routeman.pActivePoint->GetWaypointArrivalRadius() > 0) {
212 if (m_routeman.CurrentRangeToActiveNormalCrossing <=
213 m_routeman.pActivePoint->GetWaypointArrivalRadius()) {
214 m_routeman.m_bArrival =
true;
215 m_routeman.UpdateAutopilot();
224 if ((m_routeman.CurrentRangeToActiveNormalCrossing -
225 m_routeman.m_arrival_min) >
226 m_routeman.pActivePoint->GetWaypointArrivalRadius()) {
227 if (++m_routeman.m_arrival_test > 2 &&
228 !g_bAdvanceRouteWaypointOnArrivalOnly) {
229 m_routeman.m_bArrival =
true;
230 m_routeman.UpdateAutopilot();
236 m_routeman.m_arrival_test = 0;
240 m_routeman.m_arrival_min =
241 wxMin(m_routeman.m_arrival_min,
242 m_routeman.CurrentRangeToActiveNormalCrossing);
244 if (!bDidArrival) m_routeman.UpdateAutopilot();
247 m_routeman.m_bDataValid =
true;
251void RoutemanGui::DeleteTrack(
Track *pTrack) {
253 if (pTrack->m_bIsInLayer)
return;
255 ::wxBeginBusyCursor();
257 wxGenericProgressDialog *pprog =
nullptr;
259 int count = pTrack->GetnPoints();
261 pprog =
new wxGenericProgressDialog(
262 _(
"OpenCPN Track Delete"),
"0/0", count, NULL,
263 wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME |
264 wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
265 pprog->SetSize(400, wxDefaultCoord);
275 pTrack = gFrame->TrackOff();
278 pSelect->DeleteAllSelectableTrackSegments(pTrack);
291void RoutemanGui::DeleteAllTracks() {
294 ::wxBeginBusyCursor();
300 for (
Track *ptrack : to_del) {
301 if (ptrack->m_bIsInLayer)
continue;
303 g_pAIS->DeletePersistentTrack(ptrack);
304 NavObj_dB::GetInstance().DeleteTrack(ptrack);
310void RoutemanGui::DoAdvance() {
314 Route *pthis_route = m_routeman.pActiveRoute;
315 m_routeman.DeactivateRoute(
true);
321 if (pRouteManagerDialog) pRouteManagerDialog->UpdateRouteListCtrl();
AisDecoder * g_pAIS
Global instance.
Class AisDecoder and helpers.
Generic Chart canvas base.
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
double GetPixPerMM()
Get the number of logical pixels per millimeter on the screen.
Represents a navigational route in the navigation system.
bool m_bDeleteOnArrival
Flag indicating whether the route should be deleted once navigation reaches the end.
bool m_bIsBeingEdited
Flag indicating that the route is currently being edited by the user.
bool ActivateNextPoint(Route *pr, bool skipped)
Activates the next waypoint in a route when the current waypoint is reached.
bool DeleteRoute(Route *pRoute)
Represents a track, which is a series of connected track points.
APConsole * console
Global instance.
Primary navigation console display for route and vessel tracking.
Global variables stored in configuration file.
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
MySQL based storage for routes, tracks, etc.
double gLat
Vessel's current latitude in decimal degrees.
double gLon
Vessel's current longitude in decimal degrees.
Position, course, speed, etc.
Waypoint or mark abstraction.
Select * pSelect
Global instance.
Selected route, segment, waypoint, etc.
ActiveTrack * g_pActiveTrack
global instance
std::vector< Track * > g_TrackList
Global instance.
Recorded track abstraction.
TrackPropDlg * pTrackPropDialog
Global instance.