diff -Nru opencpn-plugin-iacfleet-0.10.0/appveyor.yml opencpn-plugin-iacfleet-0.20/appveyor.yml --- opencpn-plugin-iacfleet-0.10.0/appveyor.yml 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/appveyor.yml 2019-03-14 00:47:06.000000000 +0000 @@ -1,9 +1,9 @@ version: 0.9.{build} -clone_folder: c:\projects\iacfleet_pi +clone_folder: c:\project\iacfleet_pi shallow_clone: true image: -- Visual Studio 2015 +- Visual Studio 2017 platform: - Win32 @@ -12,40 +12,34 @@ test: OFF install: - - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x86' + - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat" # sent environment variables for wxWidgets - - set WXPARENT=C:\ - - set WXWIN=C:\wxWidgets-3.0.2 + - set WXWIN=C:\wxWidgets-3.1.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 + - choco install poedit + + - ps: Start-FileDownload http://opencpn.navnux.org/build_deps/nsis-3.04-setup.exe + - cmd: nsis-3.04-setup.exe /S # 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_ + - ps: Start-FileDownload http://opencpn.navnux.org/build_deps/wxWidgets-3.1.2.7z + - cmd: 7z x wxWidgets-3.1.2.7z -o%WXWIN% > null + + #- set #Use only while debugging - it reveals the deploy token set on Appveyor before_build: - - cd c:\projects\iacfleet_pi + - cd c:\project\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 .. + - ps: Start-FileDownload https://downloads.sourceforge.net/project/opencpnplugins/opencpn_lib/4.99.1405-vc141_xp/opencpn.lib + - ps: Start-FileDownload http://opencpn.navnux.org/build_deps/OpenCPN_buildwin-4.99a.7z + - cmd: 7z x -y OpenCPN_buildwin-4.99a.7z -oc:\project\iacfleet_pi\buildwin + - cmake -T v141_xp .. build_script: - cmake --build . --config Release --target package @@ -54,3 +48,13 @@ - path: build\iacfleet_pi*.exe name: installer +deploy: + description: 'release created by AppVeyor CI' + provider: GitHub + auth_token: '%GitHub_auth_token%' + artifact: installer,portable + draft: true + prerelease: true + on: + appveyor_repo_tag: true # deploy on tag push only + configuration: Release # Debug contains non-redist MS DLLs diff -Nru opencpn-plugin-iacfleet-0.10.0/buildosx/InstallOSX/iacfleet_pi.pkgproj.in opencpn-plugin-iacfleet-0.20/buildosx/InstallOSX/iacfleet_pi.pkgproj.in --- opencpn-plugin-iacfleet-0.10.0/buildosx/InstallOSX/iacfleet_pi.pkgproj.in 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/buildosx/InstallOSX/iacfleet_pi.pkgproj.in 2019-03-14 00:47:06.000000000 +0000 @@ -62,7 +62,7 @@ GID 80 PATH - Plugins + PlugIns PATH_TYPE 0 PERMISSIONS @@ -131,7 +131,7 @@ GID 80 PATH - plugins + PlugIns PATH_TYPE 0 PERMISSIONS @@ -1334,7 +1334,7 @@ NAME - ${VERBOSE_NAME}-Plugin_${VERSION_MAJOR}.${VERSION_MINOR} + ${VERBOSE_NAME}-Plugin-${NAME_SUFFIX}_${VERSION_MAJOR}.${VERSION_MINOR} REFERENCE_FOLDER_PATH . Binary files /tmp/tmpLCkvBH/omEq5NEsXA/opencpn-plugin-iacfleet-0.10.0/buildosx/InstallOSX/pkg_background.jpg and /tmp/tmpLCkvBH/lXYeT6oC9d/opencpn-plugin-iacfleet-0.20/buildosx/InstallOSX/pkg_background.jpg differ diff -Nru opencpn-plugin-iacfleet-0.10.0/.circleci/config.yml opencpn-plugin-iacfleet-0.20/.circleci/config.yml --- opencpn-plugin-iacfleet-0.10.0/.circleci/config.yml 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/.circleci/config.yml 2019-03-14 00:47:06.000000000 +0000 @@ -0,0 +1,14 @@ +version: 2.0 +jobs: + build: + docker: + - image: nohal/opencpn-builder + builder environment: + OCPN_CI_BUILD: yes + branches: + only: + - master + steps: + - run: git clone --depth=10 "https://github.com/nohal/iacfleet_pi.git" work + - run: mkdir work/build + - run: cd work/build; cmake ..; make diff -Nru opencpn-plugin-iacfleet-0.10.0/.clang-tidy opencpn-plugin-iacfleet-0.20/.clang-tidy --- opencpn-plugin-iacfleet-0.10.0/.clang-tidy 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/.clang-tidy 2019-03-14 00:47:06.000000000 +0000 @@ -0,0 +1,8 @@ +--- +Checks: 'readability-redundant-string-cstr,modernize-use-override,readability-implicit-bool-conversion,modernize-deprecated-headers,readability-delete-null-pointer,modernize-redundant-void-arg,google-readability-redundant-smartptr-get,hicpp-move-const-arg,readability-redundant-member-init' +WarningsAsErrors: 'readability-redundant-string-cstr,modernize-use-override,readability-implicit-bool-conversion,modernize-deprecated-headers,readability-delete-null-pointer,modernize-redundant-void-arg,google-readability-redundant-smartptr-get,hicpp-move-const-arg,clang-analyzer-core.CallAndMessage' +CheckOptions: + - key: readability-implicit-bool-conversion.AllowPointerConditions + value: '1' + - key: readability-implicit-bool-conversion.AllowIntegerConditions + value: '1' diff -Nru opencpn-plugin-iacfleet-0.10.0/cmake/PluginPackage.cmake opencpn-plugin-iacfleet-0.20/cmake/PluginPackage.cmake --- opencpn-plugin-iacfleet-0.10.0/cmake/PluginPackage.cmake 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/cmake/PluginPackage.cmake 2019-03-14 00:47:06.000000000 +0000 @@ -6,11 +6,14 @@ # 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") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_NAME} ${PACKAGE_VERSION}) -SET(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION}) +SET(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION}-${NAME_SUFFIX}) SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) @@ -37,6 +40,8 @@ # SET(CPACK_NSIS_INSTALLED_ICON_NAME "${PACKAGE_NAME}") SET(CPACK_NSIS_DISPLAY_NAME "OpenCPN ${PACKAGE_NAME}") +# SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}_${VERSION_MAJOR}.${VERSION_MINOR}_setup" ) + SET(CPACK_NSIS_DIR "${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode") #Gunther SET(CPACK_BUILDWIN_DIR "${PROJECT_SOURCE_DIR}/buildwin") #Gunther @@ -185,13 +190,13 @@ SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${VERSION_MAJOR}.${VERSION_MINOR}-win32.exe" ) MESSAGE(STATUS "FILE: ${CPACK_PACKAGE_FILE_NAME}") add_custom_command(OUTPUT ${CPACK_PACKAGE_FILE_NAME} - COMMAND signtool sign /v /f \\cert\\OpenCPNSPC.pfx /d http://www.opencpn.org /t http://timestamp.verisign.com/scripts/timstamp.dll ${CPACK_PACKAGE_FILE_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${PACKAGE_NAME} - COMMENT "Code-Signing: ${CPACK_PACKAGE_FILE_NAME}") + COMMAND signtool sign /v /f \\cert\\OpenCPNSPC.pfx /d http://www.opencpn.org /t http://timestamp.verisign.com/scripts/timstamp.dll ${CPACK_PACKAGE_FILE_NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${PACKAGE_NAME} + COMMENT "Code-Signing: ${CPACK_PACKAGE_FILE_NAME}") ADD_CUSTOM_TARGET(codesign COMMENT "code signing: Done." DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME} ) ENDIF(WIN32) -ENDIF(NOT STANDALONE MATCHES "BUNDLED") +ENDIF(NOT STANDALONE MATCHES "BUNDLED") diff -Nru opencpn-plugin-iacfleet-0.10.0/CMakeLists.txt opencpn-plugin-iacfleet-0.20/CMakeLists.txt --- opencpn-plugin-iacfleet-0.10.0/CMakeLists.txt 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/CMakeLists.txt 2019-03-14 00:47:06.000000000 +0000 @@ -15,11 +15,15 @@ SET(CPACK_PACKAGE_CONTACT "Pavel Kalian") SET(VERSION_MAJOR "0") -SET(VERSION_MINOR "10") +SET(VERSION_MINOR "21") + +SET(NAME_SUFFIX "ov50") #SET(CMAKE_BUILD_TYPE Debug) SET(CMAKE_MACOSX_RPATH "ON") +set (CMAKE_CXX_STANDARD 11) + # Definitions add_definitions ( -D_FILE_OFFSET_BITS=64 diff -Nru opencpn-plugin-iacfleet-0.10.0/data/iacfleet_pi_rollover.svg opencpn-plugin-iacfleet-0.20/data/iacfleet_pi_rollover.svg --- opencpn-plugin-iacfleet-0.10.0/data/iacfleet_pi_rollover.svg 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/data/iacfleet_pi_rollover.svg 2019-03-14 00:47:06.000000000 +0000 @@ -1,202 +1 @@ - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff -Nru opencpn-plugin-iacfleet-0.10.0/data/iacfleet_pi.svg opencpn-plugin-iacfleet-0.20/data/iacfleet_pi.svg --- opencpn-plugin-iacfleet-0.10.0/data/iacfleet_pi.svg 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/data/iacfleet_pi.svg 2019-03-14 00:47:06.000000000 +0000 @@ -1,226 +1 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff -Nru opencpn-plugin-iacfleet-0.10.0/data/iacfleet_pi_toggled.svg opencpn-plugin-iacfleet-0.20/data/iacfleet_pi_toggled.svg --- opencpn-plugin-iacfleet-0.10.0/data/iacfleet_pi_toggled.svg 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/data/iacfleet_pi_toggled.svg 2019-03-14 00:47:06.000000000 +0000 @@ -1,179 +1 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff -Nru opencpn-plugin-iacfleet-0.10.0/debian/changelog opencpn-plugin-iacfleet-0.20/debian/changelog --- opencpn-plugin-iacfleet-0.10.0/debian/changelog 2018-02-02 15:08:22.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/debian/changelog 2019-03-14 00:47:06.000000000 +0000 @@ -1,330 +1,11 @@ -opencpn-plugin-iacfleet (0.10.0-0~xenial1) xenial; urgency=low +opencpn-plugin-iacfleet (0.20-0~201903130124~ubuntu16.04.1) xenial; urgency=low - * Version 0.10 + * Auto build. - -- Pavel Kalian Fri, 02 Feb 2018 09:07:28 -0600 -opencpn-plugin-iacfleet (0.10.0-0~artful1) artful; urgency=low + -- Pavel Kalian Thu, 14 Mar 2019 00:47:06 +0000 - * Version 0.10 +opencpn-plugin-iacfleet (0.20-1) unstable; urgency=medium - -- Pavel Kalian Fri, 02 Feb 2018 09:07:28 -0600 -opencpn-plugin-iacfleet (0.10.0-0~bionic1) bionic; urgency=low + * Initial release for O5 using CI - * 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 - - -- Pavel Kalian Wed, 21 Sep 2016 16:14:51 -0500 -opencpn-plugin-iacfleet (0.9.0-0~yakkety1) yakkety; urgency=low - - * Version 0.9 - - -- Pavel Kalian Wed, 21 Sep 2016 16:14:51 -0500 -opencpn-plugin-iacfleet (0.8.0-0~precise1) precise; urgency=low - - * Version 0.8 - - -- Pavel Kalian Wed, 24 Feb 2016 16:13:22 -0600 -opencpn-plugin-iacfleet (0.8.0-0~trusty1) trusty; urgency=low - - * Version 0.8 - - -- Pavel Kalian Wed, 24 Feb 2016 16:13:22 -0600 -opencpn-plugin-iacfleet (0.8.0-0~vivid1) vivid; urgency=low - - * Version 0.8 - - -- Pavel Kalian Wed, 24 Feb 2016 16:13:22 -0600 -opencpn-plugin-iacfleet (0.8.0-0~wily1) wily; urgency=low - - * Version 0.8 - - -- Pavel Kalian Wed, 24 Feb 2016 16:13:22 -0600 -opencpn-plugin-iacfleet (0.8.0-0~xenial1) xenial; urgency=low - - * Version 0.8 - - -- Pavel Kalian Wed, 24 Feb 2016 16:13:22 -0600 -opencpn-plugin-iacfleet (0.7.0-0~precise1) precise; urgency=low - - * Version 0.7 - - -- Pavel Kalian Thu, 04 Jun 2015 12:48:01 -0500 -opencpn-plugin-iacfleet (0.7.0-0~trusty1) trusty; urgency=low - - * Version 0.7 - - -- Pavel Kalian Thu, 04 Jun 2015 12:48:01 -0500 -opencpn-plugin-iacfleet (0.7.0-0~utopic1) utopic; urgency=low - - * Version 0.7 - - -- Pavel Kalian Thu, 04 Jun 2015 12:48:01 -0500 -opencpn-plugin-iacfleet (0.7.0-0~vivid1) vivid; urgency=low - - * Version 0.7 - - -- Pavel Kalian Thu, 04 Jun 2015 12:48:01 -0500 -opencpn-plugin-iacfleet (0.7.0-0~wily1) wily; urgency=low - - * Version 0.7 - - -- Pavel Kalian Thu, 04 Jun 2015 12:48:01 -0500 -opencpn-plugin-iacfleet (0.6.0-0~precise1) precise; urgency=low - - * Version 0.6 - - -- Pavel Kalian Fri, 08 May 2015 10:28:45 -0500 -opencpn-plugin-iacfleet (0.6.0-0~trusty1) trusty; urgency=low - - * Version 0.6 - - -- Pavel Kalian Fri, 08 May 2015 10:28:45 -0500 -opencpn-plugin-iacfleet (0.6.0-0~utopic1) utopic; urgency=low - - * Version 0.6 - - -- Pavel Kalian Fri, 08 May 2015 10:28:45 -0500 -opencpn-plugin-iacfleet (0.6.0-0~vivid1) vivid; urgency=low - - * Version 0.6 - - -- Pavel Kalian Fri, 08 May 2015 10:28:45 -0500 -opencpn-plugin-iacfleet (0.6.0-0~wily1) wily; urgency=low - - * Version 0.6 - - -- Pavel Kalian Fri, 08 May 2015 10:28:45 -0500 -opencpn-plugin-iacfleet (0.5.0-0~precise1) precise; urgency=low - - * Version 0.5 - - -- Pavel Kalian Sat, 02 May 2015 14:54:50 -0500 -opencpn-plugin-iacfleet (0.5.0-0~trusty1) trusty; urgency=low - - * Version 0.5 - - -- Pavel Kalian Sat, 02 May 2015 14:54:50 -0500 -opencpn-plugin-iacfleet (0.5.0-0~utopic1) utopic; urgency=low - - * Version 0.5 - - -- Pavel Kalian Sat, 02 May 2015 14:54:50 -0500 -opencpn-plugin-iacfleet (0.5.0-0~vivid1) vivid; urgency=low - - * Version 0.5 - - -- Pavel Kalian Sat, 02 May 2015 14:54:50 -0500 -opencpn-plugin-iacfleet (0.4.2-0~precise1) precise; urgency=low - - * Version 0.4.2 - - -- Pavel Kalian Fri, 01 May 2015 23:54:05 -0500 -opencpn-plugin-iacfleet (0.4.2-0~trusty1) trusty; urgency=low - - * Version 0.4.2 - - -- Pavel Kalian Fri, 01 May 2015 23:54:05 -0500 -opencpn-plugin-iacfleet (0.4.2-0~utopic1) utopic; urgency=low - - * Version 0.4.2 - - -- Pavel Kalian Fri, 01 May 2015 23:54:05 -0500 -opencpn-plugin-iacfleet (0.4.2-0~vivid1) vivid; urgency=low - - * Version 0.4.2 - - -- Pavel Kalian Fri, 01 May 2015 23:54:05 -0500 -opencpn-plugin-iacfleet (0.4.1-0~precise1) precise; urgency=low - - * Version 0.4.1 - - -- Pavel Kalian Fri, 01 May 2015 23:49:26 -0500 -opencpn-plugin-iacfleet (0.4.1-0~trusty1) trusty; urgency=low - - * Version 0.4.1 - - -- Pavel Kalian Fri, 01 May 2015 23:49:26 -0500 -opencpn-plugin-iacfleet (0.4.1-0~utopic1) utopic; urgency=low - - * Version 0.4.1 - - -- Pavel Kalian Fri, 01 May 2015 23:49:26 -0500 -opencpn-plugin-iacfleet (0.4.1-0~vivid1) vivid; urgency=low - - * Version 0.4.1 - - -- Pavel Kalian Fri, 01 May 2015 23:49:26 -0500 -opencpn-plugin-iacfleet (0.4.0-0~lucid1) lucid; urgency=low - - * Version 0.4 - - -- Pavel Kalian Fri, 01 May 2015 23:04:51 -0500 -opencpn-plugin-iacfleet (0.4.0-0~precise1) precise; urgency=low - - * Version 0.4 - - -- Pavel Kalian Fri, 01 May 2015 23:04:51 -0500 -opencpn-plugin-iacfleet (0.4.0-0~trusty1) trusty; urgency=low - - * Version 0.4 - - -- Pavel Kalian Fri, 01 May 2015 23:04:51 -0500 -opencpn-plugin-iacfleet (0.4.0-0~utopic1) utopic; urgency=low - - * Version 0.4 - - -- Pavel Kalian Fri, 01 May 2015 23:04:51 -0500 -opencpn-plugin-iacfleet (0.4.0-0~vivid1) vivid; urgency=low - - * Version 0.4 - - -- Pavel Kalian Fri, 01 May 2015 23:04:51 -0500 -opencpn-plugin-iacfleet (0.3.0-0~lucid1) lucid; urgency=low - - * Version 0.3 - - -- Pavel Kalian Sun, 26 Apr 2015 19:34:52 -0500 -opencpn-plugin-iacfleet (0.3.0-0~precise1) precise; urgency=low - - * Version 0.3 - - -- Pavel Kalian Sun, 26 Apr 2015 19:34:52 -0500 -opencpn-plugin-iacfleet (0.3.0-0~trusty1) trusty; urgency=low - - * Version 0.3 - - -- Pavel Kalian Sun, 26 Apr 2015 19:34:52 -0500 -opencpn-plugin-iacfleet (0.3.0-0~utopic1) utopic; urgency=low - - * Version 0.3 - - -- Pavel Kalian Sun, 26 Apr 2015 19:34:52 -0500 -opencpn-plugin-iacfleet (0.3.0-0~vivid1) vivid; urgency=low - - * Version 0.3 - - -- Pavel Kalian Sun, 26 Apr 2015 19:34:52 -0500 -opencpn-plugin-iacfleet (0.2.1-0~lucid1) lucid; urgency=low - - * Version 0.2.1 - - -- Pavel Kalian Sat, 25 Apr 2015 13:53:50 -0500 -opencpn-plugin-iacfleet (0.2.1-0~precise1) precise; urgency=low - - * Version 0.2.1 - - -- Pavel Kalian Sat, 25 Apr 2015 13:53:50 -0500 -opencpn-plugin-iacfleet (0.2.1-0~trusty1) trusty; urgency=low - - * Version 0.2.1 - - -- Pavel Kalian Sat, 25 Apr 2015 13:53:50 -0500 -opencpn-plugin-iacfleet (0.2.1-0~utopic1) utopic; urgency=low - - * Version 0.2.1 - - -- Pavel Kalian Sat, 25 Apr 2015 13:53:50 -0500 -opencpn-plugin-iacfleet (0.2.1-0~vivid1) vivid; urgency=low - - * Version 0.2.1 - - -- Pavel Kalian Sat, 25 Apr 2015 13:53:50 -0500 -opencpn-plugin-iacfleet (0.2.0-0~lucid1) lucid; urgency=low - - * Version 0.2 - - -- Pavel Kalian Sat, 25 Apr 2015 13:38:34 -0500 -opencpn-plugin-iacfleet (0.2.0-0~precise1) precise; urgency=low - - * Version 0.2 - - -- Pavel Kalian Sat, 25 Apr 2015 13:38:34 -0500 -opencpn-plugin-iacfleet (0.2.0-0~trusty1) trusty; urgency=low - - * Version 0.2 - - -- Pavel Kalian Sat, 25 Apr 2015 13:38:34 -0500 -opencpn-plugin-iacfleet (0.2.0-0~utopic1) utopic; urgency=low - - * Version 0.2 - - -- Pavel Kalian Sat, 25 Apr 2015 13:38:34 -0500 -opencpn-plugin-iacfleet (0.2.0-0~vivid1) vivid; urgency=low - - * Version 0.2 - - -- Pavel Kalian Sat, 25 Apr 2015 13:38:34 -0500 -opencpn-plugin-iacfleet (0.1.1-0~lucid1) lucid; urgency=low - - * Version 0.1.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:35:08 -0500 -opencpn-plugin-iacfleet (0.1.1-0~precise1) precise; urgency=low - - * Version 0.1.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:35:08 -0500 -opencpn-plugin-iacfleet (0.1.1-0~trusty1) trusty; urgency=low - - * Version 0.1.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:35:08 -0500 -opencpn-plugin-iacfleet (0.1.1-0~utopic1) utopic; urgency=low - - * Version 0.1.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:35:08 -0500 -opencpn-plugin-iacfleet (0.1.1-0~vivid1) vivid; urgency=low - - * Version 0.1.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:35:08 -0500 -opencpn-plugin-iacfleet (0.1.0-0~lucid1) lucid; urgency=low - - * Version 0.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:07:07 -0500 -opencpn-plugin-iacfleet (0.1.0-0~precise1) precise; urgency=low - - * Version 0.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:07:07 -0500 -opencpn-plugin-iacfleet (0.1.0-0~trusty1) trusty; urgency=low - - * Version 0.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:07:07 -0500 -opencpn-plugin-iacfleet (0.1.0-0~utopic1) utopic; urgency=low - - * Version 0.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:07:07 -0500 -opencpn-plugin-iacfleet (0.1.0-0~vivid1) vivid; urgency=low - - * Version 0.1 - - -- Pavel Kalian Fri, 24 Apr 2015 20:07:07 -0500 + -- Pavel Kalian Tue, 12 Mar 2019 09:01:17 -0300 diff -Nru opencpn-plugin-iacfleet-0.10.0/debian/compat opencpn-plugin-iacfleet-0.20/debian/compat --- opencpn-plugin-iacfleet-0.10.0/debian/compat 2018-02-02 15:07:31.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/debian/compat 2019-03-14 00:47:06.000000000 +0000 @@ -1 +1 @@ -8 +9 diff -Nru opencpn-plugin-iacfleet-0.10.0/debian/control opencpn-plugin-iacfleet-0.20/debian/control --- opencpn-plugin-iacfleet-0.10.0/debian/control 2018-02-02 15:08:22.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/debian/control 2019-03-14 00:47:06.000000000 +0000 @@ -1,15 +1,15 @@ Source: opencpn-plugin-iacfleet Section: misc -Priority: extra +Priority: optional Maintainer: Pavel Kalian -Build-Depends: debhelper (>= 8.0.0), cmake, cdbs, libgtk2.0-dev, gettext, gpsd, gpsd-clients, libgps-dev, wx-common, libwxgtk3.0-dev, libglu1-mesa-dev, libgtk2.0-dev, wx3.0-headers, libbz2-dev, libtinyxml-dev, libsdl1.2debian, libportaudio2, portaudio19-dev -Standards-Version: 3.9.3 -Homepage: http://www.opencpn.org -#Vcs-Git: git://git.debian.org/collab-maint/opencpn.git -#Vcs-Browser: http://git.debian.org/?p=collab-maint/opencpn.git;a=summary +Build-Depends: debhelper (>= 9), cmake, gettext, git-core, gpsd, gpsd-clients, libgps-dev, wx-common, libwxgtk3.0-dev, libglu1-mesa-dev, libgtk2.0-dev, wx3.0-headers, libbz2-dev, libtinyxml-dev, libportaudio2, portaudio19-dev, libcurl4-openssl-dev, libexpat1-dev, libcairo2-dev, libarchive-dev, liblzma-dev, libexif-dev, libelf-dev, libsqlite3-dev +Standards-Version: 4.1.2 +Homepage: https://github.com/nohal/iacfleet_pi +#Vcs-Git: https://anonscm.debian.org/git/collab-maint/opencpn-plugin-iacfleet.git +#Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/opencpn-plugin-iacfleet.git Package: opencpn-plugin-iacfleet Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, wx3.0-i18n, opencpn (>= 4.1.0) -Description: Plugin for OpenCPN - OpenCPN is a free software (GPLv2) project to create a concise chartplotter and navigation software for use as an underway or planning tool. OpenCPN is developed by a team of active sailors using real world conditions for program testing and refinement. +Depends: ${misc:Depends}, ${shlibs:Depends}, opencpn (>= 4.99.0) +Description: IAC Fleetcode plugin for OpenCPN + Allows graphical display of IAC Fleetcode messages as chart overlay. diff -Nru opencpn-plugin-iacfleet-0.10.0/debian/copyright opencpn-plugin-iacfleet-0.20/debian/copyright --- opencpn-plugin-iacfleet-0.10.0/debian/copyright 2018-02-02 15:08:22.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/debian/copyright 2019-03-14 00:47:06.000000000 +0000 @@ -1,29 +1,16 @@ -Format: http://dep.debian.net/deps/dep5 +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: opencpn-plugin-iacfleet -Source: +Source: https://github.com/nohal/iacfleet_pi Files: * -Copyright: Pavel Kalian -License: GPL-2+ - This package 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 package 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, see - . - On Debian systems, the complete text of the GNU General - Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". +Copyright: 2010 Carsten Borchardt , 2015-2019 Pavel Kalian +License: GPL-2.0+ Files: debian/* -Copyright: 2012 Pavel Kalian -License: GPL-2+ +Copyright: 2019 Pavel Kalian +License: GPL-2.0+ + +License: GPL-2.0+ This package 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 @@ -35,7 +22,7 @@ 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, see + along with this program. If not, see . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". diff -Nru opencpn-plugin-iacfleet-0.10.0/debian/git-build-recipe.manifest opencpn-plugin-iacfleet-0.20/debian/git-build-recipe.manifest --- opencpn-plugin-iacfleet-0.10.0/debian/git-build-recipe.manifest 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/debian/git-build-recipe.manifest 2019-03-14 00:47:06.000000000 +0000 @@ -0,0 +1,2 @@ +# git-build-recipe format 0.4 deb-version {debupstream}-0~201903130124 +lp:~nohal/iacfleet-pi/+git/master git-commit:9c7d1389fd9acc73fd7d154aff1f0d401ccc5ca2 diff -Nru opencpn-plugin-iacfleet-0.10.0/debian/rules opencpn-plugin-iacfleet-0.20/debian/rules --- opencpn-plugin-iacfleet-0.10.0/debian/rules 2018-02-02 15:07:31.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/debian/rules 2019-03-14 00:47:06.000000000 +0000 @@ -1,19 +1,5 @@ #!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 +%: + dh $@ --buildsystem=cmake -#Don't touch the SVG files otherwise cairo is not able to render them... -DEB_DH_SCOUR_ARGS += -Xsvg - -include /usr/share/cdbs/1/rules/debhelper.mk -include /usr/share/cdbs/1/class/cmake.mk - -#%: -# dh $@ diff -Nru opencpn-plugin-iacfleet-0.10.0/debian/source/format opencpn-plugin-iacfleet-0.20/debian/source/format --- opencpn-plugin-iacfleet-0.10.0/debian/source/format 2018-02-02 15:07:31.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/debian/source/format 2019-03-14 00:47:06.000000000 +0000 @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) diff -Nru opencpn-plugin-iacfleet-0.10.0/.github/ISSUE_TEMPLATE/bug_report.md opencpn-plugin-iacfleet-0.20/.github/ISSUE_TEMPLATE/bug_report.md --- opencpn-plugin-iacfleet-0.10.0/.github/ISSUE_TEMPLATE/bug_report.md 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/.github/ISSUE_TEMPLATE/bug_report.md 2019-03-14 00:47:06.000000000 +0000 @@ -0,0 +1,33 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the issue is. Only one issue. If you have found several problems, create a separate report for each. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - Device: [desktop, RPi3, Asus Zenbook - Intel Iris 600] + - OS: [e.g. Rasbian/RPi, Ubuntu, Windows 10, macOS] + - Version: [eg. 1.1] + - OpenCPN version: [e.g. 4.8.8, OpenCPN_4.99.1408+731e3e8] + +**Additional context** +Add any other context about the problem here. diff -Nru opencpn-plugin-iacfleet-0.10.0/.github/ISSUE_TEMPLATE/feature_request.md opencpn-plugin-iacfleet-0.20/.github/ISSUE_TEMPLATE/feature_request.md --- opencpn-plugin-iacfleet-0.10.0/.github/ISSUE_TEMPLATE/feature_request.md 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/.github/ISSUE_TEMPLATE/feature_request.md 2019-03-14 00:47:06.000000000 +0000 @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff -Nru opencpn-plugin-iacfleet-0.10.0/include/ocpn_plugin.h opencpn-plugin-iacfleet-0.20/include/ocpn_plugin.h --- opencpn-plugin-iacfleet-0.10.0/include/ocpn_plugin.h 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/include/ocpn_plugin.h 2019-03-14 00:47:06.000000000 +0000 @@ -28,20 +28,28 @@ #ifndef DECL_EXP #ifdef __WXMSW__ -# define DECL_EXP __declspec(dllexport) +#define DECL_EXP __declspec(dllexport) #else -# ifdef __GNUC__ -# define DECL_EXP __attribute__((visibility("default"))) -# endif +#ifdef __GNUC__ +#define DECL_EXP __attribute__((visibility("default"))) +#endif #endif #endif +#ifdef __WXMSW__ +#ifdef MAKING_PLUGIN +#define DECL_IMP __declspec(dllimport) +#endif +#endif #include #ifdef ocpnUSE_SVG -#include "wxsvg/include/wxSVG/svg.h" -#endif // ocpnUSE_SVG +#include "wxSVG/svg.h" +#endif // ocpnUSE_SVG + +#include +#include class wxGLContext; @@ -49,308 +57,286 @@ // It is expected that the API will remain downward compatible, meaning that // PlugIns conforming to API Version less then the most modern will also // be correctly supported. -#define API_VERSION_MAJOR 1 -#define API_VERSION_MINOR 13 +#define API_VERSION_MAJOR 1 +#define API_VERSION_MINOR 16 // Fwd Definitions -class wxFileConfig; -class wxNotebook; -class wxFont; -class wxAuiManager; -class wxScrolledWindow; +class wxFileConfig; +class wxNotebook; +class wxFont; +class wxAuiManager; +class wxScrolledWindow; +class wxGLCanvas; //--------------------------------------------------------------------------------------------------------- // // 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 +#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; +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 }; -// Describe AIS Alarm state -enum plugin_ais_alarm_type -{ - PI_AIS_NO_ALARM = 0, - PI_AIS_ALARM_SET, - PI_AIS_ALARM_ACKNOWLEDGED +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_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; +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; +}; - double Range_NM; - double Brg; +// 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 + bool bCPA_Valid; + double TCPA; // Minutes + double CPA; // Nautical Miles - plugin_ais_alarm_type alarm_state; + 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; +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; +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; +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; +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 - +#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; +class DECL_EXP PlugInChartBase : public wxObject { + public: + // These methods Must be overriden in any derived class + PlugInChartBase(); + virtual ~PlugInChartBase(); + + virtual wxString GetFileSearchMask(); + + 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() { 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 // @@ -363,166 +349,170 @@ // 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(); +class DECL_EXP opencpn_plugin { + public: + opencpn_plugin(void *pmgr) {} + virtual ~opencpn_plugin(); - // 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(); + // Public API to the PlugIn class - // This group is optional. - // PlugIns may override any of these methods as required + // This group of methods is required, and will be called by the opencpn host + // opencpn PlugIns must implement this group + virtual int Init(); // Return the PlugIn Capabilites flag + virtual bool DeInit(); - 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 GetAPIVersionMajor(); + virtual int GetAPIVersionMinor(); + virtual int GetPlugInVersionMajor(); + virtual int GetPlugInVersionMinor(); + virtual wxBitmap *GetPlugInBitmap(); - virtual int GetToolbarToolCount(void); + // 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(); - virtual int GetToolboxPanelCount(void); - virtual void SetupToolboxPanel(int page_sel, wxNotebook* pnotebook); - virtual void OnCloseToolboxPanel(int page_sel, int ok_apply_cancel); + // This group is optional. + // PlugIns may override any of these methods as required - virtual void ShowPreferencesDialog( wxWindow* parent ); + virtual void SetDefaults(); // This will be called upon enabling a PlugIn via the user Dialog + // It gives a chance to setup any default options and behavior - virtual bool RenderOverlay(wxMemoryDC *pmdc, PlugIn_ViewPort *vp); - virtual void SetCursorLatLon(double lat, double lon); - virtual void SetCurrentViewPort(PlugIn_ViewPort &vp); + virtual int GetToolbarToolCount(); - virtual void SetPositionFix(PlugIn_Position_Fix &pfix); - virtual void SetNMEASentence(wxString &sentence); - virtual void SetAISSentence(wxString &sentence); + virtual int GetToolboxPanelCount(); + virtual void SetupToolboxPanel(int page_sel, wxNotebook *pnotebook); + virtual void OnCloseToolboxPanel(int page_sel, int ok_apply_cancel); - virtual void ProcessParentResize(int x, int y); - virtual void SetColorScheme(PI_ColorScheme cs); + virtual void ShowPreferencesDialog(wxWindow *parent); - virtual void OnToolbarToolCallback(int id); - virtual void OnContextMenuItemCallback(int id); + virtual bool RenderOverlay(wxMemoryDC *pmdc, PlugIn_ViewPort *vp); + virtual void SetCursorLatLon(double lat, double lon); + virtual void SetCurrentViewPort(PlugIn_ViewPort &vp); - virtual void UpdateAuiStatus(void); + virtual void SetPositionFix(PlugIn_Position_Fix &pfix); + virtual void SetNMEASentence(wxString &sentence); + virtual void SetAISSentence(wxString &sentence); - virtual wxArrayString GetDynamicChartClassNameArray(void); - }; + virtual void ProcessParentResize(int x, int y); + virtual void SetColorScheme(PI_ColorScheme cs); + virtual void OnToolbarToolCallback(int id); + virtual void OnContextMenuItemCallback(int id); - // the types of the class factories used to create PlugIn instances - typedef opencpn_plugin* create_t(void*); - typedef void destroy_t(opencpn_plugin*); + virtual void UpdateAuiStatus(); - class DECL_EXP opencpn_plugin_16 : public opencpn_plugin - { - public: - opencpn_plugin_16(void *pmgr); - virtual ~opencpn_plugin_16(); + virtual wxArrayString GetDynamicChartClassNameArray(); +}; - virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp); +// the types of the class factories used to create PlugIn instances +typedef opencpn_plugin *create_t(void *); +typedef void destroy_t(opencpn_plugin *); - virtual void SetPluginMessage(wxString &message_id, wxString &message_body); +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); -class DECL_EXP opencpn_plugin_17 : public opencpn_plugin -{ - public: - opencpn_plugin_17(void *pmgr); - virtual ~opencpn_plugin_17(); + virtual void SetPluginMessage(wxString &message_id, wxString &message_body); +}; - virtual bool RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp); - virtual bool RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp); +class DECL_EXP opencpn_plugin_17 : public opencpn_plugin { + public: + opencpn_plugin_17(void *pmgr); + virtual ~opencpn_plugin_17(); - virtual void SetPluginMessage(wxString &message_id, wxString &message_body); + 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_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(); +class DECL_EXP opencpn_plugin_19 : public opencpn_plugin_18 { + public: + opencpn_plugin_19(void *pmgr); + virtual ~opencpn_plugin_19(); - virtual void OnSetupOptions(void); + virtual void OnSetupOptions(); }; -class DECL_EXP opencpn_plugin_110 : public opencpn_plugin_19 -{ - public: - opencpn_plugin_110(void *pmgr); - virtual ~opencpn_plugin_110(); +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() + virtual void LateInit(); // If WANTS_LATE_INIT is returned by Init() }; -class DECL_EXP opencpn_plugin_111 : public opencpn_plugin_110 -{ -public: +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: +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); - + + 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: +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 bool KeyboardEventHook(wxKeyEvent &event); virtual void OnToolbarToolDownCallback(int id); virtual void OnToolbarToolUpCallback(int id); }; +class DECL_EXP opencpn_plugin_114 : public opencpn_plugin_113 { + public: + opencpn_plugin_114(void *pmgr); + virtual ~opencpn_plugin_114(); +}; + +class DECL_EXP opencpn_plugin_115 : public opencpn_plugin_114 { + public: + opencpn_plugin_115(void *pmgr); + virtual ~opencpn_plugin_115(); +}; + +class DECL_EXP opencpn_plugin_116 : public opencpn_plugin_115 { + public: + opencpn_plugin_116(void *pmgr); + virtual ~opencpn_plugin_116(); + virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex); + virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex); + virtual void PrepareContextMenu(int canvasIndex); +}; + //------------------------------------------------------------------ // Route and Waypoint PlugIn support // //------------------------------------------------------------------ -class DECL_EXP Plugin_Hyperlink -{ -public: +class DECL_EXP Plugin_Hyperlink { + public: wxString DescrText; wxString Link; wxString Type; @@ -530,64 +520,54 @@ WX_DECLARE_LIST(Plugin_Hyperlink, Plugin_HyperlinkList); - - -class DECL_EXP PlugIn_Waypoint -{ -public: +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 lat, double lon, const wxString &icon_ident, const wxString &wp_name, const wxString &GUID = _T("")); ~PlugIn_Waypoint(); - double m_lat; - double m_lon; + double m_lat; + double m_lon; - wxString m_GUID; + wxString m_GUID; - wxString m_MarkName; - wxString m_MarkDescription; - wxDateTime m_CreateTime; - bool m_IsVisible; + wxString m_MarkName; + wxString m_MarkDescription; + wxDateTime m_CreateTime; + bool m_IsVisible; - wxString m_IconName; + 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; +class DECL_EXP PlugIn_Route { + public: + PlugIn_Route(); + ~PlugIn_Route(); + + wxString m_NameString; + wxString m_StartString; + wxString m_EndString; + wxString m_GUID; - Plugin_WaypointList *pWaypointList; + Plugin_WaypointList *pWaypointList; }; +class DECL_EXP PlugIn_Track { + public: + PlugIn_Track(); + ~PlugIn_Track(); + + wxString m_NameString; + wxString m_StartString; + wxString m_EndString; + wxString m_GUID; + Plugin_WaypointList *pWaypointList; +}; //---------------------------------------------------------------------------------------------------------- // The PlugIn CallBack API Definition @@ -597,68 +577,64 @@ // //---------------------------------------------------------------------------------------------------------- +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 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 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 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(); -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 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 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 wxWindow *GetOCPNCanvasWindow(); +extern "C" DECL_EXP wxFont *OCPNGetFont(wxString TextElement, int default_size); -extern "C" DECL_EXP wxFont *OCPNGetFont(wxString TextElement, int default_size); +extern "C" DECL_EXP wxString *GetpSharedDataLocation(); -extern "C" DECL_EXP wxString *GetpSharedDataLocation(); +extern "C" DECL_EXP ArrayOfPlugIn_AIS_Targets *GetAISTargetArray(); -extern "C" DECL_EXP ArrayOfPlugIn_AIS_Targets *GetAISTargetArray(void); +extern "C" DECL_EXP wxAuiManager *GetFrameAuiManager(); -extern "C" DECL_EXP wxAuiManager *GetFrameAuiManager(void); +extern "C" DECL_EXP bool AddLocaleCatalog(wxString catalog); -extern "C" DECL_EXP bool AddLocaleCatalog( wxString catalog ); +extern "C" DECL_EXP void PushNMEABuffer(wxString str); -extern "C" DECL_EXP void PushNMEABuffer( wxString str ); +extern DECL_EXP wxXmlDocument GetChartDatabaseEntryXML(int dbIndex, bool b_getGeom); -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 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 SendPluginMessage( wxString message_id, wxString message_body ); +extern "C" DECL_EXP void DimeWindow(wxWindow *); -extern "C" DECL_EXP void DimeWindow(wxWindow *); - -extern "C" DECL_EXP void JumpToPosition(double lat, double lon, double scale); +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 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); @@ -668,90 +644,84 @@ 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 ); - - +extern "C" DECL_EXP bool DecodeSingleVDOMessage(const wxString &str, PlugIn_Position_Fix_Ex *pos, wxString *acc); +extern "C" DECL_EXP int GetChartbarHeight(); +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 ); - +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 "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 ); - - - +/** + * Start playing a sound file asynchronously. Supported formats depends + * on sound backend. + */ +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 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 ); +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); +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(); +extern "C" DECL_EXP wxString *GetpPrivateApplicationDataLocation(); +extern DECL_EXP wxString GetOCPN_ExePath(); +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 +// 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 - +#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; @@ -762,174 +732,192 @@ // Derived from PlugInChartBase, add OpenGL Vector chart support // ---------------------------------------------------------------------------- -class DECL_EXP PlugInChartBaseGL : public PlugInChartBase -{ -public: +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 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 wxString CreateObjDescriptions(ListOfPI_S57Obj *obj_list); virtual int GetNoCOVREntries(); virtual int GetNoCOVRTablePoints(int iTable); - virtual int GetNoCOVRTablenPoints(int iTable); + virtual int GetNoCOVRTablenPoints(int iTable); virtual float *GetNoCOVRTableHead(int iTable); - }; +// ---------------------------------------------------------------------------- +// PlugInChartBaseExtended +// Derived from PlugInChartBase, add extended chart support methods +// ---------------------------------------------------------------------------- +class DECL_EXP PlugInChartBaseExtended : public PlugInChartBase { + public: + PlugInChartBaseExtended(); + virtual ~PlugInChartBaseExtended(); + virtual int RenderRegionViewOnGL(const wxGLContext &glc, const PlugIn_ViewPort &VPoint, const wxRegion &Region, + bool b_use_stencil); + virtual wxBitmap &RenderRegionViewOnDCNoText(const PlugIn_ViewPort &VPoint, const wxRegion &Region); + virtual bool RenderRegionViewOnDCTextOnly(wxMemoryDC &dc, const PlugIn_ViewPort &VPoint, const wxRegion &Region); + virtual int RenderRegionViewOnGLNoText(const wxGLContext &glc, const PlugIn_ViewPort &VPoint, const wxRegion &Region, + bool b_use_stencil); + virtual int RenderRegionViewOnGLTextOnly(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); + + virtual void ClearPLIBTextList(); +}; 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; +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; +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 +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; +} PI_DisPrio; -typedef enum PI_InitReturn -{ +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; -}; + 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; -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; + 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(); @@ -937,29 +925,26 @@ 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); +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 ); +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 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_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 ); +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 @@ -982,132 +967,134 @@ 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 ); +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); +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 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 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 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 ); +/** + * Start playing a sound file asynchronously. Supported formats depends + * on sound backend. The deviceIx is only used on platforms using the + * portaudio sound backend where -1 indicates the default device. + */ +extern DECL_EXP bool PlugInPlaySoundEx(wxString &sound_file, int deviceIndex = -1); +extern DECL_EXP void AddChartDirectory(wxString &path); extern DECL_EXP void ForceChartDBUpdate(); -extern DECL_EXP wxString GetWritableDocumentsDir( void ); -extern DECL_EXP wxDialog *GetActiveOptionsDialog(); -extern DECL_EXP wxArrayString GetWaypointGUIDArray( void ); +extern DECL_EXP wxString GetWritableDocumentsDir(); +extern DECL_EXP wxWindow *GetActiveOptionsDialog(); +extern DECL_EXP wxArrayString GetWaypointGUIDArray(); +extern DECL_EXP wxArrayString GetIconNameArray(); -extern DECL_EXP bool AddPersistentFontKey(wxString TextElement); -extern DECL_EXP wxString GetActiveStyleName(); +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); +extern DECL_EXP wxBitmap GetBitmapFromSVGFile(wxString filename, unsigned int width, unsigned int height); +extern DECL_EXP bool IsTouchInterface_PlugIn(); /* 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); +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; +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. - +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. - + + 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 + 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 +#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); - +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 _OCPN_DLStatus OCPN_downloadFileBackground(const wxString &url, const wxString &outputFile, wxEvtHandler *handler, + long *handle); -extern DECL_EXP void OCPN_cancelDownloadFileBackground( 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 ); +extern DECL_EXP _OCPN_DLStatus OCPN_postDataHttp(const wxString &url, const wxString ¶meters, wxString &result, + int timeout_secs); /* Check whether connection to the Internet is working */ @@ -1116,54 +1103,128 @@ /* Supporting Event for Background downloading */ /* OCPN_downloadEvent Definition */ -/* PlugIn should be ready/able to handle this event after initiating a background file transfer - * +/* 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 + * + * 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( ); - +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; } - - + _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: + + 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; + +#ifdef MAKING_PLUGIN +extern DECL_IMP wxEventType wxEVT_DOWNLOAD_EVENT; +#else +extern DECL_EXP wxEventType wxEVT_DOWNLOAD_EVENT; +#endif + +// API 1.14 Extra canvas Support + +/* Allow drawing of objects onto other OpenGL canvases */ +extern DECL_EXP void PlugInAISDrawGL(wxGLCanvas *glcanvas, const PlugIn_ViewPort &vp); +extern DECL_EXP bool PlugInSetFontColor(const wxString TextElement, const wxColour color); + +// API 1.15 +extern DECL_EXP double PlugInGetDisplaySizeMM(); + +// +extern DECL_EXP wxFont *FindOrCreateFont_PlugIn(int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, + bool underline = false, const wxString &facename = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + +extern DECL_EXP int PlugInGetMinAvailableGshhgQuality(); +extern DECL_EXP int PlugInGetMaxAvailableGshhgQuality(); + +extern DECL_EXP void PlugInHandleAutopilotRoute(bool enable); + +// API 1.16 +// +/** + * Return the plugin data directory for a given directory name. + * + * On Linux, the returned data path is an existing directory ending in + * "opencpn/plugins/" where the last part is the plugin_name + * argument. The prefix part is one of the directories listed in the + * environment variable XDG_DATA_DIRS, by default + * ~/.local/share:/usr/local/share:/usr/share. + * + * On other platforms, the returned value is GetSharedDataDir() + + * "/opencpn/plugins/" + plugin_name (with native path separators) + * if that path exists. + * + * Return "" if no existing directory is found. + */ +extern DECL_EXP wxString GetPluginDataDir(const char *plugin_name); + +extern DECL_EXP bool ShuttingDown(); + +// Support for MUI MultiCanvas model + +extern DECL_EXP wxWindow *PluginGetFocusCanvas(); +extern DECL_EXP wxWindow *PluginGetOverlayRenderCanvas(); + +extern "C" DECL_EXP void CanvasJumpToPosition(wxWindow *canvas, double lat, double lon, double scale); +extern "C" DECL_EXP int AddCanvasMenuItem(wxMenuItem *pitem, opencpn_plugin *pplugin, const char *name = ""); +extern "C" DECL_EXP void RemoveCanvasMenuItem(int item, const char *name = ""); // Fully remove this item +extern "C" DECL_EXP void SetCanvasMenuItemViz(int item, bool viz, + const char *name = ""); // Temporarily change context menu options +extern "C" DECL_EXP void SetCanvasMenuItemGrey(int item, bool grey, const char *name = ""); + +// Extract waypoints, routes and tracks +extern DECL_EXP wxString GetSelectedWaypointGUID_Plugin(); +extern DECL_EXP wxString GetSelectedRouteGUID_Plugin(); +extern DECL_EXP wxString GetSelectedTrackGUID_Plugin(); + +extern DECL_EXP std::unique_ptr GetWaypoint_Plugin(const wxString &); // doublon with GetSingleWaypoint +extern DECL_EXP std::unique_ptr GetRoute_Plugin(const wxString &); +extern DECL_EXP std::unique_ptr GetTrack_Plugin(const wxString &); + +extern DECL_EXP wxWindow *GetCanvasUnderMouse(); +extern DECL_EXP int GetCanvasIndexUnderMouse(); +// extern DECL_EXP std::vector GetCanvasArray(); +extern DECL_EXP wxWindow *GetCanvasByIndex(int canvasIndex); +extern DECL_EXP int GetCanvasCount(); +extern DECL_EXP bool CheckMUIEdgePan_PlugIn(int x, int y, bool dragging, int margin, int delta, int canvasIndex); +extern DECL_EXP void SetMUICursor_PlugIn(wxCursor *pCursor, int canvasIndex); + +enum SDDMFORMAT { DEGREES_DECIMAL_MINUTES = 0, DECIMAL_DEGREES, DEGREES_MINUTES_SECONDS, END_SDDMFORMATS }; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_DOWNLOAD_EVENT; +extern DECL_EXP int GetLatLonFormat(); -#endif //_PLUGIN_H_ +#endif //_PLUGIN_H_ diff -Nru opencpn-plugin-iacfleet-0.10.0/README.md opencpn-plugin-iacfleet-0.20/README.md --- opencpn-plugin-iacfleet-0.10.0/README.md 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/README.md 2019-03-14 00:47:06.000000000 +0000 @@ -77,5 +77,5 @@ * ~~http://www.mar.mil.br/dhn/chm/meteo/prev/iac/iac.htm~~ * ~~http://weather.noaa.gov/pub/data/raw/as/asxx21.egrr..txt~~ * ~~Automatic download from NOAA and BR~~ -* Refine the GUI to save space +* ~~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.10.0/src/iacfile.cpp opencpn-plugin-iacfleet-0.20/src/iacfile.cpp --- opencpn-plugin-iacfleet-0.10.0/src/iacfile.cpp 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/iacfile.cpp 2019-03-14 00:47:06.000000000 +0000 @@ -57,16 +57,16 @@ //--------------------------------------------- // IACFile implementation //--------------------------------------------- -IACFile::IACFile(void) { Invalidate(); } +IACFile::IACFile() { Invalidate(); } IACFile::IACFile(wxInputStream &stream) { Invalidate(); m_isok = Read(stream); } -IACFile::~IACFile(void) {} +IACFile::~IACFile() {} -void IACFile::Invalidate(void) { +void IACFile::Invalidate() { m_tokens.Clear(); m_tokensI = 0; m_isok = false; @@ -127,7 +127,7 @@ return isok; } -wxString IACFile::ToString(void) { +wxString IACFile::ToString() { wxString t; size_t i; t.Append(_T("IAC Fleet Code issued at ") + m_issueDate + _T("\n")); @@ -157,7 +157,7 @@ return t; } -bool IACFile::Decode(void) { +bool IACFile::Decode() { // init m_tokensI = 0; bool res = ReadHeader(); @@ -167,7 +167,7 @@ return res; } -bool IACFile::ReadHeader(void) { +bool IACFile::ReadHeader() { bool data = !tokenFind(_T("10001"), true).IsEmpty(); if (!data) // If it is not analysis, lets check for NOAA 24 hour forecast { @@ -311,7 +311,7 @@ } } -bool IACFile::ParseSections(void) { +bool IACFile::ParseSections() { wxString token; do { token = tokenFind(_T("999??"), true); @@ -341,7 +341,7 @@ } while (!token.IsEmpty()); return true; } -bool IACFile::ParsePressureSection(void) { +bool IACFile::ParsePressureSection() { wxString token; for (;;) { token = tokenFind(_T("8????")); @@ -375,7 +375,7 @@ return true; } -bool IACFile::ParseFrontalSection(void) { +bool IACFile::ParseFrontalSection() { wxString token; for (;;) { token = tokenFind(_T("66???")); @@ -399,7 +399,7 @@ return true; } -bool IACFile::ParseIsobarSection(void) { +bool IACFile::ParseIsobarSection() { wxString token; for (;;) { token = tokenFind(_T("44???")); @@ -422,7 +422,7 @@ return true; } -bool IACFile::ParseTropicalSection(void) { +bool IACFile::ParseTropicalSection() { wxString token; for (;;) { token = tokenFind(_T("55???")); @@ -485,7 +485,7 @@ return wxEmptyString; } -void IACFile::PushbackToken(void) { +void IACFile::PushbackToken() { if (m_tokensI > 0) { m_tokensI--; } @@ -502,7 +502,7 @@ while (file.IsOk() && mode != 2) { int c = file.GetC(); - if (c != wxEOF) { + if (c != wxEOF && c <= 128) { if (c == '\n' && m_tokensI > 0) { m_newlineTokens.push_back(m_tokensI + 1); } @@ -724,7 +724,7 @@ } } -wxString GeoPoint::ToString(void) { +wxString GeoPoint::ToString() { wxString t; // latitude unsigned int latdeg = floor(fabs(y)); @@ -747,7 +747,7 @@ // implementation of IACSystem //----------------------------- -IACSystem::IACSystem(void) +IACSystem::IACSystem() : 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; } @@ -893,7 +893,7 @@ } } -wxString IACSystem::GetMovement(void) const { +wxString IACSystem::GetMovement() const { static const wxChar *(tab[]) = { wxT("-"), _("stationary"), _("little change"), _("stopping"), _("retarding"), _("curving to left"), _("recurving"), _("accelerating"), _("curving to right"), _("expected to recurve")}; @@ -954,7 +954,7 @@ wxString IACSystem::GetCharacteristic(size_t index) const { return (wxEmptyString); } -wxString IACSystem::PositionsToString(void) const { +wxString IACSystem::PositionsToString() const { wxString t; for (size_t i = 0; i < m_positions.Count(); i++) { if (i != 0) { @@ -965,7 +965,7 @@ return t; } -wxString IACPressureSystem::GetValue(void) const { +wxString IACPressureSystem::GetValue() const { wxString t; if (m_val >= 0) { t.Printf(wxT("%4u hPa"), m_val); @@ -1022,7 +1022,7 @@ return (wxString(tab[index])); } -wxString IACFrontalSystem::GetIntensity(void) const { +wxString IACFrontalSystem::GetIntensity() const { static const wxChar *(tab[]) = {wxEmptyString, _("weak, decreasing"), _("weak, no change"), @@ -1093,7 +1093,7 @@ return (GetTab(tab, index)); } -wxString IACTropicalSystem::GetIntensity(void) const { +wxString IACTropicalSystem::GetIntensity() const { static const wxChar *(tab[]) = {wxT("-"), _("weak, decreasing"), _("weak, no change"), @@ -1111,7 +1111,7 @@ } } -wxString IACTropicalSystem::GetValue(void) const { +wxString IACTropicalSystem::GetValue() const { wxString t; if (m_val >= 0) { t.Printf(wxT("%4u hPa"), m_val); diff -Nru opencpn-plugin-iacfleet-0.10.0/src/iacfile.h opencpn-plugin-iacfleet-0.20/src/iacfile.h --- opencpn-plugin-iacfleet-0.10.0/src/iacfile.h 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/iacfile.h 2019-03-14 00:47:06.000000000 +0000 @@ -100,7 +100,7 @@ x = lon; y = lat; } - wxString ToString(void); + wxString ToString(); bool MatchPosition(GeoPoint &refPos, double deviation); }; @@ -108,13 +108,13 @@ class IACSystem { public: - IACSystem(void); + IACSystem(); 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; + wxString PositionsToString() const; bool DrawPositions(wxDC *dc, PlugIn_ViewPort *vp); virtual bool FindAtPos(GeoPoint &pos, double deviation); GeoPoints m_positions; @@ -134,9 +134,9 @@ 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; + virtual wxString GetValue() const { return wxEmptyString; } + virtual wxString GetIntensity() const { return wxEmptyString; } + wxString GetMovement() const; }; class IACPressureSystem : public IACSystem { @@ -144,7 +144,7 @@ wxString GetType(size_t index) const; wxString GetShortType(size_t index) const; wxString GetCharacteristic(size_t index) const; - wxString GetValue(void) const; + wxString GetValue() const; }; class IACFrontalSystem : public IACSystem { @@ -152,7 +152,7 @@ private: wxString GetType(size_t index) const; wxString GetCharacteristic(size_t index) const; - wxString GetIntensity(void) const; + wxString GetIntensity() const; bool Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont); }; @@ -167,9 +167,9 @@ private: wxString GetType(size_t index) const; wxString GetShortType(size_t index) const; - wxString GetIntensity(void) const; + wxString GetIntensity() const; wxString GetCharacteristic(size_t index) const; - wxString GetValue(void) const; + wxString GetValue() const; bool Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont); }; @@ -185,38 +185,38 @@ IACFile(wxInputStream &stream); ~IACFile(); - wxString ToString(void); - wxString GetIssueDate(void) { return m_issueDate; } - bool IsForecast(void) { return m_RawData.StartsWith(_T("F")); } + wxString ToString(); + wxString GetIssueDate() { return m_issueDate; } + bool IsForecast() { return m_RawData.StartsWith(_T("F")); } bool Read(wxInputStream &stream); - bool IsOk(void) { return m_isok; } + bool IsOk() { 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 &GetRawData() { return m_RawData; } static const size_t IACMaxSize = MAX_FILESIZE; - void Invalidate(void); + void Invalidate(); 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); + void PushbackToken(); + bool Decode(); - bool Parse(void); - bool ReadHeader(void); + bool Parse(); + bool ReadHeader(); 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 ParseSections(); + bool ParsePressureSection(); + bool ParseFrontalSection(); + bool ParseIsobarSection(); + bool ParseTropicalSection(); + GeoPoint ParsePosition(); bool DrawSystems(wxDC *dc, PlugIn_ViewPort *vp, IACSystems &iacsystem); bool m_isok; diff -Nru opencpn-plugin-iacfleet-0.10.0/src/iacfleet.cpp opencpn-plugin-iacfleet-0.20/src/iacfleet.cpp --- opencpn-plugin-iacfleet-0.10.0/src/iacfleet.cpp 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/iacfleet.cpp 2019-03-14 00:47:06.000000000 +0000 @@ -59,27 +59,11 @@ EVT_TIMER(ID_ANIMATION_TIMER, IACFleetUIDialog::OnTimerAnimation) END_EVENT_TABLE() -/* -IACFleetUIDialog::IACFleetUIDialog(void): - pParent(NULL), - pPlugIn(NULL), - m_pfolder_bitmap(NULL), - m_lastViewPortValid(false), - m_pitemCurrentDirectoryCtrl(NULL), - m_pFileListCtrl(NULL), - m_pTextCtrl(NULL), - m_pRawCtrl(NULL), - m_pFileTime(NULL), - m_pTipWindow(NULL) -{ - // Init(); privat member of "wxDialog" in dialog.h -} -*/ - -IACFleetUIDialog::~IACFleetUIDialog(void) { +IACFleetUIDialog::~IACFleetUIDialog() { if (m_timer->IsRunning()) m_timer->Stop(); delete m_timer; - // m_bBrDownload->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IACFleetUIDialog::OnBrDownload), NULL, this); + delete m_pfolder_bitmap; + 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); @@ -162,7 +146,7 @@ pPlugIn->OnDialogClose(); } -void IACFleetUIDialog::Invalidate(void) { +void IACFleetUIDialog::Invalidate() { m_iacfile.Invalidate(); m_pRawCtrl->Clear(); m_pTextCtrl->Clear(); @@ -253,7 +237,7 @@ m_pitemCurrentDirectoryCtrl->AppendText(m_currentDir); wxButton* bChooseDir = new wxBitmapButton(win, ID_CHOOSEIACFLEETDIR, *m_pfolder_bitmap); - itemStaticBoxSizer11Static->Add(bChooseDir, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + itemStaticBoxSizer11Static->Add(bChooseDir, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); paneSz->Add(itemStaticBoxSizer11Static, 0, wxALL | wxEXPAND, 5); @@ -323,66 +307,26 @@ wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer(wxVERTICAL); dnldpanel->SetSizer(bSizerMain); - /* - 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); - - 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); - - bsBRazil->Add(0, 0, 1, wxEXPAND, 5); - - m_bBrDownload = new wxButton(dnldpanel, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0); - bsBRazil->Add(m_bBrDownload, 0, wxALL, 5); - - sbSizerBrazil->Add(bsBRazil, 0, wxEXPAND, 5); - - wxBoxSizer* bSizerHistory; - bSizerHistory = new wxBoxSizer(wxHORIZONTAL); - 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); + // Brazil from the new website + wxStaticBoxSizer* sbSizerBrazil; + sbSizerBrazil = new wxStaticBoxSizer(new wxStaticBox(dnldpanel, wxID_ANY, _("Brazil South Atlantic")), wxVERTICAL); - 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); + wxBoxSizer* bsBrazil; + bsBrazil = new wxBoxSizer(wxHORIZONTAL); - 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); + m_rbAnalysisBrazil = new wxRadioButton(dnldpanel, wxID_ANY, _("Analysis"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); + m_rbAnalysisBrazil->SetValue(true); + bsBrazil->Add(m_rbAnalysisBrazil, 0, wxALL, 5); - sbSizerBrazil->Add(bSizerHistory, 1, wxEXPAND, 5); + bsBrazil->Add(0, 0, 1, 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); + m_bBrDownload = new wxButton(dnldpanel, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0); + bsBrazil->Add(m_bBrDownload, 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); + sbSizerBrazil->Add(bsBrazil, 1, wxEXPAND, 5); - bSizerMain->Add(sbSizerBrazil, 0, wxALL | wxEXPAND, 5); - */ + bSizerMain->Add(sbSizerBrazil, 0, wxALL | wxEXPAND, 5); // NOAA wxStaticBoxSizer* sbSizerNOAA; sbSizerNOAA = new wxStaticBoxSizer(new wxStaticBox(dnldpanel, wxID_ANY, _("NOAA North Atlantic and Europe")), wxVERTICAL); @@ -390,7 +334,7 @@ wxBoxSizer* bsNOAA; bsNOAA = new wxBoxSizer(wxHORIZONTAL); - m_rbAnalysis = new wxRadioButton(dnldpanel, wxID_ANY, _("Analysis"), wxDefaultPosition, wxDefaultSize, 0); + m_rbAnalysis = new wxRadioButton(dnldpanel, wxID_ANY, _("Analysis"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); bsNOAA->Add(m_rbAnalysis, 0, wxALL, 5); m_rbForecast = new wxRadioButton(dnldpanel, wxID_ANY, _("24h forecast"), wxDefaultPosition, wxDefaultSize, 0); @@ -420,7 +364,7 @@ bSizerMain->Add(sbSizerNadi, 0, wxALL | wxEXPAND, 5); // Connect Events - // m_bBrDownload->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IACFleetUIDialog::OnBrDownload), 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); @@ -457,7 +401,7 @@ } //--------------------------------------------------------- -void IACFleetUIDialog::updateFileList(void) { +void IACFleetUIDialog::updateFileList() { m_FilenameArray.Empty(); if (m_currentDir == wxEmptyString || !wxDirExists(m_currentDir)) return; wxDir::GetAllFiles(m_currentDir, &m_FilenameArray, wxEmptyString, wxDIR_FILES); @@ -552,7 +496,7 @@ // if rawdata is not empty use it as input to the // IACFleet code // otherwise use m_currentFileName -void IACFleetUIDialog::updateIACFleet(void) { +void IACFleetUIDialog::updateIACFleet() { bool ok = false; ::wxBeginBusyCursor(); @@ -577,7 +521,7 @@ void IACFleetUIDialog::updateRawPanel(wxString& rawData) { m_pRawCtrl->ChangeValue(rawData); } -void IACFleetUIDialog::updateTextPanel(void) { +void IACFleetUIDialog::updateTextPanel() { m_pTextCtrl->ChangeValue(m_iacfile.ToString()); if (m_iacfile.IsForecast()) m_pIssueDate->SetLabel(_("Forecast issued at ")); @@ -595,65 +539,58 @@ } 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()) { - wxMessageBox(_("Sorry, you can't download data from the future - they don't exist...")); - return; - } else if (dt < wxDateTime(1, 9, 2006)) { - wxMessageBox(_("Sorry, the data is not available before September 1, 2006...")); - return; - } + wxDateTime dt = wxDateTime::Now(); 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)); - wxString url = _T("http://www.mar.mil.br/dhn/chm/meteo/prev/iac/") + filename; - - 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())) { - showfile = fn.GetFullPath(); - showfilename = filename; - } 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); - break; - } - case OCPN_DL_USER_TIMEOUT: - case OCPN_DL_ABORTED: { - break; - } - case OCPN_DL_UNKNOWN: - case OCPN_DL_STARTED: { - break; - } + wxString url; + wxString prefix; - default: - wxASSERT(false); // This should never happen because we handle all possible cases of ret + if (m_rbAnalysisBrazil->GetValue()) { + prefix = _T("IAC_BRA_A"); + url = _T("https://data.navnux.org/br_iac/"); + } + + 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())) { + showfile = fn.GetFullPath(); + showfilename = filename; + } 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); + break; + } + case OCPN_DL_USER_TIMEOUT: + case OCPN_DL_ABORTED: { + break; } - if (wxFileExists(tfn.GetFullPath())) wxRemoveFile(tfn.GetFullPath()); + case OCPN_DL_UNKNOWN: + case OCPN_DL_STARTED: { + break; + } + + default: + wxASSERT(false); // This should never happen because we handle all possible cases of ret } + if (wxFileExists(tfn.GetFullPath())) wxRemoveFile(tfn.GetFullPath()); if (showfile != wxEmptyString) { updateFileList(); m_pFileListCtrl->SetStringSelection(showfilename); diff -Nru opencpn-plugin-iacfleet-0.10.0/src/iacfleet.h opencpn-plugin-iacfleet-0.20/src/iacfleet.h --- opencpn-plugin-iacfleet-0.10.0/src/iacfleet.h 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/iacfleet.h 2019-03-14 00:47:06.000000000 +0000 @@ -73,8 +73,8 @@ DECLARE_CLASS(IACFleetUIDialog) DECLARE_EVENT_TABLE() public: - // IACFleetUIDialog( void ); - ~IACFleetUIDialog(void); + // IACFleetUIDialog(); + ~IACFleetUIDialog(); 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, @@ -101,11 +101,11 @@ void OnNoaaDownload(wxCommandEvent &event); private: - void Invalidate(void); - void updateFileList(void); - void updateIACFleet(void); + void Invalidate(); + void updateFileList(); + void updateIACFleet(); void updateRawPanel(wxString &awData); - void updateTextPanel(void); + void updateTextPanel(); private: wxTimer m_TooltipTimer; @@ -137,17 +137,10 @@ 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; + wxButton *m_bBrDownload; + + wxRadioButton *m_rbAnalysisBrazil; wxRadioButton *m_rbAnalysis; wxRadioButton *m_rbForecast; diff -Nru opencpn-plugin-iacfleet-0.10.0/src/iacfleet_pi.cpp opencpn-plugin-iacfleet-0.20/src/iacfleet_pi.cpp --- opencpn-plugin-iacfleet-0.10.0/src/iacfleet_pi.cpp 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/iacfleet_pi.cpp 2019-03-14 00:47:06.000000000 +0000 @@ -59,7 +59,7 @@ // //--------------------------------------------------------------------------------------------------------- -iacfleet_pi::iacfleet_pi(void *ppimgr) : opencpn_plugin_113(ppimgr) { +iacfleet_pi::iacfleet_pi(void *ppimgr) : opencpn_plugin_116(ppimgr) { // Set some default private member parameters m_dialog_x = 0; m_dialog_y = 0; @@ -81,7 +81,7 @@ iacfleet_pi::~iacfleet_pi() { deinitialize_images(); } -int iacfleet_pi::Init(void) { +int iacfleet_pi::Init() { AddLocaleCatalog(_T("opencpn-iacfleet_pi")); // And load the configuration items @@ -100,7 +100,7 @@ INSTALLS_TOOLBAR_TOOL | WANTS_CONFIG); } -bool iacfleet_pi::DeInit(void) { +bool iacfleet_pi::DeInit() { if (m_pDialog) { m_pDialog->Close(); } @@ -127,7 +127,7 @@ "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() { return 1; } void iacfleet_pi::ShowPreferencesDialog(wxWindow *parent) { wxDialog *dialog = @@ -163,19 +163,26 @@ m_pDialog = NULL; SaveConfig(); } -bool iacfleet_pi::RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp) { + +bool iacfleet_pi::RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex) { + if (GetCanvasCount() > canvasIndex + 1) { + return false; + } m_pdc = &dc; bool hasDrawn = m_pDialog && m_pDialog->RenderOverlay(m_pdc, vp); return hasDrawn; } -bool iacfleet_pi::RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp) { +bool iacfleet_pi::RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex) { + if (GetCanvasCount() > canvasIndex + 1) { + return false; + } m_pdc = NULL; bool hasDrawn = m_pDialog && m_pDialog->RenderOverlay(m_pdc, vp); return hasDrawn; } -bool iacfleet_pi::LoadConfig(void) { +bool iacfleet_pi::LoadConfig() { wxFileConfig *pConf = GetOCPNConfigObject(); if (pConf) { @@ -196,7 +203,7 @@ return false; } -bool iacfleet_pi::SaveConfig(void) { +bool iacfleet_pi::SaveConfig() { wxFileConfig *pConf = GetOCPNConfigObject(); if (pConf) { diff -Nru opencpn-plugin-iacfleet-0.10.0/src/iacfleet_pi.h opencpn-plugin-iacfleet-0.20/src/iacfleet_pi.h --- opencpn-plugin-iacfleet-0.10.0/src/iacfleet_pi.h 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/iacfleet_pi.h 2019-03-14 00:47:06.000000000 +0000 @@ -37,7 +37,7 @@ #include "version.h" #define MY_API_VERSION_MAJOR 1 -#define MY_API_VERSION_MINOR 13 +#define MY_API_VERSION_MINOR 16 #include "ocpn_plugin.h" @@ -47,14 +47,14 @@ // The PlugIn Class Definition //---------------------------------------------------------------------------------------------------------- class IACFleetUIDialog; -class iacfleet_pi : public opencpn_plugin_113 { +class iacfleet_pi : public opencpn_plugin_116 { public: iacfleet_pi(void *ppimgr); ~iacfleet_pi(); // The required PlugIn Methods - int Init(void); - bool DeInit(void); + int Init(); + bool DeInit(); int GetAPIVersionMajor(); int GetAPIVersionMinor(); @@ -67,9 +67,9 @@ 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); + bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex); + bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvasIndex); + int GetToolbarToolCount(); void ShowPreferencesDialog(wxWindow *parent); void OnToolbarToolCallback(int id); void SetDialogX(int x) { m_dialog_x = x; }; @@ -81,8 +81,8 @@ void SetSortType(int sort_type) { m_sort_type = sort_type; }; private: - bool LoadConfig(void); - bool SaveConfig(void); + bool LoadConfig(); + bool SaveConfig(); private: wxWindow *m_parent_window; diff -Nru opencpn-plugin-iacfleet-0.10.0/src/icons.cpp opencpn-plugin-iacfleet-0.20/src/icons.cpp --- opencpn-plugin-iacfleet-0.10.0/src/icons.cpp 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/icons.cpp 2019-03-14 00:47:06.000000000 +0000 @@ -15,7 +15,7 @@ wxString _svg_iacfleet_toggled; #endif -void initialize_images(void) { +void initialize_images() { { wxMemoryInputStream sm( "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 " @@ -54,7 +54,7 @@ return; } -void deinitialize_images(void) { +void deinitialize_images() { if (NULL != _img_iacfleet_pi) { delete (_img_iacfleet_pi); } diff -Nru opencpn-plugin-iacfleet-0.10.0/src/icons.h opencpn-plugin-iacfleet-0.20/src/icons.h --- opencpn-plugin-iacfleet-0.10.0/src/icons.h 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/icons.h 2019-03-14 00:47:06.000000000 +0000 @@ -6,8 +6,8 @@ #include #endif -extern void initialize_images(void); -extern void deinitialize_images(void); +extern void initialize_images(); +extern void deinitialize_images(); extern wxBitmap *_img_iacfleet_pi; diff -Nru opencpn-plugin-iacfleet-0.10.0/src/TexFont.cpp opencpn-plugin-iacfleet-0.20/src/TexFont.cpp --- opencpn-plugin-iacfleet-0.10.0/src/TexFont.cpp 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/TexFont.cpp 2019-03-14 00:47:06.000000000 +0000 @@ -31,6 +31,15 @@ #include "TexFont.h" +TexFont::TexFont() { + texobj = 0; + m_blur = false; + tex_w = 0; + tex_h = 0; +} + +TexFont::~TexFont() { Delete(); } + 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; @@ -279,7 +288,7 @@ glBindTexture(GL_TEXTURE_2D, texobj); for (unsigned int i = 0; i < string.size(); i++) { - wchar_t x = string[i]; + wchar_t c = string[i]; if (x == '\n') { glPopMatrix(); @@ -287,7 +296,7 @@ glPushMatrix(); continue; } - RenderGlyph(x); + RenderGlyph(c); } glPopMatrix(); diff -Nru opencpn-plugin-iacfleet-0.10.0/src/TexFont.h opencpn-plugin-iacfleet-0.20/src/TexFont.h --- opencpn-plugin-iacfleet-0.10.0/src/TexFont.h 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/src/TexFont.h 2019-03-14 00:47:06.000000000 +0000 @@ -23,6 +23,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * **************************************************************************/ +#ifndef __tex_font_h_ +#define __tex_font_h_ + /* support ascii plus degree symbol for now pack font in a single texture 16x8 */ #define DEGREE_GLYPH 127 #define MIN_GLYPH 32 @@ -36,11 +39,13 @@ struct TexGlyphInfo { int x, y, width, height; float advance; + TexGlyphInfo() : x(0), y(0), width(0), height(0), advance(0.) {} }; class TexFont { public: - TexFont() {} + TexFont(); + ~TexFont(); void Build(wxFont &font, bool blur = false, bool luminance = false); void Delete(); @@ -57,5 +62,6 @@ TexGlyphInfo tgi[MAX_GLYPH]; unsigned int texobj; - int tex_w, tex_h; + size_t tex_w, tex_h; }; +#endif diff -Nru opencpn-plugin-iacfleet-0.10.0/.travis.yml opencpn-plugin-iacfleet-0.20/.travis.yml --- opencpn-plugin-iacfleet-0.10.0/.travis.yml 2018-02-02 14:45:41.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/.travis.yml 2019-03-14 00:47:06.000000000 +0000 @@ -1,43 +1,71 @@ language: cpp - os: - - linux - - osx - -#compiler: -# - gcc -# - clang - -branches: - only: - - master - +- linux +- osx before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade; fi - +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential cmake gettext git-core gpsd gpsd-clients libgps-dev wx-common libwxgtk3.0-dev libglu1-mesa-dev libgtk2.0-dev wx3.0-headers libbz2-dev libtinyxml-dev libportaudio2 portaudio19-dev libcurl4-openssl-dev libexpat1-dev libcairo2-dev libarchive-dev liblzma-dev libexif-dev; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install cairo libexif libarchive wxmac; export PATH="/usr/local/opt/gettext/bin:$PATH"; echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile; fi +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential + cmake gettext git-core gpsd gpsd-clients libgps-dev wx-common libwxgtk3.0-dev libglu1-mesa-dev + libgtk2.0-dev wx3.0-headers libbz2-dev libtinyxml-dev libportaudio2 portaudio19-dev + libcurl4-openssl-dev libexpat1-dev libcairo2-dev libarchive-dev liblzma-dev libexif-dev; + fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + brew install cairo libexif xz libarchive; + wget http://opencpn.navnux.org/build_deps/wx312_opencpn50_macos109.tar.xz; + tar xJf wx312_opencpn50_macos109.tar.xz -C /tmp; + export PATH="/usr/local/opt/gettext/bin:$PATH"; + echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile; + wget http://opencpn.navnux.org/build_deps/Packages.dmg; + hdiutil attach Packages.dmg; + sudo installer -pkg "/Volumes/Packages 1.2.5/Install Packages.pkg" -target "/"; + fi script: - - mkdir -p build - - cd build - - cmake .. - - make - +- mkdir -p build +- cd build +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DwxWidgets_CONFIG_EXECUTABLE=/tmp/wx312_opencpn50_macos109/bin/wx-config -DwxWidgets_CONFIG_OPTIONS="--prefix=/tmp/wx312_opencpn50_macos109" -DCMAKE_INSTALL_PREFIX=/tmp/opencpn -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 ..; fi +- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake ..; fi +- make +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make create-pkg; ls -la; pwd; fi env: global: - # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - - secure: "gzuRKPoISDCbjfRdI+KS0H3/9T4CDLybTxLwirUJ660IaFTewNYXj/pyOJOr7miOrBmQaJQw7aKAG4fpfbHpY0kkLQe2JHaJv84uyuev4QuJGtfyim3a2U4FbxtCyyjREyGI15enBra3N1xKtQqNbnkgOCKPtWSAlX4rf1elj5A=" + - secure: "eDH/wZxvJcA26VgDWglJwvr1nMyZjECGUDnjgrOZE/xjSz7i2JNbCFKHOx7kCkJh+hxJwsKWpDHRFTQbaiecze5JjFZfRRZOon1GQEvszBhhy5T0mjIHoWOwi0J/htBqUoYjNO1IYHW2OGJNIHARqddgnnGLG7K5XlPjTUcuv6Y=" +before_install: + - echo -n | openssl s_client -connect https://scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca- addons: coverity_scan: project: name: "nohal/iacfleet_pi" - description: "Build submitted via Travis CI" + description: "IAC Fleetcode plugin for OpenCPN" notification_email: pavel@kalian.cz build_command_prepend: "mkdir -p build; cd build; cmake ..; make clean" - build_command: "make" + build_command: "make" branch_pattern: coverity_scan -# build_script_url: "https://raw.githubusercontent.com/nohal/iacfleet_pi/master/scan_script.sh" + +before_deploy: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export RELEASE_PKG_FILE=$(ls *.pkg); fi +deploy: + - provider: releases + api_key: + secure: VU95qFxSJuxVzddd23xL3XYUxYVRl50Kov1bhUc5Mq9ClZ+t4P1M45nuTPm8787UREkUXV5+pU+T6vLvcpBb8NkWs2gbU7hgNcTTYRjSY93+Ot+GHDOiYnKlf/td3KzE06jfoJoW8QX5cuNfYkNNdh+PW0eV1ixk60OjK9//MZw= + file: "${RELEASE_PKG_FILE}" + skip_cleanup: true + on: + tags: true + all_branches: true + os: osx + repo: nohal/iacfleet_pi + - provider: launchpad + slug: "~nohal/iacfleet-pi/+git/master" + skip_cleanup: true + on: + tags: true + all_branches: true + condition: "$TRAVIS_OS_NAME = linux" + repo: nohal/iacfleet_pi + oauth_token: + secure: OKmt3MKJVsOKhG6TDQ5eUQQp9kKeTGxxb3FL6y+o0K6V4iMsXi6N435rZkWA4bcXEMAsofDDxrngxwE+C4QC9XarFtQXCF3B4thty6XJgCWS2FCgx0aHn16N75tG4NalhgJ65y9WXWdUIm4I7qZUP8jJQ7xggxPhL093XZ8zIPw= + oauth_token_secret: + secure: DbRVCzp1ZFTHSUfwe4VqsLjg/pKvKiSsZ19TSYcHPqiq3SfhLo8ymrbrA2ZdutgaWYjZ2fLu+JeNVB5f+seCR/ZINkD2wUyaBuUm0PIx3g/sfTq2iJx3huu+wkwR4Uhlj9qQL4ZIbYcMH6RKVr4dG91DcF5SUJZZzVe5d9SkXYE= diff -Nru opencpn-plugin-iacfleet-0.10.0/website_filter/index.php opencpn-plugin-iacfleet-0.20/website_filter/index.php --- opencpn-plugin-iacfleet-0.10.0/website_filter/index.php 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/website_filter/index.php 2019-03-14 00:47:06.000000000 +0000 @@ -0,0 +1,9 @@ +find('div[class*=field-item"]', 0); +$str = $ret->find('p', 0)->plaintext; +preg_replace('/[[:^print:]]/', '', $str); +echo $str; +?> diff -Nru opencpn-plugin-iacfleet-0.10.0/website_filter/simple_html_dom.php opencpn-plugin-iacfleet-0.20/website_filter/simple_html_dom.php --- opencpn-plugin-iacfleet-0.10.0/website_filter/simple_html_dom.php 1970-01-01 00:00:00.000000000 +0000 +++ opencpn-plugin-iacfleet-0.20/website_filter/simple_html_dom.php 2019-03-14 00:47:06.000000000 +0000 @@ -0,0 +1,2808 @@ +size is the "real" + * number of bytes the dom was created from. But for most purposes, it's a + * really good estimation. + * + * Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags + * closed is great for malformed html, but it CAN lead to parsing errors. + * + * Allow the user to tell us how much they trust the html. + * + * Paperg add the text and plaintext to the selectors for the find syntax. + * plaintext implies text in the innertext of a node. text implies that the + * tag is a text node. This allows for us to find tags based on the text they + * contain. + * + * Create find_ancestor_tag to see if a tag is - at any level - inside of + * another specific tag. + * + * Paperg: added parse_charset so that we know about the character set of + * the source document. NOTE: If the user's system has a routine called + * get_last_retrieve_url_contents_content_type availalbe, we will assume it's + * returning the content-type header from the last transfer or curl_exec, and + * we will parse that and use it in preference to any other method of charset + * detection. + * + * Found infinite loop in the case of broken html in restore_noise. Rewrote to + * protect from that. + * + * PaperG (John Schlick) Added get_display_size for "IMG" tags. + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @author S.C. Chen + * @author John Schlick + * @author Rus Carroll + * @version Rev. 1.8.1 (247) + * @package PlaceLocalInclude + * @subpackage simple_html_dom + */ + +/** + * All of the Defines for the classes below. + * @author S.C. Chen + */ +define('HDOM_TYPE_ELEMENT', 1); +define('HDOM_TYPE_COMMENT', 2); +define('HDOM_TYPE_TEXT', 3); +define('HDOM_TYPE_ENDTAG', 4); +define('HDOM_TYPE_ROOT', 5); +define('HDOM_TYPE_UNKNOWN', 6); +define('HDOM_QUOTE_DOUBLE', 0); +define('HDOM_QUOTE_SINGLE', 1); +define('HDOM_QUOTE_NO', 3); +define('HDOM_INFO_BEGIN', 0); +define('HDOM_INFO_END', 1); +define('HDOM_INFO_QUOTE', 2); +define('HDOM_INFO_SPACE', 3); +define('HDOM_INFO_TEXT', 4); +define('HDOM_INFO_INNER', 5); +define('HDOM_INFO_OUTER', 6); +define('HDOM_INFO_ENDSPACE', 7); + +/** The default target charset */ +defined('DEFAULT_TARGET_CHARSET') || define('DEFAULT_TARGET_CHARSET', 'UTF-8'); + +/** The default
text used instead of
tags when returning text */ +defined('DEFAULT_BR_TEXT') || define('DEFAULT_BR_TEXT', "\r\n"); + +/** The default text used instead of tags when returning text */ +defined('DEFAULT_SPAN_TEXT') || define('DEFAULT_SPAN_TEXT', ' '); + +/** The maximum file size the parser should load */ +defined('MAX_FILE_SIZE') || define('MAX_FILE_SIZE', 600000); + +/** Contents between curly braces "{" and "}" are interpreted as text */ +define('HDOM_SMARTY_AS_TEXT', 1); + +// helper functions +// ----------------------------------------------------------------------------- +// get html dom from file +// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1. +function file_get_html( + $url, + $use_include_path = false, + $context = null, + $offset = 0, + $maxLen = -1, + $lowercase = true, + $forceTagsClosed = true, + $target_charset = DEFAULT_TARGET_CHARSET, + $stripRN = true, + $defaultBRText = DEFAULT_BR_TEXT, + $defaultSpanText = DEFAULT_SPAN_TEXT) +{ + // Ensure maximum length is greater than zero + if($maxLen <= 0) { $maxLen = MAX_FILE_SIZE; } + + // We DO force the tags to be terminated. + $dom = new simple_html_dom( + null, + $lowercase, + $forceTagsClosed, + $target_charset, + $stripRN, + $defaultBRText, + $defaultSpanText); + + /** + * For sourceforge users: uncomment the next line and comment the + * retrieve_url_contents line 2 lines down if it is not already done. + */ + $contents = file_get_contents( + $url, + $use_include_path, + $context, + $offset, + $maxLen); + + // Paperg - use our own mechanism for getting the contents as we want to + // control the timeout. + // $contents = retrieve_url_contents($url); + if (empty($contents) || strlen($contents) > $maxLen) { return false; } + + // The second parameter can force the selectors to all be lowercase. + $dom->load($contents, $lowercase, $stripRN); + return $dom; +} + +// get html dom from string +function str_get_html( + $str, + $lowercase = true, + $forceTagsClosed = true, + $target_charset = DEFAULT_TARGET_CHARSET, + $stripRN = true, + $defaultBRText = DEFAULT_BR_TEXT, + $defaultSpanText = DEFAULT_SPAN_TEXT) +{ + $dom = new simple_html_dom( + null, + $lowercase, + $forceTagsClosed, + $target_charset, + $stripRN, + $defaultBRText, + $defaultSpanText); + + if (empty($str) || strlen($str) > MAX_FILE_SIZE) { + $dom->clear(); + return false; + } + + $dom->load($str, $lowercase, $stripRN); + return $dom; +} + +// dump html dom tree +function dump_html_tree($node, $show_attr = true, $deep = 0) +{ + $node->dump($node); +} + +/** + * simple html dom node + * PaperG - added ability for "find" routine to lowercase the value of the + * selector. + * + * PaperG - added $tag_start to track the start position of the tag in the total + * byte index + * + * @package PlaceLocalInclude + */ +class simple_html_dom_node +{ + /** + * Node type + * + * Default is {@see HDOM_TYPE_TEXT} + * + * @var int + */ + public $nodetype = HDOM_TYPE_TEXT; + + /** + * Tag name + * + * Default is 'text' + * + * @var string + */ + public $tag = 'text'; + + /** + * List of attributes + * + * @var array + */ + public $attr = array(); + + /** + * List of child node objects + * + * @var array + */ + public $children = array(); + public $nodes = array(); + + /** + * The parent node object + * + * @var object|null + */ + public $parent = null; + + // The "info" array - see HDOM_INFO_... for what each element contains. + public $_ = array(); + + /** + * Start position of the tag in the document + * + * @var int + */ + public $tag_start = 0; + + /** + * The DOM object + * + * @var object|null + */ + private $dom = null; + + /** + * Construct new node object + * + * Adds itself to the list of DOM Nodes {@see simple_html_dom::$nodes} + */ + function __construct($dom) + { + $this->dom = $dom; + $dom->nodes[] = $this; + } + + function __destruct() + { + $this->clear(); + } + + function __toString() + { + return $this->outertext(); + } + + // clean up memory due to php5 circular references memory leak... + function clear() + { + $this->dom = null; + $this->nodes = null; + $this->parent = null; + $this->children = null; + } + + // dump node's tree + function dump($show_attr = true, $deep = 0) + { + $lead = str_repeat(' ', $deep); + + echo $lead . $this->tag; + + if ($show_attr && count($this->attr) > 0) { + echo '('; + foreach ($this->attr as $k => $v) { + echo "[$k]=>\"" . $this->$k . '", '; + } + echo ')'; + } + + echo "\n"; + + if ($this->nodes) { + foreach ($this->nodes as $c) { + $c->dump($show_attr, $deep + 1); + } + } + } + + + // Debugging function to dump a single dom node with a bunch of information about it. + function dump_node($echo = true) + { + $string = $this->tag; + + if (count($this->attr) > 0) { + $string .= '('; + foreach ($this->attr as $k => $v) { + $string .= "[$k]=>\"" . $this->$k . '", '; + } + $string .= ')'; + } + + if (count($this->_) > 0) { + $string .= ' $_ ('; + foreach ($this->_ as $k => $v) { + if (is_array($v)) { + $string .= "[$k]=>("; + foreach ($v as $k2 => $v2) { + $string .= "[$k2]=>\"" . $v2 . '", '; + } + $string .= ')'; + } else { + $string .= "[$k]=>\"" . $v . '", '; + } + } + $string .= ')'; + } + + if (isset($this->text)) { + $string .= ' text: (' . $this->text . ')'; + } + + $string .= " HDOM_INNER_INFO: '"; + + if (isset($node->_[HDOM_INFO_INNER])) { + $string .= $node->_[HDOM_INFO_INNER] . "'"; + } else { + $string .= ' NULL '; + } + + $string .= ' children: ' . count($this->children); + $string .= ' nodes: ' . count($this->nodes); + $string .= ' tag_start: ' . $this->tag_start; + $string .= "\n"; + + if ($echo) { + echo $string; + return; + } else { + return $string; + } + } + + /** + * Return or set parent node + * + * @param object|null $parent (optional) The parent node, `null` to return + * the current parent node. + * @return object|null The parent node + */ + function parent($parent = null) + { + // I am SURE that this doesn't work properly. + // It fails to unset the current node from it's current parents nodes or + // children list first. + if ($parent !== null) { + $this->parent = $parent; + $this->parent->nodes[] = $this; + $this->parent->children[] = $this; + } + + return $this->parent; + } + + /** + * @return bool True if the node has at least one child node + */ + function has_child() + { + return !empty($this->children); + } + + /** + * Get child node at specified index + * + * @param int $idx The index of the child node to return, `-1` to return all + * child nodes. + * @return object|array|null The child node at the specified index, all child + * nodes or null if the index is invalid. + */ + function children($idx = -1) + { + if ($idx === -1) { + return $this->children; + } + + if (isset($this->children[$idx])) { + return $this->children[$idx]; + } + + return null; + } + + /** + * Get first child node + * + * @return object|null The first child node or null if the current node has + * no child nodes. + * + * @todo Use `empty()` instead of `count()` to improve performance on large + * arrays. + */ + function first_child() + { + if (count($this->children) > 0) { + return $this->children[0]; + } + return null; + } + + /** + * Get last child node + * + * @return object|null The last child node or null if the current node has + * no child nodes. + * + * @todo Use `end()` to slightly improve performance on large arrays. + */ + function last_child() + { + if (($count = count($this->children)) > 0) { + return $this->children[$count - 1]; + } + return null; + } + + /** + * Get next sibling node + * + * @return object|null The sibling node or null if the current node has no + * sibling nodes. + */ + function next_sibling() + { + if ($this->parent === null) { + return null; + } + + $idx = 0; + $count = count($this->parent->children); + + while ($idx < $count && $this !== $this->parent->children[$idx]) { + ++$idx; + } + + if (++$idx >= $count) { + return null; + } + + return $this->parent->children[$idx]; + } + + /** + * Get previous sibling node + * + * @return object|null The sibling node or null if the current node has no + * sibling nodes. + */ + function prev_sibling() + { + if ($this->parent === null) { return null; } + + $idx = 0; + $count = count($this->parent->children); + + while ($idx < $count && $this !== $this->parent->children[$idx]) { + ++$idx; + } + + if (--$idx < 0) { return null; } + + return $this->parent->children[$idx]; + } + + /** + * Traverse ancestors to the first matching tag. + * + * @param string $tag Tag to find + * @return object|null First matching node in the DOM tree or null if no + * match was found. + * + * @todo Null is returned implicitly by calling ->parent on the root node. + * This behaviour could change at any time, rendering this function invalid. + */ + function find_ancestor_tag($tag) + { + global $debug_object; + if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } + + // Start by including ourselves in the comparison. + $returnDom = $this; + + while (!is_null($returnDom)) { + if (is_object($debug_object)) { + $debug_object->debug_log(2, 'Current tag is: ' . $returnDom->tag); + } + + if ($returnDom->tag == $tag) { + break; + } + + $returnDom = $returnDom->parent; + } + + return $returnDom; + } + + /** + * Get node's inner text (everything inside the opening and closing tags) + * + * @return string + */ + function innertext() + { + if (isset($this->_[HDOM_INFO_INNER])) { + return $this->_[HDOM_INFO_INNER]; + } + + if (isset($this->_[HDOM_INFO_TEXT])) { + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + } + + $ret = ''; + + foreach ($this->nodes as $n) { + $ret .= $n->outertext(); + } + + return $ret; + } + + /** + * Get node's outer text (everything including the opening and closing tags) + * + * @return string + */ + function outertext() + { + global $debug_object; + + if (is_object($debug_object)) { + $text = ''; + + if ($this->tag === 'text') { + if (!empty($this->text)) { + $text = ' with text: ' . $this->text; + } + } + + $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text); + } + + if ($this->tag === 'root') return $this->innertext(); + + // trigger callback + if ($this->dom && $this->dom->callback !== null) { + call_user_func_array($this->dom->callback, array($this)); + } + + if (isset($this->_[HDOM_INFO_OUTER])) { + return $this->_[HDOM_INFO_OUTER]; + } + + if (isset($this->_[HDOM_INFO_TEXT])) { + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + } + + // render begin tag + if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) { + $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup(); + } else { + $ret = ''; + } + + // render inner text + if (isset($this->_[HDOM_INFO_INNER])) { + // If it's a br tag... don't return the HDOM_INNER_INFO that we + // may or may not have added. + if ($this->tag !== 'br') { + $ret .= $this->_[HDOM_INFO_INNER]; + } + } else { + if ($this->nodes) { + foreach ($this->nodes as $n) { + $ret .= $this->convert_text($n->outertext()); + } + } + } + + // render end tag + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) { + $ret .= 'tag . '>'; + } + + return $ret; + } + + /** + * Get node's plain text (everything excluding all tags) + * + * @return string + */ + function text() + { + if (isset($this->_[HDOM_INFO_INNER])) { + return $this->_[HDOM_INFO_INNER]; + } + + switch ($this->nodetype) { + case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + case HDOM_TYPE_COMMENT: return ''; + case HDOM_TYPE_UNKNOWN: return ''; + } + + if (strcasecmp($this->tag, 'script') === 0) { return ''; } + if (strcasecmp($this->tag, 'style') === 0) { return ''; } + + $ret = ''; + + // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed + // for some span tags, and some p tags) $this->nodes is set to NULL. + // NOTE: This indicates that there is a problem where it's set to NULL + // without a clear happening. + // WHY is this happening? + if (!is_null($this->nodes)) { + foreach ($this->nodes as $n) { + // Start paragraph after a blank line + if ($n->tag === 'p') { + $ret .= "\n\n"; + } + + $ret .= $this->convert_text($n->text()); + + // If this node is a span... add a space at the end of it so + // multiple spans don't run into each other. This is plaintext + // after all. + if ($n->tag === 'span') { + $ret .= $this->dom->default_span_text; + } + } + } + return trim($ret); + } + + /** + * Get node's xml text (inner text as a CDATA section) + * + * @return string + */ + function xmltext() + { + $ret = $this->innertext(); + $ret = str_ireplace('', '', $ret); + return $ret; + } + + // build node's text with tag + function makeup() + { + // text, comment, unknown + if (isset($this->_[HDOM_INFO_TEXT])) { + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); + } + + $ret = '<' . $this->tag; + $i = -1; + + foreach ($this->attr as $key => $val) { + ++$i; + + // skip removed attribute + if ($val === null || $val === false) { continue; } + + $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; + + //no value attr: nowrap, checked selected... + if ($val === true) { + $ret .= $key; + } else { + switch ($this->_[HDOM_INFO_QUOTE][$i]) + { + case HDOM_QUOTE_DOUBLE: $quote = '"'; break; + case HDOM_QUOTE_SINGLE: $quote = '\''; break; + default: $quote = ''; + } + + $ret .= $key + . $this->_[HDOM_INFO_SPACE][$i][1] + . '=' + . $this->_[HDOM_INFO_SPACE][$i][2] + . $quote + . $val + . $quote; + } + } + + $ret = $this->dom->restore_noise($ret); + return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>'; + } + + /** + * Find elements by CSS selector + * + * @param string $selector The CSS selector + * @param int|null $idx Index of element to return form the list of matching + * elements (default: `null` = disabled). + * @param bool $lowercase Matches tag names case insensitive (lowercase) if + * enabled (default: `false`) + * @return array|object|null A list of elements matching the specified CSS + * selector or a single element if $idx is specified or null if no element + * was found. + */ + function find($selector, $idx = null, $lowercase = false) + { + $selectors = $this->parse_selector($selector); + if (($count = count($selectors)) === 0) { return array(); } + $found_keys = array(); + + // find each selector + for ($c = 0; $c < $count; ++$c) { + // The change on the below line was documented on the sourceforge + // code tracker id 2788009 + // used to be: if (($levle=count($selectors[0]))===0) return array(); + if (($levle = count($selectors[$c])) === 0) { return array(); } + if (!isset($this->_[HDOM_INFO_BEGIN])) { return array(); } + + $head = array($this->_[HDOM_INFO_BEGIN] => 1); + $cmd = ' '; // Combinator + + // handle descendant selectors, no recursive! + for ($l = 0; $l < $levle; ++$l) { + $ret = array(); + + foreach ($head as $k => $v) { + $n = ($k === -1) ? $this->dom->root : $this->dom->nodes[$k]; + //PaperG - Pass this optional parameter on to the seek function. + $n->seek($selectors[$c][$l], $ret, $cmd, $lowercase); + } + + $head = $ret; + $cmd = $selectors[$c][$l][4]; // Next Combinator + } + + foreach ($head as $k => $v) { + if (!isset($found_keys[$k])) { + $found_keys[$k] = 1; + } + } + } + + // sort keys + ksort($found_keys); + + $found = array(); + foreach ($found_keys as $k => $v) { + $found[] = $this->dom->nodes[$k]; + } + + // return nth-element or array + if (is_null($idx)) { return $found; } + elseif ($idx < 0) { $idx = count($found) + $idx; } + return (isset($found[$idx])) ? $found[$idx] : null; + } + + /** + * Seek DOM elements by selector + * + * **Note** + * The selector element must be compatible to a selector from + * {@see simple_html_dom_node::parse_selector()} + * + * @param array $selector A selector element + * @param array $ret An array of matches + * @param bool $lowercase Matches tag names case insensitive (lowercase) if + * enabled (default: `false`) + * @return void + */ + protected function seek($selector, &$ret, $parent_cmd, $lowercase = false) + { + global $debug_object; + if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } + + list($tag, $id, $class, $attributes, $cmb) = $selector; + $nodes = array(); + + if ($parent_cmd === ' ') { // Descendant Combinator + // Find parent closing tag if the current element doesn't have a closing + // tag (i.e. void element) + $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0; + if ($end == 0) { + $parent = $this->parent; + while (!isset($parent->_[HDOM_INFO_END]) && $parent !== null) { + $end -= 1; + $parent = $parent->parent; + } + $end += $parent->_[HDOM_INFO_END]; + } + + // Get list of target nodes + $nodes_start = $this->_[HDOM_INFO_BEGIN] + 1; + $nodes_count = $end - $nodes_start; + $nodes = array_slice($this->dom->nodes, $nodes_start, $nodes_count, true); + } elseif ($parent_cmd === '>') { // Child Combinator + $nodes = $this->children; + } elseif ($parent_cmd === '+' + && $this->parent + && in_array($this, $this->parent->children)) { // Next-Sibling Combinator + $index = array_search($this, $this->parent->children, true) + 1; + $nodes[] = $this->parent->children[$index]; + } elseif ($parent_cmd === '~' + && $this->parent + && in_array($this, $this->parent->children)) { // Subsequent Sibling Combinator + $index = array_search($this, $this->parent->children, true); + $nodes = array_slice($this->parent->children, $index); + } + + // Go throgh each element starting at this element until the end tag + // Note: If this element is a void tag, any previous void element is + // skipped. + foreach($nodes as $node) { + $pass = true; + + // Skip root nodes + if(!$node->parent) { + $pass = false; + } + + // Skip if node isn't a child node (i.e. text nodes) + if($pass && !in_array($node, $node->parent->children, true)) { + $pass = false; + } + + // Skip if tag doesn't match + if ($pass && $tag !== '' && $tag !== $node->tag && $tag !== '*') { + $pass = false; + } + + // Skip if ID doesn't exist + if ($pass && $id !== '' && !isset($node->attr['id'])) { + $pass = false; + } + + // Check if ID matches + if ($pass && $id !== '' && isset($node->attr['id'])) { + // Note: Only consider the first ID (as browsers do) + $node_id = explode(' ', trim($node->attr['id']))[0]; + + if($id !== $node_id) { $pass = false; } + } + + // Check if all class(es) exist + if ($pass && $class !== '' && is_array($class) && !empty($class)) { + if (isset($node->attr['class'])) { + $node_classes = explode(' ', $node->attr['class']); + + if ($lowercase) { + $node_classes = array_map('strtolower', $node_classes); + } + + foreach($class as $c) { + if(!in_array($c, $node_classes)) { + $pass = false; + break; + } + } + } else { + $pass = false; + } + } + + // Check attributes + if ($pass + && $attributes !== '' + && is_array($attributes) + && !empty($attributes)) { + foreach($attributes as $a) { + list ( + $att_name, + $att_expr, + $att_val, + $att_inv, + $att_case_sensitivity + ) = $a; + + // Handle indexing attributes (i.e. "[2]") + /** + * Note: This is not supported by the CSS Standard but adds + * the ability to select items compatible to XPath (i.e. + * the 3rd element within it's parent). + * + * Note: This doesn't conflict with the CSS Standard which + * doesn't work on numeric attributes anyway. + */ + if (is_numeric($att_name) + && $att_expr === '' + && $att_val === '') { + $count = 0; + + // Find index of current element in parent + foreach ($node->parent->children as $c) { + if ($c->tag === $node->tag) ++$count; + if ($c === $node) break; + } + + // If this is the correct node, continue with next + // attribute + if ($count === (int)$att_name) continue; + } + + // Check attribute availability + if ($att_inv) { // Attribute should NOT be set + if (isset($node->attr[$att_name])) { + $pass = false; + break; + } + } else { // Attribute should be set + // todo: "plaintext" is not a valid CSS selector! + if ($att_name !== 'plaintext' + && !isset($node->attr[$att_name])) { + $pass = false; + break; + } + } + + // Continue with next attribute if expression isn't defined + if ($att_expr === '') continue; + + // If they have told us that this is a "plaintext" + // search then we want the plaintext of the node - right? + // todo "plaintext" is not a valid CSS selector! + if ($att_name === 'plaintext') { + $nodeKeyValue = $node->text(); + } else { + $nodeKeyValue = $node->attr[$att_name]; + } + + if (is_object($debug_object)) { + $debug_object->debug_log(2, + 'testing node: ' + . $node->tag + . ' for attribute: ' + . $att_name + . $att_expr + . $att_val + . ' where nodes value is: ' + . $nodeKeyValue + ); + } + + // If lowercase is set, do a case insensitive test of + // the value of the selector. + if ($lowercase) { + $check = $this->match( + $att_expr, + strtolower($att_val), + strtolower($nodeKeyValue), + $att_case_sensitivity + ); + } else { + $check = $this->match( + $att_expr, + $att_val, + $nodeKeyValue, + $att_case_sensitivity + ); + } + + if (is_object($debug_object)) { + $debug_object->debug_log(2, + 'after match: ' + . ($check ? 'true' : 'false') + ); + } + + if (!$check) { + $pass = false; + break; + } + } + } + + // Found a match. Add to list and clear node + if ($pass) $ret[$node->_[HDOM_INFO_BEGIN]] = 1; + unset($node); + } + // It's passed by reference so this is actually what this function returns. + if (is_object($debug_object)) { + $debug_object->debug_log(1, 'EXIT - ret: ', $ret); + } + } + + /** + * Match value and pattern for a given CSS expression + * + * **Supported Expressions** + * + * | Expression | Description + * | ---------- | ----------- + * | `=` | $value and $pattern must be equal + * | `!=` | $value and $pattern must not be equal + * | `^=` | $value must start with $pattern + * | `$=` | $value must end with $pattern + * | `*=` | $value must contain $pattern + * + * @param string $exp The expression. + * @param string $pattern The pattern + * @param string $value The value + * @value bool True if $value matches $pattern + */ + protected function match($exp, $pattern, $value, $case_sensitivity) + { + global $debug_object; + if (is_object($debug_object)) {$debug_object->debug_log_entry(1);} + + if ($case_sensitivity === 'i') { + $pattern = strtolower($pattern); + $value = strtolower($value); + } + + switch ($exp) { + case '=': + return ($value === $pattern); + case '!=': + return ($value !== $pattern); + case '^=': + return preg_match('/^' . preg_quote($pattern, '/') . '/', $value); + case '$=': + return preg_match('/' . preg_quote($pattern, '/') . '$/', $value); + case '*=': + return preg_match('/' . preg_quote($pattern, '/') . '/', $value); + case '|=': + /** + * [att|=val] + * + * Represents an element with the att attribute, its value + * either being exactly "val" or beginning with "val" + * immediately followed by "-" (U+002D). + */ + return strpos($value, $pattern) === 0; + case '~=': + /** + * [att~=val] + * + * Represents an element with the att attribute whose value is a + * whitespace-separated list of words, one of which is exactly + * "val". If "val" contains whitespace, it will never represent + * anything (since the words are separated by spaces). Also if + * "val" is the empty string, it will never represent anything. + */ + return in_array($pattern, explode(' ', trim($value)), true); + } + return false; + } + + /** + * Parse CSS selector + * + * @param string $selector_string CSS selector string + * @return array List of CSS selectors. The format depends on the type of + * selector: + * + * ```php + * + * array( // list of selectors (each separated by a comma), i.e. 'img, p, div' + * array( // list of combinator selectors, i.e. 'img > p > div' + * array( // selector element + * [0], // (string) The element tag + * [1], // (string) The element id + * [2], // (array) The element classes + * [3], // (array>) The list of attributes, each + * // with four elements: name, expression, value, inverted + * [4] // (string) The selector combinator (' ' | '>' | '+' | '~') + * ) + * ) + * ) + * ``` + * + * @link https://www.w3.org/TR/selectors/#compound Compound selector + */ + protected function parse_selector($selector_string) + { + global $debug_object; + if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } + + /** + * Pattern of CSS selectors, modified from mootools (https://mootools.net/) + * + * Paperg: Add the colon to the attribute, so that it properly finds + * like google does. + * + * Note: if you try to look at this attribute, you MUST use getAttribute + * since $dom->x:y will fail the php syntax check. + * + * Notice the \[ starting the attribute? and the @? following? This + * implies that an attribute can begin with an @ sign that is not + * captured. This implies that an html attribute specifier may start + * with an @ sign that is NOT captured by the expression. Farther study + * is required to determine of this should be documented or removed. + * + * Matches selectors in this order: + * + * [0] - full match + * + * [1] - tag name + * ([\w:\*-]*) + * Matches the tag name consisting of zero or more words, colons, + * asterisks and hyphens. + * + * [2] - id name + * (?:\#([\w-]+)) + * Optionally matches a id name, consisting of an "#" followed by + * the id name (one or more words and hyphens). + * + * [3] - class names (including dots) + * (?:\.([\w\.-]+))? + * Optionally matches a list of classs, consisting of an "." + * followed by the class name (one or more words and hyphens) + * where multiple classes can be chained (i.e. ".foo.bar.baz") + * + * [4] - attributes + * ((?:\[@?(?:!?[\w:-]+)(?:(?:[!*^$|~]?=)[\"']?(?:.*?)[\"']?)?(?:\s*?(?:[iIsS])?)?\])+)? + * Optionally matches the attributes list + * + * [5] - separator + * ([\/, >+~]+) + * Matches the selector list separator + */ + // phpcs:ignore Generic.Files.LineLength + $pattern = "/([\w:\*-]*)(?:\#([\w-]+))?(?:|\.([\w\.-]+))?((?:\[@?(?:!?[\w:-]+)(?:(?:[!*^$|~]?=)[\"']?(?:.*?)[\"']?)?(?:\s*?(?:[iIsS])?)?\])+)?([\/, >+~]+)/is"; + + preg_match_all( + $pattern, + trim($selector_string) . ' ', // Add final ' ' as pseudo separator + $matches, + PREG_SET_ORDER + ); + + if (is_object($debug_object)) { + $debug_object->debug_log(2, 'Matches Array: ', $matches); + } + + $selectors = array(); + $result = array(); + + foreach ($matches as $m) { + $m[0] = trim($m[0]); + + // Skip NoOps + if ($m[0] === '' || $m[0] === '/' || $m[0] === '//') { continue; } + + // Convert to lowercase + if ($this->dom->lowercase) { + $m[1] = strtolower($m[1]); + } + + // Extract classes + if ($m[3] !== '') { $m[3] = explode('.', $m[3]); } + + /* Extract attributes (pattern based on the pattern above!) + + * [0] - full match + * [1] - attribute name + * [2] - attribute expression + * [3] - attribute value + * [4] - case sensitivity + * + * Note: Attributes can be negated with a "!" prefix to their name + */ + if($m[4] !== '') { + preg_match_all( + "/\[@?(!?[\w:-]+)(?:([!*^$|~]?=)[\"']?(.*?)[\"']?)?(?:\s*?([iIsS])?)?\]/is", + trim($m[4]), + $attributes, + PREG_SET_ORDER + ); + + // Replace element by array + $m[4] = array(); + + foreach($attributes as $att) { + // Skip empty matches + if(trim($att[0]) === '') { continue; } + + $inverted = (isset($att[1][0]) && $att[1][0] === '!'); + $m[4][] = array( + $inverted ? substr($att[1], 1) : $att[1], // Name + (isset($att[2])) ? $att[2] : '', // Expression + (isset($att[3])) ? $att[3] : '', // Value + $inverted, // Inverted Flag + (isset($att[4])) ? strtolower($att[4]) : '', // Case-Sensitivity + ); + } + } + + // Sanitize Separator + if ($m[5] !== '' && trim($m[5]) === '') { // Descendant Separator + $m[5] = ' '; + } else { // Other Separator + $m[5] = trim($m[5]); + } + + // Clear Separator if it's a Selector List + if ($is_list = ($m[5] === ',')) { $m[5] = ''; } + + // Remove full match before adding to results + array_shift($m); + $result[] = $m; + + if ($is_list) { // Selector List + $selectors[] = $result; + $result = array(); + } + } + + if (count($result) > 0) { $selectors[] = $result; } + return $selectors; + } + + function __get($name) + { + if (isset($this->attr[$name])) { + return $this->convert_text($this->attr[$name]); + } + switch ($name) { + case 'outertext': return $this->outertext(); + case 'innertext': return $this->innertext(); + case 'plaintext': return $this->text(); + case 'xmltext': return $this->xmltext(); + default: return array_key_exists($name, $this->attr); + } + } + + function __set($name, $value) + { + global $debug_object; + if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } + + switch ($name) { + case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; + case 'innertext': + if (isset($this->_[HDOM_INFO_TEXT])) { + return $this->_[HDOM_INFO_TEXT] = $value; + } + return $this->_[HDOM_INFO_INNER] = $value; + } + + if (!isset($this->attr[$name])) { + $this->_[HDOM_INFO_SPACE][] = array(' ', '', ''); + $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE; + } + + $this->attr[$name] = $value; + } + + function __isset($name) + { + switch ($name) { + case 'outertext': return true; + case 'innertext': return true; + case 'plaintext': return true; + } + //no value attr: nowrap, checked selected... + return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]); + } + + function __unset($name) + { + if (isset($this->attr[$name])) { unset($this->attr[$name]); } + } + + // PaperG - Function to convert the text from one character set to another + // if the two sets are not the same. + function convert_text($text) + { + global $debug_object; + if (is_object($debug_object)) { $debug_object->debug_log_entry(1); } + + $converted_text = $text; + + $sourceCharset = ''; + $targetCharset = ''; + + if ($this->dom) { + $sourceCharset = strtoupper($this->dom->_charset); + $targetCharset = strtoupper($this->dom->_target_charset); + } + + if (is_object($debug_object)) { + $debug_object->debug_log(3, + 'source charset: ' + . $sourceCharset + . ' target charaset: ' + . $targetCharset + ); + } + + if (!empty($sourceCharset) + && !empty($targetCharset) + && (strcasecmp($sourceCharset, $targetCharset) != 0)) { + // Check if the reported encoding could have been incorrect and the text is actually already UTF-8 + if ((strcasecmp($targetCharset, 'UTF-8') == 0) + && ($this->is_utf8($text))) { + $converted_text = $text; + } else { + $converted_text = iconv($sourceCharset, $targetCharset, $text); + } + } + + // Lets make sure that we don't have that silly BOM issue with any of the utf-8 text we output. + if ($targetCharset === 'UTF-8') { + if (substr($converted_text, 0, 3) === "\xef\xbb\xbf") { + $converted_text = substr($converted_text, 3); + } + + if (substr($converted_text, -3) === "\xef\xbb\xbf") { + $converted_text = substr($converted_text, 0, -3); + } + } + + return $converted_text; + } + + /** + * Returns true if $string is valid UTF-8 and false otherwise. + * + * @param mixed $str String to be tested + * @return boolean + */ + static function is_utf8($str) + { + $c = 0; $b = 0; + $bits = 0; + $len = strlen($str); + for($i = 0; $i < $len; $i++) { + $c = ord($str[$i]); + if($c > 128) { + if(($c >= 254)) { return false; } + elseif($c >= 252) { $bits = 6; } + elseif($c >= 248) { $bits = 5; } + elseif($c >= 240) { $bits = 4; } + elseif($c >= 224) { $bits = 3; } + elseif($c >= 192) { $bits = 2; } + else { return false; } + if(($i + $bits) > $len) { return false; } + while($bits > 1) { + $i++; + $b = ord($str[$i]); + if($b < 128 || $b > 191) { return false; } + $bits--; + } + } + } + return true; + } + + /** + * Function to try a few tricks to determine the displayed size of an img on + * the page. NOTE: This will ONLY work on an IMG tag. Returns FALSE on all + * other tag types. + * + * @author John Schlick + * @version April 19 2012 + * @return array an array containing the 'height' and 'width' of the image + * on the page or -1 if we can't figure it out. + */ + function get_display_size() + { + global $debug_object; + + $width = -1; + $height = -1; + + if ($this->tag !== 'img') { + return false; + } + + // See if there is aheight or width attribute in the tag itself. + if (isset($this->attr['width'])) { + $width = $this->attr['width']; + } + + if (isset($this->attr['height'])) { + $height = $this->attr['height']; + } + + // Now look for an inline style. + if (isset($this->attr['style'])) { + // Thanks to user gnarf from stackoverflow for this regular expression. + $attributes = array(); + + preg_match_all( + '/([\w-]+)\s*:\s*([^;]+)\s*;?/', + $this->attr['style'], + $matches, + PREG_SET_ORDER + ); + + foreach ($matches as $match) { + $attributes[$match[1]] = $match[2]; + } + + // If there is a width in the style attributes: + if (isset($attributes['width']) && $width == -1) { + // check that the last two characters are px (pixels) + if (strtolower(substr($attributes['width'], -2)) === 'px') { + $proposed_width = substr($attributes['width'], 0, -2); + // Now make sure that it's an integer and not something stupid. + if (filter_var($proposed_width, FILTER_VALIDATE_INT)) { + $width = $proposed_width; + } + } + } + + // If there is a width in the style attributes: + if (isset($attributes['height']) && $height == -1) { + // check that the last two characters are px (pixels) + if (strtolower(substr($attributes['height'], -2)) == 'px') { + $proposed_height = substr($attributes['height'], 0, -2); + // Now make sure that it's an integer and not something stupid. + if (filter_var($proposed_height, FILTER_VALIDATE_INT)) { + $height = $proposed_height; + } + } + } + + } + + // Future enhancement: + // Look in the tag to see if there is a class or id specified that has + // a height or width attribute to it. + + // Far future enhancement + // Look at all the parent tags of this image to see if they specify a + // class or id that has an img selector that specifies a height or width + // Note that in this case, the class or id will have the img subselector + // for it to apply to the image. + + // ridiculously far future development + // If the class or id is specified in a SEPARATE css file thats not on + // the page, go get it and do what we were just doing for the ones on + // the page. + + $result = array( + 'height' => $height, + 'width' => $width + ); + + return $result; + } + + // camel naming conventions + function getAllAttributes() + { + return $this->attr; + } + + function getAttribute($name) + { + return $this->__get($name); + } + + function setAttribute($name, $value) + { + $this->__set($name, $value); + } + + function hasAttribute($name) + { + return $this->__isset($name); + } + + function removeAttribute($name) + { + $this->__set($name, null); + } + + function getElementById($id) + { + return $this->find("#$id", 0); + } + + function getElementsById($id, $idx = null) + { + return $this->find("#$id", $idx); + } + + function getElementByTagName($name) + { + return $this->find($name, 0); + } + + function getElementsByTagName($name, $idx = null) + { + return $this->find($name, $idx); + } + + function parentNode() + { + return $this->parent(); + } + + function childNodes($idx = -1) + { + return $this->children($idx); + } + + function firstChild() + { + return $this->first_child(); + } + + function lastChild() + { + return $this->last_child(); + } + + function nextSibling() + { + return $this->next_sibling(); + } + + function previousSibling() + { + return $this->prev_sibling(); + } + + function hasChildNodes() + { + return $this->has_child(); + } + + function nodeName() + { + return $this->tag; + } + + function appendChild($node) + { + $node->parent($this); + return $node; + } + +} + +/** + * simple html dom parser + * + * Paperg - in the find routine: allow us to specify that we want case + * insensitive testing of the value of the selector. + * + * Paperg - change $size from protected to public so we can easily access it + * + * Paperg - added ForceTagsClosed in the constructor which tells us whether we + * trust the html or not. Default is to NOT trust it. + * + * @package PlaceLocalInclude + */ +class simple_html_dom +{ + /** + * The root node of the document + * + * @var object + */ + public $root = null; + + /** + * List of nodes in the current DOM + * + * @var array + */ + public $nodes = array(); + + /** + * Callback function to run for each element in the DOM. + * + * @var callable|null + */ + public $callback = null; + + /** + * Indicates how tags and attributes are matched + * + * @var bool When set to **true** tags and attributes will be converted to + * lowercase before matching. + */ + public $lowercase = false; + + /** + * Original document size + * + * Holds the original document size. + * + * @var int + */ + public $original_size; + + /** + * Current document size + * + * Holds the current document size. The document size is determined by the + * string length of ({@see simple_html_dom::$doc}). + * + * _Note_: Using this variable is more efficient than calling `strlen($doc)` + * + * @var int + * */ + public $size; + + /** + * Current position in the document + * + * @var int + */ + protected $pos; + + /** + * The document + * + * @var string + */ + protected $doc; + + /** + * Current character + * + * Holds the current character at position {@see simple_html_dom::$pos} in + * the document {@see simple_html_dom::$doc} + * + * _Note_: Using this variable is more efficient than calling + * `substr($doc, $pos, 1)` + * + * @var string + */ + protected $char; + + protected $cursor; + + /** + * Parent node of the next node detected by the parser + * + * @var object + */ + protected $parent; + protected $noise = array(); + + /** + * Tokens considered blank in HTML + * + * @var string + */ + protected $token_blank = " \t\r\n"; + + /** + * Tokens to identify the equal sign for attributes, stopping either at the + * closing tag ("/" i.e. "") or the end of an opening tag (">" i.e. + * "") + * + * @var string + */ + protected $token_equal = ' =/>'; + + /** + * Tokens to identify the end of a tag name. A tag name either ends on the + * ending slash ("/" i.e. "") or whitespace ("\s\r\n\t") + * + * @var string + */ + protected $token_slash = " />\r\n\t"; + + /** + * Tokens to identify the end of an attribute + * + * @var string + */ + protected $token_attr = ' >'; + + // Note that this is referenced by a child node, and so it needs to be + // public for that node to see this information. + public $_charset = ''; + public $_target_charset = ''; + + /** + * Innertext for
elements + * + * @var string + */ + protected $default_br_text = ''; + + /** + * Suffix for elements + * + * @var string + */ + public $default_span_text = ''; + + /** + * Defines a list of self-closing tags (Void elements) according to the HTML + * Specification + * + * _Remarks_: + * - Use `isset()` instead of `in_array()` on array elements to boost + * performance about 30% + * - Sort elements by name for better readability! + * + * @link https://www.w3.org/TR/html HTML Specification + * @link https://www.w3.org/TR/html/syntax.html#void-elements Void elements + */ + protected $self_closing_tags = array( + 'area' => 1, + 'base' => 1, + 'br' => 1, + 'col' => 1, + 'embed' => 1, + 'hr' => 1, + 'img' => 1, + 'input' => 1, + 'link' => 1, + 'meta' => 1, + 'param' => 1, + 'source' => 1, + 'track' => 1, + 'wbr' => 1 + ); + + /** + * Defines a list of tags which - if closed - close all optional closing + * elements within if they haven't been closed yet. (So, an element where + * neither opening nor closing tag is omissible consistently closes every + * optional closing element within) + * + * _Remarks_: + * - Use `isset()` instead of `in_array()` on array elements to boost + * performance about 30% + * - Sort elements by name for better readability! + */ + protected $block_tags = array( + 'body' => 1, + 'div' => 1, + 'form' => 1, + 'root' => 1, + 'span' => 1, + 'table' => 1 + ); + + /** + * Defines elements whose end tag is omissible. + * + * * key = Name of an element whose end tag is omissible. + * * value = Names of elements whose end tag is omissible, that are closed + * by the current element. + * + * _Remarks_: + * - Use `isset()` instead of `in_array()` on array elements to boost + * performance about 30% + * - Sort elements by name for better readability! + * + * **Example** + * + * An `li` element’s end tag may be omitted if the `li` element is immediately + * followed by another `li` element. To do that, add following element to the + * array: + * + * ```php + * 'li' => array('li'), + * ``` + * + * With this, the following two examples are considered equal. Note that the + * second example is missing the closing tags on `li` elements. + * + * ```html + *
  • First Item
  • Second Item
+ * ``` + * + *
  • First Item
  • Second Item
+ * + * ```html + *
  • First Item
  • Second Item
+ * ``` + * + *
  • First Item
  • Second Item
+ * + * @var array A two-dimensional array where the key is the name of an + * element whose end tag is omissible and the value is an array of elements + * whose end tag is omissible, that are closed by the current element. + * + * @link https://www.w3.org/TR/html/syntax.html#optional-tags Optional tags + * + * @todo The implementation of optional closing tags doesn't work in all cases + * because it only consideres elements who close other optional closing + * tags, not taking into account that some (non-blocking) tags should close + * these optional closing tags. For example, the end tag for "p" is omissible + * and can be closed by an "address" element, whose end tag is NOT omissible. + * Currently a "p" element without closing tag stops at the next "p" element + * or blocking tag, even if it contains other elements. + * + * @todo Known sourceforge issue #2977341 + * B tags that are not closed cause us to return everything to the end of + * the document. + */ + protected $optional_closing_tags = array( + // Not optional, see + // https://www.w3.org/TR/html/textlevel-semantics.html#the-b-element + 'b' => array('b' => 1), + 'dd' => array('dd' => 1, 'dt' => 1), + // Not optional, see + // https://www.w3.org/TR/html/grouping-content.html#the-dl-element + 'dl' => array('dd' => 1, 'dt' => 1), + 'dt' => array('dd' => 1, 'dt' => 1), + 'li' => array('li' => 1), + 'optgroup' => array('optgroup' => 1, 'option' => 1), + 'option' => array('optgroup' => 1, 'option' => 1), + 'p' => array('p' => 1), + 'rp' => array('rp' => 1, 'rt' => 1), + 'rt' => array('rp' => 1, 'rt' => 1), + 'td' => array('td' => 1, 'th' => 1), + 'th' => array('td' => 1, 'th' => 1), + 'tr' => array('td' => 1, 'th' => 1, 'tr' => 1), + ); + + function __construct( + $str = null, + $lowercase = true, + $forceTagsClosed = true, + $target_charset = DEFAULT_TARGET_CHARSET, + $stripRN = true, + $defaultBRText = DEFAULT_BR_TEXT, + $defaultSpanText = DEFAULT_SPAN_TEXT, + $options = 0) + { + if ($str) { + if (preg_match('/^http:\/\//i', $str) || is_file($str)) { + $this->load_file($str); + } else { + $this->load( + $str, + $lowercase, + $stripRN, + $defaultBRText, + $defaultSpanText, + $options + ); + } + } + // Forcing tags to be closed implies that we don't trust the html, but + // it can lead to parsing errors if we SHOULD trust the html. + if (!$forceTagsClosed) { + $this->optional_closing_array = array(); + } + + $this->_target_charset = $target_charset; + } + + function __destruct() + { + $this->clear(); + } + + // load html from string + function load( + $str, + $lowercase = true, + $stripRN = true, + $defaultBRText = DEFAULT_BR_TEXT, + $defaultSpanText = DEFAULT_SPAN_TEXT, + $options = 0) + { + global $debug_object; + + // prepare + $this->prepare($str, $lowercase, $defaultBRText, $defaultSpanText); + + // Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037 + // Script tags removal now preceeds style tag removal. + // strip out