QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslayoutviewrubberband.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutviewrubberband.h
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#ifndef QGSLAYOUTVIEWRUBBERBAND_H
17#define QGSLAYOUTVIEWRUBBERBAND_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21
22#include <QBrush>
23#include <QObject>
24#include <QPen>
25
26class QgsLayoutView;
27class QGraphicsRectItem;
28class QGraphicsEllipseItem;
29class QGraphicsPolygonItem;
30class QgsLayout;
31
37class GUI_EXPORT QgsLayoutViewRubberBand : public QObject
38{
39 Q_OBJECT
40
41#ifdef SIP_RUN
43 if ( dynamic_cast<QgsLayoutViewMouseEvent *>( sipCpp ) )
44 sipType = sipType_QgsLayoutViewMouseEvent;
45 else
46 sipType = 0;
48#endif
49
50 public:
55
56 ~QgsLayoutViewRubberBand() override = default;
57
62
67 virtual void start( QPointF position, Qt::KeyboardModifiers modifiers ) = 0;
68
73 virtual void update( QPointF position, Qt::KeyboardModifiers modifiers ) = 0;
74
80 virtual QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers() ) = 0;
81
86 QgsLayoutView *view() const;
87
92 QgsLayout *layout() const;
93
99 QBrush brush() const;
100
106 void setBrush( const QBrush &brush );
107
113 QPen pen() const;
114
120 void setPen( const QPen &pen );
121
122 signals:
123
130 void sizeChanged( const QString &size );
131
132 protected:
139 QRectF updateRect( QPointF start, QPointF position, bool constrainSquare, bool fromCenter );
140
141 private:
142 QgsLayoutView *mView = nullptr;
143
144 QBrush mBrush = Qt::NoBrush;
145 QPen mPen = QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 );
146};
147
148
154{
155 Q_OBJECT
156
157 public:
163
165
166 void start( QPointF position, Qt::KeyboardModifiers modifiers ) override;
167 void update( QPointF position, Qt::KeyboardModifiers modifiers ) override;
168 QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers() ) override;
169
170 private:
172 QGraphicsRectItem *mRubberBandItem = nullptr;
173
175 QPointF mRubberBandStartPos;
176};
177
183{
184 Q_OBJECT
185
186 public:
192
194
195 void start( QPointF position, Qt::KeyboardModifiers modifiers ) override;
196 void update( QPointF position, Qt::KeyboardModifiers modifiers ) override;
197 QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers() ) override;
198
199 private:
201 QGraphicsEllipseItem *mRubberBandItem = nullptr;
202
204 QPointF mRubberBandStartPos;
205};
206
212{
213 Q_OBJECT
214
215 public:
221
223
224 void start( QPointF position, Qt::KeyboardModifiers modifiers ) override;
225 void update( QPointF position, Qt::KeyboardModifiers modifiers ) override;
226 QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers() ) override;
227
228 private:
230 QGraphicsPolygonItem *mRubberBandItem = nullptr;
231
233 QPointF mRubberBandStartPos;
234};
235#endif // QGSLAYOUTVIEWRUBBERBAND_H
QgsLayoutViewEllipticalRubberBand(QgsLayoutView *view=nullptr)
Constructor for QgsLayoutViewEllipticalRubberBand.
void update(QPointF position, Qt::KeyboardModifiers modifiers) override
Called when a rubber band should be updated to reflect a temporary ending position (in layout coordin...
QgsLayoutViewEllipticalRubberBand * create(QgsLayoutView *view) const override
Creates a new instance of the QgsLayoutViewRubberBand subclass.
void start(QPointF position, Qt::KeyboardModifiers modifiers) override
Called when a rubber band should be created at the specified starting position (in layout coordinate ...
QRectF finish(QPointF position=QPointF(), Qt::KeyboardModifiers modifiers=Qt::KeyboardModifiers()) override
Called when a rubber band use has finished and the rubber band is no longer required.
A mouse event which is the result of a user interaction with a QgsLayoutView.
QgsLayoutViewRectangularRubberBand * create(QgsLayoutView *view) const override
Creates a new instance of the QgsLayoutViewRubberBand subclass.
void update(QPointF position, Qt::KeyboardModifiers modifiers) override
Called when a rubber band should be updated to reflect a temporary ending position (in layout coordin...
QgsLayoutViewRectangularRubberBand(QgsLayoutView *view=nullptr)
Constructor for QgsLayoutViewRectangularRubberBand.
void start(QPointF position, Qt::KeyboardModifiers modifiers) override
Called when a rubber band should be created at the specified starting position (in layout coordinate ...
QRectF finish(QPointF position=QPointF(), Qt::KeyboardModifiers modifiers=Qt::KeyboardModifiers()) override
Called when a rubber band use has finished and the rubber band is no longer required.
QgsLayoutViewRubberBand(QgsLayoutView *view=nullptr)
Constructor for QgsLayoutViewRubberBand.
~QgsLayoutViewRubberBand() override=default
virtual QRectF finish(QPointF position=QPointF(), Qt::KeyboardModifiers modifiers=Qt::KeyboardModifiers())=0
Called when a rubber band use has finished and the rubber band is no longer required.
QgsLayoutView * view() const
Returns the view associated with the rubber band.
void sizeChanged(const QString &size)
Emitted when the size of the rubber band is changed.
QBrush brush() const
Returns the brush used for drawing the rubber band.
virtual void start(QPointF position, Qt::KeyboardModifiers modifiers)=0
Called when a rubber band should be created at the specified starting position (in layout coordinate ...
void setPen(const QPen &pen)
Sets the pen used for drawing the rubber band.
virtual QgsLayoutViewRubberBand * create(QgsLayoutView *view) const =0
Creates a new instance of the QgsLayoutViewRubberBand subclass.
void setBrush(const QBrush &brush)
Sets the brush used for drawing the rubber band.
QgsLayout * layout() const
Returns the layout associated with the rubber band.
QPen pen() const
Returns the pen used for drawing the rubber band.
virtual void update(QPointF position, Qt::KeyboardModifiers modifiers)=0
Called when a rubber band should be updated to reflect a temporary ending position (in layout coordin...
QRectF updateRect(QPointF start, QPointF position, bool constrainSquare, bool fromCenter)
Calculates an updated bounding box rectangle from a original start position and new position.
QRectF finish(QPointF position=QPointF(), Qt::KeyboardModifiers modifiers=Qt::KeyboardModifiers()) override
Called when a rubber band use has finished and the rubber band is no longer required.
QgsLayoutViewTriangleRubberBand(QgsLayoutView *view=nullptr)
Constructor for QgsLayoutViewTriangleRubberBand.
QgsLayoutViewTriangleRubberBand * create(QgsLayoutView *view) const override
Creates a new instance of the QgsLayoutViewRubberBand subclass.
void update(QPointF position, Qt::KeyboardModifiers modifiers) override
Called when a rubber band should be updated to reflect a temporary ending position (in layout coordin...
void start(QPointF position, Qt::KeyboardModifiers modifiers) override
Called when a rubber band should be created at the specified starting position (in layout coordinate ...
A graphical widget to display and interact with QgsLayouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:50
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_END
Definition qgis_sip.h:216