QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsCoordinateBoundsPreviewMapWidget Class Reference

A widget for showing the bounds of a rectangular region on an interactive map. More...

#include <qgscoordinateboundspreviewmapwidget.h>

Inheritance diagram for QgsCoordinateBoundsPreviewMapWidget:
Inheritance graph
[legend]

Public Member Functions

 QgsCoordinateBoundsPreviewMapWidget (QWidget *parent=nullptr)
 Constructor for QgsCoordinateBoundsPreviewMapWidget.
 
 ~QgsCoordinateBoundsPreviewMapWidget () override
 
QgsRectangle canvasRect () const
 Returns the current canvas bounds rectangle shown in the map.
 
void setCanvasRect (const QgsRectangle &rect)
 Sets the canvas bounds rectangle for the bounds overview map.
 
void setPreviewRect (const QgsRectangle &rect)
 Sets the "preview" rectangle for the bounds overview map.
 
- Public Member Functions inherited from QgsMapCanvas
 QgsMapCanvas (QWidget *parent=nullptr)
 Constructor.
 
 ~QgsMapCanvas () override
 
void addOverlayWidget (QWidget *widget, Qt::Edge edge)
 Adds an overlay widget to the layout, which will be bound to the specified edge.
 
bool allowInteraction (QgsMapCanvasInteractionBlocker::Interaction interaction) const
 Returns true if the specified interaction is currently permitted on the canvas.
 
QList< QgsMapCanvasAnnotationItem * > annotationItems () const
 Returns a list of all annotation items in the canvas.
 
bool annotationsVisible () const
 Returns true if annotations are visible within the map canvas.
 
bool antiAliasingEnabled () const
 true if antialiasing is enabled
 
QgsMapRendererCachecache ()
 Returns the map renderer cache, if caching is enabled.
 
void cancelJobs ()
 Cancel any rendering job, in a blocking way.
 
QColor canvasColor () const
 Read property of QColor bgColor.
 
QgsPointXY center () const
 Gets map center, in geographical coordinates.
 
void clearCache ()
 Make sure to remove any rendered images from cache (does nothing if cache is not enabled)
 
void clearExtentHistory ()
 Clears the list of extents and sets current extent as first item.
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context.
 
QgsMapLayercurrentLayer ()
 returns current layer (set by legend widget)
 
QgsExpressionContextScopedefaultExpressionContextScope () const
 Creates a new scope which contains default variables and functions relating to the map canvas.
 
void enableAntiAliasing (bool flag)
 used to determine if anti-aliasing is enabled or not
 
void enableMapTileRendering (bool flag)
 sets map tile rendering flag
 
QgsExpressionContextScopeexpressionContextScope ()
 Returns a reference to the expression context scope for the map canvas.
 
const QgsExpressionContextScopeexpressionContextScope () const
 Returns a const reference to the expression context scope for the map canvas.
 
QgsRectangle extent () const
 Returns the current zoom extent of the map canvas.
 
Qgis::MapCanvasFlags flags () const
 Returns flags which control how the map canvas behaves.
 
void flashFeatureIds (QgsVectorLayer *layer, const QgsFeatureIds &ids, const QColor &startColor=QColor(255, 0, 0, 255), const QColor &endColor=QColor(255, 0, 0, 0), int flashes=3, int duration=500)
 Causes a set of features with matching ids from a vector layer to flash within the canvas.
 
void flashGeometries (const QList< QgsGeometry > &geometries, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), const QColor &startColor=QColor(255, 0, 0, 255), const QColor &endColor=QColor(255, 0, 0, 0), int flashes=3, int duration=500)
 Causes a set of geometries to flash within the canvas.
 
void freeze (bool frozen=true)
 Freezes/thaws the map canvas.
 
QgsRectangle fullExtent () const
 Returns the combined extent for all layers on the map canvas.
 
const QgsMapToPixelgetCoordinateTransform ()
 Gets the current coordinate transform.
 
void installInteractionBlocker (QgsMapCanvasInteractionBlocker *blocker)
 Installs an interaction blocker onto the canvas, which may prevent certain map canvas interactions from occurring.
 
bool isCachingEnabled () const
 Check whether images of rendered layers are curerently being cached.
 
bool isDrawing ()
 Find out whether rendering is in progress.
 
bool isFrozen () const
 Returns true if canvas is frozen.
 
