17#include "moc_qgstolerance.cpp"
34 const QgsPointXY ptMapCenterRightMU( ptMapCenterMU.
x() + distMU, ptMapCenterMU.
y() );
37 const double distLU = std::sqrt( ptMapCenterLU.
sqrDist( ptMapCenterRightLU ) );
38 const double ratio = distMU / distLU;
52 return tolerance *
_ratioMU2LU( mapSettings, layer );
66 const double layerUnitsPerPixel = computeMapUnitPerPixel( layer, mapSettings );
67 return tolerance * layerUnitsPerPixel;
72 return tolerance /
_ratioMU2LU( mapSettings, layer );
105 const QgsPointXY p1 = toLayerCoordinates( layer, mapSettings, QPoint( 0, 1 ) );
106 const QgsPointXY p2 = toLayerCoordinates( layer, mapSettings, QPoint( 0, 2 ) );
107 const QgsPointXY p3 = toLayerCoordinates( layer, mapSettings, QPoint( 1, 0 ) );
108 const QgsPointXY p4 = toLayerCoordinates( layer, mapSettings, QPoint( 2, 0 ) );
109 const double x = p1.
sqrDist( p2 );
110 const double y = p3.
sqrDist( p4 );
113 return std::sqrt( x );
117 return std::sqrt( y );
MapToolUnit
Type of unit of tolerance value from settings.
@ Project
Map (project) units.
@ Pixels
Pixels unit of tolerance.
Base class for all map layer types.
The QgsMapSettings class contains configuration for rendering of the map.
const QgsMapToPixel & mapToPixel() const
double mapUnitsPerPixel() const
Returns the distance in geographical coordinates that equals to one pixel in the map.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
A class to represent a 2D point.
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
static const QgsSettingsEntryDouble * settingsDigitizingSearchRadiusVertexEdit
Settings entry digitizing search radius vertex edit.
static const QgsSettingsEntryEnumFlag< Qgis::MapToolUnit > * settingsDigitizingDefaultSnappingToleranceUnit
Settings entry digitizing default snapping tolerance unit.
static const QgsSettingsEntryEnumFlag< Qgis::MapToolUnit > * settingsDigitizingSearchRadiusVertexEditUnit
Settings entry digitizing search radius vertex edit unit.
static const QgsSettingsEntryDouble * settingsDigitizingDefaultSnappingTolerance
Settings entry digitizing default snapping tolerance.
static double toleranceInMapUnits(double tolerance, QgsMapLayer *layer, const QgsMapSettings &mapSettings, Qgis::MapToolUnit units=Qgis::MapToolUnit::Layer)
Static function to translate tolerance value into layer units.
static double vertexSearchRadius(const QgsMapSettings &mapSettings)
Static function to get vertex tolerance value.
static double defaultTolerance(QgsMapLayer *layer, const QgsMapSettings &mapSettings)
Static function to get default tolerance value for a layer.
static double toleranceInProjectUnits(double tolerance, QgsMapLayer *layer, const QgsMapSettings &mapSettings, Qgis::MapToolUnit units)
Static function to translate tolerance value into map units.
double _ratioMU2LU(const QgsMapSettings &mapSettings, QgsMapLayer *layer)