24#include "routemanagerdialog.h"
34#include <wx/filename.h>
35#include <wx/stdpaths.h>
36#include <wx/progdlg.h>
37#include <wx/clipbrd.h>
38#include <wx/statline.h>
44#include "model/ais_decoder.h"
45#include "model/config_vars.h"
46#include "model/georef.h"
49#include "model/navutil_base.h"
50#include "model/own_ship.h"
51#include "model/route.h"
52#include "model/routeman.h"
53#include "model/select.h"
54#include "model/track.h"
62#include "ocpn_frame.h"
63#include "OCPNPlatform.h"
64#include "routeman_gui.h"
65#include "route_point_gui.h"
66#include "RoutePropDlgImpl.h"
67#include "SendToGpsDlg.h"
68#include "SendToPeerDlg.h"
71#include "TrackPropDlg.h"
74#include "androidUTIL.h"
77#define DIALOG_MARGIN 10
79enum { rmVISIBLE = 0, rmROUTENAME, rmROUTEDESC };
80enum { colTRKVISIBLE = 0, colTRKNAME, colTRKLENGTH, colTRKDATE };
81enum { colLAYVISIBLE = 0, colLAYNAME, colLAYITEMS, colLAYPERSIST };
82enum { colWPTICON = 0, colWPTSCALE, colWPTNAME, colWPTDIST };
85extern RouteList *pRouteList;
86extern std::vector<Track *> g_TrackList;
87extern LayerList *pLayerList;
88extern wxString GetLayerName(
int id);
96extern bool g_bShowLayers;
97extern wxString g_default_wp_icon;
101void appendOSDirSlash(wxString *pString);
103static int SortRouteTrack(
const int order,
const wxString &it1,
104 const wxString &it2) {
105 if (order & 1)
return it2.CmpNoCase(it1);
107 return it1.CmpNoCase(it2);
111static int sort_route_name_dir;
112#if wxCHECK_VERSION(2, 9, 0)
113static int wxCALLBACK SortRoutesOnName(wxIntPtr item1, wxIntPtr item2,
116int wxCALLBACK SortRoutesOnName(
long item1,
long item2,
long list)
119 return SortRouteTrack(sort_route_name_dir, ((
Route *)item1)->GetName(),
120 ((
Route *)item2)->GetName());
124static int sort_route_to_dir;
125#if wxCHECK_VERSION(2, 9, 0)
126static int wxCALLBACK SortRoutesOnTo(wxIntPtr item1, wxIntPtr item2,
129int wxCALLBACK SortRoutesOnTo(
long item1,
long item2,
long list)
132 return SortRouteTrack(sort_route_to_dir, ((
Route *)item1)->GetTo(),
133 ((
Route *)item2)->GetTo());
137static int sort_track_name_dir;
138#if wxCHECK_VERSION(2, 9, 0)
139static int wxCALLBACK SortTracksOnName(wxIntPtr item1, wxIntPtr item2,
142int wxCALLBACK SortTracksOnName(
long item1,
long item2,
long list)
145 return SortRouteTrack(sort_track_name_dir, ((
Track *)item1)->GetName(),
146 ((
Track *)item2)->GetName());
149static int SortDouble(
const int order,
const double &it1,
const double &it2) {
161 if (l1 == l2)
return 0;
162 if (l2 < l1)
return 1;
167static int sort_track_len_dir;
168#if wxCHECK_VERSION(2, 9, 0)
169static int wxCALLBACK SortTracksOnDistance(wxIntPtr item1, wxIntPtr item2,
172int wxCALLBACK SortTracksOnDistance(
long item1,
long item2,
long list)
175 return SortDouble(sort_track_len_dir, ((
Track *)item1)->Length(),
176 ((
Track *)item2)->Length());
180static int sort_track_date_dir;
181#if wxCHECK_VERSION(2, 9, 0)
182static int wxCALLBACK SortTracksOnDate(wxIntPtr item1, wxIntPtr item2,
185int wxCALLBACK SortTracksOnDate(
long item1,
long item2,
long list)
189 return SortRouteTrack(sort_track_date_dir, ((
Track *)item1)->GetIsoDateTime(),
190 ((
Track *)item2)->GetIsoDateTime());
193static int sort_wp_key;
194static int sort_track_key;
197static int sort_wp_name_dir;
198#if wxCHECK_VERSION(2, 9, 0)
199static int wxCALLBACK SortWaypointsOnName(wxIntPtr item1, wxIntPtr item2,
202int wxCALLBACK SortWaypointsOnName(
long item1,
long item2,
long list)
210 if (sort_wp_name_dir & 1)
211 return pRP2->GetName().CmpNoCase(pRP1->GetName());
213 return pRP1->GetName().CmpNoCase(pRP2->GetName());
219static int sort_wp_len_dir;
220#if wxCHECK_VERSION(2, 9, 0)
221static int wxCALLBACK SortWaypointsOnDistance(wxIntPtr item1, wxIntPtr item2,
224int wxCALLBACK SortWaypointsOnDistance(
long item1,
long item2,
long list)
228 DistanceBearingMercator(((
RoutePoint *)item1)->m_lat,
229 ((
RoutePoint *)item1)->m_lon, gLat, gLon, NULL,
231 DistanceBearingMercator(((
RoutePoint *)item2)->m_lat,
232 ((
RoutePoint *)item2)->m_lon, gLat, gLon, NULL,
234 return SortDouble(sort_wp_len_dir, dst1, dst2);
238static int sort_layer_name_dir;
239#if wxCHECK_VERSION(2, 9, 0)
240static int wxCALLBACK SortLayersOnName(wxIntPtr item1, wxIntPtr item2,
243int wxCALLBACK SortLayersOnName(
long item1,
long item2,
long list)
246 return SortRouteTrack(sort_layer_name_dir, ((
Layer *)item1)->m_LayerName,
247 ((
Layer *)item2)->m_LayerName);
251static int sort_layer_len_dir;
252#if wxCHECK_VERSION(2, 9, 0)
253static int wxCALLBACK SortLayersOnSize(wxIntPtr item1, wxIntPtr item2,
256int wxCALLBACK SortLayersOnSize(
long item1,
long item2,
long list)
259 return SortDouble(sort_layer_len_dir, ((
Layer *)item1)->m_NoOfItems,
260 ((
Layer *)item2)->m_NoOfItems);
267EVT_NOTEBOOK_PAGE_CHANGED(
269 RouteManagerDialog::OnTabSwitch)
270EVT_CLOSE(RouteManagerDialog::OnClose)
271EVT_COMMAND(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, RouteManagerDialog::OnOK)
272EVT_CHAR_HOOK(RouteManagerDialog::OnKey)
276 if (ke.GetKeyCode() == WXK_ESCAPE)
282void RouteManagerDialog::OnTabSwitch(wxNotebookEvent &event) {
283 if (!m_pNotebook)
return;
284 int current_page = m_pNotebook->GetSelection();
285 if (current_page == 3) {
286 if (btnImport) btnImport->Enable(
false);
287 if (btnExport) btnExport->Enable(
false);
288 if (btnExportViz) btnExportViz->Enable(
false);
290 if (btnImport) btnImport->Enable(
true);
291 if (btnExport) btnExport->Enable(
true);
292 if (btnExportViz) btnExportViz->Enable(
true);
299bool RouteManagerDialog::instanceFlag =
false;
312RouteManagerDialog::RouteManagerDialog(wxWindow *parent) {
314 wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT;
316 wxFrame::Create(parent, -1, wxString(_(
"Route & Mark Manager")),
317 wxDefaultPosition, wxDefaultSize, style);
325 sort_wp_key = SORT_ON_NAME;
326 sort_track_key = SORT_ON_NAME;
334 [&](wxCommandEvent) { UpdateRouteListCtrl(); });
337void RouteManagerDialog::Create() {
339 int char_width, char_height;
340 GetTextExtent(_T(
"W"), &char_width, &char_height);
341 m_charWidth = char_width;
343 wxBoxSizer *itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
344 SetSizer(itemBoxSizer1);
346 m_pNotebook =
new wxNotebook(
this, wxID_ANY, wxDefaultPosition,
347 wxSize(-1, -1), wxNB_TOP);
348 itemBoxSizer1->Add(m_pNotebook, 1, wxALL | wxEXPAND, 5);
351 m_pPanelRte =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
352 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
354 wxBoxSizer *sbsRoutes =
new wxBoxSizer(wxHORIZONTAL);
355 m_pPanelRte->SetSizer(sbsRoutes);
356 m_pNotebook->AddPage(m_pPanelRte, _(
"Routes"));
359 sort_wp_name_dir = 0;
360 sort_track_len_dir = 1;
361 sort_route_to_dir = 0;
362 sort_track_name_dir = 0;
363 sort_route_name_dir = 0;
364 sort_layer_name_dir = 0;
365 sort_layer_len_dir = 1;
367 m_listIconSize = 2 * GetCharHeight();
370 wxBoxSizer *bSizerRteContents;
371 bSizerRteContents =
new wxBoxSizer(wxVERTICAL);
373 wxFlexGridSizer *fgSizerFilterRte;
374 fgSizerFilterRte =
new wxFlexGridSizer(0, 2, 0, 0);
375 fgSizerFilterRte->AddGrowableCol(1);
376 fgSizerFilterRte->SetFlexibleDirection(wxBOTH);
377 fgSizerFilterRte->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
379 m_stFilterRte =
new wxStaticText(m_pPanelRte, wxID_ANY, _(
"Filter"),
380 wxDefaultPosition, wxDefaultSize, 0);
381 m_stFilterRte->Wrap(-1);
382 fgSizerFilterRte->Add(m_stFilterRte, 0, wxALL, 5);
384 m_tFilterRte =
new wxTextCtrl(m_pPanelRte, wxID_ANY, wxEmptyString,
385 wxDefaultPosition, wxDefaultSize, 0);
386 fgSizerFilterRte->Add(m_tFilterRte, 1, wxALL | wxEXPAND, 5);
388 bSizerRteContents->Add(fgSizerFilterRte, 0, wxEXPAND, 5);
389 m_tFilterRte->Connect(
390 wxEVT_COMMAND_TEXT_UPDATED,
391 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
393 m_cbShowAllRte =
new wxCheckBox(m_pPanelRte, wxID_ANY, _(
"Show all routes"));
394 bSizerRteContents->Add(m_cbShowAllRte, 0, wxEXPAND | wxLEFT, 5);
395 m_cbShowAllRte->Connect(
396 wxEVT_COMMAND_CHECKBOX_CLICKED,
397 wxCommandEventHandler(RouteManagerDialog::OnShowAllRteCBClicked), NULL,
401 new wxListCtrl(m_pPanelRte, -1, wxDefaultPosition, wxSize(-1, -1),
402 wxLC_REPORT | wxLC_SORT_ASCENDING | wxLC_HRULES |
405 m_pRouteListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
408 m_pRouteListCtrl->Connect(
409 wxEVT_COMMAND_LIST_ITEM_SELECTED,
410 wxListEventHandler(RouteManagerDialog::OnRteSelected), NULL,
this);
411 m_pRouteListCtrl->Connect(
412 wxEVT_COMMAND_LIST_ITEM_DESELECTED,
413 wxListEventHandler(RouteManagerDialog::OnRteSelected), NULL,
this);
414 m_pRouteListCtrl->Connect(
415 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
416 wxListEventHandler(RouteManagerDialog::OnRteDefaultAction), NULL,
this);
417 m_pRouteListCtrl->Connect(
419 wxMouseEventHandler(RouteManagerDialog::OnRteToggleVisibility), NULL,
421 m_pRouteListCtrl->Connect(
422 wxEVT_COMMAND_LIST_COL_CLICK,
423 wxListEventHandler(RouteManagerDialog::OnRteColumnClicked), NULL,
this);
424 bSizerRteContents->Add(m_pRouteListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
425 sbsRoutes->Add(bSizerRteContents, 1, wxEXPAND, 5);
430 m_pRouteListCtrl->InsertColumn(rmVISIBLE, _(
"Show"), wxLIST_FORMAT_LEFT,
432 m_pRouteListCtrl->InsertColumn(rmROUTENAME, _(
"Route Name"),
433 wxLIST_FORMAT_LEFT, 15 * char_width);
434 m_pRouteListCtrl->InsertColumn(rmROUTEDESC, _(
"From <-> To"),
435 wxLIST_FORMAT_LEFT, 10 * char_width);
438 wxBoxSizer *bsRouteButtons =
new wxBoxSizer(wxVERTICAL);
439 sbsRoutes->Add(bsRouteButtons, 0, wxEXPAND);
441 wxScrolledWindow *winr =
new wxScrolledWindow(
442 m_pPanelRte, wxID_ANY, wxDefaultPosition, wxDefaultSize,
443 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
444 winr->SetScrollRate(0, 5);
446 bsRouteButtons->Add(winr, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
448 wxBoxSizer *bsRouteButtonsInner =
new wxBoxSizer(wxVERTICAL);
449 winr->SetSizer(bsRouteButtonsInner);
451 btnRteProperties =
new wxButton(winr, -1, _(
"&Properties") + _T(
"..."));
452 bsRouteButtonsInner->Add(btnRteProperties, 0, wxALL | wxEXPAND,
454 btnRteProperties->Connect(
455 wxEVT_COMMAND_BUTTON_CLICKED,
456 wxCommandEventHandler(RouteManagerDialog::OnRtePropertiesClick), NULL,
459 btnRteActivate =
new wxButton(winr, -1, _(
"&Activate"));
460 bsRouteButtonsInner->Add(btnRteActivate, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
461 btnRteActivate->Connect(
462 wxEVT_COMMAND_BUTTON_CLICKED,
463 wxCommandEventHandler(RouteManagerDialog::OnRteActivateClick), NULL,
465 btnRteActivate->Connect(
467 wxMouseEventHandler(RouteManagerDialog::OnRteBtnLeftDown), NULL,
this);
469 btnRteZoomto =
new wxButton(winr, -1, _(
"&Center View"));
470 bsRouteButtonsInner->Add(btnRteZoomto, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
471 btnRteZoomto->Connect(
472 wxEVT_COMMAND_BUTTON_CLICKED,
473 wxCommandEventHandler(RouteManagerDialog::OnRteZoomtoClick), NULL,
this);
474 btnRteZoomto->Connect(
476 wxMouseEventHandler(RouteManagerDialog::OnRteBtnLeftDown), NULL,
this);
478 btnRteReverse =
new wxButton(winr, -1, _(
"&Reverse"));
479 bsRouteButtonsInner->Add(btnRteReverse, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
480 btnRteReverse->Connect(
481 wxEVT_COMMAND_BUTTON_CLICKED,
482 wxCommandEventHandler(RouteManagerDialog::OnRteReverseClick), NULL,
this);
484 btnRteDelete =
new wxButton(winr, -1, _(
"&Delete"));
485 bsRouteButtonsInner->Add(btnRteDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
486 btnRteDelete->Connect(
487 wxEVT_COMMAND_BUTTON_CLICKED,
488 wxCommandEventHandler(RouteManagerDialog::OnRteDeleteClick), NULL,
this);
490 wxString reseq_label(_(
"&Resequence Waypoints"));
491 wxString export_label(_(
"&Export selected..."));
492 wxString send_to_gps_label(_(
"&Send to GPS..."));
493 wxString send_to_peer_label(_(
"Send to &Peer..."));
496 reseq_label = wxString(_(
"Resequence"));
497 export_label = wxString(_(
"Export"));
498 send_to_gps_label = wxString(_(
"Send to GPS"));
499 send_to_peer_label = wxString(_(
"Send to Peer"));
502 btnRteExport =
new wxButton(winr, -1, export_label);
503 bsRouteButtonsInner->Add(btnRteExport, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
504 btnRteExport->Connect(
505 wxEVT_COMMAND_BUTTON_CLICKED,
506 wxCommandEventHandler(RouteManagerDialog::OnRteExportClick), NULL,
this);
508 btnRteResequence =
new wxButton(winr, -1, reseq_label);
509 bsRouteButtonsInner->Add(btnRteResequence, 0, wxALL | wxEXPAND,
511 btnRteResequence->Connect(
512 wxEVT_COMMAND_BUTTON_CLICKED,
513 wxCommandEventHandler(RouteManagerDialog::OnRteResequenceClick), NULL,
516 btnRteSendToPeer =
new wxButton(winr, -1, send_to_peer_label);
517 bsRouteButtonsInner->Add(btnRteSendToPeer, 0, wxALL | wxEXPAND,
519 btnRteSendToPeer->Connect(
520 wxEVT_COMMAND_BUTTON_CLICKED,
521 wxCommandEventHandler(RouteManagerDialog::OnRteSendToPeerClick), NULL,
524 btnRteSendToGPS =
new wxButton(winr, -1, send_to_gps_label);
525 bsRouteButtonsInner->Add(btnRteSendToGPS, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
526 btnRteSendToGPS->Connect(
527 wxEVT_COMMAND_BUTTON_CLICKED,
528 wxCommandEventHandler(RouteManagerDialog::OnRteSendToGPSClick), NULL,
531 bsRouteButtonsInner->AddSpacer(10);
533 btnRteDeleteAll =
new wxButton(winr, -1, _(
"&Delete All"));
534 bsRouteButtonsInner->Add(btnRteDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
535 btnRteDeleteAll->Connect(
536 wxEVT_COMMAND_BUTTON_CLICKED,
537 wxCommandEventHandler(RouteManagerDialog::OnRteDeleteAllClick), NULL,
541 m_pPanelTrk =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
542 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
543 wxBoxSizer *sbsTracks =
new wxBoxSizer(wxHORIZONTAL);
544 m_pPanelTrk->SetSizer(sbsTracks);
545 m_pNotebook->AddPage(m_pPanelTrk, _(
"Tracks"));
547 wxBoxSizer *bSizerTrkContents;
548 bSizerTrkContents =
new wxBoxSizer(wxVERTICAL);
550 wxFlexGridSizer *fgSizerFilterTrk;
551 fgSizerFilterTrk =
new wxFlexGridSizer(0, 2, 0, 0);
552 fgSizerFilterTrk->AddGrowableCol(1);
553 fgSizerFilterTrk->SetFlexibleDirection(wxBOTH);
554 fgSizerFilterTrk->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
556 m_stFilterTrk =
new wxStaticText(m_pPanelTrk, wxID_ANY, _(
"Filter"),
557 wxDefaultPosition, wxDefaultSize, 0);
558 m_stFilterTrk->Wrap(-1);
559 fgSizerFilterTrk->Add(m_stFilterTrk, 0, wxALL, 5);
561 m_tFilterTrk =
new wxTextCtrl(m_pPanelTrk, wxID_ANY, wxEmptyString,
562 wxDefaultPosition, wxDefaultSize, 0);
563 fgSizerFilterTrk->Add(m_tFilterTrk, 1, wxALL | wxEXPAND, 5);
565 bSizerTrkContents->Add(fgSizerFilterTrk, 0, wxEXPAND, 5);
566 m_tFilterTrk->Connect(
567 wxEVT_COMMAND_TEXT_UPDATED,
568 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
570 m_cbShowAllTrk =
new wxCheckBox(m_pPanelTrk, wxID_ANY, _(
"Show all tracks"));
571 bSizerTrkContents->Add(m_cbShowAllTrk, 0, wxEXPAND | wxLEFT, 5);
572 m_cbShowAllTrk->Connect(
573 wxEVT_COMMAND_CHECKBOX_CLICKED,
574 wxCommandEventHandler(RouteManagerDialog::OnShowAllTrkCBClicked), NULL,
578 new wxListCtrl(m_pPanelTrk, -1, wxDefaultPosition, wxDefaultSize,
579 wxLC_REPORT | wxLC_SORT_ASCENDING | wxLC_HRULES |
583 m_pTrkListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
586 m_pTrkListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
587 wxListEventHandler(RouteManagerDialog::OnTrkSelected),
589 m_pTrkListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_DESELECTED,
590 wxListEventHandler(RouteManagerDialog::OnTrkSelected),
592 m_pTrkListCtrl->Connect(
593 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
594 wxListEventHandler(RouteManagerDialog::OnTrkDefaultAction), NULL,
this);
595 m_pTrkListCtrl->Connect(
597 wxMouseEventHandler(RouteManagerDialog::OnTrkToggleVisibility), NULL,
599 m_pTrkListCtrl->Connect(
600 wxEVT_COMMAND_LIST_COL_CLICK,
601 wxListEventHandler(RouteManagerDialog::OnTrkColumnClicked), NULL,
this);
602 m_pTrkListCtrl->Connect(
603 wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
604 wxListEventHandler(RouteManagerDialog::OnTrkRightClick), NULL,
this);
605 this->Connect(wxEVT_COMMAND_MENU_SELECTED,
606 wxCommandEventHandler(RouteManagerDialog::OnTrkMenuSelected),
609 bSizerTrkContents->Add(m_pTrkListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
610 sbsTracks->Add(bSizerTrkContents, 1, wxEXPAND, 5);
612 m_pTrkListCtrl->InsertColumn(colTRKVISIBLE, _(
"Show"), wxLIST_FORMAT_LEFT,
614 m_pTrkListCtrl->InsertColumn(colTRKNAME, _(
"Track Name"), wxLIST_FORMAT_LEFT,
616 m_pTrkListCtrl->InsertColumn(colTRKDATE, _(
"Start Date"), wxLIST_FORMAT_LEFT,
618 m_pTrkListCtrl->InsertColumn(colTRKLENGTH, _(
"Length"), wxLIST_FORMAT_LEFT,
621 wxBoxSizer *bsTrkButtons =
new wxBoxSizer(wxVERTICAL);
622 sbsTracks->Add(bsTrkButtons, 0, wxEXPAND);
624 wxScrolledWindow *wint =
new wxScrolledWindow(
625 m_pPanelTrk, wxID_ANY, wxDefaultPosition, wxDefaultSize,
626 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
627 wint->SetScrollRate(0, 5);
629 bsTrkButtons->Add(wint, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
631 wxBoxSizer *bsTrkButtonsInner =
new wxBoxSizer(wxVERTICAL);
632 wint->SetSizer(bsTrkButtonsInner);
634 btnTrkNew =
new wxButton(wint, -1, _(
"&Start Track"));
635 bsTrkButtonsInner->Add(btnTrkNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
636 btnTrkNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
637 wxCommandEventHandler(RouteManagerDialog::OnTrkNewClick),
640 btnTrkProperties =
new wxButton(wint, -1, _(
"&Properties"));
641 bsTrkButtonsInner->Add(btnTrkProperties, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
642 btnTrkProperties->Connect(
643 wxEVT_COMMAND_BUTTON_CLICKED,
644 wxCommandEventHandler(RouteManagerDialog::OnTrkPropertiesClick), NULL,
647 btnTrkDelete =
new wxButton(wint, -1, _(
"&Delete"));
648 bsTrkButtonsInner->Add(btnTrkDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
649 btnTrkDelete->Connect(
650 wxEVT_COMMAND_BUTTON_CLICKED,
651 wxCommandEventHandler(RouteManagerDialog::OnTrkDeleteClick), NULL,
this);
653 btnTrkExport =
new wxButton(wint, -1, _(
"&Export selected..."));
654 bsTrkButtonsInner->Add(btnTrkExport, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
655 btnTrkExport->Connect(
656 wxEVT_COMMAND_BUTTON_CLICKED,
657 wxCommandEventHandler(RouteManagerDialog::OnTrkExportClick), NULL,
this);
659 btnTrkRouteFromTrack =
new wxButton(wint, -1, _(
"Route from Track"));
660 bsTrkButtonsInner->Add(btnTrkRouteFromTrack, 0, wxALL | wxEXPAND,
662 btnTrkRouteFromTrack->Connect(
663 wxEVT_COMMAND_BUTTON_CLICKED,
664 wxCommandEventHandler(RouteManagerDialog::OnTrkRouteFromTrackClick), NULL,
667 btnTrkSendToPeer =
new wxButton(wint, -1, _(
"Send to &Peer"));
668 bsTrkButtonsInner->Add(btnTrkSendToPeer, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
669 btnTrkSendToPeer->Connect(
670 wxEVT_COMMAND_BUTTON_CLICKED,
671 wxCommandEventHandler(RouteManagerDialog::OnTrkSendToPeerClick), NULL,
674 bsTrkButtonsInner->AddSpacer(10);
676 btnTrkDeleteAll =
new wxButton(wint, -1, _(
"&Delete All"));
677 bsTrkButtonsInner->Add(btnTrkDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
678 btnTrkDeleteAll->Connect(
679 wxEVT_COMMAND_BUTTON_CLICKED,
680 wxCommandEventHandler(RouteManagerDialog::OnTrkDeleteAllClick), NULL,
684 m_pPanelWpt =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
685 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
686 wxBoxSizer *sbsWpts =
new wxBoxSizer(wxHORIZONTAL);
687 m_pPanelWpt->SetSizer(sbsWpts);
688 m_pNotebook->AddPage(m_pPanelWpt, _(
"Marks"));
690 wxBoxSizer *bSizerWptContents;
691 bSizerWptContents =
new wxBoxSizer(wxVERTICAL);
693 wxFlexGridSizer *fgSizerFilterWpt;
694 fgSizerFilterWpt =
new wxFlexGridSizer(0, 2, 0, 0);
695 fgSizerFilterWpt->AddGrowableCol(1);
696 fgSizerFilterWpt->SetFlexibleDirection(wxBOTH);
697 fgSizerFilterWpt->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
699 m_stFilterWpt =
new wxStaticText(m_pPanelWpt, wxID_ANY, _(
"Filter"),
700 wxDefaultPosition, wxDefaultSize, 0);
701 m_stFilterWpt->Wrap(-1);
702 fgSizerFilterWpt->Add(m_stFilterWpt, 0, wxALL, 5);
704 m_tFilterWpt =
new wxTextCtrl(m_pPanelWpt, wxID_ANY, wxEmptyString,
705 wxDefaultPosition, wxDefaultSize, 0);
706 fgSizerFilterWpt->Add(m_tFilterWpt, 1, wxALL | wxEXPAND, 5);
708 bSizerWptContents->Add(fgSizerFilterWpt, 0, wxEXPAND, 5);
709 m_tFilterWpt->Connect(
710 wxEVT_COMMAND_TEXT_UPDATED,
711 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
713 m_cbShowAllWP =
new wxCheckBox(m_pPanelWpt, wxID_ANY, _(
"Show all marks"));
714 bSizerWptContents->Add(m_cbShowAllWP, 0, wxEXPAND | wxLEFT, 5);
715 m_cbShowAllWP->Connect(
716 wxEVT_COMMAND_CHECKBOX_CLICKED,
717 wxCommandEventHandler(RouteManagerDialog::OnShowAllWpCBClicked), NULL,
721 new wxListCtrl(m_pPanelWpt, -1, wxDefaultPosition, wxDefaultSize,
722 wxLC_REPORT | wxLC_SORT_ASCENDING | wxLC_HRULES |
725 m_pWptListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
728 m_pWptListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
729 wxListEventHandler(RouteManagerDialog::OnWptSelected),
731 m_pWptListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_DESELECTED,
732 wxListEventHandler(RouteManagerDialog::OnWptSelected),
734 m_pWptListCtrl->Connect(
735 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
736 wxListEventHandler(RouteManagerDialog::OnWptDefaultAction), NULL,
this);
737 m_pWptListCtrl->Connect(
739 wxMouseEventHandler(RouteManagerDialog::OnWptToggleVisibility), NULL,
741 m_pWptListCtrl->Connect(
742 wxEVT_COMMAND_LIST_COL_CLICK,
743 wxListEventHandler(RouteManagerDialog::OnWptColumnClicked), NULL,
this);
744 bSizerWptContents->Add(m_pWptListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
745 sbsWpts->Add(bSizerWptContents, 1, wxEXPAND, 5);
747 m_pWptListCtrl->InsertColumn(colWPTICON, _(
"Icon"), wxLIST_FORMAT_LEFT,
749 m_pWptListCtrl->InsertColumn(colWPTSCALE, _(
"Scale"), wxLIST_FORMAT_LEFT,
751 m_pWptListCtrl->InsertColumn(colWPTNAME, _(
"Mark Name"), wxLIST_FORMAT_LEFT,
753 m_pWptListCtrl->InsertColumn(colWPTDIST, _(
"Distance from own ship"),
754 wxLIST_FORMAT_LEFT, 14 * char_width);
756 wxBoxSizer *bsWptButtons =
new wxBoxSizer(wxVERTICAL);
757 sbsWpts->Add(bsWptButtons, 0, wxEXPAND);
759 wxScrolledWindow *winw =
new wxScrolledWindow(
760 m_pPanelWpt, wxID_ANY, wxDefaultPosition, wxDefaultSize,
761 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
762 winw->SetScrollRate(0, 5);
764 bsWptButtons->Add(winw, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
766 wxBoxSizer *bsWptButtonsInner =
new wxBoxSizer(wxVERTICAL);
767 winw->SetSizer(bsWptButtonsInner);
769 btnWptNew =
new wxButton(winw, -1, _(
"&New"));
770 bsWptButtonsInner->Add(btnWptNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
771 btnWptNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
772 wxCommandEventHandler(RouteManagerDialog::OnWptNewClick),
775 btnWptProperties =
new wxButton(winw, -1, _(
"&Properties"));
776 bsWptButtonsInner->Add(btnWptProperties, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
777 btnWptProperties->Connect(
778 wxEVT_COMMAND_BUTTON_CLICKED,
779 wxCommandEventHandler(RouteManagerDialog::OnWptPropertiesClick), NULL,
782 btnWptZoomto =
new wxButton(winw, -1, _(
"&Center View"));
783 bsWptButtonsInner->Add(btnWptZoomto, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
784 btnWptZoomto->Connect(
785 wxEVT_COMMAND_BUTTON_CLICKED,
786 wxCommandEventHandler(RouteManagerDialog::OnWptZoomtoClick), NULL,
this);
788 btnWptDelete =
new wxButton(winw, -1, _(
"&Delete"));
789 bsWptButtonsInner->Add(btnWptDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
790 btnWptDelete->Connect(
791 wxEVT_COMMAND_BUTTON_CLICKED,
792 wxCommandEventHandler(RouteManagerDialog::OnWptDeleteClick), NULL,
this);
794 btnWptGoTo =
new wxButton(winw, -1, _(
"&Go To"));
795 bsWptButtonsInner->Add(btnWptGoTo, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
796 btnWptGoTo->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
797 wxCommandEventHandler(RouteManagerDialog::OnWptGoToClick),
800 btnWptExport =
new wxButton(winw, -1, _(
"&Export selected..."));
801 bsWptButtonsInner->Add(btnWptExport, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
802 btnWptExport->Connect(
803 wxEVT_COMMAND_BUTTON_CLICKED,
804 wxCommandEventHandler(RouteManagerDialog::OnWptExportClick), NULL,
this);
806 btnWptSendToGPS =
new wxButton(winw, -1, _(
"&Send to GPS"));
807 bsWptButtonsInner->Add(btnWptSendToGPS, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
808 btnWptSendToGPS->Connect(
809 wxEVT_COMMAND_BUTTON_CLICKED,
810 wxCommandEventHandler(RouteManagerDialog::OnWptSendToGPSClick), NULL,
813 btnWptSendToPeer =
new wxButton(winw, -1, _(
"Send to &Peer"));
814 bsWptButtonsInner->Add(btnWptSendToPeer, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
815 btnWptSendToPeer->Connect(
816 wxEVT_COMMAND_BUTTON_CLICKED,
817 wxCommandEventHandler(RouteManagerDialog::OnWptSendToPeerClick), NULL,
820 bsWptButtonsInner->AddSpacer(10);
822 btnWptDeleteAll =
new wxButton(winw, -1, _(
"Delete All"));
823 bsWptButtonsInner->Add(btnWptDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
824 btnWptDeleteAll->Connect(
825 wxEVT_COMMAND_BUTTON_CLICKED,
826 wxCommandEventHandler(RouteManagerDialog::OnWptDeleteAllClick), NULL,
829 wxBoxSizer *itemBoxSizer5 =
new wxBoxSizer(wxHORIZONTAL);
830 itemBoxSizer1->Add(itemBoxSizer5, 0, wxALL | wxEXPAND);
832 wxBoxSizer *itemBoxSizer6 =
new wxBoxSizer(wxHORIZONTAL);
833 itemBoxSizer5->Add(itemBoxSizer6, 1, wxALL | wxEXPAND);
835 btnImport =
new wxButton(
this, -1, _(
"I&mport GPX..."));
836 itemBoxSizer6->Add(btnImport, 0, wxALL | wxALIGN_LEFT, DIALOG_MARGIN);
837 btnImport->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
838 wxCommandEventHandler(RouteManagerDialog::OnImportClick),
847 btnExportViz =
new wxButton(
this, -1, _(
"Export All Visible..."));
848 itemBoxSizer6->Add(btnExportViz, 0, wxALL | wxALIGN_LEFT, DIALOG_MARGIN);
849 btnExportViz->Connect(
850 wxEVT_COMMAND_BUTTON_CLICKED,
851 wxCommandEventHandler(RouteManagerDialog::OnExportVizClick), NULL,
this);
854 wxSize sz = ::wxGetDisplaySize();
856 itemBoxSizer6->Add(0, 0, 1, wxEXPAND, 5);
857 itemBoxSizer6->Add(
new wxButton(
this, wxID_OK), 0, wxALL, DIALOG_MARGIN);
859 wxStaticLine *staticLine121 =
new wxStaticLine(
860 this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
861 itemBoxSizer1->Add(staticLine121, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
863 wxBoxSizer *itemBoxSizer7 =
new wxBoxSizer(wxHORIZONTAL);
864 itemBoxSizer1->Add(itemBoxSizer7, 0, wxEXPAND);
866 wxBoxSizer *itemBoxSizer7a =
new wxBoxSizer(wxHORIZONTAL);
867 itemBoxSizer7->Add(itemBoxSizer7a, 1, wxEXPAND);
869 itemBoxSizer7a->AddStretchSpacer();
870 itemBoxSizer7a->Add(
new wxButton(
this, wxID_OK), 0, wxRIGHT | wxALIGN_RIGHT,
875 m_pPanelLay =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
876 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
877 wxBoxSizer *sbsLayers =
new wxBoxSizer(wxHORIZONTAL);
878 m_pPanelLay->SetSizer(sbsLayers);
879 m_pNotebook->AddPage(m_pPanelLay, _(
"Layers"));
881 wxBoxSizer *bSizerLayContents;
882 bSizerLayContents =
new wxBoxSizer(wxVERTICAL);
884 wxFlexGridSizer *fgSizerFilterLay;
885 fgSizerFilterLay =
new wxFlexGridSizer(0, 2, 0, 0);
886 fgSizerFilterLay->AddGrowableCol(1);
887 fgSizerFilterLay->SetFlexibleDirection(wxBOTH);
888 fgSizerFilterLay->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
890 m_stFilterLay =
new wxStaticText(m_pPanelLay, wxID_ANY, _(
"Filter"),
891 wxDefaultPosition, wxDefaultSize, 0);
892 m_stFilterLay->Wrap(-1);
893 fgSizerFilterLay->Add(m_stFilterLay, 0, wxALL, 5);
895 m_tFilterLay =
new wxTextCtrl(m_pPanelLay, wxID_ANY, wxEmptyString,
896 wxDefaultPosition, wxDefaultSize, 0);
897 fgSizerFilterLay->Add(m_tFilterLay, 1, wxALL | wxEXPAND, 5);
899 bSizerLayContents->Add(fgSizerFilterLay, 0, wxEXPAND, 5);
900 m_tFilterLay->Connect(
901 wxEVT_COMMAND_TEXT_UPDATED,
902 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
904 m_cbShowAllLay =
new wxCheckBox(m_pPanelLay, wxID_ANY, _(
"Show all layers"));
905 bSizerLayContents->Add(m_cbShowAllLay, 0, wxEXPAND | wxLEFT, 5);
906 m_cbShowAllLay->Connect(
907 wxEVT_COMMAND_CHECKBOX_CLICKED,
908 wxCommandEventHandler(RouteManagerDialog::OnShowAllLayCBClicked), NULL,
912 new wxListCtrl(m_pPanelLay, -1, wxDefaultPosition, wxDefaultSize,
913 wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING |
914 wxLC_HRULES | wxBORDER_SUNKEN );
916 m_pLayListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
919 m_pLayListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
920 wxListEventHandler(RouteManagerDialog::OnLaySelected),
922 m_pLayListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_DESELECTED,
923 wxListEventHandler(RouteManagerDialog::OnLaySelected),
925 m_pLayListCtrl->Connect(
926 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
927 wxListEventHandler(RouteManagerDialog::OnLayDefaultAction), NULL,
this);
928 m_pLayListCtrl->Connect(
930 wxMouseEventHandler(RouteManagerDialog::OnLayToggleVisibility), NULL,
932 m_pLayListCtrl->Connect(
933 wxEVT_COMMAND_LIST_COL_CLICK,
934 wxListEventHandler(RouteManagerDialog::OnLayColumnClicked), NULL,
this);
935 bSizerLayContents->Add(m_pLayListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
936 sbsLayers->Add(bSizerLayContents, 1, wxEXPAND, 5);
938 m_pLayListCtrl->InsertColumn(colLAYVISIBLE, _T(
""), wxLIST_FORMAT_LEFT,
940 m_pLayListCtrl->InsertColumn(colLAYNAME, _(
"Layer Name"), wxLIST_FORMAT_LEFT,
942 m_pLayListCtrl->InsertColumn(colLAYITEMS, _(
"No. of items"),
943 wxLIST_FORMAT_LEFT, 10 * char_width);
944 m_pLayListCtrl->InsertColumn(colLAYPERSIST, _(
"Layer type"),
945 wxLIST_FORMAT_LEFT, 10 * char_width);
947 wxBoxSizer *bsLayButtons =
new wxBoxSizer(wxVERTICAL);
948 sbsLayers->Add(bsLayButtons, 0, wxEXPAND);
950 wxScrolledWindow *winl =
new wxScrolledWindow(
951 m_pPanelLay, wxID_ANY, wxDefaultPosition, wxDefaultSize,
952 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
953 winl->SetScrollRate(0, 5);
955 bsLayButtons->Add(winl, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
957 wxBoxSizer *bsLayButtonsInner =
new wxBoxSizer(wxVERTICAL);
958 winl->SetSizer(bsLayButtonsInner);
960 btnLayNew =
new wxButton(winl, -1, _(
"Create Temporary layer"));
961 bsLayButtonsInner->Add(btnLayNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
962 btnLayNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
963 wxCommandEventHandler(RouteManagerDialog::OnLayNewClick),
966 btnPerLayNew =
new wxButton(winl, -1, _(
"Create Persistent layer"));
967 bsLayButtonsInner->Add(btnPerLayNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
968 btnPerLayNew->Connect(
969 wxEVT_COMMAND_BUTTON_CLICKED,
970 wxCommandEventHandler(RouteManagerDialog::OnPerLayNewClick), NULL,
this);
972 btnLayDelete =
new wxButton(winl, -1, _(
"&Delete"));
973 bsLayButtonsInner->Add(btnLayDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
974 btnLayDelete->Connect(
975 wxEVT_COMMAND_BUTTON_CLICKED,
976 wxCommandEventHandler(RouteManagerDialog::OnLayDeleteClick), NULL,
this);
978 cbLayToggleChart =
new wxCheckBox(winl, -1, _(
"Show on chart"));
979 bsLayButtonsInner->Add(cbLayToggleChart, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
980 cbLayToggleChart->Connect(
981 wxEVT_COMMAND_CHECKBOX_CLICKED,
982 wxCommandEventHandler(RouteManagerDialog::OnLayToggleChartClick), NULL,
986 new wxCheckBox(winl, -1, _(
"Show WPT names"), wxDefaultPosition,
987 wxDefaultSize, wxCHK_3STATE);
989 bsLayButtonsInner->Add(cbLayToggleNames, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
990 cbLayToggleNames->Connect(
991 wxEVT_COMMAND_CHECKBOX_CLICKED,
992 wxCommandEventHandler(RouteManagerDialog::OnLayToggleNamesClick), NULL,
995 cbLayToggleListing =
new wxCheckBox(winl, -1, _(
"List contents"));
996 bsLayButtonsInner->Add(cbLayToggleListing, 0, wxALL | wxEXPAND,
998 cbLayToggleListing->Connect(
999 wxEVT_COMMAND_CHECKBOX_CLICKED,
1000 wxCommandEventHandler(RouteManagerDialog::OnLayToggleListingClick), NULL,
1005 int imageRefSize = m_charWidth * 2;
1006 wxImageList *imglist =
new wxImageList(imageRefSize, imageRefSize,
true, 1);
1009 wxString UserIconPath = g_Platform->GetSharedDataDir() + _T(
"uidata") +
1010 wxFileName::GetPathSeparator();
1012 LoadSVG(UserIconPath + _T(
"eye.svg"), imageRefSize, imageRefSize)
1014 if (iconSVG.IsOk()) {
1015 iconSVG.Resize(wxSize(imageRefSize, imageRefSize),
1017 imglist->Add(wxBitmap(iconSVG));
1020 iconSVG = LoadSVG(UserIconPath + _T(
"eyex.svg"), imageRefSize, imageRefSize)
1022 if (iconSVG.IsOk()) {
1023 iconSVG.Resize(wxSize(imageRefSize, imageRefSize), wxPoint(0, 0));
1024 imglist->Add(wxBitmap(iconSVG));
1028 LoadSVG(UserIconPath + _T(
"eyeGray.svg"), imageRefSize, imageRefSize)
1030 if (iconSVG.IsOk()) {
1031 iconSVG.Resize(wxSize(imageRefSize, imageRefSize), wxPoint(0, 0));
1032 imglist->Add(wxBitmap(iconSVG));
1035 m_pRouteListCtrl->AssignImageList(imglist, wxIMAGE_LIST_SMALL);
1038 m_pRouteListCtrl->GetHandle()->setIconSize(QSize(imageRefSize, imageRefSize));
1042 m_pTrkListCtrl->SetImageList(imglist, wxIMAGE_LIST_SMALL);
1043 m_pWptListCtrl->SetImageList(
1044 pWayPointMan->Getpmarkicon_image_list(m_listIconSize),
1045 wxIMAGE_LIST_SMALL);
1046 m_pLayListCtrl->SetImageList(imglist, wxIMAGE_LIST_SMALL);
1056 m_bNeedConfigFlush =
false;
1059RouteManagerDialog::~RouteManagerDialog() {
1060 delete m_pRouteListCtrl;
1061 delete m_pTrkListCtrl;
1062 delete m_pWptListCtrl;
1063 delete m_pLayListCtrl;
1065 delete btnRteDelete;
1066 delete btnRteResequence;
1067 delete btnRteExport;
1068 delete btnRteZoomto;
1069 delete btnRteProperties;
1070 delete btnRteActivate;
1071 delete btnRteReverse;
1072 delete btnRteSendToGPS;
1073 delete btnRteDeleteAll;
1075 delete btnTrkProperties;
1076 delete btnTrkDelete;
1077 delete btnTrkExport;
1078 delete btnTrkRouteFromTrack;
1079 delete btnTrkDeleteAll;
1081 delete btnWptProperties;
1082 delete btnWptZoomto;
1083 delete btnWptDelete;
1085 delete btnWptExport;
1086 delete btnWptSendToGPS;
1087 delete btnWptDeleteAll;
1090 delete cbLayToggleChart;
1091 delete cbLayToggleListing;
1092 delete cbLayToggleNames;
1093 delete btnLayDelete;
1096 delete btnExportViz;
1099 btnExportViz = NULL;
1102 instanceFlag =
false;
1105void RouteManagerDialog::RecalculateSize() {
1111 int char_width, char_height;
1112 GetTextExtent(_T(
"W"), &char_width, &char_height);
1115 sz.x = 60 * char_width;
1116 sz.y = 30 * char_height;
1118 wxSize dsize = GetParent()->GetClientSize();
1119 sz.y = wxMin(sz.y, dsize.y);
1120 sz.x = wxMin(sz.x, dsize.x);
1123 wxSize fsize = GetSize();
1124 fsize.y = wxMin(fsize.y, dsize.y);
1125 fsize.x = wxMin(fsize.x, dsize.x);
1131void RouteManagerDialog::OnClose(wxCloseEvent &event) {
1139void RouteManagerDialog::OnOK(wxCommandEvent &event) {
1146void RouteManagerDialog::SetColorScheme() { DimeControl(
this); }
1148void RouteManagerDialog::OnShowAllRteCBClicked(wxCommandEvent &event) {
1149 bool viz = m_cbShowAllRte->GetValue();
1152 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1153 wxLIST_STATE_DONTCARE);
1154 if (item == -1)
break;
1156 Route *pR = (
Route *)m_pRouteListCtrl->GetItemData(item);
1158 pR->SetVisible(viz, viz);
1159 pR->SetSharedWPViz(viz);
1161 m_pRouteListCtrl->SetItemImage(item, !viz);
1163 pConfig->UpdateRoute(pR);
1166 UpdateWptListCtrlViz();
1168 gFrame->RefreshAllCanvas();
1171void RouteManagerDialog::OnShowAllWpCBClicked(wxCommandEvent &event) {
1172 bool viz = m_cbShowAllWP->GetValue();
1175 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1176 wxLIST_STATE_DONTCARE);
1177 if (item == -1)
break;
1181 if (!pRP->IsSharedInVisibleRoute()) {
1182 pRP->SetVisible(viz);
1184 pRP->SetVisible(
true);
1186 m_pWptListCtrl->SetItemImage(item,
RoutePointGui(*pRP).GetIconImageIndex());
1187 pConfig->UpdateWayPoint(pRP);
1190 gFrame->RefreshAllCanvas();
1193void RouteManagerDialog::OnShowAllTrkCBClicked(wxCommandEvent &event) {
1194 bool viz = m_cbShowAllTrk->GetValue();
1197 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1198 wxLIST_STATE_DONTCARE);
1199 if (item == -1)
break;
1201 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1203 track->SetVisible(viz);
1204 m_pTrkListCtrl->SetItemImage(item, track->IsVisible() ? 0 : 1);
1207 gFrame->RefreshAllCanvas();
1210void RouteManagerDialog::OnShowAllLayCBClicked(wxCommandEvent &event) {
1211 bool viz = m_cbShowAllLay->GetValue();
1214 item = m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1215 wxLIST_STATE_DONTCARE);
1216 if (item == -1)
break;
1218 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
1220 layer->SetVisibleOnChart(viz);
1221 m_pLayListCtrl->SetItemImage(item, layer->IsVisibleOnChart() ? 0 : 1);
1223 ToggleLayerContentsOnChart(layer);
1226 gFrame->RefreshAllCanvas();
1229void RouteManagerDialog::UpdateRouteListCtrl() {
1232 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1233 wxLIST_STATE_SELECTED);
1234 wxUIntPtr selected_id = wxUIntPtr(0);
1235 if (item != -1) selected_id = m_pRouteListCtrl->GetItemData(item);
1238 m_pRouteListCtrl->DeleteAllItems();
1241 RouteList::iterator it;
1244 bool bpartialViz =
false;
1246 for (it = (*pRouteList).begin(); it != (*pRouteList).end(); ++it, ++index) {
1247 if (!(*it)->IsListed())
continue;
1249 if (!(*it)->GetName().Upper().Contains(m_tFilterRte->GetValue().Upper())) {
1254 li.SetId(list_index);
1255 li.SetImage((*it)->IsVisible() ? 0 : 1);
1258 li.SetAlign(wxLIST_FORMAT_LEFT);
1260 if ((*it)->m_bRtIsActive) {
1261 wxFont font = *wxNORMAL_FONT;
1262 font.SetWeight(wxFONTWEIGHT_BOLD);
1266 long idx = m_pRouteListCtrl->InsertItem(li);
1268 wxString name = (*it)->m_RouteNameString;
1269 if (name.IsEmpty()) name = _(
"(Unnamed Route)");
1270 m_pRouteListCtrl->SetItem(idx, rmROUTENAME, name);
1272 wxString startend = (*it)->m_RouteStartString;
1273 if (!(*it)->m_RouteEndString.IsEmpty())
1274 startend.append(_(
" - ") + (*it)->m_RouteEndString);
1275 m_pRouteListCtrl->SetItem(idx, rmROUTEDESC, startend);
1278 lic.SetId(list_index);
1280 lic.SetAlign(wxLIST_FORMAT_LEFT);
1281 m_pRouteListCtrl->SetItem(lic);
1284 lic.SetAlign(wxLIST_FORMAT_LEFT);
1285 m_pRouteListCtrl->SetItem(lic);
1288 if (!(*it)->IsVisible()) bpartialViz =
true;
1293 m_pRouteListCtrl->SortItems(SortRoutesOnName, (wxIntPtr)NULL);
1295 m_pRouteListCtrl->SetColumnWidth(0, 4 * m_charWidth);
1300 if (selected_id != wxUIntPtr(0)) {
1301 item = m_pRouteListCtrl->FindItem(-1, selected_id);
1302 m_pRouteListCtrl->SetItemState(
1303 item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
1304 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
1307 if ((m_lastRteItem >= 0) && (m_pRouteListCtrl->GetItemCount()))
1308 m_pRouteListCtrl->EnsureVisible(m_lastRteItem);
1312 m_cbShowAllRte->SetValue(!bpartialViz);
1315void RouteManagerDialog::UpdateRteButtons() {
1317 long selected_index_index =
1318 m_pRouteListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
1319 bool enable1 = m_pRouteListCtrl->GetSelectedItemCount() == 1;
1320 bool enablemultiple = m_pRouteListCtrl->GetSelectedItemCount() >= 1;
1322 m_lastRteItem = selected_index_index;
1324 btnRteDelete->Enable(m_pRouteListCtrl->GetSelectedItemCount() > 0);
1325 btnRteZoomto->Enable(enable1);
1326 btnRteProperties->Enable(enable1);
1327 btnRteReverse->Enable(enable1);
1328 btnRteExport->Enable(enablemultiple);
1329 btnRteResequence->Enable(enable1);
1330 btnRteSendToGPS->Enable(enable1);
1331 btnRteDeleteAll->Enable(m_pRouteListCtrl->GetItemCount() > 0);
1332 btnRteSendToPeer->Enable(enablemultiple);
1335 Route *route = NULL;
1337 route = (
Route *)m_pRouteListCtrl->GetItemData(selected_index_index);
1339 if (!g_pRouteMan->IsAnyRouteActive()) {
1340 btnRteActivate->Enable(enable1);
1341 if (enable1) btnRteActivate->SetLabel(_(
"Activate"));
1346 btnRteActivate->Enable(enable1);
1347 btnRteActivate->SetLabel(_(
"Deactivate"));
1349 btnRteActivate->Enable(
false);
1351 btnRteActivate->Enable(
false);
1355void RouteManagerDialog::MakeAllRoutesInvisible() {
1356 RouteList::iterator it;
1358 for (it = (*pRouteList).begin(); it != (*pRouteList).end(); ++it, ++index) {
1359 if ((*it)->IsVisible()) {
1360 (*it)->SetVisible(
false);
1361 m_pRouteListCtrl->SetItemImage(m_pRouteListCtrl->FindItem(-1, index),
1363 pConfig->UpdateRoute(*it);
1368void RouteManagerDialog::ZoomtoRoute(
Route *route) {
1370 LLBBox RBBox = route->GetBBox();
1371 double clat = (RBBox.GetMinLat() + RBBox.GetMaxLat()) / 2;
1372 double clon = (RBBox.GetMinLon() + RBBox.GetMaxLon()) / 2;
1378 DistanceBearingMercator(RBBox.GetMinLat(), RBBox.GetMinLon(),
1379 RBBox.GetMinLat(), RBBox.GetMaxLon(), NULL, &rw);
1381 DistanceBearingMercator(RBBox.GetMinLat(), RBBox.GetMinLon(),
1382 RBBox.GetMaxLat(), RBBox.GetMinLon(), NULL, &rh);
1384 if (gFrame->GetFocusCanvas()) {
1385 gFrame->GetFocusCanvas()->GetSize(&ww, &wh);
1386 ppm = wxMin(ww / (rw * 1852), wh / (rh * 1852)) * (100 - fabs(clat)) / 90;
1387 ppm = wxMin(ppm, 1.0);
1389 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), clat, clon, ppm);
1392 m_bNeedConfigFlush =
true;
1396void RouteManagerDialog::OnRteDeleteClick(wxCommandEvent &event) {
1397 int count = m_pRouteListCtrl->GetSelectedItemCount();
1398 bool confirmed = RouteGui::OnDelete(
this, count);
1400 if (confirmed && count > 0) {
1401 ::wxBeginBusyCursor();
1404 gFrame->CancelAllMouseRoute();
1405 m_bNeedConfigFlush =
true;
1409 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1410 wxLIST_STATE_SELECTED);
1411 if (item == -1)
break;
1413 Route *proute_to_delete = (
Route *)m_pRouteListCtrl->GetItemData(item);
1415 if (proute_to_delete) list.Append(proute_to_delete);
1418 for (
unsigned int i = 0; i < list.GetCount(); i++) {
1419 Route *route = list.Item(i)->GetData();
1421 pConfig->DeleteConfigRoute(route);
1422 g_pRouteMan->
DeleteRoute(route, NavObjectChanges::getInstance());
1427 UpdateRouteListCtrl();
1428 UpdateTrkListCtrl();
1430 gFrame->InvalidateAllCanvasUndo();
1431 gFrame->RefreshAllCanvas();
1432 ::wxEndBusyCursor();
1436void RouteManagerDialog::OnRteDeleteAllClick(wxCommandEvent &event) {
1438 OCPNMessageBox(
this, _(
"Are you sure you want to delete <ALL> routes?"),
1439 wxString(_(
"OpenCPN Alert")), wxYES_NO);
1441 if (dialog_ret == wxID_YES) {
1442 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1444 gFrame->CancelAllMouseRoute();
1446 g_pRouteMan->DeleteAllRoutes(NavObjectChanges::getInstance());
1453 UpdateRouteListCtrl();
1457 UpdateTrkListCtrl();
1459 if (pRoutePropDialog) pRoutePropDialog->Hide();
1460 gFrame->InvalidateAllCanvasUndo();
1461 gFrame->RefreshAllCanvas();
1463 m_bNeedConfigFlush =
true;
1467void RouteManagerDialog::OnRtePropertiesClick(wxCommandEvent &event) {
1470 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1471 wxLIST_STATE_SELECTED);
1472 if (item == -1)
return;
1474 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1478 pRoutePropDialog = RoutePropDlgImpl::getInstance(GetParent());
1480 pRoutePropDialog->SetRouteAndUpdate(route);
1482 if (!pRoutePropDialog->IsShown()) pRoutePropDialog->Show();
1484 pRoutePropDialog->Raise();
1486 m_bNeedConfigFlush =
true;
1489void RouteManagerDialog::OnRteZoomtoClick(wxCommandEvent &event) {
1492 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1493 wxLIST_STATE_SELECTED);
1494 if (item == -1)
return;
1497 if (m_bCtrlDown) MakeAllRoutesInvisible();
1499 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1504 if (!route->IsVisible()) {
1505 route->SetVisible(
true);
1506 m_pRouteListCtrl->SetItemImage(item, route->IsVisible() ? 0 : 1);
1507 pConfig->UpdateRoute(route);
1513void RouteManagerDialog::OnRteReverseClick(wxCommandEvent &event) {
1516 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1517 wxLIST_STATE_SELECTED);
1518 if (item == -1)
return;
1520 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1525 int ask_return = OCPNMessageBox(
this, g_pRouteMan->GetRouteReverseMessage(),
1526 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1527 if (ask_return != wxID_CANCEL) {
1528 bool rename = (ask_return == wxID_YES);
1530 pSelect->DeleteAllSelectableRouteSegments(route);
1531 route->Reverse(rename);
1532 pSelect->AddAllSelectableRouteSegments(route);
1538 m_pRouteListCtrl->SetItem(item, 2, startend);
1540 pConfig->UpdateRoute(route);
1541 gFrame->RefreshAllCanvas();
1544 m_bNeedConfigFlush =
true;
1547void RouteManagerDialog::OnRteExportClick(wxCommandEvent &event) {
1550 wxString suggested_name = _T(
"routes");
1554 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1555 wxLIST_STATE_SELECTED);
1556 if (item == -1)
break;
1558 Route *proute_to_export = (
Route *)m_pRouteListCtrl->GetItemData(item);
1560 if (proute_to_export) {
1561 list.Append(proute_to_export);
1567 ExportGPXRoutes(
this, &list, suggested_name);
1570void RouteManagerDialog::OnRteResequenceClick(wxCommandEvent &event) {
1572 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1573 wxLIST_STATE_SELECTED);
1574 if (item == -1)
return;
1576 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1580 route->RenameRoutePoints();
1583void RouteManagerDialog::OnRteSendToPeerClick(wxCommandEvent &event) {
1584 std::vector<Route *> list;
1587 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1588 wxLIST_STATE_SELECTED);
1589 if (item == -1)
break;
1591 Route *proute = (
Route *)m_pRouteListCtrl->GetItemData(item);
1594 list.push_back(proute);
1597 if (!list.empty()) {
1599 for (
auto r : list) {
1606 MdnsCache::GetInstance().
Validate();
1607 if (MdnsCache::GetInstance().GetCache().empty()) dlg.SetScanOnCreate(
true);
1610 dlg.Create(NULL, -1, _(
"Send Route(s) to OpenCPN Peer") + _T(
"..." ),
1616void RouteManagerDialog::OnWptSendToPeerClick(wxCommandEvent &event) {
1617 std::vector<RoutePoint *> list;
1620 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1621 wxLIST_STATE_SELECTED);
1622 if (item == -1)
break;
1627 list.push_back(proutep);
1630 if (!list.empty()) {
1632 for (
auto r : list) {
1639 MdnsCache::GetInstance().
Validate();
1640 if (MdnsCache::GetInstance().GetCache().empty()) dlg.SetScanOnCreate(
true);
1643 dlg.Create(NULL, -1, _(
"Send Waypoint(s) to OpenCPN Peer") + _T(
"..." ),
1649void RouteManagerDialog::OnTrkSendToPeerClick(wxCommandEvent &event) {
1650 std::vector<Track *> list;
1653 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1654 wxLIST_STATE_SELECTED);
1655 if (item == -1)
break;
1657 Track *ptrk = (
Track *)m_pTrkListCtrl->GetItemData(item);
1660 list.push_back(ptrk);
1663 if (!list.empty()) {
1665 for (
auto r : list) {
1672 MdnsCache::GetInstance().
Validate();
1673 if (MdnsCache::GetInstance().GetCache().empty()) dlg.SetScanOnCreate(
true);
1676 dlg.Create(NULL, -1, _(
"Send Track(s) to OpenCPN Peer") + _T(
"..." ),
1682void RouteManagerDialog::OnRteActivateClick(wxCommandEvent &event) {
1685 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1686 wxLIST_STATE_SELECTED);
1687 if (item == -1)
return;
1689 if (m_bCtrlDown) MakeAllRoutesInvisible();
1691 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1696 if (!route->IsVisible()) {
1697 route->SetVisible(
true);
1698 m_pRouteListCtrl->SetItemImage(item, 0, 0);
1704 g_pRouteMan->FindBestActivatePoint(route, gLat, gLon, gCog, gSog);
1708 g_pRouteMan->DeactivateRoute();
1710 UpdateRouteListCtrl();
1712 pConfig->UpdateRoute(route);
1714 gFrame->RefreshAllCanvas();
1719 m_bNeedConfigFlush =
true;
1722void RouteManagerDialog::OnRteToggleVisibility(wxMouseEvent &event) {
1723 wxPoint pos =
event.GetPosition();
1725 long clicked_index = m_pRouteListCtrl->HitTest(pos, flags);
1728 if (clicked_index > -1 &&
1729 event.GetX() < m_pRouteListCtrl->GetColumnWidth(rmVISIBLE)) {
1731 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(clicked_index);
1733 route->SetVisible(!route->IsVisible());
1735 m_pRouteListCtrl->SetItemImage(clicked_index, route->IsVisible() ? 0 : 1);
1737 ::wxBeginBusyCursor();
1739 pConfig->UpdateRoute(route);
1740 gFrame->RefreshAllCanvas();
1744 if (g_pRouteMan->DoesRouteContainSharedPoints(route))
1745 UpdateWptListCtrlViz();
1751 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1752 wxLIST_STATE_DONTCARE);
1753 if (item == -1)
break;
1755 Route *pR = (
Route *)m_pRouteListCtrl->GetItemData(item);
1757 if (!pR->IsVisible()) {
1762 m_cbShowAllRte->SetValue(viz);
1764 ::wxEndBusyCursor();
1771void RouteManagerDialog::OnRteBtnLeftDown(wxMouseEvent &event) {
1772 m_bCtrlDown =
event.ControlDown();
1776void RouteManagerDialog::OnRteSelected(wxListEvent &event) {
1777 long clicked_index =
event.m_itemIndex;
1779 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(clicked_index);
1781 m_pRouteListCtrl->SetItemImage(clicked_index, route->IsVisible() ? 0 : 1);
1784 gFrame->RefreshAllCanvas();
1789void RouteManagerDialog::OnRteColumnClicked(wxListEvent &event) {
1790 if (event.m_col == 1) {
1791 sort_route_name_dir++;
1793 m_pRouteListCtrl->SortItems(SortRoutesOnName, (wxIntPtr)NULL);
1794 }
else if (event.m_col == 2) {
1795 sort_route_to_dir++;
1796 m_pRouteListCtrl->SortItems(SortRoutesOnTo, (wxIntPtr)NULL);
1800void RouteManagerDialog::OnRteSendToGPSClick(wxCommandEvent &event) {
1802 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1803 wxLIST_STATE_SELECTED);
1804 if (item == -1)
return;
1806 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1811 pdlg->SetRoute(route);
1817 pdlg->Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), source);
1820 HideWithEffect(wxSHOW_EFFECT_BLEND);
1826 ShowWithEffect(wxSHOW_EFFECT_BLEND);
1832void RouteManagerDialog::OnRteDefaultAction(wxListEvent &event) {
1834 OnRtePropertiesClick(evt);
1837void RouteManagerDialog::OnTrkDefaultAction(wxListEvent &event) {
1839 OnTrkPropertiesClick(evt);
1842void RouteManagerDialog::OnTrkRightClick(wxListEvent &event) {
1844 wxMenuItem *mergeItem = menu.Append(TRACK_MERGE, _(
"&Merge Selected Tracks"));
1845 mergeItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() > 1);
1846 wxMenuItem *cleanItem = menu.Append(TRACK_CLEAN, _(
"Reduce Data..."));
1847 cleanItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() == 1);
1848 wxMenuItem *copyItem = menu.Append(TRACK_COPY_TEXT, _(
"&Copy as text"));
1849 copyItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() > 0);
1853static bool CompareTracks(
Track *track1,
Track *track2) {
1859void RouteManagerDialog::OnTrkMenuSelected(wxCommandEvent &event) {
1862 switch (event.GetId()) {
1864 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1865 wxLIST_STATE_SELECTED);
1866 if (item == -1)
break;
1867 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1868 if (track->IsRunning()) {
1873 const wxString choices[] = {_T(
"5.0"), _T(
"10.0"), _T(
"20.0"), _T(
"50.0"),
1876 wxSingleChoiceDialog precisionDlg(
this,
1877 _(
"Select the maximum error allowed "
1878 "(in meters)\nafter data reduction:"),
1879 _(
"Reduce Data Precision"), 5, choices);
1881 precisionDlg.ShowWindowModal();
1882 while (precisionDlg.IsShown()) {
1886 int result = precisionDlg.GetReturnCode();
1888 int result = precisionDlg.ShowModal();
1890 if (result == wxID_CANCEL)
break;
1891 double precision = 5.0;
1892 switch (precisionDlg.GetSelection()) {
1910 int pointsBefore = track->GetnPoints();
1912 int reduction = track->Simplify(precision);
1913 gFrame->Refresh(
false);
1915 reduction = 100 * reduction / pointsBefore;
1916 wxString msg = wxString::Format(
1917 _(
"The amount of data used by the track\n was reduced by %d%%."),
1919 OCPNMessageBox(
this, msg, _(
"OpenCPN info"), wxICON_INFORMATION | wxOK);
1921 UpdateTrkListCtrl();
1922 UpdateRouteListCtrl();
1927 case TRACK_COPY_TEXT: {
1930 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1931 wxLIST_STATE_SELECTED);
1932 if (item == -1)
break;
1933 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1934 csvString << track->GetName() << _T(
"\t")
1935 << wxString::Format(_T(
"%.1f"), track->Length()) << _T(
"\t")
1939 if (wxTheClipboard->Open()) {
1940 wxTextDataObject *data =
new wxTextDataObject;
1941 data->SetText(csvString);
1942 wxTheClipboard->SetData(data);
1943 wxTheClipboard->Close();
1950 Track *targetTrack = NULL;
1954 std::vector<Track *> mergeList;
1955 std::vector<Track *> deleteList;
1956 bool runningSkipped =
false;
1958 ::wxBeginBusyCursor();
1961 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1962 wxLIST_STATE_SELECTED);
1963 if (item == -1)
break;
1964 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1965 mergeList.push_back(track);
1968 if (!mergeList.size()) {
1969 ::wxEndBusyCursor();
1973 std::sort(mergeList.begin(), mergeList.end(), CompareTracks);
1975 targetTrack = mergeList[0];
1976 lastPoint = targetTrack->GetLastPoint();
1978 for (
auto const &mergeTrack : mergeList) {
1979 if (mergeTrack == *mergeList.begin())
continue;
1981 if (mergeTrack->IsRunning()) {
1982 runningSkipped =
true;
1986 for (
int i = 0; i < mergeTrack->GetnPoints(); i++) {
1987 tPoint = mergeTrack->GetPoint(i);
1988 newPoint =
new TrackPoint(tPoint->m_lat, tPoint->m_lon,
1991 targetTrack->AddPoint(newPoint);
1993 pSelect->AddSelectableTrackSegment(lastPoint->m_lat, lastPoint->m_lon,
1994 newPoint->m_lat, newPoint->m_lon,
1995 lastPoint, newPoint, targetTrack);
1997 lastPoint = newPoint;
1999 deleteList.push_back(mergeTrack);
2002 for (
auto const &deleteTrack : deleteList) {
2003 g_pAIS->DeletePersistentTrack(deleteTrack);
2004 pConfig->DeleteConfigTrack(deleteTrack);
2005 RoutemanGui(*g_pRouteMan).DeleteTrack(deleteTrack);
2011 ::wxEndBusyCursor();
2013 UpdateTrkListCtrl();
2014 UpdateRouteListCtrl();
2015 gFrame->RefreshAllCanvas();
2017 if (runningSkipped) {
2018 wxMessageDialog skipWarning(
2020 _(
"The currently running Track was not merged.\nYou can merge it "
2021 "later when it is completed."),
2022 _T(
"Warning"), wxCANCEL | wxICON_WARNING);
2023 skipWarning.ShowModal();
2031void RouteManagerDialog::UpdateTrkListCtrl() {
2035 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2037 wxUIntPtr selected_id = wxUIntPtr(0);
2038 if (item != -1) selected_id = m_pTrkListCtrl->GetItemData(item);
2041 m_pTrkListCtrl->DeleteAllItems();
2044 std::vector<Track *>::iterator it;
2047 bool bpartialViz =
false;
2049 for (
Track *trk : g_TrackList) {
2050 if (!trk->IsVisible()) bpartialViz =
true;
2052 if (!trk->IsListed())
continue;
2054 if (!trk->GetName(
true).Upper().Contains(
2055 m_tFilterTrk->GetValue().Upper())) {
2060 li.SetId(list_index);
2061 li.SetImage(trk->IsVisible() ? 0 : 1);
2065 if (g_pActiveTrack == trk) {
2066 wxFont font = *wxNORMAL_FONT;
2067 font.SetWeight(wxFONTWEIGHT_BOLD);
2070 long idx = m_pTrkListCtrl->InsertItem(li);
2072 m_pTrkListCtrl->SetItem(idx, colTRKNAME, trk->GetName(
true));
2075 m_pTrkListCtrl->SetItem(idx, colTRKDATE, trk->GetDateTime());
2078 len.Printf(wxT(
"%5.2f"), trk->Length());
2079 m_pTrkListCtrl->SetItem(idx, colTRKLENGTH, len);
2082 lic.SetId(list_index);
2084 lic.SetAlign(wxLIST_FORMAT_LEFT);
2085 m_pTrkListCtrl->SetItem(lic);
2088 lic.SetAlign(wxLIST_FORMAT_LEFT);
2089 m_pTrkListCtrl->SetItem(lic);
2094 switch (sort_track_key) {
2095 case SORT_ON_DISTANCE:
2096 m_pTrkListCtrl->SortItems(SortTracksOnDistance, (wxIntPtr)NULL);
2099 m_pTrkListCtrl->SortItems(SortTracksOnDate, (wxIntPtr)NULL);
2103 m_pTrkListCtrl->SortItems(SortTracksOnName, (wxIntPtr)NULL);
2107 m_pTrkListCtrl->SetColumnWidth(0, 4 * m_charWidth);
2112 if (selected_id != wxUIntPtr(0)) {
2113 item = m_pTrkListCtrl->FindItem(-1, selected_id);
2114 m_pTrkListCtrl->SetItemState(item,
2115 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
2116 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
2119 if ((m_lastTrkItem >= 0) && (m_pTrkListCtrl->GetItemCount()))
2120 m_pTrkListCtrl->EnsureVisible(m_lastTrkItem);
2122 m_cbShowAllTrk->SetValue(!bpartialViz);
2126void RouteManagerDialog::OnTrkSelected(wxListEvent &event) {
2130void RouteManagerDialog::OnTrkColumnClicked(wxListEvent &event) {
2131 if (event.m_col == 1) {
2132 sort_track_key = SORT_ON_NAME;
2133 sort_track_name_dir++;
2134 m_pTrkListCtrl->SortItems(SortTracksOnName, (wxIntPtr)NULL);
2135 }
else if (event.m_col == 2) {
2136 sort_track_key = SORT_ON_DISTANCE;
2137 sort_track_len_dir++;
2138 m_pTrkListCtrl->SortItems(SortTracksOnDistance, (wxIntPtr)NULL);
2139 }
else if (event.m_col == 3) {
2140 sort_track_key = SORT_ON_DATE;
2141 sort_track_date_dir++;
2142 m_pTrkListCtrl->SortItems(SortTracksOnDate, (wxIntPtr)NULL);
2146void RouteManagerDialog::UpdateTrkButtons() {
2149 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2150 int items = m_pTrkListCtrl->GetSelectedItemCount();
2152 m_lastTrkItem = item;
2154 btnTrkProperties->Enable(items == 1);
2155 btnTrkDelete->Enable(items >= 1);
2156 btnTrkExport->Enable(items >= 1);
2157 btnTrkRouteFromTrack->Enable(items == 1);
2158 btnTrkDeleteAll->Enable(m_pTrkListCtrl->GetItemCount() > 0);
2159 btnTrkSendToPeer->Enable(items >= 1);
2162void RouteManagerDialog::OnTrkToggleVisibility(wxMouseEvent &event) {
2163 wxPoint pos =
event.GetPosition();
2165 long clicked_index = m_pTrkListCtrl->HitTest(pos, flags);
2168 if (clicked_index > -1 &&
2169 event.GetX() < m_pTrkListCtrl->GetColumnWidth(colTRKVISIBLE)) {
2171 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(clicked_index);
2173 track->SetVisible(!track->IsVisible());
2174 m_pTrkListCtrl->SetItemImage(clicked_index, track->IsVisible() ? 0 : 1);
2181 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2182 wxLIST_STATE_DONTCARE);
2183 if (item == -1)
break;
2185 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2187 if (!track->IsVisible()) {
2192 m_cbShowAllTrk->SetValue(viz);
2194 gFrame->RefreshAllCanvas();
2201void RouteManagerDialog::OnTrkNewClick(wxCommandEvent &event) {
2203 if (pConfig && pConfig->IsChangesFileDirty()) {
2204 pConfig->UpdateNavObj(
true);
2209 UpdateTrkListCtrl();
2212void RouteManagerDialog::OnTrkPropertiesClick(wxCommandEvent &event) {
2216 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2217 if (item == -1)
return;
2219 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2223 pTrackPropDialog = TrackPropDlg::getInstance(GetParent());
2224 pTrackPropDialog->SetTrackAndUpdate(track);
2226 if (!pTrackPropDialog->IsShown()) pTrackPropDialog->Show();
2227 UpdateTrkListCtrl();
2229 m_bNeedConfigFlush =
true;
2232void RouteManagerDialog::OnTrkDeleteClick(wxCommandEvent &event) {
2233 std::vector<Track *> list;
2235 int answer = OCPNMessageBox(
2236 this, _(
"Are you sure you want to delete the selected object(s)"),
2237 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2238 if (answer != wxID_YES)
return;
2241 if (m_pTrkListCtrl->GetSelectedItemCount()) {
2242 ::wxBeginBusyCursor();
2243 m_bNeedConfigFlush =
true;
2249 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2250 wxLIST_STATE_SELECTED);
2251 if (item == -1)
break;
2253 Track *ptrack_to_delete = (
Track *)m_pTrkListCtrl->GetItemData(item);
2255 if (ptrack_to_delete) list.push_back(ptrack_to_delete);
2259 for (
unsigned int i = 0; i < list.size(); i++) {
2260 Track *track = list.at(i);
2262 g_pAIS->DeletePersistentTrack(track);
2263 pConfig->DeleteConfigTrack(track);
2270 UpdateTrkListCtrl();
2272 if (pConfig && pConfig->IsChangesFileDirty()) {
2273 pConfig->UpdateNavObj(
true);
2276 gFrame->InvalidateAllCanvasUndo();
2277 gFrame->RefreshAllCanvas();
2278 ::wxEndBusyCursor();
2282void RouteManagerDialog::OnTrkExportClick(wxCommandEvent &event) {
2283 std::vector<Track *> list;
2284 wxString suggested_name = _T(
"tracks");
2288 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2289 wxLIST_STATE_SELECTED);
2290 if (item == -1)
break;
2292 Track *ptrack_to_export = (
Track *)m_pTrkListCtrl->GetItemData(item);
2294 if (ptrack_to_export) {
2295 list.push_back(ptrack_to_export);
2296 if (ptrack_to_export->GetName() != wxEmptyString)
2297 suggested_name = ptrack_to_export->GetName();
2301 ExportGPXTracks(
this, &list, suggested_name);
2304void RouteManagerDialog::TrackToRoute(
Track *track) {
2306 if (track->m_bIsInLayer)
return;
2308 wxGenericProgressDialog pprog(_(
"OpenCPN Converting Track to Route...."),
2309 _(
"Processing Waypoints..."), 101, NULL,
2310 wxPD_AUTO_HIDE | wxPD_SMOOTH |
2311 wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
2312 wxPD_REMAINING_TIME);
2314 ::wxBeginBusyCursor();
2316 Route *route = track->RouteFromTrack(&pprog);
2318 pRouteList->Append(route);
2320 pprog.Update(101, _(
"Done."));
2322 gFrame->RefreshAllCanvas();
2324 ::wxEndBusyCursor();
2327void RouteManagerDialog::OnTrkRouteFromTrackClick(wxCommandEvent &event) {
2330 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2331 if (item == -1)
return;
2333 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2335 TrackToRoute(track);
2337 UpdateRouteListCtrl();
2340void RouteManagerDialog::OnTrkDeleteAllClick(wxCommandEvent &event) {
2342 OCPNMessageBox(
this, _(
"Are you sure you want to delete <ALL> tracks?"),
2343 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2345 if (dialog_ret == wxID_YES) {
2352 UpdateTrkListCtrl();
2356 UpdateRouteListCtrl();
2358 if (pRoutePropDialog) pRoutePropDialog->Hide();
2360 gFrame->RefreshAllCanvas();
2362 m_bNeedConfigFlush =
true;
2365void RouteManagerDialog::UpdateWptListCtrl(
RoutePoint *rp_select,
2366 bool b_retain_sort) {
2367 wxIntPtr selected_id = wxUIntPtr(0);
2370 if (NULL == rp_select) {
2372 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2373 wxLIST_STATE_SELECTED);
2375 if (item != -1) selected_id = m_pWptListCtrl->GetItemData(item);
2379 m_pWptListCtrl->SetImageList(
2380 pWayPointMan->Getpmarkicon_image_list(m_listIconSize),
2381 wxIMAGE_LIST_SMALL);
2383 m_pWptListCtrl->DeleteAllItems();
2385 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
2388 bool b_anyHidden =
false;
2391 if (rp && rp->IsListed()) {
2392 if (rp->m_bIsInRoute && !rp->IsShared()) {
2393 node = node->GetNext();
2397 if (!rp->GetName().Upper().Contains(m_tFilterWpt->GetValue().Upper())) {
2398 node = node->GetNext();
2407 long idx = m_pWptListCtrl->InsertItem(li);
2409 wxString scamin = wxString::Format(_T(
"%i"), (
int)rp->GetScaMin());
2410 if (!rp->GetUseSca()) scamin = _(
"Always");
2411 if (g_bOverruleScaMin) scamin = _(
"Overruled");
2412 m_pWptListCtrl->SetItem(idx, colWPTSCALE, scamin);
2414 wxString name = rp->GetName();
2415 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
2416 m_pWptListCtrl->SetItem(idx, colWPTNAME, name);
2419 DistanceBearingMercator(rp->m_lat, rp->m_lon, gLat, gLon, NULL, &dst);
2421 dist.Printf(_T(
"%5.2f ") + getUsrDistanceUnit(), toUsrDistance(dst));
2422 m_pWptListCtrl->SetItem(idx, colWPTDIST, dist);
2424 if (rp == rp_select) selected_id = (wxIntPtr)rp_select;
2429 lic.SetAlign(wxLIST_FORMAT_LEFT);
2430 m_pWptListCtrl->SetItem(lic);
2433 lic.SetAlign(wxLIST_FORMAT_LEFT);
2434 m_pWptListCtrl->SetItem(lic);
2436 if (!rp->IsVisible()) b_anyHidden =
true;
2441 node = node->GetNext();
2444 if (!b_retain_sort) {
2445 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2446 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2447 sort_wp_key = SORT_ON_NAME;
2449 switch (sort_wp_key) {
2451 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2452 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2454 case SORT_ON_DISTANCE:
2455 m_pWptListCtrl->SortItems(SortWaypointsOnDistance,
2456 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2461 if (selected_id != wxUIntPtr(0)) {
2462 item = m_pWptListCtrl->FindItem(-1, selected_id);
2463 m_pWptListCtrl->SetItemState(item,
2464 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
2465 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
2468 if ((m_lastWptItem >= 0) && (m_pWptListCtrl->GetItemCount()))
2469 m_pWptListCtrl->EnsureVisible(m_lastWptItem);
2471 if (pWayPointMan->Getpmarkicon_image_list(m_listIconSize)->GetImageCount()) {
2472 int iwidth, iheight;
2473 pWayPointMan->Getpmarkicon_image_list(m_listIconSize)
2474 ->GetSize(0, iwidth, iheight);
2476 m_pWptListCtrl->SetColumnWidth(0, wxMax(iwidth + 4, 4 * m_charWidth));
2481 m_cbShowAllWP->SetValue(!b_anyHidden);
2484void RouteManagerDialog::UpdateWptListCtrlViz() {
2487 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2488 wxLIST_STATE_DONTCARE);
2489 if (item == -1)
break;
2494 m_pWptListCtrl->SetItemImage(item, imageIndex);
2498void RouteManagerDialog::OnWptDefaultAction(wxListEvent &event) {
2500 OnWptPropertiesClick(evt);
2503void RouteManagerDialog::OnWptSelected(wxListEvent &event) {
2507void RouteManagerDialog::OnWptColumnClicked(wxListEvent &event) {
2508 if (event.m_col == NAME_COLUMN) {
2510 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2511 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2512 sort_wp_key = SORT_ON_NAME;
2514 if (event.m_col == DISTANCE_COLUMN) {
2516 m_pWptListCtrl->SortItems(SortWaypointsOnDistance,
2517 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2518 sort_wp_key = SORT_ON_DISTANCE;
2521 UpdateWptListCtrl();
2524void RouteManagerDialog::UpdateWptButtons() {
2527 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2528 bool enable1 = (m_pWptListCtrl->GetSelectedItemCount() == 1);
2529 bool enablemultiple = (m_pWptListCtrl->GetSelectedItemCount() >= 1);
2532 m_lastWptItem = item;
2538 bool b_delete_enable =
true;
2541 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2542 wxLIST_STATE_SELECTED);
2543 if (item == -1)
break;
2547 if (wp && wp->m_bIsInLayer) {
2548 b_delete_enable =
false;
2553 btnWptProperties->Enable(enablemultiple);
2554 btnWptZoomto->Enable(enable1);
2555 btnWptDeleteAll->Enable(m_pWptListCtrl->GetItemCount() > 0);
2556 btnWptDelete->Enable(b_delete_enable && enablemultiple);
2557 btnWptGoTo->Enable(enable1);
2558 btnWptExport->Enable(enablemultiple);
2559 btnWptSendToGPS->Enable(enable1);
2560 btnWptSendToPeer->Enable(enablemultiple);
2563void RouteManagerDialog::OnWptToggleVisibility(wxMouseEvent &event) {
2564 wxPoint pos =
event.GetPosition();
2566 long clicked_index = m_pWptListCtrl->HitTest(pos, flags);
2569 if (clicked_index > -1 &&
2570 event.GetX() < m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE)) {
2574 if (!wp->IsSharedInVisibleRoute()) {
2575 wp->SetVisible(!wp->IsVisible());
2576 m_pWptListCtrl->SetItemImage(clicked_index,
2579 pConfig->UpdateWayPoint(wp);
2586 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2587 wxLIST_STATE_DONTCARE);
2588 if (item == -1)
break;
2592 if (!wp->IsVisible()) {
2597 m_cbShowAllWP->SetValue(viz);
2599 gFrame->RefreshAllCanvas();
2601 if (clicked_index > -1 &&
2602 event.GetX() > m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE) &&
2603 event.GetX() < (m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE) +
2604 m_pWptListCtrl->GetColumnWidth(colWPTSCALE)) &&
2605 !g_bOverruleScaMin) {
2607 wp->SetUseSca(!wp->GetUseSca());
2608 pConfig->UpdateWayPoint(wp);
2609 gFrame->RefreshAllCanvas();
2610 wxString scamin = wxString::Format(_T(
"%i"), (
int)wp->GetScaMin());
2611 if (!wp->GetUseSca()) scamin = _(
"Always");
2612 m_pWptListCtrl->SetItem(clicked_index, colWPTSCALE, scamin);
2619void RouteManagerDialog::OnWptNewClick(wxCommandEvent &event) {
2623 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP);
2624 pConfig->AddNewWayPoint(pWP, -1);
2625 gFrame->RefreshAllCanvas();
2629 if (!g_pMarkInfoDialog) g_pMarkInfoDialog =
new MarkInfoDlg(GetParent());
2631 WptShowPropertiesDialog(pWP, GetParent());
2634void RouteManagerDialog::OnWptPropertiesClick(wxCommandEvent &event) {
2635 long item = wxNOT_FOUND;
2637 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2638 if (item == wxNOT_FOUND)
return;
2640 auto pWP = (
RoutePoint *)m_pWptListCtrl->GetItemData(item);
2641 WptShowPropertiesDialog(pWP, GetParent());
2643 UpdateWptListCtrl();
2644 m_bNeedConfigFlush =
true;
2647void RouteManagerDialog::WptShowPropertiesDialog(
RoutePoint *pWP,
2649 if (!g_pMarkInfoDialog)
2653 g_pMarkInfoDialog->SetRoutePoint(pWP);
2654 g_pMarkInfoDialog->UpdateProperties();
2656 wxString base_title = _(
"Waypoint Properties");
2658 if (pWP->m_bIsInLayer) {
2659 wxString caption(wxString::Format(_T(
"%s, %s: %s"), base_title, _(
"Layer"),
2660 GetLayerName(pWP->m_LayerID)));
2661 g_pMarkInfoDialog->SetDialogTitle(caption);
2663 g_pMarkInfoDialog->SetDialogTitle(base_title);
2666 if (!g_pMarkInfoDialog->IsShown()) g_pMarkInfoDialog->Show();
2667 g_pMarkInfoDialog->Raise();
2670void RouteManagerDialog::OnWptZoomtoClick(wxCommandEvent &event) {
2673 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2674 if (item == -1)
return;
2680 if (gFrame->GetFocusCanvas()) {
2681 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), wp->m_lat, wp->m_lon,
2682 gFrame->GetFocusCanvas()->GetVPScale());
2686void RouteManagerDialog::OnWptDeleteClick(wxCommandEvent &event) {
2687 RoutePointList list;
2689 int answer = OCPNMessageBox(
2690 this, _(
"Are you sure you want to delete the selected object(s)"),
2691 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2692 if (answer != wxID_YES)
return;
2695 if (m_pWptListCtrl->GetSelectedItemCount()) {
2696 ::wxBeginBusyCursor();
2697 m_bNeedConfigFlush =
true;
2702 long item_last_selected = -1;
2704 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2705 wxLIST_STATE_SELECTED);
2706 if (item == -1)
break;
2708 item_last_selected = item;
2711 if (wp && !wp->m_bIsInLayer) list.Append(wp);
2715 for (
unsigned int i = 0; i < list.GetCount(); i++) {
2718 if (wp->m_bIsInRoute) {
2720 OCPNMessageBox(
this,
2721 _(
"The waypoint you want to delete is used in a "
2722 "route, do you really want to delete it?"),
2723 _(
"OpenCPN Alert"), wxYES_NO))
2724 pWayPointMan->DestroyWaypoint(wp);
2726 pWayPointMan->DestroyWaypoint(wp);
2731 m_pWptListCtrl->GetNextItem(item_last_selected);
2734 wp_next = (
RoutePoint *)m_pWptListCtrl->GetItemData(item_next);
2736 m_lastWptItem = item_next;
2738 UpdateRouteListCtrl();
2739 UpdateTrkListCtrl();
2740 UpdateWptListCtrl(wp_next,
true);
2742 if (g_pMarkInfoDialog) {
2743 g_pMarkInfoDialog->ClearData();
2746 gFrame->InvalidateAllCanvasUndo();
2747 gFrame->RefreshAllCanvas();
2748 ::wxEndBusyCursor();
2752void RouteManagerDialog::OnWptGoToClick(wxCommandEvent &event) {
2755 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2756 if (item == -1)
return;
2763 wxEmptyString, wxEmptyString);
2764 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
2767 pRouteList->Append(temp_route);
2769 temp_route->AddPoint(pWP_src);
2770 temp_route->AddPoint(wp);
2772 pSelect->AddSelectableRouteSegment(gLat, gLon, wp->m_lat, wp->m_lon, pWP_src,
2775 wxString name = wp->GetName();
2776 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
2777 wxString rteName = _(
"Go to ");
2778 rteName.Append(name);
2785 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
2789 UpdateRouteListCtrl();
2792void RouteManagerDialog::OnWptExportClick(wxCommandEvent &event) {
2793 RoutePointList list;
2795 wxString suggested_name = _T(
"waypoints");
2799 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2800 wxLIST_STATE_SELECTED);
2801 if (item == -1)
break;
2805 if (wp && !wp->m_bIsInLayer) {
2807 if (wp->GetName() != wxEmptyString) suggested_name = wp->GetName();
2811 ExportGPXWaypoints(
this, &list, suggested_name);
2814void RouteManagerDialog::OnWptSendToGPSClick(wxCommandEvent &event) {
2817 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2818 if (item == -1)
return;
2825 pdlg->SetWaypoint(wp);
2828 pdlg->Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), source);
2831 HideWithEffect(wxSHOW_EFFECT_BLEND);
2835 ShowWithEffect(wxSHOW_EFFECT_BLEND);
2841void RouteManagerDialog::OnWptDeleteAllClick(wxCommandEvent &event) {
2844 if (!pWayPointMan->SharedWptsExist()) {
2845 prompt = _(
"Are you sure you want to delete <ALL> waypoints?");
2850 _(
"There are some waypoints used in routes or anchor alarms.\n Do you "
2851 "want to delete them as well?\n This will change the routes and "
2852 "disable the anchor alarms.\n Answering No keeps the waypoints used "
2853 "in routes or alarms.");
2854 buttons = wxYES_NO | wxCANCEL;
2858 OCPNMessageBox(
this, prompt, wxString(_(
"OpenCPN Alert")), buttons);
2859 if (answer == wxID_YES) pWayPointMan->DeleteAllWaypoints(
true);
2860 if (answer == wxID_NO && type == 2)
2861 pWayPointMan->DeleteAllWaypoints(
false);
2863 if (g_pMarkInfoDialog) {
2864 g_pMarkInfoDialog->ClearData();
2868 UpdateRouteListCtrl();
2869 UpdateWptListCtrl();
2870 gFrame->InvalidateAllCanvasUndo();
2871 gFrame->RefreshAllCanvas();
2874void RouteManagerDialog::OnLaySelected(wxListEvent &event) {
2878void RouteManagerDialog::OnLayColumnClicked(wxListEvent &event) {
2879 if (event.m_col == 1) {
2880 sort_layer_name_dir++;
2881 m_pLayListCtrl->SortItems(SortLayersOnName, (wxIntPtr)NULL);
2882 }
else if (event.m_col == 2) {
2883 sort_layer_len_dir++;
2884 m_pLayListCtrl->SortItems(SortLayersOnSize, (wxIntPtr)NULL);
2888void RouteManagerDialog::UpdateLayButtons() {
2891 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2892 bool enable = (item != -1);
2895 btnLayDelete->Enable(enable);
2896 cbLayToggleChart->Enable(enable);
2897 cbLayToggleListing->Enable(enable);
2898 cbLayToggleNames->Enable(enable);
2901 cbLayToggleChart->SetValue(
2902 ((
Layer *)m_pLayListCtrl->GetItemData(item))->IsVisibleOnChart());
2904 cbLayToggleNames->Set3StateValue(
2905 ((
Layer *)m_pLayListCtrl->GetItemData(item))->HasVisibleNames());
2907 cbLayToggleListing->SetValue(
2908 ((
Layer *)m_pLayListCtrl->GetItemData(item))->IsVisibleOnListing());
2911 cbLayToggleChart->SetValue(
true);
2912 cbLayToggleNames->Set3StateValue(wxCHK_UNDETERMINED);
2913 cbLayToggleListing->SetValue(
true);
2917void RouteManagerDialog::OnLayToggleVisibility(wxMouseEvent &event) {
2918 wxPoint pos =
event.GetPosition();
2920 long clicked_index = m_pLayListCtrl->HitTest(pos, flags);
2923 if (clicked_index > -1 &&
2924 event.GetX() < m_pLayListCtrl->GetColumnWidth(colLAYVISIBLE)) {
2926 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(clicked_index);
2928 layer->SetVisibleOnChart(!layer->IsVisibleOnChart());
2929 m_pLayListCtrl->SetItemImage(clicked_index,
2930 layer->IsVisibleOnChart() ? 0 : 1);
2936 item = m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2937 wxLIST_STATE_DONTCARE);
2938 if (item == -1)
break;
2940 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
2942 if (!layer->IsVisibleOnChart()) {
2947 m_cbShowAllLay->SetValue(viz);
2949 ToggleLayerContentsOnChart(layer);
2956void RouteManagerDialog::UpdateLists() {
2957 UpdateRouteListCtrl();
2958 UpdateTrkListCtrl();
2959 UpdateWptListCtrl();
2960 UpdateLayListCtrl();
2963void RouteManagerDialog::OnLayNewClick(wxCommandEvent &event) {
2967void RouteManagerDialog::OnPerLayNewClick(wxCommandEvent &event) {
2971void RouteManagerDialog::AddNewLayer(
bool isPersistent) {
2972 bool show_flag = g_bShowLayers;
2973 g_bShowLayers =
true;
2975 UI_ImportGPX(
this,
true, _T(
""),
true, isPersistent);
2977 g_bShowLayers = show_flag;
2979 gFrame->RefreshAllCanvas();
2982void RouteManagerDialog::OnLayPropertiesClick(wxCommandEvent &event) {
2986 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2987 if (item == -1)
return;
2990void RouteManagerDialog::OnLayDeleteClick(wxCommandEvent &event) {
2993 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2994 if (item == -1)
return;
2996 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3002 bool ispers =
false;
3003 wxString destf, f, name, ext;
3004 f = layer->m_LayerFileName;
3005 wxFileName::SplitPath(f, NULL, NULL, &name, &ext);
3007 appendOSDirSlash(&destf);
3008 destf.Append(_T(
"layers"));
3009 appendOSDirSlash(&destf);
3010 destf << name << _T(
".") << ext;
3012 wxString prompt = _(
3013 "Are you sure you want to delete this layer and <ALL> of its contents?");
3014 if (wxFileExists(destf)) {
3015 prompt.Append(_T(
"\n"));
3017 _(
"The file will also be deleted from OpenCPN's layer directory."));
3018 prompt.Append(_T(
"\n (") + destf + _T(
")" ));
3022 OCPNMessageBox(
this, prompt, wxString(_(
"OpenCPN Alert")), wxYES_NO);
3023 if (answer == wxID_NO)
return;
3028 if (wxRemoveFile(destf))
3029 remMSG.sprintf(_T(
"Layer file: %s is deleted"), destf);
3031 remMSG.sprintf(_T(
"Error deleting Layer file: %s"), destf);
3033 wxLogMessage(remMSG);
3037 wxRouteListNode *node1 = pRouteList->GetFirst();
3039 Route *pRoute = node1->GetData();
3040 wxRouteListNode *next_node = node1->GetNext();
3044 g_pRouteMan->
DeleteRoute(pRoute, NavObjectChanges::getInstance());
3049 for (
Track *pTrack : g_TrackList) {
3050 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID)) {
3051 pTrack->m_bIsInLayer =
false;
3052 pTrack->m_LayerID = 0;
3058 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3059 wxRoutePointListNode *node3;
3062 node3 = node->GetNext();
3064 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3065 rp->m_bIsInLayer =
false;
3067 pWayPointMan->DestroyWaypoint(
3075 if (g_pMarkInfoDialog) {
3076 g_pMarkInfoDialog->ClearData();
3079 pLayerList->DeleteObject(layer);
3083 gFrame->RefreshAllCanvas();
3085 m_bNeedConfigFlush =
false;
3088void RouteManagerDialog::OnLayToggleChartClick(wxCommandEvent &event) {
3092 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3093 if (item == -1)
return;
3095 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3099 layer->SetVisibleOnChart(!layer->IsVisibleOnChart());
3100 m_pLayListCtrl->SetItemImage(item, layer->IsVisibleOnChart() ? 0 : 1);
3102 ToggleLayerContentsOnChart(layer);
3105void RouteManagerDialog::ToggleLayerContentsOnChart(
Layer *layer) {
3107 wxRouteListNode *node1 = pRouteList->GetFirst();
3109 Route *pRoute = node1->GetData();
3111 pRoute->SetVisible(layer->IsVisibleOnChart());
3113 node1 = node1->GetNext();
3116 for (
Track *pTrack : g_TrackList) {
3117 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID))
3118 pTrack->SetVisible(layer->IsVisibleOnChart());
3122 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3126 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3127 rp->SetVisible(layer->IsVisibleOnChart());
3130 node = node->GetNext();
3136 gFrame->RefreshAllCanvas();
3139void RouteManagerDialog::OnLayToggleNamesClick(wxCommandEvent &event) {
3143 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3144 if (item == -1)
return;
3146 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3150 layer->SetVisibleNames(cbLayToggleNames->Get3StateValue());
3152 ToggleLayerContentsNames(layer);
3155void RouteManagerDialog::ToggleLayerContentsNames(
Layer *layer) {
3157 wxRouteListNode *node1 = pRouteList->GetFirst();
3159 Route *pRoute = node1->GetData();
3164 if (layer->HasVisibleNames() == wxCHK_UNDETERMINED) {
3165 prp1->m_bShowName = prp1->m_bShowNameData;
3167 prp1->m_bShowName = (layer->HasVisibleNames() == wxCHK_CHECKED);
3169 node = node->GetNext();
3172 node1 = node1->GetNext();
3176 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3180 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3181 rp->SetNameShown(layer->HasVisibleNames() == wxCHK_CHECKED ||
3182 (rp->m_bShowNameData &&
3183 layer->HasVisibleNames() == wxCHK_UNDETERMINED));
3186 node = node->GetNext();
3191 gFrame->RefreshAllCanvas();
3194void RouteManagerDialog::OnLayToggleListingClick(wxCommandEvent &event) {
3198 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3199 if (item == -1)
return;
3201 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3205 layer->SetVisibleOnListing(!layer->IsVisibleOnListing());
3207 ToggleLayerContentsOnListing(layer);
3210void RouteManagerDialog::ToggleLayerContentsOnListing(
Layer *layer) {
3211 ::wxBeginBusyCursor();
3214 wxRouteListNode *node1 = pRouteList->GetFirst();
3216 Route *pRoute = node1->GetData();
3218 pRoute->SetListed(layer->IsVisibleOnListing());
3220 node1 = node1->GetNext();
3223 for (
Track *pTrack : g_TrackList) {
3224 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID))
3225 pTrack->SetListed(layer->IsVisibleOnListing());
3232 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3236 if (rp && rp->
m_bIsolatedMark && (rp->m_LayerID == layer->m_LayerID)) {
3237 rp->SetListed(layer->IsVisibleOnListing());
3240 node = node->GetNext();
3245 ::wxEndBusyCursor();
3247 gFrame->RefreshAllCanvas();
3250void RouteManagerDialog::OnLayDefaultAction(wxListEvent &event) {
3252 OnLayPropertiesClick(evt);
3255void RouteManagerDialog::UpdateLayListCtrl() {
3259 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3261 wxUIntPtr selected_id = wxUIntPtr(0);
3262 if (item != -1) selected_id = m_pLayListCtrl->GetItemData(item);
3265 m_pLayListCtrl->DeleteAllItems();
3268 LayerList::iterator it;
3270 bool b_anyHidden =
false;
3271 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
3274 if (!lay->m_LayerName.Upper().Contains(m_tFilterLay->GetValue().Upper())) {
3280 li.SetImage(lay->IsVisibleOnChart() ? 0 : 1);
3284 long idx = m_pLayListCtrl->InsertItem(li);
3286 wxString name = lay->m_LayerName;
3287 if (name.IsEmpty()) {
3294 name = _(
"(Unnamed Layer)");
3296 m_pLayListCtrl->SetItem(idx, colLAYNAME, name);
3299 len.Printf(wxT(
"%d"), (
int)lay->m_NoOfItems);
3300 m_pLayListCtrl->SetItem(idx, colLAYITEMS, len);
3301 m_pLayListCtrl->SetItem(idx, colLAYPERSIST, lay->m_LayerType);
3306 lic.SetAlign(wxLIST_FORMAT_LEFT);
3307 m_pLayListCtrl->SetItem(lic);
3310 lic.SetAlign(wxLIST_FORMAT_LEFT);
3311 m_pLayListCtrl->SetItem(lic);
3313 if (!lay->IsVisibleOnChart()) b_anyHidden =
true;
3316 m_pLayListCtrl->SortItems(SortLayersOnName,
3317 reinterpret_cast<wxIntPtr
>(m_pLayListCtrl));
3318 m_pLayListCtrl->SetColumnWidth(0, 4 * m_charWidth);
3323 if (selected_id != wxUIntPtr(0)) {
3324 item = m_pLayListCtrl->FindItem(-1, selected_id);
3325 m_pLayListCtrl->SetItemState(item,
3326 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
3327 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
3331 m_cbShowAllLay->SetValue(!b_anyHidden);
3334void RouteManagerDialog::OnImportClick(wxCommandEvent &event) {
3343 gFrame->RefreshAllCanvas();
3345void RouteManagerDialog::OnExportClick(wxCommandEvent &event) {
3349void RouteManagerDialog::OnExportVizClick(wxCommandEvent &event) {
3350 ExportGPX(
this,
true,
true);
3353void RouteManagerDialog::OnFilterChanged(wxCommandEvent &event) {
3354 if (event.GetEventObject() == m_tFilterWpt) {
3355 UpdateWptListCtrl(NULL,
true);
3356 }
else if (event.GetEventObject() == m_tFilterRte) {
3357 UpdateRouteListCtrl();
3358 }
else if (event.GetEventObject() == m_tFilterTrk) {
3359 UpdateTrkListCtrl();
3360 }
else if (event.GetEventObject() == m_tFilterLay) {
3361 UpdateLayListCtrl();
Represents an active track that is currently being recorded.
Represents a layer of chart objects in OpenCPN.
Dialog for displaying and editing waypoint properties.
void Validate()
Check that all entries are accessible, remove stale ones.
void Init(const KeyProvider &kp, std::function< void(ObservedEvt &ev)> action)
Initiate an object yet not listening.
Represents a waypoint or mark within the navigation system.
bool m_bIsolatedMark
Flag indicating if the waypoint is a standalone mark.
Represents a navigational route in the navigation system.
wxString m_RouteStartString
Name or description of the route's starting point.
RoutePointList * pRoutePointList
Ordered list of waypoints (RoutePoints) that make up this route.
bool m_bRtIsActive
Flag indicating whether this route is currently active for navigation.
bool m_bDeleteOnArrival
Flag indicating whether the route should be deleted once navigation reaches the end.
wxString m_RouteEndString
Name or description of the route's ending point.
wxString m_RouteNameString
User-assigned name for the route.
bool m_bIsInLayer
Flag indicating whether this route belongs to a layer.
int m_LayerID
Identifier of the layer containing this route.
EventVar on_routes_update
Notified when list of routes is updated (no data in event)
bool DeleteRoute(Route *pRoute, NavObjectChanges *nav_obj_changes)
bool ActivateRoute(Route *pRouteToActivate, RoutePoint *pStartPoint=NULL)
Activates a route for navigation.
Dialog for sending routes/waypoints to a GPS device.
Dialog for sending navigation objects to peer devices.
Represents a single point in a track.
wxDateTime GetCreateTime(void)
Retrieves the creation timestamp of a track point as a wxDateTime object.
Represents a track, which is a series of connected track points.
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
wxFont GetOCPNGUIScaledFont(wxString item)
Retrieves a font optimized for touch and high-resolution interfaces.
MdnsCache mDNS host lookups cache.