28#include "moc_qgsannotationmaptool.cpp"
38 double closestItemDistance = std::numeric_limits<double>::max();
39 double closestItemArea = std::numeric_limits<double>::max();
44 if ( !annotationItem )
48 const double itemDistance = itemBounds.
contains( mapPoint ) ? 0 : itemBounds.
distance( mapPoint );
49 if ( !closestItem || itemDistance < closestItemDistance || ( itemDistance == closestItemDistance && itemBounds.
area() < closestItemArea ) )
52 closestItemDistance = itemDistance;
53 closestItemArea = itemBounds.
area();
73 return layer ?
layer->item( itemId ) :
nullptr;
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Represents a map layer containing a set of georeferenced annotations, e.g.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsAnnotationLayer * mainAnnotationLayer()
Returns the main annotation layer associated with the project.
A rectangle specified with double values.
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
double distance(const QgsPointXY &point) const
Returns the distance from point to the nearest point on the boundary of the rectangle.
Contains information about a rendered annotation item.