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