QGIS API Documentation  2.99.0-Master (716ff6c)
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 
40 class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
41 {
42  Q_OBJECT
43 
44  public:
45  QgsMapOverviewCanvas( QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr );
46 
48  void refresh();
49 
51  void setBackgroundColor( const QColor &color );
52 
54  void setLayers( const QList<QgsMapLayer *> &layers );
55 
57  QList<QgsMapLayer *> layers() const;
58 
59  void enableAntiAliasing( bool flag ) { mSettings.setFlag( QgsMapSettings::Antialiasing, flag ); }
60 
61  void updateFullExtent();
62 
63  public slots:
64 
65  // ### QGIS 3: make protected
67  void drawExtentRect();
68 
69  // ### QGIS 3: make protected
71  void destinationCrsChanged();
72 
73  protected slots:
74  void mapRenderingFinished();
75 
79  void layerRepaintRequested( bool deferred = false );
80 
81  protected:
82 
84  void paintEvent( QPaintEvent *pe ) override;
85 
87  void showEvent( QShowEvent *e ) override;
88 
90  void resizeEvent( QResizeEvent *e ) override;
91 
93  void mouseMoveEvent( QMouseEvent *e ) override;
94 
96  void mousePressEvent( QMouseEvent *e ) override;
97 
99  void mouseReleaseEvent( QMouseEvent *e ) override;
100 
102  void updatePanningWidget( QPoint pos );
103 
105  QgsPanningWidget *mPanningWidget = nullptr;
106 
109 
111  QgsMapCanvas *mMapCanvas = nullptr;
112 
114  QPixmap mPixmap;
115 
118 
120  QgsMapRendererQImageJob *mJob = nullptr;
121 };
122 
123 
125 // Widget that serves as rectangle showing current extent in overview
126 class QgsPanningWidget : public QWidget
127 {
128  Q_OBJECT
129 
130  QPolygon mPoly;
131 
132  public:
133  explicit QgsPanningWidget( QWidget *parent );
134 
135  void setPolygon( const QPolygon &p );
136 
137  void paintEvent( QPaintEvent *pe ) override;
138 
139 };
141 
142 #endif
QPoint mPanningCursorOffset
position of cursor inside panning widget
A rectangle specified with double values.
Definition: qgsrectangle.h:38
A widget that displays an overview map.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:72
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...