OpenCPN Partial API docs
Loading...
Searching...
No Matches
ocpn_plugin_gui.cpp
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2024 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19
25#include <vector>
26#include "dychart.h" // Must be ahead due to buggy GL includes handling
27
28#include <wx/wx.h>
29#include <wx/arrstr.h>
30#include <wx/dc.h>
31#include <wx/dcmemory.h>
32#include <wx/event.h>
33#include <wx/glcanvas.h>
34#include <wx/notebook.h>
35#include <wx/string.h>
36#include <wx/window.h>
37
38#include "model/ais_decoder.h"
40#include "model/gui_vars.h"
41#include "model/idents.h"
42#include "model/multiplexer.h"
43#include "model/navobj_db.h"
45#include "model/own_ship.h"
46#include "model/plugin_comm.h"
47#include "model/svg_utils.h"
48#include "model/route.h"
49#include "model/track.h"
50
51#include "ais.h"
52#include "chartdb.h"
53#include "chcanv.h"
54#include "config_mgr.h"
55#include "font_mgr.h"
56#include "gl_chart_canvas.h"
57#include "gui_lib.h"
58#include "navutil.h"
59#include "ocpn_app.h"
60#include "ocpn_aui_manager.h"
61#include "ocpn_frame.h"
62#include "ocpn_platform.h"
63#include "ocpn_plugin.h"
64#include "options.h"
65#include "piano.h"
66#include "pluginmanager.h"
67#include "routemanagerdialog.h"
68#include "routeman_gui.h"
69#include "s52plib.h"
70#include "shapefile_basemap.h"
71#include "SoundFactory.h"
72#include "SystemCmdSound.h"
73#include "toolbar.h"
74#include "waypointman_gui.h"
75
76extern PlugInManager* s_ppim; // FIXME (leamas) another name for global mgr
77
78#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
79extern wxLocale* plocale_def_lang;
80#endif
81
82extern options* g_pOptions; // FIXME (leamas) merge to g_options
83
84extern arrayofCanvasPtr g_canvasArray; // FIXME (leamas) find new home
85
86int g_canvas_context_Menu_Disable_Mask;
87
88void NotifySetupOptionsPlugin(const PlugInData* pic);
89
90//---------------------------------------------------------------------------
91/* Implementation of OCPN core functions callable by plugins
92 * Sorted by API version number
93 * The definitions of this API are found in ocpn_plugin.h
94 * PlugIns may call these static functions as necessary for system services
95 */
96//---------------------------------------------------------------------------
97
98//---------------------------------------------------------------------------
99// API 1.6
100//---------------------------------------------------------------------------
101/* Main Toolbar support */
102int InsertPlugInTool(wxString label, wxBitmap* bitmap, wxBitmap* bmpRollover,
103 wxItemKind kind, wxString shortHelp, wxString longHelp,
104 wxObject* clientData, int position, int tool_sel,
105 opencpn_plugin* pplugin) {
106 if (s_ppim)
107 return s_ppim->AddToolbarTool(label, bitmap, bmpRollover, kind, shortHelp,
108 longHelp, clientData, position, tool_sel,
109 pplugin);
110 else
111 return -1;
112}
113
114void RemovePlugInTool(int tool_id) {
115 if (s_ppim) s_ppim->RemoveToolbarTool(tool_id);
116}
117
118void SetToolbarToolViz(int item, bool viz) {
119 if (s_ppim) s_ppim->SetToolbarToolViz(item, viz);
120}
121
122void SetToolbarItemState(int item, bool toggle) {
123 if (s_ppim) s_ppim->SetToolbarItemState(item, toggle);
124}
125
126void SetToolbarToolBitmaps(int item, wxBitmap* bitmap, wxBitmap* bmpRollover) {
127 if (s_ppim) s_ppim->SetToolbarItemBitmaps(item, bitmap, bmpRollover);
128}
129
130int InsertPlugInToolSVG(wxString label, wxString SVGfile,
131 wxString SVGfileRollover, wxString SVGfileToggled,
132 wxItemKind kind, wxString shortHelp, wxString longHelp,
133 wxObject* clientData, int position, int tool_sel,
134 opencpn_plugin* pplugin) {
135 if (s_ppim)
136 return s_ppim->AddToolbarTool(label, SVGfile, SVGfileRollover,
137 SVGfileToggled, kind, shortHelp, longHelp,
138 clientData, position, tool_sel, pplugin);
139 else
140 return -1;
141}
142
143void SetToolbarToolBitmapsSVG(int item, wxString SVGfile,
144 wxString SVGfileRollover,
145 wxString SVGfileToggled) {
146 if (s_ppim)
147 s_ppim->SetToolbarItemBitmaps(item, SVGfile, SVGfileRollover,
148 SVGfileToggled);
149}
150
151/* Canvas Context Menu support */
152int AddCanvasMenuItem(wxMenuItem* pitem, opencpn_plugin* pplugin,
153 const char* name) {
154 if (s_ppim)
155 return s_ppim->AddCanvasContextMenuItemPIM(pitem, pplugin, name, false);
156 else
157 return -1;
158}
159
160void SetCanvasMenuItemViz(int item, bool viz, const char* name) {
161 if (s_ppim) s_ppim->SetCanvasContextMenuItemViz(item, viz, name);
162}
163
164void SetCanvasMenuItemGrey(int item, bool grey, const char* name) {
165 if (s_ppim) s_ppim->SetCanvasContextMenuItemGrey(item, grey, name);
166}
167
168void RemoveCanvasMenuItem(int item, const char* name) {
169 if (s_ppim) s_ppim->RemoveCanvasContextMenuItem(item, name);
170}
171
172int AddCanvasContextMenuItem(wxMenuItem* pitem, opencpn_plugin* pplugin) {
173 /* main context popup menu */
174 if (s_ppim)
175 return s_ppim->AddCanvasContextMenuItemPIM(pitem, pplugin, "", false);
176 else
177 return -1;
178}
179
180void SetCanvasContextMenuItemViz(int item, bool viz) {
181 SetCanvasMenuItemViz(item, viz);
182}
183
184void SetCanvasContextMenuItemGrey(int item, bool grey) {
185 SetCanvasMenuItemGrey(item, grey);
186}
187
189
190int AddCanvasContextMenuItemExt(wxMenuItem* pitem, opencpn_plugin* pplugin,
191 const std::string object_type) {
192 /* main context popup menu */
193 if (s_ppim)
194 return s_ppim->AddCanvasContextMenuItemPIM(pitem, pplugin,
195 object_type.c_str(), true);
196 else
197 return -1;
198}
199
200/* Utility functions */
201wxFileConfig* GetOCPNConfigObject() {
202 if (s_ppim)
203 return reinterpret_cast<wxFileConfig*>(
204 pConfig); // return the global application config object
205 else
206 return NULL;
207}
208
210 wxWindow* pret = NULL;
211 if (s_ppim) {
212 MyFrame* pFrame = s_ppim->GetParentFrame();
213 pret = (wxWindow*)pFrame->GetPrimaryCanvas();
214 }
215 return pret;
216}
217
218void RequestRefresh(wxWindow* win) {
219 if (win) win->Refresh(true);
220}
221
222void GetCanvasPixLL(PlugIn_ViewPort* vp, wxPoint* pp, double lat, double lon) {
223 // Make enough of an application viewport to run its method....
224 ViewPort ocpn_vp;
225 ocpn_vp.clat = vp->clat;
226 ocpn_vp.clon = vp->clon;
227 ocpn_vp.m_projection_type = vp->m_projection_type;
228 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
229 ocpn_vp.skew = vp->skew;
230 ocpn_vp.rotation = vp->rotation;
231 ocpn_vp.pix_width = vp->pix_width;
232 ocpn_vp.pix_height = vp->pix_height;
233
234 wxPoint ret = ocpn_vp.GetPixFromLL(lat, lon);
235 pp->x = ret.x;
236 pp->y = ret.y;
237}
238
239void GetDoubleCanvasPixLL(PlugIn_ViewPort* vp, wxPoint2DDouble* pp, double lat,
240 double lon) {
241 // Make enough of an application viewport to run its method....
242 ViewPort ocpn_vp;
243 ocpn_vp.clat = vp->clat;
244 ocpn_vp.clon = vp->clon;
245 ocpn_vp.m_projection_type = vp->m_projection_type;
246 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
247 ocpn_vp.skew = vp->skew;
248 ocpn_vp.rotation = vp->rotation;
249 ocpn_vp.pix_width = vp->pix_width;
250 ocpn_vp.pix_height = vp->pix_height;
251
252 *pp = ocpn_vp.GetDoublePixFromLL(lat, lon);
253}
254
255void GetCanvasLLPix(PlugIn_ViewPort* vp, wxPoint p, double* plat,
256 double* plon) {
257 // Make enough of an application viewport to run its method....
258 ViewPort ocpn_vp;
259 ocpn_vp.clat = vp->clat;
260 ocpn_vp.clon = vp->clon;
261 ocpn_vp.m_projection_type = vp->m_projection_type;
262 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
263 ocpn_vp.skew = vp->skew;
264 ocpn_vp.rotation = vp->rotation;
265 ocpn_vp.pix_width = vp->pix_width;
266 ocpn_vp.pix_height = vp->pix_height;
267
268 return ocpn_vp.GetLLFromPix(p, plat, plon);
269}
270
271bool GetGlobalColor(wxString colorName, wxColour* pcolour) {
272 wxColour c = GetGlobalColor(colorName);
273 *pcolour = c;
274
275 return true;
276}
277
278wxFont* OCPNGetFont(wxString TextElement, int default_size) {
279 return FontMgr::Get().GetFontLegacy(TextElement, default_size);
280}
281
282wxFont* GetOCPNScaledFont_PlugIn(wxString TextElement, int default_size) {
283 return FontMgr::Get().GetFontLegacy(TextElement, default_size);
284}
285
286double GetOCPNGUIToolScaleFactor_PlugIn(int GUIScaleFactor) {
287 return g_Platform->GetToolbarScaleFactor(GUIScaleFactor);
288}
289
291 return g_Platform->GetToolbarScaleFactor(g_GUIScaleFactor);
292}
293
295 return g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor);
296}
297
298wxFont GetOCPNGUIScaledFont_PlugIn(wxString item) {
299 return GetOCPNGUIScaledFont(item);
300}
301
302bool AddPersistentFontKey(wxString TextElement) {
303 return FontMgr::Get().AddAuxKey(TextElement);
304}
305
307 if (g_StyleManager)
308 return g_StyleManager->GetCurrentStyle()->name;
309 else
310 return "";
311}
312
313wxBitmap GetBitmapFromSVGFile(wxString filename, unsigned int width,
314 unsigned int height) {
315 wxBitmap bmp = LoadSVG(filename, width, height);
316
317 if (bmp.IsOk())
318 return bmp;
319 else {
320 // On error in requested width/height parameters,
321 // try to find and use dimensions embedded in the SVG file
322 unsigned int w, h;
323 SVGDocumentPixelSize(filename, w, h);
324 if (w == 0 || h == 0) {
325 // We did not succeed in deducing the size from SVG (svg element
326 // x misses width, height or both attributes), let's use some "safe"
327 // default
328 w = 32;
329 h = 32;
330 }
331 return LoadSVG(filename, w, h);
332 }
333}
334
335bool IsTouchInterface_PlugIn() { return g_btouch; }
336
337wxColour GetFontColour_PlugIn(wxString TextElement) {
338 return FontMgr::Get().GetFontColor(TextElement);
339}
340
341wxString* GetpSharedDataLocation() { return g_Platform->GetSharedDataDirPtr(); }
342
343ArrayOfPlugIn_AIS_Targets* GetAISTargetArray() {
344 if (!g_pAIS) return NULL;
345
346 ArrayOfPlugIn_AIS_Targets* pret = new ArrayOfPlugIn_AIS_Targets;
347
348 // Iterate over the AIS Target Hashmap
349 for (const auto& it : g_pAIS->GetTargetList()) {
350 auto td = it.second;
351 PlugIn_AIS_Target* ptarget = Create_PI_AIS_Target(td.get());
352 pret->Add(ptarget);
353 }
354
355// Test one alarm target
356#if 0
357 AisTargetData td;
358 td.n_alarm_state = AIS_ALARM_SET;
359 PlugIn_AIS_Target *ptarget = Create_PI_AIS_Target(&td);
360 pret->Add(ptarget);
361#endif
362 return pret;
363}
364
365wxAuiManager* GetFrameAuiManager() { return g_pauimgr; }
366
367void SendPluginMessage(wxString message_id, wxString message_body) {
368 SendMessageToAllPlugins(message_id, message_body);
369
370 // We will send an event to the main application frame (gFrame)
371 // for informational purposes.
372 // Of course, gFrame is encouraged to use any or all the
373 // data flying by if judged useful and dependable....
374
375 OCPN_MsgEvent Nevent(wxEVT_OCPN_MSG, 0);
376 Nevent.SetID(message_id);
377 Nevent.SetJSONText(message_body);
378 gFrame->GetEventHandler()->AddPendingEvent(Nevent);
379}
380
381void DimeWindow(wxWindow* win) { DimeControl(win); }
382
383void JumpToPosition(double lat, double lon, double scale) {
384 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), lat, lon, scale);
385}
386
387/* Locale (i18N) support */
388bool AddLocaleCatalog(wxString catalog) {
389#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
390
391 if (plocale_def_lang) {
392 // Add this catalog to the persistent catalog array
393 g_locale_catalog_array.Add(catalog);
394
395 return plocale_def_lang->AddCatalog(catalog);
396 } else
397#endif
398 return false;
399}
400
401wxString GetLocaleCanonicalName() { return g_locale; }
402
403/* NMEA interface support */
404void PushNMEABuffer(wxString buf) {
405 std::string full_sentence = buf.ToStdString();
406
407 if ((full_sentence[0] == '$') || (full_sentence[0] == '!')) { // Sanity check
408 // We notify based on full message, including the Talker ID
409 std::string id = full_sentence.substr(1, 5);
410
411 // notify message listener
412 auto address = std::make_shared<NavAddr0183>("virtual");
413 auto msg = std::make_shared<const Nmea0183Msg>(id, full_sentence, address);
414 NavMsgBus::GetInstance().Notify(std::move(msg));
415 }
416}
417
418/* Chart database access support */
419wxXmlDocument GetChartDatabaseEntryXML(int dbIndex, bool b_getGeom) {
420 wxXmlDocument doc = ChartData->GetXMLDescription(dbIndex, b_getGeom);
421
422 return doc;
423}
424
425bool UpdateChartDBInplace(wxArrayString dir_array, bool b_force_update,
426 bool b_ProgressDialog) {
427 // Make an array of CDI
428 ArrayOfCDI ChartDirArray;
429 for (unsigned int i = 0; i < dir_array.GetCount(); i++) {
430 wxString dirname = dir_array[i];
431 ChartDirInfo cdi;
432 cdi.fullpath = dirname;
433 cdi.magic_number = "";
434 ChartDirArray.Add(cdi);
435 }
436 bool b_ret = gFrame->UpdateChartDatabaseInplace(
437 ChartDirArray, b_force_update, b_ProgressDialog, ChartListFileName);
438 gFrame->RefreshGroupIndices();
439 gFrame->ChartsRefresh();
440 return b_ret;
441}
442
444 return ChartData->GetChartDirArrayString();
445}
446
447int AddChartToDBInPlace(wxString& full_path, bool b_RefreshCanvas) {
448 // extract the path from the chart name
449 wxFileName fn(full_path);
450 wxString fdir = fn.GetPath();
451
452 bool bret = false;
453 if (ChartData) {
454 bret = ChartData->AddSingleChart(full_path);
455
456 if (bret) {
457 // Save to disk
458 pConfig->UpdateChartDirs(ChartData->GetChartDirArray());
459 ChartData->SaveBinary(ChartListFileName);
460
461 // Completely reload the chart database, for a fresh start
462 ArrayOfCDI XnewChartDirArray;
463 pConfig->LoadChartDirArray(XnewChartDirArray);
464 delete ChartData;
465 ChartData = new ChartDB();
466 ChartData->LoadBinary(ChartListFileName, XnewChartDirArray);
467
468 // Update group contents
469 if (g_pGroupArray) ChartData->ApplyGroupArray(g_pGroupArray);
470
471 if (g_options && g_options->IsShown())
472 g_options->UpdateDisplayedChartDirList(ChartData->GetChartDirArray());
473
474 if (b_RefreshCanvas || !gFrame->GetPrimaryCanvas()->GetQuiltMode()) {
475 gFrame->ChartsRefresh();
476 }
477 }
478 }
479 return bret;
480}
481
482int RemoveChartFromDBInPlace(wxString& full_path) {
483 bool bret = false;
484 if (ChartData) {
485 bret = ChartData->RemoveSingleChart(full_path);
486
487 // Save to disk
488 pConfig->UpdateChartDirs(ChartData->GetChartDirArray());
489 ChartData->SaveBinary(ChartListFileName);
490
491 // Completely reload the chart database, for a fresh start
492 ArrayOfCDI XnewChartDirArray;
493 pConfig->LoadChartDirArray(XnewChartDirArray);
494 delete ChartData;
495 ChartData = new ChartDB();
496 ChartData->LoadBinary(ChartListFileName, XnewChartDirArray);
497
498 // Update group contents
499 if (g_pGroupArray) ChartData->ApplyGroupArray(g_pGroupArray);
500
501 if (g_options && g_options->IsShown())
502 g_options->UpdateDisplayedChartDirList(ChartData->GetChartDirArray());
503
504 gFrame->ChartsRefresh();
505 }
506
507 return bret;
508}
509
510//---------------------------------------------------------------------------
511// API 1.9
512//---------------------------------------------------------------------------
513wxScrolledWindow* AddOptionsPage(OptionsParentPI parent, wxString title) {
514 if (!g_pOptions) return NULL;
515
516 size_t parentid;
517 switch (parent) {
519 parentid = g_pOptions->m_pageDisplay;
520 break;
522 parentid = g_pOptions->m_pageConnections;
523 break;
525 parentid = g_pOptions->m_pageCharts;
526 break;
528 parentid = g_pOptions->m_pageShips;
529 break;
531 parentid = g_pOptions->m_pageUI;
532 break;
534 parentid = g_pOptions->m_pagePlugins;
535 break;
536 default:
537 wxLogMessage("Error in PluginManager::AddOptionsPage: Unknown parent");
538 return NULL;
539 break;
540 }
541
542 return g_pOptions->AddPage(parentid, title);
543}
544
545bool DeleteOptionsPage(wxScrolledWindow* page) {
546 if (!g_pOptions) return false;
547 return g_pOptions->DeletePluginPage(page);
548}
549
550bool DecodeSingleVDOMessage(const wxString& str, PlugIn_Position_Fix_Ex* pos,
551 wxString* accumulator) {
552 if (!pos) return false;
553
554 GenericPosDatEx gpd;
555 AisError nerr = AIS_GENERIC_ERROR;
556 if (g_pAIS) nerr = g_pAIS->DecodeSingleVDO(str, &gpd, accumulator);
557 if (nerr == AIS_NoError) {
558 pos->Lat = gpd.kLat;
559 pos->Lon = gpd.kLon;
560 pos->Cog = gpd.kCog;
561 pos->Sog = gpd.kSog;
562 pos->Hdt = gpd.kHdt;
563
564 // Fill in the dummy values
565 pos->FixTime = 0;
566 pos->Hdm = 1000;
567 pos->Var = 1000;
568 pos->nSats = 0;
569
570 return true;
571 }
572
573 return false;
574}
575
577 int val = 0;
578 if (g_bShowChartBar) {
579 ChartCanvas* cc = gFrame->GetPrimaryCanvas();
580 if (cc && cc->GetPiano()) {
581 val = cc->GetPiano()->GetHeight();
582 }
583 }
584 return val;
585}
586
587bool GetRoutepointGPX(RoutePoint* pRoutePoint, char* buffer,
588 unsigned int buffer_length) {
589 bool ret = false;
590
592 pgpx->AddGPXWaypoint(pRoutePoint);
593 wxString gpxfilename = wxFileName::CreateTempFileName("gpx");
594 pgpx->SaveFile(gpxfilename);
595 delete pgpx;
596
597 wxFFile gpxfile(gpxfilename);
598 wxString s;
599 if (gpxfile.ReadAll(&s)) {
600 if (s.Length() < buffer_length) {
601 strncpy(buffer, (const char*)s.mb_str(wxConvUTF8), buffer_length - 1);
602 ret = true;
603 }
604 }
605
606 gpxfile.Close();
607 ::wxRemoveFile(gpxfilename);
608
609 return ret;
610}
611
612bool GetActiveRoutepointGPX(char* buffer, unsigned int buffer_length) {
613 if (g_pRouteMan->IsAnyRouteActive())
614 return GetRoutepointGPX(g_pRouteMan->GetpActivePoint(), buffer,
615 buffer_length);
616 else
617 return false;
618}
619
620void PositionBearingDistanceMercator_Plugin(double lat, double lon, double brg,
621 double dist, double* dlat,
622 double* dlon) {
623 PositionBearingDistanceMercator(lat, lon, brg, dist, dlat, dlon);
624}
625
626void DistanceBearingMercator_Plugin(double lat0, double lon0, double lat1,
627 double lon1, double* brg, double* dist) {
628 DistanceBearingMercator(lat0, lon0, lat1, lon1, brg, dist);
629}
630
631double DistGreatCircle_Plugin(double slat, double slon, double dlat,
632 double dlon) {
633 return DistGreatCircle(slat, slon, dlat, dlon);
634}
635
636void toTM_Plugin(float lat, float lon, float lat0, float lon0, double* x,
637 double* y) {
638 toTM(lat, lon, lat0, lon0, x, y);
639}
640
641void fromTM_Plugin(double x, double y, double lat0, double lon0, double* lat,
642 double* lon) {
643 fromTM(x, y, lat0, lon0, lat, lon);
644}
645
646void toSM_Plugin(double lat, double lon, double lat0, double lon0, double* x,
647 double* y) {
648 toSM(lat, lon, lat0, lon0, x, y);
649}
650
651void fromSM_Plugin(double x, double y, double lat0, double lon0, double* lat,
652 double* lon) {
653 fromSM(x, y, lat0, lon0, lat, lon);
654}
655
656void toSM_ECC_Plugin(double lat, double lon, double lat0, double lon0,
657 double* x, double* y) {
658 toSM_ECC(lat, lon, lat0, lon0, x, y);
659}
660
661void fromSM_ECC_Plugin(double x, double y, double lat0, double lon0,
662 double* lat, double* lon) {
663 fromSM_ECC(x, y, lat0, lon0, lat, lon);
664}
665
666double toUsrDistance_Plugin(double nm_distance, int unit) {
667 return toUsrDistance(nm_distance, unit);
668}
669
670double fromUsrDistance_Plugin(double usr_distance, int unit) {
671 return fromUsrDistance(usr_distance, unit);
672}
673
674double toUsrSpeed_Plugin(double kts_speed, int unit) {
675 return toUsrSpeed(kts_speed, unit);
676}
677
678double toUsrWindSpeed_Plugin(double kts_speed, int unit) {
679 return toUsrWindSpeed(kts_speed, unit);
680}
681
682double fromUsrSpeed_Plugin(double usr_speed, int unit) {
683 return fromUsrSpeed(usr_speed, unit);
684}
685
686double fromUsrWindSpeed_Plugin(double usr_wspeed, int unit) {
687 return fromUsrWindSpeed(usr_wspeed, unit);
688}
689
690double toUsrTemp_Plugin(double cel_temp, int unit) {
691 return toUsrTemp(cel_temp, unit);
692}
693
694double fromUsrTemp_Plugin(double usr_temp, int unit) {
695 return fromUsrTemp(usr_temp, unit);
696}
697
699 return getUsrDistanceUnit(unit);
700}
701
702wxString getUsrSpeedUnit_Plugin(int unit) { return getUsrSpeedUnit(unit); }
703
705 return getUsrWindSpeedUnit(unit);
706}
707
708wxString getUsrTempUnit_Plugin(int unit) { return getUsrTempUnit(unit); }
709
710/*
711 * Depth Conversion Functions
712 */
713double toUsrDepth_Plugin(double m_depth, int unit) {
714 return toUsrDepth(m_depth, unit);
715}
716
717double fromUsrDepth_Plugin(double usr_depth, int unit) {
718 return fromUsrDepth(usr_depth, unit);
719}
720
721wxString getUsrDepthUnit_Plugin(int unit) { return getUsrDepthUnit(unit); }
722
726double toUsrHeight_Plugin(double m_height, int unit) {
727 return toUsrHeight(m_height, unit);
728}
729
730double fromUsrHeight_Plugin(double usr_height, int unit) {
731 return fromUsrHeight(usr_height, unit);
732}
733
735
736double fromDMM_PlugIn(wxString sdms) { return fromDMM(sdms); }
737
738bool PlugIn_GSHHS_CrossesLand(double lat1, double lon1, double lat2,
739 double lon2) {
740 // TODO: Enable call to gShapeBasemap.CrossesLand after fixing performance
741 // issues. if (gShapeBasemap.IsUsable()) {
742 // return gShapeBasemap.CrossesLand(lat1, lon1, lat2, lon2);
743 // } else {
744 // Fall back to the GSHHS data.
745 static bool loaded = false;
746 if (!loaded) {
747 gshhsCrossesLandInit();
748 loaded = true;
749 }
750 return gshhsCrossesLand(lat1, lon1, lat2, lon2);
751 //}
752}
753
754void PlugInPlaySound(wxString& sound_file) {
755 PlugInPlaySoundEx(sound_file, -1);
756}
757
758//---------------------------------------------------------------------------
759// API 1.10
760//---------------------------------------------------------------------------
761
762// API Route and Waypoint Support
764
765PlugIn_Waypoint::PlugIn_Waypoint(double lat, double lon,
766 const wxString& icon_ident,
767 const wxString& wp_name,
768 const wxString& GUID) {
769 wxDateTime now = wxDateTime::Now();
770 m_CreateTime = now.ToUTC();
771 m_HyperlinkList = NULL;
772
773 m_lat = lat;
774 m_lon = lon;
775 m_IconName = icon_ident;
776 m_MarkName = wp_name;
777 m_GUID = GUID;
778}
779
780PlugIn_Waypoint::~PlugIn_Waypoint() {}
781
782// PlugInRoute implementation
783PlugIn_Route::PlugIn_Route() { pWaypointList = new Plugin_WaypointList; }
784
785PlugIn_Route::~PlugIn_Route() {
786 pWaypointList->DeleteContents(false); // do not delete Waypoints
787 pWaypointList->Clear();
788
789 delete pWaypointList;
790}
791
792// PlugInTrack implementation
793PlugIn_Track::PlugIn_Track() { pWaypointList = new Plugin_WaypointList; }
794
795PlugIn_Track::~PlugIn_Track() {
796 pWaypointList->DeleteContents(false); // do not delete Waypoints
797 pWaypointList->Clear();
798
799 delete pWaypointList;
800}
801
802wxString GetNewGUID() { return GpxDocument::GetUUID(); }
803
804bool AddCustomWaypointIcon(wxBitmap* pimage, wxString key,
805 wxString description) {
806 wxImage image = pimage->ConvertToImage();
807 WayPointmanGui(*pWayPointMan).ProcessIcon(image, key, description);
808 return true;
809}
810
811static void cloneHyperlinkList(RoutePoint* dst, const PlugIn_Waypoint* src) {
812 // Transcribe (clone) the html HyperLink List, if present
813 if (src->m_HyperlinkList == nullptr) return;
814
815 if (src->m_HyperlinkList->GetCount() > 0) {
816 wxPlugin_HyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
817 while (linknode) {
818 Plugin_Hyperlink* link = linknode->GetData();
819
820 Hyperlink* h = new Hyperlink();
821 h->DescrText = link->DescrText;
822 h->Link = link->Link;
823 h->LType = link->Type;
824
825 dst->m_HyperlinkList->push_back(h);
826
827 linknode = linknode->GetNext();
828 }
829 }
830}
831
832bool AddSingleWaypoint(PlugIn_Waypoint* pwaypoint, bool b_permanent) {
833 // Validate the waypoint parameters a little bit
834
835 // GUID
836 // Make sure that this GUID is indeed unique in the Routepoint list
837 bool b_unique = true;
838 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
839 if (prp->m_GUID == pwaypoint->m_GUID) {
840 b_unique = false;
841 break;
842 }
843 }
844
845 if (!b_unique) return false;
846
847 RoutePoint* pWP =
848 new RoutePoint(pwaypoint->m_lat, pwaypoint->m_lon, pwaypoint->m_IconName,
849 pwaypoint->m_MarkName, pwaypoint->m_GUID);
850
851 pWP->m_bIsolatedMark = true; // This is an isolated mark
852
853 cloneHyperlinkList(pWP, pwaypoint);
854
855 pWP->m_MarkDescription = pwaypoint->m_MarkDescription;
856
857 if (pwaypoint->m_CreateTime.IsValid())
858 pWP->SetCreateTime(pwaypoint->m_CreateTime);
859 else {
860 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
861 }
862
863 pWP->m_btemp = (b_permanent == false);
864
865 pSelect->AddSelectableRoutePoint(pwaypoint->m_lat, pwaypoint->m_lon, pWP);
866 if (b_permanent) {
867 // pConfig->AddNewWayPoint(pWP, -1);
868 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
869 }
870
871 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
872 pRouteManagerDialog->UpdateWptListCtrl();
873
874 return true;
875}
876
877bool DeleteSingleWaypoint(wxString& GUID) {
878 // Find the RoutePoint
879 bool b_found = false;
880 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
881
882 if (prp) b_found = true;
883
884 if (b_found) {
885 pWayPointMan->DestroyWaypoint(prp);
886 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
887 pRouteManagerDialog->UpdateWptListCtrl();
888 }
889
890 return b_found;
891}
892
894 // Find the RoutePoint
895 bool b_found = false;
896 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
897
898 if (prp) b_found = true;
899
900 if (b_found) {
901 double lat_save = prp->m_lat;
902 double lon_save = prp->m_lon;
903
904 prp->m_lat = pwaypoint->m_lat;
905 prp->m_lon = pwaypoint->m_lon;
906 prp->SetIconName(pwaypoint->m_IconName);
907 prp->SetName(pwaypoint->m_MarkName);
908 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
909 prp->SetVisible(pwaypoint->m_IsVisible);
910 if (pwaypoint->m_CreateTime.IsValid())
911 prp->SetCreateTime(pwaypoint->m_CreateTime);
912
913 // Transcribe (clone) the html HyperLink List, if present
914
915 if (pwaypoint->m_HyperlinkList) {
916 prp->m_HyperlinkList->clear();
917 if (pwaypoint->m_HyperlinkList->GetCount() > 0) {
918 wxPlugin_HyperlinkListNode* linknode =
919 pwaypoint->m_HyperlinkList->GetFirst();
920 while (linknode) {
921 Plugin_Hyperlink* link = linknode->GetData();
922
923 Hyperlink* h = new Hyperlink();
924 h->DescrText = link->DescrText;
925 h->Link = link->Link;
926 h->LType = link->Type;
927
928 prp->m_HyperlinkList->push_back(h);
929
930 linknode = linknode->GetNext();
931 }
932 }
933 }
934
935 if (prp) prp->ReLoadIcon();
936
937 auto canvas = gFrame->GetPrimaryCanvas();
938 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
939 canvas->GetScaleValue());
940 SelectItem* pFind =
941 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
942 if (pFind) {
943 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
944 pFind->m_slon = pwaypoint->m_lon;
945 }
946
947 if (!prp->m_btemp) {
948 // pConfig->UpdateWayPoint(prp);
949 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
950 }
951
952 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
953 pRouteManagerDialog->UpdateWptListCtrl();
954 }
955
956 return b_found;
957}
958
959// translate O route class to Plugin one
960static void PlugInFromRoutePoint(PlugIn_Waypoint* dst,
961 /* const*/ RoutePoint* src) {
962 dst->m_lat = src->m_lat;
963 dst->m_lon = src->m_lon;
964 dst->m_IconName = src->GetIconName();
965 dst->m_MarkName = src->GetName();
967 dst->m_IsVisible = src->IsVisible();
968 dst->m_CreateTime = src->GetCreateTime(); // not const
969 dst->m_GUID = src->m_GUID;
970
971 // Transcribe (clone) the html HyperLink List, if present
972 if (src->m_HyperlinkList == nullptr) return;
973
974 delete dst->m_HyperlinkList;
975 dst->m_HyperlinkList = nullptr;
976
977 if (src->m_HyperlinkList->size() > 0) {
978 dst->m_HyperlinkList = new Plugin_HyperlinkList;
979 for (Hyperlink* link : *src->m_HyperlinkList) {
981 h->DescrText = link->DescrText;
982 h->Link = link->Link;
983 h->Type = link->LType;
984
985 dst->m_HyperlinkList->Append(h);
986 }
987 }
988}
989
990bool GetSingleWaypoint(wxString GUID, PlugIn_Waypoint* pwaypoint) {
991 // Find the RoutePoint
992 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
993
994 if (!prp) return false;
995
996 PlugInFromRoutePoint(pwaypoint, prp);
997
998 return true;
999}
1000
1001wxArrayString GetWaypointGUIDArray() {
1002 wxArrayString result;
1003 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
1004 result.Add(prp->m_GUID);
1005 }
1006 return result;
1007}
1008
1009wxArrayString GetRouteGUIDArray() {
1010 wxArrayString result;
1011 for (Route* proute : *pRouteList) {
1012 result.Add(proute->m_GUID);
1013 }
1014 return result;
1015}
1016
1017wxArrayString GetTrackGUIDArray() {
1018 wxArrayString result;
1019 for (Track* ptrack : g_TrackList) {
1020 result.Add(ptrack->m_GUID);
1021 }
1022
1023 return result;
1024}
1025
1027 wxArrayString result;
1028 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
1029 switch (req) {
1030 case OBJECTS_ALL:
1031 result.Add(prp->m_GUID);
1032 break;
1033 case OBJECTS_NO_LAYERS:
1034 if (!prp->m_bIsInLayer) result.Add(prp->m_GUID);
1035 break;
1037 if (prp->m_bIsInLayer) result.Add(prp->m_GUID);
1038 break;
1039 }
1040 }
1041 return result;
1042}
1043
1045 wxArrayString result;
1046
1047 for (Route* proute : *pRouteList) {
1048 switch (req) {
1049 case OBJECTS_ALL:
1050 result.Add(proute->m_GUID);
1051 break;
1052 case OBJECTS_NO_LAYERS:
1053 if (!proute->m_bIsInLayer) result.Add(proute->m_GUID);
1054 break;
1056 if (proute->m_bIsInLayer) result.Add(proute->m_GUID);
1057 break;
1058 }
1059 }
1060
1061 return result;
1062}
1063
1065 wxArrayString result;
1066 for (Track* ptrack : g_TrackList) {
1067 switch (req) {
1068 case OBJECTS_ALL:
1069 result.Add(ptrack->m_GUID);
1070 break;
1071 case OBJECTS_NO_LAYERS:
1072 if (!ptrack->m_bIsInLayer) result.Add(ptrack->m_GUID);
1073 break;
1075 if (ptrack->m_bIsInLayer) result.Add(ptrack->m_GUID);
1076 break;
1077 }
1078 }
1079
1080 return result;
1081}
1082
1083wxArrayString GetIconNameArray() {
1084 wxArrayString result;
1085
1086 for (int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1087 wxString* ps = pWayPointMan->GetIconKey(i);
1088 result.Add(*ps);
1089 }
1090 return result;
1091}
1092
1093bool AddPlugInRoute(PlugIn_Route* proute, bool b_permanent) {
1094 Route* route = new Route();
1095
1096 PlugIn_Waypoint* pwp;
1097 RoutePoint* pWP_src;
1098 int ip = 0;
1099 wxDateTime plannedDeparture;
1100
1101 wxPlugin_WaypointListNode* pwpnode = proute->pWaypointList->GetFirst();
1102 while (pwpnode) {
1103 pwp = pwpnode->GetData();
1104
1105 RoutePoint* pWP = new RoutePoint(pwp->m_lat, pwp->m_lon, pwp->m_IconName,
1106 pwp->m_MarkName, pwp->m_GUID);
1107
1108 // Transcribe (clone) the html HyperLink List, if present
1109 cloneHyperlinkList(pWP, pwp);
1111 pWP->m_bShowName = false;
1112 pWP->SetCreateTime(pwp->m_CreateTime);
1113
1114 route->AddPoint(pWP);
1115
1116 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
1117
1118 if (ip > 0)
1119 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
1120 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
1121 route);
1122 else
1123 plannedDeparture = pwp->m_CreateTime;
1124 ip++;
1125 pWP_src = pWP;
1126
1127 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
1128 }
1129
1130 route->m_PlannedDeparture = plannedDeparture;
1131
1132 route->m_RouteNameString = proute->m_NameString;
1133 route->m_RouteStartString = proute->m_StartString;
1134 route->m_RouteEndString = proute->m_EndString;
1135 if (!proute->m_GUID.IsEmpty()) {
1136 route->m_GUID = proute->m_GUID;
1137 }
1138 route->m_btemp = (b_permanent == false);
1139
1140 pRouteList->push_back(route);
1141
1142 if (b_permanent) {
1143 // pConfig->AddNewRoute(route);
1144 NavObj_dB::GetInstance().InsertRoute(route);
1145 }
1146 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1147 pRouteManagerDialog->UpdateRouteListCtrl();
1148
1149 return true;
1150}
1151
1152bool DeletePlugInRoute(wxString& GUID) {
1153 bool b_found = false;
1154
1155 // Find the Route
1156 Route* pRoute = g_pRouteMan->FindRouteByGUID(GUID);
1157 if (pRoute) {
1158 g_pRouteMan->DeleteRoute(pRoute);
1159 b_found = true;
1160 }
1161 return b_found;
1162}
1163
1165 bool b_found = false;
1166
1167 // Find the Route
1168 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
1169 if (pRoute) b_found = true;
1170
1171 if (b_found) {
1172 bool b_permanent = (pRoute->m_btemp == false);
1173 g_pRouteMan->DeleteRoute(pRoute);
1174 b_found = AddPlugInRoute(proute, b_permanent);
1175 }
1176
1177 return b_found;
1178}
1179
1180bool AddPlugInTrack(PlugIn_Track* ptrack, bool b_permanent) {
1181 Track* track = new Track();
1182
1183 PlugIn_Waypoint* pwp = 0;
1184 TrackPoint* pWP_src = 0;
1185 int ip = 0;
1186
1187 wxPlugin_WaypointListNode* pwpnode = ptrack->pWaypointList->GetFirst();
1188 while (pwpnode) {
1189 pwp = pwpnode->GetData();
1190
1191 TrackPoint* pWP = new TrackPoint(pwp->m_lat, pwp->m_lon);
1192 pWP->SetCreateTime(pwp->m_CreateTime);
1193
1194 track->AddPoint(pWP);
1195
1196 if (ip > 0)
1197 pSelect->AddSelectableTrackSegment(pWP_src->m_lat, pWP_src->m_lon,
1198 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
1199 track);
1200 ip++;
1201 pWP_src = pWP;
1202
1203 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
1204 }
1205
1206 track->SetName(ptrack->m_NameString);
1207 track->m_TrackStartString = ptrack->m_StartString;
1208 track->m_TrackEndString = ptrack->m_EndString;
1209 track->m_GUID = ptrack->m_GUID;
1210 track->m_btemp = (b_permanent == false);
1211
1212 g_TrackList.push_back(track);
1213 if (b_permanent) NavObj_dB::GetInstance().InsertTrack(track);
1214 // if (b_permanent) pConfig->AddNewTrack(track);
1215
1216 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1217 pRouteManagerDialog->UpdateTrkListCtrl();
1218
1219 return true;
1220}
1221
1222bool DeletePlugInTrack(wxString& GUID) {
1223 bool b_found = false;
1224
1225 // Find the Route
1226 Track* pTrack = g_pRouteMan->FindTrackByGUID(GUID);
1227 if (pTrack) {
1228 NavObj_dB::GetInstance().DeleteTrack(pTrack);
1229 RoutemanGui(*g_pRouteMan).DeleteTrack(pTrack);
1230 b_found = true;
1231 }
1232
1233 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1234 pRouteManagerDialog->UpdateTrkListCtrl();
1235
1236 return b_found;
1237}
1238
1240 bool b_found = false;
1241
1242 // Find the Track
1243 Track* pTrack = g_pRouteMan->FindTrackByGUID(ptrack->m_GUID);
1244 if (pTrack) b_found = true;
1245
1246 if (b_found) {
1247 bool b_permanent = (pTrack->m_btemp == false);
1248 NavObj_dB::GetInstance().DeleteTrack(pTrack);
1249 RoutemanGui(*g_pRouteMan).DeleteTrack(pTrack);
1250
1251 b_found = AddPlugInTrack(ptrack, b_permanent);
1252 }
1253
1254 return b_found;
1255}
1256
1258#ifdef ocpnUSE_GL
1259 ViewPort ocpn_vp;
1260 ocpn_vp.m_projection_type = vp->m_projection_type;
1261
1262 return glChartCanvas::HasNormalizedViewPort(ocpn_vp);
1263#else
1264 return false;
1265#endif
1266}
1267
1268void PlugInMultMatrixViewport(PlugIn_ViewPort* vp, float lat, float lon) {
1269#ifdef ocpnUSE_GL
1270 ViewPort ocpn_vp;
1271 ocpn_vp.clat = vp->clat;
1272 ocpn_vp.clon = vp->clon;
1273 ocpn_vp.m_projection_type = vp->m_projection_type;
1274 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
1275 ocpn_vp.skew = vp->skew;
1276 ocpn_vp.rotation = vp->rotation;
1277 ocpn_vp.pix_width = vp->pix_width;
1278 ocpn_vp.pix_height = vp->pix_height;
1279
1280// TODO fix for multicanvas glChartCanvas::MultMatrixViewPort(ocpn_vp, lat,
1281// lon);
1282#endif
1283}
1284
1285void PlugInNormalizeViewport(PlugIn_ViewPort* vp, float lat, float lon) {
1286#ifdef ocpnUSE_GL
1287 ViewPort ocpn_vp;
1288 glChartCanvas::NormalizedViewPort(ocpn_vp, lat, lon);
1289
1290 vp->clat = ocpn_vp.clat;
1291 vp->clon = ocpn_vp.clon;
1292 vp->view_scale_ppm = ocpn_vp.view_scale_ppm;
1293 vp->rotation = ocpn_vp.rotation;
1294 vp->skew = ocpn_vp.skew;
1295#endif
1296}
1297
1298// Helper and interface classes
1299
1300//-------------------------------------------------------------------------------
1301// PlugIn_AIS_Target Implementation
1302//-------------------------------------------------------------------------------
1303
1304PlugIn_AIS_Target* Create_PI_AIS_Target(AisTargetData* ptarget) {
1306
1307 pret->MMSI = ptarget->MMSI;
1308 pret->Class = ptarget->Class;
1309 pret->NavStatus = ptarget->NavStatus;
1310 pret->SOG = ptarget->SOG;
1311 pret->COG = ptarget->COG;
1312 pret->HDG = ptarget->HDG;
1313 pret->Lon = ptarget->Lon;
1314 pret->Lat = ptarget->Lat;
1315 pret->ROTAIS = ptarget->ROTAIS;
1316 pret->ShipType = ptarget->ShipType;
1317 pret->IMO = ptarget->IMO;
1318
1319 pret->Range_NM = ptarget->Range_NM;
1320 pret->Brg = ptarget->Brg;
1321
1322 // Per target collision parameters
1323 pret->bCPA_Valid = ptarget->bCPA_Valid;
1324 pret->TCPA = ptarget->TCPA; // Minutes
1325 pret->CPA = ptarget->CPA; // Nautical Miles
1326
1327 pret->alarm_state = (plugin_ais_alarm_type)ptarget->n_alert_state;
1328
1329 memcpy(pret->CallSign, ptarget->CallSign, sizeof(ptarget->CallSign) - 1);
1330 memcpy(pret->ShipName, ptarget->ShipName, sizeof(ptarget->ShipName) - 1);
1331
1332 return pret;
1333}
1334
1335//---------------------------------------------------------------------------
1336// API 1.11
1337//---------------------------------------------------------------------------
1338
1339//---------------------------------------------------------------------------
1340// API 1.12
1341//---------------------------------------------------------------------------
1342
1343//---------------------------------------------------------------------------
1344// API 1.13
1345//---------------------------------------------------------------------------
1346double fromDMM_Plugin(wxString sdms) { return fromDMM(sdms); }
1347
1348void SetCanvasRotation(double rotation) {
1349 gFrame->GetPrimaryCanvas()->DoRotateCanvas(rotation);
1350}
1351
1352double GetCanvasTilt() { return gFrame->GetPrimaryCanvas()->GetVPTilt(); }
1353
1354void SetCanvasTilt(double tilt) {
1355 gFrame->GetPrimaryCanvas()->DoTiltCanvas(tilt);
1356}
1357
1358void SetCanvasProjection(int projection) {
1359 gFrame->GetPrimaryCanvas()->SetVPProjection(projection);
1360}
1361
1362OcpnSound* g_PluginSound = SoundFactory();
1363static void onPlugInPlaySoundExFinished(void* ptr) {}
1364
1365// Start playing a sound to a given device and return status to plugin
1366bool PlugInPlaySoundEx(wxString& sound_file, int deviceIndex) {
1367 bool ok = g_PluginSound->Load(sound_file, deviceIndex);
1368 if (!ok) {
1369 wxLogWarning("Cannot load sound file: %s", sound_file);
1370 return false;
1371 }
1372 auto cmd_sound = dynamic_cast<SystemCmdSound*>(g_PluginSound);
1373 if (cmd_sound) cmd_sound->SetCmd(g_CmdSoundString.mb_str(wxConvUTF8));
1374
1375 g_PluginSound->SetFinishedCallback(onPlugInPlaySoundExFinished, NULL);
1376 ok = g_PluginSound->Play();
1377 if (!ok) {
1378 wxLogWarning("Cannot play sound file: %s", sound_file);
1379 }
1380 return ok;
1381}
1382
1383bool CheckEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta) {
1384 return gFrame->GetPrimaryCanvas()->CheckEdgePan(x, y, dragging, margin,
1385 delta);
1386}
1387
1388wxBitmap GetIcon_PlugIn(const wxString& name) {
1389 ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle();
1390 return style->GetIcon(name);
1391}
1392
1393void SetCursor_PlugIn(wxCursor* pCursor) {
1394 gFrame->GetPrimaryCanvas()->pPlugIn_Cursor = pCursor;
1395}
1396
1397void AddChartDirectory(wxString& path) {
1398 if (g_options) {
1399 g_options->AddChartDir(path);
1400 }
1401}
1402
1404 if (g_options) {
1405 g_options->pScanCheckBox->SetValue(true);
1406 g_options->pUpdateCheckBox->SetValue(true);
1407 }
1408}
1409
1411 if (g_options) {
1412 g_options->pUpdateCheckBox->SetValue(true);
1413 }
1414}
1415
1416wxDialog* GetActiveOptionsDialog() { return g_options; }
1417
1418int PlatformDirSelectorDialog(wxWindow* parent, wxString* file_spec,
1419 wxString Title, wxString initDir) {
1420 return g_Platform->DoDirSelectorDialog(parent, file_spec, Title, initDir);
1421}
1422
1423int PlatformFileSelectorDialog(wxWindow* parent, wxString* file_spec,
1424 wxString Title, wxString initDir,
1425 wxString suggestedName, wxString wildcard) {
1426 return g_Platform->DoFileSelectorDialog(parent, file_spec, Title, initDir,
1427 suggestedName, wildcard);
1428}
1429
1430//---------------------------------------------------------------------------
1431// API 1.14
1432//---------------------------------------------------------------------------
1433
1434ViewPort CreateCompatibleViewportEx(const PlugIn_ViewPort& pivp) {
1435 // Create a system ViewPort
1436 ViewPort vp;
1437
1438 vp.clat = pivp.clat; // center point
1439 vp.clon = pivp.clon;
1441 vp.skew = pivp.skew;
1442 vp.rotation = pivp.rotation;
1443 vp.chart_scale = pivp.chart_scale;
1444 vp.pix_width = pivp.pix_width;
1445 vp.pix_height = pivp.pix_height;
1446 vp.rv_rect = pivp.rv_rect;
1447 vp.b_quilt = pivp.b_quilt;
1448 vp.m_projection_type = pivp.m_projection_type;
1449
1450 if (gFrame->GetPrimaryCanvas())
1451 vp.ref_scale = gFrame->GetPrimaryCanvas()->GetVP().ref_scale;
1452 else
1453 vp.ref_scale = vp.chart_scale;
1454
1455 vp.SetBoxes();
1456 vp.Validate(); // This VP is valid
1457
1458 return vp;
1459}
1460
1461void PlugInAISDrawGL(wxGLCanvas* glcanvas, const PlugIn_ViewPort& vp) {
1462 ViewPort ocpn_vp = CreateCompatibleViewportEx(vp);
1463
1464 ocpnDC dc(*glcanvas);
1465 dc.SetVP(ocpn_vp);
1466
1467 AISDraw(dc, ocpn_vp, NULL);
1468}
1469
1470bool PlugInSetFontColor(const wxString TextElement, const wxColour color) {
1471 return FontMgr::Get().SetFontColor(TextElement, color);
1472}
1473
1474//---------------------------------------------------------------------------
1475// API 1.15
1476//---------------------------------------------------------------------------
1477
1478double PlugInGetDisplaySizeMM() { return g_Platform->GetDisplaySizeMM(); }
1479
1480wxFont* FindOrCreateFont_PlugIn(int point_size, wxFontFamily family,
1481 wxFontStyle style, wxFontWeight weight,
1482 bool underline, const wxString& facename,
1483 wxFontEncoding encoding) {
1484 return FontMgr::Get().FindOrCreateFont(point_size, family, style, weight,
1485 underline, facename, encoding);
1486}
1487
1488int PluginGetMinAvailableGshhgQuality() {
1489 return gFrame->GetPrimaryCanvas()->GetMinAvailableGshhgQuality();
1490}
1491int PluginGetMaxAvailableGshhgQuality() {
1492 return gFrame->GetPrimaryCanvas()->GetMaxAvailableGshhgQuality();
1493}
1494
1495// disable builtin console canvas, and autopilot nmea sentences
1498}
1499
1500bool LaunchDefaultBrowser_Plugin(wxString url) {
1501 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1502
1503 return true;
1504}
1505
1506//---------------------------------------------------------------------------
1507// API 1.16
1508//---------------------------------------------------------------------------
1510 ChartCanvas* cc = gFrame->GetFocusCanvas();
1511 if (cc && cc->GetSelectedRoutePoint()) {
1512 return cc->GetSelectedRoutePoint()->m_GUID;
1513 }
1514 return wxEmptyString;
1515}
1516
1518 ChartCanvas* cc = gFrame->GetFocusCanvas();
1519 if (cc && cc->GetSelectedRoute()) {
1520 return cc->GetSelectedRoute()->m_GUID;
1521 }
1522 return wxEmptyString;
1523}
1524
1526 ChartCanvas* cc = gFrame->GetFocusCanvas();
1527 if (cc && cc->GetSelectedTrack()) {
1528 return cc->GetSelectedTrack()->m_GUID;
1529 }
1530 return wxEmptyString;
1531}
1532
1533std::unique_ptr<PlugIn_Waypoint> GetWaypoint_Plugin(const wxString& GUID) {
1534 std::unique_ptr<PlugIn_Waypoint> w(new PlugIn_Waypoint);
1535 GetSingleWaypoint(GUID, w.get());
1536 return w;
1537}
1538
1539std::unique_ptr<PlugIn_Route> GetRoute_Plugin(const wxString& GUID) {
1540 std::unique_ptr<PlugIn_Route> r;
1541 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
1542 if (route == nullptr) return r;
1543
1544 r = std::unique_ptr<PlugIn_Route>(new PlugIn_Route);
1545 PlugIn_Route* dst_route = r.get();
1546
1547 // PlugIn_Waypoint *pwp;
1548 RoutePoint* src_wp;
1549 for (RoutePoint* src_wp : *route->pRoutePointList) {
1550 PlugIn_Waypoint* dst_wp = new PlugIn_Waypoint();
1551 PlugInFromRoutePoint(dst_wp, src_wp);
1552 dst_route->pWaypointList->Append(dst_wp);
1553 }
1554 dst_route->m_NameString = route->m_RouteNameString;
1555 dst_route->m_StartString = route->m_RouteStartString;
1556 dst_route->m_EndString = route->m_RouteEndString;
1557 dst_route->m_GUID = route->m_GUID;
1558
1559 return r;
1560}
1561
1562std::unique_ptr<PlugIn_Track> GetTrack_Plugin(const wxString& GUID) {
1563 std::unique_ptr<PlugIn_Track> t;
1564 // Find the Track
1565 Track* pTrack = g_pRouteMan->FindTrackByGUID(GUID);
1566 if (!pTrack) return t;
1567
1568 std::unique_ptr<PlugIn_Track> tk =
1569 std::unique_ptr<PlugIn_Track>(new PlugIn_Track);
1570 PlugIn_Track* dst_track = tk.get();
1571 dst_track->m_NameString = pTrack->GetName();
1572 dst_track->m_StartString = pTrack->m_TrackStartString;
1573 dst_track->m_EndString = pTrack->m_TrackEndString;
1574 dst_track->m_GUID = pTrack->m_GUID;
1575
1576 for (int i = 0; i < pTrack->GetnPoints(); i++) {
1577 TrackPoint* ptp = pTrack->GetPoint(i);
1578
1579 PlugIn_Waypoint* dst_wp = new PlugIn_Waypoint();
1580
1581 dst_wp->m_lat = ptp->m_lat;
1582 dst_wp->m_lon = ptp->m_lon;
1583 dst_wp->m_CreateTime = ptp->GetCreateTime(); // not const
1584
1585 dst_track->pWaypointList->Append(dst_wp);
1586 }
1587
1588 return tk;
1589}
1590
1592
1594 // if(g_overlayCanvas)
1595 return g_overlayCanvas;
1596 // else
1597}
1598
1599void CanvasJumpToPosition(wxWindow* canvas, double lat, double lon,
1600 double scale) {
1601 auto oCanvas = dynamic_cast<ChartCanvas*>(canvas);
1602 if (oCanvas) gFrame->JumpToPosition(oCanvas, lat, lon, scale);
1603}
1604
1605bool ShuttingDown() { return g_bquiting; }
1606
1607wxWindow* GetCanvasUnderMouse() { return gFrame->GetCanvasUnderMouse(); }
1608
1610 ChartCanvas* l_canvas = gFrame->GetCanvasUnderMouse();
1611 if (l_canvas) {
1612 for (unsigned int i = 0; i < g_canvasArray.GetCount(); ++i) {
1613 if (l_canvas == g_canvasArray[i]) return i;
1614 }
1615 }
1616 return 0;
1617}
1618
1619// std::vector<wxWindow *> GetCanvasArray()
1620// {
1621// std::vector<wxWindow *> rv;
1622// for(unsigned int i=0 ; i < g_canvasArray.GetCount() ; i++){
1623// ChartCanvas *cc = g_canvasArray.Item(i);
1624// rv.push_back(cc);
1625// }
1626//
1627// return rv;
1628// }
1629
1630wxWindow* GetCanvasByIndex(int canvasIndex) {
1631 if (g_canvasConfig == 0)
1632 return gFrame->GetPrimaryCanvas();
1633 else {
1634 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1635 return g_canvasArray[canvasIndex];
1636 }
1637 }
1638 return NULL;
1639}
1640
1641bool CheckMUIEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta,
1642 int canvasIndex) {
1643 if (g_canvasConfig == 0)
1644 return gFrame->GetPrimaryCanvas()->CheckEdgePan(x, y, dragging, margin,
1645 delta);
1646 else {
1647 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1648 return g_canvasArray[canvasIndex]->CheckEdgePan(x, y, dragging, margin,
1649 delta);
1650 }
1651 }
1652
1653 return false;
1654}
1655
1656void SetMUICursor_PlugIn(wxCursor* pCursor, int canvasIndex) {
1657 if (g_canvasConfig == 0)
1658 gFrame->GetPrimaryCanvas()->pPlugIn_Cursor = pCursor;
1659 else {
1660 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1661 g_canvasArray[canvasIndex]->pPlugIn_Cursor = pCursor;
1662 }
1663 }
1664}
1665
1667 if (g_canvasConfig == 1) return 2;
1668 // else
1669 return 1;
1670}
1671
1672int GetLatLonFormat() { return g_iSDMMFormat; }
1673
1675 if (g_MainToolbar)
1676 return g_MainToolbar->GetToolbarRect();
1677 else
1678 return wxRect(0, 0, 1, 1);
1679}
1680
1681//---------------------------------------------------------------------------
1682// API 1.17
1683//---------------------------------------------------------------------------
1684
1685void ZeroXTE() {
1686 if (g_pRouteMan) {
1687 g_pRouteMan->ZeroCurrentXTEToActivePoint();
1688 }
1689}
1690
1691static PlugIn_ViewPort CreatePlugInViewportEx(const ViewPort& vp) {
1692 // Create a PlugIn Viewport
1693 ViewPort tvp = vp;
1694 PlugIn_ViewPort pivp;
1695
1696 pivp.clat = tvp.clat; // center point
1697 pivp.clon = tvp.clon;
1698 pivp.view_scale_ppm = tvp.view_scale_ppm;
1699 pivp.skew = tvp.skew;
1700 pivp.rotation = tvp.rotation;
1701 pivp.chart_scale = tvp.chart_scale;
1702 pivp.pix_width = tvp.pix_width;
1703 pivp.pix_height = tvp.pix_height;
1704 pivp.rv_rect = tvp.rv_rect;
1705 pivp.b_quilt = tvp.b_quilt;
1706 pivp.m_projection_type = tvp.m_projection_type;
1707
1708 pivp.lat_min = tvp.GetBBox().GetMinLat();
1709 pivp.lat_max = tvp.GetBBox().GetMaxLat();
1710 pivp.lon_min = tvp.GetBBox().GetMinLon();
1711 pivp.lon_max = tvp.GetBBox().GetMaxLon();
1712
1713 pivp.bValid = tvp.IsValid(); // This VP is valid
1714
1715 return pivp;
1716}
1717
1718ListOfPI_S57Obj* PlugInManager::GetLightsObjRuleListVisibleAtLatLon(
1719 ChartPlugInWrapper* target, float zlat, float zlon, const ViewPort& vp) {
1720 ListOfPI_S57Obj* list = NULL;
1721 if (target) {
1722 PlugInChartBaseGLPlus2* picbgl =
1723 dynamic_cast<PlugInChartBaseGLPlus2*>(target->GetPlugInChart());
1724 if (picbgl) {
1725 PlugIn_ViewPort pi_vp = CreatePlugInViewportEx(vp);
1726 list = picbgl->GetLightsObjRuleListVisibleAtLatLon(zlat, zlon, &pi_vp);
1727
1728 return list;
1729 }
1731 dynamic_cast<PlugInChartBaseExtendedPlus2*>(target->GetPlugInChart());
1732 if (picbx) {
1733 PlugIn_ViewPort pi_vp = CreatePlugInViewportEx(vp);
1734 list = picbx->GetLightsObjRuleListVisibleAtLatLon(zlat, zlon, &pi_vp);
1735
1736 return list;
1737 } else
1738 return list;
1739 } else
1740 return list;
1741}
1742
1743// PlugInWaypointEx implementation
1744
1745#include <wx/listimpl.cpp>
1746WX_DEFINE_LIST(Plugin_WaypointExList)
1747
1748// The class implementations
1749PlugIn_Waypoint_Ex::PlugIn_Waypoint_Ex() { InitDefaults(); }
1750
1751PlugIn_Waypoint_Ex::PlugIn_Waypoint_Ex(
1752 double lat, double lon, const wxString& icon_ident, const wxString& wp_name,
1753 const wxString& GUID, const double ScaMin, const bool bNameVisible,
1754 const int nRangeRings, const double RangeDistance,
1755 const wxColor RangeColor) {
1756 InitDefaults();
1757
1758 m_lat = lat;
1759 m_lon = lon;
1760 IconName = icon_ident;
1761 m_MarkName = wp_name;
1762 m_GUID = GUID;
1763 scamin = ScaMin;
1764 IsNameVisible = bNameVisible;
1765 nrange_rings = nRangeRings;
1766 RangeRingSpace = RangeDistance;
1767 RangeRingColor = RangeColor;
1768}
1769
1771 m_HyperlinkList = nullptr;
1772 scamin = 1e9;
1773 b_useScamin = false;
1774 nrange_rings = 0;
1775 RangeRingSpace = 1;
1776 IsNameVisible = false;
1777 IsVisible = true;
1778 RangeRingColor = *wxBLACK;
1779 m_CreateTime = wxDateTime::Now().ToUTC();
1780 IsActive = false;
1781 m_lat = 0;
1782 m_lon = 0;
1783}
1784
1786 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(m_GUID);
1787 if (!prp) return false;
1788
1789 if (prp->m_bIsInRoute && !prp->IsShared()) return false;
1790
1791 return true;
1792}
1793
1795 // Search all routes to count the membership of this point
1796 RoutePoint* pWP = pWayPointMan->FindRoutePointByGUID(m_GUID);
1797 if (!pWP) return 0;
1798
1799 int nCount = 0;
1800 for (Route* proute : *pRouteList) {
1801 for (RoutePoint* prp : *proute->pRoutePointList) {
1802 if (prp == pWP) nCount++;
1803 }
1804 }
1805 return nCount;
1806}
1807
1808PlugIn_Waypoint_Ex::~PlugIn_Waypoint_Ex() {}
1809
1810WX_DEFINE_LIST(Plugin_WaypointExV2List)
1811
1812PlugIn_Waypoint_ExV2::PlugIn_Waypoint_ExV2() { InitDefaults(); }
1813
1814PlugIn_Waypoint_ExV2::PlugIn_Waypoint_ExV2(
1815 double lat, double lon, const wxString& icon_ident, const wxString& wp_name,
1816 const wxString& GUID, const double ScaMin, const double ScaMax,
1817 const bool bNameVisible, const int nRangeRings, const double RangeDistance,
1818 const int RangeDistanceUnits, const wxColor RangeColor,
1819 const double WaypointArrivalRadius, const bool ShowWaypointRangeRings,
1820 const double PlannedSpeed, const wxString TideStation) {
1821 // Initialize all to defaults first
1822 InitDefaults();
1823 // Then set the specific values provided
1824 m_lat = lat;
1825 m_lon = lon;
1826 IconName = icon_ident;
1827 m_MarkName = wp_name;
1828 m_GUID = GUID;
1829 scamin = ScaMin;
1830 scamax = ScaMax;
1831
1832 IsNameVisible = bNameVisible;
1833 nrange_rings = nRangeRings;
1834 RangeRingSpace = RangeDistance;
1835 RangeRingSpaceUnits = RangeDistanceUnits; // 0 = nm, 1 = km
1836 RangeRingColor = RangeColor;
1837 m_TideStation = TideStation;
1838
1839 m_PlannedSpeed = PlannedSpeed;
1840 m_WaypointArrivalRadius = WaypointArrivalRadius;
1841 m_bShowWaypointRangeRings = ShowWaypointRangeRings;
1842}
1843
1845 m_HyperlinkList = nullptr;
1846 scamin = 1e9;
1847 scamax = 1e6;
1848 b_useScamin = false;
1849 nrange_rings = 0;
1850 RangeRingSpace = 1;
1851 RangeRingSpaceUnits = 0; // 0 = nm, 1 = km
1852 m_TideStation = wxEmptyString;
1853 IsNameVisible = false;
1854 IsVisible = true;
1855 RangeRingColor = *wxBLACK;
1856 m_CreateTime = wxDateTime::Now().ToUTC();
1857 IsActive = false;
1858 m_lat = 0;
1859 m_lon = 0;
1860
1861 m_PlannedSpeed = 0.0;
1864}
1865
1866PlugIn_Waypoint_ExV2::~PlugIn_Waypoint_ExV2() {}
1867
1869 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(m_GUID);
1870 if (!prp) return false;
1871 if (prp->m_bIsInRoute && !prp->IsShared()) return false;
1872 return true;
1873}
1874
1876 // Search all routes to count the membership of this point
1877 RoutePoint* pWP = pWayPointMan->FindRoutePointByGUID(m_GUID);
1878 if (!pWP) return 0;
1879
1880 int nCount = 0;
1881 for (Route* proute : *pRouteList) {
1882 for (RoutePoint* prp : *proute->pRoutePointList) {
1883 if (prp == pWP) nCount++;
1884 }
1885 }
1886
1887 return nCount;
1888}
1889
1890PlugIn_Route_ExV2::PlugIn_Route_ExV2() {
1891 pWaypointList = new Plugin_WaypointExV2List;
1892 m_GUID = wxEmptyString;
1893 m_NameString = wxEmptyString;
1894 m_StartString = wxEmptyString;
1895 m_EndString = wxEmptyString;
1896 m_isActive = false;
1897 m_isVisible = true;
1898 m_Description = wxEmptyString;
1899
1900 // Generate a unique GUID if none provided
1901 if (m_GUID.IsEmpty()) {
1902 wxDateTime now = wxDateTime::Now();
1903 m_GUID = wxString::Format("RT%d%d%d%d", (int)now.GetMillisecond(),
1904 (int)now.GetSecond(), (int)now.GetMinute(),
1905 (int)now.GetHour());
1906 }
1907}
1908
1909PlugIn_Route_ExV2::~PlugIn_Route_ExV2() {
1910 if (pWaypointList) {
1911 pWaypointList->DeleteContents(true);
1912 delete pWaypointList;
1913 }
1914}
1915
1916// translate O route class to PlugIn_Waypoint_ExV2
1917static void PlugInExV2FromRoutePoint(PlugIn_Waypoint_ExV2* dst,
1918 /* const*/ RoutePoint* src) {
1919 dst->m_lat = src->m_lat;
1920 dst->m_lon = src->m_lon;
1921 dst->IconName = src->GetIconName();
1922 dst->m_MarkName = src->GetName();
1923 dst->m_MarkDescription = src->GetDescription();
1924 dst->IconDescription = pWayPointMan->GetIconDescription(src->GetIconName());
1925 dst->IsVisible = src->IsVisible();
1926 dst->m_CreateTime = src->GetCreateTime(); // not const
1927 dst->m_GUID = src->m_GUID;
1928
1929 // Transcribe (clone) the html HyperLink List, if present
1930 if (src->m_HyperlinkList) {
1931 delete dst->m_HyperlinkList;
1932 dst->m_HyperlinkList = nullptr;
1933
1934 if (src->m_HyperlinkList->size() > 0) {
1935 dst->m_HyperlinkList = new Plugin_HyperlinkList;
1936
1937 for (Hyperlink* link : *src->m_HyperlinkList) {
1939 h->DescrText = link->DescrText;
1940 h->Link = link->Link;
1941 h->Type = link->LType;
1942 dst->m_HyperlinkList->Append(h);
1943 }
1944 }
1945 }
1946
1947 // Get the range ring info
1952 dst->m_TideStation = src->m_TideStation;
1953
1954 // Get other extended info
1955 dst->IsNameVisible = src->m_bShowName;
1956 dst->scamin = src->GetScaMin();
1957 dst->b_useScamin = src->GetUseSca();
1958 dst->IsActive = src->m_bIsActive;
1959
1960 dst->scamax = src->GetScaMax();
1961 dst->m_PlannedSpeed = src->GetPlannedSpeed();
1962 dst->m_ETD = src->GetManualETD();
1963 dst->m_WaypointArrivalRadius = src->GetWaypointArrivalRadius();
1964 dst->m_bShowWaypointRangeRings = src->GetShowWaypointRangeRings();
1965}
1966
1967bool GetSingleWaypointExV2(wxString GUID, PlugIn_Waypoint_ExV2* pwaypoint) {
1968 // Find the RoutePoint
1969 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
1970
1971 if (!prp) return false;
1972
1973 PlugInExV2FromRoutePoint(pwaypoint, prp);
1974
1975 return true;
1976}
1977
1978static void cloneHyperlinkListExV2(RoutePoint* dst,
1979 const PlugIn_Waypoint_ExV2* src) {
1980 // Transcribe (clone) the html HyperLink List, if present
1981 if (src->m_HyperlinkList == nullptr) return;
1982
1983 if (src->m_HyperlinkList->GetCount() > 0) {
1984 wxPlugin_HyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
1985 while (linknode) {
1986 Plugin_Hyperlink* link = linknode->GetData();
1987
1988 Hyperlink* h = new Hyperlink();
1989 h->DescrText = link->DescrText;
1990 h->Link = link->Link;
1991 h->LType = link->Type;
1992
1993 dst->m_HyperlinkList->push_back(h);
1994
1995 linknode = linknode->GetNext();
1996 }
1997 }
1998}
1999
2000RoutePoint* CreateNewPoint(const PlugIn_Waypoint_ExV2* src, bool b_permanent) {
2001 RoutePoint* pWP = new RoutePoint(src->m_lat, src->m_lon, src->IconName,
2002 src->m_MarkName, src->m_GUID);
2003
2004 pWP->m_bIsolatedMark = true; // This is an isolated mark
2005
2006 cloneHyperlinkListExV2(pWP, src);
2007
2009
2010 if (src->m_CreateTime.IsValid())
2011 pWP->SetCreateTime(src->m_CreateTime);
2012 else {
2013 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
2014 }
2015
2016 pWP->m_btemp = (b_permanent == false);
2017
2018 // Extended fields
2019 pWP->SetIconName(src->IconName);
2020 pWP->SetWaypointRangeRingsNumber(src->nrange_rings);
2021 pWP->SetWaypointRangeRingsStep(src->RangeRingSpace);
2022 pWP->SetWaypointRangeRingsStepUnits(src->RangeRingSpaceUnits);
2023 pWP->SetWaypointRangeRingsColour(src->RangeRingColor);
2024 pWP->SetTideStation(src->m_TideStation);
2025 pWP->SetScaMin(src->scamin);
2026 pWP->SetUseSca(src->b_useScamin);
2027 pWP->SetNameShown(src->IsNameVisible);
2028 pWP->SetVisible(src->IsVisible);
2029
2030 pWP->SetWaypointArrivalRadius(src->m_WaypointArrivalRadius);
2031 pWP->SetShowWaypointRangeRings(src->m_bShowWaypointRangeRings);
2032 pWP->SetScaMax(src->scamax);
2033 pWP->SetPlannedSpeed(src->m_PlannedSpeed);
2034 if (src->m_ETD.IsValid())
2035 pWP->SetETD(src->m_ETD);
2036 else
2037 pWP->SetETD(wxEmptyString);
2038 return pWP;
2039}
2040
2042 bool b_permanent) {
2043 // Validate the waypoint parameters a little bit
2044
2045 // GUID
2046 // Make sure that this GUID is indeed unique in the Routepoint list
2047 bool b_unique = true;
2048 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
2049 if (prp->m_GUID == pwaypointex->m_GUID) {
2050 b_unique = false;
2051 break;
2052 }
2053 }
2054
2055 if (!b_unique) return false;
2056
2057 RoutePoint* pWP = CreateNewPoint(pwaypointex, b_permanent);
2058
2059 pWP->SetShowWaypointRangeRings(pwaypointex->nrange_rings > 0);
2060
2061 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2062 if (b_permanent) {
2063 // pConfig->AddNewWayPoint(pWP, -1);
2064 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
2065 }
2066
2067 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2068 pRouteManagerDialog->UpdateWptListCtrl();
2069
2070 return true;
2071}
2072
2074 // Find the RoutePoint
2075 bool b_found = false;
2076 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
2077
2078 if (prp) b_found = true;
2079
2080 if (b_found) {
2081 double lat_save = prp->m_lat;
2082 double lon_save = prp->m_lon;
2083
2084 prp->m_lat = pwaypoint->m_lat;
2085 prp->m_lon = pwaypoint->m_lon;
2086 prp->SetIconName(pwaypoint->IconName);
2087 prp->SetName(pwaypoint->m_MarkName);
2088 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
2089 prp->SetVisible(pwaypoint->IsVisible);
2090 if (pwaypoint->m_CreateTime.IsValid())
2091 prp->SetCreateTime(pwaypoint->m_CreateTime);
2092
2093 // Transcribe (clone) the html HyperLink List, if present
2094
2095 if (pwaypoint->m_HyperlinkList) {
2096 prp->m_HyperlinkList->clear();
2097 for (Plugin_Hyperlink* link : *pwaypoint->m_HyperlinkList) {
2098 Hyperlink* h = new Hyperlink();
2099 h->DescrText = link->DescrText;
2100 h->Link = link->Link;
2101 h->LType = link->Type;
2102 prp->m_HyperlinkList->push_back(h);
2103 }
2104 }
2105
2106 // Extended fields
2107 prp->SetWaypointRangeRingsNumber(pwaypoint->nrange_rings);
2108 prp->SetWaypointRangeRingsStep(pwaypoint->RangeRingSpace);
2109 prp->SetWaypointRangeRingsStepUnits(pwaypoint->RangeRingSpaceUnits);
2110 prp->SetWaypointRangeRingsColour(pwaypoint->RangeRingColor);
2111 prp->SetTideStation(pwaypoint->m_TideStation);
2112 prp->SetScaMin(pwaypoint->scamin);
2113 prp->SetUseSca(pwaypoint->b_useScamin);
2114 prp->SetNameShown(pwaypoint->IsNameVisible);
2115
2116 prp->SetShowWaypointRangeRings(pwaypoint->nrange_rings > 0);
2117
2118 if (prp) prp->ReLoadIcon();
2119
2120 auto canvas = gFrame->GetPrimaryCanvas();
2121 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
2122 canvas->GetScaleValue());
2123 SelectItem* pFind =
2124 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
2125 if (pFind) {
2126 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
2127 pFind->m_slon = pwaypoint->m_lon;
2128 }
2129
2130 if (!prp->m_btemp) {
2131 // pConfig->UpdateWayPoint(prp);
2132 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
2133 }
2134
2135 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2136 pRouteManagerDialog->UpdateWptListCtrl();
2137
2138 prp->SetPlannedSpeed(pwaypoint->m_PlannedSpeed);
2139 if (pwaypoint->m_ETD.IsValid())
2140 prp->SetETD(pwaypoint->m_ETD);
2141 else
2142 prp->SetETD(wxEmptyString);
2143 prp->SetWaypointArrivalRadius(pwaypoint->m_WaypointArrivalRadius);
2144 prp->SetShowWaypointRangeRings(pwaypoint->m_bShowWaypointRangeRings);
2145 prp->SetScaMax(pwaypoint->scamax);
2146 }
2147
2148 return b_found;
2149}
2150
2151std::unique_ptr<PlugIn_Waypoint_ExV2> GetWaypointExV2_Plugin(
2152 const wxString& GUID) {
2153 std::unique_ptr<PlugIn_Waypoint_ExV2> w(new PlugIn_Waypoint_ExV2);
2154 GetSingleWaypointExV2(GUID, w.get());
2155 return w;
2156}
2157
2158bool AddPlugInRouteExV2(PlugIn_Route_ExV2* proute, bool b_permanent) {
2159 Route* route = new Route();
2160
2161 PlugIn_Waypoint_ExV2* pwaypointex;
2162 RoutePoint *pWP, *pWP_src;
2163 int ip = 0;
2164 wxDateTime plannedDeparture;
2165
2166 wxPlugin_WaypointExV2ListNode* pwpnode = proute->pWaypointList->GetFirst();
2167 while (pwpnode) {
2168 pwaypointex = pwpnode->GetData();
2169
2170 pWP = pWayPointMan->FindRoutePointByGUID(pwaypointex->m_GUID);
2171 if (!pWP) {
2172 pWP = CreateNewPoint(pwaypointex, b_permanent);
2173 pWP->m_bIsolatedMark = false;
2174 }
2175
2176 route->AddPoint(pWP);
2177
2178 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2179
2180 if (ip > 0)
2181 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
2182 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
2183 route);
2184
2185 plannedDeparture = pwaypointex->m_CreateTime;
2186 ip++;
2187 pWP_src = pWP;
2188
2189 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
2190 }
2191
2192 route->m_PlannedDeparture = plannedDeparture;
2193
2194 route->m_RouteNameString = proute->m_NameString;
2195 route->m_RouteStartString = proute->m_StartString;
2196 route->m_RouteEndString = proute->m_EndString;
2197 if (!proute->m_GUID.IsEmpty()) {
2198 route->m_GUID = proute->m_GUID;
2199 }
2200 route->m_btemp = (b_permanent == false);
2201 route->SetVisible(proute->m_isVisible);
2202 route->m_RouteDescription = proute->m_Description;
2203
2204 pRouteList->push_back(route);
2205
2206 if (b_permanent) {
2207 // pConfig->AddNewRoute(route);
2208 NavObj_dB::GetInstance().InsertRoute(route);
2209 }
2210
2211 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2212 pRouteManagerDialog->UpdateRouteListCtrl();
2213
2214 return true;
2215}
2216
2218 bool b_found = false;
2219
2220 // Find the Route
2221 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
2222 if (pRoute) b_found = true;
2223
2224 if (b_found) {
2225 bool b_permanent = !pRoute->m_btemp;
2226 g_pRouteMan->DeleteRoute(pRoute);
2227
2228 b_found = AddPlugInRouteExV2(proute, b_permanent);
2229 }
2230
2231 return b_found;
2232}
2233
2234std::unique_ptr<PlugIn_Route_ExV2> GetRouteExV2_Plugin(const wxString& GUID) {
2235 std::unique_ptr<PlugIn_Route_ExV2> r;
2236 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
2237 if (route == nullptr) return r;
2238
2239 r = std::unique_ptr<PlugIn_Route_ExV2>(new PlugIn_Route_ExV2);
2240 PlugIn_Route_ExV2* dst_route = r.get();
2241
2242 for (RoutePoint* src_wp : *route->pRoutePointList) {
2244 PlugInExV2FromRoutePoint(dst_wp, src_wp);
2245 dst_route->pWaypointList->Append(dst_wp);
2246 }
2247 dst_route->m_NameString = route->m_RouteNameString;
2248 dst_route->m_StartString = route->m_RouteStartString;
2249 dst_route->m_EndString = route->m_RouteEndString;
2250 dst_route->m_GUID = route->m_GUID;
2251 dst_route->m_isActive = g_pRouteMan->GetpActiveRoute() == route;
2252 dst_route->m_isVisible = route->IsVisible();
2253 dst_route->m_Description = route->m_RouteDescription;
2254
2255 return r;
2256}
2257
2258// PlugInRouteExtended implementation
2259PlugIn_Route_Ex::PlugIn_Route_Ex() {
2260 pWaypointList = new Plugin_WaypointExList;
2261}
2262
2263PlugIn_Route_Ex::~PlugIn_Route_Ex() {
2264 pWaypointList->DeleteContents(false); // do not delete Waypoints
2265 pWaypointList->Clear();
2266
2267 delete pWaypointList;
2268}
2269
2270// The utility methods implementations
2271
2272// translate O route class to PlugIn_Waypoint_Ex
2273static void PlugInExFromRoutePoint(PlugIn_Waypoint_Ex* dst,
2274 /* const*/ RoutePoint* src) {
2275 dst->m_lat = src->m_lat;
2276 dst->m_lon = src->m_lon;
2277 dst->IconName = src->GetIconName();
2278 dst->m_MarkName = src->GetName();
2279 dst->m_MarkDescription = src->GetDescription();
2280 dst->IconDescription = pWayPointMan->GetIconDescription(src->GetIconName());
2281 dst->IsVisible = src->IsVisible();
2282 dst->m_CreateTime = src->GetCreateTime(); // not const
2283 dst->m_GUID = src->m_GUID;
2284
2285 // Transcribe (clone) the html HyperLink List, if present
2286 if (src->m_HyperlinkList) {
2287 delete dst->m_HyperlinkList;
2288 dst->m_HyperlinkList = nullptr;
2289
2290 if (src->m_HyperlinkList->size() > 0) {
2291 dst->m_HyperlinkList = new Plugin_HyperlinkList;
2292 for (Hyperlink* link : *src->m_HyperlinkList) {
2294 h->DescrText = link->DescrText;
2295 h->Link = link->Link;
2296 h->Type = link->LType;
2297 dst->m_HyperlinkList->Append(h);
2298 }
2299 }
2300 }
2301
2302 // Get the range ring info
2306
2307 // Get other extended info
2308 dst->IsNameVisible = src->m_bShowName;
2309 dst->scamin = src->GetScaMin();
2310 dst->b_useScamin = src->GetUseSca();
2311 dst->IsActive = src->m_bIsActive;
2312}
2313
2314static void cloneHyperlinkListEx(RoutePoint* dst,
2315 const PlugIn_Waypoint_Ex* src) {
2316 // Transcribe (clone) the html HyperLink List, if present
2317 if (src->m_HyperlinkList == nullptr) return;
2318
2319 if (src->m_HyperlinkList->GetCount() > 0) {
2320 wxPlugin_HyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
2321 while (linknode) {
2322 Plugin_Hyperlink* link = linknode->GetData();
2323
2324 Hyperlink* h = new Hyperlink();
2325 h->DescrText = link->DescrText;
2326 h->Link = link->Link;
2327 h->LType = link->Type;
2328
2329 dst->m_HyperlinkList->push_back(h);
2330
2331 linknode = linknode->GetNext();
2332 }
2333 }
2334}
2335
2336RoutePoint* CreateNewPoint(const PlugIn_Waypoint_Ex* src, bool b_permanent) {
2337 RoutePoint* pWP = new RoutePoint(src->m_lat, src->m_lon, src->IconName,
2338 src->m_MarkName, src->m_GUID);
2339
2340 pWP->m_bIsolatedMark = true; // This is an isolated mark
2341
2342 cloneHyperlinkListEx(pWP, src);
2343
2345
2346 if (src->m_CreateTime.IsValid())
2347 pWP->SetCreateTime(src->m_CreateTime);
2348 else {
2349 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
2350 }
2351
2352 pWP->m_btemp = (b_permanent == false);
2353
2354 // Extended fields
2355 pWP->SetIconName(src->IconName);
2356 pWP->SetWaypointRangeRingsNumber(src->nrange_rings);
2357 pWP->SetWaypointRangeRingsStep(src->RangeRingSpace);
2358 pWP->SetWaypointRangeRingsColour(src->RangeRingColor);
2359 pWP->SetScaMin(src->scamin);
2360 pWP->SetUseSca(src->b_useScamin);
2361 pWP->SetNameShown(src->IsNameVisible);
2362 pWP->SetVisible(src->IsVisible);
2363
2364 return pWP;
2365}
2366bool GetSingleWaypointEx(wxString GUID, PlugIn_Waypoint_Ex* pwaypoint) {
2367 // Find the RoutePoint
2368 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
2369
2370 if (!prp) return false;
2371
2372 PlugInExFromRoutePoint(pwaypoint, prp);
2373
2374 return true;
2375}
2376
2377bool AddSingleWaypointEx(PlugIn_Waypoint_Ex* pwaypointex, bool b_permanent) {
2378 // Validate the waypoint parameters a little bit
2379
2380 // GUID
2381 // Make sure that this GUID is indeed unique in the Routepoint list
2382 bool b_unique = true;
2383 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
2384 if (prp->m_GUID == pwaypointex->m_GUID) {
2385 b_unique = false;
2386 break;
2387 }
2388 }
2389
2390 if (!b_unique) return false;
2391
2392 RoutePoint* pWP = CreateNewPoint(pwaypointex, b_permanent);
2393
2394 pWP->SetShowWaypointRangeRings(pwaypointex->nrange_rings > 0);
2395
2396 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2397 if (b_permanent) {
2398 // pConfig->AddNewWayPoint(pWP, -1);
2399 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
2400 }
2401 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2402 pRouteManagerDialog->UpdateWptListCtrl();
2403
2404 return true;
2405}
2406
2408 // Find the RoutePoint
2409 bool b_found = false;
2410 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
2411
2412 if (prp) b_found = true;
2413
2414 if (b_found) {
2415 double lat_save = prp->m_lat;
2416 double lon_save = prp->m_lon;
2417
2418 prp->m_lat = pwaypoint->m_lat;
2419 prp->m_lon = pwaypoint->m_lon;
2420 prp->SetIconName(pwaypoint->IconName);
2421 prp->SetName(pwaypoint->m_MarkName);
2422 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
2423 prp->SetVisible(pwaypoint->IsVisible);
2424 if (pwaypoint->m_CreateTime.IsValid())
2425 prp->SetCreateTime(pwaypoint->m_CreateTime);
2426
2427 // Transcribe (clone) the html HyperLink List, if present
2428
2429 if (pwaypoint->m_HyperlinkList) {
2430 prp->m_HyperlinkList->clear();
2431 if (pwaypoint->m_HyperlinkList->GetCount() > 0) {
2432 wxPlugin_HyperlinkListNode* linknode =
2433 pwaypoint->m_HyperlinkList->GetFirst();
2434 while (linknode) {
2435 Plugin_Hyperlink* link = linknode->GetData();
2436
2437 Hyperlink* h = new Hyperlink();
2438 h->DescrText = link->DescrText;
2439 h->Link = link->Link;
2440 h->LType = link->Type;
2441
2442 prp->m_HyperlinkList->push_back(h);
2443
2444 linknode = linknode->GetNext();
2445 }
2446 }
2447 }
2448
2449 // Extended fields
2450 prp->SetWaypointRangeRingsNumber(pwaypoint->nrange_rings);
2451 prp->SetWaypointRangeRingsStep(pwaypoint->RangeRingSpace);
2452 prp->SetWaypointRangeRingsColour(pwaypoint->RangeRingColor);
2453 prp->SetScaMin(pwaypoint->scamin);
2454 prp->SetUseSca(pwaypoint->b_useScamin);
2455 prp->SetNameShown(pwaypoint->IsNameVisible);
2456
2457 prp->SetShowWaypointRangeRings(pwaypoint->nrange_rings > 0);
2458
2459 if (prp) prp->ReLoadIcon();
2460
2461 auto canvas = gFrame->GetPrimaryCanvas();
2462 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
2463 canvas->GetScaleValue());
2464 SelectItem* pFind =
2465 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
2466 if (pFind) {
2467 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
2468 pFind->m_slon = pwaypoint->m_lon;
2469 }
2470
2471 if (!prp->m_btemp) {
2472 // pConfig->UpdateWayPoint(prp);
2473 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
2474 }
2475
2476 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2477 pRouteManagerDialog->UpdateWptListCtrl();
2478 }
2479
2480 return b_found;
2481}
2482
2483bool AddPlugInRouteEx(PlugIn_Route_Ex* proute, bool b_permanent) {
2484 Route* route = new Route();
2485
2486 PlugIn_Waypoint_Ex* pwaypointex;
2487 RoutePoint *pWP, *pWP_src;
2488 int ip = 0;
2489 wxDateTime plannedDeparture;
2490
2491 wxPlugin_WaypointExListNode* pwpnode = proute->pWaypointList->GetFirst();
2492 while (pwpnode) {
2493 pwaypointex = pwpnode->GetData();
2494
2495 pWP = pWayPointMan->FindRoutePointByGUID(pwaypointex->m_GUID);
2496 if (!pWP) {
2497 pWP = CreateNewPoint(pwaypointex, b_permanent);
2498 pWP->m_bIsolatedMark = false;
2499 }
2500
2501 route->AddPoint(pWP);
2502
2503 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2504
2505 if (ip > 0)
2506 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
2507 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
2508 route);
2509
2510 plannedDeparture = pwaypointex->m_CreateTime;
2511 ip++;
2512 pWP_src = pWP;
2513
2514 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
2515 }
2516
2517 route->m_PlannedDeparture = plannedDeparture;
2518
2519 route->m_RouteNameString = proute->m_NameString;
2520 route->m_RouteStartString = proute->m_StartString;
2521 route->m_RouteEndString = proute->m_EndString;
2522 if (!proute->m_GUID.IsEmpty()) {
2523 route->m_GUID = proute->m_GUID;
2524 }
2525 route->m_btemp = (b_permanent == false);
2526 route->SetVisible(proute->m_isVisible);
2527 route->m_RouteDescription = proute->m_Description;
2528
2529 pRouteList->push_back(route);
2530
2531 if (b_permanent) {
2532 // pConfig->AddNewRoute(route);
2533 NavObj_dB::GetInstance().InsertRoute(route);
2534 }
2535
2536 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2537 pRouteManagerDialog->UpdateRouteListCtrl();
2538
2539 return true;
2540}
2541
2543 bool b_found = false;
2544
2545 // Find the Route
2546 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
2547 if (pRoute) b_found = true;
2548
2549 if (b_found) {
2550 bool b_permanent = !pRoute->m_btemp;
2551 g_pRouteMan->DeleteRoute(pRoute);
2552 b_found = AddPlugInRouteEx(proute, b_permanent);
2553 }
2554
2555 return b_found;
2556}
2557
2558std::unique_ptr<PlugIn_Waypoint_Ex> GetWaypointEx_Plugin(const wxString& GUID) {
2559 std::unique_ptr<PlugIn_Waypoint_Ex> w(new PlugIn_Waypoint_Ex);
2560 GetSingleWaypointEx(GUID, w.get());
2561 return w;
2562}
2563
2564std::unique_ptr<PlugIn_Route_Ex> GetRouteEx_Plugin(const wxString& GUID) {
2565 std::unique_ptr<PlugIn_Route_Ex> r;
2566 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
2567 if (route == nullptr) return r;
2568
2569 r = std::unique_ptr<PlugIn_Route_Ex>(new PlugIn_Route_Ex);
2570 PlugIn_Route_Ex* dst_route = r.get();
2571
2572 // PlugIn_Waypoint *pwp;
2573 RoutePoint* src_wp;
2574 for (RoutePoint* src_wp : *route->pRoutePointList) {
2575 PlugIn_Waypoint_Ex* dst_wp = new PlugIn_Waypoint_Ex();
2576 PlugInExFromRoutePoint(dst_wp, src_wp);
2577
2578 dst_route->pWaypointList->Append(dst_wp);
2579 }
2580 dst_route->m_NameString = route->m_RouteNameString;
2581 dst_route->m_StartString = route->m_RouteStartString;
2582 dst_route->m_EndString = route->m_RouteEndString;
2583 dst_route->m_GUID = route->m_GUID;
2584 dst_route->m_isActive = g_pRouteMan->GetpActiveRoute() == route;
2585 dst_route->m_isVisible = route->IsVisible();
2586 dst_route->m_Description = route->m_RouteDescription;
2587
2588 return r;
2589}
2590
2592 void) { // if no active waypoint, returns wxEmptyString
2593 RoutePoint* rp = g_pRouteMan->GetpActivePoint();
2594 if (!rp)
2595 return wxEmptyString;
2596 else
2597 return rp->m_GUID;
2598}
2599
2601 void) { // if no active route, returns wxEmptyString
2602 Route* rt = g_pRouteMan->GetpActiveRoute();
2603 if (!rt)
2604 return wxEmptyString;
2605 else
2606 return rt->m_GUID;
2607}
2608
2610int GetGlobalWatchdogTimoutSeconds() { return gps_watchdog_timeout_ticks; }
2611
2613std::vector<std::string> GetPriorityMaps() {
2614 MyApp& app = wxGetApp();
2615 return (app.m_comm_bridge.GetPriorityMaps());
2616}
2617
2618void UpdateAndApplyPriorityMaps(std::vector<std::string> map) {
2619 MyApp& app = wxGetApp();
2620 app.m_comm_bridge.UpdateAndApplyMaps(map);
2621}
2622
2623std::vector<std::string> GetActivePriorityIdentifiers() {
2624 std::vector<std::string> result;
2625
2626 MyApp& app = wxGetApp();
2627
2628 std::string id =
2629 app.m_comm_bridge.GetPriorityContainer("position").active_source;
2630 result.push_back(id);
2631 id = app.m_comm_bridge.GetPriorityContainer("velocity").active_source;
2632 result.push_back(id);
2633 id = app.m_comm_bridge.GetPriorityContainer("heading").active_source;
2634 result.push_back(id);
2635 id = app.m_comm_bridge.GetPriorityContainer("variation").active_source;
2636 result.push_back(id);
2637 id = app.m_comm_bridge.GetPriorityContainer("satellites").active_source;
2638 result.push_back(id);
2639
2640 return result;
2641}
2642
2644 double rv = 1.0;
2645#if defined(__WXOSX__) || defined(__WXGTK3__)
2646 // Support scaled HDPI displays.
2647 if (gFrame) rv = gFrame->GetContentScaleFactor();
2648#endif
2649 return rv;
2650}
2652 double scaler = 1.0;
2653#ifdef __WXMSW__
2654 if (gFrame) scaler = (double)(gFrame->ToDIP(100)) / 100.;
2655#endif
2656 return scaler;
2657}
2658
2659//---------------------------------------------------------------------------
2660// API 1.18
2661//---------------------------------------------------------------------------
2662
2663//---------------------------------------------------------------------------
2664// API 1.19
2665//---------------------------------------------------------------------------
2666void ExitOCPN() {}
2667
2668bool GetFullScreen() { return gFrame->IsFullScreen(); }
2669
2670void SetFullScreen(bool set_full_screen_on) {
2671 bool state = gFrame->IsFullScreen();
2672 if (set_full_screen_on && !state)
2673 gFrame->ToggleFullScreen();
2674 else if (!set_full_screen_on && state)
2675 gFrame->ToggleFullScreen();
2676}
2677
2678extern bool g_useMUI;
2679void EnableMUIBar(bool enable, int CanvasIndex) {
2680 bool current_mui_state = g_useMUI;
2681
2682 g_useMUI = enable;
2683 if (enable && !current_mui_state) { // OFF going ON
2684 // ..For each canvas...
2685 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2686 ChartCanvas* cc = g_canvasArray.Item(i);
2687 if (cc) cc->CreateMUIBar();
2688 }
2689 } else if (!enable && current_mui_state) { // ON going OFF
2690 // ..For each canvas...
2691 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2692 ChartCanvas* cc = g_canvasArray.Item(i);
2693 if (cc) cc->DestroyMuiBar();
2694 }
2695 }
2696}
2697
2698bool GetEnableMUIBar(int CanvasIndex) { return g_useMUI; }
2699
2700void EnableCompassGPSIcon(bool enable, int CanvasIndex) {
2701 if (CanvasIndex < GetCanvasCount()) {
2702 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2703 if (cc) cc->SetShowGPSCompassWindow(enable);
2704 }
2705}
2706
2707bool GetEnableCompassGPSIcon(int CanvasIndex) {
2708 if (CanvasIndex < GetCanvasCount()) {
2709 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2710 if (cc)
2711 return cc->GetShowGPSCompassWindow();
2712 else
2713 return false;
2714 }
2715 return false;
2716}
2717
2718extern bool g_bShowStatusBar;
2719void EnableStatusBar(bool enable) {
2720 g_bShowStatusBar = enable;
2721 gFrame->ConfigureStatusBar();
2722}
2723
2724bool GetEnableStatusBar() { return g_bShowStatusBar; }
2725
2726void EnableChartBar(bool enable, int CanvasIndex) {
2727 bool current_chartbar_state = g_bShowChartBar;
2728 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2729 ChartCanvas* cc = g_canvasArray.Item(i);
2730 if (current_chartbar_state && !enable) {
2731 gFrame->ToggleChartBar(cc);
2732 g_bShowChartBar = current_chartbar_state;
2733 } else if (!current_chartbar_state && enable) {
2734 gFrame->ToggleChartBar(cc);
2735 g_bShowChartBar = current_chartbar_state;
2736 }
2737 }
2738 g_bShowChartBar = enable;
2739}
2740
2741bool GetEnableChartBar(int CanvasIndex) { return g_bShowChartBar; }
2742
2743extern bool g_bShowMenuBar;
2744void EnableMenu(bool enable) {
2745 if (!enable) {
2746 if (g_bShowMenuBar) {
2747 g_bShowMenuBar = false;
2748 if (gFrame->m_pMenuBar) {
2749 gFrame->SetMenuBar(NULL);
2750 gFrame->m_pMenuBar->Destroy();
2751 gFrame->m_pMenuBar = NULL;
2752 }
2753 }
2754 } else {
2755 g_bShowMenuBar = true;
2756 gFrame->BuildMenuBar();
2757 }
2758}
2759
2760bool GetEnableMenu() { return g_bShowMenuBar; }
2761
2762void SetGlobalColor(std::string table, std::string name, wxColor color) {
2763 if (ps52plib) ps52plib->m_chartSymbols.UpdateTableColor(table, name, color);
2764}
2765
2766wxColor GetGlobalColorD(std::string map_name, std::string name) {
2767 wxColor ret = wxColor(*wxRED);
2768 if (ps52plib) {
2769 int i_table = ps52plib->m_chartSymbols.FindColorTable(map_name.c_str());
2770 ret = ps52plib->m_chartSymbols.GetwxColor(name.c_str(), i_table);
2771 }
2772 return ret;
2773}
2774
2775void EnableLatLonGrid(bool enable, int CanvasIndex) {
2776 if (CanvasIndex < GetCanvasCount()) {
2777 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2778 if (cc) cc->SetShowGrid(enable);
2779 }
2780}
2781
2782void EnableChartOutlines(bool enable, int CanvasIndex) {
2783 if (CanvasIndex < GetCanvasCount()) {
2784 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2785 if (cc) cc->SetShowOutlines(enable);
2786 }
2787}
2788
2789void EnableDepthUnitDisplay(bool enable, int CanvasIndex) {
2790 if (CanvasIndex < GetCanvasCount()) {
2791 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2792 if (cc) cc->SetShowDepthUnits(enable);
2793 }
2794}
2795
2796void EnableAisTargetDisplay(bool enable, int CanvasIndex) {
2797 if (CanvasIndex < GetCanvasCount()) {
2798 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2799 if (cc) cc->SetShowAIS(enable);
2800 }
2801}
2802
2803void EnableTideStationsDisplay(bool enable, int CanvasIndex) {
2804 if (CanvasIndex < GetCanvasCount()) {
2805 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2806 if (cc) cc->ShowTides(enable);
2807 }
2808}
2809
2810void EnableCurrentStationsDisplay(bool enable, int CanvasIndex) {
2811 if (CanvasIndex < GetCanvasCount()) {
2812 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2813 if (cc) cc->ShowCurrents(enable);
2814 }
2815}
2816
2817void EnableENCTextDisplay(bool enable, int CanvasIndex) {
2818 if (CanvasIndex < GetCanvasCount()) {
2819 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2820 if (cc) cc->SetShowENCText(enable);
2821 }
2822}
2823
2824void EnableENCDepthSoundingsDisplay(bool enable, int CanvasIndex) {
2825 if (CanvasIndex < GetCanvasCount()) {
2826 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2827 if (cc) cc->SetShowENCDepth(enable);
2828 }
2829}
2830
2831void EnableBuoyLightLabelsDisplay(bool enable, int CanvasIndex) {
2832 if (CanvasIndex < GetCanvasCount()) {
2833 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2834 if (cc) cc->SetShowENCBuoyLabels(enable);
2835 }
2836}
2837
2838void EnableLightsDisplay(bool enable, int CanvasIndex) {
2839 if (CanvasIndex < GetCanvasCount()) {
2840 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2841 if (cc) cc->SetShowENCLights(enable);
2842 }
2843}
2844
2845void EnableLightDescriptionsDisplay(bool enable, int CanvasIndex) {
2846 if (CanvasIndex < GetCanvasCount()) {
2847 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2848 if (cc) cc->SetShowENCLightDesc(enable);
2849 }
2850}
2851
2852void SetENCDisplayCategory(PI_DisCat cat, int CanvasIndex) {
2853 int valSet = STANDARD;
2854 switch (cat) {
2855 case PI_DISPLAYBASE:
2856 valSet = DISPLAYBASE;
2857 break;
2858 case PI_STANDARD:
2859 valSet = STANDARD;
2860 break;
2861 case PI_OTHER:
2862 valSet = OTHER;
2863 break;
2865 valSet = MARINERS_STANDARD;
2866 break;
2867 default:
2868 valSet = STANDARD;
2869 break;
2870 }
2871 if (CanvasIndex < GetCanvasCount()) {
2872 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2873 if (cc) cc->SetENCDisplayCategory(valSet);
2874 }
2875}
2877 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2878 if (cc)
2879 return ((PI_DisCat)cc->GetENCDisplayCategory());
2880 else
2881 return PI_DisCat::PI_STANDARD;
2882}
2883
2884void SetNavigationMode(PI_NavMode mode, int CanvasIndex) {
2885 int newMode = NORTH_UP_MODE;
2886 if (mode == PI_COURSE_UP_MODE)
2887 newMode = COURSE_UP_MODE;
2888 else if (mode == PI_HEAD_UP_MODE)
2889 newMode = HEAD_UP_MODE;
2890
2891 if (CanvasIndex < GetCanvasCount()) {
2892 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2893 if (cc) cc->SetUpMode(newMode);
2894 }
2895}
2897 if (CanvasIndex < GetCanvasCount()) {
2898 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2899 if (cc) return ((PI_NavMode)cc->GetUpMode());
2900 }
2901 return PI_NavMode::PI_NORTH_UP_MODE;
2902}
2903
2904bool GetEnableLatLonGrid(int CanvasIndex) {
2905 if (CanvasIndex < GetCanvasCount()) {
2906 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2907 if (cc) return (cc->GetShowGrid());
2908 }
2909 return false;
2910}
2911
2912bool GetEnableChartOutlines(int CanvasIndex) {
2913 if (CanvasIndex < GetCanvasCount()) {
2914 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2915 if (cc) return (cc->GetShowOutlines());
2916 }
2917 return false;
2918}
2919
2920bool GetEnableDepthUnitDisplay(int CanvasIndex) {
2921 if (CanvasIndex < GetCanvasCount()) {
2922 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2923 if (cc) return (cc->GetShowDepthUnits());
2924 }
2925 return false;
2926}
2927
2928bool GetEnableAisTargetDisplay(int CanvasIndex) {
2929 if (CanvasIndex < GetCanvasCount()) {
2930 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2931 if (cc) return (cc->GetShowAIS());
2932 }
2933 return false;
2934}
2935
2936bool GetEnableTideStationsDisplay(int CanvasIndex) {
2937 if (CanvasIndex < GetCanvasCount()) {
2938 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2939 if (cc) return (cc->GetbShowTide());
2940 }
2941 return false;
2942}
2943
2944bool GetEnableCurrentStationsDisplay(int CanvasIndex) {
2945 if (CanvasIndex < GetCanvasCount()) {
2946 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2947 if (cc) return (cc->GetbShowCurrent());
2948 }
2949 return false;
2950}
2951
2952bool GetEnableENCTextDisplay(int CanvasIndex) {
2953 if (CanvasIndex < GetCanvasCount()) {
2954 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2955 if (cc) return (cc->GetShowENCText());
2956 }
2957 return false;
2958}
2959
2961 if (CanvasIndex < GetCanvasCount()) {
2962 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2963 if (cc) return (cc->GetShowENCDepth());
2964 }
2965 return false;
2966}
2967
2968bool GetEnableBuoyLightLabelsDisplay(int CanvasIndex) {
2969 if (CanvasIndex < GetCanvasCount()) {
2970 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2971 if (cc) return (cc->GetShowENCBuoyLabels());
2972 }
2973 return false;
2974}
2975
2976bool GetEnableLightsDisplay(int CanvasIndex) {
2977 if (CanvasIndex < GetCanvasCount()) {
2978 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2979 if (cc) return (cc->GetShowENCLights());
2980 }
2981 return false;
2982}
2983
2984bool GetShowENCLightDesc(int CanvasIndex) {
2985 if (CanvasIndex < GetCanvasCount()) {
2986 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2987 if (cc) return (cc->GetbShowCurrent());
2988 }
2989 return false;
2990}
2991
2992void EnableTouchMode(bool enable) { g_btouch = enable; }
2993
2994bool GetTouchMode() { return g_btouch; }
2995
2996void EnableLookaheadMode(bool enable, int CanvasIndex) {
2997 if (CanvasIndex < GetCanvasCount()) {
2998 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2999 if (cc) cc->ToggleLookahead();
3000 }
3001}
3002
3003bool GetEnableLookaheadMode(int CanvasIndex) {
3004 if (CanvasIndex < GetCanvasCount()) {
3005 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3006 if (cc) return (cc->GetLookahead());
3007 }
3008 return false;
3009}
3010
3011extern bool g_bTrackActive;
3012void SetTrackingMode(bool enable) {
3013 if (!g_bTrackActive && enable)
3014 gFrame->TrackOn();
3015 else if (g_bTrackActive && !enable)
3016 gFrame->TrackOff();
3017}
3018bool GetTrackingMode() { return g_bTrackActive; }
3019
3021 gFrame->SetAndApplyColorScheme((ColorScheme)cs);
3022}
3024 return (PI_ColorScheme)global_color_scheme;
3025}
3026
3027void RequestWindowRefresh(wxWindow* win, bool eraseBackground) {
3028 if (win) win->Refresh(eraseBackground);
3029}
3030
3031void EnableSplitScreenLayout(bool enable) {
3032 if (g_canvasConfig == 1) {
3033 if (enable)
3034 return;
3035 else { // split to single
3036 g_canvasConfig = 0; // 0 => "single canvas"
3037 gFrame->CreateCanvasLayout();
3038 gFrame->DoChartUpdate();
3039 }
3040 } else {
3041 if (enable) { // single to split
3042 g_canvasConfig = 1; // 1 => "two canvas"
3043 gFrame->CreateCanvasLayout();
3044 gFrame->DoChartUpdate();
3045 } else {
3046 return;
3047 }
3048 }
3049}
3050
3051// ChartCanvas control utilities
3052
3053void PluginZoomCanvas(int CanvasIndex, double factor) {
3054 if (CanvasIndex < GetCanvasCount()) {
3055 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3056 if (cc) cc->ZoomCanvasSimple(factor);
3057 }
3058}
3059
3060bool GetEnableMainToolbar() { return (!g_disable_main_toolbar); }
3061void SetEnableMainToolbar(bool enable) {
3062 g_disable_main_toolbar = !enable;
3063 if (g_MainToolbar) g_MainToolbar->RefreshToolbar();
3064}
3065
3067 if (gFrame) gFrame->ScheduleSettingsDialog();
3068}
3069
3070void PluginCenterOwnship(int CanvasIndex) {
3071 if (CanvasIndex < GetCanvasCount()) {
3072 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3073 if (cc) {
3074 bool bfollow = cc->GetbFollow();
3075 cc->ResetOwnshipOffset();
3076 if (bfollow)
3077 cc->SetbFollow();
3078 else
3079 cc->JumpToPosition(gLat, gLon, cc->GetVPScale());
3080 }
3081 }
3082}
3083
3084void PluginSetFollowMode(int CanvasIndex, bool enable_follow) {
3085 if (CanvasIndex < GetCanvasCount()) {
3086 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3087 if (cc) {
3088 if (cc->GetbFollow() != enable_follow) cc->TogglebFollow();
3089 }
3090 }
3091}
3092
3093bool PluginGetFollowMode(int CanvasIndex) {
3094 if (CanvasIndex < GetCanvasCount()) {
3095 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3096 if (cc) return cc->GetbFollow();
3097 }
3098 return false;
3099}
3100
3101void EnableCanvasFocusBar(bool enable, int CanvasIndex) {
3102 if (CanvasIndex < GetCanvasCount()) {
3103 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3104 if (cc) cc->SetShowFocusBar(enable);
3105 }
3106}
3107bool GetEnableCanvasFocusBar(int CanvasIndex) {
3108 if (CanvasIndex < GetCanvasCount()) {
3109 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3110 if (cc) return (cc->GetShowFocusBar());
3111 }
3112 return false;
3113}
3114
3115bool GetEnableTenHertzUpdate() { return g_btenhertz; }
3116
3117void EnableTenHertzUpdate(bool enable) { g_btenhertz = enable; }
3118
3120 if (pConfig) {
3121 pConfig->Flush();
3122
3123 // Handle system general configuration options
3124 pConfig->LoadMyConfigRaw(false);
3125
3126 // Handle chart canvas window configuration options
3127 pConfig->LoadCanvasConfigs(false);
3128 auto& config_array = ConfigMgr::Get().GetCanvasConfigArray();
3129 for (auto pcc : config_array) {
3130 if (pcc && pcc->canvas) {
3131 pcc->canvas->ApplyCanvasConfig(pcc);
3132 pcc->canvas->Refresh();
3133 }
3134 }
3135 }
3136}
3137
3142 g_CanvasHideNotificationIcon = !enable;
3143}
3144
3145//---------------------------------------------------------------------------
3146// API 1.21
3147//---------------------------------------------------------------------------
3148
3149// Plugin API121 Utility functions
3150
3151wxString DropMarkPI(double lat, double lon) {
3152 if ((fabs(lat) > 80.0) || (fabs(lon) > 180.)) return "";
3153
3154 RoutePoint* pWP =
3155 new RoutePoint(lat, lon, g_default_wp_icon, wxEmptyString, wxEmptyString);
3156 pWP->m_bIsolatedMark = true; // This is an isolated mark
3157 pSelect->AddSelectableRoutePoint(lat, lon, pWP);
3158 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
3159 return pWP->m_GUID;
3160}
3161
3162wxString RouteCreatePI(int canvas_index, bool start) {
3163 if ((size_t)canvas_index < g_canvasArray.GetCount()) {
3164 ChartCanvas* cc = g_canvasArray.Item(canvas_index);
3165 if (cc) {
3166 if (start) {
3167 cc->StartRoute();
3168 return "0";
3169 } else {
3170 return cc->FinishRoute();
3171 }
3172 }
3173 }
3174 return "-1";
3175}
3176
3177bool DoMeasurePI(int canvas_index, bool start) {
3178 if ((size_t)canvas_index < g_canvasArray.GetCount()) {
3179 ChartCanvas* cc = g_canvasArray.Item(canvas_index);
3180 if (cc) {
3181 if (start) {
3182 cc->StartMeasureRoute();
3183 return true;
3184 } else {
3185 cc->CancelMeasureRoute();
3186 cc->Refresh(false);
3187 return true;
3188 }
3189 }
3190 }
3191 return false;
3192}
3193
3194wxString NavToHerePI(double lat, double lon) {
3195 RoutePoint* pWP_dest =
3196 new RoutePoint(lat, lon, g_default_wp_icon, wxEmptyString, wxEmptyString);
3197 pSelect->AddSelectableRoutePoint(lat, lon, pWP_dest);
3198
3199 RoutePoint* pWP_src = new RoutePoint(gLat, gLon, g_default_wp_icon,
3200 wxEmptyString, wxEmptyString);
3201 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
3202
3203 Route* temp_route = new Route();
3204 pRouteList->push_back(temp_route);
3205
3206 temp_route->AddPoint(pWP_src);
3207 temp_route->AddPoint(pWP_dest);
3208
3209 pSelect->AddSelectableRouteSegment(gLat, gLon, lat, lon, pWP_src, pWP_dest,
3210 temp_route);
3211
3212 temp_route->m_RouteNameString = _("Temporary GOTO Route");
3213 temp_route->m_RouteStartString = _("Here");
3214 temp_route->m_RouteEndString = _("There");
3215 temp_route->m_bDeleteOnArrival = true;
3216
3217 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
3218
3219 g_pRouteMan->ActivateRoute(temp_route, pWP_dest);
3220 return temp_route->m_GUID;
3221}
3222
3223bool ActivateRoutePI(wxString route_guid, bool activate) {
3224 Route* route = g_pRouteMan->FindRouteByGUID(route_guid);
3225 if (!route) return false;
3226
3227 if (activate) {
3228 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
3229 RoutePoint* best_point =
3230 g_pRouteMan->FindBestActivatePoint(route, gLat, gLon, gCog, gSog);
3231 g_pRouteMan->ActivateRoute(route, best_point);
3232 route->m_bRtIsSelected = false;
3233 return true;
3234 } else {
3235 g_pRouteMan->DeactivateRoute();
3236 route->m_bRtIsSelected = false;
3237 return true;
3238 }
3239 return false;
3240}
3241
3242void EnableDefaultConsole(bool enable) { g_bhide_route_console = !enable; }
3243void EnableDefaultContextMenus(bool enable) { g_bhide_context_menus = !enable; }
3244
3245void SetMinZoomScale(double min_scale) {
3246 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
3247 ChartCanvas* cc = g_canvasArray.Item(i);
3248 cc->SetAbsoluteMinScale(min_scale);
3249 }
3250}
3251
3252void SetMaxZoomScale(double max_scale) {
3253 g_maxzoomin = wxRound(wxMax(max_scale, 100.));
3254}
3255
3256std::shared_ptr<PI_PointContext> GetContextAtPoint(int x, int y,
3257 int canvas_index) {
3258 ChartCanvas* cc = g_canvasArray.Item(canvas_index);
3259 if (cc) {
3260 return cc->GetCanvasContextAtPoint(x, y);
3261 } else {
3262 auto rstruct = std::make_shared<PI_PointContext>();
3263 rstruct->object_type = OBJECT_UNKNOWN;
3264 rstruct->object_ident = "";
3265 return rstruct;
3266 }
3267}
3268
3269wxBitmap GetObjectIcon_PlugIn(const wxString& name) {
3270 if (pWayPointMan) {
3271 return *pWayPointMan->GetIconBitmap(name);
3272 } else
3273 return wxNullBitmap;
3274}
3275
3276bool IsRouteActive(wxString route_guid) {
3277 if (g_pRouteMan->GetpActiveRoute())
3278 return (route_guid.IsSameAs(g_pRouteMan->GetpActiveRoute()->m_GUID));
3279 else
3280 return false;
3281}
3282
3283void SetBoatPosition(double zlat, double zlon) {
3284 gLat = zlat;
3285 gLon = zlon;
3286 gFrame->UpdateStatusBar();
3287}
3288
3289void RouteInsertWaypoint(int canvas_index, wxString route_guid, double zlat,
3290 double zlon) {
3291 ChartCanvas* parent =
3292 static_cast<ChartCanvas*>(GetCanvasByIndex(canvas_index));
3293 if (!parent) return;
3294
3295 Route* route = g_pRouteMan->FindRouteByGUID(route_guid);
3296 if (!route) return;
3297
3298 if (route->m_bIsInLayer) return;
3299
3300 int seltype = parent->PrepareContextSelections(zlat, zlon);
3301 if ((seltype & SELTYPE_ROUTESEGMENT) != SELTYPE_ROUTESEGMENT) return;
3302
3303 bool rename = false;
3304 route->InsertPointAfter(parent->GetFoundRoutepoint(), zlat, zlon, rename);
3305
3306 pSelect->DeleteAllSelectableRoutePoints(route);
3307 pSelect->DeleteAllSelectableRouteSegments(route);
3308 pSelect->AddAllSelectableRouteSegments(route);
3309 pSelect->AddAllSelectableRoutePoints(route);
3310
3311 NavObj_dB::GetInstance().UpdateRoute(route);
3312}
3313
3314void RouteAppendWaypoint(int canvas_index, wxString route_guid) {
3315 Route* route = g_pRouteMan->FindRouteByGUID(route_guid);
3316 if (!route) return;
3317
3318 ChartCanvas* parent =
3319 static_cast<ChartCanvas*>(GetCanvasByIndex(canvas_index));
3320 if (!parent) return;
3321
3322 parent->m_pMouseRoute = route;
3323 parent->m_routeState = route->GetnPoints() + 1;
3324 parent->m_pMouseRoute->m_lastMousePointIndex = route->GetnPoints();
3325 parent->m_pMouseRoute->SetHiLite(50);
3326
3327 auto pLast = route->GetLastPoint();
3328
3329 parent->m_prev_rlat = pLast->m_lat;
3330 parent->m_prev_rlon = pLast->m_lon;
3331 parent->m_prev_pMousePoint = pLast;
3332
3333 parent->m_bAppendingRoute = true;
3334}
3335
3336void FinishRoute(int canvas_index) {
3337 ChartCanvas* parent =
3338 static_cast<ChartCanvas*>(GetCanvasByIndex(canvas_index));
3339 if (!parent) return;
3340
3341 parent->FinishRoute();
3342}
3343
3344bool IsRouteBeingCreated(int canvas_index) {
3345 ChartCanvas* parent =
3346 static_cast<ChartCanvas*>(GetCanvasByIndex(canvas_index));
3347 if (!parent) return false;
3348 return !(parent->m_pMouseRoute == NULL);
3349}
3350
3351bool AreRouteWaypointNamesVisible(wxString route_guid) {
3352 Route* route = g_pRouteMan->FindRouteByGUID(route_guid);
3353 if (!route) return false;
3354 return route->AreWaypointNamesVisible();
3355}
3356
3357void ShowRouteWaypointNames(wxString route_guid, bool show) {
3358 Route* route = g_pRouteMan->FindRouteByGUID(route_guid);
3359 if (!route) return;
3360 route->ShowWaypointNames(show);
3361}
3362
3363void NavigateToWaypoint(wxString waypoint_guid) {
3364 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(waypoint_guid);
3365 if (!prp) return;
3366
3367 RoutePoint* pWP_src = new RoutePoint(gLat, gLon, g_default_wp_icon,
3368 wxEmptyString, wxEmptyString);
3369 pSelect->AddSelectableRoutePoint(gLat, gLon, pWP_src);
3370
3371 Route* temp_route = new Route();
3372 pRouteList->push_back(temp_route);
3373
3374 temp_route->AddPoint(pWP_src);
3375 temp_route->AddPoint(prp);
3376 prp->SetShared(true);
3377
3378 pSelect->AddSelectableRouteSegment(gLat, gLon, prp->m_lat, prp->m_lon,
3379 pWP_src, prp, temp_route);
3380
3381 wxString name = prp->GetName();
3382 if (name.IsEmpty()) name = _("(Unnamed Waypoint)");
3383 wxString rteName = _("Go to ");
3384 rteName.Append(name);
3385 temp_route->m_RouteNameString = rteName;
3386 temp_route->m_RouteStartString = _("Here");
3387 temp_route->m_RouteEndString = name;
3388 temp_route->m_bDeleteOnArrival = true;
3389
3390 if (g_pRouteMan->GetpActiveRoute()) g_pRouteMan->DeactivateRoute();
3391 g_pRouteMan->ActivateRoute(temp_route, prp);
3392}
3393
3394// AIS related
3395bool IsAISTrackVisible(wxString ais_mmsi) {
3396 long mmsi = 0;
3397 ais_mmsi.ToLong(&mmsi);
3398 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(mmsi);
3399 if (myptarget)
3400 return myptarget->b_show_track;
3401 else
3402 return false;
3403}
3404
3405void AISToggleShowTrack(wxString ais_mmsi) {
3406 long mmsi = 0;
3407 ais_mmsi.ToLong(&mmsi);
3408 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(mmsi);
3409 if (myptarget) myptarget->ToggleShowTrack();
3410}
3411
3412bool IsAIS_CPAVisible(wxString ais_mmsi) {
3413 long mmsi = 0;
3414 ais_mmsi.ToLong(&mmsi);
3415 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(mmsi);
3416 if (myptarget)
3417 return myptarget->b_show_AIS_CPA;
3418 else
3419 return false;
3420}
3421
3422void AISToggleShowCPA(wxString ais_mmsi) {
3423 long mmsi = 0;
3424 ais_mmsi.ToLong(&mmsi);
3425 auto myptarget = g_pAIS->Get_Target_Data_From_MMSI(mmsi);
3426 if (myptarget) myptarget->Toggle_AIS_CPA();
3427}
3428
3429void ShowAISTargetQueryDialog(int canvas_index, wxString ais_mmsi) {
3430 ChartCanvas* parent =
3431 static_cast<ChartCanvas*>(GetCanvasByIndex(canvas_index));
3432 if (!parent) return;
3433
3434 long mmsi = 0;
3435 ais_mmsi.ToLong(&mmsi);
3436 ShowAISTargetQueryDialog(parent, mmsi);
3437}
3438
3439void ShowAISTargetList(int canvas_index) {
3440 ChartCanvas* parent =
3441 static_cast<ChartCanvas*>(GetCanvasByIndex(canvas_index));
3442 if (!parent) return;
3443 parent->ShowAISTargetList();
3444}
3445
3446bool IsMeasureActive(int canvas_index) {
3447 ChartCanvas* parent =
3448 static_cast<ChartCanvas*>(GetCanvasByIndex(canvas_index));
3449 if (!parent) return false;
3450 return parent->m_bMeasure_Active;
3451}
3452
3453void CancelMeasure(int canvas_index) {
3454 ChartCanvas* parent =
3455 static_cast<ChartCanvas*>(GetCanvasByIndex(canvas_index));
3456 if (!parent) return;
3457 parent->CancelMeasureRoute();
3458}
3459
3460void SetDepthUnitVisible(bool bviz) { g_bhide_depth_units = !bviz; }
3461
3462void SetOverzoomFlagVisible(bool bviz) { g_bhide_overzoom_flag = !bviz; }
3463
3464// Extended Chart table management support
3465void AddNoShowDirectory(std::string chart_dir) {
3466 ChartDirectoryExcludedVector.push_back(chart_dir);
3467}
3468void RemoveNoShowDirectory(std::string chart_dir) {
3469 auto it = std::find(ChartDirectoryExcludedVector.begin(),
3470 ChartDirectoryExcludedVector.end(), chart_dir);
3471 if (it != ChartDirectoryExcludedVector.end())
3472 ChartDirectoryExcludedVector.erase(it); // Erase the element
3473}
3474void ClearNoShowVector() { ChartDirectoryExcludedVector.clear(); }
3475const std::vector<std::string>& GetNoShowVector() {
3477}
3478
3479// Enhanced AIS Target List support
3480
3481void CenterToAisTarget(wxString ais_mmsi) {
3482 long mmsi = 0;
3483 if (ais_mmsi.ToLong(&mmsi)) {
3484 std::shared_ptr<AisTargetData> pAISTarget = NULL;
3485 if (g_pAIS) pAISTarget = g_pAIS->Get_Target_Data_From_MMSI(mmsi);
3486
3487 if (pAISTarget) {
3488 double scale = gFrame->GetFocusCanvas()->GetVPScale();
3489 if (1) {
3490 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), pAISTarget->Lat,
3491 pAISTarget->Lon, scale);
3492 } else {
3493 // Set a reasonable (1:5000) chart scale to see the target.
3494 if (scale < 0.7) { // Don't zoom if already close.
3495 ChartCanvas* cc = gFrame->GetFocusCanvas();
3496 double factor = cc->GetScaleValue() / 5000.0;
3497 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), pAISTarget->Lat,
3498 pAISTarget->Lon, scale * factor);
3499 }
3500 }
3501 }
3502 }
3503} // same as AISTargetListDialog::CenterToTarget ( false )
3504
3505void AisTargetCreateWpt(wxString ais_mmsi) {
3506 long mmsi = 0;
3507 if (ais_mmsi.ToLong(&mmsi)) {
3508 std::shared_ptr<AisTargetData> pAISTarget = NULL;
3509 if (g_pAIS) pAISTarget = g_pAIS->Get_Target_Data_From_MMSI(mmsi);
3510
3511 if (pAISTarget) {
3512 RoutePoint* pWP =
3513 new RoutePoint(pAISTarget->Lat, pAISTarget->Lon, g_default_wp_icon,
3514 wxEmptyString, wxEmptyString);
3515 pWP->m_bIsolatedMark = true; // This is an isolated mark
3516 pSelect->AddSelectableRoutePoint(pAISTarget->Lat, pAISTarget->Lon, pWP);
3517 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
3518
3519 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
3520 pRouteManagerDialog->UpdateWptListCtrl();
3521 }
3522 }
3523} // same as AISTargetListDialog::OnTargetCreateWpt
3524
3525void AisShowAllTracks(bool show) {
3526 if (g_pAIS) {
3527 for (const auto& it : g_pAIS->GetTargetList()) {
3528 auto pAISTarget = it.second;
3529 if (NULL != pAISTarget) {
3530 pAISTarget->b_show_track = show;
3531
3532 // Check for any persistently tracked target, force b_show_track_old
3533 std::map<int, Track*>::iterator itt;
3534 itt = g_pAIS->m_persistent_tracks.find(pAISTarget->MMSI);
3535 if (itt != g_pAIS->m_persistent_tracks.end()) {
3536 pAISTarget->b_show_track_old = show;
3537 }
3538 }
3539 }
3540 } // same as AISTargetListDialog::OnHideAllTracks /
3541 // AISTargetListDialog::OnShowAllTracks
3542}
3543
3544void AisToggleTrack(wxString ais_mmsi) {
3545 long mmsi = 0;
3546 if (ais_mmsi.ToLong(&mmsi)) {
3547 std::shared_ptr<AisTargetData> pAISTarget = NULL;
3548 if (g_pAIS) pAISTarget = g_pAIS->Get_Target_Data_From_MMSI(mmsi);
3549
3550 if (pAISTarget) {
3551 pAISTarget->b_show_track_old =
3552 pAISTarget->b_show_track; // Store current state before toggling
3553 pAISTarget->b_show_track =
3554 !pAISTarget->b_show_track; // Toggle visibility
3555 }
3556 }
3557}
3558
3559// Context menu enable/disable, by object type
3560int GetContextMenuMask() { return g_canvas_context_Menu_Disable_Mask; }
3561void SetContextMenuMask(int mask) { g_canvas_context_Menu_Disable_Mask = mask; }
AisDecoder * g_pAIS
Global instance.
Class AisDecoder and helpers.
std::vector< std::string > ChartDirectoryExcludedVector
Global instance.
Definition chartdb.cpp:72
ChartDB * ChartData
Global instance.
Definition chartdb.cpp:70
Charts database management
ChartGroupArray * g_pGroupArray
Global instance.
Definition chartdbs.cpp:56
ChartCanvas * g_focusCanvas
Global instance.
Definition chcanv.cpp:1219
ChartCanvas * g_overlayCanvas
Global instance.
Definition chcanv.cpp:1218
Generic Chart canvas base.
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:157
int PrepareContextSelections(double lat, double lon)
Definition chcanv.cpp:7916
float GetVPScale()
Return the ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:472
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4497
Manages the chart database and provides access to chart data.
Definition chartdb.h:95
bool LoadBinary(const wxString &filename, ArrayOfCDI &dir_array_check)
Load the chart database from a binary file.
Definition chartdb.cpp:229
Wrapper class for plugin-based charts.
Definition chartimg.h:389
wxFont * FindOrCreateFont(int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underline=false, const wxString &facename=wxEmptyString, wxFontEncoding encoding=wxFONTENCODING_DEFAULT)
Creates or finds a matching font in the font cache.
Definition font_mgr.cpp:440
wxColour GetFontColor(const wxString &TextElement) const
Gets the text color for a UI element.
Definition font_mgr.cpp:108
bool AddAuxKey(wxString key)
Adds new plugin-defined font configuration key.
Definition font_mgr.cpp:651
bool SetFontColor(const wxString &TextElement, const wxColour color) const
Sets the text color for a UI element.
Definition font_mgr.cpp:113
static wxString GetUUID(void)
Return a unique RFC4122 version 4 compliant GUID string.
Main application frame.
Definition ocpn_frame.h:139
void Notify(std::shared_ptr< const NavMsg > message)
Accept message received by driver, make it available for upper layers.
double GetDisplaySizeMM()
Get the width of the screen in millimeters.
Extended OpenGL-optimized chart base class with additional querying capabilities.
virtual ListOfPI_S57Obj * GetLightsObjRuleListVisibleAtLatLon(float lat, float lon, PlugIn_ViewPort *VPoint)
Gets list of visible light objects at specified position.
Basic data for a loaded plugin, trivially copyable.
AIS target information accessible to plugins.
double HDG
Heading in degrees true.
int ROTAIS
Rate of turn as indicated in AIS message.
unsigned char ShipType
Ship type as per ITU-R M.1371.
double Lat
Latitude in decimal degrees.
int MMSI
Maritime Mobile Service Identity number.
bool bCPA_Valid
True if CPA calculation is valid.
double Brg
Bearing to target in degrees true.
double Lon
Longitude in decimal degrees.
double CPA
Closest Point of Approach in nautical miles.
int Class
AIS class (Class A: 0, Class B: 1)
double SOG
Speed over ground in knots.
double Range_NM
Range to target in nautical miles.
int NavStatus
Navigational status (0-15 as per ITU-R M.1371)
int IMO
IMO ship identification number.
double TCPA
Time to Closest Point of Approach in minutes.
double COG
Course over ground in degrees.
plugin_ais_alarm_type alarm_state
Current alarm state for this target.
Extended position fix information.
int nSats
Number of satellites used in the fix.
double Var
Magnetic variation in degrees, typically from RMC message.
double Cog
Course over ground in degrees [0-360).
double Lat
Latitude in decimal degrees.
double Hdm
Heading magnetic in degrees [0-360).
time_t FixTime
UTC time of fix.
double Lon
Longitude in decimal degrees.
double Sog
Speed over ground in knots.
double Hdt
Heading true in degrees [0-360).
Enhanced route class for working with PlugIn_Waypoint_ExV2 waypoints.
bool m_isVisible
True if route should be displayed.
Plugin_WaypointExV2List * pWaypointList
List of waypoints making up this route in order.
wxString m_StartString
Description of route start point.
wxString m_Description
Optional route description/notes.
wxString m_NameString
User-visible name of the route.
bool m_isActive
True if this is the active route.
wxString m_GUID
Globally unique identifier.
wxString m_EndString
Description of route end point.
Extended route class for managing complex route features.
wxString m_Description
Optional route description/notes.
wxString m_EndString
Description of route end point.
Plugin_WaypointExList * pWaypointList
List of waypoints making up this route in order.
wxString m_NameString
User-visible name of the route.
bool m_isVisible
True if route should be displayed.
wxString m_GUID
Globally unique identifier.
bool m_isActive
True if this is the active route.
wxString m_StartString
Description of route start point.
Plugin route class for managing ordered waypoint collections.
wxString m_GUID
Globally unique identifier.
wxString m_EndString
Name/description of ending point.
wxString m_NameString
Route name.
Plugin_WaypointList * pWaypointList
List of waypoints making up this route in order.
wxString m_StartString
Name/description of starting point.
Plugin track class for managing recorded track data.
Plugin_WaypointList * pWaypointList
List of waypoints making up this track in chronological order.
wxString m_GUID
Globally unique identifier.
wxString m_EndString
Description of track end point/time.
wxString m_StartString
Description of track start point/time.
wxString m_NameString
Display name of the track.
Contains view parameters and status information for a chart display viewport.
double view_scale_ppm
Display scale in pixels per meter.
wxRect rv_rect
Rectangle defining the rendered view area.
int pix_width
Viewport width in pixels.
double lon_max
Maximum longitude of the viewport.
double clon
Center longitude of the viewport in decimal degrees.
double lat_max
Maximum latitude of the viewport.
int pix_height
Viewport height in pixels.
double clat
Center latitude of the viewport in decimal degrees.
double skew
Display skew angle in radians.
double rotation
Display rotation angle in radians.
bool bValid
True if this viewport is valid and can be used for rendering.
double lon_min
Minimum longitude of the viewport.
double lat_min
Minimum latitude of the viewport.
int m_projection_type
Chart projection type (PROJECTION_MERCATOR, etc.)
bool b_quilt
True if the viewport is in quilt mode (showing multiple charts)
float chart_scale
Conventional chart displayed scale (e.g., 1:50000)
wxDateTime m_ETD
Estimated departure time in UTC, or wxInvalidDateTime if not set.
wxString m_MarkDescription
Optional description text.
int GetRouteMembershipCount()
Gets number of routes containing this waypoint.
wxString m_GUID
Globally unique identifier.
wxString m_TideStation
Tide Station Identifier.
void InitDefaults()
Initializes waypoint properties to default values.
wxDateTime m_CreateTime
Creation timestamp in UTC.
bool m_bShowWaypointRangeRings
True to show range rings on chart.
wxString IconDescription
User-friendly description of icon.
double m_lat
Latitude in decimal degrees.
wxColour RangeRingColor
Color to draw range rings.
bool IsActive
Active state (e.g. destination)
Plugin_HyperlinkList * m_HyperlinkList
List of hyperlinks associated with this waypoint.
double scamin
Minimum display scale (1:X) for waypoint visibility.
double scamax
Maximum display scale (1:X) for waypoint visibility.
bool b_useScamin
True to enable scale-dependent visibility.
wxString IconName
Name of icon to use for waypoint symbol.
bool IsNameVisible
True to show waypoint name on chart.
double m_PlannedSpeed
Planned speed for next leg (knots)
double RangeRingSpace
Distance between range rings in preferred units.
double m_lon
Longitude in decimal degrees.
double m_WaypointArrivalRadius
Arrival radius in nautical miles.
int RangeRingSpaceUnits
Units for range ring spacing - 0:nm, 1:km.
wxString m_MarkName
Display name of waypoint.
bool IsVisible
Visibility state on chart.
int nrange_rings
Number of range rings to display around waypoint.
bool GetFSStatus()
Gets "free-standing" status of waypoint.
Extended waypoint class with additional navigation features.
bool GetFSStatus()
Gets "free-standing" status of waypoint.
wxDateTime m_CreateTime
Creation timestamp in UTC.
wxColour RangeRingColor
Color to draw range rings.
int nrange_rings
Number of range rings to display around waypoint.
wxString IconDescription
User-friendly description of icon.
bool b_useScamin
True to enable scale-dependent visibility.
double RangeRingSpace
Distance between range rings in preferred units.
Plugin_HyperlinkList * m_HyperlinkList
List of hyperlinks associated with this waypoint.
wxString m_MarkName
Display name of waypoint.
wxString m_GUID
Globally unique identifier.
double m_lon
Longitude in decimal degrees.
wxString IconName
Name of icon to use for waypoint symbol.
void InitDefaults()
Initializes waypoint properties to default values.
double scamin
Minimum display scale (1:X) for waypoint visibility.
bool IsNameVisible
True to show waypoint name on chart.
double m_lat
Latitude in decimal degrees.
wxString m_MarkDescription
Optional description text.
int GetRouteMembershipCount()
Gets number of routes containing this waypoint.
bool IsActive
Active state (e.g. destination)
bool IsVisible
Visibility state on chart.
Plugin waypoint class providing core waypoint/mark functionality.
double m_lon
Longitude in decimal degrees.
wxString m_IconName
Icon identifier.
wxString m_MarkDescription
Optional description.
wxString m_GUID
Globally unique identifier.
bool m_IsVisible
Visibility state.
PlugIn_Waypoint()
Default constructor - creates waypoint at 0,0.
wxDateTime m_CreateTime
Creation timestamp in UTC.
wxString m_MarkName
Display name.
double m_lat
Latitude in decimal degrees.
Plugin_HyperlinkList * m_HyperlinkList
List of associated hyperlinks.
Represents a waypoint or mark within the navigation system.
Definition route_point.h:71
HyperlinkList * m_HyperlinkList
List of hyperlinks associated with this waypoint.
wxColour m_wxcWaypointRangeRingsColour
Color for the range rings display.
wxString m_MarkDescription
Description text for the waypoint.
int m_iWaypointRangeRingsNumber
Number of range rings to display around the waypoint.
void SetCreateTime(wxDateTime dt)
Sets the create time of this RoutePoint in UTC.
wxString m_GUID
Globally Unique Identifier for the waypoint.
bool m_bIsolatedMark
Flag indicating if the waypoint is a standalone mark.
bool m_bIsActive
Flag indicating if this waypoint is active for navigation.
wxDateTime GetManualETD()
Retrieves the manually set Estimated Time of Departure for this waypoint, in UTC.
bool m_bIsInRoute
Flag indicating if this waypoint is part of a route.
bool m_bShowName
Flag indicating if the waypoint name should be shown.
double GetPlannedSpeed()
Return the planned speed associated with this waypoint.
bool m_btemp
Flag indicating if this is a temporary waypoint.
int m_iWaypointRangeRingsStepUnits
Units for the range rings step (0=nm, 1=km).
wxDateTime GetCreateTime(void)
Returns the Create Time of this RoutePoint in UTC.
float m_fWaypointRangeRingsStep
Distance between consecutive range rings.
wxString m_TideStation
Associated tide station identifier.
void SetETD(const wxDateTime &etd)
Sets the Estimated Time of Departure for this waypoint, in UTC.
Represents a navigational route in the navigation system.
Definition route.h:99
bool m_bRtIsSelected
Flag indicating whether this route is currently selected in the UI.
Definition route.h:203
wxString m_RouteStartString
Name or description of the route's starting point.
Definition route.h:252
wxString m_RouteDescription
Additional descriptive information about the route.
Definition route.h:262
RoutePointList * pRoutePointList
Ordered list of waypoints (RoutePoints) that make up this route.
Definition route.h:336
bool m_bDeleteOnArrival
Flag indicating whether the route should be deleted once navigation reaches the end.
Definition route.h:268
wxString m_RouteEndString
Name or description of the route's ending point.
Definition route.h:257
bool m_btemp
Flag indicating if this is a temporary route.
Definition route.h:351
wxString m_RouteNameString
User-assigned name for the route.
Definition route.h:247
wxString m_GUID
Globally unique identifier for this route.
Definition route.h:273
wxDateTime m_PlannedDeparture
Planned departure time for the route, in UTC.
Definition route.h:326
bool m_bIsInLayer
Flag indicating whether this route belongs to a layer.
Definition route.h:278
int m_lastMousePointIndex
Index of the most recently interacted with route point.
Definition route.h:298
bool DeleteRoute(Route *pRoute)
Definition routeman.cpp:762
bool ActivateRoute(Route *pRouteToActivate, RoutePoint *pStartPoint=NULL)
Activates a route for navigation.
Definition routeman.cpp:222
Represents a single point in a track.
Definition track.h:59
wxDateTime GetCreateTime(void)
Retrieves the creation timestamp of a track point as a wxDateTime object.
Definition track.cpp:138
void SetCreateTime(wxDateTime dt)
Sets the creation timestamp for a track point.
Definition track.cpp:144
Represents a track, which is a series of connected track points.
Definition track.h:117
ViewPort - Core geographic projection and coordinate transformation engine.
Definition viewport.h:56
void SetBoxes()
Computes the bounding box coordinates for the current viewport.
Definition viewport.cpp:811
double view_scale_ppm
Requested view scale in physical pixels per meter (ppm), before applying projections.
Definition viewport.h:204
double ref_scale
The nominal scale of the "reference chart" for this view.
Definition viewport.h:221
int pix_height
Height of the viewport in physical pixels.
Definition viewport.h:233
double rotation
Rotation angle of the viewport in radians.
Definition viewport.h:214
int pix_width
Width of the viewport in physical pixels.
Definition viewport.h:231
wxPoint2DDouble GetDoublePixFromLL(double lat, double lon)
Convert latitude and longitude on the ViewPort to physical pixel coordinates with double precision.
Definition viewport.cpp:133
double skew
Angular distortion (shear transform) applied to the viewport in radians.
Definition viewport.h:212
void GetLLFromPix(const wxPoint &p, double *lat, double *lon)
Convert physical pixel coordinates on the ViewPort to latitude and longitude.
Definition viewport.h:80
double clon
Center longitude of the viewport in degrees.
Definition viewport.h:199
double clat
Center latitude of the viewport in degrees.
Definition viewport.h:197
wxPoint GetPixFromLL(double lat, double lon)
Convert latitude and longitude on the ViewPort to physical pixel coordinates.
Definition viewport.cpp:124
double chart_scale
Chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition viewport.h:219
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:60
Base class for OpenCPN plugins.
Raw messages layer, supports sending and recieving navmsg messages.
Config file user configuration interface.
Font list manager.
OpenGL chart rendering canvas.
wxFont GetOCPNGUIScaledFont(wxString item)
Retrieves a font optimized for touch and high-resolution interfaces.
Definition gui_lib.cpp:88
General purpose GUI support.
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
GUI constant definitions.
Multiplexer class and helpers.
MySQL based storage for routes, tracks, etc.
Utility functions.
wxString getUsrHeightUnit(int unit)
Get the abbreviation for the preferred height unit.
double toUsrHeight(double m_height, int unit)
Convert height from meters to preferred height units.
double fromUsrDistance(double usr_distance, int unit, int default_val)
Convert distance from user units to nautical miles.
double fromUsrHeight(double usr_height, int unit)
Convert height from preferred height units to meters.
double toUsrDepth(double m_depth, int unit)
Convert a depth from meters to user display units.
double toUsrTemp(double cel_temp, int unit)
Convert a temperature from Celsius to user display units.
double toUsrDistance(double nm_distance, int unit)
Convert a distance from nautical miles (NMi) to user display units.
User notifications manager.
OpenCPN main program.
OCPN_AUIManager * g_pauimgr
Global instance.
OCPN_AUIManager.
OpenCPN top window.
wxArrayString g_locale_catalog_array
Global instance.
OpenCPN Platform specific support utilities.
PlugIn Object Definition/API.
@ OBJECTS_ALL
Return all objects including those in layers.
@ OBJECTS_ONLY_LAYERS
Return only objects that are in layers.
@ OBJECTS_NO_LAYERS
Exclude objects that are in layers.
plugin_ais_alarm_type
Enumeration of AIS alarm states.
enum _PI_DisCat PI_DisCat
Display categories for S52 chart features.
PI_ColorScheme
Color schemes for different lighting conditions.
@ PI_COURSE_UP_MODE
Course Up Mode - Current course over ground at the top.
@ PI_HEAD_UP_MODE
Head Up Mode - Current vessel heading at the top.
@ PI_OTHER
Other - additional features for detailed navigation.
@ PI_DISPLAYBASE
Display Base - features that must always be shown.
@ PI_STANDARD
Standard - default features for safe navigation.
@ PI_MARINERS_STANDARD
Mariner specified standard features.
enum _PI_NavMode PI_NavMode
Navigation mode options for chart display orientation.
enum _OBJECT_LAYER_REQ OBJECT_LAYER_REQ
Filter options for object queries.
OptionsParentPI
Enum defining parent pages in OpenCPN options dialog where plugins can add panels.
@ PI_OPTIONS_PARENT_DISPLAY
Display settings section.
@ PI_OPTIONS_PARENT_UI
User Interface section.
@ PI_OPTIONS_PARENT_SHIPS
Ships section.
@ PI_OPTIONS_PARENT_CHARTS
Charts section.
@ PI_OPTIONS_PARENT_PLUGINS
Plugins section.
@ PI_OPTIONS_PARENT_CONNECTIONS
Connections section.
void EnableNotificationCanvasIcon(bool enable)
Plugin Notification Framework GUI support.
void SetCanvasContextMenuItemGrey(int item, bool grey)
Sets menu item enabled/disabled state.
bool UpdateSingleWaypoint(PlugIn_Waypoint *pwaypoint)
Updates a single waypoint.
bool PlugInHasNormalizedViewPort(PlugIn_ViewPort *vp)
Checks if viewport has been normalized.
void PluginCenterOwnship(int CanvasIndex)
Center the chart view on the own ship position for a specific canvas.
void SetCanvasRotation(double rotation)
Sets chart display rotation angle.
wxString GetSelectedWaypointGUID_Plugin()
Gets GUID of currently selected waypoint.
void RemovePlugInTool(int tool_id)
Removes a tool from OpenCPN's toolbar.
void SetCanvasProjection(int projection)
Sets chart projection type.
double toUsrTemp_Plugin(double cel_temp, int unit)
Converts Celsius to user's preferred temperature unit.
wxWindow * PluginGetFocusCanvas()
Gets the currently focused chart canvas.
int AddChartToDBInPlace(wxString &full_path, bool b_RefreshCanvas)
Adds a chart to the database without full rebuild.
void fromSM_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon)
Converts Simple Mercator coordinates to geographic.
wxWindow * GetOCPNCanvasWindow()
Gets OpenCPN's main canvas window.
bool GetEnableLatLonGrid(int CanvasIndex)
Gets latitude/longitude grid visibility state.
bool UpdatePlugInRouteEx(PlugIn_Route_Ex *proute)
Updates an existing extended route.
void SetCanvasContextMenuItemViz(int item, bool viz)
Temporarily changes context menu item visibility.
int PlatformDirSelectorDialog(wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir)
Shows platform-optimized directory selector dialog.
bool GetTouchMode()
Gets touch interface mode state.
int GetCanvasCount()
Gets total number of chart canvases.
bool GetSingleWaypointExV2(wxString GUID, PlugIn_Waypoint_ExV2 *pwaypoint)
Gets extended waypoint data by GUID.
wxString getUsrWindSpeedUnit_Plugin(int unit)
Gets display string for user's preferred wind speed unit.
void SetCanvasMenuItemViz(int item, bool viz, const char *name)
Temporarily changes context menu item visibility.
void PlugInMultMatrixViewport(PlugIn_ViewPort *vp, float lat, float lon)
Applies viewport transformation matrix.
wxFont * OCPNGetFont(wxString TextElement, int default_size)
Gets a font for UI elements.
bool GetEnableMainToolbar()
Check if the main toolbar is enabled.
bool GetEnableENCTextDisplay(int CanvasIndex)
Gets ENC text label visibility.
bool UpdateSingleWaypointEx(PlugIn_Waypoint_Ex *pwaypoint)
Updates an existing extended waypoint.
wxString getUsrDistanceUnit_Plugin(int unit)
Gets display string for user's preferred distance unit.
bool DeletePlugInTrack(wxString &GUID)
Deletes a track.
wxFileConfig * GetOCPNConfigObject()
Gets OpenCPN's configuration object.
wxString getUsrHeightUnit_Plugin(int unit)
Gets display string for user's preferred height unit.
bool DeletePlugInRoute(wxString &GUID)
Deletes a route.
void EnableSplitScreenLayout(bool enable)
Enable or disable the split-screen layout.
double toUsrWindSpeed_Plugin(double kts_speed, int unit)
Converts knots to user's preferred wind speed unit.
bool GetEnableLightsDisplay(int CanvasIndex)
Gets light icon visibility.
wxFont GetOCPNGUIScaledFont_PlugIn(wxString item)
Gets a uniquely scaled font copy for responsive UI elements.
wxBitmap GetBitmapFromSVGFile(wxString filename, unsigned int width, unsigned int height)
Creates bitmap from SVG file.
wxFont * FindOrCreateFont_PlugIn(int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underline, const wxString &facename, wxFontEncoding encoding)
Creates or finds a font in the font cache.
int GetGlobalWatchdogTimoutSeconds()
Comm Global Watchdog Query
wxColour GetFontColour_PlugIn(wxString TextElement)
Gets color configured for a UI text element.
void EnableChartBar(bool enable, int CanvasIndex)
Controls visibility of chart info bar.
void PositionBearingDistanceMercator_Plugin(double lat, double lon, double brg, double dist, double *dlat, double *dlon)
Calculates destination point given starting point, bearing and distance.
double toUsrDistance_Plugin(double nm_distance, int unit)
Converts nautical miles to user's preferred distance unit.
void SetENCDisplayCategory(PI_DisCat cat, int CanvasIndex)
Sets ENC (Electronic Navigation Chart) feature display category.
void toSM_Plugin(double lat, double lon, double lat0, double lon0, double *x, double *y)
Converts geographic coordinates to Simple Mercator projection.
PI_DisCat GetENCDisplayCategory(int CanvasIndex)
Gets current ENC display category.
void EnableTouchMode(bool enable)
Enables/disables touch interface mode.
void EnableCurrentStationsDisplay(bool enable, int CanvasIndex)
Controls current station icon display.
void EnableChartOutlines(bool enable, int CanvasIndex)
Controls chart outline display.
void EnableMUIBar(bool enable, int CanvasIndex)
Controls visibility of MUI (Mobile/Touch User Interface) bar.
double OCPN_GetDisplayContentScaleFactor()
Gets content scaling factor for current display.
wxArrayString GetIconNameArray()
Gets array of available waypoint icons.
double DistGreatCircle_Plugin(double slat, double slon, double dlat, double dlon)
Calculates great circle distance between two points.
bool AddSingleWaypointExV2(PlugIn_Waypoint_ExV2 *pwaypointex, bool b_permanent)
Adds a waypoint with extended V2 properties.
void EnableLookaheadMode(bool enable, int CanvasIndex)
Enables/disables look-ahead mode for a canvas.
bool PluginGetFollowMode(int CanvasIndex)
Get the current follow mode status for a specific canvas.
bool ShuttingDown()
Checks if OpenCPN is in shutdown process.
wxScrolledWindow * AddOptionsPage(OptionsParentPI parent, wxString title)
Adds a new preferences page to OpenCPN options dialog.
void EnableLightsDisplay(bool enable, int CanvasIndex)
Controls light icon display.
void PlugInHandleAutopilotRoute(bool enable)
Controls autopilot route handling.
wxArrayString GetTrackGUIDArray()
Gets array of track GUIDs.
wxString getUsrDepthUnit_Plugin(int unit)
Gets display string for user's preferred depth unit.
void RemoveCanvasMenuItem(int item, const char *name)
Removes a context menu item completely.
void JumpToPosition(double lat, double lon, double scale)
Centers chart display on specified position at given scale.
int InsertPlugInToolSVG(wxString label, wxString SVGfile, wxString SVGfileRollover, wxString SVGfileToggled, wxItemKind kind, wxString shortHelp, wxString longHelp, wxObject *clientData, int position, int tool_sel, opencpn_plugin *pplugin)
Adds a tool using SVG graphics.
bool GetEnableCurrentStationsDisplay(int CanvasIndex)
Gets current station icon visibility.
wxDialog * GetActiveOptionsDialog()
Gets pointer to active options dialog.
wxString getUsrSpeedUnit_Plugin(int unit)
Gets display string for user's preferred speed unit.
std::unique_ptr< PlugIn_Waypoint > GetWaypoint_Plugin(const wxString &GUID)
Gets waypoint details by GUID.
bool GetEnableLookaheadMode(int CanvasIndex)
Gets look-ahead mode state for a canvas.
void EnableTideStationsDisplay(bool enable, int CanvasIndex)
Controls tide station icon display.
bool GetEnableChartBar(int CanvasIndex)
Gets chart bar visibility state.
wxBitmap GetIcon_PlugIn(const wxString &name)
Gets icon bitmap by name.
bool PlugIn_GSHHS_CrossesLand(double lat1, double lon1, double lat2, double lon2)
Checks if a great circle route crosses land.
void SetNavigationMode(PI_NavMode mode, int CanvasIndex)
Sets the navigation mode for a specific chart canvas.
bool GetEnableStatusBar()
Gets status bar visibility state.
bool GetEnableDepthUnitDisplay(int CanvasIndex)
Gets depth unit display state.
int InsertPlugInTool(wxString label, wxBitmap *bitmap, wxBitmap *bmpRollover, wxItemKind kind, wxString shortHelp, wxString longHelp, wxObject *clientData, int position, int tool_sel, opencpn_plugin *pplugin)
Adds a tool to OpenCPN's toolbar.
void EnableENCDepthSoundingsDisplay(bool enable, int CanvasIndex)
Controls ENC depth sounding display.
void PlugInAISDrawGL(wxGLCanvas *glcanvas, const PlugIn_ViewPort &vp)
Renders AIS targets on a secondary OpenGL canvas.
double GetCanvasTilt()
Gets current canvas tilt angle.
void AddChartDirectory(wxString &path)
Adds a chart directory to OpenCPN's chart database.
double fromDMM_PlugIn(wxString sdms)
Parse a formatted coordinate string to get decimal degrees.
double toUsrDepth_Plugin(double m_depth, int unit)
Converts meters to user's preferred depth unit.
bool GetActiveRoutepointGPX(char *buffer, unsigned int buffer_length)
Gets GPX representation of active route waypoint.
std::unique_ptr< PlugIn_Waypoint_ExV2 > GetWaypointExV2_Plugin(const wxString &GUID)
Gets complete waypoint details by GUID.
double PlugInGetDisplaySizeMM()
Gets physical display size in millimeters.
bool UpdatePlugInRoute(PlugIn_Route *proute)
Updates an existing route.
void SetToolbarToolBitmaps(int item, wxBitmap *bitmap, wxBitmap *bmpRollover)
Updates toolbar tool bitmaps.
void EnableBuoyLightLabelsDisplay(bool enable, int CanvasIndex)
Controls buoy/light name label display.
wxString GetActiveWaypointGUID(void)
Gets GUID of currently active waypoint.
void ConfigFlushAndReload()
Flush configuration changes to disk and reload settings.
ArrayOfPlugIn_AIS_Targets * GetAISTargetArray()
Gets array of AIS targets.
void EnableAisTargetDisplay(bool enable, int CanvasIndex)
Controls AIS target display.
int PlatformFileSelectorDialog(wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir, wxString suggestedName, wxString wildcard)
Shows platform-optimized file selector dialog.
bool CheckMUIEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta, int canvasIndex)
Checks if chart should pan when cursor near edge.
std::unique_ptr< PlugIn_Route_ExV2 > GetRouteExV2_Plugin(const wxString &GUID)
Gets route details with V2 waypoints by GUID.
double fromUsrDepth_Plugin(double usr_depth, int unit)
Converts from user's preferred depth unit to meters.
bool AddPlugInRoute(PlugIn_Route *proute, bool b_permanent)
Adds a new route.
double fromDMM_Plugin(wxString sdms)
Converts degrees/decimal minutes string to decimal degrees.
void EnableENCTextDisplay(bool enable, int CanvasIndex)
Controls ENC text label display.
void EnableTenHertzUpdate(bool enable)
Enable or disable 10 Hz update rate.
wxRect GetMasterToolbarRect()
Gets bounding rectangle of master toolbar.
void toTM_Plugin(float lat, float lon, float lat0, float lon0, double *x, double *y)
Converts geographic coordinates to Transverse Mercator projection.
void CanvasJumpToPosition(wxWindow *canvas, double lat, double lon, double scale)
Centers specified canvas on given position at given scale.
bool GetGlobalColor(wxString colorName, wxColour *pcolour)
Gets a functionally-named color for a specific UI purpose.
double fromUsrSpeed_Plugin(double usr_speed, int unit)
Converts from user's preferred speed unit to knots.
void GetDoubleCanvasPixLL(PlugIn_ViewPort *vp, wxPoint2DDouble *pp, double lat, double lon)
Converts lat/lon to canvas pixels with double precision.
std::unique_ptr< PlugIn_Track > GetTrack_Plugin(const wxString &GUID)
Gets track details by GUID.
bool PlugInPlaySoundEx(wxString &sound_file, int deviceIndex)
Start playing a sound file asynchronously.
void EnableCompassGPSIcon(bool enable, int CanvasIndex)
Controls visibility of compass/GPS status icon.
wxString GetActiveRouteGUID(void)
Gets GUID of currently active route.
void EnableDepthUnitDisplay(bool enable, int CanvasIndex)
Controls depth unit display.
bool GetEnableTideStationsDisplay(int CanvasIndex)
Gets tide station icon visibility.
bool PlugInSetFontColor(const wxString TextElement, const wxColour color)
Sets text color for a UI element.
std::unique_ptr< PlugIn_Waypoint_Ex > GetWaypointEx_Plugin(const wxString &GUID)
Gets extended waypoint by GUID.
bool GetTrackingMode()
Get the current tracking mode status.
bool GetEnableChartOutlines(int CanvasIndex)
Gets chart outline visibility state.
void GetCanvasPixLL(PlugIn_ViewPort *vp, wxPoint *pp, double lat, double lon)
Converts lat/lon to canvas physical pixel coordinates.
double toUsrHeight_Plugin(double m_height, int unit)
Height Conversion Functions.
wxColor GetGlobalColorD(std::string map_name, std::string name)
Gets a color from the global color scheme.
wxString GetNewGUID()
Generates a new globally unique identifier (GUID).
bool GetEnableCompassGPSIcon(int CanvasIndex)
Gets compass icon visibility state.
void SetMUICursor_PlugIn(wxCursor *pCursor, int canvasIndex)
Sets mouse cursor for specific canvas.
wxString * GetpSharedDataLocation()
Gets shared application data location.
void EnableMenu(bool enable)
Shows/hides the main menu bar.
void DimeWindow(wxWindow *win)
Applies system color scheme to window.
bool GetEnableAisTargetDisplay(int CanvasIndex)
Gets AIS target display state.
wxWindow * GetCanvasUnderMouse()
Gets canvas window under mouse cursor.
wxArrayString GetRouteGUIDArray()
Gets array of route GUIDs.
bool AddPlugInRouteExV2(PlugIn_Route_ExV2 *proute, bool b_permanent)
Adds a new route with V2 waypoints.
std::vector< std::string > GetPriorityMaps()
Comm Priority query support methods
double GetOCPNGUIToolScaleFactor_PlugIn()
Gets current global GUI scaling factor.
void SetToolbarToolBitmapsSVG(int item, wxString SVGfile, wxString SVGfileRollover, wxString SVGfileToggled)
Updates SVG graphics for toolbar tool.
wxString getUsrTempUnit_Plugin(int unit)
Gets display string for user's preferred temperature unit.
bool AddSingleWaypointEx(PlugIn_Waypoint_Ex *pwaypointex, bool b_permanent)
Adds a waypoint with extended properties.
int AddCanvasContextMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin)
Adds item to chart canvas context menu.
wxString GetActiveStyleName()
Gets name of currently active style sheet.
wxArrayString GetChartDBDirArrayString()
Gets chart database directory list.
void SetCursor_PlugIn(wxCursor *pCursor)
Sets mouse cursor.
bool GetEnableTenHertzUpdate()
Check if 10 Hz update rate is enabled.
int GetCanvasIndexUnderMouse()
Gets index of chart canvas under mouse cursor.
wxString GetLocaleCanonicalName()
Gets system locale canonical name.
wxWindow * PluginGetOverlayRenderCanvas()
Gets the canvas currently designated for overlay rendering.
bool AddPersistentFontKey(wxString TextElement)
Registers a new font configuration element.
bool AddPlugInTrack(PlugIn_Track *ptrack, bool b_permanent)
Adds a new track.
bool UpdateChartDBInplace(wxArrayString dir_array, bool b_force_update, bool b_ProgressDialog)
Updates chart database in place.
void UpdateAndApplyPriorityMaps(std::vector< std::string > map)
Sets and applies new priority mapping scheme.
void RequestWindowRefresh(wxWindow *win, bool eraseBackground)
Requests window refresh.
void EnableLatLonGrid(bool enable, int CanvasIndex)
Controls latitude/longitude grid display.
void SetAppColorScheme(PI_ColorScheme cs)
Set the application color scheme.
bool DeleteSingleWaypoint(wxString &GUID)
Deletes a single waypoint.
void RemoveCanvasContextMenuItem(int item)
Removes a context menu item completely.
bool DecodeSingleVDOMessage(const wxString &str, PlugIn_Position_Fix_Ex *pos, wxString *accumulator)
Decodes a single VDO (Own Ship AIS) message.
wxAuiManager * GetFrameAuiManager()
Gets main frame AUI manager.
bool AddCustomWaypointIcon(wxBitmap *pimage, wxString key, wxString description)
Adds a custom waypoint icon.
bool CheckEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta)
Checks if chart should pan when cursor near edge.
double toUsrSpeed_Plugin(double kts_speed, int unit)
Converts knots to user's preferred speed unit.
int GetChartbarHeight()
Gets height of chart bar in pixels.
std::unique_ptr< PlugIn_Route_Ex > GetRouteEx_Plugin(const wxString &GUID)
Gets extended route by GUID.
bool UpdatePlugInRouteExV2(PlugIn_Route_ExV2 *proute)
Updates existing route with V2 waypoints.
std::vector< std::string > GetActivePriorityIdentifiers()
Gets list of active priority identifiers.
bool GetEnableENCDepthSoundingsDisplay(int CanvasIndex)
Gets ENC depth sounding visibility.
void SetToolbarItemState(int item, bool toggle)
Sets toolbar item toggle state.
bool DeleteOptionsPage(wxScrolledWindow *page)
Remove a previously added options page.
void EnableLightDescriptionsDisplay(bool enable, int CanvasIndex)
Controls light description text display.
float GetOCPNChartScaleFactor_Plugin()
Gets chart rendering scale factor.
PI_NavMode GetNavigationMode(int CanvasIndex)
Gets current navigation mode for a canvas.
int AddCanvasMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin, const char *name)
Adds item to canvas context menu.
int RemoveChartFromDBInPlace(wxString &full_path)
Removes a chart from database without full rebuild.
void PlugInNormalizeViewport(PlugIn_ViewPort *vp, float lat, float lon)
Normalizes viewport parameters.
PI_ColorScheme GetAppColorScheme()
Get the current application color scheme.
void ExitOCPN()
Exits OpenCPN application.
wxArrayString GetWaypointGUIDArray()
Gets array of all waypoint/marks GUIDs.
wxWindow * GetCanvasByIndex(int canvasIndex)
Gets chart canvas window by index.
void fromTM_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon)
Converts Transverse Mercator coordinates to geographic.
double OCPN_GetWinDIPScaleFactor()
Gets Windows-specific DPI scaling factor.
void PushNMEABuffer(wxString buf)
Pushes NMEA sentence to the system.
void SetEnableMainToolbar(bool enable)
Show or hide the main toolbar.
void SetFullScreen(bool set_full_screen_on)
Sets full screen mode.
bool GetEnableMenu()
Gets menu bar visibility state.
void SetCanvasMenuItemGrey(int item, bool grey, const char *name)
Sets menu item enabled/disabled state.
bool GetEnableBuoyLightLabelsDisplay(int CanvasIndex)
Gets buoy/light label visibility.
double fromUsrWindSpeed_Plugin(double usr_wspeed, int unit)
Converts from user's preferred wind speed unit to knots.
bool GetEnableCanvasFocusBar(int CanvasIndex)
Gets focus indicator visibility state.
wxXmlDocument GetChartDatabaseEntryXML(int dbIndex, bool b_getGeom)
Gets chart database entry as XML.
void SendPluginMessage(wxString message_id, wxString message_body)
Sends message to other plugins.
bool AddPlugInRouteEx(PlugIn_Route_Ex *proute, bool b_permanent)
Adds a route with extended features.
void fromSM_ECC_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon)
Converts Elliptical Simple Mercator coordinates to geographic.
void EnableStatusBar(bool enable)
Shows/hides the status bar.
void RequestRefresh(wxWindow *win)
Requests window refresh.
bool UpdateSingleWaypointExV2(PlugIn_Waypoint_ExV2 *pwaypoint)
Updates an existing extended V2 waypoint.
void PluginZoomCanvas(int CanvasIndex, double factor)
Zoom a specific chart canvas by the given factor.
bool IsTouchInterface_PlugIn()
Checks if touch interface mode is enabled.
int GetLatLonFormat()
Gets currently selected latitude/longitude display format.
bool AddSingleWaypoint(PlugIn_Waypoint *pwaypoint, bool b_permanent)
Adds a single waypoint.
bool GetSingleWaypoint(wxString GUID, PlugIn_Waypoint *pwaypoint)
Gets waypoint data by GUID.
double fromUsrHeight_Plugin(double usr_height, int unit)
Converts from user's preferred height unit to meters.
void SetToolbarToolViz(int item, bool viz)
Temporarily changes toolbar tool visibility.
double fromUsrTemp_Plugin(double usr_temp, int unit)
Converts from user's preferred temperature unit to Celsius.
void SetCanvasTilt(double tilt)
Gets current canvas tilt angle.
std::unique_ptr< PlugIn_Route > GetRoute_Plugin(const wxString &GUID)
Gets route details by GUID.
bool GetEnableMUIBar(int CanvasIndex)
Gets MUI bar visibility state.
bool AddLocaleCatalog(wxString catalog)
Adds a locale catalog for translations.
bool GetFullScreen()
Gets full screen state.
void SetTrackingMode(bool enable)
Enable or disable tracking mode.
void PluginSetFollowMode(int CanvasIndex, bool enable_follow)
Set follow mode for a specific canvas.
void ShowGlobalSettingsDialog()
Display the global settings dialog.
void toSM_ECC_Plugin(double lat, double lon, double lat0, double lon0, double *x, double *y)
Converts geographic coordinates to Elliptical Simple Mercator projection.
bool UpdatePlugInTrack(PlugIn_Track *ptrack)
Updates an existing track.
double fromUsrDistance_Plugin(double usr_distance, int unit)
Converts from user's preferred distance unit to nautical miles.
wxString GetSelectedTrackGUID_Plugin()
Gets GUID of currently selected track.
void DistanceBearingMercator_Plugin(double lat0, double lon0, double lat1, double lon1, double *brg, double *dist)
Calculates bearing and distance between two points using Mercator projection.
void SetGlobalColor(std::string table, std::string name, wxColor color)
Sets a color in the global color scheme.
void ZeroXTE()
Resets cross track error to zero.
void PlugInPlaySound(wxString &sound_file)
Plays a sound file asynchronously.
void GetCanvasLLPix(PlugIn_ViewPort *vp, wxPoint p, double *plat, double *plon)
Converts canvas physical pixel coordinates to lat/lon.
void EnableCanvasFocusBar(bool enable, int CanvasIndex)
Controls visibility of canvas focus indicator.
wxString GetSelectedRouteGUID_Plugin()
Gets GUID of currently selected route.
void ForceChartDBUpdate()
Forces an update of the chart database.
bool GetSingleWaypointEx(wxString GUID, PlugIn_Waypoint_Ex *pwaypoint)
Gets extended waypoint data by GUID.
void ForceChartDBRebuild()
Forces complete rebuild of chart database.
options * g_options
Global instance.
Definition options.cpp:179
Options dialog.
double gLat
Vessel's current latitude in decimal degrees.
Definition own_ship.cpp:26
double gCog
Course over ground in degrees (0-359.99).
Definition own_ship.cpp:28
double gSog
Speed over ground in knots.
Definition own_ship.cpp:29
double gLon
Vessel's current longitude in decimal degrees.
Definition own_ship.cpp:27
Position, course, speed, etc.
Chart Bar Window.
Tools to send data to plugins.
PlugInManager and helper classes – Mostly gui parts (dialogs) and plugin API stuff.
Route abstraction.
Routeman * g_pRouteMan
Global instance.
Definition routeman.cpp:60
RouteList * pRouteList
Global instance.
Definition routeman.cpp:66
bool g_bPluginHandleAutopilotRoute
Global instance.
Definition routeman.cpp:58
Routeman drawing stuff.
Manage routes dialog.
Select * pSelect
Global instance.
Definition select.cpp:36
Shapefile basemap.
A generic position and navigation data structure.
Definition ocpn_types.h:68
double kCog
Course over ground in degrees.
Definition ocpn_types.h:86
double kHdt
True heading in degrees.
Definition ocpn_types.h:111
double kLat
Latitude in decimal degrees.
Definition ocpn_types.h:75
double kSog
Speed over ground in knots.
Definition ocpn_types.h:92
double kLon
Longitude in decimal degrees.
Definition ocpn_types.h:83
wxBitmap LoadSVG(const wxString filename, const unsigned int width, const unsigned int height, wxBitmap *default_bitmap, bool use_cache)
Load SVG file and return it's bitmap representation of requested size In case file can't be loaded an...
Definition svg_utils.cpp:59
bool SVGDocumentPixelSize(const wxString filename, unsigned int &width, unsigned int &height)
Return the size of the SVG document in standard 96 DPI pixels https://developer.mozilla....
SVG utilities.
ocpnFloatingToolbarDialog * g_MainToolbar
Global instance.
Definition toolbar.cpp:65
OpenCPN Toolbar.
std::vector< Track * > g_TrackList
Global instance.
Definition track.cpp:96
Recorded track abstraction.
WaypointMan drawing stuff.