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 "o_sound/o_sound.h"
39
40#include "model/ais_decoder.h"
41#include "model/comm_bridge.h"
43#include "model/gui_vars.h"
44#include "model/idents.h"
45#include "model/multiplexer.h"
46#include "model/navobj_db.h"
48#include "model/own_ship.h"
49#include "model/plugin_comm.h"
50#include "model/svg_utils.h"
51#include "model/route.h"
52#include "model/track.h"
53
54#include "ais.h"
55#include "chartdb.h"
56#include "chcanv.h"
57#include "config_mgr.h"
58#include "font_mgr.h"
59#include "gl_chart_canvas.h"
60#include "gui_lib.h"
61#include "navutil.h"
62#include "ocpn_aui_manager.h"
63#include "ocpn_frame.h"
64#include "ocpn_platform.h"
65#include "ocpn_plugin.h"
66#include "options.h"
67#include "piano.h"
68#include "pluginmanager.h"
69#include "routemanagerdialog.h"
70#include "routeman_gui.h"
71#include "s52plib.h"
72#include "shapefile_basemap.h"
73#include "toolbar.h"
74#include "waypointman_gui.h"
75
76#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
77extern wxLocale* plocale_def_lang;
78#endif
79
80extern PlugInManager* s_ppim; // FIXME (leamas) another name for global mgr
81
82extern options* g_pOptions; // FIXME (leamas) merge to g_options
83
84extern arrayofCanvasPtr g_canvasArray; // FIXME (leamas) find new home
85
86void NotifySetupOptionsPlugin(const PlugInData* pic);
87
88//---------------------------------------------------------------------------
89/* Implementation of OCPN core functions callable by plugins
90 * Sorted by API version number
91 * The definitions of this API are found in ocpn_plugin.h
92 * PlugIns may call these static functions as necessary for system services
93 */
94//---------------------------------------------------------------------------
95
96//---------------------------------------------------------------------------
97// API 1.6
98//---------------------------------------------------------------------------
99/* Main Toolbar support */
100int InsertPlugInTool(wxString label, wxBitmap* bitmap, wxBitmap* bmpRollover,
101 wxItemKind kind, wxString shortHelp, wxString longHelp,
102 wxObject* clientData, int position, int tool_sel,
103 opencpn_plugin* pplugin) {
104 if (s_ppim)
105 return s_ppim->AddToolbarTool(label, bitmap, bmpRollover, kind, shortHelp,
106 longHelp, clientData, position, tool_sel,
107 pplugin);
108 else
109 return -1;
110}
111
112void RemovePlugInTool(int tool_id) {
113 if (s_ppim) s_ppim->RemoveToolbarTool(tool_id);
114}
115
116void SetToolbarToolViz(int item, bool viz) {
117 if (s_ppim) s_ppim->SetToolbarToolViz(item, viz);
118}
119
120void SetToolbarItemState(int item, bool toggle) {
121 if (s_ppim) s_ppim->SetToolbarItemState(item, toggle);
122}
123
124void SetToolbarToolBitmaps(int item, wxBitmap* bitmap, wxBitmap* bmpRollover) {
125 if (s_ppim) s_ppim->SetToolbarItemBitmaps(item, bitmap, bmpRollover);
126}
127
128int InsertPlugInToolSVG(wxString label, wxString SVGfile,
129 wxString SVGfileRollover, wxString SVGfileToggled,
130 wxItemKind kind, wxString shortHelp, wxString longHelp,
131 wxObject* clientData, int position, int tool_sel,
132 opencpn_plugin* pplugin) {
133 if (s_ppim)
134 return s_ppim->AddToolbarTool(label, SVGfile, SVGfileRollover,
135 SVGfileToggled, kind, shortHelp, longHelp,
136 clientData, position, tool_sel, pplugin);
137 else
138 return -1;
139}
140
141void SetToolbarToolBitmapsSVG(int item, wxString SVGfile,
142 wxString SVGfileRollover,
143 wxString SVGfileToggled) {
144 if (s_ppim)
145 s_ppim->SetToolbarItemBitmaps(item, SVGfile, SVGfileRollover,
146 SVGfileToggled);
147}
148
149/* Canvas Context Menu support */
150int AddCanvasMenuItem(wxMenuItem* pitem, opencpn_plugin* pplugin,
151 const char* name) {
152 if (s_ppim)
153 return s_ppim->AddCanvasContextMenuItemPIM(pitem, pplugin, name, false);
154 else
155 return -1;
156}
157
158void SetCanvasMenuItemViz(int item, bool viz, const char* name) {
159 if (s_ppim) s_ppim->SetCanvasContextMenuItemViz(item, viz, name);
160}
161
162void SetCanvasMenuItemGrey(int item, bool grey, const char* name) {
163 if (s_ppim) s_ppim->SetCanvasContextMenuItemGrey(item, grey, name);
164}
165
166void RemoveCanvasMenuItem(int item, const char* name) {
167 if (s_ppim) s_ppim->RemoveCanvasContextMenuItem(item, name);
168}
169
170int AddCanvasContextMenuItem(wxMenuItem* pitem, opencpn_plugin* pplugin) {
171 /* main context popup menu */
172 if (s_ppim)
173 return s_ppim->AddCanvasContextMenuItemPIM(pitem, pplugin, "", false);
174 else
175 return -1;
176}
177
178void SetCanvasContextMenuItemViz(int item, bool viz) {
179 SetCanvasMenuItemViz(item, viz);
180}
181
182void SetCanvasContextMenuItemGrey(int item, bool grey) {
183 SetCanvasMenuItemGrey(item, grey);
184}
185
187
188int AddCanvasContextMenuItemExt(wxMenuItem* pitem, opencpn_plugin* pplugin,
189 const std::string object_type) {
190 /* main context popup menu */
191 if (s_ppim)
192 return s_ppim->AddCanvasContextMenuItemPIM(pitem, pplugin,
193 object_type.c_str(), true);
194 else
195 return -1;
196}
197
198/* Utility functions */
199wxFileConfig* GetOCPNConfigObject() {
200 if (s_ppim)
201 return reinterpret_cast<wxFileConfig*>(
202 pConfig); // return the global application config object
203 else
204 return NULL;
205}
206
208 wxWindow* pret = NULL;
209 if (s_ppim) {
210 AbstractTopFrame* pFrame = s_ppim->GetParentFrame();
211 pret = (wxWindow*)pFrame->GetAbstractPrimaryCanvas();
212 }
213 return pret;
214}
215
216void RequestRefresh(wxWindow* win) {
217 if (win) win->Refresh(true);
218}
219
220void GetCanvasPixLL(PlugIn_ViewPort* vp, wxPoint* pp, double lat, double lon) {
221 // Make enough of an application viewport to run its method....
222 ViewPort ocpn_vp;
223 ocpn_vp.clat = vp->clat;
224 ocpn_vp.clon = vp->clon;
225 ocpn_vp.m_projection_type = vp->m_projection_type;
226 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
227 ocpn_vp.skew = vp->skew;
228 ocpn_vp.rotation = vp->rotation;
229 ocpn_vp.pix_width = vp->pix_width;
230 ocpn_vp.pix_height = vp->pix_height;
231
232 wxPoint ret = ocpn_vp.GetPixFromLL(lat, lon);
233 pp->x = ret.x;
234 pp->y = ret.y;
235}
236
237void GetDoubleCanvasPixLL(PlugIn_ViewPort* vp, wxPoint2DDouble* pp, double lat,
238 double lon) {
239 // Make enough of an application viewport to run its method....
240 ViewPort ocpn_vp;
241 ocpn_vp.clat = vp->clat;
242 ocpn_vp.clon = vp->clon;
243 ocpn_vp.m_projection_type = vp->m_projection_type;
244 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
245 ocpn_vp.skew = vp->skew;
246 ocpn_vp.rotation = vp->rotation;
247 ocpn_vp.pix_width = vp->pix_width;
248 ocpn_vp.pix_height = vp->pix_height;
249
250 *pp = ocpn_vp.GetDoublePixFromLL(lat, lon);
251}
252
253void GetCanvasLLPix(PlugIn_ViewPort* vp, wxPoint p, double* plat,
254 double* plon) {
255 // Make enough of an application viewport to run its method....
256 ViewPort ocpn_vp;
257 ocpn_vp.clat = vp->clat;
258 ocpn_vp.clon = vp->clon;
259 ocpn_vp.m_projection_type = vp->m_projection_type;
260 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
261 ocpn_vp.skew = vp->skew;
262 ocpn_vp.rotation = vp->rotation;
263 ocpn_vp.pix_width = vp->pix_width;
264 ocpn_vp.pix_height = vp->pix_height;
265
266 return ocpn_vp.GetLLFromPix(p, plat, plon);
267}
268
269bool GetGlobalColor(wxString colorName, wxColour* pcolour) {
270 wxColour c = GetGlobalColor(colorName);
271 *pcolour = c;
272
273 return true;
274}
275
276wxFont* OCPNGetFont(wxString TextElement, int default_size) {
277 return FontMgr::Get().GetFontLegacy(TextElement, default_size);
278}
279
280wxFont* GetOCPNScaledFont_PlugIn(wxString TextElement, int default_size) {
281 return FontMgr::Get().GetFontLegacy(TextElement, default_size);
282}
283
284double GetOCPNGUIToolScaleFactor_PlugIn(int GUIScaleFactor) {
285 return g_Platform->GetToolbarScaleFactor(GUIScaleFactor);
286}
287
289 return g_Platform->GetToolbarScaleFactor(g_GUIScaleFactor);
290}
291
293 return g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor);
294}
295
296wxFont GetOCPNGUIScaledFont_PlugIn(wxString item) {
297 return GetOCPNGUIScaledFont(item);
298}
299
300bool AddPersistentFontKey(wxString TextElement) {
301 return FontMgr::Get().AddAuxKey(TextElement);
302}
303
305 if (g_StyleManager)
306 return g_StyleManager->GetCurrentStyle()->name;
307 else
308 return "";
309}
310
311wxBitmap GetBitmapFromSVGFile(wxString filename, unsigned int width,
312 unsigned int height) {
313 wxBitmap bmp = LoadSVG(filename, width, height);
314
315 if (bmp.IsOk())
316 return bmp;
317 else {
318 // On error in requested width/height parameters,
319 // try to find and use dimensions embedded in the SVG file
320 unsigned int w, h;
321 SVGDocumentPixelSize(filename, w, h);
322 if (w == 0 || h == 0) {
323 // We did not succeed in deducing the size from SVG (svg element
324 // x misses width, height or both attributes), let's use some "safe"
325 // default
326 w = 32;
327 h = 32;
328 }
329 return LoadSVG(filename, w, h);
330 }
331}
332
333bool IsTouchInterface_PlugIn() { return g_btouch; }
334
335wxColour GetFontColour_PlugIn(wxString TextElement) {
336 return FontMgr::Get().GetFontColor(TextElement);
337}
338
339wxString* GetpSharedDataLocation() { return g_Platform->GetSharedDataDirPtr(); }
340
341ArrayOfPlugIn_AIS_Targets* GetAISTargetArray() {
342 if (!g_pAIS) return NULL;
343
344 ArrayOfPlugIn_AIS_Targets* pret = new ArrayOfPlugIn_AIS_Targets;
345
346 // Iterate over the AIS Target Hashmap
347 for (const auto& it : g_pAIS->GetTargetList()) {
348 auto td = it.second;
349 PlugIn_AIS_Target* ptarget = Create_PI_AIS_Target(td.get());
350 pret->Add(ptarget);
351 }
352
353// Test one alarm target
354#if 0
355 AisTargetData td;
356 td.n_alarm_state = AIS_ALARM_SET;
357 PlugIn_AIS_Target *ptarget = Create_PI_AIS_Target(&td);
358 pret->Add(ptarget);
359#endif
360 return pret;
361}
362
363wxAuiManager* GetFrameAuiManager() { return g_pauimgr; }
364
365void SendPluginMessage(wxString message_id, wxString message_body) {
366 SendMessageToAllPlugins(message_id, message_body);
367
368 // We will send an event to the main application frame (gFrame)
369 // for informational purposes.
370 // Of course, gFrame is encouraged to use any or all the
371 // data flying by if judged useful and dependable....
372
373 OCPN_MsgEvent Nevent(wxEVT_OCPN_MSG, 0);
374 Nevent.SetID(message_id);
375 Nevent.SetJSONText(message_body);
376 gFrame->GetEventHandler()->AddPendingEvent(Nevent);
377}
378
379void DimeWindow(wxWindow* win) { DimeControl(win); }
380
381void JumpToPosition(double lat, double lon, double scale) {
382 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), lat, lon, scale);
383}
384
385/* Locale (i18N) support */
386bool AddLocaleCatalog(wxString catalog) {
387#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
388
389 if (plocale_def_lang) {
390 // Add this catalog to the persistent catalog array
391 g_locale_catalog_array.Add(catalog);
392
393 return plocale_def_lang->AddCatalog(catalog);
394 } else
395#endif
396 return false;
397}
398
399wxString GetLocaleCanonicalName() { return g_locale; }
400
401/* NMEA interface support */
402void PushNMEABuffer(wxString buf) {
403 std::string full_sentence = buf.ToStdString();
404
405 if ((full_sentence[0] == '$') || (full_sentence[0] == '!')) { // Sanity check
406 // We notify based on full message, including the Talker ID
407 std::string id = full_sentence.substr(1, 5);
408
409 // notify message listener
410 auto address = std::make_shared<NavAddr0183>("virtual");
411 auto msg = std::make_shared<const Nmea0183Msg>(id, full_sentence, address);
412 NavMsgBus::GetInstance().Notify(std::move(msg));
413 }
414}
415
416/* Chart database access support */
417wxXmlDocument GetChartDatabaseEntryXML(int dbIndex, bool b_getGeom) {
418 wxXmlDocument doc = ChartData->GetXMLDescription(dbIndex, b_getGeom);
419
420 return doc;
421}
422
423bool UpdateChartDBInplace(wxArrayString dir_array, bool b_force_update,
424 bool b_ProgressDialog) {
425 // Make an array of CDI
426 ArrayOfCDI ChartDirArray;
427 for (unsigned int i = 0; i < dir_array.GetCount(); i++) {
428 wxString dirname = dir_array[i];
429 ChartDirInfo cdi;
430 cdi.fullpath = dirname;
431 cdi.magic_number = "";
432 ChartDirArray.Add(cdi);
433 }
434 bool b_ret = gFrame->UpdateChartDatabaseInplace(
435 ChartDirArray, b_force_update, b_ProgressDialog, ChartListFileName);
436 gFrame->RefreshGroupIndices();
437 gFrame->ChartsRefresh();
438 return b_ret;
439}
440
442 return ChartData->GetChartDirArrayString();
443}
444
445int AddChartToDBInPlace(wxString& full_path, bool b_RefreshCanvas) {
446 // extract the path from the chart name
447 wxFileName fn(full_path);
448 wxString fdir = fn.GetPath();
449
450 bool bret = false;
451 if (ChartData) {
452 bret = ChartData->AddSingleChart(full_path);
453
454 if (bret) {
455 // Save to disk
456 pConfig->UpdateChartDirs(ChartData->GetChartDirArray());
457 ChartData->SaveBinary(ChartListFileName);
458
459 // Completely reload the chart database, for a fresh start
460 ArrayOfCDI XnewChartDirArray;
461 pConfig->LoadChartDirArray(XnewChartDirArray);
462 delete ChartData;
463 ChartData = new ChartDB();
464 ChartData->LoadBinary(ChartListFileName, XnewChartDirArray);
465
466 // Update group contents
467 if (g_pGroupArray) ChartData->ApplyGroupArray(g_pGroupArray);
468
469 if (g_options && g_options->IsShown())
470 g_options->UpdateDisplayedChartDirList(ChartData->GetChartDirArray());
471
472 if (b_RefreshCanvas || !gFrame->GetPrimaryCanvas()->GetQuiltMode()) {
473 gFrame->ChartsRefresh();
474 }
475 }
476 }
477 return bret;
478}
479
480int RemoveChartFromDBInPlace(wxString& full_path) {
481 bool bret = false;
482 if (ChartData) {
483 bret = ChartData->RemoveSingleChart(full_path);
484
485 // Save to disk
486 pConfig->UpdateChartDirs(ChartData->GetChartDirArray());
487 ChartData->SaveBinary(ChartListFileName);
488
489 // Completely reload the chart database, for a fresh start
490 ArrayOfCDI XnewChartDirArray;
491 pConfig->LoadChartDirArray(XnewChartDirArray);
492 delete ChartData;
493 ChartData = new ChartDB();
494 ChartData->LoadBinary(ChartListFileName, XnewChartDirArray);
495
496 // Update group contents
497 if (g_pGroupArray) ChartData->ApplyGroupArray(g_pGroupArray);
498
499 if (g_options && g_options->IsShown())
500 g_options->UpdateDisplayedChartDirList(ChartData->GetChartDirArray());
501
502 gFrame->ChartsRefresh();
503 }
504
505 return bret;
506}
507
508//---------------------------------------------------------------------------
509// API 1.9
510//---------------------------------------------------------------------------
511wxScrolledWindow* AddOptionsPage(OptionsParentPI parent, wxString title) {
512 if (!g_pOptions) return NULL;
513
514 size_t parentid;
515 switch (parent) {
517 parentid = g_pOptions->m_pageDisplay;
518 break;
520 parentid = g_pOptions->m_pageConnections;
521 break;
523 parentid = g_pOptions->m_pageCharts;
524 break;
526 parentid = g_pOptions->m_pageShips;
527 break;
529 parentid = g_pOptions->m_pageUI;
530 break;
532 parentid = g_pOptions->m_pagePlugins;
533 break;
534 default:
535 wxLogMessage("Error in PluginManager::AddOptionsPage: Unknown parent");
536 return NULL;
537 break;
538 }
539
540 return g_pOptions->AddPage(parentid, title);
541}
542
543bool DeleteOptionsPage(wxScrolledWindow* page) {
544 if (!g_pOptions) return false;
545 return g_pOptions->DeletePluginPage(page);
546}
547
548bool DecodeSingleVDOMessage(const wxString& str, PlugIn_Position_Fix_Ex* pos,
549 wxString* accumulator) {
550 if (!pos) return false;
551
552 GenericPosDatEx gpd;
553 AisError nerr = AIS_GENERIC_ERROR;
554 if (g_pAIS) nerr = g_pAIS->DecodeSingleVDO(str, &gpd, accumulator);
555 if (nerr == AIS_NoError) {
556 pos->Lat = gpd.kLat;
557 pos->Lon = gpd.kLon;
558 pos->Cog = gpd.kCog;
559 pos->Sog = gpd.kSog;
560 pos->Hdt = gpd.kHdt;
561
562 // Fill in the dummy values
563 pos->FixTime = 0;
564 pos->Hdm = 1000;
565 pos->Var = 1000;
566 pos->nSats = 0;
567
568 return true;
569 }
570
571 return false;
572}
573
575 int val = 0;
576 if (g_bShowChartBar) {
577 ChartCanvas* cc = gFrame->GetPrimaryCanvas();
578 if (cc && cc->GetPiano()) {
579 val = cc->GetPiano()->GetHeight();
580 }
581 }
582 return val;
583}
584
585bool GetRoutepointGPX(RoutePoint* pRoutePoint, char* buffer,
586 unsigned int buffer_length) {
587 bool ret = false;
588
590 pgpx->AddGPXWaypoint(pRoutePoint);
591 wxString gpxfilename = wxFileName::CreateTempFileName("gpx");
592 pgpx->SaveFile(gpxfilename);
593 delete pgpx;
594
595 wxFFile gpxfile(gpxfilename);
596 wxString s;
597 if (gpxfile.ReadAll(&s)) {
598 if (s.Length() < buffer_length) {
599 strncpy(buffer, (const char*)s.mb_str(wxConvUTF8), buffer_length - 1);
600 ret = true;
601 }
602 }
603
604 gpxfile.Close();
605 ::wxRemoveFile(gpxfilename);
606
607 return ret;
608}
609
610bool GetActiveRoutepointGPX(char* buffer, unsigned int buffer_length) {
611 if (g_pRouteMan->IsAnyRouteActive())
612 return GetRoutepointGPX(g_pRouteMan->GetpActivePoint(), buffer,
613 buffer_length);
614 else
615 return false;
616}
617
618void PositionBearingDistanceMercator_Plugin(double lat, double lon, double brg,
619 double dist, double* dlat,
620 double* dlon) {
621 PositionBearingDistanceMercator(lat, lon, brg, dist, dlat, dlon);
622}
623
624void DistanceBearingMercator_Plugin(double lat0, double lon0, double lat1,
625 double lon1, double* brg, double* dist) {
626 DistanceBearingMercator(lat0, lon0, lat1, lon1, brg, dist);
627}
628
629double DistGreatCircle_Plugin(double slat, double slon, double dlat,
630 double dlon) {
631 return DistGreatCircle(slat, slon, dlat, dlon);
632}
633
634void toTM_Plugin(float lat, float lon, float lat0, float lon0, double* x,
635 double* y) {
636 toTM(lat, lon, lat0, lon0, x, y);
637}
638
639void fromTM_Plugin(double x, double y, double lat0, double lon0, double* lat,
640 double* lon) {
641 fromTM(x, y, lat0, lon0, lat, lon);
642}
643
644void toSM_Plugin(double lat, double lon, double lat0, double lon0, double* x,
645 double* y) {
646 toSM(lat, lon, lat0, lon0, x, y);
647}
648
649void fromSM_Plugin(double x, double y, double lat0, double lon0, double* lat,
650 double* lon) {
651 fromSM(x, y, lat0, lon0, lat, lon);
652}
653
654void toSM_ECC_Plugin(double lat, double lon, double lat0, double lon0,
655 double* x, double* y) {
656 toSM_ECC(lat, lon, lat0, lon0, x, y);
657}
658
659void fromSM_ECC_Plugin(double x, double y, double lat0, double lon0,
660 double* lat, double* lon) {
661 fromSM_ECC(x, y, lat0, lon0, lat, lon);
662}
663
664double toUsrDistance_Plugin(double nm_distance, int unit) {
665 return toUsrDistance(nm_distance, unit);
666}
667
668double fromUsrDistance_Plugin(double usr_distance, int unit) {
669 return fromUsrDistance(usr_distance, unit);
670}
671
672double toUsrSpeed_Plugin(double kts_speed, int unit) {
673 return toUsrSpeed(kts_speed, unit);
674}
675
676double toUsrWindSpeed_Plugin(double kts_speed, int unit) {
677 return toUsrWindSpeed(kts_speed, unit);
678}
679
680double fromUsrSpeed_Plugin(double usr_speed, int unit) {
681 return fromUsrSpeed(usr_speed, unit);
682}
683
684double fromUsrWindSpeed_Plugin(double usr_wspeed, int unit) {
685 return fromUsrWindSpeed(usr_wspeed, unit);
686}
687
688double toUsrTemp_Plugin(double cel_temp, int unit) {
689 return toUsrTemp(cel_temp, unit);
690}
691
692double fromUsrTemp_Plugin(double usr_temp, int unit) {
693 return fromUsrTemp(usr_temp, unit);
694}
695
697 return getUsrDistanceUnit(unit);
698}
699
700wxString getUsrSpeedUnit_Plugin(int unit) { return getUsrSpeedUnit(unit); }
701
703 return getUsrWindSpeedUnit(unit);
704}
705
706wxString getUsrTempUnit_Plugin(int unit) { return getUsrTempUnit(unit); }
707
708/*
709 * Depth Conversion Functions
710 */
711double toUsrDepth_Plugin(double m_depth, int unit) {
712 return toUsrDepth(m_depth, unit);
713}
714
715double fromUsrDepth_Plugin(double usr_depth, int unit) {
716 return fromUsrDepth(usr_depth, unit);
717}
718
719wxString getUsrDepthUnit_Plugin(int unit) { return getUsrDepthUnit(unit); }
720
724double toUsrHeight_Plugin(double m_height, int unit) {
725 return toUsrHeight(m_height, unit);
726}
727
728double fromUsrHeight_Plugin(double usr_height, int unit) {
729 return fromUsrHeight(usr_height, unit);
730}
731
733
734double fromDMM_PlugIn(wxString sdms) { return fromDMM(sdms); }
735
736bool PlugIn_GSHHS_CrossesLand(double lat1, double lon1, double lat2,
737 double lon2) {
738 // TODO: Enable call to gShapeBasemap.CrossesLand after fixing performance
739 // issues. if (gShapeBasemap.IsUsable()) {
740 // return gShapeBasemap.CrossesLand(lat1, lon1, lat2, lon2);
741 // } else {
742 // Fall back to the GSHHS data.
743 static bool loaded = false;
744 if (!loaded) {
745 gshhsCrossesLandInit();
746 loaded = true;
747 }
748 return gshhsCrossesLand(lat1, lon1, lat2, lon2);
749 //}
750}
751
752void PlugInPlaySound(wxString& sound_file) {
753 PlugInPlaySoundEx(sound_file, -1);
754}
755
756//---------------------------------------------------------------------------
757// API 1.10
758//---------------------------------------------------------------------------
759
760// API Route and Waypoint Support
762
763PlugIn_Waypoint::PlugIn_Waypoint(double lat, double lon,
764 const wxString& icon_ident,
765 const wxString& wp_name,
766 const wxString& GUID) {
767 wxDateTime now = wxDateTime::Now();
768 m_CreateTime = now.ToUTC();
769 m_HyperlinkList = NULL;
770
771 m_lat = lat;
772 m_lon = lon;
773 m_IconName = icon_ident;
774 m_MarkName = wp_name;
775 m_GUID = GUID;
776}
777
778PlugIn_Waypoint::~PlugIn_Waypoint() {}
779
780// PlugInRoute implementation
781PlugIn_Route::PlugIn_Route() { pWaypointList = new Plugin_WaypointList; }
782
783PlugIn_Route::~PlugIn_Route() {
784 pWaypointList->DeleteContents(false); // do not delete Waypoints
785 pWaypointList->Clear();
786
787 delete pWaypointList;
788}
789
790// PlugInTrack implementation
791PlugIn_Track::PlugIn_Track() { pWaypointList = new Plugin_WaypointList; }
792
793PlugIn_Track::~PlugIn_Track() {
794 pWaypointList->DeleteContents(false); // do not delete Waypoints
795 pWaypointList->Clear();
796
797 delete pWaypointList;
798}
799
800wxString GetNewGUID() { return GpxDocument::GetUUID(); }
801
802bool AddCustomWaypointIcon(wxBitmap* pimage, wxString key,
803 wxString description) {
804 // Avoid calling waypoint manager until after LateInit()
805 if (pWayPointMan == NULL) return false;
806
807 wxImage image = pimage->ConvertToImage();
808 WayPointmanGui(*pWayPointMan).ProcessIcon(image, key, description);
809 return true;
810}
811
812static void cloneHyperlinkList(RoutePoint* dst, const PlugIn_Waypoint* src) {
813 // Transcribe (clone) the html HyperLink List, if present
814 if (src->m_HyperlinkList == nullptr) return;
815
816 if (src->m_HyperlinkList->GetCount() > 0) {
817 wxPlugin_HyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
818 while (linknode) {
819 Plugin_Hyperlink* link = linknode->GetData();
820
821 Hyperlink* h = new Hyperlink();
822 h->DescrText = link->DescrText;
823 h->Link = link->Link;
824 h->LType = link->Type;
825
826 dst->m_HyperlinkList->push_back(h);
827
828 linknode = linknode->GetNext();
829 }
830 }
831}
832
833bool AddSingleWaypoint(PlugIn_Waypoint* pwaypoint, bool b_permanent) {
834 if (!pWayPointMan) return false;
835
836 // Validate the waypoint parameters a little bit
837 // GUID
838 // Make sure that this GUID is indeed unique in the Routepoint list
839 bool b_unique = true;
840 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
841 if (prp->m_GUID == pwaypoint->m_GUID) {
842 b_unique = false;
843 break;
844 }
845 }
846
847 if (!b_unique) return false;
848
849 RoutePoint* pWP =
850 new RoutePoint(pwaypoint->m_lat, pwaypoint->m_lon, pwaypoint->m_IconName,
851 pwaypoint->m_MarkName, pwaypoint->m_GUID);
852
853 pWP->m_bIsolatedMark = true; // This is an isolated mark
854
855 cloneHyperlinkList(pWP, pwaypoint);
856
857 pWP->m_MarkDescription = pwaypoint->m_MarkDescription;
858
859 if (pwaypoint->m_CreateTime.IsValid())
860 pWP->SetCreateTime(pwaypoint->m_CreateTime);
861 else {
862 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
863 }
864
865 pWP->m_btemp = (b_permanent == false);
866
867 pSelect->AddSelectableRoutePoint(pwaypoint->m_lat, pwaypoint->m_lon, pWP);
868 if (b_permanent) {
869 // pConfig->AddNewWayPoint(pWP, -1);
870 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
871 }
872
874 pRouteManagerDialog->UpdateWptListCtrl();
875
876 return true;
877}
878
879bool DeleteSingleWaypoint(wxString& GUID) {
880 if (!pWayPointMan) return false;
881
882 // Find the RoutePoint
883 bool b_found = false;
884 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
885
886 if (prp) b_found = true;
887
888 if (b_found) {
889 pWayPointMan->DestroyWaypoint(prp);
891 pRouteManagerDialog->UpdateWptListCtrl();
892 }
893
894 return b_found;
895}
896
898 if (!pWayPointMan) return false;
899
900 // Find the RoutePoint
901 bool b_found = false;
902 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
903
904 if (prp) b_found = true;
905
906 if (b_found) {
907 double lat_save = prp->m_lat;
908 double lon_save = prp->m_lon;
909
910 prp->m_lat = pwaypoint->m_lat;
911 prp->m_lon = pwaypoint->m_lon;
912 prp->SetIconName(pwaypoint->m_IconName);
913 prp->SetName(pwaypoint->m_MarkName);
914 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
915 prp->SetVisible(pwaypoint->m_IsVisible);
916 if (pwaypoint->m_CreateTime.IsValid())
917 prp->SetCreateTime(pwaypoint->m_CreateTime);
918
919 // Transcribe (clone) the html HyperLink List, if present
920
921 if (pwaypoint->m_HyperlinkList) {
922 prp->m_HyperlinkList->clear();
923 if (pwaypoint->m_HyperlinkList->GetCount() > 0) {
924 wxPlugin_HyperlinkListNode* linknode =
925 pwaypoint->m_HyperlinkList->GetFirst();
926 while (linknode) {
927 Plugin_Hyperlink* link = linknode->GetData();
928
929 Hyperlink* h = new Hyperlink();
930 h->DescrText = link->DescrText;
931 h->Link = link->Link;
932 h->LType = link->Type;
933
934 prp->m_HyperlinkList->push_back(h);
935
936 linknode = linknode->GetNext();
937 }
938 }
939 }
940
941 if (prp) prp->ReLoadIcon();
942
943 auto canvas = gFrame->GetPrimaryCanvas();
944 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
945 canvas->GetScaleValue());
946 SelectItem* pFind =
947 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
948 if (pFind) {
949 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
950 pFind->m_slon = pwaypoint->m_lon;
951 }
952
953 if (!prp->m_btemp) {
954 // pConfig->UpdateWayPoint(prp);
955 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
956 }
957
959 pRouteManagerDialog->UpdateWptListCtrl();
960 }
961
962 return b_found;
963}
964
965// translate O route class to Plugin one
966static void PlugInFromRoutePoint(PlugIn_Waypoint* dst,
967 /* const*/ RoutePoint* src) {
968 dst->m_lat = src->m_lat;
969 dst->m_lon = src->m_lon;
970 dst->m_IconName = src->GetIconName();
971 dst->m_MarkName = src->GetName();
973 dst->m_IsVisible = src->IsVisible();
974 dst->m_CreateTime = src->GetCreateTime(); // not const
975 dst->m_GUID = src->m_GUID;
976
977 // Transcribe (clone) the html HyperLink List, if present
978 if (src->m_HyperlinkList == nullptr) return;
979
980 delete dst->m_HyperlinkList;
981 dst->m_HyperlinkList = nullptr;
982
983 if (src->m_HyperlinkList->size() > 0) {
984 dst->m_HyperlinkList = new Plugin_HyperlinkList;
985 for (Hyperlink* link : *src->m_HyperlinkList) {
987 h->DescrText = link->DescrText;
988 h->Link = link->Link;
989 h->Type = link->LType;
990
991 dst->m_HyperlinkList->Append(h);
992 }
993 }
994}
995
996bool GetSingleWaypoint(wxString GUID, PlugIn_Waypoint* pwaypoint) {
997 // Find the RoutePoint
998 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
999
1000 if (!prp) return false;
1001
1002 PlugInFromRoutePoint(pwaypoint, prp);
1003
1004 return true;
1005}
1006
1007wxArrayString GetWaypointGUIDArray() {
1008 wxArrayString result;
1009 if (pWayPointMan) {
1010 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
1011 result.Add(prp->m_GUID);
1012 }
1013 }
1014 return result;
1015}
1016
1017wxArrayString GetRouteGUIDArray() {
1018 wxArrayString result;
1019 for (Route* proute : *pRouteList) {
1020 result.Add(proute->m_GUID);
1021 }
1022 return result;
1023}
1024
1025wxArrayString GetTrackGUIDArray() {
1026 wxArrayString result;
1027 for (Track* ptrack : g_TrackList) {
1028 result.Add(ptrack->m_GUID);
1029 }
1030
1031 return result;
1032}
1033
1035 wxArrayString result;
1036 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
1037 switch (req) {
1038 case OBJECTS_ALL:
1039 result.Add(prp->m_GUID);
1040 break;
1041 case OBJECTS_NO_LAYERS:
1042 if (!prp->m_bIsInLayer) result.Add(prp->m_GUID);
1043 break;
1045 if (prp->m_bIsInLayer) result.Add(prp->m_GUID);
1046 break;
1047 }
1048 }
1049 return result;
1050}
1051
1053 wxArrayString result;
1054
1055 for (Route* proute : *pRouteList) {
1056 switch (req) {
1057 case OBJECTS_ALL:
1058 result.Add(proute->m_GUID);
1059 break;
1060 case OBJECTS_NO_LAYERS:
1061 if (!proute->m_bIsInLayer) result.Add(proute->m_GUID);
1062 break;
1064 if (proute->m_bIsInLayer) result.Add(proute->m_GUID);
1065 break;
1066 }
1067 }
1068
1069 return result;
1070}
1071
1073 wxArrayString result;
1074 for (Track* ptrack : g_TrackList) {
1075 switch (req) {
1076 case OBJECTS_ALL:
1077 result.Add(ptrack->m_GUID);
1078 break;
1079 case OBJECTS_NO_LAYERS:
1080 if (!ptrack->m_bIsInLayer) result.Add(ptrack->m_GUID);
1081 break;
1083 if (ptrack->m_bIsInLayer) result.Add(ptrack->m_GUID);
1084 break;
1085 }
1086 }
1087
1088 return result;
1089}
1090
1091wxArrayString GetIconNameArray() {
1092 wxArrayString result;
1093
1094 for (int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1095 wxString* ps = pWayPointMan->GetIconKey(i);
1096 result.Add(*ps);
1097 }
1098 return result;
1099}
1100
1101bool AddPlugInRoute(PlugIn_Route* proute, bool b_permanent) {
1102 Route* route = new Route();
1103
1104 PlugIn_Waypoint* pwp;
1105 RoutePoint* pWP_src;
1106 int ip = 0;
1107 wxDateTime plannedDeparture;
1108
1109 wxPlugin_WaypointListNode* pwpnode = proute->pWaypointList->GetFirst();
1110 while (pwpnode) {
1111 pwp = pwpnode->GetData();
1112
1113 RoutePoint* pWP = new RoutePoint(pwp->m_lat, pwp->m_lon, pwp->m_IconName,
1114 pwp->m_MarkName, pwp->m_GUID);
1115
1116 if (ip == 0) pWP_src = pWP;
1117
1118 // Transcribe (clone) the html HyperLink List, if present
1119 cloneHyperlinkList(pWP, pwp);
1121 pWP->m_bShowName = false;
1122 pWP->SetCreateTime(pwp->m_CreateTime);
1123
1124 route->AddPoint(pWP);
1125
1126 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
1127
1128 if (ip > 0)
1129 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
1130 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
1131 route);
1132 else
1133 plannedDeparture = pwp->m_CreateTime;
1134 ip++;
1135 pWP_src = pWP;
1136
1137 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
1138 }
1139
1140 route->m_PlannedDeparture = plannedDeparture;
1141
1142 route->m_RouteNameString = proute->m_NameString;
1143 route->m_RouteStartString = proute->m_StartString;
1144 route->m_RouteEndString = proute->m_EndString;
1145 if (!proute->m_GUID.IsEmpty()) {
1146 route->m_GUID = proute->m_GUID;
1147 }
1148 route->m_btemp = (b_permanent == false);
1149
1150 pRouteList->push_back(route);
1151
1152 if (b_permanent) {
1153 // pConfig->AddNewRoute(route);
1154 NavObj_dB::GetInstance().InsertRoute(route);
1155 }
1156 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1157 pRouteManagerDialog->UpdateRouteListCtrl();
1158
1159 return true;
1160}
1161
1162bool DeletePlugInRoute(wxString& GUID) {
1163 bool b_found = false;
1164
1165 // Find the Route
1166 Route* pRoute = g_pRouteMan->FindRouteByGUID(GUID);
1167 if (pRoute) {
1168 g_pRouteMan->DeleteRoute(pRoute);
1169 b_found = true;
1170 }
1171 return b_found;
1172}
1173
1175 bool b_found = false;
1176
1177 // Find the Route
1178 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
1179 if (pRoute) b_found = true;
1180
1181 if (b_found) {
1182 bool b_permanent = (pRoute->m_btemp == false);
1183 g_pRouteMan->DeleteRoute(pRoute);
1184 b_found = AddPlugInRoute(proute, b_permanent);
1185 }
1186
1187 return b_found;
1188}
1189
1190bool AddPlugInTrack(PlugIn_Track* ptrack, bool b_permanent) {
1191 Track* track = new Track();
1192
1193 PlugIn_Waypoint* pwp = 0;
1194 TrackPoint* pWP_src = 0;
1195 int ip = 0;
1196
1197 wxPlugin_WaypointListNode* pwpnode = ptrack->pWaypointList->GetFirst();
1198 while (pwpnode) {
1199 pwp = pwpnode->GetData();
1200
1201 TrackPoint* pWP = new TrackPoint(pwp->m_lat, pwp->m_lon);
1202 pWP->SetCreateTime(pwp->m_CreateTime);
1203
1204 track->AddPoint(pWP);
1205
1206 if (ip > 0)
1207 pSelect->AddSelectableTrackSegment(pWP_src->m_lat, pWP_src->m_lon,
1208 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
1209 track);
1210 ip++;
1211 pWP_src = pWP;
1212
1213 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
1214 }
1215
1216 track->SetName(ptrack->m_NameString);
1217 track->m_TrackStartString = ptrack->m_StartString;
1218 track->m_TrackEndString = ptrack->m_EndString;
1219 track->m_GUID = ptrack->m_GUID;
1220 track->m_btemp = (b_permanent == false);
1221
1222 g_TrackList.push_back(track);
1223 if (b_permanent) NavObj_dB::GetInstance().InsertTrack(track);
1224 // if (b_permanent) pConfig->AddNewTrack(track);
1225
1226 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1227 pRouteManagerDialog->UpdateTrkListCtrl();
1228
1229 return true;
1230}
1231
1232bool DeletePlugInTrack(wxString& GUID) {
1233 bool b_found = false;
1234
1235 // Find the Route
1236 Track* pTrack = g_pRouteMan->FindTrackByGUID(GUID);
1237 if (pTrack) {
1238 NavObj_dB::GetInstance().DeleteTrack(pTrack);
1239 RoutemanGui(*g_pRouteMan).DeleteTrack(pTrack);
1240 b_found = true;
1241 }
1242
1243 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1244 pRouteManagerDialog->UpdateTrkListCtrl();
1245
1246 return b_found;
1247}
1248
1250 bool b_found = false;
1251
1252 // Find the Track
1253 Track* pTrack = g_pRouteMan->FindTrackByGUID(ptrack->m_GUID);
1254 if (pTrack) b_found = true;
1255
1256 if (b_found) {
1257 bool b_permanent = (pTrack->m_btemp == false);
1258 NavObj_dB::GetInstance().DeleteTrack(pTrack);
1259 RoutemanGui(*g_pRouteMan).DeleteTrack(pTrack);
1260
1261 b_found = AddPlugInTrack(ptrack, b_permanent);
1262 }
1263
1264 return b_found;
1265}
1266
1268#ifdef ocpnUSE_GL
1269 ViewPort ocpn_vp;
1270 ocpn_vp.m_projection_type = vp->m_projection_type;
1271
1272 return glChartCanvas::HasNormalizedViewPort(ocpn_vp);
1273#else
1274 return false;
1275#endif
1276}
1277
1278void PlugInMultMatrixViewport(PlugIn_ViewPort* vp, float lat, float lon) {
1279#ifdef ocpnUSE_GL
1280 ViewPort ocpn_vp;
1281 ocpn_vp.clat = vp->clat;
1282 ocpn_vp.clon = vp->clon;
1283 ocpn_vp.m_projection_type = vp->m_projection_type;
1284 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
1285 ocpn_vp.skew = vp->skew;
1286 ocpn_vp.rotation = vp->rotation;
1287 ocpn_vp.pix_width = vp->pix_width;
1288 ocpn_vp.pix_height = vp->pix_height;
1289
1290// TODO fix for multicanvas glChartCanvas::MultMatrixViewPort(ocpn_vp, lat,
1291// lon);
1292#endif
1293}
1294
1295void PlugInNormalizeViewport(PlugIn_ViewPort* vp, float lat, float lon) {
1296#ifdef ocpnUSE_GL
1297 ViewPort ocpn_vp;
1298 glChartCanvas::NormalizedViewPort(ocpn_vp, lat, lon);
1299
1300 vp->clat = ocpn_vp.clat;
1301 vp->clon = ocpn_vp.clon;
1302 vp->view_scale_ppm = ocpn_vp.view_scale_ppm;
1303 vp->rotation = ocpn_vp.rotation;
1304 vp->skew = ocpn_vp.skew;
1305#endif
1306}
1307
1308// Helper and interface classes
1309
1310//-------------------------------------------------------------------------------
1311// PlugIn_AIS_Target Implementation
1312//-------------------------------------------------------------------------------
1313
1314PlugIn_AIS_Target* Create_PI_AIS_Target(AisTargetData* ptarget) {
1316
1317 pret->MMSI = ptarget->MMSI;
1318 pret->Class = ptarget->Class;
1319 pret->NavStatus = ptarget->NavStatus;
1320 pret->SOG = ptarget->SOG;
1321 pret->COG = ptarget->COG;
1322 pret->HDG = ptarget->HDG;
1323 pret->Lon = ptarget->Lon;
1324 pret->Lat = ptarget->Lat;
1325 pret->ROTAIS = ptarget->ROTAIS;
1326 pret->ShipType = ptarget->ShipType;
1327 pret->IMO = ptarget->IMO;
1328
1329 pret->Range_NM = ptarget->Range_NM;
1330 pret->Brg = ptarget->Brg;
1331
1332 // Per target collision parameters
1333 pret->bCPA_Valid = ptarget->bCPA_Valid;
1334 pret->TCPA = ptarget->TCPA; // Minutes
1335 pret->CPA = ptarget->CPA; // Nautical Miles
1336
1337 pret->alarm_state = (plugin_ais_alarm_type)ptarget->n_alert_state;
1338
1339 memcpy(pret->CallSign, ptarget->CallSign, sizeof(ptarget->CallSign) - 1);
1340 memcpy(pret->ShipName, ptarget->ShipName, sizeof(ptarget->ShipName) - 1);
1341
1342 return pret;
1343}
1344
1345//---------------------------------------------------------------------------
1346// API 1.11
1347//---------------------------------------------------------------------------
1348
1349//---------------------------------------------------------------------------
1350// API 1.12
1351//---------------------------------------------------------------------------
1352
1353//---------------------------------------------------------------------------
1354// API 1.13
1355//---------------------------------------------------------------------------
1356double fromDMM_Plugin(wxString sdms) { return fromDMM(sdms); }
1357
1358void SetCanvasRotation(double rotation) {
1359 gFrame->GetPrimaryCanvas()->DoRotateCanvas(rotation);
1360}
1361
1362double GetCanvasTilt() { return gFrame->GetPrimaryCanvas()->GetVPTilt(); }
1363
1364void SetCanvasTilt(double tilt) {
1365 gFrame->GetPrimaryCanvas()->DoTiltCanvas(tilt);
1366}
1367
1368void SetCanvasProjection(int projection) {
1369 gFrame->GetPrimaryCanvas()->SetVPProjection(projection);
1370}
1371
1372o_sound::Sound* g_PluginSound = o_sound::Factory();
1373static void onPlugInPlaySoundExFinished(void* ptr) {}
1374
1375// Start playing a sound to a given device and return status to plugin
1376bool PlugInPlaySoundEx(wxString& sound_file, int deviceIndex) {
1377 bool ok = g_PluginSound->Load(sound_file, deviceIndex);
1378 if (!ok) {
1379 wxLogWarning("Cannot load sound file: %s", sound_file);
1380 return false;
1381 }
1382 auto cmd_sound = dynamic_cast<o_sound::SystemCmdSound*>(g_PluginSound);
1383 if (cmd_sound) cmd_sound->SetCmd(g_CmdSoundString.mb_str(wxConvUTF8));
1384
1385 g_PluginSound->SetFinishedCallback(onPlugInPlaySoundExFinished, NULL);
1386 ok = g_PluginSound->Play();
1387 if (!ok) {
1388 wxLogWarning("Cannot play sound file: %s", sound_file);
1389 }
1390 return ok;
1391}
1392
1393bool CheckEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta) {
1394 return gFrame->GetPrimaryCanvas()->CheckEdgePan(x, y, dragging, margin,
1395 delta);
1396}
1397
1398wxBitmap GetIcon_PlugIn(const wxString& name) {
1399 ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle();
1400 return style->GetIcon(name);
1401}
1402
1403void SetCursor_PlugIn(wxCursor* pCursor) {
1404 gFrame->GetPrimaryCanvas()->pPlugIn_Cursor = pCursor;
1405}
1406
1407void AddChartDirectory(wxString& path) {
1408 if (g_options) {
1409 g_options->AddChartDir(path);
1410 }
1411}
1412
1414 if (g_options) {
1415 g_options->pScanCheckBox->SetValue(true);
1416 g_options->pUpdateCheckBox->SetValue(true);
1417 }
1418}
1419
1421 if (g_options) {
1422 g_options->pUpdateCheckBox->SetValue(true);
1423 }
1424}
1425
1426wxDialog* GetActiveOptionsDialog() { return g_options; }
1427
1428int PlatformDirSelectorDialog(wxWindow* parent, wxString* file_spec,
1429 wxString Title, wxString initDir) {
1430 return g_Platform->DoDirSelectorDialog(parent, file_spec, Title, initDir);
1431}
1432
1433int PlatformFileSelectorDialog(wxWindow* parent, wxString* file_spec,
1434 wxString Title, wxString initDir,
1435 wxString suggestedName, wxString wildcard) {
1436 return g_Platform->DoFileSelectorDialog(parent, file_spec, Title, initDir,
1437 suggestedName, wildcard);
1438}
1439
1440//---------------------------------------------------------------------------
1441// API 1.14
1442//---------------------------------------------------------------------------
1443
1444ViewPort CreateCompatibleViewportEx(const PlugIn_ViewPort& pivp) {
1445 // Create a system ViewPort
1446 ViewPort vp;
1447
1448 vp.clat = pivp.clat; // center point
1449 vp.clon = pivp.clon;
1451 vp.skew = pivp.skew;
1452 vp.rotation = pivp.rotation;
1453 vp.chart_scale = pivp.chart_scale;
1454 vp.pix_width = pivp.pix_width;
1455 vp.pix_height = pivp.pix_height;
1456 vp.rv_rect = pivp.rv_rect;
1457 vp.b_quilt = pivp.b_quilt;
1458 vp.m_projection_type = pivp.m_projection_type;
1459
1460 if (gFrame->GetPrimaryCanvas())
1461 vp.ref_scale = gFrame->GetPrimaryCanvas()->GetVP().ref_scale;
1462 else
1463 vp.ref_scale = vp.chart_scale;
1464
1465 vp.SetBoxes();
1466 vp.Validate(); // This VP is valid
1467
1468 return vp;
1469}
1470
1471void PlugInAISDrawGL(wxGLCanvas* glcanvas, const PlugIn_ViewPort& vp) {
1472 ViewPort ocpn_vp = CreateCompatibleViewportEx(vp);
1473
1474 ocpnDC dc(*glcanvas);
1475 dc.SetVP(ocpn_vp);
1476
1477 AISDraw(dc, ocpn_vp, NULL);
1478}
1479
1480bool PlugInSetFontColor(const wxString TextElement, const wxColour color) {
1481 return FontMgr::Get().SetFontColor(TextElement, color);
1482}
1483
1484//---------------------------------------------------------------------------
1485// API 1.15
1486//---------------------------------------------------------------------------
1487
1488double PlugInGetDisplaySizeMM() { return g_Platform->GetDisplaySizeMM(); }
1489
1490wxFont* FindOrCreateFont_PlugIn(int point_size, wxFontFamily family,
1491 wxFontStyle style, wxFontWeight weight,
1492 bool underline, const wxString& facename,
1493 wxFontEncoding encoding) {
1494 return FontMgr::Get().FindOrCreateFont(point_size, family, style, weight,
1495 underline, facename, encoding);
1496}
1497
1498int PluginGetMinAvailableGshhgQuality() {
1499 return gFrame->GetPrimaryCanvas()->GetMinAvailableGshhgQuality();
1500}
1501int PluginGetMaxAvailableGshhgQuality() {
1502 return gFrame->GetPrimaryCanvas()->GetMaxAvailableGshhgQuality();
1503}
1504
1505// disable builtin console canvas, and autopilot nmea sentences
1508}
1509
1510bool LaunchDefaultBrowser_Plugin(wxString url) {
1511 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1512
1513 return true;
1514}
1515
1516//---------------------------------------------------------------------------
1517// API 1.16
1518//---------------------------------------------------------------------------
1520 ChartCanvas* cc = gFrame->GetFocusCanvas();
1521 if (cc && cc->GetSelectedRoutePoint()) {
1522 return cc->GetSelectedRoutePoint()->m_GUID;
1523 }
1524 return wxEmptyString;
1525}
1526
1528 ChartCanvas* cc = gFrame->GetFocusCanvas();
1529 if (cc && cc->GetSelectedRoute()) {
1530 return cc->GetSelectedRoute()->m_GUID;
1531 }
1532 return wxEmptyString;
1533}
1534
1536 ChartCanvas* cc = gFrame->GetFocusCanvas();
1537 if (cc && cc->GetSelectedTrack()) {
1538 return cc->GetSelectedTrack()->m_GUID;
1539 }
1540 return wxEmptyString;
1541}
1542
1543std::unique_ptr<PlugIn_Waypoint> GetWaypoint_Plugin(const wxString& GUID) {
1544 std::unique_ptr<PlugIn_Waypoint> w(new PlugIn_Waypoint);
1545 GetSingleWaypoint(GUID, w.get());
1546 return w;
1547}
1548
1549std::unique_ptr<PlugIn_Route> GetRoute_Plugin(const wxString& GUID) {
1550 std::unique_ptr<PlugIn_Route> r;
1551 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
1552 if (route == nullptr) return r;
1553
1554 r = std::unique_ptr<PlugIn_Route>(new PlugIn_Route);
1555 PlugIn_Route* dst_route = r.get();
1556
1557 // PlugIn_Waypoint *pwp;
1558 RoutePoint* src_wp;
1559 for (RoutePoint* src_wp : *route->pRoutePointList) {
1560 PlugIn_Waypoint* dst_wp = new PlugIn_Waypoint();
1561 PlugInFromRoutePoint(dst_wp, src_wp);
1562 dst_route->pWaypointList->Append(dst_wp);
1563 }
1564 dst_route->m_NameString = route->m_RouteNameString;
1565 dst_route->m_StartString = route->m_RouteStartString;
1566 dst_route->m_EndString = route->m_RouteEndString;
1567 dst_route->m_GUID = route->m_GUID;
1568
1569 return r;
1570}
1571
1572std::unique_ptr<PlugIn_Track> GetTrack_Plugin(const wxString& GUID) {
1573 std::unique_ptr<PlugIn_Track> t;
1574 // Find the Track
1575 Track* pTrack = g_pRouteMan->FindTrackByGUID(GUID);
1576 if (!pTrack) return t;
1577
1578 std::unique_ptr<PlugIn_Track> tk =
1579 std::unique_ptr<PlugIn_Track>(new PlugIn_Track);
1580 PlugIn_Track* dst_track = tk.get();
1581 dst_track->m_NameString = pTrack->GetName();
1582 dst_track->m_StartString = pTrack->m_TrackStartString;
1583 dst_track->m_EndString = pTrack->m_TrackEndString;
1584 dst_track->m_GUID = pTrack->m_GUID;
1585
1586 for (int i = 0; i < pTrack->GetnPoints(); i++) {
1587 TrackPoint* ptp = pTrack->GetPoint(i);
1588
1589 PlugIn_Waypoint* dst_wp = new PlugIn_Waypoint();
1590
1591 dst_wp->m_lat = ptp->m_lat;
1592 dst_wp->m_lon = ptp->m_lon;
1593 dst_wp->m_CreateTime = ptp->GetCreateTime(); // not const
1594
1595 dst_track->pWaypointList->Append(dst_wp);
1596 }
1597
1598 return tk;
1599}
1600
1602
1604 // if(g_overlayCanvas)
1605 return g_overlayCanvas;
1606 // else
1607}
1608
1609void CanvasJumpToPosition(wxWindow* canvas, double lat, double lon,
1610 double scale) {
1611 auto oCanvas = dynamic_cast<ChartCanvas*>(canvas);
1612 if (oCanvas) gFrame->JumpToPosition(oCanvas, lat, lon, scale);
1613}
1614
1615bool ShuttingDown() { return g_bquiting; }
1616
1617wxWindow* GetCanvasUnderMouse() { return gFrame->GetCanvasUnderMouse(); }
1618
1620 ChartCanvas* l_canvas = gFrame->GetCanvasUnderMouse();
1621 if (l_canvas) {
1622 for (unsigned int i = 0; i < g_canvasArray.GetCount(); ++i) {
1623 if (l_canvas == g_canvasArray[i]) return i;
1624 }
1625 }
1626 return 0;
1627}
1628
1629// std::vector<wxWindow *> GetCanvasArray()
1630// {
1631// std::vector<wxWindow *> rv;
1632// for(unsigned int i=0 ; i < g_canvasArray.GetCount() ; i++){
1633// ChartCanvas *cc = g_canvasArray.Item(i);
1634// rv.push_back(cc);
1635// }
1636//
1637// return rv;
1638// }
1639
1640wxWindow* GetCanvasByIndex(int canvasIndex) {
1641 if (g_canvasConfig == 0)
1642 return gFrame->GetPrimaryCanvas();
1643 else {
1644 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1645 return g_canvasArray[canvasIndex];
1646 }
1647 }
1648 return NULL;
1649}
1650
1651bool CheckMUIEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta,
1652 int canvasIndex) {
1653 if (g_canvasConfig == 0)
1654 return gFrame->GetPrimaryCanvas()->CheckEdgePan(x, y, dragging, margin,
1655 delta);
1656 else {
1657 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1658 return g_canvasArray[canvasIndex]->CheckEdgePan(x, y, dragging, margin,
1659 delta);
1660 }
1661 }
1662
1663 return false;
1664}
1665
1666void SetMUICursor_PlugIn(wxCursor* pCursor, int canvasIndex) {
1667 if (g_canvasConfig == 0)
1668 gFrame->GetPrimaryCanvas()->pPlugIn_Cursor = pCursor;
1669 else {
1670 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1671 g_canvasArray[canvasIndex]->pPlugIn_Cursor = pCursor;
1672 }
1673 }
1674}
1675
1677 if (g_canvasConfig == 1) return 2;
1678 // else
1679 return 1;
1680}
1681
1682int GetLatLonFormat() { return g_iSDMMFormat; }
1683
1685 if (g_MainToolbar)
1686 return g_MainToolbar->GetToolbarRect();
1687 else
1688 return wxRect(0, 0, 1, 1);
1689}
1690
1691//---------------------------------------------------------------------------
1692// API 1.17
1693//---------------------------------------------------------------------------
1694
1695void ZeroXTE() {
1696 if (g_pRouteMan) {
1697 g_pRouteMan->ZeroCurrentXTEToActivePoint();
1698 }
1699}
1700
1701static PlugIn_ViewPort CreatePlugInViewportEx(const ViewPort& vp) {
1702 // Create a PlugIn Viewport
1703 ViewPort tvp = vp;
1704 PlugIn_ViewPort pivp;
1705
1706 pivp.clat = tvp.clat; // center point
1707 pivp.clon = tvp.clon;
1708 pivp.view_scale_ppm = tvp.view_scale_ppm;
1709 pivp.skew = tvp.skew;
1710 pivp.rotation = tvp.rotation;
1711 pivp.chart_scale = tvp.chart_scale;
1712 pivp.pix_width = tvp.pix_width;
1713 pivp.pix_height = tvp.pix_height;
1714 pivp.rv_rect = tvp.rv_rect;
1715 pivp.b_quilt = tvp.b_quilt;
1716 pivp.m_projection_type = tvp.m_projection_type;
1717
1718 pivp.lat_min = tvp.GetBBox().GetMinLat();
1719 pivp.lat_max = tvp.GetBBox().GetMaxLat();
1720 pivp.lon_min = tvp.GetBBox().GetMinLon();
1721 pivp.lon_max = tvp.GetBBox().GetMaxLon();
1722
1723 pivp.bValid = tvp.IsValid(); // This VP is valid
1724
1725 return pivp;
1726}
1727
1728ListOfPI_S57Obj* PlugInManager::GetLightsObjRuleListVisibleAtLatLon(
1729 ChartPlugInWrapper* target, float zlat, float zlon, const ViewPort& vp) {
1730 ListOfPI_S57Obj* list = NULL;
1731 if (target) {
1732 PlugInChartBaseGLPlus2* picbgl =
1733 dynamic_cast<PlugInChartBaseGLPlus2*>(target->GetPlugInChart());
1734 if (picbgl) {
1735 PlugIn_ViewPort pi_vp = CreatePlugInViewportEx(vp);
1736 list = picbgl->GetLightsObjRuleListVisibleAtLatLon(zlat, zlon, &pi_vp);
1737
1738 return list;
1739 }
1741 dynamic_cast<PlugInChartBaseExtendedPlus2*>(target->GetPlugInChart());
1742 if (picbx) {
1743 PlugIn_ViewPort pi_vp = CreatePlugInViewportEx(vp);
1744 list = picbx->GetLightsObjRuleListVisibleAtLatLon(zlat, zlon, &pi_vp);
1745
1746 return list;
1747 } else
1748 return list;
1749 } else
1750 return list;
1751}
1752
1753// PlugInWaypointEx implementation
1754
1755#include <wx/listimpl.cpp>
1756WX_DEFINE_LIST(Plugin_WaypointExList)
1757
1758// The class implementations
1759PlugIn_Waypoint_Ex::PlugIn_Waypoint_Ex() { InitDefaults(); }
1760
1761PlugIn_Waypoint_Ex::PlugIn_Waypoint_Ex(
1762 double lat, double lon, const wxString& icon_ident, const wxString& wp_name,
1763 const wxString& GUID, const double ScaMin, const bool bNameVisible,
1764 const int nRangeRings, const double RangeDistance,
1765 const wxColor RangeColor) {
1766 InitDefaults();
1767
1768 m_lat = lat;
1769 m_lon = lon;
1770 IconName = icon_ident;
1771 m_MarkName = wp_name;
1772 m_GUID = GUID;
1773 scamin = ScaMin;
1774 IsNameVisible = bNameVisible;
1775 nrange_rings = nRangeRings;
1776 RangeRingSpace = RangeDistance;
1777 RangeRingColor = RangeColor;
1778}
1779
1781 m_HyperlinkList = nullptr;
1782 scamin = 1e9;
1783 b_useScamin = false;
1784 nrange_rings = 0;
1785 RangeRingSpace = 1;
1786 IsNameVisible = false;
1787 IsVisible = true;
1788 RangeRingColor = *wxBLACK;
1789 m_CreateTime = wxDateTime::Now().ToUTC();
1790 IsActive = false;
1791 m_lat = 0;
1792 m_lon = 0;
1793}
1794
1796 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(m_GUID);
1797 if (!prp) return false;
1798
1799 if (prp->m_bIsInRoute && !prp->IsShared()) return false;
1800
1801 return true;
1802}
1803
1805 // Search all routes to count the membership of this point
1806 RoutePoint* pWP = pWayPointMan->FindRoutePointByGUID(m_GUID);
1807 if (!pWP) return 0;
1808
1809 int nCount = 0;
1810 for (Route* proute : *pRouteList) {
1811 for (RoutePoint* prp : *proute->pRoutePointList) {
1812 if (prp == pWP) nCount++;
1813 }
1814 }
1815 return nCount;
1816}
1817
1818PlugIn_Waypoint_Ex::~PlugIn_Waypoint_Ex() {}
1819
1820WX_DEFINE_LIST(Plugin_WaypointExV2List)
1821
1822PlugIn_Waypoint_ExV2::PlugIn_Waypoint_ExV2() { InitDefaults(); }
1823
1824PlugIn_Waypoint_ExV2::PlugIn_Waypoint_ExV2(
1825 double lat, double lon, const wxString& icon_ident, const wxString& wp_name,
1826 const wxString& GUID, const double ScaMin, const double ScaMax,
1827 const bool bNameVisible, const int nRangeRings, const double RangeDistance,
1828 const int RangeDistanceUnits, const wxColor RangeColor,
1829 const double WaypointArrivalRadius, const bool ShowWaypointRangeRings,
1830 const double PlannedSpeed, const wxString TideStation) {
1831 // Initialize all to defaults first
1832 InitDefaults();
1833 // Then set the specific values provided
1834 m_lat = lat;
1835 m_lon = lon;
1836 IconName = icon_ident;
1837 m_MarkName = wp_name;
1838 m_GUID = GUID;
1839 scamin = ScaMin;
1840 scamax = ScaMax;
1841
1842 IsNameVisible = bNameVisible;
1843 nrange_rings = nRangeRings;
1844 RangeRingSpace = RangeDistance;
1845 RangeRingSpaceUnits = RangeDistanceUnits; // 0 = nm, 1 = km
1846 RangeRingColor = RangeColor;
1847 m_TideStation = TideStation;
1848
1849 m_PlannedSpeed = PlannedSpeed;
1850 m_WaypointArrivalRadius = WaypointArrivalRadius;
1851 m_bShowWaypointRangeRings = ShowWaypointRangeRings;
1852}
1853
1855 m_HyperlinkList = nullptr;
1856 scamin = 1e9;
1857 scamax = 1e6;
1858 b_useScamin = false;
1859 nrange_rings = 0;
1860 RangeRingSpace = 1;
1861 RangeRingSpaceUnits = 0; // 0 = nm, 1 = km
1862 m_TideStation = wxEmptyString;
1863 IsNameVisible = false;
1864 IsVisible = true;
1865 RangeRingColor = *wxBLACK;
1866 m_CreateTime = wxDateTime::Now().ToUTC();
1867 IsActive = false;
1868 m_lat = 0;
1869 m_lon = 0;
1870
1871 m_PlannedSpeed = 0.0;
1874}
1875
1876PlugIn_Waypoint_ExV2::~PlugIn_Waypoint_ExV2() {}
1877
1879 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(m_GUID);
1880 if (!prp) return false;
1881 if (prp->m_bIsInRoute && !prp->IsShared()) return false;
1882 return true;
1883}
1884
1886 // Search all routes to count the membership of this point
1887 RoutePoint* pWP = pWayPointMan->FindRoutePointByGUID(m_GUID);
1888 if (!pWP) return 0;
1889
1890 int nCount = 0;
1891 for (Route* proute : *pRouteList) {
1892 for (RoutePoint* prp : *proute->pRoutePointList) {
1893 if (prp == pWP) nCount++;
1894 }
1895 }
1896
1897 return nCount;
1898}
1899
1900PlugIn_Route_ExV2::PlugIn_Route_ExV2() {
1901 pWaypointList = new Plugin_WaypointExV2List;
1902 m_GUID = wxEmptyString;
1903 m_NameString = wxEmptyString;
1904 m_StartString = wxEmptyString;
1905 m_EndString = wxEmptyString;
1906 m_isActive = false;
1907 m_isVisible = true;
1908 m_Description = wxEmptyString;
1909
1910 // Generate a unique GUID if none provided
1911 if (m_GUID.IsEmpty()) {
1912 wxDateTime now = wxDateTime::Now();
1913 m_GUID = wxString::Format("RT%d%d%d%d", (int)now.GetMillisecond(),
1914 (int)now.GetSecond(), (int)now.GetMinute(),
1915 (int)now.GetHour());
1916 }
1917}
1918
1919PlugIn_Route_ExV2::~PlugIn_Route_ExV2() {
1920 if (pWaypointList) {
1921 pWaypointList->DeleteContents(true);
1922 delete pWaypointList;
1923 }
1924}
1925
1926// translate O route class to PlugIn_Waypoint_ExV2
1927static void PlugInExV2FromRoutePoint(PlugIn_Waypoint_ExV2* dst,
1928 /* const*/ RoutePoint* src) {
1929 dst->m_lat = src->m_lat;
1930 dst->m_lon = src->m_lon;
1931 dst->IconName = src->GetIconName();
1932 dst->m_MarkName = src->GetName();
1933 dst->m_MarkDescription = src->GetDescription();
1934 dst->IconDescription = pWayPointMan->GetIconDescription(src->GetIconName());
1935 dst->IsVisible = src->IsVisible();
1936 dst->m_CreateTime = src->GetCreateTime(); // not const
1937 dst->m_GUID = src->m_GUID;
1938
1939 // Transcribe (clone) the html HyperLink List, if present
1940 if (src->m_HyperlinkList) {
1941 delete dst->m_HyperlinkList;
1942 dst->m_HyperlinkList = nullptr;
1943
1944 if (src->m_HyperlinkList->size() > 0) {
1945 dst->m_HyperlinkList = new Plugin_HyperlinkList;
1946
1947 for (Hyperlink* link : *src->m_HyperlinkList) {
1949 h->DescrText = link->DescrText;
1950 h->Link = link->Link;
1951 h->Type = link->LType;
1952 dst->m_HyperlinkList->Append(h);
1953 }
1954 }
1955 }
1956
1957 // Get the range ring info
1962 dst->m_TideStation = src->m_TideStation;
1963
1964 // Get other extended info
1965 dst->IsNameVisible = src->m_bShowName;
1966 dst->scamin = src->GetScaMin();
1967 dst->b_useScamin = src->GetUseSca();
1968 dst->IsActive = src->m_bIsActive;
1969
1970 dst->scamax = src->GetScaMax();
1971 dst->m_PlannedSpeed = src->GetPlannedSpeed();
1972 dst->m_ETD = src->GetManualETD();
1973 dst->m_WaypointArrivalRadius = src->GetWaypointArrivalRadius();
1974 dst->m_bShowWaypointRangeRings = src->GetShowWaypointRangeRings();
1975}
1976
1977bool GetSingleWaypointExV2(wxString GUID, PlugIn_Waypoint_ExV2* pwaypoint) {
1978 // Find the RoutePoint
1979 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
1980
1981 if (!prp) return false;
1982
1983 PlugInExV2FromRoutePoint(pwaypoint, prp);
1984
1985 return true;
1986}
1987
1988static void cloneHyperlinkListExV2(RoutePoint* dst,
1989 const PlugIn_Waypoint_ExV2* src) {
1990 // Transcribe (clone) the html HyperLink List, if present
1991 if (src->m_HyperlinkList == nullptr) return;
1992
1993 if (src->m_HyperlinkList->GetCount() > 0) {
1994 wxPlugin_HyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
1995 while (linknode) {
1996 Plugin_Hyperlink* link = linknode->GetData();
1997
1998 Hyperlink* h = new Hyperlink();
1999 h->DescrText = link->DescrText;
2000 h->Link = link->Link;
2001 h->LType = link->Type;
2002
2003 dst->m_HyperlinkList->push_back(h);
2004
2005 linknode = linknode->GetNext();
2006 }
2007 }
2008}
2009
2010RoutePoint* CreateNewPoint(const PlugIn_Waypoint_ExV2* src, bool b_permanent) {
2011 RoutePoint* pWP = new RoutePoint(src->m_lat, src->m_lon, src->IconName,
2012 src->m_MarkName, src->m_GUID);
2013
2014 pWP->m_bIsolatedMark = true; // This is an isolated mark
2015
2016 cloneHyperlinkListExV2(pWP, src);
2017
2019
2020 if (src->m_CreateTime.IsValid())
2021 pWP->SetCreateTime(src->m_CreateTime);
2022 else {
2023 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
2024 }
2025
2026 pWP->m_btemp = (b_permanent == false);
2027
2028 // Extended fields
2029 pWP->SetIconName(src->IconName);
2030 pWP->SetWaypointRangeRingsNumber(src->nrange_rings);
2031 pWP->SetWaypointRangeRingsStep(src->RangeRingSpace);
2032 pWP->SetWaypointRangeRingsStepUnits(src->RangeRingSpaceUnits);
2033 pWP->SetWaypointRangeRingsColour(src->RangeRingColor);
2034 pWP->SetTideStation(src->m_TideStation);
2035 pWP->SetScaMin(src->scamin);
2036 pWP->SetUseSca(src->b_useScamin);
2037 pWP->SetNameShown(src->IsNameVisible);
2038 pWP->SetVisible(src->IsVisible);
2039
2040 pWP->SetWaypointArrivalRadius(src->m_WaypointArrivalRadius);
2041 pWP->SetShowWaypointRangeRings(src->m_bShowWaypointRangeRings);
2042 pWP->SetScaMax(src->scamax);
2043 pWP->SetPlannedSpeed(src->m_PlannedSpeed);
2044 if (src->m_ETD.IsValid())
2045 pWP->SetETD(src->m_ETD);
2046 else
2047 pWP->SetETD(wxEmptyString);
2048 return pWP;
2049}
2050
2052 bool b_permanent) {
2053 // Validate the waypoint parameters a little bit
2054
2055 // GUID
2056 // Make sure that this GUID is indeed unique in the Routepoint list
2057 bool b_unique = true;
2058 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
2059 if (prp->m_GUID == pwaypointex->m_GUID) {
2060 b_unique = false;
2061 break;
2062 }
2063 }
2064
2065 if (!b_unique) return false;
2066
2067 RoutePoint* pWP = CreateNewPoint(pwaypointex, b_permanent);
2068
2069 pWP->SetShowWaypointRangeRings(pwaypointex->nrange_rings > 0);
2070
2071 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2072 if (b_permanent) {
2073 // pConfig->AddNewWayPoint(pWP, -1);
2074 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
2075 }
2076
2077 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2078 pRouteManagerDialog->UpdateWptListCtrl();
2079
2080 return true;
2081}
2082
2084 // Find the RoutePoint
2085 bool b_found = false;
2086 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
2087
2088 if (prp) b_found = true;
2089
2090 if (b_found) {
2091 double lat_save = prp->m_lat;
2092 double lon_save = prp->m_lon;
2093
2094 prp->m_lat = pwaypoint->m_lat;
2095 prp->m_lon = pwaypoint->m_lon;
2096 prp->SetIconName(pwaypoint->IconName);
2097 prp->SetName(pwaypoint->m_MarkName);
2098 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
2099 prp->SetVisible(pwaypoint->IsVisible);
2100 if (pwaypoint->m_CreateTime.IsValid())
2101 prp->SetCreateTime(pwaypoint->m_CreateTime);
2102
2103 // Transcribe (clone) the html HyperLink List, if present
2104
2105 if (pwaypoint->m_HyperlinkList) {
2106 prp->m_HyperlinkList->clear();
2107 for (Plugin_Hyperlink* link : *pwaypoint->m_HyperlinkList) {
2108 Hyperlink* h = new Hyperlink();
2109 h->DescrText = link->DescrText;
2110 h->Link = link->Link;
2111 h->LType = link->Type;
2112 prp->m_HyperlinkList->push_back(h);
2113 }
2114 }
2115
2116 // Extended fields
2117 prp->SetWaypointRangeRingsNumber(pwaypoint->nrange_rings);
2118 prp->SetWaypointRangeRingsStep(pwaypoint->RangeRingSpace);
2119 prp->SetWaypointRangeRingsStepUnits(pwaypoint->RangeRingSpaceUnits);
2120 prp->SetWaypointRangeRingsColour(pwaypoint->RangeRingColor);
2121 prp->SetTideStation(pwaypoint->m_TideStation);
2122 prp->SetScaMin(pwaypoint->scamin);
2123 prp->SetUseSca(pwaypoint->b_useScamin);
2124 prp->SetNameShown(pwaypoint->IsNameVisible);
2125
2126 prp->SetShowWaypointRangeRings(pwaypoint->nrange_rings > 0);
2127
2128 if (prp) prp->ReLoadIcon();
2129
2130 auto canvas = gFrame->GetPrimaryCanvas();
2131 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
2132 canvas->GetScaleValue());
2133 SelectItem* pFind =
2134 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
2135 if (pFind) {
2136 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
2137 pFind->m_slon = pwaypoint->m_lon;
2138 }
2139
2140 if (!prp->m_btemp) {
2141 // pConfig->UpdateWayPoint(prp);
2142 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
2143 }
2144
2145 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2146 pRouteManagerDialog->UpdateWptListCtrl();
2147
2148 prp->SetPlannedSpeed(pwaypoint->m_PlannedSpeed);
2149 if (pwaypoint->m_ETD.IsValid())
2150 prp->SetETD(pwaypoint->m_ETD);
2151 else
2152 prp->SetETD(wxEmptyString);
2153 prp->SetWaypointArrivalRadius(pwaypoint->m_WaypointArrivalRadius);
2154 prp->SetShowWaypointRangeRings(pwaypoint->m_bShowWaypointRangeRings);
2155 prp->SetScaMax(pwaypoint->scamax);
2156 }
2157
2158 return b_found;
2159}
2160
2161std::unique_ptr<PlugIn_Waypoint_ExV2> GetWaypointExV2_Plugin(
2162 const wxString& GUID) {
2163 std::unique_ptr<PlugIn_Waypoint_ExV2> w(new PlugIn_Waypoint_ExV2);
2164 GetSingleWaypointExV2(GUID, w.get());
2165 return w;
2166}
2167
2168// PlugIn_Route_ExV2 utilities
2169
2170bool AddPlugInRouteExV2(PlugIn_Route_ExV2* proute, bool b_permanent) {
2171 Route* route = new Route();
2172
2173 PlugIn_Waypoint_ExV2* pwaypointex;
2174 RoutePoint *pWP, *pWP_src;
2175 int ip = 0;
2176 wxDateTime plannedDeparture;
2177
2178 wxPlugin_WaypointExV2ListNode* pwpnode = proute->pWaypointList->GetFirst();
2179 while (pwpnode) {
2180 pwaypointex = pwpnode->GetData();
2181
2182 pWP = pWayPointMan->FindRoutePointByGUID(pwaypointex->m_GUID);
2183 if (!pWP) {
2184 pWP = CreateNewPoint(pwaypointex, b_permanent);
2185 pWP->m_bIsolatedMark = false;
2186 }
2187
2188 route->AddPoint(pWP);
2189
2190 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2191
2192 if (ip > 0)
2193 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
2194 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
2195 route);
2196
2197 plannedDeparture = pwaypointex->m_CreateTime;
2198 ip++;
2199 pWP_src = pWP;
2200
2201 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
2202 }
2203
2204 route->m_PlannedDeparture = plannedDeparture;
2205
2206 route->m_RouteNameString = proute->m_NameString;
2207 route->m_RouteStartString = proute->m_StartString;
2208 route->m_RouteEndString = proute->m_EndString;
2209 if (!proute->m_GUID.IsEmpty()) {
2210 route->m_GUID = proute->m_GUID;
2211 }
2212 route->m_btemp = (b_permanent == false);
2213 route->SetVisible(proute->m_isVisible);
2214 route->m_RouteDescription = proute->m_Description;
2215
2216 pRouteList->push_back(route);
2217
2218 if (b_permanent) {
2219 // pConfig->AddNewRoute(route);
2220 NavObj_dB::GetInstance().InsertRoute(route);
2221 }
2222
2223 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2224 pRouteManagerDialog->UpdateRouteListCtrl();
2225
2226 return true;
2227}
2228
2230 bool b_found = false;
2231
2232 // Find the Route
2233 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
2234 if (pRoute) b_found = true;
2235
2236 if (b_found) {
2237 bool b_permanent = !pRoute->m_btemp;
2238 g_pRouteMan->DeleteRoute(pRoute);
2239
2240 b_found = AddPlugInRouteExV2(proute, b_permanent);
2241 }
2242
2243 return b_found;
2244}
2245
2246std::unique_ptr<PlugIn_Route_ExV2> GetRouteExV2_Plugin(const wxString& GUID) {
2247 std::unique_ptr<PlugIn_Route_ExV2> r;
2248 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
2249 if (route == nullptr) return r;
2250
2251 r = std::unique_ptr<PlugIn_Route_ExV2>(new PlugIn_Route_ExV2);
2252 PlugIn_Route_ExV2* dst_route = r.get();
2253
2254 for (RoutePoint* src_wp : *route->pRoutePointList) {
2256 PlugInExV2FromRoutePoint(dst_wp, src_wp);
2257 dst_route->pWaypointList->Append(dst_wp);
2258 }
2259 dst_route->m_NameString = route->m_RouteNameString;
2260 dst_route->m_StartString = route->m_RouteStartString;
2261 dst_route->m_EndString = route->m_RouteEndString;
2262 dst_route->m_GUID = route->m_GUID;
2263 dst_route->m_isActive = g_pRouteMan->GetpActiveRoute() == route;
2264 dst_route->m_isVisible = route->IsVisible();
2265 dst_route->m_Description = route->m_RouteDescription;
2266
2267 return r;
2268}
2269
2270// PlugInRouteExtended implementation
2271PlugIn_Route_Ex::PlugIn_Route_Ex() {
2272 pWaypointList = new Plugin_WaypointExList;
2273}
2274
2275PlugIn_Route_Ex::~PlugIn_Route_Ex() {
2276 pWaypointList->DeleteContents(false); // do not delete Waypoints
2277 pWaypointList->Clear();
2278
2279 delete pWaypointList;
2280}
2281
2282// The utility methods implementations
2283
2284// translate O route class to PlugIn_Waypoint_Ex
2285static void PlugInExFromRoutePoint(PlugIn_Waypoint_Ex* dst,
2286 /* const*/ RoutePoint* src) {
2287 dst->m_lat = src->m_lat;
2288 dst->m_lon = src->m_lon;
2289 dst->IconName = src->GetIconName();
2290 dst->m_MarkName = src->GetName();
2291 dst->m_MarkDescription = src->GetDescription();
2292 dst->IconDescription = pWayPointMan->GetIconDescription(src->GetIconName());
2293 dst->IsVisible = src->IsVisible();
2294 dst->m_CreateTime = src->GetCreateTime(); // not const
2295 dst->m_GUID = src->m_GUID;
2296
2297 // Transcribe (clone) the html HyperLink List, if present
2298 if (src->m_HyperlinkList) {
2299 delete dst->m_HyperlinkList;
2300 dst->m_HyperlinkList = nullptr;
2301
2302 if (src->m_HyperlinkList->size() > 0) {
2303 dst->m_HyperlinkList = new Plugin_HyperlinkList;
2304 for (Hyperlink* link : *src->m_HyperlinkList) {
2306 h->DescrText = link->DescrText;
2307 h->Link = link->Link;
2308 h->Type = link->LType;
2309 dst->m_HyperlinkList->Append(h);
2310 }
2311 }
2312 }
2313
2314 // Get the range ring info
2318
2319 // Get other extended info
2320 dst->IsNameVisible = src->m_bShowName;
2321 dst->scamin = src->GetScaMin();
2322 dst->b_useScamin = src->GetUseSca();
2323 dst->IsActive = src->m_bIsActive;
2324}
2325
2326static void cloneHyperlinkListEx(RoutePoint* dst,
2327 const PlugIn_Waypoint_Ex* src) {
2328 // Transcribe (clone) the html HyperLink List, if present
2329 if (src->m_HyperlinkList == nullptr) return;
2330
2331 if (src->m_HyperlinkList->GetCount() > 0) {
2332 wxPlugin_HyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
2333 while (linknode) {
2334 Plugin_Hyperlink* link = linknode->GetData();
2335
2336 Hyperlink* h = new Hyperlink();
2337 h->DescrText = link->DescrText;
2338 h->Link = link->Link;
2339 h->LType = link->Type;
2340
2341 dst->m_HyperlinkList->push_back(h);
2342
2343 linknode = linknode->GetNext();
2344 }
2345 }
2346}
2347
2348RoutePoint* CreateNewPoint(const PlugIn_Waypoint_Ex* src, bool b_permanent) {
2349 RoutePoint* pWP = new RoutePoint(src->m_lat, src->m_lon, src->IconName,
2350 src->m_MarkName, src->m_GUID);
2351
2352 pWP->m_bIsolatedMark = true; // This is an isolated mark
2353
2354 cloneHyperlinkListEx(pWP, src);
2355
2357
2358 if (src->m_CreateTime.IsValid())
2359 pWP->SetCreateTime(src->m_CreateTime);
2360 else {
2361 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
2362 }
2363
2364 pWP->m_btemp = (b_permanent == false);
2365
2366 // Extended fields
2367 pWP->SetIconName(src->IconName);
2368 pWP->SetWaypointRangeRingsNumber(src->nrange_rings);
2369 pWP->SetWaypointRangeRingsStep(src->RangeRingSpace);
2370 pWP->SetWaypointRangeRingsColour(src->RangeRingColor);
2371 pWP->SetScaMin(src->scamin);
2372 pWP->SetUseSca(src->b_useScamin);
2373 pWP->SetNameShown(src->IsNameVisible);
2374 pWP->SetVisible(src->IsVisible);
2375
2376 return pWP;
2377}
2378bool GetSingleWaypointEx(wxString GUID, PlugIn_Waypoint_Ex* pwaypoint) {
2379 // Find the RoutePoint
2380 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
2381
2382 if (!prp) return false;
2383
2384 PlugInExFromRoutePoint(pwaypoint, prp);
2385
2386 return true;
2387}
2388
2389bool AddSingleWaypointEx(PlugIn_Waypoint_Ex* pwaypointex, bool b_permanent) {
2390 // Validate the waypoint parameters a little bit
2391
2392 // GUID
2393 // Make sure that this GUID is indeed unique in the Routepoint list
2394 bool b_unique = true;
2395 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
2396 if (prp->m_GUID == pwaypointex->m_GUID) {
2397 b_unique = false;
2398 break;
2399 }
2400 }
2401
2402 if (!b_unique) return false;
2403
2404 RoutePoint* pWP = CreateNewPoint(pwaypointex, b_permanent);
2405
2406 pWP->SetShowWaypointRangeRings(pwaypointex->nrange_rings > 0);
2407
2408 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2409 if (b_permanent) {
2410 // pConfig->AddNewWayPoint(pWP, -1);
2411 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
2412 }
2413 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2414 pRouteManagerDialog->UpdateWptListCtrl();
2415
2416 return true;
2417}
2418
2420 // Find the RoutePoint
2421 bool b_found = false;
2422 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
2423
2424 if (prp) b_found = true;
2425
2426 if (b_found) {
2427 double lat_save = prp->m_lat;
2428 double lon_save = prp->m_lon;
2429
2430 prp->m_lat = pwaypoint->m_lat;
2431 prp->m_lon = pwaypoint->m_lon;
2432 prp->SetIconName(pwaypoint->IconName);
2433 prp->SetName(pwaypoint->m_MarkName);
2434 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
2435 prp->SetVisible(pwaypoint->IsVisible);
2436 if (pwaypoint->m_CreateTime.IsValid())
2437 prp->SetCreateTime(pwaypoint->m_CreateTime);
2438
2439 // Transcribe (clone) the html HyperLink List, if present
2440
2441 if (pwaypoint->m_HyperlinkList) {
2442 prp->m_HyperlinkList->clear();
2443 if (pwaypoint->m_HyperlinkList->GetCount() > 0) {
2444 wxPlugin_HyperlinkListNode* linknode =
2445 pwaypoint->m_HyperlinkList->GetFirst();
2446 while (linknode) {
2447 Plugin_Hyperlink* link = linknode->GetData();
2448
2449 Hyperlink* h = new Hyperlink();
2450 h->DescrText = link->DescrText;
2451 h->Link = link->Link;
2452 h->LType = link->Type;
2453
2454 prp->m_HyperlinkList->push_back(h);
2455
2456 linknode = linknode->GetNext();
2457 }
2458 }
2459 }
2460
2461 // Extended fields
2462 prp->SetWaypointRangeRingsNumber(pwaypoint->nrange_rings);
2463 prp->SetWaypointRangeRingsStep(pwaypoint->RangeRingSpace);
2464 prp->SetWaypointRangeRingsColour(pwaypoint->RangeRingColor);
2465 prp->SetScaMin(pwaypoint->scamin);
2466 prp->SetUseSca(pwaypoint->b_useScamin);
2467 prp->SetNameShown(pwaypoint->IsNameVisible);
2468
2469 prp->SetShowWaypointRangeRings(pwaypoint->nrange_rings > 0);
2470
2471 if (prp) prp->ReLoadIcon();
2472
2473 auto canvas = gFrame->GetPrimaryCanvas();
2474 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
2475 canvas->GetScaleValue());
2476 SelectItem* pFind =
2477 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
2478 if (pFind) {
2479 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
2480 pFind->m_slon = pwaypoint->m_lon;
2481 }
2482
2483 if (!prp->m_btemp) {
2484 // pConfig->UpdateWayPoint(prp);
2485 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
2486 }
2487
2488 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2489 pRouteManagerDialog->UpdateWptListCtrl();
2490 }
2491
2492 return b_found;
2493}
2494
2495bool AddPlugInRouteEx(PlugIn_Route_Ex* proute, bool b_permanent) {
2496 Route* route = new Route();
2497
2498 PlugIn_Waypoint_Ex* pwaypointex;
2499 RoutePoint *pWP, *pWP_src;
2500 int ip = 0;
2501 wxDateTime plannedDeparture;
2502
2503 wxPlugin_WaypointExListNode* pwpnode = proute->pWaypointList->GetFirst();
2504 while (pwpnode) {
2505 pwaypointex = pwpnode->GetData();
2506
2507 pWP = pWayPointMan->FindRoutePointByGUID(pwaypointex->m_GUID);
2508 if (!pWP) {
2509 pWP = CreateNewPoint(pwaypointex, b_permanent);
2510 pWP->m_bIsolatedMark = false;
2511 }
2512
2513 route->AddPoint(pWP);
2514
2515 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2516
2517 if (ip > 0)
2518 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
2519 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
2520 route);
2521
2522 plannedDeparture = pwaypointex->m_CreateTime;
2523 ip++;
2524 pWP_src = pWP;
2525
2526 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
2527 }
2528
2529 route->m_PlannedDeparture = plannedDeparture;
2530
2531 route->m_RouteNameString = proute->m_NameString;
2532 route->m_RouteStartString = proute->m_StartString;
2533 route->m_RouteEndString = proute->m_EndString;
2534 if (!proute->m_GUID.IsEmpty()) {
2535 route->m_GUID = proute->m_GUID;
2536 }
2537 route->m_btemp = (b_permanent == false);
2538 route->SetVisible(proute->m_isVisible);
2539 route->m_RouteDescription = proute->m_Description;
2540
2541 pRouteList->push_back(route);
2542
2543 if (b_permanent) {
2544 // pConfig->AddNewRoute(route);
2545 NavObj_dB::GetInstance().InsertRoute(route);
2546 }
2547
2548 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2549 pRouteManagerDialog->UpdateRouteListCtrl();
2550
2551 return true;
2552}
2553
2555 bool b_found = false;
2556
2557 // Find the Route
2558 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
2559 if (pRoute) b_found = true;
2560
2561 if (b_found) {
2562 bool b_permanent = !pRoute->m_btemp;
2563 g_pRouteMan->DeleteRoute(pRoute);
2564 b_found = AddPlugInRouteEx(proute, b_permanent);
2565 }
2566
2567 return b_found;
2568}
2569
2570std::unique_ptr<PlugIn_Waypoint_Ex> GetWaypointEx_Plugin(const wxString& GUID) {
2571 std::unique_ptr<PlugIn_Waypoint_Ex> w(new PlugIn_Waypoint_Ex);
2572 GetSingleWaypointEx(GUID, w.get());
2573 return w;
2574}
2575
2576std::unique_ptr<PlugIn_Route_Ex> GetRouteEx_Plugin(const wxString& GUID) {
2577 std::unique_ptr<PlugIn_Route_Ex> r;
2578 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
2579 if (route == nullptr) return r;
2580
2581 r = std::unique_ptr<PlugIn_Route_Ex>(new PlugIn_Route_Ex);
2582 PlugIn_Route_Ex* dst_route = r.get();
2583
2584 // PlugIn_Waypoint *pwp;
2585 RoutePoint* src_wp;
2586 for (RoutePoint* src_wp : *route->pRoutePointList) {
2587 PlugIn_Waypoint_Ex* dst_wp = new PlugIn_Waypoint_Ex();
2588 PlugInExFromRoutePoint(dst_wp, src_wp);
2589
2590 dst_route->pWaypointList->Append(dst_wp);
2591 }
2592 dst_route->m_NameString = route->m_RouteNameString;
2593 dst_route->m_StartString = route->m_RouteStartString;
2594 dst_route->m_EndString = route->m_RouteEndString;
2595 dst_route->m_GUID = route->m_GUID;
2596 dst_route->m_isActive = g_pRouteMan->GetpActiveRoute() == route;
2597 dst_route->m_isVisible = route->IsVisible();
2598 dst_route->m_Description = route->m_RouteDescription;
2599
2600 return r;
2601}
2602
2604 void) { // if no active waypoint, returns wxEmptyString
2605 RoutePoint* rp = g_pRouteMan->GetpActivePoint();
2606 if (!rp)
2607 return wxEmptyString;
2608 else
2609 return rp->m_GUID;
2610}
2611
2613 void) { // if no active route, returns wxEmptyString
2614 Route* rt = g_pRouteMan->GetpActiveRoute();
2615 if (!rt)
2616 return wxEmptyString;
2617 else
2618 return rt->m_GUID;
2619}
2620
2622int GetGlobalWatchdogTimoutSeconds() { return gps_watchdog_timeout_ticks; }
2623
2625std::vector<std::string> GetPriorityMaps() {
2626 return (CommBridge::GetInstance().GetPriorityMaps());
2627}
2628
2629void UpdateAndApplyPriorityMaps(std::vector<std::string> map) {
2630 CommBridge::GetInstance().UpdateAndApplyMaps(map);
2631}
2632
2633std::vector<std::string> GetActivePriorityIdentifiers() {
2634 std::vector<std::string> result;
2635
2636 auto& comm_bridge = CommBridge::GetInstance();
2637
2638 std::string id = comm_bridge.GetPriorityContainer("position").active_source;
2639 result.push_back(id);
2640 id = comm_bridge.GetPriorityContainer("velocity").active_source;
2641 result.push_back(id);
2642 id = comm_bridge.GetPriorityContainer("heading").active_source;
2643 result.push_back(id);
2644 id = comm_bridge.GetPriorityContainer("variation").active_source;
2645 result.push_back(id);
2646 id = comm_bridge.GetPriorityContainer("satellites").active_source;
2647 result.push_back(id);
2648
2649 return result;
2650}
2651
2653 double rv = 1.0;
2654#if defined(__WXOSX__) || defined(__WXGTK3__)
2655 // Support scaled HDPI displays.
2656 if (gFrame) rv = gFrame->GetContentScaleFactor();
2657#endif
2658 return rv;
2659}
2661 double scaler = 1.0;
2662#ifdef __WXMSW__
2663 if (gFrame) scaler = (double)(gFrame->ToDIP(100)) / 100.;
2664#endif
2665 return scaler;
2666}
2667
2668//---------------------------------------------------------------------------
2669// API 1.18
2670//---------------------------------------------------------------------------
2671
2672//---------------------------------------------------------------------------
2673// API 1.19
2674//---------------------------------------------------------------------------
2675void ExitOCPN() {}
2676
2677bool GetFullScreen() { return gFrame->IsFullScreen(); }
2678
2679void SetFullScreen(bool set_full_screen_on) {
2680 bool state = gFrame->IsFullScreen();
2681 if (set_full_screen_on && !state)
2682 gFrame->ToggleFullScreen();
2683 else if (!set_full_screen_on && state)
2684 gFrame->ToggleFullScreen();
2685}
2686
2687extern bool g_useMUI;
2688void EnableMUIBar(bool enable, int CanvasIndex) {
2689 bool current_mui_state = g_useMUI;
2690
2691 g_useMUI = enable;
2692 if (enable && !current_mui_state) { // OFF going ON
2693 // ..For each canvas...
2694 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2695 ChartCanvas* cc = g_canvasArray.Item(i);
2696 if (cc) cc->CreateMUIBar();
2697 }
2698 } else if (!enable && current_mui_state) { // ON going OFF
2699 // ..For each canvas...
2700 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2701 ChartCanvas* cc = g_canvasArray.Item(i);
2702 if (cc) cc->DestroyMuiBar();
2703 }
2704 }
2705}
2706
2707bool GetEnableMUIBar(int CanvasIndex) { return g_useMUI; }
2708
2709void EnableCompassGPSIcon(bool enable, int CanvasIndex) {
2710 g_bShowCompassWin = enable;
2711}
2712
2713bool GetEnableCompassGPSIcon(int CanvasIndex) {
2714 if (CanvasIndex < GetCanvasCount()) {
2715 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2716 if (cc)
2717 return cc->GetShowGPSCompassWindow();
2718 else
2719 return false;
2720 }
2721 return false;
2722}
2723
2724extern bool g_bShowStatusBar;
2725void EnableStatusBar(bool enable) {
2726 g_bShowStatusBar = enable;
2727 gFrame->ConfigureStatusBar();
2728}
2729
2730bool GetEnableStatusBar() { return g_bShowStatusBar; }
2731
2732void EnableChartBar(bool enable, int CanvasIndex) {
2733 bool current_chartbar_state = g_bShowChartBar;
2734 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2735 ChartCanvas* cc = g_canvasArray.Item(i);
2736 if (current_chartbar_state && !enable) {
2737 gFrame->ToggleChartBar(cc);
2738 g_bShowChartBar = current_chartbar_state;
2739 } else if (!current_chartbar_state && enable) {
2740 gFrame->ToggleChartBar(cc);
2741 g_bShowChartBar = current_chartbar_state;
2742 }
2743 }
2744 g_bShowChartBar = enable;
2745}
2746
2747bool GetEnableChartBar(int CanvasIndex) { return g_bShowChartBar; }
2748
2749extern bool g_bShowMenuBar;
2750void EnableMenu(bool enable) {
2751 if (!enable) {
2752 if (g_bShowMenuBar) {
2753 g_bShowMenuBar = false;
2754 if (gFrame->m_pMenuBar) {
2755 gFrame->SetMenuBar(NULL);
2756 gFrame->m_pMenuBar->Destroy();
2757 gFrame->m_pMenuBar = NULL;
2758 }
2759 }
2760 } else {
2761 g_bShowMenuBar = true;
2762 gFrame->BuildMenuBar();
2763 }
2764}
2765
2766bool GetEnableMenu() { return g_bShowMenuBar; }
2767
2768void SetGlobalColor(std::string table, std::string name, wxColor color) {
2769 if (ps52plib) ps52plib->m_chartSymbols.UpdateTableColor(table, name, color);
2770}
2771
2772wxColor GetGlobalColorD(std::string map_name, std::string name) {
2773 wxColor ret = wxColor(*wxRED);
2774 if (ps52plib) {
2775 int i_table = ps52plib->m_chartSymbols.FindColorTable(map_name.c_str());
2776 ret = ps52plib->m_chartSymbols.GetwxColor(name.c_str(), i_table);
2777 }
2778 return ret;
2779}
2780
2781void EnableLatLonGrid(bool enable, int CanvasIndex) {
2782 if (CanvasIndex < GetCanvasCount()) {
2783 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2784 if (cc) cc->SetShowGrid(enable);
2785 }
2786}
2787
2788void EnableChartOutlines(bool enable, int CanvasIndex) {
2789 if (CanvasIndex < GetCanvasCount()) {
2790 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2791 if (cc) cc->SetShowOutlines(enable);
2792 }
2793}
2794
2795void EnableDepthUnitDisplay(bool enable, int CanvasIndex) {
2796 if (CanvasIndex < GetCanvasCount()) {
2797 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2798 if (cc) cc->SetShowDepthUnits(enable);
2799 }
2800}
2801
2802void EnableAisTargetDisplay(bool enable, int CanvasIndex) {
2803 if (CanvasIndex < GetCanvasCount()) {
2804 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2805 if (cc) cc->SetShowAIS(enable);
2806 }
2807}
2808
2809void EnableTideStationsDisplay(bool enable, int CanvasIndex) {
2810 if (CanvasIndex < GetCanvasCount()) {
2811 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2812 if (cc) cc->ShowTides(enable);
2813 }
2814}
2815
2816void EnableCurrentStationsDisplay(bool enable, int CanvasIndex) {
2817 if (CanvasIndex < GetCanvasCount()) {
2818 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2819 if (cc) cc->ShowCurrents(enable);
2820 }
2821}
2822
2823void EnableENCTextDisplay(bool enable, int CanvasIndex) {
2824 if (CanvasIndex < GetCanvasCount()) {
2825 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2826 if (cc) cc->SetShowENCText(enable);
2827 }
2828}
2829
2830void EnableENCDepthSoundingsDisplay(bool enable, int CanvasIndex) {
2831 if (CanvasIndex < GetCanvasCount()) {
2832 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2833 if (cc) cc->SetShowENCDepth(enable);
2834 }
2835}
2836
2837void EnableBuoyLightLabelsDisplay(bool enable, int CanvasIndex) {
2838 if (CanvasIndex < GetCanvasCount()) {
2839 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2840 if (cc) cc->SetShowENCBuoyLabels(enable);
2841 }
2842}
2843
2844void EnableLightsDisplay(bool enable, int CanvasIndex) {
2845 if (CanvasIndex < GetCanvasCount()) {
2846 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2847 if (cc) cc->SetShowENCLights(enable);
2848 }
2849}
2850
2851void EnableLightDescriptionsDisplay(bool enable, int CanvasIndex) {
2852 if (CanvasIndex < GetCanvasCount()) {
2853 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2854 if (cc) cc->SetShowENCLightDesc(enable);
2855 }
2856}
2857
2858void SetENCDisplayCategory(PI_DisCat cat, int CanvasIndex) {
2859 int valSet = STANDARD;
2860 switch (cat) {
2861 case PI_DISPLAYBASE:
2862 valSet = DISPLAYBASE;
2863 break;
2864 case PI_STANDARD:
2865 valSet = STANDARD;
2866 break;
2867 case PI_OTHER:
2868 valSet = OTHER;
2869 break;
2871 valSet = MARINERS_STANDARD;
2872 break;
2873 default:
2874 valSet = STANDARD;
2875 break;
2876 }
2877 if (CanvasIndex < GetCanvasCount()) {
2878 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2879 if (cc) cc->SetENCDisplayCategory(valSet);
2880 }
2881}
2883 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2884 if (cc)
2885 return ((PI_DisCat)cc->GetENCDisplayCategory());
2886 else
2887 return PI_DisCat::PI_STANDARD;
2888}
2889
2890void SetNavigationMode(PI_NavMode mode, int CanvasIndex) {
2891 int newMode = NORTH_UP_MODE;
2892 if (mode == PI_COURSE_UP_MODE)
2893 newMode = COURSE_UP_MODE;
2894 else if (mode == PI_HEAD_UP_MODE)
2895 newMode = HEAD_UP_MODE;
2896
2897 if (CanvasIndex < GetCanvasCount()) {
2898 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2899 if (cc) cc->SetUpMode(newMode);
2900 }
2901}
2903 if (CanvasIndex < GetCanvasCount()) {
2904 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2905 if (cc) return ((PI_NavMode)cc->GetUpMode());
2906 }
2907 return PI_NavMode::PI_NORTH_UP_MODE;
2908}
2909
2910bool GetEnableLatLonGrid(int CanvasIndex) {
2911 if (CanvasIndex < GetCanvasCount()) {
2912 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2913 if (cc) return (cc->GetShowGrid());
2914 }
2915 return false;
2916}
2917
2918bool GetEnableChartOutlines(int CanvasIndex) {
2919 if (CanvasIndex < GetCanvasCount()) {
2920 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2921 if (cc) return (cc->GetShowOutlines());
2922 }
2923 return false;
2924}
2925
2926bool GetEnableDepthUnitDisplay(int CanvasIndex) {
2927 if (CanvasIndex < GetCanvasCount()) {
2928 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2929 if (cc) return (cc->GetShowDepthUnits());
2930 }
2931 return false;
2932}
2933
2934bool GetEnableAisTargetDisplay(int CanvasIndex) {
2935 if (CanvasIndex < GetCanvasCount()) {
2936 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2937 if (cc) return (cc->GetShowAIS());
2938 }
2939 return false;
2940}
2941
2942bool GetEnableTideStationsDisplay(int CanvasIndex) {
2943 if (CanvasIndex < GetCanvasCount()) {
2944 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2945 if (cc) return (cc->GetbShowTide());
2946 }
2947 return false;
2948}
2949
2950bool GetEnableCurrentStationsDisplay(int CanvasIndex) {
2951 if (CanvasIndex < GetCanvasCount()) {
2952 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2953 if (cc) return (cc->GetbShowCurrent());
2954 }
2955 return false;
2956}
2957
2958bool GetEnableENCTextDisplay(int CanvasIndex) {
2959 if (CanvasIndex < GetCanvasCount()) {
2960 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2961 if (cc) return (cc->GetShowENCText());
2962 }
2963 return false;
2964}
2965
2967 if (CanvasIndex < GetCanvasCount()) {
2968 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2969 if (cc) return (cc->GetShowENCDepth());
2970 }
2971 return false;
2972}
2973
2974bool GetEnableBuoyLightLabelsDisplay(int CanvasIndex) {
2975 if (CanvasIndex < GetCanvasCount()) {
2976 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2977 if (cc) return (cc->GetShowENCBuoyLabels());
2978 }
2979 return false;
2980}
2981
2982bool GetEnableLightsDisplay(int CanvasIndex) {
2983 if (CanvasIndex < GetCanvasCount()) {
2984 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2985 if (cc) return (cc->GetShowENCLights());
2986 }
2987 return false;
2988}
2989
2990bool GetShowENCLightDesc(int CanvasIndex) {
2991 if (CanvasIndex < GetCanvasCount()) {
2992 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2993 if (cc) return (cc->GetbShowCurrent());
2994 }
2995 return false;
2996}
2997
2998void EnableTouchMode(bool enable) { g_btouch = enable; }
2999
3000bool GetTouchMode() { return g_btouch; }
3001
3002void EnableLookaheadMode(bool enable, int CanvasIndex) {
3003 if (CanvasIndex < GetCanvasCount()) {
3004 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3005 if (cc) cc->ToggleLookahead();
3006 }
3007}
3008
3009bool GetEnableLookaheadMode(int CanvasIndex) {
3010 if (CanvasIndex < GetCanvasCount()) {
3011 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3012 if (cc) return (cc->GetLookahead());
3013 }
3014 return false;
3015}
3016
3017extern bool g_bTrackActive;
3018void SetTrackingMode(bool enable) {
3019 if (!g_bTrackActive && enable)
3020 gFrame->TrackOn();
3021 else if (g_bTrackActive && !enable)
3022 gFrame->TrackOff();
3023}
3024bool GetTrackingMode() { return g_bTrackActive; }
3025
3027 gFrame->SetAndApplyColorScheme((ColorScheme)cs);
3028}
3030 return (PI_ColorScheme)global_color_scheme;
3031}
3032
3033void RequestWindowRefresh(wxWindow* win, bool eraseBackground) {
3034 if (win) win->Refresh(eraseBackground);
3035}
3036
3037void EnableSplitScreenLayout(bool enable) {
3038 if (g_canvasConfig == 1) {
3039 if (enable)
3040 return;
3041 else { // split to single
3042 g_canvasConfig = 0; // 0 => "single canvas"
3043 gFrame->CreateCanvasLayout();
3044 gFrame->DoChartUpdate();
3045 }
3046 } else {
3047 if (enable) { // single to split
3048 g_canvasConfig = 1; // 1 => "two canvas"
3049 gFrame->CreateCanvasLayout();
3050 gFrame->DoChartUpdate();
3051 } else {
3052 return;
3053 }
3054 }
3055}
3056
3057// ChartCanvas control utilities
3058
3059void PluginZoomCanvas(int CanvasIndex, double factor) {
3060 if (CanvasIndex < GetCanvasCount()) {
3061 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3062 if (cc) cc->ZoomCanvasSimple(factor);
3063 }
3064}
3065
3066bool GetEnableMainToolbar() { return (!g_disable_main_toolbar); }
3067void SetEnableMainToolbar(bool enable) {
3068 g_disable_main_toolbar = !enable;
3069 if (g_MainToolbar) g_MainToolbar->RefreshToolbar();
3070}
3071
3073 if (gFrame) gFrame->ScheduleSettingsDialog();
3074}
3075
3076void PluginCenterOwnship(int CanvasIndex) {
3077 if (CanvasIndex < GetCanvasCount()) {
3078 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3079 if (cc) {
3080 bool bfollow = cc->GetbFollow();
3081 cc->ResetOwnshipOffset();
3082 if (bfollow)
3083 cc->SetbFollow();
3084 else
3085 cc->JumpToPosition(gLat, gLon, cc->GetVPScale());
3086 }
3087 }
3088}
3089
3090void PluginSetFollowMode(int CanvasIndex, bool enable_follow) {
3091 if (CanvasIndex < GetCanvasCount()) {
3092 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3093 if (cc) {
3094 if (cc->GetbFollow() != enable_follow) cc->TogglebFollow();
3095 }
3096 }
3097}
3098
3099bool PluginGetFollowMode(int CanvasIndex) {
3100 if (CanvasIndex < GetCanvasCount()) {
3101 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3102 if (cc) return cc->GetbFollow();
3103 }
3104 return false;
3105}
3106
3107void EnableCanvasFocusBar(bool enable, int CanvasIndex) {
3108 if (CanvasIndex < GetCanvasCount()) {
3109 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3110 if (cc) cc->SetShowFocusBar(enable);
3111 }
3112}
3113bool GetEnableCanvasFocusBar(int CanvasIndex) {
3114 if (CanvasIndex < GetCanvasCount()) {
3115 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3116 if (cc) return (cc->GetShowFocusBar());
3117 }
3118 return false;
3119}
3120
3121bool GetEnableTenHertzUpdate() { return g_btenhertz; }
3122
3123void EnableTenHertzUpdate(bool enable) { g_btenhertz = enable; }
3124
3126 if (pConfig) {
3127 // Store current locale to detect changes
3128 wxString oldLocale = g_locale;
3129 pConfig->Flush();
3130
3131 // Handle system general configuration options
3132 pConfig->LoadMyConfigRaw(false);
3133
3134 // Handle S57 configuration options
3135 pConfig->LoadS57Config();
3136
3137 // Handle chart canvas window configuration options
3138 pConfig->LoadCanvasConfigs(false);
3139 auto& config_array = ConfigMgr::Get().GetCanvasConfigArray();
3140 for (auto pcc : config_array) {
3141 if (pcc && pcc->canvas) {
3142 pcc->canvas->ApplyCanvasConfig(pcc);
3143 pcc->canvas->Refresh();
3144 }
3145 }
3146
3147#if wxUSE_XLOCALE
3148 // Detect and apply locale changes
3149 if (g_locale != oldLocale && !g_locale.IsEmpty()) {
3150 wxLogMessage("ConfigFlushAndReload: Locale changed, applying...");
3151 g_Platform->ChangeLocale(g_locale, plocale_def_lang, &plocale_def_lang);
3152 ApplyLocale(); // Deactivates/reactivates plugins, rebuilds UI
3153 }
3154#endif
3155 }
3156}
3157
3162 g_CanvasHideNotificationIcon = !enable;
3163}
AisDecoder * g_pAIS
Global instance.
Class AisDecoder and helpers.
ChartDB * ChartData
Global instance.
Definition chartdb.cpp:71
Charts database management
ChartGroupArray * g_pGroupArray
Global instance.
Definition chartdbs.cpp:61
ChartCanvas * g_focusCanvas
Global instance.
Definition chcanv.cpp:1316
ChartCanvas * g_overlayCanvas
Global instance.
Definition chcanv.cpp:1315
Generic Chart canvas base.
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:173
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4685
float GetVPScale() override
Return ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:183
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:242
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:442
wxColour GetFontColor(const wxString &TextElement) const
Gets the text color for a UI element.
Definition font_mgr.cpp:110
bool AddAuxKey(wxString key)
Adds new plugin-defined font configuration key.
Definition font_mgr.cpp:653
bool SetFontColor(const wxString &TextElement, const wxColour color) const
Sets the text color for a UI element.
Definition font_mgr.cpp:115
static wxString GetUUID(void)
Return a unique RFC4122 version 4 compliant GUID string.
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
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
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 DeleteRoute(Route *pRoute)
Definition routeman.cpp:772
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:809
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.
CommBridge class and helpers.
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:90
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.
MyConfig * pConfig
Global instance.
Definition navutil.cpp:118
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.
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.
arrayofCanvasPtr g_canvasArray
Global instance.
Definition chcanv.cpp:173
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:181
Options dialog.
double gLat
Vessel's current latitude in decimal degrees.
Definition own_ship.cpp:26
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.
RouteManagerDialog * pRouteManagerDialog
Global instance.
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:66
OpenCPN Toolbar.
std::vector< Track * > g_TrackList
Global instance.
Definition track.cpp:96
Recorded track abstraction.
WaypointMan drawing stuff.