QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
28 #include <QPainterPath>
29 #include <QPaintEvent>
30 #include <QResizeEvent>
31 #include <QMouseEvent>
38 , mMapCanvas( mapCanvas )
41 setAutoFillBackground(
true );
42 setObjectName( QStringLiteral(
"theOverviewCanvas" ) );
65 QWidget::resizeEvent( e );
71 QWidget::showEvent( e );
78 QPainter paint(
this );
79 paint.drawPixmap( pe->rect().topLeft(),
mPixmap, pe->rect() );
99 QVector< QPoint > pts;
135 if ( e->button() == Qt::LeftButton )
153 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( e->angleDelta().y() );
155 if ( e->modifiers() & Qt::ControlModifier )
158 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
161 const double signedWheelFactor = e->angleDelta().y() > 0 ? 1 / zoomFactor : zoomFactor;
164 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
177 if ( ( e->buttons() & Qt::LeftButton ) == Qt::LeftButton )
207 QgsDebugMsg( QStringLiteral(
"oveview - canceling old" ) );
209 QgsDebugMsg( QStringLiteral(
"oveview - deleting old" ) );
213 QgsDebugMsg( QStringLiteral(
"oveview - starting new" ) );
231 QgsDebugMsg( QStringLiteral(
"overview - finished" ) );
254 palette.setColor( backgroundRole(), color );
255 setPalette( palette );
329 QgsPanningWidget::QgsPanningWidget( QWidget *parent )
332 setObjectName( QStringLiteral(
"panningWidget" ) );
333 setMinimumSize( 5, 5 );
334 setAttribute( Qt::WA_NoSystemBackground );
337 void QgsPanningWidget::setPolygon(
const QPolygon &p )
339 if ( p == mPoly )
return;
343 if ( mPoly.at( 0 ) != mPoly.at( mPoly.length() - 1 ) )
344 mPoly.append( mPoly.at( 0 ) );
346 const QRect rect = p.boundingRect() + QMargins( 1, 1, 1, 1 );
351 void QgsPanningWidget::paintEvent( QPaintEvent *pe )
358 const QPolygonF t = mPoly.translated( -mPoly.boundingRect().left() + 1, -mPoly.boundingRect().top() + 1 );
363 path.addPolygon( t );
366 pen.setJoinStyle( Qt::MiterJoin );
367 pen.setColor( Qt::white );
371 pen.setColor( Qt::red );
QgsRectangle projectExtent() const
Returns the associated project's full extent, in the canvas' CRS.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Sets the destination crs (coordinate reference system) for the map render.
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.
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
void refresh()
Repaints the canvas map.
void destinationCrsChanged()
Emitted when map CRS has changed.
void setFlag(Qgis::MapSettingsFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void updatePanningWidget(QPoint pos)
called when panning to reflect mouse movement
void zoomByFactor(double scaleFactor, const QgsPointXY *center=nullptr, bool ignoreScaleLock=false)
Zoom with the factor supplied.
void presetFullExtentChanged()
Emitted whenever the presetFullExtent() is changed.
A QgsRectangle with associated coordinate reference system.
void mouseReleaseEvent(QMouseEvent *e) override
Overridden mouse release event.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
@ DrawLabeling
Enable drawing of labels on top of the map.
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
QgsCoordinateTransformContext transformContext
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsPointXY toMapCoordinates(int x, int y) const
Transforms 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.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
Custom exception class for Coordinate Reference System related exceptions.
void start()
Start the rendering job and immediately return.
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...
QgsReferencedRectangle fullExtent() const
Returns the full extent of the project, which represents the maximal limits of the project.
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
Returns 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.
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
void wheelEvent(QWheelEvent *e) override
Overridden mouse release event.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of layers to render in the map.
QgsMapSettings mSettings
map settings used for rendering of the overview map
A class to represent a 2D point.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
Perform transforms between map coordinates and device coordinates.
Base class for all map layer types. This is the base class for all map layer types (vector,...
void transformContextChanged()
Called when the canvas transform context is changed.
double zoomOutFactor() const
Returns the zoom in factor.
void mousePressEvent(QMouseEvent *e) override
Overridden mouse press event.
void mapRenderingFinished()
void paintEvent(QPaintEvent *pe) override
Overridden paint event.
void setOutputSize(QSize size)
Sets the size of the resulting map image, in pixels.
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 output image size into account.
void setLayers(const QList< QgsMapLayer * > &layers)
updates layer set for overview
void setExtent(const QgsRectangle &rect, bool magnified=true)
Sets the 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
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
QList< QgsMapLayer * > layers(bool expandGroupLayers=false) const
Returns the list of layers which will be rendered in the map.
double zoomInFactor() const
Returns the zoom in factor.
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