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 55 #ifdef ocpnUSE_SVG 56 #include <wx/bitmap.h> 57 #endif // ocpnUSE_SVG 58 59 #include <memory> 60 #include <vector> 61 62 class 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 17 70 71 // Fwd Definitions 72 class wxFileConfig; 73 class wxNotebook; 74 class wxFont; 75 class wxAuiManager; 76 class wxScrolledWindow; 77 class 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 // Some PlugIn API interface object class definitions 109 //---------------------------------------------------------------------------------------------------------- 110 enum PI_ColorScheme 111 { 112 PI_GLOBAL_COLOR_SCHEME_RGB, 113 PI_GLOBAL_COLOR_SCHEME_DAY, 114 PI_GLOBAL_COLOR_SCHEME_DUSK, 115 PI_GLOBAL_COLOR_SCHEME_NIGHT, 116 PI_N_COLOR_SCHEMES 117 }; 118 119 class PlugIn_ViewPort 120 { 121 public: 122 double clat; // center point 123 double clon; 124 double view_scale_ppm; 125 double skew; 126 double rotation; 127 128 float chart_scale; // conventional chart displayed scale 129 130 int pix_width; 131 int pix_height; 132 wxRect rv_rect; 133 bool b_quilt; 134 int m_projection_type; 135 136 double lat_min, lat_max, lon_min, lon_max; 137 138 bool bValid; // This VP is valid 139 }; 140 141 class PlugIn_Position_Fix 142 { 143 public: 144 double Lat; 145 double Lon; 146 double Cog; 147 double Sog; 148 double Var; // Variation, typically from RMC message 149 time_t FixTime; 150 int nSats; 151 }; 152 153 class PlugIn_Position_Fix_Ex 154 { 155 public: 156 double Lat; 157 double Lon; 158 double Cog; 159 double Sog; 160 double Var; // Variation, typically from RMC message 161 double Hdm; 162 double Hdt; 163 time_t FixTime; 164 int nSats; 165 }; 166 167 class Plugin_Active_Leg_Info 168 { 169 public: 170 double Xte; // Left side of the track -> negative XTE 171 double Btw; 172 double Dtw; 173 wxString wp_name; // Name of destination waypoint for active leg 174 bool arrival; // True when within arrival circle 175 }; 176 177 // Describe AIS Alarm state 178 enum plugin_ais_alarm_type 179 { 180 PI_AIS_NO_ALARM = 0, 181 PI_AIS_ALARM_SET, 182 PI_AIS_ALARM_ACKNOWLEDGED 183 184 }; 185 186 187 class PlugIn_AIS_Target 188 { 189 public: 190 191 int MMSI; 192 int Class; 193 int NavStatus; 194 double SOG; 195 double COG; 196 double HDG; 197 double Lon; 198 double Lat; 199 int ROTAIS; 200 char CallSign[8]; // includes terminator 201 char ShipName[21]; 202 unsigned char ShipType; 203 int IMO; 204 205 double Range_NM; 206 double Brg; 207 208 // Per target collision parameters 209 bool bCPA_Valid; 210 double TCPA; // Minutes 211 double CPA; // Nautical Miles 212 213 plugin_ais_alarm_type alarm_state; 214 }; 215 216 217 // ChartType constants 218 typedef enum ChartTypeEnumPI 219 { 220 PI_CHART_TYPE_UNKNOWN = 0, 221 PI_CHART_TYPE_DUMMY, 222 PI_CHART_TYPE_DONTCARE, 223 PI_CHART_TYPE_KAP, 224 PI_CHART_TYPE_GEO, 225 PI_CHART_TYPE_S57, 226 PI_CHART_TYPE_CM93, 227 PI_CHART_TYPE_CM93COMP, 228 PI_CHART_TYPE_PLUGIN 229 }_ChartTypeEnumPI; 230 231 // ChartFamily constants 232 typedef enum ChartFamilyEnumPI 233 { 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 { 243 PI_DEPTH_UNIT_UNKNOWN, 244 PI_DEPTH_UNIT_FEET, 245 PI_DEPTH_UNIT_METERS, 246 PI_DEPTH_UNIT_FATHOMS 247 }_ChartDepthUnitTypePI; 248 249 // Projection type enum 250 typedef enum OcpnProjTypePI 251 { 252 PI_PROJECTION_UNKNOWN, 253 PI_PROJECTION_MERCATOR, 254 PI_PROJECTION_TRANSVERSE_MERCATOR, 255 PI_PROJECTION_POLYCONIC, 256 257 PI_PROJECTION_ORTHOGRAPHIC, 258 PI_PROJECTION_POLAR, 259 PI_PROJECTION_STEREOGRAPHIC, 260 PI_PROJECTION_GNOMONIC, 261 PI_PROJECTION_EQUIRECTANGULAR 262 }_OcpnProjTypePI; 263 264 typedef struct _ExtentPI{ 265 double SLAT; 266 double WLON; 267 double NLAT; 268 double ELON; 269 }ExtentPI; 270 271 // PlugInChartBase::Init() init_flags constants 272 #define PI_FULL_INIT 0 273 #define PI_HEADER_ONLY 1 274 #define PI_THUMB_ONLY 2 275 276 277 // ---------------------------------------------------------------------------- 278 // PlugInChartBase 279 // This class is the base class for Plug-able chart types 280 // ---------------------------------------------------------------------------- 281 282 class DECL_EXP PlugInChartBase : public wxObject 283 { 284 public: 285 // These methods Must be overriden in any derived class 286 PlugInChartBase(); 287 virtual ~PlugInChartBase(); 288 289 virtual wxString GetFileSearchMask(void); 290 291 virtual int Init( const wxString& full_path, int init_flags ); 292 virtual void SetColorScheme(int cs, bool bApplyImmediate); 293 294 virtual double GetNormalScaleMin(double canvas_scale_factor, bool b_allow_overzoom); 295 virtual double GetNormalScaleMax(double canvas_scale_factor, int canvas_width); 296 virtual double GetNearestPreferredScalePPM(double target_scale_ppm); 297 298 virtual bool GetChartExtent(ExtentPI *pext); 299 300 virtual wxBitmap &RenderRegionView(const PlugIn_ViewPort& VPoint, const wxRegion &Region); 301 302 virtual bool AdjustVP(PlugIn_ViewPort &vp_last, PlugIn_ViewPort &vp_proposed); 303 304 virtual void GetValidCanvasRegion(const PlugIn_ViewPort& VPoint, wxRegion *pValidRegion); 305 GetCOVREntries()306 virtual int GetCOVREntries(){ return 0; } GetCOVRTablePoints(int iTable)307 virtual int GetCOVRTablePoints(int iTable) { return 0; } GetCOVRTablenPoints(int iTable)308 virtual int GetCOVRTablenPoints(int iTable){ return 0; } GetCOVRTableHead(int iTable)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 variables are maintained GetFullPath()314 virtual wxString GetFullPath() const { return m_FullPath;} GetChartType()315 virtual ChartTypeEnumPI GetChartType() { return m_ChartType;} GetChartFamily()316 virtual ChartFamilyEnumPI GetChartFamily() { return m_ChartFamily;} GetChartProjection()317 virtual OcpnProjTypePI GetChartProjection() { return m_projection;} GetName()318 virtual wxString GetName() { return m_Name;} GetDescription()319 virtual wxString GetDescription() { return m_Description;} GetID()320 virtual wxString GetID() { return m_ID;} GetSE()321 virtual wxString GetSE() { return m_SE;} GetDepthUnits()322 virtual wxString GetDepthUnits() { return m_DepthUnits;} GetSoundingsDatum()323 virtual wxString GetSoundingsDatum() { return m_SoundingsDatum;} GetDatumString()324 virtual wxString GetDatumString() { return m_datum_str;} GetExtraInfo()325 virtual wxString GetExtraInfo() { return m_ExtraInfo; } GetPubDate()326 virtual wxString GetPubDate() { return m_PubYear;} GetChartErrorFactor()327 virtual double GetChartErrorFactor() { return m_Chart_Error_Factor;} GetDepthUnitId()328 virtual ChartDepthUnitTypePI GetDepthUnitId() { return m_depth_unit_id;} IsReadyToRender()329 virtual bool IsReadyToRender() { return m_bReadyToRender;} GetNativeScale()330 virtual int GetNativeScale() { return m_Chart_Scale; }; GetChartSkew()331 virtual double GetChartSkew() { return m_Chart_Skew; } GetEditionDate(void)332 virtual wxDateTime GetEditionDate(void) { return m_EdDate;} 333 334 // Methods pertaining to CHART_FAMILY_RASTER type PlugIn charts only 335 virtual void ComputeSourceRectangle(const PlugIn_ViewPort &vp, 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, double &pixy); 341 virtual void chartpix_to_latlong(double pixx, double pixy, double *plat, double *plon); 342 343 protected: 344 ChartTypeEnumPI m_ChartType; 345 ChartFamilyEnumPI m_ChartFamily; 346 347 wxString m_FullPath; 348 OcpnProjTypePI m_projection; 349 int m_Chart_Scale; 350 double m_Chart_Skew; 351 352 wxDateTime m_EdDate; 353 bool m_bReadyToRender; 354 355 wxString m_Name; 356 wxString m_Description; 357 wxString m_ID; 358 wxString m_SE; 359 wxString m_SoundingsDatum; 360 wxString m_datum_str; 361 wxString m_PubYear; 362 wxString m_DepthUnits; 363 wxString m_ExtraInfo; 364 365 ChartDepthUnitTypePI m_depth_unit_id; 366 367 double m_Chart_Error_Factor; 368 369 370 }; 371 372 373 374 375 376 // Declare an array of PlugIn_AIS_Targets 377 WX_DEFINE_ARRAY_PTR(PlugIn_AIS_Target *, ArrayOfPlugIn_AIS_Targets); 378 379 380 381 //---------------------------------------------------------------------------------------------------------- 382 // The Generic PlugIn Interface Class Definition 383 // 384 // This is a virtual class. 385 // opencpn PlugIns must derive from this class. 386 // There are two types of methods in this class 387 // a. Required...must be overridden and implemented by PlugIns 388 // b. Optional..may be overridden by PlugIns 389 390 // PlugIns must implement optional method overrides consistent with their 391 // declared capabilities flag as returned by Init(). 392 //---------------------------------------------------------------------------------------------------------- 393 class DECL_EXP opencpn_plugin 394 { 395 396 public: opencpn_plugin(void * pmgr)397 opencpn_plugin(void *pmgr) {} 398 virtual ~opencpn_plugin(); 399 400 // Public API to the PlugIn class 401 402 // This group of methods is required, and will be called by the opencpn host 403 // opencpn PlugIns must implement this group 404 virtual int Init(void); // Return the PlugIn Capabilites flag 405 virtual bool DeInit(void); 406 407 virtual int GetAPIVersionMajor(); 408 virtual int GetAPIVersionMinor(); 409 virtual int GetPlugInVersionMajor(); 410 virtual int GetPlugInVersionMinor(); 411 virtual wxBitmap *GetPlugInBitmap(); 412 413 // These three methods should produce valid, meaningful strings always 414 // ---EVEN IF--- the PlugIn has not (yet) been initialized. 415 // They are used by the PlugInManager GUI 416 virtual wxString GetCommonName(); 417 virtual wxString GetShortDescription(); 418 virtual wxString GetLongDescription(); 419 420 // This group is optional. 421 // PlugIns may override any of these methods as required 422 423 virtual void SetDefaults(void); //This will be called upon enabling a PlugIn via the user Dialog 424 //It gives a chance to setup any default options and behavior 425 426 virtual int GetToolbarToolCount(void); 427 428 virtual int GetToolboxPanelCount(void); 429 virtual void SetupToolboxPanel(int page_sel, wxNotebook* pnotebook); 430 virtual void OnCloseToolboxPanel(int page_sel, int ok_apply_cancel); 431 432 virtual void ShowPreferencesDialog( wxWindow* parent ); 433 434 virtual bool RenderOverlay(wxMemoryDC *pmdc, PlugIn_ViewPort *vp); 435 virtual void SetCursorLatLon(double lat, double lon); 436 virtual void SetCurrentViewPort(PlugIn_ViewPort &vp); 437 438 virtual void SetPositionFix(PlugIn_Position_Fix &pfix); 439 virtual void SetNMEASentence(wxString &sentence); 440 virtual void SetAISSentence(wxString &sentence); 441 442 virtual void ProcessParentResize(int x, int y); 443 virtual void SetColorScheme(PI_ColorScheme cs); 444 445 virtual void OnToolbarToolCallback(int id); 446 virtual void OnContextMenuItemCallback(int id); 447 448 virtual void UpdateAuiStatus(void); 449 450 virtual wxArrayString GetDynamicChartClassNameArray(void); 451 }; 452 453 454 // the types of the class factories used to create PlugIn instances 455 typedef opencpn_plugin* create_t(void*); 456 typedef void destroy_t(opencpn_plugin*); 457 458 class DECL_EXP opencpn_plugin_16 : public opencpn_plugin 459 { 460 public: 461 opencpn_plugin_16(void *pmgr); 462 virtual ~opencpn_plugin_16(); 463 464 virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp); 465 466 virtual void SetPluginMessage(wxString &message_id, wxString &message_body); 467 468 }; 469 470 class DECL_EXP opencpn_plugin_17 : public opencpn_plugin 471 { 472 public: 473 opencpn_plugin_17(void *pmgr); 474 virtual ~opencpn_plugin_17(); 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 483 class DECL_EXP opencpn_plugin_18 : public opencpn_plugin 484 { 485 public: 486 opencpn_plugin_18(void *pmgr); 487 virtual ~opencpn_plugin_18(); 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 496 class DECL_EXP opencpn_plugin_19 : public opencpn_plugin_18 497 { 498 public: 499 opencpn_plugin_19(void *pmgr); 500 virtual ~opencpn_plugin_19(); 501 502 virtual void OnSetupOptions(void); 503 }; 504 505 class DECL_EXP opencpn_plugin_110 : public opencpn_plugin_19 506 { 507 public: 508 opencpn_plugin_110(void *pmgr); 509 virtual ~opencpn_plugin_110(); 510 511 virtual void LateInit(void); // If WANTS_LATE_INIT is returned by Init() 512 }; 513 514 class DECL_EXP opencpn_plugin_111 : public opencpn_plugin_110 515 { 516 public: 517 opencpn_plugin_111(void *pmgr); 518 virtual ~opencpn_plugin_111(); 519 520 }; 521 522 class DECL_EXP opencpn_plugin_112 : public opencpn_plugin_111 523 { 524 public: 525 opencpn_plugin_112(void *pmgr); 526 virtual ~opencpn_plugin_112(); 527 528 virtual bool MouseEventHook( wxMouseEvent &event ); 529 virtual void SendVectorChartObjectInfo(wxString &chart, wxString &feature, wxString &objname, double lat, double lon, double scale, int nativescale); 530 531 }; 532 533 class DECL_EXP opencpn_plugin_113 : public opencpn_plugin_112 534 { 535 public: 536 opencpn_plugin_113(void *pmgr); 537 virtual ~opencpn_plugin_113(); 538 539 virtual bool KeyboardEventHook( wxKeyEvent &event ); 540 virtual void OnToolbarToolDownCallback(int id); 541 virtual void OnToolbarToolUpCallback(int id); 542 }; 543 544 class DECL_EXP opencpn_plugin_114 : public opencpn_plugin_113 545 { 546 public: 547 opencpn_plugin_114(void *pmgr); 548 virtual ~opencpn_plugin_114(); 549 550 }; 551 552 class DECL_EXP opencpn_plugin_115 : public opencpn_plugin_114 553 { 554 public: 555 opencpn_plugin_115(void *pmgr); 556 virtual ~opencpn_plugin_115(); 557 }; 558 559 class DECL_EXP opencpn_plugin_116 : public opencpn_plugin_115 560 { 561 public: 562 opencpn_plugin_116(void *pmgr); 563 virtual ~opencpn_plugin_116(); 564 virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex); 565 virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex); 566 virtual void PrepareContextMenu( int canvasIndex); 567 568 }; 569 570 class DECL_EXP opencpn_plugin_117 : public opencpn_plugin_116 571 { 572 public: 573 opencpn_plugin_117(void *pmgr); 574 /* 575 * Forms a semantic version together with GetPlugInVersionMajor() and 576 * GetPlugInVersionMinor(), see https://semver.org/ 577 */ 578 virtual int GetPlugInVersionPatch(); 579 580 /** Post-release version part, extends the semver spec. */ 581 virtual int GetPlugInVersionPost(); 582 583 /** Pre-release tag version part, see GetPlugInVersionPatch() */ 584 virtual const char* GetPlugInVersionPre(); 585 586 /** Build version part see GetPlugInVersionPatch(). */ 587 virtual const char* GetPlugInVersionBuild(); 588 589 /*Provide active leg data to plugins*/ 590 virtual void SetActiveLegInfo(Plugin_Active_Leg_Info &leg_info); 591 }; 592 //------------------------------------------------------------------ 593 // Route and Waypoint PlugIn support 594 // 595 //------------------------------------------------------------------ 596 597 class DECL_EXP Plugin_Hyperlink 598 { 599 public: 600 wxString DescrText; 601 wxString Link; 602 wxString Type; 603 }; 604 605 WX_DECLARE_LIST(Plugin_Hyperlink, Plugin_HyperlinkList); 606 607 608 609 class DECL_EXP PlugIn_Waypoint 610 { 611 public: 612 PlugIn_Waypoint(); 613 PlugIn_Waypoint(double lat, double lon, 614 const wxString& icon_ident, const wxString& wp_name, 615 const wxString& GUID = _T("") ); 616 ~PlugIn_Waypoint(); 617 618 double m_lat; 619 double m_lon; 620 621 wxString m_GUID; 622 623 wxString m_MarkName; 624 wxString m_MarkDescription; 625 wxDateTime m_CreateTime; 626 bool m_IsVisible; 627 628 wxString m_IconName; 629 630 Plugin_HyperlinkList *m_HyperlinkList; 631 632 }; 633 634 WX_DECLARE_LIST(PlugIn_Waypoint, Plugin_WaypointList); 635 636 class DECL_EXP PlugIn_Route 637 { 638 public: 639 PlugIn_Route(void); 640 ~PlugIn_Route(void); 641 642 wxString m_NameString; 643 wxString m_StartString; 644 wxString m_EndString; 645 wxString m_GUID; 646 647 Plugin_WaypointList *pWaypointList; 648 }; 649 650 class DECL_EXP PlugIn_Track 651 { 652 public: 653 PlugIn_Track(void); 654 ~PlugIn_Track(void); 655 656 wxString m_NameString; 657 wxString m_StartString; 658 wxString m_EndString; 659 wxString m_GUID; 660 661 Plugin_WaypointList *pWaypointList; 662 }; 663 664 665 666 //---------------------------------------------------------------------------------------------------------- 667 // The PlugIn CallBack API Definition 668 // 669 // The API back up to the PlugIn Manager 670 // PlugIns may call these static functions as necessary for system services 671 // 672 //---------------------------------------------------------------------------------------------------------- 673 674 675 extern "C" DECL_EXP int InsertPlugInTool(wxString label, wxBitmap *bitmap, wxBitmap *bmpRollover, wxItemKind kind, 676 wxString shortHelp, wxString longHelp, wxObject *clientData, int position, 677 int tool_sel, opencpn_plugin *pplugin); 678 extern "C" DECL_EXP void RemovePlugInTool(int tool_id); 679 extern "C" DECL_EXP void SetToolbarToolViz(int item, bool viz); // Temporarily change toolbar tool viz 680 extern "C" DECL_EXP void SetToolbarItemState(int item, bool toggle); 681 extern "C" DECL_EXP void SetToolbarToolBitmaps(int item, wxBitmap *bitmap, wxBitmap *bmpRollover); 682 683 extern "C" DECL_EXP int InsertPlugInToolSVG(wxString label, wxString SVGfile, wxString SVGfileRollover, wxString SVGfileToggled, 684 wxItemKind kind, wxString shortHelp, wxString longHelp, 685 wxObject *clientData, int position, int tool_sel, opencpn_plugin *pplugin); 686 extern "C" DECL_EXP void SetToolbarToolBitmapsSVG(int item, wxString SVGfile, 687 wxString SVGfileRollover, 688 wxString SVGfileToggled ); 689 690 extern "C" DECL_EXP int AddCanvasContextMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin ); 691 extern "C" DECL_EXP void RemoveCanvasContextMenuItem(int item); // Fully remove this item 692 extern "C" DECL_EXP void SetCanvasContextMenuItemViz(int item, bool viz); // Temporarily change context menu ptions 693 extern "C" DECL_EXP void SetCanvasContextMenuItemGrey(int item, bool grey); 694 695 696 extern "C" DECL_EXP wxFileConfig *GetOCPNConfigObject(void); 697 698 extern "C" DECL_EXP void RequestRefresh(wxWindow *); 699 extern "C" DECL_EXP bool GetGlobalColor(wxString colorName, wxColour *pcolour); 700 701 extern "C" DECL_EXP void GetCanvasPixLL(PlugIn_ViewPort *vp, wxPoint *pp, double lat, double lon); 702 extern "C" DECL_EXP void GetCanvasLLPix( PlugIn_ViewPort *vp, wxPoint p, double *plat, double *plon); 703 704 extern "C" DECL_EXP wxWindow *GetOCPNCanvasWindow(); 705 706 extern "C" DECL_EXP wxFont *OCPNGetFont(wxString TextElement, int default_size); 707 708 extern "C" DECL_EXP wxString *GetpSharedDataLocation(); 709 710 extern "C" DECL_EXP ArrayOfPlugIn_AIS_Targets *GetAISTargetArray(void); 711 712 extern "C" DECL_EXP wxAuiManager *GetFrameAuiManager(void); 713 714 extern "C" DECL_EXP bool AddLocaleCatalog( wxString catalog ); 715 716 extern "C" DECL_EXP void PushNMEABuffer( wxString str ); 717 718 extern DECL_EXP wxXmlDocument GetChartDatabaseEntryXML(int dbIndex, bool b_getGeom); 719 720 extern DECL_EXP bool UpdateChartDBInplace(wxArrayString dir_array, 721 bool b_force_update, 722 bool b_ProgressDialog); 723 extern DECL_EXP wxArrayString GetChartDBDirArrayString(); 724 725 extern "C" DECL_EXP void SendPluginMessage( wxString message_id, wxString message_body ); 726 727 extern "C" DECL_EXP void DimeWindow(wxWindow *); 728 729 extern "C" DECL_EXP void JumpToPosition(double lat, double lon, double scale); 730 731 /* API 1.9 adds some common cartographic functions to avoid unnecessary code duplication */ 732 /* Study the original OpenCPN source (georef.c) for functional definitions */ 733 734 extern "C" DECL_EXP void PositionBearingDistanceMercator_Plugin(double lat, double lon, double brg, double dist, double *dlat, double *dlon); 735 extern "C" DECL_EXP void DistanceBearingMercator_Plugin(double lat0, double lon0, double lat1, double lon1, double *brg, double *dist); 736 extern "C" DECL_EXP double DistGreatCircle_Plugin(double slat, double slon, double dlat, double dlon); 737 738 extern "C" DECL_EXP void toTM_Plugin(float lat, float lon, float lat0, float lon0, double *x, double *y); 739 extern "C" DECL_EXP void fromTM_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); 740 extern "C" DECL_EXP void toSM_Plugin(double lat, double lon, double lat0, double lon0, double *x, double *y); 741 extern "C" DECL_EXP void fromSM_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); 742 extern "C" DECL_EXP void toSM_ECC_Plugin(double lat, double lon, double lat0, double lon0, double *x, double *y); 743 extern "C" DECL_EXP void fromSM_ECC_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); 744 745 extern "C" DECL_EXP bool DecodeSingleVDOMessage( const wxString& str, PlugIn_Position_Fix_Ex *pos, wxString *acc ); 746 extern "C" DECL_EXP int GetChartbarHeight( void ); 747 extern "C" DECL_EXP bool GetActiveRoutepointGPX( char *buffer, unsigned int buffer_length ); 748 749 750 751 /* API 1.9 */ 752 typedef enum OptionsParentPI 753 { 754 PI_OPTIONS_PARENT_DISPLAY, 755 PI_OPTIONS_PARENT_CONNECTIONS, 756 PI_OPTIONS_PARENT_CHARTS, 757 PI_OPTIONS_PARENT_SHIPS, 758 PI_OPTIONS_PARENT_UI, 759 PI_OPTIONS_PARENT_PLUGINS 760 }_OptionsParentPI; 761 extern DECL_EXP wxScrolledWindow *AddOptionsPage( OptionsParentPI parent, wxString title ); 762 extern DECL_EXP bool DeleteOptionsPage( wxScrolledWindow* page ); 763 764 765 /* API 1.10 */ 766 767 /* API 1.10 adds some common functions to avoid unnecessary code duplication */ 768 /* Study the original OpenCPN source for functional definitions */ 769 extern "C" DECL_EXP double toUsrDistance_Plugin( double nm_distance, int unit = -1 ); 770 extern "C" DECL_EXP double fromUsrDistance_Plugin( double usr_distance, int unit = -1 ); 771 extern "C" DECL_EXP double toUsrSpeed_Plugin( double kts_speed, int unit = -1 ); 772 extern "C" DECL_EXP double fromUsrSpeed_Plugin( double usr_speed, int unit = -1 ); 773 extern DECL_EXP wxString getUsrDistanceUnit_Plugin( int unit = -1 ); 774 extern DECL_EXP wxString getUsrSpeedUnit_Plugin( int unit = -1 ); 775 extern DECL_EXP wxString GetNewGUID(); 776 extern "C" DECL_EXP bool PlugIn_GSHHS_CrossesLand(double lat1, double lon1, double lat2, double lon2); 777 /** 778 * Start playing a sound file asynchronously. Supported formats depends 779 * on sound backend. 780 */ 781 extern DECL_EXP void PlugInPlaySound( wxString &sound_file ); 782 783 784 785 786 // API 1.10 Route and Waypoint Support 787 extern DECL_EXP wxBitmap *FindSystemWaypointIcon( wxString& icon_name ); 788 extern DECL_EXP bool AddCustomWaypointIcon( wxBitmap *pimage, wxString key, wxString description ); 789 790 extern DECL_EXP bool AddSingleWaypoint( PlugIn_Waypoint *pwaypoint, bool b_permanent = true); 791 extern DECL_EXP bool DeleteSingleWaypoint( wxString &GUID ); 792 extern DECL_EXP bool UpdateSingleWaypoint( PlugIn_Waypoint *pwaypoint ); 793 794 extern DECL_EXP bool AddPlugInRoute( PlugIn_Route *proute, bool b_permanent = true ); 795 extern DECL_EXP bool DeletePlugInRoute( wxString& GUID ); 796 extern DECL_EXP bool UpdatePlugInRoute ( PlugIn_Route *proute ); 797 798 extern DECL_EXP bool AddPlugInTrack( PlugIn_Track *ptrack, bool b_permanent = true ); 799 extern DECL_EXP bool DeletePlugInTrack( wxString& GUID ); 800 extern DECL_EXP bool UpdatePlugInTrack ( PlugIn_Track *ptrack ); 801 802 /* API 1.11 */ 803 804 /* API 1.11 adds some more common functions to avoid unnecessary code duplication */ 805 wxColour DECL_EXP GetBaseGlobalColor(wxString colorName); 806 int DECL_EXP OCPNMessageBox_PlugIn(wxWindow *parent, 807 const wxString& message, 808 const wxString& caption = _T("Message"), 809 int style = wxOK, int x = -1, int y = -1); 810 811 extern DECL_EXP wxString toSDMM_PlugIn(int NEflag, double a, bool hi_precision = true); 812 813 extern "C" DECL_EXP wxString *GetpPrivateApplicationDataLocation(); 814 extern DECL_EXP wxString GetOCPN_ExePath( void ); 815 extern "C" DECL_EXP wxString *GetpPlugInLocation(); 816 extern DECL_EXP wxString GetPlugInPath(opencpn_plugin *pplugin); 817 818 extern "C" DECL_EXP int AddChartToDBInPlace( wxString &full_path, bool b_RefreshCanvas ); 819 extern "C" DECL_EXP int RemoveChartFromDBInPlace( wxString &full_path ); 820 extern DECL_EXP wxString GetLocaleCanonicalName(); 821 822 // API 1.11 adds access to S52 Presentation library 823 //Types 824 825 // A flag field that defines the object capabilities passed by a chart to the S52 PLIB 826 827 #define PLIB_CAPS_LINE_VBO 1 828 #define PLIB_CAPS_LINE_BUFFER 1 << 1 829 #define PLIB_CAPS_SINGLEGEO_BUFFER 1 << 2 830 #define PLIB_CAPS_OBJSEGLIST 1 << 3 831 #define PLIB_CAPS_OBJCATMUTATE 1 << 4 832 833 834 class PI_S57Obj; 835 836 WX_DECLARE_LIST(PI_S57Obj, ListOfPI_S57Obj); 837 838 // ---------------------------------------------------------------------------- 839 // PlugInChartBaseGL 840 // Derived from PlugInChartBase, add OpenGL Vector chart support 841 // ---------------------------------------------------------------------------- 842 843 class DECL_EXP PlugInChartBaseGL : public PlugInChartBase 844 { 845 public: 846 PlugInChartBaseGL(); 847 virtual ~PlugInChartBaseGL(); 848 849 virtual int RenderRegionViewOnGL( const wxGLContext &glc, const PlugIn_ViewPort& VPoint, 850 const wxRegion &Region, bool b_use_stencil ); 851 852 virtual ListOfPI_S57Obj *GetObjRuleListAtLatLon(float lat, float lon, float select_radius, PlugIn_ViewPort *VPoint); 853 virtual wxString CreateObjDescriptions( ListOfPI_S57Obj* obj_list ); 854 855 virtual int GetNoCOVREntries(); 856 virtual int GetNoCOVRTablePoints(int iTable); 857 virtual int GetNoCOVRTablenPoints(int iTable); 858 virtual float *GetNoCOVRTableHead(int iTable); 859 860 }; 861 862 863 // ---------------------------------------------------------------------------- 864 // PlugInChartBaseExtended 865 // Derived from PlugInChartBase, add extended chart support methods 866 // ---------------------------------------------------------------------------- 867 868 class DECL_EXP PlugInChartBaseExtended : public PlugInChartBase 869 { 870 public: 871 PlugInChartBaseExtended(); 872 virtual ~PlugInChartBaseExtended(); 873 874 virtual int RenderRegionViewOnGL( const wxGLContext &glc, const PlugIn_ViewPort& VPoint, 875 const wxRegion &Region, bool b_use_stencil ); 876 877 virtual wxBitmap &RenderRegionViewOnDCNoText( const PlugIn_ViewPort& VPoint, const wxRegion &Region); 878 virtual bool RenderRegionViewOnDCTextOnly( wxMemoryDC &dc, const PlugIn_ViewPort& VPoint, const wxRegion &Region); 879 880 virtual int RenderRegionViewOnGLNoText( const wxGLContext &glc, const PlugIn_ViewPort& VPoint, 881 const wxRegion &Region, bool b_use_stencil ); 882 883 virtual int RenderRegionViewOnGLTextOnly( const wxGLContext &glc, const PlugIn_ViewPort& VPoint, 884 const wxRegion &Region, bool b_use_stencil ); 885 886 virtual ListOfPI_S57Obj *GetObjRuleListAtLatLon(float lat, float lon, float select_radius, PlugIn_ViewPort *VPoint); 887 virtual wxString CreateObjDescriptions( ListOfPI_S57Obj* obj_list ); 888 889 virtual int GetNoCOVREntries(); 890 virtual int GetNoCOVRTablePoints(int iTable); 891 virtual int GetNoCOVRTablenPoints(int iTable); 892 virtual float *GetNoCOVRTableHead(int iTable); 893 894 virtual void ClearPLIBTextList(); 895 896 }; 897 898 899 900 901 902 903 class wxArrayOfS57attVal; 904 905 // name of the addressed look up table set (fifth letter) 906 typedef enum _PI_LUPname{ 907 PI_SIMPLIFIED = 'L', // points 908 PI_PAPER_CHART = 'R', // points 909 PI_LINES = 'S', // lines 910 PI_PLAIN_BOUNDARIES = 'N', // areas 911 PI_SYMBOLIZED_BOUNDARIES = 'O', // areas 912 PI_LUPNAME_NUM = 5 913 }PI_LUPname; 914 915 // display category type 916 typedef enum _PI_DisCat{ 917 PI_DISPLAYBASE = 'D', // 918 PI_STANDARD = 'S', // 919 PI_OTHER = 'O', // O for OTHER 920 PI_MARINERS_STANDARD = 'M', // Mariner specified 921 PI_MARINERS_OTHER, // value not defined 922 PI_DISP_CAT_NUM, // value not defined 923 }PI_DisCat; 924 925 // Display Priority 926 typedef enum _PI_DisPrio{ 927 PI_PRIO_NODATA = '0', // no data fill area pattern 928 PI_PRIO_GROUP1 = '1', // S57 group 1 filled areas 929 PI_PRIO_AREA_1 = '2', // superimposed areas 930 PI_PRIO_AREA_2 = '3', // superimposed areas also water features 931 PI_PRIO_SYMB_POINT = '4', // point symbol also land features 932 PI_PRIO_SYMB_LINE = '5', // line symbol also restricted areas 933 PI_PRIO_SYMB_AREA = '6', // area symbol also traffic areas 934 PI_PRIO_ROUTEING = '7', // routeing lines 935 PI_PRIO_HAZARDS = '8', // hazards 936 PI_PRIO_MARINERS = '9', // VRM, EBL, own ship 937 PI_PRIO_NUM = 10 // number of priority levels 938 939 }PI_DisPrio; 940 941 typedef enum PI_InitReturn 942 { 943 PI_INIT_OK = 0, 944 PI_INIT_FAIL_RETRY, // Init failed, retry suggested 945 PI_INIT_FAIL_REMOVE, // Init failed, suggest remove from further use 946 PI_INIT_FAIL_NOERROR // Init failed, request no explicit error message 947 }_PI_InitReturn; 948 949 class PI_line_segment_element 950 { 951 public: 952 size_t vbo_offset; 953 size_t n_points; 954 int priority; 955 float lat_max; // segment bounding box 956 float lat_min; 957 float lon_max; 958 float lon_min; 959 int type; 960 void *private0; 961 962 PI_line_segment_element *next; 963 }; 964 965 966 class DECL_EXP PI_S57Obj 967 { 968 public: 969 970 // Public Methods 971 PI_S57Obj(); 972 ~PI_S57Obj(); 973 974 public: 975 // Instance Data 976 char FeatureName[8]; 977 int Primitive_type; 978 979 char *att_array; 980 wxArrayOfS57attVal *attVal; 981 int n_attr; 982 983 int iOBJL; 984 int Index; 985 986 double x; // for POINT 987 double y; 988 double z; 989 int npt; // number of points as needed by arrays 990 void *geoPt; // for LINE & AREA not described by PolyTessGeo 991 double *geoPtz; // an array[3] for MultiPoint, SM with Z, i.e. depth 992 double *geoPtMulti; // an array[2] for MultiPoint, lat/lon to make bbox 993 // of decomposed points 994 995 void *pPolyTessGeo; 996 997 double m_lat; // The lat/lon of the object's "reference" point 998 double m_lon; 999 1000 double chart_ref_lat; 1001 double chart_ref_lon; 1002 1003 double lat_min; 1004 double lat_max; 1005 double lon_min; 1006 double lon_max; 1007 1008 int Scamin; // SCAMIN attribute decoded during load 1009 1010 bool bIsClone; 1011 int nRef; // Reference counter, to signal OK for deletion 1012 1013 bool bIsAton; // This object is an aid-to-navigation 1014 bool bIsAssociable; // This object is DRGARE or DEPARE 1015 1016 int m_n_lsindex; 1017 int *m_lsindex_array; 1018 int m_n_edge_max_points; 1019 void *m_chart_context; 1020 1021 PI_DisCat m_DisplayCat; 1022 1023 void * S52_Context; 1024 PI_S57Obj *child; // child list, used only for MultiPoint Soundings 1025 1026 PI_S57Obj *next; // List linkage 1027 1028 // This transform converts from object geometry 1029 // to SM coordinates. 1030 double x_rate; // These auxiliary transform coefficients are 1031 double y_rate; // to be used in GetPointPix() and friends 1032 double x_origin; // on a per-object basis if necessary 1033 double y_origin; 1034 1035 int auxParm0; // some per-object auxiliary parameters, used for OpenGL 1036 int auxParm1; 1037 int auxParm2; 1038 int auxParm3; 1039 1040 PI_line_segment_element *m_ls_list; 1041 bool m_bcategory_mutable; 1042 int m_DPRI; 1043 }; 1044 1045 1046 1047 wxString DECL_EXP PI_GetPLIBColorScheme(); 1048 int DECL_EXP PI_GetPLIBDepthUnitInt(); 1049 int DECL_EXP PI_GetPLIBSymbolStyle(); 1050 int DECL_EXP PI_GetPLIBBoundaryStyle(); 1051 int DECL_EXP PI_GetPLIBStateHash(); 1052 double DECL_EXP PI_GetPLIBMarinerSafetyContour(); 1053 bool DECL_EXP PI_GetObjectRenderBox( PI_S57Obj *pObj, double *lat_min, double *lat_max, double *lon_min, double *lon_max); 1054 void DECL_EXP PI_UpdateContext(PI_S57Obj *pObj); 1055 1056 bool DECL_EXP PI_PLIBObjectRenderCheck( PI_S57Obj *pObj, PlugIn_ViewPort *vp ); 1057 PI_LUPname DECL_EXP PI_GetObjectLUPName( PI_S57Obj *pObj ); 1058 PI_DisPrio DECL_EXP PI_GetObjectDisplayPriority( PI_S57Obj *pObj ); 1059 PI_DisCat DECL_EXP PI_GetObjectDisplayCategory( PI_S57Obj *pObj ); 1060 void DECL_EXP PI_PLIBSetLineFeaturePriority( PI_S57Obj *pObj, int prio ); 1061 void DECL_EXP PI_PLIBPrepareForNewRender(void); 1062 void DECL_EXP PI_PLIBFreeContext( void *pContext ); 1063 void DECL_EXP PI_PLIBSetRenderCaps( unsigned int flags ); 1064 1065 bool DECL_EXP PI_PLIBSetContext( PI_S57Obj *pObj ); 1066 1067 int DECL_EXP PI_PLIBRenderObjectToDC( wxDC *pdc, PI_S57Obj *pObj, PlugIn_ViewPort *vp ); 1068 int DECL_EXP PI_PLIBRenderAreaToDC( wxDC *pdc, PI_S57Obj *pObj, PlugIn_ViewPort *vp, wxRect rect, unsigned char *pixbuf ); 1069 1070 1071 int DECL_EXP PI_PLIBRenderAreaToGL( const wxGLContext &glcc, PI_S57Obj *pObj, 1072 PlugIn_ViewPort *vp, wxRect &render_rect ); 1073 1074 int DECL_EXP PI_PLIBRenderObjectToGL( const wxGLContext &glcc, PI_S57Obj *pObj, 1075 PlugIn_ViewPort *vp, wxRect &render_rect ); 1076 1077 /* API 1.11 OpenGL Display List and vertex buffer object routines 1078 1079 Effectively these two routines cancel each other so all 1080 of the translation, scaling and rotation can be done by opengl. 1081 1082 Display lists need only be built infrequently, but used in each frame 1083 greatly accelerates the speed of rendering. This avoids costly calculations, 1084 and also allows the vertexes to be stored in graphics memory. 1085 1086 static int dl = 0; 1087 glPushMatrix(); 1088 PlugInMultMatrixViewport(current_viewport); 1089 if(dl) 1090 glCallList(dl); 1091 else { 1092 dl = glGenLists(1); 1093 PlugInViewPort norm_viewport = current_viewport; 1094 NormalizeViewPort(norm_viewport); 1095 glNewList(dl, GL_COMPILE_AND_EXECUTE); 1096 ... // use norm_viewport with GetCanvasLLPix here 1097 glEndList(); 1098 } 1099 glPopMatrix(); 1100 ... // use current_viewport with GetCanvasLLPix again 1101 */ 1102 1103 extern DECL_EXP bool PlugInHasNormalizedViewPort ( PlugIn_ViewPort *vp ); 1104 extern DECL_EXP void PlugInMultMatrixViewport ( PlugIn_ViewPort *vp, float lat=0, float lon=0 ); 1105 extern DECL_EXP void PlugInNormalizeViewport ( PlugIn_ViewPort *vp, float lat=0, float lon=0 ); 1106 1107 class wxPoint2DDouble; 1108 extern "C" DECL_EXP void GetDoubleCanvasPixLL(PlugIn_ViewPort *vp, wxPoint2DDouble *pp, double lat, double lon); 1109 1110 /* API 1.13 */ 1111 /* API 1.13 adds some more common functions to avoid unnecessary code duplication */ 1112 1113 1114 extern DECL_EXP double fromDMM_Plugin( wxString sdms ); 1115 extern DECL_EXP void SetCanvasRotation(double rotation); 1116 extern DECL_EXP void SetCanvasProjection(int projection); 1117 extern DECL_EXP bool GetSingleWaypoint( wxString GUID, PlugIn_Waypoint *pwaypoint ); 1118 extern DECL_EXP bool CheckEdgePan_PlugIn( int x, int y, bool dragging, int margin, int delta ); 1119 extern DECL_EXP wxBitmap GetIcon_PlugIn(const wxString & name); 1120 extern DECL_EXP void SetCursor_PlugIn( wxCursor *pPlugin_Cursor = NULL ); 1121 extern DECL_EXP wxFont *GetOCPNScaledFont_PlugIn(wxString TextElement, int default_size = 0); 1122 extern DECL_EXP wxFont GetOCPNGUIScaledFont_PlugIn(wxString item); 1123 extern DECL_EXP double GetOCPNGUIToolScaleFactor_PlugIn(int GUIScaledFactor); 1124 extern DECL_EXP double GetOCPNGUIToolScaleFactor_PlugIn(); 1125 extern DECL_EXP float GetOCPNChartScaleFactor_Plugin(); 1126 extern DECL_EXP wxColour GetFontColour_PlugIn(wxString TextElement); 1127 1128 extern DECL_EXP double GetCanvasTilt(); 1129 extern DECL_EXP void SetCanvasTilt(double tilt); 1130 1131 /** 1132 * Start playing a sound file asynchronously. Supported formats depends 1133 * on sound backend. The deviceIx is only used on platforms using the 1134 * portaudio sound backend where -1 indicates the default device. 1135 */ 1136 extern DECL_EXP bool PlugInPlaySoundEx( wxString &sound_file, int deviceIndex=-1 ); 1137 extern DECL_EXP void AddChartDirectory( wxString &path ); 1138 extern DECL_EXP void ForceChartDBUpdate(); 1139 extern DECL_EXP void ForceChartDBRebuild(); 1140 1141 extern DECL_EXP wxString GetWritableDocumentsDir( void ); 1142 extern DECL_EXP wxDialog *GetActiveOptionsDialog(); 1143 extern DECL_EXP wxArrayString GetWaypointGUIDArray( void ); 1144 extern DECL_EXP wxArrayString GetIconNameArray(void); 1145 1146 extern DECL_EXP bool AddPersistentFontKey(wxString TextElement); 1147 extern DECL_EXP wxString GetActiveStyleName(); 1148 1149 extern DECL_EXP wxBitmap GetBitmapFromSVGFile(wxString filename, unsigned int width, unsigned int height); 1150 extern DECL_EXP bool IsTouchInterface_PlugIn(void); 1151 1152 /* Platform optimized File/Dir selector dialogs */ 1153 extern DECL_EXP int PlatformDirSelectorDialog( wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir); 1154 1155 extern DECL_EXP int PlatformFileSelectorDialog( wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir, 1156 wxString suggestedName, wxString wildcard); 1157 1158 1159 /* OpenCPN HTTP File Download PlugIn Interface */ 1160 1161 /* Various method Return Codes, etc */ 1162 typedef enum _OCPN_DLStatus{ 1163 OCPN_DL_UNKNOWN =-1, 1164 OCPN_DL_NO_ERROR = 0, 1165 OCPN_DL_FAILED = 1, 1166 OCPN_DL_ABORTED = 2, 1167 OCPN_DL_USER_TIMEOUT = 4, 1168 OCPN_DL_STARTED = 8 1169 }OCPN_DLStatus; 1170 1171 1172 typedef enum _OCPN_DLCondition{ 1173 OCPN_DL_EVENT_TYPE_UNKNOWN = -1, 1174 OCPN_DL_EVENT_TYPE_START = 80, 1175 OCPN_DL_EVENT_TYPE_PROGRESS = 81, 1176 OCPN_DL_EVENT_TYPE_END = 82 1177 }OCPN_DLCondition; 1178 1179 // Style definitions for Synchronous file download modal dialogs, if desired. 1180 // Abstracted from wxCURL package 1181 enum OCPN_DLDialogStyle 1182 { 1183 OCPN_DLDS_ELAPSED_TIME = 0x0001, //!< The dialog shows the elapsed time. 1184 OCPN_DLDS_ESTIMATED_TIME = 0x0002, //!< The dialog shows the estimated total time. 1185 OCPN_DLDS_REMAINING_TIME = 0x0004, //!< The dialog shows the remaining time. 1186 OCPN_DLDS_SPEED = 0x0008, //!< The dialog shows the transfer speed. 1187 OCPN_DLDS_SIZE = 0x0010, //!< The dialog shows the size of the resource to download/upload. 1188 OCPN_DLDS_URL = 0x0020, //!< The dialog shows the URL involved in the transfer. 1189 1190 // styles related to the use of wxCurlConnectionSettingsDialog: 1191 1192 OCPN_DLDS_CONN_SETTINGS_AUTH = 0x0040, //!< The dialog allows the user to change the authentication settings. 1193 OCPN_DLDS_CONN_SETTINGS_PORT = 0x0080, //!< The dialog allows the user to change the port for the transfer. 1194 OCPN_DLDS_CONN_SETTINGS_PROXY = 0x0100, //!< The dialog allows the user to change the proxy settings. 1195 1196 OCPN_DLDS_CONN_SETTINGS_ALL = OCPN_DLDS_CONN_SETTINGS_AUTH|OCPN_DLDS_CONN_SETTINGS_PORT|OCPN_DLDS_CONN_SETTINGS_PROXY, 1197 1198 OCPN_DLDS_SHOW_ALL =OCPN_DLDS_ELAPSED_TIME|OCPN_DLDS_ESTIMATED_TIME|OCPN_DLDS_REMAINING_TIME| 1199 OCPN_DLDS_SPEED|OCPN_DLDS_SIZE|OCPN_DLDS_URL|OCPN_DLDS_CONN_SETTINGS_ALL, 1200 1201 OCPN_DLDS_CAN_ABORT = 0x0200, //!< The transfer can be aborted by the user. 1202 OCPN_DLDS_CAN_START = 0x0400, //!< The transfer won't start automatically. The user needs to start it. 1203 OCPN_DLDS_CAN_PAUSE = 0x0800, //!< The transfer can be paused. 1204 1205 OCPN_DLDS_AUTO_CLOSE = 0x1000, //!< The dialog auto closes when transfer is complete. 1206 1207 // by default all available features are enabled: 1208 OCPN_DLDS_DEFAULT_STYLE = OCPN_DLDS_CAN_START|OCPN_DLDS_CAN_PAUSE|OCPN_DLDS_CAN_ABORT|OCPN_DLDS_SHOW_ALL|OCPN_DLDS_AUTO_CLOSE 1209 }; 1210 1211 #define ONLINE_CHECK_RETRY 30 // Recheck the Internet connection availability every ONLINE_CHECK_RETRY s 1212 1213 /* Synchronous (Blocking) download of a single file */ 1214 1215 extern DECL_EXP _OCPN_DLStatus OCPN_downloadFile( const wxString& url, const wxString &outputFile, 1216 const wxString &title, const wxString &message, 1217 const wxBitmap& bitmap, 1218 wxWindow *parent, long style, int timeout_secs); 1219 1220 1221 /* Asynchronous (Background) download of a single file */ 1222 1223 extern DECL_EXP _OCPN_DLStatus OCPN_downloadFileBackground( const wxString& url, const wxString &outputFile, 1224 wxEvtHandler *handler, long *handle); 1225 1226 extern DECL_EXP void OCPN_cancelDownloadFileBackground( long handle ); 1227 1228 /* Synchronous (Blocking) HTTP POST operation for small amounts of data */ 1229 1230 extern DECL_EXP _OCPN_DLStatus OCPN_postDataHttp( const wxString& url, const wxString& parameters, wxString& result, int timeout_secs ); 1231 1232 /* Check whether connection to the Internet is working */ 1233 1234 extern DECL_EXP bool OCPN_isOnline(); 1235 1236 /* Supporting Event for Background downloading */ 1237 /* OCPN_downloadEvent Definition */ 1238 1239 /* PlugIn should be ready/able to handle this event after initiating a background file transfer 1240 * 1241 * The event as received should be parsed primarily by the getDLEventCondition() method. 1242 * This will allow identification of download start, progress, and end states. 1243 * 1244 * Other accessor methods contain status, byte counts, etc. 1245 * 1246 * A PlugIn may safely destroy its EvtHandler after receipt of an OCPN_downloadEvent with 1247 * getDLEventCondition == OCPN_DL_EVENT_TYPE_END 1248 */ 1249 1250 class DECL_EXP OCPN_downloadEvent: public wxEvent 1251 { 1252 public: 1253 OCPN_downloadEvent( wxEventType commandType = wxEVT_NULL, int id = 0 ); 1254 ~OCPN_downloadEvent( ); 1255 1256 // accessors getDLEventStatus()1257 _OCPN_DLStatus getDLEventStatus(){ return m_stat; } getDLEventCondition()1258 OCPN_DLCondition getDLEventCondition(){ return m_condition; } 1259 setDLEventStatus(_OCPN_DLStatus stat)1260 void setDLEventStatus( _OCPN_DLStatus stat ){ m_stat = stat; } setDLEventCondition(OCPN_DLCondition cond)1261 void setDLEventCondition( OCPN_DLCondition cond ){ m_condition = cond; } 1262 setTotal(long bytes)1263 void setTotal( long bytes ){m_totalBytes = bytes; } setTransferred(long bytes)1264 void setTransferred( long bytes ){m_sofarBytes = bytes; } getTotal()1265 long getTotal(){ return m_totalBytes; } getTransferred()1266 long getTransferred(){ return m_sofarBytes; } 1267 setComplete(bool b_complete)1268 void setComplete(bool b_complete){ m_b_complete = b_complete; } getComplete()1269 bool getComplete(){ return m_b_complete; } 1270 1271 1272 // required for sending with wxPostEvent() 1273 wxEvent *Clone() const; 1274 1275 private: 1276 OCPN_DLStatus m_stat; 1277 OCPN_DLCondition m_condition; 1278 1279 long m_totalBytes; 1280 long m_sofarBytes; 1281 bool m_b_complete; 1282 }; 1283 1284 1285 //extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DOWNLOAD_EVENT; 1286 1287 #ifdef MAKING_PLUGIN 1288 extern DECL_IMP wxEventType wxEVT_DOWNLOAD_EVENT; 1289 #else 1290 extern DECL_EXP wxEventType wxEVT_DOWNLOAD_EVENT; 1291 #endif 1292 1293 1294 /* API 1.14 */ 1295 /* API 1.14 adds some more common functions to avoid unnecessary code duplication */ 1296 1297 bool LaunchDefaultBrowser_Plugin( wxString url ); 1298 1299 1300 // API 1.14 Extra canvas Support 1301 1302 /* Allow drawing of objects onto other OpenGL canvases */ 1303 extern DECL_EXP void PlugInAISDrawGL( wxGLCanvas* glcanvas, const PlugIn_ViewPort& vp ); 1304 extern DECL_EXP bool PlugInSetFontColor(const wxString TextElement, const wxColour color); 1305 1306 // API 1.15 1307 extern DECL_EXP double PlugInGetDisplaySizeMM(); 1308 1309 // 1310 extern DECL_EXP wxFont* FindOrCreateFont_PlugIn( int point_size, wxFontFamily family, 1311 wxFontStyle style, wxFontWeight weight, bool underline = false, 1312 const wxString &facename = wxEmptyString, 1313 wxFontEncoding encoding = wxFONTENCODING_DEFAULT ); 1314 1315 extern DECL_EXP int PlugInGetMinAvailableGshhgQuality(); 1316 extern DECL_EXP int PlugInGetMaxAvailableGshhgQuality(); 1317 1318 extern DECL_EXP void PlugInHandleAutopilotRoute(bool enable); 1319 1320 // API 1.16 1321 // 1322 /** 1323 * Return the plugin data directory for a given directory name. 1324 * 1325 * On Linux, the returned data path is an existing directory ending in 1326 * "opencpn/plugins/<plugin_name>" where the last part is the plugin_name 1327 * argument. The prefix part is one of the directories listed in the 1328 * environment variable XDG_DATA_DIRS, by default 1329 * ~/.local/share:/usr/local/share:/usr/share. 1330 * 1331 * On other platforms, the returned value is GetSharedDataDir() + 1332 * "/opencpn/plugins/" + plugin_name (with native path separators) 1333 * if that path exists. 1334 * 1335 * Return "" if no existing directory is found. 1336 */ 1337 extern DECL_EXP wxString GetPluginDataDir(const char* plugin_name); 1338 1339 extern DECL_EXP bool ShuttingDown( void ); 1340 1341 // Support for MUI MultiCanvas model 1342 1343 extern DECL_EXP wxWindow* PluginGetFocusCanvas(); 1344 extern DECL_EXP wxWindow* PluginGetOverlayRenderCanvas(); 1345 1346 extern "C" DECL_EXP void CanvasJumpToPosition( wxWindow *canvas, double lat, double lon, double scale); 1347 extern "C" DECL_EXP int AddCanvasMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin, const char *name = ""); 1348 extern "C" DECL_EXP void RemoveCanvasMenuItem(int item, const char *name = ""); // Fully remove this item 1349 extern "C" DECL_EXP void SetCanvasMenuItemViz(int item, bool viz, const char *name = ""); // Temporarily change context menu options 1350 extern "C" DECL_EXP void SetCanvasMenuItemGrey(int item, bool grey, const char *name = ""); 1351 1352 // Extract waypoints, routes and tracks 1353 extern DECL_EXP wxString GetSelectedWaypointGUID_Plugin( ); 1354 extern DECL_EXP wxString GetSelectedRouteGUID_Plugin( ); 1355 extern DECL_EXP wxString GetSelectedTrackGUID_Plugin( ); 1356 1357 extern DECL_EXP std::unique_ptr<PlugIn_Waypoint> GetWaypoint_Plugin( const wxString& ); // doublon with GetSingleWaypoint 1358 extern DECL_EXP std::unique_ptr<PlugIn_Route> GetRoute_Plugin( const wxString& ); 1359 extern DECL_EXP std::unique_ptr<PlugIn_Track> GetTrack_Plugin( const wxString& ); 1360 1361 extern DECL_EXP wxWindow* GetCanvasUnderMouse( ); 1362 extern DECL_EXP int GetCanvasIndexUnderMouse( ); 1363 //extern DECL_EXP std::vector<wxWindow *> GetCanvasArray(); 1364 extern DECL_EXP wxWindow *GetCanvasByIndex( int canvasIndex ); 1365 extern DECL_EXP int GetCanvasCount( ); 1366 extern DECL_EXP bool CheckMUIEdgePan_PlugIn( int x, int y, bool dragging, int margin, int delta, int canvasIndex ); 1367 extern DECL_EXP void SetMUICursor_PlugIn( wxCursor *pCursor, int canvasIndex ); 1368 1369 // API 1.17 1370 // 1371 extern DECL_EXP wxRect GetMasterToolbarRect(); 1372 1373 enum SDDMFORMAT 1374 { 1375 DEGREES_DECIMAL_MINUTES = 0, 1376 DECIMAL_DEGREES, 1377 DEGREES_MINUTES_SECONDS, 1378 END_SDDMFORMATS 1379 }; 1380 1381 extern DECL_EXP int GetLatLonFormat(void); 1382 1383 // API 1.17 1384 extern "C" DECL_EXP void ZeroXTE(); 1385 1386 #endif //_PLUGIN_H_ 1387