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 );
494 void panAction( QMouseEvent *event );
497 QPoint mouseLastXY();
504 void setPreviewModeEnabled(
bool previewEnabled );
512 bool previewModeEnabled()
const;
595 void setSegmentationTolerance(
double tolerance );
606 QList< QgsMapCanvasAnnotationItem *> annotationItems()
const;
620 void setAnnotationsVisible(
bool visible );
642 bool previewJobsEnabled()
const;
652 void setPreviewJobsEnabled(
bool enabled );
659 void setCustomDropHandlers(
const QVector<QPointer<QgsCustomDropHandler >> &handlers )
SIP_SKIP;
675 void refreshAllLayers();
685 void redrawAllLayers();
688 void selectionChangedSlot();
691 void saveAsImage(
const QString &fileName, QPixmap *QPixmap =
nullptr,
const QString & =
"PNG" );
694 void layerStateChange();
703 void setRenderFlag(
bool flag );
709 void stopRendering();
712 void readProject(
const QDomDocument & );
715 void writeProject( QDomDocument & );
723 void setMagnificationFactor(
double factor );
730 void setScaleLocked(
bool isLocked );
746 void mapToolDestroyed();
749 void rendererJobFinished();
752 void previewJobFinished();
754 void mapUpdateTimeout();
758 void mapThemeChanged(
const QString &theme );
768 void scaleChanged(
double );
771 void extentsChanged();
777 void rotationChanged(
double );
783 void magnificationChanged(
double );
789 void canvasColorChanged();
805 void renderComplete( QPainter * );
809 void mapCanvasRefreshed();
813 void renderStarting();
816 void layersChanged();
819 void keyPressed( QKeyEvent *e );
822 void keyReleased( QKeyEvent *e );
835 void zoomLastStatusChanged(
bool );
838 void zoomNextStatusChanged(
bool );
844 void destinationCrsChanged();
850 void transformContextChanged();
862 void layerStyleOverridesChanged();
869 void themeChanged(
const QString &theme );
881 void renderErrorOccurred(
const QString &error,
QgsMapLayer *layer );
885 bool event( QEvent *e )
override;
886 void keyPressEvent( QKeyEvent *e )
override;
887 void keyReleaseEvent( QKeyEvent *e )
override;
888 void mouseDoubleClickEvent( QMouseEvent *e )
override;
889 void mouseMoveEvent( QMouseEvent *e )
override;
890 void mousePressEvent( QMouseEvent *e )
override;
891 void mouseReleaseEvent( QMouseEvent *e )
override;
892 void wheelEvent( QWheelEvent *e )
override;
893 void resizeEvent( QResizeEvent *e )
override;
894 void paintEvent( QPaintEvent *e )
override;
895 void dragEnterEvent( QDragEnterEvent *e )
override;
898 void moveCanvasContents(
bool reset =
false );
900 void dropEvent( QDropEvent *event )
override;
915 void connectNotify(
const char *signal )
override;
920 void updateCanvasItemPositions();
924 void layerRepaintRequested(
bool deferred );
926 void autoRefreshTriggered();
928 void updateAutoRefreshTimer();
930 void projectThemesChanged();
932 void startPreviewJob(
int number );
940 QgsMapCanvasMap *mMap =
nullptr;
943 bool mFrozen =
false;
946 bool mRefreshScheduled =
false;
949 bool mRenderFlag =
true;
952 QPointer< QgsMapLayer > mCurrentLayer;
955 QGraphicsScene *mScene =
nullptr;
964 QList <QgsRectangle> mLastExtent;
965 int mLastExtentIndex = -1;
968 double mWheelZoomFactor = 2.0;
971 QTimer mMapUpdateTimer;
977 bool mJobCanceled =
false;
983 bool mUseParallelRendering =
false;
986 bool mDrawRenderingStats =
false;
991 QTimer *mResizeTimer =
nullptr;
992 QTimer *mRefreshTimer =
nullptr;
1000 QList< QgsMapRendererQImageJob * > mPreviewJobs;
1003 bool mScaleLocked =
false;
1011 bool mZoomDragging =
false;
1014 std::unique_ptr< QgsRubberBand > mZoomRubberBand;
1016 QCursor mZoomCursor;
1018 QTimer mAutoRefreshTimer;
1020 QTimer mPreviewTimer;
1021 QMetaObject::Connection mPreviewTimerConnection;
1027 bool mAnnotationsVisible =
true;
1029 bool mUsePreviewJobs =
false;
1031 QHash< QString, int > mLastLayerRenderTime;
1033 QVector<QPointer<QgsCustomDropHandler >> mDropHandlers;
1045 void updateMapSize();
1052 void beginZoomRect( QPoint pos );
1059 void endZoomRect( QPoint pos );
1070 void setLayersPrivate(
const QList<QgsMapLayer *> &layers );
1072 void startPreviewJobs();
1073 void stopPreviewJobs();
1074 void schedulePreviewJob(
int number );
1076 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
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
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.
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 antialising 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.