blob: cacf365cf582c8315d74ed8e9f806b0c4e998ba2 (
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
|
#pragma once
#include "drape_frontend/message.hpp"
#include "drape_frontend/tile_key.hpp"
#include "drape/pointers.hpp"
#include "geometry/point2d.hpp"
#include "std/vector.hpp"
namespace dp
{
class Batcher;
class TextureManager;
}
namespace df
{
enum MapShapeType
{
GeometryType = 0,
OverlayType,
MapShapeTypeCount
};
class MapShape
{
public:
virtual ~MapShape(){}
virtual void Prepare(ref_ptr<dp::TextureManager> /*textures*/) const {}
virtual void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const = 0;
virtual MapShapeType GetType() const { return MapShapeType::GeometryType; }
void SetFeatureMinZoom(int minZoom) { m_minZoom = minZoom; }
int GetFeatureMinZoom() const { return m_minZoom; }
static m2::PointD ConvertToLocal(m2::PointD const & basePt, m2::PointD const & tileCenter, double scalar)
{
return (basePt - tileCenter) * scalar;
}
private:
int m_minZoom = 0;
};
using TMapShapes = vector<drape_ptr<MapShape>>;
class MapShapeMessage : public Message
{
public:
MapShapeMessage(TileKey const & key)
: m_tileKey(key)
{}
TileKey const & GetKey() const { return m_tileKey; }
private:
TileKey m_tileKey;
};
class TileReadStartMessage : public MapShapeMessage
{
public:
TileReadStartMessage(TileKey const & key) : MapShapeMessage(key) {}
Type GetType() const override { return Message::TileReadStarted; }
bool IsGLContextDependent() const override { return true; }
};
class TileReadEndMessage : public MapShapeMessage
{
public:
TileReadEndMessage(TileKey const & key) : MapShapeMessage(key) {}
Type GetType() const override { return Message::TileReadEnded; }
bool IsGLContextDependent() const override { return true; }
};
class MapShapeReadedMessage : public MapShapeMessage
{
public:
MapShapeReadedMessage(TileKey const & key, TMapShapes && shapes)
: MapShapeMessage(key), m_shapes(move(shapes))
{}
Type GetType() const override { return Message::MapShapeReaded; }
bool IsGLContextDependent() const override { return true; }
TMapShapes const & GetShapes() { return m_shapes; }
private:
TMapShapes m_shapes;
};
class OverlayMapShapeReadedMessage : public MapShapeReadedMessage
{
public:
OverlayMapShapeReadedMessage(TileKey const & key, TMapShapes && shapes)
: MapShapeReadedMessage(key, move(shapes))
{}
Type GetType() const override { return Message::OverlayMapShapeReaded; }
};
} // namespace df
|