| 1472 | } |
| 1473 | |
| 1474 | std::vector<PathObject*> PathObject::splitLineAt(const PathCoord& split_pos) const |
| 1475 | { |
| 1476 | Q_ASSERT(path_parts.size() == 1); |
| 1477 | Q_ASSERT((symbol->getContainedTypes() & ~Symbol::Combined) == Symbol::Line); |
| 1478 | |
| 1479 | std::vector<PathObject*> objects; |
| 1480 | if (path_parts.size() == 1) |
| 1481 | { |
| 1482 | const auto part_index = PathPartVector::size_type { 0 }; |
| 1483 | const auto& part = path_parts[part_index]; |
| 1484 | if (part.isClosed()) |
| 1485 | { |
| 1486 | PathObject* obj = duplicate()->asPath(); |
| 1487 | if ( split_pos.clen == part.path_coords.front().clen || |
| 1488 | split_pos.clen == part.path_coords.back().clen ) |
| 1489 | { |
| 1490 | (obj->path_parts[part_index]).setClosed(false); |
| 1491 | } |
| 1492 | else |
| 1493 | { |
| 1494 | obj->changePathBounds(part_index, split_pos.clen, split_pos.clen); |
| 1495 | } |
| 1496 | objects.push_back(obj); |
| 1497 | } |
| 1498 | else if ( split_pos.clen != part.path_coords.front().clen && |
| 1499 | split_pos.clen != part.path_coords.back().clen) |
| 1500 | { |
| 1501 | PathObject* obj1 = duplicate()->asPath(); |
| 1502 | obj1->changePathBounds(part_index, part.path_coords.front().clen, split_pos.clen); |
| 1503 | objects.push_back(obj1); |
| 1504 | |
| 1505 | PathObject* obj2 = duplicate()->asPath(); |
| 1506 | obj2->changePathBounds(part_index, split_pos.clen, part.path_coords.back().clen); |
| 1507 | objects.push_back(obj2); |
| 1508 | } |
| 1509 | } |
| 1510 | |
| 1511 | return objects; |
| 1512 | } |
| 1513 | |
| 1514 | void PathObject::changePathBounds( |
| 1515 | PathPartVector::size_type part_index, |
no test coverage detected