23 #include "routemanagerdialog.h"
26 #include <wx/wxprec.h>
32 #include <wx/filename.h>
33 #include <wx/stdpaths.h>
34 #include <wx/progdlg.h>
35 #include <wx/clipbrd.h>
36 #include <wx/statline.h>
42 #include "model/ais_decoder.h"
43 #include "model/config_vars.h"
44 #include "model/georef.h"
45 #include "model/mdns_cache.h"
46 #include "model/mDNS_query.h"
47 #include "model/navutil_base.h"
48 #include "model/own_ship.h"
49 #include "model/route.h"
50 #include "model/routeman.h"
51 #include "model/select.h"
52 #include "model/track.h"
54 #include "chartbase.h"
60 #include "ocpn_frame.h"
61 #include "OCPNPlatform.h"
62 #include "routeman_gui.h"
63 #include "route_point_gui.h"
64 #include "RoutePropDlgImpl.h"
65 #include "SendToGpsDlg.h"
66 #include "SendToPeerDlg.h"
68 #include "svg_utils.h"
69 #include "TrackPropDlg.h"
72 #include "androidUTIL.h"
75 #define DIALOG_MARGIN 10
77 enum { rmVISIBLE = 0, rmROUTENAME, rmROUTEDESC };
78 enum { colTRKVISIBLE = 0, colTRKNAME, colTRKLENGTH, colTRKDATE };
79 enum { colLAYVISIBLE = 0, colLAYNAME, colLAYITEMS, colLAYPERSIST };
80 enum { colWPTICON = 0, colWPTSCALE, colWPTNAME, colWPTDIST };
83 extern RouteList *pRouteList;
84 extern std::vector<Track*> g_TrackList;
85 extern LayerList *pLayerList;
86 extern wxString GetLayerName(
int id);
94 extern bool g_bShowLayers;
95 extern wxString g_default_wp_icon;
99 void appendOSDirSlash(wxString *pString);
101 static int SortRouteTrack(
const int order,
const wxString &it1,
102 const wxString &it2) {
103 if (order & 1)
return it2.CmpNoCase(it1);
105 return it1.CmpNoCase(it2);
109 static int sort_route_name_dir;
110 #if wxCHECK_VERSION(2, 9, 0)
111 static int wxCALLBACK SortRoutesOnName(wxIntPtr item1, wxIntPtr item2,
114 int wxCALLBACK SortRoutesOnName(
long item1,
long item2,
long list)
117 return SortRouteTrack(sort_route_name_dir, ((
Route *)item1)->GetName(),
118 ((
Route *)item2)->GetName());
122 static int sort_route_to_dir;
123 #if wxCHECK_VERSION(2, 9, 0)
124 static int wxCALLBACK SortRoutesOnTo(wxIntPtr item1, wxIntPtr item2,
127 int wxCALLBACK SortRoutesOnTo(
long item1,
long item2,
long list)
130 return SortRouteTrack(sort_route_to_dir, ((
Route *)item1)->GetTo(),
131 ((
Route *)item2)->GetTo());
135 static int sort_track_name_dir;
136 #if wxCHECK_VERSION(2, 9, 0)
137 static int wxCALLBACK SortTracksOnName(wxIntPtr item1, wxIntPtr item2,
140 int wxCALLBACK SortTracksOnName(
long item1,
long item2,
long list)
143 return SortRouteTrack(sort_track_name_dir, ((
Track *)item1)->GetName(),
144 ((
Track *)item2)->GetName());
147 static int SortDouble(
const int order,
const double &it1,
const double &it2) {
159 if (l1 == l2)
return 0;
160 if (l2 < l1)
return 1;
165 static int sort_track_len_dir;
166 #if wxCHECK_VERSION(2, 9, 0)
167 static int wxCALLBACK SortTracksOnDistance(wxIntPtr item1, wxIntPtr item2,
170 int wxCALLBACK SortTracksOnDistance(
long item1,
long item2,
long list)
173 return SortDouble(sort_track_len_dir, ((
Track *)item1)->Length(),
174 ((
Track *)item2)->Length());
178 static int sort_track_date_dir;
179 #if wxCHECK_VERSION(2, 9, 0)
180 static int wxCALLBACK SortTracksOnDate(wxIntPtr item1, wxIntPtr item2,
183 int wxCALLBACK SortTracksOnDate(
long item1,
long item2,
long list)
186 return SortRouteTrack(sort_track_date_dir, ((
Track *)item1)->GetDate(),
187 ((
Track *)item2)->GetDate());
190 static int sort_wp_key;
191 static int sort_track_key;
194 static int sort_wp_name_dir;
195 #if wxCHECK_VERSION(2, 9, 0)
196 static int wxCALLBACK SortWaypointsOnName(wxIntPtr item1, wxIntPtr item2,
199 int wxCALLBACK SortWaypointsOnName(
long item1,
long item2,
long list)
207 if (sort_wp_name_dir & 1)
208 return pRP2->GetName().CmpNoCase(pRP1->GetName());
210 return pRP1->GetName().CmpNoCase(pRP2->GetName());
216 static int sort_wp_len_dir;
217 #if wxCHECK_VERSION(2, 9, 0)
218 static int wxCALLBACK SortWaypointsOnDistance(wxIntPtr item1, wxIntPtr item2,
221 int wxCALLBACK SortWaypointsOnDistance(
long item1,
long item2,
long list)
225 DistanceBearingMercator(((
RoutePoint *)item1)->m_lat,
226 ((
RoutePoint *)item1)->m_lon, gLat, gLon, NULL,
228 DistanceBearingMercator(((
RoutePoint *)item2)->m_lat,
229 ((
RoutePoint *)item2)->m_lon, gLat, gLon, NULL,
231 return SortDouble(sort_wp_len_dir, dst1, dst2);
235 static int sort_layer_name_dir;
236 #if wxCHECK_VERSION(2, 9, 0)
237 static int wxCALLBACK SortLayersOnName(wxIntPtr item1, wxIntPtr item2,
240 int wxCALLBACK SortLayersOnName(
long item1,
long item2,
long list)
243 return SortRouteTrack(sort_layer_name_dir, ((
Layer *)item1)->m_LayerName,
244 ((
Layer *)item2)->m_LayerName);
248 static int sort_layer_len_dir;
249 #if wxCHECK_VERSION(2, 9, 0)
250 static int wxCALLBACK SortLayersOnSize(wxIntPtr item1, wxIntPtr item2,
253 int wxCALLBACK SortLayersOnSize(
long item1,
long item2,
long list)
256 return SortDouble(sort_layer_len_dir, ((
Layer *)item1)->m_NoOfItems,
257 ((
Layer *)item2)->m_NoOfItems);
264 EVT_NOTEBOOK_PAGE_CHANGED(
266 RouteManagerDialog::OnTabSwitch)
267 EVT_CLOSE(RouteManagerDialog::OnClose)
268 EVT_COMMAND(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, RouteManagerDialog::OnOK)
269 EVT_CHAR_HOOK(RouteManagerDialog::OnKey)
273 if (ke.GetKeyCode() == WXK_ESCAPE)
279 void RouteManagerDialog::OnTabSwitch(wxNotebookEvent &event) {
280 if (!m_pNotebook)
return;
281 int current_page = m_pNotebook->GetSelection();
282 if (current_page == 3) {
283 if (btnImport) btnImport->Enable(
false);
284 if (btnExport) btnExport->Enable(
false);
285 if (btnExportViz) btnExportViz->Enable(
false);
287 if (btnImport) btnImport->Enable(
true);
288 if (btnExport) btnExport->Enable(
true);
289 if (btnExportViz) btnExportViz->Enable(
true);
296 bool RouteManagerDialog::instanceFlag =
false;
309 RouteManagerDialog::RouteManagerDialog(wxWindow *parent) {
311 wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT;
313 wxFrame::Create(parent, -1, wxString(_(
"Route & Mark Manager")),
314 wxDefaultPosition, wxDefaultSize, style);
316 wxFont *qFont = GetOCPNScaledFont(_(
"Dialog"));
322 sort_wp_key = SORT_ON_NAME;
323 sort_track_key = SORT_ON_NAME;
331 [&](wxCommandEvent) { UpdateRouteListCtrl(); });
334 void RouteManagerDialog::Create() {
336 int char_width, char_height;
337 GetTextExtent(_T(
"W"), &char_width, &char_height);
338 m_charWidth = char_width;
340 wxBoxSizer *itemBoxSizer1 =
new wxBoxSizer(wxVERTICAL);
341 SetSizer(itemBoxSizer1);
343 m_pNotebook =
new wxNotebook(
this, wxID_ANY, wxDefaultPosition,
344 wxSize(-1, -1), wxNB_TOP);
345 itemBoxSizer1->Add(m_pNotebook, 1, wxALL | wxEXPAND, 5);
348 m_pPanelRte =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
349 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
351 wxBoxSizer *sbsRoutes =
new wxBoxSizer(wxHORIZONTAL);
352 m_pPanelRte->SetSizer(sbsRoutes);
353 m_pNotebook->AddPage(m_pPanelRte, _(
"Routes"));
356 sort_wp_name_dir = 0;
357 sort_track_len_dir = 1;
358 sort_route_to_dir = 0;
359 sort_track_name_dir = 0;
360 sort_route_name_dir = 0;
361 sort_layer_name_dir = 0;
362 sort_layer_len_dir = 1;
364 m_listIconSize = 2 * GetCharHeight();
367 wxBoxSizer *bSizerRteContents;
368 bSizerRteContents =
new wxBoxSizer(wxVERTICAL);
370 wxFlexGridSizer *fgSizerFilterRte;
371 fgSizerFilterRte =
new wxFlexGridSizer(0, 2, 0, 0);
372 fgSizerFilterRte->AddGrowableCol(1);
373 fgSizerFilterRte->SetFlexibleDirection(wxBOTH);
374 fgSizerFilterRte->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
376 m_stFilterRte =
new wxStaticText(m_pPanelRte, wxID_ANY, _(
"Filter"),
377 wxDefaultPosition, wxDefaultSize, 0);
378 m_stFilterRte->Wrap(-1);
379 fgSizerFilterRte->Add(m_stFilterRte, 0, wxALL, 5);
381 m_tFilterRte =
new wxTextCtrl(m_pPanelRte, wxID_ANY, wxEmptyString,
382 wxDefaultPosition, wxDefaultSize, 0);
383 fgSizerFilterRte->Add(m_tFilterRte, 1, wxALL | wxEXPAND, 5);
385 bSizerRteContents->Add(fgSizerFilterRte, 0, wxEXPAND, 5);
386 m_tFilterRte->Connect(
387 wxEVT_COMMAND_TEXT_UPDATED,
388 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
390 m_cbShowAllRte =
new wxCheckBox(m_pPanelRte, wxID_ANY, _(
"Show all routes"));
391 bSizerRteContents->Add(m_cbShowAllRte, 0, wxEXPAND | wxLEFT, 5);
392 m_cbShowAllRte->Connect(
393 wxEVT_COMMAND_CHECKBOX_CLICKED,
394 wxCommandEventHandler(RouteManagerDialog::OnShowAllRteCBClicked), NULL,
398 new wxListCtrl(m_pPanelRte, -1, wxDefaultPosition, wxSize(-1, -1),
399 wxLC_REPORT | wxLC_SORT_ASCENDING | wxLC_HRULES |
402 m_pRouteListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
405 m_pRouteListCtrl->Connect(
406 wxEVT_COMMAND_LIST_ITEM_SELECTED,
407 wxListEventHandler(RouteManagerDialog::OnRteSelected), NULL,
this);
408 m_pRouteListCtrl->Connect(
409 wxEVT_COMMAND_LIST_ITEM_DESELECTED,
410 wxListEventHandler(RouteManagerDialog::OnRteSelected), NULL,
this);
411 m_pRouteListCtrl->Connect(
412 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
413 wxListEventHandler(RouteManagerDialog::OnRteDefaultAction), NULL,
this);
414 m_pRouteListCtrl->Connect(
416 wxMouseEventHandler(RouteManagerDialog::OnRteToggleVisibility), NULL,
418 m_pRouteListCtrl->Connect(
419 wxEVT_COMMAND_LIST_COL_CLICK,
420 wxListEventHandler(RouteManagerDialog::OnRteColumnClicked), NULL,
this);
421 bSizerRteContents->Add(m_pRouteListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
422 sbsRoutes->Add(bSizerRteContents, 1, wxEXPAND, 5);
427 m_pRouteListCtrl->InsertColumn(rmVISIBLE, _(
"Show"), wxLIST_FORMAT_LEFT,
429 m_pRouteListCtrl->InsertColumn(rmROUTENAME, _(
"Route Name"),
430 wxLIST_FORMAT_LEFT, 15 * char_width);
431 m_pRouteListCtrl->InsertColumn(rmROUTEDESC, _(
"From <-> To"),
432 wxLIST_FORMAT_LEFT, 10 * char_width);
435 wxBoxSizer *bsRouteButtons =
new wxBoxSizer(wxVERTICAL);
436 sbsRoutes->Add(bsRouteButtons, 0, wxEXPAND);
438 wxScrolledWindow *winr =
new wxScrolledWindow(
439 m_pPanelRte, wxID_ANY, wxDefaultPosition, wxDefaultSize,
440 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
441 winr->SetScrollRate(0, 5);
443 bsRouteButtons->Add(winr, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
445 wxBoxSizer *bsRouteButtonsInner =
new wxBoxSizer(wxVERTICAL);
446 winr->SetSizer(bsRouteButtonsInner);
448 btnRteProperties =
new wxButton(winr, -1, _(
"&Properties") + _T(
"..."));
449 bsRouteButtonsInner->Add(btnRteProperties, 0, wxALL | wxEXPAND,
451 btnRteProperties->Connect(
452 wxEVT_COMMAND_BUTTON_CLICKED,
453 wxCommandEventHandler(RouteManagerDialog::OnRtePropertiesClick), NULL,
456 btnRteActivate =
new wxButton(winr, -1, _(
"&Activate"));
457 bsRouteButtonsInner->Add(btnRteActivate, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
458 btnRteActivate->Connect(
459 wxEVT_COMMAND_BUTTON_CLICKED,
460 wxCommandEventHandler(RouteManagerDialog::OnRteActivateClick), NULL,
462 btnRteActivate->Connect(
464 wxMouseEventHandler(RouteManagerDialog::OnRteBtnLeftDown), NULL,
this);
466 btnRteZoomto =
new wxButton(winr, -1, _(
"&Center View"));
467 bsRouteButtonsInner->Add(btnRteZoomto, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
468 btnRteZoomto->Connect(
469 wxEVT_COMMAND_BUTTON_CLICKED,
470 wxCommandEventHandler(RouteManagerDialog::OnRteZoomtoClick), NULL,
this);
471 btnRteZoomto->Connect(
473 wxMouseEventHandler(RouteManagerDialog::OnRteBtnLeftDown), NULL,
this);
475 btnRteReverse =
new wxButton(winr, -1, _(
"&Reverse"));
476 bsRouteButtonsInner->Add(btnRteReverse, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
477 btnRteReverse->Connect(
478 wxEVT_COMMAND_BUTTON_CLICKED,
479 wxCommandEventHandler(RouteManagerDialog::OnRteReverseClick), NULL,
this);
481 btnRteDelete =
new wxButton(winr, -1, _(
"&Delete"));
482 bsRouteButtonsInner->Add(btnRteDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
483 btnRteDelete->Connect(
484 wxEVT_COMMAND_BUTTON_CLICKED,
485 wxCommandEventHandler(RouteManagerDialog::OnRteDeleteClick), NULL,
this);
487 wxString reseq_label(_(
"&Resequence Waypoints"));
488 wxString export_label(_(
"&Export selected..."));
489 wxString send_to_gps_label(_(
"&Send to GPS..."));
490 wxString send_to_peer_label(_(
"Send to &Peer..."));
493 reseq_label = wxString(_(
"Resequence"));
494 export_label = wxString(_(
"Export"));
495 send_to_gps_label = wxString(_(
"Send to GPS"));
496 send_to_peer_label = wxString(_(
"Send to Peer"));
499 btnRteExport =
new wxButton(winr, -1, export_label);
500 bsRouteButtonsInner->Add(btnRteExport, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
501 btnRteExport->Connect(
502 wxEVT_COMMAND_BUTTON_CLICKED,
503 wxCommandEventHandler(RouteManagerDialog::OnRteExportClick), NULL,
this);
506 btnRteResequence =
new wxButton(winr, -1, reseq_label);
507 bsRouteButtonsInner->Add(btnRteResequence, 0, wxALL | wxEXPAND,
509 btnRteResequence->Connect(
510 wxEVT_COMMAND_BUTTON_CLICKED,
511 wxCommandEventHandler(RouteManagerDialog::OnRteResequenceClick), NULL,
514 btnRteSendToPeer =
new wxButton(winr, -1, send_to_peer_label);
515 bsRouteButtonsInner->Add(btnRteSendToPeer, 0, wxALL | wxEXPAND,
517 btnRteSendToPeer->Connect(
518 wxEVT_COMMAND_BUTTON_CLICKED,
519 wxCommandEventHandler(RouteManagerDialog::OnRteSendToPeerClick), NULL,
522 btnRteSendToGPS =
new wxButton(winr, -1, send_to_gps_label);
523 bsRouteButtonsInner->Add(btnRteSendToGPS, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
524 btnRteSendToGPS->Connect(
525 wxEVT_COMMAND_BUTTON_CLICKED,
526 wxCommandEventHandler(RouteManagerDialog::OnRteSendToGPSClick), NULL,
529 bsRouteButtonsInner->AddSpacer(10);
531 btnRteDeleteAll =
new wxButton(winr, -1, _(
"&Delete All"));
532 bsRouteButtonsInner->Add(btnRteDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
533 btnRteDeleteAll->Connect(
534 wxEVT_COMMAND_BUTTON_CLICKED,
535 wxCommandEventHandler(RouteManagerDialog::OnRteDeleteAllClick), NULL,
539 m_pPanelTrk =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
540 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
541 wxBoxSizer *sbsTracks =
new wxBoxSizer(wxHORIZONTAL);
542 m_pPanelTrk->SetSizer(sbsTracks);
543 m_pNotebook->AddPage(m_pPanelTrk, _(
"Tracks"));
545 wxBoxSizer *bSizerTrkContents;
546 bSizerTrkContents =
new wxBoxSizer(wxVERTICAL);
548 wxFlexGridSizer *fgSizerFilterTrk;
549 fgSizerFilterTrk =
new wxFlexGridSizer(0, 2, 0, 0);
550 fgSizerFilterTrk->AddGrowableCol(1);
551 fgSizerFilterTrk->SetFlexibleDirection(wxBOTH);
552 fgSizerFilterTrk->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
554 m_stFilterTrk =
new wxStaticText(m_pPanelTrk, wxID_ANY, _(
"Filter"),
555 wxDefaultPosition, wxDefaultSize, 0);
556 m_stFilterTrk->Wrap(-1);
557 fgSizerFilterTrk->Add(m_stFilterTrk, 0, wxALL, 5);
559 m_tFilterTrk =
new wxTextCtrl(m_pPanelTrk, wxID_ANY, wxEmptyString,
560 wxDefaultPosition, wxDefaultSize, 0);
561 fgSizerFilterTrk->Add(m_tFilterTrk, 1, wxALL | wxEXPAND, 5);
563 bSizerTrkContents->Add(fgSizerFilterTrk, 0, wxEXPAND, 5);
564 m_tFilterTrk->Connect(
565 wxEVT_COMMAND_TEXT_UPDATED,
566 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
568 m_cbShowAllTrk =
new wxCheckBox(m_pPanelTrk, wxID_ANY, _(
"Show all tracks"));
569 bSizerTrkContents->Add(m_cbShowAllTrk, 0, wxEXPAND | wxLEFT, 5);
570 m_cbShowAllTrk->Connect(
571 wxEVT_COMMAND_CHECKBOX_CLICKED,
572 wxCommandEventHandler(RouteManagerDialog::OnShowAllTrkCBClicked), NULL,
576 new wxListCtrl(m_pPanelTrk, -1, wxDefaultPosition, wxDefaultSize,
577 wxLC_REPORT | wxLC_SORT_ASCENDING | wxLC_HRULES |
581 m_pTrkListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
584 m_pTrkListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
585 wxListEventHandler(RouteManagerDialog::OnTrkSelected),
587 m_pTrkListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_DESELECTED,
588 wxListEventHandler(RouteManagerDialog::OnTrkSelected),
590 m_pTrkListCtrl->Connect(
591 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
592 wxListEventHandler(RouteManagerDialog::OnTrkDefaultAction), NULL,
this);
593 m_pTrkListCtrl->Connect(
595 wxMouseEventHandler(RouteManagerDialog::OnTrkToggleVisibility), NULL,
597 m_pTrkListCtrl->Connect(
598 wxEVT_COMMAND_LIST_COL_CLICK,
599 wxListEventHandler(RouteManagerDialog::OnTrkColumnClicked), NULL,
this);
600 m_pTrkListCtrl->Connect(
601 wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
602 wxListEventHandler(RouteManagerDialog::OnTrkRightClick), NULL,
this);
603 this->Connect(wxEVT_COMMAND_MENU_SELECTED,
604 wxCommandEventHandler(RouteManagerDialog::OnTrkMenuSelected),
607 bSizerTrkContents->Add(m_pTrkListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
608 sbsTracks->Add(bSizerTrkContents, 1, wxEXPAND, 5);
610 m_pTrkListCtrl->InsertColumn(colTRKVISIBLE, _(
"Show"), wxLIST_FORMAT_LEFT,
612 m_pTrkListCtrl->InsertColumn(colTRKNAME, _(
"Track Name"), wxLIST_FORMAT_LEFT,
614 m_pTrkListCtrl->InsertColumn(colTRKDATE, _(
"Start Date"), wxLIST_FORMAT_LEFT,
616 m_pTrkListCtrl->InsertColumn(colTRKLENGTH, _(
"Length"), wxLIST_FORMAT_LEFT,
619 wxBoxSizer *bsTrkButtons =
new wxBoxSizer(wxVERTICAL);
620 sbsTracks->Add(bsTrkButtons, 0, wxEXPAND);
622 wxScrolledWindow *wint =
new wxScrolledWindow(
623 m_pPanelTrk, wxID_ANY, wxDefaultPosition, wxDefaultSize,
624 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
625 wint->SetScrollRate(0, 5);
627 bsTrkButtons->Add(wint, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
629 wxBoxSizer *bsTrkButtonsInner =
new wxBoxSizer(wxVERTICAL);
630 wint->SetSizer(bsTrkButtonsInner);
632 btnTrkNew =
new wxButton(wint, -1, _(
"&Start Track"));
633 bsTrkButtonsInner->Add(btnTrkNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
634 btnTrkNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
635 wxCommandEventHandler(RouteManagerDialog::OnTrkNewClick),
638 btnTrkProperties =
new wxButton(wint, -1, _(
"&Properties"));
639 bsTrkButtonsInner->Add(btnTrkProperties, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
640 btnTrkProperties->Connect(
641 wxEVT_COMMAND_BUTTON_CLICKED,
642 wxCommandEventHandler(RouteManagerDialog::OnTrkPropertiesClick), NULL,
645 btnTrkDelete =
new wxButton(wint, -1, _(
"&Delete"));
646 bsTrkButtonsInner->Add(btnTrkDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
647 btnTrkDelete->Connect(
648 wxEVT_COMMAND_BUTTON_CLICKED,
649 wxCommandEventHandler(RouteManagerDialog::OnTrkDeleteClick), NULL,
this);
651 btnTrkExport =
new wxButton(wint, -1, _(
"&Export selected..."));
652 bsTrkButtonsInner->Add(btnTrkExport, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
653 btnTrkExport->Connect(
654 wxEVT_COMMAND_BUTTON_CLICKED,
655 wxCommandEventHandler(RouteManagerDialog::OnTrkExportClick), NULL,
this);
657 btnTrkRouteFromTrack =
new wxButton(wint, -1, _(
"Route from Track"));
658 bsTrkButtonsInner->Add(btnTrkRouteFromTrack, 0, wxALL | wxEXPAND,
660 btnTrkRouteFromTrack->Connect(
661 wxEVT_COMMAND_BUTTON_CLICKED,
662 wxCommandEventHandler(RouteManagerDialog::OnTrkRouteFromTrackClick), NULL,
665 btnTrkSendToPeer =
new wxButton(wint, -1, _(
"Send to &Peer"));
666 bsTrkButtonsInner->Add(btnTrkSendToPeer, 0, wxALL | wxEXPAND,
668 btnTrkSendToPeer->Connect(
669 wxEVT_COMMAND_BUTTON_CLICKED,
670 wxCommandEventHandler(RouteManagerDialog::OnTrkSendToPeerClick), NULL,
673 bsTrkButtonsInner->AddSpacer(10);
675 btnTrkDeleteAll =
new wxButton(wint, -1, _(
"&Delete All"));
676 bsTrkButtonsInner->Add(btnTrkDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
677 btnTrkDeleteAll->Connect(
678 wxEVT_COMMAND_BUTTON_CLICKED,
679 wxCommandEventHandler(RouteManagerDialog::OnTrkDeleteAllClick), NULL,
683 m_pPanelWpt =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
684 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
685 wxBoxSizer *sbsWpts =
new wxBoxSizer(wxHORIZONTAL);
686 m_pPanelWpt->SetSizer(sbsWpts);
687 m_pNotebook->AddPage(m_pPanelWpt, _(
"Marks"));
689 wxBoxSizer *bSizerWptContents;
690 bSizerWptContents =
new wxBoxSizer(wxVERTICAL);
692 wxFlexGridSizer *fgSizerFilterWpt;
693 fgSizerFilterWpt =
new wxFlexGridSizer(0, 2, 0, 0);
694 fgSizerFilterWpt->AddGrowableCol(1);
695 fgSizerFilterWpt->SetFlexibleDirection(wxBOTH);
696 fgSizerFilterWpt->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
698 m_stFilterWpt =
new wxStaticText(m_pPanelWpt, wxID_ANY, _(
"Filter"),
699 wxDefaultPosition, wxDefaultSize, 0);
700 m_stFilterWpt->Wrap(-1);
701 fgSizerFilterWpt->Add(m_stFilterWpt, 0, wxALL, 5);
703 m_tFilterWpt =
new wxTextCtrl(m_pPanelWpt, wxID_ANY, wxEmptyString,
704 wxDefaultPosition, wxDefaultSize, 0);
705 fgSizerFilterWpt->Add(m_tFilterWpt, 1, wxALL | wxEXPAND, 5);
707 bSizerWptContents->Add(fgSizerFilterWpt, 0, wxEXPAND, 5);
708 m_tFilterWpt->Connect(
709 wxEVT_COMMAND_TEXT_UPDATED,
710 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
713 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"),
752 wxLIST_FORMAT_LEFT, 15 * char_width);
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,
816 btnWptSendToPeer->Connect(
817 wxEVT_COMMAND_BUTTON_CLICKED,
818 wxCommandEventHandler(RouteManagerDialog::OnWptSendToPeerClick), NULL,
821 bsWptButtonsInner->AddSpacer(10);
823 btnWptDeleteAll =
new wxButton(winw, -1, _(
"Delete All"));
824 bsWptButtonsInner->Add(btnWptDeleteAll, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
825 btnWptDeleteAll->Connect(
826 wxEVT_COMMAND_BUTTON_CLICKED,
827 wxCommandEventHandler(RouteManagerDialog::OnWptDeleteAllClick), NULL,
830 wxBoxSizer *itemBoxSizer5 =
new wxBoxSizer(wxHORIZONTAL);
831 itemBoxSizer1->Add(itemBoxSizer5, 0, wxALL | wxEXPAND);
833 wxBoxSizer *itemBoxSizer6 =
new wxBoxSizer(wxHORIZONTAL);
834 itemBoxSizer5->Add(itemBoxSizer6, 1, wxALL | wxEXPAND);
836 btnImport =
new wxButton(
this, -1, _(
"I&mport GPX..."));
837 itemBoxSizer6->Add(btnImport, 0, wxALL | wxALIGN_LEFT, DIALOG_MARGIN);
838 btnImport->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
839 wxCommandEventHandler(RouteManagerDialog::OnImportClick),
848 btnExportViz =
new wxButton(
this, -1, _(
"Export All Visible..."));
849 itemBoxSizer6->Add(btnExportViz, 0, wxALL | wxALIGN_LEFT, DIALOG_MARGIN);
850 btnExportViz->Connect(
851 wxEVT_COMMAND_BUTTON_CLICKED,
852 wxCommandEventHandler(RouteManagerDialog::OnExportVizClick), NULL,
this);
855 wxSize sz = ::wxGetDisplaySize();
857 itemBoxSizer6->Add(0, 0, 1, wxEXPAND, 5);
858 itemBoxSizer6->Add(
new wxButton(
this, wxID_OK), 0, wxALL, DIALOG_MARGIN);
861 wxStaticLine* staticLine121 =
862 new wxStaticLine(
this, wxID_ANY, wxDefaultPosition,
863 wxDefaultSize, wxLI_HORIZONTAL);
864 itemBoxSizer1->Add(staticLine121, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
866 wxBoxSizer *itemBoxSizer7 =
new wxBoxSizer(wxHORIZONTAL);
867 itemBoxSizer1->Add(itemBoxSizer7, 0, wxEXPAND);
869 wxBoxSizer *itemBoxSizer7a =
new wxBoxSizer(wxHORIZONTAL);
870 itemBoxSizer7->Add(itemBoxSizer7a, 1, wxEXPAND);
872 itemBoxSizer7a->AddStretchSpacer();
873 itemBoxSizer7a->Add(
new wxButton(
this, wxID_OK), 0, wxRIGHT | wxALIGN_RIGHT, DIALOG_MARGIN *4);
877 m_pPanelLay =
new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition,
878 wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL);
879 wxBoxSizer *sbsLayers =
new wxBoxSizer(wxHORIZONTAL);
880 m_pPanelLay->SetSizer(sbsLayers);
881 m_pNotebook->AddPage(m_pPanelLay, _(
"Layers"));
883 wxBoxSizer *bSizerLayContents;
884 bSizerLayContents =
new wxBoxSizer(wxVERTICAL);
886 wxFlexGridSizer *fgSizerFilterLay;
887 fgSizerFilterLay =
new wxFlexGridSizer(0, 2, 0, 0);
888 fgSizerFilterLay->AddGrowableCol(1);
889 fgSizerFilterLay->SetFlexibleDirection(wxBOTH);
890 fgSizerFilterLay->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
892 m_stFilterLay =
new wxStaticText(m_pPanelLay, wxID_ANY, _(
"Filter"),
893 wxDefaultPosition, wxDefaultSize, 0);
894 m_stFilterLay->Wrap(-1);
895 fgSizerFilterLay->Add(m_stFilterLay, 0, wxALL, 5);
897 m_tFilterLay =
new wxTextCtrl(m_pPanelLay, wxID_ANY, wxEmptyString,
898 wxDefaultPosition, wxDefaultSize, 0);
899 fgSizerFilterLay->Add(m_tFilterLay, 1, wxALL | wxEXPAND, 5);
901 bSizerLayContents->Add(fgSizerFilterLay, 0, wxEXPAND, 5);
902 m_tFilterLay->Connect(
903 wxEVT_COMMAND_TEXT_UPDATED,
904 wxCommandEventHandler(RouteManagerDialog::OnFilterChanged), NULL,
this);
906 m_cbShowAllLay =
new wxCheckBox(m_pPanelLay, wxID_ANY, _(
"Show all layers"));
907 bSizerLayContents->Add(m_cbShowAllLay, 0, wxEXPAND | wxLEFT, 5);
908 m_cbShowAllLay->Connect(
909 wxEVT_COMMAND_CHECKBOX_CLICKED,
910 wxCommandEventHandler(RouteManagerDialog::OnShowAllLayCBClicked), NULL,
914 new wxListCtrl(m_pPanelLay, -1, wxDefaultPosition, wxDefaultSize,
915 wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING |
916 wxLC_HRULES | wxBORDER_SUNKEN );
918 m_pLayListCtrl->GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
921 m_pLayListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
922 wxListEventHandler(RouteManagerDialog::OnLaySelected),
924 m_pLayListCtrl->Connect(wxEVT_COMMAND_LIST_ITEM_DESELECTED,
925 wxListEventHandler(RouteManagerDialog::OnLaySelected),
927 m_pLayListCtrl->Connect(
928 wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
929 wxListEventHandler(RouteManagerDialog::OnLayDefaultAction), NULL,
this);
930 m_pLayListCtrl->Connect(
932 wxMouseEventHandler(RouteManagerDialog::OnLayToggleVisibility), NULL,
934 m_pLayListCtrl->Connect(
935 wxEVT_COMMAND_LIST_COL_CLICK,
936 wxListEventHandler(RouteManagerDialog::OnLayColumnClicked), NULL,
this);
937 bSizerLayContents->Add(m_pLayListCtrl, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
938 sbsLayers->Add(bSizerLayContents, 1, wxEXPAND, 5);
940 m_pLayListCtrl->InsertColumn(colLAYVISIBLE, _T(
""), wxLIST_FORMAT_LEFT,
942 m_pLayListCtrl->InsertColumn(colLAYNAME, _(
"Layer Name"), wxLIST_FORMAT_LEFT,
944 m_pLayListCtrl->InsertColumn(colLAYITEMS, _(
"No. of items"),
945 wxLIST_FORMAT_LEFT, 10 * char_width);
946 m_pLayListCtrl->InsertColumn(colLAYPERSIST, _(
"Layer type"),
947 wxLIST_FORMAT_LEFT, 10 * char_width);
949 wxBoxSizer *bsLayButtons =
new wxBoxSizer(wxVERTICAL);
950 sbsLayers->Add(bsLayButtons, 0, wxEXPAND);
952 wxScrolledWindow *winl =
new wxScrolledWindow(
953 m_pPanelLay, wxID_ANY, wxDefaultPosition, wxDefaultSize,
954 wxNO_BORDER | wxTAB_TRAVERSAL | wxVSCROLL);
955 winl->SetScrollRate(0, 5);
957 bsLayButtons->Add(winl, 1, wxALL | wxEXPAND, DIALOG_MARGIN);
959 wxBoxSizer *bsLayButtonsInner =
new wxBoxSizer(wxVERTICAL);
960 winl->SetSizer(bsLayButtonsInner);
962 btnLayNew =
new wxButton(winl, -1, _(
"Create Temporary layer"));
963 bsLayButtonsInner->Add(btnLayNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
964 btnLayNew->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
965 wxCommandEventHandler(RouteManagerDialog::OnLayNewClick),
968 btnPerLayNew =
new wxButton(winl, -1, _(
"Create Persistent layer"));
969 bsLayButtonsInner->Add(btnPerLayNew, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
970 btnPerLayNew->Connect(
971 wxEVT_COMMAND_BUTTON_CLICKED,
972 wxCommandEventHandler(RouteManagerDialog::OnPerLayNewClick), NULL,
this);
974 btnLayDelete =
new wxButton(winl, -1, _(
"&Delete"));
975 bsLayButtonsInner->Add(btnLayDelete, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
976 btnLayDelete->Connect(
977 wxEVT_COMMAND_BUTTON_CLICKED,
978 wxCommandEventHandler(RouteManagerDialog::OnLayDeleteClick), NULL,
this);
980 cbLayToggleChart =
new wxCheckBox(winl, -1, _(
"Show on chart"));
981 bsLayButtonsInner->Add(cbLayToggleChart, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
982 cbLayToggleChart->Connect(
983 wxEVT_COMMAND_CHECKBOX_CLICKED,
984 wxCommandEventHandler(RouteManagerDialog::OnLayToggleChartClick), NULL,
988 new wxCheckBox(winl, -1, _(
"Show WPT names"), wxDefaultPosition,
989 wxDefaultSize, wxCHK_3STATE);
991 bsLayButtonsInner->Add(cbLayToggleNames, 0, wxALL | wxEXPAND, DIALOG_MARGIN);
992 cbLayToggleNames->Connect(
993 wxEVT_COMMAND_CHECKBOX_CLICKED,
994 wxCommandEventHandler(RouteManagerDialog::OnLayToggleNamesClick), NULL,
997 cbLayToggleListing =
new wxCheckBox(winl, -1, _(
"List contents"));
998 bsLayButtonsInner->Add(cbLayToggleListing, 0, wxALL | wxEXPAND,
1000 cbLayToggleListing->Connect(
1001 wxEVT_COMMAND_CHECKBOX_CLICKED,
1002 wxCommandEventHandler(RouteManagerDialog::OnLayToggleListingClick), NULL,
1007 int imageRefSize = m_charWidth * 2;
1008 wxImageList *imglist =
new wxImageList(imageRefSize, imageRefSize,
true, 1);
1011 wxString UserIconPath = g_Platform->GetSharedDataDir() + _T(
"uidata") +
1012 wxFileName::GetPathSeparator();
1014 LoadSVG(UserIconPath + _T(
"eye.svg"), imageRefSize, imageRefSize)
1016 if (iconSVG.IsOk()) {
1017 iconSVG.Resize(wxSize(imageRefSize, imageRefSize),
1019 imglist->Add(wxBitmap(iconSVG));
1022 iconSVG = LoadSVG(UserIconPath + _T(
"eyex.svg"), imageRefSize, imageRefSize)
1024 if (iconSVG.IsOk()) {
1025 iconSVG.Resize(wxSize(imageRefSize, imageRefSize), wxPoint(0, 0));
1026 imglist->Add(wxBitmap(iconSVG));
1030 LoadSVG(UserIconPath + _T(
"eyeGray.svg"), imageRefSize, imageRefSize)
1032 if (iconSVG.IsOk()) {
1033 iconSVG.Resize(wxSize(imageRefSize, imageRefSize), wxPoint(0, 0));
1034 imglist->Add(wxBitmap(iconSVG));
1037 m_pRouteListCtrl->AssignImageList(imglist, wxIMAGE_LIST_SMALL);
1040 m_pRouteListCtrl->GetHandle()->setIconSize(QSize(imageRefSize, imageRefSize));
1044 m_pTrkListCtrl->SetImageList(imglist, wxIMAGE_LIST_SMALL);
1045 m_pWptListCtrl->SetImageList(
1046 pWayPointMan->Getpmarkicon_image_list(m_listIconSize),
1047 wxIMAGE_LIST_SMALL);
1048 m_pLayListCtrl->SetImageList(imglist, wxIMAGE_LIST_SMALL);
1058 m_bNeedConfigFlush =
false;
1061 RouteManagerDialog::~RouteManagerDialog() {
1062 delete m_pRouteListCtrl;
1063 delete m_pTrkListCtrl;
1064 delete m_pWptListCtrl;
1065 delete m_pLayListCtrl;
1067 delete btnRteDelete;
1068 delete btnRteResequence;
1069 delete btnRteExport;
1070 delete btnRteZoomto;
1071 delete btnRteProperties;
1072 delete btnRteActivate;
1073 delete btnRteReverse;
1074 delete btnRteSendToGPS;
1075 delete btnRteDeleteAll;
1077 delete btnTrkProperties;
1078 delete btnTrkDelete;
1079 delete btnTrkExport;
1080 delete btnTrkRouteFromTrack;
1081 delete btnTrkDeleteAll;
1083 delete btnWptProperties;
1084 delete btnWptZoomto;
1085 delete btnWptDelete;
1087 delete btnWptExport;
1088 delete btnWptSendToGPS;
1089 delete btnWptDeleteAll;
1092 delete cbLayToggleChart;
1093 delete cbLayToggleListing;
1094 delete cbLayToggleNames;
1095 delete btnLayDelete;
1098 delete btnExportViz;
1101 btnExportViz = NULL;
1104 instanceFlag =
false;
1107 void RouteManagerDialog::RecalculateSize() {
1113 int char_width, char_height;
1114 GetTextExtent(_T(
"W"), &char_width, &char_height);
1117 sz.x = 60 * char_width;
1118 sz.y = 30 * char_height;
1120 wxSize dsize = GetParent()->GetClientSize();
1121 sz.y = wxMin(sz.y, dsize.y);
1122 sz.x = wxMin(sz.x, dsize.x);
1125 wxSize fsize = GetSize();
1126 fsize.y = wxMin(fsize.y, dsize.y);
1127 fsize.x = wxMin(fsize.x, dsize.x);
1133 void RouteManagerDialog::OnClose(wxCloseEvent &event) {
1141 void RouteManagerDialog::OnOK(wxCommandEvent &event) {
1148 void RouteManagerDialog::SetColorScheme() { DimeControl(
this); }
1150 void RouteManagerDialog::OnShowAllRteCBClicked(wxCommandEvent &event) {
1151 bool viz = m_cbShowAllRte->GetValue();
1154 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1155 wxLIST_STATE_DONTCARE);
1156 if (item == -1)
break;
1158 Route *pR = (
Route *)m_pRouteListCtrl->GetItemData(item);
1160 pR->SetVisible(viz, viz);
1161 pR->SetSharedWPViz(viz);
1163 m_pRouteListCtrl->SetItemImage(item, !viz);
1165 pConfig->UpdateRoute(pR);
1168 UpdateWptListCtrlViz();
1170 gFrame->RefreshAllCanvas();
1173 void RouteManagerDialog::OnShowAllWpCBClicked(wxCommandEvent &event) {
1174 bool viz = m_cbShowAllWP->GetValue();
1177 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1178 wxLIST_STATE_DONTCARE);
1179 if (item == -1)
break;
1183 if (!pRP->IsSharedInVisibleRoute()) {
1184 pRP->SetVisible(viz);
1186 pRP->SetVisible(
true);
1188 m_pWptListCtrl->SetItemImage(item,
RoutePointGui(*pRP).GetIconImageIndex());
1189 pConfig->UpdateWayPoint(pRP);
1192 gFrame->RefreshAllCanvas();
1195 void RouteManagerDialog::OnShowAllTrkCBClicked(wxCommandEvent &event) {
1196 bool viz = m_cbShowAllTrk->GetValue();
1199 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1200 wxLIST_STATE_DONTCARE);
1201 if (item == -1)
break;
1203 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1205 track->SetVisible(viz);
1206 m_pTrkListCtrl->SetItemImage(item, track->IsVisible() ? 0 : 1);
1209 gFrame->RefreshAllCanvas();
1212 void RouteManagerDialog::OnShowAllLayCBClicked(wxCommandEvent &event) {
1213 bool viz = m_cbShowAllLay->GetValue();
1216 item = m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1217 wxLIST_STATE_DONTCARE);
1218 if (item == -1)
break;
1220 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
1222 layer->SetVisibleOnChart(viz);
1223 m_pLayListCtrl->SetItemImage(item, layer->IsVisibleOnChart() ? 0 : 1);
1225 ToggleLayerContentsOnChart(layer);
1228 gFrame->RefreshAllCanvas();
1231 void RouteManagerDialog::UpdateRouteListCtrl() {
1234 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1235 wxLIST_STATE_SELECTED);
1236 wxUIntPtr selected_id = wxUIntPtr(0);
1237 if (item != -1) selected_id = m_pRouteListCtrl->GetItemData(item);
1240 m_pRouteListCtrl->DeleteAllItems();
1243 RouteList::iterator it;
1246 bool bpartialViz =
false;
1248 for (it = (*pRouteList).begin(); it != (*pRouteList).end(); ++it, ++index) {
1249 if (!(*it)->IsListed())
continue;
1251 if (!(*it)->GetName().Upper().Contains(m_tFilterRte->GetValue().Upper())) {
1256 li.SetId(list_index);
1257 li.SetImage((*it)->IsVisible() ? 0 : 1);
1260 li.SetAlign(wxLIST_FORMAT_LEFT);
1262 if ((*it)->m_bRtIsActive) {
1263 wxFont font = *wxNORMAL_FONT;
1264 font.SetWeight(wxFONTWEIGHT_BOLD);
1268 long idx = m_pRouteListCtrl->InsertItem(li);
1270 wxString name = (*it)->m_RouteNameString;
1271 if (name.IsEmpty()) name = _(
"(Unnamed Route)");
1272 m_pRouteListCtrl->SetItem(idx, rmROUTENAME, name);
1274 wxString startend = (*it)->m_RouteStartString;
1275 if (!(*it)->m_RouteEndString.IsEmpty())
1276 startend.append(_(
" - ") + (*it)->m_RouteEndString);
1277 m_pRouteListCtrl->SetItem(idx, rmROUTEDESC, startend);
1280 lic.SetId(list_index);
1282 lic.SetAlign(wxLIST_FORMAT_LEFT);
1283 m_pRouteListCtrl->SetItem(lic);
1286 lic.SetAlign(wxLIST_FORMAT_LEFT);
1287 m_pRouteListCtrl->SetItem(lic);
1290 if (!(*it)->IsVisible()) bpartialViz =
true;
1295 m_pRouteListCtrl->SortItems(SortRoutesOnName, (wxIntPtr)NULL);
1297 m_pRouteListCtrl->SetColumnWidth(0, 4 * m_charWidth);
1302 if (selected_id != wxUIntPtr(0)) {
1303 item = m_pRouteListCtrl->FindItem(-1, selected_id);
1304 m_pRouteListCtrl->SetItemState(
1305 item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
1306 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
1309 if ((m_lastRteItem >= 0) && (m_pRouteListCtrl->GetItemCount()))
1310 m_pRouteListCtrl->EnsureVisible(m_lastRteItem);
1314 m_cbShowAllRte->SetValue(!bpartialViz);
1317 void RouteManagerDialog::UpdateRteButtons() {
1319 long selected_index_index =
1320 m_pRouteListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
1321 bool enable1 = m_pRouteListCtrl->GetSelectedItemCount() == 1;
1322 bool enablemultiple = m_pRouteListCtrl->GetSelectedItemCount() >= 1;
1324 m_lastRteItem = selected_index_index;
1326 btnRteDelete->Enable(m_pRouteListCtrl->GetSelectedItemCount() > 0);
1327 btnRteZoomto->Enable(enable1);
1328 btnRteProperties->Enable(enable1);
1329 btnRteReverse->Enable(enable1);
1330 btnRteExport->Enable(enablemultiple);
1331 btnRteResequence->Enable(enable1);
1332 btnRteSendToGPS->Enable(enable1);
1333 btnRteDeleteAll->Enable(m_pRouteListCtrl->GetItemCount() > 0);
1334 btnRteSendToPeer->Enable(enablemultiple);
1337 Route *route = NULL;
1339 route = (
Route *)m_pRouteListCtrl->GetItemData(selected_index_index);
1341 if (!g_pRouteMan->IsAnyRouteActive()) {
1342 btnRteActivate->Enable(enable1);
1343 if (enable1) btnRteActivate->SetLabel(_(
"Activate"));
1347 if (route && route->m_bRtIsActive) {
1348 btnRteActivate->Enable(enable1);
1349 btnRteActivate->SetLabel(_(
"Deactivate"));
1351 btnRteActivate->Enable(
false);
1353 btnRteActivate->Enable(
false);
1357 void RouteManagerDialog::MakeAllRoutesInvisible() {
1358 RouteList::iterator it;
1360 for (it = (*pRouteList).begin(); it != (*pRouteList).end(); ++it, ++index) {
1361 if ((*it)->IsVisible()) {
1362 (*it)->SetVisible(
false);
1363 m_pRouteListCtrl->SetItemImage(m_pRouteListCtrl->FindItem(-1, index),
1365 pConfig->UpdateRoute(*it);
1370 void RouteManagerDialog::ZoomtoRoute(
Route *route) {
1372 LLBBox RBBox = route->GetBBox();
1373 double clat = (RBBox.GetMinLat() + RBBox.GetMaxLat()) / 2;
1374 double clon = (RBBox.GetMinLon() + RBBox.GetMaxLon()) / 2;
1380 DistanceBearingMercator(RBBox.GetMinLat(), RBBox.GetMinLon(),
1381 RBBox.GetMinLat(), RBBox.GetMaxLon(), NULL, &rw);
1383 DistanceBearingMercator(RBBox.GetMinLat(), RBBox.GetMinLon(),
1384 RBBox.GetMaxLat(), RBBox.GetMinLon(), NULL, &rh);
1386 if (gFrame->GetFocusCanvas()) {
1387 gFrame->GetFocusCanvas()->GetSize(&ww, &wh);
1388 ppm = wxMin(ww / (rw * 1852), wh / (rh * 1852)) * (100 - fabs(clat)) / 90;
1389 ppm = wxMin(ppm, 1.0);
1391 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), clat, clon, ppm);
1394 m_bNeedConfigFlush =
true;
1398 void RouteManagerDialog::OnRteDeleteClick(wxCommandEvent &event) {
1401 int answer = OCPNMessageBox(
1402 this, _(
"Are you sure you want to delete the selected object(s)"),
1403 wxString(_(
"OpenCPN Alert")), wxYES_NO);
1404 if (answer != wxID_YES)
return;
1407 if (m_pRouteListCtrl->GetSelectedItemCount()) {
1408 ::wxBeginBusyCursor();
1409 gFrame->CancelAllMouseRoute();
1410 m_bNeedConfigFlush =
true;
1416 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1417 wxLIST_STATE_SELECTED);
1418 if (item == -1)
break;
1420 Route *proute_to_delete = (
Route *)m_pRouteListCtrl->GetItemData(item);
1422 if (proute_to_delete) list.Append(proute_to_delete);
1426 for (
unsigned int i = 0; i < list.GetCount(); i++) {
1427 Route *route = list.Item(i)->GetData();
1429 pConfig->DeleteConfigRoute(route);
1430 g_pRouteMan->
DeleteRoute(route, NavObjectChanges::getInstance());
1435 UpdateRouteListCtrl();
1436 UpdateTrkListCtrl();
1438 gFrame->InvalidateAllCanvasUndo();
1439 gFrame->RefreshAllCanvas();
1440 ::wxEndBusyCursor();
1444 void RouteManagerDialog::OnRteDeleteAllClick(wxCommandEvent &event) {
1446 OCPNMessageBox(
this, _(
"Are you sure you want to delete <ALL> routes?"),
1447 wxString(_(
"OpenCPN Alert")), wxYES_NO);
1449 if (dialog_ret == wxID_YES) {
1450 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
1452 gFrame->CancelAllMouseRoute();
1454 g_pRouteMan->DeleteAllRoutes(NavObjectChanges::getInstance());
1461 UpdateRouteListCtrl();
1465 UpdateTrkListCtrl();
1467 if (pRoutePropDialog) pRoutePropDialog->Hide();
1468 gFrame->InvalidateAllCanvasUndo();
1469 gFrame->RefreshAllCanvas();
1471 m_bNeedConfigFlush =
true;
1475 void RouteManagerDialog::OnRtePropertiesClick(wxCommandEvent &event) {
1478 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1479 wxLIST_STATE_SELECTED);
1480 if (item == -1)
return;
1482 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1486 pRoutePropDialog = RoutePropDlgImpl::getInstance(GetParent());
1488 pRoutePropDialog->SetRouteAndUpdate(route);
1490 if (!pRoutePropDialog->IsShown()) pRoutePropDialog->Show();
1492 pRoutePropDialog->Raise();
1494 m_bNeedConfigFlush =
true;
1497 void RouteManagerDialog::OnRteZoomtoClick(wxCommandEvent &event) {
1500 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1501 wxLIST_STATE_SELECTED);
1502 if (item == -1)
return;
1505 if (m_bCtrlDown) MakeAllRoutesInvisible();
1507 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1512 if (!route->IsVisible()) {
1513 route->SetVisible(
true);
1514 m_pRouteListCtrl->SetItemImage(item, route->IsVisible() ? 0 : 1);
1515 pConfig->UpdateRoute(route);
1521 void RouteManagerDialog::OnRteReverseClick(wxCommandEvent &event) {
1524 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1525 wxLIST_STATE_SELECTED);
1526 if (item == -1)
return;
1528 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1531 if (route->m_bIsInLayer)
return;
1533 int ask_return = OCPNMessageBox(
this, g_pRouteMan->GetRouteReverseMessage(),
1534 _(
"Rename Waypoints?"), wxYES_NO | wxCANCEL);
1535 if (ask_return != wxID_CANCEL) {
1536 bool rename = (ask_return == wxID_YES);
1538 pSelect->DeleteAllSelectableRouteSegments(route);
1539 route->Reverse(rename);
1540 pSelect->AddAllSelectableRouteSegments(route);
1543 wxString startend = route->m_RouteStartString;
1544 if (!route->m_RouteEndString.IsEmpty())
1545 startend.append(_(
" - ") + route->m_RouteEndString);
1546 m_pRouteListCtrl->SetItem(item, 2, startend);
1548 pConfig->UpdateRoute(route);
1549 gFrame->RefreshAllCanvas();
1552 m_bNeedConfigFlush =
true;
1555 void RouteManagerDialog::OnRteExportClick(wxCommandEvent &event) {
1558 wxString suggested_name = _T(
"routes");
1562 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1563 wxLIST_STATE_SELECTED);
1564 if (item == -1)
break;
1566 Route *proute_to_export = (
Route *)m_pRouteListCtrl->GetItemData(item);
1568 if (proute_to_export) {
1569 list.Append(proute_to_export);
1570 if (proute_to_export->m_RouteNameString != wxEmptyString)
1571 suggested_name = proute_to_export->m_RouteNameString;
1575 ExportGPXRoutes(
this, &list, suggested_name);
1578 void RouteManagerDialog::OnRteResequenceClick(wxCommandEvent &event) {
1580 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1581 wxLIST_STATE_SELECTED);
1582 if (item == -1)
return;
1584 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1587 if (route->m_bIsInLayer)
return;
1588 route->RenameRoutePoints();
1591 void RouteManagerDialog::OnRteSendToPeerClick(wxCommandEvent &event) {
1592 std::vector<Route*> list;
1595 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1596 wxLIST_STATE_SELECTED);
1597 if (item == -1)
break;
1599 Route *proute = (
Route *)m_pRouteListCtrl->GetItemData(item);
1602 list.push_back(proute);
1605 if (!list.empty()) {
1607 for (
auto r : list) {
1614 MdnsCache::GetInstance().
Validate();
1615 if (MdnsCache::GetInstance().GetCache().empty())
1616 dlg.SetScanOnCreate(
true);
1619 dlg.Create(NULL, -1, _(
"Send Route(s) to OpenCPN Peer") + _T(
"..." ), _T(
""));
1624 void RouteManagerDialog::OnWptSendToPeerClick(wxCommandEvent &event) {
1625 std::vector<RoutePoint*> list;
1628 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1629 wxLIST_STATE_SELECTED);
1630 if (item == -1)
break;
1635 list.push_back(proutep);
1638 if (!list.empty()) {
1640 for (
auto r : list) {
1647 MdnsCache::GetInstance().
Validate();
1648 if (MdnsCache::GetInstance().GetCache().empty())
1649 dlg.SetScanOnCreate(
true);
1652 dlg.Create(NULL, -1, _(
"Send Waypoint(s) to OpenCPN Peer") + _T(
"..." ), _T(
""));
1657 void RouteManagerDialog::OnTrkSendToPeerClick(wxCommandEvent &event) {
1658 std::vector<Track*> list;
1661 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1662 wxLIST_STATE_SELECTED);
1663 if (item == -1)
break;
1665 Track *ptrk = (
Track *)m_pTrkListCtrl->GetItemData(item);
1668 list.push_back(ptrk);
1671 if (!list.empty()) {
1673 for (
auto r : list) {
1680 MdnsCache::GetInstance().
Validate();
1681 if (MdnsCache::GetInstance().GetCache().empty())
1682 dlg.SetScanOnCreate(
true);
1685 dlg.Create(NULL, -1, _(
"Send Track(s) to OpenCPN Peer") + _T(
"..." ), _T(
""));
1690 void RouteManagerDialog::OnRteActivateClick(wxCommandEvent &event) {
1693 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1694 wxLIST_STATE_SELECTED);
1695 if (item == -1)
return;
1697 if (m_bCtrlDown) MakeAllRoutesInvisible();
1699 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1703 if (!route->m_bRtIsActive) {
1704 if (!route->IsVisible()) {
1705 route->SetVisible(
true);
1706 m_pRouteListCtrl->SetItemImage(item, 0, 0);
1712 g_pRouteMan->FindBestActivatePoint(route, gLat, gLon, gCog, gSog);
1713 g_pRouteMan->ActivateRoute(route, best_point);
1716 g_pRouteMan->DeactivateRoute();
1718 UpdateRouteListCtrl();
1720 pConfig->UpdateRoute(route);
1722 gFrame->RefreshAllCanvas();
1727 m_bNeedConfigFlush =
true;
1730 void RouteManagerDialog::OnRteToggleVisibility(wxMouseEvent &event) {
1731 wxPoint pos =
event.GetPosition();
1733 long clicked_index = m_pRouteListCtrl->HitTest(pos, flags);
1736 if (clicked_index > -1 &&
1737 event.GetX() < m_pRouteListCtrl->GetColumnWidth(rmVISIBLE)) {
1739 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(clicked_index);
1741 route->SetVisible(!route->IsVisible());
1743 m_pRouteListCtrl->SetItemImage(clicked_index, route->IsVisible() ? 0 : 1);
1745 ::wxBeginBusyCursor();
1747 pConfig->UpdateRoute(route);
1748 gFrame->RefreshAllCanvas();
1752 if (g_pRouteMan->DoesRouteContainSharedPoints(route))
1753 UpdateWptListCtrlViz();
1759 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1760 wxLIST_STATE_DONTCARE);
1761 if (item == -1)
break;
1763 Route *pR = (
Route *)m_pRouteListCtrl->GetItemData(item);
1765 if (!pR->IsVisible()) {
1770 m_cbShowAllRte->SetValue(viz);
1772 ::wxEndBusyCursor();
1779 void RouteManagerDialog::OnRteBtnLeftDown(wxMouseEvent &event) {
1780 m_bCtrlDown =
event.ControlDown();
1784 void RouteManagerDialog::OnRteSelected(wxListEvent &event) {
1785 long clicked_index =
event.m_itemIndex;
1787 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(clicked_index);
1789 m_pRouteListCtrl->SetItemImage(clicked_index, route->IsVisible() ? 0 : 1);
1792 gFrame->RefreshAllCanvas();
1797 void RouteManagerDialog::OnRteColumnClicked(wxListEvent &event) {
1798 if (event.m_col == 1) {
1799 sort_route_name_dir++;
1801 m_pRouteListCtrl->SortItems(SortRoutesOnName, (wxIntPtr)NULL);
1802 }
else if (event.m_col == 2) {
1803 sort_route_to_dir++;
1804 m_pRouteListCtrl->SortItems(SortRoutesOnTo, (wxIntPtr)NULL);
1808 void RouteManagerDialog::OnRteSendToGPSClick(wxCommandEvent &event) {
1810 item = m_pRouteListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1811 wxLIST_STATE_SELECTED);
1812 if (item == -1)
return;
1814 Route *route = (
Route *)m_pRouteListCtrl->GetItemData(item);
1819 pdlg->SetRoute(route);
1821 wxFont fo = GetOCPNGUIScaledFont(_T(
"Dialog"));
1825 pdlg->Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), source);
1828 HideWithEffect(wxSHOW_EFFECT_BLEND);
1834 ShowWithEffect(wxSHOW_EFFECT_BLEND);
1840 void RouteManagerDialog::OnRteDefaultAction(wxListEvent &event) {
1842 OnRtePropertiesClick(evt);
1845 void RouteManagerDialog::OnTrkDefaultAction(wxListEvent &event) {
1847 OnTrkPropertiesClick(evt);
1850 void RouteManagerDialog::OnTrkRightClick(wxListEvent &event) {
1852 wxMenuItem *mergeItem = menu.Append(TRACK_MERGE, _(
"&Merge Selected Tracks"));
1853 mergeItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() > 1);
1854 wxMenuItem *cleanItem = menu.Append(TRACK_CLEAN, _(
"Reduce Data..."));
1855 cleanItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() == 1);
1856 wxMenuItem *copyItem = menu.Append(TRACK_COPY_TEXT, _(
"&Copy as text"));
1857 copyItem->Enable(m_pTrkListCtrl->GetSelectedItemCount() > 0);
1861 static bool CompareTracks(
Track *track1,
Track *track2) {
1864 return start1->GetCreateTime() < start2->GetCreateTime();
1867 void RouteManagerDialog::OnTrkMenuSelected(wxCommandEvent &event) {
1870 switch (event.GetId()) {
1872 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1873 wxLIST_STATE_SELECTED);
1874 if (item == -1)
break;
1875 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1876 if (track->IsRunning()) {
1881 const wxString choices[] = {_T(
"5.0"), _T(
"10.0"), _T(
"20.0"), _T(
"50.0"),
1884 wxSingleChoiceDialog precisionDlg(
this,
1885 _(
"Select the maximum error allowed "
1886 "(in meters)\nafter data reduction:"),
1887 _(
"Reduce Data Precision"), 5, choices);
1889 precisionDlg.ShowWindowModal();
1890 while (precisionDlg.IsShown()) {
1894 int result = precisionDlg.GetReturnCode();
1896 int result = precisionDlg.ShowModal();
1898 if (result == wxID_CANCEL)
break;
1899 double precision = 5.0;
1900 switch (precisionDlg.GetSelection()) {
1918 int pointsBefore = track->GetnPoints();
1920 int reduction = track->Simplify(precision);
1921 gFrame->Refresh(
false);
1923 reduction = 100 * reduction / pointsBefore;
1924 wxString msg = wxString::Format(
1925 _(
"The amount of data used by the track\n was reduced by %d%%."),
1927 OCPNMessageBox(
this, msg, _(
"OpenCPN info"), wxICON_INFORMATION | wxOK);
1929 UpdateTrkListCtrl();
1930 UpdateRouteListCtrl();
1935 case TRACK_COPY_TEXT: {
1938 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1939 wxLIST_STATE_SELECTED);
1940 if (item == -1)
break;
1941 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1942 csvString << track->GetName() << _T(
"\t")
1943 << wxString::Format(_T(
"%.1f"), track->Length()) << _T(
"\t")
1947 if (wxTheClipboard->Open()) {
1948 wxTextDataObject *data =
new wxTextDataObject;
1949 data->SetText(csvString);
1950 wxTheClipboard->SetData(data);
1951 wxTheClipboard->Close();
1958 Track *targetTrack = NULL;
1962 std::vector<Track *> mergeList;
1963 std::vector<Track *> deleteList;
1964 bool runningSkipped =
false;
1966 ::wxBeginBusyCursor();
1969 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
1970 wxLIST_STATE_SELECTED);
1971 if (item == -1)
break;
1972 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
1973 mergeList.push_back(track);
1976 std::sort(mergeList.begin(), mergeList.end(), CompareTracks);
1978 targetTrack = mergeList[0];
1979 lastPoint = targetTrack->GetLastPoint();
1981 for (
auto const &mergeTrack : mergeList) {
1982 if (mergeTrack == *mergeList.begin())
continue;
1984 if (mergeTrack->IsRunning()) {
1985 runningSkipped =
true;
1989 for (
int i = 0; i < mergeTrack->GetnPoints(); i++) {
1990 tPoint = mergeTrack->GetPoint(i);
1991 newPoint =
new TrackPoint(tPoint->m_lat, tPoint->m_lon,
1992 tPoint->GetCreateTime());
1994 targetTrack->AddPoint(newPoint);
1996 pSelect->AddSelectableTrackSegment(lastPoint->m_lat, lastPoint->m_lon,
1997 newPoint->m_lat, newPoint->m_lon,
1998 lastPoint, newPoint, targetTrack);
2000 lastPoint = newPoint;
2002 deleteList.push_back(mergeTrack);
2005 for (
auto const &deleteTrack : deleteList) {
2006 g_pAIS->DeletePersistentTrack(deleteTrack);
2007 pConfig->DeleteConfigTrack(deleteTrack);
2008 RoutemanGui(*g_pRouteMan).DeleteTrack(deleteTrack);
2014 ::wxEndBusyCursor();
2016 UpdateTrkListCtrl();
2017 UpdateRouteListCtrl();
2018 gFrame->RefreshAllCanvas();
2020 if (runningSkipped) {
2021 wxMessageDialog skipWarning(
2023 _(
"The currently running Track was not merged.\nYou can merge it "
2024 "later when it is completed."),
2025 _T(
"Warning"), wxCANCEL | wxICON_WARNING);
2026 skipWarning.ShowModal();
2034 void RouteManagerDialog::UpdateTrkListCtrl() {
2038 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2040 wxUIntPtr selected_id = wxUIntPtr(0);
2041 if (item != -1) selected_id = m_pTrkListCtrl->GetItemData(item);
2044 m_pTrkListCtrl->DeleteAllItems();
2047 std::vector<Track*>::iterator it;
2050 bool bpartialViz =
false;
2052 for (
Track *trk : g_TrackList) {
2053 if (!trk->IsVisible()) bpartialViz =
true;
2055 if (!trk->IsListed())
continue;
2057 if (!trk->GetName(
true).Upper().Contains(
2058 m_tFilterTrk->GetValue().Upper())) {
2063 li.SetId(list_index);
2064 li.SetImage(trk->IsVisible() ? 0 : 1);
2068 if (g_pActiveTrack == trk) {
2069 wxFont font = *wxNORMAL_FONT;
2070 font.SetWeight(wxFONTWEIGHT_BOLD);
2073 long idx = m_pTrkListCtrl->InsertItem(li);
2075 m_pTrkListCtrl->SetItem(idx, colTRKNAME, trk->GetName(
true));
2076 m_pTrkListCtrl->SetItem(idx, colTRKDATE, trk->GetDate(
true));
2079 len.Printf(wxT(
"%5.2f"), trk->Length());
2080 m_pTrkListCtrl->SetItem(idx, colTRKLENGTH, len);
2083 lic.SetId(list_index);
2085 lic.SetAlign(wxLIST_FORMAT_LEFT);
2086 m_pTrkListCtrl->SetItem(lic);
2089 lic.SetAlign(wxLIST_FORMAT_LEFT);
2090 m_pTrkListCtrl->SetItem(lic);
2095 switch (sort_track_key) {
2096 case SORT_ON_DISTANCE:
2097 m_pTrkListCtrl->SortItems(SortTracksOnDistance, (wxIntPtr)NULL);
2100 m_pTrkListCtrl->SortItems(SortTracksOnDate, (wxIntPtr)NULL);
2104 m_pTrkListCtrl->SortItems(SortTracksOnName, (wxIntPtr)NULL);
2108 m_pTrkListCtrl->SetColumnWidth(0, 4 * m_charWidth);
2113 if (selected_id != wxUIntPtr(0)) {
2114 item = m_pTrkListCtrl->FindItem(-1, selected_id);
2115 m_pTrkListCtrl->SetItemState(item,
2116 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
2117 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
2120 if ((m_lastTrkItem >= 0) && (m_pTrkListCtrl->GetItemCount()))
2121 m_pTrkListCtrl->EnsureVisible(m_lastTrkItem);
2123 m_cbShowAllTrk->SetValue(!bpartialViz);
2127 void RouteManagerDialog::OnTrkSelected(wxListEvent &event) {
2131 void RouteManagerDialog::OnTrkColumnClicked(wxListEvent &event) {
2132 if (event.m_col == 1) {
2133 sort_track_key = SORT_ON_NAME;
2134 sort_track_name_dir++;
2135 m_pTrkListCtrl->SortItems(SortTracksOnName, (wxIntPtr)NULL);
2136 }
else if (event.m_col == 2) {
2137 sort_track_key = SORT_ON_DISTANCE;
2138 sort_track_len_dir++;
2139 m_pTrkListCtrl->SortItems(SortTracksOnDistance, (wxIntPtr)NULL);
2140 }
else if (event.m_col == 3) {
2141 sort_track_key = SORT_ON_DATE;
2142 sort_track_date_dir++;
2143 m_pTrkListCtrl->SortItems(SortTracksOnDate, (wxIntPtr)NULL);
2147 void RouteManagerDialog::UpdateTrkButtons() {
2150 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2151 int items = m_pTrkListCtrl->GetSelectedItemCount();
2153 m_lastTrkItem = item;
2155 btnTrkProperties->Enable(items == 1);
2156 btnTrkDelete->Enable(items >= 1);
2157 btnTrkExport->Enable(items >= 1);
2158 btnTrkRouteFromTrack->Enable(items == 1);
2159 btnTrkDeleteAll->Enable(m_pTrkListCtrl->GetItemCount() > 0);
2160 btnTrkSendToPeer->Enable(items >= 1);
2163 void RouteManagerDialog::OnTrkToggleVisibility(wxMouseEvent &event) {
2164 wxPoint pos =
event.GetPosition();
2166 long clicked_index = m_pTrkListCtrl->HitTest(pos, flags);
2169 if (clicked_index > -1 &&
2170 event.GetX() < m_pTrkListCtrl->GetColumnWidth(colTRKVISIBLE)) {
2172 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(clicked_index);
2174 track->SetVisible(!track->IsVisible());
2175 m_pTrkListCtrl->SetItemImage(clicked_index, track->IsVisible() ? 0 : 1);
2182 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2183 wxLIST_STATE_DONTCARE);
2184 if (item == -1)
break;
2186 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2188 if (!track->IsVisible()) {
2193 m_cbShowAllTrk->SetValue(viz);
2195 gFrame->RefreshAllCanvas();
2202 void RouteManagerDialog::OnTrkNewClick(wxCommandEvent &event) {
2204 if (pConfig && pConfig->IsChangesFileDirty()) {
2205 pConfig->UpdateNavObj(
true);
2210 UpdateTrkListCtrl();
2213 void RouteManagerDialog::OnTrkPropertiesClick(wxCommandEvent &event) {
2217 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2218 if (item == -1)
return;
2220 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2224 pTrackPropDialog = TrackPropDlg::getInstance(GetParent());
2225 pTrackPropDialog->SetTrackAndUpdate(track);
2227 if (!pTrackPropDialog->IsShown()) pTrackPropDialog->Show();
2228 UpdateTrkListCtrl();
2230 m_bNeedConfigFlush =
true;
2233 void RouteManagerDialog::OnTrkDeleteClick(wxCommandEvent &event) {
2234 std::vector<Track*> list;
2236 int answer = OCPNMessageBox(
2237 this, _(
"Are you sure you want to delete the selected object(s)"),
2238 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2239 if (answer != wxID_YES)
return;
2242 if (m_pTrkListCtrl->GetSelectedItemCount()) {
2243 ::wxBeginBusyCursor();
2244 m_bNeedConfigFlush =
true;
2250 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2251 wxLIST_STATE_SELECTED);
2252 if (item == -1)
break;
2254 Track *ptrack_to_delete = (
Track *)m_pTrkListCtrl->GetItemData(item);
2256 if (ptrack_to_delete) list.push_back(ptrack_to_delete);
2260 for (
unsigned int i = 0; i < list.size(); i++) {
2261 Track *track = list.at(i);
2263 g_pAIS->DeletePersistentTrack(track);
2264 pConfig->DeleteConfigTrack(track);
2271 UpdateTrkListCtrl();
2273 if (pConfig && pConfig->IsChangesFileDirty()) {
2274 pConfig->UpdateNavObj(
true);
2277 gFrame->InvalidateAllCanvasUndo();
2278 gFrame->RefreshAllCanvas();
2279 ::wxEndBusyCursor();
2283 void RouteManagerDialog::OnTrkExportClick(wxCommandEvent &event) {
2284 std::vector<Track*> list;
2285 wxString suggested_name = _T(
"tracks");
2289 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2290 wxLIST_STATE_SELECTED);
2291 if (item == -1)
break;
2293 Track *ptrack_to_export = (
Track *)m_pTrkListCtrl->GetItemData(item);
2295 if (ptrack_to_export) {
2296 list.push_back(ptrack_to_export);
2297 if (ptrack_to_export->GetName() != wxEmptyString)
2298 suggested_name = ptrack_to_export->GetName();
2302 ExportGPXTracks(
this, &list, suggested_name);
2305 void RouteManagerDialog::TrackToRoute(
Track *track) {
2307 if (track->m_bIsInLayer)
return;
2309 wxGenericProgressDialog pprog(_(
"OpenCPN Converting Track to Route...."),
2310 _(
"Processing Waypoints..."), 101, NULL,
2311 wxPD_AUTO_HIDE | wxPD_SMOOTH |
2312 wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
2313 wxPD_REMAINING_TIME);
2315 ::wxBeginBusyCursor();
2317 Route *route = track->RouteFromTrack(&pprog);
2319 pRouteList->Append(route);
2321 pprog.Update(101, _(
"Done."));
2323 gFrame->RefreshAllCanvas();
2325 ::wxEndBusyCursor();
2328 void RouteManagerDialog::OnTrkRouteFromTrackClick(wxCommandEvent &event) {
2331 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2332 if (item == -1)
return;
2334 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2336 TrackToRoute(track);
2338 UpdateRouteListCtrl();
2341 void RouteManagerDialog::OnTrkDeleteAllClick(wxCommandEvent &event) {
2343 OCPNMessageBox(
this, _(
"Are you sure you want to delete <ALL> tracks?"),
2344 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2346 if (dialog_ret == wxID_YES) {
2353 UpdateTrkListCtrl();
2357 UpdateRouteListCtrl();
2359 if (pRoutePropDialog) pRoutePropDialog->Hide();
2361 gFrame->RefreshAllCanvas();
2363 m_bNeedConfigFlush =
true;
2366 void RouteManagerDialog::UpdateWptListCtrl(
RoutePoint *rp_select,
2367 bool b_retain_sort) {
2368 wxIntPtr selected_id = wxUIntPtr(0);
2371 if (NULL == rp_select) {
2373 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2374 wxLIST_STATE_SELECTED);
2376 if (item != -1) selected_id = m_pWptListCtrl->GetItemData(item);
2380 m_pWptListCtrl->SetImageList(
2381 pWayPointMan->Getpmarkicon_image_list(m_listIconSize),
2382 wxIMAGE_LIST_SMALL);
2384 m_pWptListCtrl->DeleteAllItems();
2386 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
2389 bool b_anyHidden =
false;
2392 if (rp && rp->IsListed()) {
2393 if (rp->m_bIsInRoute && !rp->IsShared()) {
2394 node = node->GetNext();
2398 if (!rp->GetName().Upper().Contains(m_tFilterWpt->GetValue().Upper())) {
2399 node = node->GetNext();
2408 long idx = m_pWptListCtrl->InsertItem(li);
2410 wxString scamin = wxString::Format(_T(
"%i"), (
int)rp->GetScaMin());
2411 if (!rp->GetUseSca()) scamin = _(
"Always");
2412 if (g_bOverruleScaMin) scamin = _(
"Overruled");
2413 m_pWptListCtrl->SetItem(idx, colWPTSCALE, scamin);
2415 wxString name = rp->GetName();
2416 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
2417 m_pWptListCtrl->SetItem(idx, colWPTNAME, name);
2420 DistanceBearingMercator(rp->m_lat, rp->m_lon, gLat, gLon, NULL, &dst);
2422 dist.Printf(_T(
"%5.2f ") + getUsrDistanceUnit(), toUsrDistance(dst));
2423 m_pWptListCtrl->SetItem(idx, colWPTDIST, dist);
2425 if (rp == rp_select) selected_id = (wxIntPtr)rp_select;
2430 lic.SetAlign(wxLIST_FORMAT_LEFT);
2431 m_pWptListCtrl->SetItem(lic);
2434 lic.SetAlign(wxLIST_FORMAT_LEFT);
2435 m_pWptListCtrl->SetItem(lic);
2437 if (!rp->IsVisible()) b_anyHidden =
true;
2442 node = node->GetNext();
2445 if (!b_retain_sort) {
2446 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2447 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2448 sort_wp_key = SORT_ON_NAME;
2450 switch (sort_wp_key) {
2452 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2453 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2455 case SORT_ON_DISTANCE:
2456 m_pWptListCtrl->SortItems(SortWaypointsOnDistance,
2457 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2462 if (selected_id != wxUIntPtr(0)) {
2463 item = m_pWptListCtrl->FindItem(-1, selected_id);
2464 m_pWptListCtrl->SetItemState(item,
2465 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
2466 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
2469 if ((m_lastWptItem >= 0) && (m_pWptListCtrl->GetItemCount()))
2470 m_pWptListCtrl->EnsureVisible(m_lastWptItem);
2472 if (pWayPointMan->Getpmarkicon_image_list(m_listIconSize)->GetImageCount()) {
2473 int iwidth, iheight;
2474 pWayPointMan->Getpmarkicon_image_list(m_listIconSize)
2475 ->GetSize(0, iwidth, iheight);
2477 m_pWptListCtrl->SetColumnWidth(0, wxMax(iwidth + 4, 4 * m_charWidth));
2482 m_cbShowAllWP->SetValue(!b_anyHidden);
2485 void RouteManagerDialog::UpdateWptListCtrlViz() {
2488 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2489 wxLIST_STATE_DONTCARE);
2490 if (item == -1)
break;
2495 m_pWptListCtrl->SetItemImage(item, imageIndex);
2499 void RouteManagerDialog::OnWptDefaultAction(wxListEvent &event) {
2501 OnWptPropertiesClick(evt);
2504 void RouteManagerDialog::OnWptSelected(wxListEvent &event) {
2508 void RouteManagerDialog::OnWptColumnClicked(wxListEvent &event) {
2509 if (event.m_col == NAME_COLUMN) {
2511 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2512 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2513 sort_wp_key = SORT_ON_NAME;
2515 if (event.m_col == DISTANCE_COLUMN) {
2517 m_pWptListCtrl->SortItems(SortWaypointsOnDistance,
2518 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2519 sort_wp_key = SORT_ON_DISTANCE;
2522 UpdateWptListCtrl();
2525 void RouteManagerDialog::UpdateWptButtons() {
2528 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2529 bool enable1 = (m_pWptListCtrl->GetSelectedItemCount() == 1);
2530 bool enablemultiple = (m_pWptListCtrl->GetSelectedItemCount() >= 1);
2533 m_lastWptItem = item;
2539 bool b_delete_enable =
true;
2542 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2543 wxLIST_STATE_SELECTED);
2544 if (item == -1)
break;
2548 if (wp && wp->m_bIsInLayer) {
2549 b_delete_enable =
false;
2554 btnWptProperties->Enable(enablemultiple);
2555 btnWptZoomto->Enable(enable1);
2556 btnWptDeleteAll->Enable(m_pWptListCtrl->GetItemCount() > 0);
2557 btnWptDelete->Enable(b_delete_enable && enablemultiple);
2558 btnWptGoTo->Enable(enable1);
2559 btnWptExport->Enable(enablemultiple);
2560 btnWptSendToGPS->Enable(enable1);
2561 btnWptSendToPeer->Enable(enablemultiple);
2564 void RouteManagerDialog::OnWptToggleVisibility(wxMouseEvent &event) {
2565 wxPoint pos =
event.GetPosition();
2567 long clicked_index = m_pWptListCtrl->HitTest(pos, flags);
2570 if (clicked_index > -1 &&
2571 event.GetX() < m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE)) {
2575 if (!wp->IsSharedInVisibleRoute()) {
2576 wp->SetVisible(!wp->IsVisible());
2577 m_pWptListCtrl->SetItemImage(clicked_index,
RoutePointGui(*wp).GetIconImageIndex());
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);
2619 void RouteManagerDialog::OnWptNewClick(wxCommandEvent &event) {
2622 pWP->m_bIsolatedMark =
true;
2623 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP);
2624 pConfig->AddNewWayPoint(pWP, -1);
2625 gFrame->RefreshAllCanvas();
2628 if (!g_pMarkInfoDialog)
2632 WptShowPropertiesDialog(std::vector<RoutePoint*> {pWP}, GetParent());
2635 void RouteManagerDialog::OnWptPropertiesClick(wxCommandEvent &event) {
2636 std::vector<RoutePoint *> wptlist;
2637 long item = wxNOT_FOUND;
2638 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2639 while (item != wxNOT_FOUND)
2641 auto wp = (
RoutePoint *)m_pWptListCtrl->GetItemData(item);
2643 wptlist.push_back(wp);
2645 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2648 if (wptlist.size() == 0)
return;
2650 WptShowPropertiesDialog(wptlist, GetParent());
2652 UpdateWptListCtrl();
2653 m_bNeedConfigFlush =
true;
2656 void RouteManagerDialog::WptShowPropertiesDialog(std::vector<RoutePoint *> wptlist,
2658 if (!g_pMarkInfoDialog)
2662 g_pMarkInfoDialog->SetRoutePoints(wptlist);
2663 g_pMarkInfoDialog->UpdateProperties();
2665 wxString base_title = _(
"Mark Properties");
2666 if (wptlist[0]->m_bIsInRoute)
2667 base_title = _(
"Waypoint Properties");
2669 if (wptlist[0]->m_bIsInLayer) {
2670 wxString caption(wxString::Format(_T(
"%s, %s: %s"),
2671 base_title, _(
"Layer"),
2672 GetLayerName(wptlist[0]->m_LayerID)));
2673 g_pMarkInfoDialog->SetDialogTitle(caption);
2675 if (wptlist.size() > 1)
2676 g_pMarkInfoDialog->SetDialogTitle(base_title + wxString::Format(_(
" (%lu points)"), wptlist.size()));
2678 g_pMarkInfoDialog->SetDialogTitle(base_title);
2681 if (!g_pMarkInfoDialog->IsShown()) g_pMarkInfoDialog->Show();
2682 g_pMarkInfoDialog->Raise();
2685 void RouteManagerDialog::OnWptZoomtoClick(wxCommandEvent &event) {
2688 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2689 if (item == -1)
return;
2695 if (gFrame->GetFocusCanvas()) {
2696 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), wp->m_lat, wp->m_lon,
2697 gFrame->GetFocusCanvas()->GetVPScale());
2701 void RouteManagerDialog::OnWptDeleteClick(wxCommandEvent &event) {
2702 RoutePointList list;
2704 int answer = OCPNMessageBox(
2705 this, _(
"Are you sure you want to delete the selected object(s)"),
2706 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2707 if (answer != wxID_YES)
return;
2710 if (m_pWptListCtrl->GetSelectedItemCount()) {
2711 ::wxBeginBusyCursor();
2712 m_bNeedConfigFlush =
true;
2717 long item_last_selected = -1;
2719 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2720 wxLIST_STATE_SELECTED);
2721 if (item == -1)
break;
2723 item_last_selected = item;
2726 if (wp && !wp->m_bIsInLayer) list.Append(wp);
2730 for (
unsigned int i = 0; i < list.GetCount(); i++) {
2733 if (wp->m_bIsInRoute) {
2735 OCPNMessageBox(
this,
2736 _(
"The waypoint you want to delete is used in a "
2737 "route, do you really want to delete it?"),
2738 _(
"OpenCPN Alert"), wxYES_NO))
2739 pWayPointMan->DestroyWaypoint(wp);
2741 pWayPointMan->DestroyWaypoint(wp);
2746 m_pWptListCtrl->GetNextItem(item_last_selected);
2749 wp_next = (
RoutePoint *)m_pWptListCtrl->GetItemData(item_next);
2751 m_lastWptItem = item_next;
2753 UpdateRouteListCtrl();
2754 UpdateTrkListCtrl();
2755 UpdateWptListCtrl(wp_next,
true);
2757 if (g_pMarkInfoDialog) {
2758 g_pMarkInfoDialog->ClearData();
2761 gFrame->InvalidateAllCanvasUndo();
2762 gFrame->RefreshAllCanvas();
2763 ::wxEndBusyCursor();
2767 void RouteManagerDialog::OnWptGoToClick(wxCommandEvent &event) {
2770 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2771 if (item == -1)
return;
2778 wxEmptyString, wxEmptyString);
2779 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
2782 pRouteList->Append(temp_route);
2784 temp_route->AddPoint(pWP_src);
2785 temp_route->AddPoint(wp);
2787 pSelect->AddSelectableRouteSegment(gLat, gLon, wp->m_lat, wp->m_lon, pWP_src,
2790 wxString name = wp->GetName();
2791 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
2792 wxString rteName = _(
"Go to ");
2793 rteName.Append(name);
2794 temp_route->m_RouteNameString = rteName;
2795 temp_route->m_RouteStartString = _(
"Here");
2797 temp_route->m_RouteEndString = name;
2798 temp_route->m_bDeleteOnArrival =
true;
2800 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
2802 g_pRouteMan->ActivateRoute(temp_route, wp);
2804 UpdateRouteListCtrl();
2807 void RouteManagerDialog::OnWptExportClick(wxCommandEvent &event) {
2808 RoutePointList list;
2810 wxString suggested_name = _T(
"waypoints");
2814 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2815 wxLIST_STATE_SELECTED);
2816 if (item == -1)
break;
2820 if (wp && !wp->m_bIsInLayer) {
2822 if (wp->GetName() != wxEmptyString) suggested_name = wp->GetName();
2826 ExportGPXWaypoints(
this, &list, suggested_name);
2829 void RouteManagerDialog::OnWptSendToGPSClick(wxCommandEvent &event) {
2832 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2833 if (item == -1)
return;
2840 pdlg->SetWaypoint(wp);
2843 pdlg->Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), source);
2846 HideWithEffect(wxSHOW_EFFECT_BLEND);
2850 ShowWithEffect(wxSHOW_EFFECT_BLEND);
2856 void RouteManagerDialog::OnWptDeleteAllClick(wxCommandEvent &event) {
2859 if (!pWayPointMan->SharedWptsExist()) {
2860 prompt = _(
"Are you sure you want to delete <ALL> waypoints?");
2865 _(
"There are some waypoints used in routes or anchor alarms.\n Do you "
2866 "want to delete them as well?\n This will change the routes and "
2867 "disable the anchor alarms.\n Answering No keeps the waypoints used "
2868 "in routes or alarms.");
2869 buttons = wxYES_NO | wxCANCEL;
2873 OCPNMessageBox(
this, prompt, wxString(_(
"OpenCPN Alert")), buttons);
2874 if (answer == wxID_YES) pWayPointMan->DeleteAllWaypoints(
true);
2875 if (answer == wxID_NO && type == 2)
2876 pWayPointMan->DeleteAllWaypoints(
false);
2878 if (g_pMarkInfoDialog) {
2879 g_pMarkInfoDialog->ClearData();
2883 UpdateRouteListCtrl();
2884 UpdateWptListCtrl();
2885 gFrame->InvalidateAllCanvasUndo();
2886 gFrame->RefreshAllCanvas();
2889 void RouteManagerDialog::OnLaySelected(wxListEvent &event) {
2893 void RouteManagerDialog::OnLayColumnClicked(wxListEvent &event) {
2894 if (event.m_col == 1) {
2895 sort_layer_name_dir++;
2896 m_pLayListCtrl->SortItems(SortLayersOnName, (wxIntPtr)NULL);
2897 }
else if (event.m_col == 2) {
2898 sort_layer_len_dir++;
2899 m_pLayListCtrl->SortItems(SortLayersOnSize, (wxIntPtr)NULL);
2903 void RouteManagerDialog::UpdateLayButtons() {
2906 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2907 bool enable = (item != -1);
2910 btnLayDelete->Enable(enable);
2911 cbLayToggleChart->Enable(enable);
2912 cbLayToggleListing->Enable(enable);
2913 cbLayToggleNames->Enable(enable);
2916 cbLayToggleChart->SetValue(
2917 ((
Layer *)m_pLayListCtrl->GetItemData(item))->IsVisibleOnChart());
2919 cbLayToggleNames->Set3StateValue(
2920 ((
Layer *)m_pLayListCtrl->GetItemData(item))->HasVisibleNames());
2922 cbLayToggleListing->SetValue(
2923 ((
Layer *)m_pLayListCtrl->GetItemData(item))->IsVisibleOnListing());
2926 cbLayToggleChart->SetValue(
true);
2927 cbLayToggleNames->Set3StateValue(wxCHK_UNDETERMINED);
2928 cbLayToggleListing->SetValue(
true);
2932 void RouteManagerDialog::OnLayToggleVisibility(wxMouseEvent &event) {
2933 wxPoint pos =
event.GetPosition();
2935 long clicked_index = m_pLayListCtrl->HitTest(pos, flags);
2938 if (clicked_index > -1 &&
2939 event.GetX() < m_pLayListCtrl->GetColumnWidth(colLAYVISIBLE)) {
2941 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(clicked_index);
2943 layer->SetVisibleOnChart(!layer->IsVisibleOnChart());
2944 m_pLayListCtrl->SetItemImage(clicked_index,
2945 layer->IsVisibleOnChart() ? 0 : 1);
2951 item = m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2952 wxLIST_STATE_DONTCARE);
2953 if (item == -1)
break;
2955 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
2957 if (!layer->IsVisibleOnChart()) {
2962 m_cbShowAllLay->SetValue(viz);
2964 ToggleLayerContentsOnChart(layer);
2971 void RouteManagerDialog::UpdateLists() {
2972 UpdateRouteListCtrl();
2973 UpdateTrkListCtrl();
2974 UpdateWptListCtrl();
2975 UpdateLayListCtrl();
2978 void RouteManagerDialog::OnLayNewClick(wxCommandEvent &event) {
2982 void RouteManagerDialog::OnPerLayNewClick(wxCommandEvent &event) {
2986 void RouteManagerDialog::AddNewLayer(
bool isPersistent) {
2987 bool show_flag = g_bShowLayers;
2988 g_bShowLayers =
true;
2990 UI_ImportGPX(
this,
true, _T(
""),
true, isPersistent);
2992 g_bShowLayers = show_flag;
2994 gFrame->RefreshAllCanvas();
2997 void RouteManagerDialog::OnLayPropertiesClick(wxCommandEvent &event) {
3001 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3002 if (item == -1)
return;
3005 void RouteManagerDialog::OnLayDeleteClick(wxCommandEvent &event) {
3008 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3009 if (item == -1)
return;
3011 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3017 bool ispers =
false;
3018 wxString destf, f, name, ext;
3019 f = layer->m_LayerFileName;
3020 wxFileName::SplitPath(f, NULL, NULL, &name, &ext);
3022 appendOSDirSlash(&destf);
3023 destf.Append(_T(
"layers"));
3024 appendOSDirSlash(&destf);
3025 destf << name << _T(
".") << ext;
3027 wxString prompt = _(
3028 "Are you sure you want to delete this layer and <ALL> of its contents?");
3029 if (wxFileExists(destf)) {
3030 prompt.Append(_T(
"\n"));
3032 _(
"The file will also be deleted from OpenCPN's layer directory."));
3033 prompt.Append(_T(
"\n (") + destf + _T(
")" ));
3037 OCPNMessageBox(
this, prompt, wxString(_(
"OpenCPN Alert")), wxYES_NO);
3038 if (answer == wxID_NO)
return;
3043 if (wxRemoveFile(destf))
3044 remMSG.sprintf(_T(
"Layer file: %s is deleted"), destf);
3046 remMSG.sprintf(_T(
"Error deleting Layer file: %s"), destf);
3048 wxLogMessage(remMSG);
3052 wxRouteListNode *node1 = pRouteList->GetFirst();
3054 Route *pRoute = node1->GetData();
3055 wxRouteListNode *next_node = node1->GetNext();
3056 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3057 pRoute->m_bIsInLayer =
false;
3058 pRoute->m_LayerID = 0;
3059 g_pRouteMan->
DeleteRoute(pRoute, NavObjectChanges::getInstance());
3064 for (
Track *pTrack : g_TrackList) {
3065 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID)) {
3066 pTrack->m_bIsInLayer =
false;
3067 pTrack->m_LayerID = 0;
3073 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3074 wxRoutePointListNode *node3;
3077 node3 = node->GetNext();
3079 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3080 rp->m_bIsInLayer =
false;
3082 pWayPointMan->DestroyWaypoint(
3090 if (g_pMarkInfoDialog) {
3091 g_pMarkInfoDialog->ClearData();
3094 pLayerList->DeleteObject(layer);
3098 gFrame->RefreshAllCanvas();
3100 m_bNeedConfigFlush =
false;
3103 void RouteManagerDialog::OnLayToggleChartClick(wxCommandEvent &event) {
3107 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3108 if (item == -1)
return;
3110 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3114 layer->SetVisibleOnChart(!layer->IsVisibleOnChart());
3115 m_pLayListCtrl->SetItemImage(item, layer->IsVisibleOnChart() ? 0 : 1);
3117 ToggleLayerContentsOnChart(layer);
3120 void RouteManagerDialog::ToggleLayerContentsOnChart(
Layer *layer) {
3122 wxRouteListNode *node1 = pRouteList->GetFirst();
3124 Route *pRoute = node1->GetData();
3125 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3126 pRoute->SetVisible(layer->IsVisibleOnChart());
3128 node1 = node1->GetNext();
3131 for (
Track* pTrack : g_TrackList) {
3132 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID))
3133 pTrack->SetVisible(layer->IsVisibleOnChart());
3137 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3141 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3142 rp->SetVisible(layer->IsVisibleOnChart());
3145 node = node->GetNext();
3151 gFrame->RefreshAllCanvas();
3154 void RouteManagerDialog::OnLayToggleNamesClick(wxCommandEvent &event) {
3158 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3159 if (item == -1)
return;
3161 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3165 layer->SetVisibleNames(cbLayToggleNames->Get3StateValue());
3167 ToggleLayerContentsNames(layer);
3170 void RouteManagerDialog::ToggleLayerContentsNames(
Layer *layer) {
3172 wxRouteListNode *node1 = pRouteList->GetFirst();
3174 Route *pRoute = node1->GetData();
3175 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3176 wxRoutePointListNode *node = pRoute->pRoutePointList->GetFirst();
3179 if (layer->HasVisibleNames() == wxCHK_UNDETERMINED) {
3180 prp1->m_bShowName = prp1->m_bShowNameData;
3182 prp1->m_bShowName = (layer->HasVisibleNames() == wxCHK_CHECKED);
3184 node = node->GetNext();
3187 node1 = node1->GetNext();
3191 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3195 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3196 rp->SetNameShown(layer->HasVisibleNames() == wxCHK_CHECKED ||
3197 (rp->m_bShowNameData &&
3198 layer->HasVisibleNames() == wxCHK_UNDETERMINED));
3201 node = node->GetNext();
3206 gFrame->RefreshAllCanvas();
3209 void RouteManagerDialog::OnLayToggleListingClick(wxCommandEvent &event) {
3213 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3214 if (item == -1)
return;
3216 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3220 layer->SetVisibleOnListing(!layer->IsVisibleOnListing());
3222 ToggleLayerContentsOnListing(layer);
3225 void RouteManagerDialog::ToggleLayerContentsOnListing(
Layer *layer) {
3226 ::wxBeginBusyCursor();
3229 wxRouteListNode *node1 = pRouteList->GetFirst();
3231 Route *pRoute = node1->GetData();
3232 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3233 pRoute->SetListed(layer->IsVisibleOnListing());
3235 node1 = node1->GetNext();
3238 for (
Track *pTrack : g_TrackList) {
3239 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID))
3240 pTrack->SetListed(layer->IsVisibleOnListing());
3247 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3251 if (rp && rp->m_bIsolatedMark && (rp->m_LayerID == layer->m_LayerID)) {
3252 rp->SetListed(layer->IsVisibleOnListing());
3255 node = node->GetNext();
3260 ::wxEndBusyCursor();
3262 gFrame->RefreshAllCanvas();
3265 void RouteManagerDialog::OnLayDefaultAction(wxListEvent &event) {
3267 OnLayPropertiesClick(evt);
3270 void RouteManagerDialog::UpdateLayListCtrl() {
3274 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3276 wxUIntPtr selected_id = wxUIntPtr(0);
3277 if (item != -1) selected_id = m_pLayListCtrl->GetItemData(item);
3280 m_pLayListCtrl->DeleteAllItems();
3283 LayerList::iterator it;
3285 bool b_anyHidden =
false;
3286 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
3289 if (!lay->m_LayerName.Upper().Contains(m_tFilterLay->GetValue().Upper())) {
3295 li.SetImage(lay->IsVisibleOnChart() ? 0 : 1);
3299 long idx = m_pLayListCtrl->InsertItem(li);
3301 wxString name = lay->m_LayerName;
3302 if (name.IsEmpty()) {
3309 name = _(
"(Unnamed Layer)");
3311 m_pLayListCtrl->SetItem(idx, colLAYNAME, name);
3314 len.Printf(wxT(
"%d"), (
int)lay->m_NoOfItems);
3315 m_pLayListCtrl->SetItem(idx, colLAYITEMS, len);
3316 m_pLayListCtrl->SetItem(idx, colLAYPERSIST, lay->m_LayerType);
3321 lic.SetAlign(wxLIST_FORMAT_LEFT);
3322 m_pLayListCtrl->SetItem(lic);
3325 lic.SetAlign(wxLIST_FORMAT_LEFT);
3326 m_pLayListCtrl->SetItem(lic);
3328 if (!lay->IsVisibleOnChart()) b_anyHidden =
true;
3331 m_pLayListCtrl->SortItems(SortLayersOnName,
3332 reinterpret_cast<wxIntPtr
>(m_pLayListCtrl));
3333 m_pLayListCtrl->SetColumnWidth(0, 4 * m_charWidth);
3338 if (selected_id != wxUIntPtr(0)) {
3339 item = m_pLayListCtrl->FindItem(-1, selected_id);
3340 m_pLayListCtrl->SetItemState(item,
3341 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
3342 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
3346 m_cbShowAllLay->SetValue(!b_anyHidden);
3349 void RouteManagerDialog::OnImportClick(wxCommandEvent &event) {
3358 gFrame->RefreshAllCanvas();
3360 void RouteManagerDialog::OnExportClick(wxCommandEvent &event) {
3364 void RouteManagerDialog::OnExportVizClick(wxCommandEvent &event) {
3365 ExportGPX(
this,
true,
true);
3368 void RouteManagerDialog::OnFilterChanged(wxCommandEvent &event) {
3369 if (event.GetEventObject() == m_tFilterWpt) {
3370 UpdateWptListCtrl(NULL,
true);
3371 }
else if (event.GetEventObject() == m_tFilterRte) {
3372 UpdateRouteListCtrl();
3373 }
else if (event.GetEventObject() == m_tFilterTrk) {
3374 UpdateTrkListCtrl();
3375 }
else if (event.GetEventObject() == m_tFilterLay) {
3376 UpdateLayListCtrl();
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.
EventVar on_routes_update
Notified when list of routes is updated (no data in event)
bool DeleteRoute(Route *pRoute, NavObjectChanges *nav_obj_changes)
Route "Send to GPS..." Dialog Definition.
Route "Send to Peer..." Dialog Definition.