OpenCPN Partial API docs
ocpn_plugin.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: PlugIn Object Definition/API
5  * Author: David Register
6  *
7  ***************************************************************************
8  * Copyright (C) 2010 by David S. Register *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24  **************************************************************************/
25 
28 #ifndef _PLUGIN_H_
29 #define _PLUGIN_H_
30 
31 #ifndef DECL_EXP
32 #if defined(__WXMSW__) || defined(__CYGWIN__)
33 #define DECL_EXP __declspec(dllexport)
34 #elif defined __GNUC__ && __GNUC__ >= 4
35 #define DECL_EXP __attribute__((visibility("default")))
36 #elif defined __WXOSX__
37 #define DECL_EXP __attribute__((visibility("default")))
38 #else
39 #define DECL_EXP
40 #endif
41 #endif
42 
43 #if defined(__WXMSW__) && defined(MAKING_PLUGIN)
44 #define DECL_IMP __declspec(dllimport)
45 #else
46 #define DECL_IMP
47 #endif
48 
49 #include <wx/xml/xml.h>
50 #include <wx/dcmemory.h>
51 #include <wx/dialog.h>
52 #include <wx/event.h>
53 #include <wx/menuitem.h>
54 #include <wx/gdicmn.h>
55 
56 #ifdef ocpnUSE_SVG
57 #include <wx/bitmap.h>
58 #endif // ocpnUSE_SVG
59 
60 #include <memory>
61 #include <vector>
62 #include <unordered_map>
63 
64 class wxGLContext;
65 
66 // This is the most modern API Version number
67 // It is expected that the API will remain downward compatible, meaning that
68 // PlugIns conforming to API Version less then the most modern will also
69 // be correctly supported.
70 #define API_VERSION_MAJOR 1
71 #define API_VERSION_MINOR 18
72 
73 // Fwd Definitions
74 class wxFileConfig;
75 class wxNotebook;
76 class wxFont;
77 class wxAuiManager;
78 class wxScrolledWindow;
79 class wxGLCanvas;
80 
81 //---------------------------------------------------------------------------------------------------------
82 //
83 // Bitfield PlugIn Capabilites flag definition
84 //
85 //---------------------------------------------------------------------------------------------------------
86 #define WANTS_OVERLAY_CALLBACK 0x00000001
87 #define WANTS_CURSOR_LATLON 0x00000002
88 #define WANTS_TOOLBAR_CALLBACK 0x00000004
89 #define INSTALLS_TOOLBAR_TOOL 0x00000008
90 #define WANTS_CONFIG 0x00000010
91 #define INSTALLS_TOOLBOX_PAGE 0x00000020
92 #define INSTALLS_CONTEXTMENU_ITEMS 0x00000040
93 #define WANTS_NMEA_SENTENCES 0x00000080
94 #define WANTS_NMEA_EVENTS 0x00000100
95 #define WANTS_AIS_SENTENCES 0x00000200
96 #define USES_AUI_MANAGER 0x00000400
97 #define WANTS_PREFERENCES 0x00000800
98 #define INSTALLS_PLUGIN_CHART 0x00001000
99 #define WANTS_ONPAINT_VIEWPORT 0x00002000
100 #define WANTS_PLUGIN_MESSAGING 0x00004000
101 #define WANTS_OPENGL_OVERLAY_CALLBACK 0x00008000
102 #define WANTS_DYNAMIC_OPENGL_OVERLAY_CALLBACK 0x00010000
103 #define WANTS_LATE_INIT 0x00020000
104 #define INSTALLS_PLUGIN_CHART_GL 0x00040000
105 #define WANTS_MOUSE_EVENTS 0x00080000
106 #define WANTS_VECTOR_CHART_OBJECT_INFO 0x00100000
107 #define WANTS_KEYBOARD_EVENTS 0x00200000
108 
109 //---------------------------------------------------------------------------------------------------------
110 //
111 // Overlay priorities
112 //
113 //---------------------------------------------------------------------------------------------------------
114 #define OVERLAY_LEGACY 0
115 #define OVERLAY_OVER_SHIPS 64
116 #define OVERLAY_OVER_EMBOSS 96
117 #define OVERLAY_OVER_UI 128
118 
119 //----------------------------------------------------------------------------------------------------------
120 // Some PlugIn API interface object class definitions
121 //----------------------------------------------------------------------------------------------------------
122 enum PI_ColorScheme {
123  PI_GLOBAL_COLOR_SCHEME_RGB,
124  PI_GLOBAL_COLOR_SCHEME_DAY,
125  PI_GLOBAL_COLOR_SCHEME_DUSK,
126  PI_GLOBAL_COLOR_SCHEME_NIGHT,
127  PI_N_COLOR_SCHEMES
128 };
129 
131 public:
132  double clat; // center point
133  double clon;
134  double view_scale_ppm;
135  double skew;
136  double rotation;
137 
138  float chart_scale; // conventional chart displayed scale
139 
140  int pix_width;
141  int pix_height;
142  wxRect rv_rect;
143  bool b_quilt;
144  int m_projection_type;
145 
146  double lat_min, lat_max, lon_min, lon_max;
147 
148  bool bValid; // This VP is valid
149 };
150 
152 public:
153  double Lat;
154  double Lon;
155  double Cog;
156  double Sog;
157  double Var; // Variation, typically from RMC message
158  time_t FixTime;
159  int nSats;
160 };
161 
163 public:
164  double Lat;
165  double Lon;
166  double Cog;
167  double Sog;
168  double Var; // Variation, typically from RMC message
169  double Hdm;
170  double Hdt;
171  time_t FixTime;
172  int nSats;
173 };
174 
176 public:
177  double Xte; // Left side of the track -> negative XTE
178  double Btw;
179  double Dtw;
180  wxString wp_name; // Name of destination waypoint for active leg
181  bool arrival; // True when within arrival circle
182 };
183 
184 // Describe AIS Alarm state
185 enum plugin_ais_alarm_type {
186  PI_AIS_NO_ALARM = 0,
187  PI_AIS_ALARM_SET,
188  PI_AIS_ALARM_ACKNOWLEDGED
189 
190 };
191 
193 public:
194  int MMSI;
195  int Class;
196  int NavStatus;
197  double SOG;
198  double COG;
199  double HDG;
200  double Lon;
201  double Lat;
202  int ROTAIS;
203  char CallSign[8]; // includes terminator
204  char ShipName[21];
205  unsigned char ShipType;
206  int IMO;
207 
208  double Range_NM;
209  double Brg;
210 
211  // Per target collision parameters
212  bool bCPA_Valid;
213  double TCPA; // Minutes
214  double CPA; // Nautical Miles
215 
216  plugin_ais_alarm_type alarm_state;
217 };
218 
219 // ChartType constants
220 typedef enum ChartTypeEnumPI {
221  PI_CHART_TYPE_UNKNOWN = 0,
222  PI_CHART_TYPE_DUMMY,
223  PI_CHART_TYPE_DONTCARE,
224  PI_CHART_TYPE_KAP,
225  PI_CHART_TYPE_GEO,
226  PI_CHART_TYPE_S57,
227  PI_CHART_TYPE_CM93,
228  PI_CHART_TYPE_CM93COMP,
229  PI_CHART_TYPE_PLUGIN
230 } _ChartTypeEnumPI;
231 
232 // ChartFamily constants
233 typedef enum ChartFamilyEnumPI {
234  PI_CHART_FAMILY_UNKNOWN = 0,
235  PI_CHART_FAMILY_RASTER,
236  PI_CHART_FAMILY_VECTOR,
237  PI_CHART_FAMILY_DONTCARE
238 } _ChartFamilyEnumPI;
239 
240 // Depth unit type enum
241 typedef enum ChartDepthUnitTypePI {
242  PI_DEPTH_UNIT_UNKNOWN,
243  PI_DEPTH_UNIT_FEET,
244  PI_DEPTH_UNIT_METERS,
245  PI_DEPTH_UNIT_FATHOMS
246 } _ChartDepthUnitTypePI;
247 
248 // Projection type enum
249 typedef enum OcpnProjTypePI {
250  PI_PROJECTION_UNKNOWN,
251  PI_PROJECTION_MERCATOR,
252  PI_PROJECTION_TRANSVERSE_MERCATOR,
253  PI_PROJECTION_POLYCONIC,
254 
255  PI_PROJECTION_ORTHOGRAPHIC,
256  PI_PROJECTION_POLAR,
257  PI_PROJECTION_STEREOGRAPHIC,
258  PI_PROJECTION_GNOMONIC,
259  PI_PROJECTION_EQUIRECTANGULAR
260 } _OcpnProjTypePI;
261 
262 typedef struct _ExtentPI {
263  double SLAT;
264  double WLON;
265  double NLAT;
266  double ELON;
267 } ExtentPI;
268 
269 // PlugInChartBase::Init() init_flags constants
270 #define PI_FULL_INIT 0
271 #define PI_HEADER_ONLY 1
272 #define PI_THUMB_ONLY 2
273 
274 // ----------------------------------------------------------------------------
275 // PlugInChartBase
276 // This class is the base class for Plug-able chart types
277 // ----------------------------------------------------------------------------
278 
279 class DECL_EXP PlugInChartBase : public wxObject {
280 public:
281  // These methods Must be overriden in any derived class
282  PlugInChartBase();
283  virtual ~PlugInChartBase();
284 
285  virtual wxString GetFileSearchMask(void);
286 
287  virtual int Init(const wxString &full_path, int init_flags);
288  virtual void SetColorScheme(int cs, bool bApplyImmediate);
289 
290  virtual double GetNormalScaleMin(double canvas_scale_factor,
291  bool b_allow_overzoom);
292  virtual double GetNormalScaleMax(double canvas_scale_factor,
293  int canvas_width);
294  virtual double GetNearestPreferredScalePPM(double target_scale_ppm);
295 
296  virtual bool GetChartExtent(ExtentPI *pext);
297 
298  virtual wxBitmap &RenderRegionView(const PlugIn_ViewPort &VPoint,
299  const wxRegion &Region);
300 
301  virtual bool AdjustVP(PlugIn_ViewPort &vp_last, PlugIn_ViewPort &vp_proposed);
302 
303  virtual void GetValidCanvasRegion(const PlugIn_ViewPort &VPoint,
304  wxRegion *pValidRegion);
305 
306  virtual int GetCOVREntries() { return 0; }
307  virtual int GetCOVRTablePoints(int iTable) { return 0; }
308  virtual int GetCOVRTablenPoints(int iTable) { return 0; }
309  virtual float *GetCOVRTableHead(int iTable) { return (float *)NULL; }
310 
311  virtual wxBitmap *GetThumbnail(int tnx, int tny, int cs);
312 
313  // Accessors, need not be overridden in derived class if the member
314  // variables are maintained
315  virtual wxString GetFullPath() const { return m_FullPath; }
316  virtual ChartTypeEnumPI GetChartType() { return m_ChartType; }
317  virtual ChartFamilyEnumPI GetChartFamily() { return m_ChartFamily; }
318  virtual OcpnProjTypePI GetChartProjection() { return m_projection; }
319  virtual wxString GetName() { return m_Name; }
320  virtual wxString GetDescription() { return m_Description; }
321  virtual wxString GetID() { return m_ID; }
322  virtual wxString GetSE() { return m_SE; }
323  virtual wxString GetDepthUnits() { return m_DepthUnits; }
324  virtual wxString GetSoundingsDatum() { return m_SoundingsDatum; }
325  virtual wxString GetDatumString() { return m_datum_str; }
326  virtual wxString GetExtraInfo() { return m_ExtraInfo; }
327  virtual wxString GetPubDate() { return m_PubYear; }
328  virtual double GetChartErrorFactor() { return m_Chart_Error_Factor; }
329  virtual ChartDepthUnitTypePI GetDepthUnitId() { return m_depth_unit_id; }
330  virtual bool IsReadyToRender() { return m_bReadyToRender; }
331  virtual int GetNativeScale() { return m_Chart_Scale; };
332  virtual double GetChartSkew() { return m_Chart_Skew; }
333  virtual wxDateTime GetEditionDate(void) { return m_EdDate; }
334 
335  // Methods pertaining to CHART_FAMILY_RASTER type PlugIn charts only
336  virtual void ComputeSourceRectangle(const PlugIn_ViewPort &vp,
337  wxRect *pSourceRect);
338  virtual double GetRasterScaleFactor();
339  virtual bool GetChartBits(wxRect &source, unsigned char *pPix, int sub_samp);
340  virtual int GetSize_X();
341  virtual int GetSize_Y();
342  virtual void latlong_to_chartpix(double lat, double lon, double &pixx,
343  double &pixy);
344  virtual void chartpix_to_latlong(double pixx, double pixy, double *plat,
345  double *plon);
346 
347 protected:
348  ChartTypeEnumPI m_ChartType;
349  ChartFamilyEnumPI m_ChartFamily;
350 
351  wxString m_FullPath;
352  OcpnProjTypePI m_projection;
353  int m_Chart_Scale;
354  double m_Chart_Skew;
355 
356  wxDateTime m_EdDate;
357  bool m_bReadyToRender;
358 
359  wxString m_Name;
360  wxString m_Description;
361  wxString m_ID;
362  wxString m_SE;
363  wxString m_SoundingsDatum;
364  wxString m_datum_str;
365  wxString m_PubYear;
366  wxString m_DepthUnits;
367  wxString m_ExtraInfo;
368 
369  ChartDepthUnitTypePI m_depth_unit_id;
370 
371  double m_Chart_Error_Factor;
372 };
373 
374 // Declare an array of PlugIn_AIS_Targets
375 WX_DEFINE_ARRAY_PTR(PlugIn_AIS_Target *, ArrayOfPlugIn_AIS_Targets);
376 
377 //----------------------------------------------------------------------------------------------------------
378 // The Generic PlugIn Interface Class Definition
379 //
380 // This is a virtual class.
381 // opencpn PlugIns must derive from this class.
382 // There are two types of methods in this class
383 // a. Required...must be overridden and implemented by PlugIns
384 // b. Optional..may be overridden by PlugIns
385 
386 // PlugIns must implement optional method overrides consistent with their
387 // declared capabilities flag as returned by Init().
388 //----------------------------------------------------------------------------------------------------------
389 class DECL_EXP opencpn_plugin {
390 public:
391  opencpn_plugin(void *pmgr) {}
392  virtual ~opencpn_plugin();
393 
394  // Public API to the PlugIn class
395 
396  // This group of methods is required, and will be called by the opencpn
397  // host opencpn PlugIns must implement this group
398  virtual int Init(void); // Return the PlugIn Capabilites flag
399  virtual bool DeInit(void);
400 
401  virtual int GetAPIVersionMajor();
402  virtual int GetAPIVersionMinor();
403  virtual int GetPlugInVersionMajor();
404  virtual int GetPlugInVersionMinor();
405  virtual wxBitmap *GetPlugInBitmap();
406 
407  // These three methods should produce valid, meaningful strings always
408  // ---EVEN IF--- the PlugIn has not (yet) been initialized.
409  // They are used by the PlugInManager GUI
410  virtual wxString GetCommonName();
411  virtual wxString GetShortDescription();
412  virtual wxString GetLongDescription();
413 
414  // This group is optional.
415  // PlugIns may override any of these methods as required
416 
417  virtual void SetDefaults(
418  void); // This will be called upon enabling a PlugIn via the user Dialog
419  // It gives a chance to setup any default options and behavior
420 
421  virtual int GetToolbarToolCount(void);
422 
423  virtual int GetToolboxPanelCount(void);
424  virtual void SetupToolboxPanel(int page_sel, wxNotebook *pnotebook);
425  virtual void OnCloseToolboxPanel(int page_sel, int ok_apply_cancel);
426 
427  virtual void ShowPreferencesDialog(wxWindow *parent);
428 
429  virtual bool RenderOverlay(wxMemoryDC *pmdc, PlugIn_ViewPort *vp);
430  virtual void SetCursorLatLon(double lat, double lon);
431  virtual void SetCurrentViewPort(PlugIn_ViewPort &vp);
432 
433  virtual void SetPositionFix(PlugIn_Position_Fix &pfix);
434  virtual void SetNMEASentence(wxString &sentence);
435  virtual void SetAISSentence(wxString &sentence);
436 
437  virtual void ProcessParentResize(int x, int y);
438  virtual void SetColorScheme(PI_ColorScheme cs);
439 
440  virtual void OnToolbarToolCallback(int id);
441  virtual void OnContextMenuItemCallback(int id);
442 
443  virtual void UpdateAuiStatus(void);
444 
445  virtual wxArrayString GetDynamicChartClassNameArray(void);
446 };
447 
448 // the types of the class factories used to create PlugIn instances
449 typedef opencpn_plugin *create_t(void *);
450 typedef void destroy_t(opencpn_plugin *);
451 
452 #ifdef __clang__
453 #pragma clang diagnostic push
454 #pragma clang diagnostic ignored "-Woverloaded-virtual"
455 #endif
456 
457 class DECL_EXP opencpn_plugin_16 : public opencpn_plugin {
458 public:
459  opencpn_plugin_16(void *pmgr);
460  virtual ~opencpn_plugin_16();
461 
462  using opencpn_plugin::RenderOverlay;
463 
464  virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp);
465 
466  virtual void SetPluginMessage(wxString &message_id, wxString &message_body);
467 };
468 
469 class DECL_EXP opencpn_plugin_17 : public opencpn_plugin {
470 public:
471  opencpn_plugin_17(void *pmgr);
472  virtual ~opencpn_plugin_17();
473 
474  using opencpn_plugin::RenderOverlay;
475 
476  virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp);
477  virtual bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp);
478 
479  virtual void SetPluginMessage(wxString &message_id, wxString &message_body);
480 };
481 
482 class DECL_EXP opencpn_plugin_18 : public opencpn_plugin {
483 public:
484  opencpn_plugin_18(void *pmgr);
485  virtual ~opencpn_plugin_18();
486 
487  using opencpn_plugin::RenderOverlay;
488 
489  virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp);
490  virtual bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp);
491  virtual void SetPluginMessage(wxString &message_id, wxString &message_body);
492  virtual void SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix);
493 };
494 
495 #ifdef __clang__
496 #pragma clang diagnostic pop
497 #endif
498 
499 class DECL_EXP opencpn_plugin_19 : public opencpn_plugin_18 {
500 public:
501  opencpn_plugin_19(void *pmgr);
502  virtual ~opencpn_plugin_19();
503 
504  virtual void OnSetupOptions(void);
505 };
506 
507 class DECL_EXP opencpn_plugin_110 : public opencpn_plugin_19 {
508 public:
509  opencpn_plugin_110(void *pmgr);
510  virtual ~opencpn_plugin_110();
511 
512  virtual void LateInit(void); // If WANTS_LATE_INIT is returned by Init()
513 };
514 
515 class DECL_EXP opencpn_plugin_111 : public opencpn_plugin_110 {
516 public:
517  opencpn_plugin_111(void *pmgr);
518  virtual ~opencpn_plugin_111();
519 };
520 
521 class DECL_EXP opencpn_plugin_112 : public opencpn_plugin_111 {
522 public:
523  opencpn_plugin_112(void *pmgr);
524  virtual ~opencpn_plugin_112();
525 
526  virtual bool MouseEventHook(wxMouseEvent &event);
527  virtual void SendVectorChartObjectInfo(wxString &chart, wxString &feature,
528  wxString &objname, double lat,
529  double lon, double scale,
530  int nativescale);
531 };
532 
533 class DECL_EXP opencpn_plugin_113 : public opencpn_plugin_112 {
534 public:
535  opencpn_plugin_113(void *pmgr);
536  virtual ~opencpn_plugin_113();
537 
538  virtual bool KeyboardEventHook(wxKeyEvent &event);
539  virtual void OnToolbarToolDownCallback(int id);
540  virtual void OnToolbarToolUpCallback(int id);
541 };
542 
543 class DECL_EXP opencpn_plugin_114 : public opencpn_plugin_113 {
544 public:
545  opencpn_plugin_114(void *pmgr);
546  virtual ~opencpn_plugin_114();
547 };
548 
549 class DECL_EXP opencpn_plugin_115 : public opencpn_plugin_114 {
550 public:
551  opencpn_plugin_115(void *pmgr);
552  virtual ~opencpn_plugin_115();
553 };
554 
555 class DECL_EXP opencpn_plugin_116 : public opencpn_plugin_115 {
556 public:
557  opencpn_plugin_116(void *pmgr);
558  virtual ~opencpn_plugin_116();
559  virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext,
560  PlugIn_ViewPort *vp, int canvasIndex);
561  virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp,
562  int canvasIndex);
563  virtual void PrepareContextMenu(int canvasIndex);
564 };
565 
566 class DECL_EXP opencpn_plugin_117 : public opencpn_plugin_116 {
567 public:
568  opencpn_plugin_117(void *pmgr);
569  /*
570  * Forms a semantic version together with GetPlugInVersionMajor() and
571  * GetPlugInVersionMinor(), see https://semver.org/
572  */
573  virtual int GetPlugInVersionPatch();
574 
576  virtual int GetPlugInVersionPost();
577 
579  virtual const char *GetPlugInVersionPre();
580 
582  virtual const char *GetPlugInVersionBuild();
583 
584  /*Provide active leg data to plugins*/
585  virtual void SetActiveLegInfo(Plugin_Active_Leg_Info &leg_info);
586 };
587 
588 class DECL_EXP opencpn_plugin_118 : public opencpn_plugin_117 {
589 public:
590  opencpn_plugin_118(void *pmgr);
591 
592  using opencpn_plugin_116::RenderGLOverlayMultiCanvas;
593  using opencpn_plugin_116::RenderOverlayMultiCanvas;
594 
603 #ifdef _MSC_VER
604  virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp,
605  int canvasIndex, int priority = -1);
606 #else
607  virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp,
608  int canvasIndex, int priority);
609 
610  bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp,
611  int canvas_ix) override {
612  return RenderGLOverlayMultiCanvas(pcontext, vp, canvas_ix, -1);
613  }
614 #endif
615 
616 
617 
626 #ifdef _MSC_VER
627  virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp,
628  int canvasIndex, int priority = -1);
629 #else
630  virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvas_ix,
631  int priority);
632  bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp,
633  int canvas_ix) override {
634  return RenderOverlayMultiCanvas(dc, vp, canvas_ix, -1);
635  }
636 #endif
637 
638 };
639 //------------------------------------------------------------------
640 // Route and Waypoint PlugIn support
641 //
642 //------------------------------------------------------------------
643 
644 class DECL_EXP Plugin_Hyperlink {
645 public:
646  wxString DescrText;
647  wxString Link;
648  wxString Type;
649 };
650 
651 WX_DECLARE_LIST(Plugin_Hyperlink, Plugin_HyperlinkList);
652 
653 class DECL_EXP PlugIn_Waypoint {
654 public:
655  PlugIn_Waypoint();
656  PlugIn_Waypoint(double lat, double lon, const wxString &icon_ident,
657  const wxString &wp_name, const wxString &GUID = _T(""));
658  ~PlugIn_Waypoint();
659 
660  double m_lat;
661  double m_lon;
662 
663  wxString m_GUID;
664 
665  wxString m_MarkName;
666  wxString m_MarkDescription;
667  wxDateTime m_CreateTime;
668  bool m_IsVisible;
669 
670  wxString m_IconName;
671 
672  Plugin_HyperlinkList *m_HyperlinkList;
673 };
674 
675 WX_DECLARE_LIST(PlugIn_Waypoint, Plugin_WaypointList);
676 
677 class DECL_EXP PlugIn_Route {
678 public:
679  PlugIn_Route(void);
680  ~PlugIn_Route(void);
681 
682  wxString m_NameString;
683  wxString m_StartString;
684  wxString m_EndString;
685  wxString m_GUID;
686 
687  Plugin_WaypointList *pWaypointList;
688 };
689 
690 class DECL_EXP PlugIn_Track {
691 public:
692  PlugIn_Track(void);
693  ~PlugIn_Track(void);
694 
695  wxString m_NameString;
696  wxString m_StartString;
697  wxString m_EndString;
698  wxString m_GUID;
699 
700  Plugin_WaypointList *pWaypointList;
701 };
702 
703 //----------------------------------------------------------------------------------------------------------
704 // The PlugIn CallBack API Definition
705 //
706 // The API back up to the PlugIn Manager
707 // PlugIns may call these static functions as necessary for system services
708 //
709 //----------------------------------------------------------------------------------------------------------
710 
711 extern "C" DECL_EXP int InsertPlugInTool(wxString label, wxBitmap *bitmap,
712  wxBitmap *bmpRollover, wxItemKind kind,
713  wxString shortHelp, wxString longHelp,
714  wxObject *clientData, int position,
715  int tool_sel, opencpn_plugin *pplugin);
716 extern "C" DECL_EXP void RemovePlugInTool(int tool_id);
717 extern "C" DECL_EXP void SetToolbarToolViz(
718  int item, bool viz); // Temporarily change toolbar tool viz
719 extern "C" DECL_EXP void SetToolbarItemState(int item, bool toggle);
720 extern "C" DECL_EXP void SetToolbarToolBitmaps(int item, wxBitmap *bitmap,
721  wxBitmap *bmpRollover);
722 
723 extern "C" DECL_EXP int InsertPlugInToolSVG(
724  wxString label, wxString SVGfile, wxString SVGfileRollover,
725  wxString SVGfileToggled, wxItemKind kind, wxString shortHelp,
726  wxString longHelp, wxObject *clientData, int position, int tool_sel,
727  opencpn_plugin *pplugin);
728 extern "C" DECL_EXP void SetToolbarToolBitmapsSVG(int item, wxString SVGfile,
729  wxString SVGfileRollover,
730  wxString SVGfileToggled);
731 
732 extern "C" DECL_EXP int AddCanvasContextMenuItem(wxMenuItem *pitem,
733  opencpn_plugin *pplugin);
734 extern "C" DECL_EXP void RemoveCanvasContextMenuItem(
735  int item); // Fully remove this item
736 extern "C" DECL_EXP void SetCanvasContextMenuItemViz(
737  int item, bool viz); // Temporarily change context menu ptions
738 extern "C" DECL_EXP void SetCanvasContextMenuItemGrey(int item, bool grey);
739 
740 extern "C" DECL_EXP wxFileConfig *GetOCPNConfigObject(void);
741 
742 extern "C" DECL_EXP void RequestRefresh(wxWindow *);
743 extern "C" DECL_EXP bool GetGlobalColor(wxString colorName, wxColour *pcolour);
744 
745 extern "C" DECL_EXP void GetCanvasPixLL(PlugIn_ViewPort *vp, wxPoint *pp,
746  double lat, double lon);
747 extern "C" DECL_EXP void GetCanvasLLPix(PlugIn_ViewPort *vp, wxPoint p,
748  double *plat, double *plon);
749 
750 extern "C" DECL_EXP wxWindow *GetOCPNCanvasWindow();
751 
752 extern "C" DECL_EXP wxFont *OCPNGetFont(wxString TextElement, int default_size);
753 
754 extern "C" DECL_EXP wxString *GetpSharedDataLocation();
755 
756 extern "C" DECL_EXP ArrayOfPlugIn_AIS_Targets *GetAISTargetArray(void);
757 
758 extern "C" DECL_EXP wxAuiManager *GetFrameAuiManager(void);
759 
760 extern "C" DECL_EXP bool AddLocaleCatalog(wxString catalog);
761 
762 extern "C" DECL_EXP void PushNMEABuffer(wxString str);
763 
764 extern DECL_EXP wxXmlDocument GetChartDatabaseEntryXML(int dbIndex,
765  bool b_getGeom);
766 
767 extern DECL_EXP bool UpdateChartDBInplace(wxArrayString dir_array,
768  bool b_force_update,
769  bool b_ProgressDialog);
770 extern DECL_EXP wxArrayString GetChartDBDirArrayString();
771 
772 extern "C" DECL_EXP void SendPluginMessage(wxString message_id,
773  wxString message_body);
774 
775 extern "C" DECL_EXP void DimeWindow(wxWindow *);
776 
777 extern "C" DECL_EXP void JumpToPosition(double lat, double lon, double scale);
778 
779 /* API 1.9 adds some common cartographic functions to avoid unnecessary code
780  * duplication */
781 /* Study the original OpenCPN source (georef.c) for functional definitions */
782 
783 extern "C" DECL_EXP void PositionBearingDistanceMercator_Plugin(
784  double lat, double lon, double brg, double dist, double *dlat,
785  double *dlon);
786 extern "C" DECL_EXP void DistanceBearingMercator_Plugin(
787  double lat0, double lon0, double lat1, double lon1, double *brg,
788  double *dist);
789 extern "C" DECL_EXP double DistGreatCircle_Plugin(double slat, double slon,
790  double dlat, double dlon);
791 
792 extern "C" DECL_EXP void toTM_Plugin(float lat, float lon, float lat0,
793  float lon0, double *x, double *y);
794 extern "C" DECL_EXP void fromTM_Plugin(double x, double y, double lat0,
795  double lon0, double *lat, double *lon);
796 extern "C" DECL_EXP void toSM_Plugin(double lat, double lon, double lat0,
797  double lon0, double *x, double *y);
798 extern "C" DECL_EXP void fromSM_Plugin(double x, double y, double lat0,
799  double lon0, double *lat, double *lon);
800 extern "C" DECL_EXP void toSM_ECC_Plugin(double lat, double lon, double lat0,
801  double lon0, double *x, double *y);
802 extern "C" DECL_EXP void fromSM_ECC_Plugin(double x, double y, double lat0,
803  double lon0, double *lat,
804  double *lon);
805 
806 extern "C" DECL_EXP bool DecodeSingleVDOMessage(const wxString &str,
808  wxString *acc);
809 extern "C" DECL_EXP int GetChartbarHeight(void);
810 extern "C" DECL_EXP bool GetActiveRoutepointGPX(char *buffer,
811  unsigned int buffer_length);
812 
813 /* API 1.9 */
814 typedef enum OptionsParentPI {
815  PI_OPTIONS_PARENT_DISPLAY,
816  PI_OPTIONS_PARENT_CONNECTIONS,
817  PI_OPTIONS_PARENT_CHARTS,
818  PI_OPTIONS_PARENT_SHIPS,
819  PI_OPTIONS_PARENT_UI,
820  PI_OPTIONS_PARENT_PLUGINS
821 } _OptionsParentPI;
822 extern DECL_EXP wxScrolledWindow *AddOptionsPage(OptionsParentPI parent,
823  wxString title);
824 extern DECL_EXP bool DeleteOptionsPage(wxScrolledWindow *page);
825 
826 /* API 1.10 */
827 
828 /* API 1.10 adds some common functions to avoid unnecessary code duplication */
829 /* Study the original OpenCPN source for functional definitions */
830 extern "C" DECL_EXP double toUsrDistance_Plugin(double nm_distance,
831  int unit = -1);
832 extern "C" DECL_EXP double fromUsrDistance_Plugin(double usr_distance,
833  int unit = -1);
834 extern "C" DECL_EXP double toUsrSpeed_Plugin(double kts_speed, int unit = -1);
835 extern "C" DECL_EXP double fromUsrSpeed_Plugin(double usr_speed, int unit = -1);
836 extern "C" DECL_EXP double toUsrTemp_Plugin(double cel_temp, int unit = -1);
837 extern "C" DECL_EXP double fromUsrTemp_Plugin(double usr_temp, int unit = -1);
838 extern DECL_EXP wxString getUsrDistanceUnit_Plugin(int unit = -1);
839 extern DECL_EXP wxString getUsrSpeedUnit_Plugin(int unit = -1);
840 extern DECL_EXP wxString getUsrTempUnit_Plugin(int unit = -1);
841 extern DECL_EXP wxString GetNewGUID();
842 extern "C" DECL_EXP bool PlugIn_GSHHS_CrossesLand(double lat1, double lon1,
843  double lat2, double lon2);
848 extern DECL_EXP void PlugInPlaySound(wxString &sound_file);
849 
850 // API 1.10 Route and Waypoint Support
851 extern DECL_EXP wxBitmap *FindSystemWaypointIcon(wxString &icon_name);
852 extern DECL_EXP bool AddCustomWaypointIcon(wxBitmap *pimage, wxString key,
853  wxString description);
854 
855 extern DECL_EXP bool AddSingleWaypoint(PlugIn_Waypoint *pwaypoint,
856  bool b_permanent = true);
857 extern DECL_EXP bool DeleteSingleWaypoint(wxString &GUID);
858 extern DECL_EXP bool UpdateSingleWaypoint(PlugIn_Waypoint *pwaypoint);
859 
860 extern DECL_EXP bool AddPlugInRoute(PlugIn_Route *proute,
861  bool b_permanent = true);
862 extern DECL_EXP bool DeletePlugInRoute(wxString &GUID);
863 extern DECL_EXP bool UpdatePlugInRoute(PlugIn_Route *proute);
864 
865 extern DECL_EXP bool AddPlugInTrack(PlugIn_Track *ptrack,
866  bool b_permanent = true);
867 extern DECL_EXP bool DeletePlugInTrack(wxString &GUID);
868 extern DECL_EXP bool UpdatePlugInTrack(PlugIn_Track *ptrack);
869 
870 /* API 1.11 */
871 
872 /* API 1.11 adds some more common functions to avoid unnecessary code
873  * duplication */
874 wxColour DECL_EXP GetBaseGlobalColor(wxString colorName);
875 int DECL_EXP OCPNMessageBox_PlugIn(wxWindow *parent, const wxString &message,
876  const wxString &caption = _T("Message"),
877  int style = wxOK, int x = -1, int y = -1);
878 
879 extern DECL_EXP wxString toSDMM_PlugIn(int NEflag, double a,
880  bool hi_precision = true);
881 
882 extern "C" DECL_EXP wxString *GetpPrivateApplicationDataLocation();
883 extern DECL_EXP wxString GetOCPN_ExePath(void);
884 extern "C" DECL_EXP wxString *GetpPlugInLocation();
885 extern DECL_EXP wxString GetPlugInPath(opencpn_plugin *pplugin);
886 
887 extern "C" DECL_EXP int AddChartToDBInPlace(wxString &full_path,
888  bool b_RefreshCanvas);
889 extern "C" DECL_EXP int RemoveChartFromDBInPlace(wxString &full_path);
890 extern DECL_EXP wxString GetLocaleCanonicalName();
891 
892 // API 1.11 adds access to S52 Presentation library
893 // Types
894 
895 // A flag field that defines the object capabilities passed by a chart to
896 // the S52 PLIB
897 
898 #define PLIB_CAPS_LINE_VBO 1
899 #define PLIB_CAPS_LINE_BUFFER 1 << 1
900 #define PLIB_CAPS_SINGLEGEO_BUFFER 1 << 2
901 #define PLIB_CAPS_OBJSEGLIST 1 << 3
902 #define PLIB_CAPS_OBJCATMUTATE 1 << 4
903 
904 class PI_S57Obj;
905 
906 WX_DECLARE_LIST(PI_S57Obj, ListOfPI_S57Obj);
907 
908 // ----------------------------------------------------------------------------
909 // PlugInChartBaseGL
910 // Derived from PlugInChartBase, add OpenGL Vector chart support
911 // ----------------------------------------------------------------------------
912 
913 class DECL_EXP PlugInChartBaseGL : public PlugInChartBase {
914 public:
916  virtual ~PlugInChartBaseGL();
917 
918  virtual int RenderRegionViewOnGL(const wxGLContext &glc,
919  const PlugIn_ViewPort &VPoint,
920  const wxRegion &Region, bool b_use_stencil);
921 
922  virtual ListOfPI_S57Obj *GetObjRuleListAtLatLon(float lat, float lon,
923  float select_radius,
924  PlugIn_ViewPort *VPoint);
925  virtual wxString CreateObjDescriptions(ListOfPI_S57Obj *obj_list);
926 
927  virtual int GetNoCOVREntries();
928  virtual int GetNoCOVRTablePoints(int iTable);
929  virtual int GetNoCOVRTablenPoints(int iTable);
930  virtual float *GetNoCOVRTableHead(int iTable);
931 };
932 
933 // ----------------------------------------------------------------------------
934 // PlugInChartBaseGLPlus2
935 // Derived from PlugInChartBaseGL, add additional chart management methods
936 // ----------------------------------------------------------------------------
937 
938 class DECL_EXP PlugInChartBaseGLPlus2 : public PlugInChartBaseGL {
939 public:
941  virtual ~PlugInChartBaseGLPlus2();
942 
943  virtual ListOfPI_S57Obj *GetLightsObjRuleListVisibleAtLatLon(
944  float lat, float lon, PlugIn_ViewPort *VPoint);
945 };
946 
947 // ----------------------------------------------------------------------------
948 // PlugInChartBaseExtended
949 // Derived from PlugInChartBase, add extended chart support methods
950 // ----------------------------------------------------------------------------
951 
952 class DECL_EXP PlugInChartBaseExtended : public PlugInChartBase {
953 public:
955  virtual ~PlugInChartBaseExtended();
956 
957  virtual int RenderRegionViewOnGL(const wxGLContext &glc,
958  const PlugIn_ViewPort &VPoint,
959  const wxRegion &Region, bool b_use_stencil);
960 
961  virtual wxBitmap &RenderRegionViewOnDCNoText(const PlugIn_ViewPort &VPoint,
962  const wxRegion &Region);
963  virtual bool RenderRegionViewOnDCTextOnly(wxMemoryDC &dc,
964  const PlugIn_ViewPort &VPoint,
965  const wxRegion &Region);
966 
967  virtual int RenderRegionViewOnGLNoText(const wxGLContext &glc,
968  const PlugIn_ViewPort &VPoint,
969  const wxRegion &Region,
970  bool b_use_stencil);
971 
972  virtual int RenderRegionViewOnGLTextOnly(const wxGLContext &glc,
973  const PlugIn_ViewPort &VPoint,
974  const wxRegion &Region,
975  bool b_use_stencil);
976 
977  virtual ListOfPI_S57Obj *GetObjRuleListAtLatLon(float lat, float lon,
978  float select_radius,
979  PlugIn_ViewPort *VPoint);
980  virtual wxString CreateObjDescriptions(ListOfPI_S57Obj *obj_list);
981 
982  virtual int GetNoCOVREntries();
983  virtual int GetNoCOVRTablePoints(int iTable);
984  virtual int GetNoCOVRTablenPoints(int iTable);
985  virtual float *GetNoCOVRTableHead(int iTable);
986 
987  virtual void ClearPLIBTextList();
988 };
989 
990 // ----------------------------------------------------------------------------
991 // PlugInChartBaseExtendedPlus2
992 // Derived from PlugInChartBaseExtended, add additional extended chart support
993 // methods
994 // ----------------------------------------------------------------------------
995 
997 public:
999  virtual ~PlugInChartBaseExtendedPlus2();
1000 
1001  virtual ListOfPI_S57Obj *GetLightsObjRuleListVisibleAtLatLon(
1002  float lat, float lon, PlugIn_ViewPort *VPoint);
1003 };
1004 
1005 class wxArrayOfS57attVal;
1006 
1007 // name of the addressed look up table set (fifth letter)
1008 typedef enum _PI_LUPname {
1009  PI_SIMPLIFIED = 'L', // points
1010  PI_PAPER_CHART = 'R', // points
1011  PI_LINES = 'S', // lines
1012  PI_PLAIN_BOUNDARIES = 'N', // areas
1013  PI_SYMBOLIZED_BOUNDARIES = 'O', // areas
1014  PI_LUPNAME_NUM = 5
1015 } PI_LUPname;
1016 
1017 // display category type
1018 typedef enum _PI_DisCat {
1019  PI_DISPLAYBASE = 'D', //
1020  PI_STANDARD = 'S', //
1021  PI_OTHER = 'O', // O for OTHER
1022  PI_MARINERS_STANDARD = 'M', // Mariner specified
1023  PI_MARINERS_OTHER, // value not defined
1024  PI_DISP_CAT_NUM, // value not defined
1025 } PI_DisCat;
1026 
1027 // Display Priority
1028 typedef enum _PI_DisPrio {
1029  PI_PRIO_NODATA = '0', // no data fill area pattern
1030  PI_PRIO_GROUP1 = '1', // S57 group 1 filled areas
1031  PI_PRIO_AREA_1 = '2', // superimposed areas
1032  PI_PRIO_AREA_2 = '3', // superimposed areas also water features
1033  PI_PRIO_SYMB_POINT = '4', // point symbol also land features
1034  PI_PRIO_SYMB_LINE = '5', // line symbol also restricted areas
1035  PI_PRIO_SYMB_AREA = '6', // area symbol also traffic areas
1036  PI_PRIO_ROUTEING = '7', // routeing lines
1037  PI_PRIO_HAZARDS = '8', // hazards
1038  PI_PRIO_MARINERS = '9', // VRM, EBL, own ship
1039  PI_PRIO_NUM = 10 // number of priority levels
1040 
1041 } PI_DisPrio;
1042 
1043 typedef enum PI_InitReturn {
1044  PI_INIT_OK = 0,
1045  PI_INIT_FAIL_RETRY, // Init failed, retry suggested
1046  PI_INIT_FAIL_REMOVE, // Init failed, suggest remove from further use
1047  PI_INIT_FAIL_NOERROR // Init failed, request no explicit error message
1048 } _PI_InitReturn;
1049 
1051 public:
1052  size_t vbo_offset;
1053  size_t n_points;
1054  int priority;
1055  float lat_max; // segment bounding box
1056  float lat_min;
1057  float lon_max;
1058  float lon_min;
1059  int type;
1060  void *private0;
1061 
1063 };
1064 
1065 class DECL_EXP PI_S57Obj {
1066 public:
1067  // Public Methods
1068  PI_S57Obj();
1069 
1070 public:
1071  // Instance Data
1072  char FeatureName[8];
1073  int Primitive_type;
1074 
1075  char *att_array;
1076  wxArrayOfS57attVal *attVal;
1077  int n_attr;
1078 
1079  int iOBJL;
1080  int Index;
1081 
1082  double x; // for POINT
1083  double y;
1084  double z;
1085  int npt; // number of points as needed by arrays
1086  void *geoPt; // for LINE & AREA not described by PolyTessGeo
1087  double *geoPtz; // an array[3] for MultiPoint, SM with Z, i.e. depth
1088  double *geoPtMulti; // an array[2] for MultiPoint, lat/lon to make bbox
1089  // of decomposed points
1090 
1091  void *pPolyTessGeo;
1092 
1093  double m_lat; // The lat/lon of the object's "reference" point
1094  double m_lon;
1095 
1096  double chart_ref_lat;
1097  double chart_ref_lon;
1098 
1099  double lat_min;
1100  double lat_max;
1101  double lon_min;
1102  double lon_max;
1103 
1104  int Scamin; // SCAMIN attribute decoded during load
1105 
1106  bool bIsClone;
1107  int nRef; // Reference counter, to signal OK for deletion
1108 
1109  bool bIsAton; // This object is an aid-to-navigation
1110  bool bIsAssociable; // This object is DRGARE or DEPARE
1111 
1112  int m_n_lsindex;
1113  int *m_lsindex_array;
1114  int m_n_edge_max_points;
1115  void *m_chart_context;
1116 
1117  PI_DisCat m_DisplayCat;
1118 
1119  void *S52_Context;
1120  PI_S57Obj *child; // child list, used only for MultiPoint Soundings
1121 
1122  PI_S57Obj *next; // List linkage
1123 
1124  // This transform converts from object geometry
1125  // to SM coordinates.
1126  double x_rate; // These auxiliary transform coefficients are
1127  double y_rate; // to be used in GetPointPix() and friends
1128  double x_origin; // on a per-object basis if necessary
1129  double y_origin;
1130 
1131  int auxParm0; // some per-object auxiliary parameters, used for OpenGL
1132  int auxParm1;
1133  int auxParm2;
1134  int auxParm3;
1135 
1136  PI_line_segment_element *m_ls_list;
1137  bool m_bcategory_mutable;
1138  int m_DPRI;
1139 };
1140 
1141 wxString DECL_EXP PI_GetPLIBColorScheme();
1142 int DECL_EXP PI_GetPLIBDepthUnitInt();
1143 int DECL_EXP PI_GetPLIBSymbolStyle();
1144 int DECL_EXP PI_GetPLIBBoundaryStyle();
1145 int DECL_EXP PI_GetPLIBStateHash();
1146 double DECL_EXP PI_GetPLIBMarinerSafetyContour();
1147 bool DECL_EXP PI_GetObjectRenderBox(PI_S57Obj *pObj, double *lat_min,
1148  double *lat_max, double *lon_min,
1149  double *lon_max);
1150 void DECL_EXP PI_UpdateContext(PI_S57Obj *pObj);
1151 
1152 bool DECL_EXP PI_PLIBObjectRenderCheck(PI_S57Obj *pObj, PlugIn_ViewPort *vp);
1153 PI_LUPname DECL_EXP PI_GetObjectLUPName(PI_S57Obj *pObj);
1154 PI_DisPrio DECL_EXP PI_GetObjectDisplayPriority(PI_S57Obj *pObj);
1155 PI_DisCat DECL_EXP PI_GetObjectDisplayCategory(PI_S57Obj *pObj);
1156 void DECL_EXP PI_PLIBSetLineFeaturePriority(PI_S57Obj *pObj, int prio);
1157 void DECL_EXP PI_PLIBPrepareForNewRender(void);
1158 void DECL_EXP PI_PLIBFreeContext(void *pContext);
1159 void DECL_EXP PI_PLIBSetRenderCaps(unsigned int flags);
1160 
1161 bool DECL_EXP PI_PLIBSetContext(PI_S57Obj *pObj);
1162 
1163 int DECL_EXP PI_PLIBRenderObjectToDC(wxDC *pdc, PI_S57Obj *pObj,
1164  PlugIn_ViewPort *vp);
1165 int DECL_EXP PI_PLIBRenderAreaToDC(wxDC *pdc, PI_S57Obj *pObj,
1166  PlugIn_ViewPort *vp, wxRect rect,
1167  unsigned char *pixbuf);
1168 
1169 int DECL_EXP PI_PLIBRenderAreaToGL(const wxGLContext &glcc, PI_S57Obj *pObj,
1170  PlugIn_ViewPort *vp, wxRect &render_rect);
1171 
1172 int DECL_EXP PI_PLIBRenderObjectToGL(const wxGLContext &glcc, PI_S57Obj *pObj,
1173  PlugIn_ViewPort *vp, wxRect &render_rect);
1174 
1175 /* API 1.11 OpenGL Display List and vertex buffer object routines
1176 
1177  Effectively these two routines cancel each other so all
1178  of the translation, scaling and rotation can be done by opengl.
1179 
1180  Display lists need only be built infrequently, but used in each frame
1181  greatly accelerates the speed of rendering. This avoids costly calculations,
1182  and also allows the vertexes to be stored in graphics memory.
1183 
1184  static int dl = 0;
1185  glPushMatrix();
1186  PlugInMultMatrixViewport(current_viewport);
1187  if(dl)
1188  glCallList(dl);
1189  else {
1190  dl = glGenLists(1);
1191  PlugInViewPort norm_viewport = current_viewport;
1192  NormalizeViewPort(norm_viewport);
1193  glNewList(dl, GL_COMPILE_AND_EXECUTE);
1194  ... // use norm_viewport with GetCanvasLLPix here
1195  glEndList();
1196  }
1197  glPopMatrix();
1198  ... // use current_viewport with GetCanvasLLPix again
1199 */
1200 
1201 extern DECL_EXP bool PlugInHasNormalizedViewPort(PlugIn_ViewPort *vp);
1202 extern DECL_EXP void PlugInMultMatrixViewport(PlugIn_ViewPort *vp,
1203  float lat = 0, float lon = 0);
1204 extern DECL_EXP void PlugInNormalizeViewport(PlugIn_ViewPort *vp, float lat = 0,
1205  float lon = 0);
1206 
1207 class wxPoint2DDouble;
1208 extern "C" DECL_EXP void GetDoubleCanvasPixLL(PlugIn_ViewPort *vp,
1209  wxPoint2DDouble *pp, double lat,
1210  double lon);
1211 
1212 /* API 1.13 */
1213 /* API 1.13 adds some more common functions to avoid unnecessary code
1214  * duplication */
1215 
1216 extern DECL_EXP double fromDMM_Plugin(wxString sdms);
1217 extern DECL_EXP void SetCanvasRotation(double rotation);
1218 extern DECL_EXP void SetCanvasProjection(int projection);
1219 extern DECL_EXP bool GetSingleWaypoint(wxString GUID,
1220  PlugIn_Waypoint *pwaypoint);
1221 extern DECL_EXP bool CheckEdgePan_PlugIn(int x, int y, bool dragging,
1222  int margin, int delta);
1223 extern DECL_EXP wxBitmap GetIcon_PlugIn(const wxString &name);
1224 extern DECL_EXP void SetCursor_PlugIn(wxCursor *pPlugin_Cursor = NULL);
1225 extern DECL_EXP wxFont *GetOCPNScaledFont_PlugIn(wxString TextElement,
1226  int default_size = 0);
1227 extern DECL_EXP wxFont GetOCPNGUIScaledFont_PlugIn(wxString item);
1228 extern DECL_EXP double GetOCPNGUIToolScaleFactor_PlugIn(int GUIScaledFactor);
1229 extern DECL_EXP double GetOCPNGUIToolScaleFactor_PlugIn();
1230 extern DECL_EXP float GetOCPNChartScaleFactor_Plugin();
1231 extern DECL_EXP wxColour GetFontColour_PlugIn(wxString TextElement);
1232 
1233 extern DECL_EXP double GetCanvasTilt();
1234 extern DECL_EXP void SetCanvasTilt(double tilt);
1235 
1241 extern DECL_EXP bool PlugInPlaySoundEx(wxString &sound_file,
1242  int deviceIndex = -1);
1243 extern DECL_EXP void AddChartDirectory(wxString &path);
1244 extern DECL_EXP void ForceChartDBUpdate();
1245 extern DECL_EXP void ForceChartDBRebuild();
1246 
1247 extern DECL_EXP wxString GetWritableDocumentsDir(void);
1248 extern DECL_EXP wxDialog *GetActiveOptionsDialog();
1249 extern DECL_EXP wxArrayString GetWaypointGUIDArray(void);
1250 extern DECL_EXP wxArrayString GetIconNameArray(void);
1251 
1252 extern DECL_EXP bool AddPersistentFontKey(wxString TextElement);
1253 extern DECL_EXP wxString GetActiveStyleName();
1254 
1255 extern DECL_EXP wxBitmap GetBitmapFromSVGFile(wxString filename,
1256  unsigned int width,
1257  unsigned int height);
1258 extern DECL_EXP bool IsTouchInterface_PlugIn(void);
1259 
1260 /* Platform optimized File/Dir selector dialogs */
1261 extern DECL_EXP int PlatformDirSelectorDialog(wxWindow *parent,
1262  wxString *file_spec,
1263  wxString Title, wxString initDir);
1264 
1265 extern DECL_EXP int PlatformFileSelectorDialog(wxWindow *parent,
1266  wxString *file_spec,
1267  wxString Title, wxString initDir,
1268  wxString suggestedName,
1269  wxString wildcard);
1270 
1271 /* OpenCPN HTTP File Download PlugIn Interface */
1272 
1273 /* Various method Return Codes, etc */
1274 typedef enum _OCPN_DLStatus {
1275  OCPN_DL_UNKNOWN = -1,
1276  OCPN_DL_NO_ERROR = 0,
1277  OCPN_DL_FAILED = 1,
1278  OCPN_DL_ABORTED = 2,
1279  OCPN_DL_USER_TIMEOUT = 4,
1280  OCPN_DL_STARTED = 8
1281 } OCPN_DLStatus;
1282 
1283 typedef enum _OCPN_DLCondition {
1284  OCPN_DL_EVENT_TYPE_UNKNOWN = -1,
1285  OCPN_DL_EVENT_TYPE_START = 80,
1286  OCPN_DL_EVENT_TYPE_PROGRESS = 81,
1287  OCPN_DL_EVENT_TYPE_END = 82
1288 } OCPN_DLCondition;
1289 
1290 // Style definitions for Synchronous file download modal dialogs, if
1291 // desired. Abstracted from wxCURL package
1295  0x0002,
1297  OCPN_DLDS_SPEED = 0x0008,
1298  OCPN_DLDS_SIZE = 0x0010,
1300  OCPN_DLDS_URL =
1301  0x0020,
1302 
1303  // styles related to the use of wxCurlConnectionSettingsDialog:
1304 
1306  0x0040,
1308  OCPN_DLDS_CONN_SETTINGS_PORT = 0x0080,
1311  0x0100,
1312 
1313  OCPN_DLDS_CONN_SETTINGS_ALL = OCPN_DLDS_CONN_SETTINGS_AUTH |
1316 
1317  OCPN_DLDS_SHOW_ALL = OCPN_DLDS_ELAPSED_TIME | OCPN_DLDS_ESTIMATED_TIME |
1320  OCPN_DLDS_CONN_SETTINGS_ALL,
1321 
1323  OCPN_DLDS_CAN_START = 0x0400,
1326 
1328  0x1000,
1329 
1330  // by default all available features are enabled:
1331  OCPN_DLDS_DEFAULT_STYLE = OCPN_DLDS_CAN_START | OCPN_DLDS_CAN_PAUSE |
1332  OCPN_DLDS_CAN_ABORT | OCPN_DLDS_SHOW_ALL |
1334 };
1335 
1336 #define ONLINE_CHECK_RETRY \
1337  30 // Recheck the Internet connection availability every ONLINE_CHECK_RETRY s
1338 
1339 /* Synchronous (Blocking) download of a single file */
1340 
1341 extern DECL_EXP _OCPN_DLStatus OCPN_downloadFile(
1342  const wxString &url, const wxString &outputFile, const wxString &title,
1343  const wxString &message, const wxBitmap &bitmap, wxWindow *parent,
1344  long style, int timeout_secs);
1345 
1346 /* Asynchronous (Background) download of a single file */
1347 
1348 extern DECL_EXP _OCPN_DLStatus
1349 OCPN_downloadFileBackground(const wxString &url, const wxString &outputFile,
1350  wxEvtHandler *handler, long *handle);
1351 
1352 extern DECL_EXP void OCPN_cancelDownloadFileBackground(long handle);
1353 
1354 /* Synchronous (Blocking) HTTP POST operation for small amounts of data */
1355 
1356 extern DECL_EXP _OCPN_DLStatus OCPN_postDataHttp(const wxString &url,
1357  const wxString &parameters,
1358  wxString &result,
1359  int timeout_secs);
1360 
1361 /* Check whether connection to the Internet is working */
1362 
1363 extern DECL_EXP bool OCPN_isOnline();
1364 
1365 /* Supporting Event for Background downloading */
1366 /* OCPN_downloadEvent Definition */
1367 
1368 /* PlugIn should be ready/able to handle this event after initiating a
1369  * background file transfer
1370  *
1371  * The event as received should be parsed primarily by the getDLEventCondition()
1372  * method. This will allow identification of download start, progress, and end
1373  * states.
1374  *
1375  * Other accessor methods contain status, byte counts, etc.
1376  *
1377  * A PlugIn may safely destroy its EvtHandler after receipt of an
1378  * OCPN_downloadEvent with getDLEventCondition == OCPN_DL_EVENT_TYPE_END
1379  */
1380 
1381 class DECL_EXP OCPN_downloadEvent : public wxEvent {
1382 public:
1383  OCPN_downloadEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
1384  ~OCPN_downloadEvent();
1385 
1386  // accessors
1387  _OCPN_DLStatus getDLEventStatus() { return m_stat; }
1388  OCPN_DLCondition getDLEventCondition() { return m_condition; }
1389 
1390  void setDLEventStatus(_OCPN_DLStatus stat) { m_stat = stat; }
1391  void setDLEventCondition(OCPN_DLCondition cond) { m_condition = cond; }
1392 
1393  void setTotal(long bytes) { m_totalBytes = bytes; }
1394  void setTransferred(long bytes) { m_sofarBytes = bytes; }
1395  long getTotal() { return m_totalBytes; }
1396  long getTransferred() { return m_sofarBytes; }
1397 
1398  void setComplete(bool b_complete) { m_b_complete = b_complete; }
1399  bool getComplete() { return m_b_complete; }
1400 
1401  // required for sending with wxPostEvent()
1402  wxEvent *Clone() const;
1403 
1404 private:
1405  OCPN_DLStatus m_stat;
1406  OCPN_DLCondition m_condition;
1407 
1408  long m_totalBytes;
1409  long m_sofarBytes;
1410  bool m_b_complete;
1411 };
1412 
1413 // extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DOWNLOAD_EVENT;
1414 
1415 #ifdef MAKING_PLUGIN
1416 extern DECL_IMP wxEventType wxEVT_DOWNLOAD_EVENT;
1417 #else
1418 extern DECL_EXP wxEventType wxEVT_DOWNLOAD_EVENT;
1419 #endif
1420 
1421 /* API 1.14 */
1422 /* API 1.14 adds some more common functions to avoid unnecessary code
1423  * duplication */
1424 
1425 bool LaunchDefaultBrowser_Plugin(wxString url);
1426 
1427 // API 1.14 Extra canvas Support
1428 
1429 /* Allow drawing of objects onto other OpenGL canvases */
1430 extern DECL_EXP void PlugInAISDrawGL(wxGLCanvas *glcanvas,
1431  const PlugIn_ViewPort &vp);
1432 extern DECL_EXP bool PlugInSetFontColor(const wxString TextElement,
1433  const wxColour color);
1434 
1435 // API 1.15
1436 extern DECL_EXP double PlugInGetDisplaySizeMM();
1437 
1438 //
1439 extern DECL_EXP wxFont *FindOrCreateFont_PlugIn(
1440  int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight,
1441  bool underline = false, const wxString &facename = wxEmptyString,
1442  wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
1443 
1444 extern DECL_EXP int PlugInGetMinAvailableGshhgQuality();
1445 extern DECL_EXP int PlugInGetMaxAvailableGshhgQuality();
1446 
1447 extern DECL_EXP void PlugInHandleAutopilotRoute(bool enable);
1448 
1449 // API 1.16
1450 //
1466 extern DECL_EXP wxString GetPluginDataDir(const char *plugin_name);
1467 
1468 extern DECL_EXP bool ShuttingDown(void);
1469 
1470 // Support for MUI MultiCanvas model
1471 
1472 extern DECL_EXP wxWindow *PluginGetFocusCanvas();
1473 extern DECL_EXP wxWindow *PluginGetOverlayRenderCanvas();
1474 
1475 extern "C" DECL_EXP void CanvasJumpToPosition(wxWindow *canvas, double lat,
1476  double lon, double scale);
1477 extern "C" DECL_EXP int AddCanvasMenuItem(wxMenuItem *pitem,
1478  opencpn_plugin *pplugin,
1479  const char *name = "");
1480 extern "C" DECL_EXP void RemoveCanvasMenuItem(
1481  int item, const char *name = ""); // Fully remove this item
1482 extern "C" DECL_EXP void SetCanvasMenuItemViz(
1483  int item, bool viz,
1484  const char *name = ""); // Temporarily change context menu options
1485 extern "C" DECL_EXP void SetCanvasMenuItemGrey(int item, bool grey,
1486  const char *name = "");
1487 
1488 // Extract waypoints, routes and tracks
1489 extern DECL_EXP wxString GetSelectedWaypointGUID_Plugin();
1490 extern DECL_EXP wxString GetSelectedRouteGUID_Plugin();
1491 extern DECL_EXP wxString GetSelectedTrackGUID_Plugin();
1492 
1493 extern DECL_EXP std::unique_ptr<PlugIn_Waypoint> GetWaypoint_Plugin(
1494  const wxString &); // doublon with GetSingleWaypoint
1495 extern DECL_EXP std::unique_ptr<PlugIn_Route> GetRoute_Plugin(const wxString &);
1496 extern DECL_EXP std::unique_ptr<PlugIn_Track> GetTrack_Plugin(const wxString &);
1497 
1498 extern DECL_EXP wxWindow *GetCanvasUnderMouse();
1499 extern DECL_EXP int GetCanvasIndexUnderMouse();
1500 // extern DECL_EXP std::vector<wxWindow *> GetCanvasArray();
1501 extern DECL_EXP wxWindow *GetCanvasByIndex(int canvasIndex);
1502 extern DECL_EXP int GetCanvasCount();
1503 extern DECL_EXP bool CheckMUIEdgePan_PlugIn(int x, int y, bool dragging,
1504  int margin, int delta,
1505  int canvasIndex);
1506 extern DECL_EXP void SetMUICursor_PlugIn(wxCursor *pCursor, int canvasIndex);
1507 
1508 // API 1.17
1509 //
1510 extern DECL_EXP wxRect GetMasterToolbarRect();
1511 
1512 enum SDDMFORMAT {
1513  DEGREES_DECIMAL_MINUTES = 0,
1514  DECIMAL_DEGREES,
1515  DEGREES_MINUTES_SECONDS,
1516  END_SDDMFORMATS
1517 };
1518 
1519 extern DECL_EXP int GetLatLonFormat(void);
1520 
1521 // API 1.17
1522 extern "C" DECL_EXP void ZeroXTE();
1523 
1524 // Extended Waypoint manipulation API
1525 class DECL_EXP PlugIn_Waypoint_Ex {
1526 public:
1528  PlugIn_Waypoint_Ex(double lat, double lon, const wxString &icon_ident,
1529  const wxString &wp_name, const wxString &GUID = "",
1530  const double ScaMin = 1e9, const bool bNameVisible = false,
1531  const int nRanges = 0, const double RangeDistance = 1.0,
1532  const wxColor RangeColor = wxColor(255, 0, 0));
1533  ~PlugIn_Waypoint_Ex();
1534  void InitDefaults();
1535 
1536  bool GetFSStatus(); // return "free standing" status
1537  // To be a "free standing waypoint"(FSWP),
1538  // the RoutePoint will have been created by GUI dropping
1539  // a point; by importing a waypoint in a GPX file or by
1540  // the AddSingleWaypoint API.
1541 
1542  int GetRouteMembershipCount(); // Return the number of routes to which this
1543  // WP belongs
1544 
1545  double m_lat;
1546  double m_lon;
1547 
1548  wxString m_GUID;
1549 
1550  wxString m_MarkName;
1551  wxString m_MarkDescription;
1552  wxDateTime m_CreateTime;
1553  bool IsVisible;
1554  bool IsActive;
1555 
1556  double scamin;
1557  bool b_useScamin;
1558  bool IsNameVisible;
1559  int nrange_rings;
1560  double RangeRingSpace;
1561  wxColour RangeRingColor;
1562 
1563  wxString IconName;
1564  wxString IconDescription;
1565 
1566  Plugin_HyperlinkList *m_HyperlinkList;
1567 };
1568 
1569 WX_DECLARE_LIST(PlugIn_Waypoint_Ex, Plugin_WaypointExList);
1570 
1571 class DECL_EXP PlugIn_Route_Ex {
1572 public:
1573  PlugIn_Route_Ex(void);
1574  ~PlugIn_Route_Ex(void);
1575 
1576  wxString m_NameString;
1577  wxString m_StartString;
1578  wxString m_EndString;
1579  wxString m_GUID;
1580  bool m_isActive;
1581  bool m_isVisible;
1582  wxString m_Description;
1583 
1584 
1585  Plugin_WaypointExList *pWaypointList;
1586 };
1587 
1588 extern DECL_EXP wxArrayString GetRouteGUIDArray(void);
1589 extern DECL_EXP wxArrayString GetTrackGUIDArray(void);
1590 
1591 extern DECL_EXP bool GetSingleWaypointEx(wxString GUID,
1592  PlugIn_Waypoint_Ex *pwaypoint);
1593 
1594 extern DECL_EXP bool AddSingleWaypointEx(PlugIn_Waypoint_Ex *pwaypoint,
1595  bool b_permanent = true);
1596 extern DECL_EXP bool UpdateSingleWaypointEx(PlugIn_Waypoint_Ex *pwaypoint);
1597 
1598 extern DECL_EXP bool AddPlugInRouteEx(PlugIn_Route_Ex *proute,
1599  bool b_permanent = true);
1600 extern DECL_EXP bool UpdatePlugInRouteEx(PlugIn_Route_Ex *proute);
1601 
1602 extern DECL_EXP std::unique_ptr<PlugIn_Waypoint_Ex> GetWaypointEx_Plugin(
1603  const wxString &);
1604 extern DECL_EXP std::unique_ptr<PlugIn_Route_Ex> GetRouteEx_Plugin(
1605  const wxString &);
1606 
1607 extern DECL_EXP wxString
1608 GetActiveWaypointGUID(void); // if no active waypoint, returns wxEmptyString
1609 extern DECL_EXP wxString
1610 GetActiveRouteGUID(void); // if no active route, returns wxEmptyString
1611 
1612 // API 1.18
1613 
1614 // Scaled display support, as on some GTK3 and Mac Retina devices
1615 extern DECL_EXP double OCPN_GetDisplayContentScaleFactor();
1616 
1617 // Scaled display support, on Windows devices
1618 extern DECL_EXP double OCPN_GetWinDIPScaleFactor();
1619 
1620 // Comm Priority query support
1621 extern DECL_EXP std::vector<std::string> GetPriorityMaps();
1622 extern DECL_EXP std::vector<std::string> GetActivePriorityIdentifiers();
1623 
1624 extern DECL_EXP int GetGlobalWatchdogTimoutSeconds();
1625 
1626 typedef enum _OBJECT_LAYER_REQ {
1627  OBJECTS_ALL = 0,
1628  OBJECTS_NO_LAYERS,
1629  OBJECTS_ONLY_LAYERS
1630 } OBJECT_LAYER_REQ;
1631 
1632 // FIXME (dave) Implement these
1633 extern DECL_EXP wxArrayString GetRouteGUIDArray(OBJECT_LAYER_REQ req);
1634 extern DECL_EXP wxArrayString GetTrackGUIDArray(OBJECT_LAYER_REQ req);
1635 extern DECL_EXP wxArrayString GetWaypointGUIDArray(OBJECT_LAYER_REQ req);
1636 
1639 /* Listening to messages. */
1640 class ObservableListener;
1641 
1643 class ObservedEvt;
1644 
1645 // This is a verbatim copy from observable_evt.h, don't define twice.
1646 #ifndef OBSERVABLE_EVT_H
1647 #define OBSERVABLE_EVT_H
1648 
1649 wxDECLARE_EVENT(obsNOTIFY, ObservedEvt);
1650 
1652 class ObservedEvt : public wxCommandEvent {
1653 public:
1654  ObservedEvt(wxEventType commandType = obsNOTIFY, int id = 0)
1655  : wxCommandEvent(commandType, id) {}
1656  ObservedEvt(const ObservedEvt &event) : wxCommandEvent(event) {
1657  this->m_shared_ptr = event.m_shared_ptr;
1658  }
1659 
1660  wxEvent *Clone() const { return new ObservedEvt(*this); }
1661 
1662  std::shared_ptr<const void> GetSharedPtr() const { return m_shared_ptr; }
1663 
1664  void SetSharedPtr(std::shared_ptr<const void> p) { m_shared_ptr = p; }
1665 
1666 private:
1667  std::shared_ptr<const void> m_shared_ptr;
1668 };
1669 
1670 #endif // OBSERVABLE_EVT_H
1671 
1672 class ObservableListener;
1673 
1675 struct NMEA2000Id {
1676  const uint64_t id;
1677  NMEA2000Id(int value) : id(static_cast<uint64_t>(value)){};
1678 };
1679 
1680 extern DECL_EXP std::shared_ptr<ObservableListener> GetListener(
1681  NMEA2000Id id, wxEventType ev, wxEvtHandler *handler);
1682 
1684 struct NMEA0183Id {
1685  const std::string id;
1686  NMEA0183Id(const std::string &s) : id(s){};
1687 };
1688 
1689 extern DECL_EXP std::shared_ptr<ObservableListener> GetListener(
1690  NMEA0183Id id, wxEventType ev, wxEvtHandler *handler);
1691 
1693 struct SignalkId {
1694  const std::string id;
1695  SignalkId(const std::string &s) : id(s){};
1696 };
1697 
1698 extern DECL_EXP std::shared_ptr<ObservableListener> GetListener(
1699  SignalkId id, wxEventType ev, wxEvtHandler *handler);
1700 
1716 extern DECL_EXP std::vector<uint8_t> GetN2000Payload(NMEA2000Id id,
1717  ObservedEvt ev);
1718 
1735 std::shared_ptr<void> GetSignalkPayload(ObservedEvt ev);
1736 
1741 extern DECL_EXP std::string GetN2000Source(NMEA2000Id id, ObservedEvt ev);
1742 
1744 extern DECL_EXP std::string GetN0183Payload(NMEA0183Id id, ObservedEvt ev);
1745 
1747 struct NavDataId {
1748  const int type;
1749  NavDataId() : type(0) {}
1750 };
1751 
1752 extern DECL_EXP std::shared_ptr<ObservableListener> GetListener(
1753  NavDataId id, wxEventType ev, wxEvtHandler *handler);
1754 
1757  double lat;
1758  double lon;
1759  double sog;
1760  double cog;
1761  double var;
1762  double hdt;
1763  time_t time;
1764 };
1765 
1767 extern DECL_EXP PluginNavdata GetEventNavdata(ObservedEvt ev);
1768 
1770 /*
1771  * Plugins may access comm ports for direct output.
1772  * The general program flow for a plugin may look something like this
1773  * pseudo-code:
1774  * 1. Plugin will query OCPN core for a list of active comm drivers.
1775  * 2. Plugin will inspect the list, and query OCPN core for driver
1776  * attributes.
1777  * 3. Plugin will select a comm driver with appropriate attributes for output.
1778  * 4. Plugin will register a list of PGNs expected to be transmitted
1779  * (N2K specific)
1780  * 5. Plugin may then send a payload buffer to a specific comm driver for
1781  * output as soon as possible.
1782  *
1783  * The mechanism for specifying a particular comm driver uses the notion of
1784  * "handles". Each active comm driver has an associated opaque handle, managed
1785  * by OCPN core. All references by a plugin to a driver are by means of its
1786  * handle. Handles should be considered to be "opaque", meaning that the exact
1787  * contents of the handle are of no specific value to the plugin, and only
1788  * have meaning to the OCPN core management of drivers.
1789  */
1790 
1792 typedef std::string DriverHandle;
1793 
1796 typedef enum CommDriverResult {
1797  RESULT_COMM_NO_ERROR = 0,
1798  RESULT_COMM_INVALID_HANDLE,
1799  RESULT_COMM_INVALID_PARMS,
1800  RESULT_COMM_TX_ERROR,
1801  RESULT_COMM_REGISTER_GATEWAY_ERROR,
1802  RESULT_COMM_REGISTER_PGN_ERROR
1804 
1806 extern DECL_EXP std::vector<DriverHandle> GetActiveDrivers();
1807 
1809 /* Driver attributes are available from OCPN core as a hash map of
1810  * tag->attribute pairs. There is a defined set of common tags guaranteed
1811  * for every driver. Both tags and attributes are defined as std::string.
1812  * Here is the list of common tag-attribute pairs.
1813  *
1814  * Tag Attribute definition
1815  * ---------- --------------------
1816  * "protocol" Comm bus device protocol, such as "NMEA0183", "NMEA2000"
1817  *
1818  *
1819  */
1820 
1822 extern DECL_EXP const std::unordered_map<std::string, std::string>
1823  GetAttributes(DriverHandle handle);
1824 
1825 /* Writing to a specific driver */
1826 
1827 /* Comm drivers on bus protocols other than NMEA2000 may write directly to the
1828  * port * using a simple call. The physical write operation will be queued,
1829  * and executed in order as bandwidth allows.
1830  * Return value is number of bytes queued for transmission.
1831  */
1832 extern DECL_EXP CommDriverResult WriteCommDriver(
1833  DriverHandle handle,
1834  const std::shared_ptr <std::vector<uint8_t>> &payload);
1835 
1837 extern DECL_EXP CommDriverResult WriteCommDriverN2K(
1838  DriverHandle handle, int PGN, int destinationCANAddress, int priority,
1839  const std::shared_ptr <std::vector<uint8_t>> &payload);
1840 
1850 extern DECL_EXP CommDriverResult RegisterTXPGNs(DriverHandle handle,
1851  std::vector<int> &pgn_list);
1852 
1853 
1854 // API 1.19
1855 //
1856 
1858 struct PluginMsgId {
1859  const std::string id;
1860  PluginMsgId(const std::string &s) : id(s){};
1861 };
1862 
1863 extern DECL_EXP std::shared_ptr<ObservableListener> GetListener(
1864  PluginMsgId id, wxEventType ev, wxEvtHandler *handler);
1865 
1866 extern DECL_EXP std::string GetPluginMsgPayload(PluginMsgId id, ObservedEvt ev);
1867 #endif //_PLUGIN_H_
Keeps listening over it's lifespan, removes itself on destruction.
Definition: observable.h:133
Adds a std::shared<void> element to wxCommandEvent.
Definition: ocpn_plugin.h:1652
CommDriverResult
Error return values
Definition: ocpn_plugin.h:1796
std::shared_ptr< void > GetSignalkPayload(ObservedEvt ev)
Get SignalK status payload after receiving a message.
Definition: plugin_api.cpp:68
DECL_EXP std::vector< uint8_t > GetN2000Payload(NMEA2000Id id, ObservedEvt ev)
Return N2K payload for a received n2000 message of type id in ev.
Definition: plugin_api.cpp:47
DECL_EXP CommDriverResult WriteCommDriverN2K(DriverHandle handle, int PGN, int destinationCANAddress, int priority, const std::shared_ptr< std::vector< uint8_t >> &payload)
Send a PGN message to an NMEA2000 address.
Definition: plugin_api.cpp:195
DECL_EXP const std::unordered_map< std::string, std::string > GetAttributes(DriverHandle handle)
Query a specific driver for attributes
Definition: plugin_api.cpp:148
DECL_EXP std::string GetN2000Source(NMEA2000Id id, ObservedEvt ev)
Return source identifier (iface) of a received n2000 message of type id in ev.
Definition: plugin_api.cpp:52
DECL_EXP std::vector< std::string > GetPriorityMaps()
Comm Priority query support methods
OCPN_DLDialogStyle
Definition: ocpn_plugin.h:1292
@ OCPN_DLDS_CONN_SETTINGS_AUTH
The dialog allows the user to change the authentication settings.
Definition: ocpn_plugin.h:1305
@ OCPN_DLDS_CAN_START
The transfer won't start automatically.
Definition: ocpn_plugin.h:1323
@ OCPN_DLDS_URL
The dialog shows the URL involved in the transfer.
Definition: ocpn_plugin.h:1300
@ OCPN_DLDS_AUTO_CLOSE
The dialog auto closes when transfer is complete.
Definition: ocpn_plugin.h:1327
@ OCPN_DLDS_CAN_ABORT
The transfer can be aborted by the user.
Definition: ocpn_plugin.h:1322
@ OCPN_DLDS_ESTIMATED_TIME
The dialog shows the estimated total time.
Definition: ocpn_plugin.h:1294
@ OCPN_DLDS_SIZE
The dialog shows the size of the resource to download/upload.
Definition: ocpn_plugin.h:1298
@ OCPN_DLDS_CONN_SETTINGS_PROXY
The dialog allows the user to change the proxy settings.
Definition: ocpn_plugin.h:1310
@ OCPN_DLDS_REMAINING_TIME
The dialog shows the remaining time.
Definition: ocpn_plugin.h:1296
@ OCPN_DLDS_SPEED
The dialog shows the transfer speed.
Definition: ocpn_plugin.h:1297
@ OCPN_DLDS_ELAPSED_TIME
The dialog shows the elapsed time.
Definition: ocpn_plugin.h:1293
@ OCPN_DLDS_CAN_PAUSE
The transfer can be paused.
Definition: ocpn_plugin.h:1325
@ OCPN_DLDS_CONN_SETTINGS_PORT
The dialog allows the user to change the port for the transfer.
Definition: ocpn_plugin.h:1308
DECL_EXP std::string GetN0183Payload(NMEA0183Id id, ObservedEvt ev)
Return payload in a received n0183 message of type id in ev.
Definition: plugin_api.cpp:57
std::string DriverHandle
Plugin API supporting direct access to comm drivers for output purposes.
Definition: ocpn_plugin.h:1792
DECL_EXP PluginNavdata GetEventNavdata(ObservedEvt ev)
Return BasicNavDataMsg decoded data available in ev.
Definition: plugin_api.cpp:120
DECL_EXP int GetGlobalWatchdogTimoutSeconds()
Comm Global Watchdog Query
DECL_EXP bool PlugInPlaySoundEx(wxString &sound_file, int deviceIndex=-1)
Start playing a sound file asynchronously.
enum CommDriverResult _CommDriverResult
Error return values
DECL_EXP void PlugInPlaySound(wxString &sound_file)
Start playing a sound file asynchronously.
DECL_EXP std::vector< DriverHandle > GetActiveDrivers()
Query OCPN core for a list of active drivers
Definition: plugin_api.cpp:136
DECL_EXP CommDriverResult RegisterTXPGNs(DriverHandle handle, std::vector< int > &pgn_list)
Special NMEA2000 requirements NMEA2000 bus protocol device management requires that devices writing o...
Definition: plugin_api.cpp:220
DECL_EXP wxString GetPluginDataDir(const char *plugin_name)
Return the plugin data directory for a given directory name.
Facade for NavAddr0183.
Definition: ocpn_plugin.h:1684
Facade for NavAddr2000.
Definition: ocpn_plugin.h:1675
Facade for BasicNavDataMsg.
Definition: ocpn_plugin.h:1747
Facade for NavAddrPluginMsg.
Definition: ocpn_plugin.h:1858
Available decoded data for plugins.
Definition: ocpn_plugin.h:1756
Facade for NavAddrSignalK.
Definition: ocpn_plugin.h:1693
Definition: Quilt.cpp:867