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