diff -Nru opencpn-plugin-iacfleet-0.9.0/appveyor.yml opencpn-plugin-iacfleet-0.10.0/appveyor.yml --- opencpn-plugin-iacfleet-0.9.0/appveyor.yml 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/appveyor.yml 2018-02-02 14:45:41.000000000 +0000 @@ -0,0 +1,56 @@ +version: 0.9.{build} + +clone_folder: c:\projects\iacfleet_pi +shallow_clone: true +image: +- Visual Studio 2015 + +platform: + - Win32 + +configuration: Release +test: OFF + +install: + - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x86' + + # sent environment variables for wxWidgets + - set WXPARENT=C:\ + - set WXWIN=C:\wxWidgets-3.0.2 + - set wxWidgets_ROOT_DIR=%WXWIN% + - set wxWidgets_LIB_DIR=%WXWIN%\lib\vc_dll + - cmd: SET PATH=%PATH%;%WXWIN%;%wxWidgets_LIB_DIR%;C:\Program Files (x86)\Poedit\Gettexttools\bin; + + # install dependencies: + - choco install poedit nsis -x86 + + # Download and unzip wxwidgets +# - ps: Start-FileDownload http://downloads.sourceforge.net/project/wxwindows/3.0.2/wxWidgets-3.0.2.zip + - ps: Start-FileDownload http://downloads.sourceforge.net/project/opencpnplugins/opencpn_packaging_data/wxWidgets-3.0.2.7z + - cmd: 7z x wxwidgets-3.0.2.7z -o%WXPARENT% > null + + # some debugging information + - set + # - cmake --help + + # build wxWidgets +# - cmd: cd %WXWIN%\build\msw\ +# - cmd: nmake -f makefile.vc BUILD=release SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_ +# - cmd: nmake -f makefile.vc BUILD=debug SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_ + +before_build: + - cd c:\projects\iacfleet_pi + - mkdir build + - cd build + - ps: Start-FileDownload http://downloads.sourceforge.net/project/opencpnplugins/opencpn_packaging_data/OpenCPN_buildwin.7z + - cmd: 7z x -y OpenCPN_buildwin.7z -oc:\projects\iacfleet_pi + - ps: Start-FileDownload http://downloads.sourceforge.net/project/opencpnplugins/opencpn_lib/4.2-vc120_xp/opencpn.lib + - cmake -T v120_xp .. + +build_script: + - cmake --build . --config Release --target package + +artifacts: + - path: build\iacfleet_pi*.exe + name: installer + diff -Nru opencpn-plugin-iacfleet-0.9.0/.clang-format opencpn-plugin-iacfleet-0.10.0/.clang-format --- opencpn-plugin-iacfleet-0.9.0/.clang-format 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/.clang-format 2018-02-02 14:45:41.000000000 +0000 @@ -0,0 +1,8 @@ +####this configuration requires clang - format 3.8 or higher## +Language : Cpp +UseTab : Never +TabWidth : 4 +IndentWidth : 4 +BasedOnStyle : Google +PenaltyBreakString : 999999999 +ColumnLimit : 132 diff -Nru opencpn-plugin-iacfleet-0.9.0/cmake/PluginConfigure.cmake opencpn-plugin-iacfleet-0.10.0/cmake/PluginConfigure.cmake --- opencpn-plugin-iacfleet-0.9.0/cmake/PluginConfigure.cmake 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/cmake/PluginConfigure.cmake 2018-02-02 14:45:41.000000000 +0000 @@ -7,11 +7,6 @@ SET(PLUGIN_SOURCE_DIR .) # This should be 2.8.0 to have FindGTK2 module -IF (COMMAND cmake_policy) - CMAKE_POLICY(SET CMP0003 OLD) - CMAKE_POLICY(SET CMP0005 OLD) - CMAKE_POLICY(SET CMP0011 OLD) -ENDIF (COMMAND cmake_policy) MESSAGE (STATUS "*** Staging to build ${PACKAGE_NAME} ***") @@ -31,7 +26,7 @@ ADD_DEFINITIONS( "-Wall -g -fprofile-arcs -ftest-coverage -fexceptions" ) ELSE(PROFILING) # ADD_DEFINITIONS( "-Wall -g -fexceptions" ) - ADD_DEFINITIONS( "-Wall -Wno-unused-result -g -O2 -fexceptions" ) + ADD_DEFINITIONS( "-Wall -Wno-unused-result -g -O2 -fexceptions -fPIC" ) ENDIF(PROFILING) IF(NOT APPLE) diff -Nru opencpn-plugin-iacfleet-0.9.0/cmake/PluginPackage.cmake opencpn-plugin-iacfleet-0.10.0/cmake/PluginPackage.cmake --- opencpn-plugin-iacfleet-0.9.0/cmake/PluginPackage.cmake 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/cmake/PluginPackage.cmake 2018-02-02 14:45:41.000000000 +0000 @@ -6,9 +6,6 @@ # build a CPack driven installer package #include (InstallRequiredSystemLibraries) -IF (COMMAND cmake_policy) - CMAKE_POLICY(SET CMP0002 OLD) -ENDIF (COMMAND cmake_policy) SET(CPACK_PACKAGE_NAME "${PACKAGE_NAME}") SET(CPACK_PACKAGE_VENDOR "opencpn.org") diff -Nru opencpn-plugin-iacfleet-0.9.0/CMakeLists.txt opencpn-plugin-iacfleet-0.10.0/CMakeLists.txt --- opencpn-plugin-iacfleet-0.9.0/CMakeLists.txt 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/CMakeLists.txt 2018-02-02 14:45:41.000000000 +0000 @@ -15,9 +15,10 @@ SET(CPACK_PACKAGE_CONTACT "Pavel Kalian") SET(VERSION_MAJOR "0") -SET(VERSION_MINOR "9") +SET(VERSION_MINOR "10") #SET(CMAKE_BUILD_TYPE Debug) +SET(CMAKE_MACOSX_RPATH "ON") # Definitions add_definitions ( @@ -50,7 +51,7 @@ src/icon.png src/icons.cpp src/icons.h -src/ocpn_plugin.h +include/ocpn_plugin.h ) ADD_LIBRARY(${PACKAGE_NAME} SHARED ${SRC_IACFLEET}) diff -Nru opencpn-plugin-iacfleet-0.9.0/debian/changelog opencpn-plugin-iacfleet-0.10.0/debian/changelog --- opencpn-plugin-iacfleet-0.9.0/debian/changelog 2016-09-21 21:16:09.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/debian/changelog 2018-02-02 15:08:22.000000000 +0000 @@ -1,3 +1,38 @@ +opencpn-plugin-iacfleet (0.10.0-0~xenial1) xenial; urgency=low + + * Version 0.10 + + -- Pavel Kalian Fri, 02 Feb 2018 09:07:28 -0600 +opencpn-plugin-iacfleet (0.10.0-0~artful1) artful; urgency=low + + * Version 0.10 + + -- Pavel Kalian Fri, 02 Feb 2018 09:07:28 -0600 +opencpn-plugin-iacfleet (0.10.0-0~bionic1) bionic; urgency=low + + * Version 0.10 + + -- Pavel Kalian Fri, 02 Feb 2018 09:07:28 -0600 +opencpn-plugin-iacfleet (0.9.0-0~precise1) precise; urgency=low + + * Version 0.9 + + -- Pavel Kalian Wed, 21 Sep 2016 16:14:51 -0500 +opencpn-plugin-iacfleet (0.9.0-0~trusty1) trusty; urgency=low + + * Version 0.9 + + -- Pavel Kalian Wed, 21 Sep 2016 16:14:51 -0500 +opencpn-plugin-iacfleet (0.9.0-0~vivid1) vivid; urgency=low + + * Version 0.9 + + -- Pavel Kalian Wed, 21 Sep 2016 16:14:51 -0500 +opencpn-plugin-iacfleet (0.9.0-0~wily1) wily; urgency=low + + * Version 0.9 + + -- Pavel Kalian Wed, 21 Sep 2016 16:14:51 -0500 opencpn-plugin-iacfleet (0.9.0-0~xenial1) xenial; urgency=low * Version 0.9 diff -Nru opencpn-plugin-iacfleet-0.9.0/include/ocpn_plugin.h opencpn-plugin-iacfleet-0.10.0/include/ocpn_plugin.h --- opencpn-plugin-iacfleet-0.9.0/include/ocpn_plugin.h 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/include/ocpn_plugin.h 2018-02-02 14:45:41.000000000 +0000 @@ -0,0 +1,1169 @@ +/*************************************************************************** + * + * Project: OpenCPN + * Purpose: PlugIn Object Definition/API + * Author: David Register + * + *************************************************************************** + * Copyright (C) 2010 by David S. Register * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + **************************************************************************/ + +#ifndef _PLUGIN_H_ +#define _PLUGIN_H_ + +#ifndef DECL_EXP +#ifdef __WXMSW__ +# define DECL_EXP __declspec(dllexport) +#else +# ifdef __GNUC__ +# define DECL_EXP __attribute__((visibility("default"))) +# endif +#endif +#endif + + +#include + +#ifdef ocpnUSE_SVG +#include "wxsvg/include/wxSVG/svg.h" +#endif // ocpnUSE_SVG + +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 + +// Fwd Definitions +class wxFileConfig; +class wxNotebook; +class wxFont; +class wxAuiManager; +class wxScrolledWindow; + +//--------------------------------------------------------------------------------------------------------- +// +// Bitfield PlugIn Capabilites flag definition +// +//--------------------------------------------------------------------------------------------------------- +#define WANTS_OVERLAY_CALLBACK 0x00000001 +#define WANTS_CURSOR_LATLON 0x00000002 +#define WANTS_TOOLBAR_CALLBACK 0x00000004 +#define INSTALLS_TOOLBAR_TOOL 0x00000008 +#define WANTS_CONFIG 0x00000010 +#define INSTALLS_TOOLBOX_PAGE 0x00000020 +#define INSTALLS_CONTEXTMENU_ITEMS 0x00000040 +#define WANTS_NMEA_SENTENCES 0x00000080 +#define WANTS_NMEA_EVENTS 0x00000100 +#define WANTS_AIS_SENTENCES 0x00000200 +#define USES_AUI_MANAGER 0x00000400 +#define WANTS_PREFERENCES 0x00000800 +#define INSTALLS_PLUGIN_CHART 0x00001000 +#define WANTS_ONPAINT_VIEWPORT 0x00002000 +#define WANTS_PLUGIN_MESSAGING 0x00004000 +#define WANTS_OPENGL_OVERLAY_CALLBACK 0x00008000 +#define WANTS_DYNAMIC_OPENGL_OVERLAY_CALLBACK 0x00010000 +#define WANTS_LATE_INIT 0x00020000 +#define INSTALLS_PLUGIN_CHART_GL 0x00040000 +#define WANTS_MOUSE_EVENTS 0x00080000 +#define WANTS_VECTOR_CHART_OBJECT_INFO 0x00100000 +#define WANTS_KEYBOARD_EVENTS 0x00200000 + +//---------------------------------------------------------------------------------------------------------- +// Some PlugIn API interface object class definitions +//---------------------------------------------------------------------------------------------------------- +enum PI_ColorScheme +{ + PI_GLOBAL_COLOR_SCHEME_RGB, + PI_GLOBAL_COLOR_SCHEME_DAY, + PI_GLOBAL_COLOR_SCHEME_DUSK, + PI_GLOBAL_COLOR_SCHEME_NIGHT, + PI_N_COLOR_SCHEMES +}; + +class PlugIn_ViewPort +{ + public: + double clat; // center point + double clon; + double view_scale_ppm; + double skew; + double rotation; + + float chart_scale; // conventional chart displayed scale + + int pix_width; + int pix_height; + wxRect rv_rect; + bool b_quilt; + int m_projection_type; + + double lat_min, lat_max, lon_min, lon_max; + + bool bValid; // This VP is valid +}; + +class PlugIn_Position_Fix +{ + public: + double Lat; + double Lon; + double Cog; + double Sog; + double Var; // Variation, typically from RMC message + time_t FixTime; + int nSats; +}; + +class PlugIn_Position_Fix_Ex +{ + public: + double Lat; + double Lon; + double Cog; + double Sog; + double Var; // Variation, typically from RMC message + double Hdm; + double Hdt; + time_t FixTime; + int nSats; +}; + +// Describe AIS Alarm state +enum plugin_ais_alarm_type +{ + PI_AIS_NO_ALARM = 0, + PI_AIS_ALARM_SET, + PI_AIS_ALARM_ACKNOWLEDGED + +}; + + +class PlugIn_AIS_Target +{ + public: + + int MMSI; + int Class; + int NavStatus; + double SOG; + double COG; + double HDG; + double Lon; + double Lat; + int ROTAIS; + char CallSign[8]; // includes terminator + char ShipName[21]; + unsigned char ShipType; + int IMO; + + double Range_NM; + double Brg; + + // Per target collision parameters + bool bCPA_Valid; + double TCPA; // Minutes + double CPA; // Nautical Miles + + plugin_ais_alarm_type alarm_state; +}; + + +// ChartType constants +typedef enum ChartTypeEnumPI +{ + PI_CHART_TYPE_UNKNOWN = 0, + PI_CHART_TYPE_DUMMY, + PI_CHART_TYPE_DONTCARE, + PI_CHART_TYPE_KAP, + PI_CHART_TYPE_GEO, + PI_CHART_TYPE_S57, + PI_CHART_TYPE_CM93, + PI_CHART_TYPE_CM93COMP, + PI_CHART_TYPE_PLUGIN +}_ChartTypeEnumPI; + +// ChartFamily constants +typedef enum ChartFamilyEnumPI +{ + PI_CHART_FAMILY_UNKNOWN = 0, + PI_CHART_FAMILY_RASTER, + PI_CHART_FAMILY_VECTOR, + PI_CHART_FAMILY_DONTCARE +}_ChartFamilyEnumPI; + +// Depth unit type enum +typedef enum ChartDepthUnitTypePI +{ + PI_DEPTH_UNIT_UNKNOWN, + PI_DEPTH_UNIT_FEET, + PI_DEPTH_UNIT_METERS, + PI_DEPTH_UNIT_FATHOMS +}_ChartDepthUnitTypePI; + +// Projection type enum +typedef enum OcpnProjTypePI +{ + PI_PROJECTION_UNKNOWN, + PI_PROJECTION_MERCATOR, + PI_PROJECTION_TRANSVERSE_MERCATOR, + PI_PROJECTION_POLYCONIC, + + PI_PROJECTION_ORTHOGRAPHIC, + PI_PROJECTION_POLAR, + PI_PROJECTION_STEREOGRAPHIC, + PI_PROJECTION_GNOMONIC, + PI_PROJECTION_EQUIRECTANGULAR +}_OcpnProjTypePI; + +typedef struct _ExtentPI{ + double SLAT; + double WLON; + double NLAT; + double ELON; +}ExtentPI; + +// PlugInChartBase::Init() init_flags constants +#define PI_FULL_INIT 0 +#define PI_HEADER_ONLY 1 +#define PI_THUMB_ONLY 2 + + +// ---------------------------------------------------------------------------- +// PlugInChartBase +// This class is the base class for Plug-able chart types +// ---------------------------------------------------------------------------- + +class DECL_EXP PlugInChartBase : public wxObject +{ + public: + // These methods Must be overriden in any derived class + PlugInChartBase(); + virtual ~PlugInChartBase(); + + virtual wxString GetFileSearchMask(void); + + virtual int Init( const wxString& full_path, int init_flags ); + virtual void SetColorScheme(int cs, bool bApplyImmediate); + + virtual double GetNormalScaleMin(double canvas_scale_factor, bool b_allow_overzoom); + virtual double GetNormalScaleMax(double canvas_scale_factor, int canvas_width); + virtual double GetNearestPreferredScalePPM(double target_scale_ppm); + + virtual bool GetChartExtent(ExtentPI *pext); + + virtual wxBitmap &RenderRegionView(const PlugIn_ViewPort& VPoint, const wxRegion &Region); + + virtual bool AdjustVP(PlugIn_ViewPort &vp_last, PlugIn_ViewPort &vp_proposed); + + virtual void GetValidCanvasRegion(const PlugIn_ViewPort& VPoint, wxRegion *pValidRegion); + + virtual int GetCOVREntries(){ return 0; } + virtual int GetCOVRTablePoints(int iTable) { return 0; } + virtual int GetCOVRTablenPoints(int iTable){ return 0; } + virtual float *GetCOVRTableHead(int iTable){ return (float *)NULL; } + + virtual wxBitmap *GetThumbnail(int tnx, int tny, int cs); + +// Accessors, need not be overridden in derived class if the member variables are maintained + virtual wxString GetFullPath() const { return m_FullPath;} + virtual ChartTypeEnumPI GetChartType() { return m_ChartType;} + virtual ChartFamilyEnumPI GetChartFamily() { return m_ChartFamily;} + virtual OcpnProjTypePI GetChartProjection() { return m_projection;} + virtual wxString GetName() { return m_Name;} + virtual wxString GetDescription() { return m_Description;} + virtual wxString GetID() { return m_ID;} + virtual wxString GetSE() { return m_SE;} + virtual wxString GetDepthUnits() { return m_DepthUnits;} + virtual wxString GetSoundingsDatum() { return m_SoundingsDatum;} + virtual wxString GetDatumString() { return m_datum_str;} + virtual wxString GetExtraInfo() { return m_ExtraInfo; } + virtual wxString GetPubDate() { return m_PubYear;} + virtual double GetChartErrorFactor() { return m_Chart_Error_Factor;} + virtual ChartDepthUnitTypePI GetDepthUnitId() { return m_depth_unit_id;} + virtual bool IsReadyToRender() { return m_bReadyToRender;} + virtual int GetNativeScale() { return m_Chart_Scale; }; + virtual double GetChartSkew() { return m_Chart_Skew; } + virtual wxDateTime GetEditionDate(void) { return m_EdDate;} + +// Methods pertaining to CHART_FAMILY_RASTER type PlugIn charts only + virtual void ComputeSourceRectangle(const PlugIn_ViewPort &vp, wxRect *pSourceRect); + virtual double GetRasterScaleFactor(); + virtual bool GetChartBits( wxRect& source, unsigned char *pPix, int sub_samp ); + virtual int GetSize_X(); + virtual int GetSize_Y(); + virtual void latlong_to_chartpix(double lat, double lon, double &pixx, double &pixy); + virtual void chartpix_to_latlong(double pixx, double pixy, double *plat, double *plon); + + protected: + ChartTypeEnumPI m_ChartType; + ChartFamilyEnumPI m_ChartFamily; + + wxString m_FullPath; + OcpnProjTypePI m_projection; + int m_Chart_Scale; + double m_Chart_Skew; + + wxDateTime m_EdDate; + bool m_bReadyToRender; + + wxString m_Name; + wxString m_Description; + wxString m_ID; + wxString m_SE; + wxString m_SoundingsDatum; + wxString m_datum_str; + wxString m_PubYear; + wxString m_DepthUnits; + wxString m_ExtraInfo; + + ChartDepthUnitTypePI m_depth_unit_id; + + double m_Chart_Error_Factor; + + +}; + + + + + +// Declare an array of PlugIn_AIS_Targets +WX_DEFINE_ARRAY_PTR(PlugIn_AIS_Target *, ArrayOfPlugIn_AIS_Targets); + + + +//---------------------------------------------------------------------------------------------------------- +// The Generic PlugIn Interface Class Definition +// +// This is a virtual class. +// opencpn PlugIns must derive from this class. +// There are two types of methods in this class +// a. Required...must be overridden and implemented by PlugIns +// b. Optional..may be overridden by PlugIns + +// PlugIns must implement optional method overrides consistent with their +// declared capabilities flag as returned by Init(). +//---------------------------------------------------------------------------------------------------------- +class DECL_EXP opencpn_plugin +{ + +public: + opencpn_plugin(void *pmgr) {} + virtual ~opencpn_plugin(); + + // Public API to the PlugIn class + + // This group of methods is required, and will be called by the opencpn host + // opencpn PlugIns must implement this group + virtual int Init(void); // Return the PlugIn Capabilites flag + virtual bool DeInit(void); + + virtual int GetAPIVersionMajor(); + virtual int GetAPIVersionMinor(); + virtual int GetPlugInVersionMajor(); + virtual int GetPlugInVersionMinor(); + virtual wxBitmap *GetPlugInBitmap(); + + // These three methods should produce valid, meaningful strings always + // ---EVEN IF--- the PlugIn has not (yet) been initialized. + // They are used by the PlugInManager GUI + virtual wxString GetCommonName(); + virtual wxString GetShortDescription(); + virtual wxString GetLongDescription(); + + // This group is optional. + // PlugIns may override any of these methods as required + + virtual void SetDefaults(void); //This will be called upon enabling a PlugIn via the user Dialog + //It gives a chance to setup any default options and behavior + + virtual int GetToolbarToolCount(void); + + virtual int GetToolboxPanelCount(void); + virtual void SetupToolboxPanel(int page_sel, wxNotebook* pnotebook); + virtual void OnCloseToolboxPanel(int page_sel, int ok_apply_cancel); + + virtual void ShowPreferencesDialog( wxWindow* parent ); + + virtual bool RenderOverlay(wxMemoryDC *pmdc, PlugIn_ViewPort *vp); + virtual void SetCursorLatLon(double lat, double lon); + virtual void SetCurrentViewPort(PlugIn_ViewPort &vp); + + virtual void SetPositionFix(PlugIn_Position_Fix &pfix); + virtual void SetNMEASentence(wxString &sentence); + virtual void SetAISSentence(wxString &sentence); + + virtual void ProcessParentResize(int x, int y); + virtual void SetColorScheme(PI_ColorScheme cs); + + virtual void OnToolbarToolCallback(int id); + virtual void OnContextMenuItemCallback(int id); + + virtual void UpdateAuiStatus(void); + + virtual wxArrayString GetDynamicChartClassNameArray(void); + }; + + + // the types of the class factories used to create PlugIn instances + typedef opencpn_plugin* create_t(void*); + typedef void destroy_t(opencpn_plugin*); + + class DECL_EXP opencpn_plugin_16 : public opencpn_plugin + { + public: + opencpn_plugin_16(void *pmgr); + virtual ~opencpn_plugin_16(); + + virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp); + + virtual void SetPluginMessage(wxString &message_id, wxString &message_body); + + }; + +class DECL_EXP opencpn_plugin_17 : public opencpn_plugin +{ + public: + opencpn_plugin_17(void *pmgr); + virtual ~opencpn_plugin_17(); + + 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); + +}; + +class DECL_EXP opencpn_plugin_18 : public opencpn_plugin +{ + public: + opencpn_plugin_18(void *pmgr); + virtual ~opencpn_plugin_18(); + + 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); + +}; + +class DECL_EXP opencpn_plugin_19 : public opencpn_plugin_18 +{ + public: + opencpn_plugin_19(void *pmgr); + virtual ~opencpn_plugin_19(); + + virtual void OnSetupOptions(void); +}; + +class DECL_EXP opencpn_plugin_110 : public opencpn_plugin_19 +{ + public: + opencpn_plugin_110(void *pmgr); + virtual ~opencpn_plugin_110(); + + virtual void LateInit(void); // If WANTS_LATE_INIT is returned by Init() +}; + +class DECL_EXP opencpn_plugin_111 : public opencpn_plugin_110 +{ +public: + opencpn_plugin_111(void *pmgr); + virtual ~opencpn_plugin_111(); + +}; + +class DECL_EXP opencpn_plugin_112 : public opencpn_plugin_111 +{ +public: + opencpn_plugin_112(void *pmgr); + virtual ~opencpn_plugin_112(); + + virtual bool MouseEventHook( wxMouseEvent &event ); + virtual void SendVectorChartObjectInfo(wxString &chart, wxString &feature, wxString &objname, double lat, double lon, double scale, int nativescale); + +}; + +class DECL_EXP opencpn_plugin_113 : public opencpn_plugin_112 +{ +public: + opencpn_plugin_113(void *pmgr); + virtual ~opencpn_plugin_113(); + + virtual bool KeyboardEventHook( wxKeyEvent &event ); + virtual void OnToolbarToolDownCallback(int id); + virtual void OnToolbarToolUpCallback(int id); +}; + +//------------------------------------------------------------------ +// Route and Waypoint PlugIn support +// +//------------------------------------------------------------------ + +class DECL_EXP Plugin_Hyperlink +{ +public: + wxString DescrText; + wxString Link; + wxString Type; +}; + +WX_DECLARE_LIST(Plugin_Hyperlink, Plugin_HyperlinkList); + + + +class DECL_EXP PlugIn_Waypoint +{ +public: + PlugIn_Waypoint(); + PlugIn_Waypoint(double lat, double lon, + const wxString& icon_ident, const wxString& wp_name, + const wxString& GUID = _T("") ); + ~PlugIn_Waypoint(); + + double m_lat; + double m_lon; + + wxString m_GUID; + + wxString m_MarkName; + wxString m_MarkDescription; + wxDateTime m_CreateTime; + bool m_IsVisible; + + wxString m_IconName; + + Plugin_HyperlinkList *m_HyperlinkList; + +}; + +WX_DECLARE_LIST(PlugIn_Waypoint, Plugin_WaypointList); + +class DECL_EXP PlugIn_Route +{ +public: + PlugIn_Route(void); + ~PlugIn_Route(void); + + wxString m_NameString; + wxString m_StartString; + wxString m_EndString; + wxString m_GUID; + + Plugin_WaypointList *pWaypointList; +}; + +class DECL_EXP PlugIn_Track +{ +public: + PlugIn_Track(void); + ~PlugIn_Track(void); + + wxString m_NameString; + wxString m_StartString; + wxString m_EndString; + wxString m_GUID; + + Plugin_WaypointList *pWaypointList; +}; + + + +//---------------------------------------------------------------------------------------------------------- +// The PlugIn CallBack API Definition +// +// The API back up to the PlugIn Manager +// PlugIns may call these static functions as necessary for system services +// +//---------------------------------------------------------------------------------------------------------- + + +extern "C" DECL_EXP int InsertPlugInTool(wxString label, wxBitmap *bitmap, wxBitmap *bmpRollover, wxItemKind kind, + wxString shortHelp, wxString longHelp, wxObject *clientData, int position, + int tool_sel, opencpn_plugin *pplugin); +extern "C" DECL_EXP void RemovePlugInTool(int tool_id); +extern "C" DECL_EXP void SetToolbarToolViz(int item, bool viz); // Temporarily change toolbar tool viz +extern "C" DECL_EXP void SetToolbarItemState(int item, bool toggle); +extern "C" DECL_EXP void SetToolbarToolBitmaps(int item, wxBitmap *bitmap, wxBitmap *bmpRollover); + +extern "C" DECL_EXP int InsertPlugInToolSVG(wxString label, wxString SVGfile, wxString SVGfileRollover, wxString SVGfileToggled, + wxItemKind kind, wxString shortHelp, wxString longHelp, + wxObject *clientData, int position, int tool_sel, opencpn_plugin *pplugin); +extern "C" DECL_EXP void SetToolbarToolBitmapsSVG(int item, wxString SVGfile, + wxString SVGfileRollover, + wxString SVGfileToggled ); + +extern "C" DECL_EXP int AddCanvasContextMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin ); +extern "C" DECL_EXP void RemoveCanvasContextMenuItem(int item); // Fully remove this item +extern "C" DECL_EXP void SetCanvasContextMenuItemViz(int item, bool viz); // Temporarily change context menu ptions +extern "C" DECL_EXP void SetCanvasContextMenuItemGrey(int item, bool grey); + + +extern "C" DECL_EXP wxFileConfig *GetOCPNConfigObject(void); + +extern "C" DECL_EXP void RequestRefresh(wxWindow *); +extern "C" DECL_EXP bool GetGlobalColor(wxString colorName, wxColour *pcolour); + +extern "C" DECL_EXP void GetCanvasPixLL(PlugIn_ViewPort *vp, wxPoint *pp, double lat, double lon); +extern "C" DECL_EXP void GetCanvasLLPix( PlugIn_ViewPort *vp, wxPoint p, double *plat, double *plon); + +extern "C" DECL_EXP wxWindow *GetOCPNCanvasWindow(); + +extern "C" DECL_EXP wxFont *OCPNGetFont(wxString TextElement, int default_size); + +extern "C" DECL_EXP wxString *GetpSharedDataLocation(); + +extern "C" DECL_EXP ArrayOfPlugIn_AIS_Targets *GetAISTargetArray(void); + +extern "C" DECL_EXP wxAuiManager *GetFrameAuiManager(void); + +extern "C" DECL_EXP bool AddLocaleCatalog( wxString catalog ); + +extern "C" DECL_EXP void PushNMEABuffer( wxString str ); + +extern DECL_EXP wxXmlDocument GetChartDatabaseEntryXML(int dbIndex, bool b_getGeom); + +extern DECL_EXP bool UpdateChartDBInplace(wxArrayString dir_array, + bool b_force_update, + bool b_ProgressDialog); +extern DECL_EXP wxArrayString GetChartDBDirArrayString(); + +extern "C" DECL_EXP void SendPluginMessage( wxString message_id, wxString message_body ); + +extern "C" DECL_EXP void DimeWindow(wxWindow *); + +extern "C" DECL_EXP void JumpToPosition(double lat, double lon, double scale); + +/* API 1.9 adds some common cartographic functions to avoid unnecessary code duplication */ +/* Study the original OpenCPN source (georef.c) for functional definitions */ + +extern "C" DECL_EXP void PositionBearingDistanceMercator_Plugin(double lat, double lon, double brg, double dist, double *dlat, double *dlon); +extern "C" DECL_EXP void DistanceBearingMercator_Plugin(double lat0, double lon0, double lat1, double lon1, double *brg, double *dist); +extern "C" DECL_EXP double DistGreatCircle_Plugin(double slat, double slon, double dlat, double dlon); + +extern "C" DECL_EXP void toTM_Plugin(float lat, float lon, float lat0, float lon0, double *x, double *y); +extern "C" DECL_EXP void fromTM_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); +extern "C" DECL_EXP void toSM_Plugin(double lat, double lon, double lat0, double lon0, double *x, double *y); +extern "C" DECL_EXP void fromSM_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); +extern "C" DECL_EXP void toSM_ECC_Plugin(double lat, double lon, double lat0, double lon0, double *x, double *y); +extern "C" DECL_EXP void fromSM_ECC_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); + +extern "C" DECL_EXP bool DecodeSingleVDOMessage( const wxString& str, PlugIn_Position_Fix_Ex *pos, wxString *acc ); +extern "C" DECL_EXP int GetChartbarHeight( void ); +extern "C" DECL_EXP bool GetActiveRoutepointGPX( char *buffer, unsigned int buffer_length ); + + + +/* API 1.9 */ +typedef enum OptionsParentPI +{ + PI_OPTIONS_PARENT_DISPLAY, + PI_OPTIONS_PARENT_CONNECTIONS, + PI_OPTIONS_PARENT_CHARTS, + PI_OPTIONS_PARENT_SHIPS, + PI_OPTIONS_PARENT_UI, + PI_OPTIONS_PARENT_PLUGINS +}_OptionsParentPI; +extern DECL_EXP wxScrolledWindow *AddOptionsPage( OptionsParentPI parent, wxString title ); +extern DECL_EXP bool DeleteOptionsPage( wxScrolledWindow* page ); + + +/* API 1.10 */ + +/* API 1.10 adds some common functions to avoid unnecessary code duplication */ +/* Study the original OpenCPN source for functional definitions */ +extern "C" DECL_EXP double toUsrDistance_Plugin( double nm_distance, int unit = -1 ); +extern "C" DECL_EXP double fromUsrDistance_Plugin( double usr_distance, int unit = -1 ); +extern "C" DECL_EXP double toUsrSpeed_Plugin( double kts_speed, int unit = -1 ); +extern "C" DECL_EXP double fromUsrSpeed_Plugin( double usr_speed, int unit = -1 ); +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); +extern DECL_EXP void PlugInPlaySound( wxString &sound_file ); + + + + +// API 1.10 Route and Waypoint Support +extern DECL_EXP wxBitmap *FindSystemWaypointIcon( wxString& icon_name ); +extern DECL_EXP bool AddCustomWaypointIcon( wxBitmap *pimage, wxString key, wxString description ); + +extern DECL_EXP bool AddSingleWaypoint( PlugIn_Waypoint *pwaypoint, bool b_permanent = true); +extern DECL_EXP bool DeleteSingleWaypoint( wxString &GUID ); +extern DECL_EXP bool UpdateSingleWaypoint( PlugIn_Waypoint *pwaypoint ); + +extern DECL_EXP bool AddPlugInRoute( PlugIn_Route *proute, bool b_permanent = true ); +extern DECL_EXP bool DeletePlugInRoute( wxString& GUID ); +extern DECL_EXP bool UpdatePlugInRoute ( PlugIn_Route *proute ); + +extern DECL_EXP bool AddPlugInTrack( PlugIn_Track *ptrack, bool b_permanent = true ); +extern DECL_EXP bool DeletePlugInTrack( wxString& GUID ); +extern DECL_EXP bool UpdatePlugInTrack ( PlugIn_Track *ptrack ); + +/* API 1.11 */ + +/* API 1.11 adds some more common functions to avoid unnecessary code duplication */ +wxColour DECL_EXP GetBaseGlobalColor(wxString colorName); +int DECL_EXP OCPNMessageBox_PlugIn(wxWindow *parent, + const wxString& message, + const wxString& caption = _T("Message"), + int style = wxOK, int x = -1, int y = -1); + +extern DECL_EXP wxString toSDMM_PlugIn(int NEflag, double a, bool hi_precision = true); + +extern "C" DECL_EXP wxString *GetpPrivateApplicationDataLocation(); +extern DECL_EXP wxString GetOCPN_ExePath( void ); +extern "C" DECL_EXP wxString *GetpPlugInLocation(); +extern DECL_EXP wxString GetPlugInPath(opencpn_plugin *pplugin); + +extern "C" DECL_EXP int AddChartToDBInPlace( wxString &full_path, bool b_RefreshCanvas ); +extern "C" DECL_EXP int RemoveChartFromDBInPlace( wxString &full_path ); +extern DECL_EXP wxString GetLocaleCanonicalName(); + +// API 1.11 adds access to S52 Presentation library +//Types + +// A flag field that defines the object capabilities passed by a chart to the S52 PLIB + +#define PLIB_CAPS_LINE_VBO 1 +#define PLIB_CAPS_LINE_BUFFER 1 << 1 +#define PLIB_CAPS_SINGLEGEO_BUFFER 1 << 2 +#define PLIB_CAPS_OBJSEGLIST 1 << 3 +#define PLIB_CAPS_OBJCATMUTATE 1 << 4 + + +class PI_S57Obj; + +WX_DECLARE_LIST(PI_S57Obj, ListOfPI_S57Obj); + +// ---------------------------------------------------------------------------- +// PlugInChartBaseGL +// Derived from PlugInChartBase, add OpenGL Vector chart support +// ---------------------------------------------------------------------------- + +class DECL_EXP PlugInChartBaseGL : public PlugInChartBase +{ +public: + PlugInChartBaseGL(); + virtual ~PlugInChartBaseGL(); + + virtual int RenderRegionViewOnGL( const wxGLContext &glc, const PlugIn_ViewPort& VPoint, + const wxRegion &Region, bool b_use_stencil ); + + virtual ListOfPI_S57Obj *GetObjRuleListAtLatLon(float lat, float lon, float select_radius, PlugIn_ViewPort *VPoint); + virtual wxString CreateObjDescriptions( ListOfPI_S57Obj* obj_list ); + + virtual int GetNoCOVREntries(); + virtual int GetNoCOVRTablePoints(int iTable); + virtual int GetNoCOVRTablenPoints(int iTable); + virtual float *GetNoCOVRTableHead(int iTable); + +}; + + + + + + + +class wxArrayOfS57attVal; + +// name of the addressed look up table set (fifth letter) +typedef enum _PI_LUPname{ + PI_SIMPLIFIED = 'L', // points + PI_PAPER_CHART = 'R', // points + PI_LINES = 'S', // lines + PI_PLAIN_BOUNDARIES = 'N', // areas + PI_SYMBOLIZED_BOUNDARIES = 'O', // areas + PI_LUPNAME_NUM = 5 +}PI_LUPname; + +// display category type +typedef enum _PI_DisCat{ + PI_DISPLAYBASE = 'D', // + PI_STANDARD = 'S', // + PI_OTHER = 'O', // O for OTHER + PI_MARINERS_STANDARD = 'M', // Mariner specified + PI_MARINERS_OTHER, // value not defined + PI_DISP_CAT_NUM, // value not defined +}PI_DisCat; + +// Display Priority +typedef enum _PI_DisPrio{ + PI_PRIO_NODATA = '0', // no data fill area pattern + PI_PRIO_GROUP1 = '1', // S57 group 1 filled areas + PI_PRIO_AREA_1 = '2', // superimposed areas + PI_PRIO_AREA_2 = '3', // superimposed areas also water features + PI_PRIO_SYMB_POINT = '4', // point symbol also land features + PI_PRIO_SYMB_LINE = '5', // line symbol also restricted areas + PI_PRIO_SYMB_AREA = '6', // area symbol also traffic areas + PI_PRIO_ROUTEING = '7', // routeing lines + PI_PRIO_HAZARDS = '8', // hazards + PI_PRIO_MARINERS = '9', // VRM, EBL, own ship + PI_PRIO_NUM = 10 // number of priority levels + +}PI_DisPrio; + +typedef enum PI_InitReturn +{ + PI_INIT_OK = 0, + PI_INIT_FAIL_RETRY, // Init failed, retry suggested + PI_INIT_FAIL_REMOVE, // Init failed, suggest remove from further use + PI_INIT_FAIL_NOERROR // Init failed, request no explicit error message +}_PI_InitReturn; + +class PI_line_segment_element +{ +public: + size_t vbo_offset; + size_t n_points; + int priority; + float lat_max; // segment bounding box + float lat_min; + float lon_max; + float lon_min; + int type; + void *private0; + + PI_line_segment_element *next; +}; + + +class DECL_EXP PI_S57Obj +{ +public: + + // Public Methods + PI_S57Obj(); + ~PI_S57Obj(); + +public: + // Instance Data + char FeatureName[8]; + int Primitive_type; + + char *att_array; + wxArrayOfS57attVal *attVal; + int n_attr; + + int iOBJL; + int Index; + + double x; // for POINT + double y; + double z; + int npt; // number of points as needed by arrays + void *geoPt; // for LINE & AREA not described by PolyTessGeo + double *geoPtz; // an array[3] for MultiPoint, SM with Z, i.e. depth + double *geoPtMulti; // an array[2] for MultiPoint, lat/lon to make bbox + // of decomposed points + + void *pPolyTessGeo; + + double m_lat; // The lat/lon of the object's "reference" point + double m_lon; + + double chart_ref_lat; + double chart_ref_lon; + + double lat_min; + double lat_max; + double lon_min; + double lon_max; + + int Scamin; // SCAMIN attribute decoded during load + + bool bIsClone; + int nRef; // Reference counter, to signal OK for deletion + + bool bIsAton; // This object is an aid-to-navigation + bool bIsAssociable; // This object is DRGARE or DEPARE + + int m_n_lsindex; + int *m_lsindex_array; + int m_n_edge_max_points; + void *m_chart_context; + + PI_DisCat m_DisplayCat; + + void * S52_Context; + PI_S57Obj *child; // child list, used only for MultiPoint Soundings + + PI_S57Obj *next; // List linkage + + // This transform converts from object geometry + // to SM coordinates. + double x_rate; // These auxiliary transform coefficients are + double y_rate; // to be used in GetPointPix() and friends + double x_origin; // on a per-object basis if necessary + double y_origin; + + int auxParm0; // some per-object auxiliary parameters, used for OpenGL + int auxParm1; + int auxParm2; + int auxParm3; + + PI_line_segment_element *m_ls_list; + bool m_bcategory_mutable; + int m_DPRI; +}; + + + +wxString DECL_EXP PI_GetPLIBColorScheme(); +int DECL_EXP PI_GetPLIBDepthUnitInt(); +int DECL_EXP PI_GetPLIBSymbolStyle(); +int DECL_EXP PI_GetPLIBBoundaryStyle(); +int DECL_EXP PI_GetPLIBStateHash(); +double DECL_EXP PI_GetPLIBMarinerSafetyContour(); +bool DECL_EXP PI_GetObjectRenderBox( PI_S57Obj *pObj, double *lat_min, double *lat_max, double *lon_min, double *lon_max); +void DECL_EXP PI_UpdateContext(PI_S57Obj *pObj); + +bool DECL_EXP PI_PLIBObjectRenderCheck( PI_S57Obj *pObj, PlugIn_ViewPort *vp ); +PI_LUPname DECL_EXP PI_GetObjectLUPName( PI_S57Obj *pObj ); +PI_DisPrio DECL_EXP PI_GetObjectDisplayPriority( PI_S57Obj *pObj ); +PI_DisCat DECL_EXP PI_GetObjectDisplayCategory( PI_S57Obj *pObj ); +void DECL_EXP PI_PLIBSetLineFeaturePriority( PI_S57Obj *pObj, int prio ); +void DECL_EXP PI_PLIBPrepareForNewRender(void); +void DECL_EXP PI_PLIBFreeContext( void *pContext ); +void DECL_EXP PI_PLIBSetRenderCaps( unsigned int flags ); + +bool DECL_EXP PI_PLIBSetContext( PI_S57Obj *pObj ); + +int DECL_EXP PI_PLIBRenderObjectToDC( wxDC *pdc, PI_S57Obj *pObj, PlugIn_ViewPort *vp ); +int DECL_EXP PI_PLIBRenderAreaToDC( wxDC *pdc, PI_S57Obj *pObj, PlugIn_ViewPort *vp, wxRect rect, unsigned char *pixbuf ); + + +int DECL_EXP PI_PLIBRenderAreaToGL( const wxGLContext &glcc, PI_S57Obj *pObj, + PlugIn_ViewPort *vp, wxRect &render_rect ); + +int DECL_EXP PI_PLIBRenderObjectToGL( const wxGLContext &glcc, PI_S57Obj *pObj, + PlugIn_ViewPort *vp, wxRect &render_rect ); + +/* API 1.11 OpenGL Display List and vertex buffer object routines + + Effectively these two routines cancel each other so all + of the translation, scaling and rotation can be done by opengl. + + Display lists need only be built infrequently, but used in each frame + greatly accelerates the speed of rendering. This avoids costly calculations, + and also allows the vertexes to be stored in graphics memory. + + static int dl = 0; + glPushMatrix(); + PlugInMultMatrixViewport(current_viewport); + if(dl) + glCallList(dl); + else { + dl = glGenLists(1); + PlugInViewPort norm_viewport = current_viewport; + NormalizeViewPort(norm_viewport); + glNewList(dl, GL_COMPILE_AND_EXECUTE); + ... // use norm_viewport with GetCanvasLLPix here + glEndList(); + } + glPopMatrix(); + ... // use current_viewport with GetCanvasLLPix again +*/ + +extern DECL_EXP bool PlugInHasNormalizedViewPort ( PlugIn_ViewPort *vp ); +extern DECL_EXP void PlugInMultMatrixViewport ( PlugIn_ViewPort *vp, float lat=0, float lon=0 ); +extern DECL_EXP void PlugInNormalizeViewport ( PlugIn_ViewPort *vp, float lat=0, float lon=0 ); + +class wxPoint2DDouble; +extern "C" DECL_EXP void GetDoubleCanvasPixLL(PlugIn_ViewPort *vp, wxPoint2DDouble *pp, double lat, double lon); + +/* API 1.13 */ +/* API 1.13 adds some more common functions to avoid unnecessary code duplication */ + + +extern DECL_EXP double fromDMM_Plugin( wxString sdms ); +extern DECL_EXP void SetCanvasRotation(double rotation); +extern DECL_EXP void SetCanvasProjection(int projection); +extern DECL_EXP bool GetSingleWaypoint( wxString GUID, PlugIn_Waypoint *pwaypoint ); +extern DECL_EXP bool CheckEdgePan_PlugIn( int x, int y, bool dragging, int margin, int delta ); +extern DECL_EXP wxBitmap GetIcon_PlugIn(const wxString & name); +extern DECL_EXP void SetCursor_PlugIn( wxCursor *pPlugin_Cursor = NULL ); +extern DECL_EXP wxFont *GetOCPNScaledFont_PlugIn(wxString TextElement, int default_size = 0); +extern DECL_EXP wxFont GetOCPNGUIScaledFont_PlugIn(wxString item); +extern DECL_EXP double GetOCPNGUIToolScaleFactor_PlugIn(int GUIScaledFactor); +extern DECL_EXP double GetOCPNGUIToolScaleFactor_PlugIn(); +extern DECL_EXP float GetOCPNChartScaleFactor_Plugin(); +extern DECL_EXP wxColour GetFontColour_PlugIn(wxString TextElement); + +extern DECL_EXP double GetCanvasTilt(); +extern DECL_EXP void SetCanvasTilt(double tilt); + +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 wxString GetWritableDocumentsDir( void ); +extern DECL_EXP wxDialog *GetActiveOptionsDialog(); +extern DECL_EXP wxArrayString GetWaypointGUIDArray( void ); + +extern DECL_EXP bool AddPersistentFontKey(wxString TextElement); +extern DECL_EXP wxString GetActiveStyleName(); + +extern DECL_EXP wxBitmap GetBitmapFromSVGFile(wxString filename, unsigned int width, unsigned int height); +extern DECL_EXP bool IsTouchInterface_PlugIn(void); + +/* Platform optimized File/Dir selector dialogs */ +extern DECL_EXP int PlatformDirSelectorDialog( wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir); + +extern DECL_EXP int PlatformFileSelectorDialog( wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir, + wxString suggestedName, wxString wildcard); + + +/* OpenCPN HTTP File Download PlugIn Interface */ + +/* Various method Return Codes, etc */ +typedef enum _OCPN_DLStatus{ + OCPN_DL_UNKNOWN =-1, + OCPN_DL_NO_ERROR = 0, + OCPN_DL_FAILED = 1, + OCPN_DL_ABORTED = 2, + OCPN_DL_USER_TIMEOUT = 4, + OCPN_DL_STARTED = 8 +}OCPN_DLStatus; + + +typedef enum _OCPN_DLCondition{ + OCPN_DL_EVENT_TYPE_UNKNOWN = -1, + OCPN_DL_EVENT_TYPE_START = 80, + OCPN_DL_EVENT_TYPE_PROGRESS = 81, + OCPN_DL_EVENT_TYPE_END = 82 +}OCPN_DLCondition; + +// Style definitions for Synchronous file download modal dialogs, if desired. +// Abstracted from wxCURL package +enum OCPN_DLDialogStyle +{ + OCPN_DLDS_ELAPSED_TIME = 0x0001, //!< The dialog shows the elapsed time. + OCPN_DLDS_ESTIMATED_TIME = 0x0002, //!< The dialog shows the estimated total time. + OCPN_DLDS_REMAINING_TIME = 0x0004, //!< The dialog shows the remaining time. + OCPN_DLDS_SPEED = 0x0008, //!< The dialog shows the transfer speed. + OCPN_DLDS_SIZE = 0x0010, //!< The dialog shows the size of the resource to download/upload. + OCPN_DLDS_URL = 0x0020, //!< The dialog shows the URL involved in the transfer. + + // styles related to the use of wxCurlConnectionSettingsDialog: + + OCPN_DLDS_CONN_SETTINGS_AUTH = 0x0040, //!< The dialog allows the user to change the authentication settings. + OCPN_DLDS_CONN_SETTINGS_PORT = 0x0080, //!< The dialog allows the user to change the port for the transfer. + OCPN_DLDS_CONN_SETTINGS_PROXY = 0x0100, //!< The dialog allows the user to change the proxy settings. + + OCPN_DLDS_CONN_SETTINGS_ALL = OCPN_DLDS_CONN_SETTINGS_AUTH|OCPN_DLDS_CONN_SETTINGS_PORT|OCPN_DLDS_CONN_SETTINGS_PROXY, + + OCPN_DLDS_SHOW_ALL =OCPN_DLDS_ELAPSED_TIME|OCPN_DLDS_ESTIMATED_TIME|OCPN_DLDS_REMAINING_TIME| + OCPN_DLDS_SPEED|OCPN_DLDS_SIZE|OCPN_DLDS_URL|OCPN_DLDS_CONN_SETTINGS_ALL, + + OCPN_DLDS_CAN_ABORT = 0x0200, //!< The transfer can be aborted by the user. + OCPN_DLDS_CAN_START = 0x0400, //!< The transfer won't start automatically. The user needs to start it. + OCPN_DLDS_CAN_PAUSE = 0x0800, //!< The transfer can be paused. + + OCPN_DLDS_AUTO_CLOSE = 0x1000, //!< The dialog auto closes when transfer is complete. + + // by default all available features are enabled: + OCPN_DLDS_DEFAULT_STYLE = OCPN_DLDS_CAN_START|OCPN_DLDS_CAN_PAUSE|OCPN_DLDS_CAN_ABORT|OCPN_DLDS_SHOW_ALL|OCPN_DLDS_AUTO_CLOSE +}; + +#define ONLINE_CHECK_RETRY 30 // Recheck the Internet connection availability every ONLINE_CHECK_RETRY s + +/* Synchronous (Blocking) download of a single file */ + +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); + + +/* Asynchronous (Background) download of a single file */ + +extern DECL_EXP _OCPN_DLStatus OCPN_downloadFileBackground( const wxString& url, const wxString &outputFile, + wxEvtHandler *handler, long *handle); + +extern DECL_EXP void OCPN_cancelDownloadFileBackground( long handle ); + +/* Synchronous (Blocking) HTTP POST operation for small amounts of data */ + +extern DECL_EXP _OCPN_DLStatus OCPN_postDataHttp( const wxString& url, const wxString& parameters, wxString& result, int timeout_secs ); + +/* Check whether connection to the Internet is working */ + +extern DECL_EXP bool OCPN_isOnline(); + +/* Supporting Event for Background downloading */ +/* OCPN_downloadEvent Definition */ + +/* PlugIn should be ready/able to handle this event after initiating a background file transfer + * + * The event as received should be parsed primarily by the getDLEventCondition() method. + * This will allow identification of download start, progress, and end states. + * + * Other accessor methods contain status, byte counts, etc. + * + * A PlugIn may safely destroy its EvtHandler after receipt of an OCPN_downloadEvent with + * getDLEventCondition == OCPN_DL_EVENT_TYPE_END + */ + +class DECL_EXP OCPN_downloadEvent: public wxEvent +{ +public: + OCPN_downloadEvent( wxEventType commandType = wxEVT_NULL, int id = 0 ); + ~OCPN_downloadEvent( ); + + // accessors + _OCPN_DLStatus getDLEventStatus(){ return m_stat; } + OCPN_DLCondition getDLEventCondition(){ return m_condition; } + + void setDLEventStatus( _OCPN_DLStatus stat ){ m_stat = stat; } + void setDLEventCondition( OCPN_DLCondition cond ){ m_condition = cond; } + + void setTotal( long bytes ){m_totalBytes = bytes; } + void setTransferred( long bytes ){m_sofarBytes = bytes; } + long getTotal(){ return m_totalBytes; } + long getTransferred(){ return m_sofarBytes; } + + void setComplete(bool b_complete){ m_b_complete = b_complete; } + bool getComplete(){ return m_b_complete; } + + + // required for sending with wxPostEvent() + wxEvent *Clone() const; + +private: + OCPN_DLStatus m_stat; + OCPN_DLCondition m_condition; + + long m_totalBytes; + long m_sofarBytes; + 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; + +#endif //_PLUGIN_H_ diff -Nru opencpn-plugin-iacfleet-0.9.0/po/iacfleet_pi.pot opencpn-plugin-iacfleet-0.10.0/po/iacfleet_pi.pot --- opencpn-plugin-iacfleet-0.9.0/po/iacfleet_pi.pot 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/po/iacfleet_pi.pot 2018-02-02 14:45:41.000000000 +0000 @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: iacfleet_pi 0.8\n" +"Project-Id-Version: iacfleet_pi 0.9\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-02-24 13:01-0300\n" +"POT-Creation-Date: 2017-02-05 09:12-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -347,15 +347,15 @@ msgid "Isobar (%4uhPa):\n" msgstr "" -#: src/iacfleet_pi.cpp:106 src/iacfleet_pi.cpp:109 src/iacfleet_pi.cpp:157 +#: src/iacfleet_pi.cpp:107 src/iacfleet_pi.cpp:110 src/iacfleet_pi.cpp:158 msgid "IACFleet" msgstr "" -#: src/iacfleet_pi.cpp:162 +#: src/iacfleet_pi.cpp:163 msgid "IACFleet PlugIn for OpenCPN" msgstr "" -#: src/iacfleet_pi.cpp:168 +#: src/iacfleet_pi.cpp:169 msgid "" "IACFleet PlugIn for OpenCPN\n" "Display IAC Fleet Code information provided by NADI.\n" @@ -365,111 +365,111 @@ "Plugin to see the decoded text and a graphic overlay\n" msgstr "" -#: src/iacfleet_pi.cpp:178 +#: src/iacfleet_pi.cpp:179 msgid "IACFleet Preferences" msgstr "" -#: src/iacfleet_pi.cpp:199 src/iacfleet.h:81 +#: src/iacfleet_pi.cpp:207 src/iacfleet.h:81 msgid "IACFleet Display Control" msgstr "" -#: src/iacfleet.cpp:190 src/iacfleet.cpp:483 src/iacfleet.cpp:541 +#: src/iacfleet.cpp:193 src/iacfleet.cpp:486 src/iacfleet.cpp:544 msgid "Run as &animation" msgstr "" -#: src/iacfleet.cpp:206 +#: src/iacfleet.cpp:209 msgid "Stop &animation" msgstr "" -#: src/iacfleet.cpp:242 +#: src/iacfleet.cpp:245 msgid "Select IACFleet Directory" msgstr "" -#: src/iacfleet.cpp:264 +#: src/iacfleet.cpp:267 msgid "IACFleet File Directory" msgstr "" -#: src/iacfleet.cpp:284 +#: src/iacfleet.cpp:287 msgid "Files" msgstr "" -#: src/iacfleet.cpp:292 +#: src/iacfleet.cpp:295 msgid "Sort by" msgstr "" -#: src/iacfleet.cpp:296 +#: src/iacfleet.cpp:299 msgid "Name" msgstr "" -#: src/iacfleet.cpp:299 +#: src/iacfleet.cpp:302 msgid "File timestamp" msgstr "" -#: src/iacfleet.cpp:320 +#: src/iacfleet.cpp:323 msgid "Text" msgstr "" -#: src/iacfleet.cpp:335 +#: src/iacfleet.cpp:338 msgid "Raw" msgstr "" -#: src/iacfleet.cpp:351 +#: src/iacfleet.cpp:354 msgid "Downloads" msgstr "" -#: src/iacfleet.cpp:358 +#: src/iacfleet.cpp:361 msgid "Brazil" msgstr "" -#: src/iacfleet.cpp:363 +#: src/iacfleet.cpp:366 msgid "Final date" msgstr "" -#: src/iacfleet.cpp:371 +#: src/iacfleet.cpp:374 msgid "Hour" msgstr "" -#: src/iacfleet.cpp:375 +#: src/iacfleet.cpp:378 msgid "00" msgstr "" -#: src/iacfleet.cpp:375 +#: src/iacfleet.cpp:378 msgid "12" msgstr "" -#: src/iacfleet.cpp:383 src/iacfleet.cpp:391 src/iacfleet.cpp:430 +#: src/iacfleet.cpp:386 src/iacfleet.cpp:394 src/iacfleet.cpp:433 msgid "Download" msgstr "" -#: src/iacfleet.cpp:398 +#: src/iacfleet.cpp:401 msgid "dataset(s)" msgstr "" -#: src/iacfleet.cpp:404 +#: src/iacfleet.cpp:407 msgid "The data is available since 2006 and accesible manually from" msgstr "" -#: src/iacfleet.cpp:408 +#: src/iacfleet.cpp:411 msgid "http://www.mar.mil.br/dhn/chm/meteo/prev/iac/iac.htm" msgstr "" -#: src/iacfleet.cpp:416 +#: src/iacfleet.cpp:419 msgid "NOAA North Atlantic and Europe" msgstr "" -#: src/iacfleet.cpp:421 +#: src/iacfleet.cpp:424 msgid "Analysis" msgstr "" -#: src/iacfleet.cpp:424 +#: src/iacfleet.cpp:427 msgid "24h forecast" msgstr "" -#: src/iacfleet.cpp:440 +#: src/iacfleet.cpp:443 msgid "South Pacific (from Fiji Meteorological Service, Nadi)" msgstr "" -#: src/iacfleet.cpp:442 +#: src/iacfleet.cpp:445 msgid "" "The dataset is available from Saildocs\n" "Send an e-mail with the text\n" @@ -479,41 +479,41 @@ "text and open on the Files tab." msgstr "" -#: src/iacfleet.cpp:461 +#: src/iacfleet.cpp:464 msgid "Issue Date: " msgstr "" -#: src/iacfleet.cpp:478 +#: src/iacfleet.cpp:481 msgid "&Close" msgstr "" -#: src/iacfleet.cpp:628 +#: src/iacfleet.cpp:631 #, c-format msgid "Error opening: %s" msgstr "" -#: src/iacfleet.cpp:665 +#: src/iacfleet.cpp:668 msgid "Sorry, you can't download data from the future - they don't exist..." msgstr "" -#: src/iacfleet.cpp:670 +#: src/iacfleet.cpp:673 msgid "Sorry, the data is not available before September 1, 2006..." msgstr "" -#: src/iacfleet.cpp:689 src/iacfleet.cpp:778 +#: src/iacfleet.cpp:692 src/iacfleet.cpp:781 msgid "Downloading file" msgstr "" -#: src/iacfleet.cpp:690 src/iacfleet.cpp:779 +#: src/iacfleet.cpp:693 src/iacfleet.cpp:782 msgid "Reading Headers: " msgstr "" -#: src/iacfleet.cpp:704 src/iacfleet.cpp:792 +#: src/iacfleet.cpp:707 src/iacfleet.cpp:795 #, c-format msgid "Failed to save: %s " msgstr "" -#: src/iacfleet.cpp:710 src/iacfleet.cpp:798 +#: src/iacfleet.cpp:713 src/iacfleet.cpp:801 #, c-format msgid "" "Failed to download: %s \n" diff -Nru opencpn-plugin-iacfleet-0.9.0/README.md opencpn-plugin-iacfleet-0.10.0/README.md --- opencpn-plugin-iacfleet-0.9.0/README.md 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/README.md 2018-02-02 14:45:41.000000000 +0000 @@ -2,6 +2,8 @@ ======================================= [![Build Status](https://travis-ci.org/nohal/iacfleet_pi.svg?branch=master)](https://travis-ci.org/nohal/iacfleet_pi) +[![Build status](https://ci.appveyor.com/api/projects/status/405d7cygmln0urfj?svg=true)](https://ci.appveyor.com/project/nohal/iacfleet-pi) +[![Coverity scan](https://scan.coverity.com/projects/4964/badge.svg)](https://scan.coverity.com/projects/nohal-iacfleet_pi) Compiling ========= @@ -12,7 +14,7 @@ git clone git://github.com/nohal/iacfleet_pi.git ``` -###Build: +### Build: ``` mkdir iacfleet_pi/build cd iacfleet_pi/build @@ -29,7 +31,7 @@ Under windows, you must find the file "opencpn.lib" (Visual Studio) or "libopencpn.dll.a" (mingw) which is built in the build directory after compiling opencpn -###Build on Mac OS X: +### Build on Mac OS X: Tools: Can be installed either manually or from Homebrew (http://brew.sh) ``` #brew install git #If I remember well, it is already available on the system @@ -41,7 +43,7 @@ To target older OS X versions than the one you are running, you need the respective SDKs installed. The easiest way to achieve that is using https://github.com/devernay/xcodelegacy -####Building wxWidgets +#### Building wxWidgets (do not use wxmac from Homebrew, it is not compatible with OpenCPN) Get wxWidgets 3.0.x source from http://wxwidgets.org Configure, build and install @@ -52,13 +54,13 @@ sudo make install ``` -####Building the plugin +#### Building the plugin Before running cmake, you must set the deployment target to OS X 10.7 to be compatible with the libraries used by core OpenCPN ``` export MACOSX_DEPLOYMENT_TARGET=10.7 ``` -####Packaging on OS X +#### Packaging on OS X Get and install the Packages application from http://s.sudre.free.fr/Software/Packages/about.html ``` make create-pkg @@ -76,3 +78,4 @@ * ~~http://weather.noaa.gov/pub/data/raw/as/asxx21.egrr..txt~~ * ~~Automatic download from NOAA and BR~~ * Refine the GUI to save space +* Extend beyond IACFleet - at least to data from http://weather.gmdss.org/index.html diff -Nru opencpn-plugin-iacfleet-0.9.0/scan_script.sh opencpn-plugin-iacfleet-0.10.0/scan_script.sh --- opencpn-plugin-iacfleet-0.9.0/scan_script.sh 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/scan_script.sh 2018-02-02 14:45:41.000000000 +0000 @@ -0,0 +1,101 @@ +#!/bin/sh + +set -e + +# Environment check +echo -e "\033[33;1mNote: PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com\033[0m" +[ -z "$COVERITY_SCAN_PROJECT_NAME" ] && echo "ERROR: COVERITY_SCAN_PROJECT_NAME must be set" && exit 1 +#[ -z "$COVERITY_SCAN_NOTIFICATION_EMAIL" ] && echo "ERROR: COVERITY_SCAN_NOTIFICATION_EMAIL must be set" && exit 1 +[ -z "$COVERITY_SCAN_BRANCH_PATTERN" ] && echo "ERROR: COVERITY_SCAN_BRANCH_PATTERN must be set" && exit 1 +[ -z "$COVERITY_SCAN_BUILD_COMMAND" ] && echo "ERROR: COVERITY_SCAN_BUILD_COMMAND must be set" && exit 1 +[ -z "$COVERITY_SCAN_TOKEN" ] && echo "ERROR: COVERITY_SCAN_TOKEN must be set" && exit 1 + +PLATFORM=`uname` +TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz +TOOL_URL=https://scan.coverity.com/download/${PLATFORM} +TOOL_BASE=/tmp/coverity-scan-analysis +UPLOAD_URL="https://scan.coverity.com/builds" +SCAN_URL="https://scan.coverity.com" + +# Do not run on pull requests +if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then + echo -e "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m" + exit 0 +fi + +# Verify this branch should run +IS_COVERITY_SCAN_BRANCH=`ruby -e "puts '${TRAVIS_BRANCH}' =~ /\\A$COVERITY_SCAN_BRANCH_PATTERN\\z/ ? 1 : 0"` +if [ "$IS_COVERITY_SCAN_BRANCH" = "1" ]; then + echo -e "\033[33;1mCoverity Scan configured to run on branch ${TRAVIS_BRANCH}\033[0m" +else + echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m" + exit 1 +fi + +# Verify upload is permitted +AUTH_RES=`curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted` +if [ "$AUTH_RES" = "Access denied" ]; then + echo -e "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m" + exit 1 +else + AUTH=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['upload_permitted']"` + if [ "$AUTH" = "true" ]; then + echo -e "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m" + else + WHEN=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['next_upload_permitted_at']"` + echo -e "\033[33;1mCoverity Scan analysis NOT authorized until $WHEN.\033[0m" + exit 1 + fi +fi + +if [ ! -d $TOOL_BASE ]; then + # Download Coverity Scan Analysis Tool + if [ ! -e $TOOL_ARCHIVE ]; then + echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m" + wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN" + fi + + # Extract Coverity Scan Analysis Tool + echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" + mkdir -p $TOOL_BASE + pushd $TOOL_BASE + tar xzf $TOOL_ARCHIVE + popd +fi + +TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'` +export PATH=$TOOL_DIR/bin:$PATH + +# Build +echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m" +COV_BUILD_OPTIONS="" +#COV_BUILD_OPTIONS="--return-emit-failures 8 --parse-error-threshold 85" +RESULTS_DIR="cov-int" +eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}" +COVERITY_UNSUPPORTED=1 cov-build --dir $RESULTS_DIR $COV_BUILD_OPTIONS $COVERITY_SCAN_BUILD_COMMAND +cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt 2>&1 + +# Upload results +echo -e "\033[33;1mTarring Coverity Scan Analysis results...\033[0m" +RESULTS_ARCHIVE=analysis-results.tgz +tar czf $RESULTS_ARCHIVE $RESULTS_DIR +SHA=`git rev-parse --short HEAD` + +echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m" +response=$(curl \ + --silent --write-out "\n%{http_code}\n" \ + --form project=$COVERITY_SCAN_PROJECT_NAME \ + --form token=$COVERITY_SCAN_TOKEN \ + --form email=$COVERITY_SCAN_NOTIFICATION_EMAIL \ + --form file=@$RESULTS_ARCHIVE \ + --form version=$SHA \ + --form description="Travis CI build" \ + $UPLOAD_URL) +status_code=$(echo "$response" | sed -n '$p') +if [ "$status_code" != "201" ]; then + TEXT=$(echo "$response" | sed '$d') + echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m" + # changed the following + exit 1 +fi + diff -Nru opencpn-plugin-iacfleet-0.9.0/src/folder.xpm opencpn-plugin-iacfleet-0.10.0/src/folder.xpm --- opencpn-plugin-iacfleet-0.9.0/src/folder.xpm 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/folder.xpm 2018-02-02 14:45:41.000000000 +0000 @@ -1,103 +1,102 @@ /* XPM */ -static const char *folder[]={ -"16 16 84 2", -"Qt c None", -"#r c None", -"#o c #091d91", -"#q c #091e90", -"#p c #091e91", -"#l c #0b2599", -"#m c #0c2599", -"#i c #102da2", -"#d c #1337aa", -"#g c #1337ac", -"#a c #183fb5", -".8 c #1840b5", -".5 c #1b49bd", -".2 c #1c49bd", -".Z c #1e52c5", -".V c #1f52c5", -".P c #2259cb", -".S c #2259cc", -".x c #255fd1", -"#n c #274b97", -"#j c #274d9b", -"## c #277bfd", -"#h c #28509f", -"#b c #2852a3", -"#. c #287bfd", -".9 c #287cfd", -".6 c #2955a8", -".0 c #2a58ae", -".T c #2b5ab1", -".N c #2c5eb8", -".G c #2d61bd", -".y c #2e63c0", -".u c #2f66c6", -".p c #306acc", -".o c #306dd1", -".g c #306dd2", -".m c #306ed1", -".l c #316dd1", -".n c #316ed2", -".d c #3170d6", -".a c #3273db", -".# c #3274db", -".c c #3274dc", -".b c #3373db", -".3 c #3987fd", -".4 c #3988fd", -".Y c #4f97fd", -".X c #4f98fd", -"#k c #4faefd", -".W c #5098fd", -".k c #5f7db1", -"#c c #62b7fd", -".R c #6ba9fd", -".Q c #6baafd", -".7 c #6dbefd", -".1 c #7ac4fd", -".J c #86b9ec", -".U c #88cbfd", -".M c #89bdfd", -".L c #89befd", -".K c #8cbdfd", -".O c #99d3fd", -".D c #9ec6ee", -".H c #a9dafd", -".I c #a9dbfd", -".F c #acd1fd", -"#f c #aeaec6", -".B c #b9e1fd", -".z c #b9e2fd", -".C c #bce1fd", -".A c #bce2fd", -".v c #cbe8fd", -".w c #cbe9fd", -".r c #daeefd", -".t c #daf0fd", -".s c #dbeefd", -".q c #dbf0fd", -".h c #e8f5fd", -".i c #e8f6fd", -".j c #e9f5fd", -".f c #f5f9fd", -".e c #f5fbfd", -".E c #fcfcfd", -"#e c #fdfdfd", -"QtQt.#.a.b.c.#.#QtQtQtQtQtQtQtQt", -"Qt.d.e.f.e.f.f.f.dQtQtQtQtQtQtQt", -".g.h.h.h.i.h.j.h.k.l.m.n.m.o.lQt", -".p.q.q.q.q.q.r.q.s.s.r.q.s.q.t.p", -".u.v.v.v.v.v.v.v.w.x.x.x.x.x.x.x", -".y.z.z.A.z.A.B.C.x.D.E.E.E.E.F.x", -".G.H.I.x.x.x.x.x.J.E.K.L.L.M.M.x", -".N.O.P.Q.E.E.E.E.E.R.Q.R.R.R.R.S", -".T.U.V.W.X.X.Y.W.X.X.X.X.W.X.Y.Z", -".0.1.2.3.4.4.3.4.3.3.4.4.4.3.4.5", -".6.7.8.9.9#..9#.#.#.###.###.#.#a", -"#b#c#d#e#e#e#e#e#e#e#e#e#e#e#f#g", -"#h#c#i#e#e#e#e#e#e#e#e#e#e#e#f#i", -"#j#k#l#f#f#f#f#f#f#f#f#f#f#f#f#m", -"Qt#n#o#o#o#p#q#p#q#o#q#q#p#p#oQt", -"#r#r#r#r#r#r#r#r#r#r#r#r#r#r#r#r"}; +static const char *folder[] = {"16 16 84 2", + "Qt c None", + "#r c None", + "#o c #091d91", + "#q c #091e90", + "#p c #091e91", + "#l c #0b2599", + "#m c #0c2599", + "#i c #102da2", + "#d c #1337aa", + "#g c #1337ac", + "#a c #183fb5", + ".8 c #1840b5", + ".5 c #1b49bd", + ".2 c #1c49bd", + ".Z c #1e52c5", + ".V c #1f52c5", + ".P c #2259cb", + ".S c #2259cc", + ".x c #255fd1", + "#n c #274b97", + "#j c #274d9b", + "## c #277bfd", + "#h c #28509f", + "#b c #2852a3", + "#. c #287bfd", + ".9 c #287cfd", + ".6 c #2955a8", + ".0 c #2a58ae", + ".T c #2b5ab1", + ".N c #2c5eb8", + ".G c #2d61bd", + ".y c #2e63c0", + ".u c #2f66c6", + ".p c #306acc", + ".o c #306dd1", + ".g c #306dd2", + ".m c #306ed1", + ".l c #316dd1", + ".n c #316ed2", + ".d c #3170d6", + ".a c #3273db", + ".# c #3274db", + ".c c #3274dc", + ".b c #3373db", + ".3 c #3987fd", + ".4 c #3988fd", + ".Y c #4f97fd", + ".X c #4f98fd", + "#k c #4faefd", + ".W c #5098fd", + ".k c #5f7db1", + "#c c #62b7fd", + ".R c #6ba9fd", + ".Q c #6baafd", + ".7 c #6dbefd", + ".1 c #7ac4fd", + ".J c #86b9ec", + ".U c #88cbfd", + ".M c #89bdfd", + ".L c #89befd", + ".K c #8cbdfd", + ".O c #99d3fd", + ".D c #9ec6ee", + ".H c #a9dafd", + ".I c #a9dbfd", + ".F c #acd1fd", + "#f c #aeaec6", + ".B c #b9e1fd", + ".z c #b9e2fd", + ".C c #bce1fd", + ".A c #bce2fd", + ".v c #cbe8fd", + ".w c #cbe9fd", + ".r c #daeefd", + ".t c #daf0fd", + ".s c #dbeefd", + ".q c #dbf0fd", + ".h c #e8f5fd", + ".i c #e8f6fd", + ".j c #e9f5fd", + ".f c #f5f9fd", + ".e c #f5fbfd", + ".E c #fcfcfd", + "#e c #fdfdfd", + "QtQt.#.a.b.c.#.#QtQtQtQtQtQtQtQt", + "Qt.d.e.f.e.f.f.f.dQtQtQtQtQtQtQt", + ".g.h.h.h.i.h.j.h.k.l.m.n.m.o.lQt", + ".p.q.q.q.q.q.r.q.s.s.r.q.s.q.t.p", + ".u.v.v.v.v.v.v.v.w.x.x.x.x.x.x.x", + ".y.z.z.A.z.A.B.C.x.D.E.E.E.E.F.x", + ".G.H.I.x.x.x.x.x.J.E.K.L.L.M.M.x", + ".N.O.P.Q.E.E.E.E.E.R.Q.R.R.R.R.S", + ".T.U.V.W.X.X.Y.W.X.X.X.X.W.X.Y.Z", + ".0.1.2.3.4.4.3.4.3.3.4.4.4.3.4.5", + ".6.7.8.9.9#..9#.#.#.###.###.#.#a", + "#b#c#d#e#e#e#e#e#e#e#e#e#e#e#f#g", + "#h#c#i#e#e#e#e#e#e#e#e#e#e#e#f#i", + "#j#k#l#f#f#f#f#f#f#f#f#f#f#f#f#m", + "Qt#n#o#o#o#p#q#p#q#o#q#q#p#p#oQt", + "#r#r#r#r#r#r#r#r#r#r#r#r#r#r#r#r"}; diff -Nru opencpn-plugin-iacfleet-0.9.0/src/iacfile.cpp opencpn-plugin-iacfleet-0.10.0/src/iacfile.cpp --- opencpn-plugin-iacfleet-0.9.0/src/iacfile.cpp 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/iacfile.cpp 2018-02-02 14:45:41.000000000 +0000 @@ -27,12 +27,12 @@ #include "wx/wxprec.h" -#ifndef WX_PRECOMP +#ifndef WX_PRECOMP #include "wx/wx.h" -#endif //precompiled headers +#endif // precompiled headers #include -#include // this is a magic incantation which must be done! +#include // this is a magic incantation which must be done! #include "iacfile.h" @@ -46,12 +46,10 @@ // Is the given point in the vp ?? // because of a the vp-implementation we need // to check the latitude three times! (+-360) -static bool PointInLLBox( PlugIn_ViewPort *vp, double x, double y ) -{ - if ( ((x >= (vp->lon_min) && x <= (vp->lon_max)) - || ((x+360.) >= (vp->lon_min) && (x+360.) <= (vp->lon_max)) - || ((x-360.) >= (vp->lon_min) && (x-360.) <= (vp->lon_max)) - ) && (y >= (vp->lat_min) && y <= (vp->lat_max)) ) +static bool PointInLLBox(PlugIn_ViewPort *vp, double x, double y) { + if (((x >= (vp->lon_min) && x <= (vp->lon_max)) || ((x + 360.) >= (vp->lon_min) && (x + 360.) <= (vp->lon_max)) || + ((x - 360.) >= (vp->lon_min) && (x - 360.) <= (vp->lon_max))) && + (y >= (vp->lat_min) && y <= (vp->lat_max))) return TRUE; return FALSE; } @@ -59,23 +57,16 @@ //--------------------------------------------- // IACFile implementation //--------------------------------------------- -IACFile::IACFile( void ) -{ - Invalidate(); -} +IACFile::IACFile(void) { Invalidate(); } -IACFile::IACFile( wxInputStream &stream ) -{ +IACFile::IACFile(wxInputStream &stream) { Invalidate(); m_isok = Read(stream); } -IACFile::~IACFile( void ) -{ -} +IACFile::~IACFile(void) {} -void IACFile::Invalidate( void ) -{ +void IACFile::Invalidate(void) { m_tokens.Clear(); m_tokensI = 0; m_isok = false; @@ -95,51 +86,40 @@ m_newlineTokens.clear(); } -wxFileInputStream* IACFile::GetStream( wxString &filename ) -{ +wxFileInputStream *IACFile::GetStream(wxString &filename) { wxFileName file(filename); - if( file.FileExists() && (file.GetSize() < IACMaxSize) ) - { + if (file.FileExists() && (file.GetSize() < IACMaxSize)) { return new wxFileInputStream(filename); - } - else - { + } else { return NULL; } } -bool IACFile::Read( wxInputStream &stream ) -{ - bool isok = false; //true if minimum one token was read from file +bool IACFile::Read(wxInputStream &stream) { + bool isok = false; // true if minimum one token was read from file Invalidate(); wxString token; m_tokensI = 0; - if( stream.IsOk() ) - { - for(;;) - { + if (stream.IsOk()) { + for (;;) { token = ReadToken(stream); - if( !token.IsEmpty() ) - { + if (!token.IsEmpty()) { m_tokens.Add(token); m_tokensI++; isok = true; - } - else - { + } else { break; } } } m_tokensI = 0; -// for (std::vector::iterator it = m_newlineTokens.begin(); it != m_newlineTokens.end(); ++it) -// { -// wxMessageBox( wxString::Format( _T("ID: %i :"), *it ) + m_tokens[*it] ); -// } - - if( isok ) - { + // for (std::vector::iterator it = m_newlineTokens.begin(); it != m_newlineTokens.end(); ++it) + // { + // wxMessageBox( wxString::Format( _T("ID: %i :"), *it ) + m_tokens[*it] ); + // } + + if (isok) { // decode tokens if some were found isok = Decode(); } @@ -147,75 +127,62 @@ return isok; } -wxString IACFile::ToString( void ) -{ +wxString IACFile::ToString(void) { wxString t; size_t i; t.Append(_T("IAC Fleet Code issued at ") + m_issueDate + _T("\n")); // Pressure Systems t.Append(_("\n\nPressure systems:")); - t.Append(wxT( "\n=================")); - for( i=0; i 1) && (diff < 8) ) - { + } else if (m_positionsType == POS_OCTANTS && (diff > 1) && (diff < 8)) { morepos = false; - } - else if( section == SECTION_FRONTAL && token.Matches(_T("66???")) - && ( m_positionsType == 88 || m_newlineTokens.size() < 10 //In case the file seems formatted with new lines, we take advantage of it and say that new system must start on new line - || std::find(m_newlineTokens.begin(), m_newlineTokens.end(), m_tokensI - 1 ) != m_newlineTokens.end() ) ) - { + } else if (section == SECTION_FRONTAL && token.Matches(_T("66???")) && + (m_positionsType == 88 || + m_newlineTokens.size() < 10 // In case the file seems formatted with new lines, we take advantage of it and say + // that new system must start on new line + || std::find(m_newlineTokens.begin(), m_newlineTokens.end(), m_tokensI - 1) != m_newlineTokens.end())) { morepos = false; - } - else if( section == SECTION_PRESSURE && token.StartsWith(_T("8")) - && ( m_positionsType == 88 || m_newlineTokens.size() < 10 //In case the file seems formatted with new lines, we take advantage of it and say that new system must start on new line - || std::find(m_newlineTokens.begin(), m_newlineTokens.end(), m_tokensI - 1 ) != m_newlineTokens.end() ) ) - { - morepos = false; - } - else if( token.Matches( _T("999??") ) ) - { + } else if (section == SECTION_PRESSURE && token.StartsWith(_T("8")) && + (m_positionsType == 88 || + m_newlineTokens.size() < 10 // In case the file seems formatted with new lines, we take advantage of it and say + // that new system must start on new line + || std::find(m_newlineTokens.begin(), m_newlineTokens.end(), m_tokensI - 1) != m_newlineTokens.end())) { morepos = false; - } - else if( section == SECTION_ISOBAR && ( token.Matches(_T("440??")) || token.Matches(_T("449??")) || token.Matches(_T("448??")) ) ) - { + } else if (token.Matches(_T("999??"))) { morepos = false; - } - else if( token == _T("19191")) - { + } else if (section == SECTION_ISOBAR && + (token.Matches(_T("440??")) || token.Matches(_T("449??")) || token.Matches(_T("448??")))) { morepos = false; - } - -/* - // lets be even more strict and limit positions to - // SW-Pacific - if( !((oct == 6) || (oct == 7))) - { + } else if (token == _T("19191")) { morepos = false; } - GeoPoint pos(token); // decode position - // Position must be in the area bounded by 0S..35S and 120W/150E - if( (pos.y < -35.0) || - (pos.y > 0.0) || - ((pos.x > -120.0) && (pos.x < 150)) - ) - { - morepos = false; - } -*/ - if( !token.IsEmpty() && (firsttime || morepos ) ) - { - // ignore double entries following eachother - if( token != lasttoken ) - { - GeoPoint pos( token, m_positionsType ); - sys.m_positions.Add(pos); - if( pos.x >= 0.0) + /* + // lets be even more strict and limit positions to + // SW-Pacific + if( !((oct == 6) || (oct == 7))) { - if( pos.x < m_minlone ) - m_minlone = pos.x; - if( pos.x > m_maxlone ) - m_maxlone = pos.x; + morepos = false; } - else + + GeoPoint pos(token); // decode position + // Position must be in the area bounded by 0S..35S and 120W/150E + if( (pos.y < -35.0) || + (pos.y > 0.0) || + ((pos.x > -120.0) && (pos.x < 150)) + ) { - if( pos.x < m_minlonw ) - m_minlonw = pos.x; - if( pos.x > m_maxlonw ) - m_maxlonw = pos.x; + morepos = false; } - if( pos.y < m_minlat ) - m_minlat = pos.y; - if( pos.y > m_maxlat ) - m_maxlat = pos.y; -// if( pos.x < 0.1 && pos.x > -0.1 ) -// wxMessageBox( token ); - } - else - { + */ + if (!token.IsEmpty() && (firsttime || morepos)) { + // ignore double entries following eachother + if (token != lasttoken) { + GeoPoint pos(token, m_positionsType); + sys.m_positions.Add(pos); + if (pos.x >= 0.0) { + if (pos.x < m_minlone) m_minlone = pos.x; + if (pos.x > m_maxlone) m_maxlone = pos.x; + } else { + if (pos.x < m_minlonw) m_minlonw = pos.x; + if (pos.x > m_maxlonw) m_maxlonw = pos.x; + } + if (pos.y < m_minlat) m_minlat = pos.y; + if (pos.y > m_maxlat) m_maxlat = pos.y; + // if( pos.x < 0.1 && pos.x > -0.1 ) + // wxMessageBox( token ); + } else { // we got two identical position entries // meaning "no more" // stop parsing positions, but read one // more token to stay in sync - if( m_positionsType == 88 ) - token = tokenFind(); - //break; + if (m_positionsType == 88) token = tokenFind(); + // break; } - } - else - { + } else { break; } - if( firsttime ) - { + if (firsttime) { firsttime = false; } } PushbackToken(); - if( token.IsEmpty() ) - { + if (token.IsEmpty()) { return false; - } - else - { + } else { return true; } } -bool IACFile::ParseMovement( IACSystem &sys ) -{ +bool IACFile::ParseMovement(IACSystem &sys) { wxString token; token = tokenFind(); - if( !token.IsEmpty() ) - { + if (!token.IsEmpty()) { // if invalid movement, ignore, push back int dir = 10 * TokenNumber(token, 1, 2); - if( dir < 361 ) - { - - sys.m_movement = TokenNumber(token, 0, 1); + if (dir < 361) { + sys.m_movement = TokenNumber(token, 0, 1); sys.m_direction = dir; - sys.m_speed = TokenNumber(token, 3, 2); + sys.m_speed = TokenNumber(token, 3, 2); return true; - } - else - { + } else { // invalif movement, push back PushbackToken(); return false; } - } - else - { + } else { return false; } } -bool IACFile::ParseSections( void ) -{ +bool IACFile::ParseSections(void) { wxString token; - do - { + do { token = tokenFind(_T("999??"), true); - if( !token.IsEmpty() ) - { + if (!token.IsEmpty()) { //?? 00=>Pressure Systems // 11=>Frontal Systems // 22=>Isobars // 55=>Tropical Section int section = TokenNumber(token, 3, 2); - switch(section) - { - case SECTION_PRESSURE: - ParsePressureSection(); - break; - case SECTION_FRONTAL: - ParseFrontalSection(); - break; - case SECTION_ISOBAR: - ParseIsobarSection(); - break; - case SECTION_TROPICAL: - ParseTropicalSection(); - break; - default: - break; + switch (section) { + case SECTION_PRESSURE: + ParsePressureSection(); + break; + case SECTION_FRONTAL: + ParseFrontalSection(); + break; + case SECTION_ISOBAR: + ParseIsobarSection(); + break; + case SECTION_TROPICAL: + ParseTropicalSection(); + break; + default: + break; } } - } - while( !token.IsEmpty() ); + } while (!token.IsEmpty()); return true; } -bool IACFile::ParsePressureSection(void) -{ +bool IACFile::ParsePressureSection(void) { wxString token; - for(;;) - { + for (;;) { token = tokenFind(_T("8????")); - if( !token.IsEmpty( ) ) - { // parse pressure system token -// if( std::find(m_newlineTokens.begin(), m_newlineTokens.end(), m_tokensI) == m_newlineTokens.end() ) -// wxMessageBox(_T("FP: ") + token); + if (!token.IsEmpty()) { // parse pressure system token + // if( std::find(m_newlineTokens.begin(), m_newlineTokens.end(), m_tokensI) == m_newlineTokens.end() ) + // wxMessageBox(_T("FP: ") + token); IACPressureSystem sys; sys.m_type = TokenNumber(token, 1, 1); sys.m_char = TokenNumber(token, 2, 1); - sys.m_val = TokenNumber(token, 3, 2); - sys.m_int = -1; + sys.m_val = TokenNumber(token, 3, 2); + sys.m_int = -1; // guess pressure offset - if( sys.m_type == 1 && sys.m_val > 30 ) - { + if (sys.m_type == 1 && sys.m_val > 30) { sys.m_val += 900; - } - else if( sys.m_type == 5 && sys.m_val < 70 ) - { + } else if (sys.m_type == 5 && sys.m_val < 70) { sys.m_val += 1000; - } - else if( sys.m_val > 50 ) - { + } else if (sys.m_val > 50) { sys.m_val += 900; - } - else - { + } else { sys.m_val += 1000; } ParsePositions(sys, SECTION_PRESSURE); - if( !m_tokens[m_tokensI].StartsWith(_T("8")) ) - ParseMovement(sys); + if (!m_tokens[m_tokensI].StartsWith(_T("8"))) ParseMovement(sys); m_pressure.Add(sys); - } - else - { + } else { PushbackToken(); break; } @@ -464,28 +375,22 @@ return true; } -bool IACFile::ParseFrontalSection( void ) -{ +bool IACFile::ParseFrontalSection(void) { wxString token; - for(;;) - { + for (;;) { token = tokenFind(_T("66???")); - if( !token.IsEmpty() ) - { + if (!token.IsEmpty()) { // parse pressure system token IACFrontalSystem sys; sys.m_type = TokenNumber(token, 2, 1); - sys.m_val = -1; - sys.m_int = TokenNumber(token, 3, 1); + sys.m_val = -1; + sys.m_int = TokenNumber(token, 3, 1); sys.m_char = TokenNumber(token, 4, 1); - ParsePositions(sys, SECTION_FRONTAL); ParseMovement(sys); m_frontal.Add(sys); - } - else - { + } else { // no more frontal systems. PushbackToken(); break; @@ -494,27 +399,21 @@ return true; } -bool IACFile::ParseIsobarSection( void ) -{ +bool IACFile::ParseIsobarSection(void) { wxString token; - for(;;) - { + for (;;) { token = tokenFind(_T("44???")); - if( !token.IsEmpty() ) - { + if (!token.IsEmpty()) { IACIsobarSystem sys; sys.m_val = TokenNumber(token, 2, 3); - if( sys.m_val < 500 ) - { + if (sys.m_val < 500) { sys.m_val += 1000; } // Position ParsePositions(sys, SECTION_ISOBAR); m_isobars.Add(sys); - } - else - { + } else { // no more frontal systems. PushbackToken(); break; @@ -523,47 +422,36 @@ return true; } -bool IACFile::ParseTropicalSection( void ) -{ +bool IACFile::ParseTropicalSection(void) { wxString token; - for(;;) - { + for (;;) { token = tokenFind(_T("55???")); - if( !token.IsEmpty() ) - { + if (!token.IsEmpty()) { // parse pressure system token IACTropicalSystem sys; sys.m_type = TokenNumber(token, 2, 1); - sys.m_int = TokenNumber(token, 3, 1); + sys.m_int = TokenNumber(token, 3, 1); sys.m_char = TokenNumber(token, 4, 1); // tropical system token MAY be followed by 555PP pressure token // in this case it is a tropical LOW or cyclone token = tokenFind(_T("555??")); - if( token.IsEmpty() ) - { + if (token.IsEmpty()) { // no, push back token - it is a position PushbackToken(); - } - else - { + } else { sys.m_val = TokenNumber(token, 3, 2); // guess pressure offset - if( sys.m_val > 50 ) - { + if (sys.m_val > 50) { sys.m_val += 900; - } - else - { + } else { sys.m_val += 1000; } } ParsePositions(sys, SECTION_TROPICAL); ParseMovement(sys); m_tropical.Add(sys); - } - else - { + } else { PushbackToken(); break; } @@ -571,33 +459,25 @@ return true; } -int IACFile::TokenNumber( wxString &token, size_t start, size_t end ) -{ +int IACFile::TokenNumber(wxString &token, size_t start, size_t end) { unsigned long ul; - if( token.Mid(start,end).ToULong(&ul) ) - { - //success + if (token.Mid(start, end).ToULong(&ul)) { + // success return ul; - } - else - { - //failure + } else { + // failure return -1; } } -wxString IACFile::tokenFind( const wxChar* match, bool skip ) -{ - while( m_tokensI < m_tokens.GetCount() ) - { +wxString IACFile::tokenFind(const wxChar *match, bool skip) { + while (m_tokensI < m_tokens.GetCount()) { wxString token = m_tokens[m_tokensI++]; - if( token.Matches(match) ) - { + if (token.Matches(match)) { // found return token; } - if( !skip ) - { + if (!skip) { break; } } @@ -605,16 +485,13 @@ return wxEmptyString; } -void IACFile::PushbackToken( void ) -{ - if( m_tokensI > 0 ) - { +void IACFile::PushbackToken(void) { + if (m_tokensI > 0) { m_tokensI--; } } -wxString IACFile::ReadToken( wxInputStream &file ) -{ +wxString IACFile::ReadToken(wxInputStream &file) { // 0 = read chars until digit // 1 = read digits until no digit // 2 = token found @@ -622,52 +499,42 @@ int mode = 0; - while( file.IsOk() && mode != 2 ) - { + while (file.IsOk() && mode != 2) { int c = file.GetC(); - if( c != wxEOF) - { - if( c == '\n' && m_tokensI > 0) - { - m_newlineTokens.push_back( m_tokensI + 1 ); - } - m_RawData.Append( (char)c ); - switch( mode ) - { - case 0: - if( isdigit(c) ) - { - token.Append( (char)c ); - mode = 1; - } - break; - case 1: - if( isdigit(c) || c == '/' ) - { - token.Append( (char)c ); - } - else - { - if( token.Len() == 5 ) - { - // token found!! - mode = 2; + if (c != wxEOF) { + if (c == '\n' && m_tokensI > 0) { + m_newlineTokens.push_back(m_tokensI + 1); + } + m_RawData.Append((char)c); + switch (mode) { + case 0: + if (isdigit(c)) { + token.Append((char)c); + mode = 1; } - else - { - token.Empty(); + break; + case 1: + if (isdigit(c) || c == '/') { + token.Append((char)c); + } else { + if (token.Len() == 5) { + // token found!! + mode = 2; + } else { + token.Empty(); + } } - } - break; - case 2: - mode = 0; - break; - }// case + break; + /* this is dead code + case 2: + mode = 0; + break; + */ + } // case } - }// while - if( mode != 2 ) - { + } // while + if (mode != 2) { token.Empty(); } @@ -676,26 +543,23 @@ // draw the fleet code data // returns true if anything was drawn -bool IACFile::Draw( wxDC *dc, PlugIn_ViewPort *vp ) -{ +bool IACFile::Draw(wxDC *dc, PlugIn_ViewPort *vp) { bool retval = false; // draw only if file was successfully read and decoded - if( IsOk() ) - { + if (IsOk()) { wxColor colour; - GetGlobalColor ( _T ( "SNDG1" ), &colour ); + GetGlobalColor(_T ( "SNDG1" ), &colour); wxPoint p1, p2, p3, p4; double minlon, maxlon; - if( m_minlone < 999 ) + if (m_minlone < 999) minlon = m_minlone; else minlon = m_minlonw; - if( m_maxlonw > -999 ) + if (m_maxlonw > -999) maxlon = m_maxlonw; else maxlon = m_maxlone; - if( -179.0 < m_minlonw && m_minlonw < 0 && 179.0 > m_maxlone && m_maxlone > 0 ) - { + if (-179.0 < m_minlonw && m_minlonw < 0 && 179.0 > m_maxlone && m_maxlone > 0) { minlon = m_minlonw; maxlon = m_maxlone; } @@ -704,25 +568,20 @@ GetCanvasPixLL(vp, &p2, m_maxlat, minlon); GetCanvasPixLL(vp, &p3, m_maxlat, maxlon); GetCanvasPixLL(vp, &p4, m_minlat, maxlon); - if( dc ) - { - if( p3.x > 0 && p1.x < vp->pix_width ) - { - dc->SetPen( wxPen( colour, ISOBAR_WIDTH ) ); - wxPoint points[] = { p1, p2, p3, p4, p1 }; - dc->DrawLines( 5, points ); + if (dc) { + if (p3.x > 0 && p1.x < vp->pix_width) { + dc->SetPen(wxPen(colour, ISOBAR_WIDTH)); + wxPoint points[] = {p1, p2, p3, p4, p1}; + dc->DrawLines(5, points); } - } - else - { - wxFont font_numbers( NUMBERS_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); + } else { + wxFont font_numbers(NUMBERS_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); m_TexFontNumbers.Build(font_numbers); - wxFont font_systems( SYSTEMS_FONT_SIZE, wxFONTFAMILY_ROMAN, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD ); + wxFont font_systems(SYSTEMS_FONT_SIZE, wxFONTFAMILY_ROMAN, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD); m_TexFontSystems.Build(font_systems); - if( p3.x > 0 && p1.x < vp->pix_width ) - { - glColor3ub(colour.Red() , colour.Green(), colour.Blue()); + if (p3.x > 0 && p1.x < vp->pix_width) { + glColor3ub(colour.Red(), colour.Green(), colour.Blue()); glBegin(GL_LINE_LOOP); glVertex2i(p1.x, p1.y); glVertex2i(p2.x, p2.y); @@ -737,47 +596,39 @@ // I love this kind of crazy code - it is like in the good // old days of programming where everything was allowed. srand(77); - retval |= DrawSystems( dc, vp, (IACSystems &)m_pressure ); - retval |= DrawSystems( dc, vp, (IACSystems &)m_frontal ); - retval |= DrawSystems( dc, vp, (IACSystems &)m_isobars ); - retval |= DrawSystems( dc, vp, (IACSystems &)m_tropical ); + retval |= DrawSystems(dc, vp, (IACSystems &)m_pressure); + retval |= DrawSystems(dc, vp, (IACSystems &)m_frontal); + retval |= DrawSystems(dc, vp, (IACSystems &)m_isobars); + retval |= DrawSystems(dc, vp, (IACSystems &)m_tropical); } return retval; } -bool IACFile::DrawSystems( wxDC *dc, PlugIn_ViewPort *vp, IACSystems &iacsystem ) -{ +bool IACFile::DrawSystems(wxDC *dc, PlugIn_ViewPort *vp, IACSystems &iacsystem) { bool retval = false; // loop over all systems - for( size_t Index = 0; Index < iacsystem.GetCount(); Index++ ) - { - retval |= iacsystem[Index].Draw( dc, vp, m_TexFontNumbers, m_TexFontSystems ); + for (size_t Index = 0; Index < iacsystem.GetCount(); Index++) { + retval |= iacsystem[Index].Draw(dc, vp, m_TexFontNumbers, m_TexFontSystems); } return retval; } -IACSystem * IACFile::FindSystem( GeoPoint &pos, double deviation ) -{ +IACSystem *IACFile::FindSystem(GeoPoint &pos, double deviation) { IACSystem *pIACSystem = NULL; - pIACSystem = FindSystem( (IACSystems&)m_pressure, pos, deviation ); - if( NULL == pIACSystem ) - { - pIACSystem = FindSystem( (IACSystems&)m_frontal, pos, deviation ); - if( NULL == pIACSystem ) - { - pIACSystem = FindSystem( (IACSystems&)m_tropical, pos, deviation) ; + pIACSystem = FindSystem((IACSystems &)m_pressure, pos, deviation); + if (NULL == pIACSystem) { + pIACSystem = FindSystem((IACSystems &)m_frontal, pos, deviation); + if (NULL == pIACSystem) { + pIACSystem = FindSystem((IACSystems &)m_tropical, pos, deviation); } } return pIACSystem; } -IACSystem * IACFile::FindSystem( IACSystems &systems, GeoPoint &pos, double deviation ) -{ - IACSystem * pSystem = NULL; - for( size_t i = systems.GetCount(); i != 0; i-- ) - { - if( systems[i - 1].FindAtPos(pos, deviation) ) - { +IACSystem *IACFile::FindSystem(IACSystems &systems, GeoPoint &pos, double deviation) { + IACSystem *pSystem = NULL; + for (size_t i = systems.GetCount(); i != 0; i--) { + if (systems[i - 1].FindAtPos(pos, deviation)) { // found system pSystem = &(systems[i - 1]); } @@ -785,273 +636,219 @@ return pSystem; } - //--------------------------- // implementatin of GeoPoint //--------------------------- const double GeoPoint::INVALID_KOORD = 9999.9; - // initialize from IAC lat/lon token -void GeoPoint::Set( wxString &token, int coordsys ) -{ - if( token.Len() == 5 ) - { - if( coordsys == POS_OCTANTS ) - { +void GeoPoint::Set(wxString &token, int coordsys) { + if (token.Len() == 5) { + if (coordsys == POS_OCTANTS) { int oct = IACFile::TokenNumber(token, 0, 1); int lat = IACFile::TokenNumber(token, 1, 2); int lon = IACFile::TokenNumber(token, 3, 2); - int ns = (oct > 3) ? -1 : +1; // sign for south(-1) or north(+1) - lat *= ns; // lat is now in degrees + int ns = (oct > 3) ? -1 : +1; // sign for south(-1) or north(+1) + lat *= ns; // lat is now in degrees // eliminate north/south - if( oct > 4 ) - { + if (oct > 4) { oct -= 5; } - switch( oct ) - { - case 0: // West 0..90 - lon = - lon; - break; - case 1: // West 90..180 - if ( lon < 90 ) - { - lon = - (100 + lon); - } - else - { - lon = - lon; - } - break; - case 2: // East 90 .. 180 - if( lon < 90 ) - { - lon = 100 + lon; - } - break; - case 3: // East 0..90 - break; + switch (oct) { + case 0: // West 0..90 + lon = -lon; + break; + case 1: // West 90..180 + if (lon < 90) { + lon = -(100 + lon); + } else { + lon = -lon; + } + break; + case 2: // East 90 .. 180 + if (lon < 90) { + lon = 100 + lon; + } + break; + case 3: // East 0..90 + break; } - Set( double(lon), double(lat) ); - } - else if( coordsys == POS_NH_HALF_DEG ) - { + Set(double(lon), double(lat)); + } else if (coordsys == POS_NH_HALF_DEG) { int k = IACFile::TokenNumber(token, 4, 1); double lat = IACFile::TokenNumber(token, 0, 2); double lon = IACFile::TokenNumber(token, 2, 2); - switch( k ) - { - //East longitudes 0-99, west longitudes 100-180 - case 0: //As sent - break; - case 1: //Add 1/2 deg to lat - lat += 0.5; - break; - case 2: //Add 1/2 deg to lon - lon += 0.5; - break; - case 3: //Add 1/2 deg to lat and lon - lat += 0.5; - lon += 0.5; - break; - case 4: //Whole degrees - break; - case 5: //As sent - lon = -lon; - break; - //East longitudes 10-180, west longitudes 0-99 - case 6: //Add 1/2 deg to lat - lat += 0.5; - lon = -lon; - break; - case 7: //Add 1/2 deg to lon - lon += 0.5; - lon = -lon; - break; - case 8: //Add 1/2 deg to lat and lon - lat += 0.5; - lon += 0.5; - lon = -lon; - break; - case 9: //Whole degrees - lon = -lon; - break; + switch (k) { + // East longitudes 0-99, west longitudes 100-180 + case 0: // As sent + break; + case 1: // Add 1/2 deg to lat + lat += 0.5; + break; + case 2: // Add 1/2 deg to lon + lon += 0.5; + break; + case 3: // Add 1/2 deg to lat and lon + lat += 0.5; + lon += 0.5; + break; + case 4: // Whole degrees + break; + case 5: // As sent + lon = -lon; + break; + // East longitudes 10-180, west longitudes 0-99 + case 6: // Add 1/2 deg to lat + lat += 0.5; + lon = -lon; + break; + case 7: // Add 1/2 deg to lon + lon += 0.5; + lon = -lon; + break; + case 8: // Add 1/2 deg to lat and lon + lat += 0.5; + lon += 0.5; + lon = -lon; + break; + case 9: // Whole degrees + lon = -lon; + break; } - Set( lon, lat ); - } - else + Set(lon, lat); + } else Set(); - } - else - { - Set(); // invalid token. set to invalid koordinates + } else { + Set(); // invalid token. set to invalid koordinates } } -wxString GeoPoint::ToString( void ) -{ +wxString GeoPoint::ToString(void) { wxString t; // latitude unsigned int latdeg = floor(fabs(y)); - wxChar lats = (y < 0) ? 'S' : 'N'; + wxChar lats = (y < 0) ? 'S' : 'N'; unsigned int londeg = floor(fabs(x)); - wxChar lons = (x < 0) ? 'W' : 'E'; + wxChar lons = (x < 0) ? 'W' : 'E'; t.Printf(wxT("%02u%c %03u%c"), latdeg, lats, londeg, lons); return t; } -bool GeoPoint::MatchPosition( GeoPoint &refPos, double deviation ) -{ - if( (fabs(x - refPos.x) <= deviation) && (fabs(y - refPos.y) <= deviation) ) - { +bool GeoPoint::MatchPosition(GeoPoint &refPos, double deviation) { + if ((fabs(x - refPos.x) <= deviation) && (fabs(y - refPos.y) <= deviation)) { return true; - } - else - { + } else { return false; } } - //----------------------------- // implementation of IACSystem //----------------------------- -IACSystem::IACSystem( void ): - m_positions(), - m_type(-1), - m_char(-1), - m_val(-1), - m_int(-1), - m_movement(99), - m_direction(99), - m_speed(99), - m_isoLineWidth(2) -{ +IACSystem::IACSystem(void) + : m_positions(), m_type(-1), m_char(-1), m_val(-1), m_int(-1), m_movement(99), m_direction(99), m_speed(99), m_isoLineWidth(2) { m_isoLineColor = *wxBLACK; } -bool IACSystem::Draw( wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont ) -{ - bool hasDrawn=false; - if( dc ) - { - if( m_positions.GetCount() == 1 ) - { +IACSystem::~IACSystem() {} + +bool IACSystem::Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont) { + bool hasDrawn = false; + if (dc) { + if (m_positions.GetCount() == 1) { GeoPoint &Pos = m_positions[0]; - if( PointInLLBox(vp, Pos.x, Pos.y) ) - { + if (PointInLLBox(vp, Pos.x, Pos.y)) { wxPoint p; GetCanvasPixLL(vp, &p, Pos.y, Pos.x); wxColour colour; wxString msg1 = GetShortType(m_type); - if( !msg1.IsEmpty() ) - { + if (!msg1.IsEmpty()) { hasDrawn = true; - GetGlobalColor ( _T ( "UBLCK" ), &colour ); - dc->SetTextForeground( colour ); + GetGlobalColor(_T ( "UBLCK" ), &colour); + dc->SetTextForeground(colour); wxFont sfont = dc->GetFont(); - wxFont *font1 = wxTheFontList->FindOrCreateFont ( SYSTEMS_FONT_SIZE, - wxFONTFAMILY_ROMAN, wxNORMAL, wxFONTWEIGHT_BOLD, - FALSE, wxString ( _T ( "Arial" ) ) ); + wxFont *font1 = wxTheFontList->FindOrCreateFont(SYSTEMS_FONT_SIZE, wxFONTFAMILY_ROMAN, wxNORMAL, + wxFONTWEIGHT_BOLD, FALSE, wxString(_T ( "Arial" ))); dc->SetFont(*font1); wxSize s1 = dc->GetTextExtent(msg1); dc->DrawText(msg1, p.x - (s1.GetWidth() / 2), p.y - (s1.GetHeight() / 2)); - wxFont *font2 = wxTheFontList->FindOrCreateFont ( NUMBERS_FONT_SIZE, - wxFONTFAMILY_SWISS, wxITALIC, wxFONTWEIGHT_NORMAL, - FALSE, wxString ( _T ( "Arial" ) ) ); + wxFont *font2 = wxTheFontList->FindOrCreateFont(NUMBERS_FONT_SIZE, wxFONTFAMILY_SWISS, wxITALIC, + wxFONTWEIGHT_NORMAL, FALSE, wxString(_T ( "Arial" ))); dc->SetFont(*font2); wxString msg2 = GetValue(); - if( !msg2.IsEmpty() ) - { + if (!msg2.IsEmpty()) { wxSize s2 = dc->GetTextExtent(msg2); - dc->DrawText(msg2, - p.x - (s2.GetWidth() / 2), - p.y + (s1.GetHeight() / 2) + (s2.GetHeight() / 2)); + dc->DrawText(msg2, p.x - (s2.GetWidth() / 2), p.y + (s1.GetHeight() / 2) + (s2.GetHeight() / 2)); dc->SetFont(sfont); } } } - } - else - { + } else { wxColour colour; wxPen pen; pen = dc->GetPen(); - GetGlobalColor ( _T ( "GREEN2" ), &colour ); - dc->SetPen(wxPen( colour, m_isoLineWidth )); - DrawPositions( dc, vp ); + GetGlobalColor(_T ( "GREEN2" ), &colour); + dc->SetPen(wxPen(colour, m_isoLineWidth)); + DrawPositions(dc, vp); dc->SetPen(pen); } - } - else - { - if( m_positions.GetCount() == 1 ) - { + } else { + if (m_positions.GetCount() == 1) { GeoPoint &Pos = m_positions[0]; - if( PointInLLBox(vp, Pos.x, Pos.y) ) - { + if (PointInLLBox(vp, Pos.x, Pos.y)) { wxPoint p; GetCanvasPixLL(vp, &p, Pos.y, Pos.x); wxColour colour; wxString msg1 = GetShortType(m_type); - if( !msg1.IsEmpty() ) - { + if (!msg1.IsEmpty()) { hasDrawn = true; - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + wxPoint p; GetCanvasPixLL(vp, &p, Pos.y, Pos.x); int w, h; sysfont.GetTextExtent(msg1, &w, &h); - + int xd = p.x - (w / 2); int yd = p.y - (h / 2); - - GetGlobalColor ( _T ( "UBLCK" ), &colour ); - glColor3ub(colour.Red() , colour.Green(), colour.Blue()); - glEnable( GL_TEXTURE_2D ); + GetGlobalColor(_T ( "UBLCK" ), &colour); + glColor3ub(colour.Red(), colour.Green(), colour.Blue()); + + glEnable(GL_TEXTURE_2D); sysfont.RenderString(msg1, xd, yd); wxString msg2 = GetValue(); - if( !msg2.IsEmpty() ) - { + if (!msg2.IsEmpty()) { int w1, h1; numfont.GetTextExtent(msg2, &w1, &h1); numfont.RenderString(msg2, p.x - (w1 / 2), p.y + (h / 2) + (h1 / 2)); } - glDisable( GL_TEXTURE_2D ); - glDisable( GL_BLEND ); + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); } } - } - else - { + } else { wxColour colour = m_isoLineColor; - GetGlobalColor ( _T ( "GREEN2" ), &m_isoLineColor ); - DrawPositions( dc, vp ); + GetGlobalColor(_T ( "GREEN2" ), &m_isoLineColor); + DrawPositions(dc, vp); m_isoLineColor = colour; } } return hasDrawn; } -bool IACSystem::DrawPositions( wxDC *dc, PlugIn_ViewPort *vp ) -{ +bool IACSystem::DrawPositions(wxDC *dc, PlugIn_ViewPort *vp) { bool hasDrawn = false; - if( dc ) - { - for( size_t pointIndex = 0; pointIndex < m_positions.GetCount() - 1 ; pointIndex++ ) - { + if (dc) { + for (size_t pointIndex = 0; pointIndex < m_positions.GetCount() - 1; pointIndex++) { GeoPoint &startP = m_positions[pointIndex]; - GeoPoint &endP = m_positions[pointIndex+1]; - if( PointInLLBox(vp, startP.x, startP.y) || PointInLLBox(vp, endP.x, endP.y) ) - { + GeoPoint &endP = m_positions[pointIndex + 1]; + if (PointInLLBox(vp, startP.x, startP.y) || PointInLLBox(vp, endP.x, endP.y)) { wxPoint startpl; wxPoint endpl; GetCanvasPixLL(vp, &startpl, startP.y, startP.x); @@ -1060,26 +857,22 @@ hasDrawn = true; } } - } - else - { + } else { // Enable anti-aliased lines, at best quality - glEnable( GL_LINE_SMOOTH ); - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); - glLineWidth( m_isoLineWidth ); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + glLineWidth(m_isoLineWidth); - glColor4ub( m_isoLineColor.Red(), m_isoLineColor.Green(), m_isoLineColor.Blue(), 255 ); - glBegin( GL_LINES ); + glColor4ub(m_isoLineColor.Red(), m_isoLineColor.Green(), m_isoLineColor.Blue(), 255); + glBegin(GL_LINES); wxPoint startpl; wxPoint endpl; - for( size_t pointIndex = 0; pointIndex < m_positions.GetCount() - 1 ; pointIndex++ ) - { + for (size_t pointIndex = 0; pointIndex < m_positions.GetCount() - 1; pointIndex++) { GeoPoint &startP = m_positions[pointIndex]; - GeoPoint &endP = m_positions[pointIndex+1]; - if( PointInLLBox(vp, startP.x, startP.y) || PointInLLBox(vp, endP.x, endP.y) ) - { + GeoPoint &endP = m_positions[pointIndex + 1]; + if (PointInLLBox(vp, startP.x, startP.y) || PointInLLBox(vp, endP.x, endP.y)) { GetCanvasPixLL(vp, &startpl, startP.y, startP.x); GetCanvasPixLL(vp, &endpl, endP.y, endP.x); glVertex2d(startpl.x, startpl.y); @@ -1092,44 +885,31 @@ return hasDrawn; } - -wxString IACSystem::GetTab( const wxChar*(tab[10]), size_t index ) const -{ - if( index < 10 ) - { +wxString IACSystem::GetTab(const wxChar *(tab[10]), size_t index) const { + if (index < 10) { return wxString(tab[index]); - } - else - { + } else { return wxEmptyString; } } -wxString IACSystem::GetMovement( void ) const -{ - static const wxChar* (tab[])= - { - wxT("-"), _("stationary"), _("little change"), _("stopping"), _("retarding"), - _("curving to left"), _("recurving"), _("accelerating"), - _("curving to right"), _("expected to recurve") - }; +wxString IACSystem::GetMovement(void) const { + static const wxChar *(tab[]) = { + wxT("-"), _("stationary"), _("little change"), _("stopping"), _("retarding"), _("curving to left"), + _("recurving"), _("accelerating"), _("curving to right"), _("expected to recurve")}; wxString t; - if( m_movement < 10 ) - { + if (m_movement < 10) { // valid movement - t = _("Movement: ") + GetTab(tab,m_movement); - if( m_movement != 1 ) // not stationary, add dir and speed + t = _("Movement: ") + GetTab(tab, m_movement); + if (m_movement != 1) // not stationary, add dir and speed { wxString hlp; - hlp.Printf(wxT(", %u\u00B0 "),m_direction); + hlp.Printf(wxT(", %u\u00B0 "), m_direction); t.Append(hlp); - if(m_speed >= 99) - { + if (m_speed >= 99) { t.Append(_("with unknown speed")); - } - else - { - hlp.Printf(_("with %uknots"),m_speed); + } else { + hlp.Printf(_("with %uknots"), m_speed); t.Append(hlp); } } @@ -1137,69 +917,47 @@ return t; } -wxString IACSystem::ToString( bool includePosition ) const -{ +wxString IACSystem::ToString(bool includePosition) const { wxString t; t.Append(GetType(m_type) + wxT(" ")); - if(!GetValue().IsEmpty()) - { + if (!GetValue().IsEmpty()) { t.Append(wxT("(") + GetValue() + wxT(") ")); } - if(!GetIntensity().IsEmpty()) - { + if (!GetIntensity().IsEmpty()) { t.Append(wxT(" ") + GetIntensity() + wxT(" ")); } - if( m_char >= 0 ) - { + if (m_char >= 0) { t.Append(GetCharacteristic(m_char) + wxT("\n")); } - if(includePosition) - { + if (includePosition) { t.Append(PositionsToString() + wxT("\n")); } t.Append(GetMovement()); return t; } -bool IACSystem::FindAtPos( GeoPoint &pos, double deviation ) -{ - bool found=false; +bool IACSystem::FindAtPos(GeoPoint &pos, double deviation) { + bool found = false; // loop over positions and see if it matches - for( size_t i = m_positions.GetCount(); i != 0; i-- ) - { - if( m_positions[i - 1].MatchPosition(pos, deviation) ) - { - found=true; + for (size_t i = m_positions.GetCount(); i != 0; i--) { + if (m_positions[i - 1].MatchPosition(pos, deviation)) { + found = true; break; } - } return found; } +wxString IACSystem::GetType(size_t index) const { return (wxEmptyString); } -wxString IACSystem::GetType( size_t index ) const -{ - return(wxEmptyString); -} +wxString IACSystem::GetShortType(size_t index) const { return (wxEmptyString); } -wxString IACSystem::GetShortType( size_t index ) const -{ - return(wxEmptyString); -} +wxString IACSystem::GetCharacteristic(size_t index) const { return (wxEmptyString); } -wxString IACSystem::GetCharacteristic( size_t index ) const -{ - return(wxEmptyString); -} - -wxString IACSystem::PositionsToString( void ) const -{ +wxString IACSystem::PositionsToString(void) const { wxString t; - for( size_t i = 0; i < m_positions.Count(); i++ ) - { - if( i != 0) - { + for (size_t i = 0; i < m_positions.Count(); i++) { + if (i != 0) { t.Append(wxT(" : ")); } t.Append(m_positions[i].ToString()); @@ -1207,218 +965,189 @@ return t; } -wxString IACPressureSystem::GetValue( void ) const -{ +wxString IACPressureSystem::GetValue(void) const { wxString t; - if( m_val >= 0 ) - { + if (m_val >= 0) { t.Printf(wxT("%4u hPa"), m_val); } return t; } -wxString IACPressureSystem::GetType( size_t index ) const -{ - static const wxChar* (tab[])= - { - _("Complex Low"), _("Low"), _("Secondary Low"), _("Trough"), _("Wave"), - _("High"), _("Uniform pressure"), _("Ridge"), _("Col"), _("Tropical Storm") - }; - return(wxString(tab[index])); -} - -wxString IACPressureSystem::GetShortType( size_t index ) const -{ - static const wxChar* (tab[])= - { - wxT("L"), wxT("L"), wxT("L"), wxT("T"), wxT("W"), - wxT("H"), wxT("U"), wxT("R"), wxT("C"), wxT("TS") - }; - return(wxString(tab[index])); -} - -wxString IACPressureSystem::GetCharacteristic( size_t index ) const -{ - static const wxChar* (tab[])= - { - wxEmptyString, _("weakening"), _("little change"), _("intensifying"), _("complex"), - _("forming"), _("weakening but not disappearing"), _("general rise"), - _("general fall"), _("position doubtful") - }; - return(wxString(tab[index])); -} - -wxString IACFrontalSystem::GetType( size_t index ) const -{ - static const wxChar* (tab[])= - { - _("Quasistationary at surface"), _("Quasistationary above surface"), - _("Warm surface"), _("Warm above surface"), - _("Cold surface"), _("Cold above surface"), _("Occlusion"), - _("Instability line"), _("Intertropical"), _("Convergence line") - }; - return(wxString(tab[index])); -} - -wxString IACFrontalSystem::GetCharacteristic( size_t index ) const -{ - static const wxChar* (tab[])= - { - wxEmptyString, _("frontal area decreasing"), _("little change"), _("frontal area increasing"), - _("intertropical"), _("forming"), _("quasistationary"), - _("with waves"), _("diffuse"), _("strong, increasing") - }; - return(wxString(tab[index])); -} - -wxString IACFrontalSystem::GetIntensity( void ) const -{ - static const wxChar* (tab[])= - { - wxEmptyString, - _("weak, decreasing"), _("weak, no change"), _("weak, increasing"), - _("moderate, decreasing"), _("moderate, no change"), _("moderate, increasing"), - _("strong, decreasing"), _("strong, no change"), _("strong, increasing") - }; - if( m_int > 0 ) - { - return(GetTab(tab, m_int)); - } - else - { +wxString IACPressureSystem::GetType(size_t index) const { + static const wxChar *(tab[]) = {_("Complex Low"), _("Low"), _("Secondary Low"), _("Trough"), _("Wave"), _("High"), + _("Uniform pressure"), _("Ridge"), _("Col"), _("Tropical Storm")}; + return (wxString(tab[index])); +} + +wxString IACPressureSystem::GetShortType(size_t index) const { + static const wxChar *(tab[]) = {wxT("L"), wxT("L"), wxT("L"), wxT("T"), wxT("W"), + wxT("H"), wxT("U"), wxT("R"), wxT("C"), wxT("TS")}; + return (wxString(tab[index])); +} + +wxString IACPressureSystem::GetCharacteristic(size_t index) const { + static const wxChar *(tab[]) = {wxEmptyString, + _("weakening"), + _("little change"), + _("intensifying"), + _("complex"), + _("forming"), + _("weakening but not disappearing"), + _("general rise"), + _("general fall"), + _("position doubtful")}; + return (wxString(tab[index])); +} + +wxString IACFrontalSystem::GetType(size_t index) const { + static const wxChar *(tab[]) = {_("Quasistationary at surface"), + _("Quasistationary above surface"), + _("Warm surface"), + _("Warm above surface"), + _("Cold surface"), + _("Cold above surface"), + _("Occlusion"), + _("Instability line"), + _("Intertropical"), + _("Convergence line")}; + return (wxString(tab[index])); +} + +wxString IACFrontalSystem::GetCharacteristic(size_t index) const { + static const wxChar *(tab[]) = {wxEmptyString, _("frontal area decreasing"), + _("little change"), _("frontal area increasing"), + _("intertropical"), _("forming"), + _("quasistationary"), _("with waves"), + _("diffuse"), _("strong, increasing")}; + return (wxString(tab[index])); +} + +wxString IACFrontalSystem::GetIntensity(void) const { + static const wxChar *(tab[]) = {wxEmptyString, + _("weak, decreasing"), + _("weak, no change"), + _("weak, increasing"), + _("moderate, decreasing"), + _("moderate, no change"), + _("moderate, increasing"), + _("strong, decreasing"), + _("strong, no change"), + _("strong, increasing")}; + if (m_int > 0) { + return (GetTab(tab, m_int)); + } else { return wxEmptyString; } } -bool IACFrontalSystem::Draw( wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont ) -{ +bool IACFrontalSystem::Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont) { bool hasDrawn = false; wxColour colour; - if( m_type == WARM_SURFACE || m_type == WARM_ABOVE_SURFACE ) - GetGlobalColor ( _T ( "URED" ), &colour ); - else if ( m_type == COLD_SURFACE || m_type == COLD_ABOVE_SURFACE ) - GetGlobalColor ( _T ( "BLUE3" ), &colour ); - else if ( m_type == OCCLUSION ) - GetGlobalColor ( _T ( "CHMGD" ), &colour ); + if (m_type == WARM_SURFACE || m_type == WARM_ABOVE_SURFACE) + GetGlobalColor(_T ( "URED" ), &colour); + else if (m_type == COLD_SURFACE || m_type == COLD_ABOVE_SURFACE) + GetGlobalColor(_T ( "BLUE3" ), &colour); + else if (m_type == OCCLUSION) + GetGlobalColor(_T ( "CHMGD" ), &colour); else - GetGlobalColor ( _T ( "DASHN" ), &colour ); + GetGlobalColor(_T ( "DASHN" ), &colour); - if( dc ) - { - wxPen pen( colour, FRONT_WIDTH); + if (dc) { + wxPen pen(colour, FRONT_WIDTH); dc->SetPen(pen); dc->SetBrush(*wxTRANSPARENT_BRUSH); - hasDrawn = DrawPositions( dc, vp ); - } - else - { + hasDrawn = DrawPositions(dc, vp); + } else { m_isoLineColor = colour; m_isoLineWidth = wxMax(FRONT_WIDTH, GL_MIN_LINE_WIDTH); - hasDrawn = DrawPositions( dc, vp ); + hasDrawn = DrawPositions(dc, vp); } return hasDrawn; } -wxString IACTropicalSystem::GetType( size_t index ) const -{ - static const wxChar* (tab[])= - { - _("Intertropical convergence zone"), _("Shear line"), - _("Line or Zone of convergence"), _("Axis of doldrum belt"), - _("Through in westerlies"), _("Through in easterlies"), _("LOW area"), - _("Surge line"), _("Divergence zone"), _("Tropical cyclone") - }; - return(GetTab(tab,index)); -} - -wxString IACTropicalSystem::GetShortType( size_t index ) const -{ - static const wxChar* (tab[])= - { - _T("ICZ"), _T("SL"), _T("LC"), _T("ADB"), _T("TW"), - _T("TE"), _T("TL"), _T("SU"), _T("LD"), _T("TC") - }; - return(wxString(tab[index])); -} - -wxString IACTropicalSystem::GetCharacteristic( size_t index ) const -{ - static const wxChar* (tab[])= - { - wxEmptyString, _("diffuse"), _("sharply defines"), _("quasistationary"), - _("existance certain"), _("existance uncertain"), _("formation expected"), - _("position certain"), _("position uncertain"), _("movement doubtful") - }; - return(GetTab(tab, index)); -} - -wxString IACTropicalSystem::GetIntensity( void ) const -{ - static const wxChar* (tab[])= - { - wxT("-"), _("weak, decreasing"), _("weak, no change"), _("weak, increasing"), - _("moderate, decreasing"), _("moderate, no change"), _("moderate, increasing"), - _("strong, decreasing"), _("strong, no change"), _("strong, increasing") - }; - if( m_int > 0 ) - { - return(GetTab(tab, m_int)); - } - else - { +wxString IACTropicalSystem::GetType(size_t index) const { + static const wxChar *(tab[]) = {_("Intertropical convergence zone"), + _("Shear line"), + _("Line or Zone of convergence"), + _("Axis of doldrum belt"), + _("Through in westerlies"), + _("Through in easterlies"), + _("LOW area"), + _("Surge line"), + _("Divergence zone"), + _("Tropical cyclone")}; + return (GetTab(tab, index)); +} + +wxString IACTropicalSystem::GetShortType(size_t index) const { + static const wxChar *(tab[]) = {_T("ICZ"), _T("SL"), _T("LC"), _T("ADB"), _T("TW"), + _T("TE"), _T("TL"), _T("SU"), _T("LD"), _T("TC")}; + return (wxString(tab[index])); +} + +wxString IACTropicalSystem::GetCharacteristic(size_t index) const { + static const wxChar *(tab[]) = {wxEmptyString, _("diffuse"), _("sharply defines"), + _("quasistationary"), _("existance certain"), _("existance uncertain"), + _("formation expected"), _("position certain"), _("position uncertain"), + _("movement doubtful")}; + return (GetTab(tab, index)); +} + +wxString IACTropicalSystem::GetIntensity(void) const { + static const wxChar *(tab[]) = {wxT("-"), + _("weak, decreasing"), + _("weak, no change"), + _("weak, increasing"), + _("moderate, decreasing"), + _("moderate, no change"), + _("moderate, increasing"), + _("strong, decreasing"), + _("strong, no change"), + _("strong, increasing")}; + if (m_int > 0) { + return (GetTab(tab, m_int)); + } else { return wxEmptyString; } } -wxString IACTropicalSystem::GetValue( void ) const -{ +wxString IACTropicalSystem::GetValue(void) const { wxString t; - if( m_val >= 0 ) - { - t.Printf(wxT("%4u hPa"),m_val); + if (m_val >= 0) { + t.Printf(wxT("%4u hPa"), m_val); } return t; } -bool IACTropicalSystem::Draw( wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont ) -{ +bool IACTropicalSystem::Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont) { bool hasDrawn = false; - if( dc ) - { + if (dc) { wxColour colour; - GetGlobalColor ( _T ( "YELO1" ), &colour ); - wxPen pen( colour, FRONT_WIDTH); + GetGlobalColor(_T ( "YELO1" ), &colour); + wxPen pen(colour, FRONT_WIDTH); dc->SetPen(pen); dc->SetBrush(*wxTRANSPARENT_BRUSH); - } - else - { - GetGlobalColor ( _T ( "YELO1" ), &m_isoLineColor ); + } else { + GetGlobalColor(_T ( "YELO1" ), &m_isoLineColor); m_isoLineWidth = wxMax(FRONT_WIDTH, GL_MIN_LINE_WIDTH); - hasDrawn = DrawPositions( dc, vp ); } - hasDrawn = DrawPositions( dc, vp ); - if( dc ) - { - if( m_positions.Count() > 0 ) - { + hasDrawn = DrawPositions(dc, vp); + if (dc) { + if (m_positions.Count() > 0) { GeoPoint &Pos = m_positions[0]; - if( PointInLLBox(vp, Pos.x, Pos.y) ) - { + if (PointInLLBox(vp, Pos.x, Pos.y)) { wxPoint p; GetCanvasPixLL(vp, &p, Pos.y, Pos.x); wxColour colour; wxString msg1 = GetShortType(m_type); - if( !msg1.IsEmpty() ) - { + if (!msg1.IsEmpty()) { hasDrawn = true; - GetGlobalColor ( _T ( "SNDG1" ), &colour ); - dc->SetTextForeground( colour ); + GetGlobalColor(_T ( "SNDG1" ), &colour); + dc->SetTextForeground(colour); wxFont sfont = dc->GetFont(); - wxFont *font1 = wxTheFontList->FindOrCreateFont ( SYSTEMS_FONT_SIZE, - wxFONTFAMILY_ROMAN, wxNORMAL, wxFONTWEIGHT_BOLD, - FALSE, wxString ( _T ( "Arial" ) ) ); + wxFont *font1 = wxTheFontList->FindOrCreateFont(SYSTEMS_FONT_SIZE, wxFONTFAMILY_ROMAN, wxNORMAL, + wxFONTWEIGHT_BOLD, FALSE, wxString(_T ( "Arial" ))); dc->SetFont(*font1); wxSize s1 = dc->GetTextExtent(msg1); dc->DrawText(msg1, p.x - (s1.GetWidth() / 2), p.y - (s1.GetHeight() / 2)); @@ -1426,39 +1155,34 @@ } } } - } - else - { - if( m_positions.GetCount() > 0 ) - { + } else { + if (m_positions.GetCount() > 0) { GeoPoint &Pos = m_positions[0]; - if( PointInLLBox(vp, Pos.x, Pos.y) ) - { + if (PointInLLBox(vp, Pos.x, Pos.y)) { wxPoint p; GetCanvasPixLL(vp, &p, Pos.y, Pos.x); wxColour colour; wxString msg1 = GetShortType(m_type); - if( !msg1.IsEmpty() ) - { + if (!msg1.IsEmpty()) { hasDrawn = true; - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + wxPoint p; GetCanvasPixLL(vp, &p, Pos.y, Pos.x); int w, h; sysfont.GetTextExtent(msg1, &w, &h); - + int xd = p.x - (w / 2); int yd = p.y - (h / 2); - - GetGlobalColor ( _T ( "SNDG1" ), &colour ); - glColor3ub(colour.Red() , colour.Green(), colour.Blue()); - glEnable( GL_TEXTURE_2D ); + GetGlobalColor(_T ( "SNDG1" ), &colour); + glColor3ub(colour.Red(), colour.Green(), colour.Blue()); + + glEnable(GL_TEXTURE_2D); sysfont.RenderString(msg1, xd, yd); - glDisable( GL_TEXTURE_2D ); - glDisable( GL_BLEND ); + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); } } } @@ -1467,76 +1191,66 @@ return hasDrawn; } -wxString IACIsobarSystem::ToString( bool includePosition ) const -{ +wxString IACIsobarSystem::ToString(bool includePosition) const { wxString t; - t.Printf( _("Isobar (%4uhPa):\n"), m_val ); - if( includePosition ) - { + t.Printf(_("Isobar (%4uhPa):\n"), m_val); + if (includePosition) { t.Append(PositionsToString()); } return t; } -bool IACIsobarSystem::Draw( wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont ) -{ +bool IACIsobarSystem::Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont) { bool hasDrawn = false; // draw isobar text at a random position of the isoline to prevent // text clutter. Getting the random positiuon must be before // "if" because otherwise the positions depend on the viewport int randomPositionIndex = rand() % m_positions.Count(); - if( dc ) - { + if (dc) { wxColour colour; - GetGlobalColor ( _T ( "CHBLK" ), &colour ); - wxPen pen( colour, ISOBAR_WIDTH); + GetGlobalColor(_T ( "CHBLK" ), &colour); + wxPen pen(colour, ISOBAR_WIDTH); dc->SetPen(pen); dc->SetBrush(*wxTRANSPARENT_BRUSH); - hasDrawn = DrawPositions( dc, vp ); - if( hasDrawn ) - { + hasDrawn = DrawPositions(dc, vp); + if (hasDrawn) { GeoPoint &Pos = m_positions[randomPositionIndex]; - if( PointInLLBox(vp, Pos.x, Pos.y) ) - { + if (PointInLLBox(vp, Pos.x, Pos.y)) { wxPoint p; - GetCanvasPixLL( vp, &p, Pos.y, Pos.x ); - dc->SetTextForeground( colour ); - wxFont *font = wxTheFontList->FindOrCreateFont ( NUMBERS_FONT_SIZE, - wxFONTFAMILY_SWISS, wxNORMAL, wxFONTWEIGHT_NORMAL, - FALSE, wxString ( _T ( "Arial" ) ) ); + GetCanvasPixLL(vp, &p, Pos.y, Pos.x); + dc->SetTextForeground(colour); + wxFont *font = wxTheFontList->FindOrCreateFont(NUMBERS_FONT_SIZE, wxFONTFAMILY_SWISS, wxNORMAL, wxFONTWEIGHT_NORMAL, + FALSE, wxString(_T ( "Arial" ))); dc->SetFont(*font); wxString msg; msg.Printf(wxT("%u"), m_val); wxSize s1 = dc->GetTextExtent(msg); - dc->DrawText( msg, p.x - (s1.GetWidth() / 2),p.y - (s1.GetHeight()) ); + dc->DrawText(msg, p.x - (s1.GetWidth() / 2), p.y - (s1.GetHeight())); } } - } - else - { - GetGlobalColor ( _T ( "CHBLK" ), &m_isoLineColor ); + } else { + GetGlobalColor(_T ( "CHBLK" ), &m_isoLineColor); m_isoLineWidth = wxMax(ISOBAR_WIDTH, GL_MIN_LINE_WIDTH); - hasDrawn = DrawPositions( dc, vp ); - if( hasDrawn ) - { + hasDrawn = DrawPositions(dc, vp); + if (hasDrawn) { wxColour colour; - GetGlobalColor ( _T ( "CHBLK" ), &colour ); + GetGlobalColor(_T ( "CHBLK" ), &colour); GeoPoint &Pos = m_positions[randomPositionIndex]; wxPoint p; - GetCanvasPixLL( vp, &p, Pos.y, Pos.x ); + GetCanvasPixLL(vp, &p, Pos.y, Pos.x); wxString msg; msg.Printf(wxT("%u"), m_val); int w, h; - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - glEnable( GL_TEXTURE_2D ); - glColor3ub(colour.Red() , colour.Green(), colour.Blue()); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); + glColor3ub(colour.Red(), colour.Green(), colour.Blue()); numfont.GetTextExtent(msg, &w, &h); numfont.RenderString(msg, p.x - (w / 2), p.y - (h / 2)); - glDisable( GL_TEXTURE_2D ); - glDisable( GL_BLEND ); + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); } } return hasDrawn; diff -Nru opencpn-plugin-iacfleet-0.9.0/src/iacfile.h opencpn-plugin-iacfleet-0.10.0/src/iacfile.h --- opencpn-plugin-iacfleet-0.9.0/src/iacfile.h 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/iacfile.h 2018-02-02 14:45:41.000000000 +0000 @@ -30,39 +30,38 @@ #include "wx/wxprec.h" -#ifndef WX_PRECOMP +#ifndef WX_PRECOMP #include "wx/wx.h" -#endif //precompiled headers +#endif // precompiled headers -#include -#include #include -#include #include +#include +#include +#include #include "TexFont.h" #include "ocpn_plugin.h" - #ifdef ocpnUSE_GL #ifdef __WXMSW__ -#include "GL/gl.h" // local copy for Windows #include +#include "GL/gl.h" // local copy for Windows #else #ifndef __OCPN__ANDROID__ #include #include #else -#include "qopengl.h" // this gives us the qt runtime gles2.h #include "GL/gl_private.h" +#include "qopengl.h" // this gives us the qt runtime gles2.h #endif #endif #endif -#include #include +#include #define ISOBAR_WIDTH 2 #define FRONT_WIDTH 5 @@ -70,193 +69,165 @@ #define NUMBERS_FONT_SIZE 9 #define SYSTEMS_FONT_SIZE 15 -#define QUASISTATIONARY_SURFACE 0 -#define QUASISTATIONARY_ABOVE_SURFACE 1 -#define WARM_SURFACE 2 -#define WARM_ABOVE_SURFACE 3 -#define COLD_SURFACE 4 -#define COLD_ABOVE_SURFACE 5 -#define OCCLUSION 6 -#define INSTABILITY_LINE 7 -#define INTERTROPICAL 8 -#define CONVERGENCE_LINE 9 - -#define SECTION_PRESSURE 0 -#define SECTION_FRONTAL 11 -#define SECTION_ISOBAR 22 -#define SECTION_TROPICAL 55 - -#define POS_NH_HALF_DEG 0 -#define POS_OCTANTS 88 - -#define MAX_FILESIZE 20000 - -class GeoPoint:public wxRealPoint -{ -public: +#define QUASISTATIONARY_SURFACE 0 +#define QUASISTATIONARY_ABOVE_SURFACE 1 +#define WARM_SURFACE 2 +#define WARM_ABOVE_SURFACE 3 +#define COLD_SURFACE 4 +#define COLD_ABOVE_SURFACE 5 +#define OCCLUSION 6 +#define INSTABILITY_LINE 7 +#define INTERTROPICAL 8 +#define CONVERGENCE_LINE 9 + +#define SECTION_PRESSURE 0 +#define SECTION_FRONTAL 11 +#define SECTION_ISOBAR 22 +#define SECTION_TROPICAL 55 + +#define POS_NH_HALF_DEG 0 +#define POS_OCTANTS 88 + +#define MAX_FILESIZE 20000 + +class GeoPoint : public wxRealPoint { + public: static const double INVALID_KOORD; - GeoPoint( double lon = INVALID_KOORD, double lat = INVALID_KOORD ) - { - Set(lon, lat); - } - GeoPoint( wxString &token, int coordsys ) - { - Set( token, coordsys ); - } - void Set( wxString &token, int coordsys ); - void Set( double lon = INVALID_KOORD, double lat = INVALID_KOORD ) - { + GeoPoint(double lon = INVALID_KOORD, double lat = INVALID_KOORD) { Set(lon, lat); } + GeoPoint(wxString &token, int coordsys) { Set(token, coordsys); } + void Set(wxString &token, int coordsys); + void Set(double lon = INVALID_KOORD, double lat = INVALID_KOORD) { x = lon; y = lat; } - wxString ToString( void ); - bool MatchPosition( GeoPoint &refPos, double deviation ); + wxString ToString(void); + bool MatchPosition(GeoPoint &refPos, double deviation); }; WX_DECLARE_OBJARRAY(GeoPoint, GeoPoints); -class IACSystem -{ -public: - IACSystem( void ); - //void SetMovement(unsigned int m, unsigned int d, unsigned int s); - virtual wxString ToString( bool includePosition = true ) const; - virtual bool Draw( wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont ); - wxString GetTab( const wxChar*(tab[]), size_t index ) const; - wxString PositionsToString( void ) const; - bool DrawPositions( wxDC *dc, PlugIn_ViewPort *vp ); - virtual bool FindAtPos( GeoPoint &pos, double deviation ); - GeoPoints m_positions; - int m_type; - int m_char; - int m_val; - int m_int; - unsigned int m_movement; // - unsigned int m_direction; // in deg - unsigned int m_speed; // in knots, 99=unknown - -protected: - wxColor m_isoLineColor; - float m_isoLineWidth; - -private: - virtual wxString GetType( size_t index ) const; - virtual wxString GetShortType( size_t index ) const; - virtual wxString GetCharacteristic( size_t index ) const; - virtual wxString GetValue( void ) const - { - return wxEmptyString; - } - virtual wxString GetIntensity( void ) const - { - return wxEmptyString; - } - wxString GetMovement( void ) const; -}; - -class IACPressureSystem : public IACSystem -{ -private: - wxString GetType( size_t index ) const; - wxString GetShortType( size_t index ) const; - wxString GetCharacteristic( size_t index ) const; - wxString GetValue( void ) const; -}; - -class IACFrontalSystem : public IACSystem -{ -public: -private: - wxString GetType( size_t index ) const; - wxString GetCharacteristic( size_t index ) const; - wxString GetIntensity( void ) const; - bool Draw( wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont ); -}; - -class IACIsobarSystem : public IACSystem -{ -public: - wxString ToString( bool includePosition = true ) const; - bool Draw( wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont ); -}; - -class IACTropicalSystem : public IACSystem -{ -public: -private: - wxString GetType( size_t index ) const; - wxString GetShortType( size_t index ) const; - wxString GetIntensity( void ) const; - wxString GetCharacteristic( size_t index ) const; - wxString GetValue( void ) const; - bool Draw( wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont ); +class IACSystem { + public: + IACSystem(void); + virtual ~IACSystem(); + // void SetMovement(unsigned int m, unsigned int d, unsigned int s); + virtual wxString ToString(bool includePosition = true) const; + virtual bool Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont); + wxString GetTab(const wxChar *(tab[]), size_t index) const; + wxString PositionsToString(void) const; + bool DrawPositions(wxDC *dc, PlugIn_ViewPort *vp); + virtual bool FindAtPos(GeoPoint &pos, double deviation); + GeoPoints m_positions; + int m_type; + int m_char; + int m_val; + int m_int; + unsigned int m_movement; // + unsigned int m_direction; // in deg + unsigned int m_speed; // in knots, 99=unknown + + protected: + wxColor m_isoLineColor; + float m_isoLineWidth; + + private: + virtual wxString GetType(size_t index) const; + virtual wxString GetShortType(size_t index) const; + virtual wxString GetCharacteristic(size_t index) const; + virtual wxString GetValue(void) const { return wxEmptyString; } + virtual wxString GetIntensity(void) const { return wxEmptyString; } + wxString GetMovement(void) const; +}; + +class IACPressureSystem : public IACSystem { + private: + wxString GetType(size_t index) const; + wxString GetShortType(size_t index) const; + wxString GetCharacteristic(size_t index) const; + wxString GetValue(void) const; +}; + +class IACFrontalSystem : public IACSystem { + public: + private: + wxString GetType(size_t index) const; + wxString GetCharacteristic(size_t index) const; + wxString GetIntensity(void) const; + bool Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont); +}; + +class IACIsobarSystem : public IACSystem { + public: + wxString ToString(bool includePosition = true) const; + bool Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont); +}; + +class IACTropicalSystem : public IACSystem { + public: + private: + wxString GetType(size_t index) const; + wxString GetShortType(size_t index) const; + wxString GetIntensity(void) const; + wxString GetCharacteristic(size_t index) const; + wxString GetValue(void) const; + bool Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont); }; - WX_DECLARE_OBJARRAY(IACSystem, IACSystems); WX_DECLARE_OBJARRAY(IACPressureSystem, IACPressureSystems); WX_DECLARE_OBJARRAY(IACFrontalSystem, IACFrontalSystems); WX_DECLARE_OBJARRAY(IACIsobarSystem, IACIsobarSystems); WX_DECLARE_OBJARRAY(IACTropicalSystem, IACTropicalSystems); -class IACFile -{ -public: +class IACFile { + public: IACFile(); - IACFile( wxInputStream &stream ); + IACFile(wxInputStream &stream); ~IACFile(); - wxString ToString( void ); - wxString GetIssueDate( void ) - { - return m_issueDate; - } - - bool Read( wxInputStream &stream ); - bool IsOk(void) - { - return m_isok; - } - bool Draw( wxDC *dc, PlugIn_ViewPort *vp ); - static int TokenNumber( wxString &token, size_t start, size_t end ); - static wxFileInputStream* GetStream( wxString &filename ); - wxString &GetRawData( void ) - { - return m_RawData; - } + wxString ToString(void); + wxString GetIssueDate(void) { return m_issueDate; } + bool IsForecast(void) { return m_RawData.StartsWith(_T("F")); } + + bool Read(wxInputStream &stream); + bool IsOk(void) { return m_isok; } + bool Draw(wxDC *dc, PlugIn_ViewPort *vp); + static int TokenNumber(wxString &token, size_t start, size_t end); + static wxFileInputStream *GetStream(wxString &filename); + wxString &GetRawData(void) { return m_RawData; } static const size_t IACMaxSize = MAX_FILESIZE; - void Invalidate( void ); - IACSystem * FindSystem( GeoPoint &pos, double deviation ); + void Invalidate(void); + IACSystem *FindSystem(GeoPoint &pos, double deviation); -private: - IACSystem * FindSystem( IACSystems &systems, GeoPoint &pos, double deviation ); - wxString ReadToken( wxInputStream &file ); - wxString tokenFind( const wxChar* match = wxT("?????"), bool skip = false ); - void PushbackToken( void ); - bool Decode( void ); - - bool Parse( void ); - bool ReadHeader( void ); - bool ParsePositions( IACSystem &sys, int section ); - bool ParseMovement( IACSystem &sys ); - bool ParseSections( void ); - bool ParsePressureSection( void ); - bool ParseFrontalSection( void ); - bool ParseIsobarSection( void ); - bool ParseTropicalSection( void ); - GeoPoint ParsePosition( void ); - bool DrawSystems( wxDC *dc, PlugIn_ViewPort *vp, IACSystems &iacsystem ); - - bool m_isok; - wxArrayString m_tokens; - size_t m_tokensI; - wxString m_filename; - wxString m_RawData; - wxString m_issueDate; + private: + IACSystem *FindSystem(IACSystems &systems, GeoPoint &pos, double deviation); + wxString ReadToken(wxInputStream &file); + wxString tokenFind(const wxChar *match = wxT("?????"), bool skip = false); + void PushbackToken(void); + bool Decode(void); + + bool Parse(void); + bool ReadHeader(void); + bool ParsePositions(IACSystem &sys, int section); + bool ParseMovement(IACSystem &sys); + bool ParseSections(void); + bool ParsePressureSection(void); + bool ParseFrontalSection(void); + bool ParseIsobarSection(void); + bool ParseTropicalSection(void); + GeoPoint ParsePosition(void); + bool DrawSystems(wxDC *dc, PlugIn_ViewPort *vp, IACSystems &iacsystem); + + bool m_isok; + wxArrayString m_tokens; + size_t m_tokensI; + wxString m_filename; + wxString m_RawData; + wxString m_issueDate; IACPressureSystems m_pressure; - IACFrontalSystems m_frontal; - IACIsobarSystems m_isobars; + IACFrontalSystems m_frontal; + IACIsobarSystems m_isobars; IACTropicalSystems m_tropical; TexFont m_TexFontNumbers; TexFont m_TexFontSystems; diff -Nru opencpn-plugin-iacfleet-0.9.0/src/iacfleet.cpp opencpn-plugin-iacfleet-0.10.0/src/iacfleet.cpp --- opencpn-plugin-iacfleet-0.9.0/src/iacfleet.cpp 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/iacfleet.cpp 2018-02-02 14:45:41.000000000 +0000 @@ -27,37 +27,39 @@ #include "wx/wxprec.h" -#ifndef WX_PRECOMP +#ifndef WX_PRECOMP #include "wx/wx.h" -#endif //precompiled headers +#endif // precompiled headers -#include -#include +#include +#include #include #include +#include #include -#include +#include #include -#include "iacfleet_pi.h" -#include "iacfleet.h" #include "iacfile.h" -IMPLEMENT_CLASS ( IACFleetUIDialog, wxDialog ) +#include "iacfleet.h" +#include "iacfleet_pi.h" +IMPLEMENT_CLASS(IACFleetUIDialog, wxDialog) -BEGIN_EVENT_TABLE ( IACFleetUIDialog, wxDialog ) +BEGIN_EVENT_TABLE(IACFleetUIDialog, wxDialog) - EVT_CLOSE ( IACFleetUIDialog::OnClose ) - EVT_BUTTON ( ID_OK, IACFleetUIDialog::OnIdOKClick ) - EVT_BUTTON ( ID_ANIMATE, IACFleetUIDialog::OnIdAnimateClick ) - EVT_MOVE ( IACFleetUIDialog::OnMove ) - EVT_SIZE ( IACFleetUIDialog::OnSize ) - EVT_BUTTON ( ID_CHOOSEIACFLEETDIR, IACFleetUIDialog::OnChooseDirClick ) - EVT_LISTBOX ( ID_FILESELECTED,IACFleetUIDialog::OnFileSelect) - EVT_TEXT(ID_RAWTEXT, IACFleetUIDialog::OnRawTextChanged) - EVT_TIMER(ID_TIP_TIMER, IACFleetUIDialog::OnTipTimer) - EVT_TIMER(ID_ANIMATION_TIMER, IACFleetUIDialog::OnTimerAnimation) +EVT_CLOSE(IACFleetUIDialog::OnClose) +EVT_BUTTON(ID_OK, IACFleetUIDialog::OnIdOKClick) +EVT_BUTTON(ID_ANIMATE, IACFleetUIDialog::OnIdAnimateClick) +EVT_MOVE(IACFleetUIDialog::OnMove) +EVT_SIZE(IACFleetUIDialog::OnSize) +EVT_BUTTON(ID_CHOOSEIACFLEETDIR, IACFleetUIDialog::OnChooseDirClick) +EVT_LISTBOX(ID_FILESELECTED, IACFleetUIDialog::OnFileSelect) +EVT_TEXT(ID_RAWTEXT, IACFleetUIDialog::OnRawTextChanged) +EVT_TIMER(ID_TIP_TIMER, IACFleetUIDialog::OnTipTimer) +EVT_TIMER(ID_ANIMATION_TIMER, IACFleetUIDialog::OnTimerAnimation) END_EVENT_TABLE() +/* IACFleetUIDialog::IACFleetUIDialog(void): pParent(NULL), pPlugIn(NULL), @@ -72,22 +74,19 @@ { // Init(); privat member of "wxDialog" in dialog.h } +*/ -IACFleetUIDialog::~IACFleetUIDialog( void ) -{ - if( m_timer->IsRunning() ) - m_timer->Stop(); +IACFleetUIDialog::~IACFleetUIDialog(void) { + if (m_timer->IsRunning()) m_timer->Stop(); delete m_timer; - m_bBrDownload->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( IACFleetUIDialog::OnBrDownload ), NULL, this ); - m_bNoaaDownload->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( IACFleetUIDialog::OnNoaaDownload ), NULL, this ); - m_rbSortName->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( IACFleetUIDialog::OnSortChange ), NULL, this ); - m_rbSortTime->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( IACFleetUIDialog::OnSortChange ), NULL, this ); + // m_bBrDownload->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IACFleetUIDialog::OnBrDownload), NULL, this); + m_bNoaaDownload->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IACFleetUIDialog::OnNoaaDownload), NULL, this); + m_rbSortName->Disconnect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(IACFleetUIDialog::OnSortChange), NULL, this); + m_rbSortTime->Disconnect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(IACFleetUIDialog::OnSortChange), NULL, this); } -bool IACFleetUIDialog::Create ( wxWindow *parent, iacfleet_pi *ppi, wxWindowID id, - const wxString& caption, const wxString initial_dir, int sort_type, - const wxPoint& pos, const wxSize& size, long style ) -{ +IACFleetUIDialog::IACFleetUIDialog(wxWindow* parent, iacfleet_pi* ppi, wxWindowID id, const wxString& caption, + const wxString initial_dir, int sort_type, const wxPoint& pos, const wxSize& size, long style) { pParent = parent; pPlugIn = ppi; m_timer = new wxTimer(this, ID_ANIMATION_TIMER); @@ -95,26 +94,24 @@ m_currentDir = initial_dir; m_sortType = sort_type; #ifdef __WXMAC__ - long wstyle = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSTAY_ON_TOP; + long wstyle = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxSTAY_ON_TOP; #else - long wstyle = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER; + long wstyle = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER; #endif - if( !wxDialog::Create( parent, id, caption, pos, size, wstyle ) ) - return false; + wxDialog::Create(parent, id, caption, pos, size, wstyle); + // return false; #include "folder.xpm" - m_pfolder_bitmap = new wxBitmap ( folder ); // comes from XPM include + m_pfolder_bitmap = new wxBitmap(folder); // comes from XPM include CreateControls(); SetMinSize(GetBestSize()); - return true; + // return true; } - // get called if the mouse is moved on the chart -void IACFleetUIDialog::SetCursorLatLon( double lat, double lon ) -{ - m_cursorpos.x=lon; - m_cursorpos.y=lat; +void IACFleetUIDialog::SetCursorLatLon(double lat, double lon) { + m_cursorpos.x = lon; + m_cursorpos.y = lat; // Display Tip Window with details of system near the cursor. // Do this by starting and restarting a timer. // If no movement of the cursor occures, the @@ -128,33 +125,26 @@ } // -void IACFleetUIDialog::OnTipTimer( wxTimerEvent& event ) -{ +void IACFleetUIDialog::OnTipTimer(wxTimerEvent& event) { wxString tip; // try to display the tooltip only if // - our vioewpoert is valid // - no "old" tooltip is displayed - if( m_lastViewPortValid && NULL == m_pTipWindow ) - { - IACSystem *pSystem; + if (m_lastViewPortValid && NULL == m_pTipWindow) { + IACSystem* pSystem; int sel_rad_pix = 8; double view_scale_ppm = m_lastViewPort.view_scale_ppm; - double SelectRadius = sel_rad_pix/ ( view_scale_ppm * 1852 * 60 ); // Degrees, approximately - if( NULL != (pSystem = m_iacfile.FindSystem(m_cursorpos,SelectRadius)) ) - { + double SelectRadius = sel_rad_pix / (view_scale_ppm * 1852 * 60); // Degrees, approximately + if (NULL != (pSystem = m_iacfile.FindSystem(m_cursorpos, SelectRadius))) { // found - tip = pSystem->ToString(false); // get Detail-String of system near cursor - m_pTipWindow = new wxTipWindow(m_parent,tip,150); - if( NULL != m_pTipWindow ) - { + tip = pSystem->ToString(false); // get Detail-String of system near cursor + m_pTipWindow = new wxTipWindow(m_parent, tip, 150); + if (NULL != m_pTipWindow) { // hurray - we have a tip window // define area beyond the tip gets deleted wxPoint pos; GetCanvasPixLL(&m_lastViewPort, &pos, m_cursorpos.y, m_cursorpos.x); - wxRect bRect(pos.x - sel_rad_pix, - pos.y - sel_rad_pix, - pos.x + sel_rad_pix, - pos.y + sel_rad_pix); + wxRect bRect(pos.x - sel_rad_pix, pos.y - sel_rad_pix, pos.x + sel_rad_pix, pos.y + sel_rad_pix); m_pTipWindow->SetBoundingRect(bRect); // tell tip window to NULL this pointer when it deletes itself // this means we can tell if the tip window is active or not @@ -164,8 +154,7 @@ } } -void IACFleetUIDialog::OnClose ( wxCloseEvent& event ) -{ +void IACFleetUIDialog::OnClose(wxCloseEvent& event) { pPlugIn->SetDir(m_currentDir); pPlugIn->SetSortType(m_sortType); RequestRefresh(pParent); @@ -173,56 +162,45 @@ pPlugIn->OnDialogClose(); } -void IACFleetUIDialog::Invalidate( void ) -{ +void IACFleetUIDialog::Invalidate(void) { m_iacfile.Invalidate(); m_pRawCtrl->Clear(); m_pTextCtrl->Clear(); } -void IACFleetUIDialog::OnIdOKClick( wxCommandEvent& event ) -{ - Close(); // this will call OnClose() later... +void IACFleetUIDialog::OnIdOKClick(wxCommandEvent& event) { + Close(); // this will call OnClose() later... } -void IACFleetUIDialog::OnIdAnimateClick( wxCommandEvent& event ) -{ - if( m_timer->IsRunning() ) - { +void IACFleetUIDialog::OnIdAnimateClick(wxCommandEvent& event) { + if (m_timer->IsRunning()) { m_timer->Stop(); m_bAnimation->SetLabel(_("Run as &animation")); - } - else - { + } else { m_filesToAnimate.Clear(); m_animationCurrentFile = 0; wxArrayInt selectedFiles; int numberOfSelectedFiles = m_pFileListCtrl->GetSelections(selectedFiles); - if( numberOfSelectedFiles > 0 ) - { - for( int i = 0; i < numberOfSelectedFiles; i++ ) - { + if (numberOfSelectedFiles > 0) { + for (int i = 0; i < numberOfSelectedFiles; i++) { wxFileName fn(m_currentDir, m_FilenameArray[selectedFiles[i]]); m_filesToAnimate.Add(fn.GetFullPath()); } m_bAnimation->SetLabel(_("Stop &animation")); - m_timer->Start( ANIMATION_FRAME_MS ); + m_timer->Start(ANIMATION_FRAME_MS); } } } -void IACFleetUIDialog::OnTimerAnimation( wxTimerEvent& event ) -{ +void IACFleetUIDialog::OnTimerAnimation(wxTimerEvent& event) { m_currentFileName = m_filesToAnimate[m_animationCurrentFile]; updateIACFleet(); m_animationCurrentFile++; - if( m_animationCurrentFile > m_filesToAnimate.Count() - 1 ) - m_animationCurrentFile = 0; + if (m_animationCurrentFile > m_filesToAnimate.Count() - 1) m_animationCurrentFile = 0; } -void IACFleetUIDialog::OnMove( wxMoveEvent& event ) -{ +void IACFleetUIDialog::OnMove(wxMoveEvent& event) { // Record the dialog position wxPoint p = event.GetPosition(); pPlugIn->SetDialogX(p.x); @@ -231,8 +209,7 @@ event.Skip(); } -void IACFleetUIDialog::OnSize( wxSizeEvent& event ) -{ +void IACFleetUIDialog::OnSize(wxSizeEvent& event) { wxSize p = event.GetSize(); pPlugIn->SetDialogSizeX(p.x); pPlugIn->SetDialogSizeY(p.y); @@ -240,295 +217,273 @@ event.Skip(); } -void IACFleetUIDialog::OnChooseDirClick( wxCommandEvent& event ) -{ - wxString new_dir = ::wxDirSelector( _( "Select IACFleet Directory" ), m_currentDir ); - if( !new_dir.empty() ) - { +void IACFleetUIDialog::OnChooseDirClick(wxCommandEvent& event) { + wxString new_dir = ::wxDirSelector(_("Select IACFleet Directory"), m_currentDir); + if (!new_dir.empty()) { m_currentDir = new_dir; - m_pitemCurrentDirectoryCtrl->ChangeValue( m_currentDir ); + m_pitemCurrentDirectoryCtrl->ChangeValue(m_currentDir); m_pitemCurrentDirectoryCtrl->SetInsertionPoint(0); updateFileList(); Refresh(); - pPlugIn->SetDir( m_currentDir ); - + pPlugIn->SetDir(m_currentDir); } } -void IACFleetUIDialog::CreateControls() -{ -// A top-level sizer - wxBoxSizer* topSizer = new wxBoxSizer( wxVERTICAL ); - SetSizer( topSizer ); +void IACFleetUIDialog::CreateControls() { + // A top-level sizer + wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(topSizer); -// The Fleetode directory - wxStaticBoxSizer* itemStaticBoxSizer11Static = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _ ( "IACFleet File Directory" ) ), wxHORIZONTAL ); + wxCollapsiblePane* collpane = new wxCollapsiblePane(this, wxID_ANY, "IACFLeet:"); + // add the pane with a zero proportion value to the 'sz' sizer which contains it + topSizer->Add(collpane, 1, wxGROW | wxALL, 5); + // now add a test label in the collapsible pane using a sizer to layout it: + wxWindow* win = collpane->GetPane(); + wxSizer* paneSz = new wxBoxSizer(wxVERTICAL); - m_pitemCurrentDirectoryCtrl = new wxTextCtrl( this, -1, _T(""), wxDefaultPosition, wxSize(-1, -1), wxTE_READONLY ); - itemStaticBoxSizer11Static->Add( m_pitemCurrentDirectoryCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT); + // The Fleetode directory + wxStaticBoxSizer* itemStaticBoxSizer11Static = + new wxStaticBoxSizer(new wxStaticBox(win, wxID_ANY, _("IACFleet File Directory")), wxHORIZONTAL); - m_pitemCurrentDirectoryCtrl->AppendText( m_currentDir ); + m_pitemCurrentDirectoryCtrl = new wxTextCtrl(win, -1, _T(""), wxDefaultPosition, wxSize(-1, -1), wxTE_READONLY); + itemStaticBoxSizer11Static->Add(m_pitemCurrentDirectoryCtrl, 1, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); - wxButton* bChooseDir = new wxBitmapButton( this, ID_CHOOSEIACFLEETDIR, *m_pfolder_bitmap ); - itemStaticBoxSizer11Static->Add( bChooseDir, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + m_pitemCurrentDirectoryCtrl->AppendText(m_currentDir); - topSizer->Add( itemStaticBoxSizer11Static, 0, wxALL|wxEXPAND, 5 ); + wxButton* bChooseDir = new wxBitmapButton(win, ID_CHOOSEIACFLEETDIR, *m_pfolder_bitmap); + itemStaticBoxSizer11Static->Add(bChooseDir, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + paneSz->Add(itemStaticBoxSizer11Static, 0, wxALL | wxEXPAND, 5); // panels - wxNotebook *itemNotebook = new wxNotebook( this, ID_NOTEBOOK, wxDefaultPosition, - wxDefaultSize, wxNB_TOP ); - topSizer->Add(itemNotebook, 1, wxEXPAND|wxALL, 5); - itemNotebook->SetMinSize(wxSize(wxDefaultCoord,0)); + wxNotebook* itemNotebook = new wxNotebook(win, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxNB_TOP); + paneSz->Add(itemNotebook, 1, wxEXPAND | wxALL | wxGROW, 5); + itemNotebook->SetMinSize(wxSize(500, 200)); // file panel - wxPanel *filepanel = new wxPanel( itemNotebook, wxID_ANY, - wxDefaultPosition, wxDefaultSize); + wxPanel* filepanel = new wxPanel(itemNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize); itemNotebook->AddPage(filepanel, _("Files")); wxBoxSizer* fpsizer = new wxBoxSizer(wxVERTICAL); filepanel->SetSizer(fpsizer); wxBoxSizer* bSizerSort; - bSizerSort = new wxBoxSizer( wxHORIZONTAL ); + bSizerSort = new wxBoxSizer(wxHORIZONTAL); - m_stSort = new wxStaticText( filepanel, wxID_ANY, _("Sort by"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stSort->Wrap( -1 ); - bSizerSort->Add( m_stSort, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + m_stSort = new wxStaticText(filepanel, wxID_ANY, _("Sort by"), wxDefaultPosition, wxDefaultSize, 0); + m_stSort->Wrap(-1); + bSizerSort->Add(m_stSort, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - m_rbSortName = new wxRadioButton( filepanel, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerSort->Add( m_rbSortName, 0, wxALL, 5 ); + m_rbSortName = new wxRadioButton(filepanel, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0); + bSizerSort->Add(m_rbSortName, 0, wxALL, 5); - m_rbSortTime = new wxRadioButton( filepanel, wxID_ANY, _("File timestamp"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerSort->Add( m_rbSortTime, 0, wxALL, 5 ); + m_rbSortTime = new wxRadioButton(filepanel, wxID_ANY, _("File timestamp"), wxDefaultPosition, wxDefaultSize, 0); + bSizerSort->Add(m_rbSortTime, 0, wxALL, 5); - if( m_sortType == SORT_NAME ) - m_rbSortName->SetValue( true ); + if (m_sortType == SORT_NAME) + m_rbSortName->SetValue(true); else - m_rbSortTime->SetValue( true ); + m_rbSortTime->SetValue(true); - fpsizer->Add( bSizerSort, 0, wxEXPAND, 5 ); + fpsizer->Add(bSizerSort, 0, wxEXPAND, 5); - m_pFileListCtrl = new wxListBox(filepanel,ID_FILESELECTED, - wxDefaultPosition,wxDefaultSize,0, - NULL, - wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB, - wxDefaultValidator,wxListBoxNameStr); + m_pFileListCtrl = new wxListBox(filepanel, ID_FILESELECTED, wxDefaultPosition, wxDefaultSize, 0, NULL, + wxLB_EXTENDED | wxLB_HSCROLL | wxLB_NEEDED_SB, wxDefaultValidator, wxListBoxNameStr); fpsizer->Add(m_pFileListCtrl, 1, wxGROW); // Text panel - wxPanel *textpanel = new wxPanel( itemNotebook, wxID_ANY, - wxDefaultPosition, wxSize(-1, -1)); + wxPanel* textpanel = new wxPanel(itemNotebook, wxID_ANY, wxDefaultPosition, wxSize(-1, -1)); itemNotebook->AddPage(textpanel, _("Text")); wxBoxSizer* tpsizer = new wxBoxSizer(wxVERTICAL); textpanel->SetSizer(tpsizer); - m_pTextCtrl = new wxTextCtrl( textpanel, - wxID_ANY, wxEmptyString, - wxDefaultPosition,wxDefaultSize, - wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL - ); + m_pTextCtrl = new wxTextCtrl(textpanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE | wxTE_READONLY | wxHSCROLL); tpsizer->Add(m_pTextCtrl, 1, wxGROW); // Raw panel - wxPanel *rawpanel = new wxPanel( itemNotebook, wxID_ANY, - wxDefaultPosition, wxSize(-1, -1)); + wxPanel* rawpanel = new wxPanel(itemNotebook, wxID_ANY, wxDefaultPosition, wxSize(-1, -1)); itemNotebook->AddPage(rawpanel, _("Raw")); wxBoxSizer* rpsizer = new wxBoxSizer(wxVERTICAL); rawpanel->SetSizer(rpsizer); - m_pRawCtrl = new wxTextCtrl( rawpanel, - ID_RAWTEXT, wxEmptyString, - wxDefaultPosition,wxDefaultSize, - wxTE_MULTILINE|wxHSCROLL - ); + m_pRawCtrl = new wxTextCtrl(rawpanel, ID_RAWTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxHSCROLL); rpsizer->Add(m_pRawCtrl, 1, wxGROW); // Downloads panel - wxScrolledWindow *dnldpanel = new wxScrolledWindow( itemNotebook, wxID_ANY, - wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL); + wxScrolledWindow* dnldpanel = + new wxScrolledWindow(itemNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL | wxVSCROLL); dnldpanel->SetScrollRate(5, 5); itemNotebook->AddPage(dnldpanel, _("Downloads")); - //Generated mostly from wxFormBuilder + // Generated mostly from wxFormBuilder wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxVERTICAL ); + bSizerMain = new wxBoxSizer(wxVERTICAL); dnldpanel->SetSizer(bSizerMain); + /* + wxStaticBoxSizer* sbSizerBrazil; + sbSizerBrazil = new wxStaticBoxSizer(new wxStaticBox(dnldpanel, wxID_ANY, _("Brazil")), wxVERTICAL); - wxStaticBoxSizer* sbSizerBrazil; - sbSizerBrazil = new wxStaticBoxSizer( new wxStaticBox( dnldpanel, wxID_ANY, _("Brazil") ), wxVERTICAL ); - - wxBoxSizer* bsBRazil; - bsBRazil = new wxBoxSizer( wxHORIZONTAL ); - - m_stDate = new wxStaticText( dnldpanel, wxID_ANY, _("Final date"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stDate->Wrap( -1 ); - bsBRazil->Add( m_stDate, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - m_dpBrazil = new wxDatePickerCtrl( dnldpanel, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT ); - bsBRazil->Add( m_dpBrazil, 0, wxALL, 5 ); - m_dpBrazil->SetValue(wxDateTime::Today()); - - m_stHour = new wxStaticText( dnldpanel, wxID_ANY, _("Hour"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stHour->Wrap( -1 ); - bsBRazil->Add( m_stHour, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + wxBoxSizer* bsBRazil; + bsBRazil = new wxBoxSizer(wxHORIZONTAL); - wxString m_chHourChoices[] = { _("00"), _("12") }; - int m_chHourNChoices = sizeof( m_chHourChoices ) / sizeof( wxString ); - m_chHour = new wxChoice( dnldpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_chHourNChoices, m_chHourChoices, 0 ); - m_chHour->SetSelection( 0 ); - bsBRazil->Add( m_chHour, 0, wxALL, 5 ); + m_stDate = new wxStaticText(dnldpanel, wxID_ANY, _("Final date"), wxDefaultPosition, wxDefaultSize, 0); + m_stDate->Wrap(-1); + bsBRazil->Add(m_stDate, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - bsBRazil->Add( 0, 0, 1, wxEXPAND, 5 ); + m_dpBrazil = new wxDatePickerCtrl(dnldpanel, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT); + bsBRazil->Add(m_dpBrazil, 0, wxALL, 5); + m_dpBrazil->SetValue(wxDateTime::Today()); - m_bBrDownload = new wxButton( dnldpanel, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0 ); - bsBRazil->Add( m_bBrDownload, 0, wxALL, 5 ); + m_stHour = new wxStaticText(dnldpanel, wxID_ANY, _("Hour"), wxDefaultPosition, wxDefaultSize, 0); + m_stHour->Wrap(-1); + bsBRazil->Add(m_stHour, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - sbSizerBrazil->Add( bsBRazil, 0, wxEXPAND, 5 ); + wxString m_chHourChoices[] = {_("00"), _("12")}; + int m_chHourNChoices = sizeof(m_chHourChoices) / sizeof(wxString); + m_chHour = new wxChoice(dnldpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_chHourNChoices, m_chHourChoices, 0); + m_chHour->SetSelection(0); + bsBRazil->Add(m_chHour, 0, wxALL, 5); - wxBoxSizer* bSizerHistory; - bSizerHistory = new wxBoxSizer( wxHORIZONTAL ); + bsBRazil->Add(0, 0, 1, wxEXPAND, 5); - m_stHist = new wxStaticText( dnldpanel, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stHist->Wrap( -1 ); - bSizerHistory->Add( m_stHist, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + m_bBrDownload = new wxButton(dnldpanel, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0); + bsBRazil->Add(m_bBrDownload, 0, wxALL, 5); - m_spHist = new wxSpinCtrl( dnldpanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 50,-1 ), wxSP_ARROW_KEYS, 1, 100, 1 ); - bSizerHistory->Add( m_spHist, 0, wxALL, 5 ); + sbSizerBrazil->Add(bsBRazil, 0, wxEXPAND, 5); - m_stForecasts = new wxStaticText( dnldpanel, wxID_ANY, _("dataset(s)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stForecasts->Wrap( -1 ); - bSizerHistory->Add( m_stForecasts, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + wxBoxSizer* bSizerHistory; + bSizerHistory = new wxBoxSizer(wxHORIZONTAL); - sbSizerBrazil->Add( bSizerHistory, 1, wxEXPAND, 5 ); + m_stHist = new wxStaticText(dnldpanel, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0); + m_stHist->Wrap(-1); + bSizerHistory->Add(m_stHist, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - m_stBrDesc = new wxStaticText( dnldpanel, wxID_ANY, _("The data is available since 2006 and accesible manually from"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stBrDesc->Wrap( -1 ); - sbSizerBrazil->Add( m_stBrDesc, 0, wxALL, 5 ); + m_spHist = new wxSpinCtrl(dnldpanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, 100, + 1); bSizerHistory->Add(m_spHist, 0, wxALL, 5); - m_hlBr = new wxHyperlinkCtrl( dnldpanel, wxID_ANY, _("http://www.mar.mil.br/dhn/chm/meteo/prev/iac/iac.htm"), wxT("http://www.mar.mil.br/dhn/chm/meteo/prev/iac/iac.htm"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); - sbSizerBrazil->Add( m_hlBr, 0, wxALL, 5 ); + m_stForecasts = new wxStaticText(dnldpanel, wxID_ANY, _("dataset(s)"), wxDefaultPosition, wxDefaultSize, 0); + m_stForecasts->Wrap(-1); + bSizerHistory->Add(m_stForecasts, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + sbSizerBrazil->Add(bSizerHistory, 1, wxEXPAND, 5); - bSizerMain->Add( sbSizerBrazil, 0, wxALL|wxEXPAND, 5 ); + m_stBrDesc = new wxStaticText(dnldpanel, wxID_ANY, _("The data is available since 2006 and accesible manually from"), + wxDefaultPosition, wxDefaultSize, 0); + m_stBrDesc->Wrap(-1); + sbSizerBrazil->Add(m_stBrDesc, 0, wxALL, 5); - //NOAA - wxStaticBoxSizer* sbSizerNOAA; - sbSizerNOAA = new wxStaticBoxSizer( new wxStaticBox( dnldpanel, wxID_ANY, _("NOAA North Atlantic and Europe") ), wxVERTICAL ); + m_hlBr = new wxHyperlinkCtrl(dnldpanel, wxID_ANY, _("http://www.mar.mil.br/dhn/chm/meteo/prev/iac/iac.htm"), + wxT("http://www.mar.mil.br/dhn/chm/meteo/prev/iac/iac.htm"), wxDefaultPosition, wxDefaultSize, + wxHL_DEFAULT_STYLE); + sbSizerBrazil->Add(m_hlBr, 0, wxALL, 5); - wxBoxSizer* bsNOAA; - bsNOAA = new wxBoxSizer( wxHORIZONTAL ); + bSizerMain->Add(sbSizerBrazil, 0, wxALL | wxEXPAND, 5); + */ + // NOAA + wxStaticBoxSizer* sbSizerNOAA; + sbSizerNOAA = new wxStaticBoxSizer(new wxStaticBox(dnldpanel, wxID_ANY, _("NOAA North Atlantic and Europe")), wxVERTICAL); - m_rbAnalysis = new wxRadioButton( dnldpanel, wxID_ANY, _("Analysis"), wxDefaultPosition, wxDefaultSize, 0 ); - bsNOAA->Add( m_rbAnalysis, 0, wxALL, 5 ); + wxBoxSizer* bsNOAA; + bsNOAA = new wxBoxSizer(wxHORIZONTAL); - m_rbForecast = new wxRadioButton( dnldpanel, wxID_ANY, _("24h forecast"), wxDefaultPosition, wxDefaultSize, 0 ); - bsNOAA->Add( m_rbForecast, 0, wxALL, 5 ); + m_rbAnalysis = new wxRadioButton(dnldpanel, wxID_ANY, _("Analysis"), wxDefaultPosition, wxDefaultSize, 0); + bsNOAA->Add(m_rbAnalysis, 0, wxALL, 5); + m_rbForecast = new wxRadioButton(dnldpanel, wxID_ANY, _("24h forecast"), wxDefaultPosition, wxDefaultSize, 0); + bsNOAA->Add(m_rbForecast, 0, wxALL, 5); - bsNOAA->Add( 0, 0, 1, wxEXPAND, 5 ); + bsNOAA->Add(0, 0, 1, wxEXPAND, 5); - m_bNoaaDownload = new wxButton( dnldpanel, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0 ); - bsNOAA->Add( m_bNoaaDownload, 0, wxALL, 5 ); + m_bNoaaDownload = new wxButton(dnldpanel, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0); + bsNOAA->Add(m_bNoaaDownload, 0, wxALL, 5); + sbSizerNOAA->Add(bsNOAA, 1, wxEXPAND, 5); - sbSizerNOAA->Add( bsNOAA, 1, wxEXPAND, 5 ); + bSizerMain->Add(sbSizerNOAA, 0, wxALL | wxEXPAND, 5); - bSizerMain->Add( sbSizerNOAA, 0, wxALL|wxEXPAND, 5 ); + // NADI + wxStaticBoxSizer* sbSizerNadi; + sbSizerNadi = new wxStaticBoxSizer( + new wxStaticBox(dnldpanel, wxID_ANY, _("South Pacific (from Fiji Meteorological Service, Nadi)")), wxVERTICAL); - //NADI - wxStaticBoxSizer* sbSizerNadi; - sbSizerNadi = new wxStaticBoxSizer( new wxStaticBox( dnldpanel, wxID_ANY, _("South Pacific (from Fiji Meteorological Service, Nadi)") ), wxVERTICAL ); + m_stNadi = new wxStaticText( + dnldpanel, + wxID_ANY, _("The dataset is available from Saildocs\nSend an e-mail with the text\nfleet.nadi\nand any subject to query@saildocs.com\nWhen you receive the response, copy and paste it to the Raw tab or save as text and open on the Files tab."), + wxDefaultPosition, wxDefaultSize, 0); + m_stNadi->Wrap(300); + sbSizerNadi->Add(m_stNadi, 0, wxALL, 5); - m_stNadi = new wxStaticText( dnldpanel, wxID_ANY, _("The dataset is available from Saildocs\nSend an e-mail with the text\nfleet.nadi\nand any subject to query@saildocs.com\nWhen you receive the response, copy and paste it to the Raw tab or save as text and open on the Files tab."), wxDefaultPosition, wxDefaultSize, 0 ); - m_stNadi->Wrap( 300 ); - sbSizerNadi->Add( m_stNadi, 0, wxALL, 5 ); - - - bSizerMain->Add( sbSizerNadi, 0, wxALL|wxEXPAND, 5 ); + bSizerMain->Add(sbSizerNadi, 0, wxALL | wxEXPAND, 5); // Connect Events - m_bBrDownload->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( IACFleetUIDialog::OnBrDownload ), NULL, this ); - m_bNoaaDownload->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( IACFleetUIDialog::OnNoaaDownload ), NULL, this ); - m_rbSortName->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( IACFleetUIDialog::OnSortChange ), NULL, this ); - m_rbSortTime->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( IACFleetUIDialog::OnSortChange ), NULL, this ); - + // m_bBrDownload->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IACFleetUIDialog::OnBrDownload), NULL, this); + m_bNoaaDownload->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IACFleetUIDialog::OnNoaaDownload), NULL, this); + m_rbSortName->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(IACFleetUIDialog::OnSortChange), NULL, this); + m_rbSortTime->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(IACFleetUIDialog::OnSortChange), NULL, this); // the text control that shows the Date and Time // of the Fleetcode wxBoxSizer* tmsizer = new wxBoxSizer(wxHORIZONTAL); - wxStaticText *pIssueDate = new wxStaticText( this, - wxID_ANY, _("Issue Date: "), - wxDefaultPosition,wxDefaultSize, - wxALIGN_LEFT - ); - tmsizer->Add(pIssueDate, 0, wxALL, 5); - m_pFileTime = new wxStaticText( this, - wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - wxALIGN_LEFT); - tmsizer->Add(m_pFileTime, 1, wxALL|wxEXPAND, 5); - topSizer->Add(tmsizer, 0, wxGROW); + m_pIssueDate = new wxStaticText(win, wxID_ANY, _("Issue Date: "), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + tmsizer->Add(m_pIssueDate, 0, wxALL, 5); + m_pFileTime = new wxStaticText(win, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + tmsizer->Add(m_pFileTime, 1, wxALL | wxEXPAND, 5); + paneSz->Add(tmsizer, 0, wxGROW); // A horizontal box sizer to contain OK - wxBoxSizer* AckBox = new wxBoxSizer ( wxHORIZONTAL ); - topSizer->Add( AckBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + wxBoxSizer* AckBox = new wxBoxSizer(wxHORIZONTAL); + paneSz->Add(AckBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); // The OK button - wxButton* bOK = new wxButton( this, ID_OK, _( "&Close" ), - wxDefaultPosition, wxDefaultSize, 0 ); - AckBox->Add( bOK, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + wxButton* bOK = new wxButton(win, ID_OK, _("&Close"), wxDefaultPosition, wxDefaultSize, 0); + AckBox->Add(bOK, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); // The Animate button - m_bAnimation = new wxButton( this, ID_ANIMATE, _( "Run as &animation" ), - wxDefaultPosition, wxDefaultSize, 0 ); - AckBox->Add( m_bAnimation, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + m_bAnimation = new wxButton(win, ID_ANIMATE, _("Run as &animation"), wxDefaultPosition, wxDefaultSize, 0); + AckBox->Add(m_bAnimation, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_bAnimation->Disable(); + win->SetSizer(paneSz); + paneSz->SetSizeHints(win); + updateFileList(); + + collpane->Expand(); } //--------------------------------------------------------- -void IACFleetUIDialog::updateFileList( void ) -{ +void IACFleetUIDialog::updateFileList(void) { m_FilenameArray.Empty(); - if( m_currentDir == wxEmptyString || !wxDirExists( m_currentDir ) ) - return; - wxDir::GetAllFiles(m_currentDir, - &m_FilenameArray, - wxEmptyString, - wxDIR_FILES); - for( int i = m_FilenameArray.GetCount() - 1; i >= 0; i-- ) - { + if (m_currentDir == wxEmptyString || !wxDirExists(m_currentDir)) return; + wxDir::GetAllFiles(m_currentDir, &m_FilenameArray, wxEmptyString, wxDIR_FILES); + for (int i = m_FilenameArray.GetCount() - 1; i >= 0; i--) { // remove dirname from file wxFileName file(m_FilenameArray[i]); wxDateTime access; wxDateTime modified; wxDateTime created; file.GetTimes(&access, &modified, &created); - if( m_sortType == SORT_TIME ) - { + if (m_sortType == SORT_TIME) { wxString dates = modified.FormatISODate() + modified.FormatISOTime() + wxT(";"); m_FilenameArray[i] = dates + file.GetFullName(); - } - else + } else m_FilenameArray[i] = file.GetFullName(); } - if( m_sortType != SORT_NAME ) // sort the filenames according to dates, newest first + if (m_sortType != SORT_NAME) // sort the filenames according to dates, newest first { m_FilenameArray.Sort(true); - for( int i = m_FilenameArray.GetCount() - 1; i >= 0; i-- ) - { + for (int i = m_FilenameArray.GetCount() - 1; i >= 0; i--) { // throw away time info // Yes i know this is bad code! wxString str = m_FilenameArray[i].AfterFirst(';'); m_FilenameArray[i] = str; } - } - else // sort the filenames alphabetically + } else // sort the filenames alphabetically m_FilenameArray.Sort(); m_pFileListCtrl->Set(m_FilenameArray); @@ -536,43 +491,33 @@ } // a new file is selected, read and display this file -void IACFleetUIDialog::OnFileSelect( wxCommandEvent& event ) -{ - if( m_timer->IsRunning() ) - { +void IACFleetUIDialog::OnFileSelect(wxCommandEvent& event) { + if (m_timer->IsRunning()) { m_timer->Stop(); m_bAnimation->SetLabel(_("Run as &animation")); } wxArrayInt selectedFiles; int numberOfSelectedFiles = 0; numberOfSelectedFiles = m_pFileListCtrl->GetSelections(selectedFiles); - if( numberOfSelectedFiles > 0 ) - { + if (numberOfSelectedFiles > 0) { // use the one and only selected file int index = selectedFiles[0]; wxFileName fn(m_currentDir, m_FilenameArray[index]); m_currentFileName = fn.GetFullPath(); - if( numberOfSelectedFiles > 1 ) - { + if (numberOfSelectedFiles > 1) { m_bAnimation->Enable(); - } - else - { + } else { m_bAnimation->Disable(); } - } - else - { + } else { m_currentFileName = wxEmptyString; } // read File and redisplay it updateIACFleet(); } -void IACFleetUIDialog::OnRawTextChanged( wxCommandEvent& event ) -{ - if( m_pRawCtrl->IsModified() ) - { +void IACFleetUIDialog::OnRawTextChanged(wxCommandEvent& event) { + if (m_pRawCtrl->IsModified()) { ::wxBeginBusyCursor(); // the user has modified the text @@ -583,8 +528,7 @@ int numberOfSelectedFiles; numberOfSelectedFiles = m_pFileListCtrl->GetSelections(selectedFiles); - if( numberOfSelectedFiles > 0 ) - { + if (numberOfSelectedFiles > 0) { m_pFileListCtrl->Deselect(selectedFiles[0]); } // make an inputstream from the Raw data in the control @@ -592,14 +536,12 @@ wxMemoryOutputStream ostream; // is there an easier way than to loop throughall the chars in // the Control? - for( size_t Index = 0; Index < rawData.Length(); Index++ ) - { + for (size_t Index = 0; Index < rawData.Length(); Index++) { int c = rawData[Index]; ostream.PutC(c); } wxMemoryInputStream istream(ostream); - if( m_iacfile.Read(istream) ) - { + if (m_iacfile.Read(istream)) { updateTextPanel(); } RequestRefresh(pParent); @@ -610,66 +552,56 @@ // if rawdata is not empty use it as input to the // IACFleet code // otherwise use m_currentFileName -void IACFleetUIDialog::updateIACFleet( void ) -{ +void IACFleetUIDialog::updateIACFleet(void) { bool ok = false; ::wxBeginBusyCursor(); - if( m_currentFileName != wxEmptyString ) - { - wxFileInputStream *pStream = m_iacfile.GetStream(m_currentFileName); - if( NULL != pStream && pStream->IsOk() ) - { - if( m_iacfile.Read(*pStream) ) - { + if (m_currentFileName != wxEmptyString) { + wxFileInputStream* pStream = m_iacfile.GetStream(m_currentFileName); + if (NULL != pStream && pStream->IsOk()) { + if (m_iacfile.Read(*pStream)) { updateTextPanel(); updateRawPanel(m_iacfile.GetRawData()); ok = true; } - } - else if( !m_timer->IsRunning() ) //Show error just if we are not running the animation - wxMessageBox( wxString::Format(_("Error opening: %s"), m_currentFileName.c_str()), _T("IACFleet") ); - if( !ok ) - { + } else if (!m_timer->IsRunning()) // Show error just if we are not running the animation + wxMessageBox(wxString::Format(_("Error opening: %s"), m_currentFileName.c_str()), _T("IACFleet")); + if (!ok) { Invalidate(); } RequestRefresh(pParent); - delete(pStream); + delete (pStream); } ::wxEndBusyCursor(); } -void IACFleetUIDialog::updateRawPanel( wxString &rawData ) -{ - m_pRawCtrl->ChangeValue(rawData); -} +void IACFleetUIDialog::updateRawPanel(wxString& rawData) { m_pRawCtrl->ChangeValue(rawData); } -void IACFleetUIDialog::updateTextPanel( void ) -{ +void IACFleetUIDialog::updateTextPanel(void) { m_pTextCtrl->ChangeValue(m_iacfile.ToString()); + if (m_iacfile.IsForecast()) + m_pIssueDate->SetLabel(_("Forecast issued at ")); + else + m_pIssueDate->SetLabel(_("Analysis issued at ")); m_pFileTime->SetLabel(m_iacfile.GetIssueDate()); + Layout(); + // Refresh(); } -bool IACFleetUIDialog::RenderOverlay( wxDC *dc, PlugIn_ViewPort *vp ) -{ +bool IACFleetUIDialog::RenderOverlay(wxDC* dc, PlugIn_ViewPort* vp) { m_lastViewPortValid = true; m_lastViewPort = *vp; - return m_iacfile.Draw(dc,vp); + return m_iacfile.Draw(dc, vp); } -void IACFleetUIDialog::OnBrDownload( wxCommandEvent& event ) -{ +void IACFleetUIDialog::OnBrDownload(wxCommandEvent& event) { wxDateTime dt = m_dpBrazil->GetValue(); long hrs; - if( m_chHour->GetString(m_chHour->GetSelection()).ToLong(&hrs) ) - dt.Add( wxTimeSpan( hrs ) ); - if( dt > wxDateTime::Now() ) - { + if (m_chHour->GetString(m_chHour->GetSelection()).ToLong(&hrs)) dt.Add(wxTimeSpan(hrs)); + if (dt > wxDateTime::Now()) { wxMessageBox(_("Sorry, you can't download data from the future - they don't exist...")); return; - } - else if( dt < wxDateTime( 1, 9, 2006 ) ) - { + } else if (dt < wxDateTime(1, 9, 2006)) { wxMessageBox(_("Sorry, the data is not available before September 1, 2006...")); return; } @@ -677,63 +609,52 @@ wxString showfile = wxEmptyString; wxString showfilename = wxEmptyString; - for( int i = 0; i < m_spHist->GetValue(); i++ ) - { - wxString filename = wxString::Format(_T("P%u%02u%02u%02u.iac"), - dt.GetYear() - 2000, dt.GetMonth() + 1, dt.GetDay(), - dt.GetHour() ); - dt.Subtract( wxTimeSpan( 12) ); + for (int i = 0; i < m_spHist->GetValue(); i++) { + wxString filename = + wxString::Format(_T("P%u%02u%02u%02u.iac"), dt.GetYear() - 2000, dt.GetMonth() + 1, dt.GetDay(), dt.GetHour()); + dt.Subtract(wxTimeSpan(12)); wxString url = _T("http://www.mar.mil.br/dhn/chm/meteo/prev/iac/") + filename; - wxFileName tfn = wxFileName::CreateTempFileName( _T("iacfleet") ); + wxFileName tfn = wxFileName::CreateTempFileName(_T("iacfleet")); wxFileName fn(m_currentDir, filename); - - _OCPN_DLStatus ret = OCPN_downloadFile( url, tfn.GetFullPath(), - _("Downloading file"), - _("Reading Headers: ") + url, wxNullBitmap, this, - OCPN_DLDS_ELAPSED_TIME|OCPN_DLDS_ESTIMATED_TIME|OCPN_DLDS_REMAINING_TIME|OCPN_DLDS_SPEED|OCPN_DLDS_SIZE|OCPN_DLDS_URL|OCPN_DLDS_CAN_PAUSE|OCPN_DLDS_CAN_ABORT|OCPN_DLDS_AUTO_CLOSE, - 10); - - switch( ret ) - { - case OCPN_DL_NO_ERROR: - { - if ( wxCopyFile( tfn.GetFullPath(), fn.GetFullPath() ) ) - { + + _OCPN_DLStatus ret = + OCPN_downloadFile(url, tfn.GetFullPath(), _("Downloading file"), _("Reading Headers: ") + url, wxNullBitmap, this, + OCPN_DLDS_ELAPSED_TIME | OCPN_DLDS_ESTIMATED_TIME | OCPN_DLDS_REMAINING_TIME | OCPN_DLDS_SPEED | + OCPN_DLDS_SIZE | OCPN_DLDS_URL | OCPN_DLDS_CAN_PAUSE | OCPN_DLDS_CAN_ABORT | OCPN_DLDS_AUTO_CLOSE, + 10); + + switch (ret) { + case OCPN_DL_NO_ERROR: { + if (wxCopyFile(tfn.GetFullPath(), fn.GetFullPath())) { showfile = fn.GetFullPath(); showfilename = filename; - } - else - wxMessageBox(wxString::Format( _("Failed to save: %s "), fn.GetFullPath().c_str() ), - _T("IACFleet"), wxOK | wxICON_ERROR); + } else + wxMessageBox(wxString::Format(_("Failed to save: %s "), fn.GetFullPath().c_str()), _T("IACFleet"), + wxOK | wxICON_ERROR); break; } - case OCPN_DL_FAILED: - { - wxMessageBox(wxString::Format( _("Failed to download: %s \nVerify there is a working Internet connection."), url.c_str() ), - _T("IACFleet"), wxOK | wxICON_ERROR); + case OCPN_DL_FAILED: { + wxMessageBox( + wxString::Format(_("Failed to download: %s \nVerify there is a working Internet connection."), url.c_str()), + _T("IACFleet"), wxOK | wxICON_ERROR); break; } case OCPN_DL_USER_TIMEOUT: - case OCPN_DL_ABORTED: - { + case OCPN_DL_ABORTED: { break; } case OCPN_DL_UNKNOWN: - case OCPN_DL_STARTED: - { + case OCPN_DL_STARTED: { break; } - - default: - wxASSERT( false ); // This should never happen because we handle all possible cases of ret + default: + wxASSERT(false); // This should never happen because we handle all possible cases of ret } - if( wxFileExists( tfn.GetFullPath() ) ) - wxRemoveFile ( tfn.GetFullPath() ); + if (wxFileExists(tfn.GetFullPath())) wxRemoveFile(tfn.GetFullPath()); } - if( showfile != wxEmptyString ) - { + if (showfile != wxEmptyString) { updateFileList(); m_pFileListCtrl->SetStringSelection(showfilename); m_currentFileName = showfile; @@ -741,17 +662,15 @@ } } -void IACFleetUIDialog::OnSortChange( wxCommandEvent& event ) -{ - if( m_rbSortName->GetValue() ) +void IACFleetUIDialog::OnSortChange(wxCommandEvent& event) { + if (m_rbSortName->GetValue()) m_sortType = SORT_NAME; - else if( m_rbSortTime->GetValue() ) + else if (m_rbSortTime->GetValue()) m_sortType = SORT_TIME; updateFileList(); } -void IACFleetUIDialog::OnNoaaDownload( wxCommandEvent& event ) -{ +void IACFleetUIDialog::OnNoaaDownload(wxCommandEvent& event) { wxDateTime dt = wxDateTime::Now(); wxString showfile = wxEmptyString; @@ -760,66 +679,54 @@ wxString url; wxString prefix; - if( m_rbAnalysis->GetValue() ) - { + if (m_rbAnalysis->GetValue()) { prefix = _T("IAC_NOAA_A"); url = _T("http://tgftp.nws.noaa.gov/data/raw/as/asxx21.egrr..txt"); - } - else - { + } else { prefix = _T("IAC_NOAA_F"); url = _T("http://tgftp.nws.noaa.gov/data/raw/fs/fsxx21.egrr..txt"); } - wxString filename = wxString::Format(_T("%s_%i-%i-%i_%i-%i.txt"), prefix.c_str(), - dt.GetYear(), dt.GetMonth() + 1, dt.GetDay(), - dt.GetHour(), dt.GetMinute() ); - wxFileName tfn = wxFileName::CreateTempFileName( _T("iacfleet") ); + wxString filename = wxString::Format(_T("%s_%i-%i-%i_%i-%i.txt"), prefix.c_str(), dt.GetYear(), dt.GetMonth() + 1, dt.GetDay(), + dt.GetHour(), dt.GetMinute()); + wxFileName tfn = wxFileName::CreateTempFileName(_T("iacfleet")); wxFileName fn(m_currentDir, filename); - _OCPN_DLStatus ret = OCPN_downloadFile( url, tfn.GetFullPath(), - _("Downloading file"), - _("Reading Headers: ") + url, wxNullBitmap, this, - OCPN_DLDS_ELAPSED_TIME|OCPN_DLDS_ESTIMATED_TIME|OCPN_DLDS_REMAINING_TIME|OCPN_DLDS_SPEED|OCPN_DLDS_SIZE|OCPN_DLDS_URL|OCPN_DLDS_CAN_PAUSE|OCPN_DLDS_CAN_ABORT|OCPN_DLDS_AUTO_CLOSE, - 10); - switch( ret ) - { - case OCPN_DL_NO_ERROR: - { - if ( wxCopyFile( tfn.GetFullPath(), fn.GetFullPath() ) ) - { + _OCPN_DLStatus ret = + OCPN_downloadFile(url, tfn.GetFullPath(), _("Downloading file"), _("Reading Headers: ") + url, wxNullBitmap, this, + OCPN_DLDS_ELAPSED_TIME | OCPN_DLDS_ESTIMATED_TIME | OCPN_DLDS_REMAINING_TIME | OCPN_DLDS_SPEED | + OCPN_DLDS_SIZE | OCPN_DLDS_URL | OCPN_DLDS_CAN_PAUSE | OCPN_DLDS_CAN_ABORT | OCPN_DLDS_AUTO_CLOSE, + 10); + switch (ret) { + case OCPN_DL_NO_ERROR: { + if (wxCopyFile(tfn.GetFullPath(), fn.GetFullPath())) { showfile = fn.GetFullPath(); showfilename = filename; - } - else - wxMessageBox(wxString::Format( _("Failed to save: %s "), fn.GetFullPath().c_str() ), - _T("IACFleet"), wxOK | wxICON_ERROR); + } else + wxMessageBox(wxString::Format(_("Failed to save: %s "), fn.GetFullPath().c_str()), _T("IACFleet"), + wxOK | wxICON_ERROR); break; } - case OCPN_DL_FAILED: - { - wxMessageBox(wxString::Format( _("Failed to download: %s \nVerify there is a working Internet connection."), url.c_str() ), - _T("IACFleet"), wxOK | wxICON_ERROR); + case OCPN_DL_FAILED: { + wxMessageBox( + wxString::Format(_("Failed to download: %s \nVerify there is a working Internet connection."), url.c_str()), + _T("IACFleet"), wxOK | wxICON_ERROR); break; } case OCPN_DL_USER_TIMEOUT: - case OCPN_DL_ABORTED: - { + case OCPN_DL_ABORTED: { break; } case OCPN_DL_UNKNOWN: - case OCPN_DL_STARTED: - { + case OCPN_DL_STARTED: { break; } - + default: - wxASSERT( false ); // This should never happen because we handle all possible cases of ret + wxASSERT(false); // This should never happen because we handle all possible cases of ret } - if( wxFileExists( tfn.GetFullPath() ) ) - wxRemoveFile ( tfn.GetFullPath() ); - if( showfile != wxEmptyString ) - { + if (wxFileExists(tfn.GetFullPath())) wxRemoveFile(tfn.GetFullPath()); + if (showfile != wxEmptyString) { updateFileList(); m_pFileListCtrl->SetStringSelection(showfilename); m_currentFileName = showfile; diff -Nru opencpn-plugin-iacfleet-0.9.0/src/iacfleet.h opencpn-plugin-iacfleet-0.10.0/src/iacfleet.h --- opencpn-plugin-iacfleet-0.9.0/src/iacfleet.h 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/iacfleet.h 2018-02-02 14:45:41.000000000 +0000 @@ -30,35 +30,34 @@ #include "wx/wxprec.h" -#ifndef WX_PRECOMP +#ifndef WX_PRECOMP #include "wx/wx.h" -#endif //precompiled headers +#endif // precompiled headers -#include -#include -#include -#include #include -#include -#include -#include +#include +#include #include #include -#include -#include +#include +#include #include +#include #include +#include +#include +#include +#include -#include "ocpn_plugin.h" #include "iacfile.h" +#include "ocpn_plugin.h" -#define SORT_NAME 1 -#define SORT_TIME 2 +#define SORT_NAME 1 +#define SORT_TIME 2 -#define ANIMATION_FRAME_MS 1000 +#define ANIMATION_FRAME_MS 1000 -enum -{ +enum { ID_OK = 11001, ID_CHOOSEIACFLEETDIR, ID_FILESELECTED, @@ -70,95 +69,93 @@ }; class iacfleet_pi; -class IACFleetUIDialog: public wxDialog -{ - DECLARE_CLASS( IACFleetUIDialog ) +class IACFleetUIDialog : public wxDialog { + DECLARE_CLASS(IACFleetUIDialog) DECLARE_EVENT_TABLE() -public: - IACFleetUIDialog( void ); - ~IACFleetUIDialog( void ); - bool Create( wxWindow *parent, iacfleet_pi *ppi, wxWindowID id = wxID_ANY, - const wxString& caption = _("IACFleet Display Control"), - const wxString initial_dir = wxEmptyString, int sort_type = SORT_NAME, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, + public: + // IACFleetUIDialog( void ); + ~IACFleetUIDialog(void); + IACFleetUIDialog(wxWindow *parent = NULL, iacfleet_pi *ppi = NULL, wxWindowID id = wxID_ANY, + const wxString &caption = _("IACFleet Display Control"), const wxString initial_dir = wxEmptyString, + int sort_type = SORT_NAME, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, #ifdef __WXMAC__ - long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSTAY_ON_TOP ); + long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxSTAY_ON_TOP); #else - long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER); #endif void CreateControls(); - void OnClose( wxCloseEvent& event ); - void OnIdOKClick( wxCommandEvent& event ); - void OnIdAnimateClick( wxCommandEvent& event ); - void OnTimerAnimation( wxTimerEvent& event ); - void OnMove( wxMoveEvent& event ); - void OnSize( wxSizeEvent& event ); - void OnChooseDirClick( wxCommandEvent& event ); - void OnFileSelect( wxCommandEvent& event ); - void OnRawTextChanged( wxCommandEvent& event ); - void OnTipTimer( wxTimerEvent& event ); - void SetCursorLatLon( double lat, double lon ); - bool RenderOverlay( wxDC *dc, PlugIn_ViewPort *vp ); - void OnBrDownload( wxCommandEvent& event ); - void OnSortChange( wxCommandEvent& event ); - void OnNoaaDownload( wxCommandEvent& event ); - -private: - void Invalidate( void ); - void updateFileList( void ); - void updateIACFleet( void ); - void updateRawPanel( wxString &awData ); - void updateTextPanel( void ); - -private: - wxTimer m_TooltipTimer; - wxWindow *pParent; - iacfleet_pi *pPlugIn; - wxString m_currentDir; - wxString m_currentFileName; - wxBitmap *m_pfolder_bitmap; - wxArrayString m_FilenameArray; - IACFile m_iacfile; - GeoPoint m_cursorpos; - PlugIn_ViewPort m_lastViewPort; - bool m_lastViewPortValid; - int m_sortType; - wxArrayString m_filesToAnimate; - size_t m_animationCurrentFile; + void OnClose(wxCloseEvent &event); + void OnIdOKClick(wxCommandEvent &event); + void OnIdAnimateClick(wxCommandEvent &event); + void OnTimerAnimation(wxTimerEvent &event); + void OnMove(wxMoveEvent &event); + void OnSize(wxSizeEvent &event); + void OnChooseDirClick(wxCommandEvent &event); + void OnFileSelect(wxCommandEvent &event); + void OnRawTextChanged(wxCommandEvent &event); + void OnTipTimer(wxTimerEvent &event); + void SetCursorLatLon(double lat, double lon); + bool RenderOverlay(wxDC *dc, PlugIn_ViewPort *vp); + void OnBrDownload(wxCommandEvent &event); + void OnSortChange(wxCommandEvent &event); + void OnNoaaDownload(wxCommandEvent &event); + + private: + void Invalidate(void); + void updateFileList(void); + void updateIACFleet(void); + void updateRawPanel(wxString &awData); + void updateTextPanel(void); + + private: + wxTimer m_TooltipTimer; + wxWindow *pParent; + iacfleet_pi *pPlugIn; + wxString m_currentDir; + wxString m_currentFileName; + wxBitmap *m_pfolder_bitmap; + wxArrayString m_FilenameArray; + IACFile m_iacfile; + GeoPoint m_cursorpos; + PlugIn_ViewPort m_lastViewPort; + bool m_lastViewPortValid; + int m_sortType; + wxArrayString m_filesToAnimate; + size_t m_animationCurrentFile; // the Contols that will get updated - wxTextCtrl *m_pitemCurrentDirectoryCtrl; - wxListBox *m_pFileListCtrl; - wxTextCtrl *m_pTextCtrl; - wxTextCtrl *m_pRawCtrl; - wxStaticText *m_pFileTime; - wxTipWindow *m_pTipWindow; - wxRadioButton *m_rbSortName; - wxRadioButton *m_rbSortTime; - - wxButton *m_bAnimation; - - //Download panel - wxStaticText *m_stDate; - wxDatePickerCtrl *m_dpBrazil; - wxStaticText *m_stHour; - wxChoice *m_chHour; - wxButton *m_bBrDownload; - wxStaticText *m_stBrDesc; - wxHyperlinkCtrl *m_hlBr; - wxStaticText *m_stSort; - wxStaticText *m_stHist; - wxSpinCtrl *m_spHist; - wxStaticText *m_stForecasts; - - wxRadioButton *m_rbAnalysis; - wxRadioButton *m_rbForecast; - wxButton *m_bNoaaDownload; - - wxStaticText *m_stNadi; - - wxTimer *m_timer; + wxTextCtrl *m_pitemCurrentDirectoryCtrl; + wxListBox *m_pFileListCtrl; + wxTextCtrl *m_pTextCtrl; + wxTextCtrl *m_pRawCtrl; + wxStaticText *m_pIssueDate; + wxStaticText *m_pFileTime; + wxTipWindow *m_pTipWindow; + wxRadioButton *m_rbSortName; + wxRadioButton *m_rbSortTime; + + wxButton *m_bAnimation; + + // Download panel + wxStaticText *m_stDate; + wxDatePickerCtrl *m_dpBrazil; + wxStaticText *m_stHour; + wxChoice *m_chHour; + wxButton *m_bBrDownload; + wxStaticText *m_stBrDesc; + wxHyperlinkCtrl *m_hlBr; + wxStaticText *m_stSort; + wxStaticText *m_stHist; + wxSpinCtrl *m_spHist; + wxStaticText *m_stForecasts; + + wxRadioButton *m_rbAnalysis; + wxRadioButton *m_rbForecast; + wxButton *m_bNoaaDownload; + + wxStaticText *m_stNadi; + + wxTimer *m_timer; }; #endif diff -Nru opencpn-plugin-iacfleet-0.9.0/src/iacfleet_pi.cpp opencpn-plugin-iacfleet-0.10.0/src/iacfleet_pi.cpp --- opencpn-plugin-iacfleet-0.9.0/src/iacfleet_pi.cpp 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/iacfleet_pi.cpp 2018-02-02 14:45:41.000000000 +0000 @@ -25,16 +25,15 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - #include "wx/wxprec.h" -#ifndef WX_PRECOMP +#ifndef WX_PRECOMP #include "wx/wx.h" -#endif //precompiled headers +#endif // precompiled headers -#include #include #include +#include #include #include "iacfleet.h" @@ -42,15 +41,9 @@ // the class factories, used to create and destroy instances of the PlugIn -extern "C" DECL_EXP opencpn_plugin* create_pi( void *ppimgr ) -{ - return (opencpn_plugin *)new iacfleet_pi(ppimgr); -} +extern "C" DECL_EXP opencpn_plugin *create_pi(void *ppimgr) { return (opencpn_plugin *)new iacfleet_pi(ppimgr); } -extern "C" DECL_EXP void destroy_pi( opencpn_plugin* p ) -{ - delete p; -} +extern "C" DECL_EXP void destroy_pi(opencpn_plugin *p) { delete p; } //--------------------------------------------------------------------------------------------------------- // @@ -66,9 +59,7 @@ // //--------------------------------------------------------------------------------------------------------- -iacfleet_pi::iacfleet_pi( void *ppimgr ) : opencpn_plugin_113( ppimgr ) -{ - +iacfleet_pi::iacfleet_pi(void *ppimgr) : opencpn_plugin_113(ppimgr) { // Set some default private member parameters m_dialog_x = 0; m_dialog_y = 0; @@ -81,7 +72,6 @@ m_bShowIcon = false; m_leftclick_tool_id = -1; - // Get a pointer to the opencpn display canvas, to use as a parent for the GRIB dialog m_parent_window = GetOCPNCanvasWindow(); @@ -89,196 +79,139 @@ initialize_images(); } -iacfleet_pi::~iacfleet_pi() -{ - deinitialize_images(); -} - +iacfleet_pi::~iacfleet_pi() { deinitialize_images(); } -int iacfleet_pi::Init( void ) -{ - AddLocaleCatalog( _T("opencpn-iacfleet_pi") ); +int iacfleet_pi::Init(void) { + AddLocaleCatalog(_T("opencpn-iacfleet_pi")); // And load the configuration items LoadConfig(); // This PlugIn needs a toolbar icon, so request its insertion if enabled locally #ifdef IACFLEET_USE_SVG - m_leftclick_tool_id = InsertPlugInToolSVG( _T( "IACFleet" ), _svg_iacfleet, _svg_iacfleet_rollover, _svg_iacfleet_toggled, wxITEM_CHECK, _( "IACFleet" ), _T( "" ), NULL, IACFLEET_TOOL_POSITION, 0, this); + m_leftclick_tool_id = InsertPlugInToolSVG(_T( "IACFleet" ), _svg_iacfleet, _svg_iacfleet_rollover, _svg_iacfleet_toggled, + wxITEM_CHECK, _("IACFleet"), _T( "" ), NULL, IACFLEET_TOOL_POSITION, 0, this); #else - m_leftclick_tool_id = InsertPlugInTool(_T(""), _img_iacfleet_pi, _img_iacfleet_pi, wxITEM_NORMAL, - _("IACFleet"), _T(""), NULL, - IACFLEET_TOOL_POSITION, 0, this); + m_leftclick_tool_id = InsertPlugInTool(_T(""), _img_iacfleet_pi, _img_iacfleet_pi, wxITEM_NORMAL, _("IACFleet"), _T(""), NULL, + IACFLEET_TOOL_POSITION, 0, this); #endif - return (WANTS_OVERLAY_CALLBACK | - WANTS_OPENGL_OVERLAY_CALLBACK | - WANTS_CURSOR_LATLON | - WANTS_TOOLBAR_CALLBACK | - INSTALLS_TOOLBAR_TOOL | - WANTS_CONFIG - ); + return (WANTS_OVERLAY_CALLBACK | WANTS_OPENGL_OVERLAY_CALLBACK | WANTS_CURSOR_LATLON | WANTS_TOOLBAR_CALLBACK | + INSTALLS_TOOLBAR_TOOL | WANTS_CONFIG); } -bool iacfleet_pi::DeInit( void ) -{ - if( m_pDialog ) - { +bool iacfleet_pi::DeInit(void) { + if (m_pDialog) { m_pDialog->Close(); } return true; } -int iacfleet_pi::GetAPIVersionMajor() -{ - return MY_API_VERSION_MAJOR; -} +int iacfleet_pi::GetAPIVersionMajor() { return MY_API_VERSION_MAJOR; } -int iacfleet_pi::GetAPIVersionMinor() -{ - return MY_API_VERSION_MINOR; -} +int iacfleet_pi::GetAPIVersionMinor() { return MY_API_VERSION_MINOR; } -int iacfleet_pi::GetPlugInVersionMajor() -{ - return PLUGIN_VERSION_MAJOR; -} +int iacfleet_pi::GetPlugInVersionMajor() { return PLUGIN_VERSION_MAJOR; } -int iacfleet_pi::GetPlugInVersionMinor() -{ - return PLUGIN_VERSION_MINOR; -} +int iacfleet_pi::GetPlugInVersionMinor() { return PLUGIN_VERSION_MINOR; } -wxBitmap *iacfleet_pi::GetPlugInBitmap() -{ - return _img_iacfleet_pi; -} -wxString iacfleet_pi::GetCommonName() -{ - return _("IACFleet"); -} - -wxString iacfleet_pi::GetShortDescription() -{ - return _("IACFleet PlugIn for OpenCPN"); -} +wxBitmap *iacfleet_pi::GetPlugInBitmap() { return _img_iacfleet_pi; } +wxString iacfleet_pi::GetCommonName() { return _("IACFleet"); } +wxString iacfleet_pi::GetShortDescription() { return _("IACFleet PlugIn for OpenCPN"); } -wxString iacfleet_pi::GetLongDescription() -{ - return _("IACFleet PlugIn for OpenCPN\nDisplay IAC Fleet Code information provided by NADI.\nInformation can be received by email by sending an email with the contents\n\"Send fleet.nadi\" to \"query@saildocs.com\"\nSave the EMail you get as response and open it with this\nPlugin to see the decoded text and a graphic overlay\n"); +wxString iacfleet_pi::GetLongDescription() { + return _( + "IACFleet PlugIn for OpenCPN\nDisplay IAC Fleet Code information provided by NADI.\nInformation can be received by email " + "by sending an email with the contents\n\"Send fleet.nadi\" to \"query@saildocs.com\"\nSave the EMail you get as response " + "and open it with this\nPlugin to see the decoded text and a graphic overlay\n"); } -int iacfleet_pi::GetToolbarToolCount( void ) -{ - return 1; -} +int iacfleet_pi::GetToolbarToolCount(void) { return 1; } -void iacfleet_pi::ShowPreferencesDialog( wxWindow* parent ) -{ - wxDialog *dialog = new wxDialog( parent, wxID_ANY, _("IACFleet Preferences"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE ); +void iacfleet_pi::ShowPreferencesDialog(wxWindow *parent) { + wxDialog *dialog = + new wxDialog(parent, wxID_ANY, _("IACFleet Preferences"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE); dialog->Fit(); } -void iacfleet_pi::SetCursorLatLon( double lat, double lon ) -{ - if( NULL != m_pDialog ) - { - m_pDialog->SetCursorLatLon(lat,lon); +void iacfleet_pi::SetCursorLatLon(double lat, double lon) { + if (NULL != m_pDialog) { + m_pDialog->SetCursorLatLon(lat, lon); } } -void iacfleet_pi::OnToolbarToolCallback( int id ) -{ +void iacfleet_pi::OnToolbarToolCallback(int id) { // show the IACFleet dialog - if( NULL == m_pDialog ) - { - m_pDialog = new IACFleetUIDialog(); - long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER; + if (NULL == m_pDialog) { + // m_pDialog = new IACFleetUIDialog(); + long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER; #ifdef __WXMAC__ style |= wxSTAY_ON_TOP; #endif - wxPoint pos = wxPoint( m_dialog_x, m_dialog_y); - if( !m_parent_window->GetRect().Contains( pos ) ) - pos = wxDefaultPosition; // If it seems we are off position, move to the default position - m_pDialog->Create( m_parent_window, - this, - -1, - _("IACFleet Display Control"), - m_dir, - m_sort_type, - pos, - wxSize( m_dialog_sx, m_dialog_sy), - style ); + wxPoint pos = wxPoint(m_dialog_x, m_dialog_y); + if (!m_parent_window->GetRect().Contains(pos)) + pos = wxDefaultPosition; // If it seems we are off position, move to the default position + m_pDialog = new IACFleetUIDialog(m_parent_window, this, -1, _("IACFleet Display Control"), m_dir, m_sort_type, pos, + wxSize(m_dialog_sx, m_dialog_sy), style); } - m_pDialog->Show( !m_pDialog->IsShown() ); // Show modeless, so it stays on the screen + m_pDialog->Show(!m_pDialog->IsShown()); // Show modeless, so it stays on the screen } -void iacfleet_pi::OnDialogClose() -{ +void iacfleet_pi::OnDialogClose() { m_pDialog = NULL; SaveConfig(); - } -bool iacfleet_pi::RenderOverlay( wxDC &dc, PlugIn_ViewPort *vp ) -{ +bool iacfleet_pi::RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp) { m_pdc = &dc; - bool hasDrawn = m_pDialog && m_pDialog->RenderOverlay(m_pdc,vp); + bool hasDrawn = m_pDialog && m_pDialog->RenderOverlay(m_pdc, vp); return hasDrawn; } -bool iacfleet_pi::RenderGLOverlay( wxGLContext *pcontext, PlugIn_ViewPort *vp ) -{ +bool iacfleet_pi::RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp) { m_pdc = NULL; - bool hasDrawn = m_pDialog && m_pDialog->RenderOverlay(m_pdc,vp); + bool hasDrawn = m_pDialog && m_pDialog->RenderOverlay(m_pdc, vp); return hasDrawn; } - -bool iacfleet_pi::LoadConfig( void ) -{ +bool iacfleet_pi::LoadConfig(void) { wxFileConfig *pConf = GetOCPNConfigObject(); - if( pConf ) - { - pConf->SetPath ( _T( "/Settings" ) ); - - m_dialog_sx = pConf->Read ( _T ( "IACFleetDialogSizeX" ), 300L ); - m_dialog_sy = pConf->Read ( _T ( "IACFleetDialogSizeY" ), 540L ); - m_dialog_x = pConf->Read ( _T ( "IACFleetDialogPosX" ), 20L ); - m_dialog_y = pConf->Read ( _T ( "IACFleetDialogPosY" ), 170L ); - - m_sort_type = pConf->Read ( _T ( "IACFleetSortType" ), SORT_NAME ); + if (pConf) { + pConf->SetPath(_T( "/Settings" )); + + m_dialog_sx = pConf->Read(_T ( "IACFleetDialogSizeX" ), 300L); + m_dialog_sy = pConf->Read(_T ( "IACFleetDialogSizeY" ), 540L); + m_dialog_x = pConf->Read(_T ( "IACFleetDialogPosX" ), 20L); + m_dialog_y = pConf->Read(_T ( "IACFleetDialogPosY" ), 170L); + + m_sort_type = pConf->Read(_T ( "IACFleetSortType" ), SORT_NAME); - pConf->SetPath ( _T ( "/Directories" ) ); - pConf->Read ( _T ( "IACFleetDirectory" ), &m_dir, wxStandardPaths::Get().GetDocumentsDir() ); + pConf->SetPath(_T ( "/Directories" )); + pConf->Read(_T ( "IACFleetDirectory" ), &m_dir, wxStandardPaths::Get().GetDocumentsDir()); return true; - } - else + } else return false; } -bool iacfleet_pi::SaveConfig( void ) -{ +bool iacfleet_pi::SaveConfig(void) { wxFileConfig *pConf = GetOCPNConfigObject(); - if( pConf ) - { - pConf->SetPath ( _T ( "/Settings" ) ); - pConf->Write ( _T ( "IACFleetDialogSizeX" ), m_dialog_sx ); - pConf->Write ( _T ( "IACFleetDialogSizeY" ), m_dialog_sy ); - pConf->Write ( _T ( "IACFleetDialogPosX" ), m_dialog_x ); - pConf->Write ( _T ( "IACFleetDialogPosY" ), m_dialog_y ); - - pConf->Write ( _T ( "IACFleetSortType" ), m_sort_type ); + if (pConf) { + pConf->SetPath(_T ( "/Settings" )); + pConf->Write(_T ( "IACFleetDialogSizeX" ), m_dialog_sx); + pConf->Write(_T ( "IACFleetDialogSizeY" ), m_dialog_sy); + pConf->Write(_T ( "IACFleetDialogPosX" ), m_dialog_x); + pConf->Write(_T ( "IACFleetDialogPosY" ), m_dialog_y); + + pConf->Write(_T ( "IACFleetSortType" ), m_sort_type); - pConf->SetPath ( _T ( "/Directories" ) ); - pConf->Write ( _T ( "IACFleetDirectory" ), m_dir ); + pConf->SetPath(_T ( "/Directories" )); + pConf->Write(_T ( "IACFleetDirectory" ), m_dir); return true; - } - else + } else return false; } diff -Nru opencpn-plugin-iacfleet-0.9.0/src/iacfleet_pi.h opencpn-plugin-iacfleet-0.10.0/src/iacfleet_pi.h --- opencpn-plugin-iacfleet-0.9.0/src/iacfleet_pi.h 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/iacfleet_pi.h 2018-02-02 14:45:41.000000000 +0000 @@ -30,32 +30,31 @@ #include "wx/wxprec.h" -#ifndef WX_PRECOMP +#ifndef WX_PRECOMP #include "wx/wx.h" -#endif //precompiled headers +#endif // precompiled headers #include "version.h" -#define MY_API_VERSION_MAJOR 1 -#define MY_API_VERSION_MINOR 13 +#define MY_API_VERSION_MAJOR 1 +#define MY_API_VERSION_MINOR 13 #include "ocpn_plugin.h" -#define IACFLEET_TOOL_POSITION -1 // Request default positioning of toolbar tool +#define IACFLEET_TOOL_POSITION -1 // Request default positioning of toolbar tool //---------------------------------------------------------------------------------------------------------- // The PlugIn Class Definition //---------------------------------------------------------------------------------------------------------- class IACFleetUIDialog; -class iacfleet_pi : public opencpn_plugin_113 -{ -public: - iacfleet_pi( void *ppimgr ); +class iacfleet_pi : public opencpn_plugin_113 { + public: + iacfleet_pi(void *ppimgr); ~iacfleet_pi(); -// The required PlugIn Methods - int Init( void ); - bool DeInit( void ); + // The required PlugIn Methods + int Init(void); + bool DeInit(void); int GetAPIVersionMajor(); int GetAPIVersionMinor(); @@ -65,54 +64,36 @@ wxString GetCommonName(); wxString GetShortDescription(); wxString GetLongDescription(); - void SetCursorLatLon( double lat, double lon ); + void SetCursorLatLon(double lat, double lon); -// The override PlugIn Methods - bool RenderOverlay( wxDC &dc, PlugIn_ViewPort *vp ); - bool RenderGLOverlay( wxGLContext *pcontext, PlugIn_ViewPort *vp ); - int GetToolbarToolCount( void ); - void ShowPreferencesDialog( wxWindow* parent ); - void OnToolbarToolCallback( int id ); - void SetDialogX( int x ) - { - m_dialog_x = x; - }; - void SetDialogY( int x ) - { - m_dialog_y = x; - } - void SetDialogSizeX( int x ) - { - m_dialog_sx = x; - } - void SetDialogSizeY( int x ) - { - m_dialog_sy = x; - } + // The override PlugIn Methods + bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp); + bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp); + int GetToolbarToolCount(void); + void ShowPreferencesDialog(wxWindow *parent); + void OnToolbarToolCallback(int id); + void SetDialogX(int x) { m_dialog_x = x; }; + void SetDialogY(int x) { m_dialog_y = x; } + void SetDialogSizeX(int x) { m_dialog_sx = x; } + void SetDialogSizeY(int x) { m_dialog_sy = x; } void OnDialogClose(); - void SetDir( wxString dir ) - { - m_dir = dir; - }; - void SetSortType( int sort_type ) - { - m_sort_type = sort_type; - }; - -private: - bool LoadConfig( void ); - bool SaveConfig( void ); - -private: - wxWindow *m_parent_window; - bool m_bShowIcon; - int m_leftclick_tool_id; - int m_dialog_x, m_dialog_y; - int m_dialog_sx, m_dialog_sy; - int m_sort_type; - wxString m_dir; + void SetDir(wxString dir) { m_dir = dir; }; + void SetSortType(int sort_type) { m_sort_type = sort_type; }; + + private: + bool LoadConfig(void); + bool SaveConfig(void); + + private: + wxWindow *m_parent_window; + bool m_bShowIcon; + int m_leftclick_tool_id; + int m_dialog_x, m_dialog_y; + int m_dialog_sx, m_dialog_sy; + int m_sort_type; + wxString m_dir; IACFleetUIDialog *m_pDialog; - wxDC *m_pdc; + wxDC *m_pdc; }; #endif diff -Nru opencpn-plugin-iacfleet-0.9.0/src/icons.cpp opencpn-plugin-iacfleet-0.10.0/src/icons.cpp --- opencpn-plugin-iacfleet-0.9.0/src/icons.cpp 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/icons.cpp 2018-02-02 14:45:41.000000000 +0000 @@ -1,9 +1,9 @@ #include #ifndef WX_PRECOMP -# include +#include #endif -#include #include +#include #include "icons.h" wxBitmap *_img_iacfleet_pi; @@ -15,13 +15,28 @@ wxString _svg_iacfleet_toggled; #endif -void initialize_images(void) -{ - { - wxMemoryInputStream sm("\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 \b\006\000\000\000szz\364\000\000\000\001sRGB\000\256\316\034\351\000\000\000\006bKGD\000\377\000\377\000\377\240\275\247\223\000\000\000\011pHYs\000\000\013\023\000\000\013\023\001\000\232\234\030\000\000\000\atIME\a\333\n\036\004\027\n\254\004\273\025\000\000\0013IDATX\303\325WK\216\005!\b\004\303\375\257\\o\361\342\304\241\371\252\235\311\260\264\265)\212\002\221\001\200\22413\031\313\341wf&\"J\317\255{\230\231\204\232\3469\217\034O[\035\003 \000O\000\321\317\252\216f\244\031#DD\203\016M\203Z\243\003\360\013\314\nj\256\217\023\352\365wk\217\a\342\n\003\332\341t\246\035Z \346\332\330\311\361M\0337\350\177\035\300\r\200\236\026\006\375\261\275\006\300\022c\n +\231.\275\2254I\307\201W\343\272\024;\272\371\377\032X\351_\323\260j\300k\327&\200J\377\366\200\350=^\352\332\032\350\260\3401\342\315\014\014\a\236\207\274r)=\234\004\303\n\177\327{\216\252 \254a\344\321+\000`'\332\356\031O\210\262S\377V\336\273\315j\236\221\252Z\263\031owD\373\021\341\355Y0\002\352VA\006\"\242\333\232x*\377\221]\272#F:\251\224\252\350\274\331\376tb\222[\335oG\274&\200nEDwGE\254\322\255\377\352\353'\273\270\322\273 \353\353\273\242\323\201\311\215Fs2EK\247\261\234\276\r\254@>\233\227W,\3376\245\231\000\000\000\000IEND\256B`\202", 435); - _img_iacfleet_pi = new wxBitmap(wxImage(sm)); - } - +void initialize_images(void) { + { + wxMemoryInputStream sm( + "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 " + "\b\006\000\000\000szz\364\000\000\000\001sRGB\000\256\316\034\351\000\000\000\006bKGD\000\377\000\377\000\377\240\275" + "\247\223\000\000\000\011pHYs\000\000\013\023\000\000\013\023\001\000\232\234\030\000\000\000\atIME\a\333\n\036\004\027" + "\n\254\004\273\025\000\000\0013IDATX\303\325WK\216\005!" + "\b\004\303\375\257\\o\361\342\304\241\371\252\235\311\260\264\265)\212\002\221\001\200\22413\031\313\341wf&" + "\"J\317\255{\230\231\204\232\3469\217\034O[\035\003 " + "\000O\000\321\317\252\216f\244\031#" + "DD\203\016M\203Z\243\003\360\013\314\nj\256\217\023\352\365wk\217\a\342\n\003\332\341t\246\035Z " + "\346\332\330\311\361M\0337\350\177\035\300\r\200\236\026\006\375\261\275\006\300\022c\n " + "+\231.\275\2254I\307\201W\343\272\024;\272\371\377\032X\351_\323\260j\300k\327&\200J\377\366\200\350=^" + "\352\332\032\350\260\3401\342\315\014\014\a\236\207\274r)=\234\004\303\n\177\327{\216\252 " + "\254a\344\321+\000`'" + "\332\356\031O\210\262S\377V\336\273\315j\236\221\252Z\263\031owD\373\021\341\355Y0\002\352VA\006\"\242\333\232x*" + "\377\221]\272#F:\251\224\252\350\274\331\376tb\222[\335oG\274&\200nEDwGE\254\322\255\377\352\353'\273\270\322\273 " + "\353\353\273\242\323\201\311\215Fs2EK\247\261\234\276\r\254@>\233\227W,\3376\245\231\000\000\000\000IEND\256B`\202", + 435); + _img_iacfleet_pi = new wxBitmap(wxImage(sm)); + } + #ifdef IACFLEET_USE_SVG wxFileName fn; fn.SetPath(*GetpSharedDataLocation()); @@ -35,12 +50,12 @@ fn.SetFullName(_T("iacfleet_pi_toggled.svg")); _svg_iacfleet_toggled = fn.GetFullPath(); #endif - - return; + + return; } -void deinitialize_images(void){ - if(NULL !=_img_iacfleet_pi){ - delete(_img_iacfleet_pi); - } +void deinitialize_images(void) { + if (NULL != _img_iacfleet_pi) { + delete (_img_iacfleet_pi); + } } diff -Nru opencpn-plugin-iacfleet-0.9.0/src/icons.h opencpn-plugin-iacfleet-0.10.0/src/icons.h --- opencpn-plugin-iacfleet-0.9.0/src/icons.h 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/icons.h 2018-02-02 14:45:41.000000000 +0000 @@ -3,7 +3,7 @@ #include #ifndef WX_PRECOMP -# include +#include #endif extern void initialize_images(void); diff -Nru opencpn-plugin-iacfleet-0.9.0/src/ocpn_plugin.h opencpn-plugin-iacfleet-0.10.0/src/ocpn_plugin.h --- opencpn-plugin-iacfleet-0.9.0/src/ocpn_plugin.h 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/ocpn_plugin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,1169 +0,0 @@ -/*************************************************************************** - * - * Project: OpenCPN - * Purpose: PlugIn Object Definition/API - * Author: David Register - * - *************************************************************************** - * Copyright (C) 2010 by David S. Register * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - **************************************************************************/ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#ifndef DECL_EXP -#ifdef __WXMSW__ -# define DECL_EXP __declspec(dllexport) -#else -# ifdef __GNUC__ -# define DECL_EXP __attribute__((visibility("default"))) -# endif -#endif -#endif - - -#include - -#ifdef ocpnUSE_SVG -#include "wxsvg/include/wxSVG/svg.h" -#endif // ocpnUSE_SVG - -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 - -// Fwd Definitions -class wxFileConfig; -class wxNotebook; -class wxFont; -class wxAuiManager; -class wxScrolledWindow; - -//--------------------------------------------------------------------------------------------------------- -// -// Bitfield PlugIn Capabilites flag definition -// -//--------------------------------------------------------------------------------------------------------- -#define WANTS_OVERLAY_CALLBACK 0x00000001 -#define WANTS_CURSOR_LATLON 0x00000002 -#define WANTS_TOOLBAR_CALLBACK 0x00000004 -#define INSTALLS_TOOLBAR_TOOL 0x00000008 -#define WANTS_CONFIG 0x00000010 -#define INSTALLS_TOOLBOX_PAGE 0x00000020 -#define INSTALLS_CONTEXTMENU_ITEMS 0x00000040 -#define WANTS_NMEA_SENTENCES 0x00000080 -#define WANTS_NMEA_EVENTS 0x00000100 -#define WANTS_AIS_SENTENCES 0x00000200 -#define USES_AUI_MANAGER 0x00000400 -#define WANTS_PREFERENCES 0x00000800 -#define INSTALLS_PLUGIN_CHART 0x00001000 -#define WANTS_ONPAINT_VIEWPORT 0x00002000 -#define WANTS_PLUGIN_MESSAGING 0x00004000 -#define WANTS_OPENGL_OVERLAY_CALLBACK 0x00008000 -#define WANTS_DYNAMIC_OPENGL_OVERLAY_CALLBACK 0x00010000 -#define WANTS_LATE_INIT 0x00020000 -#define INSTALLS_PLUGIN_CHART_GL 0x00040000 -#define WANTS_MOUSE_EVENTS 0x00080000 -#define WANTS_VECTOR_CHART_OBJECT_INFO 0x00100000 -#define WANTS_KEYBOARD_EVENTS 0x00200000 - -//---------------------------------------------------------------------------------------------------------- -// Some PlugIn API interface object class definitions -//---------------------------------------------------------------------------------------------------------- -enum PI_ColorScheme -{ - PI_GLOBAL_COLOR_SCHEME_RGB, - PI_GLOBAL_COLOR_SCHEME_DAY, - PI_GLOBAL_COLOR_SCHEME_DUSK, - PI_GLOBAL_COLOR_SCHEME_NIGHT, - PI_N_COLOR_SCHEMES -}; - -class PlugIn_ViewPort -{ - public: - double clat; // center point - double clon; - double view_scale_ppm; - double skew; - double rotation; - - float chart_scale; // conventional chart displayed scale - - int pix_width; - int pix_height; - wxRect rv_rect; - bool b_quilt; - int m_projection_type; - - double lat_min, lat_max, lon_min, lon_max; - - bool bValid; // This VP is valid -}; - -class PlugIn_Position_Fix -{ - public: - double Lat; - double Lon; - double Cog; - double Sog; - double Var; // Variation, typically from RMC message - time_t FixTime; - int nSats; -}; - -class PlugIn_Position_Fix_Ex -{ - public: - double Lat; - double Lon; - double Cog; - double Sog; - double Var; // Variation, typically from RMC message - double Hdm; - double Hdt; - time_t FixTime; - int nSats; -}; - -// Describe AIS Alarm state -enum plugin_ais_alarm_type -{ - PI_AIS_NO_ALARM = 0, - PI_AIS_ALARM_SET, - PI_AIS_ALARM_ACKNOWLEDGED - -}; - - -class PlugIn_AIS_Target -{ - public: - - int MMSI; - int Class; - int NavStatus; - double SOG; - double COG; - double HDG; - double Lon; - double Lat; - int ROTAIS; - char CallSign[8]; // includes terminator - char ShipName[21]; - unsigned char ShipType; - int IMO; - - double Range_NM; - double Brg; - - // Per target collision parameters - bool bCPA_Valid; - double TCPA; // Minutes - double CPA; // Nautical Miles - - plugin_ais_alarm_type alarm_state; -}; - - -// ChartType constants -typedef enum ChartTypeEnumPI -{ - PI_CHART_TYPE_UNKNOWN = 0, - PI_CHART_TYPE_DUMMY, - PI_CHART_TYPE_DONTCARE, - PI_CHART_TYPE_KAP, - PI_CHART_TYPE_GEO, - PI_CHART_TYPE_S57, - PI_CHART_TYPE_CM93, - PI_CHART_TYPE_CM93COMP, - PI_CHART_TYPE_PLUGIN -}_ChartTypeEnumPI; - -// ChartFamily constants -typedef enum ChartFamilyEnumPI -{ - PI_CHART_FAMILY_UNKNOWN = 0, - PI_CHART_FAMILY_RASTER, - PI_CHART_FAMILY_VECTOR, - PI_CHART_FAMILY_DONTCARE -}_ChartFamilyEnumPI; - -// Depth unit type enum -typedef enum ChartDepthUnitTypePI -{ - PI_DEPTH_UNIT_UNKNOWN, - PI_DEPTH_UNIT_FEET, - PI_DEPTH_UNIT_METERS, - PI_DEPTH_UNIT_FATHOMS -}_ChartDepthUnitTypePI; - -// Projection type enum -typedef enum OcpnProjTypePI -{ - PI_PROJECTION_UNKNOWN, - PI_PROJECTION_MERCATOR, - PI_PROJECTION_TRANSVERSE_MERCATOR, - PI_PROJECTION_POLYCONIC, - - PI_PROJECTION_ORTHOGRAPHIC, - PI_PROJECTION_POLAR, - PI_PROJECTION_STEREOGRAPHIC, - PI_PROJECTION_GNOMONIC, - PI_PROJECTION_EQUIRECTANGULAR -}_OcpnProjTypePI; - -typedef struct _ExtentPI{ - double SLAT; - double WLON; - double NLAT; - double ELON; -}ExtentPI; - -// PlugInChartBase::Init() init_flags constants -#define PI_FULL_INIT 0 -#define PI_HEADER_ONLY 1 -#define PI_THUMB_ONLY 2 - - -// ---------------------------------------------------------------------------- -// PlugInChartBase -// This class is the base class for Plug-able chart types -// ---------------------------------------------------------------------------- - -class DECL_EXP PlugInChartBase : public wxObject -{ - public: - // These methods Must be overriden in any derived class - PlugInChartBase(); - virtual ~PlugInChartBase(); - - virtual wxString GetFileSearchMask(void); - - virtual int Init( const wxString& full_path, int init_flags ); - virtual void SetColorScheme(int cs, bool bApplyImmediate); - - virtual double GetNormalScaleMin(double canvas_scale_factor, bool b_allow_overzoom); - virtual double GetNormalScaleMax(double canvas_scale_factor, int canvas_width); - virtual double GetNearestPreferredScalePPM(double target_scale_ppm); - - virtual bool GetChartExtent(ExtentPI *pext); - - virtual wxBitmap &RenderRegionView(const PlugIn_ViewPort& VPoint, const wxRegion &Region); - - virtual bool AdjustVP(PlugIn_ViewPort &vp_last, PlugIn_ViewPort &vp_proposed); - - virtual void GetValidCanvasRegion(const PlugIn_ViewPort& VPoint, wxRegion *pValidRegion); - - virtual int GetCOVREntries(){ return 0; } - virtual int GetCOVRTablePoints(int iTable) { return 0; } - virtual int GetCOVRTablenPoints(int iTable){ return 0; } - virtual float *GetCOVRTableHead(int iTable){ return (float *)NULL; } - - virtual wxBitmap *GetThumbnail(int tnx, int tny, int cs); - -// Accessors, need not be overridden in derived class if the member variables are maintained - virtual wxString GetFullPath() const { return m_FullPath;} - virtual ChartTypeEnumPI GetChartType() { return m_ChartType;} - virtual ChartFamilyEnumPI GetChartFamily() { return m_ChartFamily;} - virtual OcpnProjTypePI GetChartProjection() { return m_projection;} - virtual wxString GetName() { return m_Name;} - virtual wxString GetDescription() { return m_Description;} - virtual wxString GetID() { return m_ID;} - virtual wxString GetSE() { return m_SE;} - virtual wxString GetDepthUnits() { return m_DepthUnits;} - virtual wxString GetSoundingsDatum() { return m_SoundingsDatum;} - virtual wxString GetDatumString() { return m_datum_str;} - virtual wxString GetExtraInfo() { return m_ExtraInfo; } - virtual wxString GetPubDate() { return m_PubYear;} - virtual double GetChartErrorFactor() { return m_Chart_Error_Factor;} - virtual ChartDepthUnitTypePI GetDepthUnitId() { return m_depth_unit_id;} - virtual bool IsReadyToRender() { return m_bReadyToRender;} - virtual int GetNativeScale() { return m_Chart_Scale; }; - virtual double GetChartSkew() { return m_Chart_Skew; } - virtual wxDateTime GetEditionDate(void) { return m_EdDate;} - -// Methods pertaining to CHART_FAMILY_RASTER type PlugIn charts only - virtual void ComputeSourceRectangle(const PlugIn_ViewPort &vp, wxRect *pSourceRect); - virtual double GetRasterScaleFactor(); - virtual bool GetChartBits( wxRect& source, unsigned char *pPix, int sub_samp ); - virtual int GetSize_X(); - virtual int GetSize_Y(); - virtual void latlong_to_chartpix(double lat, double lon, double &pixx, double &pixy); - virtual void chartpix_to_latlong(double pixx, double pixy, double *plat, double *plon); - - protected: - ChartTypeEnumPI m_ChartType; - ChartFamilyEnumPI m_ChartFamily; - - wxString m_FullPath; - OcpnProjTypePI m_projection; - int m_Chart_Scale; - double m_Chart_Skew; - - wxDateTime m_EdDate; - bool m_bReadyToRender; - - wxString m_Name; - wxString m_Description; - wxString m_ID; - wxString m_SE; - wxString m_SoundingsDatum; - wxString m_datum_str; - wxString m_PubYear; - wxString m_DepthUnits; - wxString m_ExtraInfo; - - ChartDepthUnitTypePI m_depth_unit_id; - - double m_Chart_Error_Factor; - - -}; - - - - - -// Declare an array of PlugIn_AIS_Targets -WX_DEFINE_ARRAY_PTR(PlugIn_AIS_Target *, ArrayOfPlugIn_AIS_Targets); - - - -//---------------------------------------------------------------------------------------------------------- -// The Generic PlugIn Interface Class Definition -// -// This is a virtual class. -// opencpn PlugIns must derive from this class. -// There are two types of methods in this class -// a. Required...must be overridden and implemented by PlugIns -// b. Optional..may be overridden by PlugIns - -// PlugIns must implement optional method overrides consistent with their -// declared capabilities flag as returned by Init(). -//---------------------------------------------------------------------------------------------------------- -class DECL_EXP opencpn_plugin -{ - -public: - opencpn_plugin(void *pmgr) {} - virtual ~opencpn_plugin(); - - // Public API to the PlugIn class - - // This group of methods is required, and will be called by the opencpn host - // opencpn PlugIns must implement this group - virtual int Init(void); // Return the PlugIn Capabilites flag - virtual bool DeInit(void); - - virtual int GetAPIVersionMajor(); - virtual int GetAPIVersionMinor(); - virtual int GetPlugInVersionMajor(); - virtual int GetPlugInVersionMinor(); - virtual wxBitmap *GetPlugInBitmap(); - - // These three methods should produce valid, meaningful strings always - // ---EVEN IF--- the PlugIn has not (yet) been initialized. - // They are used by the PlugInManager GUI - virtual wxString GetCommonName(); - virtual wxString GetShortDescription(); - virtual wxString GetLongDescription(); - - // This group is optional. - // PlugIns may override any of these methods as required - - virtual void SetDefaults(void); //This will be called upon enabling a PlugIn via the user Dialog - //It gives a chance to setup any default options and behavior - - virtual int GetToolbarToolCount(void); - - virtual int GetToolboxPanelCount(void); - virtual void SetupToolboxPanel(int page_sel, wxNotebook* pnotebook); - virtual void OnCloseToolboxPanel(int page_sel, int ok_apply_cancel); - - virtual void ShowPreferencesDialog( wxWindow* parent ); - - virtual bool RenderOverlay(wxMemoryDC *pmdc, PlugIn_ViewPort *vp); - virtual void SetCursorLatLon(double lat, double lon); - virtual void SetCurrentViewPort(PlugIn_ViewPort &vp); - - virtual void SetPositionFix(PlugIn_Position_Fix &pfix); - virtual void SetNMEASentence(wxString &sentence); - virtual void SetAISSentence(wxString &sentence); - - virtual void ProcessParentResize(int x, int y); - virtual void SetColorScheme(PI_ColorScheme cs); - - virtual void OnToolbarToolCallback(int id); - virtual void OnContextMenuItemCallback(int id); - - virtual void UpdateAuiStatus(void); - - virtual wxArrayString GetDynamicChartClassNameArray(void); - }; - - - // the types of the class factories used to create PlugIn instances - typedef opencpn_plugin* create_t(void*); - typedef void destroy_t(opencpn_plugin*); - - class DECL_EXP opencpn_plugin_16 : public opencpn_plugin - { - public: - opencpn_plugin_16(void *pmgr); - virtual ~opencpn_plugin_16(); - - virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp); - - virtual void SetPluginMessage(wxString &message_id, wxString &message_body); - - }; - -class DECL_EXP opencpn_plugin_17 : public opencpn_plugin -{ - public: - opencpn_plugin_17(void *pmgr); - virtual ~opencpn_plugin_17(); - - 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); - -}; - -class DECL_EXP opencpn_plugin_18 : public opencpn_plugin -{ - public: - opencpn_plugin_18(void *pmgr); - virtual ~opencpn_plugin_18(); - - 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); - -}; - -class DECL_EXP opencpn_plugin_19 : public opencpn_plugin_18 -{ - public: - opencpn_plugin_19(void *pmgr); - virtual ~opencpn_plugin_19(); - - virtual void OnSetupOptions(void); -}; - -class DECL_EXP opencpn_plugin_110 : public opencpn_plugin_19 -{ - public: - opencpn_plugin_110(void *pmgr); - virtual ~opencpn_plugin_110(); - - virtual void LateInit(void); // If WANTS_LATE_INIT is returned by Init() -}; - -class DECL_EXP opencpn_plugin_111 : public opencpn_plugin_110 -{ -public: - opencpn_plugin_111(void *pmgr); - virtual ~opencpn_plugin_111(); - -}; - -class DECL_EXP opencpn_plugin_112 : public opencpn_plugin_111 -{ -public: - opencpn_plugin_112(void *pmgr); - virtual ~opencpn_plugin_112(); - - virtual bool MouseEventHook( wxMouseEvent &event ); - virtual void SendVectorChartObjectInfo(wxString &chart, wxString &feature, wxString &objname, double lat, double lon, double scale, int nativescale); - -}; - -class DECL_EXP opencpn_plugin_113 : public opencpn_plugin_112 -{ -public: - opencpn_plugin_113(void *pmgr); - virtual ~opencpn_plugin_113(); - - virtual bool KeyboardEventHook( wxKeyEvent &event ); - virtual void OnToolbarToolDownCallback(int id); - virtual void OnToolbarToolUpCallback(int id); -}; - -//------------------------------------------------------------------ -// Route and Waypoint PlugIn support -// -//------------------------------------------------------------------ - -class DECL_EXP Plugin_Hyperlink -{ -public: - wxString DescrText; - wxString Link; - wxString Type; -}; - -WX_DECLARE_LIST(Plugin_Hyperlink, Plugin_HyperlinkList); - - - -class DECL_EXP PlugIn_Waypoint -{ -public: - PlugIn_Waypoint(); - PlugIn_Waypoint(double lat, double lon, - const wxString& icon_ident, const wxString& wp_name, - const wxString& GUID = _T("") ); - ~PlugIn_Waypoint(); - - double m_lat; - double m_lon; - - wxString m_GUID; - - wxString m_MarkName; - wxString m_MarkDescription; - wxDateTime m_CreateTime; - bool m_IsVisible; - - wxString m_IconName; - - Plugin_HyperlinkList *m_HyperlinkList; - -}; - -WX_DECLARE_LIST(PlugIn_Waypoint, Plugin_WaypointList); - -class DECL_EXP PlugIn_Route -{ -public: - PlugIn_Route(void); - ~PlugIn_Route(void); - - wxString m_NameString; - wxString m_StartString; - wxString m_EndString; - wxString m_GUID; - - Plugin_WaypointList *pWaypointList; -}; - -class DECL_EXP PlugIn_Track -{ -public: - PlugIn_Track(void); - ~PlugIn_Track(void); - - wxString m_NameString; - wxString m_StartString; - wxString m_EndString; - wxString m_GUID; - - Plugin_WaypointList *pWaypointList; -}; - - - -//---------------------------------------------------------------------------------------------------------- -// The PlugIn CallBack API Definition -// -// The API back up to the PlugIn Manager -// PlugIns may call these static functions as necessary for system services -// -//---------------------------------------------------------------------------------------------------------- - - -extern "C" DECL_EXP int InsertPlugInTool(wxString label, wxBitmap *bitmap, wxBitmap *bmpRollover, wxItemKind kind, - wxString shortHelp, wxString longHelp, wxObject *clientData, int position, - int tool_sel, opencpn_plugin *pplugin); -extern "C" DECL_EXP void RemovePlugInTool(int tool_id); -extern "C" DECL_EXP void SetToolbarToolViz(int item, bool viz); // Temporarily change toolbar tool viz -extern "C" DECL_EXP void SetToolbarItemState(int item, bool toggle); -extern "C" DECL_EXP void SetToolbarToolBitmaps(int item, wxBitmap *bitmap, wxBitmap *bmpRollover); - -extern "C" DECL_EXP int InsertPlugInToolSVG(wxString label, wxString SVGfile, wxString SVGfileRollover, wxString SVGfileToggled, - wxItemKind kind, wxString shortHelp, wxString longHelp, - wxObject *clientData, int position, int tool_sel, opencpn_plugin *pplugin); -extern "C" DECL_EXP void SetToolbarToolBitmapsSVG(int item, wxString SVGfile, - wxString SVGfileRollover, - wxString SVGfileToggled ); - -extern "C" DECL_EXP int AddCanvasContextMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin ); -extern "C" DECL_EXP void RemoveCanvasContextMenuItem(int item); // Fully remove this item -extern "C" DECL_EXP void SetCanvasContextMenuItemViz(int item, bool viz); // Temporarily change context menu ptions -extern "C" DECL_EXP void SetCanvasContextMenuItemGrey(int item, bool grey); - - -extern "C" DECL_EXP wxFileConfig *GetOCPNConfigObject(void); - -extern "C" DECL_EXP void RequestRefresh(wxWindow *); -extern "C" DECL_EXP bool GetGlobalColor(wxString colorName, wxColour *pcolour); - -extern "C" DECL_EXP void GetCanvasPixLL(PlugIn_ViewPort *vp, wxPoint *pp, double lat, double lon); -extern "C" DECL_EXP void GetCanvasLLPix( PlugIn_ViewPort *vp, wxPoint p, double *plat, double *plon); - -extern "C" DECL_EXP wxWindow *GetOCPNCanvasWindow(); - -extern "C" DECL_EXP wxFont *OCPNGetFont(wxString TextElement, int default_size); - -extern "C" DECL_EXP wxString *GetpSharedDataLocation(); - -extern "C" DECL_EXP ArrayOfPlugIn_AIS_Targets *GetAISTargetArray(void); - -extern "C" DECL_EXP wxAuiManager *GetFrameAuiManager(void); - -extern "C" DECL_EXP bool AddLocaleCatalog( wxString catalog ); - -extern "C" DECL_EXP void PushNMEABuffer( wxString str ); - -extern DECL_EXP wxXmlDocument GetChartDatabaseEntryXML(int dbIndex, bool b_getGeom); - -extern DECL_EXP bool UpdateChartDBInplace(wxArrayString dir_array, - bool b_force_update, - bool b_ProgressDialog); -extern DECL_EXP wxArrayString GetChartDBDirArrayString(); - -extern "C" DECL_EXP void SendPluginMessage( wxString message_id, wxString message_body ); - -extern "C" DECL_EXP void DimeWindow(wxWindow *); - -extern "C" DECL_EXP void JumpToPosition(double lat, double lon, double scale); - -/* API 1.9 adds some common cartographic functions to avoid unnecessary code duplication */ -/* Study the original OpenCPN source (georef.c) for functional definitions */ - -extern "C" DECL_EXP void PositionBearingDistanceMercator_Plugin(double lat, double lon, double brg, double dist, double *dlat, double *dlon); -extern "C" DECL_EXP void DistanceBearingMercator_Plugin(double lat0, double lon0, double lat1, double lon1, double *brg, double *dist); -extern "C" DECL_EXP double DistGreatCircle_Plugin(double slat, double slon, double dlat, double dlon); - -extern "C" DECL_EXP void toTM_Plugin(float lat, float lon, float lat0, float lon0, double *x, double *y); -extern "C" DECL_EXP void fromTM_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); -extern "C" DECL_EXP void toSM_Plugin(double lat, double lon, double lat0, double lon0, double *x, double *y); -extern "C" DECL_EXP void fromSM_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); -extern "C" DECL_EXP void toSM_ECC_Plugin(double lat, double lon, double lat0, double lon0, double *x, double *y); -extern "C" DECL_EXP void fromSM_ECC_Plugin(double x, double y, double lat0, double lon0, double *lat, double *lon); - -extern "C" DECL_EXP bool DecodeSingleVDOMessage( const wxString& str, PlugIn_Position_Fix_Ex *pos, wxString *acc ); -extern "C" DECL_EXP int GetChartbarHeight( void ); -extern "C" DECL_EXP bool GetActiveRoutepointGPX( char *buffer, unsigned int buffer_length ); - - - -/* API 1.9 */ -typedef enum OptionsParentPI -{ - PI_OPTIONS_PARENT_DISPLAY, - PI_OPTIONS_PARENT_CONNECTIONS, - PI_OPTIONS_PARENT_CHARTS, - PI_OPTIONS_PARENT_SHIPS, - PI_OPTIONS_PARENT_UI, - PI_OPTIONS_PARENT_PLUGINS -}_OptionsParentPI; -extern DECL_EXP wxScrolledWindow *AddOptionsPage( OptionsParentPI parent, wxString title ); -extern DECL_EXP bool DeleteOptionsPage( wxScrolledWindow* page ); - - -/* API 1.10 */ - -/* API 1.10 adds some common functions to avoid unnecessary code duplication */ -/* Study the original OpenCPN source for functional definitions */ -extern "C" DECL_EXP double toUsrDistance_Plugin( double nm_distance, int unit = -1 ); -extern "C" DECL_EXP double fromUsrDistance_Plugin( double usr_distance, int unit = -1 ); -extern "C" DECL_EXP double toUsrSpeed_Plugin( double kts_speed, int unit = -1 ); -extern "C" DECL_EXP double fromUsrSpeed_Plugin( double usr_speed, int unit = -1 ); -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); -extern DECL_EXP void PlugInPlaySound( wxString &sound_file ); - - - - -// API 1.10 Route and Waypoint Support -extern DECL_EXP wxBitmap *FindSystemWaypointIcon( wxString& icon_name ); -extern DECL_EXP bool AddCustomWaypointIcon( wxBitmap *pimage, wxString key, wxString description ); - -extern DECL_EXP bool AddSingleWaypoint( PlugIn_Waypoint *pwaypoint, bool b_permanent = true); -extern DECL_EXP bool DeleteSingleWaypoint( wxString &GUID ); -extern DECL_EXP bool UpdateSingleWaypoint( PlugIn_Waypoint *pwaypoint ); - -extern DECL_EXP bool AddPlugInRoute( PlugIn_Route *proute, bool b_permanent = true ); -extern DECL_EXP bool DeletePlugInRoute( wxString& GUID ); -extern DECL_EXP bool UpdatePlugInRoute ( PlugIn_Route *proute ); - -extern DECL_EXP bool AddPlugInTrack( PlugIn_Track *ptrack, bool b_permanent = true ); -extern DECL_EXP bool DeletePlugInTrack( wxString& GUID ); -extern DECL_EXP bool UpdatePlugInTrack ( PlugIn_Track *ptrack ); - -/* API 1.11 */ - -/* API 1.11 adds some more common functions to avoid unnecessary code duplication */ -wxColour DECL_EXP GetBaseGlobalColor(wxString colorName); -int DECL_EXP OCPNMessageBox_PlugIn(wxWindow *parent, - const wxString& message, - const wxString& caption = _T("Message"), - int style = wxOK, int x = -1, int y = -1); - -extern DECL_EXP wxString toSDMM_PlugIn(int NEflag, double a, bool hi_precision = true); - -extern "C" DECL_EXP wxString *GetpPrivateApplicationDataLocation(); -extern DECL_EXP wxString GetOCPN_ExePath( void ); -extern "C" DECL_EXP wxString *GetpPlugInLocation(); -extern DECL_EXP wxString GetPlugInPath(opencpn_plugin *pplugin); - -extern "C" DECL_EXP int AddChartToDBInPlace( wxString &full_path, bool b_RefreshCanvas ); -extern "C" DECL_EXP int RemoveChartFromDBInPlace( wxString &full_path ); -extern DECL_EXP wxString GetLocaleCanonicalName(); - -// API 1.11 adds access to S52 Presentation library -//Types - -// A flag field that defines the object capabilities passed by a chart to the S52 PLIB - -#define PLIB_CAPS_LINE_VBO 1 -#define PLIB_CAPS_LINE_BUFFER 1 << 1 -#define PLIB_CAPS_SINGLEGEO_BUFFER 1 << 2 -#define PLIB_CAPS_OBJSEGLIST 1 << 3 -#define PLIB_CAPS_OBJCATMUTATE 1 << 4 - - -class PI_S57Obj; - -WX_DECLARE_LIST(PI_S57Obj, ListOfPI_S57Obj); - -// ---------------------------------------------------------------------------- -// PlugInChartBaseGL -// Derived from PlugInChartBase, add OpenGL Vector chart support -// ---------------------------------------------------------------------------- - -class DECL_EXP PlugInChartBaseGL : public PlugInChartBase -{ -public: - PlugInChartBaseGL(); - virtual ~PlugInChartBaseGL(); - - virtual int RenderRegionViewOnGL( const wxGLContext &glc, const PlugIn_ViewPort& VPoint, - const wxRegion &Region, bool b_use_stencil ); - - virtual ListOfPI_S57Obj *GetObjRuleListAtLatLon(float lat, float lon, float select_radius, PlugIn_ViewPort *VPoint); - virtual wxString CreateObjDescriptions( ListOfPI_S57Obj* obj_list ); - - virtual int GetNoCOVREntries(); - virtual int GetNoCOVRTablePoints(int iTable); - virtual int GetNoCOVRTablenPoints(int iTable); - virtual float *GetNoCOVRTableHead(int iTable); - -}; - - - - - - - -class wxArrayOfS57attVal; - -// name of the addressed look up table set (fifth letter) -typedef enum _PI_LUPname{ - PI_SIMPLIFIED = 'L', // points - PI_PAPER_CHART = 'R', // points - PI_LINES = 'S', // lines - PI_PLAIN_BOUNDARIES = 'N', // areas - PI_SYMBOLIZED_BOUNDARIES = 'O', // areas - PI_LUPNAME_NUM = 5 -}PI_LUPname; - -// display category type -typedef enum _PI_DisCat{ - PI_DISPLAYBASE = 'D', // - PI_STANDARD = 'S', // - PI_OTHER = 'O', // O for OTHER - PI_MARINERS_STANDARD = 'M', // Mariner specified - PI_MARINERS_OTHER, // value not defined - PI_DISP_CAT_NUM, // value not defined -}PI_DisCat; - -// Display Priority -typedef enum _PI_DisPrio{ - PI_PRIO_NODATA = '0', // no data fill area pattern - PI_PRIO_GROUP1 = '1', // S57 group 1 filled areas - PI_PRIO_AREA_1 = '2', // superimposed areas - PI_PRIO_AREA_2 = '3', // superimposed areas also water features - PI_PRIO_SYMB_POINT = '4', // point symbol also land features - PI_PRIO_SYMB_LINE = '5', // line symbol also restricted areas - PI_PRIO_SYMB_AREA = '6', // area symbol also traffic areas - PI_PRIO_ROUTEING = '7', // routeing lines - PI_PRIO_HAZARDS = '8', // hazards - PI_PRIO_MARINERS = '9', // VRM, EBL, own ship - PI_PRIO_NUM = 10 // number of priority levels - -}PI_DisPrio; - -typedef enum PI_InitReturn -{ - PI_INIT_OK = 0, - PI_INIT_FAIL_RETRY, // Init failed, retry suggested - PI_INIT_FAIL_REMOVE, // Init failed, suggest remove from further use - PI_INIT_FAIL_NOERROR // Init failed, request no explicit error message -}_PI_InitReturn; - -class PI_line_segment_element -{ -public: - size_t vbo_offset; - size_t n_points; - int priority; - float lat_max; // segment bounding box - float lat_min; - float lon_max; - float lon_min; - int type; - void *private0; - - PI_line_segment_element *next; -}; - - -class DECL_EXP PI_S57Obj -{ -public: - - // Public Methods - PI_S57Obj(); - ~PI_S57Obj(); - -public: - // Instance Data - char FeatureName[8]; - int Primitive_type; - - char *att_array; - wxArrayOfS57attVal *attVal; - int n_attr; - - int iOBJL; - int Index; - - double x; // for POINT - double y; - double z; - int npt; // number of points as needed by arrays - void *geoPt; // for LINE & AREA not described by PolyTessGeo - double *geoPtz; // an array[3] for MultiPoint, SM with Z, i.e. depth - double *geoPtMulti; // an array[2] for MultiPoint, lat/lon to make bbox - // of decomposed points - - void *pPolyTessGeo; - - double m_lat; // The lat/lon of the object's "reference" point - double m_lon; - - double chart_ref_lat; - double chart_ref_lon; - - double lat_min; - double lat_max; - double lon_min; - double lon_max; - - int Scamin; // SCAMIN attribute decoded during load - - bool bIsClone; - int nRef; // Reference counter, to signal OK for deletion - - bool bIsAton; // This object is an aid-to-navigation - bool bIsAssociable; // This object is DRGARE or DEPARE - - int m_n_lsindex; - int *m_lsindex_array; - int m_n_edge_max_points; - void *m_chart_context; - - PI_DisCat m_DisplayCat; - - void * S52_Context; - PI_S57Obj *child; // child list, used only for MultiPoint Soundings - - PI_S57Obj *next; // List linkage - - // This transform converts from object geometry - // to SM coordinates. - double x_rate; // These auxiliary transform coefficients are - double y_rate; // to be used in GetPointPix() and friends - double x_origin; // on a per-object basis if necessary - double y_origin; - - int auxParm0; // some per-object auxiliary parameters, used for OpenGL - int auxParm1; - int auxParm2; - int auxParm3; - - PI_line_segment_element *m_ls_list; - bool m_bcategory_mutable; - int m_DPRI; -}; - - - -wxString DECL_EXP PI_GetPLIBColorScheme(); -int DECL_EXP PI_GetPLIBDepthUnitInt(); -int DECL_EXP PI_GetPLIBSymbolStyle(); -int DECL_EXP PI_GetPLIBBoundaryStyle(); -int DECL_EXP PI_GetPLIBStateHash(); -double DECL_EXP PI_GetPLIBMarinerSafetyContour(); -bool DECL_EXP PI_GetObjectRenderBox( PI_S57Obj *pObj, double *lat_min, double *lat_max, double *lon_min, double *lon_max); -void DECL_EXP PI_UpdateContext(PI_S57Obj *pObj); - -bool DECL_EXP PI_PLIBObjectRenderCheck( PI_S57Obj *pObj, PlugIn_ViewPort *vp ); -PI_LUPname DECL_EXP PI_GetObjectLUPName( PI_S57Obj *pObj ); -PI_DisPrio DECL_EXP PI_GetObjectDisplayPriority( PI_S57Obj *pObj ); -PI_DisCat DECL_EXP PI_GetObjectDisplayCategory( PI_S57Obj *pObj ); -void DECL_EXP PI_PLIBSetLineFeaturePriority( PI_S57Obj *pObj, int prio ); -void DECL_EXP PI_PLIBPrepareForNewRender(void); -void DECL_EXP PI_PLIBFreeContext( void *pContext ); -void DECL_EXP PI_PLIBSetRenderCaps( unsigned int flags ); - -bool DECL_EXP PI_PLIBSetContext( PI_S57Obj *pObj ); - -int DECL_EXP PI_PLIBRenderObjectToDC( wxDC *pdc, PI_S57Obj *pObj, PlugIn_ViewPort *vp ); -int DECL_EXP PI_PLIBRenderAreaToDC( wxDC *pdc, PI_S57Obj *pObj, PlugIn_ViewPort *vp, wxRect rect, unsigned char *pixbuf ); - - -int DECL_EXP PI_PLIBRenderAreaToGL( const wxGLContext &glcc, PI_S57Obj *pObj, - PlugIn_ViewPort *vp, wxRect &render_rect ); - -int DECL_EXP PI_PLIBRenderObjectToGL( const wxGLContext &glcc, PI_S57Obj *pObj, - PlugIn_ViewPort *vp, wxRect &render_rect ); - -/* API 1.11 OpenGL Display List and vertex buffer object routines - - Effectively these two routines cancel each other so all - of the translation, scaling and rotation can be done by opengl. - - Display lists need only be built infrequently, but used in each frame - greatly accelerates the speed of rendering. This avoids costly calculations, - and also allows the vertexes to be stored in graphics memory. - - static int dl = 0; - glPushMatrix(); - PlugInMultMatrixViewport(current_viewport); - if(dl) - glCallList(dl); - else { - dl = glGenLists(1); - PlugInViewPort norm_viewport = current_viewport; - NormalizeViewPort(norm_viewport); - glNewList(dl, GL_COMPILE_AND_EXECUTE); - ... // use norm_viewport with GetCanvasLLPix here - glEndList(); - } - glPopMatrix(); - ... // use current_viewport with GetCanvasLLPix again -*/ - -extern DECL_EXP bool PlugInHasNormalizedViewPort ( PlugIn_ViewPort *vp ); -extern DECL_EXP void PlugInMultMatrixViewport ( PlugIn_ViewPort *vp, float lat=0, float lon=0 ); -extern DECL_EXP void PlugInNormalizeViewport ( PlugIn_ViewPort *vp, float lat=0, float lon=0 ); - -class wxPoint2DDouble; -extern "C" DECL_EXP void GetDoubleCanvasPixLL(PlugIn_ViewPort *vp, wxPoint2DDouble *pp, double lat, double lon); - -/* API 1.13 */ -/* API 1.13 adds some more common functions to avoid unnecessary code duplication */ - - -extern DECL_EXP double fromDMM_Plugin( wxString sdms ); -extern DECL_EXP void SetCanvasRotation(double rotation); -extern DECL_EXP void SetCanvasProjection(int projection); -extern DECL_EXP bool GetSingleWaypoint( wxString GUID, PlugIn_Waypoint *pwaypoint ); -extern DECL_EXP bool CheckEdgePan_PlugIn( int x, int y, bool dragging, int margin, int delta ); -extern DECL_EXP wxBitmap GetIcon_PlugIn(const wxString & name); -extern DECL_EXP void SetCursor_PlugIn( wxCursor *pPlugin_Cursor = NULL ); -extern DECL_EXP wxFont *GetOCPNScaledFont_PlugIn(wxString TextElement, int default_size = 0); -extern DECL_EXP wxFont GetOCPNGUIScaledFont_PlugIn(wxString item); -extern DECL_EXP double GetOCPNGUIToolScaleFactor_PlugIn(int GUIScaledFactor); -extern DECL_EXP double GetOCPNGUIToolScaleFactor_PlugIn(); -extern DECL_EXP float GetOCPNChartScaleFactor_Plugin(); -extern DECL_EXP wxColour GetFontColour_PlugIn(wxString TextElement); - -extern DECL_EXP double GetCanvasTilt(); -extern DECL_EXP void SetCanvasTilt(double tilt); - -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 wxString GetWritableDocumentsDir( void ); -extern DECL_EXP wxDialog *GetActiveOptionsDialog(); -extern DECL_EXP wxArrayString GetWaypointGUIDArray( void ); - -extern DECL_EXP bool AddPersistentFontKey(wxString TextElement); -extern DECL_EXP wxString GetActiveStyleName(); - -extern DECL_EXP wxBitmap GetBitmapFromSVGFile(wxString filename, unsigned int width, unsigned int height); -extern DECL_EXP bool IsTouchInterface_PlugIn(void); - -/* Platform optimized File/Dir selector dialogs */ -extern DECL_EXP int PlatformDirSelectorDialog( wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir); - -extern DECL_EXP int PlatformFileSelectorDialog( wxWindow *parent, wxString *file_spec, wxString Title, wxString initDir, - wxString suggestedName, wxString wildcard); - - -/* OpenCPN HTTP File Download PlugIn Interface */ - -/* Various method Return Codes, etc */ -typedef enum _OCPN_DLStatus{ - OCPN_DL_UNKNOWN =-1, - OCPN_DL_NO_ERROR = 0, - OCPN_DL_FAILED = 1, - OCPN_DL_ABORTED = 2, - OCPN_DL_USER_TIMEOUT = 4, - OCPN_DL_STARTED = 8 -}OCPN_DLStatus; - - -typedef enum _OCPN_DLCondition{ - OCPN_DL_EVENT_TYPE_UNKNOWN = -1, - OCPN_DL_EVENT_TYPE_START = 80, - OCPN_DL_EVENT_TYPE_PROGRESS = 81, - OCPN_DL_EVENT_TYPE_END = 82 -}OCPN_DLCondition; - -// Style definitions for Synchronous file download modal dialogs, if desired. -// Abstracted from wxCURL package -enum OCPN_DLDialogStyle -{ - OCPN_DLDS_ELAPSED_TIME = 0x0001, //!< The dialog shows the elapsed time. - OCPN_DLDS_ESTIMATED_TIME = 0x0002, //!< The dialog shows the estimated total time. - OCPN_DLDS_REMAINING_TIME = 0x0004, //!< The dialog shows the remaining time. - OCPN_DLDS_SPEED = 0x0008, //!< The dialog shows the transfer speed. - OCPN_DLDS_SIZE = 0x0010, //!< The dialog shows the size of the resource to download/upload. - OCPN_DLDS_URL = 0x0020, //!< The dialog shows the URL involved in the transfer. - - // styles related to the use of wxCurlConnectionSettingsDialog: - - OCPN_DLDS_CONN_SETTINGS_AUTH = 0x0040, //!< The dialog allows the user to change the authentication settings. - OCPN_DLDS_CONN_SETTINGS_PORT = 0x0080, //!< The dialog allows the user to change the port for the transfer. - OCPN_DLDS_CONN_SETTINGS_PROXY = 0x0100, //!< The dialog allows the user to change the proxy settings. - - OCPN_DLDS_CONN_SETTINGS_ALL = OCPN_DLDS_CONN_SETTINGS_AUTH|OCPN_DLDS_CONN_SETTINGS_PORT|OCPN_DLDS_CONN_SETTINGS_PROXY, - - OCPN_DLDS_SHOW_ALL =OCPN_DLDS_ELAPSED_TIME|OCPN_DLDS_ESTIMATED_TIME|OCPN_DLDS_REMAINING_TIME| - OCPN_DLDS_SPEED|OCPN_DLDS_SIZE|OCPN_DLDS_URL|OCPN_DLDS_CONN_SETTINGS_ALL, - - OCPN_DLDS_CAN_ABORT = 0x0200, //!< The transfer can be aborted by the user. - OCPN_DLDS_CAN_START = 0x0400, //!< The transfer won't start automatically. The user needs to start it. - OCPN_DLDS_CAN_PAUSE = 0x0800, //!< The transfer can be paused. - - OCPN_DLDS_AUTO_CLOSE = 0x1000, //!< The dialog auto closes when transfer is complete. - - // by default all available features are enabled: - OCPN_DLDS_DEFAULT_STYLE = OCPN_DLDS_CAN_START|OCPN_DLDS_CAN_PAUSE|OCPN_DLDS_CAN_ABORT|OCPN_DLDS_SHOW_ALL|OCPN_DLDS_AUTO_CLOSE -}; - -#define ONLINE_CHECK_RETRY 30 // Recheck the Internet connection availability every ONLINE_CHECK_RETRY s - -/* Synchronous (Blocking) download of a single file */ - -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); - - -/* Asynchronous (Background) download of a single file */ - -extern DECL_EXP _OCPN_DLStatus OCPN_downloadFileBackground( const wxString& url, const wxString &outputFile, - wxEvtHandler *handler, long *handle); - -extern DECL_EXP void OCPN_cancelDownloadFileBackground( long handle ); - -/* Synchronous (Blocking) HTTP POST operation for small amounts of data */ - -extern DECL_EXP _OCPN_DLStatus OCPN_postDataHttp( const wxString& url, const wxString& parameters, wxString& result, int timeout_secs ); - -/* Check whether connection to the Internet is working */ - -extern DECL_EXP bool OCPN_isOnline(); - -/* Supporting Event for Background downloading */ -/* OCPN_downloadEvent Definition */ - -/* PlugIn should be ready/able to handle this event after initiating a background file transfer - * - * The event as received should be parsed primarily by the getDLEventCondition() method. - * This will allow identification of download start, progress, and end states. - * - * Other accessor methods contain status, byte counts, etc. - * - * A PlugIn may safely destroy its EvtHandler after receipt of an OCPN_downloadEvent with - * getDLEventCondition == OCPN_DL_EVENT_TYPE_END - */ - -class DECL_EXP OCPN_downloadEvent: public wxEvent -{ -public: - OCPN_downloadEvent( wxEventType commandType = wxEVT_NULL, int id = 0 ); - ~OCPN_downloadEvent( ); - - // accessors - _OCPN_DLStatus getDLEventStatus(){ return m_stat; } - OCPN_DLCondition getDLEventCondition(){ return m_condition; } - - void setDLEventStatus( _OCPN_DLStatus stat ){ m_stat = stat; } - void setDLEventCondition( OCPN_DLCondition cond ){ m_condition = cond; } - - void setTotal( long bytes ){m_totalBytes = bytes; } - void setTransferred( long bytes ){m_sofarBytes = bytes; } - long getTotal(){ return m_totalBytes; } - long getTransferred(){ return m_sofarBytes; } - - void setComplete(bool b_complete){ m_b_complete = b_complete; } - bool getComplete(){ return m_b_complete; } - - - // required for sending with wxPostEvent() - wxEvent *Clone() const; - -private: - OCPN_DLStatus m_stat; - OCPN_DLCondition m_condition; - - long m_totalBytes; - long m_sofarBytes; - 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; - -#endif //_PLUGIN_H_ diff -Nru opencpn-plugin-iacfleet-0.9.0/src/TexFont.cpp opencpn-plugin-iacfleet-0.10.0/src/TexFont.cpp --- opencpn-plugin-iacfleet-0.9.0/src/TexFont.cpp 2016-09-21 20:55:12.000000000 +0000 +++ opencpn-plugin-iacfleet-0.10.0/src/TexFont.cpp 2018-02-02 14:45:41.000000000 +0000 @@ -25,36 +25,34 @@ #ifdef ocpnUSE_GL -#include #include #include +#include #include "TexFont.h" -void TexFont::Build( wxFont &font, bool blur, bool luminance ) -{ +void TexFont::Build(wxFont &font, bool blur, bool luminance) { /* avoid rebuilding if the parameters are the same */ - if(font == m_font && blur == m_blur) - return; - + if (font == m_font && blur == m_blur) return; + m_font = font; m_blur = blur; wxBitmap bmp(256, 256); wxMemoryDC dc(bmp); - dc.SetFont( font ); + dc.SetFont(font); int maxglyphw = 0, maxglyphh = 0; - for( int i = MIN_GLYPH; i < MAX_GLYPH; i++ ) { + for (int i = MIN_GLYPH; i < MAX_GLYPH; i++) { wxCoord gw, gh; wxString text; - if(i == DEGREE_GLYPH) - text = wxString::Format(_T("%c"), 0x00B0); //_T("°"); + if (i == DEGREE_GLYPH) + text = wxString::Format(_T("%c"), 0x00B0); //_T("°"); else text = wxString::Format(_T("%c"), i); wxCoord descent, exlead; - dc.GetTextExtent( text, &gw, &gh, &descent, &exlead, &font ); // measure the text + dc.GetTextExtent(text, &gw, &gh, &descent, &exlead, &font); // measure the text tgi[i].width = gw; tgi[i].height = gh; @@ -76,22 +74,24 @@ wxASSERT(w < 2048 && h < 2048); /* make power of 2 */ - for(tex_w = 1; tex_w < w; tex_w *= 2); - for(tex_h = 1; tex_h < h; tex_h *= 2); + for (tex_w = 1; tex_w < w; tex_w *= 2) + ; + for (tex_h = 1; tex_h < h; tex_h *= 2) + ; wxBitmap tbmp(tex_w, tex_h); dc.SelectObject(tbmp); /* fill bitmap with black */ - dc.SetBackground( wxBrush( wxColour( 0, 0, 0 ) ) ); + dc.SetBackground(wxBrush(wxColour(0, 0, 0))); dc.Clear(); - + /* draw the text white */ - dc.SetTextForeground( wxColour( 255, 255, 255 ) ); + dc.SetTextForeground(wxColour(255, 255, 255)); int row = 0, col = 0; - for( int i = MIN_GLYPH; i < MAX_GLYPH; i++ ) { - if(col == COLS_GLYPHS) { + for (int i = MIN_GLYPH; i < MAX_GLYPH; i++) { + if (col == COLS_GLYPHS) { col = 0; row++; } @@ -100,12 +100,12 @@ tgi[i].y = row * maxglyphh; wxString text; - if(i == DEGREE_GLYPH) - text = wxString::Format(_T("%c"), 0x00B0); //_T("°"); + if (i == DEGREE_GLYPH) + text = wxString::Format(_T("%c"), 0x00B0); //_T("°"); else text = wxString::Format(_T("%c"), i); - dc.DrawText(text, tgi[i].x, tgi[i].y ); + dc.DrawText(text, tgi[i].x, tgi[i].y); col++; } @@ -114,7 +114,7 @@ GLuint format, internalformat; int stride; - if(luminance) { + if (luminance) { format = GL_LUMINANCE_ALPHA; stride = 2; } else { @@ -124,134 +124,126 @@ internalformat = format; - if( m_blur ) - image = image.Blur(1); + if (m_blur) image = image.Blur(1); unsigned char *imgdata = image.GetData(); - unsigned char *teximage = (unsigned char *) malloc( stride * tex_w * tex_h ); + unsigned char *teximage = (unsigned char *)malloc(stride * tex_w * tex_h); - if(teximage && imgdata ){ - for( int j = 0; j < tex_w*tex_h; j++ ) - for( int k = 0; k < stride; k++ ) - teximage[j * stride + k] = imgdata[3*j]; + if (teximage && imgdata) { + for (int j = 0; j < tex_w * tex_h; j++) + for (int k = 0; k < stride; k++) teximage[j * stride + k] = imgdata[3 * j]; } - if(texobj) - Delete(); + if (texobj) Delete(); - glGenTextures( 1, &texobj ); - glBindTexture( GL_TEXTURE_2D, texobj ); + glGenTextures(1, &texobj); + glBindTexture(GL_TEXTURE_2D, texobj); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D( GL_TEXTURE_2D, 0, internalformat, tex_w, tex_h, 0, - format, GL_UNSIGNED_BYTE, teximage ); + glTexImage2D(GL_TEXTURE_2D, 0, internalformat, tex_w, tex_h, 0, format, GL_UNSIGNED_BYTE, teximage); free(teximage); } -void TexFont::Delete( ) -{ +void TexFont::Delete() { glDeleteTextures(1, &texobj); texobj = 0; } -void TexFont::GetTextExtent(const wxString &string, int *width, int *height) -{ - int w=0, h=0; +void TexFont::GetTextExtent(const wxString &string, int *width, int *height) { + int w = 0, h = 0; - for(unsigned int i = 0; i < string.size(); i++ ) { + for (unsigned int i = 0; i < string.size(); i++) { wchar_t c = string[i]; - if(c == '\n') { + if (c == '\n') { h += tgi[(int)'A'].height; continue; } - if(c == 0x00B0) - c = DEGREE_GLYPH; + if (c == 0x00B0) c = DEGREE_GLYPH; - if( c < MIN_GLYPH || c >= MAX_GLYPH) { + if (c < MIN_GLYPH || c >= MAX_GLYPH) { // outside font wxMemoryDC dc; - dc.SetFont( m_font ); + dc.SetFont(m_font); wxCoord gw, gh; - dc.GetTextExtent( c, &gw, &gh ); // measure the text + dc.GetTextExtent(c, &gw, &gh); // measure the text w += gw; - if(h > gh) - gh = h; + if (h > gh) gh = h; continue; } TexGlyphInfo &tgisi = tgi[c]; w += tgisi.advance; - if(tgisi.height > h) - h = tgisi.height; + if (tgisi.height > h) h = tgisi.height; } - if(width) *width = w; - if(height) *height = h; + if (width) *width = w; + if (height) *height = h; } -void TexFont::RenderGlyph( wchar_t c ) -{ +void TexFont::RenderGlyph(wchar_t c) { /* degree symbol */ - if(c == 0x00B0) + if (c == 0x00B0) c = DEGREE_GLYPH; - else - if( c < MIN_GLYPH || c >= MAX_GLYPH) { + else if (c < MIN_GLYPH || c >= MAX_GLYPH) { // outside font, render with draw pixels (slow) wxMemoryDC dc; - dc.SetFont( m_font ); + dc.SetFont(m_font); wxCoord gw, gh; - dc.GetTextExtent( c, &gw, &gh ); // measure the text + dc.GetTextExtent(c, &gw, &gh); // measure the text wxBitmap bmp(gw, gh); dc.SelectObject(bmp); - dc.SetBackground( wxBrush( wxColour( 0, 0, 0 ) ) ); + dc.SetBackground(wxBrush(wxColour(0, 0, 0))); dc.Clear(); /* draw the text white */ - dc.SetTextForeground( wxColour( 255, 255, 255 ) ); + dc.SetTextForeground(wxColour(255, 255, 255)); dc.DrawText(c, 0, 0); wxImage image = bmp.ConvertToImage(); - if( m_blur ) - image = image.Blur(1); + if (m_blur) image = image.Blur(1); unsigned char *imgdata = image.GetData(); - char *data = new char[gw*gh*2]; - - if(data && imgdata ){ - for(int i=0; i> ~/.bash_profile; fi script: - mkdir -p build - cd build @@ -20,15 +29,15 @@ global: # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created # via the "travis encrypt" command using the project repo's public key - - secure: "TM0wWPKq1QoV5IsY+LLVvA6T04EOhduyO8d+7k+qkLb+PRG9Pjs01bzwsiQQs2Bk08KsnZkSdgAzMTv+EETH+1ptHjW0QGBHO1EfYUw9ZkLaJl+HRiTkVozUAfltTlrOeUgsWNX4e59Id8iMB00htOSmBim4CgcaFaSfmRGCto0=" + - secure: "gzuRKPoISDCbjfRdI+KS0H3/9T4CDLybTxLwirUJ660IaFTewNYXj/pyOJOr7miOrBmQaJQw7aKAG4fpfbHpY0kkLQe2JHaJv84uyuev4QuJGtfyim3a2U4FbxtCyyjREyGI15enBra3N1xKtQqNbnkgOCKPtWSAlX4rf1elj5A=" -#addons: -# coverity_scan: -# project: -# name: "nohal/iacfleet_pi" -# description: "Build submitted via Travis CI" -# notification_email: pavel@kalian.cz -# build_command_prepend: "mkdir -p build; cd build; cmake .." -# build_command: "make -j 4" -# branch_pattern: coverity_scan -# build_script_url: "https://raw.githubusercontent.com/nohal/objsearch_pi/master/scan_script.sh" +addons: + coverity_scan: + project: + name: "nohal/iacfleet_pi" + description: "Build submitted via Travis CI" + notification_email: pavel@kalian.cz + build_command_prepend: "mkdir -p build; cd build; cmake ..; make clean" + build_command: "make" + branch_pattern: coverity_scan +# build_script_url: "https://raw.githubusercontent.com/nohal/iacfleet_pi/master/scan_script.sh"