Welcome to mirror list, hosted at ThFree Co, Russian Federation.

engine_context.cpp « drape_frontend - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 35d0c76bd72cc98e9b3a2b9b8dc673290fd5fcea (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
#include "engine_context.hpp"

//#define DRAW_TILE_NET

#include "message_subclasses.hpp"
#include "map_shape.hpp"
#ifdef DRAW_TILE_NET
#include "line_shape.hpp"
#include "text_shape.hpp"

#include "../base/string_utils.hpp"
#endif

namespace df
{

EngineContext::EngineContext(dp::RefPointer<ThreadsCommutator> commutator)
  : m_commutator(commutator)
{
}

void EngineContext::BeginReadTile(TileKey const & key)
{
  PostMessage(new TileReadStartMessage(key));
}

void EngineContext::InsertShape(TileKey const & key, dp::TransferPointer<MapShape> shape)
{
  PostMessage(new MapShapeReadedMessage(key, shape));
}

void EngineContext::EndReadTile(TileKey const & key)
{
#ifdef DRAW_TILE_NET
  m2::RectD r = key.GetGlobalRect();
  vector<m2::PointD> path;
  path.push_back(r.LeftBottom());
  path.push_back(r.LeftTop());
  path.push_back(r.RightTop());
  path.push_back(r.RightBottom());
  path.push_back(r.LeftBottom());

  m2::SharedSpline spline(path);
  df::LineViewParams p;
  p.m_baseGtoPScale = 1.0;
  p.m_cap = dp::ButtCap;
  p.m_color = dp::Color(255, 0, 0, 255);
  p.m_depth = 20000;
  p.m_width = 5;
  p.m_join = dp::RoundJoin;

  InsertShape(key, dp::MovePointer<df::MapShape>(new LineShape(spline, p)));

  df::TextViewParams tp;
  tp.m_anchor = dp::Center;
  tp.m_depth = 20000;
  tp.m_primaryText = strings::to_string(key.m_x) + " " +
                     strings::to_string(key.m_y) + " " +
                     strings::to_string(key.m_zoomLevel);

  tp.m_primaryTextFont = df::FontDecl{ dp::Color(255, 0, 0, 255),
                                       dp::Color(0, 0, 0, 0),
                                       30, true};

  InsertShape(key, dp::MovePointer<df::MapShape>(new TextShape(r.Center(), tp)));
#endif

  PostMessage(new TileReadEndMessage(key));
}

void EngineContext::PostMessage(Message * message)
{
  m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, dp::MovePointer(message));
}

} // namespace df