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