QGIS API Documentation  2.99.0-Master (cd0ba91)
qgsmapoverviewcanvas.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmapoverviewcanvas.h
3  Map canvas subclassed for overview
4  -------------------
5  begin : 09/14/2005
6  copyright : (C) 2005 by Martin Dobias
7  email : won.der at centrum.sk
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSMAPOVERVIEWCANVAS_H
20 #define QGSMAPOVERVIEWCANVAS_H
21 
22 
23 #include <QMouseEvent>
24 #include <QWheelEvent>
25 #include <QWidget>
26 #include <QStringList>
27 #include <QPixmap>
28 
29 class QgsMapCanvas;
30 class QgsPanningWidget; // defined in .cpp
31 class QgsRectangle;
32 
34 #include "qgsmapsettings.h"
35 #include "qgis_gui.h"
36 
41 class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
42 {
43  Q_OBJECT
44 
45  public:
46  QgsMapOverviewCanvas( QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapCanvas *mapCanvas = nullptr );
47 
49  void refresh();
50 
52  void setBackgroundColor( const QColor &color );
53 
55  void setLayers( const QList<QgsMapLayer *> &layers );
56 
58  QList<QgsMapLayer *> layers() const;
59 
60  void enableAntiAliasing( bool flag ) { mSettings.setFlag( QgsMapSettings::Antialiasing, flag ); }
61 
62  void updateFullExtent();
63 
64  public slots:
65 
66  // ### QGIS 3: make protected
68  void drawExtentRect();
69 
70  // ### QGIS 3: make protected
72  void destinationCrsChanged();
73 
74  protected slots:
75  void mapRenderingFinished();
76 
80  void layerRepaintRequested( bool deferred = false );
81 
82  protected:
83 
85  void paintEvent( QPaintEvent *pe ) override;
86 
88  void showEvent( QShowEvent *e ) override;
89 
91  void resizeEvent( QResizeEvent *e ) override;
92 
94  void mouseMoveEvent( QMouseEvent *e ) override;
95 
97  void mousePressEvent( QMouseEvent *e ) override;
98 
100  void mouseReleaseEvent( QMouseEvent *e ) override;
101 
103  void updatePanningWidget( QPoint pos );
104 
106  QgsPanningWidget *mPanningWidget = nullptr;
107 
110 
112  QgsMapCanvas *mMapCanvas = nullptr;
113 
115  QPixmap mPixmap;
116 
119 
121  QgsMapRendererQImageJob *mJob = nullptr;
122 };
123 
124 
125 #ifndef SIP_RUN
126 
128 // Widget that serves as rectangle showing current extent in overview
129 class QgsPanningWidget : public QWidget
130 {
131  Q_OBJECT
132 
133  QPolygon mPoly;
134 
135  public:
136  explicit QgsPanningWidget( QWidget *parent );
137 
138  void setPolygon( const QPolygon &p );
139 
140  void paintEvent( QPaintEvent *pe ) override;
141 
142 };
144 
145 #endif
146 
147 #endif
QPoint mPanningCursorOffset
position of cursor inside panning widget
A rectangle specified with double values.
Definition: qgsrectangle.h:39
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A widget that displays an overview map.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:74
The QgsMapSettings class contains configuration for rendering of the map.
void enableAntiAliasing(bool flag)
QgsMapSettings mSettings
map settings used for rendering of the overview map
Enable anti-aliasing for map rendering.
QPixmap mPixmap
pixmap where the map is stored
Intermediate base class adding functionality that allows client to query the rendered image...