27 #include <wx/wxprec.h>
29 #include <wx/aui/aui.h>
30 #include <wx/clipbrd.h>
31 #include <wx/dynarray.h>
34 #include <wx/gdicmn.h>
35 #include <wx/graphics.h>
37 #include <wx/listbook.h>
38 #include <wx/listimpl.cpp>
41 #include "model/ais_decoder.h"
43 #include "model/ais_target_data.h"
44 #include "model/config_vars.h"
45 #include "model/cutil.h"
46 #include "model/georef.h"
47 #include "model/mdns_cache.h"
48 #include "model/mDNS_query.h"
49 #include "model/nav_object_database.h"
50 #include "model/own_ship.h"
51 #include "model/own_ship.h"
52 #include "model/route.h"
53 #include "model/routeman.h"
54 #include "model/select.h"
55 #include "model/track.h"
58 #include "canvasMenu.h"
67 #include "ocpn_frame.h"
68 #include "OCPNPlatform.h"
69 #include "peer_client_dlg.h"
70 #include "pluginmanager.h"
72 #include "route_gui.h"
73 #include "routemanagerdialog.h"
74 #include "routeman_gui.h"
75 #include "route_point_gui.h"
76 #include "RoutePropDlgImpl.h"
79 #include "SendToGpsDlg.h"
80 #include "SendToPeerDlg.h"
84 #include "tide_time.h"
85 #include "track_gui.h"
86 #include "TrackPropDlg.h"
90 #include "androidUTIL.h"
96 extern void pupHandler_PasteRoute();
97 extern void pupHandler_PasteTrack();
98 extern void pupHandler_PasteWaypoint();
101 extern bool g_bskew_comp;
102 extern double vLat, vLon;
104 extern ChartGroupArray *g_pGroupArray;
107 extern int g_nAWDefault;
108 extern wxString g_AW1GUID;
109 extern wxString g_AW2GUID;
110 extern int g_click_stop;
115 extern bool g_bConfirmObjectDelete;
122 extern RouteList *pRouteList;
123 extern wxString g_default_wp_icon;
124 extern bool g_bBasicMenus;
126 extern bool g_FlushNavobjChanges;
127 extern ColorScheme global_color_scheme;
131 ID_DEF_MENU_MAX_DETAIL = 1,
132 ID_DEF_MENU_SCALE_IN,
133 ID_DEF_MENU_SCALE_OUT,
137 ID_DEF_MENU_MOVE_BOAT_HERE,
138 ID_DEF_MENU_GOTO_HERE,
139 ID_DEF_MENU_GOTOPOSITION,
143 ID_WP_MENU_PROPERTIES,
145 ID_RT_MENU_DEACTIVATE,
149 ID_RT_MENU_SPLIT_LEG,
150 ID_RT_MENU_SPLIT_WPT,
153 ID_WPT_MENU_SENDTOGPS,
154 ID_WPT_MENU_SENDTONEWGPS,
155 ID_WPT_MENU_SENDTOPEER,
163 ID_RT_MENU_DEACTPOINT,
164 ID_RT_MENU_ACTNXTPOINT,
166 ID_RT_MENU_PROPERTIES,
167 ID_RT_MENU_SENDTOGPS,
168 ID_RT_MENU_SENDTONEWGPS,
169 ID_RT_MENU_SHOWNAMES,
170 ID_RT_MENU_RESEQUENCE,
171 ID_RT_MENU_SENDTOPEER,
172 ID_WP_MENU_SET_ANCHORWATCH,
173 ID_WP_MENU_CLEAR_ANCHORWATCH,
174 ID_DEF_MENU_AISTARGETLIST,
175 ID_DEF_MENU_AIS_CPAWARNING,
178 ID_RC_MENU_SCALE_OUT,
182 ID_DEF_MENU_AIS_QUERY,
184 ID_DEF_MENU_AISSHOWTRACK,
185 ID_DEF_MENU_ACTIVATE_MEASURE,
186 ID_DEF_MENU_DEACTIVATE_MEASURE,
187 ID_DEF_MENU_COPY_MMSI,
192 ID_DEF_MENU_CM93OFFSET_DIALOG,
194 ID_TK_MENU_PROPERTIES,
196 ID_TK_MENU_SENDTOPEER,
197 ID_WP_MENU_ADDITIONAL_INFO,
199 ID_DEF_MENU_QUILTREMOVE,
203 ID_DEF_MENU_TOGGLE_FULL,
204 ID_DEF_MENU_TIDEINFO,
205 ID_DEF_MENU_CURRENTINFO,
208 ID_DEF_MENU_GROUPBASE,
217 int CanvasMenuHandler::GetNextContextMenuId() {
218 return ID_DEF_MENU_LAST +
222 wxFont CanvasMenuHandler::m_scaledFont;
225 CanvasMenuHandler::CanvasMenuHandler(
ChartCanvas *parentCanvas,
228 int selectedAIS_MMSI,
229 void *selectedTCIndex)
232 parent = parentCanvas;
233 m_pSelectedRoute = selectedRoute;
234 m_pSelectedTrack = selectedTrack;
235 m_pFoundRoutePoint = selectedPoint;
236 m_FoundAIS_MMSI = selectedAIS_MMSI;
237 m_pIDXCandidate = selectedTCIndex;
238 if (!m_scaledFont.IsOk()) {
239 wxFont *qFont = GetOCPNScaledFont(_(
"Menu"));
240 m_scaledFont = *qFont;
243 m_DIPFactor = g_Platform->GetDisplayDIPMult(gFrame);
246 CanvasMenuHandler::~CanvasMenuHandler() {}
252 void CanvasMenuHandler::PrepareMenuItem(wxMenuItem *item) {
253 #if defined(__WXMSW__)
254 wxColour ctrl_back_color = GetGlobalColor(_T(
"DILG1"));
255 item->SetBackgroundColour(ctrl_back_color);
256 wxColour menu_text_color = GetGlobalColor(_T (
"UITX1" ));
257 item->SetTextColour(menu_text_color);
261 void CanvasMenuHandler::MenuPrepend1(wxMenu *menu,
int id, wxString label) {
262 wxMenuItem *item =
new wxMenuItem(menu,
id, label);
263 #if defined(__WXMSW__)
264 item->SetFont(m_scaledFont);
268 wxFont sFont = GetOCPNGUIScaledFont(_(
"Menu"));
269 item->SetFont(sFont);
272 PrepareMenuItem(item);
274 if (g_btouch) menu->InsertSeparator(0);
278 void CanvasMenuHandler::MenuAppend1(wxMenu *menu,
int id, wxString label) {
279 wxMenuItem *item =
new wxMenuItem(menu,
id, label);
280 #if defined(__WXMSW__)
281 item->SetFont(m_scaledFont);
285 wxFont sFont = GetOCPNGUIScaledFont(_T(
"Menu"));
286 item->SetFont(sFont);
289 PrepareMenuItem(item);
292 if (g_btouch) menu->AppendSeparator();
295 void CanvasMenuHandler::SetMenuItemFont1(wxMenuItem *item) {
296 #if defined(__WXMSW__)
297 item->SetFont(m_scaledFont);
300 #if defined(__ANDROID__)
301 wxFont *qFont = GetOCPNScaledFont(_(
"Menu"));
302 item->SetFont(*qFont);
305 PrepareMenuItem(item);
308 void CanvasMenuHandler::CanvasPopupMenu(
int x,
int y,
int seltype) {
309 wxMenu *contextMenu =
new wxMenu;
310 wxMenu *menuWaypoint = NULL;
311 wxMenu *menuRoute = NULL;
312 wxMenu *menuTrack = NULL;
313 wxMenu *menuAIS = NULL;
315 wxMenu *subMenuChart =
new wxMenu;
316 wxMenu *subMenuUndo =
new wxMenu(
"Undo...Ctrl-Z");
319 wxMenu *subMenuRedo =
new wxMenu(
"Redo...Shift-Ctrl-Z");
321 wxMenu *subMenuRedo =
new wxMenu(
"Redo...Ctrl-Y");
324 wxMenu *menuFocus = contextMenu;
329 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
330 bool bsubMenus =
false;
333 if (parent->undo->AnythingToUndo()) {
335 wxMenuItem *subMenuItemundo =
336 contextMenu->AppendSubMenu(subMenuUndo, _(
"Undo"));
339 undoItem << _(
"Undo") << _T(
" ")
340 << parent->undo->GetNextUndoableAction()->Description();
341 MenuAppend1(subMenuUndo, ID_UNDO, undoItem);
343 if (parent->undo->AnythingToRedo()) {
345 wxMenuItem *subMenuItemRedo =
346 contextMenu->AppendSubMenu(subMenuRedo, _(
"Redo"));
349 redoItem << _(
"Redo") << _T(
" ")
350 << parent->undo->GetNextRedoableAction()->Description();
351 MenuAppend1(subMenuRedo, ID_REDO, redoItem);
354 if (parent->undo->AnythingToUndo()) {
356 undoItem << _(
"Undo") << _T(
" ")
357 << parent->undo->GetNextUndoableAction()->Description();
358 MenuAppend1(contextMenu, ID_UNDO, _menuText(undoItem, _T(
"Ctrl-Z")));
361 if (parent->undo->AnythingToRedo()) {
363 redoItem << _(
"Redo") << _T(
" ")
364 << parent->undo->GetNextRedoableAction()->Description();
366 MenuAppend1(contextMenu, ID_REDO,
367 _menuText(redoItem, _T(
"Shift-Ctrl-Z")));
369 MenuAppend1(contextMenu, ID_REDO, _menuText(redoItem, _T(
"Ctrl-Y")));
375 if (seltype == SELTYPE_ROUTECREATE) {
376 MenuAppend1(contextMenu, ID_RC_MENU_FINISH,
377 _menuText(_(
"End Route"), _T(
"Esc")));
380 if (!parent->m_pMouseRoute) {
381 if (parent->m_bMeasure_Active)
382 MenuAppend1(contextMenu, ID_DEF_MENU_DEACTIVATE_MEASURE,
383 _menuText(_(
"Measure Off"), _T(
"Esc")));
385 MenuAppend1(contextMenu, ID_DEF_MENU_ACTIVATE_MEASURE,
386 _menuText(_(
"Measure"), _T(
"M")));
389 bool ais_areanotice =
false;
390 if (g_pAIS && parent->GetShowAIS() && g_bShowAreaNotices) {
391 float vp_scale = parent->GetVPScale();
393 for (
const auto &target : g_pAIS->GetAreaNoticeSourcesList()) {
394 auto target_data = target.second;
395 if (!target_data->area_notices.empty()) {
396 for (
auto &ani : target_data->area_notices) {
400 for (Ais8_001_22_SubAreaList::iterator sa =
401 area_notice.sub_areas.begin();
402 sa != area_notice.sub_areas.end(); ++sa) {
404 case AIS8_001_22_SHAPE_CIRCLE: {
405 wxPoint target_point;
406 parent->GetCanvasPointPix(sa->latitude, sa->longitude,
408 bbox.Expand(target_point);
409 if (sa->radius_m > 0.0) bbox.EnLarge(sa->radius_m * vp_scale);
412 case AIS8_001_22_SHAPE_RECT:
413 case AIS8_001_22_SHAPE_POLYGON:
414 case AIS8_001_22_SHAPE_POLYLINE: {
415 double lat = sa->latitude;
416 double lon = sa->longitude;
417 for (
int i = 0; i < 4; ++i) {
418 ll_gc_ll(lat, lon, sa->angles[i], sa->dists_m[i] / 1852.0,
420 wxPoint target_point;
421 parent->GetCanvasPointPix(lat, lon, &target_point);
422 bbox.Expand(target_point);
426 case AIS8_001_22_SHAPE_SECTOR: {
427 double lat1 = sa->latitude;
428 double lon1 = sa->longitude;
430 wxPoint target_point;
431 parent->GetCanvasPointPix(lat1, lon1, &target_point);
432 bbox.Expand(target_point);
433 for (
int i = 0; i < 18; ++i) {
434 ll_gc_ll(lat1, lon1, sa->left_bound_deg + i * (sa->right_bound_deg - sa->left_bound_deg) / 18 , sa->radius_m / 1852.0,
436 parent->GetCanvasPointPix(lat, lon, &target_point);
437 bbox.Expand(target_point);
439 ll_gc_ll(lat1, lon1, sa->right_bound_deg , sa->radius_m / 1852.0,
441 parent->GetCanvasPointPix(lat, lon, &target_point);
442 bbox.Expand(target_point);
448 if (bbox.GetValid() && bbox.PointInBox(x, y)) {
449 ais_areanotice =
true;
458 if (parent->GetpCurrentStack())
459 nChartStack = parent->GetpCurrentStack()->nEntry;
461 if (!parent->GetVP().b_quilt) {
462 if (nChartStack > 1) {
463 MenuAppend1(contextMenu, ID_DEF_MENU_MAX_DETAIL, _(
"Max Detail Here"));
464 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_IN,
465 _menuText(_(
"Scale In"), _T(
"Ctrl-Left")));
466 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_OUT,
467 _menuText(_(
"Scale Out"), _T(
"Ctrl-Right")));
470 if ((parent->m_singleChart &&
471 (parent->m_singleChart->GetChartFamily() == CHART_FAMILY_VECTOR)) ||
473 MenuAppend1(contextMenu, ID_DEF_MENU_QUERY,
474 _(
"Object Query") + _T(
"..." ));
479 parent->m_pQuilt->GetChartAtPix(parent->GetVP(), wxPoint(x, y));
480 if ((pChartTest && (pChartTest->GetChartFamily() == CHART_FAMILY_VECTOR)) ||
482 MenuAppend1(contextMenu, ID_DEF_MENU_QUERY,
483 _(
"Object Query") + _T(
"..." ));
486 if (!g_bBasicMenus && (nChartStack > 1)) {
487 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_IN,
488 _menuText(_(
"Scale In"), _T(
"Ctrl-Left")));
489 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_OUT,
490 _menuText(_(
"Scale Out"), _T(
"Ctrl-Right")));
496 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
497 bool b_dm_add =
true;
498 if (g_btouch && parent->IsMeasureActive()) b_dm_add =
false;
501 MenuAppend1(contextMenu, ID_DEF_MENU_DROP_WP,
502 _menuText(_(
"Drop Mark"), _T(
"Ctrl-M")));
503 MenuAppend1(contextMenu, ID_DEF_MENU_NEW_RT,
504 _menuText(_(
"New Route..."), _T(
"Ctrl-R")));
508 MenuAppend1(contextMenu, ID_DEF_MENU_MOVE_BOAT_HERE, _(
"Move Boat Here"));
511 if (!g_bBasicMenus &&
512 (!(g_pRouteMan->GetpActiveRoute() || (seltype & SELTYPE_MARKPOINT))))
513 MenuAppend1(contextMenu, ID_DEF_MENU_GOTO_HERE, _(
"Navigate To Here"));
516 MenuAppend1(contextMenu, ID_DEF_MENU_GOTOPOSITION,
517 _(
"Center view") + _T(
"..."));
519 if (!g_bBasicMenus) {
520 if (parent->GetVP().b_quilt) {
521 if (parent->GetUpMode() == NORTH_UP_MODE) {
522 MenuAppend1(contextMenu, ID_DEF_MENU_COGUP, _(
"Course Up Mode"));
523 if (!std::isnan(gHdt))
524 MenuAppend1(contextMenu, ID_DEF_MENU_HEADUP, _(
"Heading Up Mode"));
526 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"North Up Mode"));
529 if (parent->m_singleChart &&
530 (fabs(parent->m_singleChart->GetChartSkew()) > .01) && !g_bskew_comp)
531 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"Chart Up Mode"));
533 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"North Up Mode"));
537 if (!g_bBasicMenus) {
538 bool full_toggle_added =
false;
541 MenuAppend1(contextMenu, ID_DEF_MENU_TOGGLE_FULL,
542 _(
"Toggle Full Screen"));
543 full_toggle_added =
true;
546 if (!full_toggle_added) {
548 MenuAppend1(contextMenu, ID_DEF_MENU_TOGGLE_FULL,
549 _(
"Toggle Full Screen"));
553 if (g_pRouteMan->IsAnyRouteActive() &&
554 g_pRouteMan->GetCurrentXTEToActivePoint() > 0.)
555 MenuAppend1(contextMenu, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
558 int pasteBuffer = kml->ParsePasteBuffer();
559 if (pasteBuffer != KML_PASTE_INVALID) {
560 switch (pasteBuffer) {
561 case KML_PASTE_WAYPOINT: {
562 MenuAppend1(contextMenu, ID_PASTE_WAYPOINT, _(
"Paste Waypoint"));
565 case KML_PASTE_ROUTE: {
566 MenuAppend1(contextMenu, ID_PASTE_ROUTE, _(
"Paste Route"));
569 case KML_PASTE_TRACK: {
570 MenuAppend1(contextMenu, ID_PASTE_TRACK, _(
"Paste Track"));
573 case KML_PASTE_ROUTE_TRACK: {
574 MenuAppend1(contextMenu, ID_PASTE_ROUTE, _(
"Paste Route"));
575 MenuAppend1(contextMenu, ID_PASTE_TRACK, _(
"Paste Track"));
582 if (!parent->GetVP().b_quilt && parent->m_singleChart &&
583 (parent->m_singleChart->GetChartType() == CHART_TYPE_CM93COMP)) {
584 MenuAppend1(contextMenu, ID_DEF_MENU_CM93OFFSET_DIALOG,
585 _(
"CM93 Offset Dialog..."));
609 wxMenuItem *subItemChart =
610 contextMenu->AppendSubMenu(subMenuChart, _(
"Chart Groups"));
611 if (g_btouch) contextMenu->AppendSeparator();
613 SetMenuItemFont1(subItemChart);
615 if (g_pGroupArray->GetCount()) {
617 MenuAppend1(subMenuChart, wxID_CANCEL, _(
"temporary"));
619 wxMenuItem *subItem0 = subMenuChart->AppendRadioItem(
620 ID_DEF_MENU_GROUPBASE, _(
"All Active Charts"));
622 SetMenuItemFont1(subItem0);
624 for (
unsigned int i = 0; i < g_pGroupArray->GetCount(); i++) {
625 subItem0 = subMenuChart->AppendRadioItem(
626 ID_DEF_MENU_GROUPBASE + i + 1, g_pGroupArray->Item(i)->m_group_name);
627 SetMenuItemFont1(subItem0);
631 subMenuChart->Remove(wxID_CANCEL);
633 subMenuChart->Check(ID_DEF_MENU_GROUPBASE + parent->m_groupIndex,
true);
637 menuFocus = contextMenu;
640 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
642 if (parent->GetShowAIS() && (seltype & SELTYPE_AISTARGET)) {
643 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
644 if (!g_bBasicMenus && myptarget) {
645 name = myptarget->GetFullName();
646 if (name.IsEmpty()) name.Printf(_T(
"%d"), m_FoundAIS_MMSI);
647 name.Prepend(_T(
" ( ")).Append(_T(
" )"));
649 name = wxEmptyString;
650 menuAIS =
new wxMenu(_(
"AIS") + name);
651 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_QUERY, _(
"Target Query..."));
652 if (myptarget && myptarget->bCPA_Valid &&
653 (myptarget->n_alert_state != AIS_ALERT_SET)) {
654 if (myptarget->b_show_AIS_CPA)
655 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_CPA, _(
"Hide Target CPA"));
657 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_CPA, _(
"Show Target CPA"));
659 MenuAppend1(menuAIS, ID_DEF_MENU_AISTARGETLIST, _(
"Target List..."));
660 if (myptarget->Class != AIS_METEO ) {
661 if (myptarget && !myptarget->b_PersistTrack) {
662 if (myptarget->b_show_track)
663 MenuAppend1(menuAIS, ID_DEF_MENU_AISSHOWTRACK,
664 _(
"Hide Target Track"));
666 MenuAppend1(menuAIS, ID_DEF_MENU_AISSHOWTRACK,
667 _(
"Show Target Track"));
671 MenuAppend1(menuAIS, ID_DEF_MENU_COPY_MMSI, _(
"Copy Target MMSI"));
672 menuAIS->AppendSeparator();
674 if (!parent->GetVP().b_quilt) {
675 if ((parent->m_singleChart &&
676 (parent->m_singleChart->GetChartFamily() ==
677 CHART_FAMILY_VECTOR))) {
678 MenuAppend1(menuAIS, ID_DEF_MENU_QUERY, _(
"Object Query..."));
683 parent->m_pQuilt->GetChartAtPix(parent->GetVP(), wxPoint(x, y));
685 (pChartTest->GetChartFamily() == CHART_FAMILY_VECTOR))) {
686 MenuAppend1(menuAIS, ID_DEF_MENU_QUERY, _(
"Object Query..."));
692 MenuAppend1(contextMenu, ID_DEF_MENU_AISTARGETLIST,
693 _(
"AIS target list") + _T(
"..."));
695 wxString nextCPAstatus = g_bCPAWarn ? _(
"Hide") : _(
"Show");
696 MenuAppend1(contextMenu, ID_DEF_MENU_AIS_CPAWARNING,
697 _menuText(nextCPAstatus +
" " + _(
"CPA alarm "),
"W"));
702 if (seltype & SELTYPE_ROUTESEGMENT) {
703 if (!g_bBasicMenus && m_pSelectedRoute) {
704 name = m_pSelectedRoute->m_RouteNameString;
705 if (name.IsEmpty()) name = _(
"Unnamed Route");
706 name.Prepend(_T(
" ( ")).Append(_T(
" )"));
708 name = wxEmptyString;
710 if (m_pSelectedRoute && m_pSelectedRoute->m_bIsInLayer) blay =
true;
713 menuRoute =
new wxMenu(_(
"Layer Route") + name);
714 MenuAppend1(menuRoute, ID_RT_MENU_PROPERTIES,
715 _(
"Properties") + _T(
"..." ));
716 if (m_pSelectedRoute) {
717 if (m_pSelectedRoute->IsActive()) {
718 int indexActive = m_pSelectedRoute->GetIndexOf(
719 m_pSelectedRoute->m_pRouteActivePoint);
720 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints()) {
721 MenuAppend1(menuRoute, ID_RT_MENU_ACTNXTPOINT,
722 _(
"Activate Next Waypoint"));
724 MenuAppend1(menuRoute, ID_RT_MENU_DEACTIVATE, _(
"Deactivate"));
725 MenuAppend1(menuRoute, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
727 MenuAppend1(menuRoute, ID_RT_MENU_ACTIVATE, _(
"Activate"));
731 menuRoute =
new wxMenu(_(
"Route") + name);
732 MenuAppend1(menuRoute, ID_RT_MENU_PROPERTIES,
733 _(
"Properties") + _T(
"..." ));
734 if (m_pSelectedRoute) {
735 if (m_pSelectedRoute->IsActive()) {
736 int indexActive = m_pSelectedRoute->GetIndexOf(
737 m_pSelectedRoute->m_pRouteActivePoint);
738 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints()) {
739 MenuAppend1(menuRoute, ID_RT_MENU_ACTNXTPOINT,
740 _(
"Activate Next Waypoint"));
742 MenuAppend1(menuRoute, ID_RT_MENU_DEACTIVATE, _(
"Deactivate"));
743 MenuAppend1(menuRoute, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
745 MenuAppend1(menuRoute, ID_RT_MENU_ACTIVATE, _(
"Activate"));
748 MenuAppend1(menuRoute, ID_RT_MENU_INSERT, _(
"Insert Waypoint"));
749 MenuAppend1(menuRoute, ID_RT_MENU_APPEND, _(
"Append Waypoint"));
750 if (!(seltype & SELTYPE_ROUTEPOINT) && m_pSelectedRoute) {
751 m_SelectedIdx = m_pSelectedRoute->GetIndexOf(m_pFoundRoutePoint);
752 if (m_SelectedIdx > 1 &&
753 m_SelectedIdx < m_pSelectedRoute->GetnPoints() - 1)
754 MenuAppend1(menuRoute, ID_RT_MENU_SPLIT_LEG, _(
"Split around Leg"));
756 MenuAppend1(menuRoute, ID_RT_MENU_COPY, _(
"Copy as KML") + _T(
"..." ));
757 MenuAppend1(menuRoute, ID_RT_MENU_DELETE, _(
"Delete") + _T(
"..." ));
758 MenuAppend1(menuRoute, ID_RT_MENU_REVERSE, _(
"Reverse..."));
759 if (m_pSelectedRoute) {
760 if (m_pSelectedRoute->AreWaypointNamesVisible())
761 MenuAppend1(menuRoute, ID_RT_MENU_SHOWNAMES,
762 _(
"Hide Waypoint Names"));
764 MenuAppend1(menuRoute, ID_RT_MENU_SHOWNAMES,
765 _(
"Show Waypoint Names"));
767 MenuAppend1(menuRoute, ID_RT_MENU_RESEQUENCE,
768 _(
"Resequence Waypoints..."));
771 wxString port = parent->FindValidUploadPort();
772 parent->m_active_upload_port = port;
773 wxString item = _(
"Send to GPS");
774 if (!port.IsEmpty()) {
775 item.Append(_T(
" ( "));
777 item.Append(_T(
" )"));
779 MenuAppend1(menuRoute, ID_RT_MENU_SENDTOGPS, item);
781 if (!port.IsEmpty()) {
782 wxString item = _(
"Send to new GPS");
783 MenuAppend1(menuRoute, ID_RT_MENU_SENDTONEWGPS, item);
786 wxString itemstp = SYMBOL_STP_TITLE;
787 MenuAppend1(menuRoute, ID_RT_MENU_SENDTOPEER, itemstp);
790 if (menuFocus != menuAIS) menuFocus = menuRoute;
793 if (seltype & SELTYPE_TRACKSEGMENT) {
794 name = wxEmptyString;
795 if (!g_bBasicMenus && m_pSelectedTrack)
796 name = _T(
" ( ") + m_pSelectedTrack->GetName(
true) + _T(
" )");
798 name = wxEmptyString;
800 if (m_pSelectedTrack && m_pSelectedTrack->m_bIsInLayer) blay =
true;
803 menuTrack =
new wxMenu(_(
"Layer Track") + name);
804 MenuAppend1(menuTrack, ID_TK_MENU_PROPERTIES,
805 _(
"Properties") + _T(
"..." ));
807 menuTrack =
new wxMenu(_(
"Track") + name);
808 MenuAppend1(menuTrack, ID_TK_MENU_PROPERTIES,
809 _(
"Properties") + _T(
"..." ));
810 MenuAppend1(menuTrack, ID_TK_MENU_COPY, _(
"Copy as KML"));
811 MenuAppend1(menuTrack, ID_TK_MENU_DELETE, _(
"Delete") + _T(
"..." ));
814 wxString itemstp = SYMBOL_STP_TITLE;
815 MenuAppend1(menuTrack, ID_TK_MENU_SENDTOPEER, itemstp);
818 if (menuFocus != menuAIS) menuFocus = menuTrack;
821 if (seltype & SELTYPE_ROUTEPOINT) {
822 if (!g_bBasicMenus && m_pFoundRoutePoint) {
823 name = m_pFoundRoutePoint->GetName();
824 if (name.IsEmpty()) name = _(
"Unnamed Waypoint");
825 name.Prepend(_T(
" ( ")).Append(_T(
" )"));
827 name = wxEmptyString;
829 if (m_pFoundRoutePoint && m_pFoundRoutePoint->m_bIsInLayer) blay =
true;
832 menuWaypoint =
new wxMenu(_(
"Layer Waypoint") + name);
833 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
834 _(
"Properties") + _T(
"..." ));
836 if (m_pSelectedRoute && m_pSelectedRoute->IsActive())
837 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTPOINT, _(
"Activate"));
839 menuWaypoint =
new wxMenu(_(
"Waypoint") + name);
840 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
841 _(
"Properties") + _T(
"..." ));
842 if (m_pSelectedRoute && m_pSelectedRoute->IsActive()) {
843 if (m_pSelectedRoute->m_pRouteActivePoint != m_pFoundRoutePoint)
844 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTPOINT, _(
"Activate"));
847 if (m_pSelectedRoute && m_pSelectedRoute->IsActive()) {
848 if (m_pSelectedRoute->m_pRouteActivePoint == m_pFoundRoutePoint) {
849 int indexActive = m_pSelectedRoute->GetIndexOf(
850 m_pSelectedRoute->m_pRouteActivePoint);
851 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints())
852 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTNXTPOINT,
853 _(
"Activate Next Waypoint"));
856 if (m_pSelectedRoute && m_pSelectedRoute->GetnPoints() > 2) {
857 MenuAppend1(menuWaypoint, ID_RT_MENU_REMPOINT, _(
"Remove from Route"));
859 m_SelectedIdx = m_pSelectedRoute->GetIndexOf(m_pFoundRoutePoint);
860 if (m_SelectedIdx > 1 && m_SelectedIdx < m_pSelectedRoute->GetnPoints())
861 MenuAppend1(menuWaypoint, ID_RT_MENU_SPLIT_WPT,
862 _(
"Split Route at Waypoint"));
865 MenuAppend1(menuWaypoint, ID_WPT_MENU_COPY, _(
"Copy as KML"));
867 if (m_pFoundRoutePoint && m_pFoundRoutePoint->GetIconName() != _T(
"mob"))
868 MenuAppend1(menuWaypoint, ID_RT_MENU_DELPOINT, _(
"Delete"));
871 wxString port = parent->FindValidUploadPort();
872 parent->m_active_upload_port = port;
873 wxString item = _(
"Send to GPS");
874 if (!port.IsEmpty()) {
875 item.Append(_T(
" ( "));
877 item.Append(_T(
" )"));
879 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOGPS, item);
881 if (!port.IsEmpty()) {
882 wxString item = _(
"Send to new GPS");
883 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTONEWGPS, item);
886 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOPEER,
891 if (menuFocus != menuAIS) menuFocus = menuWaypoint;
894 if (seltype & SELTYPE_MARKPOINT) {
895 if (!g_bBasicMenus && m_pFoundRoutePoint) {
896 name = m_pFoundRoutePoint->GetName();
897 if (name.IsEmpty()) name = _(
"Unnamed Mark");
898 name.Prepend(_T(
" ( ")).Append(_T(
" )"));
900 name = wxEmptyString;
902 if (m_pFoundRoutePoint && m_pFoundRoutePoint->m_bIsInLayer) blay =
true;
905 menuWaypoint =
new wxMenu(_(
"Layer Waypoint") + name);
906 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
907 _(
"Properties") + _T(
"..." ));
909 menuWaypoint =
new wxMenu(_(
"Mark") + name);
910 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
911 _(
"Properties") + _T(
"..." ));
913 if (!g_pRouteMan->GetpActiveRoute())
914 MenuAppend1(menuWaypoint, ID_WP_MENU_GOTO, _(
"Navigate To This"));
916 MenuAppend1(menuWaypoint, ID_WPT_MENU_COPY, _(
"Copy as KML"));
918 if (m_pFoundRoutePoint && m_pFoundRoutePoint->GetIconName() != _T(
"mob"))
919 MenuAppend1(menuWaypoint, ID_WP_MENU_DELPOINT, _(
"Delete"));
922 wxString port = parent->FindValidUploadPort();
923 parent->m_active_upload_port = port;
924 wxString item = _(
"Send to GPS");
925 if (!port.IsEmpty()) {
926 item.Append(_T(
" ( "));
928 item.Append(_T(
" )"));
930 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOGPS, item);
932 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOPEER,
936 if ((m_pFoundRoutePoint == pAnchorWatchPoint1) ||
937 (m_pFoundRoutePoint == pAnchorWatchPoint2))
938 MenuAppend1(menuWaypoint, ID_WP_MENU_CLEAR_ANCHORWATCH,
939 _(
"Clear Anchor Watch"));
941 if (m_pFoundRoutePoint && !(m_pFoundRoutePoint->m_bIsInLayer) &&
942 ((NULL == pAnchorWatchPoint1) || (NULL == pAnchorWatchPoint2))) {
945 DistanceBearingMercator(m_pFoundRoutePoint->m_lat,
946 m_pFoundRoutePoint->m_lon, gLat, gLon, &brg,
948 if (dist * 1852. <= g_nAWMax)
949 MenuAppend1(menuWaypoint, ID_WP_MENU_SET_ANCHORWATCH,
950 _(
"Set Anchor Watch"));
955 if (menuFocus != menuAIS) menuFocus = menuWaypoint;
958 enum { WPMENU = 1, TKMENU = 2, RTMENU = 4, MMMENU = 8 };
960 if (!g_bBasicMenus && menuFocus != contextMenu) {
961 if (global_color_scheme != GLOBAL_COLOR_SCHEME_DUSK &&
962 global_color_scheme != GLOBAL_COLOR_SCHEME_NIGHT) {
963 menuFocus->AppendSeparator();
965 wxMenuItem *subMenu1;
966 if (menuWaypoint && menuFocus != menuWaypoint) {
968 menuFocus->AppendSubMenu(menuWaypoint, menuWaypoint->GetTitle());
969 SetMenuItemFont1(subMenu1);
972 menuWaypoint->SetTitle(wxEmptyString);
975 if (menuTrack && menuFocus != menuTrack) {
976 subMenu1 = menuFocus->AppendSubMenu(menuTrack, menuTrack->GetTitle());
977 SetMenuItemFont1(subMenu1);
980 menuTrack->SetTitle(wxEmptyString);
983 if (menuRoute && menuFocus != menuRoute) {
984 subMenu1 = menuFocus->AppendSubMenu(menuRoute, menuRoute->GetTitle());
985 SetMenuItemFont1(subMenu1);
988 menuRoute->SetTitle(wxEmptyString);
991 subMenu1 = menuFocus->AppendSubMenu(contextMenu, _(
"Main Menu"));
992 SetMenuItemFont1(subMenu1);
996 if (!subMenuChart->GetMenuItemCount()) contextMenu->Destroy(subItemChart);
1001 if (seltype & SELTYPE_TIDEPOINT) {
1002 menuFocus->AppendSeparator();
1004 MenuAppend1(menuFocus, ID_DEF_MENU_TIDEINFO, _(
"Show Tide Information"));
1007 if (seltype & SELTYPE_CURRENTPOINT) {
1008 if (!bsep) menuFocus->AppendSeparator();
1009 MenuAppend1(menuFocus, ID_DEF_MENU_CURRENTINFO,
1010 _(
"Show Current Information"));
1014 g_pi_manager->PrepareAllPluginContextMenus();
1017 ArrayOfPlugInMenuItems item_array =
1018 g_pi_manager->GetPluginContextMenuItemArray();
1020 for (
unsigned int i = 0; i < item_array.GetCount(); i++) {
1022 if (!pimis->b_viz)
continue;
1024 wxMenu *submenu = NULL;
1025 if (pimis->pmenu_item->GetSubMenu()) {
1026 submenu =
new wxMenu();
1027 const wxMenuItemList &items =
1028 pimis->pmenu_item->GetSubMenu()->GetMenuItems();
1029 for (wxMenuItemList::const_iterator it = items.begin(); it != items.end();
1032 for (
unsigned int j = 0; j < item_array.GetCount(); j++) {
1034 if (pimis->pmenu_item == *it)
id = pimis->id;
1037 wxMenuItem *pmi =
new wxMenuItem(submenu,
id,
1038 #
if wxCHECK_VERSION(3, 0, 0)
1039 (*it)->GetItemLabelText(),
1043 (*it)->GetHelp(), (*it)->GetKind());
1046 pmi->SetFont(m_scaledFont);
1050 wxFont sFont = GetOCPNGUIScaledFont(_(
"Menu"));
1051 pmi->SetFont(sFont);
1054 PrepareMenuItem(pmi);
1055 submenu->Append(pmi);
1056 pmi->Check((*it)->IsChecked());
1060 wxMenuItem *pmi =
new wxMenuItem(contextMenu, pimis->id,
1061 #
if wxCHECK_VERSION(3, 0, 0)
1062 pimis->pmenu_item->GetItemLabelText(),
1064 pimis->pmenu_item->GetLabel(),
1066 pimis->pmenu_item->GetHelp(),
1067 pimis->pmenu_item->GetKind(), submenu);
1069 pmi->SetFont(m_scaledFont);
1073 wxFont sFont = GetOCPNGUIScaledFont(_(
"Menu"));
1074 pmi->SetFont(sFont);
1077 PrepareMenuItem(pmi);
1079 wxMenu *dst = contextMenu;
1080 if (pimis->m_in_menu ==
"Waypoint")
1082 else if (pimis->m_in_menu ==
"Route")
1084 else if (pimis->m_in_menu ==
"Track")
1086 else if (pimis->m_in_menu ==
"AIS")
1091 dst->Enable(pimis->id, !pimis->b_grey);
1098 androidEnableBackButton(
false);
1099 androidEnableOptionsMenu(
false);
1101 setMenuStyleSheet(menuRoute, GetOCPNGUIScaledFont(_T(
"Menu")));
1102 setMenuStyleSheet(menuWaypoint, GetOCPNGUIScaledFont(_T(
"Menu")));
1103 setMenuStyleSheet(menuTrack, GetOCPNGUIScaledFont(_T(
"Menu")));
1104 setMenuStyleSheet(menuAIS, GetOCPNGUIScaledFont(_T(
"Menu")));
1107 parent->PopupMenu(menuFocus, x, y);
1110 androidEnableBackButton(
true);
1111 androidEnableOptionsMenu(
true);
1118 if (!(sub_menu & MMMENU))
delete contextMenu;
1119 if (!(sub_menu & RTMENU))
delete menuRoute;
1120 if (!(sub_menu & TKMENU))
delete menuTrack;
1121 if (!(sub_menu & WPMENU))
delete menuWaypoint;
1124 void CanvasMenuHandler::PopupMenuHandler(wxCommandEvent &event) {
1131 bool dupFirstWpt =
true, showRPD;
1133 parent->GetCanvasPixPoint(popx * parent->GetDisplayScale(),
1134 popy * parent->GetDisplayScale(), zlat, zlon);
1136 switch (event.GetId()) {
1137 case ID_DEF_MENU_MAX_DETAIL:
1140 parent->ClearbFollow();
1142 parent->parent_frame->DoChartUpdate();
1144 parent->SelectChartFromStack(0,
false, CHART_TYPE_DONTCARE,
1145 CHART_FAMILY_RASTER);
1148 case ID_DEF_MENU_SCALE_IN:
1149 parent->DoCanvasStackDelta(-1);
1152 case ID_DEF_MENU_SCALE_OUT:
1153 parent->DoCanvasStackDelta(1);
1157 parent->undo->UndoLastAction();
1158 parent->InvalidateGL();
1159 parent->Refresh(
false);
1163 parent->undo->RedoNextAction();
1164 parent->InvalidateGL();
1165 parent->Refresh(
false);
1168 case ID_DEF_MENU_MOVE_BOAT_HERE:
1171 gFrame->UpdateStatusBar();
1174 case ID_DEF_MENU_GOTO_HERE: {
1176 wxEmptyString, wxEmptyString);
1177 pSelect->AddSelectableRoutePoint(zlat, zlon, pWP_dest);
1180 wxEmptyString, wxEmptyString);
1181 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
1184 pRouteList->Append(temp_route);
1186 temp_route->AddPoint(pWP_src);
1187 temp_route->AddPoint(pWP_dest);
1189 pSelect->AddSelectableRouteSegment(gLat, gLon, zlat, zlon, pWP_src,
1190 pWP_dest, temp_route);
1192 temp_route->m_RouteNameString = _(
"Temporary GOTO Route");
1193 temp_route->m_RouteStartString = _(
"Here");
1195 temp_route->m_RouteEndString = _(
"There");
1197 temp_route->m_bDeleteOnArrival =
true;
1199 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1201 g_pRouteMan->ActivateRoute(temp_route, pWP_dest);
1206 case ID_DEF_MENU_DROP_WP: {
1208 wxEmptyString, wxEmptyString);
1209 pWP->m_bIsolatedMark =
true;
1210 pSelect->AddSelectableRoutePoint(zlat, zlon, pWP);
1211 pConfig->AddNewWayPoint(pWP, -1);
1215 if (RouteManagerDialog::getInstanceFlag()) {
1216 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1217 pRouteManagerDialog->UpdateWptListCtrl();
1221 parent->undo->BeforeUndoableAction(Undo_CreateWaypoint, pWP,
1222 Undo_HasParent, NULL);
1223 parent->undo->AfterUndoableAction(NULL);
1224 gFrame->RefreshAllCanvas(
false);
1225 gFrame->InvalidateAllGL();
1226 g_FlushNavobjChanges =
true;
1230 case ID_DEF_MENU_NEW_RT: {
1231 parent->StartRoute();
1235 case ID_DEF_MENU_AISTARGETLIST:
1236 parent->ShowAISTargetList();
1239 case ID_DEF_MENU_AIS_CPAWARNING:
1240 parent->ToggleCPAWarn();
1243 case ID_WP_MENU_GOTO: {
1245 wxEmptyString, wxEmptyString);
1246 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
1249 pRouteList->Append(temp_route);
1251 temp_route->AddPoint(pWP_src);
1252 temp_route->AddPoint(m_pFoundRoutePoint);
1253 m_pFoundRoutePoint->SetShared(
true);
1255 pSelect->AddSelectableRouteSegment(gLat, gLon, m_pFoundRoutePoint->m_lat,
1256 m_pFoundRoutePoint->m_lon, pWP_src,
1257 m_pFoundRoutePoint, temp_route);
1259 wxString name = m_pFoundRoutePoint->GetName();
1260 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
1261 wxString rteName = _(
"Go to ");
1262 rteName.Append(name);
1263 temp_route->m_RouteNameString = rteName;
1264 temp_route->m_RouteStartString = _(
"Here");
1266 temp_route->m_RouteEndString = name;
1267 temp_route->m_bDeleteOnArrival =
true;
1269 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1271 g_pRouteMan->ActivateRoute(temp_route, m_pFoundRoutePoint);
1276 case ID_DEF_MENU_COGUP:
1277 parent->SetUpMode(COURSE_UP_MODE);
1280 case ID_DEF_MENU_HEADUP:
1281 parent->SetUpMode(HEAD_UP_MODE);
1284 case ID_DEF_MENU_NORTHUP:
1285 parent->SetUpMode(NORTH_UP_MODE);
1288 case ID_DEF_MENU_TOGGLE_FULL:
1289 gFrame->ToggleFullScreen();
1292 case ID_DEF_MENU_GOTOPOSITION:
1293 if (NULL == pGoToPositionDialog)
1296 pGoToPositionDialog->SetCanvas(parent);
1297 pGoToPositionDialog->CheckPasteBufferForPosition();
1298 pGoToPositionDialog->Show();
1301 case ID_WP_MENU_DELPOINT: {
1302 if (m_pFoundRoutePoint == pAnchorWatchPoint1) {
1303 pAnchorWatchPoint1 = NULL;
1305 }
else if (m_pFoundRoutePoint == pAnchorWatchPoint2) {
1306 pAnchorWatchPoint2 = NULL;
1310 if (m_pFoundRoutePoint && !(m_pFoundRoutePoint->m_bIsInLayer) &&
1311 (m_pFoundRoutePoint->GetIconName() != _T(
"mob"))) {
1315 wxArrayPtrVoid *proute_array =
1316 g_pRouteMan->GetRouteArrayContaining(m_pFoundRoutePoint);
1318 pWayPointMan->DestroyWaypoint(m_pFoundRoutePoint);
1320 parent->undo->BeforeUndoableAction(
1321 Undo_DeleteWaypoint, m_pFoundRoutePoint, Undo_IsOrphanded,
1323 pConfig->DeleteWayPoint(m_pFoundRoutePoint);
1324 pSelect->DeleteSelectablePoint(m_pFoundRoutePoint,
1325 SELTYPE_ROUTEPOINT);
1326 if (NULL != pWayPointMan)
1327 pWayPointMan->RemoveRoutePoint(m_pFoundRoutePoint);
1328 parent->undo->AfterUndoableAction(NULL);
1331 if (g_pMarkInfoDialog) {
1332 g_pMarkInfoDialog->ClearData();
1335 if (RouteManagerDialog::getInstanceFlag()) {
1336 if (pRouteManagerDialog) {
1337 if (pRouteManagerDialog->IsShown())
1338 pRouteManagerDialog->UpdateWptListCtrl();
1342 gFrame->RefreshAllCanvas(
false);
1343 gFrame->InvalidateAllGL();
1347 case ID_WP_MENU_PROPERTIES:
1348 parent->ShowMarkPropertiesDialog(m_pFoundRoutePoint);
1351 case ID_WP_MENU_CLEAR_ANCHORWATCH: {
1352 wxString guid = wxEmptyString;
1353 if (pAnchorWatchPoint1 == m_pFoundRoutePoint) {
1354 pAnchorWatchPoint1 = NULL;
1357 }
else if (pAnchorWatchPoint2 == m_pFoundRoutePoint) {
1358 pAnchorWatchPoint2 = NULL;
1362 if (!guid.IsEmpty()) {
1364 v[_T(
"GUID")] = guid;
1365 wxString msg_id(_T(
"OCPN_ANCHOR_WATCH_CLEARED"));
1366 g_pi_manager->SendJSONMessageToAllPlugins(msg_id, v);
1371 case ID_WP_MENU_SET_ANCHORWATCH: {
1372 wxString guid = wxEmptyString;
1373 if (pAnchorWatchPoint1 == NULL) {
1374 pAnchorWatchPoint1 = m_pFoundRoutePoint;
1375 g_AW1GUID = pAnchorWatchPoint1->m_GUID;
1378 nn = m_pFoundRoutePoint->GetName();
1380 nn.Printf(_T(
"%d m"), g_nAWDefault);
1381 m_pFoundRoutePoint->SetName(nn);
1383 }
else if (pAnchorWatchPoint2 == NULL) {
1384 pAnchorWatchPoint2 = m_pFoundRoutePoint;
1385 g_AW2GUID = pAnchorWatchPoint2->m_GUID;
1388 nn = m_pFoundRoutePoint->GetName();
1390 nn.Printf(_T(
"%d m"), g_nAWDefault);
1391 m_pFoundRoutePoint->SetName(nn);
1394 if (!guid.IsEmpty()) {
1396 v[_T(
"GUID")] = guid;
1397 wxString msg_id(_T(
"OCPN_ANCHOR_WATCH_SET"));
1398 g_pi_manager->SendJSONMessageToAllPlugins(msg_id, v);
1403 case ID_DEF_MENU_ACTIVATE_MEASURE:
1404 parent->StartMeasureRoute();
1407 case ID_DEF_MENU_DEACTIVATE_MEASURE:
1408 parent->CancelMeasureRoute();
1410 parent->InvalidateGL();
1411 parent->Refresh(
false);
1414 case ID_DEF_MENU_CM93OFFSET_DIALOG: {
1415 if (NULL == g_pCM93OffsetDialog) {
1420 if (!parent->GetVP().b_quilt && parent->m_singleChart &&
1421 (parent->m_singleChart->GetChartType() == CHART_TYPE_CM93COMP)) {
1425 if (g_pCM93OffsetDialog) {
1426 g_pCM93OffsetDialog->SetCM93Chart(pch);
1427 g_pCM93OffsetDialog->Show();
1428 g_pCM93OffsetDialog->UpdateMCOVRList(parent->GetVP());
1433 case ID_DEF_MENU_QUERY: {
1434 parent->ShowObjectQueryWindow(popx, popy, zlat, zlon);
1437 case ID_DEF_MENU_AIS_QUERY: {
1438 wxWindow *pwin = wxDynamicCast(parent, wxWindow);
1439 ShowAISTargetQueryDialog(pwin, m_FoundAIS_MMSI);
1443 case ID_DEF_MENU_AIS_CPA: {
1444 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
1445 if (myptarget) myptarget->Toggle_AIS_CPA();
1449 case ID_DEF_MENU_AISSHOWTRACK: {
1450 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
1451 if (myptarget) myptarget->ToggleShowTrack();
1455 case ID_DEF_MENU_COPY_MMSI: {
1457 if (wxTheClipboard->Open()) {
1458 wxTheClipboard->SetData(
new wxTextDataObject(
1459 wxString::Format(wxT(
"%09d"), m_FoundAIS_MMSI)));
1460 wxTheClipboard->Close();
1465 case ID_DEF_MENU_QUILTREMOVE: {
1466 if (parent->GetVP().b_quilt) {
1467 int dbIndex = parent->m_pQuilt->GetChartdbIndexAtPix(
1468 parent->GetVP(), wxPoint(popx, popy));
1469 parent->RemoveChartFromQuilt(dbIndex);
1477 case ID_DEF_MENU_CURRENTINFO: {
1478 parent->DrawTCWindow(popx, popy, (
void *)m_pIDXCandidate);
1479 parent->Refresh(
false);
1484 case ID_DEF_MENU_TIDEINFO: {
1485 parent->DrawTCWindow(popx, popy, (
void *)m_pIDXCandidate);
1486 parent->Refresh(
false);
1490 case ID_RT_MENU_REVERSE: {
1491 if (m_pSelectedRoute->m_bIsInLayer)
break;
1494 OCPNMessageBox(parent, g_pRouteMan->GetRouteReverseMessage(),
1495 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1497 if (ask_return != wxID_CANCEL) {
1498 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1499 m_pSelectedRoute->Reverse(ask_return == wxID_YES);
1500 pSelect->AddAllSelectableRouteSegments(m_pSelectedRoute);
1502 pConfig->UpdateRoute(m_pSelectedRoute);
1504 if (pRoutePropDialog && (pRoutePropDialog->IsShown())) {
1505 pRoutePropDialog->SetRouteAndUpdate(m_pSelectedRoute);
1508 gFrame->InvalidateAllGL();
1509 gFrame->RefreshAllCanvas();
1514 case ID_RT_MENU_SHOWNAMES: {
1515 if (m_pSelectedRoute) {
1516 m_pSelectedRoute->ShowWaypointNames(
1517 !m_pSelectedRoute->AreWaypointNamesVisible());
1523 case ID_RT_MENU_RESEQUENCE: {
1524 if (m_pSelectedRoute) {
1525 if (m_pSelectedRoute->m_bIsInLayer)
break;
1528 OCPNMessageBox(parent, g_pRouteMan->GetRouteResequenceMessage(),
1529 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1531 if (ask_return != wxID_CANCEL) {
1532 m_pSelectedRoute->RenameRoutePoints();
1535 gFrame->InvalidateAllGL();
1536 gFrame->RefreshAllCanvas();
1542 case ID_RT_MENU_DELETE: {
1543 int dlg_return = wxID_YES;
1544 if (g_bConfirmObjectDelete) {
1545 dlg_return = OCPNMessageBox(
1546 parent, _(
"Are you sure you want to delete this route?"),
1547 _(
"OpenCPN Route Delete"),
1548 (
long)wxYES_NO | wxCANCEL | wxYES_DEFAULT);
1551 if (dlg_return == wxID_YES) {
1552 if (g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute)
1553 g_pRouteMan->DeactivateRoute();
1555 if (m_pSelectedRoute->m_bIsInLayer)
break;
1558 NavObjectChanges::getInstance()))
1561 if (RouteManagerDialog::getInstanceFlag()) {
1562 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1563 pRouteManagerDialog->UpdateRouteListCtrl();
1566 if (g_pMarkInfoDialog && g_pMarkInfoDialog->IsShown()) {
1567 g_pMarkInfoDialog->ValidateMark();
1568 g_pMarkInfoDialog->UpdateProperties();
1571 parent->undo->InvalidateUndo();
1573 gFrame->InvalidateAllGL();
1574 gFrame->RefreshAllCanvas();
1579 case ID_RT_MENU_ACTIVATE: {
1580 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1586 if (m_pSelectedRoute) {
1588 m_pSelectedRoute->m_RouteNameString.Find(_T(
"MOB"))) {
1589 best_point = g_pRouteMan->FindBestActivatePoint(
1590 m_pSelectedRoute, gLat, gLon, gCog, gSog);
1592 best_point = m_pSelectedRoute->GetPoint(2);
1594 g_pRouteMan->ActivateRoute(m_pSelectedRoute, best_point);
1595 m_pSelectedRoute->m_bRtIsSelected =
false;
1601 case ID_RT_MENU_DEACTIVATE:
1602 g_pRouteMan->DeactivateRoute();
1603 m_pSelectedRoute->m_bRtIsSelected =
false;
1607 case ID_RT_MENU_INSERT: {
1608 if (m_pSelectedRoute->m_bIsInLayer)
break;
1609 bool rename =
false;
1610 m_pSelectedRoute->InsertPointAfter(m_pFoundRoutePoint, zlat, zlon,
1613 pSelect->DeleteAllSelectableRoutePoints(m_pSelectedRoute);
1614 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1616 pSelect->AddAllSelectableRouteSegments(m_pSelectedRoute);
1617 pSelect->AddAllSelectableRoutePoints(m_pSelectedRoute);
1630 pConfig->UpdateRoute(m_pSelectedRoute);
1632 if (pRoutePropDialog && (pRoutePropDialog->IsShown())) {
1633 pRoutePropDialog->SetRouteAndUpdate(m_pSelectedRoute,
true);
1639 case ID_RT_MENU_APPEND:
1641 if (m_pSelectedRoute->m_bIsInLayer)
break;
1643 parent->m_pMouseRoute = m_pSelectedRoute;
1644 parent->m_routeState = m_pSelectedRoute->GetnPoints() + 1;
1645 parent->m_pMouseRoute->m_lastMousePointIndex =
1646 m_pSelectedRoute->GetnPoints();
1647 parent->m_pMouseRoute->SetHiLite(50);
1649 pLast = m_pSelectedRoute->GetLastPoint();
1651 parent->m_prev_rlat = pLast->m_lat;
1652 parent->m_prev_rlon = pLast->m_lon;
1653 parent->m_prev_pMousePoint = pLast;
1655 parent->m_bAppendingRoute =
true;
1657 parent->SetCursor(*parent->pCursorPencil);
1659 androidSetRouteAnnunciator(
true);
1662 parent->HideGlobalToolbar();
1666 case ID_RT_MENU_SPLIT_LEG:
1668 dupFirstWpt =
false;
1669 case ID_RT_MENU_SPLIT_WPT:
1671 showRPD = (pRoutePropDialog && pRoutePropDialog->IsShown());
1673 if (g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute)
1674 g_pRouteMan->DeactivateRoute();
1676 m_pHead =
new Route();
1677 m_pTail =
new Route();
1678 m_pHead->CloneRoute(m_pSelectedRoute, 1, m_SelectedIdx, _(
"_A"));
1679 m_pTail->CloneRoute(m_pSelectedRoute, m_SelectedIdx + splitMode,
1680 m_pSelectedRoute->GetnPoints(), _(
"_B"), dupFirstWpt);
1681 pRouteList->Append(m_pHead);
1682 pConfig->AddNewRoute(m_pHead);
1684 pRouteList->Append(m_pTail);
1685 pConfig->AddNewRoute(m_pTail);
1687 pConfig->DeleteConfigRoute(m_pSelectedRoute);
1689 pSelect->DeleteAllSelectableRoutePoints(m_pSelectedRoute);
1690 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1692 NavObjectChanges::getInstance());
1693 pSelect->AddAllSelectableRouteSegments(m_pTail);
1694 pSelect->AddAllSelectableRoutePoints(m_pTail);
1695 pSelect->AddAllSelectableRouteSegments(m_pHead);
1696 pSelect->AddAllSelectableRoutePoints(m_pHead);
1699 pRoutePropDialog->SetRouteAndUpdate(m_pHead);
1700 pRoutePropDialog->Show();
1702 if (RouteManagerDialog::getInstanceFlag() && pRouteManagerDialog &&
1703 (pRouteManagerDialog->IsShown()))
1704 pRouteManagerDialog->UpdateRouteListCtrl();
1707 case ID_RT_MENU_COPY:
1708 if (m_pSelectedRoute) Kml::CopyRouteToClipboard(m_pSelectedRoute);
1711 case ID_TK_MENU_COPY:
1712 if (m_pSelectedTrack) Kml::CopyTrackToClipboard(m_pSelectedTrack);
1715 case ID_WPT_MENU_COPY:
1716 if (m_pFoundRoutePoint) Kml::CopyWaypointToClipboard(m_pFoundRoutePoint);
1719 case ID_WPT_MENU_SENDTOGPS:
1720 if (m_pFoundRoutePoint) {
1721 if (parent->m_active_upload_port.Length())
1723 .SendToGPS(parent->m_active_upload_port.BeforeFirst(
' '), NULL);
1726 dlg.SetWaypoint(m_pFoundRoutePoint);
1727 wxFont fo = GetOCPNGUIScaledFont(_T(
"Dialog"));
1730 dlg.Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), _T(
""));
1736 case ID_WPT_MENU_SENDTONEWGPS:
1737 if (m_pFoundRoutePoint) {
1739 dlg.SetWaypoint(m_pFoundRoutePoint);
1741 dlg.Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), _T(
""));
1746 case ID_WPT_MENU_SENDTOPEER:
1747 if (m_pFoundRoutePoint) {
1749 dlg.SetWaypoint(m_pFoundRoutePoint);
1754 MdnsCache::GetInstance().
Validate();
1755 if (MdnsCache::GetInstance().GetCache().empty())
1756 dlg.SetScanOnCreate(
true);
1759 dlg.Create(NULL, -1, _(
"Send Waypoint to OpenCPN Peer") + _T(
"..." ),
1765 case ID_RT_MENU_SENDTOGPS:
1766 if (m_pSelectedRoute) {
1767 if (parent->m_active_upload_port.Length())
1769 .SendToGPS(parent->m_active_upload_port.BeforeFirst(
' '),
true,
1773 dlg.SetRoute(m_pSelectedRoute);
1775 dlg.Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), _T(
""));
1781 case ID_RT_MENU_SENDTONEWGPS:
1782 if (m_pSelectedRoute) {
1784 dlg.SetRoute(m_pSelectedRoute);
1786 dlg.Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), _T(
""));
1791 case ID_RT_MENU_SENDTOPEER:
1792 if (m_pSelectedRoute) {
1794 dlg.SetRoute(m_pSelectedRoute);
1799 MdnsCache::GetInstance().
Validate();
1800 if (MdnsCache::GetInstance().GetCache().empty())
1801 dlg.SetScanOnCreate(
true);
1804 dlg.Create(NULL, -1, _(
"Send Route to OpenCPN Peer") + _T(
"..." ),
1810 case ID_PASTE_WAYPOINT:
1811 pupHandler_PasteWaypoint();
1814 case ID_PASTE_ROUTE:
1815 pupHandler_PasteRoute();
1818 case ID_PASTE_TRACK:
1819 pupHandler_PasteTrack();
1822 case ID_RT_MENU_DELPOINT:
1823 if (m_pSelectedRoute) {
1824 if (m_pSelectedRoute->m_bIsInLayer)
break;
1826 pWayPointMan->DestroyWaypoint(m_pFoundRoutePoint);
1828 if (pRoutePropDialog && (pRoutePropDialog->IsShown())) {
1831 if (g_pRouteMan->IsRouteValid(m_pSelectedRoute)) {
1832 pRoutePropDialog->SetRouteAndUpdate(m_pSelectedRoute,
true);
1834 pRoutePropDialog->Hide();
1837 if (RouteManagerDialog::getInstanceFlag()) {
1838 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1839 pRouteManagerDialog->UpdateWptListCtrl();
1840 pRouteManagerDialog->UpdateRouteListCtrl();
1844 gFrame->InvalidateAllGL();
1845 gFrame->RefreshAllCanvas(
true);
1850 case ID_RT_MENU_REMPOINT:
1851 if (m_pSelectedRoute) {
1852 if (m_pSelectedRoute->m_bIsInLayer)
break;
1853 g_pRouteMan->RemovePointFromRoute(m_pFoundRoutePoint, m_pSelectedRoute,
1854 parent->m_routeState);
1855 gFrame->InvalidateAllGL();
1856 gFrame->RefreshAllCanvas();
1860 case ID_RT_MENU_ACTPOINT:
1861 if (g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute) {
1863 m_pSelectedRoute->m_bRtIsSelected =
false;
1868 case ID_RT_MENU_DEACTPOINT:
1871 case ID_RT_MENU_ACTNXTPOINT:
1872 if (g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute) {
1874 m_pSelectedRoute->m_bRtIsSelected =
false;
1879 case ID_RT_MENU_PROPERTIES: {
1880 parent->ShowRoutePropertiesDialog(_(
"Route Properties"),
1885 case ID_TK_MENU_PROPERTIES: {
1886 parent->ShowTrackPropertiesDialog(m_pSelectedTrack);
1890 case ID_TK_MENU_DELETE: {
1891 int dlg_return = wxID_YES;
1892 if (g_bConfirmObjectDelete) {
1893 dlg_return = OCPNMessageBox(
1894 parent, _(
"Are you sure you want to delete this track?"),
1895 _(
"OpenCPN Track Delete"),
1896 (
long)wxYES_NO | wxCANCEL | wxYES_DEFAULT);
1899 if (dlg_return == wxID_YES) {
1900 if (m_pSelectedTrack == g_pActiveTrack)
1901 m_pSelectedTrack = parent->parent_frame->TrackOff();
1902 g_pAIS->DeletePersistentTrack(m_pSelectedTrack);
1903 pConfig->DeleteConfigTrack(m_pSelectedTrack);
1905 RoutemanGui(*g_pRouteMan).DeleteTrack(m_pSelectedTrack);
1907 if (TrackPropDlg::getInstanceFlag() && pTrackPropDialog &&
1908 (pTrackPropDialog->IsShown()) &&
1909 (m_pSelectedTrack == pTrackPropDialog->GetTrack())) {
1910 pTrackPropDialog->Hide();
1913 if (RoutePropDlgImpl::getInstanceFlag() && pRouteManagerDialog &&
1914 pRouteManagerDialog->IsShown()) {
1915 pRouteManagerDialog->UpdateTrkListCtrl();
1916 pRouteManagerDialog->UpdateRouteListCtrl();
1918 gFrame->InvalidateAllGL();
1919 gFrame->RefreshAllCanvas();
1924 case ID_TK_MENU_SENDTOPEER:
1925 if (m_pSelectedTrack) {
1927 dlg.SetTrack(m_pSelectedTrack);
1932 MdnsCache::GetInstance().
Validate();
1933 if (MdnsCache::GetInstance().GetCache().empty())
1934 dlg.SetScanOnCreate(
true);
1937 dlg.Create(NULL, -1, _(
"Send Track to OpenCPN Peer") + _T(
"..." ),
1943 case ID_RC_MENU_SCALE_IN:
1944 parent->parent_frame->DoStackDown(parent);
1945 parent->GetCanvasPointPix(zlat, zlon, &r);
1946 parent->WarpPointer(r.x, r.y);
1949 case ID_RC_MENU_SCALE_OUT:
1950 parent->parent_frame->DoStackUp(parent);
1951 parent->GetCanvasPointPix(zlat, zlon, &r);
1952 parent->WarpPointer(r.x, r.y);
1955 case ID_RC_MENU_ZOOM_IN:
1956 parent->SetVPScale(parent->GetVPScale() * 2);
1957 parent->GetCanvasPointPix(zlat, zlon, &r);
1958 parent->WarpPointer(r.x, r.y);
1961 case ID_RC_MENU_ZOOM_OUT:
1962 parent->SetVPScale(parent->GetVPScale() / 2);
1963 parent->GetCanvasPointPix(zlat, zlon, &r);
1964 parent->WarpPointer(r.x, r.y);
1967 case ID_RC_MENU_FINISH:
1968 parent->FinishRoute();
1970 parent->Refresh(
false);
1971 g_FlushNavobjChanges =
true;
1974 case ID_DEF_ZERO_XTE:
1975 g_pRouteMan->ZeroCurrentXTEToActivePoint();
1981 ArrayOfPlugInMenuItems item_array =
1982 g_pi_manager->GetPluginContextMenuItemArray();
1984 for (
unsigned int i = 0; i < item_array.GetCount(); i++) {
1987 if (pimis->id == event.GetId()) {
1988 if (pimis->m_pplugin)
1989 pimis->m_pplugin->OnContextMenuItemCallback(pimis->id);
1999 if ((event.GetId() >= ID_DEF_MENU_GROUPBASE) &&
2001 ID_DEF_MENU_GROUPBASE + (
int)g_pGroupArray->GetCount())) {
2002 parent->SetGroupIndex(event.GetId() - ID_DEF_MENU_GROUPBASE);
2005 parent->InvalidateGL();
Global state for AIS decoder.
void Validate()
Check that all entries are accessible, remove stale ones.
bool ActivateRoutePoint(Route *pA, RoutePoint *pRP)
bool ActivateNextPoint(Route *pr, bool skipped)
bool DeleteRoute(Route *pRoute, NavObjectChanges *nav_obj_changes)
Route "Send to GPS..." Dialog Definition.
Route "Send to Peer..." Dialog Definition.