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 ( dynamic_cast<QgsMapCanvas *>( sipCpp ) != NULL )
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();
276 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
277 int flashes = 3,
int duration = 500 );
292 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
293 int flashes = 3,
int duration = 500 );
296 void setMapTool(
QgsMapTool *mapTool,
bool clean = false );
311 void setCanvasColor( const QColor &_newVal );
313 QColor canvasColor() const;
319 void setSelectionColor( const QColor &color );
325 QColor selectionColor() const;
334 int layerCount() const;
351 void freeze(
bool frozen = true );
360 bool isFrozen() const;
370 bool renderFlag()
const {
return mRenderFlag; }
383 QMap<QString, QString> layerStyleOverrides()
const;
396 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
416 void setTheme(
const QString &theme );
423 QString
theme()
const {
return mTheme; }
435 void setWheelFactor(
double factor );
441 void zoomScale(
double scale );
447 void zoomByFactor(
double scaleFactor,
const QgsPointXY *center =
nullptr );
450 void zoomWithCenter(
int x,
int y,
bool zoomIn );
466 void enableAntiAliasing(
bool flag );
472 void enableMapTileRendering(
bool flag );
477 void panActionEnd( QPoint releasePoint );
480 void panAction( QMouseEvent *event );
483 QPoint mouseLastXY();
490 void setPreviewModeEnabled(
bool previewEnabled );
498 bool previewModeEnabled()
const;
581 void setSegmentationTolerance(
double tolerance );
592 QList< QgsMapCanvasAnnotationItem *> annotationItems()
const;
606 void setAnnotationsVisible(
bool visible );
628 bool previewJobsEnabled()
const;
638 void setPreviewJobsEnabled(
bool enabled );
649 void refreshAllLayers();
652 void selectionChangedSlot();
655 void saveAsImage(
const QString &fileName, QPixmap *QPixmap =
nullptr,
const QString & =
"PNG" );
658 void layerStateChange();
667 void setRenderFlag(
bool flag );
673 void stopRendering();
676 void readProject(
const QDomDocument & );
679 void writeProject( QDomDocument & );
692 void setMagnificationFactor(
double factor );
699 void setScaleLocked(
bool isLocked );
715 void mapToolDestroyed();
718 void rendererJobFinished();
721 void previewJobFinished();
723 void mapUpdateTimeout();
727 void mapThemeChanged(
const QString &theme );
737 void scaleChanged(
double );
740 void extentsChanged();
746 void rotationChanged(
double );
752 void magnificationChanged(
double );
758 void canvasColorChanged();
774 void renderComplete( QPainter * );
778 void mapCanvasRefreshed();
782 void renderStarting();
785 void layersChanged();
788 void keyPressed( QKeyEvent *e );
791 void keyReleased( QKeyEvent *e );
804 void zoomLastStatusChanged(
bool );
807 void zoomNextStatusChanged(
bool );
813 void destinationCrsChanged();
819 void transformContextChanged();
831 void layerStyleOverridesChanged();
838 void themeChanged(
const QString &theme );
846 bool event( QEvent *e )
override;
849 void keyPressEvent( QKeyEvent *e )
override;
852 void keyReleaseEvent( QKeyEvent *e )
override;
855 void mouseDoubleClickEvent( QMouseEvent *e )
override;
858 void mouseMoveEvent( QMouseEvent *e )
override;
861 void mousePressEvent( QMouseEvent *e )
override;
864 void mouseReleaseEvent( QMouseEvent *e )
override;
867 void wheelEvent( QWheelEvent *e )
override;
870 void resizeEvent( QResizeEvent *e )
override;
873 void paintEvent( QPaintEvent *e )
override;
876 void dragEnterEvent( QDragEnterEvent *e )
override;
879 void moveCanvasContents(
bool reset =
false );
893 void connectNotify(
const char *signal )
override;
898 void updateCanvasItemPositions();
902 void layerRepaintRequested(
bool deferred );
904 void autoRefreshTriggered();
906 void updateAutoRefreshTimer();
908 void projectThemesChanged();
910 void startPreviewJob(
int number );
918 QgsMapCanvasMap *mMap =
nullptr;
921 bool mFrozen =
false;
924 bool mRefreshScheduled =
false;
927 bool mRenderFlag =
true;
930 QPointer< QgsMapLayer > mCurrentLayer;
933 QGraphicsScene *mScene =
nullptr;
942 QList <QgsRectangle> mLastExtent;
943 int mLastExtentIndex = -1;
946 double mWheelZoomFactor = 2.0;
949 QTimer mMapUpdateTimer;
955 bool mJobCanceled =
false;
961 bool mUseParallelRendering =
false;
964 bool mDrawRenderingStats =
false;
969 QTimer *mResizeTimer =
nullptr;
970 QTimer *mRefreshTimer =
nullptr;
978 QList< QgsMapRendererQImageJob * > mPreviewJobs;
981 bool mScaleLocked =
false;
989 bool mZoomDragging =
false;
992 std::unique_ptr< QgsRubberBand > mZoomRubberBand;
996 QTimer mAutoRefreshTimer;
998 QTimer mPreviewTimer;
999 QMetaObject::Connection mPreviewTimerConnection;
1005 bool mAnnotationsVisible =
true;
1007 bool mUsePreviewJobs =
false;
1009 QHash< QString, int > mLastLayerRenderTime;
1021 void updateMapSize();
1028 void beginZoomRect( QPoint pos );
1035 void endZoomRect( QPoint pos );
1046 void setLayersPrivate(
const QList<QgsMapLayer *> &layers );
1048 void startPreviewJobs();
1049 void stopPreviewJobs();
1050 void schedulePreviewJob(
int number );
1052 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.