QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
qgsmodelviewrubberband.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelviewrubberband.h
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#ifndef QGSMODELVIEWRUBBERBAND_H
17#define QGSMODELVIEWRUBBERBAND_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21#include <QBrush>
22#include <QPen>
23#include <QObject>
24
25#define SIP_NO_FILE
26
27class QgsModelGraphicsView;
28class QGraphicsRectItem;
29class QGraphicsEllipseItem;
30class QGraphicsPolygonItem;
31
38class GUI_EXPORT QgsModelViewRubberBand : public QObject
39{
40
41 Q_OBJECT
42
43 public:
44
48 QgsModelViewRubberBand( QgsModelGraphicsView *view = nullptr );
49
50 ~QgsModelViewRubberBand() override = default;
51
55 virtual QgsModelViewRubberBand *create( QgsModelGraphicsView *view ) const = 0 SIP_FACTORY;
56
61 virtual void start( QPointF position, Qt::KeyboardModifiers modifiers ) = 0;
62
67 virtual void update( QPointF position, Qt::KeyboardModifiers modifiers ) = 0;
68
74 virtual QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers() ) = 0;
75
79 QgsModelGraphicsView *view() const;
80
86 QBrush brush() const;
87
93 void setBrush( const QBrush &brush );
94
100 QPen pen() const;
101
107 void setPen( const QPen &pen );
108
109 signals:
110
117 void sizeChanged( const QString &size );
118
119 protected:
120
127 QRectF updateRect( QPointF start, QPointF position, bool constrainSquare, bool fromCenter );
128
129 private:
130
131 QgsModelGraphicsView *mView = nullptr;
132
133 QBrush mBrush = Qt::NoBrush;
134 QPen mPen = QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 );
135
136};
137
138
145{
146 Q_OBJECT
147
148 public:
149
153 QgsModelViewRectangularRubberBand( QgsModelGraphicsView *view = nullptr );
154 QgsModelViewRectangularRubberBand *create( QgsModelGraphicsView *view ) const override SIP_FACTORY;
155
157
158 void start( QPointF position, Qt::KeyboardModifiers modifiers ) override;
159 void update( QPointF position, Qt::KeyboardModifiers modifiers ) override;
160 QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers() ) override;
161
162 private:
163
165 QGraphicsRectItem *mRubberBandItem = nullptr;
166
168 QPointF mRubberBandStartPos;
169
170};
171
172#endif // QGSMODELVIEWRUBBERBAND_H
QgsModelViewRectangularRubberBand is rectangular rubber band for use within QgsModelGraphicsView widg...
QgsModelViewRubberBand is an abstract base class for temporary rubber band items in various shapes,...
virtual void update(QPointF position, Qt::KeyboardModifiers modifiers)=0
Called when a rubber band should be updated to reflect a temporary ending position (in model coordina...
~QgsModelViewRubberBand() 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.
void sizeChanged(const QString &size)
Emitted when the size of the rubber band is changed.
virtual QgsModelViewRubberBand * create(QgsModelGraphicsView *view) const =0
Creates a new instance of the QgsModelViewRubberBand subclass.
virtual void start(QPointF position, Qt::KeyboardModifiers modifiers)=0
Called when a rubber band should be created at the specified starting position (in model coordinate s...
#define SIP_FACTORY
Definition qgis_sip.h:76