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 )
177 QgsDebugMsg( QStringLiteral(
"oveview - canceling old" ) );
179 QgsDebugMsg( QStringLiteral(
"oveview - deleting old" ) );
183 QgsDebugMsg( QStringLiteral(
"oveview - starting new" ) );
201 QgsDebugMsg( QStringLiteral(
"overview - finished" ) );
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 );
QPointF toQPointF() const
Converts a point to a QPointF.
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.
bool isEmpty() const
Returns true if the rectangle is empty.
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...
QgsRectangle fullExtent() const
returns current extent of layer set
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
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
void updatePanningWidget(QPoint pos)
called when panning to reflect mouse movement
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
void refresh()
Repaints the canvas map.
const QgsMapToPixel & mapToPixel() const
void setBackgroundColor(const QColor &color)
changes background color
virtual QImage renderedImage()=0
Gets a preview/resulting image.
Map canvas is a class for displaying all GIS data types on a canvas.
Enable drawing of labels on top of the map.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
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)
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
Perform transforms between map coordinates and device coordinates.
void setOutputSize(QSize size)
Sets the size of the resulting map image.
void showEvent(QShowEvent *e) override
Overridden show event.
QgsPanningWidget * mPanningWidget
widget for panning map in overview
bool hasValidSettings() const
Check whether the map settings are valid and can be used for rendering.
QgsMapSettings mSettings
map settings used for rendering of the overview map
void mouseMoveEvent(QMouseEvent *e) override
Overridden mouse move event.
void destinationCrsChanged()
Emitted when map CRS has changed.
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
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.
void mapRenderingFinished()
void setLayers(const QList< QgsMapLayer * > &layers)
updates layer set for overview
QColor backgroundColor() const
Gets the background color of the map.
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.
Job implementation that renders everything sequentially in one thread.
void setBackgroundColor(const QColor &color)
Sets the background color of the map.
void paintEvent(QPaintEvent *pe) override
Overridden paint event.
QPixmap mPixmap
pixmap where the map is stored
QList< QgsMapLayer * > layers() const
Returns list of layers visible in the overview.
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
void resizeEvent(QResizeEvent *e) override
Overridden resize event.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
QPolygonF visiblePolygon() const
Returns the visible area as a polygon (may be rotated)
void destinationCrsChanged()
Should be called when the canvas destination CRS is changed.
void mousePressEvent(QMouseEvent *e) override
Overridden mouse press event.
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
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.
void drawExtentRect()
used for overview canvas to reflect changed extent in main map canvas
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.