QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
maptools
qgsmaptoolextent.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsmaptoolextent.h - map tool that emits an extent
3
---------------------
4
begin : July 2017
5
copyright : (C) 2017 by Mathieu Pellerin
6
email : nirvn dot asia 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 QGSMAPTOOLEXTENT_H
17
#define QGSMAPTOOLEXTENT_H
18
19
#include "qgis_gui.h"
20
#include "
qgsmaptool.h
"
21
#include "
qgspointxy.h
"
22
#include "
qgsrubberband.h
"
23
#include "
qobjectuniqueptr.h
"
24
25
class
QgsMapCanvas
;
26
27
32
class
GUI_EXPORT
QgsMapToolExtent
:
public
QgsMapTool
33
{
34
Q_OBJECT
35
36
public
:
38
QgsMapToolExtent
(
QgsMapCanvas
*
canvas
);
39
40
Flags
flags
()
const override
{
return
QgsMapTool::AllowZoomRect
; }
41
void
canvasMoveEvent
(
QgsMapMouseEvent
*e )
override
;
42
void
canvasPressEvent
(
QgsMapMouseEvent
*e )
override
;
43
void
canvasReleaseEvent
(
QgsMapMouseEvent
*e )
override
;
44
void
activate
()
override
;
45
void
deactivate
()
override
;
46
52
void
setRatio
( QSize
ratio
) { mRatio =
ratio
; }
53
58
QSize
ratio
()
const
{
return
mRatio; }
59
63
QgsRectangle
extent()
const
;
64
70
void
clearRubberBand();
71
72
signals:
73
75
void
extentChanged
(
const
QgsRectangle
&
extent
);
76
77
private
:
78
void
calculateEndPoint(
QgsPointXY
&point );
79
80
void
drawExtent();
81
82
QObjectUniquePtr<QgsRubberBand>
mRubberBand;
83
84
QgsPointXY
mStartPoint;
85
QgsPointXY
mEndPoint;
86
87
bool
mDraw =
false
;
88
89
QSize mRatio;
90
};
91
92
#endif
QObjectUniquePtr
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
Definition
qobjectuniqueptr.h:45
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition
qgsmapcanvas.h:96
QgsMapMouseEvent
A mouse event which is the result of a user interaction with a QgsMapCanvas.
Definition
qgsmapmouseevent.h:38
QgsMapToolExtent::flags
Flags flags() const override
Returns the flags for the map tool.
Definition
qgsmaptoolextent.h:40
QgsMapToolExtent::ratio
QSize ratio() const
Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.
Definition
qgsmaptoolextent.h:58
QgsMapToolExtent::extent
QgsRectangle extent() const
Returns the current extent drawn onto the canvas.
Definition
qgsmaptoolextent.cpp:85
QgsMapToolExtent::extentChanged
void extentChanged(const QgsRectangle &extent)
signal emitted on extent change
QgsMapToolExtent::QgsMapToolExtent
QgsMapToolExtent(QgsMapCanvas *canvas)
constructor
Definition
qgsmaptoolextent.cpp:24
QgsMapToolExtent::setRatio
void setRatio(QSize ratio)
Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
Definition
qgsmaptoolextent.h:52
QgsMapTool::canvas
QgsMapCanvas * canvas() const
returns pointer to the tool's map canvas
Definition
qgsmaptool.cpp:236
QgsMapTool::QgsMapTool
QgsMapTool(QgsMapCanvas *canvas)
Constructor takes a map canvas as a parameter.
Definition
qgsmaptool.cpp:39
QgsMapTool::Flags
QFlags< Flag > Flags
Definition
qgsmaptool.h:117
QgsMapTool::QgsMapCanvas
friend class QgsMapCanvas
Definition
qgsmaptool.h:423
QgsMapTool::canvasPressEvent
virtual void canvasPressEvent(QgsMapMouseEvent *e)
Mouse press event for overriding. Default implementation does nothing.
Definition
qgsmaptool.cpp:193
QgsMapTool::canvasMoveEvent
virtual void canvasMoveEvent(QgsMapMouseEvent *e)
Mouse move event for overriding. Default implementation does nothing.
Definition
qgsmaptool.cpp:183
QgsMapTool::canvasReleaseEvent
virtual void canvasReleaseEvent(QgsMapMouseEvent *e)
Mouse release event for overriding. Default implementation does nothing.
Definition
qgsmaptool.cpp:198
QgsMapTool::AllowZoomRect
@ AllowZoomRect
Allow zooming by rectangle (by holding shift and dragging) while the tool is active.
Definition
qgsmaptool.h:114
QgsMapTool::activate
virtual void activate()
called when set as currently active map tool
Definition
qgsmaptool.cpp:105
QgsMapTool::deactivate
virtual void deactivate()
called when map tool is being deactivated
Definition
qgsmaptool.cpp:121
QgsPointXY
Represents a 2D point.
Definition
qgspointxy.h:62
QgsRectangle
A rectangle specified with double values.
Definition
qgsrectangle.h:47
qgsmaptool.h
qgspointxy.h
qgsrubberband.h
qobjectuniqueptr.h
Generated on
for QGIS API Documentation by
1.17.0