29#include <wx/aui/aui.h>
30#include <wx/clipbrd.h>
31#include <wx/dynarray.h>
35#include <wx/graphics.h>
37#include <wx/listbook.h>
85#include "androidUTIL.h"
90 ID_DEF_MENU_MAX_DETAIL = 1,
92 ID_DEF_MENU_SCALE_OUT,
96 ID_DEF_MENU_MOVE_BOAT_HERE,
97 ID_DEF_MENU_GOTO_HERE,
98 ID_DEF_MENU_GOTOPOSITION,
101 ID_WP_MENU_PROPERTIES,
103 ID_RT_MENU_DEACTIVATE,
107 ID_RT_MENU_SPLIT_LEG,
108 ID_RT_MENU_SPLIT_WPT,
111 ID_WPT_MENU_SENDTOGPS,
112 ID_WPT_MENU_SENDTONEWGPS,
113 ID_WPT_MENU_SENDTOPEER,
121 ID_RT_MENU_DEACTPOINT,
122 ID_RT_MENU_ACTNXTPOINT,
124 ID_RT_MENU_PROPERTIES,
125 ID_RT_MENU_SENDTOGPS,
126 ID_RT_MENU_SENDTONEWGPS,
127 ID_RT_MENU_SHOWNAMES,
128 ID_RT_MENU_RESEQUENCE,
129 ID_RT_MENU_SENDTOPEER,
130 ID_WP_MENU_SET_ANCHORWATCH,
131 ID_WP_MENU_CLEAR_ANCHORWATCH,
132 ID_DEF_MENU_AISTARGETLIST,
133 ID_DEF_MENU_AIS_CPAWARNING,
136 ID_RC_MENU_SCALE_OUT,
140 ID_DEF_MENU_AIS_QUERY,
142 ID_DEF_MENU_AISSHOWTRACK,
143 ID_DEF_MENU_ACTIVATE_MEASURE,
144 ID_DEF_MENU_DEACTIVATE_MEASURE,
145 ID_DEF_MENU_COPY_MMSI,
150 ID_DEF_MENU_CM93OFFSET_DIALOG,
152 ID_TK_MENU_PROPERTIES,
154 ID_TK_MENU_SENDTOPEER,
155 ID_WP_MENU_ADDITIONAL_INFO,
157 ID_DEF_MENU_QUILTREMOVE,
161 ID_DEF_MENU_TOGGLE_FULL,
162 ID_DEF_MENU_TIDEINFO,
163 ID_DEF_MENU_CURRENTINFO,
167 ID_DGB_MENU_NMEA_WINDOW,
169 ID_DEF_MENU_GROUPBASE,
178int CanvasMenuHandler::GetNextContextMenuId() {
179 return ID_DEF_MENU_LAST +
183wxFont CanvasMenuHandler::m_scaledFont;
186CanvasMenuHandler::CanvasMenuHandler(
ChartCanvas *parentCanvas,
189 int selectedAIS_MMSI,
190 void *selectedTCIndex, wxWindow *nmea_log)
191 : m_nmea_log(nmea_log) {
192 parent = parentCanvas;
193 m_pSelectedRoute = selectedRoute;
194 m_pSelectedTrack = selectedTrack;
195 m_pFoundRoutePoint = selectedPoint;
196 m_FoundAIS_MMSI = selectedAIS_MMSI;
197 m_pIDXCandidate = selectedTCIndex;
198 if (!m_scaledFont.IsOk()) {
200 m_scaledFont = *qFont;
206CanvasMenuHandler::~CanvasMenuHandler() {}
212void CanvasMenuHandler::PrepareMenuItem(wxMenuItem *item) {
213#if defined(__WXMSW__)
214 wxColour ctrl_back_color = GetGlobalColor(
"DILG1");
215 item->SetBackgroundColour(ctrl_back_color);
216 wxColour menu_text_color = GetGlobalColor(
"UITX1");
217 item->SetTextColour(menu_text_color);
221void CanvasMenuHandler::MenuPrepend1(wxMenu *menu,
int id, wxString label) {
222 wxMenuItem *item =
new wxMenuItem(menu,
id, label);
223#if defined(__WXMSW__)
224 item->SetFont(m_scaledFont);
229 item->SetFont(sFont);
232 PrepareMenuItem(item);
234 if (g_btouch) menu->InsertSeparator(0);
238void CanvasMenuHandler::MenuAppend1(wxMenu *menu,
int id, wxString label) {
239 wxMenuItem *item =
new wxMenuItem(menu,
id, label);
240#if defined(__WXMSW__)
241 item->SetFont(m_scaledFont);
246 item->SetFont(sFont);
249 PrepareMenuItem(item);
252 if (g_btouch) menu->AppendSeparator();
255void CanvasMenuHandler::SetMenuItemFont1(wxMenuItem *item) {
256#if defined(__WXMSW__)
257 item->SetFont(m_scaledFont);
260#if defined(__ANDROID__)
262 item->SetFont(*qFont);
265 PrepareMenuItem(item);
268void CanvasMenuHandler::CanvasPopupMenu(
int x,
int y,
int seltype) {
269 wxMenu *contextMenu =
new wxMenu;
270 wxMenu *menuWaypoint = NULL;
271 wxMenu *menuRoute = NULL;
272 wxMenu *menuTrack = NULL;
273 wxMenu *menuAIS = NULL;
275 wxMenu *subMenuChart =
new wxMenu;
276 wxMenu *subMenuUndo =
new wxMenu(
"Undo...Ctrl-Z");
279 wxMenu *subMenuRedo =
new wxMenu(
"Redo...Shift-Ctrl-Z");
281 wxMenu *subMenuRedo =
new wxMenu(
"Redo...Ctrl-Y");
283 wxMenu *subMenuDebug =
new wxMenu(
"");
284 MenuAppend1(subMenuDebug, ID_DGB_MENU_NMEA_WINDOW, _(
"Show Data Monitor"));
286 wxMenu *menuFocus = contextMenu;
291 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
292 bool bsubMenus =
false;
295 if (parent->undo->AnythingToUndo()) {
297 wxMenuItem *subMenuItemundo =
298 contextMenu->AppendSubMenu(subMenuUndo, _(
"Undo"));
301 undoItem << _(
"Undo") <<
" "
302 << parent->undo->GetNextUndoableAction()->Description();
303 MenuAppend1(subMenuUndo, ID_UNDO, undoItem);
305 if (parent->undo->AnythingToRedo()) {
307 wxMenuItem *subMenuItemRedo =
308 contextMenu->AppendSubMenu(subMenuRedo, _(
"Redo"));
311 redoItem << _(
"Redo") <<
" "
312 << parent->undo->GetNextRedoableAction()->Description();
313 MenuAppend1(subMenuRedo, ID_REDO, redoItem);
316 if (parent->undo->AnythingToUndo()) {
318 undoItem << _(
"Undo") <<
" "
319 << parent->undo->GetNextUndoableAction()->Description();
320 MenuAppend1(contextMenu, ID_UNDO, _menuText(undoItem,
"Ctrl-Z"));
323 if (parent->undo->AnythingToRedo()) {
325 redoItem << _(
"Redo") <<
" "
326 << parent->undo->GetNextRedoableAction()->Description();
328 MenuAppend1(contextMenu, ID_REDO, _menuText(redoItem,
"Shift-Ctrl-Z"));
330 MenuAppend1(contextMenu, ID_REDO, _menuText(redoItem,
"Ctrl-Y"));
336 if (seltype == SELTYPE_ROUTECREATE) {
337 MenuAppend1(contextMenu, ID_RC_MENU_FINISH,
338 _menuText(_(
"End Route"),
"Esc"));
341 if (!parent->m_pMouseRoute) {
342 if (parent->m_bMeasure_Active)
343 MenuAppend1(contextMenu, ID_DEF_MENU_DEACTIVATE_MEASURE,
344 _menuText(_(
"Measure Off"),
"Esc"));
346 MenuAppend1(contextMenu, ID_DEF_MENU_ACTIVATE_MEASURE,
347 _menuText(_(
"Measure"),
"M"));
350 bool ais_areanotice =
false;
351 if (
g_pAIS && parent->GetShowAIS() && g_bShowAreaNotices) {
354 for (
const auto &target :
g_pAIS->GetAreaNoticeSourcesList()) {
355 auto target_data = target.second;
356 if (!target_data->area_notices.empty()) {
357 for (
auto &ani : target_data->area_notices) {
361 for (Ais8_001_22_SubAreaList::iterator sa =
362 area_notice.sub_areas.begin();
363 sa != area_notice.sub_areas.end(); ++sa) {
365 case AIS8_001_22_SHAPE_CIRCLE: {
366 wxPoint target_point;
369 bbox.Expand(target_point);
370 if (sa->radius_m > 0.0) bbox.EnLarge(sa->radius_m * vp_scale);
373 case AIS8_001_22_SHAPE_RECT:
374 case AIS8_001_22_SHAPE_POLYGON:
375 case AIS8_001_22_SHAPE_POLYLINE: {
376 double lat = sa->latitude;
377 double lon = sa->longitude;
378 for (
int i = 0; i < 4; ++i) {
379 ll_gc_ll(lat, lon, sa->angles[i], sa->dists_m[i] / 1852.0,
381 wxPoint target_point;
383 bbox.Expand(target_point);
387 case AIS8_001_22_SHAPE_SECTOR: {
388 double lat1 = sa->latitude;
389 double lon1 = sa->longitude;
391 wxPoint target_point;
393 bbox.Expand(target_point);
394 for (
int i = 0; i < 18; ++i) {
398 i * (sa->right_bound_deg - sa->left_bound_deg) / 18,
399 sa->radius_m / 1852.0, &lat, &lon);
401 bbox.Expand(target_point);
403 ll_gc_ll(lat1, lon1, sa->right_bound_deg, sa->radius_m / 1852.0,
406 bbox.Expand(target_point);
412 if (bbox.GetValid() && bbox.PointInBox(x, y)) {
413 ais_areanotice =
true;
422 if (parent->GetpCurrentStack())
423 nChartStack = parent->GetpCurrentStack()->nEntry;
425 if (!parent->GetVP().b_quilt) {
426 if (nChartStack > 1) {
427 MenuAppend1(contextMenu, ID_DEF_MENU_MAX_DETAIL, _(
"Max Detail Here"));
428 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_IN,
429 _menuText(_(
"Scale In"),
"Ctrl-Left"));
430 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_OUT,
431 _menuText(_(
"Scale Out"),
"Ctrl-Right"));
434 if ((parent->m_singleChart &&
435 (parent->m_singleChart->GetChartFamily() == CHART_FAMILY_VECTOR)) ||
437 MenuAppend1(contextMenu, ID_DEF_MENU_QUERY, _(
"Object Query") +
"...");
442 parent->m_pQuilt->GetChartAtPix(parent->GetVP(), wxPoint(x, y));
443 if ((pChartTest && (pChartTest->GetChartFamily() == CHART_FAMILY_VECTOR)) ||
445 MenuAppend1(contextMenu, ID_DEF_MENU_QUERY, _(
"Object Query") +
"...");
448 if (!g_bBasicMenus && (nChartStack > 1)) {
449 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_IN,
450 _menuText(_(
"Scale In"),
"Ctrl-Left"));
451 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_OUT,
452 _menuText(_(
"Scale Out"),
"Ctrl-Right"));
458 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
459 bool b_dm_add =
true;
460 if (g_btouch && parent->IsMeasureActive()) b_dm_add =
false;
463 MenuAppend1(contextMenu, ID_DEF_MENU_DROP_WP,
464 _menuText(_(
"Drop Mark"),
"Ctrl-M"));
465 MenuAppend1(contextMenu, ID_DEF_MENU_NEW_RT,
466 _menuText(_(
"New Route..."),
"Ctrl-R"));
470 MenuAppend1(contextMenu, ID_DEF_MENU_MOVE_BOAT_HERE, _(
"Move Boat Here"));
473 if (!g_bBasicMenus && !
g_pRouteMan->GetpActiveRoute() &&
474 (!(seltype & SELTYPE_MARKPOINT) ||
475 (m_pFoundRoutePoint && m_pFoundRoutePoint->
m_bIsInLayer)))
476 MenuAppend1(contextMenu, ID_DEF_MENU_GOTO_HERE, _(
"Navigate To Here"));
479 MenuAppend1(contextMenu, ID_DEF_MENU_GOTOPOSITION,
480 _(
"Center view") +
"...");
482 if (!g_bBasicMenus) {
483 if (parent->GetVP().b_quilt) {
484 if (parent->GetUpMode() == NORTH_UP_MODE) {
485 MenuAppend1(contextMenu, ID_DEF_MENU_COGUP, _(
"Course Up Mode"));
486 if (!std::isnan(
gHdt))
487 MenuAppend1(contextMenu, ID_DEF_MENU_HEADUP, _(
"Heading Up Mode"));
489 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"North Up Mode"));
492 if (parent->m_singleChart &&
493 (fabs(parent->m_singleChart->GetChartSkew()) > .01) && !g_bskew_comp)
494 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"Chart Up Mode"));
496 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"North Up Mode"));
500 if (!g_bBasicMenus) {
501 bool full_toggle_added =
false;
504 MenuAppend1(contextMenu, ID_DEF_MENU_TOGGLE_FULL,
505 _(
"Toggle Full Screen"));
506 full_toggle_added =
true;
509 if (!full_toggle_added) {
511 MenuAppend1(contextMenu, ID_DEF_MENU_TOGGLE_FULL,
512 _(
"Toggle Full Screen"));
518 MenuAppend1(contextMenu, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
521 int pasteBuffer = kml->ParsePasteBuffer();
522 if (pasteBuffer != KML_PASTE_INVALID) {
523 switch (pasteBuffer) {
524 case KML_PASTE_WAYPOINT: {
525 MenuAppend1(contextMenu, ID_PASTE_WAYPOINT, _(
"Paste Waypoint"));
528 case KML_PASTE_ROUTE: {
529 MenuAppend1(contextMenu, ID_PASTE_ROUTE, _(
"Paste Route"));
532 case KML_PASTE_TRACK: {
533 MenuAppend1(contextMenu, ID_PASTE_TRACK, _(
"Paste Track"));
536 case KML_PASTE_ROUTE_TRACK: {
537 MenuAppend1(contextMenu, ID_PASTE_ROUTE, _(
"Paste Route"));
538 MenuAppend1(contextMenu, ID_PASTE_TRACK, _(
"Paste Track"));
545 if (!parent->GetVP().b_quilt && parent->m_singleChart &&
546 (parent->m_singleChart->GetChartType() == CHART_TYPE_CM93COMP)) {
547 MenuAppend1(contextMenu, ID_DEF_MENU_CM93OFFSET_DIALOG,
548 _(
"CM93 Offset Dialog..."));
572 wxMenuItem *subItemChart =
573 contextMenu->AppendSubMenu(subMenuChart, _(
"Chart Groups"));
574 if (g_btouch) contextMenu->AppendSeparator();
576 SetMenuItemFont1(subItemChart);
580 MenuAppend1(subMenuChart, wxID_CANCEL, _(
"temporary"));
582 wxMenuItem *subItem0 = subMenuChart->AppendRadioItem(
583 ID_DEF_MENU_GROUPBASE, _(
"All Active Charts"));
585 SetMenuItemFont1(subItem0);
587 for (
unsigned int i = 0; i <
g_pGroupArray->GetCount(); i++) {
588 subItem0 = subMenuChart->AppendRadioItem(
589 ID_DEF_MENU_GROUPBASE + i + 1,
g_pGroupArray->Item(i)->m_group_name);
590 SetMenuItemFont1(subItem0);
594 subMenuChart->Remove(wxID_CANCEL);
596 subMenuChart->Check(ID_DEF_MENU_GROUPBASE + parent->m_groupIndex,
true);
600 menuFocus = contextMenu;
603 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
605 if (parent->GetShowAIS() &&
606 (seltype & SELTYPE_AISTARGET &&
607 !(GetContextMenuMask() & CONTEXT_MENU_DISABLE_AISTARGET))) {
608 auto myptarget =
g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
609 if (!g_bBasicMenus && myptarget) {
610 name = myptarget->GetFullName();
611 if (name.IsEmpty()) name.Printf(
"%d", m_FoundAIS_MMSI);
612 name.Prepend(
" ( ").Append(
" )");
614 name = wxEmptyString;
615 menuAIS =
new wxMenu(_(
"AIS") + name);
616 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_QUERY, _(
"Target Query..."));
617 if (myptarget && myptarget->bCPA_Valid &&
618 (myptarget->n_alert_state != AIS_ALERT_SET)) {
619 if (myptarget->b_show_AIS_CPA)
620 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_CPA, _(
"Hide Target CPA"));
622 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_CPA, _(
"Show Target CPA"));
624 MenuAppend1(menuAIS, ID_DEF_MENU_AISTARGETLIST, _(
"Target List..."));
625 if (myptarget->Class != AIS_METEO ) {
626 if (myptarget && !myptarget->b_PersistTrack) {
627 if (myptarget->b_show_track)
628 MenuAppend1(menuAIS, ID_DEF_MENU_AISSHOWTRACK,
629 _(
"Hide Target Track"));
631 MenuAppend1(menuAIS, ID_DEF_MENU_AISSHOWTRACK,
632 _(
"Show Target Track"));
636 MenuAppend1(menuAIS, ID_DEF_MENU_COPY_MMSI, _(
"Copy Target MMSI"));
637 menuAIS->AppendSeparator();
639 if (!parent->GetVP().b_quilt) {
640 if ((parent->m_singleChart &&
641 (parent->m_singleChart->GetChartFamily() ==
642 CHART_FAMILY_VECTOR))) {
643 MenuAppend1(menuAIS, ID_DEF_MENU_QUERY, _(
"Object Query..."));
648 parent->m_pQuilt->GetChartAtPix(parent->GetVP(), wxPoint(x, y));
650 (pChartTest->GetChartFamily() == CHART_FAMILY_VECTOR))) {
651 MenuAppend1(menuAIS, ID_DEF_MENU_QUERY, _(
"Object Query..."));
657 bool enable_list =
true;
659 double char_x = gFrame->GetSize().x / gFrame->GetCharWidth();
660 double char_y = gFrame->GetSize().y / gFrame->GetCharWidth();
661 double char_min = wxMin(char_x, char_y);
662 if (char_min < 100) enable_list =
false;
666 if (wxMin(size_x, size_y) < 100)
670 MenuAppend1(contextMenu, ID_DEF_MENU_AISTARGETLIST,
671 _(
"AIS target list") +
"...");
673 wxString nextCPAstatus = g_bCPAWarn ? _(
"Hide") : _(
"Show");
674 MenuAppend1(contextMenu, ID_DEF_MENU_AIS_CPAWARNING,
675 _menuText(nextCPAstatus +
" " + _(
"CPA alarm "),
"W"));
679 if (g_enable_root_menu_debug) {
680 wxMenuItem *subItemDebug =
681 contextMenu->AppendSubMenu(subMenuDebug, _(
"Debug"));
682 if (g_btouch) contextMenu->AppendSeparator();
683 SetMenuItemFont1(subItemDebug);
686 if (seltype & SELTYPE_ROUTESEGMENT &&
687 !(GetContextMenuMask() & CONTEXT_MENU_DISABLE_ROUTE)) {
688 if (!g_bBasicMenus && m_pSelectedRoute) {
690 if (name.IsEmpty()) name = _(
"Unnamed Route");
691 name.Prepend(
" ( ").Append(
" )");
693 name = wxEmptyString;
695 if (m_pSelectedRoute && m_pSelectedRoute->
m_bIsInLayer) blay =
true;
698 menuRoute =
new wxMenu(_(
"Layer Route") + name);
699 MenuAppend1(menuRoute, ID_RT_MENU_PROPERTIES, _(
"Properties") +
"...");
700 if (m_pSelectedRoute) {
701 if (m_pSelectedRoute->IsActive()) {
702 int indexActive = m_pSelectedRoute->GetIndexOf(
704 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints()) {
705 MenuAppend1(menuRoute, ID_RT_MENU_ACTNXTPOINT,
706 _(
"Activate Next Waypoint"));
708 MenuAppend1(menuRoute, ID_RT_MENU_DEACTIVATE, _(
"Deactivate"));
709 MenuAppend1(menuRoute, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
711 MenuAppend1(menuRoute, ID_RT_MENU_ACTIVATE, _(
"Activate"));
715 menuRoute =
new wxMenu(_(
"Route") + name);
716 MenuAppend1(menuRoute, ID_RT_MENU_PROPERTIES, _(
"Properties") +
"...");
717 if (m_pSelectedRoute) {
718 if (m_pSelectedRoute->IsActive()) {
719 int indexActive = m_pSelectedRoute->GetIndexOf(
721 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints()) {
722 MenuAppend1(menuRoute, ID_RT_MENU_ACTNXTPOINT,
723 _(
"Activate Next Waypoint"));
725 MenuAppend1(menuRoute, ID_RT_MENU_DEACTIVATE, _(
"Deactivate"));
726 MenuAppend1(menuRoute, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
728 MenuAppend1(menuRoute, ID_RT_MENU_ACTIVATE, _(
"Activate"));
731 MenuAppend1(menuRoute, ID_RT_MENU_INSERT, _(
"Insert Waypoint"));
732 MenuAppend1(menuRoute, ID_RT_MENU_APPEND, _(
"Append Waypoint"));
733 if (!(seltype & SELTYPE_ROUTEPOINT) && m_pSelectedRoute) {
734 m_SelectedIdx = m_pSelectedRoute->GetIndexOf(m_pFoundRoutePoint);
735 if (m_SelectedIdx > 1 &&
736 m_SelectedIdx < m_pSelectedRoute->GetnPoints() - 1)
737 MenuAppend1(menuRoute, ID_RT_MENU_SPLIT_LEG, _(
"Split around Leg"));
739 MenuAppend1(menuRoute, ID_RT_MENU_COPY, _(
"Copy as KML") +
"...");
740 MenuAppend1(menuRoute, ID_RT_MENU_DELETE, _(
"Delete") +
"...");
741 MenuAppend1(menuRoute, ID_RT_MENU_REVERSE, _(
"Reverse..."));
742 if (m_pSelectedRoute) {
743 if (m_pSelectedRoute->AreWaypointNamesVisible())
744 MenuAppend1(menuRoute, ID_RT_MENU_SHOWNAMES,
745 _(
"Hide Waypoint Names"));
747 MenuAppend1(menuRoute, ID_RT_MENU_SHOWNAMES,
748 _(
"Show Waypoint Names"));
750 MenuAppend1(menuRoute, ID_RT_MENU_RESEQUENCE,
751 _(
"Resequence Waypoints..."));
754 wxString port = parent->FindValidUploadPort();
755 parent->m_active_upload_port = port;
756 wxString item = _(
"Send to GPS");
757 if (!port.IsEmpty()) {
762 MenuAppend1(menuRoute, ID_RT_MENU_SENDTOGPS, item);
764 if (!port.IsEmpty()) {
765 wxString item = _(
"Send to new GPS");
766 MenuAppend1(menuRoute, ID_RT_MENU_SENDTONEWGPS, item);
769 wxString itemstp = SYMBOL_STP_TITLE;
770 MenuAppend1(menuRoute, ID_RT_MENU_SENDTOPEER, itemstp);
773 if (menuFocus != menuAIS) menuFocus = menuRoute;
776 if (seltype & SELTYPE_TRACKSEGMENT &&
777 !(GetContextMenuMask() & CONTEXT_MENU_DISABLE_TRACK)) {
778 name = wxEmptyString;
779 if (!g_bBasicMenus && m_pSelectedTrack)
780 name =
" ( " + m_pSelectedTrack->GetName(
true) +
" )";
782 name = wxEmptyString;
784 if (m_pSelectedTrack && m_pSelectedTrack->m_bIsInLayer) blay =
true;
787 menuTrack =
new wxMenu(_(
"Layer Track") + name);
788 MenuAppend1(menuTrack, ID_TK_MENU_PROPERTIES, _(
"Properties") +
"...");
790 menuTrack =
new wxMenu(_(
"Track") + name);
791 MenuAppend1(menuTrack, ID_TK_MENU_PROPERTIES, _(
"Properties") +
"...");
792 MenuAppend1(menuTrack, ID_TK_MENU_COPY, _(
"Copy as KML"));
793 MenuAppend1(menuTrack, ID_TK_MENU_DELETE, _(
"Delete") +
"...");
796 wxString itemstp = SYMBOL_STP_TITLE;
797 MenuAppend1(menuTrack, ID_TK_MENU_SENDTOPEER, itemstp);
800 if (menuFocus != menuAIS) menuFocus = menuTrack;
803 if (seltype & SELTYPE_ROUTEPOINT &&
804 !(GetContextMenuMask() & CONTEXT_MENU_DISABLE_WAYPOINT)) {
805 if (!g_bBasicMenus && m_pFoundRoutePoint) {
806 name = m_pFoundRoutePoint->GetName();
807 if (name.IsEmpty()) name = _(
"Unnamed Waypoint");
808 name.Prepend(
" ( ").Append(
" )");
810 name = wxEmptyString;
812 if (m_pFoundRoutePoint && m_pFoundRoutePoint->
m_bIsInLayer) blay =
true;
815 menuWaypoint =
new wxMenu(_(
"Layer Waypoint") + name);
816 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES, _(
"Properties") +
"...");
818 if (m_pSelectedRoute && m_pSelectedRoute->IsActive())
819 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTPOINT, _(
"Activate"));
821 menuWaypoint =
new wxMenu(_(
"Waypoint") + name);
822 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES, _(
"Properties") +
"...");
823 if (m_pSelectedRoute && m_pSelectedRoute->IsActive()) {
825 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTPOINT, _(
"Activate"));
828 if (m_pSelectedRoute && m_pSelectedRoute->IsActive()) {
830 int indexActive = m_pSelectedRoute->GetIndexOf(
832 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints())
833 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTNXTPOINT,
834 _(
"Activate Next Waypoint"));
837 if (m_pSelectedRoute && m_pSelectedRoute->GetnPoints() > 2) {
838 MenuAppend1(menuWaypoint, ID_RT_MENU_REMPOINT, _(
"Remove from Route"));
840 m_SelectedIdx = m_pSelectedRoute->GetIndexOf(m_pFoundRoutePoint);
841 if (m_SelectedIdx > 1 && m_SelectedIdx < m_pSelectedRoute->GetnPoints())
842 MenuAppend1(menuWaypoint, ID_RT_MENU_SPLIT_WPT,
843 _(
"Split Route at Waypoint"));
846 MenuAppend1(menuWaypoint, ID_WPT_MENU_COPY, _(
"Copy as KML"));
848 if (m_pFoundRoutePoint && m_pFoundRoutePoint->GetIconName() !=
"mob")
849 MenuAppend1(menuWaypoint, ID_RT_MENU_DELPOINT, _(
"Delete"));
852 wxString port = parent->FindValidUploadPort();
853 parent->m_active_upload_port = port;
854 wxString item = _(
"Send to GPS");
855 if (!port.IsEmpty()) {
860 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOGPS, item);
862 if (!port.IsEmpty()) {
863 wxString item = _(
"Send to new GPS");
864 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTONEWGPS, item);
867 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOPEER,
872 if (menuFocus != menuAIS) menuFocus = menuWaypoint;
875 if (seltype & SELTYPE_MARKPOINT &&
876 !(GetContextMenuMask() & CONTEXT_MENU_DISABLE_WAYPOINT)) {
877 if (!g_bBasicMenus && m_pFoundRoutePoint) {
878 name = m_pFoundRoutePoint->GetName();
879 if (name.IsEmpty()) name = _(
"Unnamed Mark");
880 name.Prepend(
" ( ").Append(
" )");
882 name = wxEmptyString;
884 if (m_pFoundRoutePoint && m_pFoundRoutePoint->
m_bIsInLayer) blay =
true;
887 menuWaypoint =
new wxMenu(_(
"Layer Waypoint") + name);
888 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES, _(
"Properties") +
"...");
890 menuWaypoint =
new wxMenu(_(
"Mark") + name);
891 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES, _(
"Properties") +
"...");
894 MenuAppend1(menuWaypoint, ID_WP_MENU_GOTO, _(
"Navigate To This"));
896 MenuAppend1(menuWaypoint, ID_WPT_MENU_COPY, _(
"Copy as KML"));
898 if (m_pFoundRoutePoint && m_pFoundRoutePoint->GetIconName() !=
"mob")
899 MenuAppend1(menuWaypoint, ID_WP_MENU_DELPOINT, _(
"Delete"));
902 wxString port = parent->FindValidUploadPort();
903 parent->m_active_upload_port = port;
904 wxString item = _(
"Send to GPS");
905 if (!port.IsEmpty()) {
910 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOGPS, item);
912 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOPEER,
918 MenuAppend1(menuWaypoint, ID_WP_MENU_CLEAR_ANCHORWATCH,
919 _(
"Clear Anchor Watch"));
921 if (m_pFoundRoutePoint && !(m_pFoundRoutePoint->
m_bIsInLayer) &&
925 DistanceBearingMercator(m_pFoundRoutePoint->m_lat,
926 m_pFoundRoutePoint->m_lon,
gLat,
gLon, &brg,
928 if (dist * 1852. <= g_nAWMax)
929 MenuAppend1(menuWaypoint, ID_WP_MENU_SET_ANCHORWATCH,
930 _(
"Set Anchor Watch"));
935 if (menuFocus != menuAIS) menuFocus = menuWaypoint;
939 AddPluginContextMenuItems(contextMenu, menuRoute, menuTrack, menuWaypoint,
943 enum { WPMENU = 1, TKMENU = 2, RTMENU = 4, MMMENU = 8 };
945 if (!g_bBasicMenus && menuFocus != contextMenu) {
946 if (global_color_scheme != GLOBAL_COLOR_SCHEME_DUSK &&
947 global_color_scheme != GLOBAL_COLOR_SCHEME_NIGHT) {
948 menuFocus->AppendSeparator();
951 wxMenuItem *subMenu1;
952 if (menuWaypoint && menuFocus != menuWaypoint) {
954 menuFocus->AppendSubMenu(menuWaypoint, menuWaypoint->GetTitle());
955 SetMenuItemFont1(subMenu1);
958 menuWaypoint->SetTitle(wxEmptyString);
961 if (menuTrack && menuFocus != menuTrack) {
962 subMenu1 = menuFocus->AppendSubMenu(menuTrack, menuTrack->GetTitle());
963 SetMenuItemFont1(subMenu1);
966 menuTrack->SetTitle(wxEmptyString);
969 if (menuRoute && menuFocus != menuRoute) {
970 subMenu1 = menuFocus->AppendSubMenu(menuRoute, menuRoute->GetTitle());
971 SetMenuItemFont1(subMenu1);
974 menuRoute->SetTitle(wxEmptyString);
977 subMenu1 = menuFocus->AppendSubMenu(contextMenu, _(
"Main Menu"));
978 SetMenuItemFont1(subMenu1);
982 if (!subMenuChart->GetMenuItemCount()) contextMenu->Destroy(subItemChart);
987 if (seltype & SELTYPE_TIDEPOINT) {
988 menuFocus->AppendSeparator();
990 MenuAppend1(menuFocus, ID_DEF_MENU_TIDEINFO, _(
"Show Tide Information"));
993 if (seltype & SELTYPE_CURRENTPOINT) {
994 if (!bsep) menuFocus->AppendSeparator();
995 MenuAppend1(menuFocus, ID_DEF_MENU_CURRENTINFO,
996 _(
"Show Current Information"));
1002 androidEnableBackButton(
false);
1003 androidEnableOptionsMenu(
false);
1011 parent->PopupMenu(menuFocus, x, y);
1014 androidEnableBackButton(
true);
1015 androidEnableOptionsMenu(
true);
1022 if (!(sub_menu & MMMENU))
delete contextMenu;
1023 if (!(sub_menu & RTMENU))
delete menuRoute;
1024 if (!(sub_menu & TKMENU))
delete menuTrack;
1025 if (!(sub_menu & WPMENU))
delete menuWaypoint;
1028void CanvasMenuHandler::AddPluginContextMenuItems(wxMenu *contextMenu,
1031 wxMenu *menuWaypoint,
1037 ArrayOfPlugInMenuItems item_array =
1040 for (
unsigned int i = 0; i < item_array.GetCount(); i++) {
1042 if (!pimis->b_viz)
continue;
1044 wxMenu *submenu = NULL;
1045 if (pimis->pmenu_item->GetSubMenu()) {
1047 auto submenu_proto = pimis->pmenu_item->GetSubMenu();
1048 submenu =
new wxMenu();
1049 const wxMenuItemList &items =
1050 pimis->pmenu_item->GetSubMenu()->GetMenuItems();
1051 for (wxMenuItemList::const_iterator it = items.begin(); it != items.end();
1053 int id = (*it)->GetId();
1055 new wxMenuItem(submenu,
id, (*it)->GetItemLabelText(),
1056 (*it)->GetHelp(), (*it)->GetKind());
1059 psmi->SetFont(m_scaledFont);
1064 psmi->SetFont(sFont);
1067 PrepareMenuItem(psmi);
1068 submenu->Append(psmi);
1069 psmi->Check((*it)->IsChecked());
1073 wxMenuItem *pmi =
new wxMenuItem(
1074 contextMenu, pimis->id, pimis->pmenu_item->GetItemLabelText(),
1075 pimis->pmenu_item->GetHelp(), pimis->pmenu_item->GetKind(), submenu);
1077 pmi->SetFont(m_scaledFont);
1082 pmi->SetFont(sFont);
1085 PrepareMenuItem(pmi);
1087 wxMenu *dst = contextMenu;
1088 if (pimis->m_in_menu ==
"Waypoint")
1090 else if (pimis->m_in_menu ==
"Route")
1092 else if (pimis->m_in_menu ==
"Track")
1094 else if (pimis->m_in_menu ==
"AIS")
1099 dst->Enable(pimis->id, !pimis->b_grey);
1104void CanvasMenuHandler::PopupMenuHandler(wxCommandEvent &event) {
1111 bool dupFirstWpt =
true, showRPD;
1116 switch (event.GetId()) {
1117 case ID_DEF_MENU_MAX_DETAIL:
1120 parent->ClearbFollow();
1122 parent->parent_frame->DoChartUpdate();
1124 parent->SelectChartFromStack(0,
false, CHART_TYPE_DONTCARE,
1125 CHART_FAMILY_RASTER);
1128 case ID_DEF_MENU_SCALE_IN:
1129 parent->DoCanvasStackDelta(-1);
1132 case ID_DEF_MENU_SCALE_OUT:
1133 parent->DoCanvasStackDelta(1);
1137 parent->undo->UndoLastAction();
1138 parent->InvalidateGL();
1139 parent->Refresh(
false);
1143 parent->undo->RedoNextAction();
1144 parent->InvalidateGL();
1145 parent->Refresh(
false);
1148 case ID_DEF_MENU_MOVE_BOAT_HERE:
1151 gFrame->UpdateStatusBar();
1154 case ID_DEF_MENU_GOTO_HERE: {
1156 wxEmptyString, wxEmptyString);
1157 pSelect->AddSelectableRoutePoint(zlat, zlon, pWP_dest);
1160 wxEmptyString, wxEmptyString);
1166 temp_route->AddPoint(pWP_src);
1167 temp_route->AddPoint(pWP_dest);
1170 pWP_dest, temp_route);
1186 case ID_DEF_MENU_DROP_WP: {
1188 wxEmptyString, wxEmptyString);
1190 pSelect->AddSelectableRoutePoint(zlat, zlon, pWP);
1191 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
1196 if (RouteManagerDialog::getInstanceFlag()) {
1197 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1198 pRouteManagerDialog->UpdateWptListCtrl();
1202 parent->undo->BeforeUndoableAction(Undo_CreateWaypoint, pWP,
1203 Undo_HasParent, NULL);
1204 parent->undo->AfterUndoableAction(NULL);
1205 gFrame->RefreshAllCanvas(
false);
1206 gFrame->InvalidateAllGL();
1207 g_FlushNavobjChanges =
true;
1211 case ID_DEF_MENU_NEW_RT: {
1212 parent->StartRoute();
1216 case ID_DEF_MENU_AISTARGETLIST:
1217 parent->ShowAISTargetList();
1220 case ID_DEF_MENU_AIS_CPAWARNING:
1221 parent->ToggleCPAWarn();
1224 case ID_WP_MENU_GOTO: {
1226 wxEmptyString, wxEmptyString);
1232 temp_route->AddPoint(pWP_src);
1233 temp_route->AddPoint(m_pFoundRoutePoint);
1234 m_pFoundRoutePoint->SetShared(
true);
1236 pSelect->AddSelectableRouteSegment(
gLat,
gLon, m_pFoundRoutePoint->m_lat,
1237 m_pFoundRoutePoint->m_lon, pWP_src,
1238 m_pFoundRoutePoint, temp_route);
1240 wxString name = m_pFoundRoutePoint->GetName();
1241 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
1242 wxString rteName = _(
"Go to ");
1243 rteName.Append(name);
1257 case ID_DEF_MENU_COGUP:
1258 parent->SetUpMode(COURSE_UP_MODE);
1261 case ID_DEF_MENU_HEADUP:
1262 parent->SetUpMode(HEAD_UP_MODE);
1265 case ID_DEF_MENU_NORTHUP:
1266 parent->SetUpMode(NORTH_UP_MODE);
1269 case ID_DEF_MENU_TOGGLE_FULL:
1270 gFrame->ToggleFullScreen();
1273 case ID_DEF_MENU_GOTOPOSITION:
1282 case ID_WP_MENU_DELPOINT: {
1291 if (m_pFoundRoutePoint && !(m_pFoundRoutePoint->
m_bIsInLayer) &&
1292 (m_pFoundRoutePoint->GetIconName() !=
"mob")) {
1296 wxArrayPtrVoid *proute_array =
1299 pWayPointMan->DestroyWaypoint(m_pFoundRoutePoint);
1300 delete proute_array;
1302 parent->undo->BeforeUndoableAction(
1303 Undo_DeleteWaypoint, m_pFoundRoutePoint, Undo_IsOrphanded,
1305 NavObj_dB::GetInstance().DeleteRoutePoint(m_pFoundRoutePoint);
1306 pSelect->DeleteSelectablePoint(m_pFoundRoutePoint,
1307 SELTYPE_ROUTEPOINT);
1308 if (NULL != pWayPointMan)
1310 parent->undo->AfterUndoableAction(NULL);
1317 if (RouteManagerDialog::getInstanceFlag()) {
1318 if (pRouteManagerDialog) {
1319 if (pRouteManagerDialog->IsShown())
1320 pRouteManagerDialog->UpdateWptListCtrl();
1324 gFrame->RefreshAllCanvas(
false);
1325 gFrame->InvalidateAllGL();
1329 case ID_WP_MENU_PROPERTIES:
1330 parent->ShowMarkPropertiesDialog(m_pFoundRoutePoint);
1333 case ID_WP_MENU_CLEAR_ANCHORWATCH: {
1334 wxString guid = wxEmptyString;
1344 if (!guid.IsEmpty()) {
1347 wxString msg_id(
"OCPN_ANCHOR_WATCH_CLEARED");
1348 SendJSONMessageToAllPlugins(msg_id, v);
1353 case ID_WP_MENU_SET_ANCHORWATCH: {
1354 wxString guid = wxEmptyString;
1360 nn = m_pFoundRoutePoint->GetName();
1362 nn.Printf(
"%d m", g_nAWDefault);
1363 m_pFoundRoutePoint->SetName(nn);
1370 nn = m_pFoundRoutePoint->GetName();
1372 nn.Printf(
"%d m", g_nAWDefault);
1373 m_pFoundRoutePoint->SetName(nn);
1376 if (!guid.IsEmpty()) {
1379 wxString msg_id(
"OCPN_ANCHOR_WATCH_SET");
1380 SendJSONMessageToAllPlugins(msg_id, v);
1385 case ID_DEF_MENU_ACTIVATE_MEASURE:
1386 parent->StartMeasureRoute();
1389 case ID_DEF_MENU_DEACTIVATE_MEASURE:
1390 parent->CancelMeasureRoute();
1392 parent->InvalidateGL();
1393 parent->Refresh(
false);
1396 case ID_DEF_MENU_CM93OFFSET_DIALOG: {
1402 if (!parent->GetVP().b_quilt && parent->m_singleChart &&
1403 (parent->m_singleChart->GetChartType() == CHART_TYPE_CM93COMP)) {
1415 case ID_DEF_MENU_QUERY: {
1416 parent->ShowObjectQueryWindow(popx, popy, zlat, zlon);
1419 case ID_DEF_MENU_AIS_QUERY: {
1420 ShowAISTargetQueryDialog(parent, m_FoundAIS_MMSI);
1424 case ID_DEF_MENU_AIS_CPA: {
1425 auto myptarget =
g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
1426 if (myptarget) myptarget->Toggle_AIS_CPA();
1430 case ID_DEF_MENU_AISSHOWTRACK: {
1431 auto myptarget =
g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
1432 if (myptarget) myptarget->ToggleShowTrack();
1436 case ID_DEF_MENU_COPY_MMSI: {
1438 if (wxTheClipboard->Open()) {
1439 wxTheClipboard->SetData(
1440 new wxTextDataObject(wxString::Format(
"%09d", m_FoundAIS_MMSI)));
1441 wxTheClipboard->Close();
1446 case ID_DEF_MENU_QUILTREMOVE: {
1447 if (parent->GetVP().b_quilt) {
1448 int dbIndex = parent->m_pQuilt->GetChartdbIndexAtPix(
1449 parent->GetVP(), wxPoint(popx, popy));
1450 parent->RemoveChartFromQuilt(dbIndex);
1458 case ID_DEF_MENU_CURRENTINFO: {
1459 parent->
DrawTCWindow(popx, popy, (
void *)m_pIDXCandidate);
1460 parent->Refresh(
false);
1465 case ID_DEF_MENU_TIDEINFO: {
1466 parent->
DrawTCWindow(popx, popy, (
void *)m_pIDXCandidate);
1467 parent->Refresh(
false);
1472 case ID_DGB_MENU_NMEA_WINDOW:
1474 m_nmea_log->Raise();
1477 case ID_RT_MENU_REVERSE: {
1481 OCPNMessageBox(parent,
g_pRouteMan->GetRouteReverseMessage(),
1482 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1484 if (ask_return != wxID_CANCEL) {
1485 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1486 m_pSelectedRoute->Reverse(ask_return == wxID_YES);
1487 pSelect->AddAllSelectableRouteSegments(m_pSelectedRoute);
1489 NavObj_dB::GetInstance().UpdateRoute(m_pSelectedRoute);
1495 gFrame->InvalidateAllGL();
1496 gFrame->RefreshAllCanvas();
1501 case ID_RT_MENU_SHOWNAMES: {
1502 if (m_pSelectedRoute) {
1503 m_pSelectedRoute->ShowWaypointNames(
1504 !m_pSelectedRoute->AreWaypointNamesVisible());
1510 case ID_RT_MENU_RESEQUENCE: {
1511 if (m_pSelectedRoute) {
1515 OCPNMessageBox(parent,
g_pRouteMan->GetRouteResequenceMessage(),
1516 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1518 if (ask_return != wxID_CANCEL) {
1519 m_pSelectedRoute->RenameRoutePoints();
1522 gFrame->InvalidateAllGL();
1523 gFrame->RefreshAllCanvas();
1529 case ID_RT_MENU_DELETE: {
1530 bool confirmed = RouteGui::OnDelete(parent);
1533 if (
g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute)
1538 NavObj_dB::GetInstance().DeleteRoute(m_pSelectedRoute);
1541 if (RouteManagerDialog::getInstanceFlag()) {
1542 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1543 pRouteManagerDialog->UpdateRouteListCtrl();
1551 parent->undo->InvalidateUndo();
1553 gFrame->InvalidateAllGL();
1554 gFrame->RefreshAllCanvas();
1559 case ID_RT_MENU_ACTIVATE: {
1566 if (m_pSelectedRoute) {
1571 best_point = m_pSelectedRoute->GetPoint(2);
1580 case ID_RT_MENU_DEACTIVATE:
1586 case ID_RT_MENU_INSERT: {
1588 bool rename =
false;
1589 m_pSelectedRoute->InsertPointAfter(m_pFoundRoutePoint, zlat, zlon,
1592 pSelect->DeleteAllSelectableRoutePoints(m_pSelectedRoute);
1593 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1595 pSelect->AddAllSelectableRouteSegments(m_pSelectedRoute);
1596 pSelect->AddAllSelectableRoutePoints(m_pSelectedRoute);
1609 NavObj_dB::GetInstance().UpdateRoute(m_pSelectedRoute);
1618 case ID_RT_MENU_APPEND:
1622 parent->m_pMouseRoute = m_pSelectedRoute;
1623 parent->m_routeState = m_pSelectedRoute->GetnPoints() + 1;
1625 m_pSelectedRoute->GetnPoints();
1626 parent->m_pMouseRoute->SetHiLite(50);
1628 pLast = m_pSelectedRoute->GetLastPoint();
1630 parent->m_prev_rlat = pLast->m_lat;
1631 parent->m_prev_rlon = pLast->m_lon;
1632 parent->m_prev_pMousePoint = pLast;
1634 parent->m_bAppendingRoute =
true;
1636 parent->SetCursor(*parent->pCursorPencil);
1638 androidSetRouteAnnunciator(
true);
1641 parent->HideGlobalToolbar();
1645 case ID_RT_MENU_SPLIT_LEG:
1647 dupFirstWpt =
false;
1648 case ID_RT_MENU_SPLIT_WPT:
1652 if (
g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute)
1655 m_pHead =
new Route();
1656 m_pTail =
new Route();
1657 m_pHead->CloneRoute(m_pSelectedRoute, 1, m_SelectedIdx, _(
"_A"));
1658 m_pTail->CloneRoute(m_pSelectedRoute, m_SelectedIdx + splitMode,
1659 m_pSelectedRoute->GetnPoints(), _(
"_B"), dupFirstWpt);
1661 NavObj_dB::GetInstance().InsertRoute(m_pHead);
1664 NavObj_dB::GetInstance().InsertRoute(m_pTail);
1666 NavObj_dB::GetInstance().DeleteRoute(m_pSelectedRoute);
1668 pSelect->DeleteAllSelectableRoutePoints(m_pSelectedRoute);
1669 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1671 pSelect->AddAllSelectableRouteSegments(m_pTail);
1672 pSelect->AddAllSelectableRoutePoints(m_pTail);
1673 pSelect->AddAllSelectableRouteSegments(m_pHead);
1674 pSelect->AddAllSelectableRoutePoints(m_pHead);
1680 if (RouteManagerDialog::getInstanceFlag() && pRouteManagerDialog &&
1681 (pRouteManagerDialog->IsShown()))
1682 pRouteManagerDialog->UpdateRouteListCtrl();
1685 case ID_RT_MENU_COPY:
1686 if (m_pSelectedRoute) Kml::CopyRouteToClipboard(m_pSelectedRoute);
1689 case ID_TK_MENU_COPY:
1690 if (m_pSelectedTrack) Kml::CopyTrackToClipboard(m_pSelectedTrack);
1693 case ID_WPT_MENU_COPY:
1694 if (m_pFoundRoutePoint) Kml::CopyWaypointToClipboard(m_pFoundRoutePoint);
1697 case ID_WPT_MENU_SENDTOGPS:
1698 if (m_pFoundRoutePoint) {
1699 if (parent->m_active_upload_port.Length())
1701 .SendToGPS(parent->m_active_upload_port.BeforeFirst(
' '), NULL);
1704 dlg.SetWaypoint(m_pFoundRoutePoint);
1708 dlg.Create(NULL, -1, _(
"Send to GPS") +
"...",
"");
1714 case ID_WPT_MENU_SENDTONEWGPS:
1715 if (m_pFoundRoutePoint) {
1717 dlg.SetWaypoint(m_pFoundRoutePoint);
1719 dlg.Create(NULL, -1, _(
"Send to GPS") +
"...",
"");
1724 case ID_WPT_MENU_SENDTOPEER:
1725 if (m_pFoundRoutePoint) {
1727 dlg.SetWaypoint(m_pFoundRoutePoint);
1732 MdnsCache::GetInstance().
Validate();
1733 if (MdnsCache::GetInstance().GetCache().empty())
1734 dlg.SetScanOnCreate(
true);
1737 dlg.Create(NULL, -1, _(
"Send Waypoint to OpenCPN Peer") +
"...",
"");
1742 case ID_RT_MENU_SENDTOGPS:
1743 if (m_pSelectedRoute) {
1744 if (parent->m_active_upload_port.Length())
1746 .SendToGPS(parent->m_active_upload_port.BeforeFirst(
' '),
true,
1750 dlg.SetRoute(m_pSelectedRoute);
1752 dlg.Create(NULL, -1, _(
"Send to GPS") +
"...",
"");
1758 case ID_RT_MENU_SENDTONEWGPS:
1759 if (m_pSelectedRoute) {
1761 dlg.SetRoute(m_pSelectedRoute);
1763 dlg.Create(NULL, -1, _(
"Send to GPS") +
"...",
"");
1768 case ID_RT_MENU_SENDTOPEER:
1769 if (m_pSelectedRoute) {
1771 dlg.SetRoute(m_pSelectedRoute);
1776 MdnsCache::GetInstance().
Validate();
1777 if (MdnsCache::GetInstance().GetCache().empty())
1778 dlg.SetScanOnCreate(
true);
1781 dlg.Create(NULL, -1, _(
"Send Route to OpenCPN Peer") +
"...",
"");
1786 case ID_PASTE_WAYPOINT:
1787 pupHandler_PasteWaypoint();
1790 case ID_PASTE_ROUTE:
1791 pupHandler_PasteRoute();
1794 case ID_PASTE_TRACK:
1795 pupHandler_PasteTrack();
1798 case ID_RT_MENU_DELPOINT:
1799 if (m_pSelectedRoute) {
1802 pWayPointMan->DestroyWaypoint(m_pFoundRoutePoint);
1807 if (
g_pRouteMan->IsRouteValid(m_pSelectedRoute)) {
1813 if (RouteManagerDialog::getInstanceFlag()) {
1814 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1815 pRouteManagerDialog->UpdateWptListCtrl();
1816 pRouteManagerDialog->UpdateRouteListCtrl();
1820 gFrame->InvalidateAllGL();
1821 gFrame->RefreshAllCanvas(
true);
1826 case ID_RT_MENU_REMPOINT:
1827 if (m_pSelectedRoute) {
1829 g_pRouteMan->RemovePointFromRoute(m_pFoundRoutePoint, m_pSelectedRoute,
1830 parent->m_routeState);
1831 gFrame->InvalidateAllGL();
1832 gFrame->RefreshAllCanvas();
1836 case ID_RT_MENU_ACTPOINT:
1837 if (
g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute) {
1844 case ID_RT_MENU_DEACTPOINT:
1847 case ID_RT_MENU_ACTNXTPOINT:
1848 if (
g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute) {
1855 case ID_RT_MENU_PROPERTIES: {
1856 parent->ShowRoutePropertiesDialog(_(
"Route Properties"),
1861 case ID_TK_MENU_PROPERTIES: {
1862 parent->ShowTrackPropertiesDialog(m_pSelectedTrack);
1866 case ID_TK_MENU_DELETE: {
1867 int dlg_return = wxID_YES;
1868 if (g_bConfirmObjectDelete) {
1869 dlg_return = OCPNMessageBox(
1870 parent, _(
"Are you sure you want to delete this track?"),
1871 _(
"OpenCPN Track Delete"),
1872 (
long)wxYES_NO | wxCANCEL | wxYES_DEFAULT);
1875 if (dlg_return == wxID_YES) {
1877 m_pSelectedTrack = parent->parent_frame->TrackOff();
1878 g_pAIS->DeletePersistentTrack(m_pSelectedTrack);
1880 NavObj_dB::GetInstance().DeleteTrack(m_pSelectedTrack);
1881 RoutemanGui(*g_pRouteMan).DeleteTrack(m_pSelectedTrack);
1889 if (RoutePropDlgImpl::getInstanceFlag() && pRouteManagerDialog &&
1890 pRouteManagerDialog->IsShown()) {
1891 pRouteManagerDialog->UpdateTrkListCtrl();
1892 pRouteManagerDialog->UpdateRouteListCtrl();
1894 gFrame->InvalidateAllGL();
1895 gFrame->RefreshAllCanvas();
1900 case ID_TK_MENU_SENDTOPEER:
1901 if (m_pSelectedTrack) {
1903 dlg.SetTrack(m_pSelectedTrack);
1908 MdnsCache::GetInstance().
Validate();
1909 if (MdnsCache::GetInstance().GetCache().empty())
1910 dlg.SetScanOnCreate(
true);
1913 dlg.Create(NULL, -1, _(
"Send Track to OpenCPN Peer") +
"...",
"");
1918 case ID_RC_MENU_SCALE_IN:
1919 parent->parent_frame->DoStackDown(parent);
1921 parent->WarpPointer(r.x, r.y);
1924 case ID_RC_MENU_SCALE_OUT:
1925 parent->parent_frame->DoStackUp(parent);
1927 parent->WarpPointer(r.x, r.y);
1930 case ID_RC_MENU_ZOOM_IN:
1933 parent->WarpPointer(r.x, r.y);
1936 case ID_RC_MENU_ZOOM_OUT:
1939 parent->WarpPointer(r.x, r.y);
1942 case ID_RC_MENU_FINISH:
1943 parent->FinishRoute();
1945 parent->Refresh(
false);
1946 g_FlushNavobjChanges =
true;
1949 case ID_DEF_ZERO_XTE:
1956 ArrayOfPlugInMenuItems item_array =
1959 for (
unsigned int i = 0; i < item_array.GetCount(); i++) {
1961 int target_id = pimis->id;
1964 if (pimis->pmenu_item->GetSubMenu()) {
1965 const wxMenuItemList &items =
1966 pimis->pmenu_item->GetSubMenu()->GetMenuItems();
1967 for (wxMenuItemList::const_iterator it = items.begin();
1968 it != items.end(); ++it) {
1969 if ((*it)->GetId() ==
event.GetId()) {
1970 target_id = (*it)->GetId();
1976 if (pimis->m_pplugin && (target_id == event.GetId())) {
1977 if (pimis->extended) {
1978 std::string object_type;
1979 std::string object_ident;
1981 if ((pimis->m_in_menu.IsSameAs(
"Waypoint")) && m_pFoundRoutePoint) {
1982 object_type =
"Waypoint";
1983 object_ident = m_pFoundRoutePoint->
m_GUID.ToStdString();
1984 }
else if ((pimis->m_in_menu.IsSameAs(
"Route")) &&
1986 object_type =
"Route";
1987 object_ident = m_pSelectedRoute->
m_GUID.ToStdString();
1988 }
else if ((pimis->m_in_menu.IsSameAs(
"Track")) &&
1990 object_type =
"Track";
1991 object_ident = m_pSelectedTrack->m_GUID.ToStdString();
1992 }
else if ((pimis->m_in_menu.IsSameAs(
"AIS")) && m_FoundAIS_MMSI) {
1993 object_type =
"AIS";
1994 wxString sAIS = wxString::Format(
"%d", m_FoundAIS_MMSI);
1995 object_ident = sAIS.ToStdString();
2001 ppi->OnContextMenuItemCallbackExt(target_id, object_ident,
2002 object_type, zlat, zlon);
2013 if ((event.GetId() >= ID_DEF_MENU_GROUPBASE) &&
2016 parent->SetGroupIndex(event.GetId() - ID_DEF_MENU_GROUPBASE);
2019 parent->InvalidateGL();
AisDecoder * g_pAIS
Global instance.
Class AisDecoder and helpers.
Global state for AIS decoder.
Charts database management
ChartGroupArray * g_pGroupArray
Global instance.
Basic chart info storage.
Generic Chart canvas base.
Dialog for managing CM93 chart offsets.
Base class for all chart types.
ChartCanvas - Main chart display and interaction component.
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
double GetDisplayScale()
Get the ratio of physical to logical pixel for the display.
float GetVPScale()
Return the ViewPort scale factor, in physical pixels per meter.
bool SetVPScale(double sc, bool b_refresh=true)
Sets the viewport scale while maintaining the center point.
void GetCanvasPixPoint(double x, double y, double &lat, double &lon)
Convert canvas pixel coordinates (physical pixels) to latitude/longitude.
void DrawTCWindow(int x, int y, void *pIDX)
Legacy tide dialog creation method.
void Validate()
Check that all entries are accessible, remove stale ones.
Represents a waypoint or mark within the navigation system.
wxString m_GUID
Globally Unique Identifier for the waypoint.
bool m_bIsolatedMark
Flag indicating if the waypoint is a standalone mark.
bool m_bIsInLayer
Flag indicating if the waypoint belongs to a layer.
Represents a navigational route in the navigation system.
bool m_bRtIsSelected
Flag indicating whether this route is currently selected in the UI.
wxString m_RouteStartString
Name or description of the route's starting point.
bool m_bDeleteOnArrival
Flag indicating whether the route should be deleted once navigation reaches the end.
wxString m_RouteEndString
Name or description of the route's ending point.
RoutePoint * m_pRouteActivePoint
Pointer to the currently active waypoint within this route.
wxString m_RouteNameString
User-assigned name for the route.
wxString m_GUID
Globally unique identifier for this route.
bool m_bIsInLayer
Flag indicating whether this route belongs to a layer.
int m_lastMousePointIndex
Index of the most recently interacted with route point.
bool ActivateRoutePoint(Route *pA, RoutePoint *pRP)
Activates a specific waypoint within a route for navigation.
wxArrayPtrVoid * GetRouteArrayContaining(RoutePoint *pWP)
Find all routes that contain the given waypoint.
bool ActivateNextPoint(Route *pr, bool skipped)
Activates the next waypoint in a route when the current waypoint is reached.
bool DeleteRoute(Route *pRoute)
bool ActivateRoute(Route *pRouteToActivate, RoutePoint *pStartPoint=NULL)
Activates a route for navigation.
Dialog for sending routes/waypoints to a GPS device.
Dialog for sending navigation objects to peer devices.
Represents a track, which is a series of connected track points.
bool RemoveRoutePoint(RoutePoint *prp)
Remove a routepoint from list if present, deallocate it all cases.
Represents a composite CM93 chart covering multiple scales.
virtual void OnContextMenuItemCallback(int id)
Handles context menu item selection.
The JSON value class implementation.
CM93OffsetDialog * g_pCM93OffsetDialog
Global instance.
Class cm93chart and helpers – CM93 chart state.
Global variables stored in configuration file.
GoToPositionDialog * pGoToPositionDialog
Global instance.
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
wxFont GetOCPNGUIScaledFont(wxString item)
Retrieves a font optimized for touch and high-resolution interfaces.
double vLat
Virtual lat from chcanv popup.
double vLon
Virtual lon from chcanv popup.
double g_androidDPmm
Only used used by ANDROID
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
Read and write KML Format.
MarkInfoDlg * g_pMarkInfoDialog
global instance
Waypoint properties maintenance dialog.
MySQL based storage for routes, tracks, etc.
bool bGPSValid
Indicate whether the Global Navigation Satellite System (GNSS) has a valid position.
double gHdt
True heading in degrees (0-359.99).
double gLat
Vessel's current latitude in decimal degrees.
double gCog
Course over ground in degrees (0-359.99).
double gSog
Speed over ground in knots.
double gLon
Vessel's current longitude in decimal degrees.
Position, course, speed, etc.
Confirm peer transfer PIN code dialog.
Tools to send data to plugins.
PlugInManager * g_pi_manager
Global instance.
PlugInManager and helper classes – Mostly gui parts (dialogs) and plugin API stuff.
Purpose: Track and Trackpoint drawing stuff.
RoutePropDlgImpl * pRoutePropDialog
Global instance.
RoutePoint * pAnchorWatchPoint2
Global instance.
Routeman * g_pRouteMan
Global instance.
RouteList * pRouteList
Global instance.
RoutePoint * pAnchorWatchPoint1
Global instance.
Select * pSelect
Global instance.
Selected route, segment, waypoint, etc.
Send route/waypoint to GPS dialog.
Send Route/Waypoint/Track to peer dialog.
Tide and Current Manager @TODO Add original author copyright.
ActiveTrack * g_pActiveTrack
global instance
Recorded track abstraction.
Track and Trackpoint drawing stuff.
TrackPropDlg * pTrackPropDialog
Global instance.
Framework for Undo features.