18 #ifndef QGSMAPCANVAS_H 19 #define QGSMAPCANVAS_H 21 #include "qgsconfig.h" 30 #include <QDomDocument> 31 #include <QGraphicsView> 37 #include <QGestureEvent> 62 class QgsMapCanvasMap;
80 if ( qobject_cast<QgsMapCanvas *>( sipCpp ) !=
nullptr )
81 sipType = sipType_QgsMapCanvas;
88 Q_PROPERTY( QString theme READ theme WRITE setTheme NOTIFY themeChanged )
89 Q_PROPERTY(
bool previewJobsEnabled READ previewJobsEnabled WRITE setPreviewJobsEnabled )
102 double magnificationFactor() const;
115 void setLayers( const QList<
QgsMapLayer *> &layers );
147 void setCachingEnabled(
bool enabled );
153 bool isCachingEnabled() const;
170 void waitWhileRendering();
176 void setParallelRenderingEnabled(
bool enabled );
182 bool isParallelRenderingEnabled() const;
188 void setMapUpdateInterval(
int timeMilliseconds );
194 int mapUpdateInterval() const;
200 double scale() const;
203 double mapUnitsPerPixel() const;
211 void setExtent( const
QgsRectangle &r,
bool magnified = false );
227 double rotation() const;
233 void setRotation(
double degrees );
248 void zoomToFullExtent();
251 void zoomToPreviousExtent();
254 void zoomToNextExtent();
257 void clearExtentHistory();
290 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
291 int flashes = 3,
int duration = 500 );
306 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
307 int flashes = 3,
int duration = 500 );
310 void setMapTool(
QgsMapTool *mapTool,
bool clean = false );
325 void setCanvasColor( const QColor &_newVal );
327 QColor canvasColor() const;
333 void setSelectionColor( const QColor &color );
339 QColor selectionColor() const;
348 int layerCount() const;
365 void freeze(
bool frozen = true );
374 bool isFrozen() const;
384 bool renderFlag()
const {
return mRenderFlag; }
397 QMap<QString, QString> layerStyleOverrides()
const;
410 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
430 void setTheme(
const QString &theme );
437 QString
theme()
const {
return mTheme; }
449 void setWheelFactor(
double factor );
455 void zoomScale(
double scale );
461 void zoomByFactor(
double scaleFactor,
const QgsPointXY *center =
nullptr );
464 void zoomWithCenter(
int x,
int y,
bool zoomIn );
480 void enableAntiAliasing(
bool flag );
486 void enableMapTileRendering(
bool flag );
491 void panActionEnd( QPoint releasePoint );
500 void panActionStart( QPoint releasePoint );
504 void panAction( QMouseEvent *event );
507 QPoint mouseLastXY();
514 void setPreviewModeEnabled(
bool previewEnabled );
522 bool previewModeEnabled()
const;
605 void setSegmentationTolerance(
double tolerance );
616 QList< QgsMapCanvasAnnotationItem *> annotationItems()
const;
630 void setAnnotationsVisible(
bool visible );
652 bool previewJobsEnabled()
const;
662 void setPreviewJobsEnabled(
bool enabled );
669 void setCustomDropHandlers(
const QVector<QPointer<QgsCustomDropHandler >> &handlers )
SIP_SKIP;
685 void refreshAllLayers();
695 void redrawAllLayers();
698 void selectionChangedSlot();
701 void saveAsImage(
const QString &fileName, QPixmap *QPixmap =
nullptr,
const QString & =
"PNG" );
704 void layerStateChange();
713 void setRenderFlag(
bool flag );
719 void stopRendering();
722 void readProject(
const QDomDocument & );
725 void writeProject( QDomDocument & );
733 void setMagnificationFactor(
double factor );
740 void setScaleLocked(
bool isLocked );
770 void mapToolDestroyed();
773 void rendererJobFinished();
776 void previewJobFinished();
778 void mapUpdateTimeout();
782 void mapThemeChanged(
const QString &theme );
792 void scaleChanged(
double );
795 void extentsChanged();
801 void rotationChanged(
double );
807 void magnificationChanged(
double );
813 void canvasColorChanged();
829 void renderComplete( QPainter * );
833 void mapCanvasRefreshed();
837 void renderStarting();
840 void layersChanged();
843 void keyPressed( QKeyEvent *e );
846 void keyReleased( QKeyEvent *e );
859 void zoomLastStatusChanged(
bool );
862 void zoomNextStatusChanged(
bool );
868 void destinationCrsChanged();
874 void transformContextChanged();
886 void layerStyleOverridesChanged();
893 void themeChanged(
const QString &theme );
905 void renderErrorOccurred(
const QString &error,
QgsMapLayer *layer );
923 void tapAndHoldGestureOccurred(
const QgsPointXY &mapPoint, QTapAndHoldGesture *gesture );
927 bool event( QEvent *e )
override;
928 void keyPressEvent( QKeyEvent *e )
override;
929 void keyReleaseEvent( QKeyEvent *e )
override;
930 void mouseDoubleClickEvent( QMouseEvent *e )
override;
931 void mouseMoveEvent( QMouseEvent *e )
override;
932 void mousePressEvent( QMouseEvent *e )
override;
933 void mouseReleaseEvent( QMouseEvent *e )
override;
934 void wheelEvent( QWheelEvent *e )
override;
935 void resizeEvent( QResizeEvent *e )
override;
936 void paintEvent( QPaintEvent *e )
override;
937 void dragEnterEvent( QDragEnterEvent *e )
override;
940 void moveCanvasContents(
bool reset =
false );
942 void dropEvent( QDropEvent *event )
override;
957 void connectNotify(
const char *signal )
override;
962 void updateCanvasItemPositions();
966 void layerRepaintRequested(
bool deferred );
968 void autoRefreshTriggered();
970 void updateAutoRefreshTimer();
972 void projectThemesChanged();
974 void startPreviewJob(
int number );
982 QgsMapCanvasMap *mMap =
nullptr;
985 bool mFrozen =
false;
988 bool mRefreshScheduled =
false;
991 bool mRenderFlag =
true;
994 QPointer< QgsMapLayer > mCurrentLayer;
997 QGraphicsScene *mScene =
nullptr;
1006 QList <QgsRectangle> mLastExtent;
1007 int mLastExtentIndex = -1;
1010 double mWheelZoomFactor = 2.0;
1013 QTimer mMapUpdateTimer;
1019 bool mJobCanceled =
false;
1025 bool mUseParallelRendering =
false;
1028 bool mDrawRenderingStats =
false;
1033 QTimer *mResizeTimer =
nullptr;
1034 QTimer *mRefreshTimer =
nullptr;
1042 QList< QgsMapRendererQImageJob * > mPreviewJobs;
1045 bool mScaleLocked =
false;
1053 bool mZoomDragging =
false;
1056 std::unique_ptr< QgsRubberBand > mZoomRubberBand;
1058 QCursor mZoomCursor;
1060 QTimer mAutoRefreshTimer;
1062 QTimer mPreviewTimer;
1063 QMetaObject::Connection mPreviewTimerConnection;
1069 bool mAnnotationsVisible =
true;
1071 bool mUsePreviewJobs =
false;
1073 QHash< QString, int > mLastLayerRenderTime;
1075 QVector<QPointer<QgsCustomDropHandler >> mDropHandlers;
1078 QList<double> mZoomResolutions;
1090 void updateMapSize();
1097 void beginZoomRect( QPoint pos );
1104 void endZoomRect( QPoint pos );
1115 void setLayersPrivate(
const QList<QgsMapLayer *> &layers );
1117 void startPreviewJobs();
1118 void stopPreviewJobs();
1119 void schedulePreviewJob(
int number );
1124 bool panOperationInProgress();
1126 int nextZoomLevel(
const QList<double> &resolutions,
bool zoomIn =
true )
const;
1127 double zoomInFactor()
const;
1128 double zoomOutFactor()
const;
1130 friend class TestQgsMapCanvas;
A rectangle specified with double values.
Base class for all map layer types.
std::unique_ptr< CanvasProperties > mCanvasProperties
Handle pattern for implementation object.
QSet< QgsFeatureId > QgsFeatureIds
const QList< double > & zoomResolutions() const
A widget that displays an overview map.
bool annotationsVisible() const
Returns true if annotations are visible within the map canvas.
A class to represent a 2D point.
A geometry is the spatial representation of a feature.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
const QgsCoordinateReferenceSystem & crs
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Map canvas is a class for displaying all GIS data types on a canvas.
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
The QgsMapSettings class contains configuration for rendering of the map.
Deprecated to be deleted, stuff from here should be moved elsewhere.
Perform transforms between map coordinates and device coordinates.
A class for drawing transient features (e.g.
Enable anti-aliasing for map rendering.
A class for highlight features on the map.
#define SIP_KEEPREFERENCE
void setZoomResolutions(const QList< double > &resolutions)
Set a list of resolutions (map units per pixel) to which to "snap to" when zooming the map...
A QgsRectangle with associated coordinate reference system.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setExpressionContextScope(const QgsExpressionContextScope &scope)
Sets an expression context scope for the map canvas.
DistanceUnit
Units of distance.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
QString theme() const
Returns the map's theme shown in the canvas, if set.
QgsExpressionContextScope & expressionContextScope()
Returns a reference to the expression context scope for the map canvas.
bool antiAliasingEnabled() const
true if antialiasing is enabled
bool scaleLocked() const
Returns whether the scale is locked, so zooming can be performed using magnication.
const QgsExpressionContextScope & expressionContextScope() const
Returns a const reference to the expression context scope for the map canvas.
Intermediate base class adding functionality that allows client to query the rendered image...
Stores global configuration for labeling engine.
This class represents a coordinate reference system (CRS).
This class has all the configuration of snapping and can return answers to snapping queries...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Class that stores computed placement from labeling engine.
This class is responsible for keeping cache of rendered images resulting from a map rendering job...
Custom exception class for Coordinate Reference System related exceptions.
Represents a vector layer which manages a vector based data sets.
An interactive map canvas item which displays a QgsAnnotation.