40#include "model/nav_object_database.h"
57static bool ConfirmDeleteAisMob() {
58 int r = OCPNMessageBox(NULL,
59 _(
"You are trying to delete an active AIS MOB "
60 "route, are you REALLY sure?"),
61 _(
"OpenCPN Warning"), wxYES_NO);
68 ctx.confirm_delete_ais_mob = []() {
return ConfirmDeleteAisMob(); };
69 ctx.get_global_colour = [](wxString c) {
return GetGlobalColor(c); };
70 ctx.show_with_fresh_fonts = [] {
71 if (
console && !g_bhide_route_console)
console->ShowWithFreshFonts();
73 ctx.clear_console_background = []() {
74 console->GetCDI()->ClearBackground();
77 ctx.route_mgr_dlg_update_list_ctrl = []() {
78 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
79 pRouteManagerDialog->UpdateRouteListCtrl();
84bool RoutemanGui::UpdateProgress() {
85 bool bret_val =
false;
87 if (m_routeman.pActiveRoute) {
93 toSM(m_routeman.pActivePoint->m_lat, m_routeman.pActivePoint->m_lon,
gLat,
95 double a = atan(north / east);
96 if (fabs(m_routeman.pActivePoint->m_lon -
gLon) < 180.) {
97 if (m_routeman.pActivePoint->m_lon >=
gLon)
98 m_routeman.CurrentBrgToActivePoint = 90. - (a * 180 / PI);
100 m_routeman.CurrentBrgToActivePoint = 270. - (a * 180 / PI);
102 if (m_routeman.pActivePoint->m_lon >=
gLon)
103 m_routeman.CurrentBrgToActivePoint = 270. - (a * 180 / PI);
105 m_routeman.CurrentBrgToActivePoint = 90. - (a * 180 / PI);
110 double d5 = DistGreatCircle(
gLat,
gLon, m_routeman.pActivePoint->m_lat,
111 m_routeman.pActivePoint->m_lon);
112 m_routeman.CurrentRngToActivePoint = d5;
117 double brg1, dist1, brg2, dist2;
118 DistanceBearingMercator(
119 m_routeman.pActivePoint->m_lat, m_routeman.pActivePoint->m_lon,
120 m_routeman.pActiveRouteSegmentBeginPoint->m_lat,
121 m_routeman.pActiveRouteSegmentBeginPoint->m_lon, &brg1, &dist1);
122 vb.x = dist1 * sin(brg1 * PI / 180.);
123 vb.y = dist1 * cos(brg1 * PI / 180.);
125 DistanceBearingMercator(m_routeman.pActivePoint->m_lat,
126 m_routeman.pActivePoint->m_lon,
gLat,
gLon, &brg2,
128 va.x = dist2 * sin(brg2 * PI / 180.);
129 va.y = dist2 * cos(brg2 * PI / 180.);
131 double sdelta = vGetLengthOfNormal(&va, &vb, &vn);
132 m_routeman.CurrentXTEToActivePoint = sdelta;
137 vector2D vToArriveNormal;
138 vSubtractVectors(&va, &vn, &vToArriveNormal);
140 m_routeman.CurrentRangeToActiveNormalCrossing =
141 vVectorMagnitude(&vToArriveNormal);
145 double x1, y1, x2, y2;
146 toSM(m_routeman.pActiveRouteSegmentBeginPoint->m_lat,
147 m_routeman.pActiveRouteSegmentBeginPoint->m_lon,
148 m_routeman.pActiveRouteSegmentBeginPoint->m_lat,
149 m_routeman.pActiveRouteSegmentBeginPoint->m_lon, &x1, &y1);
151 toSM(m_routeman.pActivePoint->m_lat, m_routeman.pActivePoint->m_lon,
152 m_routeman.pActiveRouteSegmentBeginPoint->m_lat,
153 m_routeman.pActiveRouteSegmentBeginPoint->m_lon, &x2, &y2);
155 double e1 = atan2((x2 - x1), (y2 - y1));
156 m_routeman.CurrentSegmentCourse = e1 * 180 / PI;
157 if (m_routeman.CurrentSegmentCourse < 0)
158 m_routeman.CurrentSegmentCourse += 360;
161 double h = atan(vn.y / vn.x);
163 m_routeman.CourseToRouteSegment = 90. - (h * 180 / PI);
165 m_routeman.CourseToRouteSegment = 270. - (h * 180 / PI);
167 h = m_routeman.CurrentBrgToActivePoint - m_routeman.CourseToRouteSegment;
168 if (h < 0) h = h + 360;
171 m_routeman.XTEDir = 1;
173 m_routeman.XTEDir = -1;
177 if (g_bShowShipToActive) {
178 if (m_routeman.pActiveRoute->GetIndexOf(m_routeman.pActivePoint) == 1)
179 g_bAllowShipToActive =
true;
184 ll_gc_ll(
gLat,
gLon, m_routeman.CourseToRouteSegment,
185 (m_routeman.CurrentXTEToActivePoint / 1.852), &tlat, &tlon);
189 sqrt(pow((
double)(r1.x - r.x), 2) + pow((
double)(r1.y - r.y), 2));
191 double xtemm = xtepix / gFrame->GetFocusCanvas()->
GetPixPerMM();
193 g_bAllowShipToActive = (xtemm > 3.0) ?
true : false;
199 bool bDidArrival =
false;
202 if (isnan(m_routeman.CurrentRangeToActiveNormalCrossing)) {
203 m_routeman.CurrentRangeToActiveNormalCrossing =
204 m_routeman.CurrentRngToActivePoint;
209 if (m_routeman.pActivePoint->GetWaypointArrivalRadius() > 0) {
210 if (m_routeman.CurrentRangeToActiveNormalCrossing <=
211 m_routeman.pActivePoint->GetWaypointArrivalRadius()) {
212 m_routeman.m_bArrival =
true;
213 m_routeman.UpdateAutopilot();
222 if ((m_routeman.CurrentRangeToActiveNormalCrossing -
223 m_routeman.m_arrival_min) >
224 m_routeman.pActivePoint->GetWaypointArrivalRadius()) {
225 if (++m_routeman.m_arrival_test > 2 &&
226 !g_bAdvanceRouteWaypointOnArrivalOnly) {
227 m_routeman.m_bArrival =
true;
228 m_routeman.UpdateAutopilot();
234 m_routeman.m_arrival_test = 0;
238 m_routeman.m_arrival_min =
239 wxMin(m_routeman.m_arrival_min,
240 m_routeman.CurrentRangeToActiveNormalCrossing);
242 if (!bDidArrival) m_routeman.UpdateAutopilot();
245 m_routeman.m_bDataValid =
true;
249void RoutemanGui::DeleteTrack(
Track *pTrack) {
251 if (pTrack->m_bIsInLayer)
return;
253 ::wxBeginBusyCursor();
255 wxGenericProgressDialog *pprog =
nullptr;
257 int count = pTrack->GetnPoints();
259 pprog =
new wxGenericProgressDialog(
260 _(
"OpenCPN Track Delete"),
"0/0", count, NULL,
261 wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME |
262 wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
263 pprog->SetSize(400, wxDefaultCoord);
273 pTrack = gFrame->TrackOff();
276 pSelect->DeleteAllSelectableTrackSegments(pTrack);
289void RoutemanGui::DeleteAllTracks() {
292 ::wxBeginBusyCursor();
298 for (
Track *ptrack : to_del) {
299 if (ptrack->m_bIsInLayer)
continue;
301 g_pAIS->DeletePersistentTrack(ptrack);
302 NavObj_dB::GetInstance().DeleteTrack(ptrack);
308void RoutemanGui::DoAdvance() {
312 Route *pthis_route = m_routeman.pActiveRoute;
313 m_routeman.DeactivateRoute(
true);
319 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.