| 620 | |
| 621 | |
| 622 | int Object::isPointOnObject(const MapCoordF& coord, qreal tolerance, bool treat_areas_as_paths, bool extended_selection) const |
| 623 | { |
| 624 | Symbol::Type type = symbol->getType(); |
| 625 | auto contained_types = symbol->getContainedTypes(); |
| 626 | |
| 627 | // Points |
| 628 | if (type == Symbol::Point) |
| 629 | { |
| 630 | if (extended_selection) |
| 631 | return extent.contains(coord) ? Symbol::Point : Symbol::NoSymbol; |
| 632 | |
| 633 | return (coord.distanceSquaredTo(MapCoordF(coords[0])) <= tolerance) ? Symbol::Point : Symbol::NoSymbol; |
| 634 | } |
| 635 | |
| 636 | // First check using extent |
| 637 | auto extent_extension = ((contained_types & Symbol::Line) || treat_areas_as_paths) ? tolerance : 0; |
| 638 | if (coord.x() < extent.left() - extent_extension) return Symbol::NoSymbol; |
| 639 | if (coord.y() < extent.top() - extent_extension) return Symbol::NoSymbol; |
| 640 | if (coord.x() > extent.right() + extent_extension) return Symbol::NoSymbol; |
| 641 | if (coord.y() > extent.bottom() + extent_extension) return Symbol::NoSymbol; |
| 642 | |
| 643 | if (type == Symbol::Text) |
| 644 | { |
| 645 | // Texts |
| 646 | auto const* text_object = static_cast<TextObject const*>(this); |
| 647 | return (text_object->calcTextPositionAt(coord, true) != -1) ? Symbol::Text : Symbol::NoSymbol; |
| 648 | } |
| 649 | |
| 650 | // Path objects |
| 651 | auto const* path = static_cast<PathObject const*>(this); |
| 652 | return path->isPointOnPath(coord, tolerance, treat_areas_as_paths, true); |
| 653 | } |
| 654 | |
| 655 | void Object::takeRenderables() |
| 656 | { |
no test coverage detected