QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
17
19#include "qgsmodelsnapper.h"
20
21QgsModelViewMouseEvent::QgsModelViewMouseEvent( QgsModelGraphicsView *view, QMouseEvent *event, bool snap )
22 : QMouseEvent( event->type(), event->pos(), event->button(), event->buttons(), event->modifiers() )
23 , mView( view )
24{
25 mModelPoint = mView->mapToScene( x(), y() );
26
27 if ( snap && mView->snapper() )
28 {
29 mSnappedPoint = mView->snapper()->snapPoint( mModelPoint, mView->transform().m11(), mSnapped );
30 }
31 else
32 {
33 mSnappedPoint = mModelPoint;
34 }
35}
36
38{
39 if ( mView->snapper() )
40 {
41 mSnappedPoint = mView->snapper()->snapPoint( mModelPoint, mView->transform().m11(), mSnapped );
42 }
43}
44
46{
47 return mModelPoint;
48}
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.