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