QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
27 #include <QPainterPath>
28 #include <QPaintEvent>
29 #include <QResizeEvent>
30 #include <QMouseEvent>
37 , mMapCanvas( mapCanvas )
40 setAutoFillBackground(
true );
41 setObjectName( QStringLiteral(
"theOverviewCanvas" ) );
62 QWidget::resizeEvent( e );
68 QWidget::showEvent( e );
75 QPainter paint(
this );
76 paint.drawPixmap( pe->rect().topLeft(),
mPixmap, pe->rect() );
96 QVector< QPoint > pts;
132 if ( e->button() == Qt::LeftButton )
148 if ( ( e->buttons() & Qt::LeftButton ) == Qt::LeftButton )
178 QgsDebugMsg( QStringLiteral(
"oveview - canceling old" ) );
180 QgsDebugMsg( QStringLiteral(
"oveview - deleting old" ) );
184 QgsDebugMsg( QStringLiteral(
"oveview - starting new" ) );
202 QgsDebugMsg( QStringLiteral(
"overview - finished" ) );
225 palette.setColor( backgroundRole(), color );
226 setPalette( palette );
283 QgsPanningWidget::QgsPanningWidget( QWidget *parent )
286 setObjectName( QStringLiteral(
"panningWidget" ) );
287 setMinimumSize( 5, 5 );
288 setAttribute( Qt::WA_NoSystemBackground );
291 void QgsPanningWidget::setPolygon(
const QPolygon &p )
293 if ( p == mPoly )
return;
297 if ( mPoly.at( 0 ) != mPoly.at( mPoly.length() - 1 ) )
298 mPoly.append( mPoly.at( 0 ) );
300 QRect rect = p.boundingRect() + QMargins( 1, 1, 1, 1 );
305 void QgsPanningWidget::paintEvent( QPaintEvent *pe )
312 QPolygonF t = mPoly.translated( -mPoly.boundingRect().left() + 1, -mPoly.boundingRect().top() + 1 );
317 path.addPolygon( t );
320 pen.setJoinStyle( Qt::MiterJoin );
321 pen.setColor( Qt::white );
325 pen.setColor( Qt::red );
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
void resizeEvent(QResizeEvent *e) override
Overridden resize event.
void transformContextChanged()
Emitted when the canvas transform context is changed.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
void refresh()
Repaints the canvas map.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void destinationCrsChanged()
Emitted when map CRS has changed.
void updatePanningWidget(QPoint pos)
called when panning to reflect mouse movement
void mouseReleaseEvent(QMouseEvent *e) override
Overridden mouse release event.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
virtual QImage renderedImage()=0
Gets a preview/resulting image.
bool hasValidSettings() const
Check whether the map settings are valid and can be used for rendering.
void showEvent(QShowEvent *e) override
Overridden show event.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsRectangle fullExtent() const
returns current extent of layer set
QgsMapRendererQImageJob * mJob
for rendering overview
QgsRectangle fullExtent() const
Returns the combined extent for all layers on the map canvas.
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
QList< QgsMapLayer * > layers() const
Returns list of layers visible in the overview.
void layerRepaintRequested(bool deferred=false)
Triggered when a layer in the overview requests a repaint.
void setBackgroundColor(const QColor &color)
changes background color
A rectangle specified with double values.
void mouseMoveEvent(QMouseEvent *e) override
Overridden mouse move event.
@ DrawLabeling
Enable drawing of labels on top of the map.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
void setBackgroundColor(const QColor &color)
Sets the background color of the map.
QgsPanningWidget * mPanningWidget
widget for panning map in overview
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
QgsMapCanvas * mMapCanvas
main map canvas - used to get/set extent
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
QgsMapOverviewCanvas(QWidget *parent=nullptr, QgsMapCanvas *mapCanvas=nullptr)
void extentsChanged()
Emitted when the extents of the map change.
QPolygonF visiblePolygon() const
Returns the visible area as a polygon (may be rotated)
QColor backgroundColor() const
Gets the background color of the map.
QPixmap mPixmap
pixmap where the map is stored
Job implementation that renders everything sequentially in one thread.
void setCenter(const QgsPointXY ¢er)
Set the center of the map canvas, in geographical coordinates.
virtual void start()=0
Start the rendering job and immediately return.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
QPoint mPanningCursorOffset
position of cursor inside panning widget
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
void setLayers(const QList< QgsMapLayer * > &layers)
Set list of layers for map rendering.
QgsMapSettings mSettings
map settings used for rendering of the overview map
A class to represent a 2D point.
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
Perform transforms between map coordinates and device coordinates.
Base class for all map layer types.
void transformContextChanged()
Called when the canvas transform context is changed.
void mousePressEvent(QMouseEvent *e) override
Overridden mouse press event.
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
void mapRenderingFinished()
void paintEvent(QPaintEvent *pe) override
Overridden paint event.
void setOutputSize(QSize size)
Sets the size of the resulting map image.
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
void setLayers(const QList< QgsMapLayer * > &layers)
updates layer set for overview
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
bool isEmpty() const
Returns true if the rectangle is empty.
void destinationCrsChanged()
Should be called when the canvas destination CRS is changed.
const QgsMapToPixel & mapToPixel() const
void refresh()
renders overview and updates panning widget
void finished()
emitted when asynchronous rendering is finished (or canceled).
void drawExtentRect()
used for overview canvas to reflect changed extent in main map canvas