├── icon.rc.in
├── version.txt.in
├── src
├── tilefactory
│ ├── rust
│ │ ├── .gitignore
│ │ ├── build.rs
│ │ ├── Cargo.toml
│ │ ├── lib.rs
│ │ └── CMakeLists.txt
│ ├── coverageratio.h
│ ├── include
│ │ └── tilefactory
│ │ │ ├── itilesource.h
│ │ │ ├── triangulator.h
│ │ │ ├── pos.h
│ │ │ ├── catalog.h
│ │ │ ├── mercator.h
│ │ │ ├── oesenctilesource.h
│ │ │ ├── georect.h
│ │ │ ├── chartclipper.h
│ │ │ ├── chart.h
│ │ │ └── tilefactory.h
│ ├── pos.cpp
│ ├── filehelper.h
│ ├── triangulator.cpp
│ ├── CMakeLists.txt
│ ├── georect.cpp
│ ├── filehelper.cpp
│ ├── coverageratio.cpp
│ ├── mercator.cpp
│ ├── chartdata.capnp
│ ├── catalog.cpp
│ ├── oesenctilesource.cpp
│ └── chartclipper.cpp
├── scene
│ ├── geometrynode.cpp
│ ├── geometrynode.h
│ ├── polygon
│ │ ├── polygonshader.h
│ │ ├── polygon.frag
│ │ ├── polygon.vert
│ │ ├── polygonmaterial.h
│ │ ├── polygonnode.h
│ │ ├── polygonmaterial.cpp
│ │ ├── polygonshader.cpp
│ │ └── polygonnode.cpp
│ ├── test
│ │ ├── CMakeLists.txt
│ │ └── fontimage_test.cpp
│ ├── line
│ │ ├── line.frag
│ │ ├── lineshader.h
│ │ ├── linematerial.h
│ │ ├── linenode.h
│ │ ├── linematerial.cpp
│ │ ├── line.vert
│ │ ├── lineshader.cpp
│ │ └── linenode.cpp
│ ├── rootnode.h
│ ├── annotations
│ │ ├── zoomsweeper.h
│ │ ├── annotationmaterial.h
│ │ ├── annotationmaterial.cpp
│ │ ├── annotation.vert
│ │ ├── annotationshader.h
│ │ ├── annotationnode.h
│ │ ├── annotation.frag
│ │ ├── symbolimage.h
│ │ ├── annotationshader.cpp
│ │ ├── annotationnode.cpp
│ │ └── annotater.h
│ ├── rootnode.cpp
│ ├── tiledata.h
│ ├── tilefactorywrapper.cpp
│ ├── materialcreator.h
│ ├── include
│ │ └── scene
│ │ │ ├── annotations
│ │ │ ├── fontimage.h
│ │ │ └── types.h
│ │ │ ├── tilefactorywrapper.h
│ │ │ └── scene.h
│ ├── tessellator.h
│ ├── materialcreator.cpp
│ └── CMakeLists.txt
├── licenses.h
├── tileinfobackend.h
├── maptilemodel.h
├── mercatorwrapper.h
├── licenses.cpp
├── usersettings.h
├── tileinfobackend.cpp
├── chartmodel.h
├── usersettings.cpp
├── main.cpp
├── maptilemodel.cpp
└── maptile.h
├── .gitignore
├── version.h.in
├── chocolatey.config
├── qml
├── XdgFileDialogWrapper.qml
├── qmldir
├── qml.qrc
├── about.md
├── ChartSelector.qml
├── FolderDialog.qml
├── StatusBar.qml
├── About.qml
└── TileInfo.qml
├── snap
├── gui
│ └── nautograf.desktop
└── snapcraft.yaml
├── deploy-qt-windows.cmake.in
├── symbols
├── test_symbol.svg
├── underwater_rocks
│ ├── awash.svg
│ ├── always_submerged.svg
│ └── cover_and_uncovers.svg
├── buoys
│ ├── super_buoy.svg
│ ├── can.svg
│ ├── spar_port.svg
│ ├── spar_starboard.svg
│ ├── conical.svg
│ ├── barrel.svg
│ ├── pillar.svg
│ └── spherical.svg
├── beacons
│ └── beacon_norwegian.svg
└── symbols.qrc
├── .commitlintrc.mjs
├── privacy_policy.md
├── .clang-format
├── vcpkg.json
├── cmake
├── InstallLicense.cmake
└── GetVersionFromGit.cmake
├── create_icon.sh
├── external
└── CMakeLists.txt
├── .gitmodules
├── AppxManifest.xml.in
├── CMakePresets.json
├── README.md
├── CMakeLists.txt
└── .github
└── workflows
└── ci.yml
/icon.rc.in:
--------------------------------------------------------------------------------
1 | Icon ICON icon.ico
2 |
--------------------------------------------------------------------------------
/version.txt.in:
--------------------------------------------------------------------------------
1 | @NAUTOGRAF_VERSION_DESCRIBE@
2 |
3 |
--------------------------------------------------------------------------------
/src/tilefactory/rust/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | Cargo.lock
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | CMakeLists.txt.user
2 | CMakeUserPresets.json
3 | build*
4 | *.png
5 | *.ico
6 |
--------------------------------------------------------------------------------
/version.h.in:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define NAUTOGRAF_VERSION "@NAUTOGRAF_VERSION_DESCRIBE@"
4 |
--------------------------------------------------------------------------------
/chocolatey.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/qml/XdgFileDialogWrapper.qml:
--------------------------------------------------------------------------------
1 | import QtQuick
2 | import org.seatronomy.nautograf
3 |
4 | // Only used on Linux when compiled with option USE_XDG_FILE_DIALOG
5 |
6 | XdgFileDialog {}
7 |
--------------------------------------------------------------------------------
/snap/gui/nautograf.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Type=Application
3 | Name=Nautograf
4 | Comment=Tile-based nautical chart viewer
5 | Exec=nautograf
6 | Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/nautograf.svg
7 |
--------------------------------------------------------------------------------
/qml/qmldir:
--------------------------------------------------------------------------------
1 | module Nautograf
2 | Viewer 1.0 Viewer.qml
3 | ChartSelector 1.0 ChartSelector.qml
4 | ViewerMenu 1.0 ViewerMenu.qml
5 | ViewerMenuItem 1.0 ViewerMenuItem.qml
6 | StatusBar 1.0 StatusBar.qml
7 | TileInfo 1.0 TileInfo.qml
8 |
--------------------------------------------------------------------------------
/src/scene/geometrynode.cpp:
--------------------------------------------------------------------------------
1 | #include "geometrynode.h"
2 |
3 | GeometryNode::GeometryNode(const QString &id)
4 | : m_id(id)
5 | {
6 | }
7 |
8 | const QString &GeometryNode::id() const
9 | {
10 | return m_id;
11 | }
12 |
--------------------------------------------------------------------------------
/src/tilefactory/rust/build.rs:
--------------------------------------------------------------------------------
1 | use cxx_build::CFG;
2 |
3 | #[allow(unused_must_use)]
4 | fn main() {
5 | CFG.include_prefix = "tilefactory_rust";
6 | cxx_build::bridge("lib.rs");
7 | println!("cargo:rerun-if-changed=lib.rs");
8 | }
9 |
--------------------------------------------------------------------------------
/deploy-qt-windows.cmake.in:
--------------------------------------------------------------------------------
1 | set(WINDEPLOYQT "@WINDEPLOYQT@")
2 | set(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
3 |
4 | execute_process(
5 | COMMAND ${WINDEPLOYQT} --no-compiler-runtime --qmldir ${CMAKE_SOURCE_DIR}/qml ${EXECUTABLE_DIR}
6 | COMMAND_ERROR_IS_FATAL ANY
7 | )
8 |
--------------------------------------------------------------------------------
/src/scene/geometrynode.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | class GeometryNode : public QSGNode
7 | {
8 | public:
9 | GeometryNode() = delete;
10 | GeometryNode(const QString &id);
11 | const QString &id() const;
12 |
13 | private:
14 | QString m_id;
15 | };
16 |
--------------------------------------------------------------------------------
/symbols/test_symbol.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/scene/polygon/polygonshader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class PolygonShader : public QSGMaterialShader
6 | {
7 | public:
8 | PolygonShader();
9 | bool updateUniformData(RenderState &state,
10 | QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
11 | };
12 |
--------------------------------------------------------------------------------
/.commitlintrc.mjs:
--------------------------------------------------------------------------------
1 | const scopes = [
2 | 'scene',
3 | 'tilefactory',
4 | ];
5 |
6 | export default {
7 | extends: ['@commitlint/config-conventional'],
8 |
9 | rules: {
10 | 'header-max-length': [2, 'always', 72],
11 | 'subject-case': [2, 'always', 'sentence-case'],
12 | 'scope-enum': [2, 'always', scopes],
13 | },
14 | };
15 |
--------------------------------------------------------------------------------
/src/scene/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(GTest CONFIG REQUIRED)
2 | include(GoogleTest)
3 |
4 | add_executable(fontimage_test
5 | fontimage_test.cpp
6 | )
7 |
8 | target_link_libraries(fontimage_test
9 | PUBLIC
10 | GTest::gtest
11 | GTest::gtest_main
12 | scene
13 | )
14 |
15 | gtest_discover_tests(fontimage_test)
16 |
--------------------------------------------------------------------------------
/privacy_policy.md:
--------------------------------------------------------------------------------
1 | # Privacy policy
2 |
3 | 1. This application does not transmit any information to third parties.
4 | 2. This application will generate and store "map tiles" on the device it
5 | is installed. These map tiles will indicate the geographic areas that have
6 | been viewed in the application. The map tiles are kept until the application
7 | is uninstalled.
8 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: WebKit
2 | Standard: Cpp11
3 | ColumnLimit: 0
4 | PointerBindsToType: false
5 | BreakBeforeBinaryOperators: NonAssignment
6 | AlignAfterOpenBracket: true
7 | AlwaysBreakTemplateDeclarations: true
8 | SortIncludes: true
9 | BreakBeforeBraces: Custom
10 | BraceWrapping:
11 | AfterClass: true
12 | AfterFunction: true
13 | AfterStruct: true
14 |
--------------------------------------------------------------------------------
/symbols/underwater_rocks/awash.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/scene/polygon/polygon.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout(location = 0) in vec4 color;
4 |
5 | layout(location = 0) out vec4 fragColor;
6 |
7 | layout(std140, binding = 0) uniform buf {
8 | mat4 qt_Matrix;
9 | float qt_Opacity;
10 | } ubuf;
11 |
12 | void main()
13 | {
14 | float opacity = ubuf.qt_Opacity * color.a;
15 | fragColor = vec4(color.rgb * opacity, opacity);
16 | }
17 |
--------------------------------------------------------------------------------
/symbols/underwater_rocks/always_submerged.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/vcpkg.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nautograf",
3 | "version": "0.1.0",
4 | "builtin-baseline": "a1703aa3e8b3fccd8c98ab9685444c2a3f007aab",
5 | "dependencies": ["capnproto", "tinyxml2", "earcut-hpp", "clipper2",
6 | {
7 | "name": "freetype",
8 | "default-features": false,
9 | "features": ["zlib"]
10 | },
11 | "libpng",
12 | "nlohmann-json",
13 | "quadtree"]
14 | }
15 |
--------------------------------------------------------------------------------
/src/tilefactory/rust/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "tilefactory_rust"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 | [lib]
8 | crate-type = ["staticlib"]
9 | path = "lib.rs"
10 |
11 | [dependencies]
12 | cxx = "=1.0.173"
13 | geo = { version = "0.28.0", default-features = false }
14 |
15 | [build-dependencies]
16 | cxx-build = "=1.0.173"
17 |
--------------------------------------------------------------------------------
/src/scene/polygon/polygon.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout(location = 0) in vec3 aPos;
4 | layout(location = 1) in vec4 colorIn;
5 |
6 | layout(location = 0) out vec4 color;
7 |
8 | layout(std140, binding = 0) uniform buf {
9 | mat4 qt_Matrix;
10 | float qt_Opacity;
11 | } ubuf;
12 |
13 | out gl_PerVertex { vec4 gl_Position; };
14 |
15 | void main()
16 | {
17 | gl_Position = ubuf.qt_Matrix * vec4(aPos.xyz, 1.0);
18 | color = colorIn;
19 | }
20 |
--------------------------------------------------------------------------------
/qml/qml.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | main.qml
4 | About.qml
5 | FolderDialog.qml
6 | Viewer.qml
7 | ChartSelector.qml
8 | StatusBar.qml
9 | TileInfo.qml
10 | XdgFileDialogWrapper.qml
11 | about.md
12 | graphics/title.svg
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/tilefactory/coverageratio.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "tilefactory/chart.h"
6 | #include "tilefactory/georect.h"
7 |
8 | class CoverageRatio
9 | {
10 | public:
11 | CoverageRatio(const GeoRect &rect);
12 | void accumulate(const capnp::List::Reader &coverages);
13 | float ratio() const;
14 |
15 | private:
16 | float coveredArea() const;
17 | GeoRect m_rect;
18 | Clipper2Lib::PathsD m_coverage;
19 | };
20 |
--------------------------------------------------------------------------------
/src/scene/line/line.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout(location = 1) in vec3 color;
4 | layout(location = 2) in vec2 normal;
5 |
6 | layout(std140, binding = 0) uniform buf {
7 | mat4 modelView;
8 | mat4 projection;
9 | float qt_Opacity;
10 | float width;
11 | } ubuf;
12 |
13 | layout(location = 0) out vec4 fragColor;
14 |
15 | void main()
16 | {
17 | float alpha = smoothstep(1.0, 0.0, length(normal)) * ubuf.qt_Opacity;
18 | fragColor = vec4(color.rgb * alpha, alpha) ;
19 | }
20 |
--------------------------------------------------------------------------------
/src/scene/rootnode.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class MaterialCreator;
6 | class QSGTexture;
7 | class QQuickWindow;
8 |
9 | class RootNode : public QSGTransformNode
10 | {
11 | public:
12 | RootNode(const QImage &symbolImage,
13 | const QImage &fontImage,
14 | const QQuickWindow *window);
15 | ~RootNode();
16 | MaterialCreator *materialCreator() const;
17 |
18 | private:
19 | MaterialCreator *m_materialCreator = nullptr;
20 | };
21 |
--------------------------------------------------------------------------------
/src/tilefactory/include/tilefactory/itilesource.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "chart.h"
7 | #include "georect.h"
8 |
9 | #include "tilefactory_export.h"
10 |
11 | class TILEFACTORY_EXPORT ITileSource
12 | {
13 | public:
14 | virtual std::shared_ptr create(const GeoRect &boundingBox,
15 | int pixelsPerLongitude) = 0;
16 | virtual GeoRect extent() const = 0;
17 | virtual int scale() const = 0;
18 | };
19 |
--------------------------------------------------------------------------------
/src/tilefactory/include/tilefactory/triangulator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "tilefactory_export.h"
7 |
8 | class TILEFACTORY_EXPORT Triangulator
9 | {
10 | public:
11 | Triangulator() = delete;
12 | using Point = std::array;
13 | static std::vector calc(const std::vector> &polygons);
14 |
15 | private:
16 | static Point getPoint(const std::vector> &polygon, int index);
17 | };
18 |
--------------------------------------------------------------------------------
/src/scene/polygon/polygonmaterial.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | class PolygonMaterial : public QSGMaterial
7 | {
8 | public:
9 | enum class BlendMode {
10 | Opaque,
11 | Alpha
12 | };
13 | PolygonMaterial(BlendMode blendMode = BlendMode::Opaque);
14 | QSGMaterialType *type() const override;
15 | int compare(const QSGMaterial *other) const override;
16 | QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
17 | };
18 |
--------------------------------------------------------------------------------
/src/scene/polygon/polygonnode.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class QSGMaterial;
6 |
7 | class PolygonNode : public QSGGeometryNode
8 | {
9 | public:
10 | struct Vertex
11 | {
12 | float x;
13 | float y;
14 | float z;
15 | uchar red;
16 | uchar green;
17 | uchar blue;
18 | uchar alpha;
19 | };
20 | PolygonNode(QSGMaterial *material, const QList &vertices);
21 | void updateVertices(const QList &vertices);
22 | };
23 |
--------------------------------------------------------------------------------
/src/scene/test/fontimage_test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 | #include
5 |
6 | #include "scene/annotations/fontimage.h"
7 |
8 | TEST(FontImageTest, SaveAtlasToFile)
9 | {
10 | FontImage fontImage;
11 | const QImage &image = fontImage.image();
12 | image.save("atlas.png");
13 | }
14 |
15 | TEST(FontImageTest, EmptyTextGivesZeroBoundingBox)
16 | {
17 | FontImage fontImage;
18 | QRectF boundingBox = fontImage.boundingBox(QString(), 12);
19 | ASSERT_TRUE(boundingBox.isNull());
20 | }
21 |
--------------------------------------------------------------------------------
/src/tilefactory/pos.cpp:
--------------------------------------------------------------------------------
1 | #include "tilefactory/pos.h"
2 |
3 | Pos::Pos(double lat, double lon)
4 | : m_lat(lat)
5 | , m_lon(lon)
6 | {
7 | }
8 |
9 | bool Pos::operator!=(const Pos &pos) const
10 | {
11 | return (m_lat != pos.lat() || m_lon != pos.lon());
12 | }
13 |
14 | bool Pos::operator==(const Pos &pos) const
15 | {
16 | return (m_lat == pos.lat() && m_lon == pos.lon());
17 | }
18 |
19 | std::ostream &operator<<(std::ostream &os, const Pos &pos)
20 | {
21 | os << pos.lat() << " " << pos.lon();
22 | return os;
23 | }
24 |
--------------------------------------------------------------------------------
/symbols/underwater_rocks/cover_and_uncovers.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/symbols/buoys/super_buoy.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/symbols/beacons/beacon_norwegian.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/scene/line/lineshader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | class LineShader : public QSGMaterialShader
9 | {
10 | public:
11 | LineShader()
12 | {
13 | setShaderFileName(VertexStage, QLatin1String(":/scene/line/line.vert.qsb"));
14 | setShaderFileName(FragmentStage, QLatin1String(":/scene/line/line.frag.qsb"));
15 | }
16 | bool updateUniformData(RenderState &state,
17 | QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
18 | };
19 |
--------------------------------------------------------------------------------
/src/scene/line/linematerial.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | class LineMaterial : public QSGMaterial
7 | {
8 | public:
9 | LineMaterial();
10 | QSGMaterialType *type() const override;
11 |
12 | int compare(const QSGMaterial *other) const override;
13 | QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
14 |
15 | void setWidth(float width)
16 | {
17 | uniforms.width = width;
18 | uniforms.dirty = true;
19 | }
20 |
21 | struct Uniforms
22 | {
23 | float width = 0;
24 | bool dirty = false;
25 | };
26 |
27 | Uniforms uniforms;
28 | };
29 |
--------------------------------------------------------------------------------
/symbols/symbols.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | test_symbol.svg
5 | buoys/barrel.svg
6 | buoys/can.svg
7 | buoys/conical.svg
8 | buoys/pillar.svg
9 | buoys/spar_port.svg
10 | buoys/spar_starboard.svg
11 | buoys/spherical.svg
12 | buoys/super_buoy.svg
13 | beacons/beacon_norwegian.svg
14 | underwater_rocks/always_submerged.svg
15 | underwater_rocks/awash.svg
16 | underwater_rocks/cover_and_uncovers.svg
17 |
18 |
--------------------------------------------------------------------------------
/symbols/buoys/can.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/qml/about.md:
--------------------------------------------------------------------------------
1 | Nautograf is an experimental viewer for marine vector charts and is inspired by [OpenCPN](https://opencpn.org/).
2 |
3 | This software is released under the GNU General Public License and comes with no warranty. Using this software for navigation is highly discouraged.
4 |
5 | This software depends on other libraries such as [The Qt Framework](https://www.qt.io/product/qt6). The Qt framework is licensed under the "GNU Lesser General Public License".
6 |
7 | Please open the "Licenses" tab to review the licenses of the other dependent software libraries.
8 |
9 | For more information, see the [GitHub repository for the project](https://github.com/hornang/nautograf).
10 |
11 | Copyright 2024 Stig Hornang
12 |
--------------------------------------------------------------------------------
/cmake/InstallLicense.cmake:
--------------------------------------------------------------------------------
1 | function(install_license)
2 | set(oneValueArgs FILE)
3 | cmake_parse_arguments(INSTALL_LICENSE "" "${oneValueArgs}" "" ${ARGN})
4 |
5 | if(NOT EXISTS ${INSTALL_LICENSE_FILE})
6 | message(FATAL_ERROR "Can not find license file ${INSTALL_LICENSE_FILE}")
7 | endif()
8 |
9 | cmake_path(GET INSTALL_LICENSE_FILE PARENT_PATH DIR)
10 | cmake_path(GET DIR FILENAME NAME)
11 |
12 | configure_file(
13 | ${INSTALL_LICENSE_FILE}
14 | "${CMAKE_BINARY_DIR}/licenses/${NAME}.txt"
15 | COPYONLY
16 | )
17 |
18 | install(
19 | FILES "${CMAKE_BINARY_DIR}/licenses/${NAME}.txt"
20 | DESTINATION licenses
21 | )
22 |
23 | endfunction()
24 |
--------------------------------------------------------------------------------
/symbols/buoys/spar_port.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/scene/line/linenode.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | class LineMaterial;
10 |
11 | class LineNode : public QSGGeometryNode
12 | {
13 | public:
14 | struct Vertex
15 | {
16 | float xPos;
17 | float yPos;
18 | float zPos;
19 | float xOffset;
20 | float yOffset;
21 | uchar red;
22 | uchar green;
23 | uchar blue;
24 | uchar alpha;
25 | };
26 | LineNode(QSGMaterial *material,
27 | const QList &vertices);
28 |
29 | public:
30 | void updateVertices(const QList &vertices);
31 | };
32 |
--------------------------------------------------------------------------------
/symbols/buoys/spar_starboard.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/scene/line/linematerial.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "linematerial.h"
4 | #include "lineshader.h"
5 |
6 | LineMaterial::LineMaterial()
7 | {
8 | setFlag(QSGMaterial::Blending);
9 | }
10 |
11 | QSGMaterialType *LineMaterial::type() const
12 | {
13 | static QSGMaterialType type;
14 | return &type;
15 | }
16 |
17 | int LineMaterial::compare(const QSGMaterial *o) const
18 | {
19 | Q_ASSERT(o && type() == o->type());
20 | const auto *other = static_cast(o);
21 | return other == this ? 0 : 1; // ### TODO: compare state??? <- From custommaterial example
22 | }
23 |
24 | QSGMaterialShader *LineMaterial::createShader(QSGRendererInterface::RenderMode) const
25 | {
26 | return new LineShader();
27 | }
28 |
--------------------------------------------------------------------------------
/create_icon.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | INPUT=$1
6 | OUTPUT=$2
7 | IMAGEMAGICK=$3
8 |
9 | FILENAME=$(basename -- "$INPUT")
10 | EXTENSION="${FILENAME##*.}"
11 | FILENAME="${FILENAME%.*}"
12 |
13 | WIDTHS=(16 32 44 64 128 150 256)
14 |
15 | for WIDTH in "${WIDTHS[@]}"
16 | do
17 | rsvg-convert --output="${FILENAME}_${WIDTH}.png" -w $WIDTH "$INPUT"
18 | done
19 |
20 | PNGS=()
21 | for WIDTH in "${WIDTHS[@]}"; do
22 | PNGS+=("${FILENAME}_${WIDTH}.png")
23 | done
24 |
25 | PNGS_ARG="${PNGS[@]}"
26 |
27 | if [[ "$IMAGEMAGICK" == *convert ]]; then
28 | # We don't call use subcommand on a system with the legacy "convert" executable
29 | convert $PNGS_ARG "$OUTPUT"
30 | else
31 | "$IMAGEMAGICK" convert $PNGS_ARG "$OUTPUT"
32 | fi
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/scene/annotations/zoomsweeper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include "scene/annotations/types.h"
8 |
9 | class ZoomSweeper
10 | {
11 |
12 | public:
13 | ZoomSweeper(float maxZoom, const QRect ®ion);
14 | void calcSymbols(std::vector &symbols);
15 | void calcLabels(const std::vector &symbols,
16 | std::vector &labels);
17 |
18 | private:
19 | static constexpr float m_zoomRatios[] = { 5, 4, 3, 2, 1, 0 };
20 |
21 | struct TestZoom
22 | {
23 | QTransform transform;
24 | float zoom = 0;
25 | };
26 |
27 | TestZoom m_testZooms[std::size(m_zoomRatios)];
28 | QRect m_region;
29 | };
30 |
--------------------------------------------------------------------------------
/symbols/buoys/conical.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/scene/line/line.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout(location = 0) in vec2 aPos;
4 | layout(location = 1) in vec2 aNormal;
5 | layout(location = 2) in vec3 colorIn;
6 |
7 | layout(location = 1) out vec3 color;
8 | layout(location = 2) out vec2 normal;
9 |
10 | layout(std140, binding = 0) uniform buf {
11 | mat4 modelView;
12 | mat4 projection;
13 | float qt_Opacity;
14 | float width;
15 | } ubuf;
16 |
17 | out gl_PerVertex { vec4 gl_Position; };
18 |
19 | void main()
20 | {
21 | float u_linewidth = ubuf.width;
22 | vec4 delta = vec4(0.5 * aNormal * u_linewidth, 0, 0);
23 | vec4 center = ubuf.modelView * vec4(aPos.x, aPos.y, 0.0, 1.0);
24 |
25 | gl_Position = ubuf.projection * (center + delta);
26 | color = colorIn;
27 | normal = aNormal;
28 | }
29 |
--------------------------------------------------------------------------------
/src/tilefactory/include/tilefactory/pos.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "tilefactory_export.h"
6 |
7 | class TILEFACTORY_EXPORT Pos
8 | {
9 | public:
10 | Pos() = default;
11 | Pos(double lat, double lon);
12 | bool operator!=(const Pos &pos) const;
13 | bool operator==(const Pos &pos) const;
14 | inline double lat() const { return m_lat; }
15 | inline double lon() const { return m_lon; }
16 | inline void setLat(double lat) { m_lat = lat; }
17 | inline void setLon(double lon) { m_lon = lon; }
18 |
19 | private:
20 | /// North/South coordinate in degrees
21 | double m_lat = 0;
22 |
23 | /// East/West coordinate in degrees
24 | double m_lon = 0;
25 | };
26 |
27 | std::ostream &operator<<(std::ostream &os, const Pos &pos);
28 |
--------------------------------------------------------------------------------
/src/scene/annotations/annotationmaterial.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | class AnnotationMaterial : public QSGMaterial
7 | {
8 | public:
9 | AnnotationMaterial(QSGTexture *texture);
10 | QSGMaterialType *type() const override;
11 |
12 | int compare(const QSGMaterial *other) const override;
13 | QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
14 | QSGTexture *texture() const { return m_texture; }
15 | void setZoom(float zoom)
16 | {
17 | uniforms.zoom = zoom;
18 | uniforms.dirty = true;
19 | }
20 |
21 | struct
22 | {
23 | float zoom = 0;
24 | bool dirty = false;
25 | } uniforms;
26 |
27 | private:
28 | QSGTexture *m_texture = nullptr;
29 | };
30 |
--------------------------------------------------------------------------------
/src/tilefactory/filehelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "tilefactory/georect.h"
6 |
7 | class FileHelper
8 | {
9 | public:
10 | static std::string tileId(const GeoRect &boundingBox, int pixelsPerLongitude);
11 | static std::string chartTypeIdToString(uint64_t typeId);
12 | static std::string getTileDir(const std::string &tileDir, uint64_t typeId);
13 | static std::string tileFileName(const std::string &tileDir,
14 | const std::string &name,
15 | const std::string &id);
16 | static std::string internalChartFileName(const std::string &tileDir,
17 | const std::string &name,
18 | int pixelsPerLon);
19 | };
20 |
--------------------------------------------------------------------------------
/symbols/buoys/barrel.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/scene/polygon/polygonmaterial.cpp:
--------------------------------------------------------------------------------
1 | #include "polygonmaterial.h"
2 | #include "polygonshader.h"
3 |
4 | PolygonMaterial::PolygonMaterial(BlendMode blendMode)
5 | {
6 | if (blendMode == BlendMode::Alpha) {
7 | setFlag(QSGMaterial::Blending);
8 | }
9 | }
10 |
11 | QSGMaterialType *PolygonMaterial::type() const
12 | {
13 | static QSGMaterialType type;
14 | return &type;
15 | }
16 |
17 | int PolygonMaterial::compare(const QSGMaterial *o) const
18 | {
19 | Q_ASSERT(o && type() == o->type());
20 | const auto *other = static_cast(o);
21 | return other == this ? 0 : 1; // ### TODO: compare state??? <- From custommaterial example
22 | }
23 |
24 | QSGMaterialShader *PolygonMaterial::createShader(QSGRendererInterface::RenderMode) const
25 | {
26 | return new PolygonShader();
27 | }
28 |
--------------------------------------------------------------------------------
/symbols/buoys/pillar.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/external/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if(${USE_XDG_FILE_DIALOG})
2 | add_subdirectory(xdg-file-dialog)
3 | endif()
4 |
5 | set(MSDFGEN_BUILD_STANDALONE OFF)
6 | set(MSDFGEN_USE_SKIA OFF)
7 | set(MSDFGEN_INSTALL ON)
8 | set(MSDFGEN_DYNAMIC_RUNTIME ON)
9 |
10 | add_subdirectory(msdfgen)
11 | install_license(FILE ${CMAKE_CURRENT_SOURCE_DIR}/msdfgen/LICENSE.txt)
12 |
13 | set(MSDF_ATLAS_MSDFGEN_EXTERNAL ON)
14 | set(MSDF_ATLAS_NO_ARTERY_FONT ON)
15 | set(MSDF_ATLAS_INSTALL ON)
16 | set(MSDF_ATLAS_BUILD_STANDALONE OFF)
17 | set(MSDF_ATLAS_DYNAMIC_RUNTIME ON)
18 |
19 | add_subdirectory(msdf-atlas-gen)
20 | install_license(FILE ${CMAKE_CURRENT_SOURCE_DIR}/msdf-atlas-gen/LICENSE.txt)
21 |
22 | add_subdirectory(cutlines)
23 | add_subdirectory(msdf-atlas-read)
24 |
25 | add_subdirectory(MercatorTile)
26 | install_license(FILE ${CMAKE_CURRENT_SOURCE_DIR}/MercatorTile/LICENSE)
27 |
28 | add_subdirectory(oesenc)
29 |
--------------------------------------------------------------------------------
/src/scene/annotations/annotationmaterial.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "annotationmaterial.h"
4 | #include "annotationshader.h"
5 |
6 | AnnotationMaterial::AnnotationMaterial(QSGTexture *texture)
7 | : m_texture(texture)
8 | {
9 | setFlag(QSGMaterial::RequiresFullMatrix | QSGMaterial::Blending);
10 | }
11 |
12 | QSGMaterialType *AnnotationMaterial::type() const
13 | {
14 | static QSGMaterialType type;
15 | return &type;
16 | }
17 |
18 | int AnnotationMaterial::compare(const QSGMaterial *o) const
19 | {
20 | Q_ASSERT(o && type() == o->type());
21 | const auto *other = static_cast(o);
22 | return other == this ? 0 : 1; // ### TODO: compare state??? <- From custommaterial example
23 | }
24 |
25 | QSGMaterialShader *AnnotationMaterial::createShader(QSGRendererInterface::RenderMode) const
26 | {
27 | return new AnnotationShader();
28 | }
29 |
--------------------------------------------------------------------------------
/symbols/buoys/spherical.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/src/scene/annotations/annotation.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout(location = 0) in vec2 aPos;
4 | layout(location = 1) in vec2 offset;
5 | layout(location = 2) in vec2 aTexCoord;
6 | layout(location = 3) in vec3 colorIn;
7 | layout(location = 4) in float minZoomIn;
8 |
9 | layout(location = 0) out vec2 vTexCoord;
10 | layout(location = 1) out vec3 color;
11 | layout(location = 2) out float minZoom;
12 |
13 | layout(std140, binding = 0) uniform buf {
14 | mat4 modelView;
15 | mat4 projection;
16 | float qt_Opacity;
17 | float zoom;
18 | } ubuf;
19 |
20 | out gl_PerVertex { vec4 gl_Position; };
21 |
22 | void main()
23 | {
24 | vec4 center = ubuf.modelView * vec4(aPos.x, aPos.y, 0.0, 1.0);
25 | center.x += offset.x;
26 | center.y += offset.y;
27 |
28 | gl_Position = ubuf.projection * center;
29 |
30 | vTexCoord = aTexCoord;
31 | minZoom = minZoomIn;
32 | color = colorIn;
33 | }
34 |
--------------------------------------------------------------------------------
/src/scene/annotations/annotationshader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | class AnnotationShader : public QSGMaterialShader
9 | {
10 | public:
11 | AnnotationShader()
12 | {
13 | setShaderFileName(VertexStage, QLatin1String(":/scene/annotations/annotation.vert.qsb"));
14 | setShaderFileName(FragmentStage, QLatin1String(":/scene/annotations/annotation.frag.qsb"));
15 | }
16 | bool updateUniformData(RenderState &state,
17 | QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
18 |
19 | void updateSampledImage(QSGMaterialShader::RenderState &state,
20 | int binding,
21 | QSGTexture **texture,
22 | QSGMaterial *newMaterial,
23 | QSGMaterial *oldMaterial) override;
24 | };
25 |
--------------------------------------------------------------------------------
/src/tilefactory/include/tilefactory/catalog.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | #include "tilefactory_export.h"
11 |
12 | class TILEFACTORY_EXPORT Catalog
13 | {
14 | public:
15 | enum class Type {
16 | Invalid,
17 | Oesu,
18 | Oesenc,
19 | Unencrypted,
20 | };
21 |
22 | Catalog(oesenc::ServerControl *serverControl, std::string_view dir);
23 | std::shared_ptr openChart(std::string_view fileName);
24 | std::vector chartFileNames() const;
25 | Type type() const;
26 |
27 | private:
28 | std::unordered_map m_oesuKeys;
29 | std::string m_oesencKey;
30 | std::filesystem::path m_dir;
31 | Type m_type = Type::Invalid;
32 | oesenc::ServerControl *m_serverControl;
33 | std::shared_ptr m_currentStream;
34 | };
35 |
--------------------------------------------------------------------------------
/src/scene/polygon/polygonshader.cpp:
--------------------------------------------------------------------------------
1 | #include "polygonshader.h"
2 | #include "polygonmaterial.h"
3 |
4 | PolygonShader::PolygonShader()
5 | {
6 | setShaderFileName(VertexStage, QLatin1String(":/scene/polygon/polygon.vert.qsb"));
7 | setShaderFileName(FragmentStage, QLatin1String(":/scene/polygon/polygon.frag.qsb"));
8 | }
9 |
10 | bool PolygonShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
11 | {
12 | bool changed = false;
13 | QByteArray *uniformBuffer = state.uniformData();
14 | Q_ASSERT(uniformBuffer->size() == 68);
15 |
16 | if (state.isMatrixDirty()) {
17 | memcpy(uniformBuffer->data(), state.combinedMatrix().constData(), 64);
18 | changed = true;
19 | }
20 |
21 | if (state.isOpacityDirty()) {
22 | const float opacity = state.opacity();
23 | memcpy(uniformBuffer->data() + 64, &opacity, 4);
24 | changed = true;
25 | }
26 |
27 | return changed;
28 | }
29 |
--------------------------------------------------------------------------------
/src/tilefactory/rust/lib.rs:
--------------------------------------------------------------------------------
1 | use ffi::*;
2 | use geo::{self, Simplify};
3 |
4 | #[cxx::bridge(namespace = "tilefactory_rust")]
5 | mod ffi {
6 | #[derive(Clone, Copy)]
7 | struct Pos {
8 | x: f64,
9 | y: f64,
10 | }
11 |
12 | extern "Rust" {
13 | fn simplify(input: &Vec, epsilon: f64) -> Vec;
14 | }
15 | }
16 |
17 | fn simplify(input: &Vec, epsilon: f64) -> Vec {
18 | let mut coord_vector = Vec::new();
19 |
20 | for val in input {
21 | coord_vector.push(geo::Coord { x: val.x, y: val.y });
22 | }
23 |
24 | let geo_line_string = geo::LineString::new(coord_vector);
25 | let simplified_geo_line_string = geo_line_string.simplify(&epsilon);
26 | let mut simplified_coord_vector: Vec = Vec::new();
27 |
28 | for value in simplified_geo_line_string {
29 | simplified_coord_vector.push(Pos {
30 | x: value.x,
31 | y: value.y,
32 | });
33 | }
34 |
35 | simplified_coord_vector
36 | }
37 |
--------------------------------------------------------------------------------
/src/scene/annotations/annotationnode.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | class AnnotationMaterial;
10 |
11 | class AnnotationNode : public QSGGeometryNode
12 | {
13 | public:
14 | struct Vertex
15 | {
16 | float xCenter;
17 | float yCenter;
18 | float xOffset;
19 | float yOffset;
20 | float xTexture;
21 | float yTexture;
22 | uchar red;
23 | uchar green;
24 | uchar blue;
25 | uchar alpha; // For padding purposes. Ignored by shader
26 | float minZoom;
27 | };
28 | AnnotationNode(const QString &tileId,
29 | QSGMaterial *material,
30 | const QList &vertices);
31 | const QString &id() const { return m_id; }
32 |
33 | public:
34 | void updateVertices(const QList &vertices);
35 |
36 | private:
37 | QString m_id;
38 | };
39 |
--------------------------------------------------------------------------------
/src/scene/rootnode.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "annotations/annotationmaterial.h"
5 | #include "annotations/symbolimage.h"
6 | #include "line/linematerial.h"
7 | #include "materialcreator.h"
8 | #include "polygon/polygonmaterial.h"
9 | #include "rootnode.h"
10 |
11 | RootNode::RootNode(const QImage &symbolImage,
12 | const QImage &fontImage,
13 | const QQuickWindow *window)
14 | {
15 | QSGTexture *symbolTexture = window->createTextureFromImage(symbolImage);
16 | symbolTexture->setFiltering(QSGTexture::Linear);
17 |
18 | QSGTexture *fontTexture = window->createTextureFromImage(fontImage);
19 | fontTexture->setFiltering(QSGTexture::Linear);
20 |
21 | m_materialCreator = new MaterialCreator(symbolTexture, fontTexture);
22 | }
23 |
24 | MaterialCreator *RootNode::materialCreator() const
25 | {
26 | return m_materialCreator;
27 | }
28 |
29 | RootNode::~RootNode()
30 | {
31 | if (m_materialCreator) {
32 | delete m_materialCreator;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/licenses.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class Licenses : public QObject
6 | {
7 | Q_OBJECT
8 | Q_PROPERTY(QStringList names MEMBER m_names NOTIFY licensesChanged)
9 | Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged)
10 | Q_PROPERTY(QString currentLicense READ currentLicense NOTIFY currentLicenseChanged)
11 |
12 | public:
13 | Licenses();
14 | QStringList names() const;
15 |
16 | int index() const;
17 | QString currentLicense() const;
18 | void setIndex(int newIndex);
19 | void load(int index);
20 |
21 | public slots:
22 |
23 | signals:
24 | void indexChanged();
25 | void currentLicenseChanged();
26 | void licensesChanged();
27 |
28 | private:
29 | QString m_licenseDir;
30 | void setLicenseDir(const QString &path);
31 |
32 | struct License
33 | {
34 | QString name;
35 | QString file;
36 | };
37 |
38 | QStringList m_names;
39 | QString m_currentLicense;
40 | QList m_licenses;
41 | int m_index = -1;
42 | };
43 |
--------------------------------------------------------------------------------
/src/scene/tiledata.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "annotations/annotationnode.h"
4 | #include "line/linenode.h"
5 | #include "polygon/polygonnode.h"
6 |
7 | struct GeometryLayer
8 | {
9 | struct LineGroup
10 | {
11 | struct Style
12 | {
13 | bool operator==(const Style &other) const
14 | {
15 | return width == other.width;
16 | }
17 |
18 | enum class Width {
19 | Thin,
20 | Medium,
21 | Thick,
22 | };
23 |
24 | Width width = Width::Medium;
25 | };
26 |
27 | QList vertices;
28 | Style style = { Style::Width::Medium };
29 | };
30 |
31 | QList polygonVertices;
32 | QList lineGroups;
33 | };
34 |
35 | struct TileData
36 | {
37 | // Per layer (chart) geometric objects
38 | QList geometryLayers;
39 |
40 | // Symbolism and text for all layers
41 | QList symbolVertices;
42 | QList textVertices;
43 | };
44 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "vcpkg"]
2 | path = vcpkg
3 | url = https://github.com/microsoft/vcpkg.git
4 | [submodule "external/oesenc"]
5 | path = external/oesenc
6 | url = https://github.com/hornang/oesenc.git
7 | [submodule "msdfgen"]
8 | path = external/msdfgen
9 | url = https://github.com/hornang/msdfgen.git
10 | [submodule "cutlines"]
11 | path = external/cutlines
12 | url = https://github.com/hornang/cutlines.git
13 | [submodule "MercatorTile"]
14 | path = external/MercatorTile
15 | url = https://github.com/hornang/MercatorTile
16 | [submodule "external/xdg-file-dialog"]
17 | path = external/xdg-file-dialog
18 | url = https://github.com/hornang/xdg-file-dialog.git
19 | [submodule "external/msdf-atlas-gen"]
20 | path = external/msdf-atlas-gen
21 | url = https://github.com/Chlumsky/msdf-atlas-gen.git
22 | [submodule "external/msdf-atlas-read"]
23 | path = external/msdf-atlas-read
24 | url = https://github.com/hornang/msdf-atlas-read.git
25 | [submodule "external/slippy-map-tiles-rs/slippy-map-tiles-rs"]
26 | path = external/slippy-map-tiles-rs/slippy-map-tiles-rs
27 | url = https://github.com/amandasaurus/slippy-map-tiles-rs.git
28 |
--------------------------------------------------------------------------------
/src/scene/line/lineshader.cpp:
--------------------------------------------------------------------------------
1 | #include "lineshader.h"
2 | #include "linematerial.h"
3 | #include "linenode.h"
4 |
5 | bool LineShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
6 | {
7 | bool changed = false;
8 | QByteArray *uniformBuffer = state.uniformData();
9 | Q_ASSERT(uniformBuffer->size() == 136);
10 |
11 | if (state.isMatrixDirty()) {
12 | memcpy(uniformBuffer->data(), state.modelViewMatrix().constData(), 64);
13 | memcpy(uniformBuffer->data() + 64, state.projectionMatrix().constData(), 64);
14 | changed = true;
15 | }
16 |
17 | if (state.isOpacityDirty()) {
18 | const float opacity = state.opacity();
19 | memcpy(uniformBuffer->data() + 128, &opacity, 4);
20 | changed = true;
21 | }
22 |
23 | LineMaterial *material = static_cast(newMaterial);
24 | if (oldMaterial != newMaterial || material->uniforms.dirty) {
25 | memcpy(uniformBuffer->data() + 132, &material->uniforms.width, 4);
26 | material->uniforms.dirty = false;
27 | changed = true;
28 | }
29 |
30 | return changed;
31 | }
32 |
--------------------------------------------------------------------------------
/src/scene/annotations/annotation.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout(location = 0) in vec2 vTexCoord;
4 | layout(location = 1) in vec3 color;
5 | layout(location = 2) in float minZoom;
6 |
7 | layout(std140, binding = 0) uniform buf {
8 | mat4 modelView;
9 | mat4 projection;
10 | float qt_Opacity;
11 | float zoom;
12 | } ubuf;
13 |
14 | layout(binding = 1) uniform sampler2D ourTexture;
15 | layout(location = 0) out vec4 fragColor;
16 |
17 | const float smoothing = 2.0 / 16.0;
18 | const float borderSmoothing = 3.0 / 16.0;
19 | const float outlineWidth = 4.0 / 16.0;
20 | const float edgeCenter = 0.5;
21 | const float outerEdgeCenter = edgeCenter - outlineWidth;
22 | const vec4 u_outlineColor = vec4(1, 1, 1, 1);
23 |
24 | void main()
25 | {
26 | float dist = texture(ourTexture, vTexCoord).r;
27 | float alpha = smoothstep(outerEdgeCenter - smoothing, outerEdgeCenter + smoothing, dist) * ubuf.qt_Opacity;
28 | float zoomRevealAlpha = smoothstep(0, 1, ((ubuf.zoom - minZoom) + 1));
29 | alpha *= zoomRevealAlpha;
30 | float border = smoothstep(edgeCenter - borderSmoothing, edgeCenter + borderSmoothing, dist);
31 | fragColor = vec4(mix(u_outlineColor.rgb, color.rgb, border) * alpha, alpha);
32 | }
33 |
--------------------------------------------------------------------------------
/src/tilefactory/include/tilefactory/mercator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "tilefactory_export.h"
4 |
5 | class TILEFACTORY_EXPORT Mercator
6 | {
7 | public:
8 | static double mercatorWidth(double leftLongitude,
9 | double rightLongitude,
10 | double pixelsPerLongitude);
11 |
12 | static double mercatorNormalizedHeight(double topLat, double bottomLat);
13 |
14 | static double mercatorHeightInverse(double topLatitude,
15 | double height,
16 | double pixelsPerLongitude);
17 |
18 | static double mercatorNormalizedWidth(double leftLon, double rightLon);
19 |
20 | static double mercatorWidthInverse(double leftLongitude,
21 | double pixels,
22 | double pixelsPerLongitude);
23 |
24 | static double mercatorWidthInverse(double pixels, double pixelsPerLon);
25 |
26 | static double mercatorHeight(double topLatitude,
27 | double bottomLatitude,
28 | double pixelsPerLongitude);
29 | static double toLatitude(double y);
30 | static double toLongitude(double x);
31 | };
32 |
--------------------------------------------------------------------------------
/src/scene/tilefactorywrapper.cpp:
--------------------------------------------------------------------------------
1 | #include "scene/tilefactorywrapper.h"
2 |
3 | std::vector> TileFactoryWrapper::create(TileRecipe recipe)
4 | {
5 | return m_tileDataCallback(recipe.rect, recipe.pixelsPerLongitude);
6 | }
7 |
8 | void TileFactoryWrapper::setTileDataCallback(TileDataCallback tileDataCallback)
9 | {
10 | m_tileDataCallback = tileDataCallback;
11 | }
12 |
13 | std::vector TileFactoryWrapper::chartInfos(TileRecipe recipe)
14 | {
15 | assert(m_chartInfoCallback);
16 | return m_chartInfoCallback(recipe.rect, recipe.pixelsPerLongitude);
17 | }
18 |
19 | void TileFactoryWrapper::setChartInfoCallback(ChartInfoCallback callback)
20 | {
21 | m_chartInfoCallback = callback;
22 | }
23 |
24 | void TileFactoryWrapper::triggerTileDataChanged(const std::vector &_tileIds)
25 | {
26 | QStringList tileIds;
27 |
28 | for (const std::string &tileId : _tileIds) {
29 | tileIds.push_back(QString::fromStdString(tileId));
30 | }
31 | emit tileDataChanged(tileIds);
32 | }
33 |
34 | void TileFactoryWrapper::setTileSettingsCb(TileSettingsCallback callback)
35 | {
36 | m_tileSettingsCallback = callback;
37 | }
38 |
39 | void TileFactoryWrapper::setTileSettings(const std::string &tileId, TileFactory::TileSettings tileSettings)
40 | {
41 | assert(m_tileSettingsCallback);
42 |
43 | m_tileSettingsCallback(tileId, tileSettings);
44 | }
45 |
--------------------------------------------------------------------------------
/src/scene/annotations/symbolimage.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "chartdata.capnp.h"
7 | #include "scene/annotations/types.h"
8 |
9 | class SymbolImage
10 | {
11 | public:
12 | SymbolImage(const QString &baseDir);
13 | SymbolImage(const SymbolImage &other) = delete;
14 | void load();
15 | const QImage image() const { return m_image; }
16 | std::optional underwaterRock(const ChartData::UnderwaterRock::Reader &rock) const;
17 | std::optional lateralBuoy(const ChartData::BuoyLateral::Reader &buoy) const;
18 | std::optional beacon(const ChartData::Beacon::Reader &beacon) const;
19 | std::optional testSymbol() const;
20 |
21 | private:
22 | enum class Laterality {
23 | Port,
24 | Starboard
25 | };
26 |
27 | static QString underwaterRockHash(ChartData::WaterLevelEffect waterLevelEffect);
28 | static QString buoyHash(ChartData::BuoyShape buoyShape, Laterality laterality);
29 | static QString beaconHash(ChartData::BeaconShape shape);
30 | static QRectF toNormalized(const QRect &rect, const QSize &image);
31 | QRect render(QImage &image,
32 | const QRect &lastRect,
33 | int &rowHeight,
34 | const QString &filename);
35 |
36 | QHash m_symbols;
37 | QImage m_image;
38 | QString m_baseDir;
39 | };
40 |
--------------------------------------------------------------------------------
/src/scene/materialcreator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include