23#include "routemanagerdialog.h"
32#include <wx/filename.h>
33#include <wx/stdpaths.h>
34#include <wx/progdlg.h>
35#include <wx/clipbrd.h>
45#include "RoutePropDlgImpl.h"
47#include "routeman_gui.h"
48#include "route_point_gui.h"
52#include "SendToGpsDlg.h"
53#include "TrackPropDlg.h"
54#include "ais_decoder.h"
55#include "OCPNPlatform.h"
59#include "navutil_base.h"
61#include "ocpn_frame.h"
63#include "config_vars.h"
64#include "mDNS_query.h"
65#include "SendToPeerDlg.h"
67#ifdef __OCPN__ANDROID__
68#include "androidUTIL.h"
71#define DIALOG_MARGIN 3
73enum { rmVISIBLE = 0, rmROUTENAME, rmROUTEDESC };
74enum { colTRKVISIBLE = 0, colTRKNAME, colTRKLENGTH };
75enum { colLAYVISIBLE = 0, colLAYNAME, colLAYITEMS, colLAYPERSIST };
76enum { colWPTICON = 0, colWPTSCALE, colWPTNAME, colWPTDIST };
79extern RouteList *pRouteList;
80extern std::vector<Track*> g_TrackList;
81extern LayerList *pLayerList;
82extern wxString GetLayerName(
int id);
92extern bool g_bShowLayers;
93extern wxString g_default_wp_icon;
96extern bool g_bOverruleScaMin;
97extern std::vector<std::shared_ptr<ocpn_DNS_record_t>> g_DNS_cache;
100void appendOSDirSlash(wxString *pString);
102static int SortRouteTrack(
const int order,
const wxString &it1,
103 const wxString &it2) {
104 if (order & 1)
return it2.CmpNoCase(it1);
106 return it1.CmpNoCase(it2);
110static int sort_route_name_dir;
111#if wxCHECK_VERSION(2, 9, 0)
112static int wxCALLBACK SortRoutesOnName(wxIntPtr item1, wxIntPtr item2,
115int wxCALLBACK SortRoutesOnName(
long item1,
long item2,
long list)
118 return SortRouteTrack(sort_route_name_dir, ((
Route *)item1)->GetName(),
119 ((
Route *)item2)->GetName());
123static int sort_route_to_dir;
124#if wxCHECK_VERSION(2, 9, 0)
125static int wxCALLBACK SortRoutesOnTo(wxIntPtr item1, wxIntPtr item2,
128int wxCALLBACK SortRoutesOnTo(
long item1,
long item2,
long list)
131 return SortRouteTrack(sort_route_to_dir, ((
Route *)item1)->GetTo(),
132 ((
Route *)item2)->GetTo());
136static int sort_track_name_dir;
137#if wxCHECK_VERSION(2, 9, 0)
138static int wxCALLBACK SortTracksOnName(wxIntPtr item1, wxIntPtr item2,
141int wxCALLBACK SortTracksOnName(
long item1,
long item2,
long list)
144 return SortRouteTrack(sort_track_name_dir, ((
Track *)item1)->GetName(),
145 ((
Track *)item2)->GetName());
148static int SortDouble(
const int order,
const double &it1,
const double &it2) {
160 if (l1 == l2)
return 0;
161 if (l2 < l1)
return 1;
166static int sort_track_len_dir;
167#if wxCHECK_VERSION(2, 9, 0)
168static int wxCALLBACK SortTracksOnDistance(wxIntPtr item1, wxIntPtr item2,
171int wxCALLBACK SortTracksOnDistance(
long item1,
long item2,
long list)
174 return SortDouble(sort_track_len_dir, ((
Track *)item1)->Length(),
175 ((
Track *)item2)->Length());
178static int sort_wp_key;
179static int sort_track_key;
182static int sort_wp_name_dir;
183#if wxCHECK_VERSION(2, 9, 0)
184static int wxCALLBACK SortWaypointsOnName(wxIntPtr item1, wxIntPtr item2,
187int wxCALLBACK SortWaypointsOnName(
long item1,
long item2,
long list)
195 if (sort_wp_name_dir & 1)
196 return pRP2->GetName().CmpNoCase(pRP1->GetName());
198 return pRP1->GetName().CmpNoCase(pRP2->GetName());
204static int sort_wp_len_dir;
205#if wxCHECK_VERSION(2, 9, 0)
206static int wxCALLBACK SortWaypointsOnDistance(wxIntPtr item1, wxIntPtr item2,
209int wxCALLBACK SortWaypointsOnDistance(
long item1,
long item2,
long list)
213 DistanceBearingMercator(((
RoutePoint *)item1)->m_lat,
214 ((
RoutePoint *)item1)->m_lon, gLat, gLon, NULL,
216 DistanceBearingMercator(((
RoutePoint *)item2)->m_lat,
217 ((
RoutePoint *)item2)->m_lon, gLat, gLon, NULL,
219 return SortDouble(sort_wp_len_dir, dst1, dst2);
223static int sort_layer_name_dir;
224#if wxCHECK_VERSION(2, 9, 0)
225static int wxCALLBACK SortLayersOnName(wxIntPtr item1, wxIntPtr item2,
228int wxCALLBACK SortLayersOnName(
long item1,
long item2,
long list)
231 return SortRouteTrack(sort_layer_name_dir, ((
Layer *)item1)->m_LayerName,
232 ((
Layer *)item2)->m_LayerName);
236static int sort_layer_len_dir;
237#if wxCHECK_VERSION(2, 9, 0)
238static int wxCALLBACK SortLayersOnSize(wxIntPtr item1, wxIntPtr item2,
241int wxCALLBACK SortLayersOnSize(
long item1,
long item2,
long list)
244 return SortDouble(sort_layer_len_dir, ((
Layer *)item1)->m_NoOfItems,
245 ((
Layer *)item2)->m_NoOfItems);
252EVT_NOTEBOOK_PAGE_CHANGED(
254 RouteManagerDialog::OnTabSwitch)
255EVT_CLOSE(RouteManagerDialog::OnClose)
256EVT_COMMAND(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, RouteManagerDialog::OnOK)
257EVT_CHAR_HOOK(RouteManagerDialog::OnKey)
261 if (ke.GetKeyCode() == WXK_ESCAPE)
267void RouteManagerDialog::OnTabSwitch(wxNotebookEvent &event) {
268 if (!m_pNotebook)
return;
269 int current_page = m_pNotebook->GetSelection();
270 if (current_page == 3) {
271 if (btnImport) btnImport->Enable(
false);
272 if (btnExport) btnExport->Enable(
false);
273 if (btnExportViz) btnExportViz->Enable(
false);
275 if (btnImport) btnImport->Enable(
true);
276 if (btnExport) btnExport->Enable(
true);
277 if (btnExportViz) btnExportViz->Enable(
true);
284bool RouteManagerDialog::instanceFlag =
false;
297RouteManagerDialog::RouteManagerDialog(wxWindow *parent) {
299 wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT;
301 wxFrame::Create(parent, -1, wxString(_(
"Route & Mark Manager")),
302 wxDefaultPosition, wxDefaultSize, style);
304 wxFont *qFont = GetOCPNScaledFont(_(
"Dialog"));
310 sort_wp_key = SORT_ON_NAME;
311 sort_track_key = SORT_ON_NAME;
320void RouteManagerDialog::Create() {
322 int char_width, char_height;
323 GetTextExtent(_T(
"W"), &char_width, &char_height);
324 m_charWidth = char_width;
326 wxBoxSizer *itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
327 SetSizer(itemBoxSizer1);
329 m_pNotebook =
new wxNotebook(
this, wxID_ANY, wxDefaultPosition,
330 wxSize(-1, -1), wxNB_TOP);
331 itemBoxSizer1->Add(m_pNotebook, 1, wxALL | wxEXPAND, 5);
334 m_pPanelRte =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
335 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
337 wxBoxSizer *sbsRoutes =
new wxBoxSizer(wxHORIZONTAL);
338 m_pPanelRte->SetSizer(sbsRoutes);
339 m_pNotebook->AddPage(m_pPanelRte, _(
"Routes"));
342 sort_wp_name_dir = 0;
343 sort_track_len_dir = 1;
344 sort_route_to_dir = 0;
345 sort_track_name_dir = 0;
346 sort_route_name_dir = 0;
347 sort_layer_name_dir = 0;
348 sort_layer_len_dir = 1;
350 m_listIconSize = 2 * GetCharHeight();
353 wxBoxSizer *bSizerRteContents;
354 bSizerRteContents =
new wxBoxSizer(wxVERTICAL);
356 wxFlexGridSizer *fgSizerFilterRte;
357 fgSizerFilterRte =
new wxFlexGridSizer(0, 2, 0, 0);
358 fgSizerFilterRte->AddGrowableCol(1);
359 fgSizerFilterRte->SetFlexibleDirection(wxBOTH);
360 fgSizerFilterRte->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
362 m_stFilterRte =
new wxStaticText(m_pPanelRte, wxID_ANY, _(
"Filter"),
363 wxDefaultPosition, wxDefaultSize, 0);
364 m_stFilterRte->Wrap(-1);
365 fgSizerFilterRte->Add(m_stFilterRte, 0, wxALL, 5);
367 m_tFilterRte =
new wxTextCtrl(m_pPanelRte, wxID_ANY, wxEmptyString,
368 wxDefaultPosition, wxDefaultSize, 0);
369 fgSizerFilterRte->Add(m_tFilterRte, 1, wxALL | wxEXPAND, 5);
371 bSizerRteContents->Add(fgSizerFilterRte, 0, wxEXPAND, 5);
372 m_tFilterRte->Connect(
373 wxEVT_COMMAND_TEXT_UPDATED,
374 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
376 m_cbShowAllRte =
new wxCheckBox(m_pPanelRte, wxID_ANY, _(
"Show all routes"));
377 bSizerRteContents->Add(m_cbShowAllRte, 0, wxEXPAND | wxLEFT, 5);
378 m_cbShowAllRte->Connect(
379 wxEVT_COMMAND_CHECKBOX_CLICKED,
380 wxCommandEventHandler(RouteManagerDialog::OnShowAllRteCBClicked), NULL,
384 new wxListCtrl(m_pPanelRte, -1, wxDefaultPosition, wxSize(-1, -1),
385 wxLC_REPORT | wxLC_SORT_ASCENDING | wxLC_HRULES |
387#ifdef __OCPN__ANDROID__
388 m_pRouteListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
391 m_pRouteListCtrl->Connect(
392 wxEVT_COMMAND_LIST_ITEM_SELECTED,
393 wxListEventHandler(RouteManagerDialog::OnRteSelected), NULL,
this);
394 m_pRouteListCtrl->Connect(
395 wxEVT_COMMAND_LIST_ITEM_DESELECTED,
396 wxListEventHandler(RouteManagerDialog::OnRteSelected), NULL,
this);
397 m_pRouteListCtrl->Connect(
398 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
399 wxListEventHandler(RouteManagerDialog::OnRteDefaultAction), NULL,
this);
400 m_pRouteListCtrl->Connect(
402 wxMouseEventHandler(RouteManagerDialog::OnRteToggleVisibility), NULL,
404 m_pRouteListCtrl->Connect(
405 wxEVT_COMMAND_LIST_COL_CLICK,
406 wxListEventHandler(RouteManagerDialog::OnRteColumnClicked), NULL,
this);
407 bSizerRteContents->Add(m_pRouteListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
408 sbsRoutes->Add(bSizerRteContents, 1, wxEXPAND, 5);
413 m_pRouteListCtrl->InsertColumn(rmVISIBLE, _(
"Show"), wxLIST_FORMAT_LEFT,
415 m_pRouteListCtrl->InsertColumn(rmROUTENAME, _(
"Route Name"),
416 wxLIST_FORMAT_LEFT, 15 * char_width);
417 m_pRouteListCtrl->InsertColumn(rmROUTEDESC, _(
"From <-> To"),
418 wxLIST_FORMAT_LEFT, 10 * char_width);
421 wxBoxSizer *bsRouteButtons =
new wxBoxSizer(wxVERTICAL);
422 sbsRoutes->Add(bsRouteButtons, 0, wxEXPAND);
424 wxScrolledWindow *winr =
new wxScrolledWindow(
425 m_pPanelRte, wxID_ANY, wxDefaultPosition, wxDefaultSize,
426 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
427 winr->SetScrollRate(0, 5);
429 bsRouteButtons->Add(winr, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
431 wxBoxSizer *bsRouteButtonsInner =
new wxBoxSizer(wxVERTICAL);
432 winr->SetSizer(bsRouteButtonsInner);
434 btnRteProperties =
new wxButton(winr, -1, _(
"&Properties") + _T(
"..."));
435 bsRouteButtonsInner->Add(btnRteProperties, 0, wxALL | wxEXPAND,
437 btnRteProperties->Connect(
438 wxEVT_COMMAND_BUTTON_CLICKED,
439 wxCommandEventHandler(RouteManagerDialog::OnRtePropertiesClick), NULL,
442 btnRteActivate =
new wxButton(winr, -1, _(
"&Activate"));
443 bsRouteButtonsInner->Add(btnRteActivate, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
444 btnRteActivate->Connect(
445 wxEVT_COMMAND_BUTTON_CLICKED,
446 wxCommandEventHandler(RouteManagerDialog::OnRteActivateClick), NULL,
448 btnRteActivate->Connect(
450 wxMouseEventHandler(RouteManagerDialog::OnRteBtnLeftDown), NULL,
this);
452 btnRteZoomto =
new wxButton(winr, -1, _(
"&Center View"));
453 bsRouteButtonsInner->Add(btnRteZoomto, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
454 btnRteZoomto->Connect(
455 wxEVT_COMMAND_BUTTON_CLICKED,
456 wxCommandEventHandler(RouteManagerDialog::OnRteZoomtoClick), NULL,
this);
457 btnRteZoomto->Connect(
459 wxMouseEventHandler(RouteManagerDialog::OnRteBtnLeftDown), NULL,
this);
461 btnRteReverse =
new wxButton(winr, -1, _(
"&Reverse"));
462 bsRouteButtonsInner->Add(btnRteReverse, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
463 btnRteReverse->Connect(
464 wxEVT_COMMAND_BUTTON_CLICKED,
465 wxCommandEventHandler(RouteManagerDialog::OnRteReverseClick), NULL,
this);
467 btnRteDelete =
new wxButton(winr, -1, _(
"&Delete"));
468 bsRouteButtonsInner->Add(btnRteDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
469 btnRteDelete->Connect(
470 wxEVT_COMMAND_BUTTON_CLICKED,
471 wxCommandEventHandler(RouteManagerDialog::OnRteDeleteClick), NULL,
this);
473 btnRteExport =
new wxButton(winr, -1, _(
"&Export selected..."));
474 bsRouteButtonsInner->Add(btnRteExport, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
475 btnRteExport->Connect(
476 wxEVT_COMMAND_BUTTON_CLICKED,
477 wxCommandEventHandler(RouteManagerDialog::OnRteExportClick), NULL,
this);
479 btnRteResequence =
new wxButton(winr, -1, _(
"&Resequence Waypoints"));
480 bsRouteButtonsInner->Add(btnRteResequence, 0, wxALL | wxEXPAND,
482 btnRteResequence->Connect(
483 wxEVT_COMMAND_BUTTON_CLICKED,
484 wxCommandEventHandler(RouteManagerDialog::OnRteResequenceClick), NULL,
487 btnRteSendToPeer =
new wxButton(winr, -1, _(
"Send to &Peer"));
488 bsRouteButtonsInner->Add(btnRteSendToPeer, 0, wxALL | wxEXPAND,
490 btnRteSendToPeer->Connect(
491 wxEVT_COMMAND_BUTTON_CLICKED,
492 wxCommandEventHandler(RouteManagerDialog::OnRteSendToPeerClick), NULL,
495 btnRteSendToGPS =
new wxButton(winr, -1, _(
"&Send to GPS"));
496 bsRouteButtonsInner->Add(btnRteSendToGPS, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
497 btnRteSendToGPS->Connect(
498 wxEVT_COMMAND_BUTTON_CLICKED,
499 wxCommandEventHandler(RouteManagerDialog::OnRteSendToGPSClick), NULL,
502 bsRouteButtonsInner->AddSpacer(10);
504 btnRteDeleteAll =
new wxButton(winr, -1, _(
"&Delete All"));
505 bsRouteButtonsInner->Add(btnRteDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
506 btnRteDeleteAll->Connect(
507 wxEVT_COMMAND_BUTTON_CLICKED,
508 wxCommandEventHandler(RouteManagerDialog::OnRteDeleteAllClick), NULL,
512 m_pPanelTrk =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
513 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
514 wxBoxSizer *sbsTracks =
new wxBoxSizer(wxHORIZONTAL);
515 m_pPanelTrk->SetSizer(sbsTracks);
516 m_pNotebook->AddPage(m_pPanelTrk, _(
"Tracks"));
518 wxBoxSizer *bSizerTrkContents;
519 bSizerTrkContents =
new wxBoxSizer(wxVERTICAL);
521 wxFlexGridSizer *fgSizerFilterTrk;
522 fgSizerFilterTrk =
new wxFlexGridSizer(0, 2, 0, 0);
523 fgSizerFilterTrk->AddGrowableCol(1);
524 fgSizerFilterTrk->SetFlexibleDirection(wxBOTH);
525 fgSizerFilterTrk->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
527 m_stFilterTrk =
new wxStaticText(m_pPanelTrk, wxID_ANY, _(
"Filter"),
528 wxDefaultPosition, wxDefaultSize, 0);
529 m_stFilterTrk->Wrap(-1);
530 fgSizerFilterTrk->Add(m_stFilterTrk, 0, wxALL, 5);
532 m_tFilterTrk =
new wxTextCtrl(m_pPanelTrk, wxID_ANY, wxEmptyString,
533 wxDefaultPosition, wxDefaultSize, 0);
534 fgSizerFilterTrk->Add(m_tFilterTrk, 1, wxALL | wxEXPAND, 5);
536 bSizerTrkContents->Add(fgSizerFilterTrk, 0, wxEXPAND, 5);
537 m_tFilterTrk->Connect(
538 wxEVT_COMMAND_TEXT_UPDATED,
539 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
541 m_cbShowAllTrk =
new wxCheckBox(m_pPanelTrk, wxID_ANY, _(
"Show all tracks"));
542 bSizerTrkContents->Add(m_cbShowAllTrk, 0, wxEXPAND | wxLEFT, 5);
543 m_cbShowAllTrk->Connect(
544 wxEVT_COMMAND_CHECKBOX_CLICKED,
545 wxCommandEventHandler(RouteManagerDialog::OnShowAllTrkCBClicked), NULL,
549 new wxListCtrl(m_pPanelTrk, -1, wxDefaultPosition, wxDefaultSize,
550 wxLC_REPORT | wxLC_SORT_ASCENDING | wxLC_HRULES |
553#ifdef __OCPN__ANDROID__
554 m_pTrkListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
557 m_pTrkListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
558 wxListEventHandler(RouteManagerDialog::OnTrkSelected),
560 m_pTrkListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_DESELECTED,
561 wxListEventHandler(RouteManagerDialog::OnTrkSelected),
563 m_pTrkListCtrl->Connect(
564 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
565 wxListEventHandler(RouteManagerDialog::OnTrkDefaultAction), NULL,
this);
566 m_pTrkListCtrl->Connect(
568 wxMouseEventHandler(RouteManagerDialog::OnTrkToggleVisibility), NULL,
570 m_pTrkListCtrl->Connect(
571 wxEVT_COMMAND_LIST_COL_CLICK,
572 wxListEventHandler(RouteManagerDialog::OnTrkColumnClicked), NULL,
this);
573 m_pTrkListCtrl->Connect(
574 wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
575 wxListEventHandler(RouteManagerDialog::OnTrkRightClick), NULL,
this);
576 this->Connect(wxEVT_COMMAND_MENU_SELECTED,
577 wxCommandEventHandler(RouteManagerDialog::OnTrkMenuSelected),
580 bSizerTrkContents->Add(m_pTrkListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
581 sbsTracks->Add(bSizerTrkContents, 1, wxEXPAND, 5);
583 m_pTrkListCtrl->InsertColumn(colTRKVISIBLE, _(
"Show"), wxLIST_FORMAT_LEFT,
585 m_pTrkListCtrl->InsertColumn(colTRKNAME, _(
"Track Name"), wxLIST_FORMAT_LEFT,
587 m_pTrkListCtrl->InsertColumn(colTRKLENGTH, _(
"Length"), wxLIST_FORMAT_LEFT,
590 wxBoxSizer *bsTrkButtons =
new wxBoxSizer(wxVERTICAL);
591 sbsTracks->Add(bsTrkButtons, 0, wxEXPAND);
593 wxScrolledWindow *wint =
new wxScrolledWindow(
594 m_pPanelTrk, wxID_ANY, wxDefaultPosition, wxDefaultSize,
595 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
596 wint->SetScrollRate(0, 5);
598 bsTrkButtons->Add(wint, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
600 wxBoxSizer *bsTrkButtonsInner =
new wxBoxSizer(wxVERTICAL);
601 wint->SetSizer(bsTrkButtonsInner);
603 btnTrkNew =
new wxButton(wint, -1, _(
"&Start Track"));
604 bsTrkButtonsInner->Add(btnTrkNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
605 btnTrkNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
606 wxCommandEventHandler(RouteManagerDialog::OnTrkNewClick),
609 btnTrkProperties =
new wxButton(wint, -1, _(
"&Properties"));
610 bsTrkButtonsInner->Add(btnTrkProperties, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
611 btnTrkProperties->Connect(
612 wxEVT_COMMAND_BUTTON_CLICKED,
613 wxCommandEventHandler(RouteManagerDialog::OnTrkPropertiesClick), NULL,
616 btnTrkDelete =
new wxButton(wint, -1, _(
"&Delete"));
617 bsTrkButtonsInner->Add(btnTrkDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
618 btnTrkDelete->Connect(
619 wxEVT_COMMAND_BUTTON_CLICKED,
620 wxCommandEventHandler(RouteManagerDialog::OnTrkDeleteClick), NULL,
this);
622 btnTrkExport =
new wxButton(wint, -1, _(
"&Export selected..."));
623 bsTrkButtonsInner->Add(btnTrkExport, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
624 btnTrkExport->Connect(
625 wxEVT_COMMAND_BUTTON_CLICKED,
626 wxCommandEventHandler(RouteManagerDialog::OnTrkExportClick), NULL,
this);
628 btnTrkRouteFromTrack =
new wxButton(wint, -1, _(
"Route from Track"));
629 bsTrkButtonsInner->Add(btnTrkRouteFromTrack, 0, wxALL | wxEXPAND,
631 btnTrkRouteFromTrack->Connect(
632 wxEVT_COMMAND_BUTTON_CLICKED,
633 wxCommandEventHandler(RouteManagerDialog::OnTrkRouteFromTrackClick), NULL,
636 btnTrkSendToPeer =
new wxButton(wint, -1, _(
"Send to &Peer"));
637 bsTrkButtonsInner->Add(btnTrkSendToPeer, 0, wxALL | wxEXPAND,
639 btnTrkSendToPeer->Connect(
640 wxEVT_COMMAND_BUTTON_CLICKED,
641 wxCommandEventHandler(RouteManagerDialog::OnTrkSendToPeerClick), NULL,
644 bsTrkButtonsInner->AddSpacer(10);
646 btnTrkDeleteAll =
new wxButton(wint, -1, _(
"&Delete All"));
647 bsTrkButtonsInner->Add(btnTrkDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
648 btnTrkDeleteAll->Connect(
649 wxEVT_COMMAND_BUTTON_CLICKED,
650 wxCommandEventHandler(RouteManagerDialog::OnTrkDeleteAllClick), NULL,
654 m_pPanelWpt =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
655 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
656 wxBoxSizer *sbsWpts =
new wxBoxSizer(wxHORIZONTAL);
657 m_pPanelWpt->SetSizer(sbsWpts);
658 m_pNotebook->AddPage(m_pPanelWpt, _(
"Waypoints"));
660 wxBoxSizer *bSizerWptContents;
661 bSizerWptContents =
new wxBoxSizer(wxVERTICAL);
663 wxFlexGridSizer *fgSizerFilterWpt;
664 fgSizerFilterWpt =
new wxFlexGridSizer(0, 2, 0, 0);
665 fgSizerFilterWpt->AddGrowableCol(1);
666 fgSizerFilterWpt->SetFlexibleDirection(wxBOTH);
667 fgSizerFilterWpt->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
669 m_stFilterWpt =
new wxStaticText(m_pPanelWpt, wxID_ANY, _(
"Filter"),
670 wxDefaultPosition, wxDefaultSize, 0);
671 m_stFilterWpt->Wrap(-1);
672 fgSizerFilterWpt->Add(m_stFilterWpt, 0, wxALL, 5);
674 m_tFilterWpt =
new wxTextCtrl(m_pPanelWpt, wxID_ANY, wxEmptyString,
675 wxDefaultPosition, wxDefaultSize, 0);
676 fgSizerFilterWpt->Add(m_tFilterWpt, 1, wxALL | wxEXPAND, 5);
678 bSizerWptContents->Add(fgSizerFilterWpt, 0, wxEXPAND, 5);
679 m_tFilterWpt->Connect(
680 wxEVT_COMMAND_TEXT_UPDATED,
681 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
684 new wxCheckBox(m_pPanelWpt, wxID_ANY, _(
"Show all waypoints"));
685 bSizerWptContents->Add(m_cbShowAllWP, 0, wxEXPAND | wxLEFT, 5);
686 m_cbShowAllWP->Connect(
687 wxEVT_COMMAND_CHECKBOX_CLICKED,
688 wxCommandEventHandler(RouteManagerDialog::OnShowAllWpCBClicked), NULL,
692 new wxListCtrl(m_pPanelWpt, -1, wxDefaultPosition, wxDefaultSize,
693 wxLC_REPORT | wxLC_SORT_ASCENDING | wxLC_HRULES |
695#ifdef __OCPN__ANDROID__
696 m_pWptListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
699 m_pWptListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
700 wxListEventHandler(RouteManagerDialog::OnWptSelected),
702 m_pWptListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_DESELECTED,
703 wxListEventHandler(RouteManagerDialog::OnWptSelected),
705 m_pWptListCtrl->Connect(
706 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
707 wxListEventHandler(RouteManagerDialog::OnWptDefaultAction), NULL,
this);
708 m_pWptListCtrl->Connect(
710 wxMouseEventHandler(RouteManagerDialog::OnWptToggleVisibility), NULL,
712 m_pWptListCtrl->Connect(
713 wxEVT_COMMAND_LIST_COL_CLICK,
714 wxListEventHandler(RouteManagerDialog::OnWptColumnClicked), NULL,
this);
715 bSizerWptContents->Add(m_pWptListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
716 sbsWpts->Add(bSizerWptContents, 1, wxEXPAND, 5);
718 m_pWptListCtrl->InsertColumn(colWPTICON, _(
"Icon"), wxLIST_FORMAT_LEFT,
720 m_pWptListCtrl->InsertColumn(colWPTSCALE, _(
"Scale"), wxLIST_FORMAT_LEFT,
722 m_pWptListCtrl->InsertColumn(colWPTNAME, _(
"Waypoint Name"),
723 wxLIST_FORMAT_LEFT, 15 * char_width);
724 m_pWptListCtrl->InsertColumn(colWPTDIST, _(
"Distance from own ship"),
725 wxLIST_FORMAT_LEFT, 14 * char_width);
727 wxBoxSizer *bsWptButtons =
new wxBoxSizer(wxVERTICAL);
728 sbsWpts->Add(bsWptButtons, 0, wxEXPAND);
730 wxScrolledWindow *winw =
new wxScrolledWindow(
731 m_pPanelWpt, wxID_ANY, wxDefaultPosition, wxDefaultSize,
732 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
733 winw->SetScrollRate(0, 5);
735 bsWptButtons->Add(winw, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
737 wxBoxSizer *bsWptButtonsInner =
new wxBoxSizer(wxVERTICAL);
738 winw->SetSizer(bsWptButtonsInner);
740 btnWptNew =
new wxButton(winw, -1, _(
"&New"));
741 bsWptButtonsInner->Add(btnWptNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
742 btnWptNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
743 wxCommandEventHandler(RouteManagerDialog::OnWptNewClick),
746 btnWptProperties =
new wxButton(winw, -1, _(
"&Properties"));
747 bsWptButtonsInner->Add(btnWptProperties, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
748 btnWptProperties->Connect(
749 wxEVT_COMMAND_BUTTON_CLICKED,
750 wxCommandEventHandler(RouteManagerDialog::OnWptPropertiesClick), NULL,
753 btnWptZoomto =
new wxButton(winw, -1, _(
"&Center View"));
754 bsWptButtonsInner->Add(btnWptZoomto, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
755 btnWptZoomto->Connect(
756 wxEVT_COMMAND_BUTTON_CLICKED,
757 wxCommandEventHandler(RouteManagerDialog::OnWptZoomtoClick), NULL,
this);
759 btnWptDelete =
new wxButton(winw, -1, _(
"&Delete"));
760 bsWptButtonsInner->Add(btnWptDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
761 btnWptDelete->Connect(
762 wxEVT_COMMAND_BUTTON_CLICKED,
763 wxCommandEventHandler(RouteManagerDialog::OnWptDeleteClick), NULL,
this);
765 btnWptGoTo =
new wxButton(winw, -1, _(
"&Go To"));
766 bsWptButtonsInner->Add(btnWptGoTo, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
767 btnWptGoTo->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
768 wxCommandEventHandler(RouteManagerDialog::OnWptGoToClick),
771 btnWptExport =
new wxButton(winw, -1, _(
"&Export selected..."));
772 bsWptButtonsInner->Add(btnWptExport, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
773 btnWptExport->Connect(
774 wxEVT_COMMAND_BUTTON_CLICKED,
775 wxCommandEventHandler(RouteManagerDialog::OnWptExportClick), NULL,
this);
777 btnWptSendToGPS =
new wxButton(winw, -1, _(
"&Send to GPS"));
778 bsWptButtonsInner->Add(btnWptSendToGPS, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
779 btnWptSendToGPS->Connect(
780 wxEVT_COMMAND_BUTTON_CLICKED,
781 wxCommandEventHandler(RouteManagerDialog::OnWptSendToGPSClick), NULL,
784 btnWptSendToPeer =
new wxButton(winw, -1, _(
"Send to &Peer"));
785 bsWptButtonsInner->Add(btnWptSendToPeer, 0, wxALL | wxEXPAND,
787 btnWptSendToPeer->Connect(
788 wxEVT_COMMAND_BUTTON_CLICKED,
789 wxCommandEventHandler(RouteManagerDialog::OnWptSendToPeerClick), NULL,
792 bsWptButtonsInner->AddSpacer(10);
794 btnWptDeleteAll =
new wxButton(winw, -1, _(
"Delete All"));
795 bsWptButtonsInner->Add(btnWptDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
796 btnWptDeleteAll->Connect(
797 wxEVT_COMMAND_BUTTON_CLICKED,
798 wxCommandEventHandler(RouteManagerDialog::OnWptDeleteAllClick), NULL,
801 wxBoxSizer *itemBoxSizer5 =
new wxBoxSizer(wxHORIZONTAL);
802 itemBoxSizer1->Add(itemBoxSizer5, 0, wxALL | wxEXPAND);
804 wxBoxSizer *itemBoxSizer6 =
new wxBoxSizer(wxHORIZONTAL);
805 itemBoxSizer5->Add(itemBoxSizer6, 1, wxALL | wxEXPAND);
807 btnImport =
new wxButton(
this, -1, _(
"I&mport GPX..."));
808 itemBoxSizer6->Add(btnImport, 0, wxALL | wxALIGN_LEFT, DIALOG_MARGIN);
809 btnImport->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
810 wxCommandEventHandler(RouteManagerDialog::OnImportClick),
819 btnExportViz =
new wxButton(
this, -1, _(
"Export All Visible..."));
820 itemBoxSizer6->Add(btnExportViz, 0, wxALL | wxALIGN_LEFT, DIALOG_MARGIN);
821 btnExportViz->Connect(
822 wxEVT_COMMAND_BUTTON_CLICKED,
823 wxCommandEventHandler(RouteManagerDialog::OnExportVizClick), NULL,
this);
826 itemBoxSizer6->Add(0, 0, 1, wxEXPAND, 5);
827 itemBoxSizer6->Add(
new wxButton(
this, wxID_OK), 0, wxALL, DIALOG_MARGIN);
830 m_pPanelLay =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
831 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
832 wxBoxSizer *sbsLayers =
new wxBoxSizer(wxHORIZONTAL);
833 m_pPanelLay->SetSizer(sbsLayers);
834 m_pNotebook->AddPage(m_pPanelLay, _(
"Layers"));
836 wxBoxSizer *bSizerLayContents;
837 bSizerLayContents =
new wxBoxSizer(wxVERTICAL);
839 wxFlexGridSizer *fgSizerFilterLay;
840 fgSizerFilterLay =
new wxFlexGridSizer(0, 2, 0, 0);
841 fgSizerFilterLay->AddGrowableCol(1);
842 fgSizerFilterLay->SetFlexibleDirection(wxBOTH);
843 fgSizerFilterLay->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
845 m_stFilterLay =
new wxStaticText(m_pPanelLay, wxID_ANY, _(
"Filter"),
846 wxDefaultPosition, wxDefaultSize, 0);
847 m_stFilterLay->Wrap(-1);
848 fgSizerFilterLay->Add(m_stFilterLay, 0, wxALL, 5);
850 m_tFilterLay =
new wxTextCtrl(m_pPanelLay, wxID_ANY, wxEmptyString,
851 wxDefaultPosition, wxDefaultSize, 0);
852 fgSizerFilterLay->Add(m_tFilterLay, 1, wxALL | wxEXPAND, 5);
854 bSizerLayContents->Add(fgSizerFilterLay, 0, wxEXPAND, 5);
855 m_tFilterLay->Connect(
856 wxEVT_COMMAND_TEXT_UPDATED,
857 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
859 m_cbShowAllLay =
new wxCheckBox(m_pPanelLay, wxID_ANY, _(
"Show all layers"));
860 bSizerLayContents->Add(m_cbShowAllLay, 0, wxEXPAND | wxLEFT, 5);
861 m_cbShowAllLay->Connect(
862 wxEVT_COMMAND_CHECKBOX_CLICKED,
863 wxCommandEventHandler(RouteManagerDialog::OnShowAllLayCBClicked), NULL,
867 new wxListCtrl(m_pPanelLay, -1, wxDefaultPosition, wxDefaultSize,
868 wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING |
869 wxLC_HRULES | wxBORDER_SUNKEN );
870#ifdef __OCPN__ANDROID__
871 m_pLayListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
874 m_pLayListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
875 wxListEventHandler(RouteManagerDialog::OnLaySelected),
877 m_pLayListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_DESELECTED,
878 wxListEventHandler(RouteManagerDialog::OnLaySelected),
880 m_pLayListCtrl->Connect(
881 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
882 wxListEventHandler(RouteManagerDialog::OnLayDefaultAction), NULL,
this);
883 m_pLayListCtrl->Connect(
885 wxMouseEventHandler(RouteManagerDialog::OnLayToggleVisibility), NULL,
887 m_pLayListCtrl->Connect(
888 wxEVT_COMMAND_LIST_COL_CLICK,
889 wxListEventHandler(RouteManagerDialog::OnLayColumnClicked), NULL,
this);
890 bSizerLayContents->Add(m_pLayListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
891 sbsLayers->Add(bSizerLayContents, 1, wxEXPAND, 5);
893 m_pLayListCtrl->InsertColumn(colLAYVISIBLE, _T(
""), wxLIST_FORMAT_LEFT,
895 m_pLayListCtrl->InsertColumn(colLAYNAME, _(
"Layer Name"), wxLIST_FORMAT_LEFT,
897 m_pLayListCtrl->InsertColumn(colLAYITEMS, _(
"No. of items"),
898 wxLIST_FORMAT_LEFT, 10 * char_width);
899 m_pLayListCtrl->InsertColumn(colLAYPERSIST, _(
"Layer type"),
900 wxLIST_FORMAT_LEFT, 10 * char_width);
902 wxBoxSizer *bsLayButtons =
new wxBoxSizer(wxVERTICAL);
903 sbsLayers->Add(bsLayButtons, 0, wxEXPAND);
905 wxScrolledWindow *winl =
new wxScrolledWindow(
906 m_pPanelLay, wxID_ANY, wxDefaultPosition, wxDefaultSize,
907 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
908 winl->SetScrollRate(0, 5);
910 bsLayButtons->Add(winl, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
912 wxBoxSizer *bsLayButtonsInner =
new wxBoxSizer(wxVERTICAL);
913 winl->SetSizer(bsLayButtonsInner);
915 btnLayNew =
new wxButton(winl, -1, _(
"Create Temporary layer"));
916 bsLayButtonsInner->Add(btnLayNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
917 btnLayNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
918 wxCommandEventHandler(RouteManagerDialog::OnLayNewClick),
921 btnPerLayNew =
new wxButton(winl, -1, _(
"Create Persistent layer"));
922 bsLayButtonsInner->Add(btnPerLayNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
923 btnPerLayNew->Connect(
924 wxEVT_COMMAND_BUTTON_CLICKED,
925 wxCommandEventHandler(RouteManagerDialog::OnPerLayNewClick), NULL,
this);
927 btnLayDelete =
new wxButton(winl, -1, _(
"&Delete"));
928 bsLayButtonsInner->Add(btnLayDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
929 btnLayDelete->Connect(
930 wxEVT_COMMAND_BUTTON_CLICKED,
931 wxCommandEventHandler(RouteManagerDialog::OnLayDeleteClick), NULL,
this);
933 cbLayToggleChart =
new wxCheckBox(winl, -1, _(
"Show on chart"));
934 bsLayButtonsInner->Add(cbLayToggleChart, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
935 cbLayToggleChart->Connect(
936 wxEVT_COMMAND_CHECKBOX_CLICKED,
937 wxCommandEventHandler(RouteManagerDialog::OnLayToggleChartClick), NULL,
941 new wxCheckBox(winl, -1, _(
"Show WPT names"), wxDefaultPosition,
942 wxDefaultSize, wxCHK_3STATE);
944 bsLayButtonsInner->Add(cbLayToggleNames, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
945 cbLayToggleNames->Connect(
946 wxEVT_COMMAND_CHECKBOX_CLICKED,
947 wxCommandEventHandler(RouteManagerDialog::OnLayToggleNamesClick), NULL,
950 cbLayToggleListing =
new wxCheckBox(winl, -1, _(
"List contents"));
951 bsLayButtonsInner->Add(cbLayToggleListing, 0, wxALL | wxEXPAND,
953 cbLayToggleListing->Connect(
954 wxEVT_COMMAND_CHECKBOX_CLICKED,
955 wxCommandEventHandler(RouteManagerDialog::OnLayToggleListingClick), NULL,
960 int imageRefSize = m_charWidth * 2;
961 wxImageList *imglist =
new wxImageList(imageRefSize, imageRefSize,
true, 1);
964 wxString UserIconPath = g_Platform->GetSharedDataDir() + _T(
"uidata") +
965 wxFileName::GetPathSeparator();
967 LoadSVG(UserIconPath + _T(
"eye.svg"), imageRefSize, imageRefSize)
969 if (iconSVG.IsOk()) {
970 iconSVG.Resize(wxSize(imageRefSize, imageRefSize),
972 imglist->Add(wxBitmap(iconSVG));
975 iconSVG = LoadSVG(UserIconPath + _T(
"eyex.svg"), imageRefSize, imageRefSize)
977 if (iconSVG.IsOk()) {
978 iconSVG.Resize(wxSize(imageRefSize, imageRefSize), wxPoint(0, 0));
979 imglist->Add(wxBitmap(iconSVG));
983 LoadSVG(UserIconPath + _T(
"eyeGray.svg"), imageRefSize, imageRefSize)
985 if (iconSVG.IsOk()) {
986 iconSVG.Resize(wxSize(imageRefSize, imageRefSize), wxPoint(0, 0));
987 imglist->Add(wxBitmap(iconSVG));
990 m_pRouteListCtrl->AssignImageList(imglist, wxIMAGE_LIST_SMALL);
992#ifdef __OCPN__ANDROID__
993 m_pRouteListCtrl->GetHandle()->setIconSize(QSize(imageRefSize, imageRefSize));
997 m_pTrkListCtrl->SetImageList(imglist, wxIMAGE_LIST_SMALL);
998 m_pWptListCtrl->SetImageList(
999 pWayPointMan->Getpmarkicon_image_list(m_listIconSize),
1000 wxIMAGE_LIST_SMALL);
1001 m_pLayListCtrl->SetImageList(imglist, wxIMAGE_LIST_SMALL);
1011 m_bNeedConfigFlush =
false;
1014RouteManagerDialog::~RouteManagerDialog() {
1015 delete m_pRouteListCtrl;
1016 delete m_pTrkListCtrl;
1017 delete m_pWptListCtrl;
1018 delete m_pLayListCtrl;
1020 delete btnRteDelete;
1021 delete btnRteResequence;
1022 delete btnRteExport;
1023 delete btnRteZoomto;
1024 delete btnRteProperties;
1025 delete btnRteActivate;
1026 delete btnRteReverse;
1027 delete btnRteSendToGPS;
1028 delete btnRteDeleteAll;
1030 delete btnTrkProperties;
1031 delete btnTrkDelete;
1032 delete btnTrkExport;
1033 delete btnTrkRouteFromTrack;
1034 delete btnTrkDeleteAll;
1036 delete btnWptProperties;
1037 delete btnWptZoomto;
1038 delete btnWptDelete;
1040 delete btnWptExport;
1041 delete btnWptSendToGPS;
1042 delete btnWptDeleteAll;
1045 delete cbLayToggleChart;
1046 delete cbLayToggleListing;
1047 delete cbLayToggleNames;
1048 delete btnLayDelete;
1051 delete btnExportViz;
1054 btnExportViz = NULL;
1057 instanceFlag =
false;
1060void RouteManagerDialog::RecalculateSize() {
1066 int char_width, char_height;
1067 GetTextExtent(_T(
"W"), &char_width, &char_height);
1070 sz.x = 60 * char_width;
1071 sz.y = 30 * char_height;
1073 wxSize dsize = GetParent()->GetClientSize();
1074 sz.y = wxMin(sz.y, dsize.y - (0 * char_height));
1075 sz.x = wxMin(sz.x, dsize.x - (0 * char_height));
1078 wxSize fsize = GetSize();
1079 fsize.y = wxMin(fsize.y, dsize.y - (0 * char_height));
1080 fsize.x = wxMin(fsize.x, dsize.x - (0 * char_height));
1086void RouteManagerDialog::OnClose(wxCloseEvent &event) {
1094void RouteManagerDialog::OnOK(wxCommandEvent &event) {
1101void RouteManagerDialog::SetColorScheme() { DimeControl(
this); }
1103void RouteManagerDialog::OnShowAllRteCBClicked(wxCommandEvent &event) {
1104 bool viz = m_cbShowAllRte->GetValue();
1107 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1108 wxLIST_STATE_DONTCARE);
1109 if (item == -1)
break;
1111 Route *pR = (
Route *)m_pRouteListCtrl->GetItemData(item);
1113 pR->SetVisible(viz, viz);
1114 pR->SetSharedWPViz(viz);
1116 m_pRouteListCtrl->SetItemImage(item, !viz);
1118 pConfig->UpdateRoute(pR);
1121 UpdateWptListCtrlViz();
1123 gFrame->RefreshAllCanvas();
1126void RouteManagerDialog::OnShowAllWpCBClicked(wxCommandEvent &event) {
1127 bool viz = m_cbShowAllWP->GetValue();
1130 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1131 wxLIST_STATE_DONTCARE);
1132 if (item == -1)
break;
1136 if (!pRP->IsSharedInVisibleRoute()) {
1137 pRP->SetVisible(viz);
1139 pRP->SetVisible(
true);
1141 m_pWptListCtrl->SetItemImage(item,
RoutePointGui(*pRP).GetIconImageIndex());
1142 pConfig->UpdateWayPoint(pRP);
1145 gFrame->RefreshAllCanvas();
1148void RouteManagerDialog::OnShowAllTrkCBClicked(wxCommandEvent &event) {
1149 bool viz = m_cbShowAllTrk->GetValue();
1152 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1153 wxLIST_STATE_DONTCARE);
1154 if (item == -1)
break;
1156 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1158 track->SetVisible(viz);
1159 m_pTrkListCtrl->SetItemImage(item, track->IsVisible() ? 0 : 1);
1162 gFrame->RefreshAllCanvas();
1165void RouteManagerDialog::OnShowAllLayCBClicked(wxCommandEvent &event) {
1166 bool viz = m_cbShowAllLay->GetValue();
1169 item = m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1170 wxLIST_STATE_DONTCARE);
1171 if (item == -1)
break;
1173 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
1175 layer->SetVisibleOnChart(viz);
1176 m_pLayListCtrl->SetItemImage(item, layer->IsVisibleOnChart() ? 0 : 1);
1178 ToggleLayerContentsOnChart(layer);
1181 gFrame->RefreshAllCanvas();
1184void RouteManagerDialog::UpdateRouteListCtrl() {
1187 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1188 wxLIST_STATE_SELECTED);
1189 wxUIntPtr selected_id = wxUIntPtr(0);
1190 if (item != -1) selected_id = m_pRouteListCtrl->GetItemData(item);
1193 m_pRouteListCtrl->DeleteAllItems();
1196 RouteList::iterator it;
1199 bool bpartialViz =
false;
1201 for (it = (*pRouteList).begin(); it != (*pRouteList).end(); ++it, ++index) {
1202 if (!(*it)->IsListed())
continue;
1204 if (!(*it)->GetName().Upper().Contains(m_tFilterRte->GetValue().Upper())) {
1209 li.SetId(list_index);
1210 li.SetImage((*it)->IsVisible() ? 0 : 1);
1213 li.SetAlign(wxLIST_FORMAT_LEFT);
1215 if ((*it)->m_bRtIsActive) {
1216 wxFont font = *wxNORMAL_FONT;
1217 font.SetWeight(wxFONTWEIGHT_BOLD);
1221 long idx = m_pRouteListCtrl->InsertItem(li);
1223 wxString name = (*it)->m_RouteNameString;
1224 if (name.IsEmpty()) name = _(
"(Unnamed Route)");
1225 m_pRouteListCtrl->SetItem(idx, rmROUTENAME, name);
1227 wxString startend = (*it)->m_RouteStartString;
1228 if (!(*it)->m_RouteEndString.IsEmpty())
1229 startend.append(_(
" - ") + (*it)->m_RouteEndString);
1230 m_pRouteListCtrl->SetItem(idx, rmROUTEDESC, startend);
1233 lic.SetId(list_index);
1235 lic.SetAlign(wxLIST_FORMAT_LEFT);
1236 m_pRouteListCtrl->SetItem(lic);
1239 lic.SetAlign(wxLIST_FORMAT_LEFT);
1240 m_pRouteListCtrl->SetItem(lic);
1243 if (!(*it)->IsVisible()) bpartialViz =
true;
1248 m_pRouteListCtrl->SortItems(SortRoutesOnName, (wxIntPtr)NULL);
1250 m_pRouteListCtrl->SetColumnWidth(0, 4 * m_charWidth);
1255 if (selected_id != wxUIntPtr(0)) {
1256 item = m_pRouteListCtrl->FindItem(-1, selected_id);
1257 m_pRouteListCtrl->SetItemState(
1258 item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
1259 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
1262 if ((m_lastRteItem >= 0) && (m_pRouteListCtrl->GetItemCount()))
1263 m_pRouteListCtrl->EnsureVisible(m_lastRteItem);
1267 m_cbShowAllRte->SetValue(!bpartialViz);
1270void RouteManagerDialog::UpdateRteButtons() {
1272 long selected_index_index =
1273 m_pRouteListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
1274 bool enable1 = m_pRouteListCtrl->GetSelectedItemCount() == 1;
1275 bool enablemultiple = m_pRouteListCtrl->GetSelectedItemCount() >= 1;
1277 m_lastRteItem = selected_index_index;
1279 btnRteDelete->Enable(m_pRouteListCtrl->GetSelectedItemCount() > 0);
1280 btnRteZoomto->Enable(enable1);
1281 btnRteProperties->Enable(enable1);
1282 btnRteReverse->Enable(enable1);
1283 btnRteExport->Enable(enablemultiple);
1284 btnRteResequence->Enable(enable1);
1285 btnRteSendToGPS->Enable(enable1);
1286 btnRteDeleteAll->Enable(m_pRouteListCtrl->GetItemCount() > 0);
1287 btnRteSendToPeer->Enable(enablemultiple);
1290 Route *route = NULL;
1292 route = (
Route *)m_pRouteListCtrl->GetItemData(selected_index_index);
1294 if (!g_pRouteMan->IsAnyRouteActive()) {
1295 btnRteActivate->Enable(enable1);
1296 if (enable1) btnRteActivate->SetLabel(_(
"Activate"));
1300 if (route && route->m_bRtIsActive) {
1301 btnRteActivate->Enable(enable1);
1302 btnRteActivate->SetLabel(_(
"Deactivate"));
1304 btnRteActivate->Enable(
false);
1306 btnRteActivate->Enable(
false);
1310void RouteManagerDialog::MakeAllRoutesInvisible() {
1311 RouteList::iterator it;
1313 for (it = (*pRouteList).begin(); it != (*pRouteList).end(); ++it, ++index) {
1314 if ((*it)->IsVisible()) {
1315 (*it)->SetVisible(
false);
1316 m_pRouteListCtrl->SetItemImage(m_pRouteListCtrl->FindItem(-1, index),
1318 pConfig->UpdateRoute(*it);
1323void RouteManagerDialog::ZoomtoRoute(
Route *route) {
1325 LLBBox RBBox = route->GetBBox();
1326 double clat = (RBBox.GetMinLat() + RBBox.GetMaxLat()) / 2;
1327 double clon = (RBBox.GetMinLon() + RBBox.GetMaxLon()) / 2;
1333 DistanceBearingMercator(RBBox.GetMinLat(), RBBox.GetMinLon(),
1334 RBBox.GetMinLat(), RBBox.GetMaxLon(), NULL, &rw);
1336 DistanceBearingMercator(RBBox.GetMinLat(), RBBox.GetMinLon(),
1337 RBBox.GetMaxLat(), RBBox.GetMinLon(), NULL, &rh);
1339 gFrame->GetPrimaryCanvas()->GetSize(&ww, &wh);
1341 ppm = wxMin(ww / (rw * 1852), wh / (rh * 1852)) * (100 - fabs(clat)) / 90;
1343 ppm = wxMin(ppm, 1.0);
1345 gFrame->JumpToPosition(gFrame->GetPrimaryCanvas(), clat, clon, ppm);
1347 m_bNeedConfigFlush =
true;
1351void RouteManagerDialog::OnRteDeleteClick(wxCommandEvent &event) {
1354 int answer = OCPNMessageBox(
1355 this, _(
"Are you sure you want to delete the selected object(s)"),
1356 wxString(_(
"OpenCPN Alert")), wxYES_NO);
1357 if (answer != wxID_YES)
return;
1360 if (m_pRouteListCtrl->GetSelectedItemCount()) {
1361 ::wxBeginBusyCursor();
1362 gFrame->CancelAllMouseRoute();
1363 m_bNeedConfigFlush =
true;
1369 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1370 wxLIST_STATE_SELECTED);
1371 if (item == -1)
break;
1373 Route *proute_to_delete = (
Route *)m_pRouteListCtrl->GetItemData(item);
1375 if (proute_to_delete) list.Append(proute_to_delete);
1379 for (
unsigned int i = 0; i < list.GetCount(); i++) {
1380 Route *route = list.Item(i)->GetData();
1382 pConfig->DeleteConfigRoute(route);
1383 g_pRouteMan->
DeleteRoute(route, NavObjectChanges::getInstance());
1388 UpdateRouteListCtrl();
1389 UpdateTrkListCtrl();
1391 gFrame->InvalidateAllCanvasUndo();
1392 gFrame->RefreshAllCanvas();
1393 ::wxEndBusyCursor();
1397void RouteManagerDialog::OnRteDeleteAllClick(wxCommandEvent &event) {
1399 OCPNMessageBox(
this, _(
"Are you sure you want to delete <ALL> routes?"),
1400 wxString(_(
"OpenCPN Alert")), wxYES_NO);
1402 if (dialog_ret == wxID_YES) {
1403 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1405 gFrame->CancelAllMouseRoute();
1407 g_pRouteMan->DeleteAllRoutes(NavObjectChanges::getInstance());
1414 UpdateRouteListCtrl();
1418 UpdateTrkListCtrl();
1420 if (pRoutePropDialog) pRoutePropDialog->Hide();
1421 gFrame->InvalidateAllCanvasUndo();
1422 gFrame->RefreshAllCanvas();
1424 m_bNeedConfigFlush =
true;
1428void RouteManagerDialog::OnRtePropertiesClick(wxCommandEvent &event) {
1431 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1432 wxLIST_STATE_SELECTED);
1433 if (item == -1)
return;
1435 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1439 pRoutePropDialog = RoutePropDlgImpl::getInstance(GetParent());
1441 pRoutePropDialog->SetRouteAndUpdate(route);
1443 if (!pRoutePropDialog->IsShown()) pRoutePropDialog->Show();
1445 m_bNeedConfigFlush =
true;
1448void RouteManagerDialog::OnRteZoomtoClick(wxCommandEvent &event) {
1451 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1452 wxLIST_STATE_SELECTED);
1453 if (item == -1)
return;
1456 if (m_bCtrlDown) MakeAllRoutesInvisible();
1458 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1463 if (!route->IsVisible()) {
1464 route->SetVisible(
true);
1465 m_pRouteListCtrl->SetItemImage(item, route->IsVisible() ? 0 : 1);
1466 pConfig->UpdateRoute(route);
1472void RouteManagerDialog::OnRteReverseClick(wxCommandEvent &event) {
1475 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1476 wxLIST_STATE_SELECTED);
1477 if (item == -1)
return;
1479 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1482 if (route->m_bIsInLayer)
return;
1484 int ask_return = OCPNMessageBox(
this, g_pRouteMan->GetRouteReverseMessage(),
1485 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1486 if (ask_return != wxID_CANCEL) {
1487 bool rename = (ask_return == wxID_YES);
1489 pSelect->DeleteAllSelectableRouteSegments(route);
1490 route->Reverse(rename);
1491 pSelect->AddAllSelectableRouteSegments(route);
1494 wxString startend = route->m_RouteStartString;
1495 if (!route->m_RouteEndString.IsEmpty())
1496 startend.append(_(
" - ") + route->m_RouteEndString);
1497 m_pRouteListCtrl->SetItem(item, 2, startend);
1499 pConfig->UpdateRoute(route);
1500 gFrame->RefreshAllCanvas();
1503 m_bNeedConfigFlush =
true;
1506void RouteManagerDialog::OnRteExportClick(wxCommandEvent &event) {
1509 wxString suggested_name = _T(
"routes");
1513 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1514 wxLIST_STATE_SELECTED);
1515 if (item == -1)
break;
1517 Route *proute_to_export = (
Route *)m_pRouteListCtrl->GetItemData(item);
1519 if (proute_to_export) {
1520 list.Append(proute_to_export);
1521 if (proute_to_export->m_RouteNameString != wxEmptyString)
1522 suggested_name = proute_to_export->m_RouteNameString;
1526 ExportGPXRoutes(
this, &list, suggested_name);
1529void RouteManagerDialog::OnRteResequenceClick(wxCommandEvent &event) {
1531 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1532 wxLIST_STATE_SELECTED);
1533 if (item == -1)
return;
1535 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1538 if (route->m_bIsInLayer)
return;
1539 route->RenameRoutePoints();
1542void RouteManagerDialog::OnRteSendToPeerClick(wxCommandEvent &event) {
1543 std::vector<Route*> list;
1546 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1547 wxLIST_STATE_SELECTED);
1548 if (item == -1)
break;
1550 Route *proute = (
Route *)m_pRouteListCtrl->GetItemData(item);
1553 list.push_back(proute);
1556 if (!list.empty()) {
1557 g_Platform->ShowBusySpinner();
1558 FindAllOCPNServers(2);
1559 g_Platform->HideBusySpinner();
1563 for (
unsigned int i=0; i < g_DNS_cache.size(); i++){
1564 wxString item(g_DNS_cache[i]->hostname.c_str());
1567 if (!g_hostname.IsSameAs(item.BeforeFirst(
'.'))) {
1573 OCPNMessageBox(NULL,
1574 _(
"No OpenCPN servers found on this network."),
1575 _(
"OpenCPN Send Route(s)"), wxOK, 5);
1581 for (
auto r : list) {
1585 dlg.Create(NULL, -1, _(
"Send Route(s) to OpenCPN Peer") + _T(
"..." ), _T(
""));
1590void RouteManagerDialog::OnWptSendToPeerClick(wxCommandEvent &event) {
1591 std::vector<RoutePoint*> list;
1594 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1595 wxLIST_STATE_SELECTED);
1596 if (item == -1)
break;
1601 list.push_back(proutep);
1604 if (!list.empty()) {
1605 g_Platform->ShowBusySpinner();
1606 FindAllOCPNServers(2);
1607 g_Platform->HideBusySpinner();
1611 for (
unsigned int i=0; i < g_DNS_cache.size(); i++){
1612 wxString item(g_DNS_cache[i]->hostname.c_str());
1615 if (!g_hostname.IsSameAs(item.BeforeFirst(
'.'))) {
1621 OCPNMessageBox(NULL,
1622 _(
"No OpenCPN servers found on this network."),
1623 _(
"OpenCPN Send Waypoint(s)"), wxOK, 5);
1629 for (
auto r : list) {
1633 dlg.Create(NULL, -1, _(
"Send Waypoint(s) to OpenCPN Peer") + _T(
"..." ), _T(
""));
1638void RouteManagerDialog::OnTrkSendToPeerClick(wxCommandEvent &event) {
1639 std::vector<Track*> list;
1642 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1643 wxLIST_STATE_SELECTED);
1644 if (item == -1)
break;
1646 Track *ptrk = (
Track *)m_pTrkListCtrl->GetItemData(item);
1649 list.push_back(ptrk);
1652 if (!list.empty()) {
1653 g_Platform->ShowBusySpinner();
1654 FindAllOCPNServers(2);
1655 g_Platform->HideBusySpinner();
1659 for (
unsigned int i=0; i < g_DNS_cache.size(); i++){
1660 wxString item(g_DNS_cache[i]->hostname.c_str());
1663 if (!g_hostname.IsSameAs(item.BeforeFirst(
'.'))) {
1669 OCPNMessageBox(NULL,
1670 _(
"No OpenCPN servers found on this network."),
1671 _(
"OpenCPN Send Track(s)"), wxOK, 5);
1677 for (
auto r : list) {
1681 dlg.Create(NULL, -1, _(
"Send Track(s) to OpenCPN Peer") + _T(
"..." ), _T(
""));
1686void RouteManagerDialog::OnRteActivateClick(wxCommandEvent &event) {
1689 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1690 wxLIST_STATE_SELECTED);
1691 if (item == -1)
return;
1693 if (m_bCtrlDown) MakeAllRoutesInvisible();
1695 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1699 if (!route->m_bRtIsActive) {
1700 if (!route->IsVisible()) {
1701 route->SetVisible(
true);
1702 m_pRouteListCtrl->SetItemImage(item, 0, 0);
1708 g_pRouteMan->FindBestActivatePoint(route, gLat, gLon, gCog, gSog);
1709 g_pRouteMan->ActivateRoute(route, best_point);
1712 g_pRouteMan->DeactivateRoute();
1714 UpdateRouteListCtrl();
1716 pConfig->UpdateRoute(route);
1718 gFrame->RefreshAllCanvas();
1723 m_bNeedConfigFlush =
true;
1726void RouteManagerDialog::OnRteToggleVisibility(wxMouseEvent &event) {
1727 wxPoint pos =
event.GetPosition();
1729 long clicked_index = m_pRouteListCtrl->HitTest(pos, flags);
1732 if (clicked_index > -1 &&
1733 event.GetX() < m_pRouteListCtrl->GetColumnWidth(rmVISIBLE)) {
1735 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(clicked_index);
1737 route->SetVisible(!route->IsVisible());
1739 m_pRouteListCtrl->SetItemImage(clicked_index, route->IsVisible() ? 0 : 1);
1741 ::wxBeginBusyCursor();
1743 pConfig->UpdateRoute(route);
1744 gFrame->RefreshAllCanvas();
1748 if (g_pRouteMan->DoesRouteContainSharedPoints(route))
1749 UpdateWptListCtrlViz();
1755 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1756 wxLIST_STATE_DONTCARE);
1757 if (item == -1)
break;
1759 Route *pR = (
Route *)m_pRouteListCtrl->GetItemData(item);
1761 if (!pR->IsVisible()) {
1766 m_cbShowAllRte->SetValue(viz);
1768 ::wxEndBusyCursor();
1775void RouteManagerDialog::OnRteBtnLeftDown(wxMouseEvent &event) {
1776 m_bCtrlDown =
event.ControlDown();
1780void RouteManagerDialog::OnRteSelected(wxListEvent &event) {
1781 long clicked_index =
event.m_itemIndex;
1783 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(clicked_index);
1785 m_pRouteListCtrl->SetItemImage(clicked_index, route->IsVisible() ? 0 : 1);
1788 gFrame->RefreshAllCanvas();
1793void RouteManagerDialog::OnRteColumnClicked(wxListEvent &event) {
1794 if (event.m_col == 1) {
1795 sort_route_name_dir++;
1797 m_pRouteListCtrl->SortItems(SortRoutesOnName, (wxIntPtr)NULL);
1798 }
else if (event.m_col == 2) {
1799 sort_route_to_dir++;
1800 m_pRouteListCtrl->SortItems(SortRoutesOnTo, (wxIntPtr)NULL);
1804void RouteManagerDialog::OnRteSendToGPSClick(wxCommandEvent &event) {
1806 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1807 wxLIST_STATE_SELECTED);
1808 if (item == -1)
return;
1810 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1815 pdlg->SetRoute(route);
1817 wxFont fo = GetOCPNGUIScaledFont(_T(
"Dialog"));
1821 pdlg->Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), source);
1824 HideWithEffect(wxSHOW_EFFECT_BLEND);
1830 ShowWithEffect(wxSHOW_EFFECT_BLEND);
1836void RouteManagerDialog::OnRteDefaultAction(wxListEvent &event) {
1838 OnRtePropertiesClick(evt);
1841void RouteManagerDialog::OnTrkDefaultAction(wxListEvent &event) {
1843 OnTrkPropertiesClick(evt);
1846void RouteManagerDialog::OnTrkRightClick(wxListEvent &event) {
1848 wxMenuItem *mergeItem = menu.Append(TRACK_MERGE, _(
"&Merge Selected Tracks"));
1849 mergeItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() > 1);
1850 wxMenuItem *cleanItem = menu.Append(TRACK_CLEAN, _(
"Reduce Data..."));
1851 cleanItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() == 1);
1852 wxMenuItem *copyItem = menu.Append(TRACK_COPY_TEXT, _(
"&Copy as text"));
1853 copyItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() > 0);
1857static bool CompareTracks(
Track *track1,
Track *track2) {
1860 return start1->GetCreateTime() < start2->GetCreateTime();
1863void RouteManagerDialog::OnTrkMenuSelected(wxCommandEvent &event) {
1866 switch (event.GetId()) {
1868 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1869 wxLIST_STATE_SELECTED);
1870 if (item == -1)
break;
1871 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1872 if (track->IsRunning()) {
1877 const wxString choices[] = {_T(
"5.0"), _T(
"10.0"), _T(
"20.0"), _T(
"50.0"),
1880 wxSingleChoiceDialog precisionDlg(
this,
1881 _(
"Select the maximum error allowed "
1882 "(in meters)\nafter data reduction:"),
1883 _(
"Reduce Data Precision"), 5, choices);
1885 precisionDlg.ShowWindowModal();
1886 while (precisionDlg.IsShown()) {
1890 int result = precisionDlg.GetReturnCode();
1892 int result = precisionDlg.ShowModal();
1894 if (result == wxID_CANCEL)
break;
1895 double precision = 5.0;
1896 switch (precisionDlg.GetSelection()) {
1914 int pointsBefore = track->GetnPoints();
1916 int reduction = track->Simplify(precision);
1917 gFrame->Refresh(
false);
1919 reduction = 100 * reduction / pointsBefore;
1920 wxString msg = wxString::Format(
1921 _(
"The amount of data used by the track\n was reduced by %d%%."),
1923 OCPNMessageBox(
this, msg, _(
"OpenCPN info"), wxICON_INFORMATION | wxOK);
1925 UpdateTrkListCtrl();
1926 UpdateRouteListCtrl();
1931 case TRACK_COPY_TEXT: {
1934 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1935 wxLIST_STATE_SELECTED);
1936 if (item == -1)
break;
1937 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1938 csvString << track->GetName() << _T(
"\t")
1939 << wxString::Format(_T(
"%.1f"), track->Length()) << _T(
"\t")
1943 if (wxTheClipboard->Open()) {
1944 wxTextDataObject *data =
new wxTextDataObject;
1945 data->SetText(csvString);
1946 wxTheClipboard->SetData(data);
1947 wxTheClipboard->Close();
1954 Track *targetTrack = NULL;
1958 std::vector<Track *> mergeList;
1959 std::vector<Track *> deleteList;
1960 bool runningSkipped =
false;
1962 ::wxBeginBusyCursor();
1965 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1966 wxLIST_STATE_SELECTED);
1967 if (item == -1)
break;
1968 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1969 mergeList.push_back(track);
1972 std::sort(mergeList.begin(), mergeList.end(), CompareTracks);
1974 targetTrack = mergeList[0];
1975 lastPoint = targetTrack->GetLastPoint();
1977 for (
auto const &mergeTrack : mergeList) {
1978 if (mergeTrack == *mergeList.begin())
continue;
1980 if (mergeTrack->IsRunning()) {
1981 runningSkipped =
true;
1985 for (
int i = 0; i < mergeTrack->GetnPoints(); i++) {
1986 tPoint = mergeTrack->GetPoint(i);
1987 newPoint =
new TrackPoint(tPoint->m_lat, tPoint->m_lon,
1988 tPoint->GetCreateTime());
1990 targetTrack->AddPoint(newPoint);
1992 pSelect->AddSelectableTrackSegment(lastPoint->m_lat, lastPoint->m_lon,
1993 newPoint->m_lat, newPoint->m_lon,
1994 lastPoint, newPoint, targetTrack);
1996 lastPoint = newPoint;
1998 deleteList.push_back(mergeTrack);
2001 for (
auto const &deleteTrack : deleteList) {
2002 g_pAIS->DeletePersistentTrack(deleteTrack);
2003 pConfig->DeleteConfigTrack(deleteTrack);
2004 RoutemanGui(*g_pRouteMan).DeleteTrack(deleteTrack);
2010 ::wxEndBusyCursor();
2012 UpdateTrkListCtrl();
2013 UpdateRouteListCtrl();
2014 gFrame->RefreshAllCanvas();
2016 if (runningSkipped) {
2017 wxMessageDialog skipWarning(
2019 _(
"The currently running Track was not merged.\nYou can merge it "
2020 "later when it is completed."),
2021 _T(
"Warning"), wxCANCEL | wxICON_WARNING);
2022 skipWarning.ShowModal();
2030void RouteManagerDialog::UpdateTrkListCtrl() {
2034 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2036 wxUIntPtr selected_id = wxUIntPtr(0);
2037 if (item != -1) selected_id = m_pTrkListCtrl->GetItemData(item);
2040 m_pTrkListCtrl->DeleteAllItems();
2043 std::vector<Track*>::iterator it;
2046 bool bpartialViz =
false;
2048 for (
Track *trk : g_TrackList) {
2049 if (!trk->IsVisible()) bpartialViz =
true;
2051 if (!trk->IsListed())
continue;
2053 if (!trk->GetName(
true).Upper().Contains(
2054 m_tFilterTrk->GetValue().Upper())) {
2059 li.SetId(list_index);
2060 li.SetImage(trk->IsVisible() ? 0 : 1);
2064 if (g_pActiveTrack == trk) {
2065 wxFont font = *wxNORMAL_FONT;
2066 font.SetWeight(wxFONTWEIGHT_BOLD);
2069 long idx = m_pTrkListCtrl->InsertItem(li);
2071 m_pTrkListCtrl->SetItem(idx, colTRKNAME, trk->GetName(
true));
2074 len.Printf(wxT(
"%5.2f"), trk->Length());
2075 m_pTrkListCtrl->SetItem(idx, colTRKLENGTH, len);
2078 lic.SetId(list_index);
2080 lic.SetAlign(wxLIST_FORMAT_LEFT);
2081 m_pTrkListCtrl->SetItem(lic);
2084 lic.SetAlign(wxLIST_FORMAT_LEFT);
2085 m_pTrkListCtrl->SetItem(lic);
2090 switch (sort_track_key) {
2091 case SORT_ON_DISTANCE:
2092 m_pTrkListCtrl->SortItems(SortTracksOnDistance, (wxIntPtr)NULL);
2096 m_pTrkListCtrl->SortItems(SortTracksOnName, (wxIntPtr)NULL);
2100 m_pTrkListCtrl->SetColumnWidth(0, 4 * m_charWidth);
2105 if (selected_id != wxUIntPtr(0)) {
2106 item = m_pTrkListCtrl->FindItem(-1, selected_id);
2107 m_pTrkListCtrl->SetItemState(item,
2108 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
2109 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
2112 if ((m_lastTrkItem >= 0) && (m_pTrkListCtrl->GetItemCount()))
2113 m_pTrkListCtrl->EnsureVisible(m_lastTrkItem);
2115 m_cbShowAllTrk->SetValue(!bpartialViz);
2119void RouteManagerDialog::OnTrkSelected(wxListEvent &event) {
2123void RouteManagerDialog::OnTrkColumnClicked(wxListEvent &event) {
2124 if (event.m_col == 1) {
2125 sort_track_key = SORT_ON_NAME;
2126 sort_track_name_dir++;
2127 m_pTrkListCtrl->SortItems(SortTracksOnName, (wxIntPtr)NULL);
2128 }
else if (event.m_col == 2) {
2129 sort_track_key = SORT_ON_DISTANCE;
2130 sort_track_len_dir++;
2131 m_pTrkListCtrl->SortItems(SortTracksOnDistance, (wxIntPtr)NULL);
2135void RouteManagerDialog::UpdateTrkButtons() {
2138 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2139 int items = m_pTrkListCtrl->GetSelectedItemCount();
2141 m_lastTrkItem = item;
2143 btnTrkProperties->Enable(items == 1);
2144 btnTrkDelete->Enable(items >= 1);
2145 btnTrkExport->Enable(items >= 1);
2146 btnTrkRouteFromTrack->Enable(items == 1);
2147 btnTrkDeleteAll->Enable(m_pTrkListCtrl->GetItemCount() > 0);
2148 btnTrkSendToPeer->Enable(items >= 1);
2151void RouteManagerDialog::OnTrkToggleVisibility(wxMouseEvent &event) {
2152 wxPoint pos =
event.GetPosition();
2154 long clicked_index = m_pTrkListCtrl->HitTest(pos, flags);
2157 if (clicked_index > -1 &&
2158 event.GetX() < m_pTrkListCtrl->GetColumnWidth(colTRKVISIBLE)) {
2160 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(clicked_index);
2162 track->SetVisible(!track->IsVisible());
2163 m_pTrkListCtrl->SetItemImage(clicked_index, track->IsVisible() ? 0 : 1);
2170 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2171 wxLIST_STATE_DONTCARE);
2172 if (item == -1)
break;
2174 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2176 if (!track->IsVisible()) {
2181 m_cbShowAllTrk->SetValue(viz);
2183 gFrame->RefreshAllCanvas();
2190void RouteManagerDialog::OnTrkNewClick(wxCommandEvent &event) {
2192 if (pConfig && pConfig->IsChangesFileDirty()) {
2193 pConfig->UpdateNavObj(
true);
2198 UpdateTrkListCtrl();
2201void RouteManagerDialog::OnTrkPropertiesClick(wxCommandEvent &event) {
2205 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2206 if (item == -1)
return;
2208 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2212 pTrackPropDialog = TrackPropDlg::getInstance(GetParent());
2213 pTrackPropDialog->SetTrackAndUpdate(track);
2215 if (!pTrackPropDialog->IsShown()) pTrackPropDialog->Show();
2216 UpdateTrkListCtrl();
2218 m_bNeedConfigFlush =
true;
2221void RouteManagerDialog::OnTrkDeleteClick(wxCommandEvent &event) {
2222 std::vector<Track*> list;
2224 int answer = OCPNMessageBox(
2225 this, _(
"Are you sure you want to delete the selected object(s)"),
2226 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2227 if (answer != wxID_YES)
return;
2230 if (m_pTrkListCtrl->GetSelectedItemCount()) {
2231 ::wxBeginBusyCursor();
2232 m_bNeedConfigFlush =
true;
2238 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2239 wxLIST_STATE_SELECTED);
2240 if (item == -1)
break;
2242 Track *ptrack_to_delete = (
Track *)m_pTrkListCtrl->GetItemData(item);
2244 if (ptrack_to_delete) list.push_back(ptrack_to_delete);
2248 for (
unsigned int i = 0; i < list.size(); i++) {
2249 Track *track = list.at(i);
2251 g_pAIS->DeletePersistentTrack(track);
2252 pConfig->DeleteConfigTrack(track);
2259 UpdateTrkListCtrl();
2261 if (pConfig && pConfig->IsChangesFileDirty()) {
2262 pConfig->UpdateNavObj(
true);
2265 gFrame->InvalidateAllCanvasUndo();
2266 gFrame->RefreshAllCanvas();
2267 ::wxEndBusyCursor();
2271void RouteManagerDialog::OnTrkExportClick(wxCommandEvent &event) {
2272 std::vector<Track*> list;
2273 wxString suggested_name = _T(
"tracks");
2277 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2278 wxLIST_STATE_SELECTED);
2279 if (item == -1)
break;
2281 Track *ptrack_to_export = (
Track *)m_pTrkListCtrl->GetItemData(item);
2283 if (ptrack_to_export) {
2284 list.push_back(ptrack_to_export);
2285 if (ptrack_to_export->GetName() != wxEmptyString)
2286 suggested_name = ptrack_to_export->GetName();
2290 ExportGPXTracks(
this, &list, suggested_name);
2293void RouteManagerDialog::TrackToRoute(
Track *track) {
2295 if (track->m_bIsInLayer)
return;
2297 wxGenericProgressDialog pprog(_(
"OpenCPN Converting Track to Route...."),
2298 _(
"Processing Waypoints..."), 101, NULL,
2299 wxPD_AUTO_HIDE | wxPD_SMOOTH |
2300 wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
2301 wxPD_REMAINING_TIME);
2303 ::wxBeginBusyCursor();
2305 Route *route = track->RouteFromTrack(&pprog);
2307 pRouteList->Append(route);
2309 pprog.Update(101, _(
"Done."));
2311 gFrame->RefreshAllCanvas();
2313 ::wxEndBusyCursor();
2316void RouteManagerDialog::OnTrkRouteFromTrackClick(wxCommandEvent &event) {
2319 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2320 if (item == -1)
return;
2322 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2324 TrackToRoute(track);
2326 UpdateRouteListCtrl();
2329void RouteManagerDialog::OnTrkDeleteAllClick(wxCommandEvent &event) {
2331 OCPNMessageBox(
this, _(
"Are you sure you want to delete <ALL> tracks?"),
2332 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2334 if (dialog_ret == wxID_YES) {
2341 UpdateTrkListCtrl();
2345 UpdateRouteListCtrl();
2347 if (pRoutePropDialog) pRoutePropDialog->Hide();
2349 gFrame->RefreshAllCanvas();
2351 m_bNeedConfigFlush =
true;
2354void RouteManagerDialog::UpdateWptListCtrl(
RoutePoint *rp_select,
2355 bool b_retain_sort) {
2356 wxIntPtr selected_id = wxUIntPtr(0);
2359 if (NULL == rp_select) {
2361 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2362 wxLIST_STATE_SELECTED);
2364 if (item != -1) selected_id = m_pWptListCtrl->GetItemData(item);
2368 m_pWptListCtrl->SetImageList(
2369 pWayPointMan->Getpmarkicon_image_list(m_listIconSize),
2370 wxIMAGE_LIST_SMALL);
2372 m_pWptListCtrl->DeleteAllItems();
2374 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
2377 bool b_anyHidden =
false;
2380 if (rp && rp->IsListed()) {
2381 if (rp->m_bIsInRoute && !rp->IsShared()) {
2382 node = node->GetNext();
2386 if (!rp->GetName().Upper().Contains(m_tFilterWpt->GetValue().Upper())) {
2387 node = node->GetNext();
2396 long idx = m_pWptListCtrl->InsertItem(li);
2398 wxString scamin = wxString::Format(_T(
"%i"), (
int)rp->GetScaMin());
2399 if (!rp->GetUseSca()) scamin = _(
"Always");
2400 if (g_bOverruleScaMin) scamin = _(
"Overruled");
2401 m_pWptListCtrl->SetItem(idx, colWPTSCALE, scamin);
2403 wxString name = rp->GetName();
2404 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
2405 m_pWptListCtrl->SetItem(idx, colWPTNAME, name);
2408 DistanceBearingMercator(rp->m_lat, rp->m_lon, gLat, gLon, NULL, &dst);
2410 dist.Printf(_T(
"%5.2f ") + getUsrDistanceUnit(), toUsrDistance(dst));
2411 m_pWptListCtrl->SetItem(idx, colWPTDIST, dist);
2413 if (rp == rp_select) selected_id = (wxIntPtr)rp_select;
2418 lic.SetAlign(wxLIST_FORMAT_LEFT);
2419 m_pWptListCtrl->SetItem(lic);
2422 lic.SetAlign(wxLIST_FORMAT_LEFT);
2423 m_pWptListCtrl->SetItem(lic);
2425 if (!rp->IsVisible()) b_anyHidden =
true;
2430 node = node->GetNext();
2433 if (!b_retain_sort) {
2434 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2435 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2436 sort_wp_key = SORT_ON_NAME;
2438 switch (sort_wp_key) {
2440 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2441 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2443 case SORT_ON_DISTANCE:
2444 m_pWptListCtrl->SortItems(SortWaypointsOnDistance,
2445 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2450 if (selected_id != wxUIntPtr(0)) {
2451 item = m_pWptListCtrl->FindItem(-1, selected_id);
2452 m_pWptListCtrl->SetItemState(item,
2453 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
2454 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
2457 if ((m_lastWptItem >= 0) && (m_pWptListCtrl->GetItemCount()))
2458 m_pWptListCtrl->EnsureVisible(m_lastWptItem);
2460 if (pWayPointMan->Getpmarkicon_image_list(m_listIconSize)->GetImageCount()) {
2461 int iwidth, iheight;
2462 pWayPointMan->Getpmarkicon_image_list(m_listIconSize)
2463 ->GetSize(0, iwidth, iheight);
2465 m_pWptListCtrl->SetColumnWidth(0, wxMax(iwidth + 4, 4 * m_charWidth));
2470 m_cbShowAllWP->SetValue(!b_anyHidden);
2473void RouteManagerDialog::UpdateWptListCtrlViz() {
2476 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2477 wxLIST_STATE_DONTCARE);
2478 if (item == -1)
break;
2483 m_pWptListCtrl->SetItemImage(item, imageIndex);
2487void RouteManagerDialog::OnWptDefaultAction(wxListEvent &event) {
2489 OnWptPropertiesClick(evt);
2492void RouteManagerDialog::OnWptSelected(wxListEvent &event) {
2496void RouteManagerDialog::OnWptColumnClicked(wxListEvent &event) {
2497 if (event.m_col == NAME_COLUMN) {
2499 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2500 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2501 sort_wp_key = SORT_ON_NAME;
2503 if (event.m_col == DISTANCE_COLUMN) {
2505 m_pWptListCtrl->SortItems(SortWaypointsOnDistance,
2506 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2507 sort_wp_key = SORT_ON_DISTANCE;
2510 UpdateWptListCtrl();
2513void RouteManagerDialog::UpdateWptButtons() {
2516 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2517 bool enable1 = (m_pWptListCtrl->GetSelectedItemCount() == 1);
2518 bool enablemultiple = (m_pWptListCtrl->GetSelectedItemCount() >= 1);
2521 m_lastWptItem = item;
2527 bool b_delete_enable =
true;
2530 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2531 wxLIST_STATE_SELECTED);
2532 if (item == -1)
break;
2536 if (wp && wp->m_bIsInLayer) {
2537 b_delete_enable =
false;
2542 btnWptProperties->Enable(enable1);
2543 btnWptZoomto->Enable(enable1);
2544 btnWptDeleteAll->Enable(m_pWptListCtrl->GetItemCount() > 0);
2545 btnWptDelete->Enable(b_delete_enable && enablemultiple);
2546 btnWptGoTo->Enable(enable1);
2547 btnWptExport->Enable(enablemultiple);
2548 btnWptSendToGPS->Enable(enable1);
2549 btnWptSendToPeer->Enable(enablemultiple);
2552void RouteManagerDialog::OnWptToggleVisibility(wxMouseEvent &event) {
2553 wxPoint pos =
event.GetPosition();
2555 long clicked_index = m_pWptListCtrl->HitTest(pos, flags);
2558 if (clicked_index > -1 &&
2559 event.GetX() < m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE)) {
2563 if (!wp->IsSharedInVisibleRoute()) {
2564 wp->SetVisible(!wp->IsVisible());
2565 m_pWptListCtrl->SetItemImage(clicked_index,
RoutePointGui(*wp).GetIconImageIndex());
2567 pConfig->UpdateWayPoint(wp);
2574 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2575 wxLIST_STATE_DONTCARE);
2576 if (item == -1)
break;
2580 if (!wp->IsVisible()) {
2585 m_cbShowAllWP->SetValue(viz);
2587 gFrame->RefreshAllCanvas();
2589 if (clicked_index > -1 &&
2590 event.GetX() > m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE) &&
2591 event.GetX() < (m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE) +
2592 m_pWptListCtrl->GetColumnWidth(colWPTSCALE)) &&
2593 !g_bOverruleScaMin) {
2595 wp->SetUseSca(!wp->GetUseSca());
2596 pConfig->UpdateWayPoint(wp);
2597 gFrame->RefreshAllCanvas();
2598 wxString scamin = wxString::Format(_T(
"%i"), (
int)wp->GetScaMin());
2599 if (!wp->GetUseSca()) scamin = _(
"Always");
2600 m_pWptListCtrl->SetItem(clicked_index, colWPTSCALE, scamin);
2607void RouteManagerDialog::OnWptNewClick(wxCommandEvent &event) {
2610 pWP->m_bIsolatedMark =
true;
2611 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP);
2612 pConfig->AddNewWayPoint(pWP, -1);
2613 gFrame->RefreshAllCanvas();
2616 if (!g_pMarkInfoDialog)
2620 g_pMarkInfoDialog->SetRoutePoint(pWP);
2621 g_pMarkInfoDialog->UpdateProperties();
2623 WptShowPropertiesDialog(pWP, GetParent());
2626void RouteManagerDialog::OnWptPropertiesClick(wxCommandEvent &event) {
2629 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2630 if (item == -1)
return;
2636 WptShowPropertiesDialog(wp, GetParent());
2638 UpdateWptListCtrl();
2639 m_bNeedConfigFlush =
true;
2642void RouteManagerDialog::WptShowPropertiesDialog(
RoutePoint *wp,
2644 if (!g_pMarkInfoDialog)
2648 g_pMarkInfoDialog->SetRoutePoint(wp);
2649 g_pMarkInfoDialog->UpdateProperties();
2650 if (wp->m_bIsInLayer) {
2651 wxString caption(wxString::Format(_T(
"%s, %s: %s"),
2652 _(
"Waypoint Properties"), _(
"Layer"),
2653 GetLayerName(wp->m_LayerID)));
2654 g_pMarkInfoDialog->SetDialogTitle(caption);
2656 g_pMarkInfoDialog->SetDialogTitle(_(
"Waypoint Properties"));
2658 if (!g_pMarkInfoDialog->IsShown()) g_pMarkInfoDialog->Show();
2659 g_pMarkInfoDialog->Raise();
2662void RouteManagerDialog::OnWptZoomtoClick(wxCommandEvent &event) {
2665 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2666 if (item == -1)
return;
2672 gFrame->JumpToPosition(gFrame->GetPrimaryCanvas(), wp->m_lat, wp->m_lon,
2673 gFrame->GetPrimaryCanvas()->GetVPScale());
2676void RouteManagerDialog::OnWptDeleteClick(wxCommandEvent &event) {
2677 RoutePointList list;
2679 int answer = OCPNMessageBox(
2680 this, _(
"Are you sure you want to delete the selected object(s)"),
2681 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2682 if (answer != wxID_YES)
return;
2685 if (m_pWptListCtrl->GetSelectedItemCount()) {
2686 ::wxBeginBusyCursor();
2687 m_bNeedConfigFlush =
true;
2692 long item_last_selected = -1;
2694 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2695 wxLIST_STATE_SELECTED);
2696 if (item == -1)
break;
2698 item_last_selected = item;
2701 if (wp && !wp->m_bIsInLayer) list.Append(wp);
2705 for (
unsigned int i = 0; i < list.GetCount(); i++) {
2708 if (wp->m_bIsInRoute) {
2710 OCPNMessageBox(
this,
2711 _(
"The waypoint you want to delete is used in a "
2712 "route, do you really want to delete it?"),
2713 _(
"OpenCPN Alert"), wxYES_NO))
2714 pWayPointMan->DestroyWaypoint(wp);
2716 pWayPointMan->DestroyWaypoint(wp);
2721 m_pWptListCtrl->GetNextItem(item_last_selected);
2724 wp_next = (
RoutePoint *)m_pWptListCtrl->GetItemData(item_next);
2726 m_lastWptItem = item_next;
2728 UpdateRouteListCtrl();
2729 UpdateTrkListCtrl();
2730 UpdateWptListCtrl(wp_next,
true);
2732 if (g_pMarkInfoDialog) {
2733 g_pMarkInfoDialog->SetRoutePoint(NULL);
2734 g_pMarkInfoDialog->UpdateProperties();
2737 gFrame->InvalidateAllCanvasUndo();
2738 gFrame->RefreshAllCanvas();
2739 ::wxEndBusyCursor();
2743void RouteManagerDialog::OnWptGoToClick(wxCommandEvent &event) {
2746 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2747 if (item == -1)
return;
2754 wxEmptyString, wxEmptyString);
2755 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
2758 pRouteList->Append(temp_route);
2760 temp_route->AddPoint(pWP_src);
2761 temp_route->AddPoint(wp);
2763 pSelect->AddSelectableRouteSegment(gLat, gLon, wp->m_lat, wp->m_lon, pWP_src,
2766 wxString name = wp->GetName();
2767 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
2768 wxString rteName = _(
"Go to ");
2769 rteName.Append(name);
2770 temp_route->m_RouteNameString = rteName;
2771 temp_route->m_RouteStartString = _(
"Here");
2773 temp_route->m_RouteEndString = name;
2774 temp_route->m_bDeleteOnArrival =
true;
2776 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
2778 g_pRouteMan->ActivateRoute(temp_route, wp);
2780 UpdateRouteListCtrl();
2783void RouteManagerDialog::OnWptExportClick(wxCommandEvent &event) {
2784 RoutePointList list;
2786 wxString suggested_name = _T(
"waypoints");
2790 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2791 wxLIST_STATE_SELECTED);
2792 if (item == -1)
break;
2796 if (wp && !wp->m_bIsInLayer) {
2798 if (wp->GetName() != wxEmptyString) suggested_name = wp->GetName();
2802 ExportGPXWaypoints(
this, &list, suggested_name);
2805void RouteManagerDialog::OnWptSendToGPSClick(wxCommandEvent &event) {
2808 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2809 if (item == -1)
return;
2816 pdlg->SetWaypoint(wp);
2819 pdlg->Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), source);
2822 HideWithEffect(wxSHOW_EFFECT_BLEND);
2826 ShowWithEffect(wxSHOW_EFFECT_BLEND);
2832void RouteManagerDialog::OnWptDeleteAllClick(wxCommandEvent &event) {
2835 if (!pWayPointMan->SharedWptsExist()) {
2836 prompt = _(
"Are you sure you want to delete <ALL> waypoints?");
2841 _(
"There are some waypoints used in routes or anchor alarms.\n Do you "
2842 "want to delete them as well?\n This will change the routes and "
2843 "disable the anchor alarms.\n Answering No keeps the waypoints used "
2844 "in routes or alarms.");
2845 buttons = wxYES_NO | wxCANCEL;
2849 OCPNMessageBox(
this, prompt, wxString(_(
"OpenCPN Alert")), buttons);
2850 if (answer == wxID_YES) pWayPointMan->DeleteAllWaypoints(
true);
2851 if (answer == wxID_NO && type == 2)
2852 pWayPointMan->DeleteAllWaypoints(
false);
2854 if (g_pMarkInfoDialog) {
2855 g_pMarkInfoDialog->SetRoutePoint(NULL);
2856 g_pMarkInfoDialog->UpdateProperties();
2860 UpdateRouteListCtrl();
2861 UpdateWptListCtrl();
2862 gFrame->InvalidateAllCanvasUndo();
2863 gFrame->RefreshAllCanvas();
2866void RouteManagerDialog::OnLaySelected(wxListEvent &event) {
2870void RouteManagerDialog::OnLayColumnClicked(wxListEvent &event) {
2871 if (event.m_col == 1) {
2872 sort_layer_name_dir++;
2873 m_pLayListCtrl->SortItems(SortLayersOnName, (wxIntPtr)NULL);
2874 }
else if (event.m_col == 2) {
2875 sort_layer_len_dir++;
2876 m_pLayListCtrl->SortItems(SortLayersOnSize, (wxIntPtr)NULL);
2880void RouteManagerDialog::UpdateLayButtons() {
2883 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2884 bool enable = (item != -1);
2887 btnLayDelete->Enable(enable);
2888 cbLayToggleChart->Enable(enable);
2889 cbLayToggleListing->Enable(enable);
2890 cbLayToggleNames->Enable(enable);
2893 cbLayToggleChart->SetValue(
2894 ((
Layer *)m_pLayListCtrl->GetItemData(item))->IsVisibleOnChart());
2896 cbLayToggleNames->Set3StateValue(
2897 ((
Layer *)m_pLayListCtrl->GetItemData(item))->HasVisibleNames());
2899 cbLayToggleListing->SetValue(
2900 ((
Layer *)m_pLayListCtrl->GetItemData(item))->IsVisibleOnListing());
2903 cbLayToggleChart->SetValue(
true);
2904 cbLayToggleNames->Set3StateValue(wxCHK_UNDETERMINED);
2905 cbLayToggleListing->SetValue(
true);
2909void RouteManagerDialog::OnLayToggleVisibility(wxMouseEvent &event) {
2910 wxPoint pos =
event.GetPosition();
2912 long clicked_index = m_pLayListCtrl->HitTest(pos, flags);
2915 if (clicked_index > -1 &&
2916 event.GetX() < m_pLayListCtrl->GetColumnWidth(colLAYVISIBLE)) {
2918 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(clicked_index);
2920 layer->SetVisibleOnChart(!layer->IsVisibleOnChart());
2921 m_pLayListCtrl->SetItemImage(clicked_index,
2922 layer->IsVisibleOnChart() ? 0 : 1);
2928 item = m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2929 wxLIST_STATE_DONTCARE);
2930 if (item == -1)
break;
2932 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
2934 if (!layer->IsVisibleOnChart()) {
2939 m_cbShowAllLay->SetValue(viz);
2941 ToggleLayerContentsOnChart(layer);
2948void RouteManagerDialog::UpdateLists() {
2949 UpdateRouteListCtrl();
2950 UpdateTrkListCtrl();
2951 UpdateWptListCtrl();
2952 UpdateLayListCtrl();
2955void RouteManagerDialog::OnLayNewClick(wxCommandEvent &event) {
2959void RouteManagerDialog::OnPerLayNewClick(wxCommandEvent &event) {
2963void RouteManagerDialog::AddNewLayer(
bool isPersistent) {
2964 bool show_flag = g_bShowLayers;
2965 g_bShowLayers =
true;
2967 UI_ImportGPX(
this,
true, _T(
""),
true, isPersistent);
2969 g_bShowLayers = show_flag;
2971 gFrame->RefreshAllCanvas();
2974void RouteManagerDialog::OnLayPropertiesClick(wxCommandEvent &event) {
2978 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2979 if (item == -1)
return;
2982void RouteManagerDialog::OnLayDeleteClick(wxCommandEvent &event) {
2985 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2986 if (item == -1)
return;
2988 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
2994 bool ispers =
false;
2995 wxString destf, f, name, ext;
2996 f = layer->m_LayerFileName;
2997 wxFileName::SplitPath(f, NULL, NULL, &name, &ext);
2998 destf = g_Platform->GetPrivateDataDir();
2999 appendOSDirSlash(&destf);
3000 destf.Append(_T(
"layers"));
3001 appendOSDirSlash(&destf);
3002 destf << name << _T(
".") << ext;
3004 wxString prompt = _(
3005 "Are you sure you want to delete this layer and <ALL> of its contents?");
3006 if (wxFileExists(destf)) {
3007 prompt.Append(_T(
"\n"));
3009 _(
"The file will also be deleted from OpenCPN's layer directory."));
3010 prompt.Append(_T(
"\n (") + destf + _T(
")" ));
3014 OCPNMessageBox(
this, prompt, wxString(_(
"OpenCPN Alert")), wxYES_NO);
3015 if (answer == wxID_NO)
return;
3020 if (wxRemoveFile(destf))
3021 remMSG.sprintf(_T(
"Layer file: %s is deleted"), destf);
3023 remMSG.sprintf(_T(
"Error deleting Layer file: %s"), destf);
3025 wxLogMessage(remMSG);
3029 wxRouteListNode *node1 = pRouteList->GetFirst();
3031 Route *pRoute = node1->GetData();
3032 wxRouteListNode *next_node = node1->GetNext();
3033 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3034 pRoute->m_bIsInLayer =
false;
3035 pRoute->m_LayerID = 0;
3036 g_pRouteMan->
DeleteRoute(pRoute, NavObjectChanges::getInstance());
3041 for (
Track *pTrack : g_TrackList) {
3042 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID)) {
3043 pTrack->m_bIsInLayer =
false;
3044 pTrack->m_LayerID = 0;
3050 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3051 wxRoutePointListNode *node3;
3054 node3 = node->GetNext();
3056 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3057 rp->m_bIsInLayer =
false;
3059 pWayPointMan->DestroyWaypoint(
3067 if (g_pMarkInfoDialog) {
3068 g_pMarkInfoDialog->SetRoutePoint(NULL);
3069 g_pMarkInfoDialog->UpdateProperties();
3072 pLayerList->DeleteObject(layer);
3076 gFrame->RefreshAllCanvas();
3078 m_bNeedConfigFlush =
false;
3081void RouteManagerDialog::OnLayToggleChartClick(wxCommandEvent &event) {
3085 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3086 if (item == -1)
return;
3088 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3092 layer->SetVisibleOnChart(!layer->IsVisibleOnChart());
3093 m_pLayListCtrl->SetItemImage(item, layer->IsVisibleOnChart() ? 0 : 1);
3095 ToggleLayerContentsOnChart(layer);
3098void RouteManagerDialog::ToggleLayerContentsOnChart(
Layer *layer) {
3100 wxRouteListNode *node1 = pRouteList->GetFirst();
3102 Route *pRoute = node1->GetData();
3103 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3104 pRoute->SetVisible(layer->IsVisibleOnChart());
3105 pConfig->UpdateRoute(pRoute);
3107 node1 = node1->GetNext();
3110 for (
Track* pTrack : g_TrackList) {
3111 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID))
3112 pTrack->SetVisible(layer->IsVisibleOnChart());
3116 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3120 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3121 rp->SetVisible(layer->IsVisibleOnChart());
3124 node = node->GetNext();
3130 gFrame->RefreshAllCanvas();
3133void RouteManagerDialog::OnLayToggleNamesClick(wxCommandEvent &event) {
3137 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3138 if (item == -1)
return;
3140 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3144 layer->SetVisibleNames(cbLayToggleNames->Get3StateValue());
3146 ToggleLayerContentsNames(layer);
3149void RouteManagerDialog::ToggleLayerContentsNames(
Layer *layer) {
3151 wxRouteListNode *node1 = pRouteList->GetFirst();
3153 Route *pRoute = node1->GetData();
3154 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3155 wxRoutePointListNode *node = pRoute->pRoutePointList->GetFirst();
3158 if (layer->HasVisibleNames() == wxCHK_UNDETERMINED) {
3159 prp1->m_bShowName = prp1->m_bShowNameData;
3161 prp1->m_bShowName = (layer->HasVisibleNames() == wxCHK_CHECKED);
3163 node = node->GetNext();
3166 node1 = node1->GetNext();
3170 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3174 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3175 rp->SetNameShown(layer->HasVisibleNames() == wxCHK_CHECKED ||
3176 (rp->m_bShowNameData &&
3177 layer->HasVisibleNames() == wxCHK_UNDETERMINED));
3180 node = node->GetNext();
3185 gFrame->RefreshAllCanvas();
3188void RouteManagerDialog::OnLayToggleListingClick(wxCommandEvent &event) {
3192 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3193 if (item == -1)
return;
3195 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3199 layer->SetVisibleOnListing(!layer->IsVisibleOnListing());
3201 ToggleLayerContentsOnListing(layer);
3204void RouteManagerDialog::ToggleLayerContentsOnListing(
Layer *layer) {
3205 ::wxBeginBusyCursor();
3208 wxRouteListNode *node1 = pRouteList->GetFirst();
3210 Route *pRoute = node1->GetData();
3211 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3212 pRoute->SetListed(layer->IsVisibleOnListing());
3214 node1 = node1->GetNext();
3217 for (
Track *pTrack : g_TrackList) {
3218 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID))
3219 pTrack->SetListed(layer->IsVisibleOnListing());
3226 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3230 if (rp && rp->m_bIsolatedMark && (rp->m_LayerID == layer->m_LayerID)) {
3231 rp->SetListed(layer->IsVisibleOnListing());
3234 node = node->GetNext();
3239 ::wxEndBusyCursor();
3241 gFrame->RefreshAllCanvas();
3244void RouteManagerDialog::OnLayDefaultAction(wxListEvent &event) {
3246 OnLayPropertiesClick(evt);
3249void RouteManagerDialog::UpdateLayListCtrl() {
3253 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3255 wxUIntPtr selected_id = wxUIntPtr(0);
3256 if (item != -1) selected_id = m_pLayListCtrl->GetItemData(item);
3259 m_pLayListCtrl->DeleteAllItems();
3262 LayerList::iterator it;
3264 bool b_anyHidden =
false;
3265 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
3268 if (!lay->m_LayerName.Upper().Contains(m_tFilterLay->GetValue().Upper())) {
3274 li.SetImage(lay->IsVisibleOnChart() ? 0 : 1);
3278 long idx = m_pLayListCtrl->InsertItem(li);
3280 wxString name = lay->m_LayerName;
3281 if (name.IsEmpty()) {
3288 name = _(
"(Unnamed Layer)");
3290 m_pLayListCtrl->SetItem(idx, colLAYNAME, name);
3293 len.Printf(wxT(
"%d"), (
int)lay->m_NoOfItems);
3294 m_pLayListCtrl->SetItem(idx, colLAYITEMS, len);
3295 m_pLayListCtrl->SetItem(idx, colLAYPERSIST, lay->m_LayerType);
3300 lic.SetAlign(wxLIST_FORMAT_LEFT);
3301 m_pLayListCtrl->SetItem(lic);
3304 lic.SetAlign(wxLIST_FORMAT_LEFT);
3305 m_pLayListCtrl->SetItem(lic);
3307 if (!lay->IsVisibleOnChart()) b_anyHidden =
true;
3310 m_pLayListCtrl->SortItems(SortLayersOnName,
3311 reinterpret_cast<wxIntPtr
>(m_pLayListCtrl));
3312 m_pLayListCtrl->SetColumnWidth(0, 4 * m_charWidth);
3317 if (selected_id != wxUIntPtr(0)) {
3318 item = m_pLayListCtrl->FindItem(-1, selected_id);
3319 m_pLayListCtrl->SetItemState(item,
3320 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
3321 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
3325 m_cbShowAllLay->SetValue(!b_anyHidden);
3328void RouteManagerDialog::OnImportClick(wxCommandEvent &event) {
3337 gFrame->RefreshAllCanvas();
3339void RouteManagerDialog::OnExportClick(wxCommandEvent &event) {
3343void RouteManagerDialog::OnExportVizClick(wxCommandEvent &event) {
3344 ExportGPX(
this,
true,
true);
3347void RouteManagerDialog::OnFilterChanged(wxCommandEvent &event) {
3348 if (event.GetEventObject() == m_tFilterWpt) {
3349 UpdateWptListCtrl(NULL,
true);
3350 }
else if (event.GetEventObject() == m_tFilterRte) {
3351 UpdateRouteListCtrl();
3352 }
else if (event.GetEventObject() == m_tFilterTrk) {
3353 UpdateTrkListCtrl();
3354 }
else if (event.GetEventObject() == m_tFilterLay) {
3355 UpdateLayListCtrl();
bool DeleteRoute(Route *pRoute, NavObjectChanges *nav_obj_changes)
Route "Send to GPS..." Dialog Definition.
Route "Send to Peer..." Dialog Definition.