18 #ifndef QGSMAPCANVAS_H 19 #define QGSMAPCANVAS_H 21 #include "qgsconfig.h" 30 #include <QDomDocument> 31 #include <QGraphicsView> 37 #include <QGestureEvent> 62 class QgsMapCanvasMap;
79 if ( dynamic_cast<QgsMapCanvas *>( sipCpp ) != NULL )
80 sipType = sipType_QgsMapCanvas;
87 Q_PROPERTY( QString theme READ theme WRITE setTheme NOTIFY themeChanged )
88 Q_PROPERTY(
bool previewJobsEnabled READ previewJobsEnabled WRITE setPreviewJobsEnabled )
101 double magnificationFactor() const;
114 void setLayers( const QList<
QgsMapLayer *> &layers );
146 void setCachingEnabled(
bool enabled );
152 bool isCachingEnabled() const;
169 void waitWhileRendering();
175 void setParallelRenderingEnabled(
bool enabled );
181 bool isParallelRenderingEnabled() const;
187 void setMapUpdateInterval(
int timeMilliseconds );
193 int mapUpdateInterval() const;
199 double scale() const;
202 double mapUnitsPerPixel() const;
210 void setExtent( const
QgsRectangle &r,
bool magnified = false );
216 double rotation() const;
222 void setRotation(
double degrees );
237 void zoomToFullExtent();
240 void zoomToPreviousExtent();
243 void zoomToNextExtent();
246 void clearExtentHistory();
277 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
278 int flashes = 3,
int duration = 500 );
293 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
294 int flashes = 3,
int duration = 500 );
297 void setMapTool(
QgsMapTool *mapTool,
bool clean = false );
312 void setCanvasColor( const QColor &_newVal );
314 QColor canvasColor() const;
320 void setSelectionColor( const QColor &color );
326 QColor selectionColor() const;
335 int layerCount() const;
352 void freeze(
bool frozen = true );
361 bool isFrozen() const;
371 bool renderFlag()
const {
return mRenderFlag; }
384 QMap<QString, QString> layerStyleOverrides()
const;
397 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
417 void setTheme(
const QString &theme );
424 QString
theme()
const {
return mTheme; }
436 void setWheelFactor(
double factor );
442 void zoomScale(
double scale );
448 void zoomByFactor(
double scaleFactor,
const QgsPointXY *center =
nullptr );
451 void zoomWithCenter(
int x,
int y,
bool zoomIn );
467 void enableAntiAliasing(
bool flag );
473 void enableMapTileRendering(
bool flag );
478 void panActionEnd( QPoint releasePoint );
481 void panAction( QMouseEvent *event );
484 QPoint mouseLastXY();
491 void setPreviewModeEnabled(
bool previewEnabled );
499 bool previewModeEnabled()
const;
571 void setSegmentationTolerance(
double tolerance );
582 QList< QgsMapCanvasAnnotationItem *> annotationItems()
const;
596 void setAnnotationsVisible(
bool visible );
618 bool previewJobsEnabled()
const;
628 void setPreviewJobsEnabled(
bool enabled );
639 void refreshAllLayers();
642 void selectionChangedSlot();
645 void saveAsImage(
const QString &fileName, QPixmap *QPixmap =
nullptr,
const QString & =
"PNG" );
648 void layerStateChange();
657 void setRenderFlag(
bool flag );
663 void stopRendering();
666 void readProject(
const QDomDocument & );
669 void writeProject( QDomDocument & );
682 void setMagnificationFactor(
double factor );
689 void setScaleLocked(
bool isLocked );
705 void mapToolDestroyed();
708 void rendererJobFinished();
711 void previewJobFinished();
713 void mapUpdateTimeout();
717 void mapThemeChanged(
const QString &theme );
727 void scaleChanged(
double );
730 void extentsChanged();
736 void rotationChanged(
double );
742 void magnificationChanged(
double );
748 void canvasColorChanged();
764 void renderComplete( QPainter * );
768 void mapCanvasRefreshed();
772 void renderStarting();
775 void layersChanged();
778 void keyPressed( QKeyEvent *e );
781 void keyReleased( QKeyEvent *e );
794 void zoomLastStatusChanged(
bool );
797 void zoomNextStatusChanged(
bool );
803 void destinationCrsChanged();
809 void transformContextChanged();
821 void layerStyleOverridesChanged();
828 void themeChanged(
const QString &theme );
836 bool event( QEvent *e )
override;
839 void keyPressEvent( QKeyEvent *e )
override;
842 void keyReleaseEvent( QKeyEvent *e )
override;
845 void mouseDoubleClickEvent( QMouseEvent *e )
override;
848 void mouseMoveEvent( QMouseEvent *e )
override;
851 void mousePressEvent( QMouseEvent *e )
override;
854 void mouseReleaseEvent( QMouseEvent *e )
override;
857 void wheelEvent( QWheelEvent *e )
override;
860 void resizeEvent( QResizeEvent *e )
override;
863 void paintEvent( QPaintEvent *e )
override;
866 void dragEnterEvent( QDragEnterEvent *e )
override;
869 void moveCanvasContents(
bool reset =
false );
883 void connectNotify(
const char *signal )
override;
888 void updateCanvasItemPositions();
892 void layerRepaintRequested(
bool deferred );
894 void autoRefreshTriggered();
896 void updateAutoRefreshTimer();
898 void projectThemesChanged();
900 void startPreviewJob(
int number );
908 QgsMapCanvasMap *mMap =
nullptr;
911 bool mFrozen =
false;
914 bool mRefreshScheduled =
false;
917 bool mRenderFlag =
true;
923 QGraphicsScene *mScene =
nullptr;
932 QList <QgsRectangle> mLastExtent;
933 int mLastExtentIndex = -1;
936 double mWheelZoomFactor = 2.0;
939 QTimer mMapUpdateTimer;
945 bool mJobCanceled =
false;
951 bool mUseParallelRendering =
false;
954 bool mDrawRenderingStats =
false;
959 QTimer *mResizeTimer =
nullptr;
960 QTimer *mRefreshTimer =
nullptr;
968 QList< QgsMapRendererQImageJob * > mPreviewJobs;
971 bool mScaleLocked =
false;
979 bool mZoomDragging =
false;
982 std::unique_ptr< QgsRubberBand > mZoomRubberBand;
986 QTimer mAutoRefreshTimer;
988 QTimer mPreviewTimer;
989 QMetaObject::Connection mPreviewTimerConnection;
993 bool mAnnotationsVisible =
true;
995 bool mUsePreviewJobs =
false;
997 QHash< QString, int > mLastLayerRenderTime;
1003 void updateMapSize();
1010 void beginZoomRect( QPoint pos );
1017 void endZoomRect( QPoint pos );
1028 void setLayersPrivate(
const QList<QgsMapLayer *> &layers );
1030 void startPreviewJobs();
1031 void stopPreviewJobs();
1032 void schedulePreviewJob(
int number );
1034 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.
A widget that displays an overview map.
QSet< QgsFeatureId > QgsFeatureIds
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...
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.