MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / isPointOnObject

Method isPointOnObject

src/core/objects/object.cpp:622–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

620
621
622int 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
655void Object::takeRenderables()
656{

Callers 1

findObjectsAtMethod · 0.80

Calls 9

distanceSquaredToMethod · 0.80
xMethod · 0.80
yMethod · 0.80
calcTextPositionAtMethod · 0.80
isPointOnPathMethod · 0.80
MapCoordFClass · 0.50
getTypeMethod · 0.45
getContainedTypesMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected