QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslayoutviewmouseevent.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutviewmouseevent.cpp
3 ---------------------------
4 Date : July 2017
5 Copyright : (C) 2017 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
18
19#include "qgslayout.h"
20#include "qgslayoutview.h"
21
23 : QMouseEvent( event->type(), event->pos(), event->button(), event->buttons(), event->modifiers() )
24 , mView( view )
25{
26 mLayoutPoint = mView->mapToScene( x(), y() );
27 if ( snap && mView->currentLayout() )
28 {
29 mSnappedPoint = mView->currentLayout()->snapper().snapPoint( mLayoutPoint, mView->transform().m11(), mSnapped );
30 }
31 else
32 {
33 mSnappedPoint = mLayoutPoint;
34 }
35}
36
37void QgsLayoutViewMouseEvent::snapPoint( QGraphicsLineItem *horizontalSnapLine, QGraphicsLineItem *verticalSnapLine, const QList<QgsLayoutItem *> &excludeItems )
38{
39 if ( mView->currentLayout() )
40 {
41 mSnappedPoint = mView->currentLayout()->snapper().snapPoint( mLayoutPoint, mView->transform().m11(), mSnapped, horizontalSnapLine, verticalSnapLine, &excludeItems );
42 }
43}
44
46{
47 return mLayoutPoint;
48}
void snapPoint(QGraphicsLineItem *horizontalSnapLine=nullptr, QGraphicsLineItem *verticalSnapLine=nullptr, const QList< QgsLayoutItem * > &ignoreItems=QList< QgsLayoutItem * >())
Manually triggers a snap for the mouse event position using the layout's snapper.
QgsLayoutViewMouseEvent(QgsLayoutView *view, QMouseEvent *event, bool snap=false)
Constructor for QgsLayoutViewMouseEvent.
QPointF layoutPoint() const
Returns the event point location in layout coordinates.
A graphical widget to display and interact with QgsLayouts.