QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
24 : QMouseEvent( event->type(), event->pos(), event->button(), event->buttons(), event->modifiers() )
25 , mHasCachedSnapResult( false )
26 , mOriginalMapPoint( mapCanvas ? mapCanvas->mapSettings().mapToPixel().toMapCoordinates( event->pos() ) :
QgsPointXY() )
27 , mMapPoint( mOriginalMapPoint )
28 , mPixelPoint( event->pos() )
29 , mMapCanvas( mapCanvas )
34 : QMouseEvent( type, pos, button, buttons, modifiers )
35 , mHasCachedSnapResult( false )
36 , mOriginalMapPoint( mapCanvas ? mapCanvas->mapSettings().mapToPixel().toMapCoordinates( pos ) :
QgsPointXY() )
37 , mMapPoint( mOriginalMapPoint )
39 , mMapCanvas( mapCanvas )
46 if ( mHasCachedSnapResult )
49 mHasCachedSnapResult =
true;
52 mSnapMatch = snappingUtils->
snapToMap( mMapPoint,
nullptr,
true );
56 mMapPoint = mSnapMatch.
point();
57 mPixelPoint = mapToPixelCoordinates( mMapPoint );
61 mMapPoint = mOriginalMapPoint;
71 mPixelPoint = mapToPixelCoordinates( point );
88 pt = ct.
transform( pt, Qgis::TransformDirection::Reverse );
98 QPoint QgsMapMouseEvent::mapToPixelCoordinates(
const QgsPointXY &point )
100 double x = point.
x(), y = point.
y();
104 return QPoint( std::round( x ), std::round( y ) );
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
QgsPointXY snapPoint()
snapPoint will snap the points using the map canvas snapping utils configuration
const QgsCoordinateReferenceSystem & crs
Map canvas is a class for displaying all GIS data types on a canvas.
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
QgsPointXY point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords,...
void setX(double x) SIP_HOLDGIL
Sets the x value of the point.
QgsSnappingUtils * snappingUtils() const
Returns snapping utility class that is associated with map canvas.
QgsPointLocator::Match snapToMap(QPoint point, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false)
Snap to map according to the current configuration.
Custom exception class for Coordinate Reference System related exceptions.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
void snapToGrid(double precision, const QgsCoordinateReferenceSystem &crs)
Snaps the mapPoint to a grid with the given precision.
This class represents a coordinate reference system (CRS).
This class has all the configuration of snapping and can return answers to snapping queries.
A class to represent a 2D point.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
void transformInPlace(double &x, double &y) const
Transforms device coordinates to map coordinates.
QgsMapMouseEvent(QgsMapCanvas *mapCanvas, QMouseEvent *event)
Creates a new QgsMapMouseEvent.
const QgsMapToPixel & mapToPixel() const
void setMapPoint(const QgsPointXY &point)
Set the (snapped) point this event points to in map coordinates.