bool isParallelRenderingEnabled () const
 Check whether the layers are rendered in parallel or sequentially.
 
const QgsLabelingEngineSettingslabelingEngineSettings () const
 Returns global labeling engine settings from the internal map settings.
 
const QgsLabelingResultslabelingResults (bool allowOutdatedResults=true) const
 Gets access to the labeling results (may be nullptr).
 
QgsMapLayerlayer (const QString &id)
 Returns the map layer with the matching ID, or nullptr if no layers could be found.
 
QgsMapLayerlayer (int index)
 Returns the map layer at position index in the layer stack.
 
int layerCount () const
 Returns number of layers on the map.
 
template<typename T >
QVector< T > layers () const
 Returns a list of registered map layers with a specified layer type.
 
QList< QgsMapLayer * > layers (bool expandGroupLayers=false) const
 Returns the list of layers shown within the map canvas.
 
QMap< QString, QString > layerStyleOverrides () const
 Returns the stored overrides of styles for layers.
 
double magnificationFactor () const
 Returns the magnification factor.
 
QgsMapSettingsmapSettings ()
 Returns a reference to the map settings used for map rendering.
 
const QgsMapSettingsmapSettings () const
 Gets access to properties used for map rendering.
 
QgsMapToolmapTool () const
 Returns the currently active tool.
 
Qgis::DistanceUnit mapUnits () const
 Convenience function for returning the current canvas map units.
 
double mapUnitsPerPixel () const
 Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
 
int mapUpdateInterval () const
 Find out how often map preview should be updated while it is being rendered (in milliseconds)
 
QPoint mouseLastXY ()
 returns last position of mouse cursor
 
void panAction (QMouseEvent *event)
 Called when mouse is moving and pan is activated.
 
void panActionEnd (QPoint releasePoint)
 Ends pan action and redraws the canvas.
 
void panActionStart (QPoint releasePoint)
 Starts a pan action.
 
void panToFeatureIds (QgsVectorLayer *layer, const QgsFeatureIds &ids, bool alwaysRecenter=true)
 Centers canvas extent to feature ids.
 
void panToSelected (const QList< QgsMapLayer * > &layers)
 Pan to the combined extent of the selected features of all provided (vector) layers.
 
void panToSelected (QgsMapLayer *layer=nullptr)
 Pan to the selected features of current ayer keeping same extent.
 
bool previewJobsEnabled () const
 Returns true if canvas map preview jobs (low priority render jobs which render portions of the view just outside of the canvas extent, to allow preview of these out-of-canvas areas when panning or zooming out the map) are enabled for the canvas.
 
QgsPreviewEffect::PreviewMode previewMode () const
 Returns the current preview mode for the map canvas.
 
bool previewModeEnabled () const
 Returns whether a preview mode is enabled for the map canvas.
 
QgsProjectproject ()
 Returns the project linked to this canvas.
 
QgsRectangle projectExtent () const
 Returns the associated project's full extent, in the canvas' CRS.
 
void removeInteractionBlocker (QgsMapCanvasInteractionBlocker *blocker)
 Removes an interaction blocker from the canvas.
 
const QgsRenderedItemResultsrenderedItemResults (bool allowOutdatedResults=true) const
 Gets access to the rendered item results (may be nullptr), which includes the results of rendering annotation items in the canvas map.
 
bool renderFlag () const
 Returns true if canvas render is disabled as a result of user disabling renders via the GUI.
 
double rotation () const
 Gets the current map canvas rotation in clockwise degrees.
 
double scale () const
 Returns the last reported scale of the canvas.
 
bool scaleLocked () const
 Returns whether the scale is locked, so zooming can be performed using magnication.
 
QColor selectionColor () const
 Returns color for selected features.
 
void setAnnotationsVisible (bool visible)
 Sets whether annotations are visible in the canvas.
 
void setCachingEnabled (bool enabled)
 Set whether to cache images of rendered layers.
 
void setCanvasColor (const QColor &_newVal)
 Write property of QColor bgColor.
 
void setCenter (const QgsPointXY &center)
 Set the center of the map canvas, in geographical coordinates.
 
void setCurrentLayer (QgsMapLayer *layer)
 
void setCustomDropHandlers (const QVector< QPointer< QgsCustomDropHandler > > &handlers)
 Sets a list of custom drop handlers to use when drop events occur on the canvas.
 
