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.ToStdString(), message_body.ToStdString());
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 Plugin_HyperlinkList::compatibility_iterator linknode =
818 src->m_HyperlinkList->GetFirst();
819 while (linknode) {
820 Plugin_Hyperlink* link = linknode->GetData();
821
822 Hyperlink* h = new Hyperlink();
823 h->DescrText = link->DescrText;
824 h->Link = link->Link;
825 h->LType = link->Type;
826
827 dst->m_HyperlinkList->push_back(h);
828
829 linknode = linknode->GetNext();
830 }
831 }
832}
833
834bool AddSingleWaypoint(PlugIn_Waypoint* pwaypoint, bool b_permanent) {
835 if (!pWayPointMan) return false;
836
837 // Validate the waypoint parameters a little bit
838 // GUID
839 // Make sure that this GUID is indeed unique in the Routepoint list
840 bool b_unique = true;
841 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
842 if (prp->m_GUID == pwaypoint->m_GUID) {
843 b_unique = false;
844 break;
845 }
846 }
847
848 if (!b_unique) return false;
849
850 RoutePoint* pWP =
851 new RoutePoint(pwaypoint->m_lat, pwaypoint->m_lon, pwaypoint->m_IconName,
852 pwaypoint->m_MarkName, pwaypoint->m_GUID);
853
854 pWP->m_bIsolatedMark = true; // This is an isolated mark
855
856 cloneHyperlinkList(pWP, pwaypoint);
857
858 pWP->m_MarkDescription = pwaypoint->m_MarkDescription;
859
860 if (pwaypoint->m_CreateTime.IsValid())
861 pWP->SetCreateTime(pwaypoint->m_CreateTime);
862 else {
863 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
864 }
865
866 pWP->m_btemp = (b_permanent == false);
867
868 pSelect->AddSelectableRoutePoint(pwaypoint->m_lat, pwaypoint->m_lon, pWP);
869 if (b_permanent) {
870 // pConfig->AddNewWayPoint(pWP, -1);
871 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
872 }
873
875 pRouteManagerDialog->UpdateWptListCtrl();
876
877 return true;
878}
879
880bool DeleteSingleWaypoint(wxString& GUID) {
881 if (!pWayPointMan) return false;
882
883 // Find the RoutePoint
884 bool b_found = false;
885 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
886
887 if (prp) b_found = true;
888
889 if (b_found) {
890 pWayPointMan->DestroyWaypoint(prp);
892 pRouteManagerDialog->UpdateWptListCtrl();
893 }
894
895 return b_found;
896}
897
899 if (!pWayPointMan) return false;
900
901 // Find the RoutePoint
902 bool b_found = false;
903 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
904
905 if (prp) b_found = true;
906
907 if (b_found) {
908 double lat_save = prp->m_lat;
909 double lon_save = prp->m_lon;
910
911 prp->m_lat = pwaypoint->m_lat;
912 prp->m_lon = pwaypoint->m_lon;
913 prp->SetIconName(pwaypoint->m_IconName);
914 prp->SetName(pwaypoint->m_MarkName);
915 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
916 prp->SetVisible(pwaypoint->m_IsVisible);
917 if (pwaypoint->m_CreateTime.IsValid())
918 prp->SetCreateTime(pwaypoint->m_CreateTime);
919
920 // Transcribe (clone) the html HyperLink List, if present
921
922 if (pwaypoint->m_HyperlinkList) {
923 prp->m_HyperlinkList->clear();
924 if (pwaypoint->m_HyperlinkList->GetCount() > 0) {
925 Plugin_HyperlinkList::compatibility_iterator linknode =
926 pwaypoint->m_HyperlinkList->GetFirst();
927 while (linknode) {
928 Plugin_Hyperlink* link = linknode->GetData();
929
930 Hyperlink* h = new Hyperlink();
931 h->DescrText = link->DescrText;
932 h->Link = link->Link;
933 h->LType = link->Type;
934
935 prp->m_HyperlinkList->push_back(h);
936
937 linknode = linknode->GetNext();
938 }
939 }
940 }
941
942 if (prp) prp->ReLoadIcon();
943
944 auto canvas = gFrame->GetPrimaryCanvas();
945 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
946 canvas->GetScaleValue());
947 SelectItem* pFind =
948 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
949 if (pFind) {
950 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
951 pFind->m_slon = pwaypoint->m_lon;
952 }
953
954 if (!prp->m_btemp) {
955 // pConfig->UpdateWayPoint(prp);
956 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
957 }
958
960 pRouteManagerDialog->UpdateWptListCtrl();
961 }
962
963 return b_found;
964}
965
966// translate O route class to Plugin one
967static void PlugInFromRoutePoint(PlugIn_Waypoint* dst,
968 /* const*/ RoutePoint* src) {
969 dst->m_lat = src->m_lat;
970 dst->m_lon = src->m_lon;
971 dst->m_IconName = src->GetIconName();
972 dst->m_MarkName = src->GetName();
974 dst->m_IsVisible = src->IsVisible();
975 dst->m_CreateTime = src->GetCreateTime(); // not const
976 dst->m_GUID = src->m_GUID;
977
978 // Transcribe (clone) the html HyperLink List, if present
979 if (src->m_HyperlinkList == nullptr) return;
980
981 delete dst->m_HyperlinkList;
982 dst->m_HyperlinkList = nullptr;
983
984 if (src->m_HyperlinkList->size() > 0) {
985 dst->m_HyperlinkList = new Plugin_HyperlinkList;
986 for (Hyperlink* link : *src->m_HyperlinkList) {
988 h->DescrText = link->DescrText;
989 h->Link = link->Link;
990 h->Type = link->LType;
991
992 dst->m_HyperlinkList->Append(h);
993 }
994 }
995}
996
997bool GetSingleWaypoint(wxString GUID, PlugIn_Waypoint* pwaypoint) {
998 // Find the RoutePoint
999 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
1000
1001 if (!prp) return false;
1002
1003 PlugInFromRoutePoint(pwaypoint, prp);
1004
1005 return true;
1006}
1007
1008wxArrayString GetWaypointGUIDArray() {
1009 wxArrayString result;
1010 if (pWayPointMan) {
1011 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
1012 result.Add(prp->m_GUID);
1013 }
1014 }
1015 return result;
1016}
1017
1018wxArrayString GetRouteGUIDArray() {
1019 wxArrayString result;
1020 for (Route* proute : *pRouteList) {
1021 result.Add(proute->m_GUID);
1022 }
1023 return result;
1024}
1025
1026wxArrayString GetTrackGUIDArray() {
1027 wxArrayString result;
1028 for (Track* ptrack : g_TrackList) {
1029 result.Add(ptrack->m_GUID);
1030 }
1031
1032 return result;
1033}
1034
1036 wxArrayString result;
1037 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
1038 switch (req) {
1039 case OBJECTS_ALL:
1040 result.Add(prp->m_GUID);
1041 break;
1042 case OBJECTS_NO_LAYERS:
1043 if (!prp->m_bIsInLayer) result.Add(prp->m_GUID);
1044 break;
1046 if (prp->m_bIsInLayer) result.Add(prp->m_GUID);
1047 break;
1048 }
1049 }
1050 return result;
1051}
1052
1054 wxArrayString result;
1055
1056 for (Route* proute : *pRouteList) {
1057 switch (req) {
1058 case OBJECTS_ALL:
1059 result.Add(proute->m_GUID);
1060 break;
1061 case OBJECTS_NO_LAYERS:
1062 if (!proute->m_bIsInLayer) result.Add(proute->m_GUID);
1063 break;
1065 if (proute->m_bIsInLayer) result.Add(proute->m_GUID);
1066 break;
1067 }
1068 }
1069
1070 return result;
1071}
1072
1074 wxArrayString result;
1075 for (Track* ptrack : g_TrackList) {
1076 switch (req) {
1077 case OBJECTS_ALL:
1078 result.Add(ptrack->m_GUID);
1079 break;
1080 case OBJECTS_NO_LAYERS:
1081 if (!ptrack->m_bIsInLayer) result.Add(ptrack->m_GUID);
1082 break;
1084 if (ptrack->m_bIsInLayer) result.Add(ptrack->m_GUID);
1085 break;
1086 }
1087 }
1088
1089 return result;
1090}
1091
1092wxArrayString GetIconNameArray() {
1093 wxArrayString result;
1094
1095 for (int i = 0; i < pWayPointMan->GetNumIcons(); i++) {
1096 wxString* ps = pWayPointMan->GetIconKey(i);
1097 result.Add(*ps);
1098 }
1099 return result;
1100}
1101
1102bool AddPlugInRoute(PlugIn_Route* proute, bool b_permanent) {
1103 Route* route = new Route();
1104
1105 PlugIn_Waypoint* pwp;
1106 RoutePoint* pWP_src;
1107 int ip = 0;
1108 wxDateTime plannedDeparture;
1109
1110 Plugin_WaypointList::compatibility_iterator pwpnode =
1111 proute->pWaypointList->GetFirst();
1112 while (pwpnode) {
1113 pwp = pwpnode->GetData();
1114
1115 RoutePoint* pWP = new RoutePoint(pwp->m_lat, pwp->m_lon, pwp->m_IconName,
1116 pwp->m_MarkName, pwp->m_GUID);
1117
1118 if (ip == 0) pWP_src = pWP;
1119
1120 // Transcribe (clone) the html HyperLink List, if present
1121 cloneHyperlinkList(pWP, pwp);
1123 pWP->m_bShowName = false;
1124 pWP->SetCreateTime(pwp->m_CreateTime);
1125
1126 route->AddPoint(pWP);
1127
1128 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
1129
1130 if (ip > 0)
1131 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
1132 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
1133 route);
1134 else
1135 plannedDeparture = pwp->m_CreateTime;
1136 ip++;
1137 pWP_src = pWP;
1138
1139 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
1140 }
1141
1142 route->m_PlannedDeparture = plannedDeparture;
1143
1144 route->m_RouteNameString = proute->m_NameString;
1145 route->m_RouteStartString = proute->m_StartString;
1146 route->m_RouteEndString = proute->m_EndString;
1147 if (!proute->m_GUID.IsEmpty()) {
1148 route->m_GUID = proute->m_GUID;
1149 }
1150 route->m_btemp = (b_permanent == false);
1151
1152 pRouteList->push_back(route);
1153
1154 if (b_permanent) {
1155 // pConfig->AddNewRoute(route);
1156 NavObj_dB::GetInstance().InsertRoute(route);
1157 }
1158 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1159 pRouteManagerDialog->UpdateRouteListCtrl();
1160
1161 return true;
1162}
1163
1164bool DeletePlugInRoute(wxString& GUID) {
1165 bool b_found = false;
1166
1167 // Find the Route
1168 Route* pRoute = g_pRouteMan->FindRouteByGUID(GUID);
1169 if (pRoute) {
1170 g_pRouteMan->DeleteRoute(pRoute);
1171 b_found = true;
1172 }
1173 return b_found;
1174}
1175
1177 bool b_found = false;
1178
1179 // Find the Route
1180 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
1181 if (pRoute) b_found = true;
1182
1183 if (b_found) {
1184 bool b_permanent = (pRoute->m_btemp == false);
1185 g_pRouteMan->DeleteRoute(pRoute);
1186 b_found = AddPlugInRoute(proute, b_permanent);
1187 }
1188
1189 return b_found;
1190}
1191
1192bool AddPlugInTrack(PlugIn_Track* ptrack, bool b_permanent) {
1193 Track* track = new Track();
1194
1195 PlugIn_Waypoint* pwp = 0;
1196 TrackPoint* pWP_src = 0;
1197 int ip = 0;
1198
1199 Plugin_WaypointList::compatibility_iterator pwpnode =
1200 ptrack->pWaypointList->GetFirst();
1201 while (pwpnode) {
1202 pwp = pwpnode->GetData();
1203
1204 TrackPoint* pWP = new TrackPoint(pwp->m_lat, pwp->m_lon);
1205 pWP->SetCreateTime(pwp->m_CreateTime);
1206
1207 track->AddPoint(pWP);
1208
1209 if (ip > 0)
1210 pSelect->AddSelectableTrackSegment(pWP_src->m_lat, pWP_src->m_lon,
1211 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
1212 track);
1213 ip++;
1214 pWP_src = pWP;
1215
1216 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
1217 }
1218
1219 track->SetName(ptrack->m_NameString);
1220 track->m_TrackStartString = ptrack->m_StartString;
1221 track->m_TrackEndString = ptrack->m_EndString;
1222 track->m_GUID = ptrack->m_GUID;
1223 track->m_btemp = (b_permanent == false);
1224
1225 g_TrackList.push_back(track);
1226 if (b_permanent) NavObj_dB::GetInstance().InsertTrack(track);
1227 // if (b_permanent) pConfig->AddNewTrack(track);
1228
1229 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1230 pRouteManagerDialog->UpdateTrkListCtrl();
1231
1232 return true;
1233}
1234
1235bool DeletePlugInTrack(wxString& GUID) {
1236 bool b_found = false;
1237
1238 // Find the Route
1239 Track* pTrack = g_pRouteMan->FindTrackByGUID(GUID);
1240 if (pTrack) {
1241 NavObj_dB::GetInstance().DeleteTrack(pTrack);
1242 RoutemanGui(*g_pRouteMan).DeleteTrack(pTrack);
1243 b_found = true;
1244 }
1245
1246 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1247 pRouteManagerDialog->UpdateTrkListCtrl();
1248
1249 return b_found;
1250}
1251
1253 bool b_found = false;
1254
1255 // Find the Track
1256 Track* pTrack = g_pRouteMan->FindTrackByGUID(ptrack->m_GUID);
1257 if (pTrack) b_found = true;
1258
1259 if (b_found) {
1260 bool b_permanent = (pTrack->m_btemp == false);
1261 NavObj_dB::GetInstance().DeleteTrack(pTrack);
1262 RoutemanGui(*g_pRouteMan).DeleteTrack(pTrack);
1263
1264 b_found = AddPlugInTrack(ptrack, b_permanent);
1265 }
1266
1267 return b_found;
1268}
1269
1271#ifdef ocpnUSE_GL
1272 ViewPort ocpn_vp;
1273 ocpn_vp.m_projection_type = vp->m_projection_type;
1274
1275 return glChartCanvas::HasNormalizedViewPort(ocpn_vp);
1276#else
1277 return false;
1278#endif
1279}
1280
1281void PlugInMultMatrixViewport(PlugIn_ViewPort* vp, float lat, float lon) {
1282#ifdef ocpnUSE_GL
1283 ViewPort ocpn_vp;
1284 ocpn_vp.clat = vp->clat;
1285 ocpn_vp.clon = vp->clon;
1286 ocpn_vp.m_projection_type = vp->m_projection_type;
1287 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
1288 ocpn_vp.skew = vp->skew;
1289 ocpn_vp.rotation = vp->rotation;
1290 ocpn_vp.pix_width = vp->pix_width;
1291 ocpn_vp.pix_height = vp->pix_height;
1292
1293// TODO fix for multicanvas glChartCanvas::MultMatrixViewPort(ocpn_vp, lat,
1294// lon);
1295#endif
1296}
1297
1298void PlugInNormalizeViewport(PlugIn_ViewPort* vp, float lat, float lon) {
1299#ifdef ocpnUSE_GL
1300 ViewPort ocpn_vp;
1301 glChartCanvas::NormalizedViewPort(ocpn_vp, lat, lon);
1302
1303 vp->clat = ocpn_vp.clat;
1304 vp->clon = ocpn_vp.clon;
1305 vp->view_scale_ppm = ocpn_vp.view_scale_ppm;
1306 vp->rotation = ocpn_vp.rotation;
1307 vp->skew = ocpn_vp.skew;
1308#endif
1309}
1310
1311// Helper and interface classes
1312
1313//-------------------------------------------------------------------------------
1314// PlugIn_AIS_Target Implementation
1315//-------------------------------------------------------------------------------
1316
1317PlugIn_AIS_Target* Create_PI_AIS_Target(AisTargetData* ptarget) {
1319
1320 pret->MMSI = ptarget->MMSI;
1321 pret->Class = ptarget->Class;
1322 pret->NavStatus = ptarget->NavStatus;
1323 pret->SOG = ptarget->SOG;
1324 pret->COG = ptarget->COG;
1325 pret->HDG = ptarget->HDG;
1326 pret->Lon = ptarget->Lon;
1327 pret->Lat = ptarget->Lat;
1328 pret->ROTAIS = ptarget->ROTAIS;
1329 pret->ShipType = ptarget->ShipType;
1330 pret->IMO = ptarget->IMO;
1331
1332 pret->Range_NM = ptarget->Range_NM;
1333 pret->Brg = ptarget->Brg;
1334
1335 // Per target collision parameters
1336 pret->bCPA_Valid = ptarget->bCPA_Valid;
1337 pret->TCPA = ptarget->TCPA; // Minutes
1338 pret->CPA = ptarget->CPA; // Nautical Miles
1339
1340 pret->alarm_state = (plugin_ais_alarm_type)ptarget->n_alert_state;
1341
1342 memcpy(pret->CallSign, ptarget->CallSign, sizeof(ptarget->CallSign) - 1);
1343 memcpy(pret->ShipName, ptarget->ShipName, sizeof(ptarget->ShipName) - 1);
1344
1345 return pret;
1346}
1347
1348//---------------------------------------------------------------------------
1349// API 1.11
1350//---------------------------------------------------------------------------
1351
1352//---------------------------------------------------------------------------
1353// API 1.12
1354//---------------------------------------------------------------------------
1355
1356//---------------------------------------------------------------------------
1357// API 1.13
1358//---------------------------------------------------------------------------
1359double fromDMM_Plugin(wxString sdms) { return fromDMM(sdms); }
1360
1361void SetCanvasRotation(double rotation) {
1362 gFrame->GetPrimaryCanvas()->DoRotateCanvas(rotation);
1363}
1364
1365double GetCanvasTilt() { return gFrame->GetPrimaryCanvas()->GetVPTilt(); }
1366
1367void SetCanvasTilt(double tilt) {
1368 gFrame->GetPrimaryCanvas()->DoTiltCanvas(tilt);
1369}
1370
1371void SetCanvasProjection(int projection) {
1372 gFrame->GetPrimaryCanvas()->SetVPProjection(projection);
1373}
1374
1375o_sound::Sound* g_PluginSound = o_sound::Factory();
1376static void onPlugInPlaySoundExFinished(void* ptr) {}
1377
1378// Start playing a sound to a given device and return status to plugin
1379bool PlugInPlaySoundEx(wxString& sound_file, int deviceIndex) {
1380 bool ok = g_PluginSound->Load(sound_file, deviceIndex);
1381 if (!ok) {
1382 wxLogWarning("Cannot load sound file: %s", sound_file);
1383 return false;
1384 }
1385 auto cmd_sound = dynamic_cast<o_sound::SystemCmdSound*>(g_PluginSound);
1386 if (cmd_sound) cmd_sound->SetCmd(g_CmdSoundString.mb_str(wxConvUTF8));
1387
1388 g_PluginSound->SetFinishedCallback(onPlugInPlaySoundExFinished, NULL);
1389 ok = g_PluginSound->Play();
1390 if (!ok) {
1391 wxLogWarning("Cannot play sound file: %s", sound_file);
1392 }
1393 return ok;
1394}
1395
1396bool CheckEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta) {
1397 return gFrame->GetPrimaryCanvas()->CheckEdgePan(x, y, dragging, margin,
1398 delta);
1399}
1400
1401wxBitmap GetIcon_PlugIn(const wxString& name) {
1402 ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle();
1403 return style->GetIcon(name);
1404}
1405
1406void SetCursor_PlugIn(wxCursor* pCursor) {
1407 gFrame->GetPrimaryCanvas()->pPlugIn_Cursor = pCursor;
1408}
1409
1410void AddChartDirectory(wxString& path) {
1411 if (g_options) {
1412 g_options->AddChartDir(path);
1413 }
1414}
1415
1417 if (g_options) {
1418 g_options->pScanCheckBox->SetValue(true);
1419 g_options->pUpdateCheckBox->SetValue(true);
1420 }
1421}
1422
1424 if (g_options) {
1425 g_options->pUpdateCheckBox->SetValue(true);
1426 }
1427}
1428
1429wxDialog* GetActiveOptionsDialog() { return g_options; }
1430
1431int PlatformDirSelectorDialog(wxWindow* parent, wxString* file_spec,
1432 wxString Title, wxString initDir) {
1433 return g_Platform->DoDirSelectorDialog(parent, file_spec, Title, initDir);
1434}
1435
1436int PlatformFileSelectorDialog(wxWindow* parent, wxString* file_spec,
1437 wxString Title, wxString initDir,
1438 wxString suggestedName, wxString wildcard) {
1439 return g_Platform->DoFileSelectorDialog(parent, file_spec, Title, initDir,
1440 suggestedName, wildcard);
1441}
1442
1443//---------------------------------------------------------------------------
1444// API 1.14
1445//---------------------------------------------------------------------------
1446
1447ViewPort CreateCompatibleViewportEx(const PlugIn_ViewPort& pivp) {
1448 // Create a system ViewPort
1449 ViewPort vp;
1450
1451 vp.clat = pivp.clat; // center point
1452 vp.clon = pivp.clon;
1454 vp.skew = pivp.skew;
1455 vp.rotation = pivp.rotation;
1456 vp.chart_scale = pivp.chart_scale;
1457 vp.pix_width = pivp.pix_width;
1458 vp.pix_height = pivp.pix_height;
1459 vp.rv_rect = pivp.rv_rect;
1460 vp.b_quilt = pivp.b_quilt;
1461 vp.m_projection_type = pivp.m_projection_type;
1462
1463 if (gFrame->GetPrimaryCanvas())
1464 vp.ref_scale = gFrame->GetPrimaryCanvas()->GetVP().ref_scale;
1465 else
1466 vp.ref_scale = vp.chart_scale;
1467
1468 vp.SetBoxes();
1469 vp.Validate(); // This VP is valid
1470
1471 return vp;
1472}
1473
1474void PlugInAISDrawGL(wxGLCanvas* glcanvas, const PlugIn_ViewPort& vp) {
1475 ViewPort ocpn_vp = CreateCompatibleViewportEx(vp);
1476
1477 ocpnDC dc(*glcanvas);
1478 dc.SetVP(ocpn_vp);
1479
1480 AISDraw(dc, ocpn_vp, NULL);
1481}
1482
1483bool PlugInSetFontColor(const wxString TextElement, const wxColour color) {
1484 return FontMgr::Get().SetFontColor(TextElement, color);
1485}
1486
1487//---------------------------------------------------------------------------
1488// API 1.15
1489//---------------------------------------------------------------------------
1490
1491double PlugInGetDisplaySizeMM() { return g_Platform->GetDisplaySizeMM(); }
1492
1493wxFont* FindOrCreateFont_PlugIn(int point_size, wxFontFamily family,
1494 wxFontStyle style, wxFontWeight weight,
1495 bool underline, const wxString& facename,
1496 wxFontEncoding encoding) {
1497 return FontMgr::Get().FindOrCreateFont(point_size, family, style, weight,
1498 underline, facename, encoding);
1499}
1500
1501int PluginGetMinAvailableGshhgQuality() {
1502 return gFrame->GetPrimaryCanvas()->GetMinAvailableGshhgQuality();
1503}
1504int PluginGetMaxAvailableGshhgQuality() {
1505 return gFrame->GetPrimaryCanvas()->GetMaxAvailableGshhgQuality();
1506}
1507
1508// disable builtin console canvas, and autopilot nmea sentences
1511}
1512
1513bool LaunchDefaultBrowser_Plugin(wxString url) {
1514 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1515
1516 return true;
1517}
1518
1519//---------------------------------------------------------------------------
1520// API 1.16
1521//---------------------------------------------------------------------------
1523 ChartCanvas* cc = gFrame->GetFocusCanvas();
1524 if (cc && cc->GetSelectedRoutePoint()) {
1525 return cc->GetSelectedRoutePoint()->m_GUID;
1526 }
1527 return wxEmptyString;
1528}
1529
1531 ChartCanvas* cc = gFrame->GetFocusCanvas();
1532 if (cc && cc->GetSelectedRoute()) {
1533 return cc->GetSelectedRoute()->m_GUID;
1534 }
1535 return wxEmptyString;
1536}
1537
1539 ChartCanvas* cc = gFrame->GetFocusCanvas();
1540 if (cc && cc->GetSelectedTrack()) {
1541 return cc->GetSelectedTrack()->m_GUID;
1542 }
1543 return wxEmptyString;
1544}
1545
1546std::unique_ptr<PlugIn_Waypoint> GetWaypoint_Plugin(const wxString& GUID) {
1547 std::unique_ptr<PlugIn_Waypoint> w(new PlugIn_Waypoint);
1548 GetSingleWaypoint(GUID, w.get());
1549 return w;
1550}
1551
1552std::unique_ptr<PlugIn_Route> GetRoute_Plugin(const wxString& GUID) {
1553 std::unique_ptr<PlugIn_Route> r;
1554 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
1555 if (route == nullptr) return r;
1556
1557 r = std::unique_ptr<PlugIn_Route>(new PlugIn_Route);
1558 PlugIn_Route* dst_route = r.get();
1559
1560 // PlugIn_Waypoint *pwp;
1561 RoutePoint* src_wp;
1562 for (RoutePoint* src_wp : *route->pRoutePointList) {
1563 PlugIn_Waypoint* dst_wp = new PlugIn_Waypoint();
1564 PlugInFromRoutePoint(dst_wp, src_wp);
1565 dst_route->pWaypointList->Append(dst_wp);
1566 }
1567 dst_route->m_NameString = route->m_RouteNameString;
1568 dst_route->m_StartString = route->m_RouteStartString;
1569 dst_route->m_EndString = route->m_RouteEndString;
1570 dst_route->m_GUID = route->m_GUID;
1571
1572 return r;
1573}
1574
1575std::unique_ptr<PlugIn_Track> GetTrack_Plugin(const wxString& GUID) {
1576 std::unique_ptr<PlugIn_Track> t;
1577 // Find the Track
1578 Track* pTrack = g_pRouteMan->FindTrackByGUID(GUID);
1579 if (!pTrack) return t;
1580
1581 std::unique_ptr<PlugIn_Track> tk =
1582 std::unique_ptr<PlugIn_Track>(new PlugIn_Track);
1583 PlugIn_Track* dst_track = tk.get();
1584 dst_track->m_NameString = pTrack->GetName();
1585 dst_track->m_StartString = pTrack->m_TrackStartString;
1586 dst_track->m_EndString = pTrack->m_TrackEndString;
1587 dst_track->m_GUID = pTrack->m_GUID;
1588
1589 for (int i = 0; i < pTrack->GetnPoints(); i++) {
1590 TrackPoint* ptp = pTrack->GetPoint(i);
1591
1592 PlugIn_Waypoint* dst_wp = new PlugIn_Waypoint();
1593
1594 dst_wp->m_lat = ptp->m_lat;
1595 dst_wp->m_lon = ptp->m_lon;
1596 dst_wp->m_CreateTime = ptp->GetCreateTime(); // not const
1597
1598 dst_track->pWaypointList->Append(dst_wp);
1599 }
1600
1601 return tk;
1602}
1603
1605
1607 // if(g_overlayCanvas)
1608 return g_overlayCanvas;
1609 // else
1610}
1611
1612void CanvasJumpToPosition(wxWindow* canvas, double lat, double lon,
1613 double scale) {
1614 auto oCanvas = dynamic_cast<ChartCanvas*>(canvas);
1615 if (oCanvas) gFrame->JumpToPosition(oCanvas, lat, lon, scale);
1616}
1617
1618bool ShuttingDown() { return g_bquiting; }
1619
1620wxWindow* GetCanvasUnderMouse() { return gFrame->GetCanvasUnderMouse(); }
1621
1623 ChartCanvas* l_canvas = gFrame->GetCanvasUnderMouse();
1624 if (l_canvas) {
1625 for (unsigned int i = 0; i < g_canvasArray.GetCount(); ++i) {
1626 if (l_canvas == g_canvasArray[i]) return i;
1627 }
1628 }
1629 return 0;
1630}
1631
1632// std::vector<wxWindow *> GetCanvasArray()
1633// {
1634// std::vector<wxWindow *> rv;
1635// for(unsigned int i=0 ; i < g_canvasArray.GetCount() ; i++){
1636// ChartCanvas *cc = g_canvasArray.Item(i);
1637// rv.push_back(cc);
1638// }
1639//
1640// return rv;
1641// }
1642
1643wxWindow* GetCanvasByIndex(int canvasIndex) {
1644 if (g_canvasConfig == 0)
1645 return gFrame->GetPrimaryCanvas();
1646 else {
1647 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1648 return g_canvasArray[canvasIndex];
1649 }
1650 }
1651 return NULL;
1652}
1653
1654bool CheckMUIEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta,
1655 int canvasIndex) {
1656 if (g_canvasConfig == 0)
1657 return gFrame->GetPrimaryCanvas()->CheckEdgePan(x, y, dragging, margin,
1658 delta);
1659 else {
1660 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1661 return g_canvasArray[canvasIndex]->CheckEdgePan(x, y, dragging, margin,
1662 delta);
1663 }
1664 }
1665
1666 return false;
1667}
1668
1669void SetMUICursor_PlugIn(wxCursor* pCursor, int canvasIndex) {
1670 if (g_canvasConfig == 0)
1671 gFrame->GetPrimaryCanvas()->pPlugIn_Cursor = pCursor;
1672 else {
1673 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1674 g_canvasArray[canvasIndex]->pPlugIn_Cursor = pCursor;
1675 }
1676 }
1677}
1678
1680 if (g_canvasConfig == 1) return 2;
1681 // else
1682 return 1;
1683}
1684
1685int GetLatLonFormat() { return g_iSDMMFormat; }
1686
1688 if (g_MainToolbar)
1689 return g_MainToolbar->GetToolbarRect();
1690 else
1691 return wxRect(0, 0, 1, 1);
1692}
1693
1694//---------------------------------------------------------------------------
1695// API 1.17
1696//---------------------------------------------------------------------------
1697
1698void ZeroXTE() {
1699 if (g_pRouteMan) {
1700 g_pRouteMan->ZeroCurrentXTEToActivePoint();
1701 }
1702}
1703
1704static PlugIn_ViewPort CreatePlugInViewportEx(const ViewPort& vp) {
1705 // Create a PlugIn Viewport
1706 ViewPort tvp = vp;
1707 PlugIn_ViewPort pivp;
1708
1709 pivp.clat = tvp.clat; // center point
1710 pivp.clon = tvp.clon;
1711 pivp.view_scale_ppm = tvp.view_scale_ppm;
1712 pivp.skew = tvp.skew;
1713 pivp.rotation = tvp.rotation;
1714 pivp.chart_scale = tvp.chart_scale;
1715 pivp.pix_width = tvp.pix_width;
1716 pivp.pix_height = tvp.pix_height;
1717 pivp.rv_rect = tvp.rv_rect;
1718 pivp.b_quilt = tvp.b_quilt;
1719 pivp.m_projection_type = tvp.m_projection_type;
1720
1721 pivp.lat_min = tvp.GetBBox().GetMinLat();
1722 pivp.lat_max = tvp.GetBBox().GetMaxLat();
1723 pivp.lon_min = tvp.GetBBox().GetMinLon();
1724 pivp.lon_max = tvp.GetBBox().GetMaxLon();
1725
1726 pivp.bValid = tvp.IsValid(); // This VP is valid
1727
1728 return pivp;
1729}
1730
1731ListOfPI_S57Obj* PlugInManager::GetLightsObjRuleListVisibleAtLatLon(
1732 ChartPlugInWrapper* target, float zlat, float zlon, const ViewPort& vp) {
1733 ListOfPI_S57Obj* list = NULL;
1734 if (target) {
1735 PlugInChartBaseGLPlus2* picbgl =
1736 dynamic_cast<PlugInChartBaseGLPlus2*>(target->GetPlugInChart());
1737 if (picbgl) {
1738 PlugIn_ViewPort pi_vp = CreatePlugInViewportEx(vp);
1739 list = picbgl->GetLightsObjRuleListVisibleAtLatLon(zlat, zlon, &pi_vp);
1740
1741 return list;
1742 }
1743 PlugInChartBaseExtendedPlus2* picbx =
1744 dynamic_cast<PlugInChartBaseExtendedPlus2*>(target->GetPlugInChart());
1745 if (picbx) {
1746 PlugIn_ViewPort pi_vp = CreatePlugInViewportEx(vp);
1747 list = picbx->GetLightsObjRuleListVisibleAtLatLon(zlat, zlon, &pi_vp);
1748
1749 return list;
1750 } else
1751 return list;
1752 } else
1753 return list;
1754}
1755
1756// PlugInWaypointEx implementation
1757
1758#include <wx/listimpl.cpp>
1759WX_DEFINE_LIST(Plugin_WaypointExList)
1760
1761// The class implementations
1762PlugIn_Waypoint_Ex::PlugIn_Waypoint_Ex() { InitDefaults(); }
1763
1764PlugIn_Waypoint_Ex::PlugIn_Waypoint_Ex(
1765 double lat, double lon, const wxString& icon_ident, const wxString& wp_name,
1766 const wxString& GUID, const double ScaMin, const bool bNameVisible,
1767 const int nRangeRings, const double RangeDistance,
1768 const wxColor RangeColor) {
1769 InitDefaults();
1770
1771 m_lat = lat;
1772 m_lon = lon;
1773 IconName = icon_ident;
1774 m_MarkName = wp_name;
1775 m_GUID = GUID;
1776 scamin = ScaMin;
1777 IsNameVisible = bNameVisible;
1778 nrange_rings = nRangeRings;
1779 RangeRingSpace = RangeDistance;
1780 RangeRingColor = RangeColor;
1781}
1782
1784 m_HyperlinkList = nullptr;
1785 scamin = 1e9;
1786 b_useScamin = false;
1787 nrange_rings = 0;
1788 RangeRingSpace = 1;
1789 IsNameVisible = false;
1790 IsVisible = true;
1791 RangeRingColor = *wxBLACK;
1792 m_CreateTime = wxDateTime::Now().ToUTC();
1793 IsActive = false;
1794 m_lat = 0;
1795 m_lon = 0;
1796}
1797
1799 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(m_GUID);
1800 if (!prp) return false;
1801
1802 if (prp->m_bIsInRoute && !prp->IsShared()) return false;
1803
1804 return true;
1805}
1806
1808 // Search all routes to count the membership of this point
1809 RoutePoint* pWP = pWayPointMan->FindRoutePointByGUID(m_GUID);
1810 if (!pWP) return 0;
1811
1812 int nCount = 0;
1813 for (Route* proute : *pRouteList) {
1814 for (RoutePoint* prp : *proute->pRoutePointList) {
1815 if (prp == pWP) nCount++;
1816 }
1817 }
1818 return nCount;
1819}
1820
1821PlugIn_Waypoint_Ex::~PlugIn_Waypoint_Ex() {}
1822
1823WX_DEFINE_LIST(Plugin_WaypointExV2List)
1824
1825PlugIn_Waypoint_ExV2::PlugIn_Waypoint_ExV2() { InitDefaults(); }
1826
1827PlugIn_Waypoint_ExV2::PlugIn_Waypoint_ExV2(
1828 double lat, double lon, const wxString& icon_ident, const wxString& wp_name,
1829 const wxString& GUID, const double ScaMin, const double ScaMax,
1830 const bool bNameVisible, const int nRangeRings, const double RangeDistance,
1831 const int RangeDistanceUnits, const wxColor RangeColor,
1832 const double WaypointArrivalRadius, const bool ShowWaypointRangeRings,
1833 const double PlannedSpeed, const wxString TideStation) {
1834 // Initialize all to defaults first
1835 InitDefaults();
1836 // Then set the specific values provided
1837 m_lat = lat;
1838 m_lon = lon;
1839 IconName = icon_ident;
1840 m_MarkName = wp_name;
1841 m_GUID = GUID;
1842 scamin = ScaMin;
1843 scamax = ScaMax;
1844
1845 IsNameVisible = bNameVisible;
1846 nrange_rings = nRangeRings;
1847 RangeRingSpace = RangeDistance;
1848 RangeRingSpaceUnits = RangeDistanceUnits; // 0 = nm, 1 = km
1849 RangeRingColor = RangeColor;
1850 m_TideStation = TideStation;
1851
1852 m_PlannedSpeed = PlannedSpeed;
1853 m_WaypointArrivalRadius = WaypointArrivalRadius;
1854 m_bShowWaypointRangeRings = ShowWaypointRangeRings;
1855}
1856
1858 m_HyperlinkList = nullptr;
1859 scamin = 1e9;
1860 scamax = 1e6;
1861 b_useScamin = false;
1862 nrange_rings = 0;
1863 RangeRingSpace = 1;
1864 RangeRingSpaceUnits = 0; // 0 = nm, 1 = km
1865 m_TideStation = wxEmptyString;
1866 IsNameVisible = false;
1867 IsVisible = true;
1868 RangeRingColor = *wxBLACK;
1869 m_CreateTime = wxDateTime::Now().ToUTC();
1870 IsActive = false;
1871 m_lat = 0;
1872 m_lon = 0;
1873
1874 m_PlannedSpeed = 0.0;
1877}
1878
1879PlugIn_Waypoint_ExV2::~PlugIn_Waypoint_ExV2() {}
1880
1882 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(m_GUID);
1883 if (!prp) return false;
1884 if (prp->m_bIsInRoute && !prp->IsShared()) return false;
1885 return true;
1886}
1887
1889 // Search all routes to count the membership of this point
1890 RoutePoint* pWP = pWayPointMan->FindRoutePointByGUID(m_GUID);
1891 if (!pWP) return 0;
1892
1893 int nCount = 0;
1894 for (Route* proute : *pRouteList) {
1895 for (RoutePoint* prp : *proute->pRoutePointList) {
1896 if (prp == pWP) nCount++;
1897 }
1898 }
1899
1900 return nCount;
1901}
1902
1903PlugIn_Route_ExV2::PlugIn_Route_ExV2() {
1904 pWaypointList = new Plugin_WaypointExV2List;
1905 m_GUID = wxEmptyString;
1906 m_NameString = wxEmptyString;
1907 m_StartString = wxEmptyString;
1908 m_EndString = wxEmptyString;
1909 m_isActive = false;
1910 m_isVisible = true;
1911 m_Description = wxEmptyString;
1912
1913 // Generate a unique GUID if none provided
1914 if (m_GUID.IsEmpty()) {
1915 wxDateTime now = wxDateTime::Now();
1916 m_GUID = wxString::Format("RT%d%d%d%d", (int)now.GetMillisecond(),
1917 (int)now.GetSecond(), (int)now.GetMinute(),
1918 (int)now.GetHour());
1919 }
1920}
1921
1922PlugIn_Route_ExV2::~PlugIn_Route_ExV2() {
1923 if (pWaypointList) {
1924 pWaypointList->DeleteContents(true);
1925 delete pWaypointList;
1926 }
1927}
1928
1929// translate O route class to PlugIn_Waypoint_ExV2
1930static void PlugInExV2FromRoutePoint(PlugIn_Waypoint_ExV2* dst,
1931 /* const*/ RoutePoint* src) {
1932 dst->m_lat = src->m_lat;
1933 dst->m_lon = src->m_lon;
1934 dst->IconName = src->GetIconName();
1935 dst->m_MarkName = src->GetName();
1936 dst->m_MarkDescription = src->GetDescription();
1937 dst->IconDescription = pWayPointMan->GetIconDescription(src->GetIconName());
1938 dst->IsVisible = src->IsVisible();
1939 dst->m_CreateTime = src->GetCreateTime(); // not const
1940 dst->m_GUID = src->m_GUID;
1941
1942 // Transcribe (clone) the html HyperLink List, if present
1943 if (src->m_HyperlinkList) {
1944 delete dst->m_HyperlinkList;
1945 dst->m_HyperlinkList = nullptr;
1946
1947 if (src->m_HyperlinkList->size() > 0) {
1948 dst->m_HyperlinkList = new Plugin_HyperlinkList;
1949
1950 for (Hyperlink* link : *src->m_HyperlinkList) {
1952 h->DescrText = link->DescrText;
1953 h->Link = link->Link;
1954 h->Type = link->LType;
1955 dst->m_HyperlinkList->Append(h);
1956 }
1957 }
1958 }
1959
1960 // Get the range ring info
1965 dst->m_TideStation = src->m_TideStation;
1966
1967 // Get other extended info
1968 dst->IsNameVisible = src->m_bShowName;
1969 dst->scamin = src->GetScaMin();
1970 dst->b_useScamin = src->GetUseSca();
1971 dst->IsActive = src->m_bIsActive;
1972
1973 dst->scamax = src->GetScaMax();
1974 dst->m_PlannedSpeed = src->GetPlannedSpeed();
1975 dst->m_ETD = src->GetManualETD();
1976 dst->m_WaypointArrivalRadius = src->GetWaypointArrivalRadius();
1977 dst->m_bShowWaypointRangeRings = src->GetShowWaypointRangeRings();
1978}
1979
1980bool GetSingleWaypointExV2(wxString GUID, PlugIn_Waypoint_ExV2* pwaypoint) {
1981 // Find the RoutePoint
1982 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
1983
1984 if (!prp) return false;
1985
1986 PlugInExV2FromRoutePoint(pwaypoint, prp);
1987
1988 return true;
1989}
1990
1991static void cloneHyperlinkListExV2(RoutePoint* dst,
1992 const PlugIn_Waypoint_ExV2* src) {
1993 // Transcribe (clone) the html HyperLink List, if present
1994 if (src->m_HyperlinkList == nullptr) return;
1995
1996 if (src->m_HyperlinkList->GetCount() > 0) {
1997 Plugin_HyperlinkList::compatibility_iterator linknode =
1998 src->m_HyperlinkList->GetFirst();
1999 while (linknode) {
2000 Plugin_Hyperlink* link = linknode->GetData();
2001
2002 Hyperlink* h = new Hyperlink();
2003 h->DescrText = link->DescrText;
2004 h->Link = link->Link;
2005 h->LType = link->Type;
2006
2007 dst->m_HyperlinkList->push_back(h);
2008
2009 linknode = linknode->GetNext();
2010 }
2011 }
2012}
2013
2014RoutePoint* CreateNewPoint(const PlugIn_Waypoint_ExV2* src, bool b_permanent) {
2015 RoutePoint* pWP = new RoutePoint(src->m_lat, src->m_lon, src->IconName,
2016 src->m_MarkName, src->m_GUID);
2017
2018 pWP->m_bIsolatedMark = true; // This is an isolated mark
2019
2020 cloneHyperlinkListExV2(pWP, src);
2021
2023
2024 if (src->m_CreateTime.IsValid())
2025 pWP->SetCreateTime(src->m_CreateTime);
2026 else {
2027 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
2028 }
2029
2030 pWP->m_btemp = (b_permanent == false);
2031
2032 // Extended fields
2033 pWP->SetIconName(src->IconName);
2034 pWP->SetWaypointRangeRingsNumber(src->nrange_rings);
2035 pWP->SetWaypointRangeRingsStep(src->RangeRingSpace);
2036 pWP->SetWaypointRangeRingsStepUnits(src->RangeRingSpaceUnits);
2037 pWP->SetWaypointRangeRingsColour(src->RangeRingColor);
2038 pWP->SetTideStation(src->m_TideStation);
2039 pWP->SetScaMin(src->scamin);
2040 pWP->SetUseSca(src->b_useScamin);
2041 pWP->SetNameShown(src->IsNameVisible);
2042 pWP->SetVisible(src->IsVisible);
2043
2044 pWP->SetWaypointArrivalRadius(src->m_WaypointArrivalRadius);
2045 pWP->SetShowWaypointRangeRings(src->m_bShowWaypointRangeRings);
2046 pWP->SetScaMax(src->scamax);
2047 pWP->SetPlannedSpeed(src->m_PlannedSpeed);
2048 if (src->m_ETD.IsValid())
2049 pWP->SetETD(src->m_ETD);
2050 else
2051 pWP->SetETD(wxEmptyString);
2052 return pWP;
2053}
2054
2056 bool b_permanent) {
2057 // Validate the waypoint parameters a little bit
2058
2059 // GUID
2060 // Make sure that this GUID is indeed unique in the Routepoint list
2061 bool b_unique = true;
2062 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
2063 if (prp->m_GUID == pwaypointex->m_GUID) {
2064 b_unique = false;
2065 break;
2066 }
2067 }
2068
2069 if (!b_unique) return false;
2070
2071 RoutePoint* pWP = CreateNewPoint(pwaypointex, b_permanent);
2072
2073 pWP->SetShowWaypointRangeRings(pwaypointex->nrange_rings > 0);
2074
2075 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2076 if (b_permanent) {
2077 // pConfig->AddNewWayPoint(pWP, -1);
2078 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
2079 }
2080
2081 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2082 pRouteManagerDialog->UpdateWptListCtrl();
2083
2084 return true;
2085}
2086
2088 // Find the RoutePoint
2089 bool b_found = false;
2090 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
2091
2092 if (prp) b_found = true;
2093
2094 if (b_found) {
2095 double lat_save = prp->m_lat;
2096 double lon_save = prp->m_lon;
2097
2098 prp->m_lat = pwaypoint->m_lat;
2099 prp->m_lon = pwaypoint->m_lon;
2100 prp->SetIconName(pwaypoint->IconName);
2101 prp->SetName(pwaypoint->m_MarkName);
2102 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
2103 prp->SetVisible(pwaypoint->IsVisible);
2104 if (pwaypoint->m_CreateTime.IsValid())
2105 prp->SetCreateTime(pwaypoint->m_CreateTime);
2106
2107 // Transcribe (clone) the html HyperLink List, if present
2108
2109 if (pwaypoint->m_HyperlinkList) {
2110 prp->m_HyperlinkList->clear();
2111 for (Plugin_Hyperlink* link : *pwaypoint->m_HyperlinkList) {
2112 Hyperlink* h = new Hyperlink();
2113 h->DescrText = link->DescrText;
2114 h->Link = link->Link;
2115 h->LType = link->Type;
2116 prp->m_HyperlinkList->push_back(h);
2117 }
2118 }
2119
2120 // Extended fields
2121 prp->SetWaypointRangeRingsNumber(pwaypoint->nrange_rings);
2122 prp->SetWaypointRangeRingsStep(pwaypoint->RangeRingSpace);
2123 prp->SetWaypointRangeRingsStepUnits(pwaypoint->RangeRingSpaceUnits);
2124 prp->SetWaypointRangeRingsColour(pwaypoint->RangeRingColor);
2125 prp->SetTideStation(pwaypoint->m_TideStation);
2126 prp->SetScaMin(pwaypoint->scamin);
2127 prp->SetUseSca(pwaypoint->b_useScamin);
2128 prp->SetNameShown(pwaypoint->IsNameVisible);
2129
2130 prp->SetShowWaypointRangeRings(pwaypoint->nrange_rings > 0);
2131
2132 if (prp) prp->ReLoadIcon();
2133
2134 auto canvas = gFrame->GetPrimaryCanvas();
2135 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
2136 canvas->GetScaleValue());
2137 SelectItem* pFind =
2138 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
2139 if (pFind) {
2140 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
2141 pFind->m_slon = pwaypoint->m_lon;
2142 }
2143
2144 if (!prp->m_btemp) {
2145 // pConfig->UpdateWayPoint(prp);
2146 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
2147 }
2148
2149 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2150 pRouteManagerDialog->UpdateWptListCtrl();
2151
2152 prp->SetPlannedSpeed(pwaypoint->m_PlannedSpeed);
2153 if (pwaypoint->m_ETD.IsValid())
2154 prp->SetETD(pwaypoint->m_ETD);
2155 else
2156 prp->SetETD(wxEmptyString);
2157 prp->SetWaypointArrivalRadius(pwaypoint->m_WaypointArrivalRadius);
2158 prp->SetShowWaypointRangeRings(pwaypoint->m_bShowWaypointRangeRings);
2159 prp->SetScaMax(pwaypoint->scamax);
2160 }
2161
2162 return b_found;
2163}
2164
2165std::unique_ptr<PlugIn_Waypoint_ExV2> GetWaypointExV2_Plugin(
2166 const wxString& GUID) {
2167 std::unique_ptr<PlugIn_Waypoint_ExV2> w(new PlugIn_Waypoint_ExV2);
2168 GetSingleWaypointExV2(GUID, w.get());
2169 return w;
2170}
2171
2172// PlugIn_Route_ExV2 utilities
2173
2174bool AddPlugInRouteExV2(PlugIn_Route_ExV2* proute, bool b_permanent) {
2175 Route* route = new Route();
2176
2177 PlugIn_Waypoint_ExV2* pwaypointex;
2178 RoutePoint *pWP, *pWP_src;
2179 int ip = 0;
2180 wxDateTime plannedDeparture;
2181
2182 Plugin_WaypointExV2List::compatibility_iterator pwpnode =
2183 proute->pWaypointList->GetFirst();
2184 while (pwpnode) {
2185 pwaypointex = pwpnode->GetData();
2186
2187 pWP = pWayPointMan->FindRoutePointByGUID(pwaypointex->m_GUID);
2188 if (!pWP) {
2189 pWP = CreateNewPoint(pwaypointex, b_permanent);
2190 pWP->m_bIsolatedMark = false;
2191 }
2192
2193 route->AddPoint(pWP);
2194
2195 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2196
2197 if (ip > 0)
2198 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
2199 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
2200 route);
2201
2202 plannedDeparture = pwaypointex->m_CreateTime;
2203 ip++;
2204 pWP_src = pWP;
2205
2206 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
2207 }
2208
2209 route->m_PlannedDeparture = plannedDeparture;
2210
2211 route->m_RouteNameString = proute->m_NameString;
2212 route->m_RouteStartString = proute->m_StartString;
2213 route->m_RouteEndString = proute->m_EndString;
2214 if (!proute->m_GUID.IsEmpty()) {
2215 route->m_GUID = proute->m_GUID;
2216 }
2217 route->m_btemp = (b_permanent == false);
2218 route->SetVisible(proute->m_isVisible);
2219 route->m_RouteDescription = proute->m_Description;
2220
2221 pRouteList->push_back(route);
2222
2223 if (b_permanent) {
2224 // pConfig->AddNewRoute(route);
2225 NavObj_dB::GetInstance().InsertRoute(route);
2226 }
2227
2228 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2229 pRouteManagerDialog->UpdateRouteListCtrl();
2230
2231 return true;
2232}
2233
2235 bool b_found = false;
2236
2237 // Find the Route
2238 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
2239 if (pRoute) b_found = true;
2240
2241 if (b_found) {
2242 bool b_permanent = !pRoute->m_btemp;
2243 g_pRouteMan->DeleteRoute(pRoute);
2244
2245 b_found = AddPlugInRouteExV2(proute, b_permanent);
2246 }
2247
2248 return b_found;
2249}
2250
2251std::unique_ptr<PlugIn_Route_ExV2> GetRouteExV2_Plugin(const wxString& GUID) {
2252 std::unique_ptr<PlugIn_Route_ExV2> r;
2253 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
2254 if (route == nullptr) return r;
2255
2256 r = std::unique_ptr<PlugIn_Route_ExV2>(new PlugIn_Route_ExV2);
2257 PlugIn_Route_ExV2* dst_route = r.get();
2258
2259 for (RoutePoint* src_wp : *route->pRoutePointList) {
2261 PlugInExV2FromRoutePoint(dst_wp, src_wp);
2262 dst_route->pWaypointList->Append(dst_wp);
2263 }
2264 dst_route->m_NameString = route->m_RouteNameString;
2265 dst_route->m_StartString = route->m_RouteStartString;
2266 dst_route->m_EndString = route->m_RouteEndString;
2267 dst_route->m_GUID = route->m_GUID;
2268 dst_route->m_isActive = g_pRouteMan->GetpActiveRoute() == route;
2269 dst_route->m_isVisible = route->IsVisible();
2270 dst_route->m_Description = route->m_RouteDescription;
2271
2272 return r;
2273}
2274
2275// PlugInRouteExtended implementation
2276PlugIn_Route_Ex::PlugIn_Route_Ex() {
2277 pWaypointList = new Plugin_WaypointExList;
2278}
2279
2280PlugIn_Route_Ex::~PlugIn_Route_Ex() {
2281 pWaypointList->DeleteContents(false); // do not delete Waypoints
2282 pWaypointList->Clear();
2283
2284 delete pWaypointList;
2285}
2286
2287// The utility methods implementations
2288
2289// translate O route class to PlugIn_Waypoint_Ex
2290static void PlugInExFromRoutePoint(PlugIn_Waypoint_Ex* dst,
2291 /* const*/ RoutePoint* src) {
2292 dst->m_lat = src->m_lat;
2293 dst->m_lon = src->m_lon;
2294 dst->IconName = src->GetIconName();
2295 dst->m_MarkName = src->GetName();
2296 dst->m_MarkDescription = src->GetDescription();
2297 dst->IconDescription = pWayPointMan->GetIconDescription(src->GetIconName());
2298 dst->IsVisible = src->IsVisible();
2299 dst->m_CreateTime = src->GetCreateTime(); // not const
2300 dst->m_GUID = src->m_GUID;
2301
2302 // Transcribe (clone) the html HyperLink List, if present
2303 if (src->m_HyperlinkList) {
2304 delete dst->m_HyperlinkList;
2305 dst->m_HyperlinkList = nullptr;
2306
2307 if (src->m_HyperlinkList->size() > 0) {
2308 dst->m_HyperlinkList = new Plugin_HyperlinkList;
2309 for (Hyperlink* link : *src->m_HyperlinkList) {
2311 h->DescrText = link->DescrText;
2312 h->Link = link->Link;
2313 h->Type = link->LType;
2314 dst->m_HyperlinkList->Append(h);
2315 }
2316 }
2317 }
2318
2319 // Get the range ring info
2323
2324 // Get other extended info
2325 dst->IsNameVisible = src->m_bShowName;
2326 dst->scamin = src->GetScaMin();
2327 dst->b_useScamin = src->GetUseSca();
2328 dst->IsActive = src->m_bIsActive;
2329}
2330
2331static void cloneHyperlinkListEx(RoutePoint* dst,
2332 const PlugIn_Waypoint_Ex* src) {
2333 // Transcribe (clone) the html HyperLink List, if present
2334 if (src->m_HyperlinkList == nullptr) return;
2335
2336 if (src->m_HyperlinkList->GetCount() > 0) {
2337 Plugin_HyperlinkList::compatibility_iterator linknode =
2338 src->m_HyperlinkList->GetFirst();
2339 while (linknode) {
2340 Plugin_Hyperlink* link = linknode->GetData();
2341
2342 Hyperlink* h = new Hyperlink();
2343 h->DescrText = link->DescrText;
2344 h->Link = link->Link;
2345 h->LType = link->Type;
2346
2347 dst->m_HyperlinkList->push_back(h);
2348
2349 linknode = linknode->GetNext();
2350 }
2351 }
2352}
2353
2354RoutePoint* CreateNewPoint(const PlugIn_Waypoint_Ex* src, bool b_permanent) {
2355 RoutePoint* pWP = new RoutePoint(src->m_lat, src->m_lon, src->IconName,
2356 src->m_MarkName, src->m_GUID);
2357
2358 pWP->m_bIsolatedMark = true; // This is an isolated mark
2359
2360 cloneHyperlinkListEx(pWP, src);
2361
2363
2364 if (src->m_CreateTime.IsValid())
2365 pWP->SetCreateTime(src->m_CreateTime);
2366 else {
2367 pWP->SetCreateTime(wxDateTime::Now().ToUTC());
2368 }
2369
2370 pWP->m_btemp = (b_permanent == false);
2371
2372 // Extended fields
2373 pWP->SetIconName(src->IconName);
2374 pWP->SetWaypointRangeRingsNumber(src->nrange_rings);
2375 pWP->SetWaypointRangeRingsStep(src->RangeRingSpace);
2376 pWP->SetWaypointRangeRingsColour(src->RangeRingColor);
2377 pWP->SetScaMin(src->scamin);
2378 pWP->SetUseSca(src->b_useScamin);
2379 pWP->SetNameShown(src->IsNameVisible);
2380 pWP->SetVisible(src->IsVisible);
2381
2382 return pWP;
2383}
2384bool GetSingleWaypointEx(wxString GUID, PlugIn_Waypoint_Ex* pwaypoint) {
2385 // Find the RoutePoint
2386 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
2387
2388 if (!prp) return false;
2389
2390 PlugInExFromRoutePoint(pwaypoint, prp);
2391
2392 return true;
2393}
2394
2395bool AddSingleWaypointEx(PlugIn_Waypoint_Ex* pwaypointex, bool b_permanent) {
2396 // Validate the waypoint parameters a little bit
2397
2398 // GUID
2399 // Make sure that this GUID is indeed unique in the Routepoint list
2400 bool b_unique = true;
2401 for (RoutePoint* prp : *pWayPointMan->GetWaypointList()) {
2402 if (prp->m_GUID == pwaypointex->m_GUID) {
2403 b_unique = false;
2404 break;
2405 }
2406 }
2407
2408 if (!b_unique) return false;
2409
2410 RoutePoint* pWP = CreateNewPoint(pwaypointex, b_permanent);
2411
2412 pWP->SetShowWaypointRangeRings(pwaypointex->nrange_rings > 0);
2413
2414 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2415 if (b_permanent) {
2416 // pConfig->AddNewWayPoint(pWP, -1);
2417 NavObj_dB::GetInstance().InsertRoutePoint(pWP);
2418 }
2419 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2420 pRouteManagerDialog->UpdateWptListCtrl();
2421
2422 return true;
2423}
2424
2426 // Find the RoutePoint
2427 bool b_found = false;
2428 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
2429
2430 if (prp) b_found = true;
2431
2432 if (b_found) {
2433 double lat_save = prp->m_lat;
2434 double lon_save = prp->m_lon;
2435
2436 prp->m_lat = pwaypoint->m_lat;
2437 prp->m_lon = pwaypoint->m_lon;
2438 prp->SetIconName(pwaypoint->IconName);
2439 prp->SetName(pwaypoint->m_MarkName);
2440 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
2441 prp->SetVisible(pwaypoint->IsVisible);
2442 if (pwaypoint->m_CreateTime.IsValid())
2443 prp->SetCreateTime(pwaypoint->m_CreateTime);
2444
2445 // Transcribe (clone) the html HyperLink List, if present
2446
2447 if (pwaypoint->m_HyperlinkList) {
2448 prp->m_HyperlinkList->clear();
2449 if (pwaypoint->m_HyperlinkList->GetCount() > 0) {
2450 Plugin_HyperlinkList::compatibility_iterator linknode =
2451 pwaypoint->m_HyperlinkList->GetFirst();
2452 while (linknode) {
2453 Plugin_Hyperlink* link = linknode->GetData();
2454
2455 Hyperlink* h = new Hyperlink();
2456 h->DescrText = link->DescrText;
2457 h->Link = link->Link;
2458 h->LType = link->Type;
2459
2460 prp->m_HyperlinkList->push_back(h);
2461
2462 linknode = linknode->GetNext();
2463 }
2464 }
2465 }
2466
2467 // Extended fields
2468 prp->SetWaypointRangeRingsNumber(pwaypoint->nrange_rings);
2469 prp->SetWaypointRangeRingsStep(pwaypoint->RangeRingSpace);
2470 prp->SetWaypointRangeRingsColour(pwaypoint->RangeRingColor);
2471 prp->SetScaMin(pwaypoint->scamin);
2472 prp->SetUseSca(pwaypoint->b_useScamin);
2473 prp->SetNameShown(pwaypoint->IsNameVisible);
2474
2475 prp->SetShowWaypointRangeRings(pwaypoint->nrange_rings > 0);
2476
2477 if (prp) prp->ReLoadIcon();
2478
2479 auto canvas = gFrame->GetPrimaryCanvas();
2480 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
2481 canvas->GetScaleValue());
2482 SelectItem* pFind =
2483 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
2484 if (pFind) {
2485 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
2486 pFind->m_slon = pwaypoint->m_lon;
2487 }
2488
2489 if (!prp->m_btemp) {
2490 // pConfig->UpdateWayPoint(prp);
2491 NavObj_dB::GetInstance().UpdateRoutePoint(prp);
2492 }
2493
2494 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2495 pRouteManagerDialog->UpdateWptListCtrl();
2496 }
2497
2498 return b_found;
2499}
2500
2501bool AddPlugInRouteEx(PlugIn_Route_Ex* proute, bool b_permanent) {
2502 Route* route = new Route();
2503
2504 PlugIn_Waypoint_Ex* pwaypointex;
2505 RoutePoint *pWP, *pWP_src;
2506 int ip = 0;
2507 wxDateTime plannedDeparture;
2508
2509 Plugin_WaypointExList::compatibility_iterator pwpnode =
2510 proute->pWaypointList->GetFirst();
2511 while (pwpnode) {
2512 pwaypointex = pwpnode->GetData();
2513
2514 pWP = pWayPointMan->FindRoutePointByGUID(pwaypointex->m_GUID);
2515 if (!pWP) {
2516 pWP = CreateNewPoint(pwaypointex, b_permanent);
2517 pWP->m_bIsolatedMark = false;
2518 }
2519
2520 route->AddPoint(pWP);
2521
2522 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2523
2524 if (ip > 0)
2525 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
2526 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
2527 route);
2528
2529 plannedDeparture = pwaypointex->m_CreateTime;
2530 ip++;
2531 pWP_src = pWP;
2532
2533 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
2534 }
2535
2536 route->m_PlannedDeparture = plannedDeparture;
2537
2538 route->m_RouteNameString = proute->m_NameString;
2539 route->m_RouteStartString = proute->m_StartString;
2540 route->m_RouteEndString = proute->m_EndString;
2541 if (!proute->m_GUID.IsEmpty()) {
2542 route->m_GUID = proute->m_GUID;
2543 }
2544 route->m_btemp = (b_permanent == false);
2545 route->SetVisible(proute->m_isVisible);
2546 route->m_RouteDescription = proute->m_Description;
2547
2548 pRouteList->push_back(route);
2549
2550 if (b_permanent) {
2551 // pConfig->AddNewRoute(route);
2552 NavObj_dB::GetInstance().InsertRoute(route);
2553 }
2554
2555 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2556 pRouteManagerDialog->UpdateRouteListCtrl();
2557
2558 return true;
2559}
2560
2562 bool b_found = false;
2563
2564 // Find the Route
2565 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
2566 if (pRoute) b_found = true;
2567
2568 if (b_found) {
2569 bool b_permanent = !pRoute->m_btemp;
2570 g_pRouteMan->DeleteRoute(pRoute);
2571 b_found = AddPlugInRouteEx(proute, b_permanent);
2572 }
2573
2574 return b_found;
2575}
2576
2577std::unique_ptr<PlugIn_Waypoint_Ex> GetWaypointEx_Plugin(const wxString& GUID) {
2578 std::unique_ptr<PlugIn_Waypoint_Ex> w(new PlugIn_Waypoint_Ex);
2579 GetSingleWaypointEx(GUID, w.get());
2580 return w;
2581}
2582
2583std::unique_ptr<PlugIn_Route_Ex> GetRouteEx_Plugin(const wxString& GUID) {
2584 std::unique_ptr<PlugIn_Route_Ex> r;
2585 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
2586 if (route == nullptr) return r;
2587
2588 r = std::unique_ptr<PlugIn_Route_Ex>(new PlugIn_Route_Ex);
2589 PlugIn_Route_Ex* dst_route = r.get();
2590
2591 // PlugIn_Waypoint *pwp;
2592 RoutePoint* src_wp;
2593 for (RoutePoint* src_wp : *route->pRoutePointList) {
2594 PlugIn_Waypoint_Ex* dst_wp = new PlugIn_Waypoint_Ex();
2595 PlugInExFromRoutePoint(dst_wp, src_wp);
2596
2597 dst_route->pWaypointList->Append(dst_wp);
2598 }
2599 dst_route->m_NameString = route->m_RouteNameString;
2600 dst_route->m_StartString = route->m_RouteStartString;
2601 dst_route->m_EndString = route->m_RouteEndString;
2602 dst_route->m_GUID = route->m_GUID;
2603 dst_route->m_isActive = g_pRouteMan->GetpActiveRoute() == route;
2604 dst_route->m_isVisible = route->IsVisible();
2605 dst_route->m_Description = route->m_RouteDescription;
2606
2607 return r;
2608}
2609
2611 void) { // if no active waypoint, returns wxEmptyString
2612 RoutePoint* rp = g_pRouteMan->GetpActivePoint();
2613 if (!rp)
2614 return wxEmptyString;
2615 else
2616 return rp->m_GUID;
2617}
2618
2620 void) { // if no active route, returns wxEmptyString
2621 Route* rt = g_pRouteMan->GetpActiveRoute();
2622 if (!rt)
2623 return wxEmptyString;
2624 else
2625 return rt->m_GUID;
2626}
2627
2629int GetGlobalWatchdogTimoutSeconds() { return gps_watchdog_timeout_ticks; }
2630
2632std::vector<std::string> GetPriorityMaps() {
2633 return (CommBridge::GetInstance().GetPriorityMaps());
2634}
2635
2636void UpdateAndApplyPriorityMaps(std::vector<std::string> map) {
2637 CommBridge::GetInstance().UpdateAndApplyMaps(map);
2638}
2639
2640std::vector<std::string> GetActivePriorityIdentifiers() {
2641 std::vector<std::string> result;
2642
2643 auto& comm_bridge = CommBridge::GetInstance();
2644
2645 std::string id = comm_bridge.GetPriorityContainer("position").active_source;
2646 result.push_back(id);
2647 id = comm_bridge.GetPriorityContainer("velocity").active_source;
2648 result.push_back(id);
2649 id = comm_bridge.GetPriorityContainer("heading").active_source;
2650 result.push_back(id);
2651 id = comm_bridge.GetPriorityContainer("variation").active_source;
2652 result.push_back(id);
2653 id = comm_bridge.GetPriorityContainer("satellites").active_source;
2654 result.push_back(id);
2655
2656 return result;
2657}
2658
2660 double rv = 1.0;
2661#if defined(__WXOSX__) || defined(__WXGTK3__)
2662 // Support scaled HDPI displays.
2663 if (gFrame) rv = gFrame->GetContentScaleFactor();
2664#endif
2665 return rv;
2666}
2668 double scaler = 1.0;
2669#ifdef __WXMSW__
2670 if (gFrame) scaler = (double)(gFrame->ToDIP(100)) / 100.;
2671#endif
2672 return scaler;
2673}
2674
2675//---------------------------------------------------------------------------
2676// API 1.18
2677//---------------------------------------------------------------------------
2678
2679//---------------------------------------------------------------------------
2680// API 1.19
2681//---------------------------------------------------------------------------
2682void ExitOCPN() {}
2683
2684bool GetFullScreen() { return gFrame->IsFullScreen(); }
2685
2686void SetFullScreen(bool set_full_screen_on) {
2687 bool state = gFrame->IsFullScreen();
2688 if (set_full_screen_on && !state)
2689 gFrame->ToggleFullScreen();
2690 else if (!set_full_screen_on && state)
2691 gFrame->ToggleFullScreen();
2692}
2693
2694extern bool g_useMUI;
2695void EnableMUIBar(bool enable, int CanvasIndex) {
2696 bool current_mui_state = g_useMUI;
2697
2698 g_useMUI = enable;
2699 if (enable && !current_mui_state) { // OFF going ON
2700 // ..For each canvas...
2701 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2702 ChartCanvas* cc = g_canvasArray.Item(i);
2703 if (cc) cc->CreateMUIBar();
2704 }
2705 } else if (!enable && current_mui_state) { // ON going OFF
2706 // ..For each canvas...
2707 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2708 ChartCanvas* cc = g_canvasArray.Item(i);
2709 if (cc) cc->DestroyMuiBar();
2710 }
2711 }
2712}
2713
2714bool GetEnableMUIBar(int CanvasIndex) { return g_useMUI; }
2715
2716void EnableCompassGPSIcon(bool enable, int CanvasIndex) {
2717 g_bShowCompassWin = enable;
2718}
2719
2720bool GetEnableCompassGPSIcon(int CanvasIndex) {
2721 if (CanvasIndex < GetCanvasCount()) {
2722 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2723 if (cc)
2724 return cc->GetShowGPSCompassWindow();
2725 else
2726 return false;
2727 }
2728 return false;
2729}
2730
2731extern bool g_bShowStatusBar;
2732void EnableStatusBar(bool enable) {
2733 g_bShowStatusBar = enable;
2734 gFrame->ConfigureStatusBar();
2735}
2736
2737bool GetEnableStatusBar() { return g_bShowStatusBar; }
2738
2739void EnableChartBar(bool enable, int CanvasIndex) {
2740 bool current_chartbar_state = g_bShowChartBar;
2741 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2742 ChartCanvas* cc = g_canvasArray.Item(i);
2743 if (current_chartbar_state && !enable) {
2744 gFrame->ToggleChartBar(cc);
2745 g_bShowChartBar = current_chartbar_state;
2746 } else if (!current_chartbar_state && enable) {
2747 gFrame->ToggleChartBar(cc);
2748 g_bShowChartBar = current_chartbar_state;
2749 }
2750 }
2751 g_bShowChartBar = enable;
2752}
2753
2754bool GetEnableChartBar(int CanvasIndex) { return g_bShowChartBar; }
2755
2756extern bool g_bShowMenuBar;
2757void EnableMenu(bool enable) {
2758 if (!enable) {
2759 if (g_bShowMenuBar) {
2760 g_bShowMenuBar = false;
2761 if (gFrame->m_pMenuBar) {
2762 gFrame->SetMenuBar(NULL);
2763 gFrame->m_pMenuBar->Destroy();
2764 gFrame->m_pMenuBar = NULL;
2765 }
2766 }
2767 } else {
2768 g_bShowMenuBar = true;
2769 gFrame->BuildMenuBar();
2770 }
2771}
2772
2773bool GetEnableMenu() { return g_bShowMenuBar; }
2774
2775void SetGlobalColor(std::string table, std::string name, wxColor color) {
2776 if (ps52plib) ps52plib->m_chartSymbols.UpdateTableColor(table, name, color);
2777}
2778
2779wxColor GetGlobalColorD(std::string map_name, std::string name) {
2780 wxColor ret = wxColor(*wxRED);
2781 if (ps52plib) {
2782 int i_table = ps52plib->m_chartSymbols.FindColorTable(map_name.c_str());
2783 ret = ps52plib->m_chartSymbols.GetwxColor(name.c_str(), i_table);
2784 }
2785 return ret;
2786}
2787
2788void EnableLatLonGrid(bool enable, int CanvasIndex) {
2789 if (CanvasIndex < GetCanvasCount()) {
2790 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2791 if (cc) cc->SetShowGrid(enable);
2792 }
2793}
2794
2795void EnableChartOutlines(bool enable, int CanvasIndex) {
2796 if (CanvasIndex < GetCanvasCount()) {
2797 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2798 if (cc) cc->SetShowOutlines(enable);
2799 }
2800}
2801
2802void EnableDepthUnitDisplay(bool enable, int CanvasIndex) {
2803 if (CanvasIndex < GetCanvasCount()) {
2804 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2805 if (cc) cc->SetShowDepthUnits(enable);
2806 }
2807}
2808
2809void EnableAisTargetDisplay(bool enable, int CanvasIndex) {
2810 if (CanvasIndex < GetCanvasCount()) {
2811 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2812 if (cc) cc->SetShowAIS(enable);
2813 }
2814}
2815
2816void EnableTideStationsDisplay(bool enable, int CanvasIndex) {
2817 if (CanvasIndex < GetCanvasCount()) {
2818 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2819 if (cc) cc->ShowTides(enable);
2820 }
2821}
2822
2823void EnableCurrentStationsDisplay(bool enable, int CanvasIndex) {
2824 if (CanvasIndex < GetCanvasCount()) {
2825 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2826 if (cc) cc->ShowCurrents(enable);
2827 }
2828}
2829
2830void EnableENCTextDisplay(bool enable, int CanvasIndex) {
2831 if (CanvasIndex < GetCanvasCount()) {
2832 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2833 if (cc) cc->SetShowENCText(enable);
2834 }
2835}
2836
2837void EnableENCDepthSoundingsDisplay(bool enable, int CanvasIndex) {
2838 if (CanvasIndex < GetCanvasCount()) {
2839 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2840 if (cc) cc->SetShowENCDepth(enable);
2841 }
2842}
2843
2844void EnableBuoyLightLabelsDisplay(bool enable, int CanvasIndex) {
2845 if (CanvasIndex < GetCanvasCount()) {
2846 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2847 if (cc) cc->SetShowENCBuoyLabels(enable);
2848 }
2849}
2850
2851void EnableLightsDisplay(bool enable, int CanvasIndex) {
2852 if (CanvasIndex < GetCanvasCount()) {
2853 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2854 if (cc) cc->SetShowENCLights(enable);
2855 }
2856}
2857
2858void EnableLightDescriptionsDisplay(bool enable, int CanvasIndex) {
2859 if (CanvasIndex < GetCanvasCount()) {
2860 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2861 if (cc) cc->SetShowENCLightDesc(enable);
2862 }
2863}
2864
2865void SetENCDisplayCategory(PI_DisCat cat, int CanvasIndex) {
2866 int valSet = STANDARD;
2867 switch (cat) {
2868 case PI_DISPLAYBASE:
2869 valSet = DISPLAYBASE;
2870 break;
2871 case PI_STANDARD:
2872 valSet = STANDARD;
2873 break;
2874 case PI_OTHER:
2875 valSet = OTHER;
2876 break;
2878 valSet = MARINERS_STANDARD;
2879 break;
2880 default:
2881 valSet = STANDARD;
2882 break;
2883 }
2884 if (CanvasIndex < GetCanvasCount()) {
2885 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2886 if (cc) cc->SetENCDisplayCategory(valSet);
2887 }
2888}
2890 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2891 if (cc)
2892 return ((PI_DisCat)cc->GetENCDisplayCategory());
2893 else
2894 return PI_DisCat::PI_STANDARD;
2895}
2896
2897void SetNavigationMode(PI_NavMode mode, int CanvasIndex) {
2898 int newMode = NORTH_UP_MODE;
2899 if (mode == PI_COURSE_UP_MODE)
2900 newMode = COURSE_UP_MODE;
2901 else if (mode == PI_HEAD_UP_MODE)
2902 newMode = HEAD_UP_MODE;
2903
2904 if (CanvasIndex < GetCanvasCount()) {
2905 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2906 if (cc) cc->SetUpMode(newMode);
2907 }
2908}
2910 if (CanvasIndex < GetCanvasCount()) {
2911 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2912 if (cc) return ((PI_NavMode)cc->GetUpMode());
2913 }
2914 return PI_NavMode::PI_NORTH_UP_MODE;
2915}
2916
2917bool GetEnableLatLonGrid(int CanvasIndex) {
2918 if (CanvasIndex < GetCanvasCount()) {
2919 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2920 if (cc) return (cc->GetShowGrid());
2921 }
2922 return false;
2923}
2924
2925bool GetEnableChartOutlines(int CanvasIndex) {
2926 if (CanvasIndex < GetCanvasCount()) {
2927 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2928 if (cc) return (cc->GetShowOutlines());
2929 }
2930 return false;
2931}
2932
2933bool GetEnableDepthUnitDisplay(int CanvasIndex) {
2934 if (CanvasIndex < GetCanvasCount()) {
2935 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2936 if (cc) return (cc->GetShowDepthUnits());
2937 }
2938 return false;
2939}
2940
2941bool GetEnableAisTargetDisplay(int CanvasIndex) {
2942 if (CanvasIndex < GetCanvasCount()) {
2943 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2944 if (cc) return (cc->GetShowAIS());
2945 }
2946 return false;
2947}
2948
2949bool GetEnableTideStationsDisplay(int CanvasIndex) {
2950 if (CanvasIndex < GetCanvasCount()) {
2951 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2952 if (cc) return (cc->GetbShowTide());
2953 }
2954 return false;
2955}
2956
2957bool GetEnableCurrentStationsDisplay(int CanvasIndex) {
2958 if (CanvasIndex < GetCanvasCount()) {
2959 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2960 if (cc) return (cc->GetbShowCurrent());
2961 }
2962 return false;
2963}
2964
2965bool GetEnableENCTextDisplay(int CanvasIndex) {
2966 if (CanvasIndex < GetCanvasCount()) {
2967 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2968 if (cc) return (cc->GetShowENCText());
2969 }
2970 return false;
2971}
2972
2974 if (CanvasIndex < GetCanvasCount()) {
2975 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2976 if (cc) return (cc->GetShowENCDepth());
2977 }
2978 return false;
2979}
2980
2981bool GetEnableBuoyLightLabelsDisplay(int CanvasIndex) {
2982 if (CanvasIndex < GetCanvasCount()) {
2983 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2984 if (cc) return (cc->GetShowENCBuoyLabels());
2985 }
2986 return false;
2987}
2988
2989bool GetEnableLightsDisplay(int CanvasIndex) {
2990 if (CanvasIndex < GetCanvasCount()) {
2991 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2992 if (cc) return (cc->GetShowENCLights());
2993 }
2994 return false;
2995}
2996
2997bool GetShowENCLightDesc(int CanvasIndex) {
2998 if (CanvasIndex < GetCanvasCount()) {
2999 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3000 if (cc) return (cc->GetbShowCurrent());
3001 }
3002 return false;
3003}
3004
3005void EnableTouchMode(bool enable) { g_btouch = enable; }
3006
3007bool GetTouchMode() { return g_btouch; }
3008
3009void EnableLookaheadMode(bool enable, int CanvasIndex) {
3010 if (CanvasIndex < GetCanvasCount()) {
3011 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3012 if (cc) cc->ToggleLookahead();
3013 }
3014}
3015
3016bool GetEnableLookaheadMode(int CanvasIndex) {
3017 if (CanvasIndex < GetCanvasCount()) {
3018 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3019 if (cc) return (cc->GetLookahead());
3020 }
3021 return false;
3022}
3023
3024extern bool g_bTrackActive;
3025void SetTrackingMode(bool enable) {
3026 if (!g_bTrackActive && enable)
3027 gFrame->TrackOn();
3028 else if (g_bTrackActive && !enable)
3029 gFrame->TrackOff();
3030}
3031bool GetTrackingMode() { return g_bTrackActive; }
3032
3034 gFrame->SetAndApplyColorScheme((ColorScheme)cs);
3035}
3037 return (PI_ColorScheme)global_color_scheme;
3038}
3039
3040void RequestWindowRefresh(wxWindow* win, bool eraseBackground) {
3041 if (win) win->Refresh(eraseBackground);
3042}
3043
3044void EnableSplitScreenLayout(bool enable) {
3045 if (g_canvasConfig == 1) {
3046 if (enable)
3047 return;
3048 else { // split to single
3049 g_canvasConfig = 0; // 0 => "single canvas"
3050 gFrame->CreateCanvasLayout();
3051 gFrame->DoChartUpdate();
3052 }
3053 } else {
3054 if (enable) { // single to split
3055 g_canvasConfig = 1; // 1 => "two canvas"
3056 gFrame->CreateCanvasLayout();
3057 gFrame->DoChartUpdate();
3058 } else {
3059 return;
3060 }
3061 }
3062}
3063
3064// ChartCanvas control utilities
3065
3066void PluginZoomCanvas(int CanvasIndex, double factor) {
3067 if (CanvasIndex < GetCanvasCount()) {
3068 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3069 if (cc) cc->ZoomCanvasSimple(factor);
3070 }
3071}
3072
3073bool GetEnableMainToolbar() { return (!g_disable_main_toolbar); }
3074void SetEnableMainToolbar(bool enable) {
3075 g_disable_main_toolbar = !enable;
3076 if (g_MainToolbar) g_MainToolbar->RefreshToolbar();
3077}
3078
3080 if (gFrame) gFrame->ScheduleSettingsDialog();
3081}
3082
3083void PluginCenterOwnship(int CanvasIndex) {
3084 if (CanvasIndex < GetCanvasCount()) {
3085 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3086 if (cc) {
3087 bool bfollow = cc->GetbFollow();
3088 cc->ResetOwnshipOffset();
3089 if (bfollow)
3090 cc->SetbFollow();
3091 else
3092 cc->JumpToPosition(gLat, gLon, cc->GetVPScale());
3093 }
3094 }
3095}
3096
3097void PluginSetFollowMode(int CanvasIndex, bool enable_follow) {
3098 if (CanvasIndex < GetCanvasCount()) {
3099 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3100 if (cc) {
3101 if (cc->GetbFollow() != enable_follow) cc->TogglebFollow();
3102 }
3103 }
3104}
3105
3106bool PluginGetFollowMode(int CanvasIndex) {
3107 if (CanvasIndex < GetCanvasCount()) {
3108 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3109 if (cc) return cc->GetbFollow();
3110 }
3111 return false;
3112}
3113
3114void EnableCanvasFocusBar(bool enable, int CanvasIndex) {
3115 if (CanvasIndex < GetCanvasCount()) {
3116 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3117 if (cc) cc->SetShowFocusBar(enable);
3118 }
3119}
3120bool GetEnableCanvasFocusBar(int CanvasIndex) {
3121 if (CanvasIndex < GetCanvasCount()) {
3122 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
3123 if (cc) return (cc->GetShowFocusBar());
3124 }
3125 return false;
3126}
3127
3128bool GetEnableTenHertzUpdate() { return g_btenhertz; }
3129
3130void EnableTenHertzUpdate(bool enable) { g_btenhertz = enable; }
3131
3133 if (pConfig) {
3134 // Store current locale to detect changes
3135 wxString oldLocale = g_locale;
3136 pConfig->Flush();
3137
3138 // Handle system general configuration options
3139 pConfig->LoadMyConfigRaw(false);
3140
3141 // Handle S57 configuration options
3142 pConfig->LoadS57Config();
3143
3144 // Handle chart canvas window configuration options
3145 pConfig->LoadCanvasConfigs(false);
3146 auto& config_array = ConfigMgr::Get().GetCanvasConfigArray();
3147 for (auto pcc : config_array) {
3148 if (pcc && pcc->canvas) {
3149 pcc->canvas->ApplyCanvasConfig(pcc);
3150 pcc->canvas->Refresh();
3151 }
3152 }
3153
3154#if wxUSE_XLOCALE
3155 // Detect and apply locale changes
3156 if (g_locale != oldLocale && !g_locale.IsEmpty()) {
3157 wxLogMessage("ConfigFlushAndReload: Locale changed, applying...");
3158 g_Platform->ChangeLocale(g_locale, plocale_def_lang, &plocale_def_lang);
3159 ApplyLocale(); // Deactivates/reactivates plugins, rebuilds UI
3160 }
3161#endif
3162 }
3163}
3164
3169 g_CanvasHideNotificationIcon = !enable;
3170}
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
arrayofCanvasPtr g_canvasArray
Global instance.
Definition chcanv.cpp:173
ChartCanvas * g_overlayCanvas
Global instance.
Definition chcanv.cpp:1315
Generic Chart canvas base.
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:174
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4688
float GetVPScale() override
Return ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:184
Manages the chart database and provides access to chart data.
Definition chartdb.h:95
Wrapper class for plugin-based charts.
Definition chartimg.h:389
static wxString GetUUID(void)
Return a unique RFC4122 version 4 compliant GUID string.
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.).
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
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:139
void SetCreateTime(wxDateTime dt)
Sets the creation timestamp for a track point.
Definition track.cpp:145
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.
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:97
Recorded track abstraction.
WaypointMan drawing stuff.