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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
#include "../base/SRC_FIRST.hpp"
#include "overlay_renderer.hpp"
#include "composite_overlay_element.hpp"
#include "straight_text_element.hpp"
#include "path_text_element.hpp"
#include "symbol_element.hpp"
#include "circle_element.hpp"
#include "overlay.hpp"
#include "resource_manager.hpp"
namespace graphics
{
OverlayRenderer::Params::Params()
: m_drawTexts(true),
m_drawSymbols(true)
{
}
OverlayRenderer::OverlayRenderer(Params const & p)
: TextRenderer(p),
m_drawTexts(p.m_drawTexts),
m_drawSymbols(p.m_drawSymbols),
m_overlay(p.m_overlay)
{
}
void OverlayRenderer::drawSymbol(SymbolElement::Params & params)
{
if (!m_drawSymbols)
return;
shared_ptr<OverlayElement> oe(new SymbolElement(params));
math::Matrix<double, 3, 3> id = math::Identity<double, 3>();
if (!m_overlay.get())
oe->draw(this, id);
else
m_overlay->processOverlayElement(oe);
}
void OverlayRenderer::drawSymbol(m2::PointD const & pt, string const & name, EPosition pos, int depth)
{
graphics::SymbolElement::Params params;
params.m_depth = depth;
params.m_position = pos;
params.m_pivot = pt;
params.m_info.m_name = name;
params.m_renderer = this;
drawSymbol(params);
}
void OverlayRenderer::drawCircle(m2::PointD const & pt,
graphics::Circle::Info const & ci,
EPosition pos,
int depth)
{
CircleElement::Params params;
params.m_depth = depth;
params.m_position = pos;
params.m_pivot = pt;
params.m_ci = ci;
shared_ptr<OverlayElement> oe(new CircleElement(params));
math::Matrix<double, 3, 3> id = math::Identity<double, 3>();
if (!m_overlay.get())
oe->draw(this, id);
else
m_overlay->processOverlayElement(oe);
}
void OverlayRenderer::drawText(FontDesc const & fontDesc,
m2::PointD const & pt,
graphics::EPosition pos,
string const & utf8Text,
double depth,
bool log2vis,
bool doSplit)
{
if (!m_drawTexts)
return;
StraightTextElement::Params params;
params.m_depth = depth;
params.m_fontDesc = fontDesc;
params.m_log2vis = log2vis;
params.m_pivot = pt;
params.m_position = pos;
params.m_glyphCache = glyphCache();
params.m_logText = strings::MakeUniString(utf8Text);
params.m_doSplit = doSplit;
params.m_useAllParts = false;
shared_ptr<OverlayElement> oe(new StraightTextElement(params));
math::Matrix<double, 3, 3> id = math::Identity<double, 3>();
if (!m_overlay.get())
oe->draw(this, id);
else
m_overlay->processOverlayElement(oe);
}
void OverlayRenderer::drawTextEx(FontDesc const & primaryFont,
FontDesc const & secondaryFont,
m2::PointD const & pt,
graphics::EPosition pos,
string const & text,
string const & secondaryText,
double depth,
bool log2vis,
bool doSplit)
{
if (!m_drawTexts)
return;
StraightTextElement::Params params;
params.m_depth = depth;
params.m_fontDesc = primaryFont;
params.m_auxFontDesc = secondaryFont;
params.m_log2vis = log2vis;
params.m_pivot = pt;
params.m_position = pos;
params.m_glyphCache = glyphCache();
params.m_logText = strings::MakeUniString(text);
params.m_auxLogText = strings::MakeUniString(secondaryText);
params.m_doSplit = doSplit;
params.m_useAllParts = false;
shared_ptr<OverlayElement> oe(new StraightTextElement(params));
math::Matrix<double, 3, 3> id = math::Identity<double, 3>();
if (!m_overlay.get())
oe->draw(this, id);
else
m_overlay->processOverlayElement(oe);
}
bool OverlayRenderer::drawPathText(
FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text,
double fullLength, double pathOffset, graphics::EPosition pos, double depth)
{
if (!m_drawTexts)
return false;
PathTextElement::Params params;
params.m_pts = path;
params.m_ptsCount = s;
params.m_fullLength = fullLength;
params.m_pathOffset = pathOffset;
params.m_fontDesc = fontDesc;
params.m_logText = strings::MakeUniString(utf8Text);
params.m_depth = depth;
params.m_log2vis = true;
params.m_glyphCache = glyphCache();
params.m_pivot = path[0];
params.m_position = pos;
shared_ptr<PathTextElement> pte(new PathTextElement(params));
math::Matrix<double, 3, 3> id = math::Identity<double, 3>();
if (!m_overlay.get())
pte->draw(this, id);
else
m_overlay->processOverlayElement(pte);
return true;
}
void OverlayRenderer::setOverlay(shared_ptr<Overlay> const & overlay)
{
m_overlay = overlay;
}
shared_ptr<Overlay> const & OverlayRenderer::overlay() const
{
return m_overlay;
}
void OverlayRenderer::resetOverlay()
{
m_overlay.reset();
}
}
|