20 #include <QApplication> 24 #include <QGraphicsItem> 25 #include <QGraphicsScene> 26 #include <QGraphicsView> 28 #include <QMouseEvent> 30 #include <QPaintEvent> 34 #include <QTextStream> 35 #include <QResizeEvent> 37 #include <QStringList> 38 #include <QWheelEvent> 94 , mRenderer( renderer )
95 , mSyncingExtent( false )
190 , mJobCancelled( false )
191 , mLabelingResults( nullptr )
192 , mUseParallelRendering( false )
193 , mDrawRenderingStats( false )
195 , mPreviewEffect( nullptr )
196 , mSnappingUtils( nullptr )
197 , mExpressionContextScope(
tr(
"Map Canvas" ) )
204 mLastExtentIndex = -1;
205 mCurrentLayer =
nullptr;
206 mMapOverview =
nullptr;
208 mLastNonZoomMapTool =
nullptr;
211 mRefreshScheduled =
false;
223 mResizeTimer =
new QTimer(
this );
225 connect( mResizeTimer, SIGNAL( timeout() ),
this, SLOT(
refresh() ) );
251 connect( &mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) );
278 mLastNonZoomMapTool =
nullptr;
285 while ( it != list.
end() )
306 delete mLabelingResults;
342 if ( index >= 0 && index < (
int ) layers.
size() )
351 mCurrentLayer =
layer;
373 return nullptr != mJob;
389 for ( i = 0; i < layers.
size(); i++ )
410 bool layerSetChanged = layerSetOld != layerSet;
413 if ( layerSetChanged )
424 disconnect( currentLayer, SIGNAL( repaintRequested() ),
this, SLOT(
refresh() ) );
442 connect( currentLayer, SIGNAL( repaintRequested() ),
this, SLOT(
refresh() ) );
462 if ( layerSetOvOld != layerSetOverview )
481 mMapOverview, SLOT( destinationSrsChanged() ) );
486 mMapOverview = overview;
494 overview, SLOT( destinationSrsChanged() ) );
544 QgsDebugMsg(
"refreshing after destination CRS changed" );
557 return mLabelingResults;
584 return nullptr != mCache;
595 mUseParallelRendering =
enabled;
600 return mUseParallelRendering;
626 return mCurrentLayer;
634 QgsDebugMsg(
"CANVAS refresh - invalid settings -> nothing to do" );
638 if ( !mRenderFlag || mFrozen )
644 if ( mRefreshScheduled )
650 mRefreshScheduled =
true;
658 void QgsMapCanvas::refreshMap()
660 Q_ASSERT( mRefreshScheduled );
677 mJobCancelled =
false;
678 if ( mUseParallelRendering )
682 connect( mJob, SIGNAL( finished() ), SLOT( rendererJobFinished() ) );
690 if ( vl->isEditable() )
691 layersForGeometryCache <<
id;
704 mRefreshScheduled =
false;
706 mMapUpdateTimer.
start();
712 void QgsMapCanvas::rendererJobFinished()
716 mMapUpdateTimer.
stop();
724 if ( !mJobCancelled )
728 delete mLabelingResults;
738 if ( settings.
value(
"/Map/logCanvasRefreshEvent",
false ).
toBool() )
744 if ( mDrawRenderingStats )
751 QRect r( 0, h - lh, w, lh );
784 void QgsMapCanvas::mapUpdateTimeout()
795 mJobCancelled =
true;
815 painter.
begin( theQPixmap );
835 myHeader +=
"0 \r\n";
837 myHeader +=
"0 \r\n";
848 QFile myWorldFile( myWorldFileName );
849 if ( !myWorldFile.
open( QIODevice::WriteOnly ) )
854 myStream << myHeader;
887 QgsDebugMsg(
"Empty extent - keeping old scale with new center!" );
896 if ( mLastExtent.
size() > 20 )
900 for (
int i = mLastExtent.
size() - 1; i > mLastExtentIndex; i-- )
908 if ( mLastExtent.
size() > 20 )
914 mLastExtentIndex = mLastExtent.
size() - 1;
927 double x = center.
x();
928 double y = center.
y();
956 if ( degrees == current )
989 extent.
scale( 1.05 );
1000 if ( mLastExtentIndex > 0 )
1003 mSettings.
setExtent( mLastExtent[mLastExtentIndex] );
1018 if ( mLastExtentIndex < mLastExtent.
size() - 1 )
1021 mSettings.
setExtent( mLastExtent[mLastExtentIndex] );
1035 mLastExtent.
clear();
1037 mLastExtentIndex = mLastExtent.
size() - 1;
1073 rect.
scale( 1.0, &c );
1099 int featureCount = 0;
1104 if ( !geom || geom->
isEmpty() )
1106 errorMessage =
tr(
"Feature does not have a geometry" );
1110 errorMessage =
tr(
"Feature geometry is empty" );
1112 if ( !errorMessage.
isEmpty() )
1122 if ( featureCount != ids.
count() )
1161 QPen pen( Qt::gray );
1169 double dx = qAbs( currentExtent.
width() / 4 );
1170 double dy = qAbs( currentExtent.
height() / 4 );
1212 case Qt::Key_PageUp:
1217 case Qt::Key_PageDown:
1224 mUseParallelRendering = !mUseParallelRendering;
1229 mDrawRenderingStats = !mDrawRenderingStats;
1296 if ( e->
button() == Qt::MidButton )
1326 if ( e->
button() == Qt::MidButton )
1339 QgsDebugMsg(
"Right click in map tool zoom or pan, last tool is " +
1340 QString( mLastNonZoomMapTool ?
"not null." :
"null." ) );
1345 if ( mLastNonZoomMapTool
1349 mLastNonZoomMapTool =
nullptr;
1370 mResizeTimer->
start( 500 );
1402 while ( it != list.
end() )
1434 switch ( mWheelAction )
1438 if ( e->
delta() > 0 )
1452 double scaleFactor = e->
delta() > 0 ? 1 / mWheelZoomFactor : mWheelZoomFactor;
1456 QgsPoint newCenter( mousePos.
x() + (( oldCenter.
x() - mousePos.
x() ) * scaleFactor ),
1457 mousePos.
y() + (( oldCenter.
y() - mousePos.
y() ) * scaleFactor ) );
1471 mWheelAction = action;
1472 mWheelZoomFactor = factor;
1492 double scaleFactor = ( zoomIn ? 1 / mWheelZoomFactor : mWheelZoomFactor );
1497 r.
scale( scaleFactor, ¢er );
1545 mLastNonZoomMapTool = mMapTool;
1549 mLastNonZoomMapTool =
nullptr;
1558 connect( mMapTool, SIGNAL(
destroyed() ),
this, SLOT( mapToolDestroyed() ) );
1568 if ( mMapTool && mMapTool == tool )
1577 if ( mLastNonZoomMapTool && mLastNonZoomMapTool == tool )
1579 mLastNonZoomMapTool =
nullptr;
1590 QBrush bgBrush( theColor );
1712 mRenderFlag = theFlag;
1769 double dx = end.
x() - start.
x();
1770 double dy = end.
y() - start.
y();
1772 c.
set( c.
x() - dx, c.
y() - dy );
1797 Q_UNUSED( mapLayer );
1807 if ( !mPreviewEffect )
1812 mPreviewEffect->
setEnabled( previewEnabled );
1817 if ( !mPreviewEffect )
1827 if ( !mPreviewEffect )
1832 mPreviewEffect->
setMode( mode );
1837 if ( !mPreviewEffect )
1842 return mPreviewEffect->
mode();
1847 if ( !mSnappingUtils )
1853 return mSnappingUtils;
1858 mSnappingUtils = utils;
1864 if ( nodes.
count() )
1882 QgsDebugMsg(
"Couldn't read mapcanvas information from project" );
1893 QgsDebugMsg(
"Unable to find qgis element in project file" );
1901 mSettings.
writeXML( mapcanvasNode, doc );
1915 QString settingsString =
"/Projections/" + srcAuthId +
"//" + destAuthId;
1916 QVariant defaultSrcTransform = s.
value( settingsString +
"_srcTransform" );
1917 QVariant defaultDestTransform = s.
value( settingsString +
"_destTransform" );
1918 if ( defaultSrcTransform.
isValid() && defaultDestTransform.
isValid() )
1928 if ( !s.
value(
"/Projections/showDatumTransformDialog",
false ).
toBool() )
1938 if ( dt.
size() < 2 )
1946 if ( d.exec() == QDialog::Accepted )
1948 int srcTransform = -1;
1949 int destTransform = -1;
1953 srcTransform = t.
at( 0 );
1957 destTransform = t.
at( 1 );
1961 if ( d.rememberSelection() )
1963 s.
setValue( settingsString +
"_srcTransform", srcTransform );
1964 s.
setValue( settingsString +
"_destTransform", destTransform );
1977 r.
scale( scaleFactor, center );
1998 void QgsMapCanvas::mapToolDestroyed()
2008 if ( e->
type() == QEvent::Gesture )
2013 done = mMapTool->gestureEvent( static_cast<QGestureEvent*>( e ) );
void unsetMapTool(QgsMapTool *mapTool)
Unset the current map tool or last non zoom tool.
void setInterval(int msec)
void setRequestedGeometryCacheForLayers(const QStringList &layerIds)
Set which vector layers should be cached while rendering.
Wrapper for iterator of features from vector data provider or vector layer.
void updateCanvasItemPositions()
called on resize or changed extent to notify canvas items to change their rectangle ...
const QgsMapSettings & mapSettings() const
Return map settings with which this job was started.
void setParallelRenderingEnabled(bool enabled)
Set whether the layers are rendered in parallel or sequentially.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
QPoint mouseLastXY
Last seen point of the mouse.
A rectangle specified with double values.
Base class for all map layer types.
Job implementation that renders everything sequentially using a custom painter.
void setRotation(double degrees)
Set the rotation of the map canvas in clockwise degrees.
QgsPoint center() const
Center point of the rectangle.
bool isEmpty() const
Returns true if the geometry is empty.
int mapUpdateInterval() const
Find out how often map preview should be updated while it is being rendered (in milliseconds) ...
const QgsCoordinateReferenceSystem & crsByAuthId(const QString &authid)
Returns the CRS for authid, e.g.
QDomNode item(int index) const
void zoomToNextExtent()
Zoom to the next extent (view)
void zoomWithCenter(int x, int y, bool zoomIn)
Zooms in/out with a given center.
void freeze(bool frz=true)
Freeze/thaw the map canvas.
virtual void setCanvasColor(const QColor &_newVal)
Write property of QColor bgColor.
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
void enableOverviewMode(QgsMapOverviewCanvas *overview)
QList< QgsMapLayer * > layers() const
return list of layers within map canvas.
QgsMapCanvas(QWidget *parent=nullptr, const char *name=nullptr)
Constructor.
Q_DECL_DEPRECATED bool isDirty() const
Return the state of the canvas (dirty or not)
Qt::KeyboardModifiers keyboardModifiers()
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Setter for stored overrides of styles for layers.
A widget that displays an overview map.
QDomNode appendChild(const QDomNode &newChild)
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void clearExtentHistory()
void setColor(ColorGroup group, ColorRole role, const QColor &color)
void readXML(QDomNode &theNode)
void push_back(const T &value)
bool mouseButtonDown
Flag to indicate status of mouse button.
void wheelEvent(QWheelEvent *e) override
Overridden mouse wheel event.
QList< QGraphicsItem * > items() const
void stopRendering()
stop rendering (if there is any right now)
bool save(const QString &fileName, const char *format, int quality) const
const QFont & font() const
QgsRectangle layerExtentToOutputExtent(QgsMapLayer *theLayer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
double rotation() const
Get the current map canvas rotation in clockwise degrees.
QgsPreviewEffect::PreviewMode previewMode() const
Returns the current preview mode for the map canvas.
void setExtent(const QgsRectangle &r)
Set the extent of the map canvas.
void addLayerCoordinateTransform(const QString &layerId, const QString &srcAuthId, const QString &destAuthId, int srcDatumTransform=-1, int destDatumTransform=-1)
void keyPressEvent(QKeyEvent *e) override
Overridden key press event.
void zoomToFeatureExtent(QgsRectangle &rect)
Zooms to feature extent.
const T & at(int i) const
virtual void reload()
Synchronises with changes in the datasource.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
void setBackgroundBrush(const QBrush &brush)
void scale(double scaleFactor, const QgsPoint *c=nullptr)
Scale the rectangle around its center point.
#define Q_NOWARN_DEPRECATED_PUSH
An abstract class for items that can be placed on the map canvas.
A class that stores visibility and presence in overview flags together with pointer to the layer...
bool hasCrsTransformEnabled()
A simple helper method to find out if on the fly projections are enabled or not.
void setCurrentLayer(QgsMapLayer *layer)
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
QgsPoint toMapPoint(double x, double y) const
int layerCount() const
return number of layers on the map
const QgsDatumTransformStore & datumTransformStore() const
void moveCanvasContents(bool reset=false)
called when panning is in action, reset indicates end of panning
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
QGis::UnitType mapUnits() const
Get units of map's geographical coordinates - used for scale calculation.
void setSceneRect(const QRectF &rect)
QgsPoint toMapCoordinates(int x, int y) const
void readProject(const QDomDocument &)
called to read map canvas settings from project
bool panSelectorDown
Flag to indicate the pan selector key is held down by user.
void refresh()
Repaints the canvas map.
A geometry is the spatial representation of a feature.
void renderComplete(QPainter *)
Emitted when the canvas has rendered.
void setSceneRect(const QRectF &rect)
void setProjectionsEnabled(bool enabled)
sets whether to use projections for this layer set
~QgsMapCanvas()
Destructor.
Snapping utils instance that is connected to a canvas and updates the configuration (map settings + c...
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
bool isCachingEnabled() const
Check whether images of rendered layers are curerently being cached.
QString join(const QString &separator) const
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Set map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
QgsMapTool * mapTool()
Returns the currently active tool.
bool isAutoRepeat() const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setLayerSet(const QStringList &layers)
change current layer set
A non GUI class for rendering a map layer set onto a QPainter.
void setLayers(const QStringList &layers)
Set list of layer IDs for map rendering.
void mousePressEvent(QMouseEvent *e) override
Overridden mouse press event.
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
virtual bool isEditable() const override
Returns true if the provider is in editing mode.
QImage contentImage() const
void setEnabled(bool enable)
QString tr(const char *sourceText, const char *disambiguation, int n)
virtual QImage renderedImage()=0
Get a preview/resulting image.
int renderingTime() const
Find out how log it took to finish the job (in miliseconds)
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
Map canvas is a class for displaying all GIS data types on a canvas.
void zoomLastStatusChanged(bool)
Emitted when zoom last status changed.
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
void setCache(QgsMapRendererCache *cache)
Assign a cache to be used for reading and storing rendered images of individual layers.
double y() const
Get the y value of the point.
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void updateScale()
Emits signal scaleChanged to update scale in main window.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
The QgsMapSettings class contains configuration for rendering of the map.
void resizeEvent(QResizeEvent *e) override
Overridden resize event.
Deprecated to be deleted, stuff from here should be moved elsewhere.
void hasCrsTransformEnabledChanged(bool flag)
Emitted when on-the-fly projection has been turned on/off.
void setBold(bool enable)
void setMapTool(QgsMapTool *mapTool)
Sets the map tool currently being used on the canvas.
void enableAntiAliasing(bool flag)
void setValue(const QString &key, const QVariant &value)
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
QgsMapRenderer * mRenderer
void drawRect(const QRectF &rectangle)
Perform transforms between map coordinates and device coordinates.
void setSnappingUtils(QgsSnappingUtils *utils)
Assign an instance of snapping utils to the map canvas.
const char * name() const
void setFont(const QFont &font)
QString number(int n, int base)
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
QgsRectangle extent() const
Return geographical coordinates of the rectangle that should be rendered.
void append(const T &value)
void setOutputSize(QSize size)
Set the size of the resulting map image.
Q_DECL_DEPRECATED void showError(QgsMapLayer *mapLayer)
bool save(const QString &fileName, const char *format, int quality) const
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
A rectangular graphics item representing the map on the canvas.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
void saveAsImage(const QString &theFileName, QPixmap *QPixmap=nullptr, const QString &="PNG")
Save the convtents of the map canvas to disk as an image.
virtual void start() override
Start the rendering job and immediately return.
Q_DECL_DEPRECATED void clear()
Clear the map canvas.
void mapCanvasRefreshed()
Emitted when canvas finished a refresh request.
int toInt(bool *ok) const
double scale()
Get the last reported scale of the canvas.
void rotationChanged(double)
Emitted when the rotation of the map changes.
void setInteractive(bool allowed)
void zoomNextStatusChanged(bool)
Emitted when zoom next status changed.
bool isEmpty() const
test if rectangle is empty.
void setRotation(double degrees)
Set the rotation of the resulting map image Units are clockwise degrees.
virtual bool event(QEvent *event)
void setPen(const QColor &color)
void clearCache()
Make sure to remove any rendered images from cache (does nothing if cache is not enabled) ...
void layerCrsChange()
This slot is connected to the layer's CRS change.
void setBackgroundBrush(const QBrush &brush)
double scale() const
Return the calculated scale of the map.
QGis::UnitType mapUnits() const
Get the current canvas map units.
void setMapUnits(QGis::UnitType u)
Set units of map's geographical coordinates - used for scale calculation.
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
Job implementation that renders all layers in parallel.
void setLayerSet(QList< QgsMapCanvasLayer > &layers)
double width() const
Width of the rectangle.
QString qgsDoubleToString(double a, int precision=17)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QDomNodeList elementsByTagName(const QString &tagname) const
void setMapUpdateInterval(int timeMilliseconds)
Set how often map preview should be updated while it is being rendered (in milliseconds) ...
void setObjectName(const QString &name)
void keyReleased(QKeyEvent *e)
Emit key release event.
Q_DECL_DEPRECATED QPaintDevice & paintDevice()
virtual void waitForFinished()=0
Block until the job has finished.
double mapUnitsPerPixel() const
Return the distance in geographical coordinates that equals to one pixel in the map.
bool setExtent(const QgsRectangle &extent)
sets extent and checks whether suitable (returns false if not)
Enable anti-aliasing for map rendering.
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
void setMapUnits(QGis::UnitType u)
void getDatumTransformInfo(const QgsMapLayer *ml, const QString &srcAuthId, const QString &destAuthId)
ask user about datum transformation
void enableMapTileRendering(bool theFlag)
sets map tile rendering flag
Q_DECL_DEPRECATED QPaintDevice & canvasPaintDevice()
Accessor for the canvas paint device.
void mouseDoubleClickEvent(QMouseEvent *e) override
Overridden mouse double click event.
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
static bool rotationEnabled()
return if canvas rotation is enabled
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void setOverrideCursor(const QCursor &cursor)
void panToSelected(QgsVectorLayer *layer=nullptr)
Pan to the selected features of current (vector) layer keeping same extent.
QList< int > QgsAttributeList
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
void setBrush(const QBrush &brush)
void setScene(QGraphicsScene *scene)
void drawText(const QPointF &position, const QString &text)
void restoreOverrideCursor()
void messageEmitted(const QString &title, const QString &message, QgsMessageBar::MessageLevel=QgsMessageBar::INFO)
emit a message (usually to be displayed in a message bar)
void destinationCrsChanged()
Emitted when map CRS has changed.
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void updateDatumTransformEntries()
Make sure the datum transform store is properly populated.
void setRenderFlag(bool theFlag)
Whether to suppress rendering or not.
bool hasValidSettings() const
Check whether the map settings are valid and can be used for rendering.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
void setOutputSize(QSize size, int dpi)
void setCachingEnabled(bool enabled)
Set whether to cache images of rendered layers.
Single scope for storing variables and functions for use within a QgsExpressionContext.
double mapUnitsPerPixel() const
Return current map units per pixel.
Q_DECL_DEPRECATED QgsMapCanvasMap * map()
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
void setPreviewMode(QgsPreviewEffect::PreviewMode mode)
Sets a preview mode for the map canvas.
void refresh()
renders overview and updates panning widget
void set(double x, double y)
Sets the x and y value of the point.
void setMode(PreviewMode mode)
Sets the mode for the preview effect, which controls how the effect modifies a widgets appearance...
void renderStarting()
Emitted when the canvas is about to be rendered.
A class to represent a point.
const QgsMapToPixel & mapToPixel() const
QgsRectangle extent() const
returns current extent
void keyPressed(QKeyEvent *e)
Emit key press event.
void currentLayerChanged(QgsMapLayer *layer)
Emitted when the current layer is changed.
void zoomOut()
Zoom out with fixed factor.
Enable drawing of vertex markers for layers in editing mode.
void zoomToPreviousExtent()
Zoom to the previous extent (view)
void xyCoordinates(const QgsPoint &p)
Emits current mouse position.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs, bool refreshCoordinateTransformInfo=true, bool transformExtent=true)
sets destination coordinate reference system
bool isDrawing()
Find out whether rendering is in progress.
virtual void connectNotify(const char *signal)
QByteArray toLocal8Bit() const
void setRotation(double degrees)
sets rotation value in clockwise degrees
QScopedPointer< CanvasProperties > mCanvasProperties
Handle pattern for implementation object.
void zoomToSelected(QgsVectorLayer *layer=nullptr)
Zoom to the extent of the selected features of current (vector) layer.
A class to represent a vector.
PreviewMode mode() const
Returns the mode used for the preview effect.
void setPreviewModeEnabled(bool previewEnabled)
Enables a preview mode for the map canvas.
virtual void start()=0
Start the rendering job and immediately return.
static void enableRotation(bool enabled)
change canvas rotation support
QPoint mouseLastXY()
returns last position of mouse cursor
QgsMapLayer * currentLayer()
returns current layer (set by legend widget)
QMap< QString, QString > layerStyleOverrides() const
Getter for stored overrides of styles for layers.
void setWheelAction(WheelAction action, double factor=2)
set wheel action and zoom factor (should be greater than 1)
void mouseMoveEvent(QMouseEvent *e) override
Overridden mouse move event.
void keyReleaseEvent(QKeyEvent *e) override
Overridden key release event.
void selectionChanged(QgsMapLayer *layer)
Emitted when selection in any layer gets changed.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
virtual QColor canvasColor() const
Read property of QColor bgColor.
void clear()
invalidate the cache contents
void selectionChangedSlot()
Receives signal about selection change, and pass it on with layer info.
virtual void paintEvent(QPaintEvent *event)
Draw map such that there are no problems between adjacent tiles.
Job implementation that renders everything sequentially in one thread.
#define Q_NOWARN_DEPRECATED_POP
void setBackgroundColor(const QColor &color)
Set the background color of the map.
QGis::UnitType mapUnits() const
QVariant value(const QString &key, const QVariant &defaultValue) const
void mouseReleaseEvent(QMouseEvent *e) override
Overridden mouse release event.
QStringList layerSet() const
QString name() const
Get the display name of the layer.
QMap< QString, QString > layerStyleOverrides() const
Get map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
bool isInOverview() const
void zoomToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids)
Set canvas extent to the bounding box of a set of features.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
Q_DECL_DEPRECATED void useImageToRender(bool theFlag)
Select which Qt class to render with.
void setContent(const QImage &image, const QgsRectangle &rect)
void setSelectionColor(const QColor &color)
Set color that is used for drawing of selected vector features.
void layerStyleOverridesChanged()
Emitted when the configuration of overridden layer styles changes.
void setLayerSet(const QStringList &layerSet)
updates layer set for overview
void dragEnterEvent(QDragEnterEvent *e) override
Overridden drag enter event.
QFontMetrics fontMetrics() const
void writeProject(QDomDocument &)
called to write map canvas settings to project
void panAction(QMouseEvent *event)
Called when mouse is moving and pan is activated.
QgsRectangle fullExtent() const
returns current extent of layer set
static QgsProject * instance()
access to canonical QgsProject instance
Q_DECL_DEPRECATED QgsMapRenderer * mapRenderer()
void zoomToFullExtent()
Zoom to the full extent of all layers.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
Class for storing a coordinate reference system (CRS)
QgsRectangle fullExtent() const
Returns the combined exent for all layers on the map canvas.
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
This class has all the configuration of snapping and can return answers to snapping queries...
const QgsLabelingResults * labelingResults() const
Get access to the labeling results (may be null)
QgsMapCanvasRendererSync(QgsMapCanvas *canvas, QgsMapRenderer *renderer)
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void refreshAllLayers()
Reload all layers, clear the cache and refresh the canvas.
void zoomScale(double scale)
Zoom to a specific scale.
UnitType
Map units that qgis supports.
double xMinimum() const
Get the x minimum value (left side of rectangle)
bool isFrozen()
Accessor for frozen status of canvas.
const QgsMapToPixel * getCoordinateTransform()
Get the current coordinate transform.
void scaleChanged(double)
Emitted when the scale of the map changes.
QString completeBaseName() const
void setCenter(const QgsPoint ¢er)
Set the center of the map canvas, in geographical coordinates.
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
void enableAntiAliasing(bool theFlag)
used to determine if anti-aliasing is enabled or not
double yMaximum() const
Get the y maximum value (top side of rectangle)
void setSelectionColor(const QColor &color)
Set color of selected vector features.
void paintEvent(QPaintEvent *e) override
Overridden paint event.
void layerStateChange()
This slot is connected to the visibility change of one or more layers.
Enable vector simplification and other rendering optimizations.
Class that stores computed placement from labeling engine.
This class is responsible for keeping cache of rendered images of individual layers.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
void setMapUnits(QGis::UnitType mapUnits)
Set map units (needed by project properties dialog)
Custom exception class for Coordinate Reference System related exceptions.
const QPoint & pos() const
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
Q_DECL_DEPRECATED void setDirty(bool _dirty)
Flag the canvas as dirty and needed a refresh.
QDomElement createElement(const QString &tagName)
bool nextFeature(QgsFeature &f)
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
QPoint rubberStartPoint
Beginning point of a rubber band.
Class that does synchronization between QgsMapCanvas and its associated QgsMapRenderer: ...
QgsSnappingUtils * snappingUtils() const
Return snapping utility class that is associated with map canvas.
QString absolutePath() const
virtual QgsLabelingResults * takeLabelingResults()=0
Get pointer to internal labeling engine (in order to get access to the results)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void zoomIn()
Zoom in with fixed factor.
int outputDpi() const
Return DPI used for conversion between real world units (e.g.
virtual void waitForFinished() override
Block until the job has finished.
Represents a vector layer which manages a vector based data sets.
bool begin(QPaintDevice *device)
virtual void updatePosition()
called on changed extent or resize event to update position of the item
bool isParallelRenderingEnabled() const
Check whether the layers are rendered in parallel or sequentially.
int selectedFeatureCount()
The number of features that are selected in this layer.
QgsPoint center() const
Get map center, in geographical coordinates.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
static QgsCRSCache * instance()
void extentsChanged()
Emitted when the extents of the map change.
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void destroyed(QObject *obj)
QgsMapLayer * layer(int index)
return the map layer at position index in the layer stack
QString authid() const
Returns the authority identifier for the CRS, which includes both the authority (eg EPSG) and the CRS...
double x() const
Get the x value of the point.
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
Q_DECL_DEPRECATED void updateMap()
void zoomByFactor(double scaleFactor, const QgsPoint *center=nullptr)
Zoom with the factor supplied.
double rotation() const
returns current rotation in clockwise degrees
double height() const
Height of the rectangle.
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
void panActionEnd(QPoint releasePoint)
Ends pan action and redraws the canvas.
void mapUnitsChanged()
Emitted when map units are changed.
bool previewModeEnabled() const
Returns whether a preview mode is enabled for the map canvas.
void layersChanged()
Emitted when a new set of layers has been received.
void setSingleShot(bool singleShot)
QgsRectangle boundingBoxOfSelected()
Returns the bounding box of the selected features.
void writeXML(QDomNode &theNode, QDomDocument &theDoc)
void mapToolSet(QgsMapTool *tool)
Emit map tool changed event.
virtual void resizeEvent(QResizeEvent *event)