30 QgsPointXY ptMapCenterRightMU( ptMapCenterMU.
x() + distMU, ptMapCenterMU.
y() );
33 double distLU = std::sqrt( ptMapCenterLU.sqrDist( ptMapCenterRightLU ) );
34 double ratio = distMU / distLU;
43 else if ( units ==
Pixels )
48 return tolerance *
_ratioMU2LU( mapSettings, layer );
60 else if ( units ==
Pixels )
62 double layerUnitsPerPixel = computeMapUnitPerPixel( layer, mapSettings );
63 return tolerance * layerUnitsPerPixel;
68 return tolerance /
_ratioMU2LU( mapSettings, layer );
75 double tolerance = settings.
value( QStringLiteral(
"qgis/digitizing/search_radius_vertex_edit" ), 10 ).toDouble();
85 double tolerance = settings.
value( QStringLiteral(
"qgis/digitizing/search_radius_vertex_edit" ), 10 ).toDouble();
104 QgsPointXY p1 = toLayerCoordinates( layer, mapSettings, QPoint( 0, 1 ) );
105 QgsPointXY p2 = toLayerCoordinates( layer, mapSettings, QPoint( 0, 2 ) );
106 QgsPointXY p3 = toLayerCoordinates( layer, mapSettings, QPoint( 1, 0 ) );
107 QgsPointXY p4 = toLayerCoordinates( layer, mapSettings, QPoint( 2, 0 ) );
112 return std::sqrt( x );
116 return std::sqrt( y );
Base class for all map layer types.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
A class to represent a 2D point.
UnitType
Type of unit of tolerance value from settings.
static double toleranceInMapUnits(double tolerance, QgsMapLayer *layer, const QgsMapSettings &mapSettings, UnitType units=LayerUnits)
Static function to translate tolerance value into layer units.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
The QgsMapSettings class contains configuration for rendering of the map.
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
static const double DEFAULT_SNAP_TOLERANCE
Default snapping distance tolerance.
Pixels unit of tolerance.
double mapUnitsPerPixel() const
Returns the distance in geographical coordinates that equals to one pixel in the map.
static double defaultTolerance(QgsMapLayer *layer, const QgsMapSettings &mapSettings)
Static function to get default tolerance value for a layer.
static const QgsTolerance::UnitType DEFAULT_SNAP_UNITS
Default snapping distance units.
const QgsMapToPixel & mapToPixel() const
static double vertexSearchRadius(const QgsMapSettings &mapSettings)
Static function to get vertex tolerance value.
Map (project) units. Added in 2.8.
static double toleranceInProjectUnits(double tolerance, QgsMapLayer *layer, const QgsMapSettings &mapSettings, QgsTolerance::UnitType units)
Static function to translate tolerance value into map units.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
double _ratioMU2LU(const QgsMapSettings &mapSettings, QgsMapLayer *layer)
QgsPointXY center() const
Returns the center point of the rectangle.
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