18 #ifndef QGSMAPCANVAS_H 19 #define QGSMAPCANVAS_H 21 #include "qgsconfig.h" 29 #include <QDomDocument> 30 #include <QGraphicsView> 36 #include <QGestureEvent> 61 class QgsMapCanvasMap;
78 if ( qobject_cast<QgsMapCanvas *>( sipCpp ) !=
nullptr )
79 sipType = sipType_QgsMapCanvas;
86 Q_PROPERTY( QString theme READ theme WRITE setTheme NOTIFY themeChanged )
87 Q_PROPERTY(
bool previewJobsEnabled READ previewJobsEnabled WRITE setPreviewJobsEnabled )
100 double magnificationFactor() const;
113 void setLayers( const QList<
QgsMapLayer *> &layers );
145 void setCachingEnabled(
bool enabled );
151 bool isCachingEnabled() const;
168 void waitWhileRendering();
174 void setParallelRenderingEnabled(
bool enabled );
180 bool isParallelRenderingEnabled() const;
186 void setMapUpdateInterval(
int timeMilliseconds );
192 int mapUpdateInterval() const;
198 double scale() const;
201 double mapUnitsPerPixel() const;
209 void setExtent( const
QgsRectangle &r,
bool magnified = false );
215 double rotation() const;
221 void setRotation(
double degrees );
236 void zoomToFullExtent();
239 void zoomToPreviousExtent();
242 void zoomToNextExtent();
245 void clearExtentHistory();
278 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
279 int flashes = 3,
int duration = 500 );
294 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
295 int flashes = 3,
int duration = 500 );
298 void setMapTool(
QgsMapTool *mapTool,
bool clean = false );
313 void setCanvasColor( const QColor &_newVal );
315 QColor canvasColor() const;
321 void setSelectionColor( const QColor &color );
327 QColor selectionColor() const;
336 int layerCount() const;
353 void freeze(
bool frozen = true );
362 bool isFrozen() const;
372 bool renderFlag()
const {
return mRenderFlag; }
385 QMap<QString, QString> layerStyleOverrides()
const;
398 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
418 void setTheme(
const QString &theme );
425 QString
theme()
const {
return mTheme; }
437 void setWheelFactor(
double factor );
443 void zoomScale(
double scale );
449 void zoomByFactor(
double scaleFactor,
const QgsPointXY *center =
nullptr );
452 void zoomWithCenter(
int x,
int y,
bool zoomIn );
468 void enableAntiAliasing(
bool flag );
474 void enableMapTileRendering(
bool flag );
479 void panActionEnd( QPoint releasePoint );
482 void panAction( QMouseEvent *event );
485 QPoint mouseLastXY();
492 void setPreviewModeEnabled(
bool previewEnabled );
500 bool previewModeEnabled()
const;
583 void setSegmentationTolerance(
double tolerance );
594 QList< QgsMapCanvasAnnotationItem *> annotationItems()
const;
608 void setAnnotationsVisible(
bool visible );
630 bool previewJobsEnabled()
const;
640 void setPreviewJobsEnabled(
bool enabled );
651 void refreshAllLayers();
654 void selectionChangedSlot();
657 void saveAsImage(
const QString &fileName, QPixmap *QPixmap =
nullptr,
const QString & =
"PNG" );
660 void layerStateChange();
669 void setRenderFlag(
bool flag );
675 void stopRendering();
678 void readProject(
const QDomDocument & );
681 void writeProject( QDomDocument & );
689 void setMagnificationFactor(
double factor );
696 void setScaleLocked(
bool isLocked );
712 void mapToolDestroyed();
715 void rendererJobFinished();
718 void previewJobFinished();
720 void mapUpdateTimeout();
724 void mapThemeChanged(
const QString &theme );
734 void scaleChanged(
double );
737 void extentsChanged();
743 void rotationChanged(
double );
749 void magnificationChanged(
double );
755 void canvasColorChanged();
771 void renderComplete( QPainter * );
775 void mapCanvasRefreshed();
779 void renderStarting();
782 void layersChanged();
785 void keyPressed( QKeyEvent *e );
788 void keyReleased( QKeyEvent *e );
801 void zoomLastStatusChanged(
bool );
804 void zoomNextStatusChanged(
bool );
810 void destinationCrsChanged();
816 void transformContextChanged();
828 void layerStyleOverridesChanged();
835 void themeChanged(
const QString &theme );
843 bool event( QEvent *e )
override;
846 void keyPressEvent( QKeyEvent *e )
override;
849 void keyReleaseEvent( QKeyEvent *e )
override;
852 void mouseDoubleClickEvent( QMouseEvent *e )
override;
855 void mouseMoveEvent( QMouseEvent *e )
override;
858 void mousePressEvent( QMouseEvent *e )
override;
861 void mouseReleaseEvent( QMouseEvent *e )
override;
864 void wheelEvent( QWheelEvent *e )
override;
867 void resizeEvent( QResizeEvent *e )
override;
870 void paintEvent( QPaintEvent *e )
override;
873 void dragEnterEvent( QDragEnterEvent *e )
override;
876 void moveCanvasContents(
bool reset =
false );
890 void connectNotify(
const char *signal )
override;
895 void updateCanvasItemPositions();
899 void layerRepaintRequested(
bool deferred );
901 void autoRefreshTriggered();
903 void updateAutoRefreshTimer();
905 void projectThemesChanged();
907 void startPreviewJob(
int number );
915 QgsMapCanvasMap *mMap =
nullptr;
918 bool mFrozen =
false;
921 bool mRefreshScheduled =
false;
924 bool mRenderFlag =
true;
927 QPointer< QgsMapLayer > mCurrentLayer;
930 QGraphicsScene *mScene =
nullptr;
939 QList <QgsRectangle> mLastExtent;
940 int mLastExtentIndex = -1;
943 double mWheelZoomFactor = 2.0;
946 QTimer mMapUpdateTimer;
952 bool mJobCanceled =
false;
958 bool mUseParallelRendering =
false;
961 bool mDrawRenderingStats =
false;
966 QTimer *mResizeTimer =
nullptr;
967 QTimer *mRefreshTimer =
nullptr;
975 QList< QgsMapRendererQImageJob * > mPreviewJobs;
978 bool mScaleLocked =
false;
986 bool mZoomDragging =
false;
989 std::unique_ptr< QgsRubberBand > mZoomRubberBand;
993 QTimer mAutoRefreshTimer;
995 QTimer mPreviewTimer;
996 QMetaObject::Connection mPreviewTimerConnection;
1002 bool mAnnotationsVisible =
true;
1004 bool mUsePreviewJobs =
false;
1006 QHash< QString, int > mLastLayerRenderTime;
1018 void updateMapSize();
1025 void beginZoomRect( QPoint pos );
1032 void endZoomRect( QPoint pos );
1043 void setLayersPrivate(
const QList<QgsMapLayer *> &layers );
1045 void startPreviewJobs();
1046 void stopPreviewJobs();
1047 void schedulePreviewJob(
int number );
1049 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
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...
Represents a vector layer which manages a vector based data sets.
An interactive map canvas item which displays a QgsAnnotation.