forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguides_marks.cpp
156 lines (132 loc) · 4.39 KB
/
guides_marks.cpp
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
#include "map/guides_marks.hpp"
#include "drape_frontend/color_constants.hpp"
#include "drape_frontend/visual_params.hpp"
#include "indexer/scales.hpp"
#include "base/string_utils.hpp"
namespace
{
std::string const kCityMarkTextColor = "GuideCityMarkText";
std::string const kOutdoorMarkTextColor = "GuideOutdoorMarkText";
std::string const kSelectionMarkColor = "Selection";
float constexpr kGuideMarkSize = 26.0f;
float constexpr kGuideMarkTextSize = 14.0f;
float constexpr kGuideMarkRadius = 4.0f;
float constexpr kGuideSelectionWidth = 10.0f;
m2::PointD const kGuideMarkOffset = {0.0, 0.0};
m2::PointD const kGuideDownloadedMarkOffset = {1.5, -1.5};
int constexpr kMinGuideMarkerZoom = 1;
} // namespace
GuideMark::GuideMark(m2::PointD const & ptOrg)
: UserMark(ptOrg, UserMark::GUIDE)
{
Update();
}
void GuideMark::Update()
{
if (m_type == Type::City)
{
m_symbolInfo[kMinGuideMarkerZoom] = m_isDownloaded ? "guide_city_downloaded"
: "guide_city";
}
else
{
m_symbolInfo[kMinGuideMarkerZoom] = m_isDownloaded ? "guide_outdoor_downloaded"
: "guide_outdoor";
}
}
m2::PointD GuideMark::GetPixelOffset() const
{
auto const vs = static_cast<float>(df::VisualParams::Instance().GetVisualScale());
return m_isDownloaded ? kGuideDownloadedMarkOffset * vs : kGuideMarkOffset * vs;
}
void GuideMark::SetGuideType(Type type)
{
SetDirty();
m_type = type;
Update();
}
void GuideMark::SetIsDownloaded(bool isDownloaded)
{
SetDirty();
m_isDownloaded = isDownloaded;
Update();
}
void GuideMark::SetGuideId(std::string guideId)
{
SetDirty();
m_guideId = guideId;
}
void GuideMark::SetDepth(float depth)
{
SetDirty();
m_depth = depth;
}
drape_ptr<df::UserPointMark::SymbolNameZoomInfo> GuideMark::GetSymbolNames() const
{
return make_unique_dp<SymbolNameZoomInfo>(m_symbolInfo);
}
GuidesClusterMark::GuidesClusterMark(m2::PointD const & ptOrg)
: UserMark(ptOrg, UserMark::GUIDE_CLUSTER)
{
Update();
}
void GuidesClusterMark::SetDepth(float depth)
{
SetDirty();
m_depth = depth;
}
void GuidesClusterMark::Update()
{
auto const isCity = m_outdoorGuidesCount < m_cityGuidesCount;
auto const totalCount = m_outdoorGuidesCount + m_cityGuidesCount;
auto const bigCluster = totalCount > 99;
if (isCity)
{
m_symbolInfo[kMinGuideMarkerZoom] = bigCluster ? "guide_city_cluster_plus"
: "guide_city_cluster";
}
else
{
m_symbolInfo[kMinGuideMarkerZoom] = bigCluster ? "guide_outdoor_cluster_plus"
: "guide_outdoor_cluster";
}
m_titleDecl.m_primaryTextFont.m_color = df::GetColorConstant(isCity ? kCityMarkTextColor
: kOutdoorMarkTextColor);
m_titleDecl.m_primaryTextFont.m_size = kGuideMarkTextSize;
m_titleDecl.m_anchor = dp::Center;
m_titleDecl.m_primaryText = bigCluster ? "99+" : strings::to_string(totalCount);
}
void GuidesClusterMark::SetGuidesCount(uint32_t cityGuidesCount, uint32_t outdoorGuidesCount)
{
SetDirty();
m_cityGuidesCount = cityGuidesCount;
m_outdoorGuidesCount = outdoorGuidesCount;
Update();
}
drape_ptr<df::UserPointMark::SymbolNameZoomInfo> GuidesClusterMark::GetSymbolNames() const
{
return make_unique_dp<SymbolNameZoomInfo>(m_symbolInfo);
}
drape_ptr<df::UserPointMark::TitlesInfo> GuidesClusterMark::GetTitleDecl() const
{
auto titleInfo = make_unique_dp<TitlesInfo>();
titleInfo->push_back(m_titleDecl);
return titleInfo;
}
GuideSelectionMark::GuideSelectionMark(m2::PointD const & ptOrg)
: UserMark(ptOrg, UserMark::GUIDE_SELECTION)
{
auto const vs = static_cast<float>(df::VisualParams::Instance().GetVisualScale());
df::ColoredSymbolViewParams params;
params.m_color = df::GetColorConstant(kSelectionMarkColor);
params.m_shape = df::ColoredSymbolViewParams::Shape::RoundedRectangle;
params.m_radiusInPixels = kGuideMarkRadius * vs;
params.m_sizeInPixels = m2::PointF(kGuideMarkSize + kGuideSelectionWidth,
kGuideMarkSize + kGuideSelectionWidth) * vs;
m_coloredInfo.m_zoomInfo[kMinGuideMarkerZoom] = params;
m_coloredInfo.m_needOverlay = false;
}
drape_ptr<df::UserPointMark::ColoredSymbolZoomInfo> GuideSelectionMark::GetColoredSymbols() const
{
return make_unique_dp<ColoredSymbolZoomInfo>(m_coloredInfo);
}