summaryrefslogtreecommitdiff
path: root/platform/qt/include/qmapbox.hpp
blob: 417609bd9349b1b4e43e0d44a8cb7cad5cb6ec38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef QMAPBOX_H
#define QMAPBOX_H

#include <QColor>
#include <QList>
#include <QPair>
#include <QVariant>
#include <QString>

// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style

namespace QMapbox {

// Reflects mapbox::geometry::point<double>.
typedef QPair<double, double> Coordinate;
typedef QPair<Coordinate, double> CoordinateZoom;

// Reflects mapbox::geometry::line_string<double> and mapbox::geometry::linear_ring<double>.
typedef QList<Coordinate> Coordinates;

// Reflects mapbox::geometry::multi_line_string<double> and mapbox::geometry::polygon<double>.
typedef QList<Coordinates> CoordinatesCollection;

// Reflects mapbox::geometry::multi_polygon<double>.
typedef QList<CoordinatesCollection> CoordinatesCollections;

// Reflects mbgl::ShapeAnnotationGeometry.
struct Q_DECL_EXPORT ShapeAnnotationGeometry {
    enum Type {
        LineStringType,
        PolygonType,
        MultiLineStringType,
        MultiPolygonType
    };

    ShapeAnnotationGeometry() {}

    ShapeAnnotationGeometry(Type type_, const CoordinatesCollections& geometry_)
        : type(type_), geometry(geometry_) {}

    Type type;
    CoordinatesCollections geometry;
};

// Reflects mbgl::SymbolAnnotation.
struct Q_DECL_EXPORT SymbolAnnotation {
    Coordinate geometry;
    QString icon;
};

// Reflects mbgl::LineAnnotation.
struct Q_DECL_EXPORT LineAnnotation {
    LineAnnotation() {}

    LineAnnotation(const ShapeAnnotationGeometry& geometry_, float opacity_, float width_, const QColor& color_)
        : geometry(geometry_), opacity(opacity_), width(width_), color(color_) {}

    ShapeAnnotationGeometry geometry;
    float opacity = 1.0f;
    float width = 1.0f;
    QColor color = Qt::black;
};

// Reflects mbgl::FillAnnotation.
struct Q_DECL_EXPORT FillAnnotation {
    FillAnnotation() {}

    FillAnnotation(const ShapeAnnotationGeometry& geometry_, float opacity_, const QColor& color_, const QVariant& outlineColor_ = QVariant())
        : geometry(geometry_), opacity(opacity_), color(color_), outlineColor(outlineColor_) {}

    ShapeAnnotationGeometry geometry;
    float opacity = 1.0f;
    QColor color = Qt::black;
    QVariant outlineColor;
};

// Reflects mbgl::StyleSourcedAnnotation.
struct Q_DECL_EXPORT StyleSourcedAnnotation {
    StyleSourcedAnnotation() {}

    StyleSourcedAnnotation(const ShapeAnnotationGeometry geometry_, const QString& layerID_)
        : geometry(geometry_), layerID(layerID_) {}

    ShapeAnnotationGeometry geometry;
    QString layerID;
};

// SymbolAnnotation, LineAnnotation, FillAnnotation, StyleSourcedAnnotation.
typedef QVariant Annotation;

typedef quint32 AnnotationID;
typedef QList<AnnotationID> AnnotationIDs;

// Reflects mbgl::NetworkStatus::Status.
enum NetworkMode {
    Online, // Default
    Offline,
};

Q_DECL_EXPORT QList<QPair<QString, QString> >& defaultStyles();

Q_DECL_EXPORT NetworkMode networkMode();
Q_DECL_EXPORT void setNetworkMode(NetworkMode);

// This struct is a 1:1 copy of mbgl::CustomLayerRenderParameters.
struct Q_DECL_EXPORT CustomLayerRenderParameters {
    double width;
    double height;
    double latitude;
    double longitude;
    double zoom;
    double bearing;
    double pitch;
    double altitude;
};

typedef void (*CustomLayerInitializeFunction)(void* context) ;
typedef void (*CustomLayerRenderFunction)(void* context, const CustomLayerRenderParameters&);
typedef void (*CustomLayerDeinitializeFunction)(void* context);

Q_DECL_EXPORT void initializeGLExtensions();

} // namespace QMapbox

Q_DECLARE_METATYPE(QMapbox::Coordinate);
Q_DECLARE_METATYPE(QMapbox::Coordinates);
Q_DECLARE_METATYPE(QMapbox::CoordinatesCollection);
Q_DECLARE_METATYPE(QMapbox::CoordinatesCollections);

Q_DECLARE_METATYPE(QMapbox::SymbolAnnotation);
Q_DECLARE_METATYPE(QMapbox::ShapeAnnotationGeometry);
Q_DECLARE_METATYPE(QMapbox::LineAnnotation);
Q_DECLARE_METATYPE(QMapbox::FillAnnotation);
Q_DECLARE_METATYPE(QMapbox::StyleSourcedAnnotation);

#endif // QMAPBOX_H