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
73extern PlugInManager* s_ppim;
74extern MyConfig* pConfig;
75extern OCPN_AUIManager* g_pauimgr;
76
77#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
78extern wxLocale* plocale_def_lang;
79#endif
80
81extern OCPNPlatform* g_Platform;
82extern ChartDB* ChartData;
83extern MyFrame* gFrame;
84extern ocpnStyle::StyleManager* g_StyleManager;
85extern options* g_pOptions;
86extern Multiplexer* g_pMUX;
87extern bool g_bShowChartBar;
88extern Routeman* g_pRouteMan;
89extern Select* pSelect;
90extern RouteManagerDialog* pRouteManagerDialog;
91extern RouteList* pRouteList;
92extern std::vector<Track*> g_TrackList;
93extern PlugInManager* g_pi_manager;
94extern s52plib* ps52plib;
95extern wxString ChartListFileName;
96extern options* g_options;
97extern ColorScheme global_color_scheme;
98extern wxArrayString g_locale_catalog_array;
99extern int g_GUIScaleFactor;
100extern int g_ChartScaleFactor;
101extern wxString g_locale;
102extern ocpnFloatingToolbarDialog* g_MainToolbar;
103
104extern int g_chart_zoom_modifier_raster;
105extern int g_chart_zoom_modifier_vector;
106extern double g_display_size_mm;
107extern bool g_bopengl;
108extern AisDecoder* g_pAIS;
109extern ChartGroupArray* g_pGroupArray;
110extern ShapeBaseChartSet gShapeBasemap;
111
112// extern ChartGroupArray* g_pGroupArray;
113extern unsigned int g_canvasConfig;
114
115extern wxString g_CmdSoundString;
116
117unsigned int gs_plib_flags;
118extern ChartCanvas* g_focusCanvas;
119extern ChartCanvas* g_overlayCanvas;
120extern bool g_bquiting;
121extern bool g_disable_main_toolbar;
122extern bool g_btenhertz;
123extern bool g_CanvasHideNotificationIcon;
124
125WX_DEFINE_ARRAY_PTR(ChartCanvas*, arrayofCanvasPtr);
126extern arrayofCanvasPtr g_canvasArray;
127
128void NotifySetupOptionsPlugin(const PlugInData* pic);
129
130//---------------------------------------------------------------------------
131/* Implementation of OCPN core functions callable by plugins
132 * Sorted by API version number
133 * The definitions of this API are found in ocpn_plugin.h
134 * PlugIns may call these static functions as necessary for system services
135 */
136//---------------------------------------------------------------------------
137
138//---------------------------------------------------------------------------
139// API 1.6
140//---------------------------------------------------------------------------
141/* Main Toolbar support */
142int InsertPlugInTool(wxString label, wxBitmap* bitmap, wxBitmap* bmpRollover,
143 wxItemKind kind, wxString shortHelp, wxString longHelp,
144 wxObject* clientData, int position, int tool_sel,
145 opencpn_plugin* pplugin) {
146 if (s_ppim)
147 return s_ppim->AddToolbarTool(label, bitmap, bmpRollover, kind, shortHelp,
148 longHelp, clientData, position, tool_sel,
149 pplugin);
150 else
151 return -1;
152}
153
154void RemovePlugInTool(int tool_id) {
155 if (s_ppim) s_ppim->RemoveToolbarTool(tool_id);
156}
157
158void SetToolbarToolViz(int item, bool viz) {
159 if (s_ppim) s_ppim->SetToolbarToolViz(item, viz);
160}
161
162void SetToolbarItemState(int item, bool toggle) {
163 if (s_ppim) s_ppim->SetToolbarItemState(item, toggle);
164}
165
166void SetToolbarToolBitmaps(int item, wxBitmap* bitmap, wxBitmap* bmpRollover) {
167 if (s_ppim) s_ppim->SetToolbarItemBitmaps(item, bitmap, bmpRollover);
168}
169
170int InsertPlugInToolSVG(wxString label, wxString SVGfile,
171 wxString SVGfileRollover, wxString SVGfileToggled,
172 wxItemKind kind, wxString shortHelp, wxString longHelp,
173 wxObject* clientData, int position, int tool_sel,
174 opencpn_plugin* pplugin) {
175 if (s_ppim)
176 return s_ppim->AddToolbarTool(label, SVGfile, SVGfileRollover,
177 SVGfileToggled, kind, shortHelp, longHelp,
178 clientData, position, tool_sel, pplugin);
179 else
180 return -1;
181}
182
183void SetToolbarToolBitmapsSVG(int item, wxString SVGfile,
184 wxString SVGfileRollover,
185 wxString SVGfileToggled) {
186 if (s_ppim)
187 s_ppim->SetToolbarItemBitmaps(item, SVGfile, SVGfileRollover,
188 SVGfileToggled);
189}
190
191/* Canvas Context Menu support */
192int AddCanvasMenuItem(wxMenuItem* pitem, opencpn_plugin* pplugin,
193 const char* name) {
194 if (s_ppim)
195 return s_ppim->AddCanvasContextMenuItem(pitem, pplugin, name);
196 else
197 return -1;
198}
199
200void SetCanvasMenuItemViz(int item, bool viz, const char* name) {
201 if (s_ppim) s_ppim->SetCanvasContextMenuItemViz(item, viz, name);
202}
203
204void SetCanvasMenuItemGrey(int item, bool grey, const char* name) {
205 if (s_ppim) s_ppim->SetCanvasContextMenuItemGrey(item, grey, name);
206}
207
208void RemoveCanvasMenuItem(int item, const char* name) {
209 if (s_ppim) s_ppim->RemoveCanvasContextMenuItem(item, name);
210}
211
212int AddCanvasContextMenuItem(wxMenuItem* pitem, opencpn_plugin* pplugin) {
213 /* main context popup menu */
214 return AddCanvasMenuItem(pitem, pplugin, "");
215}
216
217void SetCanvasContextMenuItemViz(int item, bool viz) {
218 SetCanvasMenuItemViz(item, viz);
219}
220
221void SetCanvasContextMenuItemGrey(int item, bool grey) {
222 SetCanvasMenuItemGrey(item, grey);
223}
224
226
227/* Utility functions */
228wxFileConfig* GetOCPNConfigObject(void) {
229 if (s_ppim)
230 return reinterpret_cast<wxFileConfig*>(
231 pConfig); // return the global application config object
232 else
233 return NULL;
234}
235
237 wxWindow* pret = NULL;
238 if (s_ppim) {
239 MyFrame* pFrame = s_ppim->GetParentFrame();
240 pret = (wxWindow*)pFrame->GetPrimaryCanvas();
241 }
242 return pret;
243}
244
245void RequestRefresh(wxWindow* win) {
246 if (win) win->Refresh(true);
247}
248
249void GetCanvasPixLL(PlugIn_ViewPort* vp, wxPoint* pp, double lat, double lon) {
250 // Make enough of an application viewport to run its method....
251 ViewPort ocpn_vp;
252 ocpn_vp.clat = vp->clat;
253 ocpn_vp.clon = vp->clon;
254 ocpn_vp.m_projection_type = vp->m_projection_type;
255 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
256 ocpn_vp.skew = vp->skew;
257 ocpn_vp.rotation = vp->rotation;
258 ocpn_vp.pix_width = vp->pix_width;
259 ocpn_vp.pix_height = vp->pix_height;
260
261 wxPoint ret = ocpn_vp.GetPixFromLL(lat, lon);
262 pp->x = ret.x;
263 pp->y = ret.y;
264}
265
266void GetDoubleCanvasPixLL(PlugIn_ViewPort* vp, wxPoint2DDouble* pp, double lat,
267 double lon) {
268 // Make enough of an application viewport to run its method....
269 ViewPort ocpn_vp;
270 ocpn_vp.clat = vp->clat;
271 ocpn_vp.clon = vp->clon;
272 ocpn_vp.m_projection_type = vp->m_projection_type;
273 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
274 ocpn_vp.skew = vp->skew;
275 ocpn_vp.rotation = vp->rotation;
276 ocpn_vp.pix_width = vp->pix_width;
277 ocpn_vp.pix_height = vp->pix_height;
278
279 *pp = ocpn_vp.GetDoublePixFromLL(lat, lon);
280}
281
282void GetCanvasLLPix(PlugIn_ViewPort* vp, wxPoint p, double* plat,
283 double* plon) {
284 // Make enough of an application viewport to run its method....
285 ViewPort ocpn_vp;
286 ocpn_vp.clat = vp->clat;
287 ocpn_vp.clon = vp->clon;
288 ocpn_vp.m_projection_type = vp->m_projection_type;
289 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
290 ocpn_vp.skew = vp->skew;
291 ocpn_vp.rotation = vp->rotation;
292 ocpn_vp.pix_width = vp->pix_width;
293 ocpn_vp.pix_height = vp->pix_height;
294
295 return ocpn_vp.GetLLFromPix(p, plat, plon);
296}
297
298bool GetGlobalColor(wxString colorName, wxColour* pcolour) {
299 wxColour c = GetGlobalColor(colorName);
300 *pcolour = c;
301
302 return true;
303}
304
305wxFont* OCPNGetFont(wxString TextElement, int default_size) {
306 return FontMgr::Get().GetFont(TextElement, default_size);
307}
308
309wxFont* GetOCPNScaledFont_PlugIn(wxString TextElement, int default_size) {
310 return GetOCPNScaledFont(TextElement, default_size);
311}
312
313double GetOCPNGUIToolScaleFactor_PlugIn(int GUIScaleFactor) {
314 return g_Platform->GetToolbarScaleFactor(GUIScaleFactor);
315}
316
318 return g_Platform->GetToolbarScaleFactor(g_GUIScaleFactor);
319}
320
322 return g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor);
323}
324
325wxFont GetOCPNGUIScaledFont_PlugIn(wxString item) {
326 return GetOCPNGUIScaledFont(item);
327}
328
329bool AddPersistentFontKey(wxString TextElement) {
330 return FontMgr::Get().AddAuxKey(TextElement);
331}
332
334 if (g_StyleManager)
335 return g_StyleManager->GetCurrentStyle()->name;
336 else
337 return _T("");
338}
339
340wxBitmap GetBitmapFromSVGFile(wxString filename, unsigned int width,
341 unsigned int height) {
342 wxBitmap bmp = LoadSVG(filename, width, height);
343
344 if (bmp.IsOk())
345 return bmp;
346 else {
347 // On error in requested width/height parameters,
348 // try to find and use dimensions embedded in the SVG file
349 unsigned int w, h;
350 SVGDocumentPixelSize(filename, w, h);
351 if (w == 0 || h == 0) {
352 // We did not succeed in deducing the size from SVG (svg element
353 // x misses width, height or both attributes), let's use some "safe"
354 // default
355 w = 32;
356 h = 32;
357 }
358 return LoadSVG(filename, w, h);
359 }
360}
361
362bool IsTouchInterface_PlugIn(void) { return g_btouch; }
363
364wxColour GetFontColour_PlugIn(wxString TextElement) {
365 return FontMgr::Get().GetFontColor(TextElement);
366}
367
368wxString* GetpSharedDataLocation(void) {
369 return g_Platform->GetSharedDataDirPtr();
370}
371
372ArrayOfPlugIn_AIS_Targets* GetAISTargetArray(void) {
373 if (!g_pAIS) return NULL;
374
375 ArrayOfPlugIn_AIS_Targets* pret = new ArrayOfPlugIn_AIS_Targets;
376
377 // Iterate over the AIS Target Hashmap
378 for (const auto& it : g_pAIS->GetTargetList()) {
379 auto td = it.second;
380 PlugIn_AIS_Target* ptarget = Create_PI_AIS_Target(td.get());
381 pret->Add(ptarget);
382 }
383
384// Test one alarm target
385#if 0
386 AisTargetData td;
387 td.n_alarm_state = AIS_ALARM_SET;
388 PlugIn_AIS_Target *ptarget = Create_PI_AIS_Target(&td);
389 pret->Add(ptarget);
390#endif
391 return pret;
392}
393
394wxAuiManager* GetFrameAuiManager(void) { return g_pauimgr; }
395
396void SendPluginMessage(wxString message_id, wxString message_body) {
397 SendMessageToAllPlugins(message_id, message_body);
398
399 // We will send an event to the main application frame (gFrame)
400 // for informational purposes.
401 // Of course, gFrame is encouraged to use any or all the
402 // data flying by if judged useful and dependable....
403
404 OCPN_MsgEvent Nevent(wxEVT_OCPN_MSG, 0);
405 Nevent.SetID(message_id);
406 Nevent.SetJSONText(message_body);
407 gFrame->GetEventHandler()->AddPendingEvent(Nevent);
408}
409
410void DimeWindow(wxWindow* win) { DimeControl(win); }
411
412void JumpToPosition(double lat, double lon, double scale) {
413 gFrame->JumpToPosition(gFrame->GetFocusCanvas(), lat, lon, scale);
414}
415
416/* Locale (i18N) support */
417bool AddLocaleCatalog(wxString catalog) {
418#if wxUSE_XLOCALE || !wxCHECK_VERSION(3, 0, 0)
419
420 if (plocale_def_lang) {
421 // Add this catalog to the persistent catalog array
422 g_locale_catalog_array.Add(catalog);
423
424 return plocale_def_lang->AddCatalog(catalog);
425 } else
426#endif
427 return false;
428}
429
430wxString GetLocaleCanonicalName() { return g_locale; }
431
432/* NMEA interface support */
433void PushNMEABuffer(wxString buf) {
434 std::string full_sentence = buf.ToStdString();
435
436 if ((full_sentence[0] == '$') || (full_sentence[0] == '!')) { // Sanity check
437 std::string identifier;
438 // We notify based on full message, including the Talker ID
439 identifier = full_sentence.substr(1, 5);
440
441 // notify message listener and also "ALL" N0183 messages, to support plugin
442 // API using original talker id
443 auto address = std::make_shared<NavAddr0183>("virtual");
444 auto msg =
445 std::make_shared<const Nmea0183Msg>(identifier, full_sentence, address);
446 auto msg_all = std::make_shared<const Nmea0183Msg>(*msg, "ALL");
447
448 auto& msgbus = NavMsgBus::GetInstance();
449
450 msgbus.Notify(std::move(msg));
451 msgbus.Notify(std::move(msg_all));
452 }
453}
454
455/* Chart database access support */
456wxXmlDocument GetChartDatabaseEntryXML(int dbIndex, bool b_getGeom) {
457 wxXmlDocument doc = ChartData->GetXMLDescription(dbIndex, b_getGeom);
458
459 return doc;
460}
461
462bool UpdateChartDBInplace(wxArrayString dir_array, bool b_force_update,
463 bool b_ProgressDialog) {
464 // Make an array of CDI
465 ArrayOfCDI ChartDirArray;
466 for (unsigned int i = 0; i < dir_array.GetCount(); i++) {
467 wxString dirname = dir_array[i];
468 ChartDirInfo cdi;
469 cdi.fullpath = dirname;
470 cdi.magic_number = _T("");
471 ChartDirArray.Add(cdi);
472 }
473 bool b_ret = gFrame->UpdateChartDatabaseInplace(ChartDirArray, b_force_update,
474 b_ProgressDialog,
475 ChartData->GetDBFileName());
476 gFrame->ChartsRefresh();
477 return b_ret;
478}
479
481 return ChartData->GetChartDirArrayString();
482}
483
484int AddChartToDBInPlace(wxString& full_path, bool b_RefreshCanvas) {
485 // extract the path from the chart name
486 wxFileName fn(full_path);
487 wxString fdir = fn.GetPath();
488
489 bool bret = false;
490 if (ChartData) {
491 bret = ChartData->AddSingleChart(full_path);
492
493 if (bret) {
494 // Save to disk
495 pConfig->UpdateChartDirs(ChartData->GetChartDirArray());
496 ChartData->SaveBinary(ChartListFileName);
497
498 // Completely reload the chart database, for a fresh start
499 ArrayOfCDI XnewChartDirArray;
500 pConfig->LoadChartDirArray(XnewChartDirArray);
501 delete ChartData;
502 ChartData = new ChartDB();
503 ChartData->LoadBinary(ChartListFileName, XnewChartDirArray);
504
505 // Update group contents
506 if (g_pGroupArray) ChartData->ApplyGroupArray(g_pGroupArray);
507
508 if (g_options && g_options->IsShown())
509 g_options->UpdateDisplayedChartDirList(ChartData->GetChartDirArray());
510
511 if (b_RefreshCanvas || !gFrame->GetPrimaryCanvas()->GetQuiltMode()) {
512 gFrame->ChartsRefresh();
513 }
514 }
515 }
516 return bret;
517}
518
519int RemoveChartFromDBInPlace(wxString& full_path) {
520 bool bret = false;
521 if (ChartData) {
522 bret = ChartData->RemoveSingleChart(full_path);
523
524 // Save to disk
525 pConfig->UpdateChartDirs(ChartData->GetChartDirArray());
526 ChartData->SaveBinary(ChartListFileName);
527
528 // Completely reload the chart database, for a fresh start
529 ArrayOfCDI XnewChartDirArray;
530 pConfig->LoadChartDirArray(XnewChartDirArray);
531 delete ChartData;
532 ChartData = new ChartDB();
533 ChartData->LoadBinary(ChartListFileName, XnewChartDirArray);
534
535 // Update group contents
536 if (g_pGroupArray) ChartData->ApplyGroupArray(g_pGroupArray);
537
538 if (g_options && g_options->IsShown())
539 g_options->UpdateDisplayedChartDirList(ChartData->GetChartDirArray());
540
541 gFrame->ChartsRefresh();
542 }
543
544 return bret;
545}
546
547//---------------------------------------------------------------------------
548// API 1.9
549//---------------------------------------------------------------------------
550wxScrolledWindow* AddOptionsPage(OptionsParentPI parent, wxString title) {
551 if (!g_pOptions) return NULL;
552
553 size_t parentid;
554 switch (parent) {
556 parentid = g_pOptions->m_pageDisplay;
557 break;
559 parentid = g_pOptions->m_pageConnections;
560 break;
562 parentid = g_pOptions->m_pageCharts;
563 break;
565 parentid = g_pOptions->m_pageShips;
566 break;
568 parentid = g_pOptions->m_pageUI;
569 break;
571 parentid = g_pOptions->m_pagePlugins;
572 break;
573 default:
574 wxLogMessage(
575 _T("Error in PluginManager::AddOptionsPage: Unknown parent"));
576 return NULL;
577 break;
578 }
579
580 return g_pOptions->AddPage(parentid, title);
581}
582
583bool DeleteOptionsPage(wxScrolledWindow* page) {
584 if (!g_pOptions) return false;
585 return g_pOptions->DeletePluginPage(page);
586}
587
588bool DecodeSingleVDOMessage(const wxString& str, PlugIn_Position_Fix_Ex* pos,
589 wxString* accumulator) {
590 if (!pos) return false;
591
592 GenericPosDatEx gpd;
593 AisError nerr = AIS_GENERIC_ERROR;
594 if (g_pAIS) nerr = g_pAIS->DecodeSingleVDO(str, &gpd, accumulator);
595 if (nerr == AIS_NoError) {
596 pos->Lat = gpd.kLat;
597 pos->Lon = gpd.kLon;
598 pos->Cog = gpd.kCog;
599 pos->Sog = gpd.kSog;
600 pos->Hdt = gpd.kHdt;
601
602 // Fill in the dummy values
603 pos->FixTime = 0;
604 pos->Hdm = 1000;
605 pos->Var = 1000;
606 pos->nSats = 0;
607
608 return true;
609 }
610
611 return false;
612}
613
615 int val = 0;
616 if (g_bShowChartBar) {
617 ChartCanvas* cc = gFrame->GetPrimaryCanvas();
618 if (cc && cc->GetPiano()) {
619 val = cc->GetPiano()->GetHeight();
620 }
621 }
622 return val;
623}
624
625bool GetRoutepointGPX(RoutePoint* pRoutePoint, char* buffer,
626 unsigned int buffer_length) {
627 bool ret = false;
628
630 pgpx->AddGPXWaypoint(pRoutePoint);
631 wxString gpxfilename = wxFileName::CreateTempFileName(wxT("gpx"));
632 pgpx->SaveFile(gpxfilename);
633 delete pgpx;
634
635 wxFFile gpxfile(gpxfilename);
636 wxString s;
637 if (gpxfile.ReadAll(&s)) {
638 if (s.Length() < buffer_length) {
639 strncpy(buffer, (const char*)s.mb_str(wxConvUTF8), buffer_length - 1);
640 ret = true;
641 }
642 }
643
644 gpxfile.Close();
645 ::wxRemoveFile(gpxfilename);
646
647 return ret;
648}
649
650bool GetActiveRoutepointGPX(char* buffer, unsigned int buffer_length) {
651 if (g_pRouteMan->IsAnyRouteActive())
652 return GetRoutepointGPX(g_pRouteMan->GetpActivePoint(), buffer,
653 buffer_length);
654 else
655 return false;
656}
657
658void PositionBearingDistanceMercator_Plugin(double lat, double lon, double brg,
659 double dist, double* dlat,
660 double* dlon) {
661 PositionBearingDistanceMercator(lat, lon, brg, dist, dlat, dlon);
662}
663
664void DistanceBearingMercator_Plugin(double lat0, double lon0, double lat1,
665 double lon1, double* brg, double* dist) {
666 DistanceBearingMercator(lat0, lon0, lat1, lon1, brg, dist);
667}
668
669double DistGreatCircle_Plugin(double slat, double slon, double dlat,
670 double dlon) {
671 return DistGreatCircle(slat, slon, dlat, dlon);
672}
673
674void toTM_Plugin(float lat, float lon, float lat0, float lon0, double* x,
675 double* y) {
676 toTM(lat, lon, lat0, lon0, x, y);
677}
678
679void fromTM_Plugin(double x, double y, double lat0, double lon0, double* lat,
680 double* lon) {
681 fromTM(x, y, lat0, lon0, lat, lon);
682}
683
684void toSM_Plugin(double lat, double lon, double lat0, double lon0, double* x,
685 double* y) {
686 toSM(lat, lon, lat0, lon0, x, y);
687}
688
689void fromSM_Plugin(double x, double y, double lat0, double lon0, double* lat,
690 double* lon) {
691 fromSM(x, y, lat0, lon0, lat, lon);
692}
693
694void toSM_ECC_Plugin(double lat, double lon, double lat0, double lon0,
695 double* x, double* y) {
696 toSM_ECC(lat, lon, lat0, lon0, x, y);
697}
698
699void fromSM_ECC_Plugin(double x, double y, double lat0, double lon0,
700 double* lat, double* lon) {
701 fromSM_ECC(x, y, lat0, lon0, lat, lon);
702}
703
704double toUsrDistance_Plugin(double nm_distance, int unit) {
705 return toUsrDistance(nm_distance, unit);
706}
707
708double fromUsrDistance_Plugin(double usr_distance, int unit) {
709 return fromUsrDistance(usr_distance, unit);
710}
711
712double toUsrSpeed_Plugin(double kts_speed, int unit) {
713 return toUsrSpeed(kts_speed, unit);
714}
715
716double toUsrWindSpeed_Plugin(double kts_speed, int unit) {
717 return toUsrWindSpeed(kts_speed, unit);
718}
719
720double fromUsrSpeed_Plugin(double usr_speed, int unit) {
721 return fromUsrSpeed(usr_speed, unit);
722}
723
724double fromUsrWindSpeed_Plugin(double usr_wspeed, int unit) {
725 return fromUsrWindSpeed(usr_wspeed, unit);
726}
727
728double toUsrTemp_Plugin(double cel_temp, int unit) {
729 return toUsrTemp(cel_temp, unit);
730}
731
732double fromUsrTemp_Plugin(double usr_temp, int unit) {
733 return fromUsrTemp(usr_temp, unit);
734}
735
737 return getUsrDistanceUnit(unit);
738}
739
740wxString getUsrSpeedUnit_Plugin(int unit) { return getUsrSpeedUnit(unit); }
741
743 return getUsrWindSpeedUnit(unit);
744}
745
746wxString getUsrTempUnit_Plugin(int unit) { return getUsrTempUnit(unit); }
747
748/*
749 * Depth Conversion Functions
750 */
751double toUsrDepth_Plugin(double m_depth, int unit) {
752 return toUsrDepth(m_depth, unit);
753}
754
755double fromUsrDepth_Plugin(double usr_depth, int unit) {
756 return fromUsrDepth(usr_depth, unit);
757}
758
759wxString getUsrDepthUnit_Plugin(int unit) { return getUsrDepthUnit(unit); }
760
761double fromDMM_PlugIn(wxString sdms) { return fromDMM(sdms); }
762
763bool PlugIn_GSHHS_CrossesLand(double lat1, double lon1, double lat2,
764 double lon2) {
765 // TODO: Enable call to gShapeBasemap.CrossesLand after fixing performance
766 // issues. if (gShapeBasemap.IsUsable()) {
767 // return gShapeBasemap.CrossesLand(lat1, lon1, lat2, lon2);
768 // } else {
769 // Fall back to the GSHHS data.
770 static bool loaded = false;
771 if (!loaded) {
772 gshhsCrossesLandInit();
773 loaded = true;
774 }
775 return gshhsCrossesLand(lat1, lon1, lat2, lon2);
776 //}
777}
778
779void PlugInPlaySound(wxString& sound_file) {
780 PlugInPlaySoundEx(sound_file, -1);
781}
782
783//---------------------------------------------------------------------------
784// API 1.10
785//---------------------------------------------------------------------------
786
787// API Route and Waypoint Support
789
790PlugIn_Waypoint::PlugIn_Waypoint(double lat, double lon,
791 const wxString& icon_ident,
792 const wxString& wp_name,
793 const wxString& GUID) {
794 wxDateTime now = wxDateTime::Now();
795 m_CreateTime = now.ToUTC();
796 m_HyperlinkList = NULL;
797
798 m_lat = lat;
799 m_lon = lon;
800 m_IconName = icon_ident;
801 m_MarkName = wp_name;
802 m_GUID = GUID;
803}
804
805PlugIn_Waypoint::~PlugIn_Waypoint() {}
806
807// PlugInRoute implementation
808PlugIn_Route::PlugIn_Route(void) { pWaypointList = new Plugin_WaypointList; }
809
810PlugIn_Route::~PlugIn_Route(void) {
811 pWaypointList->DeleteContents(false); // do not delete Waypoints
812 pWaypointList->Clear();
813
814 delete pWaypointList;
815}
816
817// PlugInTrack implementation
818PlugIn_Track::PlugIn_Track(void) { pWaypointList = new Plugin_WaypointList; }
819
820PlugIn_Track::~PlugIn_Track(void) {
821 pWaypointList->DeleteContents(false); // do not delete Waypoints
822 pWaypointList->Clear();
823
824 delete pWaypointList;
825}
826
827wxString GetNewGUID(void) { return GpxDocument::GetUUID(); }
828
829bool AddCustomWaypointIcon(wxBitmap* pimage, wxString key,
830 wxString description) {
831 wxImage image = pimage->ConvertToImage();
832 WayPointmanGui(*pWayPointMan).ProcessIcon(image, key, description);
833 return true;
834}
835
836static void cloneHyperlinkList(RoutePoint* dst, const PlugIn_Waypoint* src) {
837 // Transcribe (clone) the html HyperLink List, if present
838 if (src->m_HyperlinkList == nullptr) return;
839
840 if (src->m_HyperlinkList->GetCount() > 0) {
841 wxPlugin_HyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
842 while (linknode) {
843 Plugin_Hyperlink* link = linknode->GetData();
844
845 Hyperlink* h = new Hyperlink();
846 h->DescrText = link->DescrText;
847 h->Link = link->Link;
848 h->LType = link->Type;
849
850 dst->m_HyperlinkList->Append(h);
851
852 linknode = linknode->GetNext();
853 }
854 }
855}
856
857bool AddSingleWaypoint(PlugIn_Waypoint* pwaypoint, bool b_permanent) {
858 // Validate the waypoint parameters a little bit
859
860 // GUID
861 // Make sure that this GUID is indeed unique in the Routepoint list
862 bool b_unique = true;
863 wxRoutePointListNode* prpnode = pWayPointMan->GetWaypointList()->GetFirst();
864 while (prpnode) {
865 RoutePoint* prp = prpnode->GetData();
866
867 if (prp->m_GUID == pwaypoint->m_GUID) {
868 b_unique = false;
869 break;
870 }
871 prpnode = prpnode->GetNext(); // RoutePoint
872 }
873
874 if (!b_unique) return false;
875
876 RoutePoint* pWP =
877 new RoutePoint(pwaypoint->m_lat, pwaypoint->m_lon, pwaypoint->m_IconName,
878 pwaypoint->m_MarkName, pwaypoint->m_GUID);
879
880 pWP->m_bIsolatedMark = true; // This is an isolated mark
881
882 cloneHyperlinkList(pWP, pwaypoint);
883
884 pWP->m_MarkDescription = pwaypoint->m_MarkDescription;
885
886 if (pwaypoint->m_CreateTime.IsValid())
887 pWP->SetCreateTime(pwaypoint->m_CreateTime);
888 else {
889 wxDateTime dtnow(wxDateTime::Now());
890 pWP->SetCreateTime(dtnow);
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();
990 dst->m_MarkDescription = src->m_MarkDescription;
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);
1166 pWP->m_MarkDescription = pwp->m_MarkDescription;
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
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 RoutemanGui(*g_pRouteMan).DeleteTrack(pTrack);
1284 b_found = true;
1285 }
1286
1287 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
1288 pRouteManagerDialog->UpdateTrkListCtrl();
1289
1290 return b_found;
1291}
1292
1294 bool b_found = false;
1295
1296 // Find the Track
1297 Track* pTrack = g_pRouteMan->FindTrackByGUID(ptrack->m_GUID);
1298 if (pTrack) b_found = true;
1299
1300 if (b_found) {
1301 bool b_permanent = (pTrack->m_btemp == false);
1302 RoutemanGui(*g_pRouteMan).DeleteTrack(pTrack);
1303
1304 b_found = AddPlugInTrack(ptrack, b_permanent);
1305 }
1306
1307 return b_found;
1308}
1309
1311#ifdef ocpnUSE_GL
1312 ViewPort ocpn_vp;
1313 ocpn_vp.m_projection_type = vp->m_projection_type;
1314
1315 return glChartCanvas::HasNormalizedViewPort(ocpn_vp);
1316#else
1317 return false;
1318#endif
1319}
1320
1321void PlugInMultMatrixViewport(PlugIn_ViewPort* vp, float lat, float lon) {
1322#ifdef ocpnUSE_GL
1323 ViewPort ocpn_vp;
1324 ocpn_vp.clat = vp->clat;
1325 ocpn_vp.clon = vp->clon;
1326 ocpn_vp.m_projection_type = vp->m_projection_type;
1327 ocpn_vp.view_scale_ppm = vp->view_scale_ppm;
1328 ocpn_vp.skew = vp->skew;
1329 ocpn_vp.rotation = vp->rotation;
1330 ocpn_vp.pix_width = vp->pix_width;
1331 ocpn_vp.pix_height = vp->pix_height;
1332
1333// TODO fix for multicanvas glChartCanvas::MultMatrixViewPort(ocpn_vp, lat,
1334// lon);
1335#endif
1336}
1337
1338void PlugInNormalizeViewport(PlugIn_ViewPort* vp, float lat, float lon) {
1339#ifdef ocpnUSE_GL
1340 ViewPort ocpn_vp;
1341 glChartCanvas::NormalizedViewPort(ocpn_vp, lat, lon);
1342
1343 vp->clat = ocpn_vp.clat;
1344 vp->clon = ocpn_vp.clon;
1345 vp->view_scale_ppm = ocpn_vp.view_scale_ppm;
1346 vp->rotation = ocpn_vp.rotation;
1347 vp->skew = ocpn_vp.skew;
1348#endif
1349}
1350
1351// Helper and interface classes
1352
1353//-------------------------------------------------------------------------------
1354// PlugIn_AIS_Target Implementation
1355//-------------------------------------------------------------------------------
1356
1357PlugIn_AIS_Target* Create_PI_AIS_Target(AisTargetData* ptarget) {
1359
1360 pret->MMSI = ptarget->MMSI;
1361 pret->Class = ptarget->Class;
1362 pret->NavStatus = ptarget->NavStatus;
1363 pret->SOG = ptarget->SOG;
1364 pret->COG = ptarget->COG;
1365 pret->HDG = ptarget->HDG;
1366 pret->Lon = ptarget->Lon;
1367 pret->Lat = ptarget->Lat;
1368 pret->ROTAIS = ptarget->ROTAIS;
1369 pret->ShipType = ptarget->ShipType;
1370 pret->IMO = ptarget->IMO;
1371
1372 pret->Range_NM = ptarget->Range_NM;
1373 pret->Brg = ptarget->Brg;
1374
1375 // Per target collision parameters
1376 pret->bCPA_Valid = ptarget->bCPA_Valid;
1377 pret->TCPA = ptarget->TCPA; // Minutes
1378 pret->CPA = ptarget->CPA; // Nautical Miles
1379
1380 pret->alarm_state = (plugin_ais_alarm_type)ptarget->n_alert_state;
1381
1382 memcpy(pret->CallSign, ptarget->CallSign, sizeof(ptarget->CallSign) - 1);
1383 memcpy(pret->ShipName, ptarget->ShipName, sizeof(ptarget->ShipName) - 1);
1384
1385 return pret;
1386}
1387
1388//---------------------------------------------------------------------------
1389// API 1.11
1390//---------------------------------------------------------------------------
1391
1392//---------------------------------------------------------------------------
1393// API 1.12
1394//---------------------------------------------------------------------------
1395
1396//---------------------------------------------------------------------------
1397// API 1.13
1398//---------------------------------------------------------------------------
1399double fromDMM_Plugin(wxString sdms) { return fromDMM(sdms); }
1400
1401void SetCanvasRotation(double rotation) {
1402 gFrame->GetPrimaryCanvas()->DoRotateCanvas(rotation);
1403}
1404
1405double GetCanvasTilt() { return gFrame->GetPrimaryCanvas()->GetVPTilt(); }
1406
1407void SetCanvasTilt(double tilt) {
1408 gFrame->GetPrimaryCanvas()->DoTiltCanvas(tilt);
1409}
1410
1411void SetCanvasProjection(int projection) {
1412 gFrame->GetPrimaryCanvas()->SetVPProjection(projection);
1413}
1414
1415OcpnSound* g_PluginSound = SoundFactory();
1416static void onPlugInPlaySoundExFinished(void* ptr) {}
1417
1418// Start playing a sound to a given device and return status to plugin
1419bool PlugInPlaySoundEx(wxString& sound_file, int deviceIndex) {
1420 bool ok = g_PluginSound->Load(sound_file, deviceIndex);
1421 if (!ok) {
1422 wxLogWarning("Cannot load sound file: %s", sound_file);
1423 return false;
1424 }
1425 auto cmd_sound = dynamic_cast<SystemCmdSound*>(g_PluginSound);
1426 if (cmd_sound) cmd_sound->SetCmd(g_CmdSoundString.mb_str(wxConvUTF8));
1427
1428 g_PluginSound->SetFinishedCallback(onPlugInPlaySoundExFinished, NULL);
1429 ok = g_PluginSound->Play();
1430 if (!ok) {
1431 wxLogWarning("Cannot play sound file: %s", sound_file);
1432 }
1433 return ok;
1434}
1435
1436bool CheckEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta) {
1437 return gFrame->GetPrimaryCanvas()->CheckEdgePan(x, y, dragging, margin,
1438 delta);
1439}
1440
1441wxBitmap GetIcon_PlugIn(const wxString& name) {
1442 ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle();
1443 return style->GetIcon(name);
1444}
1445
1446void SetCursor_PlugIn(wxCursor* pCursor) {
1447 gFrame->GetPrimaryCanvas()->pPlugIn_Cursor = pCursor;
1448}
1449
1450void AddChartDirectory(wxString& path) {
1451 if (g_options) {
1452 g_options->AddChartDir(path);
1453 }
1454}
1455
1457 if (g_options) {
1458 g_options->pScanCheckBox->SetValue(true);
1459 g_options->pUpdateCheckBox->SetValue(true);
1460 }
1461}
1462
1464 if (g_options) {
1465 g_options->pUpdateCheckBox->SetValue(true);
1466 }
1467}
1468
1469wxDialog* GetActiveOptionsDialog() { return g_options; }
1470
1471int PlatformDirSelectorDialog(wxWindow* parent, wxString* file_spec,
1472 wxString Title, wxString initDir) {
1473 return g_Platform->DoDirSelectorDialog(parent, file_spec, Title, initDir);
1474}
1475
1476int PlatformFileSelectorDialog(wxWindow* parent, wxString* file_spec,
1477 wxString Title, wxString initDir,
1478 wxString suggestedName, wxString wildcard) {
1479 return g_Platform->DoFileSelectorDialog(parent, file_spec, Title, initDir,
1480 suggestedName, wildcard);
1481}
1482
1483//---------------------------------------------------------------------------
1484// API 1.14
1485//---------------------------------------------------------------------------
1486
1487ViewPort CreateCompatibleViewportEx(const PlugIn_ViewPort& pivp) {
1488 // Create a system ViewPort
1489 ViewPort vp;
1490
1491 vp.clat = pivp.clat; // center point
1492 vp.clon = pivp.clon;
1494 vp.skew = pivp.skew;
1495 vp.rotation = pivp.rotation;
1496 vp.chart_scale = pivp.chart_scale;
1497 vp.pix_width = pivp.pix_width;
1498 vp.pix_height = pivp.pix_height;
1499 vp.rv_rect = pivp.rv_rect;
1500 vp.b_quilt = pivp.b_quilt;
1501 vp.m_projection_type = pivp.m_projection_type;
1502
1503 if (gFrame->GetPrimaryCanvas())
1504 vp.ref_scale = gFrame->GetPrimaryCanvas()->GetVP().ref_scale;
1505 else
1506 vp.ref_scale = vp.chart_scale;
1507
1508 vp.SetBoxes();
1509 vp.Validate(); // This VP is valid
1510
1511 return vp;
1512}
1513
1514void PlugInAISDrawGL(wxGLCanvas* glcanvas, const PlugIn_ViewPort& vp) {
1515 ViewPort ocpn_vp = CreateCompatibleViewportEx(vp);
1516
1517 ocpnDC dc(*glcanvas);
1518 dc.SetVP(ocpn_vp);
1519
1520 AISDraw(dc, ocpn_vp, NULL);
1521}
1522
1523bool PlugInSetFontColor(const wxString TextElement, const wxColour color) {
1524 return FontMgr::Get().SetFontColor(TextElement, color);
1525}
1526
1527//---------------------------------------------------------------------------
1528// API 1.15
1529//---------------------------------------------------------------------------
1530
1531double PlugInGetDisplaySizeMM() { return g_Platform->GetDisplaySizeMM(); }
1532
1533wxFont* FindOrCreateFont_PlugIn(int point_size, wxFontFamily family,
1534 wxFontStyle style, wxFontWeight weight,
1535 bool underline, const wxString& facename,
1536 wxFontEncoding encoding) {
1537 return FontMgr::Get().FindOrCreateFont(point_size, family, style, weight,
1538 underline, facename, encoding);
1539}
1540
1541int PluginGetMinAvailableGshhgQuality() {
1542 return gFrame->GetPrimaryCanvas()->GetMinAvailableGshhgQuality();
1543}
1544int PluginGetMaxAvailableGshhgQuality() {
1545 return gFrame->GetPrimaryCanvas()->GetMaxAvailableGshhgQuality();
1546}
1547
1548// disable builtin console canvas, and autopilot nmea sentences
1550 g_bPluginHandleAutopilotRoute = enable;
1551}
1552
1553bool LaunchDefaultBrowser_Plugin(wxString url) {
1554 if (g_Platform) g_Platform->platformLaunchDefaultBrowser(url);
1555
1556 return true;
1557}
1558
1559//---------------------------------------------------------------------------
1560// API 1.16
1561//---------------------------------------------------------------------------
1563 ChartCanvas* cc = gFrame->GetFocusCanvas();
1564 if (cc && cc->GetSelectedRoutePoint()) {
1565 return cc->GetSelectedRoutePoint()->m_GUID;
1566 }
1567 return wxEmptyString;
1568}
1569
1571 ChartCanvas* cc = gFrame->GetFocusCanvas();
1572 if (cc && cc->GetSelectedRoute()) {
1573 return cc->GetSelectedRoute()->m_GUID;
1574 }
1575 return wxEmptyString;
1576}
1577
1579 ChartCanvas* cc = gFrame->GetFocusCanvas();
1580 if (cc && cc->GetSelectedTrack()) {
1581 return cc->GetSelectedTrack()->m_GUID;
1582 }
1583 return wxEmptyString;
1584}
1585
1586std::unique_ptr<PlugIn_Waypoint> GetWaypoint_Plugin(const wxString& GUID) {
1587 std::unique_ptr<PlugIn_Waypoint> w(new PlugIn_Waypoint);
1588 GetSingleWaypoint(GUID, w.get());
1589 return w;
1590}
1591
1592std::unique_ptr<PlugIn_Route> GetRoute_Plugin(const wxString& GUID) {
1593 std::unique_ptr<PlugIn_Route> r;
1594 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
1595 if (route == nullptr) return r;
1596
1597 r = std::unique_ptr<PlugIn_Route>(new PlugIn_Route);
1598 PlugIn_Route* dst_route = r.get();
1599
1600 // PlugIn_Waypoint *pwp;
1601 RoutePoint* src_wp;
1602 wxRoutePointListNode* node = route->pRoutePointList->GetFirst();
1603
1604 while (node) {
1605 src_wp = node->GetData();
1606
1607 PlugIn_Waypoint* dst_wp = new PlugIn_Waypoint();
1608 PlugInFromRoutePoint(dst_wp, src_wp);
1609
1610 dst_route->pWaypointList->Append(dst_wp);
1611
1612 node = node->GetNext();
1613 }
1614 dst_route->m_NameString = route->m_RouteNameString;
1615 dst_route->m_StartString = route->m_RouteStartString;
1616 dst_route->m_EndString = route->m_RouteEndString;
1617 dst_route->m_GUID = route->m_GUID;
1618
1619 return r;
1620}
1621
1622std::unique_ptr<PlugIn_Track> GetTrack_Plugin(const wxString& GUID) {
1623 std::unique_ptr<PlugIn_Track> t;
1624 // Find the Track
1625 Track* pTrack = g_pRouteMan->FindTrackByGUID(GUID);
1626 if (!pTrack) return t;
1627
1628 std::unique_ptr<PlugIn_Track> tk =
1629 std::unique_ptr<PlugIn_Track>(new PlugIn_Track);
1630 PlugIn_Track* dst_track = tk.get();
1631 dst_track->m_NameString = pTrack->GetName();
1632 dst_track->m_StartString = pTrack->m_TrackStartString;
1633 dst_track->m_EndString = pTrack->m_TrackEndString;
1634 dst_track->m_GUID = pTrack->m_GUID;
1635
1636 for (int i = 0; i < pTrack->GetnPoints(); i++) {
1637 TrackPoint* ptp = pTrack->GetPoint(i);
1638
1639 PlugIn_Waypoint* dst_wp = new PlugIn_Waypoint();
1640
1641 dst_wp->m_lat = ptp->m_lat;
1642 dst_wp->m_lon = ptp->m_lon;
1643 dst_wp->m_CreateTime = ptp->GetCreateTime(); // not const
1644
1645 dst_track->pWaypointList->Append(dst_wp);
1646 }
1647
1648 return tk;
1649}
1650
1651wxWindow* PluginGetFocusCanvas() { return g_focusCanvas; }
1652
1654 // if(g_overlayCanvas)
1655 return g_overlayCanvas;
1656 // else
1657}
1658
1659void CanvasJumpToPosition(wxWindow* canvas, double lat, double lon,
1660 double scale) {
1661 auto oCanvas = dynamic_cast<ChartCanvas*>(canvas);
1662 if (oCanvas) gFrame->JumpToPosition(oCanvas, lat, lon, scale);
1663}
1664
1665bool ShuttingDown(void) { return g_bquiting; }
1666
1667wxWindow* GetCanvasUnderMouse(void) { return gFrame->GetCanvasUnderMouse(); }
1668
1670 ChartCanvas* l_canvas = gFrame->GetCanvasUnderMouse();
1671 if (l_canvas) {
1672 for (unsigned int i = 0; i < g_canvasArray.GetCount(); ++i) {
1673 if (l_canvas == g_canvasArray[i]) return i;
1674 }
1675 }
1676 return 0;
1677}
1678
1679// std::vector<wxWindow *> GetCanvasArray()
1680// {
1681// std::vector<wxWindow *> rv;
1682// for(unsigned int i=0 ; i < g_canvasArray.GetCount() ; i++){
1683// ChartCanvas *cc = g_canvasArray.Item(i);
1684// rv.push_back(cc);
1685// }
1686//
1687// return rv;
1688// }
1689
1690wxWindow* GetCanvasByIndex(int canvasIndex) {
1691 if (g_canvasConfig == 0)
1692 return gFrame->GetPrimaryCanvas();
1693 else {
1694 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1695 return g_canvasArray[canvasIndex];
1696 }
1697 }
1698 return NULL;
1699}
1700
1701bool CheckMUIEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta,
1702 int canvasIndex) {
1703 if (g_canvasConfig == 0)
1704 return gFrame->GetPrimaryCanvas()->CheckEdgePan(x, y, dragging, margin,
1705 delta);
1706 else {
1707 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1708 return g_canvasArray[canvasIndex]->CheckEdgePan(x, y, dragging, margin,
1709 delta);
1710 }
1711 }
1712
1713 return false;
1714}
1715
1716void SetMUICursor_PlugIn(wxCursor* pCursor, int canvasIndex) {
1717 if (g_canvasConfig == 0)
1718 gFrame->GetPrimaryCanvas()->pPlugIn_Cursor = pCursor;
1719 else {
1720 if ((canvasIndex >= 0) && g_canvasArray[canvasIndex]) {
1721 g_canvasArray[canvasIndex]->pPlugIn_Cursor = pCursor;
1722 }
1723 }
1724}
1725
1727 if (g_canvasConfig == 1) return 2;
1728 // else
1729 return 1;
1730}
1731
1732int GetLatLonFormat() { return g_iSDMMFormat; }
1733
1735 if (g_MainToolbar)
1736 return g_MainToolbar->GetToolbarRect();
1737 else
1738 return wxRect(0, 0, 1, 1);
1739}
1740
1741//---------------------------------------------------------------------------
1742// API 1.17
1743//---------------------------------------------------------------------------
1744
1745void ZeroXTE() {
1746 if (g_pRouteMan) {
1747 g_pRouteMan->ZeroCurrentXTEToActivePoint();
1748 }
1749}
1750
1751static PlugIn_ViewPort CreatePlugInViewportEx(const ViewPort& vp) {
1752 // Create a PlugIn Viewport
1753 ViewPort tvp = vp;
1754 PlugIn_ViewPort pivp;
1755
1756 pivp.clat = tvp.clat; // center point
1757 pivp.clon = tvp.clon;
1758 pivp.view_scale_ppm = tvp.view_scale_ppm;
1759 pivp.skew = tvp.skew;
1760 pivp.rotation = tvp.rotation;
1761 pivp.chart_scale = tvp.chart_scale;
1762 pivp.pix_width = tvp.pix_width;
1763 pivp.pix_height = tvp.pix_height;
1764 pivp.rv_rect = tvp.rv_rect;
1765 pivp.b_quilt = tvp.b_quilt;
1766 pivp.m_projection_type = tvp.m_projection_type;
1767
1768 pivp.lat_min = tvp.GetBBox().GetMinLat();
1769 pivp.lat_max = tvp.GetBBox().GetMaxLat();
1770 pivp.lon_min = tvp.GetBBox().GetMinLon();
1771 pivp.lon_max = tvp.GetBBox().GetMaxLon();
1772
1773 pivp.bValid = tvp.IsValid(); // This VP is valid
1774
1775 return pivp;
1776}
1777
1778ListOfPI_S57Obj* PlugInManager::GetLightsObjRuleListVisibleAtLatLon(
1779 ChartPlugInWrapper* target, float zlat, float zlon, const ViewPort& vp) {
1780 ListOfPI_S57Obj* list = NULL;
1781 if (target) {
1782 PlugInChartBaseGLPlus2* picbgl =
1783 dynamic_cast<PlugInChartBaseGLPlus2*>(target->GetPlugInChart());
1784 if (picbgl) {
1785 PlugIn_ViewPort pi_vp = CreatePlugInViewportEx(vp);
1786 list = picbgl->GetLightsObjRuleListVisibleAtLatLon(zlat, zlon, &pi_vp);
1787
1788 return list;
1789 }
1791 dynamic_cast<PlugInChartBaseExtendedPlus2*>(target->GetPlugInChart());
1792 if (picbx) {
1793 PlugIn_ViewPort pi_vp = CreatePlugInViewportEx(vp);
1794 list = picbx->GetLightsObjRuleListVisibleAtLatLon(zlat, zlon, &pi_vp);
1795
1796 return list;
1797 } else
1798 return list;
1799 } else
1800 return list;
1801}
1802
1803// PlugInWaypointEx implementation
1804
1805#include <wx/listimpl.cpp>
1806WX_DEFINE_LIST(Plugin_WaypointExList)
1807
1808// The class implementations
1809PlugIn_Waypoint_Ex::PlugIn_Waypoint_Ex() { InitDefaults(); }
1810
1811PlugIn_Waypoint_Ex::PlugIn_Waypoint_Ex(
1812 double lat, double lon, const wxString& icon_ident, const wxString& wp_name,
1813 const wxString& GUID, const double ScaMin, const bool bNameVisible,
1814 const int nRangeRings, const double RangeDistance,
1815 const wxColor RangeColor) {
1816 InitDefaults();
1817
1818 wxDateTime now = wxDateTime::Now();
1819 m_CreateTime = now.ToUTC();
1820 m_HyperlinkList = NULL;
1821
1822 m_lat = lat;
1823 m_lon = lon;
1824 IconName = icon_ident;
1825 m_MarkName = wp_name;
1826 m_GUID = GUID;
1827 scamin = ScaMin;
1828 IsNameVisible = bNameVisible;
1829 nrange_rings = nRangeRings;
1830 RangeRingSpace = RangeDistance;
1831 RangeRingColor = RangeColor;
1832}
1833
1835 m_HyperlinkList = NULL;
1836 scamin = 1e9;
1837 b_useScamin = false;
1838 nrange_rings = 0;
1839 RangeRingSpace = 1;
1840 IsNameVisible = false;
1841 IsVisible = true;
1842 RangeRingColor = *wxBLACK;
1843 m_CreateTime = wxDateTime::Now();
1844 IsActive = false;
1845 m_lat = 0;
1846 m_lon = 0;
1847}
1848
1850 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(m_GUID);
1851 if (!prp) return false;
1852
1853 if (prp->m_bIsInRoute && !prp->IsShared()) return false;
1854
1855 return true;
1856}
1857
1859 // Search all routes to count the membership of this point
1860 RoutePoint* pWP = pWayPointMan->FindRoutePointByGUID(m_GUID);
1861 if (!pWP) return 0;
1862
1863 int nCount = 0;
1864 wxRouteListNode* node = pRouteList->GetFirst();
1865 while (node) {
1866 Route* proute = node->GetData();
1867 wxRoutePointListNode* pnode = (proute->pRoutePointList)->GetFirst();
1868 while (pnode) {
1869 RoutePoint* prp = pnode->GetData();
1870 if (prp == pWP) nCount++;
1871 pnode = pnode->GetNext();
1872 }
1873
1874 node = node->GetNext();
1875 }
1876
1877 return nCount;
1878}
1879
1880PlugIn_Waypoint_Ex::~PlugIn_Waypoint_Ex() {}
1881
1882// PlugInRouteExtended implementation
1883PlugIn_Route_Ex::PlugIn_Route_Ex(void) {
1884 pWaypointList = new Plugin_WaypointExList;
1885}
1886
1887PlugIn_Route_Ex::~PlugIn_Route_Ex(void) {
1888 pWaypointList->DeleteContents(false); // do not delete Waypoints
1889 pWaypointList->Clear();
1890
1891 delete pWaypointList;
1892}
1893
1894// The utility methods implementations
1895
1896// translate O route class to PlugIn_Waypoint_Ex
1897static void PlugInExFromRoutePoint(PlugIn_Waypoint_Ex* dst,
1898 /* const*/ RoutePoint* src) {
1899 dst->m_lat = src->m_lat;
1900 dst->m_lon = src->m_lon;
1901 dst->IconName = src->GetIconName();
1902 dst->m_MarkName = src->GetName();
1903 dst->m_MarkDescription = src->GetDescription();
1904 dst->IconDescription = pWayPointMan->GetIconDescription(src->GetIconName());
1905 dst->IsVisible = src->IsVisible();
1906 dst->m_CreateTime = src->GetCreateTime(); // not const
1907 dst->m_GUID = src->m_GUID;
1908
1909 // Transcribe (clone) the html HyperLink List, if present
1910 if (src->m_HyperlinkList == nullptr) return;
1911
1912 delete dst->m_HyperlinkList;
1913 dst->m_HyperlinkList = nullptr;
1914
1915 if (src->m_HyperlinkList->GetCount() > 0) {
1916 dst->m_HyperlinkList = new Plugin_HyperlinkList;
1917
1918 wxHyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
1919 while (linknode) {
1920 Hyperlink* link = linknode->GetData();
1921
1923 h->DescrText = link->DescrText;
1924 h->Link = link->Link;
1925 h->Type = link->LType;
1926
1927 dst->m_HyperlinkList->Append(h);
1928
1929 linknode = linknode->GetNext();
1930 }
1931 }
1932
1933 // Get the range ring info
1934 dst->nrange_rings = src->m_iWaypointRangeRingsNumber;
1935 dst->RangeRingSpace = src->m_fWaypointRangeRingsStep;
1936 dst->RangeRingColor = src->m_wxcWaypointRangeRingsColour;
1937
1938 // Get other extended info
1939 dst->IsNameVisible = src->m_bShowName;
1940 dst->scamin = src->GetScaMin();
1941 dst->b_useScamin = src->GetUseSca();
1942 dst->IsActive = src->m_bIsActive;
1943}
1944
1945static void cloneHyperlinkListEx(RoutePoint* dst,
1946 const PlugIn_Waypoint_Ex* src) {
1947 // Transcribe (clone) the html HyperLink List, if present
1948 if (src->m_HyperlinkList == nullptr) return;
1949
1950 if (src->m_HyperlinkList->GetCount() > 0) {
1951 wxPlugin_HyperlinkListNode* linknode = src->m_HyperlinkList->GetFirst();
1952 while (linknode) {
1953 Plugin_Hyperlink* link = linknode->GetData();
1954
1955 Hyperlink* h = new Hyperlink();
1956 h->DescrText = link->DescrText;
1957 h->Link = link->Link;
1958 h->LType = link->Type;
1959
1960 dst->m_HyperlinkList->Append(h);
1961
1962 linknode = linknode->GetNext();
1963 }
1964 }
1965}
1966
1967RoutePoint* CreateNewPoint(const PlugIn_Waypoint_Ex* src, bool b_permanent) {
1968 RoutePoint* pWP = new RoutePoint(src->m_lat, src->m_lon, src->IconName,
1969 src->m_MarkName, src->m_GUID);
1970
1971 pWP->m_bIsolatedMark = true; // This is an isolated mark
1972
1973 cloneHyperlinkListEx(pWP, src);
1974
1975 pWP->m_MarkDescription = src->m_MarkDescription;
1976
1977 if (src->m_CreateTime.IsValid())
1978 pWP->SetCreateTime(src->m_CreateTime);
1979 else {
1980 wxDateTime dtnow(wxDateTime::Now());
1981 pWP->SetCreateTime(dtnow);
1982 }
1983
1984 pWP->m_btemp = (b_permanent == false);
1985
1986 // Extended fields
1987 pWP->SetIconName(src->IconName);
1988 pWP->SetWaypointRangeRingsNumber(src->nrange_rings);
1989 pWP->SetWaypointRangeRingsStep(src->RangeRingSpace);
1990 pWP->SetWaypointRangeRingsColour(src->RangeRingColor);
1991 pWP->SetScaMin(src->scamin);
1992 pWP->SetUseSca(src->b_useScamin);
1993 pWP->SetNameShown(src->IsNameVisible);
1994 pWP->SetVisible(src->IsVisible);
1995
1996 return pWP;
1997}
1998bool GetSingleWaypointEx(wxString GUID, PlugIn_Waypoint_Ex* pwaypoint) {
1999 // Find the RoutePoint
2000 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(GUID);
2001
2002 if (!prp) return false;
2003
2004 PlugInExFromRoutePoint(pwaypoint, prp);
2005
2006 return true;
2007}
2008
2009bool AddSingleWaypointEx(PlugIn_Waypoint_Ex* pwaypointex, bool b_permanent) {
2010 // Validate the waypoint parameters a little bit
2011
2012 // GUID
2013 // Make sure that this GUID is indeed unique in the Routepoint list
2014 bool b_unique = true;
2015 wxRoutePointListNode* prpnode = pWayPointMan->GetWaypointList()->GetFirst();
2016 while (prpnode) {
2017 RoutePoint* prp = prpnode->GetData();
2018
2019 if (prp->m_GUID == pwaypointex->m_GUID) {
2020 b_unique = false;
2021 break;
2022 }
2023 prpnode = prpnode->GetNext(); // RoutePoint
2024 }
2025
2026 if (!b_unique) return false;
2027
2028 RoutePoint* pWP = CreateNewPoint(pwaypointex, b_permanent);
2029
2030 pWP->SetShowWaypointRangeRings(pwaypointex->nrange_rings > 0);
2031
2032 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2033 if (b_permanent) pConfig->AddNewWayPoint(pWP, -1);
2034
2035 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2036 pRouteManagerDialog->UpdateWptListCtrl();
2037
2038 return true;
2039}
2040
2042 // Find the RoutePoint
2043 bool b_found = false;
2044 RoutePoint* prp = pWayPointMan->FindRoutePointByGUID(pwaypoint->m_GUID);
2045
2046 if (prp) b_found = true;
2047
2048 if (b_found) {
2049 double lat_save = prp->m_lat;
2050 double lon_save = prp->m_lon;
2051
2052 prp->m_lat = pwaypoint->m_lat;
2053 prp->m_lon = pwaypoint->m_lon;
2054 prp->SetIconName(pwaypoint->IconName);
2055 prp->SetName(pwaypoint->m_MarkName);
2056 prp->m_MarkDescription = pwaypoint->m_MarkDescription;
2057 prp->SetVisible(pwaypoint->IsVisible);
2058 if (pwaypoint->m_CreateTime.IsValid())
2059 prp->SetCreateTime(pwaypoint->m_CreateTime);
2060
2061 // Transcribe (clone) the html HyperLink List, if present
2062
2063 if (pwaypoint->m_HyperlinkList) {
2064 prp->m_HyperlinkList->Clear();
2065 if (pwaypoint->m_HyperlinkList->GetCount() > 0) {
2066 wxPlugin_HyperlinkListNode* linknode =
2067 pwaypoint->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 prp->m_HyperlinkList->Append(h);
2077
2078 linknode = linknode->GetNext();
2079 }
2080 }
2081 }
2082
2083 // Extended fields
2084 prp->SetWaypointRangeRingsNumber(pwaypoint->nrange_rings);
2085 prp->SetWaypointRangeRingsStep(pwaypoint->RangeRingSpace);
2086 prp->SetWaypointRangeRingsColour(pwaypoint->RangeRingColor);
2087 prp->SetScaMin(pwaypoint->scamin);
2088 prp->SetUseSca(pwaypoint->b_useScamin);
2089 prp->SetNameShown(pwaypoint->IsNameVisible);
2090
2091 prp->SetShowWaypointRangeRings(pwaypoint->nrange_rings > 0);
2092
2093 if (prp) prp->ReLoadIcon();
2094
2095 auto canvas = gFrame->GetPrimaryCanvas();
2096 SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(),
2097 canvas->GetScaleValue());
2098 SelectItem* pFind =
2099 pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT);
2100 if (pFind) {
2101 pFind->m_slat = pwaypoint->m_lat; // update the SelectList entry
2102 pFind->m_slon = pwaypoint->m_lon;
2103 }
2104
2105 if (!prp->m_btemp) pConfig->UpdateWayPoint(prp);
2106
2107 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2108 pRouteManagerDialog->UpdateWptListCtrl();
2109 }
2110
2111 return b_found;
2112}
2113
2114bool AddPlugInRouteEx(PlugIn_Route_Ex* proute, bool b_permanent) {
2115 Route* route = new Route();
2116
2117 PlugIn_Waypoint_Ex* pwaypointex;
2118 RoutePoint *pWP, *pWP_src;
2119 int ip = 0;
2120 wxDateTime plannedDeparture;
2121
2122 wxPlugin_WaypointExListNode* pwpnode = proute->pWaypointList->GetFirst();
2123 while (pwpnode) {
2124 pwaypointex = pwpnode->GetData();
2125
2126 pWP = pWayPointMan->FindRoutePointByGUID(pwaypointex->m_GUID);
2127 if (!pWP) {
2128 pWP = CreateNewPoint(pwaypointex, b_permanent);
2129 pWP->m_bIsolatedMark = false;
2130 }
2131
2132 route->AddPoint(pWP);
2133
2134 pSelect->AddSelectableRoutePoint(pWP->m_lat, pWP->m_lon, pWP);
2135
2136 if (ip > 0)
2137 pSelect->AddSelectableRouteSegment(pWP_src->m_lat, pWP_src->m_lon,
2138 pWP->m_lat, pWP->m_lon, pWP_src, pWP,
2139 route);
2140
2141 plannedDeparture = pwaypointex->m_CreateTime;
2142 ip++;
2143 pWP_src = pWP;
2144
2145 pwpnode = pwpnode->GetNext(); // PlugInWaypoint
2146 }
2147
2148 route->m_PlannedDeparture = plannedDeparture;
2149
2150 route->m_RouteNameString = proute->m_NameString;
2151 route->m_RouteStartString = proute->m_StartString;
2152 route->m_RouteEndString = proute->m_EndString;
2153 if (!proute->m_GUID.IsEmpty()) {
2154 route->m_GUID = proute->m_GUID;
2155 }
2156 route->m_btemp = (b_permanent == false);
2157 route->SetVisible(proute->m_isVisible);
2158 route->m_RouteDescription = proute->m_Description;
2159
2160 pRouteList->Append(route);
2161
2162 if (b_permanent) pConfig->AddNewRoute(route);
2163
2164 if (pRouteManagerDialog && pRouteManagerDialog->IsShown())
2165 pRouteManagerDialog->UpdateRouteListCtrl();
2166
2167 return true;
2168}
2169
2171 bool b_found = false;
2172
2173 // Find the Route
2174 Route* pRoute = g_pRouteMan->FindRouteByGUID(proute->m_GUID);
2175 if (pRoute) b_found = true;
2176
2177 if (b_found) {
2178 bool b_permanent = !pRoute->m_btemp;
2179 g_pRouteMan->DeleteRoute(pRoute, NavObjectChanges::getInstance());
2180
2181 b_found = AddPlugInRouteEx(proute, b_permanent);
2182 }
2183
2184 return b_found;
2185}
2186
2187// std::unique_ptr<PlugIn_Waypoint_Ex> GetWaypointEx_Plugin(const wxString &)
2188// {
2189// }
2190
2191// std::unique_ptr<PlugIn_Route_Ex> GetRouteEx_Plugin(const wxString &)
2192// {
2193// }
2194
2195std::unique_ptr<PlugIn_Waypoint_Ex> GetWaypointEx_Plugin(const wxString& GUID) {
2196 std::unique_ptr<PlugIn_Waypoint_Ex> w(new PlugIn_Waypoint_Ex);
2197 GetSingleWaypointEx(GUID, w.get());
2198 return w;
2199}
2200
2201std::unique_ptr<PlugIn_Route_Ex> GetRouteEx_Plugin(const wxString& GUID) {
2202 std::unique_ptr<PlugIn_Route_Ex> r;
2203 Route* route = g_pRouteMan->FindRouteByGUID(GUID);
2204 if (route == nullptr) return r;
2205
2206 r = std::unique_ptr<PlugIn_Route_Ex>(new PlugIn_Route_Ex);
2207 PlugIn_Route_Ex* dst_route = r.get();
2208
2209 // PlugIn_Waypoint *pwp;
2210 RoutePoint* src_wp;
2211 wxRoutePointListNode* node = route->pRoutePointList->GetFirst();
2212
2213 while (node) {
2214 src_wp = node->GetData();
2215
2216 PlugIn_Waypoint_Ex* dst_wp = new PlugIn_Waypoint_Ex();
2217 PlugInExFromRoutePoint(dst_wp, src_wp);
2218
2219 dst_route->pWaypointList->Append(dst_wp);
2220
2221 node = node->GetNext();
2222 }
2223 dst_route->m_NameString = route->m_RouteNameString;
2224 dst_route->m_StartString = route->m_RouteStartString;
2225 dst_route->m_EndString = route->m_RouteEndString;
2226 dst_route->m_GUID = route->m_GUID;
2227 dst_route->m_isActive = g_pRouteMan->GetpActiveRoute() == route;
2228 dst_route->m_isVisible = route->IsVisible();
2229 dst_route->m_Description = route->m_RouteDescription;
2230
2231 return r;
2232}
2233
2235 void) { // if no active waypoint, returns wxEmptyString
2236 RoutePoint* rp = g_pRouteMan->GetpActivePoint();
2237 if (!rp)
2238 return wxEmptyString;
2239 else
2240 return rp->m_GUID;
2241}
2242
2244 void) { // if no active route, returns wxEmptyString
2245 Route* rt = g_pRouteMan->GetpActiveRoute();
2246 if (!rt)
2247 return wxEmptyString;
2248 else
2249 return rt->m_GUID;
2250}
2251
2253int GetGlobalWatchdogTimoutSeconds() { return gps_watchdog_timeout_ticks; }
2254
2256std::vector<std::string> GetPriorityMaps() {
2257 MyApp& app = wxGetApp();
2258 return (app.m_comm_bridge.GetPriorityMaps());
2259}
2260
2261std::vector<std::string> GetActivePriorityIdentifiers() {
2262 std::vector<std::string> result;
2263
2264 MyApp& app = wxGetApp();
2265
2266 std::string id =
2267 app.m_comm_bridge.GetPriorityContainer("position").active_source;
2268 result.push_back(id);
2269 id = app.m_comm_bridge.GetPriorityContainer("velocity").active_source;
2270 result.push_back(id);
2271 id = app.m_comm_bridge.GetPriorityContainer("heading").active_source;
2272 result.push_back(id);
2273 id = app.m_comm_bridge.GetPriorityContainer("variation").active_source;
2274 result.push_back(id);
2275 id = app.m_comm_bridge.GetPriorityContainer("satellites").active_source;
2276 result.push_back(id);
2277
2278 return result;
2279}
2280
2282 double rv = 1.0;
2283#if defined(__WXOSX__) || defined(__WXGTK3__)
2284 // Support scaled HDPI displays.
2285 if (gFrame) rv = gFrame->GetContentScaleFactor();
2286#endif
2287 return rv;
2288}
2290 double scaler = 1.0;
2291#ifdef __WXMSW__
2292 if (gFrame) scaler = (double)(gFrame->ToDIP(100)) / 100.;
2293#endif
2294 return scaler;
2295}
2296
2297//---------------------------------------------------------------------------
2298// API 1.18
2299//---------------------------------------------------------------------------
2300
2301//---------------------------------------------------------------------------
2302// API 1.19
2303//---------------------------------------------------------------------------
2304void ExitOCPN() {}
2305
2306bool GetFullScreen() { return gFrame->IsFullScreen(); }
2307
2308void SetFullScreen(bool set_full_screen_on) {
2309 bool state = gFrame->IsFullScreen();
2310 if (set_full_screen_on && !state)
2311 gFrame->ToggleFullScreen();
2312 else if (!set_full_screen_on && state)
2313 gFrame->ToggleFullScreen();
2314}
2315
2316extern bool g_useMUI;
2317void EnableMUIBar(bool enable, int CanvasIndex) {
2318 bool current_mui_state = g_useMUI;
2319
2320 g_useMUI = enable;
2321 if (enable && !current_mui_state) { // OFF going ON
2322 // ..For each canvas...
2323 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2324 ChartCanvas* cc = g_canvasArray.Item(i);
2325 if (cc) cc->CreateMUIBar();
2326 }
2327 } else if (!enable && current_mui_state) { // ON going OFF
2328 // ..For each canvas...
2329 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2330 ChartCanvas* cc = g_canvasArray.Item(i);
2331 if (cc) cc->DestroyMuiBar();
2332 }
2333 }
2334}
2335
2336bool GetEnableMUIBar(int CanvasIndex) { return g_useMUI; }
2337
2338void EnableCompassGPSIcon(bool enable, int CanvasIndex) {
2339 if (CanvasIndex < GetCanvasCount()) {
2340 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2341 if (cc) cc->SetShowGPSCompassWindow(enable);
2342 }
2343}
2344
2345bool GetEnableCompassGPSIcon(int CanvasIndex) {
2346 if (CanvasIndex < GetCanvasCount()) {
2347 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2348 if (cc)
2349 return cc->GetShowGPSCompassWindow();
2350 else
2351 return false;
2352 }
2353 return false;
2354}
2355
2356extern bool g_bShowStatusBar;
2357void EnableStatusBar(bool enable) {
2358 g_bShowStatusBar = enable;
2359 gFrame->ConfigureStatusBar();
2360}
2361
2362bool GetEnableStatusBar() { return g_bShowStatusBar; }
2363
2364void EnableChartBar(bool enable, int CanvasIndex) {
2365 bool current_chartbar_state = g_bShowChartBar;
2366 for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) {
2367 ChartCanvas* cc = g_canvasArray.Item(i);
2368 if (current_chartbar_state && !enable) {
2369 gFrame->ToggleChartBar(cc);
2370 g_bShowChartBar = current_chartbar_state;
2371 } else if (!current_chartbar_state && enable) {
2372 gFrame->ToggleChartBar(cc);
2373 g_bShowChartBar = current_chartbar_state;
2374 }
2375 }
2376 g_bShowChartBar = enable;
2377}
2378
2379bool GetEnableChartBar(int CanvasIndex) { return g_bShowChartBar; }
2380
2381extern bool g_bShowMenuBar;
2382void EnableMenu(bool enable) {
2383 if (!enable) {
2384 if (g_bShowMenuBar) {
2385 g_bShowMenuBar = false;
2386 if (gFrame->m_pMenuBar) {
2387 gFrame->SetMenuBar(NULL);
2388 gFrame->m_pMenuBar->Destroy();
2389 gFrame->m_pMenuBar = NULL;
2390 }
2391 }
2392 } else {
2393 g_bShowMenuBar = true;
2394 gFrame->BuildMenuBar();
2395 }
2396}
2397
2398bool GetEnableMenu() { return g_bShowMenuBar; }
2399
2400void SetGlobalColor(std::string table, std::string name, wxColor color) {
2401 if (ps52plib) ps52plib->m_chartSymbols.UpdateTableColor(table, name, color);
2402}
2403
2404wxColor GetGlobalColorD(std::string map_name, std::string name) {
2405 wxColor ret = wxColor(*wxRED);
2406 if (ps52plib) {
2407 int i_table = ps52plib->m_chartSymbols.FindColorTable(map_name.c_str());
2408 ret = ps52plib->m_chartSymbols.GetwxColor(name.c_str(), i_table);
2409 }
2410 return ret;
2411}
2412
2413void EnableLatLonGrid(bool enable, int CanvasIndex) {
2414 if (CanvasIndex < GetCanvasCount()) {
2415 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2416 if (cc) cc->SetShowGrid(enable);
2417 }
2418}
2419
2420void EnableChartOutlines(bool enable, int CanvasIndex) {
2421 if (CanvasIndex < GetCanvasCount()) {
2422 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2423 if (cc) cc->SetShowOutlines(enable);
2424 }
2425}
2426
2427void EnableDepthUnitDisplay(bool enable, int CanvasIndex) {
2428 if (CanvasIndex < GetCanvasCount()) {
2429 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2430 if (cc) cc->SetShowDepthUnits(enable);
2431 }
2432}
2433
2434void EnableAisTargetDisplay(bool enable, int CanvasIndex) {
2435 if (CanvasIndex < GetCanvasCount()) {
2436 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2437 if (cc) cc->SetShowAIS(enable);
2438 }
2439}
2440
2441void EnableTideStationsDisplay(bool enable, int CanvasIndex) {
2442 if (CanvasIndex < GetCanvasCount()) {
2443 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2444 if (cc) cc->ShowTides(enable);
2445 }
2446}
2447
2448void EnableCurrentStationsDisplay(bool enable, int CanvasIndex) {
2449 if (CanvasIndex < GetCanvasCount()) {
2450 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2451 if (cc) cc->ShowCurrents(enable);
2452 }
2453}
2454
2455void EnableENCTextDisplay(bool enable, int CanvasIndex) {
2456 if (CanvasIndex < GetCanvasCount()) {
2457 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2458 if (cc) cc->SetShowENCText(enable);
2459 }
2460}
2461
2462void EnableENCDepthSoundingsDisplay(bool enable, int CanvasIndex) {
2463 if (CanvasIndex < GetCanvasCount()) {
2464 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2465 if (cc) cc->SetShowENCDepth(enable);
2466 }
2467}
2468
2469void EnableBuoyLightLabelsDisplay(bool enable, int CanvasIndex) {
2470 if (CanvasIndex < GetCanvasCount()) {
2471 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2472 if (cc) cc->SetShowENCBuoyLabels(enable);
2473 }
2474}
2475
2476void EnableLightsDisplay(bool enable, int CanvasIndex) {
2477 if (CanvasIndex < GetCanvasCount()) {
2478 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2479 if (cc) cc->SetShowENCLights(enable);
2480 }
2481}
2482
2483void EnableLightDescriptionsDisplay(bool enable, int CanvasIndex) {
2484 if (CanvasIndex < GetCanvasCount()) {
2485 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2486 if (cc) cc->SetShowENCLightDesc(enable);
2487 }
2488}
2489
2490void SetENCDisplayCategory(PI_DisCat cat, int CanvasIndex) {
2491 int valSet = STANDARD;
2492 switch (cat) {
2493 case PI_DISPLAYBASE:
2494 valSet = DISPLAYBASE;
2495 break;
2496 case PI_STANDARD:
2497 valSet = STANDARD;
2498 break;
2499 case PI_OTHER:
2500 valSet = OTHER;
2501 break;
2503 valSet = MARINERS_STANDARD;
2504 break;
2505 default:
2506 valSet = STANDARD;
2507 break;
2508 }
2509 if (CanvasIndex < GetCanvasCount()) {
2510 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2511 if (cc) cc->SetENCDisplayCategory(valSet);
2512 }
2513}
2515 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2516 if (cc)
2517 return ((PI_DisCat)cc->GetENCDisplayCategory());
2518 else
2519 return PI_DisCat::PI_STANDARD;
2520}
2521
2522void SetNavigationMode(PI_NavMode mode, int CanvasIndex) {
2523 int newMode = NORTH_UP_MODE;
2524 if (mode == PI_COURSE_UP_MODE)
2525 newMode = COURSE_UP_MODE;
2526 else if (mode == PI_HEAD_UP_MODE)
2527 newMode = HEAD_UP_MODE;
2528
2529 if (CanvasIndex < GetCanvasCount()) {
2530 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2531 if (cc) cc->SetUpMode(newMode);
2532 }
2533}
2535 if (CanvasIndex < GetCanvasCount()) {
2536 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2537 if (cc) return ((PI_NavMode)cc->GetUpMode());
2538 }
2539 return PI_NavMode::PI_NORTH_UP_MODE;
2540}
2541
2542bool GetEnableLatLonGrid(int CanvasIndex) {
2543 if (CanvasIndex < GetCanvasCount()) {
2544 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2545 if (cc) return (cc->GetShowGrid());
2546 }
2547 return false;
2548}
2549
2550bool GetEnableChartOutlines(int CanvasIndex) {
2551 if (CanvasIndex < GetCanvasCount()) {
2552 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2553 if (cc) return (cc->GetShowOutlines());
2554 }
2555 return false;
2556}
2557
2558bool GetEnableDepthUnitDisplay(int CanvasIndex) {
2559 if (CanvasIndex < GetCanvasCount()) {
2560 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2561 if (cc) return (cc->GetShowDepthUnits());
2562 }
2563 return false;
2564}
2565
2566bool GetEnableAisTargetDisplay(int CanvasIndex) {
2567 if (CanvasIndex < GetCanvasCount()) {
2568 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2569 if (cc) return (cc->GetShowAIS());
2570 }
2571 return false;
2572}
2573
2574bool GetEnableTideStationsDisplay(int CanvasIndex) {
2575 if (CanvasIndex < GetCanvasCount()) {
2576 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2577 if (cc) return (cc->GetbShowTide());
2578 }
2579 return false;
2580}
2581
2582bool GetEnableCurrentStationsDisplay(int CanvasIndex) {
2583 if (CanvasIndex < GetCanvasCount()) {
2584 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2585 if (cc) return (cc->GetbShowCurrent());
2586 }
2587 return false;
2588}
2589
2590bool GetEnableENCTextDisplay(int CanvasIndex) {
2591 if (CanvasIndex < GetCanvasCount()) {
2592 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2593 if (cc) return (cc->GetShowENCText());
2594 }
2595 return false;
2596}
2597
2599 if (CanvasIndex < GetCanvasCount()) {
2600 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2601 if (cc) return (cc->GetShowENCDepth());
2602 }
2603 return false;
2604}
2605
2606bool GetEnableBuoyLightLabelsDisplay(int CanvasIndex) {
2607 if (CanvasIndex < GetCanvasCount()) {
2608 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2609 if (cc) return (cc->GetShowENCBuoyLabels());
2610 }
2611 return false;
2612}
2613
2614bool GetEnableLightsDisplay(int CanvasIndex) {
2615 if (CanvasIndex < GetCanvasCount()) {
2616 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2617 if (cc) return (cc->GetShowENCLights());
2618 }
2619 return false;
2620}
2621
2622bool GetShowENCLightDesc(int CanvasIndex) {
2623 if (CanvasIndex < GetCanvasCount()) {
2624 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2625 if (cc) return (cc->GetbShowCurrent());
2626 }
2627 return false;
2628}
2629
2630void EnableTouchMode(bool enable) { g_btouch = enable; }
2631
2632bool GetTouchMode() { return g_btouch; }
2633
2634void EnableLookaheadMode(bool enable, int CanvasIndex) {
2635 if (CanvasIndex < GetCanvasCount()) {
2636 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2637 if (cc) cc->ToggleLookahead();
2638 }
2639}
2640
2641bool GetEnableLookaheadMode(int CanvasIndex) {
2642 if (CanvasIndex < GetCanvasCount()) {
2643 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2644 if (cc) return (cc->GetLookahead());
2645 }
2646 return false;
2647}
2648
2649extern bool g_bTrackActive;
2650void SetTrackingMode(bool enable) {
2651 if (!g_bTrackActive && enable)
2652 gFrame->TrackOn();
2653 else if (g_bTrackActive && !enable)
2654 gFrame->TrackOff();
2655}
2656bool GetTrackingMode() { return g_bTrackActive; }
2657
2659 gFrame->SetAndApplyColorScheme((ColorScheme)cs);
2660}
2662 return (PI_ColorScheme)global_color_scheme;
2663}
2664
2665void RequestWindowRefresh(wxWindow* win, bool eraseBackground) {
2666 if (win) win->Refresh(eraseBackground);
2667}
2668
2669void EnableSplitScreenLayout(bool enable) {
2670 if (g_canvasConfig == 1) {
2671 if (enable)
2672 return;
2673 else { // split to single
2674 g_canvasConfig = 0; // 0 => "single canvas"
2675 gFrame->CreateCanvasLayout();
2676 gFrame->DoChartUpdate();
2677 }
2678 } else {
2679 if (enable) { // single to split
2680 g_canvasConfig = 1; // 1 => "two canvas"
2681 gFrame->CreateCanvasLayout();
2682 gFrame->DoChartUpdate();
2683 } else {
2684 return;
2685 }
2686 }
2687}
2688
2689// ChartCanvas control utilities
2690
2691void PluginZoomCanvas(int CanvasIndex, double factor) {
2692 if (CanvasIndex < GetCanvasCount()) {
2693 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2694 if (cc) cc->ZoomCanvasSimple(factor);
2695 }
2696}
2697
2698bool GetEnableMainToolbar() { return (!g_disable_main_toolbar); }
2699void SetEnableMainToolbar(bool enable) {
2700 g_disable_main_toolbar = !enable;
2701 if (g_MainToolbar) g_MainToolbar->RefreshToolbar();
2702}
2703
2705 if (gFrame) gFrame->ScheduleSettingsDialog();
2706}
2707
2708void PluginCenterOwnship(int CanvasIndex) {
2709 if (CanvasIndex < GetCanvasCount()) {
2710 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2711 if (cc) {
2712 bool bfollow = cc->GetbFollow();
2713 cc->ResetOwnshipOffset();
2714 if (bfollow)
2715 cc->SetbFollow();
2716 else
2717 cc->JumpToPosition(gLat, gLon, cc->GetVPScale());
2718 }
2719 }
2720}
2721
2722void PluginSetFollowMode(int CanvasIndex, bool enable_follow) {
2723 if (CanvasIndex < GetCanvasCount()) {
2724 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2725 if (cc) {
2726 if (cc->GetbFollow() != enable_follow) cc->TogglebFollow();
2727 }
2728 }
2729}
2730
2731bool PluginGetFollowMode(int CanvasIndex) {
2732 if (CanvasIndex < GetCanvasCount()) {
2733 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2734 if (cc) return cc->GetbFollow();
2735 }
2736 return false;
2737}
2738
2739void EnableCanvasFocusBar(bool enable, int CanvasIndex) {
2740 if (CanvasIndex < GetCanvasCount()) {
2741 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2742 if (cc) cc->SetShowFocusBar(enable);
2743 }
2744}
2745bool GetEnableCanvasFocusBar(int CanvasIndex) {
2746 if (CanvasIndex < GetCanvasCount()) {
2747 ChartCanvas* cc = g_canvasArray.Item(CanvasIndex);
2748 if (cc) return (cc->GetShowFocusBar());
2749 }
2750 return false;
2751}
2752
2753bool GetEnableTenHertzUpdate() { return g_btenhertz; }
2754
2755void EnableTenHertzUpdate(bool enable) { g_btenhertz = enable; }
2756
2758 if (pConfig) {
2759 pConfig->Flush();
2760
2761 // Handle system general configuration options
2762 pConfig->LoadMyConfigRaw(false);
2763
2764 // Handle chart canvas window configuration options
2765 pConfig->LoadCanvasConfigs(false);
2766 auto& config_array = ConfigMgr::Get().GetCanvasConfigArray();
2767 for (auto pcc : config_array) {
2768 if (pcc && pcc->canvas) {
2769 pcc->canvas->ApplyCanvasConfig(pcc);
2770 pcc->canvas->Refresh();
2771 }
2772 }
2773 }
2774}
2775
2780 g_CanvasHideNotificationIcon = !enable;
2781}
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:450
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4646
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.
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)
Extended waypoint class with additional navigation features.
bool GetFSStatus()
Gets "free-standing" status of waypoint.
wxDateTime m_CreateTime
Creation timestamp.
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.
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
bool m_bIsolatedMark
Flag indicating if the waypoint is a standalone mark.
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:835
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:139
void SetCreateTime(wxDateTime dt)
Sets the creation timestamp for a track point.
Definition track.cpp:145
Represents a track, which is a series of connected track points.
Definition track.h: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 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.
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.
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.
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.
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.
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 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.
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)
Removes 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.
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:591
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:393
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