34#include <QDomDocument>
35#include <QGraphicsView>
41#include <QGestureEvent>
96 if ( qobject_cast<QgsMapCanvas *>( sipCpp ) !=
nullptr )
97 sipType = sipType_QgsMapCanvas;
104 Q_PROPERTY( QString theme READ theme WRITE setTheme NOTIFY themeChanged )
105 Q_PROPERTY(
bool previewJobsEnabled READ previewJobsEnabled WRITE setPreviewJobsEnabled )
118 double magnificationFactor() const;
131 void setLayers( const QList<
QgsMapLayer *> &layers );
175 void setMapSettingsFlags(
Qgis::MapSettingsFlags flags );
206 void setCachingEnabled(
bool enabled );
216 bool isCachingEnabled() const;
249 void waitWhileRendering();
255 void setParallelRenderingEnabled(
bool enabled );
261 bool isParallelRenderingEnabled() const;
267 void setMapUpdateInterval(
int timeMilliseconds );
273 int mapUpdateInterval() const;
279 double scale() const;
282 double mapUnitsPerPixel() const;
319 void setExtent( const
QgsRectangle &r,
bool magnified = false );
335 double rotation() const;
341 void setRotation(
double degrees );
360 void zoomToFullExtent();
370 void zoomToProjectExtent();
373 void zoomToPreviousExtent();
376 void zoomToNextExtent();
379 void clearExtentHistory();
398 void panToSelected(
QgsMapLayer *layer =
nullptr );
405 void panToSelected( const QList<
QgsMapLayer *> &layers );
420 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
421 int flashes = 3,
int duration = 500 );
436 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
437 int flashes = 3,
int duration = 500 );
440 void setMapTool(
QgsMapTool *mapTool,
bool clean = false );
470 void setCanvasColor( const QColor &_newVal );
472 QColor canvasColor() const;
478 void setSelectionColor( const QColor &color );
484 QColor selectionColor() const;
507 int layerCount() const;
517 QList<
QgsMapLayer *> layers(
bool expandGroupLayers = false ) const;
528 void freeze(
bool frozen = true );
537 bool isFrozen() const;
547 bool renderFlag()
const {
return mRenderFlag; }
560 QMap<QString, QString> layerStyleOverrides()
const;
573 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
593 void setTheme(
const QString &theme );
600 QString
theme()
const {
return mTheme; }
612 void setWheelFactor(
double factor );
621 void zoomScale(
double scale,
bool ignoreScaleLock =
false );
630 void zoomByFactor(
double scaleFactor,
const QgsPointXY *center =
nullptr,
bool ignoreScaleLock =
false );
633 void zoomWithCenter(
int x,
int y,
bool zoomIn );
649 void enableAntiAliasing(
bool flag );
652 bool antiAliasingEnabled()
const;
655 void enableMapTileRendering(
bool flag );
660 void panActionEnd( QPoint releasePoint );
669 void panActionStart( QPoint releasePoint );
673 void panAction( QMouseEvent *event );
676 QPoint mouseLastXY();
684 void setPreviewModeEnabled(
bool previewEnabled );
693 bool previewModeEnabled()
const;
781 void setSegmentationTolerance(
double tolerance );
800 bool annotationsVisible()
const {
return mAnnotationsVisible; }
807 void setAnnotationsVisible(
bool visible );
829 bool previewJobsEnabled()
const;
839 void setPreviewJobsEnabled(
bool enabled );
846 void setCustomDropHandlers(
const QVector<QPointer<QgsCustomDropHandler >> &handlers )
SIP_SKIP;
920 void refreshAllLayers();
930 void redrawAllLayers();
933 void selectionChangedSlot();
936 void saveAsImage(
const QString &fileName, QPixmap *QPixmap =
nullptr,
const QString & =
"PNG" );
939 void layerStateChange();
948 void setRenderFlag(
bool flag );
954 void stopRendering();
957 void readProject(
const QDomDocument & );
960 void writeProject( QDomDocument & );
970 void setMagnificationFactor(
double factor,
const QgsPointXY *center =
nullptr );
977 void setScaleLocked(
bool isLocked );
989 void zoomToSelected(
QgsMapLayer *layer =
nullptr );
996 void zoomToSelected(
const QList<QgsMapLayer *> &layers );
1008 double zoomInFactor()
const;
1013 double zoomOutFactor()
const;
1044 void mapToolDestroyed();
1047 void rendererJobFinished();
1050 void previewJobFinished();
1052 void mapUpdateTimeout();
1056 void mapThemeChanged(
const QString &theme );
1058 void mapThemeRenamed(
const QString &theme,
const QString &newTheme );
1060 void updateDevicePixelFromScreen();
1062 void onElevationShadingRendererChanged();
1249 bool event( QEvent *e )
override;
1250 void keyPressEvent( QKeyEvent *e )
override;
1251 void keyReleaseEvent( QKeyEvent *e )
override;
1252 void mouseDoubleClickEvent( QMouseEvent *e )
override;
1253 void mouseMoveEvent( QMouseEvent *e )
override;
1254 void mousePressEvent( QMouseEvent *e )
override;
1255 void mouseReleaseEvent( QMouseEvent *e )
override;
1256 void wheelEvent( QWheelEvent *e )
override;
1257 void resizeEvent( QResizeEvent *e )
override;
1258 void paintEvent( QPaintEvent *e )
override;
1259 void dragEnterEvent( QDragEnterEvent *e )
override;
1260 bool viewportEvent( QEvent *event )
override;
1263 void moveCanvasContents(
bool reset =
false );
1265 void dropEvent( QDropEvent *event )
override;
1267 void showEvent( QShowEvent *event )
override;
1274 void emitExtentsChanged();
1288 void connectNotify(
const char *signal )
override;
1293 void updateCanvasItemPositions();
1297 void layerRepaintRequested(
bool deferred );
1299 void autoRefreshTriggered();
1301 void updateAutoRefreshTimer();
1303 void projectThemesChanged();
1305 void startPreviewJob(
int number );
1307 void temporalControllerModeChanged();
1318 mLockedScale = mCanvas->mapSettings().scale();
1323 QgsRectangle newExtent = mCanvas->mapSettings().extent();
1324 newExtent.
scale( mLockedScale / mCanvas->mapSettings().scale() );
1325 mCanvas->mSettings.setExtent( newExtent );
1330 double mLockedScale;
1337 QgsMapCanvasMap *mMap =
nullptr;
1348 bool mFrozen =
false;
1351 bool mRefreshScheduled =
false;
1354 bool mRefreshAfterJob =
false;
1357 bool mRenderFlag =
true;
1360 QPointer< QgsMapLayer > mCurrentLayer;
1363 QGraphicsScene *mScene =
nullptr;
1375 QList <QgsRectangle> mLastExtent;
1376 int mLastExtentIndex = -1;
1379 double mWheelZoomFactor = 2.0;
1382 QTimer mMapUpdateTimer;
1388 bool mJobCanceled =
false;
1391 std::unique_ptr< QgsLabelingResults > mLabelingResults;
1394 bool mLabelingResultsOutdated =
false;
1400 std::unique_ptr< QgsRenderedItemResults > mRenderedItemResults;
1406 std::unique_ptr< QgsRenderedItemResults > mPreviousRenderedItemResults;
1413 bool mRenderedItemResultsOutdated =
false;
1416 bool mUseParallelRendering =
false;
1419 bool mDrawRenderingStats =
false;
1424 QTimer *mResizeTimer =
nullptr;
1425 QTimer *mRefreshTimer =
nullptr;
1433 QList< QgsMapRendererQImageJob * > mPreviewJobs;
1436 bool mScaleLocked =
false;
1444 bool mZoomDragging =
false;
1447 std::unique_ptr< QgsRubberBand > mZoomRubberBand;
1449 QCursor mZoomCursor;
1451 QTimer mAutoRefreshTimer;
1453 QTimer mPreviewTimer;
1454 QMetaObject::Connection mPreviewTimerConnection;
1460 bool mAnnotationsVisible =
true;
1462 bool mUsePreviewJobs =
false;
1464 QHash< QString, int > mLastLayerRenderTime;
1466 QVector<QPointer<QgsCustomDropHandler >> mDropHandlers;
1469 QList<double> mZoomResolutions;
1471 QList< QgsMapCanvasInteractionBlocker * > mInteractionBlockers;
1473 int mBlockItemPositionUpdates = 0;
1474 int mBlockExtentChangedSignal = 0;
1475 int mBlockScaleChangedSignal = 0;
1477 std::unique_ptr< QgsTemporaryCursorOverride > mTemporaryCursorOverride;
1486 QMap <QString, QDateTime> mRendererErrors;
1489 QPointer< QgsAbstract2DMapController > mMapController;
1501 void updateMapSize();
1508 void beginZoomRect( QPoint pos );
1515 void endZoomRect( QPoint pos );
1518 void stopZoomRect();
1544 void setLayersPrivate(
const QList<QgsMapLayer *> &layers );
1546 void startPreviewJobs();
1547 void stopPreviewJobs();
1548 void schedulePreviewJob(
int number );
1553 bool panOperationInProgress();
1555 int nextZoomLevel(
const QList<double> &resolutions,
bool zoomIn =
true )
const;
1561 void clearTemporalCache();
1566 void clearElevationCache();
1576 friend class TestQgsMapCanvas;
The Qgis class provides global constants for use throughout the application.
DistanceUnit
Units of distance.
MessageLevel
Level for messages This will be used both for message log and message bar in application.
@ Info
Information message.
Abstract base class for all 2D map controllers.
Abstract base class for all geometries.
This class represents a coordinate reference system (CRS).
Custom exception class for Coordinate Reference System related exceptions.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
QgsRange which stores a range of double values.
Abstract interface for generating an expression context.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A geometry is the spatial representation of a feature.
A class for highlight features on the map.
Stores global configuration for labeling engine.
Class that stores computed placement from labeling engine.
An interactive map canvas item which displays a QgsAnnotation.
An interface for objects which block interactions with a QgsMapCanvas.
Interaction
Available interactions to block.
Deprecated to be deleted, stuff from here should be moved elsewhere.
Map canvas is a class for displaying all GIS data types on a canvas.
void messageEmitted(const QString &title, const QString &message, Qgis::MessageLevel=Qgis::MessageLevel::Info)
emit a message (usually to be displayed in a message bar)
void contextMenuAboutToShow(QMenu *menu, QgsMapMouseEvent *event)
Emitted before the map canvas context menu will be shown.
void selectionChanged(QgsMapLayer *layer)
Emitted when selection in any layer gets changed.
void extentsChanged()
Emitted when the extents of the map change.
void xyCoordinates(const QgsPointXY &p)
Emits current mouse position.
QgsExpressionContextScope & expressionContextScope()
Returns a reference to the expression context scope for the map canvas.
void magnificationChanged(double)
Emitted when the scale of the map changes.
void setZoomResolutions(const QList< double > &resolutions)
Set a list of resolutions (map units per pixel) to which to "snap to" when zooming the map.
QString theme() const
Returns the map's theme shown in the canvas, if set.
void renderComplete(QPainter *)
Emitted when the canvas has rendered.
void tapAndHoldGestureOccurred(const QgsPointXY &mapPoint, QTapAndHoldGesture *gesture)
Emitted whenever a tap and hold gesture occurs at the specified map point.
void zoomNextStatusChanged(bool)
Emitted when zoom next status changed.
const QList< double > & zoomResolutions() const
void panDistanceBearingChanged(double distance, Qgis::DistanceUnit unit, double bearing)
Emitted whenever the distance or bearing of an in-progress panning operation is changed.
void rotationChanged(double)
Emitted when the rotation of the map changes.
bool scaleLocked() const
Returns whether the scale is locked, so zooming can be performed using magnication.
void zRangeChanged()
Emitted when the map canvas z (elevation) range changes.
void mapToolSet(QgsMapTool *newTool, QgsMapTool *oldTool)
Emit map tool changed with the old tool.
void canvasColorChanged()
Emitted when canvas background color changes.
void currentLayerChanged(QgsMapLayer *layer)
Emitted when the current layer is changed.
void renderErrorOccurred(const QString &error, QgsMapLayer *layer)
Emitted whenever an error is encountered during a map render operation.
void mapRefreshCanceled()
Emitted when the pending map refresh has been canceled.
void renderStarting()
Emitted when the canvas is about to be rendered.
std::unique_ptr< CanvasProperties > mCanvasProperties
Handle pattern for implementation object.
void keyReleased(QKeyEvent *e)
Emit key release event.
const QgsExpressionContextScope & expressionContextScope() const
Returns a const reference to the expression context scope for the map canvas.
void layerStyleOverridesChanged()
Emitted when the configuration of overridden layer styles changes.
void scaleChanged(double)
Emitted when the scale of the map changes.
void scaleLockChanged(bool locked)
Emitted when the scale locked state of the map changes.
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 destinationCrsChanged()
Emitted when map CRS has changed.
void transformContextChanged()
Emitted when the canvas transform context is changed.
void keyPressed(QKeyEvent *e)
Emit key press event.
void mapCanvasRefreshed()
Emitted when canvas finished a refresh request.
void zoomLastStatusChanged(bool)
Emitted when zoom last status changed.
void layersChanged()
Emitted when a new set of layers has been received.
void setExpressionContextScope(const QgsExpressionContextScope &scope)
Sets an expression context scope for the map canvas.
Base class for all map layer types.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
A widget that displays an overview map.
This class is responsible for keeping cache of rendered images resulting from a map rendering job.
QList< QgsMapRendererJob::Error > Errors
Intermediate base class adding functionality that allows client to query the rendered image.
The QgsMapSettings class contains configuration for rendering of the map.
Perform transforms between map coordinates and device coordinates.
A class to represent a 2D point.
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A rectangle specified with double values.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
A QgsRectangle with associated coordinate reference system.
Stores collated details of rendered items during a map rendering operation.
A class for drawing transient features (e.g.
A utility class for dynamic handling of changes to screen properties.
This class has all the configuration of snapping and can return answers to snapping queries.
A controller base class for temporal objects, contains a signal for notifying updates of the objects ...
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Represents a vector layer which manages a vector based data sets.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_KEEPREFERENCE
#define SIP_THROW(name,...)
QSet< QgsFeatureId > QgsFeatureIds
const QgsCoordinateReferenceSystem & crs