void setDestinationCrs (const QgsCoordinateReferenceSystem &crs)
 Sets destination coordinate reference system.
 
void setExpressionContextScope (const QgsExpressionContextScope &scope)
 Sets an expression context scope for the map canvas.
 
void setExtent (const QgsRectangle &r, bool magnified=false)
 Sets the extent of the map canvas to the specified rectangle.
 
void setFlags (Qgis::MapCanvasFlags flags)
 Sets flags which control how the map canvas behaves.
 
void setLabelingEngineSettings (const QgsLabelingEngineSettings &settings)
 Sets global labeling engine settings in the internal map settings.
 
void setLayers (const QList< QgsMapLayer * > &layers)
 Sets the list of layers that should be shown in the canvas.
 
void setLayerStyleOverrides (const QMap< QString, QString > &overrides)
 Sets the stored overrides of styles for rendering layers.
 
void setMapController (QgsAbstract2DMapController *controller)
 Sets the input controller device to use for controlling the canvas.
 
void setMapSettingsFlags (Qgis::MapSettingsFlags flags)
 Resets the flags for the canvas' map settings.
 
void setMapTool (QgsMapTool *mapTool, bool clean=false)
 Sets the map tool currently being used on the canvas.
 
void setMapUpdateInterval (int timeMilliseconds)
 Set how often map preview should be updated while it is being rendered (in milliseconds)
 
void setParallelRenderingEnabled (bool enabled)
 Set whether the layers are rendered in parallel or sequentially.
 
void setPreviewJobsEnabled (bool enabled)
 Sets whether canvas map preview jobs (low priority render jobs which render portions of the view just outside of the canvas extent, to allow preview of these out-of-canvas areas when panning or zooming out the map) are enabled for the canvas.
 
void setPreviewMode (QgsPreviewEffect::PreviewMode mode)
 Sets a preview mode for the map canvas.
 
void setPreviewModeEnabled (bool previewEnabled)
 Enables a preview mode for the map canvas.
 
void setProject (QgsProject *project)
 Sets the project linked to this canvas.
 
bool setReferencedExtent (const QgsReferencedRectangle &extent)
 Sets the canvas to the specified extent.
 
void setRotation (double degrees)
 Set the rotation of the map canvas in clockwise degrees.
 
void setSegmentationTolerance (double tolerance)
 Sets the segmentation tolerance applied when rendering curved geometries.
 
void setSegmentationToleranceType (QgsAbstractGeometry::SegmentationToleranceType type)
 Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)
 
void setSelectionColor (const QColor &color)
 Set color of selected vector features.
 
void setSnappingUtils (QgsSnappingUtils *utils)
 Assign an instance of snapping utils to the map canvas.
 
void setTemporalController (QgsTemporalController *controller)
 Sets the temporal controller for this canvas.
 
void setTemporalRange (const QgsDateTimeRange &range)
 Set datetime range for the map canvas.
 
void setTheme (const QString &theme)
 Sets a map theme to show in the canvas.
 
void setWheelFactor (double factor)
 Sets wheel zoom factor (should be greater than 1)
 
QgsSnappingUtilssnappingUtils () const
 Returns snapping utility class that is associated with map canvas.
 
const QgsTemporalControllertemporalController () const
 Gets access to the temporal controller that will be used to update the canvas temporal range.
 
const QgsDateTimeRangetemporalRange () const
 Returns map canvas datetime range.
 
QString theme () const
 Returns the map's theme shown in the canvas, if set.
 
void unsetMapTool (QgsMapTool *mapTool)
 Unset the current map tool or last non zoom tool.
 
void updateScale ()
 Emits signal scaleChanged to update scale in main window.
 
void waitWhileRendering ()
 Blocks until the rendering job has finished.
 
void zoomByFactor (double scaleFactor, const QgsPointXY *center=nullptr, bool ignoreScaleLock=false)
 Zoom with the factor supplied.
 
void zoomScale (double scale, bool ignoreScaleLock=false)
 Zooms the canvas to a specific scale.
 
void zoomToFeatureExtent (QgsRectangle &rect)
 Zooms to feature extent.
 
void zoomToFeatureIds (QgsVectorLayer *layer, const QgsFeatureIds &ids)
 Set canvas extent to the bounding box of a set of features.
 
void zoomToFullExtent ()
 Zoom to the full extent of all layers currently visible in the canvas.
 
void zoomToNextExtent ()
 Zoom to the next extent (view)
 
