30 :
QMouseEvent( event->type(), event->pos(), event->button(), event->buttons(), event->modifiers() )
31 , mSnappingMode( NoSnapping )
32 , mOriginalMapPoint( mapCanvas ? mapCanvas->mapSettings().mapToPixel().toMapCoordinates( event->pos() ) :
QgsPoint() )
33 , mMapPoint( mOriginalMapPoint )
34 , mPixelPoint( event->pos() )
35 , mMapCanvas( mapCanvas )
40 :
QMouseEvent( type, pos, button, buttons, modifiers )
42 , mOriginalMapPoint( mapCanvas ? mapCanvas->mapSettings().mapToPixel().toMapCoordinates( pos ) :
QgsPoint() )
43 , mMapPoint( mOriginalMapPoint )
45 , mMapCanvas( mapCanvas )
52 if ( mSnappingMode == snappingMode )
55 mSnappingMode = snappingMode;
59 mMapPoint = mOriginalMapPoint;
74 mSnapMatch = snappingUtils->
snapToMap( mMapPoint );
80 mSnapMatch = snappingUtils->
snapToMap( mMapPoint );
85 mMapPoint = mSnapMatch.
point();
86 mPixelPoint = mapToPixelCoordinates( mMapPoint );
90 mMapPoint = mOriginalMapPoint;
103 if ( snappingMode == mSnappingMode && mSnapMatch.
hasEdge() )
106 segment << pt1 << pt2;
129 match = snappingUtils->
snapToMap( mOriginalMapPoint );
136 segment << pt1 << pt2;
142 *snapped = segment.
count() == 2;
151 mPixelPoint = mapToPixelCoordinates( point );
154 QPoint QgsMapMouseEvent::mapToPixelCoordinates(
const QgsPoint& point )
156 double x = point.
x(),
y = point.
y();
160 return QPoint( qRound( x ), qRound(
y ) );
SnapToMapMode snapToMapMode() const
Find out how the snapping to map is done.
snap to all rendered layers (tolerance and type from defaultSettings())
snap to all rendered layers (tolerance and type from defaultSettings())
bool acceptMatch(const QgsPointLocator::Match &m) override
UnitType
Type of unit of tolerance value from settings.
QgsMapMouseEvent(QgsMapCanvas *mapCanvas, QMouseEvent *event)
Creates a new QgsMapMouseEvent.
Interface that allows rejection of some matches in intersection queries (e.g.
Map canvas is a class for displaying all GIS data types on a canvas.
double y() const
Get the y value of the point.
void transformInPlace(double &x, double &y) const
Transform device coordinates to map coordinates.
int count(const T &value) const
snap according to the configuration set in the snapping settings
void setSnapToMapMode(SnapToMapMode mode)
Set how the snapping to map is done.
QList< QgsPoint > snapSegment(SnappingMode snappingMode, bool *snapped=nullptr, bool allLayers=false) const
Returns the first snapped segment.
Snapped to a vertex. Can be a vertex of the geometry or an intersection.
A class to represent a point.
const QgsMapToPixel & mapToPixel() const
void setMapPoint(const QgsPoint &point)
Set the (snapped) point this event points to in map coordinates.
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
This class has all the configuration of snapping and can return answers to snapping queries...
void edgePoints(QgsPoint &pt1, QgsPoint &pt2) const
Only for a valid edge match - obtain endpoints of the edge.
const QPoint & pos() const
QgsPoint point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords...
QgsPointLocator::Match snapToMap(QPoint point, QgsPointLocator::MatchFilter *filter=nullptr)
Snap to map according to the current configuration (mode).
QgsPoint snapPoint(SnappingMode snappingMode)
snapPoint will snap the points using the map canvas snapping utils configuration
QgsSnappingUtils * snappingUtils() const
Return snapping utility class that is associated with map canvas.
void setDefaultSettings(int type, double tolerance, QgsTolerance::UnitType unit)
Configure options used when the mode is snap to current layer or to all layers.
double x() const
Get the x value of the point.
void defaultSettings(int &type, double &tolerance, QgsTolerance::UnitType &unit)
Query options used when the mode is snap to current layer or to all layers.
typedef KeyboardModifiers
SnapToMapMode
modes for "snap to background"