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();
282 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
283 int flashes = 3,
int duration = 500 );
298 const QColor &startColor = QColor( 255, 0, 0, 255 ), const QColor &endColor = QColor( 255, 0, 0, 0 ),
299 int flashes = 3,
int duration = 500 );
302 void setMapTool(
QgsMapTool *mapTool,
bool clean = false );
317 void setCanvasColor( const QColor &_newVal );
319 QColor canvasColor() const;
325 void setSelectionColor( const QColor &color );
331 QColor selectionColor() const;
340 int layerCount() const;
357 void freeze(
bool frozen = true );
366 bool isFrozen() const;
376 bool renderFlag()
const {
return mRenderFlag; }
389 QMap<QString, QString> layerStyleOverrides()
const;
402 void setLayerStyleOverrides(
const QMap<QString, QString> &overrides );
422 void setTheme(
const QString &theme );
429 QString
theme()
const {
return mTheme; }
441 void setWheelFactor(
double factor );
447 void zoomScale(
double scale );
453 void zoomByFactor(
double scaleFactor,
const QgsPointXY *center =
nullptr );
456 void zoomWithCenter(
int x,
int y,
bool zoomIn );
472 void enableAntiAliasing(
bool flag );
478 void enableMapTileRendering(
bool flag );
483 void panActionEnd( QPoint releasePoint );
486 void panAction( QMouseEvent *event );
489 QPoint mouseLastXY();
496 void setPreviewModeEnabled(
bool previewEnabled );
504 bool previewModeEnabled()
const;
576 void setSegmentationTolerance(
double tolerance );
587 QList< QgsMapCanvasAnnotationItem *> annotationItems()
const;
601 void setAnnotationsVisible(
bool visible );
623 bool previewJobsEnabled()
const;
633 void setPreviewJobsEnabled(
bool enabled );
644 void refreshAllLayers();
647 void selectionChangedSlot();
650 void saveAsImage(
const QString &fileName, QPixmap *QPixmap =
nullptr,
const QString & =
"PNG" );
653 void layerStateChange();
662 void setRenderFlag(
bool flag );
668 void stopRendering();
671 void readProject(
const QDomDocument & );
674 void writeProject( QDomDocument & );
687 void setMagnificationFactor(
double factor );
694 void setScaleLocked(
bool isLocked );
704 void mapToolDestroyed();
707 void rendererJobFinished();
710 void previewJobFinished();
712 void mapUpdateTimeout();
716 void mapThemeChanged(
const QString &theme );
726 void scaleChanged(
double );
729 void extentsChanged();
735 void rotationChanged(
double );
741 void magnificationChanged(
double );
747 void canvasColorChanged();
763 void renderComplete( QPainter * );
767 void mapCanvasRefreshed();
771 void renderStarting();
774 void layersChanged();
777 void keyPressed( QKeyEvent *e );
780 void keyReleased( QKeyEvent *e );
793 void zoomLastStatusChanged(
bool );
796 void zoomNextStatusChanged(
bool );
802 void destinationCrsChanged();
808 void transformContextChanged();
820 void layerStyleOverridesChanged();
827 void themeChanged(
const QString &theme );
835 bool event( QEvent *e )
override;
838 void keyPressEvent( QKeyEvent *e )
override;
841 void keyReleaseEvent( QKeyEvent *e )
override;
844 void mouseDoubleClickEvent( QMouseEvent *e )
override;
847 void mouseMoveEvent( QMouseEvent *e )
override;
850 void mousePressEvent( QMouseEvent *e )
override;
853 void mouseReleaseEvent( QMouseEvent *e )
override;
856 void wheelEvent( QWheelEvent *e )
override;
859 void resizeEvent( QResizeEvent *e )
override;
862 void paintEvent( QPaintEvent *e )
override;
865 void dragEnterEvent( QDragEnterEvent *e )
override;
868 void moveCanvasContents(
bool reset =
false );
882 void connectNotify(
const char *signal )
override;
887 void updateCanvasItemPositions();
891 void layerRepaintRequested(
bool deferred );
893 void autoRefreshTriggered();
895 void updateAutoRefreshTimer();
897 void projectThemesChanged();
899 void startPreviewJob(
int number );
916 QgsMapCanvasMap *mMap =
nullptr;
919 bool mFrozen =
false;
922 bool mRefreshScheduled =
false;
925 bool mRenderFlag =
true;
931 QGraphicsScene *mScene =
nullptr;
940 QList <QgsRectangle> mLastExtent;
941 int mLastExtentIndex = -1;
944 double mWheelZoomFactor = 2.0;
947 QTimer mMapUpdateTimer;
953 bool mJobCanceled =
false;
959 bool mUseParallelRendering =
false;
962 bool mDrawRenderingStats =
false;
967 QTimer *mResizeTimer =
nullptr;
968 QTimer *mRefreshTimer =
nullptr;
976 QList< QgsMapRendererQImageJob * > mPreviewJobs;
979 bool mScaleLocked =
false;
987 bool mZoomDragging =
false;
990 std::unique_ptr< QgsRubberBand > mZoomRubberBand;
994 QTimer mAutoRefreshTimer;
996 QTimer mPreviewTimer;
997 QMetaObject::Connection mPreviewTimerConnection;
1001 bool mAnnotationsVisible =
true;
1003 bool mUsePreviewJobs =
false;
1005 QHash< QString, int > mLastLayerRenderTime;
1011 void updateMapSize();
1018 void beginZoomRect( QPoint pos );
1025 void endZoomRect( QPoint pos );
1036 void setLayersPrivate(
const QList<QgsMapLayer *> &layers );
1038 void startPreviewJobs();
1039 void stopPreviewJobs();
1040 void schedulePreviewJob(
int number );
1042 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.