QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsmodelviewmouseevent.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelviewmouseevent.cpp
3 ---------------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
18#include "qgsmodelsnapper.h"
19
20QgsModelViewMouseEvent::QgsModelViewMouseEvent( QgsModelGraphicsView *view, QMouseEvent *event, bool snap )
21 : QMouseEvent( event->type(), event->pos(), event->button(), event->buttons(), event->modifiers() )
22 , mView( view )
23{
24 mModelPoint = mView->mapToScene( x(), y() );
25
26 if ( snap && mView->snapper() )
27 {
28 mSnappedPoint = mView->snapper()->snapPoint( mModelPoint, mView->transform().m11(), mSnapped );
29 }
30 else
31 {
32 mSnappedPoint = mModelPoint;
33 }
34}
35
37{
38 if ( mView->snapper() )
39 {
40 mSnappedPoint = mView->snapper()->snapPoint( mModelPoint, mView->transform().m11(), mSnapped );
41 }
42}
43
45{
46 return mModelPoint;
47}
QgsModelViewMouseEvent(QgsModelGraphicsView *view, QMouseEvent *event, bool snaps)
Constructor for QgsModelViewMouseEvent.
void snapPoint()
Manually triggers a snap for the mouse event position using the model's snapper.
QPointF modelPoint() const
Returns the event point location in model coordinates.