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>
40#include "ocpn-nlohmann/json.hpp"
86#include "user_colors.h"
89#include "androidUTIL.h"
94 ID_DEF_MENU_MAX_DETAIL = 1,
96 ID_DEF_MENU_SCALE_OUT,
100 ID_DEF_MENU_MOVE_BOAT_HERE,
101 ID_DEF_MENU_GOTO_HERE,
102 ID_DEF_MENU_GOTOPOSITION,
105 ID_WP_MENU_PROPERTIES,
107 ID_RT_MENU_DEACTIVATE,
111 ID_RT_MENU_SPLIT_LEG,
112 ID_RT_MENU_SPLIT_WPT,
115 ID_WPT_MENU_SENDTOGPS,
116 ID_WPT_MENU_SENDTONEWGPS,
117 ID_WPT_MENU_SENDTOPEER,
125 ID_RT_MENU_DEACTPOINT,
126 ID_RT_MENU_ACTNXTPOINT,
128 ID_RT_MENU_PROPERTIES,
129 ID_RT_MENU_SENDTOGPS,
130 ID_RT_MENU_SENDTONEWGPS,
131 ID_RT_MENU_SHOWNAMES,
132 ID_RT_MENU_RESEQUENCE,
133 ID_RT_MENU_SENDTOPEER,
134 ID_WP_MENU_SET_ANCHORWATCH,
135 ID_WP_MENU_CLEAR_ANCHORWATCH,
136 ID_DEF_MENU_AISTARGETLIST,
137 ID_DEF_MENU_AIS_CPAWARNING,
140 ID_RC_MENU_SCALE_OUT,
144 ID_DEF_MENU_AIS_QUERY,
146 ID_DEF_MENU_AISSHOWTRACK,
147 ID_DEF_MENU_ACTIVATE_MEASURE,
148 ID_DEF_MENU_DEACTIVATE_MEASURE,
149 ID_DEF_MENU_COPY_MMSI,
154 ID_DEF_MENU_CM93OFFSET_DIALOG,
156 ID_TK_MENU_PROPERTIES,
158 ID_TK_MENU_SENDTOPEER,
159 ID_WP_MENU_ADDITIONAL_INFO,
161 ID_DEF_MENU_QUILTREMOVE,
165 ID_DEF_MENU_TOGGLE_FULL,
166 ID_DEF_MENU_TIDEINFO,
167 ID_DEF_MENU_CURRENTINFO,
171 ID_DGB_MENU_NMEA_WINDOW,
173 ID_DEF_MENU_GROUPBASE,
180static wxString _menuText(wxString name, wxString shortcut) {
184 menutext <<
"\t" << shortcut;
192int CanvasMenuHandler::GetNextContextMenuId() {
193 return ID_DEF_MENU_LAST +
197wxFont CanvasMenuHandler::m_scaledFont;
200CanvasMenuHandler::CanvasMenuHandler(
ChartCanvas *parentCanvas,
203 int selectedAIS_MMSI,
204 void *selectedTCIndex, wxWindow *nmea_log)
205 : m_nmea_log(nmea_log) {
206 parent = parentCanvas;
207 m_pSelectedRoute = selectedRoute;
208 m_pSelectedTrack = selectedTrack;
209 m_pFoundRoutePoint = selectedPoint;
210 m_FoundAIS_MMSI = selectedAIS_MMSI;
211 m_pIDXCandidate = selectedTCIndex;
212 if (!m_scaledFont.IsOk()) {
213 wxFont *qFont = GetOCPNScaledFont(_(
"Menu"));
214 m_scaledFont = *qFont;
217 m_DIPFactor = g_Platform->GetDisplayDIPMult(wxTheApp->GetTopWindow());
220CanvasMenuHandler::~CanvasMenuHandler() {}
226void CanvasMenuHandler::PrepareMenuItem(wxMenuItem *item) {
227#if defined(__WXMSW__)
228 wxColour ctrl_back_color = GetGlobalColor(
"DILG1");
229 item->SetBackgroundColour(ctrl_back_color);
230 wxColour menu_text_color = GetGlobalColor(
"UITX1");
231 item->SetTextColour(menu_text_color);
235void CanvasMenuHandler::MenuPrepend1(wxMenu *menu,
int id, wxString label) {
236 wxMenuItem *item =
new wxMenuItem(menu,
id, label);
237#if defined(__WXMSW__)
238 item->SetFont(m_scaledFont);
243 item->SetFont(sFont);
246 PrepareMenuItem(item);
248 if (g_btouch) menu->InsertSeparator(0);
252void CanvasMenuHandler::MenuAppend1(wxMenu *menu,
int id, wxString label) {
253 wxMenuItem *item =
new wxMenuItem(menu,
id, label);
254#if defined(__WXMSW__)
255 item->SetFont(m_scaledFont);
260 item->SetFont(sFont);
263 PrepareMenuItem(item);
266 if (g_btouch) menu->AppendSeparator();
269void CanvasMenuHandler::SetMenuItemFont1(wxMenuItem *item) {
270#if defined(__WXMSW__)
271 item->SetFont(m_scaledFont);
274#if defined(__ANDROID__)
276 item->SetFont(*qFont);
279 PrepareMenuItem(item);
282void CanvasMenuHandler::CanvasPopupMenu(
int x,
int y,
int seltype) {
283 wxMenu *contextMenu =
new wxMenu;
284 wxMenu *menuWaypoint = NULL;
285 wxMenu *menuRoute = NULL;
286 wxMenu *menuTrack = NULL;
287 wxMenu *menuAIS = NULL;
289 wxMenu *subMenuChart =
new wxMenu;
290 wxMenu *subMenuUndo =
new wxMenu(
"Undo...Ctrl-Z");
293 wxMenu *subMenuRedo =
new wxMenu(
"Redo...Shift-Ctrl-Z");
295 wxMenu *subMenuRedo =
new wxMenu(
"Redo...Ctrl-Y");
297 wxMenu *subMenuDebug =
new wxMenu(
"");
303 wxFont *dFont = GetOCPNScaledFont_PlugIn(_(
"Dialog"));
306 gFrame->GetTextExtent(
"W", &fwidth, &fheight, NULL, NULL, dFont);
307 auto frame_size =
gFrame->GetSize();
308 if ((frame_size.x > fwidth * 60) && (frame_size.y > fheight * 18))
310 MenuAppend1(subMenuDebug, ID_DGB_MENU_NMEA_WINDOW, _(
"Show Data Monitor"));
312 wxMenu *menuFocus = contextMenu;
317 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
318 bool bsubMenus =
false;
321 if (parent->undo->AnythingToUndo()) {
323 wxMenuItem *subMenuItemundo =
324 contextMenu->AppendSubMenu(subMenuUndo, _(
"Undo"));
327 undoItem << _(
"Undo") <<
" "
328 << parent->undo->GetNextUndoableAction()->Description();
329 MenuAppend1(subMenuUndo, ID_UNDO, undoItem);
331 if (parent->undo->AnythingToRedo()) {
333 wxMenuItem *subMenuItemRedo =
334 contextMenu->AppendSubMenu(subMenuRedo, _(
"Redo"));
337 redoItem << _(
"Redo") <<
" "
338 << parent->undo->GetNextRedoableAction()->Description();
339 MenuAppend1(subMenuRedo, ID_REDO, redoItem);
342 if (parent->undo->AnythingToUndo()) {
344 undoItem << _(
"Undo") <<
" "
345 << parent->undo->GetNextUndoableAction()->Description();
346 MenuAppend1(contextMenu, ID_UNDO, _menuText(undoItem,
"Ctrl-Z"));
349 if (parent->undo->AnythingToRedo()) {
351 redoItem << _(
"Redo") <<
" "
352 << parent->undo->GetNextRedoableAction()->Description();
354 MenuAppend1(contextMenu, ID_REDO, _menuText(redoItem,
"Shift-Ctrl-Z"));
356 MenuAppend1(contextMenu, ID_REDO, _menuText(redoItem,
"Ctrl-Y"));
362 if (seltype == SELTYPE_ROUTECREATE) {
363 MenuAppend1(contextMenu, ID_RC_MENU_FINISH,
364 _menuText(_(
"End Route"),
"Esc"));
367 if (!parent->m_pMouseRoute) {
368 if (parent->m_bMeasure_Active)
369 MenuAppend1(contextMenu, ID_DEF_MENU_DEACTIVATE_MEASURE,
370 _menuText(_(
"Measure Off"),
"Esc"));
372 MenuAppend1(contextMenu, ID_DEF_MENU_ACTIVATE_MEASURE,
373 _menuText(_(
"Measure"),
"M"));
376 bool ais_areanotice =
false;
377 if (
g_pAIS && parent->GetShowAIS() && g_bShowAreaNotices) {
378 float vp_scale = parent->GetVPScale();
380 for (
const auto &target :
g_pAIS->GetAreaNoticeSourcesList()) {
381 auto target_data = target.second;
382 if (!target_data->area_notices.empty()) {
383 for (
auto &ani : target_data->area_notices) {
384 Ais8_001_22 &area_notice = ani.second;
387 for (Ais8_001_22_SubAreaList::iterator sa =
388 area_notice.sub_areas.begin();
389 sa != area_notice.sub_areas.end(); ++sa) {
391 case AIS8_001_22_SHAPE_CIRCLE: {
392 wxPoint target_point;
393 parent->GetCanvasPointPix(sa->latitude, sa->longitude,
395 bbox.Expand(target_point);
396 if (sa->radius_m > 0.0) bbox.EnLarge(sa->radius_m * vp_scale);
399 case AIS8_001_22_SHAPE_RECT:
400 case AIS8_001_22_SHAPE_POLYGON:
401 case AIS8_001_22_SHAPE_POLYLINE: {
402 double lat = sa->latitude;
403 double lon = sa->longitude;
404 for (
int i = 0; i < 4; ++i) {
405 ll_gc_ll(lat, lon, sa->angles[i], sa->dists_m[i] / 1852.0,
407 wxPoint target_point;
408 parent->GetCanvasPointPix(lat, lon, &target_point);
409 bbox.Expand(target_point);
413 case AIS8_001_22_SHAPE_SECTOR: {
414 double lat1 = sa->latitude;
415 double lon1 = sa->longitude;
417 wxPoint target_point;
418 parent->GetCanvasPointPix(lat1, lon1, &target_point);
419 bbox.Expand(target_point);
420 for (
int i = 0; i < 18; ++i) {
424 i * (sa->right_bound_deg - sa->left_bound_deg) / 18,
425 sa->radius_m / 1852.0, &lat, &lon);
426 parent->GetCanvasPointPix(lat, lon, &target_point);
427 bbox.Expand(target_point);
429 ll_gc_ll(lat1, lon1, sa->right_bound_deg, sa->radius_m / 1852.0,
431 parent->GetCanvasPointPix(lat, lon, &target_point);
432 bbox.Expand(target_point);
438 if (bbox.GetValid() && bbox.PointInBox(x, y)) {
439 ais_areanotice =
true;
448 if (parent->GetpCurrentStack())
449 nChartStack = parent->GetpCurrentStack()->nEntry;
451 if (!parent->GetVP().b_quilt) {
452 if (nChartStack > 1) {
453 MenuAppend1(contextMenu, ID_DEF_MENU_MAX_DETAIL, _(
"Max Detail Here"));
454 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_IN,
455 _menuText(_(
"Scale In"),
"Ctrl-Left"));
456 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_OUT,
457 _menuText(_(
"Scale Out"),
"Ctrl-Right"));
460 if ((parent->m_singleChart &&
461 (parent->m_singleChart->GetChartFamily() == CHART_FAMILY_VECTOR)) ||
463 MenuAppend1(contextMenu, ID_DEF_MENU_QUERY, _(
"Object Query") +
"...");
467 ChartBase *pChartTest =
468 parent->m_pQuilt->GetChartAtPix(parent->GetVP(), wxPoint(x, y));
469 if ((pChartTest && (pChartTest->GetChartFamily() == CHART_FAMILY_VECTOR)) ||
471 MenuAppend1(contextMenu, ID_DEF_MENU_QUERY, _(
"Object Query") +
"...");
474 if (!g_bBasicMenus && (nChartStack > 1)) {
475 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_IN,
476 _menuText(_(
"Scale In"),
"Ctrl-Left"));
477 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_OUT,
478 _menuText(_(
"Scale Out"),
"Ctrl-Right"));
484 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
485 bool b_dm_add =
true;
486 if (g_btouch && parent->IsMeasureActive()) b_dm_add =
false;
489 MenuAppend1(contextMenu, ID_DEF_MENU_DROP_WP,
490 _menuText(_(
"Drop Mark"),
"Ctrl-M"));
491 MenuAppend1(contextMenu, ID_DEF_MENU_NEW_RT,
492 _menuText(_(
"New Route..."),
"Ctrl-R"));
496 MenuAppend1(contextMenu, ID_DEF_MENU_MOVE_BOAT_HERE, _(
"Move Boat Here"));
499 if (!g_bBasicMenus && !
g_pRouteMan->GetpActiveRoute() &&
500 (!(seltype & SELTYPE_MARKPOINT) ||
501 (m_pFoundRoutePoint && m_pFoundRoutePoint->m_bIsInLayer)))
502 MenuAppend1(contextMenu, ID_DEF_MENU_GOTO_HERE, _(
"Navigate To Here"));
505 MenuAppend1(contextMenu, ID_DEF_MENU_GOTOPOSITION,
506 _(
"Center view") +
"...");
508 if (!g_bBasicMenus) {
509 if (parent->GetVP().b_quilt) {
510 if (parent->GetUpMode() == NORTH_UP_MODE) {
511 MenuAppend1(contextMenu, ID_DEF_MENU_COGUP, _(
"Course Up Mode"));
512 if (!std::isnan(
gHdt))
513 MenuAppend1(contextMenu, ID_DEF_MENU_HEADUP, _(
"Heading Up Mode"));
515 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"North Up Mode"));
518 if (parent->m_singleChart &&
519 (fabs(parent->m_singleChart->GetChartSkew()) > .01) && !g_bskew_comp)
520 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"Chart Up Mode"));
522 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"North Up Mode"));
526 if (!g_bBasicMenus) {
527 bool full_toggle_added =
false;
530 MenuAppend1(contextMenu, ID_DEF_MENU_TOGGLE_FULL,
531 _(
"Toggle Full Screen"));
532 full_toggle_added =
true;
535 if (!full_toggle_added) {
537 MenuAppend1(contextMenu, ID_DEF_MENU_TOGGLE_FULL,
538 _(
"Toggle Full Screen"));
544 MenuAppend1(contextMenu, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
547 int pasteBuffer = kml->ParsePasteBuffer();
548 if (pasteBuffer != KML_PASTE_INVALID) {
549 switch (pasteBuffer) {
550 case KML_PASTE_WAYPOINT: {
551 MenuAppend1(contextMenu, ID_PASTE_WAYPOINT, _(
"Paste Waypoint"));
554 case KML_PASTE_ROUTE: {
555 MenuAppend1(contextMenu, ID_PASTE_ROUTE, _(
"Paste Route"));
558 case KML_PASTE_TRACK: {
559 MenuAppend1(contextMenu, ID_PASTE_TRACK, _(
"Paste Track"));
562 case KML_PASTE_ROUTE_TRACK: {
563 MenuAppend1(contextMenu, ID_PASTE_ROUTE, _(
"Paste Route"));
564 MenuAppend1(contextMenu, ID_PASTE_TRACK, _(
"Paste Track"));
571 if (!parent->GetVP().b_quilt && parent->m_singleChart &&
572 (parent->m_singleChart->GetChartType() == CHART_TYPE_CM93COMP)) {
573 MenuAppend1(contextMenu, ID_DEF_MENU_CM93OFFSET_DIALOG,
574 _(
"CM93 Offset Dialog..."));
598 wxMenuItem *subItemChart =
599 contextMenu->AppendSubMenu(subMenuChart, _(
"Chart Groups"));
600 if (g_btouch) contextMenu->AppendSeparator();
602 SetMenuItemFont1(subItemChart);
606 MenuAppend1(subMenuChart, wxID_CANCEL, _(
"temporary"));
608 wxMenuItem *subItem0 = subMenuChart->AppendRadioItem(
609 ID_DEF_MENU_GROUPBASE, _(
"All Active Charts"));
611 SetMenuItemFont1(subItem0);
613 for (
unsigned int i = 0; i <
g_pGroupArray->GetCount(); i++) {
614 subItem0 = subMenuChart->AppendRadioItem(
615 ID_DEF_MENU_GROUPBASE + i + 1,
g_pGroupArray->Item(i)->m_group_name);
616 SetMenuItemFont1(subItem0);
620 subMenuChart->Remove(wxID_CANCEL);
622 subMenuChart->Check(ID_DEF_MENU_GROUPBASE + parent->m_groupIndex,
true);
626 menuFocus = contextMenu;
629 std::unique_ptr<HostApi> host_api =
GetHostApi();
630 auto *api_121 =
dynamic_cast<HostApi121 *
>(host_api.get());
632 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
634 if (api_121 && parent->GetShowAIS() &&
635 (seltype & SELTYPE_AISTARGET &&
636 !(api_121->GetContextMenuMask() &
637 api_121->kContextMenuDisableAistarget))) {
638 auto myptarget =
g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
639 if (!g_bBasicMenus && myptarget) {
640 name = myptarget->GetFullName();
641 if (name.IsEmpty()) name.Printf(
"%d", m_FoundAIS_MMSI);
642 name.Prepend(
" ( ").Append(
" )");
644 name = wxEmptyString;
645 menuAIS =
new wxMenu(_(
"AIS") + name);
646 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_QUERY, _(
"Target Query..."));
647 if (myptarget && myptarget->bCPA_Valid &&
648 (myptarget->n_alert_state != AIS_ALERT_SET)) {
649 if (myptarget->b_show_AIS_CPA)
650 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_CPA, _(
"Hide Target CPA"));
652 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_CPA, _(
"Show Target CPA"));
654 MenuAppend1(menuAIS, ID_DEF_MENU_AISTARGETLIST, _(
"Target List..."));
655 if (myptarget->Class != AIS_METEO ) {
656 if (myptarget && !myptarget->b_PersistTrack) {
657 if (myptarget->b_show_track)
658 MenuAppend1(menuAIS, ID_DEF_MENU_AISSHOWTRACK,
659 _(
"Hide Target Track"));
661 MenuAppend1(menuAIS, ID_DEF_MENU_AISSHOWTRACK,
662 _(
"Show Target Track"));
666 MenuAppend1(menuAIS, ID_DEF_MENU_COPY_MMSI, _(
"Copy Target MMSI"));
667 menuAIS->AppendSeparator();
669 if (!parent->GetVP().b_quilt) {
670 if ((parent->m_singleChart &&
671 (parent->m_singleChart->GetChartFamily() ==
672 CHART_FAMILY_VECTOR))) {
673 MenuAppend1(menuAIS, ID_DEF_MENU_QUERY, _(
"Object Query..."));
677 ChartBase *pChartTest =
678 parent->m_pQuilt->GetChartAtPix(parent->GetVP(), wxPoint(x, y));
680 (pChartTest->GetChartFamily() == CHART_FAMILY_VECTOR))) {
681 MenuAppend1(menuAIS, ID_DEF_MENU_QUERY, _(
"Object Query..."));
687 bool enable_list =
true;
689 double char_x = wxTheApp->GetTopWindow()->GetSize().x /
690 wxTheApp->GetTopWindow()->GetCharWidth();
691 double char_y = wxTheApp->GetTopWindow()->GetSize().y /
692 wxTheApp->GetTopWindow()->GetCharWidth();
693 double char_min = wxMin(char_x, char_y);
694 if (char_min < 100) enable_list =
false;
696 double size_x = wxTheApp->GetTopWindow()->GetSize().x /
g_androidDPmm;
697 double size_y = wxTheApp->GetTopWindow()->GetSize().y /
g_androidDPmm;
698 if (wxMin(size_x, size_y) < 100)
702 MenuAppend1(contextMenu, ID_DEF_MENU_AISTARGETLIST,
703 _(
"AIS target list") +
"...");
705 wxString nextCPAstatus = g_bCPAWarn ? _(
"Hide") : _(
"Show");
706 MenuAppend1(contextMenu, ID_DEF_MENU_AIS_CPAWARNING,
707 _menuText(nextCPAstatus +
" " + _(
"CPA alarm "),
"W"));
711 if (g_enable_root_menu_debug) {
712 wxMenuItem *subItemDebug =
713 contextMenu->AppendSubMenu(subMenuDebug, _(
"Debug"));
714 if (g_btouch) contextMenu->AppendSeparator();
715 SetMenuItemFont1(subItemDebug);
718 if (seltype & SELTYPE_ROUTESEGMENT &&
719 !(api_121->GetContextMenuMask() & api_121->kContextMenuDisableRoute)) {
720 if (!g_bBasicMenus && m_pSelectedRoute) {
721 name = m_pSelectedRoute->m_RouteNameString;
722 if (name.IsEmpty()) name = _(
"Unnamed Route");
723 name.Prepend(
" ( ").Append(
" )");
725 name = wxEmptyString;
727 if (m_pSelectedRoute && m_pSelectedRoute->m_bIsInLayer) blay =
true;
730 menuRoute =
new wxMenu(_(
"Layer Route") + name);
731 MenuAppend1(menuRoute, ID_RT_MENU_PROPERTIES, _(
"Properties") +
"...");
732 if (m_pSelectedRoute) {
733 if (m_pSelectedRoute->IsActive()) {
734 int indexActive = m_pSelectedRoute->GetIndexOf(
735 m_pSelectedRoute->m_pRouteActivePoint);
736 if (indexActive + 1 < m_pSelectedRoute->GetnPoints() - 1) {
737 MenuAppend1(menuRoute, ID_RT_MENU_ACTNXTPOINT,
738 _(
"Activate Next Waypoint"));
740 MenuAppend1(menuRoute, ID_RT_MENU_DEACTIVATE, _(
"Deactivate"));
741 MenuAppend1(menuRoute, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
743 MenuAppend1(menuRoute, ID_RT_MENU_ACTIVATE, _(
"Activate"));
747 menuRoute =
new wxMenu(_(
"Route") + name);
748 MenuAppend1(menuRoute, ID_RT_MENU_PROPERTIES, _(
"Properties") +
"...");
749 if (m_pSelectedRoute) {
750 if (m_pSelectedRoute->IsActive()) {
751 int indexActive = m_pSelectedRoute->GetIndexOf(
752 m_pSelectedRoute->m_pRouteActivePoint);
753 if (indexActive + 1 < m_pSelectedRoute->GetnPoints() - 1) {
754 MenuAppend1(menuRoute, ID_RT_MENU_ACTNXTPOINT,
755 _(
"Activate Next Waypoint"));
757 MenuAppend1(menuRoute, ID_RT_MENU_DEACTIVATE, _(
"Deactivate"));
758 MenuAppend1(menuRoute, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
760 MenuAppend1(menuRoute, ID_RT_MENU_ACTIVATE, _(
"Activate"));
763 MenuAppend1(menuRoute, ID_RT_MENU_INSERT, _(
"Insert Waypoint"));
764 MenuAppend1(menuRoute, ID_RT_MENU_APPEND, _(
"Append Waypoint"));
765 if (!(seltype & SELTYPE_ROUTEPOINT) && m_pSelectedRoute) {
766 m_SelectedIdx = m_pSelectedRoute->GetIndexOf(m_pFoundRoutePoint);
767 if (m_SelectedIdx >= 1 &&
768 m_SelectedIdx < m_pSelectedRoute->GetnPoints() - 2)
769 MenuAppend1(menuRoute, ID_RT_MENU_SPLIT_LEG, _(
"Split around Leg"));
771 MenuAppend1(menuRoute, ID_RT_MENU_COPY, _(
"Copy as KML") +
"...");
772 MenuAppend1(menuRoute, ID_RT_MENU_DELETE, _(
"Delete") +
"...");
773 MenuAppend1(menuRoute, ID_RT_MENU_REVERSE, _(
"Reverse..."));
774 if (m_pSelectedRoute) {
775 if (m_pSelectedRoute->AreWaypointNamesVisible())
776 MenuAppend1(menuRoute, ID_RT_MENU_SHOWNAMES,
777 _(
"Hide Waypoint Names"));
779 MenuAppend1(menuRoute, ID_RT_MENU_SHOWNAMES,
780 _(
"Show Waypoint Names"));
782 MenuAppend1(menuRoute, ID_RT_MENU_RESEQUENCE,
783 _(
"Resequence Waypoints..."));
786 wxString port = parent->FindValidUploadPort();
787 parent->m_active_upload_port = port;
788 wxString item = _(
"Send to GPS");
789 if (!port.IsEmpty()) {
794 MenuAppend1(menuRoute, ID_RT_MENU_SENDTOGPS, item);
796 if (!port.IsEmpty()) {
797 wxString item = _(
"Send to new GPS");
798 MenuAppend1(menuRoute, ID_RT_MENU_SENDTONEWGPS, item);
801 wxString itemstp = SYMBOL_STP_TITLE;
802 MenuAppend1(menuRoute, ID_RT_MENU_SENDTOPEER, itemstp);
805 if (menuFocus != menuAIS) menuFocus = menuRoute;
808 if (seltype & SELTYPE_TRACKSEGMENT &&
809 !(api_121->GetContextMenuMask() & api_121->kContextMenuDisableTrack)) {
810 name = wxEmptyString;
811 if (!g_bBasicMenus && m_pSelectedTrack)
812 name =
" ( " + m_pSelectedTrack->GetName(
true) +
" )";
814 name = wxEmptyString;
816 if (m_pSelectedTrack && m_pSelectedTrack->m_bIsInLayer) blay =
true;
819 menuTrack =
new wxMenu(_(
"Layer Track") + name);
820 MenuAppend1(menuTrack, ID_TK_MENU_PROPERTIES, _(
"Properties") +
"...");
822 menuTrack =
new wxMenu(_(
"Track") + name);
823 MenuAppend1(menuTrack, ID_TK_MENU_PROPERTIES, _(
"Properties") +
"...");
824 MenuAppend1(menuTrack, ID_TK_MENU_COPY, _(
"Copy as KML"));
825 MenuAppend1(menuTrack, ID_TK_MENU_DELETE, _(
"Delete") +
"...");
828 wxString itemstp = SYMBOL_STP_TITLE;
829 MenuAppend1(menuTrack, ID_TK_MENU_SENDTOPEER, itemstp);
832 if (menuFocus != menuAIS) menuFocus = menuTrack;
835 if (seltype & SELTYPE_ROUTEPOINT &&
836 !(api_121->GetContextMenuMask() &
837 api_121->kContextMenuDisableWaypoint)) {
838 if (!g_bBasicMenus && m_pFoundRoutePoint) {
839 name = m_pFoundRoutePoint->GetName();
840 if (name.IsEmpty()) name = _(
"Unnamed Waypoint");
841 name.Prepend(
" ( ").Append(
" )");
843 name = wxEmptyString;
845 if (m_pFoundRoutePoint && m_pFoundRoutePoint->m_bIsInLayer) blay =
true;
848 menuWaypoint =
new wxMenu(_(
"Layer Waypoint") + name);
849 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
850 _(
"Properties") +
"...");
852 if (m_pSelectedRoute && m_pSelectedRoute->IsActive())
853 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTPOINT, _(
"Activate"));
855 menuWaypoint =
new wxMenu(_(
"Waypoint") + name);
856 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
857 _(
"Properties") +
"...");
858 if (m_pSelectedRoute && m_pSelectedRoute->IsActive()) {
859 if (m_pSelectedRoute->m_pRouteActivePoint != m_pFoundRoutePoint)
860 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTPOINT, _(
"Activate"));
863 if (m_pSelectedRoute && m_pSelectedRoute->IsActive()) {
864 if (m_pSelectedRoute->m_pRouteActivePoint == m_pFoundRoutePoint) {
865 int indexActive = m_pSelectedRoute->GetIndexOf(
866 m_pSelectedRoute->m_pRouteActivePoint);
867 if (indexActive < m_pSelectedRoute->GetnPoints() - 1)
868 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTNXTPOINT,
869 _(
"Activate Next Waypoint"));
872 if (m_pSelectedRoute && m_pSelectedRoute->GetnPoints() > 2) {
873 MenuAppend1(menuWaypoint, ID_RT_MENU_REMPOINT,
874 _(
"Remove from Route"));
876 m_SelectedIdx = m_pSelectedRoute->GetIndexOf(m_pFoundRoutePoint);
877 if (m_SelectedIdx >= 1 &&
878 m_SelectedIdx < m_pSelectedRoute->GetnPoints() - 1)
879 MenuAppend1(menuWaypoint, ID_RT_MENU_SPLIT_WPT,
880 _(
"Split Route at Waypoint"));
883 MenuAppend1(menuWaypoint, ID_WPT_MENU_COPY, _(
"Copy as KML"));
885 if (m_pFoundRoutePoint && m_pFoundRoutePoint->GetIconName() !=
"mob")
886 MenuAppend1(menuWaypoint, ID_RT_MENU_DELPOINT, _(
"Delete"));
889 wxString port = parent->FindValidUploadPort();
890 parent->m_active_upload_port = port;
891 wxString item = _(
"Send to GPS");
892 if (!port.IsEmpty()) {
897 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOGPS, item);
899 if (!port.IsEmpty()) {
900 wxString item = _(
"Send to new GPS");
901 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTONEWGPS, item);
904 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOPEER,
909 if (menuFocus != menuAIS) menuFocus = menuWaypoint;
912 if (seltype & SELTYPE_MARKPOINT &&
913 !(api_121->GetContextMenuMask() &
914 api_121->kContextMenuDisableWaypoint)) {
915 if (!g_bBasicMenus && m_pFoundRoutePoint) {
916 name = m_pFoundRoutePoint->GetName();
917 if (name.IsEmpty()) name = _(
"Unnamed Mark");
918 name.Prepend(
" ( ").Append(
" )");
920 name = wxEmptyString;
922 if (m_pFoundRoutePoint && m_pFoundRoutePoint->m_bIsInLayer) blay =
true;
925 menuWaypoint =
new wxMenu(_(
"Layer Waypoint") + name);
926 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
927 _(
"Properties") +
"...");
929 menuWaypoint =
new wxMenu(_(
"Mark") + name);
930 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
931 _(
"Properties") +
"...");
934 MenuAppend1(menuWaypoint, ID_WP_MENU_GOTO, _(
"Navigate To This"));
936 MenuAppend1(menuWaypoint, ID_WPT_MENU_COPY, _(
"Copy as KML"));
938 if (m_pFoundRoutePoint && m_pFoundRoutePoint->GetIconName() !=
"mob")
939 MenuAppend1(menuWaypoint, ID_WP_MENU_DELPOINT, _(
"Delete"));
942 wxString port = parent->FindValidUploadPort();
943 parent->m_active_upload_port = port;
944 wxString item = _(
"Send to GPS");
945 if (!port.IsEmpty()) {
950 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOGPS, item);
952 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOPEER,
958 MenuAppend1(menuWaypoint, ID_WP_MENU_CLEAR_ANCHORWATCH,
959 _(
"Clear Anchor Watch"));
961 if (m_pFoundRoutePoint && !(m_pFoundRoutePoint->m_bIsInLayer) &&
965 DistanceBearingMercator(m_pFoundRoutePoint->m_lat,
966 m_pFoundRoutePoint->m_lon,
gLat,
gLon, &brg,
968 if (dist * 1852. <= g_nAWMax)
969 MenuAppend1(menuWaypoint, ID_WP_MENU_SET_ANCHORWATCH,
970 _(
"Set Anchor Watch"));
975 if (menuFocus != menuAIS) menuFocus = menuWaypoint;
979 AddPluginContextMenuItems(contextMenu, menuRoute, menuTrack, menuWaypoint,
983 enum { WPMENU = 1, TKMENU = 2, RTMENU = 4, MMMENU = 8 };
985 if (!g_bBasicMenus && menuFocus != contextMenu) {
986 if (global_color_scheme != GLOBAL_COLOR_SCHEME_DUSK &&
987 global_color_scheme != GLOBAL_COLOR_SCHEME_NIGHT &&
988 global_color_scheme != GLOBAL_COLOR_SCHEME_NIGHT_HICON) {
989 menuFocus->AppendSeparator();
992 wxMenuItem *subMenu1;
993 if (menuWaypoint && menuFocus != menuWaypoint) {
995 menuFocus->AppendSubMenu(menuWaypoint, menuWaypoint->GetTitle());
996 SetMenuItemFont1(subMenu1);
999 menuWaypoint->SetTitle(wxEmptyString);
1002 if (menuTrack && menuFocus != menuTrack) {
1003 subMenu1 = menuFocus->AppendSubMenu(menuTrack, menuTrack->GetTitle());
1004 SetMenuItemFont1(subMenu1);
1007 menuTrack->SetTitle(wxEmptyString);
1010 if (menuRoute && menuFocus != menuRoute) {
1011 subMenu1 = menuFocus->AppendSubMenu(menuRoute, menuRoute->GetTitle());
1012 SetMenuItemFont1(subMenu1);
1015 menuRoute->SetTitle(wxEmptyString);
1018 subMenu1 = menuFocus->AppendSubMenu(contextMenu, _(
"Main Menu"));
1019 SetMenuItemFont1(subMenu1);
1023 if (!subMenuChart->GetMenuItemCount()) contextMenu->Destroy(subItemChart);
1028 if (seltype & SELTYPE_TIDEPOINT) {
1029 menuFocus->AppendSeparator();
1031 MenuAppend1(menuFocus, ID_DEF_MENU_TIDEINFO, _(
"Show Tide Information"));
1034 if (seltype & SELTYPE_CURRENTPOINT) {
1035 if (!bsep) menuFocus->AppendSeparator();
1036 MenuAppend1(menuFocus, ID_DEF_MENU_CURRENTINFO,
1037 _(
"Show Current Information"));
1043 androidEnableBackButton(
false);
1044 androidEnableOptionsMenu(
false);
1052 parent->PopupMenu(menuFocus, x, y);
1055 androidEnableBackButton(
true);
1056 androidEnableOptionsMenu(
true);
1063 if (!(sub_menu & MMMENU))
delete contextMenu;
1064 if (!(sub_menu & RTMENU))
delete menuRoute;
1065 if (!(sub_menu & TKMENU))
delete menuTrack;
1066 if (!(sub_menu & WPMENU))
delete menuWaypoint;
1070void CanvasMenuHandler::AddPluginContextMenuItems(wxMenu *contextMenu,
1073 wxMenu *menuWaypoint,
1079 ArrayOfPlugInMenuItems item_array =
1082 for (
unsigned int i = 0; i < item_array.GetCount(); i++) {
1083 PlugInMenuItemContainer *pimis = item_array[i];
1084 if (!pimis->b_viz)
continue;
1086 wxMenu *submenu = NULL;
1087 if (pimis->pmenu_item->GetSubMenu()) {
1089 auto submenu_proto = pimis->pmenu_item->GetSubMenu();
1090 submenu =
new wxMenu();
1091 const wxMenuItemList &items =
1092 pimis->pmenu_item->GetSubMenu()->GetMenuItems();
1093 for (wxMenuItemList::const_iterator it = items.begin(); it != items.end();
1095 int id = (*it)->GetId();
1097 new wxMenuItem(submenu,
id, (*it)->GetItemLabelText(),
1098 (*it)->GetHelp(), (*it)->GetKind());
1101 psmi->SetFont(m_scaledFont);
1106 psmi->SetFont(sFont);
1109 PrepareMenuItem(psmi);
1110 submenu->Append(psmi);
1111 psmi->Check((*it)->IsChecked());
1115 wxMenuItem *pmi =
new wxMenuItem(
1116 contextMenu, pimis->id, pimis->pmenu_item->GetItemLabelText(),
1117 pimis->pmenu_item->GetHelp(), pimis->pmenu_item->GetKind(), submenu);
1119 pmi->SetFont(m_scaledFont);
1124 pmi->SetFont(sFont);
1127 PrepareMenuItem(pmi);
1129 wxMenu *dst = contextMenu;
1130 if (pimis->m_in_menu ==
"Waypoint")
1132 else if (pimis->m_in_menu ==
"Route")
1134 else if (pimis->m_in_menu ==
"Track")
1136 else if (pimis->m_in_menu ==
"AIS")
1141 dst->Enable(pimis->id, !pimis->b_grey);
1146void CanvasMenuHandler::PopupMenuHandler(wxCommandEvent &event) {
1153 bool dupFirstWpt =
true, showRPD;
1155 parent->GetCanvasPixPoint(popx * parent->GetDisplayScale(),
1156 popy * parent->GetDisplayScale(), zlat, zlon);
1158 switch (event.GetId()) {
1159 case ID_DEF_MENU_MAX_DETAIL:
1162 parent->ClearbFollow();
1164 top_frame::Get()->DoChartUpdate();
1166 parent->SelectChartFromStack(0,
false, CHART_TYPE_DONTCARE,
1167 CHART_FAMILY_RASTER);
1170 case ID_DEF_MENU_SCALE_IN:
1171 parent->DoCanvasStackDelta(-1);
1174 case ID_DEF_MENU_SCALE_OUT:
1175 parent->DoCanvasStackDelta(1);
1179 parent->undo->UndoLastAction();
1180 parent->InvalidateGL();
1181 parent->Refresh(
false);
1185 parent->undo->RedoNextAction();
1186 parent->InvalidateGL();
1187 parent->Refresh(
false);
1190 case ID_DEF_MENU_MOVE_BOAT_HERE:
1193 top_frame::Get()->UpdateStatusBar();
1196 case ID_DEF_MENU_GOTO_HERE: {
1197 RoutePoint *pWP_dest =
new RoutePoint(zlat, zlon, g_default_wp_icon,
1198 wxEmptyString, wxEmptyString);
1199 pSelect->AddSelectableRoutePoint(zlat, zlon, pWP_dest);
1201 RoutePoint *pWP_src =
new RoutePoint(
gLat,
gLon, g_default_wp_icon,
1202 wxEmptyString, wxEmptyString);
1205 Route *temp_route =
new Route();
1208 temp_route->AddPoint(pWP_src);
1209 temp_route->AddPoint(pWP_dest);
1212 pWP_dest, temp_route);
1228 case ID_DEF_MENU_DROP_WP: {
1229 RoutePoint *pWP =
new RoutePoint(zlat, zlon, g_default_wp_icon,
1230 wxEmptyString, wxEmptyString);
1232 pSelect->AddSelectableRoutePoint(zlat, zlon, pWP);
1233 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
1235 if (!RoutePointGui(*pWP).IsVisibleSelectable(this->parent))
1236 RoutePointGui(*pWP).ShowScaleWarningMessage(parent);
1238 if (RouteManagerDialog::getInstanceFlag()) {
1244 parent->undo->BeforeUndoableAction(Undo_CreateWaypoint, pWP,
1245 Undo_HasParent, NULL);
1246 parent->undo->AfterUndoableAction(NULL);
1247 top_frame::Get()->RefreshAllCanvas(
false);
1248 top_frame::Get()->InvalidateAllGL();
1249 g_FlushNavobjChanges =
true;
1253 case ID_DEF_MENU_NEW_RT: {
1254 parent->StartRoute();
1258 case ID_DEF_MENU_AISTARGETLIST:
1259 parent->ShowAISTargetList();
1262 case ID_DEF_MENU_AIS_CPAWARNING:
1263 parent->ToggleCPAWarn();
1266 case ID_WP_MENU_GOTO: {
1267 RoutePoint *pWP_src =
new RoutePoint(
gLat,
gLon, g_default_wp_icon,
1268 wxEmptyString, wxEmptyString);
1271 Route *temp_route =
new Route();
1274 temp_route->AddPoint(pWP_src);
1275 temp_route->AddPoint(m_pFoundRoutePoint);
1276 m_pFoundRoutePoint->SetShared(
true);
1278 pSelect->AddSelectableRouteSegment(
gLat,
gLon, m_pFoundRoutePoint->m_lat,
1279 m_pFoundRoutePoint->m_lon, pWP_src,
1280 m_pFoundRoutePoint, temp_route);
1282 wxString name = m_pFoundRoutePoint->GetName();
1283 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
1284 wxString rteName = _(
"Go to ");
1285 rteName.Append(name);
1299 case ID_DEF_MENU_COGUP:
1300 parent->SetUpMode(COURSE_UP_MODE);
1303 case ID_DEF_MENU_HEADUP:
1304 parent->SetUpMode(HEAD_UP_MODE);
1307 case ID_DEF_MENU_NORTHUP:
1308 parent->SetUpMode(NORTH_UP_MODE);
1311 case ID_DEF_MENU_TOGGLE_FULL:
1312 top_frame::Get()->ToggleFullScreen();
1315 case ID_DEF_MENU_GOTOPOSITION:
1324 case ID_WP_MENU_DELPOINT: {
1333 if (m_pFoundRoutePoint && !(m_pFoundRoutePoint->m_bIsInLayer) &&
1334 (m_pFoundRoutePoint->GetIconName() !=
"mob")) {
1338 wxArrayPtrVoid *proute_array =
1341 pWayPointMan->DestroyWaypoint(m_pFoundRoutePoint);
1342 delete proute_array;
1344 parent->undo->BeforeUndoableAction(
1345 Undo_DeleteWaypoint, m_pFoundRoutePoint, Undo_IsOrphanded,
1347 NavObj_dB::GetInstance().DeleteRoutePoint(m_pFoundRoutePoint);
1348 pSelect->DeleteSelectablePoint(m_pFoundRoutePoint,
1349 SELTYPE_ROUTEPOINT);
1350 if (NULL != pWayPointMan)
1352 parent->undo->AfterUndoableAction(NULL);
1359 if (RouteManagerDialog::getInstanceFlag()) {
1365 top_frame::Get()->RefreshAllCanvas(
false);
1366 top_frame::Get()->InvalidateAllGL();
1370 case ID_WP_MENU_PROPERTIES:
1371 parent->ShowMarkPropertiesDialog(m_pFoundRoutePoint);
1374 case ID_WP_MENU_CLEAR_ANCHORWATCH: {
1375 wxString guid = wxEmptyString;
1385 if (!guid.IsEmpty()) {
1388 SendJsonMessageToAllPlugins(
"OCPN_ANCHOR_WATCH_CLEARED", v);
1393 case ID_WP_MENU_SET_ANCHORWATCH: {
1394 wxString guid = wxEmptyString;
1400 nn = m_pFoundRoutePoint->GetName();
1402 nn.Printf(
"%d m", g_nAWDefault);
1403 m_pFoundRoutePoint->SetName(nn);
1410 nn = m_pFoundRoutePoint->GetName();
1412 nn.Printf(
"%d m", g_nAWDefault);
1413 m_pFoundRoutePoint->SetName(nn);
1416 if (!guid.IsEmpty()) {
1419 SendJsonMessageToAllPlugins(
"OCPN_ANCHOR_WATCH_SET", v);
1424 case ID_DEF_MENU_ACTIVATE_MEASURE:
1425 parent->StartMeasureRoute();
1428 case ID_DEF_MENU_DEACTIVATE_MEASURE:
1429 parent->CancelMeasureRoute();
1431 parent->InvalidateGL();
1432 parent->Refresh(
false);
1435 case ID_DEF_MENU_CM93OFFSET_DIALOG: {
1440 cm93compchart *pch = NULL;
1441 if (!parent->GetVP().b_quilt && parent->m_singleChart &&
1442 (parent->m_singleChart->GetChartType() == CHART_TYPE_CM93COMP)) {
1443 pch = (cm93compchart *)parent->m_singleChart;
1454 case ID_DEF_MENU_QUERY: {
1455 parent->ShowObjectQueryWindow(popx, popy, zlat, zlon);
1458 case ID_DEF_MENU_AIS_QUERY: {
1459 ShowAISTargetQueryDialog(parent, m_FoundAIS_MMSI);
1463 case ID_DEF_MENU_AIS_CPA: {
1464 auto myptarget =
g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
1465 if (myptarget) myptarget->Toggle_AIS_CPA();
1469 case ID_DEF_MENU_AISSHOWTRACK: {
1470 auto myptarget =
g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
1471 if (myptarget) myptarget->ToggleShowTrack();
1475 case ID_DEF_MENU_COPY_MMSI: {
1477 if (wxTheClipboard->Open()) {
1478 wxTheClipboard->SetData(
1479 new wxTextDataObject(wxString::Format(
"%09d", m_FoundAIS_MMSI)));
1480 wxTheClipboard->Close();
1485 case ID_DEF_MENU_QUILTREMOVE: {
1486 if (parent->GetVP().b_quilt) {
1487 int dbIndex = parent->m_pQuilt->GetChartdbIndexAtPix(
1488 parent->GetVP(), wxPoint(popx, popy));
1489 parent->RemoveChartFromQuilt(dbIndex);
1497 case ID_DEF_MENU_CURRENTINFO: {
1498 parent->DrawTCWindow(popx, popy, (
void *)m_pIDXCandidate);
1499 parent->Refresh(
false);
1504 case ID_DEF_MENU_TIDEINFO: {
1505 parent->DrawTCWindow(popx, popy, (
void *)m_pIDXCandidate);
1506 parent->Refresh(
false);
1511 case ID_DGB_MENU_NMEA_WINDOW:
1513 m_nmea_log->Raise();
1516 case ID_RT_MENU_REVERSE: {
1517 if (m_pSelectedRoute->m_bIsInLayer)
break;
1520 OCPNMessageBox(parent,
g_pRouteMan->GetRouteReverseMessage(),
1521 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1523 if (ask_return != wxID_CANCEL) {
1524 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1525 m_pSelectedRoute->Reverse(ask_return == wxID_YES);
1526 pSelect->AddAllSelectableRouteSegments(m_pSelectedRoute);
1528 NavObj_dB::GetInstance().UpdateRoute(m_pSelectedRoute);
1534 top_frame::Get()->InvalidateAllGL();
1535 top_frame::Get()->RefreshAllCanvas();
1540 case ID_RT_MENU_SHOWNAMES: {
1541 if (m_pSelectedRoute) {
1542 m_pSelectedRoute->ShowWaypointNames(
1543 !m_pSelectedRoute->AreWaypointNamesVisible());
1549 case ID_RT_MENU_RESEQUENCE: {
1550 if (m_pSelectedRoute) {
1551 if (m_pSelectedRoute->m_bIsInLayer)
break;
1554 OCPNMessageBox(parent,
g_pRouteMan->GetRouteResequenceMessage(),
1555 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1557 if (ask_return != wxID_CANCEL) {
1558 m_pSelectedRoute->RenameRoutePoints();
1561 top_frame::Get()->InvalidateAllGL();
1562 top_frame::Get()->RefreshAllCanvas();
1568 case ID_RT_MENU_DELETE: {
1569 bool confirmed = RouteGui::OnDelete(parent);
1572 if (
g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute)
1575 if (m_pSelectedRoute->m_bIsInLayer)
break;
1577 NavObj_dB::GetInstance().DeleteRoute(m_pSelectedRoute);
1580 if (RouteManagerDialog::getInstanceFlag()) {
1590 parent->undo->InvalidateUndo();
1592 top_frame::Get()->InvalidateAllGL();
1593 top_frame::Get()->RefreshAllCanvas();
1598 case ID_RT_MENU_ACTIVATE: {
1604 RoutePoint *best_point;
1605 if (m_pSelectedRoute) {
1606 if (wxNOT_FOUND == m_pSelectedRoute->m_RouteNameString.Find(
"MOB")) {
1610 best_point = m_pSelectedRoute->GetPoint(2);
1613 m_pSelectedRoute->m_bRtIsSelected =
false;
1619 case ID_RT_MENU_DEACTIVATE:
1621 m_pSelectedRoute->m_bRtIsSelected =
false;
1625 case ID_RT_MENU_INSERT: {
1626 if (m_pSelectedRoute->m_bIsInLayer)
break;
1627 bool rename =
false;
1628 m_pSelectedRoute->InsertPointAfter(m_pFoundRoutePoint, zlat, zlon,
1631 pSelect->DeleteAllSelectableRoutePoints(m_pSelectedRoute);
1632 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1634 pSelect->AddAllSelectableRouteSegments(m_pSelectedRoute);
1635 pSelect->AddAllSelectableRoutePoints(m_pSelectedRoute);
1648 NavObj_dB::GetInstance().UpdateRoute(m_pSelectedRoute);
1657 case ID_RT_MENU_APPEND:
1659 if (m_pSelectedRoute->m_bIsInLayer)
break;
1661 parent->m_pMouseRoute = m_pSelectedRoute;
1662 parent->m_routeState = m_pSelectedRoute->GetnPoints() + 1;
1663 parent->m_pMouseRoute->m_lastMousePointIndex =
1664 m_pSelectedRoute->GetnPoints();
1665 parent->m_pMouseRoute->SetHiLite(50);
1667 pLast = m_pSelectedRoute->GetLastPoint();
1669 parent->m_prev_rlat = pLast->m_lat;
1670 parent->m_prev_rlon = pLast->m_lon;
1671 parent->m_prev_pMousePoint = pLast;
1673 parent->m_bAppendingRoute =
true;
1675 parent->SetCursor(*parent->pCursorPencil);
1677 androidSetRouteAnnunciator(
true);
1680 parent->HideGlobalToolbar();
1684 case ID_RT_MENU_SPLIT_LEG:
1686 dupFirstWpt =
false;
1687 case ID_RT_MENU_SPLIT_WPT:
1691 if (
g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute)
1694 m_pHead =
new Route();
1695 m_pTail =
new Route();
1696 m_pHead->CloneRoute(m_pSelectedRoute, 1, m_SelectedIdx + 1, _(
"_A"));
1697 m_pTail->CloneRoute(m_pSelectedRoute, m_SelectedIdx + 1 + splitMode,
1698 m_pSelectedRoute->GetnPoints(), _(
"_B"), dupFirstWpt);
1700 NavObj_dB::GetInstance().InsertRoute(m_pHead);
1703 NavObj_dB::GetInstance().InsertRoute(m_pTail);
1705 NavObj_dB::GetInstance().DeleteRoute(m_pSelectedRoute);
1707 pSelect->DeleteAllSelectableRoutePoints(m_pSelectedRoute);
1708 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1710 pSelect->AddAllSelectableRouteSegments(m_pTail);
1711 pSelect->AddAllSelectableRoutePoints(m_pTail);
1712 pSelect->AddAllSelectableRouteSegments(m_pHead);
1713 pSelect->AddAllSelectableRoutePoints(m_pHead);
1724 case ID_RT_MENU_COPY:
1725 if (m_pSelectedRoute) Kml::CopyRouteToClipboard(m_pSelectedRoute);
1728 case ID_TK_MENU_COPY:
1729 if (m_pSelectedTrack) Kml::CopyTrackToClipboard(m_pSelectedTrack);
1732 case ID_WPT_MENU_COPY:
1733 if (m_pFoundRoutePoint) Kml::CopyWaypointToClipboard(m_pFoundRoutePoint);
1736 case ID_WPT_MENU_SENDTOGPS:
1737 if (m_pFoundRoutePoint) {
1738 if (parent->m_active_upload_port.Length())
1739 RoutePointGui(*m_pFoundRoutePoint)
1740 .SendToGPS(parent->m_active_upload_port.BeforeFirst(
' '), NULL);
1743 dlg.SetWaypoint(m_pFoundRoutePoint);
1747 dlg.Create(NULL, -1, _(
"Send to GPS") +
"...",
"");
1753 case ID_WPT_MENU_SENDTONEWGPS:
1754 if (m_pFoundRoutePoint) {
1756 dlg.SetWaypoint(m_pFoundRoutePoint);
1758 dlg.Create(NULL, -1, _(
"Send to GPS") +
"...",
"");
1763 case ID_WPT_MENU_SENDTOPEER:
1764 if (m_pFoundRoutePoint) {
1766 dlg.SetWaypoint(m_pFoundRoutePoint);
1771 MdnsCache::GetInstance().
Validate();
1772 if (MdnsCache::GetInstance().GetCache().empty())
1773 dlg.SetScanOnCreate(
true);
1776 dlg.Create(NULL, -1, _(
"Send Waypoint to OpenCPN Peer") +
"...",
"");
1781 case ID_RT_MENU_SENDTOGPS:
1782 if (m_pSelectedRoute) {
1783 if (parent->m_active_upload_port.Length())
1784 RouteGui(*m_pSelectedRoute)
1785 .SendToGPS(parent->m_active_upload_port.BeforeFirst(
' '),
true,
1789 dlg.SetRoute(m_pSelectedRoute);
1791 dlg.Create(NULL, -1, _(
"Send to GPS") +
"...",
"");
1797 case ID_RT_MENU_SENDTONEWGPS:
1798 if (m_pSelectedRoute) {
1800 dlg.SetRoute(m_pSelectedRoute);
1802 dlg.Create(NULL, -1, _(
"Send to GPS") +
"...",
"");
1807 case ID_RT_MENU_SENDTOPEER:
1808 if (m_pSelectedRoute) {
1810 dlg.SetRoute(m_pSelectedRoute);
1815 MdnsCache::GetInstance().
Validate();
1816 if (MdnsCache::GetInstance().GetCache().empty())
1817 dlg.SetScanOnCreate(
true);
1820 dlg.Create(NULL, -1, _(
"Send Route to OpenCPN Peer") +
"...",
"");
1825 case ID_PASTE_WAYPOINT:
1826 pupHandler_PasteWaypoint();
1829 case ID_PASTE_ROUTE:
1830 pupHandler_PasteRoute();
1833 case ID_PASTE_TRACK:
1834 pupHandler_PasteTrack();
1837 case ID_RT_MENU_DELPOINT:
1838 if (m_pSelectedRoute) {
1839 if (m_pSelectedRoute->m_bIsInLayer)
break;
1841 pWayPointMan->DestroyWaypoint(m_pFoundRoutePoint);
1846 if (
g_pRouteMan->IsRouteValid(m_pSelectedRoute)) {
1852 if (RouteManagerDialog::getInstanceFlag()) {
1859 top_frame::Get()->InvalidateAllGL();
1860 top_frame::Get()->RefreshAllCanvas(
true);
1865 case ID_RT_MENU_REMPOINT:
1866 if (m_pSelectedRoute) {
1867 if (m_pSelectedRoute->m_bIsInLayer)
break;
1868 g_pRouteMan->RemovePointFromRoute(m_pFoundRoutePoint, m_pSelectedRoute,
1869 parent->m_routeState);
1870 top_frame::Get()->InvalidateAllGL();
1871 top_frame::Get()->RefreshAllCanvas();
1875 case ID_RT_MENU_ACTPOINT:
1876 if (
g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute) {
1878 m_pSelectedRoute->m_bRtIsSelected =
false;
1883 case ID_RT_MENU_DEACTPOINT:
1886 case ID_RT_MENU_ACTNXTPOINT:
1887 if (
g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute) {
1889 m_pSelectedRoute->m_bRtIsSelected =
false;
1894 case ID_RT_MENU_PROPERTIES: {
1895 parent->ShowRoutePropertiesDialog(_(
"Route Properties"),
1900 case ID_TK_MENU_PROPERTIES: {
1901 parent->ShowTrackPropertiesDialog(m_pSelectedTrack);
1905 case ID_TK_MENU_DELETE: {
1906 int dlg_return = wxID_YES;
1907 if (g_bConfirmObjectDelete) {
1908 dlg_return = OCPNMessageBox(
1909 parent, _(
"Are you sure you want to delete this track?"),
1910 _(
"OpenCPN Track Delete"),
1911 (
long)wxYES_NO | wxCANCEL | wxYES_DEFAULT);
1914 if (dlg_return == wxID_YES) {
1916 m_pSelectedTrack = top_frame::Get()->TrackOff();
1917 g_pAIS->DeletePersistentTrack(m_pSelectedTrack);
1919 NavObj_dB::GetInstance().DeleteTrack(m_pSelectedTrack);
1920 RoutemanGui(*g_pRouteMan).DeleteTrack(m_pSelectedTrack);
1933 top_frame::Get()->InvalidateAllGL();
1934 top_frame::Get()->RefreshAllCanvas();
1939 case ID_TK_MENU_SENDTOPEER:
1940 if (m_pSelectedTrack) {
1942 dlg.SetTrack(m_pSelectedTrack);
1947 MdnsCache::GetInstance().
Validate();
1948 if (MdnsCache::GetInstance().GetCache().empty())
1949 dlg.SetScanOnCreate(
true);
1952 dlg.Create(NULL, -1, _(
"Send Track to OpenCPN Peer") +
"...",
"");
1957 case ID_RC_MENU_SCALE_IN:
1958 top_frame::Get()->DoStackDown(parent);
1959 parent->GetCanvasPointPix(zlat, zlon, &r);
1960 parent->WarpPointer(r.x, r.y);
1963 case ID_RC_MENU_SCALE_OUT:
1964 top_frame::Get()->DoStackUp(parent);
1965 parent->GetCanvasPointPix(zlat, zlon, &r);
1966 parent->WarpPointer(r.x, r.y);
1969 case ID_RC_MENU_ZOOM_IN:
1970 parent->SetVPScale(parent->GetVPScale() * 2);
1971 parent->GetCanvasPointPix(zlat, zlon, &r);
1972 parent->WarpPointer(r.x, r.y);
1975 case ID_RC_MENU_ZOOM_OUT:
1976 parent->SetVPScale(parent->GetVPScale() / 2);
1977 parent->GetCanvasPointPix(zlat, zlon, &r);
1978 parent->WarpPointer(r.x, r.y);
1981 case ID_RC_MENU_FINISH:
1982 parent->FinishRoute();
1984 parent->Refresh(
false);
1985 g_FlushNavobjChanges =
true;
1988 case ID_DEF_ZERO_XTE:
1995 ArrayOfPlugInMenuItems item_array =
1998 for (
unsigned int i = 0; i < item_array.GetCount(); i++) {
1999 PlugInMenuItemContainer *pimis = item_array[i];
2000 int target_id = pimis->id;
2003 if (pimis->pmenu_item->GetSubMenu()) {
2004 const wxMenuItemList &items =
2005 pimis->pmenu_item->GetSubMenu()->GetMenuItems();
2006 for (wxMenuItemList::const_iterator it = items.begin();
2007 it != items.end(); ++it) {
2008 if ((*it)->GetId() == event.GetId()) {
2009 target_id = (*it)->GetId();
2015 if (pimis->m_pplugin && (target_id == event.GetId())) {
2016 if (pimis->extended) {
2017 std::string object_type;
2018 std::string object_ident;
2020 if ((pimis->m_in_menu.IsSameAs(
"Waypoint")) && m_pFoundRoutePoint) {
2021 object_type =
"Waypoint";
2022 object_ident = m_pFoundRoutePoint->m_GUID.ToStdString();
2023 }
else if ((pimis->m_in_menu.IsSameAs(
"Route")) &&
2025 object_type =
"Route";
2026 object_ident = m_pSelectedRoute->m_GUID.ToStdString();
2027 }
else if ((pimis->m_in_menu.IsSameAs(
"Track")) &&
2029 object_type =
"Track";
2030 object_ident = m_pSelectedTrack->m_GUID.ToStdString();
2031 }
else if ((pimis->m_in_menu.IsSameAs(
"AIS")) && m_FoundAIS_MMSI) {
2032 object_type =
"AIS";
2033 wxString sAIS = wxString::Format(
"%d", m_FoundAIS_MMSI);
2034 object_ident = sAIS.ToStdString();
2037 opencpn_plugin_120 *ppi =
2038 dynamic_cast<opencpn_plugin_120 *
>(pimis->m_pplugin);
2040 ppi->OnContextMenuItemCallbackExt(target_id, object_ident,
2041 object_type, zlat, zlon);
2052 if ((event.GetId() >= ID_DEF_MENU_GROUPBASE) &&
2055 parent->SetGroupIndex(event.GetId() - ID_DEF_MENU_GROUPBASE);
2058 parent->InvalidateGL();
AisDecoder * g_pAIS
Global instance.
Class AisDecoder and helpers.
Global state for AIS decoder.
std::unique_ptr< HostApi > GetHostApi()
HostApi factory,.
Charts database management
ChartGroupArray * g_pGroupArray
Global instance.
Basic chart info storage.
Generic Chart canvas base.
ChartCanvas - Main chart display and interaction component.
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.
Represents a navigational route in the navigation system.
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.
wxString m_RouteNameString
User-assigned name for the route.
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.
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.
virtual void OnContextMenuItemCallback(int id)
Handles context menu item selection.
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.
MyFrame * gFrame
Global instance.
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.
RouteManagerDialog * pRouteManagerDialog
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.
Abstract gFrame/MyFrame interface.
ActiveTrack * g_pActiveTrack
global instance
Recorded track abstraction.
Track and Trackpoint drawing stuff.
TrackPropDlg * pTrackPropDialog
Global instance.
Framework for Undo features.