Skip to content

Commit

Permalink
Implement improved depth sounding render method
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbcat committed Apr 14, 2020
1 parent 17ff678 commit 59f97d3
Show file tree
Hide file tree
Showing 6 changed files with 1,031 additions and 14 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ SET(SRC_OESENC
src/tinyxmlerror.cpp
src/tinyxmlparser.cpp
src/razdsparser.cpp
src/pi_DepthFont.cpp
)

SET(SRC_CPL
Expand Down
204 changes: 193 additions & 11 deletions src/ocpn_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,54 @@
#define _PLUGIN_H_

#ifndef DECL_EXP
#ifdef __WXMSW__
#if defined(__WXMSW__) || defined(__CYGWIN__)
# define DECL_EXP __declspec(dllexport)
#elif defined __GNUC__ && __GNUC__ >= 4
# define DECL_EXP __attribute__((visibility("default")))
#elif defined __WXOSX__
# define DECL_EXP __attribute__((visibility("default")))
#else
# ifdef __GNUC__
# define DECL_EXP __attribute__((visibility("default")))
# endif
# define DECL_EXP
#endif
#endif

#ifdef __WXMSW__
#ifdef MAKING_PLUGIN
# define DECL_IMP __declspec(dllimport)
#endif
#endif

#include <wx/xml/xml.h>
#include <wx/dcmemory.h>
#include <wx/dialog.h>
#include <wx/event.h>
#include <wx/menuitem.h>
#include <wx/gdicmn.h>


#ifdef ocpnUSE_SVG
#include "wxsvg/include/wxSVG/svg.h"
#include <wx/bitmap.h>
#endif // ocpnUSE_SVG

#include <memory>
#include <vector>

class wxGLContext;

// This is the most modern API Version number
// It is expected that the API will remain downward compatible, meaning that
// PlugIns conforming to API Version less then the most modern will also
// be correctly supported.
#define API_VERSION_MAJOR 1
#define API_VERSION_MINOR 13
#define API_VERSION_MINOR 17

// Fwd Definitions
class wxFileConfig;
class wxNotebook;
class wxFont;
class wxAuiManager;
class wxScrolledWindow;
class wxGLCanvas;

//---------------------------------------------------------------------------------------------------------
//
Expand Down Expand Up @@ -147,6 +164,16 @@ class PlugIn_Position_Fix_Ex
int nSats;
};

class Plugin_Active_Leg_Info
{
public:
double Xte; // Left side of the track -> negative XTE
double Btw;
double Dtw;
wxString wp_name; // Name of destination waypoint for active leg
bool arrival; // True when within arrival circle
};

// Describe AIS Alarm state
enum plugin_ais_alarm_type
{
Expand Down Expand Up @@ -461,7 +488,6 @@ class DECL_EXP opencpn_plugin_18 : public opencpn_plugin

virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp);
virtual bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp);

virtual void SetPluginMessage(wxString &message_id, wxString &message_body);
virtual void SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix);

Expand Down Expand Up @@ -515,6 +541,54 @@ class DECL_EXP opencpn_plugin_113 : public opencpn_plugin_112
virtual void OnToolbarToolUpCallback(int id);
};

class DECL_EXP opencpn_plugin_114 : public opencpn_plugin_113
{
public:
opencpn_plugin_114(void *pmgr);
virtual ~opencpn_plugin_114();

};

class DECL_EXP opencpn_plugin_115 : public opencpn_plugin_114
{
public:
opencpn_plugin_115(void *pmgr);
virtual ~opencpn_plugin_115();
};

class DECL_EXP opencpn_plugin_116 : public opencpn_plugin_115
{
public:
opencpn_plugin_116(void *pmgr);
virtual ~opencpn_plugin_116();
virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex);
virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex);
virtual void PrepareContextMenu( int canvasIndex);

};

