QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
16 #include "qgsmodelviewmouseevent.h"
17 #include "qgsmodelgraphicsview.h"
18 #include "qgsmodelsnapper.h"
19 
20 QgsModelViewMouseEvent::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.h
qgsmodelgraphicsview.h
QgsModelViewMouseEvent::modelPoint
QPointF modelPoint() const
Returns the event point location in model coordinates.
Definition: qgsmodelviewmouseevent.cpp:44
qgsmodelsnapper.h
QgsModelViewMouseEvent::QgsModelViewMouseEvent
QgsModelViewMouseEvent(QgsModelGraphicsView *view, QMouseEvent *event, bool snaps)
Constructor for QgsModelViewMouseEvent.
Definition: qgsmodelviewmouseevent.cpp:20
QgsModelViewMouseEvent::snapPoint
void snapPoint()
Manually triggers a snap for the mouse event position using the model's snapper.
Definition: qgsmodelviewmouseevent.cpp:36