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"));
1345 if (route && route->m_bRtIsActive) {
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);
1523 if (route->m_bIsInLayer)
return;
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);
1535 wxString startend = route->m_RouteStartString;
1536 if (!route->m_RouteEndString.IsEmpty())
1537 startend.append(_(
" - ") + route->m_RouteEndString);
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);
1562 if (proute_to_export->m_RouteNameString != wxEmptyString)
1563 suggested_name = proute_to_export->m_RouteNameString;
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);
1579 if (route->m_bIsInLayer)
return;
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);
1695 if (!route->m_bRtIsActive) {
1696 if (!route->IsVisible()) {
1697 route->SetVisible(
true);
1698 m_pRouteListCtrl->SetItemImage(item, 0, 0);
1704 g_pRouteMan->FindBestActivatePoint(route, gLat, gLon, gCog, gSog);
1705 g_pRouteMan->ActivateRoute(route, best_point);
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) {
1856 return start1->GetCreateTime() < start2->GetCreateTime();
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 std::sort(mergeList.begin(), mergeList.end(), CompareTracks);
1970 targetTrack = mergeList[0];
1971 lastPoint = targetTrack->GetLastPoint();
1973 for (
auto const &mergeTrack : mergeList) {
1974 if (mergeTrack == *mergeList.begin())
continue;
1976 if (mergeTrack->IsRunning()) {
1977 runningSkipped =
true;
1981 for (
int i = 0; i < mergeTrack->GetnPoints(); i++) {
1982 tPoint = mergeTrack->GetPoint(i);
1983 newPoint =
new TrackPoint(tPoint->m_lat, tPoint->m_lon,
1984 tPoint->GetCreateTime());
1986 targetTrack->AddPoint(newPoint);
1988 pSelect->AddSelectableTrackSegment(lastPoint->m_lat, lastPoint->m_lon,
1989 newPoint->m_lat, newPoint->m_lon,
1990 lastPoint, newPoint, targetTrack);
1992 lastPoint = newPoint;
1994 deleteList.push_back(mergeTrack);
1997 for (
auto const &deleteTrack : deleteList) {
1998 g_pAIS->DeletePersistentTrack(deleteTrack);
1999 pConfig->DeleteConfigTrack(deleteTrack);
2000 RoutemanGui(*g_pRouteMan).DeleteTrack(deleteTrack);
2006 ::wxEndBusyCursor();
2008 UpdateTrkListCtrl();
2009 UpdateRouteListCtrl();
2010 gFrame->RefreshAllCanvas();
2012 if (runningSkipped) {
2013 wxMessageDialog skipWarning(
2015 _(
"The currently running Track was not merged.\nYou can merge it "
2016 "later when it is completed."),
2017 _T(
"Warning"), wxCANCEL | wxICON_WARNING);
2018 skipWarning.ShowModal();
2026void RouteManagerDialog::UpdateTrkListCtrl() {
2030 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2032 wxUIntPtr selected_id = wxUIntPtr(0);
2033 if (item != -1) selected_id = m_pTrkListCtrl->GetItemData(item);
2036 m_pTrkListCtrl->DeleteAllItems();
2039 std::vector<Track *>::iterator it;
2042 bool bpartialViz =
false;
2044 for (
Track *trk : g_TrackList) {
2045 if (!trk->IsVisible()) bpartialViz =
true;
2047 if (!trk->IsListed())
continue;
2049 if (!trk->GetName(
true).Upper().Contains(
2050 m_tFilterTrk->GetValue().Upper())) {
2055 li.SetId(list_index);
2056 li.SetImage(trk->IsVisible() ? 0 : 1);
2060 if (g_pActiveTrack == trk) {
2061 wxFont font = *wxNORMAL_FONT;
2062 font.SetWeight(wxFONTWEIGHT_BOLD);
2065 long idx = m_pTrkListCtrl->InsertItem(li);
2067 m_pTrkListCtrl->SetItem(idx, colTRKNAME, trk->GetName(
true));
2070 m_pTrkListCtrl->SetItem(idx, colTRKDATE, trk->GetDateTime());
2073 len.Printf(wxT(
"%5.2f"), trk->Length());
2074 m_pTrkListCtrl->SetItem(idx, colTRKLENGTH, len);
2077 lic.SetId(list_index);
2079 lic.SetAlign(wxLIST_FORMAT_LEFT);
2080 m_pTrkListCtrl->SetItem(lic);
2083 lic.SetAlign(wxLIST_FORMAT_LEFT);
2084 m_pTrkListCtrl->SetItem(lic);
2089 switch (sort_track_key) {
2090 case SORT_ON_DISTANCE:
2091 m_pTrkListCtrl->SortItems(SortTracksOnDistance, (wxIntPtr)NULL);
2094 m_pTrkListCtrl->SortItems(SortTracksOnDate, (wxIntPtr)NULL);
2098 m_pTrkListCtrl->SortItems(SortTracksOnName, (wxIntPtr)NULL);
2102 m_pTrkListCtrl->SetColumnWidth(0, 4 * m_charWidth);
2107 if (selected_id != wxUIntPtr(0)) {
2108 item = m_pTrkListCtrl->FindItem(-1, selected_id);
2109 m_pTrkListCtrl->SetItemState(item,
2110 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
2111 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
2114 if ((m_lastTrkItem >= 0) && (m_pTrkListCtrl->GetItemCount()))
2115 m_pTrkListCtrl->EnsureVisible(m_lastTrkItem);
2117 m_cbShowAllTrk->SetValue(!bpartialViz);
2121void RouteManagerDialog::OnTrkSelected(wxListEvent &event) {
2125void RouteManagerDialog::OnTrkColumnClicked(wxListEvent &event) {
2126 if (event.m_col == 1) {
2127 sort_track_key = SORT_ON_NAME;
2128 sort_track_name_dir++;
2129 m_pTrkListCtrl->SortItems(SortTracksOnName, (wxIntPtr)NULL);
2130 }
else if (event.m_col == 2) {
2131 sort_track_key = SORT_ON_DISTANCE;
2132 sort_track_len_dir++;
2133 m_pTrkListCtrl->SortItems(SortTracksOnDistance, (wxIntPtr)NULL);
2134 }
else if (event.m_col == 3) {
2135 sort_track_key = SORT_ON_DATE;
2136 sort_track_date_dir++;
2137 m_pTrkListCtrl->SortItems(SortTracksOnDate, (wxIntPtr)NULL);
2141void RouteManagerDialog::UpdateTrkButtons() {
2144 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2145 int items = m_pTrkListCtrl->GetSelectedItemCount();
2147 m_lastTrkItem = item;
2149 btnTrkProperties->Enable(items == 1);
2150 btnTrkDelete->Enable(items >= 1);
2151 btnTrkExport->Enable(items >= 1);
2152 btnTrkRouteFromTrack->Enable(items == 1);
2153 btnTrkDeleteAll->Enable(m_pTrkListCtrl->GetItemCount() > 0);
2154 btnTrkSendToPeer->Enable(items >= 1);
2157void RouteManagerDialog::OnTrkToggleVisibility(wxMouseEvent &event) {
2158 wxPoint pos =
event.GetPosition();
2160 long clicked_index = m_pTrkListCtrl->HitTest(pos, flags);
2163 if (clicked_index > -1 &&
2164 event.GetX() < m_pTrkListCtrl->GetColumnWidth(colTRKVISIBLE)) {
2166 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(clicked_index);
2168 track->SetVisible(!track->IsVisible());
2169 m_pTrkListCtrl->SetItemImage(clicked_index, track->IsVisible() ? 0 : 1);
2176 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2177 wxLIST_STATE_DONTCARE);
2178 if (item == -1)
break;
2180 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2182 if (!track->IsVisible()) {
2187 m_cbShowAllTrk->SetValue(viz);
2189 gFrame->RefreshAllCanvas();
2196void RouteManagerDialog::OnTrkNewClick(wxCommandEvent &event) {
2198 if (pConfig && pConfig->IsChangesFileDirty()) {
2199 pConfig->UpdateNavObj(
true);
2204 UpdateTrkListCtrl();
2207void RouteManagerDialog::OnTrkPropertiesClick(wxCommandEvent &event) {
2211 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2212 if (item == -1)
return;
2214 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2218 pTrackPropDialog = TrackPropDlg::getInstance(GetParent());
2219 pTrackPropDialog->SetTrackAndUpdate(track);
2221 if (!pTrackPropDialog->IsShown()) pTrackPropDialog->Show();
2222 UpdateTrkListCtrl();
2224 m_bNeedConfigFlush =
true;
2227void RouteManagerDialog::OnTrkDeleteClick(wxCommandEvent &event) {
2228 std::vector<Track *> list;
2230 int answer = OCPNMessageBox(
2231 this, _(
"Are you sure you want to delete the selected object(s)"),
2232 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2233 if (answer != wxID_YES)
return;
2236 if (m_pTrkListCtrl->GetSelectedItemCount()) {
2237 ::wxBeginBusyCursor();
2238 m_bNeedConfigFlush =
true;
2244 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2245 wxLIST_STATE_SELECTED);
2246 if (item == -1)
break;
2248 Track *ptrack_to_delete = (
Track *)m_pTrkListCtrl->GetItemData(item);
2250 if (ptrack_to_delete) list.push_back(ptrack_to_delete);
2254 for (
unsigned int i = 0; i < list.size(); i++) {
2255 Track *track = list.at(i);
2257 g_pAIS->DeletePersistentTrack(track);
2258 pConfig->DeleteConfigTrack(track);
2265 UpdateTrkListCtrl();
2267 if (pConfig && pConfig->IsChangesFileDirty()) {
2268 pConfig->UpdateNavObj(
true);
2271 gFrame->InvalidateAllCanvasUndo();
2272 gFrame->RefreshAllCanvas();
2273 ::wxEndBusyCursor();
2277void RouteManagerDialog::OnTrkExportClick(wxCommandEvent &event) {
2278 std::vector<Track *> list;
2279 wxString suggested_name = _T(
"tracks");
2283 item = m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2284 wxLIST_STATE_SELECTED);
2285 if (item == -1)
break;
2287 Track *ptrack_to_export = (
Track *)m_pTrkListCtrl->GetItemData(item);
2289 if (ptrack_to_export) {
2290 list.push_back(ptrack_to_export);
2291 if (ptrack_to_export->GetName() != wxEmptyString)
2292 suggested_name = ptrack_to_export->GetName();
2296 ExportGPXTracks(
this, &list, suggested_name);
2299void RouteManagerDialog::TrackToRoute(
Track *track) {
2301 if (track->m_bIsInLayer)
return;
2303 wxGenericProgressDialog pprog(_(
"OpenCPN Converting Track to Route...."),
2304 _(
"Processing Waypoints..."), 101, NULL,
2305 wxPD_AUTO_HIDE | wxPD_SMOOTH |
2306 wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
2307 wxPD_REMAINING_TIME);
2309 ::wxBeginBusyCursor();
2311 Route *route = track->RouteFromTrack(&pprog);
2313 pRouteList->Append(route);
2315 pprog.Update(101, _(
"Done."));
2317 gFrame->RefreshAllCanvas();
2319 ::wxEndBusyCursor();
2322void RouteManagerDialog::OnTrkRouteFromTrackClick(wxCommandEvent &event) {
2325 m_pTrkListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2326 if (item == -1)
return;
2328 Track *track = (
Track *)m_pTrkListCtrl->GetItemData(item);
2330 TrackToRoute(track);
2332 UpdateRouteListCtrl();
2335void RouteManagerDialog::OnTrkDeleteAllClick(wxCommandEvent &event) {
2337 OCPNMessageBox(
this, _(
"Are you sure you want to delete <ALL> tracks?"),
2338 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2340 if (dialog_ret == wxID_YES) {
2347 UpdateTrkListCtrl();
2351 UpdateRouteListCtrl();
2353 if (pRoutePropDialog) pRoutePropDialog->Hide();
2355 gFrame->RefreshAllCanvas();
2357 m_bNeedConfigFlush =
true;
2360void RouteManagerDialog::UpdateWptListCtrl(
RoutePoint *rp_select,
2361 bool b_retain_sort) {
2362 wxIntPtr selected_id = wxUIntPtr(0);
2365 if (NULL == rp_select) {
2367 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2368 wxLIST_STATE_SELECTED);
2370 if (item != -1) selected_id = m_pWptListCtrl->GetItemData(item);
2374 m_pWptListCtrl->SetImageList(
2375 pWayPointMan->Getpmarkicon_image_list(m_listIconSize),
2376 wxIMAGE_LIST_SMALL);
2378 m_pWptListCtrl->DeleteAllItems();
2380 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
2383 bool b_anyHidden =
false;
2386 if (rp && rp->IsListed()) {
2387 if (rp->m_bIsInRoute && !rp->IsShared()) {
2388 node = node->GetNext();
2392 if (!rp->GetName().Upper().Contains(m_tFilterWpt->GetValue().Upper())) {
2393 node = node->GetNext();
2402 long idx = m_pWptListCtrl->InsertItem(li);
2404 wxString scamin = wxString::Format(_T(
"%i"), (
int)rp->GetScaMin());
2405 if (!rp->GetUseSca()) scamin = _(
"Always");
2406 if (g_bOverruleScaMin) scamin = _(
"Overruled");
2407 m_pWptListCtrl->SetItem(idx, colWPTSCALE, scamin);
2409 wxString name = rp->GetName();
2410 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
2411 m_pWptListCtrl->SetItem(idx, colWPTNAME, name);
2414 DistanceBearingMercator(rp->m_lat, rp->m_lon, gLat, gLon, NULL, &dst);
2416 dist.Printf(_T(
"%5.2f ") + getUsrDistanceUnit(), toUsrDistance(dst));
2417 m_pWptListCtrl->SetItem(idx, colWPTDIST, dist);
2419 if (rp == rp_select) selected_id = (wxIntPtr)rp_select;
2424 lic.SetAlign(wxLIST_FORMAT_LEFT);
2425 m_pWptListCtrl->SetItem(lic);
2428 lic.SetAlign(wxLIST_FORMAT_LEFT);
2429 m_pWptListCtrl->SetItem(lic);
2431 if (!rp->IsVisible()) b_anyHidden =
true;
2436 node = node->GetNext();
2439 if (!b_retain_sort) {
2440 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2441 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2442 sort_wp_key = SORT_ON_NAME;
2444 switch (sort_wp_key) {
2446 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2447 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2449 case SORT_ON_DISTANCE:
2450 m_pWptListCtrl->SortItems(SortWaypointsOnDistance,
2451 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2456 if (selected_id != wxUIntPtr(0)) {
2457 item = m_pWptListCtrl->FindItem(-1, selected_id);
2458 m_pWptListCtrl->SetItemState(item,
2459 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
2460 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
2463 if ((m_lastWptItem >= 0) && (m_pWptListCtrl->GetItemCount()))
2464 m_pWptListCtrl->EnsureVisible(m_lastWptItem);
2466 if (pWayPointMan->Getpmarkicon_image_list(m_listIconSize)->GetImageCount()) {
2467 int iwidth, iheight;
2468 pWayPointMan->Getpmarkicon_image_list(m_listIconSize)
2469 ->GetSize(0, iwidth, iheight);
2471 m_pWptListCtrl->SetColumnWidth(0, wxMax(iwidth + 4, 4 * m_charWidth));
2476 m_cbShowAllWP->SetValue(!b_anyHidden);
2479void RouteManagerDialog::UpdateWptListCtrlViz() {
2482 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2483 wxLIST_STATE_DONTCARE);
2484 if (item == -1)
break;
2489 m_pWptListCtrl->SetItemImage(item, imageIndex);
2493void RouteManagerDialog::OnWptDefaultAction(wxListEvent &event) {
2495 OnWptPropertiesClick(evt);
2498void RouteManagerDialog::OnWptSelected(wxListEvent &event) {
2502void RouteManagerDialog::OnWptColumnClicked(wxListEvent &event) {
2503 if (event.m_col == NAME_COLUMN) {
2505 m_pWptListCtrl->SortItems(SortWaypointsOnName,
2506 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2507 sort_wp_key = SORT_ON_NAME;
2509 if (event.m_col == DISTANCE_COLUMN) {
2511 m_pWptListCtrl->SortItems(SortWaypointsOnDistance,
2512 reinterpret_cast<wxIntPtr
>(m_pWptListCtrl));
2513 sort_wp_key = SORT_ON_DISTANCE;
2516 UpdateWptListCtrl();
2519void RouteManagerDialog::UpdateWptButtons() {
2522 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2523 bool enable1 = (m_pWptListCtrl->GetSelectedItemCount() == 1);
2524 bool enablemultiple = (m_pWptListCtrl->GetSelectedItemCount() >= 1);
2527 m_lastWptItem = item;
2533 bool b_delete_enable =
true;
2536 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2537 wxLIST_STATE_SELECTED);
2538 if (item == -1)
break;
2542 if (wp && wp->m_bIsInLayer) {
2543 b_delete_enable =
false;
2548 btnWptProperties->Enable(enablemultiple);
2549 btnWptZoomto->Enable(enable1);
2550 btnWptDeleteAll->Enable(m_pWptListCtrl->GetItemCount() > 0);
2551 btnWptDelete->Enable(b_delete_enable && enablemultiple);
2552 btnWptGoTo->Enable(enable1);
2553 btnWptExport->Enable(enablemultiple);
2554 btnWptSendToGPS->Enable(enable1);
2555 btnWptSendToPeer->Enable(enablemultiple);
2558void RouteManagerDialog::OnWptToggleVisibility(wxMouseEvent &event) {
2559 wxPoint pos =
event.GetPosition();
2561 long clicked_index = m_pWptListCtrl->HitTest(pos, flags);
2564 if (clicked_index > -1 &&
2565 event.GetX() < m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE)) {
2569 if (!wp->IsSharedInVisibleRoute()) {
2570 wp->SetVisible(!wp->IsVisible());
2571 m_pWptListCtrl->SetItemImage(clicked_index,
2574 pConfig->UpdateWayPoint(wp);
2581 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2582 wxLIST_STATE_DONTCARE);
2583 if (item == -1)
break;
2587 if (!wp->IsVisible()) {
2592 m_cbShowAllWP->SetValue(viz);
2594 gFrame->RefreshAllCanvas();
2596 if (clicked_index > -1 &&
2597 event.GetX() > m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE) &&
2598 event.GetX() < (m_pWptListCtrl->GetColumnWidth(colTRKVISIBLE) +
2599 m_pWptListCtrl->GetColumnWidth(colWPTSCALE)) &&
2600 !g_bOverruleScaMin) {
2602 wp->SetUseSca(!wp->GetUseSca());
2603 pConfig->UpdateWayPoint(wp);
2604 gFrame->RefreshAllCanvas();
2605 wxString scamin = wxString::Format(_T(
"%i"), (
int)wp->GetScaMin());
2606 if (!wp->GetUseSca()) scamin = _(
"Always");
2607 m_pWptListCtrl->SetItem(clicked_index, colWPTSCALE, scamin);
2614void RouteManagerDialog::OnWptNewClick(wxCommandEvent &event) {
2618 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP);
2619 pConfig->AddNewWayPoint(pWP, -1);
2620 gFrame->RefreshAllCanvas();
2624 if (!g_pMarkInfoDialog) g_pMarkInfoDialog =
new MarkInfoDlg(GetParent());
2626 WptShowPropertiesDialog(pWP, GetParent());
2629void RouteManagerDialog::OnWptPropertiesClick(wxCommandEvent &event) {
2630 long item = wxNOT_FOUND;
2632 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2633 if (item == wxNOT_FOUND)
return;
2635 auto pWP = (
RoutePoint *)m_pWptListCtrl->GetItemData(item);
2636 WptShowPropertiesDialog(pWP, GetParent());
2638 UpdateWptListCtrl();
2639 m_bNeedConfigFlush =
true;
2642void RouteManagerDialog::WptShowPropertiesDialog(
RoutePoint *pWP,
2644 if (!g_pMarkInfoDialog)
2648 g_pMarkInfoDialog->SetRoutePoint(pWP);
2649 g_pMarkInfoDialog->UpdateProperties();
2651 wxString base_title = _(
"Waypoint Properties");
2653 if (pWP->m_bIsInLayer) {
2654 wxString caption(wxString::Format(_T(
"%s, %s: %s"), base_title, _(
"Layer"),
2655 GetLayerName(pWP->m_LayerID)));
2656 g_pMarkInfoDialog->SetDialogTitle(caption);
2658 g_pMarkInfoDialog->SetDialogTitle(base_title);
2661 if (!g_pMarkInfoDialog->IsShown()) g_pMarkInfoDialog->Show();
2662 g_pMarkInfoDialog->Raise();
2665void RouteManagerDialog::OnWptZoomtoClick(wxCommandEvent &event) {
2668 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2669 if (item == -1)
return;
2675 if (gFrame->GetFocusCanvas()) {
2676 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), wp->m_lat, wp->m_lon,
2677 gFrame->GetFocusCanvas()->GetVPScale());
2681void RouteManagerDialog::OnWptDeleteClick(wxCommandEvent &event) {
2682 RoutePointList list;
2684 int answer = OCPNMessageBox(
2685 this, _(
"Are you sure you want to delete the selected object(s)"),
2686 wxString(_(
"OpenCPN Alert")), wxYES_NO);
2687 if (answer != wxID_YES)
return;
2690 if (m_pWptListCtrl->GetSelectedItemCount()) {
2691 ::wxBeginBusyCursor();
2692 m_bNeedConfigFlush =
true;
2697 long item_last_selected = -1;
2699 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2700 wxLIST_STATE_SELECTED);
2701 if (item == -1)
break;
2703 item_last_selected = item;
2706 if (wp && !wp->m_bIsInLayer) list.Append(wp);
2710 for (
unsigned int i = 0; i < list.GetCount(); i++) {
2713 if (wp->m_bIsInRoute) {
2715 OCPNMessageBox(
this,
2716 _(
"The waypoint you want to delete is used in a "
2717 "route, do you really want to delete it?"),
2718 _(
"OpenCPN Alert"), wxYES_NO))
2719 pWayPointMan->DestroyWaypoint(wp);
2721 pWayPointMan->DestroyWaypoint(wp);
2726 m_pWptListCtrl->GetNextItem(item_last_selected);
2729 wp_next = (
RoutePoint *)m_pWptListCtrl->GetItemData(item_next);
2731 m_lastWptItem = item_next;
2733 UpdateRouteListCtrl();
2734 UpdateTrkListCtrl();
2735 UpdateWptListCtrl(wp_next,
true);
2737 if (g_pMarkInfoDialog) {
2738 g_pMarkInfoDialog->ClearData();
2741 gFrame->InvalidateAllCanvasUndo();
2742 gFrame->RefreshAllCanvas();
2743 ::wxEndBusyCursor();
2747void RouteManagerDialog::OnWptGoToClick(wxCommandEvent &event) {
2750 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2751 if (item == -1)
return;
2758 wxEmptyString, wxEmptyString);
2759 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
2762 pRouteList->Append(temp_route);
2764 temp_route->AddPoint(pWP_src);
2765 temp_route->AddPoint(wp);
2767 pSelect->AddSelectableRouteSegment(gLat, gLon, wp->m_lat, wp->m_lon, pWP_src,
2770 wxString name = wp->GetName();
2771 if (name.IsEmpty()) name = _(
"(Unnamed Waypoint)");
2772 wxString rteName = _(
"Go to ");
2773 rteName.Append(name);
2774 temp_route->m_RouteNameString = rteName;
2775 temp_route->m_RouteStartString = _(
"Here");
2777 temp_route->m_RouteEndString = name;
2778 temp_route->m_bDeleteOnArrival =
true;
2780 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
2782 g_pRouteMan->ActivateRoute(temp_route, wp);
2784 UpdateRouteListCtrl();
2787void RouteManagerDialog::OnWptExportClick(wxCommandEvent &event) {
2788 RoutePointList list;
2790 wxString suggested_name = _T(
"waypoints");
2794 item = m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2795 wxLIST_STATE_SELECTED);
2796 if (item == -1)
break;
2800 if (wp && !wp->m_bIsInLayer) {
2802 if (wp->GetName() != wxEmptyString) suggested_name = wp->GetName();
2806 ExportGPXWaypoints(
this, &list, suggested_name);
2809void RouteManagerDialog::OnWptSendToGPSClick(wxCommandEvent &event) {
2812 m_pWptListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2813 if (item == -1)
return;
2820 pdlg->SetWaypoint(wp);
2823 pdlg->Create(NULL, -1, _(
"Send to GPS") + _T(
"..." ), source);
2826 HideWithEffect(wxSHOW_EFFECT_BLEND);
2830 ShowWithEffect(wxSHOW_EFFECT_BLEND);
2836void RouteManagerDialog::OnWptDeleteAllClick(wxCommandEvent &event) {
2839 if (!pWayPointMan->SharedWptsExist()) {
2840 prompt = _(
"Are you sure you want to delete <ALL> waypoints?");
2845 _(
"There are some waypoints used in routes or anchor alarms.\n Do you "
2846 "want to delete them as well?\n This will change the routes and "
2847 "disable the anchor alarms.\n Answering No keeps the waypoints used "
2848 "in routes or alarms.");
2849 buttons = wxYES_NO | wxCANCEL;
2853 OCPNMessageBox(
this, prompt, wxString(_(
"OpenCPN Alert")), buttons);
2854 if (answer == wxID_YES) pWayPointMan->DeleteAllWaypoints(
true);
2855 if (answer == wxID_NO && type == 2)
2856 pWayPointMan->DeleteAllWaypoints(
false);
2858 if (g_pMarkInfoDialog) {
2859 g_pMarkInfoDialog->ClearData();
2863 UpdateRouteListCtrl();
2864 UpdateWptListCtrl();
2865 gFrame->InvalidateAllCanvasUndo();
2866 gFrame->RefreshAllCanvas();
2869void RouteManagerDialog::OnLaySelected(wxListEvent &event) {
2873void RouteManagerDialog::OnLayColumnClicked(wxListEvent &event) {
2874 if (event.m_col == 1) {
2875 sort_layer_name_dir++;
2876 m_pLayListCtrl->SortItems(SortLayersOnName, (wxIntPtr)NULL);
2877 }
else if (event.m_col == 2) {
2878 sort_layer_len_dir++;
2879 m_pLayListCtrl->SortItems(SortLayersOnSize, (wxIntPtr)NULL);
2883void RouteManagerDialog::UpdateLayButtons() {
2886 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2887 bool enable = (item != -1);
2890 btnLayDelete->Enable(enable);
2891 cbLayToggleChart->Enable(enable);
2892 cbLayToggleListing->Enable(enable);
2893 cbLayToggleNames->Enable(enable);
2896 cbLayToggleChart->SetValue(
2897 ((
Layer *)m_pLayListCtrl->GetItemData(item))->IsVisibleOnChart());
2899 cbLayToggleNames->Set3StateValue(
2900 ((
Layer *)m_pLayListCtrl->GetItemData(item))->HasVisibleNames());
2902 cbLayToggleListing->SetValue(
2903 ((
Layer *)m_pLayListCtrl->GetItemData(item))->IsVisibleOnListing());
2906 cbLayToggleChart->SetValue(
true);
2907 cbLayToggleNames->Set3StateValue(wxCHK_UNDETERMINED);
2908 cbLayToggleListing->SetValue(
true);
2912void RouteManagerDialog::OnLayToggleVisibility(wxMouseEvent &event) {
2913 wxPoint pos =
event.GetPosition();
2915 long clicked_index = m_pLayListCtrl->HitTest(pos, flags);
2918 if (clicked_index > -1 &&
2919 event.GetX() < m_pLayListCtrl->GetColumnWidth(colLAYVISIBLE)) {
2921 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(clicked_index);
2923 layer->SetVisibleOnChart(!layer->IsVisibleOnChart());
2924 m_pLayListCtrl->SetItemImage(clicked_index,
2925 layer->IsVisibleOnChart() ? 0 : 1);
2931 item = m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
2932 wxLIST_STATE_DONTCARE);
2933 if (item == -1)
break;
2935 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
2937 if (!layer->IsVisibleOnChart()) {
2942 m_cbShowAllLay->SetValue(viz);
2944 ToggleLayerContentsOnChart(layer);
2951void RouteManagerDialog::UpdateLists() {
2952 UpdateRouteListCtrl();
2953 UpdateTrkListCtrl();
2954 UpdateWptListCtrl();
2955 UpdateLayListCtrl();
2958void RouteManagerDialog::OnLayNewClick(wxCommandEvent &event) {
2962void RouteManagerDialog::OnPerLayNewClick(wxCommandEvent &event) {
2966void RouteManagerDialog::AddNewLayer(
bool isPersistent) {
2967 bool show_flag = g_bShowLayers;
2968 g_bShowLayers =
true;
2970 UI_ImportGPX(
this,
true, _T(
""),
true, isPersistent);
2972 g_bShowLayers = show_flag;
2974 gFrame->RefreshAllCanvas();
2977void RouteManagerDialog::OnLayPropertiesClick(wxCommandEvent &event) {
2981 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2982 if (item == -1)
return;
2985void RouteManagerDialog::OnLayDeleteClick(wxCommandEvent &event) {
2988 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
2989 if (item == -1)
return;
2991 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
2997 bool ispers =
false;
2998 wxString destf, f, name, ext;
2999 f = layer->m_LayerFileName;
3000 wxFileName::SplitPath(f, NULL, NULL, &name, &ext);
3002 appendOSDirSlash(&destf);
3003 destf.Append(_T(
"layers"));
3004 appendOSDirSlash(&destf);
3005 destf << name << _T(
".") << ext;
3007 wxString prompt = _(
3008 "Are you sure you want to delete this layer and <ALL> of its contents?");
3009 if (wxFileExists(destf)) {
3010 prompt.Append(_T(
"\n"));
3012 _(
"The file will also be deleted from OpenCPN's layer directory."));
3013 prompt.Append(_T(
"\n (") + destf + _T(
")" ));
3017 OCPNMessageBox(
this, prompt, wxString(_(
"OpenCPN Alert")), wxYES_NO);
3018 if (answer == wxID_NO)
return;
3023 if (wxRemoveFile(destf))
3024 remMSG.sprintf(_T(
"Layer file: %s is deleted"), destf);
3026 remMSG.sprintf(_T(
"Error deleting Layer file: %s"), destf);
3028 wxLogMessage(remMSG);
3032 wxRouteListNode *node1 = pRouteList->GetFirst();
3034 Route *pRoute = node1->GetData();
3035 wxRouteListNode *next_node = node1->GetNext();
3036 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3037 pRoute->m_bIsInLayer =
false;
3038 pRoute->m_LayerID = 0;
3039 g_pRouteMan->
DeleteRoute(pRoute, NavObjectChanges::getInstance());
3044 for (
Track *pTrack : g_TrackList) {
3045 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID)) {
3046 pTrack->m_bIsInLayer =
false;
3047 pTrack->m_LayerID = 0;
3053 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3054 wxRoutePointListNode *node3;
3057 node3 = node->GetNext();
3059 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3060 rp->m_bIsInLayer =
false;
3062 pWayPointMan->DestroyWaypoint(
3070 if (g_pMarkInfoDialog) {
3071 g_pMarkInfoDialog->ClearData();
3074 pLayerList->DeleteObject(layer);
3078 gFrame->RefreshAllCanvas();
3080 m_bNeedConfigFlush =
false;
3083void RouteManagerDialog::OnLayToggleChartClick(wxCommandEvent &event) {
3087 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3088 if (item == -1)
return;
3090 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3094 layer->SetVisibleOnChart(!layer->IsVisibleOnChart());
3095 m_pLayListCtrl->SetItemImage(item, layer->IsVisibleOnChart() ? 0 : 1);
3097 ToggleLayerContentsOnChart(layer);
3100void RouteManagerDialog::ToggleLayerContentsOnChart(
Layer *layer) {
3102 wxRouteListNode *node1 = pRouteList->GetFirst();
3104 Route *pRoute = node1->GetData();
3105 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3106 pRoute->SetVisible(layer->IsVisibleOnChart());
3108 node1 = node1->GetNext();
3111 for (
Track *pTrack : g_TrackList) {
3112 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID))
3113 pTrack->SetVisible(layer->IsVisibleOnChart());
3117 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3121 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3122 rp->SetVisible(layer->IsVisibleOnChart());
3125 node = node->GetNext();
3131 gFrame->RefreshAllCanvas();
3134void RouteManagerDialog::OnLayToggleNamesClick(wxCommandEvent &event) {
3138 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3139 if (item == -1)
return;
3141 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3145 layer->SetVisibleNames(cbLayToggleNames->Get3StateValue());
3147 ToggleLayerContentsNames(layer);
3150void RouteManagerDialog::ToggleLayerContentsNames(
Layer *layer) {
3152 wxRouteListNode *node1 = pRouteList->GetFirst();
3154 Route *pRoute = node1->GetData();
3155 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3156 wxRoutePointListNode *node = pRoute->pRoutePointList->GetFirst();
3159 if (layer->HasVisibleNames() == wxCHK_UNDETERMINED) {
3160 prp1->m_bShowName = prp1->m_bShowNameData;
3162 prp1->m_bShowName = (layer->HasVisibleNames() == wxCHK_CHECKED);
3164 node = node->GetNext();
3167 node1 = node1->GetNext();
3171 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3175 if (rp && (rp->m_LayerID == layer->m_LayerID)) {
3176 rp->SetNameShown(layer->HasVisibleNames() == wxCHK_CHECKED ||
3177 (rp->m_bShowNameData &&
3178 layer->HasVisibleNames() == wxCHK_UNDETERMINED));
3181 node = node->GetNext();
3186 gFrame->RefreshAllCanvas();
3189void RouteManagerDialog::OnLayToggleListingClick(wxCommandEvent &event) {
3193 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3194 if (item == -1)
return;
3196 Layer *layer = (
Layer *)m_pLayListCtrl->GetItemData(item);
3200 layer->SetVisibleOnListing(!layer->IsVisibleOnListing());
3202 ToggleLayerContentsOnListing(layer);
3205void RouteManagerDialog::ToggleLayerContentsOnListing(
Layer *layer) {
3206 ::wxBeginBusyCursor();
3209 wxRouteListNode *node1 = pRouteList->GetFirst();
3211 Route *pRoute = node1->GetData();
3212 if (pRoute->m_bIsInLayer && (pRoute->m_LayerID == layer->m_LayerID)) {
3213 pRoute->SetListed(layer->IsVisibleOnListing());
3215 node1 = node1->GetNext();
3218 for (
Track *pTrack : g_TrackList) {
3219 if (pTrack->m_bIsInLayer && (pTrack->m_LayerID == layer->m_LayerID))
3220 pTrack->SetListed(layer->IsVisibleOnListing());
3227 wxRoutePointListNode *node = pWayPointMan->GetWaypointList()->GetFirst();
3231 if (rp && rp->
m_bIsolatedMark && (rp->m_LayerID == layer->m_LayerID)) {
3232 rp->SetListed(layer->IsVisibleOnListing());
3235 node = node->GetNext();
3240 ::wxEndBusyCursor();
3242 gFrame->RefreshAllCanvas();
3245void RouteManagerDialog::OnLayDefaultAction(wxListEvent &event) {
3247 OnLayPropertiesClick(evt);
3250void RouteManagerDialog::UpdateLayListCtrl() {
3254 m_pLayListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3256 wxUIntPtr selected_id = wxUIntPtr(0);
3257 if (item != -1) selected_id = m_pLayListCtrl->GetItemData(item);
3260 m_pLayListCtrl->DeleteAllItems();
3263 LayerList::iterator it;
3265 bool b_anyHidden =
false;
3266 for (it = (*pLayerList).begin(); it != (*pLayerList).end(); ++it, ++index) {
3269 if (!lay->m_LayerName.Upper().Contains(m_tFilterLay->GetValue().Upper())) {
3275 li.SetImage(lay->IsVisibleOnChart() ? 0 : 1);
3279 long idx = m_pLayListCtrl->InsertItem(li);
3281 wxString name = lay->m_LayerName;
3282 if (name.IsEmpty()) {
3289 name = _(
"(Unnamed Layer)");
3291 m_pLayListCtrl->SetItem(idx, colLAYNAME, name);
3294 len.Printf(wxT(
"%d"), (
int)lay->m_NoOfItems);
3295 m_pLayListCtrl->SetItem(idx, colLAYITEMS, len);
3296 m_pLayListCtrl->SetItem(idx, colLAYPERSIST, lay->m_LayerType);
3301 lic.SetAlign(wxLIST_FORMAT_LEFT);
3302 m_pLayListCtrl->SetItem(lic);
3305 lic.SetAlign(wxLIST_FORMAT_LEFT);
3306 m_pLayListCtrl->SetItem(lic);
3308 if (!lay->IsVisibleOnChart()) b_anyHidden =
true;
3311 m_pLayListCtrl->SortItems(SortLayersOnName,
3312 reinterpret_cast<wxIntPtr
>(m_pLayListCtrl));
3313 m_pLayListCtrl->SetColumnWidth(0, 4 * m_charWidth);
3318 if (selected_id != wxUIntPtr(0)) {
3319 item = m_pLayListCtrl->FindItem(-1, selected_id);
3320 m_pLayListCtrl->SetItemState(item,
3321 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
3322 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
3326 m_cbShowAllLay->SetValue(!b_anyHidden);
3329void RouteManagerDialog::OnImportClick(wxCommandEvent &event) {
3338 gFrame->RefreshAllCanvas();
3340void RouteManagerDialog::OnExportClick(wxCommandEvent &event) {
3344void RouteManagerDialog::OnExportVizClick(wxCommandEvent &event) {
3345 ExportGPX(
this,
true,
true);
3348void RouteManagerDialog::OnFilterChanged(wxCommandEvent &event) {
3349 if (event.GetEventObject() == m_tFilterWpt) {
3350 UpdateWptListCtrl(NULL,
true);
3351 }
else if (event.GetEventObject() == m_tFilterRte) {
3352 UpdateRouteListCtrl();
3353 }
else if (event.GetEventObject() == m_tFilterTrk) {
3354 UpdateTrkListCtrl();
3355 }
else if (event.GetEventObject() == m_tFilterLay) {
3356 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.
EventVar on_routes_update
Notified when list of routes is updated (no data in event)
bool DeleteRoute(Route *pRoute, NavObjectChanges *nav_obj_changes)
Dialog for sending routes/waypoints to a GPS device.
Dialog for sending navigation objects to peer devices.
Represents a single point in a track.
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.