class DECL_EXP opencpn_plugin_117 : public opencpn_plugin_116
{
public:
opencpn_plugin_117(void *pmgr);
/*
* Forms a semantic version together with GetPlugInVersionMajor() and
* GetPlugInVersionMinor(), see https://semver.org/
*/
virtual int GetPlugInVersionPatch();

/** Post-release version part, extends the semver spec. */
virtual int GetPlugInVersionPost();

/** Pre-release tag version part, see GetPlugInVersionPatch() */
virtual const char* GetPlugInVersionPre();

/** Build version part see GetPlugInVersionPatch(). */
virtual const char* GetPlugInVersionBuild();

/*Provide active leg data to plugins*/
virtual void SetActiveLegInfo(Plugin_Active_Leg_Info &leg_info);
};
//------------------------------------------------------------------
// Route and Waypoint PlugIn support
//
Expand Down Expand Up @@ -700,6 +774,10 @@ extern DECL_EXP wxString getUsrDistanceUnit_Plugin( int unit = -1 );
extern DECL_EXP wxString getUsrSpeedUnit_Plugin( int unit = -1 );
extern DECL_EXP wxString GetNewGUID();
extern "C" DECL_EXP bool PlugIn_GSHHS_CrossesLand(double lat1, double lon1, double lat2, double lon2);
/**
* Start playing a sound file asynchronously. Supported formats depends
* on sound backend.
*/
extern DECL_EXP void PlugInPlaySound( wxString &sound_file );


Expand Down Expand Up @@ -1050,13 +1128,20 @@ extern DECL_EXP wxColour GetFontColour_PlugIn(wxString TextElement);
extern DECL_EXP double GetCanvasTilt();
extern DECL_EXP void SetCanvasTilt(double tilt);

/**
* Start playing a sound file asynchronously. Supported formats depends
* on sound backend. The deviceIx is only used on platforms using the
* portaudio sound backend where -1 indicates the default device.
*/
extern DECL_EXP bool PlugInPlaySoundEx( wxString &sound_file, int deviceIndex=-1 );
extern DECL_EXP void AddChartDirectory( wxString &path );
extern DECL_EXP void ForceChartDBUpdate();
extern DECL_EXP void ForceChartDBRebuild();

extern DECL_EXP wxString GetWritableDocumentsDir( void );
extern DECL_EXP wxDialog *GetActiveOptionsDialog();
extern DECL_EXP wxArrayString GetWaypointGUIDArray( void );
extern DECL_EXP wxArrayString GetIconNameArray(void);

extern DECL_EXP bool AddPersistentFontKey(wxString TextElement);
extern DECL_EXP wxString GetActiveStyleName();
Expand Down Expand Up @@ -1127,7 +1212,7 @@ enum OCPN_DLDialogStyle

/* Synchronous (Blocking) download of a single file */

extern DECL_EXP _OCPN_DLStatus OCPN_downloadFile( const wxString& url, const wxString &outputFile,
extern DECL_EXP _OCPN_DLStatus OCPN_downloadFile( const wxString& url, const wxString &outputFile,
const wxString &title, const wxString &message,
const wxBitmap& bitmap,
wxWindow *parent, long style, int timeout_secs);
Expand Down Expand Up @@ -1196,9 +1281,106 @@ class DECL_EXP OCPN_downloadEvent: public wxEvent
bool m_b_complete;
};

//DECLARE_EVENT_TYPE(wxEVT_DOWNLOAD_EVENT, -1)
//extern const wxEventType DECL_EXP wxEVT_DOWNLOAD_EVENT;

extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DOWNLOAD_EVENT;
//extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DOWNLOAD_EVENT;

#ifdef MAKING_PLUGIN
extern DECL_IMP wxEventType wxEVT_DOWNLOAD_EVENT;
#else
extern DECL_EXP wxEventType wxEVT_DOWNLOAD_EVENT;
#endif


/* API 1.14 */
/* API 1.14 adds some more common functions to avoid unnecessary code duplication */

bool LaunchDefaultBrowser_Plugin( wxString url );


// API 1.14 Extra canvas Support

