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