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>
38#include <wx/listimpl.cpp>
45#include "RoutePropDlgImpl.h"
46#include "SendToGpsDlg.h"
47#include "SendToPeerDlg.h"
50#include "TrackPropDlg.h"
52#include "ais_decoder.h"
53#include "ais_target_data.h"
54#include "canvasMenu.h"
59#include "config_vars.h"
64#include "nav_object_database.h"
65#include "ocpn_frame.h"
67#include "pluginmanager.h"
69#include "route_point_gui.h"
71#include "routeman_gui.h"
72#include "routemanagerdialog.h"
80#include "peer_client.h"
81#include "mDNS_query.h"
82#include "OCPNPlatform.h"
84#ifdef __OCPN__ANDROID__
85#include "androidUTIL.h"
91extern void pupHandler_PasteRoute();
92extern void pupHandler_PasteTrack();
93extern void pupHandler_PasteWaypoint();
96extern bool g_bShowAreaNotices;
99extern bool g_bskew_comp;
100extern double vLat, vLon;
102extern ChartGroupArray *g_pGroupArray;
105extern int g_nAWDefault;
108extern wxString g_AW1GUID;
109extern wxString g_AW2GUID;
110extern int g_click_stop;
115extern bool g_bConfirmObjectDelete;
124extern RouteList *pRouteList;
125extern wxString g_default_wp_icon;
127extern bool g_bBasicMenus;
130extern bool g_FlushNavobjChanges;
131extern ColorScheme global_color_scheme;
132extern std::vector<std::shared_ptr<ocpn_DNS_record_t>> g_DNS_cache;
133extern wxDateTime g_DNS_cache_time;
137 ID_DEF_MENU_MAX_DETAIL = 1,
138 ID_DEF_MENU_SCALE_IN,
139 ID_DEF_MENU_SCALE_OUT,
143 ID_DEF_MENU_MOVE_BOAT_HERE,
144 ID_DEF_MENU_GOTO_HERE,
145 ID_DEF_MENU_GOTOPOSITION,
149 ID_WP_MENU_PROPERTIES,
151 ID_RT_MENU_DEACTIVATE,
155 ID_RT_MENU_SPLIT_LEG,
156 ID_RT_MENU_SPLIT_WPT,
159 ID_WPT_MENU_SENDTOGPS,
160 ID_WPT_MENU_SENDTONEWGPS,
168 ID_RT_MENU_DEACTPOINT,
169 ID_RT_MENU_ACTNXTPOINT,
171 ID_RT_MENU_PROPERTIES,
172 ID_RT_MENU_SENDTOGPS,
173 ID_RT_MENU_SENDTONEWGPS,
174 ID_RT_MENU_SHOWNAMES,
175 ID_RT_MENU_RESEQUENCE,
176 ID_RT_MENU_SENDTOPEER,
177 ID_WP_MENU_SET_ANCHORWATCH,
178 ID_WP_MENU_CLEAR_ANCHORWATCH,
179 ID_DEF_MENU_AISTARGETLIST,
182 ID_RC_MENU_SCALE_OUT,
186 ID_DEF_MENU_AIS_QUERY,
188 ID_DEF_MENU_AISSHOWTRACK,
189 ID_DEF_MENU_ACTIVATE_MEASURE,
190 ID_DEF_MENU_DEACTIVATE_MEASURE,
191 ID_DEF_MENU_COPY_MMSI,
196 ID_DEF_MENU_CM93OFFSET_DIALOG,
198 ID_TK_MENU_PROPERTIES,
200 ID_WP_MENU_ADDITIONAL_INFO,
202 ID_DEF_MENU_QUILTREMOVE,
206 ID_DEF_MENU_TOGGLE_FULL,
207 ID_DEF_MENU_TIDEINFO,
208 ID_DEF_MENU_CURRENTINFO,
211 ID_DEF_MENU_GROUPBASE,
220int CanvasMenuHandler::GetNextContextMenuId() {
221 return ID_DEF_MENU_LAST +
225wxFont CanvasMenuHandler::m_scaledFont;
228CanvasMenuHandler::CanvasMenuHandler(
ChartCanvas *parentCanvas,
231 int selectedAIS_MMSI,
232 void *selectedTCIndex)
235 parent = parentCanvas;
236 m_pSelectedRoute = selectedRoute;
237 m_pSelectedTrack = selectedTrack;
238 m_pFoundRoutePoint = selectedPoint;
239 m_FoundAIS_MMSI = selectedAIS_MMSI;
240 m_pIDXCandidate = selectedTCIndex;
241 if (!m_scaledFont.IsOk()){
242 wxFont *qFont = GetOCPNScaledFont(_(
"Menu"));
243 m_scaledFont = *qFont;
246 m_DIPFactor =g_Platform->GetDisplayDIPMult(gFrame);
250CanvasMenuHandler::~CanvasMenuHandler() {}
256void CanvasMenuHandler::PrepareMenuItem( wxMenuItem *item ){
257#if defined(__WXMSW__)
258 if (m_DIPFactor == 1.0){
259 wxColour ctrl_back_color = GetGlobalColor(_T(
"DILG1"));
260 item->SetBackgroundColour(ctrl_back_color);
261 wxColour menu_text_color = GetGlobalColor(_T (
"UITX1" ));
262 item->SetTextColour(menu_text_color);
267void CanvasMenuHandler::MenuPrepend1(wxMenu *menu,
int id, wxString label) {
268 wxMenuItem *item =
new wxMenuItem(menu,
id, label);
269#if defined(__WXMSW__)
270 if (m_DIPFactor == 1.0)
271 item->SetFont(m_scaledFont);
274#ifdef __OCPN__ANDROID__
275 wxFont sFont = GetOCPNGUIScaledFont(_(
"Menu"));
276 item->SetFont(sFont);
279 PrepareMenuItem( item );
281 if (g_btouch) menu->InsertSeparator(0);
285void CanvasMenuHandler::MenuAppend1(wxMenu *menu,
int id, wxString label) {
286 wxMenuItem *item =
new wxMenuItem(menu,
id, label);
287#if defined(__WXMSW__)
288 if (m_DIPFactor == 1.0)
289 item->SetFont(m_scaledFont);
292#ifdef __OCPN__ANDROID__
293 wxFont sFont = GetOCPNGUIScaledFont(_T(
"Menu"));
294 item->SetFont(sFont);
297 PrepareMenuItem( item );
300 if (g_btouch) menu->AppendSeparator();
303void CanvasMenuHandler::SetMenuItemFont1(wxMenuItem *item) {
304#if defined(__WXMSW__)
305 if (m_DIPFactor == 1.0)
306 item->SetFont(m_scaledFont);
309#if defined(__OCPN__ANDROID__)
310 wxFont *qFont = GetOCPNScaledFont(_(
"Menu"));
311 item->SetFont(*qFont);
314 PrepareMenuItem( item );
317void CanvasMenuHandler::CanvasPopupMenu(
int x,
int y,
int seltype) {
318 wxMenu *contextMenu =
new wxMenu;
319 wxMenu *menuWaypoint = NULL;
320 wxMenu *menuRoute = NULL;
321 wxMenu *menuTrack = NULL;
322 wxMenu *menuAIS = NULL;
324 wxMenu *subMenuChart =
new wxMenu;
325 wxMenu *subMenuUndo =
new wxMenu(
"Undo...Ctrl-Z");
328 wxMenu *subMenuRedo =
new wxMenu(
"Redo...Shift-Ctrl-Z");
330 wxMenu *subMenuRedo =
new wxMenu(
"Redo...Ctrl-Y");
333 wxMenu *menuFocus = contextMenu;
338 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
340 bool bsubMenus =
false;
343 if (parent->undo->AnythingToUndo()) {
345 wxMenuItem *subMenuItemundo =
346 contextMenu->AppendSubMenu(subMenuUndo, _(
"Undo"));
349 undoItem << _(
"Undo") << _T(
" ")
350 << parent->undo->GetNextUndoableAction()->Description();
351 MenuAppend1(subMenuUndo, ID_UNDO, undoItem);
353 if (parent->undo->AnythingToRedo()) {
355 wxMenuItem *subMenuItemRedo =
356 contextMenu->AppendSubMenu(subMenuRedo, _(
"Redo"));
359 redoItem << _(
"Redo") << _T(
" ")
360 << parent->undo->GetNextRedoableAction()->Description();
361 MenuAppend1(subMenuRedo, ID_REDO, redoItem);
365 if (parent->undo->AnythingToUndo()) {
367 undoItem << _(
"Undo") << _T(
" ")
368 << parent->undo->GetNextUndoableAction()->Description();
369 MenuAppend1(contextMenu, ID_UNDO, _menuText(undoItem, _T(
"Ctrl-Z")));
372 if (parent->undo->AnythingToRedo()) {
374 redoItem << _(
"Redo") << _T(
" ")
375 << parent->undo->GetNextRedoableAction()->Description();
377 MenuAppend1(contextMenu, ID_REDO, _menuText(redoItem, _T(
"Shift-Ctrl-Z")));
379 MenuAppend1(contextMenu, ID_REDO, _menuText(redoItem, _T(
"Ctrl-Y")));
385 if (seltype == SELTYPE_ROUTECREATE) {
386 MenuAppend1(contextMenu, ID_RC_MENU_FINISH,
387 _menuText(_(
"End Route"), _T(
"Esc")));
390 if (!parent->m_pMouseRoute) {
391 if (parent->m_bMeasure_Active)
392 MenuAppend1(contextMenu, ID_DEF_MENU_DEACTIVATE_MEASURE,
393 _menuText(_(
"Measure Off"), _T(
"Esc")));
395 MenuAppend1(contextMenu, ID_DEF_MENU_ACTIVATE_MEASURE,
396 _menuText(_(
"Measure"), _T(
"M")));
400 bool ais_areanotice =
false;
401 if (g_pAIS && parent->GetShowAIS() && g_bShowAreaNotices) {
402 float vp_scale = parent->GetVPScale();
404 for (
const auto &target : g_pAIS->GetAreaNoticeSourcesList()) {
405 auto target_data = target.second;
406 if (!target_data->area_notices.empty()) {
407 for (
auto &ani : target_data->area_notices) {
411 for (Ais8_001_22_SubAreaList::iterator sa =
412 area_notice.sub_areas.begin();
413 sa != area_notice.sub_areas.end(); ++sa) {
415 case AIS8_001_22_SHAPE_CIRCLE: {
416 wxPoint target_point;
417 parent->GetCanvasPointPix(sa->latitude, sa->longitude,
419 bbox.Expand(target_point);
420 if (sa->radius_m > 0.0) bbox.EnLarge(sa->radius_m * vp_scale);
423 case AIS8_001_22_SHAPE_POLYGON:
424 case AIS8_001_22_SHAPE_POLYLINE: {
425 double lat = sa->latitude;
426 double lon = sa->longitude;
427 for (
int i = 0; i < 4; ++i) {
428 ll_gc_ll(lat, lon, sa->angles[i], sa->dists_m[i] / 1852.0,
430 wxPoint target_point;
431 parent->GetCanvasPointPix(lat, lon, &target_point);
432 bbox.Expand(target_point);
438 if (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"), _T(
"Ctrl-Left")));
456 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_OUT,
457 _menuText(_(
"Scale Out"), _T(
"Ctrl-Right")));
460 if ((parent->m_singleChart &&
461 (parent->m_singleChart->GetChartFamily() == CHART_FAMILY_VECTOR)) ||
463 MenuAppend1(contextMenu, ID_DEF_MENU_QUERY,
464 _(
"Object Query") + _T(
"..." ));
469 parent->m_pQuilt->GetChartAtPix(parent->GetVP(), wxPoint(x, y));
470 if ((pChartTest && (pChartTest->GetChartFamily() == CHART_FAMILY_VECTOR)) ||
472 MenuAppend1(contextMenu, ID_DEF_MENU_QUERY,
473 _(
"Object Query") + _T(
"..." ));
475#ifndef __OCPN__ANDROID__
476 if (!g_bBasicMenus && (nChartStack > 1)) {
477 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_IN,
478 _menuText(_(
"Scale In"), _T(
"Ctrl-Left")));
479 MenuAppend1(contextMenu, ID_DEF_MENU_SCALE_OUT,
480 _menuText(_(
"Scale Out"), _T(
"Ctrl-Right")));
486 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
487 MenuAppend1(contextMenu, ID_DEF_MENU_DROP_WP,
488 _menuText(_(
"Drop Mark"), _T(
"Ctrl-M")));
489 MenuAppend1(contextMenu, ID_DEF_MENU_NEW_RT,
490 _menuText(_(
"New Route..."), _T(
"Ctrl-R")));
493 MenuAppend1(contextMenu, ID_DEF_MENU_MOVE_BOAT_HERE, _(
"Move Boat Here"));
496 if (!g_bBasicMenus &&
497 (!(g_pRouteMan->GetpActiveRoute() || (seltype & SELTYPE_MARKPOINT))))
498 MenuAppend1(contextMenu, ID_DEF_MENU_GOTO_HERE, _(
"Navigate To Here"));
501 MenuAppend1(contextMenu, ID_DEF_MENU_GOTOPOSITION,
502 _(
"Center view") + _T(
"..."));
504 if (!g_bBasicMenus) {
505 if (parent->GetVP().b_quilt) {
506 if (parent->GetUpMode() == NORTH_UP_MODE) {
507 MenuAppend1(contextMenu, ID_DEF_MENU_COGUP, _(
"Course Up Mode"));
508 if (!std::isnan(gHdt))
509 MenuAppend1(contextMenu, ID_DEF_MENU_HEADUP, _(
"Heading Up Mode"));
511 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"North Up Mode"));
514 if (parent->m_singleChart &&
515 (fabs(parent->m_singleChart->GetChartSkew()) > .01) && !g_bskew_comp)
516 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"Chart Up Mode"));
518 MenuAppend1(contextMenu, ID_DEF_MENU_NORTHUP, _(
"North Up Mode"));
522 if (!g_bBasicMenus) {
523 bool full_toggle_added =
false;
524#ifndef __OCPN__ANDROID__
526 MenuAppend1(contextMenu, ID_DEF_MENU_TOGGLE_FULL,
527 _(
"Toggle Full Screen"));
528 full_toggle_added =
true;
531 if (!full_toggle_added) {
533 MenuAppend1(contextMenu, ID_DEF_MENU_TOGGLE_FULL,
534 _(
"Toggle Full Screen"));
538 if (g_pRouteMan->IsAnyRouteActive() &&
539 g_pRouteMan->GetCurrentXTEToActivePoint() > 0.)
540 MenuAppend1(contextMenu, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
543 int pasteBuffer = kml->ParsePasteBuffer();
544 if (pasteBuffer != KML_PASTE_INVALID) {
545 switch (pasteBuffer) {
546 case KML_PASTE_WAYPOINT: {
547 MenuAppend1(contextMenu, ID_PASTE_WAYPOINT, _(
"Paste Waypoint"));
550 case KML_PASTE_ROUTE: {
551 MenuAppend1(contextMenu, ID_PASTE_ROUTE, _(
"Paste Route"));
554 case KML_PASTE_TRACK: {
555 MenuAppend1(contextMenu, ID_PASTE_TRACK, _(
"Paste Track"));
558 case KML_PASTE_ROUTE_TRACK: {
559 MenuAppend1(contextMenu, ID_PASTE_ROUTE, _(
"Paste Route"));
560 MenuAppend1(contextMenu, ID_PASTE_TRACK, _(
"Paste Track"));
567 if (!parent->GetVP().b_quilt && parent->m_singleChart &&
568 (parent->m_singleChart->GetChartType() == CHART_TYPE_CM93COMP)) {
569 MenuAppend1(contextMenu, ID_DEF_MENU_CM93OFFSET_DIALOG,
570 _(
"CM93 Offset Dialog..."));
575#ifndef __OCPN__ANDROID__
594 wxMenuItem *subItemChart =
595 contextMenu->AppendSubMenu(subMenuChart, _(
"Chart Groups"));
596 if (g_btouch) contextMenu->AppendSeparator();
598 SetMenuItemFont1(subItemChart);
600 if (g_pGroupArray->GetCount()) {
602 MenuAppend1(subMenuChart, wxID_CANCEL, _(
"temporary"));
604 wxMenuItem *subItem0 = subMenuChart->AppendRadioItem(
605 ID_DEF_MENU_GROUPBASE, _(
"All Active Charts"));
607 SetMenuItemFont1(subItem0);
609 for (
unsigned int i = 0; i < g_pGroupArray->GetCount(); i++) {
610 subItem0 = subMenuChart->AppendRadioItem(
611 ID_DEF_MENU_GROUPBASE + i + 1, g_pGroupArray->Item(i)->m_group_name);
612 SetMenuItemFont1(subItem0);
616 subMenuChart->Remove(wxID_CANCEL);
618 subMenuChart->Check(ID_DEF_MENU_GROUPBASE + parent->m_groupIndex,
true);
622 menuFocus = contextMenu;
625 if (!g_bBasicMenus || (seltype != SELTYPE_ROUTECREATE)) {
627 if (parent->GetShowAIS() && (seltype & SELTYPE_AISTARGET)) {
628 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
629 if (!g_bBasicMenus && myptarget) {
630 name = myptarget->GetFullName();
631 if (name.IsEmpty()) name.Printf(_T(
"%d"), m_FoundAIS_MMSI);
632 name.Prepend(_T(
" ( ")).Append(_T(
" )"));
634 name = wxEmptyString;
635 menuAIS =
new wxMenu(_(
"AIS") + name);
636 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_QUERY, _(
"Target Query..."));
637 if (myptarget && myptarget->bCPA_Valid &&
638 (myptarget->n_alert_state != AIS_ALERT_SET)) {
639 if (myptarget->b_show_AIS_CPA)
640 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_CPA, _(
"Hide Target CPA"));
642 MenuAppend1(menuAIS, ID_DEF_MENU_AIS_CPA, _(
"Show Target CPA"));
644 MenuAppend1(menuAIS, ID_DEF_MENU_AISTARGETLIST, _(
"Target List..."));
646 if (myptarget && myptarget->b_show_track)
647 MenuAppend1(menuAIS, ID_DEF_MENU_AISSHOWTRACK,
648 _(
"Hide Target Track"));
650 MenuAppend1(menuAIS, ID_DEF_MENU_AISSHOWTRACK,
651 _(
"Show Target Track"));
654 MenuAppend1(menuAIS, ID_DEF_MENU_COPY_MMSI, _(
"Copy Target MMSI"));
655 menuAIS->AppendSeparator();
657 if (!parent->GetVP().b_quilt) {
658 if ((parent->m_singleChart &&
659 (parent->m_singleChart->GetChartFamily() ==
660 CHART_FAMILY_VECTOR))) {
661 MenuAppend1(menuAIS, ID_DEF_MENU_QUERY, _(
"Object Query..."));
666 parent->m_pQuilt->GetChartAtPix(parent->GetVP(), wxPoint(x, y));
668 (pChartTest->GetChartFamily() == CHART_FAMILY_VECTOR))) {
669 MenuAppend1(menuAIS, ID_DEF_MENU_QUERY, _(
"Object Query..."));
675 MenuAppend1(contextMenu, ID_DEF_MENU_AISTARGETLIST,
676 _(
"AIS target list") + _T(
"..."));
680 if (seltype & SELTYPE_ROUTESEGMENT) {
681 if (!g_bBasicMenus && m_pSelectedRoute) {
682 name = m_pSelectedRoute->m_RouteNameString;
683 if (name.IsEmpty()) name = _(
"Unnamed Route");
684 name.Prepend(_T(
" ( ")).Append(_T(
" )"));
686 name = wxEmptyString;
688 if (m_pSelectedRoute && m_pSelectedRoute->m_bIsInLayer) blay =
true;
691 menuRoute =
new wxMenu(_(
"Layer Route") + name);
692 MenuAppend1(menuRoute, ID_RT_MENU_PROPERTIES,
693 _(
"Properties") + _T(
"..." ));
694 if (m_pSelectedRoute) {
695 if (m_pSelectedRoute->IsActive()) {
696 int indexActive = m_pSelectedRoute->GetIndexOf(
697 m_pSelectedRoute->m_pRouteActivePoint);
698 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints()) {
699 MenuAppend1(menuRoute, ID_RT_MENU_ACTNXTPOINT,
700 _(
"Activate Next Waypoint"));
702 MenuAppend1(menuRoute, ID_RT_MENU_DEACTIVATE, _(
"Deactivate"));
703 MenuAppend1(menuRoute, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
705 MenuAppend1(menuRoute, ID_RT_MENU_ACTIVATE, _(
"Activate"));
709 menuRoute =
new wxMenu(_(
"Route") + name);
710 MenuAppend1(menuRoute, ID_RT_MENU_PROPERTIES,
711 _(
"Properties") + _T(
"..." ));
712 if (m_pSelectedRoute) {
713 if (m_pSelectedRoute->IsActive()) {
714 int indexActive = m_pSelectedRoute->GetIndexOf(
715 m_pSelectedRoute->m_pRouteActivePoint);
716 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints()) {
717 MenuAppend1(menuRoute, ID_RT_MENU_ACTNXTPOINT,
718 _(
"Activate Next Waypoint"));
720 MenuAppend1(menuRoute, ID_RT_MENU_DEACTIVATE, _(
"Deactivate"));
721 MenuAppend1(menuRoute, ID_DEF_ZERO_XTE, _(
"Zero XTE"));
723 MenuAppend1(menuRoute, ID_RT_MENU_ACTIVATE, _(
"Activate"));
726 MenuAppend1(menuRoute, ID_RT_MENU_INSERT, _(
"Insert Waypoint"));
727 MenuAppend1(menuRoute, ID_RT_MENU_APPEND, _(
"Append Waypoint"));
728 if (!(seltype & SELTYPE_ROUTEPOINT) && m_pSelectedRoute) {
729 m_SelectedIdx = m_pSelectedRoute->GetIndexOf(m_pFoundRoutePoint);
730 if (m_SelectedIdx > 1 &&
731 m_SelectedIdx < m_pSelectedRoute->GetnPoints() - 1)
732 MenuAppend1(menuRoute, ID_RT_MENU_SPLIT_LEG, _(
"Split around Leg"));
734 MenuAppend1(menuRoute, ID_RT_MENU_COPY, _(
"Copy as KML") + _T(
"..." ));
735 MenuAppend1(menuRoute, ID_RT_MENU_DELETE, _(
"Delete") + _T(
"..." ));
736 MenuAppend1(menuRoute, ID_RT_MENU_REVERSE, _(
"Reverse..."));
737 if (m_pSelectedRoute) {
738 if (m_pSelectedRoute->AreWaypointNamesVisible())
739 MenuAppend1(menuRoute, ID_RT_MENU_SHOWNAMES,
740 _(
"Hide Waypoint Names"));
742 MenuAppend1(menuRoute, ID_RT_MENU_SHOWNAMES,
743 _(
"Show Waypoint Names"));
745 MenuAppend1(menuRoute, ID_RT_MENU_RESEQUENCE,
746 _(
"Resequence Waypoints..."));
749 wxString port = parent->FindValidUploadPort();
750 parent->m_active_upload_port = port;
751 wxString item = _(
"Send to GPS");
752 if (!port.IsEmpty()) {
753 item.Append(_T(
" ( "));
755 item.Append(_T(
" )"));
757 MenuAppend1(menuRoute, ID_RT_MENU_SENDTOGPS, item);
759 if (!port.IsEmpty()) {
760 wxString item = _(
"Send to new GPS");
761 MenuAppend1(menuRoute, ID_RT_MENU_SENDTONEWGPS, item);
764 wxString itemstp = _(
"Send to...");
765 MenuAppend1(menuRoute, ID_RT_MENU_SENDTOPEER, itemstp);
769 if (menuFocus != menuAIS) menuFocus = menuRoute;
772 if (seltype & SELTYPE_TRACKSEGMENT) {
773 name = wxEmptyString;
774 if (!g_bBasicMenus && m_pSelectedTrack)
775 name = _T(
" ( ") + m_pSelectedTrack->GetName(
true) + _T(
" )");
777 name = wxEmptyString;
779 if (m_pSelectedTrack && m_pSelectedTrack->m_bIsInLayer) blay =
true;
782 menuTrack =
new wxMenu(_(
"Layer Track") + name);
783 MenuAppend1(menuTrack, ID_TK_MENU_PROPERTIES,
784 _(
"Properties") + _T(
"..." ));
786 menuTrack =
new wxMenu(_(
"Track") + name);
787 MenuAppend1(menuTrack, ID_TK_MENU_PROPERTIES,
788 _(
"Properties") + _T(
"..." ));
789 MenuAppend1(menuTrack, ID_TK_MENU_COPY, _(
"Copy as KML"));
790 MenuAppend1(menuTrack, ID_TK_MENU_DELETE, _(
"Delete") + _T(
"..." ));
793 if (menuFocus != menuAIS) menuFocus = menuTrack;
796 if (seltype & SELTYPE_ROUTEPOINT) {
797 if (!g_bBasicMenus && m_pFoundRoutePoint) {
798 name = m_pFoundRoutePoint->GetName();
799 if (name.IsEmpty()) name = _(
"Unnamed Waypoint");
800 name.Prepend(_T(
" ( ")).Append(_T(
" )"));
802 name = wxEmptyString;
804 if (m_pFoundRoutePoint && m_pFoundRoutePoint->m_bIsInLayer) blay =
true;
807 menuWaypoint =
new wxMenu(_(
"Layer Waypoint") + name);
808 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
809 _(
"Properties") + _T(
"..." ));
811 if (m_pSelectedRoute && m_pSelectedRoute->IsActive())
812 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTPOINT, _(
"Activate"));
814 menuWaypoint =
new wxMenu(_(
"Waypoint") + name);
815 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
816 _(
"Properties") + _T(
"..." ));
817 if (m_pSelectedRoute && m_pSelectedRoute->IsActive()) {
818 if (m_pSelectedRoute->m_pRouteActivePoint != m_pFoundRoutePoint)
819 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTPOINT, _(
"Activate"));
822 if (m_pSelectedRoute && m_pSelectedRoute->IsActive()) {
823 if (m_pSelectedRoute->m_pRouteActivePoint == m_pFoundRoutePoint) {
824 int indexActive = m_pSelectedRoute->GetIndexOf(
825 m_pSelectedRoute->m_pRouteActivePoint);
826 if ((indexActive + 1) <= m_pSelectedRoute->GetnPoints())
827 MenuAppend1(menuWaypoint, ID_RT_MENU_ACTNXTPOINT,
828 _(
"Activate Next Waypoint"));
831 if (m_pSelectedRoute && m_pSelectedRoute->GetnPoints() > 2) {
832 MenuAppend1(menuWaypoint, ID_RT_MENU_REMPOINT, _(
"Remove from Route"));
834 m_SelectedIdx = m_pSelectedRoute->GetIndexOf(m_pFoundRoutePoint);
835 if (m_SelectedIdx > 1 && m_SelectedIdx < m_pSelectedRoute->GetnPoints())
836 MenuAppend1(menuWaypoint, ID_RT_MENU_SPLIT_WPT,
837 _(
"Split Route at Waypoint"));
840 MenuAppend1(menuWaypoint, ID_WPT_MENU_COPY, _(
"Copy as KML"));
842 if (m_pFoundRoutePoint && m_pFoundRoutePoint->GetIconName() != _T(
"mob"))
843 MenuAppend1(menuWaypoint, ID_RT_MENU_DELPOINT, _(
"Delete"));
846 wxString port = parent->FindValidUploadPort();
847 parent->m_active_upload_port = port;
848 wxString item = _(
"Send to GPS");
849 if (!port.IsEmpty()) {
850 item.Append(_T(
" ( "));
852 item.Append(_T(
" )"));
854 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOGPS, item);
856 if (!port.IsEmpty()) {
857 wxString item = _(
"Send to new GPS");
858 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTONEWGPS, item);
863 if (menuFocus != menuAIS) menuFocus = menuWaypoint;
866 if (seltype & SELTYPE_MARKPOINT) {
867 if (!g_bBasicMenus && m_pFoundRoutePoint) {
868 name = m_pFoundRoutePoint->GetName();
869 if (name.IsEmpty()) name = _(
"Unnamed Waypoint");
870 name.Prepend(_T(
" ( ")).Append(_T(
" )"));
872 name = wxEmptyString;
874 if (m_pFoundRoutePoint && m_pFoundRoutePoint->m_bIsInLayer) blay =
true;
877 menuWaypoint =
new wxMenu(_(
"Layer Waypoint") + name);
878 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
879 _(
"Properties") + _T(
"..." ));
881 menuWaypoint =
new wxMenu(_(
"Waypoint") + name);
882 MenuAppend1(menuWaypoint, ID_WP_MENU_PROPERTIES,
883 _(
"Properties") + _T(
"..." ));
885 if (!g_pRouteMan->GetpActiveRoute())
886 MenuAppend1(menuWaypoint, ID_WP_MENU_GOTO, _(
"Navigate To This"));
888 MenuAppend1(menuWaypoint, ID_WPT_MENU_COPY, _(
"Copy as KML"));
890 if (m_pFoundRoutePoint && m_pFoundRoutePoint->GetIconName() != _T(
"mob"))
891 MenuAppend1(menuWaypoint, ID_WP_MENU_DELPOINT, _(
"Delete"));
894 wxString port = parent->FindValidUploadPort();
895 parent->m_active_upload_port = port;
896 wxString item = _(
"Send to GPS");
897 if (!port.IsEmpty()) {
898 item.Append(_T(
" ( "));
900 item.Append(_T(
" )"));
902 MenuAppend1(menuWaypoint, ID_WPT_MENU_SENDTOGPS, item);
905 if ((m_pFoundRoutePoint == pAnchorWatchPoint1) ||
906 (m_pFoundRoutePoint == pAnchorWatchPoint2))
907 MenuAppend1(menuWaypoint, ID_WP_MENU_CLEAR_ANCHORWATCH,
908 _(
"Clear Anchor Watch"));
910 if (m_pFoundRoutePoint && !(m_pFoundRoutePoint->m_bIsInLayer) &&
911 ((NULL == pAnchorWatchPoint1) || (NULL == pAnchorWatchPoint2))) {
914 DistanceBearingMercator(m_pFoundRoutePoint->m_lat,
915 m_pFoundRoutePoint->m_lon, gLat, gLon, &brg,
917 if (dist * 1852. <= g_nAWMax)
918 MenuAppend1(menuWaypoint, ID_WP_MENU_SET_ANCHORWATCH,
919 _(
"Set Anchor Watch"));
924 if (menuFocus != menuAIS) menuFocus = menuWaypoint;
927 enum { WPMENU = 1, TKMENU = 2, RTMENU = 4, MMMENU = 8 };
929 if (!g_bBasicMenus && menuFocus != contextMenu) {
930 if(global_color_scheme != GLOBAL_COLOR_SCHEME_DUSK &&
931 global_color_scheme != GLOBAL_COLOR_SCHEME_NIGHT ){
932 menuFocus->AppendSeparator();
934 wxMenuItem *subMenu1;
935 if (menuWaypoint && menuFocus != menuWaypoint) {
937 menuFocus->AppendSubMenu(menuWaypoint, menuWaypoint->GetTitle());
938 SetMenuItemFont1(subMenu1);
941 menuWaypoint->SetTitle(wxEmptyString);
944 if (menuTrack && menuFocus != menuTrack) {
945 subMenu1 = menuFocus->AppendSubMenu(menuTrack, menuTrack->GetTitle());
946 SetMenuItemFont1(subMenu1);
949 menuTrack->SetTitle(wxEmptyString);
952 if (menuRoute && menuFocus != menuRoute) {
953 subMenu1 = menuFocus->AppendSubMenu(menuRoute, menuRoute->GetTitle());
954 SetMenuItemFont1(subMenu1);
957 menuRoute->SetTitle(wxEmptyString);
960 subMenu1 = menuFocus->AppendSubMenu(contextMenu, _(
"Main Menu"));
961 SetMenuItemFont1(subMenu1);
965 if (!subMenuChart->GetMenuItemCount()) contextMenu->Destroy(subItemChart);
970 if (seltype & SELTYPE_TIDEPOINT) {
971 menuFocus->AppendSeparator();
973 MenuAppend1(menuFocus, ID_DEF_MENU_TIDEINFO, _(
"Show Tide Information"));
976 if (seltype & SELTYPE_CURRENTPOINT) {
977 if (!bsep) menuFocus->AppendSeparator();
978 MenuAppend1(menuFocus, ID_DEF_MENU_CURRENTINFO,
979 _(
"Show Current Information"));
983 g_pi_manager->PrepareAllPluginContextMenus();
986 ArrayOfPlugInMenuItems item_array =
987 g_pi_manager->GetPluginContextMenuItemArray();
989 for (
unsigned int i = 0; i < item_array.GetCount(); i++) {
991 if (!pimis->b_viz)
continue;
993 wxMenu *submenu = NULL;
994 if (pimis->pmenu_item->GetSubMenu()) {
995 submenu =
new wxMenu();
996 const wxMenuItemList &items =
997 pimis->pmenu_item->GetSubMenu()->GetMenuItems();
998 for (wxMenuItemList::const_iterator it = items.begin(); it != items.end();
1001 for (
unsigned int j = 0; j < item_array.GetCount(); j++) {
1003 if (pimis->pmenu_item == *it)
id = pimis->id;
1006 wxMenuItem *pmi =
new wxMenuItem(submenu,
id,
1007#
if wxCHECK_VERSION(3, 0, 0)
1008 (*it)->GetItemLabelText(),
1012 (*it)->GetHelp(), (*it)->GetKind());
1015 if (m_DIPFactor == 1.0)
1016 pmi->SetFont(m_scaledFont);
1018 PrepareMenuItem( pmi );
1019 submenu->Append(pmi);
1020 pmi->Check((*it)->IsChecked());
1024 wxMenuItem *pmi =
new wxMenuItem(contextMenu, pimis->id,
1025#
if wxCHECK_VERSION(3, 0, 0)
1026 pimis->pmenu_item->GetItemLabelText(),
1028 pimis->pmenu_item->GetLabel(),
1030 pimis->pmenu_item->GetHelp(),
1031 pimis->pmenu_item->GetKind(), submenu);
1033 if (m_DIPFactor == 1.0)
1034 pmi->SetFont(m_scaledFont);
1037 PrepareMenuItem( pmi );
1039 wxMenu *dst = contextMenu;
1040 if (pimis->m_in_menu ==
"Waypoint")
1042 else if (pimis->m_in_menu ==
"Route")
1044 else if (pimis->m_in_menu ==
"Track")
1046 else if (pimis->m_in_menu ==
"AIS")
1051 dst->Enable(pimis->id, !pimis->b_grey);
1057#ifdef __OCPN__ANDROID__
1058 androidEnableBackButton(
false);
1059 androidEnableOptionsMenu(
false);
1061 setMenuStyleSheet(menuRoute, GetOCPNGUIScaledFont(_T(
"Menu")));
1062 setMenuStyleSheet(menuWaypoint, GetOCPNGUIScaledFont(_T(
"Menu")));
1063 setMenuStyleSheet(menuTrack, GetOCPNGUIScaledFont(_T(
"Menu")));
1064 setMenuStyleSheet(menuAIS, GetOCPNGUIScaledFont(_T(
"Menu")));
1067 parent->PopupMenu(menuFocus, x, y);
1069#ifdef __OCPN__ANDROID__
1070 androidEnableBackButton(
true);
1071 androidEnableOptionsMenu(
true);
1078 if (!(sub_menu & MMMENU))
delete contextMenu;
1079 if (!(sub_menu & RTMENU))
delete menuRoute;
1080 if (!(sub_menu & TKMENU))
delete menuTrack;
1081 if (!(sub_menu & WPMENU))
delete menuWaypoint;
1084void CanvasMenuHandler::PopupMenuHandler(wxCommandEvent &event) {
1091 bool dupFirstWpt =
true, showRPD;
1093 parent->GetCanvasPixPoint(popx * parent->GetDisplayScale(),
1094 popy* parent->GetDisplayScale(),
1097 switch (event.GetId()) {
1098 case ID_DEF_MENU_MAX_DETAIL:
1101 parent->ClearbFollow();
1103 parent->parent_frame->DoChartUpdate();
1105 parent->SelectChartFromStack(0,
false, CHART_TYPE_DONTCARE,
1106 CHART_FAMILY_RASTER);
1109 case ID_DEF_MENU_SCALE_IN:
1110 parent->DoCanvasStackDelta(-1);
1113 case ID_DEF_MENU_SCALE_OUT:
1114 parent->DoCanvasStackDelta(1);
1118 parent->undo->UndoLastAction();
1119 parent->InvalidateGL();
1120 parent->Refresh(
false);
1124 parent->undo->RedoNextAction();
1125 parent->InvalidateGL();
1126 parent->Refresh(
false);
1129 case ID_DEF_MENU_MOVE_BOAT_HERE:
1132 gFrame->UpdateStatusBar();
1135 case ID_DEF_MENU_GOTO_HERE: {
1137 wxEmptyString, wxEmptyString);
1138 pSelect->AddSelectableRoutePoint(zlat, zlon, pWP_dest);
1141 wxEmptyString, wxEmptyString);
1142 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
1145 pRouteList->Append(temp_route);
1147 temp_route->AddPoint(pWP_src);
1148 temp_route->AddPoint(pWP_dest);
1150 pSelect->AddSelectableRouteSegment(gLat, gLon, zlat, zlon, pWP_src,
1151 pWP_dest, temp_route);
1153 temp_route->m_RouteNameString = _(
"Temporary GOTO Route");
1154 temp_route->m_RouteStartString = _(
"Here");
1156 temp_route->m_RouteEndString = _(
"There");
1158 temp_route->m_bDeleteOnArrival =
true;
1160 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1162 g_pRouteMan->ActivateRoute(temp_route, pWP_dest);
1167 case ID_DEF_MENU_DROP_WP: {
1169 wxEmptyString, wxEmptyString);
1170 pWP->m_bIsolatedMark =
true;
1171 pSelect->AddSelectableRoutePoint(zlat, zlon, pWP);
1172 pConfig->AddNewWayPoint(pWP, -1);
1176 if (RouteManagerDialog::getInstanceFlag()) {
1177 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1178 pRouteManagerDialog->UpdateWptListCtrl();
1182 parent->undo->BeforeUndoableAction(Undo_CreateWaypoint, pWP,
1183 Undo_HasParent, NULL);
1184 parent->undo->AfterUndoableAction(NULL);
1185 gFrame->RefreshAllCanvas(
false);
1186 gFrame->InvalidateAllGL();
1187 g_FlushNavobjChanges =
true;
1191 case ID_DEF_MENU_NEW_RT: {
1192 parent->StartRoute();
1196 case ID_DEF_MENU_AISTARGETLIST:
1197 parent->ShowAISTargetList();
1200 case ID_WP_MENU_GOTO: {
1202 wxEmptyString, wxEmptyString);
1203 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
1206 pRouteList->Append(temp_route);
1208 temp_route->AddPoint(pWP_src);
1209 temp_route->AddPoint(m_pFoundRoutePoint);
1210 m_pFoundRoutePoint->SetShared(
true);
1212 pSelect->AddSelectableRouteSegment(gLat, gLon, m_pFoundRoutePoint->m_lat,
1213 m_pFoundRoutePoint->m_lon, pWP_src,
1214 m_pFoundRoutePoint, temp_route);
1216 wxString name = m_pFoundRoutePoint->GetName();
1217 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
1218 wxString rteName = _(
"Go to ");
1219 rteName.Append(name);
1220 temp_route->m_RouteNameString = rteName;
1221 temp_route->m_RouteStartString = _(
"Here");
1223 temp_route->m_RouteEndString = name;
1224 temp_route->m_bDeleteOnArrival =
true;
1226 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1228 g_pRouteMan->ActivateRoute(temp_route, m_pFoundRoutePoint);
1233 case ID_DEF_MENU_COGUP:
1234 parent->SetUpMode(COURSE_UP_MODE);
1237 case ID_DEF_MENU_HEADUP:
1238 parent->SetUpMode(HEAD_UP_MODE);
1241 case ID_DEF_MENU_NORTHUP:
1242 parent->SetUpMode(NORTH_UP_MODE);
1245 case ID_DEF_MENU_TOGGLE_FULL:
1246 gFrame->ToggleFullScreen();
1249 case ID_DEF_MENU_GOTOPOSITION:
1250 if (NULL == pGoToPositionDialog)
1253 pGoToPositionDialog->SetCanvas(parent);
1254 pGoToPositionDialog->CheckPasteBufferForPosition();
1255 pGoToPositionDialog->Show();
1258 case ID_WP_MENU_DELPOINT: {
1259 if (m_pFoundRoutePoint == pAnchorWatchPoint1) {
1260 pAnchorWatchPoint1 = NULL;
1262 }
else if (m_pFoundRoutePoint == pAnchorWatchPoint2) {
1263 pAnchorWatchPoint2 = NULL;
1267 if (m_pFoundRoutePoint && !(m_pFoundRoutePoint->m_bIsInLayer) &&
1268 (m_pFoundRoutePoint->GetIconName() != _T(
"mob"))) {
1272 wxArrayPtrVoid *proute_array =
1273 g_pRouteMan->GetRouteArrayContaining(m_pFoundRoutePoint);
1275 pWayPointMan->DestroyWaypoint(m_pFoundRoutePoint);
1277 parent->undo->BeforeUndoableAction(
1278 Undo_DeleteWaypoint, m_pFoundRoutePoint, Undo_IsOrphanded,
1280 pConfig->DeleteWayPoint(m_pFoundRoutePoint);
1281 pSelect->DeleteSelectablePoint(m_pFoundRoutePoint,
1282 SELTYPE_ROUTEPOINT);
1283 if (NULL != pWayPointMan)
1284 pWayPointMan->RemoveRoutePoint(m_pFoundRoutePoint);
1285 parent->undo->AfterUndoableAction(NULL);
1288 if (g_pMarkInfoDialog) {
1289 g_pMarkInfoDialog->SetRoutePoint(NULL);
1290 g_pMarkInfoDialog->UpdateProperties();
1293 if(RouteManagerDialog::getInstanceFlag()){
1294 if (pRouteManagerDialog) {
1295 if (pRouteManagerDialog->IsShown())
1296 pRouteManagerDialog->UpdateWptListCtrl();
1300 gFrame->RefreshAllCanvas(
false);
1301 gFrame->InvalidateAllGL();
1305 case ID_WP_MENU_PROPERTIES:
1306 parent->ShowMarkPropertiesDialog(m_pFoundRoutePoint);
1309 case ID_WP_MENU_CLEAR_ANCHORWATCH:
1310 if (pAnchorWatchPoint1 == m_pFoundRoutePoint) {
1311 pAnchorWatchPoint1 = NULL;
1313 }
else if (pAnchorWatchPoint2 == m_pFoundRoutePoint) {
1314 pAnchorWatchPoint2 = NULL;
1319 case ID_WP_MENU_SET_ANCHORWATCH:
1320 if (pAnchorWatchPoint1 == NULL) {
1321 pAnchorWatchPoint1 = m_pFoundRoutePoint;
1322 g_AW1GUID = pAnchorWatchPoint1->m_GUID;
1324 nn = m_pFoundRoutePoint->GetName();
1326 nn.Printf(_T(
"%d m"), g_nAWDefault);
1327 m_pFoundRoutePoint->SetName(nn);
1329 }
else if (pAnchorWatchPoint2 == NULL) {
1330 pAnchorWatchPoint2 = m_pFoundRoutePoint;
1331 g_AW2GUID = pAnchorWatchPoint2->m_GUID;
1333 nn = m_pFoundRoutePoint->GetName();
1335 nn.Printf(_T(
"%d m"), g_nAWDefault);
1336 m_pFoundRoutePoint->SetName(nn);
1341 case ID_DEF_MENU_ACTIVATE_MEASURE:
1342 parent->StartMeasureRoute();
1345 case ID_DEF_MENU_DEACTIVATE_MEASURE:
1346 parent->CancelMeasureRoute();
1348 parent->InvalidateGL();
1349 parent->Refresh(
false);
1352 case ID_DEF_MENU_CM93OFFSET_DIALOG: {
1353 if (NULL == g_pCM93OffsetDialog) {
1358 if (!parent->GetVP().b_quilt && parent->m_singleChart &&
1359 (parent->m_singleChart->GetChartType() == CHART_TYPE_CM93COMP)) {
1363 if (g_pCM93OffsetDialog) {
1364 g_pCM93OffsetDialog->SetCM93Chart(pch);
1365 g_pCM93OffsetDialog->Show();
1366 g_pCM93OffsetDialog->UpdateMCOVRList(parent->GetVP());
1371 case ID_DEF_MENU_QUERY: {
1372 parent->ShowObjectQueryWindow(popx, popy, zlat, zlon);
1375 case ID_DEF_MENU_AIS_QUERY: {
1376 wxWindow *pwin = wxDynamicCast(parent, wxWindow);
1377 ShowAISTargetQueryDialog(pwin, m_FoundAIS_MMSI);
1381 case ID_DEF_MENU_AIS_CPA: {
1382 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
1383 if (myptarget) myptarget->Toggle_AIS_CPA();
1387 case ID_DEF_MENU_AISSHOWTRACK: {
1388 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(m_FoundAIS_MMSI);
1389 if (myptarget) myptarget->ToggleShowTrack();
1393 case ID_DEF_MENU_COPY_MMSI: {
1395 if (wxTheClipboard->Open()) {
1396 wxTheClipboard->SetData(
new wxTextDataObject(
1397 wxString::Format(wxT(
"%09d"), m_FoundAIS_MMSI)));
1398 wxTheClipboard->Close();
1403 case ID_DEF_MENU_QUILTREMOVE: {
1404 if (parent->GetVP().b_quilt) {
1405 int dbIndex = parent->m_pQuilt->GetChartdbIndexAtPix(
1406 parent->GetVP(), wxPoint(popx, popy));
1407 parent->RemoveChartFromQuilt(dbIndex);
1415 case ID_DEF_MENU_CURRENTINFO: {
1416 parent->DrawTCWindow(popx, popy, (
void *)m_pIDXCandidate);
1417 parent->Refresh(
false);
1422 case ID_DEF_MENU_TIDEINFO: {
1423 parent->DrawTCWindow(popx, popy, (
void *)m_pIDXCandidate);
1424 parent->Refresh(
false);
1428 case ID_RT_MENU_REVERSE: {
1429 if (m_pSelectedRoute->m_bIsInLayer)
break;
1432 OCPNMessageBox(parent, g_pRouteMan->GetRouteReverseMessage(),
1433 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1435 if (ask_return != wxID_CANCEL) {
1436 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1437 m_pSelectedRoute->Reverse(ask_return == wxID_YES);
1438 pSelect->AddAllSelectableRouteSegments(m_pSelectedRoute);
1440 pConfig->UpdateRoute(m_pSelectedRoute);
1442 if (pRoutePropDialog && (pRoutePropDialog->IsShown())) {
1443 pRoutePropDialog->SetRouteAndUpdate(m_pSelectedRoute);
1446 gFrame->InvalidateAllGL();
1447 gFrame->RefreshAllCanvas();
1452 case ID_RT_MENU_SHOWNAMES: {
1453 if (m_pSelectedRoute) {
1454 m_pSelectedRoute->ShowWaypointNames(
1455 !m_pSelectedRoute->AreWaypointNamesVisible());
1461 case ID_RT_MENU_RESEQUENCE: {
1462 if (m_pSelectedRoute) {
1463 if (m_pSelectedRoute->m_bIsInLayer)
break;
1466 OCPNMessageBox(parent, g_pRouteMan->GetRouteResequenceMessage(),
1467 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1469 if (ask_return != wxID_CANCEL) {
1470 m_pSelectedRoute->RenameRoutePoints();
1473 gFrame->InvalidateAllGL();
1474 gFrame->RefreshAllCanvas();
1480 case ID_RT_MENU_DELETE: {
1481 int dlg_return = wxID_YES;
1482 if (g_bConfirmObjectDelete) {
1483 dlg_return = OCPNMessageBox(
1484 parent, _(
"Are you sure you want to delete this route?"),
1485 _(
"OpenCPN Route Delete"),
1486 (
long)wxYES_NO | wxCANCEL | wxYES_DEFAULT);
1489 if (dlg_return == wxID_YES) {
1490 if (g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute)
1491 g_pRouteMan->DeactivateRoute();
1493 if (m_pSelectedRoute->m_bIsInLayer)
break;
1496 NavObjectChanges::getInstance()))
break;
1498 if(RouteManagerDialog::getInstanceFlag()){
1499 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1500 pRouteManagerDialog->UpdateRouteListCtrl();
1503 if (g_pMarkInfoDialog && g_pMarkInfoDialog->IsShown()) {
1504 g_pMarkInfoDialog->ValidateMark();
1505 g_pMarkInfoDialog->UpdateProperties();
1508 parent->undo->InvalidateUndo();
1510 gFrame->InvalidateAllGL();
1511 gFrame->RefreshAllCanvas();
1516 case ID_RT_MENU_ACTIVATE: {
1517 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1523 if (m_pSelectedRoute) {
1525 m_pSelectedRoute->m_RouteNameString.Find(_T(
"MOB"))) {
1526 best_point = g_pRouteMan->FindBestActivatePoint(
1527 m_pSelectedRoute, gLat, gLon, gCog, gSog);
1529 best_point = m_pSelectedRoute->GetPoint(2);
1531 g_pRouteMan->ActivateRoute(m_pSelectedRoute, best_point);
1532 m_pSelectedRoute->m_bRtIsSelected =
false;
1538 case ID_RT_MENU_DEACTIVATE:
1539 g_pRouteMan->DeactivateRoute();
1540 m_pSelectedRoute->m_bRtIsSelected =
false;
1544 case ID_RT_MENU_INSERT: {
1545 if (m_pSelectedRoute->m_bIsInLayer)
break;
1546 bool rename =
false;
1547 m_pSelectedRoute->InsertPointAfter(m_pFoundRoutePoint, zlat, zlon,
1550 pSelect->DeleteAllSelectableRoutePoints(m_pSelectedRoute);
1551 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1553 pSelect->AddAllSelectableRouteSegments(m_pSelectedRoute);
1554 pSelect->AddAllSelectableRoutePoints(m_pSelectedRoute);
1567 pConfig->UpdateRoute(m_pSelectedRoute);
1569 if (pRoutePropDialog && (pRoutePropDialog->IsShown())) {
1570 pRoutePropDialog->SetRouteAndUpdate(m_pSelectedRoute,
true);
1576 case ID_RT_MENU_APPEND:
1578 if (m_pSelectedRoute->m_bIsInLayer)
break;
1580 parent->m_pMouseRoute = m_pSelectedRoute;
1581 parent->m_routeState = m_pSelectedRoute->GetnPoints() + 1;
1582 parent->m_pMouseRoute->m_lastMousePointIndex =
1583 m_pSelectedRoute->GetnPoints();
1584 parent->m_pMouseRoute->SetHiLite(50);
1586 pLast = m_pSelectedRoute->GetLastPoint();
1588 parent->m_prev_rlat = pLast->m_lat;
1589 parent->m_prev_rlon = pLast->m_lon;
1590 parent->m_prev_pMousePoint = pLast;
1592 parent->m_bAppendingRoute =
true;
1594 parent->SetCursor(*parent->pCursorPencil);
1595#ifdef __OCPN__ANDROID__
1596 androidSetRouteAnnunciator(
true);
1599 parent->HideGlobalToolbar();
1603 case ID_RT_MENU_SPLIT_LEG:
1605 dupFirstWpt =
false;
1606 case ID_RT_MENU_SPLIT_WPT:
1608 showRPD = (pRoutePropDialog && pRoutePropDialog->IsShown());
1610 m_pHead =
new Route();
1611 m_pTail =
new Route();
1612 m_pHead->CloneRoute(m_pSelectedRoute, 1, m_SelectedIdx, _(
"_A"));
1613 m_pTail->CloneRoute(m_pSelectedRoute, m_SelectedIdx + splitMode,
1614 m_pSelectedRoute->GetnPoints(), _(
"_B"), dupFirstWpt);
1615 pRouteList->Append(m_pHead);
1616 pConfig->AddNewRoute(m_pHead);
1618 pRouteList->Append(m_pTail);
1619 pConfig->AddNewRoute(m_pTail);
1621 pConfig->DeleteConfigRoute(m_pSelectedRoute);
1623 pSelect->DeleteAllSelectableRoutePoints(m_pSelectedRoute);
1624 pSelect->DeleteAllSelectableRouteSegments(m_pSelectedRoute);
1626 NavObjectChanges::getInstance());
1627 pSelect->AddAllSelectableRouteSegments(m_pTail);
1628 pSelect->AddAllSelectableRoutePoints(m_pTail);
1629 pSelect->AddAllSelectableRouteSegments(m_pHead);
1630 pSelect->AddAllSelectableRoutePoints(m_pHead);
1633 pRoutePropDialog->SetRouteAndUpdate(m_pHead);
1634 pRoutePropDialog->Show();
1636 if (RouteManagerDialog::getInstanceFlag() && pRouteManagerDialog &&
1637 (pRouteManagerDialog->IsShown()))
1638 pRouteManagerDialog->UpdateRouteListCtrl();
1641 case ID_RT_MENU_COPY:
1642 if (m_pSelectedRoute) Kml::CopyRouteToClipboard(m_pSelectedRoute);
1645 case ID_TK_MENU_COPY:
1646 if (m_pSelectedTrack) Kml::CopyTrackToClipboard(m_pSelectedTrack);
1649 case ID_WPT_MENU_COPY:
1650 if (m_pFoundRoutePoint) Kml::CopyWaypointToClipboard(m_pFoundRoutePoint);
1653 case ID_WPT_MENU_SENDTOGPS:
1654 if (m_pFoundRoutePoint) {
1655 if (parent->m_active_upload_port.Length())
1657 parent->m_active_upload_port.BeforeFirst(
' '), NULL);
1660 dlg.SetWaypoint(m_pFoundRoutePoint);
1661 wxFont fo = GetOCPNGUIScaledFont(_T(
"Dialog"));
1664 dlg.Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), _T(
""));
1670 case ID_WPT_MENU_SENDTONEWGPS:
1671 if (m_pFoundRoutePoint) {
1673 dlg.SetWaypoint(m_pFoundRoutePoint);
1675 dlg.Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), _T(
""));
1680 case ID_RT_MENU_SENDTOGPS:
1681 if (m_pSelectedRoute) {
1682 if (parent->m_active_upload_port.Length())
1683 RouteGui(*m_pSelectedRoute).SendToGPS(
1684 parent->m_active_upload_port.BeforeFirst(
' '),
true, NULL);
1687 dlg.SetRoute(m_pSelectedRoute);
1689 dlg.Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), _T(
""));
1695 case ID_RT_MENU_SENDTONEWGPS:
1696 if (m_pSelectedRoute) {
1698 dlg.SetRoute(m_pSelectedRoute);
1700 dlg.Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), _T(
""));
1705 case ID_RT_MENU_SENDTOPEER:
1706 if (m_pSelectedRoute) {
1709 dlg.SetRoute(m_pSelectedRoute);
1714 bool bDNScacheStale =
true;
1715 wxDateTime tnow = wxDateTime::Now();
1716 if (g_DNS_cache_time.IsValid()){
1717 wxTimeSpan delta = tnow.Subtract(g_DNS_cache_time);
1718 if (delta.GetMinutes() < 5)
1719 bDNScacheStale =
false;
1722 if ((g_DNS_cache.size() == 0) || bDNScacheStale)
1723 dlg.SetScanOnCreate(
true);
1726 dlg.Create(NULL, -1, _(
"Send Route to OpenCPN Peer") + _T(
"..." ), _T(
""));
1731 case ID_PASTE_WAYPOINT:
1732 pupHandler_PasteWaypoint();
1735 case ID_PASTE_ROUTE:
1736 pupHandler_PasteRoute();
1739 case ID_PASTE_TRACK:
1740 pupHandler_PasteTrack();
1743 case ID_RT_MENU_DELPOINT:
1744 if (m_pSelectedRoute) {
1745 if (m_pSelectedRoute->m_bIsInLayer)
break;
1747 pWayPointMan->DestroyWaypoint(m_pFoundRoutePoint);
1749 if (pRoutePropDialog && (pRoutePropDialog->IsShown())) {
1752 if (g_pRouteMan->IsRouteValid(m_pSelectedRoute)) {
1753 pRoutePropDialog->SetRouteAndUpdate(m_pSelectedRoute,
true);
1755 pRoutePropDialog->Hide();
1758 if(RouteManagerDialog::getInstanceFlag()){
1759 if (pRouteManagerDialog && pRouteManagerDialog->IsShown()) {
1760 pRouteManagerDialog->UpdateWptListCtrl();
1761 pRouteManagerDialog->UpdateRouteListCtrl();
1765 gFrame->InvalidateAllGL();
1766 gFrame->RefreshAllCanvas(
true);
1771 case ID_RT_MENU_REMPOINT:
1772 if (m_pSelectedRoute) {
1773 if (m_pSelectedRoute->m_bIsInLayer)
break;
1774 g_pRouteMan->RemovePointFromRoute(m_pFoundRoutePoint, m_pSelectedRoute,
1775 parent->m_routeState);
1776 gFrame->InvalidateAllGL();
1777 gFrame->RefreshAllCanvas();
1781 case ID_RT_MENU_ACTPOINT:
1782 if (g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute) {
1784 m_pSelectedRoute->m_bRtIsSelected =
false;
1789 case ID_RT_MENU_DEACTPOINT:
1792 case ID_RT_MENU_ACTNXTPOINT:
1793 if (g_pRouteMan->GetpActiveRoute() == m_pSelectedRoute) {
1795 m_pSelectedRoute->m_bRtIsSelected =
false;
1800 case ID_RT_MENU_PROPERTIES: {
1801 parent->ShowRoutePropertiesDialog(_(
"Route Properties"),
1806 case ID_TK_MENU_PROPERTIES: {
1807 parent->ShowTrackPropertiesDialog(m_pSelectedTrack);
1811 case ID_TK_MENU_DELETE: {
1812 int dlg_return = wxID_YES;
1813 if (g_bConfirmObjectDelete) {
1814 dlg_return = OCPNMessageBox(
1815 parent, _(
"Are you sure you want to delete this track?"),
1816 _(
"OpenCPN Track Delete"),
1817 (
long)wxYES_NO | wxCANCEL | wxYES_DEFAULT);
1820 if (dlg_return == wxID_YES) {
1821 if (m_pSelectedTrack == g_pActiveTrack)
1822 m_pSelectedTrack = parent->parent_frame->TrackOff();
1823 g_pAIS->DeletePersistentTrack(m_pSelectedTrack);
1824 pConfig->DeleteConfigTrack(m_pSelectedTrack);
1826 RoutemanGui(*g_pRouteMan).DeleteTrack(m_pSelectedTrack);
1828 if (TrackPropDlg::getInstanceFlag() && pTrackPropDialog &&
1829 (pTrackPropDialog->IsShown()) &&
1830 (m_pSelectedTrack == pTrackPropDialog->GetTrack())) {
1831 pTrackPropDialog->Hide();
1834 if (RoutePropDlgImpl::getInstanceFlag() && pRouteManagerDialog &&
1835 pRouteManagerDialog->IsShown()) {
1836 pRouteManagerDialog->UpdateTrkListCtrl();
1837 pRouteManagerDialog->UpdateRouteListCtrl();
1839 gFrame->InvalidateAllGL();
1840 gFrame->RefreshAllCanvas();
1845 case ID_RC_MENU_SCALE_IN:
1846 parent->parent_frame->DoStackDown(parent);
1847 parent->GetCanvasPointPix(zlat, zlon, &r);
1848 parent->WarpPointer(r.x, r.y);
1851 case ID_RC_MENU_SCALE_OUT:
1852 parent->parent_frame->DoStackUp(parent);
1853 parent->GetCanvasPointPix(zlat, zlon, &r);
1854 parent->WarpPointer(r.x, r.y);
1857 case ID_RC_MENU_ZOOM_IN:
1858 parent->SetVPScale(parent->GetVPScale() * 2);
1859 parent->GetCanvasPointPix(zlat, zlon, &r);
1860 parent->WarpPointer(r.x, r.y);
1863 case ID_RC_MENU_ZOOM_OUT:
1864 parent->SetVPScale(parent->GetVPScale() / 2);
1865 parent->GetCanvasPointPix(zlat, zlon, &r);
1866 parent->WarpPointer(r.x, r.y);
1869 case ID_RC_MENU_FINISH:
1870 parent->FinishRoute();
1872 parent->Refresh(
false);
1873 g_FlushNavobjChanges =
true;
1876 case ID_DEF_ZERO_XTE:
1877 g_pRouteMan->ZeroCurrentXTEToActivePoint();
1883 ArrayOfPlugInMenuItems item_array =
1884 g_pi_manager->GetPluginContextMenuItemArray();
1886 for (
unsigned int i = 0; i < item_array.GetCount(); i++) {
1889 if (pimis->id == event.GetId()) {
1890 if (pimis->m_pplugin)
1891 pimis->m_pplugin->OnContextMenuItemCallback(pimis->id);
1901 if ((event.GetId() >= ID_DEF_MENU_GROUPBASE) &&
1903 ID_DEF_MENU_GROUPBASE + (
int)g_pGroupArray->GetCount())) {
1904 parent->SetGroupIndex(event.GetId() - ID_DEF_MENU_GROUPBASE);
1907 parent->InvalidateGL();
void SurfaceAllCanvasToolbars(void)
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.