/* Allow drawing of objects onto other OpenGL canvases */
extern DECL_EXP void PlugInAISDrawGL( wxGLCanvas* glcanvas, const PlugIn_ViewPort& vp );
extern DECL_EXP bool PlugInSetFontColor(const wxString TextElement, const wxColour color);

// API 1.15
extern DECL_EXP double PlugInGetDisplaySizeMM();

//
extern DECL_EXP wxFont* FindOrCreateFont_PlugIn( int point_size, wxFontFamily family,
wxFontStyle style, wxFontWeight weight, bool underline = false,
const wxString &facename = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT );

extern DECL_EXP int PlugInGetMinAvailableGshhgQuality();
extern DECL_EXP int PlugInGetMaxAvailableGshhgQuality();

extern DECL_EXP void PlugInHandleAutopilotRoute(bool enable);

// API 1.16
//
/**
* Return the plugin data directory for a given directory name.
*
* On Linux, the returned data path is an existing directory ending in
* "opencpn/plugins/<plugin_name>" where the last part is the plugin_name
* argument. The prefix part is one of the directories listed in the
* environment variable XDG_DATA_DIRS, by default
* ~/.local/share:/usr/local/share:/usr/share.
*
* On other platforms, the returned value is GetSharedDataDir() +
* "/opencpn/plugins/" + plugin_name (with native path separators)
* if that path exists.
*
* Return "" if no existing directory is found.
*/
extern DECL_EXP wxString GetPluginDataDir(const char* plugin_name);

extern DECL_EXP bool ShuttingDown( void );

// Support for MUI MultiCanvas model

extern DECL_EXP wxWindow* PluginGetFocusCanvas();
extern DECL_EXP wxWindow* PluginGetOverlayRenderCanvas();

extern "C" DECL_EXP void CanvasJumpToPosition( wxWindow *canvas, double lat, double lon, double scale);
extern "C" DECL_EXP int AddCanvasMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin, const char *name = "");
extern "C" DECL_EXP void RemoveCanvasMenuItem(int item, const char *name = ""); // Fully remove this item
extern "C" DECL_EXP void SetCanvasMenuItemViz(int item, bool viz, const char *name = ""); // Temporarily change context menu options
extern "C" DECL_EXP void SetCanvasMenuItemGrey(int item, bool grey, const char *name = "");

// Extract waypoints, routes and tracks
extern DECL_EXP wxString GetSelectedWaypointGUID_Plugin( );
extern DECL_EXP wxString GetSelectedRouteGUID_Plugin( );
extern DECL_EXP wxString GetSelectedTrackGUID_Plugin( );

extern DECL_EXP std::unique_ptr<PlugIn_Waypoint> GetWaypoint_Plugin( const wxString& ); // doublon with GetSingleWaypoint
extern DECL_EXP std::unique_ptr<PlugIn_Route> GetRoute_Plugin( const wxString& );
extern DECL_EXP std::unique_ptr<PlugIn_Track> GetTrack_Plugin( const wxString& );

extern DECL_EXP wxWindow* GetCanvasUnderMouse( );
extern DECL_EXP int GetCanvasIndexUnderMouse( );
//extern DECL_EXP std::vector<wxWindow *> GetCanvasArray();
extern DECL_EXP wxWindow *GetCanvasByIndex( int canvasIndex );
extern DECL_EXP int GetCanvasCount( );
extern DECL_EXP bool CheckMUIEdgePan_PlugIn( int x, int y, bool dragging, int margin, int delta, int canvasIndex );
extern DECL_EXP void SetMUICursor_PlugIn( wxCursor *pCursor, int canvasIndex );

// API 1.17
//
extern DECL_EXP wxRect GetMasterToolbarRect();

enum SDDMFORMAT
{
DEGREES_DECIMAL_MINUTES = 0,
DECIMAL_DEGREES,
DEGREES_MINUTES_SECONDS,
END_SDDMFORMATS
};

extern DECL_EXP int GetLatLonFormat(void);

// API 1.17
extern "C" DECL_EXP void ZeroXTE();

#endif //_PLUGIN_H_
Loading

0 comments on commit 59f97d3

Please sign in to comment.