| 1 | #ifndef QMAPBOX_H |
| 2 | #define QMAPBOX_H |
| 3 | |
| 4 | #include <QColor> |
| 5 | #include <QList> |
| 6 | #include <QPair> |
| 7 | #include <QVariant> |
| 8 | #include <QString> |
| 9 | |
| 10 | // This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style |
| 11 | |
| 12 | #if !defined(QT_MAPBOXGL_STATIC) |
| 13 | # if defined(QT_BUILD_MAPBOXGL_LIB) |
| 14 | # define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT |
| 15 | # else |
| 16 | # define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT |
| 17 | # endif |
| 18 | #else |
| 19 | # define Q_MAPBOXGL_EXPORT |
| 20 | #endif |
| 21 | |
| 22 | namespace QMapbox { |
| 23 | |
| 24 | typedef QPair<double, double> Coordinate; |
| 25 | typedef QPair<Coordinate, double> CoordinateZoom; |
| 26 | typedef QPair<double, double> ProjectedMeters; |
| 27 | |
| 28 | typedef QList<Coordinate> Coordinates; |
| 29 | typedef QList<Coordinates> CoordinatesCollection; |
| 30 | |
| 31 | typedef QList<CoordinatesCollection> CoordinatesCollections; |
| 32 | |
| 33 | struct Q_MAPBOXGL_EXPORT Feature { |
| 34 | enum Type { |
| 35 | PointType = 1, |
| 36 | LineStringType, |
| 37 | PolygonType |
| 38 | }; |
| 39 | |
| 40 | /*! Class constructor. */ |
| 41 | Feature(Type type_ = PointType, const CoordinatesCollections& geometry_ = CoordinatesCollections(), |
| 42 | const QVariantMap& properties_ = QVariantMap(), const QVariant& id_ = QVariant()) |
| 43 | : type(type_), geometry(geometry_), properties(properties_), id(id_) {} |
| 44 | |
| 45 | Type type; |
| 46 | CoordinatesCollections geometry; |
| 47 | QVariantMap properties; |
| 48 | QVariant id; |
| 49 | }; |
| 50 | |
| 51 | struct Q_MAPBOXGL_EXPORT ShapeAnnotationGeometry { |
| 52 | enum Type { |
| 53 | LineStringType = 1, |
| 54 | PolygonType, |
| 55 | MultiLineStringType, |
| 56 | MultiPolygonType |
| 57 | }; |
| 58 | |
| 59 | /*! Class constructor. */ |
| 60 | ShapeAnnotationGeometry(Type type_ = LineStringType, const CoordinatesCollections& geometry_ = CoordinatesCollections()) |
| 61 | : type(type_), geometry(geometry_) {} |
| 62 | |
| 63 | Type type; |
| 64 | CoordinatesCollections geometry; |
| 65 | }; |
| 66 | |
| 67 | struct Q_MAPBOXGL_EXPORT SymbolAnnotation { |
| 68 | Coordinate geometry; |
| 69 | QString icon; |
| 70 | }; |
| 71 | |
| 72 | struct Q_MAPBOXGL_EXPORT LineAnnotation { |
| 73 | /*! Class constructor. */ |
| 74 | LineAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, |
| 75 | float width_ = 1.0f, const QColor& color_ = Qt::black) |
| 76 | : geometry(geometry_), opacity(opacity_), width(width_), color(color_) {} |
| 77 | |
| 78 | ShapeAnnotationGeometry geometry; |
| 79 | float opacity; |
| 80 | float width; |
| 81 | QColor color; |
| 82 | }; |
| 83 | |
| 84 | struct Q_MAPBOXGL_EXPORT FillAnnotation { |
| 85 | /*! Class constructor. */ |
| 86 | FillAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, |
| 87 | const QColor& color_ = Qt::black, const QVariant& outlineColor_ = QVariant()) |
| 88 | : geometry(geometry_), opacity(opacity_), color(color_), outlineColor(outlineColor_) {} |
| 89 | |
| 90 | ShapeAnnotationGeometry geometry; |
| 91 | float opacity; |
| 92 | QColor color; |
| 93 | QVariant outlineColor; |
| 94 | }; |
| 95 | |
| 96 | typedef QVariant Annotation; |
| 97 | typedef quint32 AnnotationID; |
| 98 | typedef QList<AnnotationID> AnnotationIDs; |
| 99 | |
| 100 | enum NetworkMode { |
| 101 | Online, // Default |
| 102 | Offline, |
| 103 | }; |
| 104 | |
| 105 | Q_MAPBOXGL_EXPORT QList<QPair<QString, QString> >& defaultStyles(); |
| 106 | |
| 107 | Q_MAPBOXGL_EXPORT NetworkMode networkMode(); |
| 108 | Q_MAPBOXGL_EXPORT void setNetworkMode(NetworkMode); |
| 109 | |
| 110 | // This struct is a 1:1 copy of mbgl::CustomLayerRenderParameters. |
| 111 | struct Q_MAPBOXGL_EXPORT CustomLayerRenderParameters { |
| 112 | double width; |
| 113 | double height; |
| 114 | double latitude; |
| 115 | double longitude; |
| 116 | double zoom; |
| 117 | double bearing; |
| 118 | double pitch; |
| 119 | double fieldOfView; |
| 120 | }; |
| 121 | |
| 122 | class Q_MAPBOXGL_EXPORT CustomLayerHostInterface { |
| 123 | public: |
| 124 | virtual ~CustomLayerHostInterface() = default; |
| 125 | virtual void initialize() = 0; |
| 126 | virtual void render(const CustomLayerRenderParameters&) = 0; |
| 127 | virtual void deinitialize() = 0; |
| 128 | }; |
| 129 | |
| 130 | } // namespace QMapbox |
| 131 | |
| 132 | Q_DECLARE_METATYPE(QMapbox::Coordinate); |
| 133 | Q_DECLARE_METATYPE(QMapbox::Coordinates); |
| 134 | Q_DECLARE_METATYPE(QMapbox::CoordinatesCollection); |
| 135 | Q_DECLARE_METATYPE(QMapbox::CoordinatesCollections); |
| 136 | Q_DECLARE_METATYPE(QMapbox::Feature); |
| 137 | |
| 138 | Q_DECLARE_METATYPE(QMapbox::SymbolAnnotation); |
| 139 | Q_DECLARE_METATYPE(QMapbox::ShapeAnnotationGeometry); |
| 140 | Q_DECLARE_METATYPE(QMapbox::LineAnnotation); |
| 141 | Q_DECLARE_METATYPE(QMapbox::FillAnnotation); |
| 142 | |
| 143 | #endif // QMAPBOX_H |
| 144 | |