void zoomToPreviousExtent ()
 Zoom to the previous extent (view)
 
void zoomToProjectExtent ()
 Zoom to the full extent the project associated with this canvas.
 
void zoomWithCenter (int x, int y, bool zoomIn)
 Zooms in/out with a given center.
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Additional Inherited Members

- Public Slots inherited from QgsMapCanvas
void layerStateChange ()
 This slot is connected to the visibility change of one or more layers.
 
void readProject (const QDomDocument &)
 called to read map canvas settings from project
 
void redrawAllLayers ()
 Clears all cached images and redraws all layers.
 
void refresh ()
 Repaints the canvas map.
 
void refreshAllLayers ()
 Reload all layers (including refreshing layer properties from their data sources), clears the cache and refreshes the canvas.
 
void saveAsImage (const QString &fileName, QPixmap *QPixmap=nullptr, const QString &="PNG")
 Save the contents of the map canvas to disk as an image.
 
void selectionChangedSlot ()
 Receives signal about selection change, and pass it on with layer info.
 
void setMagnificationFactor (double factor, const QgsPointXY *center=nullptr)
 Sets the factor of magnification to apply to the map canvas.
 
void setRenderFlag (bool flag)
 Sets whether a user has disabled canvas renders via the GUI.
 
void setScaleLocked (bool isLocked)
 Lock the scale, so zooming can be performed using magnication.
 
void setZoomResolutions (const QList< double > &resolutions)
 Set a list of resolutions (map units per pixel) to which to "snap to" when zooming the map.
 
void setZRange (const QgsDoubleRange &range)
 Sets the range of z-values which will be visible in the map.
 
void stopRendering ()
 stop rendering (if there is any right now)
 
void writeProject (QDomDocument &)
 called to write map canvas settings to project
 
void zoomIn ()
 Zoom in with fixed factor.
 
double zoomInFactor () const
 Returns the zoom in factor.
 
void zoomOut ()
 Zoom out with fixed factor.
 
double zoomOutFactor () const
 Returns the zoom in factor.
 
const QList< double > & zoomResolutions () const
 
void zoomToSelected (const QList< QgsMapLayer * > &layers)
 Zoom to the combined extent of the selected features of all provided (vector) layers.
 
void zoomToSelected (QgsMapLayer *layer=nullptr)
 Zoom to the extent of the selected features of provided map layer.
 
QgsDoubleRange zRange () const
 Returns the range of z-values which will be visible in the map.
 
- Signals inherited from QgsMapCanvas
void canvasColorChanged ()
 Emitted when canvas background color changes.
 
void contextMenuAboutToShow (QMenu *menu, QgsMapMouseEvent *event)
 Emitted before the map canvas context menu will be shown.
 
void currentLayerChanged (QgsMapLayer *layer)
 Emitted when the current layer is changed.
 
void destinationCrsChanged ()
 Emitted when map CRS has changed.
 
void extentsChanged ()
 Emitted when the extents of the map change.
 
void keyPressed (QKeyEvent *e)
 Emit key press event.
 
void keyReleased (QKeyEvent *e)
 Emit key release event.
 
void layersChanged ()
 Emitted when a new set of layers has been received.
 
void layerStyleOverridesChanged ()
 Emitted when the configuration of overridden layer styles changes.
 
void magnificationChanged (double magnification)
 Emitted when the scale of the map changes.
 
void mapCanvasRefreshed ()
 Emitted when canvas finished a refresh request.
 
void mapRefreshCanceled ()
 Emitted when the pending map refresh has been canceled.
 
void mapToolSet (QgsMapTool *newTool, QgsMapTool *oldTool)
 Emit map tool changed with the old tool.
 
void messageEmitted (const QString &title, const QString &message, Qgis::MessageLevel level=Qgis::MessageLevel::Info)
 emit a message (usually to be displayed in a message bar)
 
void panDistanceBearingChanged (double distance, Qgis::DistanceUnit unit, double bearing)
 Emitted whenever the distance or bearing of an in-progress panning operation is changed.
 
void renderComplete (QPainter *painter)
 Emitted when the canvas has rendered.
 
void renderErrorOccurred (const QString &error, QgsMapLayer *layer)
 Emitted whenever an error is encountered during a map render operation.
 
void renderStarting ()
 Emitted when the canvas is about to be rendered.
 
