| 256 | } |
| 257 | |
| 258 | bool RoutePointsLayout::RemoveRoutePoint(RouteMarkType type, size_t intermediateIndex) |
| 259 | { |
| 260 | RouteMarkPoint const * point = nullptr; |
| 261 | for (auto markId : m_manager.GetUserMarkIds(UserMark::Type::ROUTING)) |
| 262 | { |
| 263 | auto const * mark = m_manager.GetMark<RouteMarkPoint>(markId); |
| 264 | if (mark->IsEqualFullType(type, intermediateIndex)) |
| 265 | { |
| 266 | point = mark; |
| 267 | break; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | if (point == nullptr) |
| 272 | return false; |
| 273 | |
| 274 | if (type == RouteMarkType::Finish) |
| 275 | { |
| 276 | RouteMarkPoint * lastIntermediate = nullptr; |
| 277 | size_t maxIntermediateIndex = 0; |
| 278 | ForEachIntermediatePoint([&lastIntermediate, &maxIntermediateIndex](RouteMarkPoint * mark) |
| 279 | { |
| 280 | if (lastIntermediate == nullptr || mark->GetIntermediateIndex() > maxIntermediateIndex) |
| 281 | { |
| 282 | lastIntermediate = mark; |
| 283 | maxIntermediateIndex = mark->GetIntermediateIndex(); |
| 284 | } |
| 285 | }); |
| 286 | |
| 287 | if (lastIntermediate != nullptr) |
| 288 | lastIntermediate->SetRoutePointFullType(RouteMarkType::Finish, 0); |
| 289 | } |
| 290 | else if (type == RouteMarkType::Start) |
| 291 | { |
| 292 | ForEachIntermediatePoint([](RouteMarkPoint * mark) |
| 293 | { |
| 294 | if (mark->GetIntermediateIndex() == 0) |
| 295 | mark->SetRoutePointFullType(RouteMarkType::Start, 0); |
| 296 | else |
| 297 | mark->SetIntermediateIndex(mark->GetIntermediateIndex() - 1); |
| 298 | }); |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | ForEachIntermediatePoint([point](RouteMarkPoint * mark) |
| 303 | { |
| 304 | if (mark->GetIntermediateIndex() > point->GetIntermediateIndex()) |
| 305 | mark->SetIntermediateIndex(mark->GetIntermediateIndex() - 1); |
| 306 | }); |
| 307 | } |
| 308 | |
| 309 | m_editSession.DeleteUserMark(point->GetId()); |
| 310 | return true; |
| 311 | } |
| 312 | |
| 313 | void RoutePointsLayout::RemoveRoutePoints() |
| 314 | { |
no test coverage detected