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;
582 void setSegmentationTolerance(
double tolerance );
593 QList< QgsMapCanvasAnnotationItem *> annotationItems()
const;
607 void setAnnotationsVisible(
bool visible );
629 bool previewJobsEnabled()
const;
639 void setPreviewJobsEnabled(
bool enabled );
650 void refreshAllLayers();
653 void selectionChangedSlot();
656 void saveAsImage(
const QString &fileName, QPixmap *QPixmap =
nullptr,
const QString & =
"PNG" );
659 void layerStateChange();
668 void setRenderFlag(
bool flag );
674 void stopRendering();
677 void readProject(
const QDomDocument & );
680 void writeProject( QDomDocument & );
693 void setMagnificationFactor(
double factor );
700 void setScaleLocked(
bool isLocked );
716 void mapToolDestroyed();
719 void rendererJobFinished();
722 void previewJobFinished();
724 void mapUpdateTimeout();
728 void mapThemeChanged(
const QString &theme );
738 void scaleChanged(
double );
741 void extentsChanged();
747 void rotationChanged(
double );
753 void magnificationChanged(
double );
759 void canvasColorChanged();
775 void renderComplete( QPainter * );
779 void mapCanvasRefreshed();
783 void renderStarting();
786 void layersChanged();
789 void keyPressed( QKeyEvent *e );
792 void keyReleased( QKeyEvent *e );
805 void zoomLastStatusChanged(
bool );
808 void zoomNextStatusChanged(
bool );
814 void destinationCrsChanged();
820 void transformContextChanged();
832 void layerStyleOverridesChanged();
839 void themeChanged(
const QString &theme );
847 bool event( QEvent *e )
override;
850 void keyPressEvent( QKeyEvent *e )
override;
853 void keyReleaseEvent( QKeyEvent *e )
override;
856 void mouseDoubleClickEvent( QMouseEvent *e )
override;
859 void mouseMoveEvent( QMouseEvent *e )
override;
862 void mousePressEvent( QMouseEvent *e )
override;
865 void mouseReleaseEvent( QMouseEvent *e )
override;
868 void wheelEvent( QWheelEvent *e )
override;
871 void resizeEvent( QResizeEvent *e )
override;
874 void paintEvent( QPaintEvent *e )
override;
877 void dragEnterEvent( QDragEnterEvent *e )
override;
880 void moveCanvasContents(
bool reset =
false );
894 void connectNotify(
const char *signal )
override;
899 void updateCanvasItemPositions();
903 void layerRepaintRequested(
bool deferred );
905 void autoRefreshTriggered();
907 void updateAutoRefreshTimer();
909 void projectThemesChanged();
911 void startPreviewJob(
int number );
919 QgsMapCanvasMap *mMap =
nullptr;
922 bool mFrozen =
false;
925 bool mRefreshScheduled =
false;
928 bool mRenderFlag =
true;
931 QPointer< QgsMapLayer > mCurrentLayer;
934 QGraphicsScene *mScene =
nullptr;
943 QList <QgsRectangle> mLastExtent;
944 int mLastExtentIndex = -1;
947 double mWheelZoomFactor = 2.0;
950 QTimer mMapUpdateTimer;
956 bool mJobCanceled =
false;
962 bool mUseParallelRendering =
false;
965 bool mDrawRenderingStats =
false;
970 QTimer *mResizeTimer =
nullptr;
971 QTimer *mRefreshTimer =
nullptr;
979 QList< QgsMapRendererQImageJob * > mPreviewJobs;
982 bool mScaleLocked =
false;
990 bool mZoomDragging =
false;
993 std::unique_ptr< QgsRubberBand > mZoomRubberBand;
997 QTimer mAutoRefreshTimer;
999 QTimer mPreviewTimer;
1000 QMetaObject::Connection mPreviewTimerConnection;
1006 bool mAnnotationsVisible =
true;
1008 bool mUsePreviewJobs =
false;
1010 QHash< QString, int > mLastLayerRenderTime;
1022 void updateMapSize();
1029 void beginZoomRect( QPoint pos );
1036 void endZoomRect( QPoint pos );
1047 void setLayersPrivate(
const QList<QgsMapLayer *> &layers );
1049 void startPreviewJobs();
1050 void stopPreviewJobs();
1051 void schedulePreviewJob(
int number );
1053 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.
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.
bool antiAliasingEnabled() const
true if antialising is enabled
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.
const QgsExpressionContextScope & expressionContextScope() const
Returns a const reference to the expression context scope for the map canvas.
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.
bool scaleLocked() const
Returns whether the scale is locked, so zooming can be performed using magnication.
DistanceUnit
Units of distance.
QgsExpressionContextScope & expressionContextScope()
Returns a 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.
bool annotationsVisible() const
Returns true if annotations are visible within the map canvas.
QString theme() const
Returns the map's theme shown in the canvas, if set.