| 254 | } |
| 255 | |
| 256 | void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider, bool firstTime) |
| 257 | { |
| 258 | auto const updatedGroupIds = firstTime ? provider->GetAllGroupIds() : provider->GetUpdatedGroupIds(); |
| 259 | if (updatedGroupIds.empty()) |
| 260 | return; |
| 261 | |
| 262 | auto marksRenderCollection = make_unique_dp<UserMarksRenderCollection>(); |
| 263 | auto linesRenderCollection = make_unique_dp<UserLinesRenderCollection>(); |
| 264 | auto justCreatedIdCollection = make_unique_dp<IDCollections>(); |
| 265 | auto removedIdCollection = make_unique_dp<IDCollections>(); |
| 266 | |
| 267 | ankerl::unordered_dense::map<kml::MarkGroupId, drape_ptr<IDCollections>> groupsVisibleIds; |
| 268 | |
| 269 | auto const groupFilter = [&](kml::MarkGroupId groupId) |
| 270 | { return provider->IsGroupVisible(groupId) && (provider->GetBecameVisibleGroupIds().count(groupId) == 0); }; |
| 271 | |
| 272 | using GroupFilter = std::function<bool(kml::MarkGroupId groupId)>; |
| 273 | |
| 274 | auto const collectIds = [&](kml::MarkIdSet const & markIds, kml::TrackIdSet const & lineIds, |
| 275 | GroupFilter const & filter, IDCollections & collection) |
| 276 | { |
| 277 | for (auto const markId : markIds) |
| 278 | if (filter == nullptr || filter(provider->GetUserPointMark(markId)->GetGroupId())) |
| 279 | collection.m_markIds.push_back(markId); |
| 280 | |
| 281 | for (auto const lineId : lineIds) |
| 282 | if (filter == nullptr || filter(provider->GetUserLineMark(lineId)->GetGroupId())) |
| 283 | collection.m_lineIds.push_back(lineId); |
| 284 | }; |
| 285 | |
| 286 | auto const collectRenderData = |
| 287 | [&](kml::MarkIdSet const & markIds, kml::TrackIdSet const & lineIds, GroupFilter const & filter) |
| 288 | { |
| 289 | for (auto const markId : markIds) |
| 290 | { |
| 291 | auto const mark = provider->GetUserPointMark(markId); |
| 292 | if (filter == nullptr || filter(mark->GetGroupId())) |
| 293 | marksRenderCollection->emplace(markId, GenerateMarkRenderInfo(mark)); |
| 294 | } |
| 295 | |
| 296 | for (auto const lineId : lineIds) |
| 297 | { |
| 298 | auto const line = provider->GetUserLineMark(lineId); |
| 299 | if (filter == nullptr || filter(line->GetGroupId())) |
| 300 | linesRenderCollection->emplace(lineId, GenerateLineRenderInfo(line)); |
| 301 | } |
| 302 | }; |
| 303 | |
| 304 | if (firstTime) |
| 305 | { |
| 306 | for (auto groupId : provider->GetAllGroupIds()) |
| 307 | { |
| 308 | auto visibleIdCollection = make_unique_dp<IDCollections>(); |
| 309 | |
| 310 | if (provider->IsGroupVisible(groupId)) |
| 311 | { |
| 312 | collectIds(provider->GetGroupPointIds(groupId), provider->GetGroupLineIds(groupId), nullptr /* filter */, |
| 313 | *visibleIdCollection); |
no test coverage detected