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