void rotationChanged (double rotation)
 Emitted when the rotation of the map changes.
 
void scaleChanged (double scale)
 Emitted when the scale of the map changes.
 
void scaleLockChanged (bool locked)
 Emitted when the scale locked state of the map changes.
 
void selectionChanged (QgsMapLayer *layer)
 Emitted when selection in any layer gets changed.
 
void tapAndHoldGestureOccurred (const QgsPointXY &mapPoint, QTapAndHoldGesture *gesture)
 Emitted whenever a tap and hold gesture occurs at the specified map point.
 
void temporalRangeChanged ()
 Emitted when the map canvas temporal range changes.
 
void themeChanged (const QString &theme)
 Emitted when the canvas has been assigned a different map theme.
 
void transformContextChanged ()
 Emitted when the canvas transform context is changed.
 
void xyCoordinates (const QgsPointXY &p)
 Emits current mouse position.
 
void zoomLastStatusChanged (bool available)
 Emitted when zoom last status changed.
 
void zoomNextStatusChanged (bool available)
 Emitted when zoom next status changed.
 
void zRangeChanged ()
 Emitted when the map canvas z (elevation) range changes.
 
- Protected Slots inherited from QgsMapCanvas
void updateCanvasItemPositions ()
 called on resize or changed extent to notify canvas items to change their rectangle
 
- Protected Member Functions inherited from QgsMapCanvas
void dragEnterEvent (QDragEnterEvent *e) override
 
void dropEvent (QDropEvent *event) override
 
void emitExtentsChanged ()
 Emits the extentsChanged signal when appropriate.
 
bool event (QEvent *e) override
 
void keyPressEvent (QKeyEvent *e) override
 
void keyReleaseEvent (QKeyEvent *e) override
 
void mouseDoubleClickEvent (QMouseEvent *e) override
 
void mouseMoveEvent (QMouseEvent *e) override
 
void mousePressEvent (QMouseEvent *e) override
 
void mouseReleaseEvent (QMouseEvent *e) override
 
void moveCanvasContents (bool reset=false)
 called when panning is in action, reset indicates end of panning
 
void paintEvent (QPaintEvent *e) override
 
void resizeEvent (QResizeEvent *e) override
 
void showEvent (QShowEvent *event) override
 
bool viewportEvent (QEvent *event) override
 
void wheelEvent (QWheelEvent *e) override
 
- Protected Attributes inherited from QgsMapCanvas
std::unique_ptr< CanvasPropertiesmCanvasProperties
 Handle pattern for implementation object.
 
- Properties inherited from QgsMapCanvas
bool previewJobsEnabled
 
QString theme
 

Detailed Description

A widget for showing the bounds of a rectangular region on an interactive map.

Since
QGIS 3.8.1

Definition at line 28 of file qgscoordinateboundspreviewmapwidget.h.

Constructor & Destructor Documentation

◆ QgsCoordinateBoundsPreviewMapWidget()

QgsCoordinateBoundsPreviewMapWidget::QgsCoordinateBoundsPreviewMapWidget ( QWidget *  parent = nullptr)

◆ ~QgsCoordinateBoundsPreviewMapWidget()

QgsCoordinateBoundsPreviewMapWidget::~QgsCoordinateBoundsPreviewMapWidget ( )
override

Definition at line 48 of file qgscoordinateboundspreviewmapwidget.cpp.

Member Function Documentation

◆ canvasRect()

QgsRectangle QgsCoordinateBoundsPreviewMapWidget::canvasRect ( ) const

Returns the current canvas bounds rectangle shown in the map.

See also
setCanvasRect()

Definition at line 91 of file qgscoordinateboundspreviewmapwidget.cpp.

◆ setCanvasRect()

void QgsCoordinateBoundsPreviewMapWidget::setCanvasRect ( const QgsRectangle rect)

Sets the canvas bounds rectangle for the bounds overview map.

Must be in EPSG:4326 coordinate reference system.

See also
canvasRect()

Definition at line 96 of file qgscoordinateboundspreviewmapwidget.cpp.

◆ setPreviewRect()

void QgsCoordinateBoundsPreviewMapWidget::setPreviewRect ( const QgsRectangle rect)

Sets the "preview" rectangle for the bounds overview map.

Must be in EPSG:4326 coordinate reference system.

Definition at line 60 of file qgscoordinateboundspreviewmapwidget.cpp.


The documentation for this class was generated from the following files: