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> 99 , mRenderer( renderer )
100 , mSyncingExtent( false )
194 , mMapRenderer( nullptr )
196 , mMapOverview( nullptr )
198 , mRefreshScheduled( false )
199 , mRenderFlag( true )
200 , mCurrentLayer( nullptr )
202 , mMapTool( nullptr )
203 , mLastNonZoomMapTool( nullptr )
204 , mLastExtentIndex( -1 )
205 , mWheelZoomFactor( 2.0 )
207 , mJobCancelled( false )
208 , mLabelingResults( nullptr )
209 , mUseParallelRendering( false )
210 , mDrawRenderingStats( false )
212 , mResizeTimer( nullptr )
213 , mPreviewEffect( nullptr )
214 , mSnappingUtils( nullptr )
215 , mScaleLocked( false )
216 , mExpressionContextScope(
tr(
"Map Canvas" ) )
217 , mZoomDragging( false )
229 mResizeTimer =
new QTimer(
this );
231 connect( mResizeTimer, SIGNAL( timeout() ),
this, SLOT(
refresh() ) );
248 double segmentationTolerance = settings.
value(
"/qgis/segmentationTolerance",
"0.01745" ).
toDouble();
253 mWheelZoomFactor = settings.
value(
"/qgis/zoom_factor", 2 ).
toDouble();
267 connect( &mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) );
281 mZoomCursor =
QCursor( zoomPixmap, 7, 7 );
297 mLastNonZoomMapTool =
nullptr;
304 while ( it != list.
end() )
325 delete mLabelingResults;
334 factor = qBound( magnifierMin, factor, magnifierMax );
382 if ( index >= 0 && index < (
int ) layers.
size() )
391 mCurrentLayer =
layer;
413 return nullptr != mJob;
429 for ( i = 0; i < layers.
size(); i++ )
450 bool layerSetChanged = layerSetOld != layerSet;
453 if ( layerSetChanged )
464 disconnect( currentLayer, SIGNAL( repaintRequested() ),
this, SLOT(
refresh() ) );
482 connect( currentLayer, SIGNAL( repaintRequested() ),
this, SLOT(
refresh() ) );
502 if ( layerSetOvOld != layerSetOverview )
521 mMapOverview, SLOT( destinationSrsChanged() ) );
526 mMapOverview = overview;
534 overview, SLOT( destinationSrsChanged() ) );
587 QgsDebugMsg(
"refreshing after destination CRS changed" );
599 return mLabelingResults;
626 return nullptr != mCache;
637 mUseParallelRendering =
enabled;
642 return mUseParallelRendering;
668 return mCurrentLayer;
676 QgsDebugMsg(
"CANVAS refresh - invalid settings -> nothing to do" );
680 if ( !mRenderFlag || mFrozen )
686 if ( mRefreshScheduled )
692 mRefreshScheduled =
true;
700 void QgsMapCanvas::refreshMap()
702 Q_ASSERT( mRefreshScheduled );
719 mJobCancelled =
false;
720 if ( mUseParallelRendering )
724 connect( mJob, SIGNAL( finished() ), SLOT( rendererJobFinished() ) );
732 if ( vl->isEditable() )
733 layersForGeometryCache <<
id;
746 mRefreshScheduled =
false;
748 mMapUpdateTimer.
start();
754 void QgsMapCanvas::rendererJobFinished()
758 mMapUpdateTimer.
stop();
766 if ( !mJobCancelled )
770 delete mLabelingResults;
780 if ( settings.
value(
"/Map/logCanvasRefreshEvent",
false ).
toBool() )
786 if ( mDrawRenderingStats )
793 QRect r( 0, h - lh, w, lh );
804 mMap->
setContent( img, imageRect( img, mSettings ) );
826 void QgsMapCanvas::mapUpdateTimeout()
831 mMap->
setContent( img, imageRect( img, mSettings ) );
840 mJobCancelled =
true;
841 disconnect( mJob, SIGNAL( finished() ),
this, SLOT( rendererJobFinished() ) );
864 painter.
begin( &image );
875 painter.
begin( &image );
888 if ( !item || item->
data( 0 ).
toString() !=
"AnnotationItem" )
896 painter.
translate( itemScenePos.
x(), itemScenePos.
y() );
898 item->
paint( &painter, &option );
913 myHeader +=
"0 \r\n";
915 myHeader +=
"0 \r\n";
927 + outputSuffix.
at( 0 ) + outputSuffix.
at( myInfo.
suffix().
size() - 1 ) +
'w';
928 QFile myWorldFile( myWorldFileName );
929 if ( !myWorldFile.
open( QIODevice::WriteOnly ) )
934 myStream << myHeader;
954 if (( r == current ) && magnified )
967 QgsDebugMsg(
"Empty extent - keeping old scale with new center!" );
976 if ( mLastExtent.
size() > 20 )
980 for (
int i = mLastExtent.
size() - 1; i > mLastExtentIndex; i-- )
988 if ( mLastExtent.
size() > 20 )
994 mLastExtentIndex = mLastExtent.
size() - 1;
1007 double x = center.
x();
1008 double y = center.
y();
1037 if ( degrees == current )
1069 extent.
scale( 1.05 );
1080 if ( mLastExtentIndex > 0 )
1083 mSettings.
setExtent( mLastExtent[mLastExtentIndex] );
1098 if ( mLastExtentIndex < mLastExtent.
size() - 1 )
1101 mSettings.
setExtent( mLastExtent[mLastExtentIndex] );
1115 mLastExtent.
clear();
1117 mLastExtentIndex = mLastExtent.
size() - 1;
1153 rect.
scale( 1.0, &c );
1179 int featureCount = 0;
1184 if ( !geom || geom->
isEmpty() )
1186 errorMessage =
tr(
"Feature does not have a geometry" );
1190 errorMessage =
tr(
"Feature geometry is empty" );
1192 if ( !errorMessage.
isEmpty() )
1202 if ( featureCount != ids.
count() )
1246 double dx = qAbs( currentExtent.
width() / 4 );
1247 double dy = qAbs( currentExtent.
height() / 4 );
1289 case Qt::Key_PageUp:
1294 case Qt::Key_PageDown:
1301 mUseParallelRendering = !mUseParallelRendering;
1306 mDrawRenderingStats = !mDrawRenderingStats;
1370 void QgsMapCanvas::beginZoomRect(
QPoint pos )
1372 mZoomRect.
setRect( 0, 0, 0, 0 );
1374 mZoomDragging =
true;
1376 QColor color( Qt::blue );
1378 mZoomRubberBand->setColor( color );
1382 void QgsMapCanvas::endZoomRect(
QPoint pos )
1384 mZoomDragging =
false;
1385 mZoomRubberBand.
reset(
nullptr );
1392 if ( mZoomRect.
width() < 5 && mZoomRect.
height() < 5 )
1402 const QSize& zoomRectSize = mZoomRect.
size();
1404 double sfx = ( double )zoomRectSize.
width() / canvasSize.
width();
1405 double sfy = ( double )zoomRectSize.
height() / canvasSize.
height();
1406 double sf = qMax( sfx, sfy );
1417 if ( e->
button() == Qt::MidButton )
1431 beginZoomRect( e->
pos() );
1456 if ( e->
button() == Qt::MidButton )
1464 if ( mZoomDragging && e->
button() == Qt::LeftButton )
1466 endZoomRect( e->
pos() );
1476 QgsDebugMsg(
"Right click in map tool zoom or pan, last tool is " +
1477 QString( mLastNonZoomMapTool ?
"not null." :
"null." ) );
1482 if ( mLastNonZoomMapTool
1487 mLastNonZoomMapTool =
nullptr;
1508 mResizeTimer->
start( 500 );
1540 while ( it != list.
end() )
1568 double zoomFactor = mWheelZoomFactor;
1569 if ( e->
modifiers() & Qt::ControlModifier )
1572 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
1575 double signedWheelFactor = e->
delta() > 0 ? 1 / zoomFactor : zoomFactor;
1580 QgsPoint newCenter( mousePos.
x() + (( oldCenter.
x() - mousePos.
x() ) * signedWheelFactor ),
1581 mousePos.
y() + (( oldCenter.
y() - mousePos.
y() ) * signedWheelFactor ) );
1594 mWheelZoomFactor = factor;
1616 double scaleFactor = ( zoomIn ? 1 / mWheelZoomFactor : mWheelZoomFactor );
1627 r.
scale( scaleFactor, ¢er );
1635 mScaleLocked = isLocked;
1646 else if ( mZoomDragging )
1649 mZoomRubberBand->setToCanvasRectangle( mZoomRect );
1650 mZoomRubberBand->show();
1688 mLastNonZoomMapTool = mMapTool;
1692 mLastNonZoomMapTool =
nullptr;
1701 connect( mMapTool, SIGNAL(
destroyed() ),
this, SLOT( mapToolDestroyed() ) );
1711 if ( mMapTool && mMapTool == tool )
1720 if ( mLastNonZoomMapTool && mLastNonZoomMapTool == tool )
1722 mLastNonZoomMapTool =
nullptr;
1733 QBrush bgBrush( theColor );
1855 mRenderFlag = theFlag;
1912 double dx = end.
x() - start.
x();
1913 double dy = end.
y() - start.
y();
1915 c.
set( c.
x() - dx, c.
y() - dy );
1940 Q_UNUSED( mapLayer );
1950 if ( !mPreviewEffect )
1955 mPreviewEffect->
setEnabled( previewEnabled );
1960 if ( !mPreviewEffect )
1970 if ( !mPreviewEffect )
1975 mPreviewEffect->
setMode( mode );
1980 if ( !mPreviewEffect )
1985 return mPreviewEffect->
mode();
1990 if ( !mSnappingUtils )
1996 return mSnappingUtils;
2001 mSnappingUtils = utils;
2007 if ( nodes.
count() )
2025 QgsDebugMsg(
"Couldn't read mapcanvas information from project" );
2036 QgsDebugMsg(
"Unable to find qgis element in project file" );
2044 mSettings.
writeXML( mapcanvasNode, doc );
2058 QString settingsString =
"/Projections/" + srcAuthId +
"//" + destAuthId;
2059 QVariant defaultSrcTransform = s.
value( settingsString +
"_srcTransform" );
2060 QVariant defaultDestTransform = s.
value( settingsString +
"_destTransform" );
2061 if ( defaultSrcTransform.
isValid() && defaultDestTransform.
isValid() )
2071 if ( !s.
value(
"/Projections/showDatumTransformDialog",
false ).
toBool() )
2081 if ( dt.
size() < 2 )
2089 if ( d.exec() == QDialog::Accepted )
2091 int srcTransform = -1;
2092 int destTransform = -1;
2096 srcTransform = t.
at( 0 );
2100 destTransform = t.
at( 1 );
2104 if ( d.rememberSelection() )
2106 s.
setValue( settingsString +
"_srcTransform", srcTransform );
2107 s.
setValue( settingsString +
"_destTransform", destTransform );
2127 r.
scale( scaleFactor, center );
2149 void QgsMapCanvas::mapToolDestroyed()
2159 if ( e->
type() == QEvent::Gesture )
2164 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 ...
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.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
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) ...
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.
QgsCoordinateReferenceSystem crsByOgcWmsCrs(const QString &ogcCrs) const
Returns the CRS from a given OGC WMS-format Coordinate Reference System string.
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)
const char * zoom_in[]
Bitmap cursors for map operations.
QList< QGraphicsItem * > items() const
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0
void setBottomRight(const QPoint &position)
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Setter for stored overrides of styles for layers.
double magnificationFactor() const
Return the magnification factor.
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
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
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.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
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.
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
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
QImage copy(const QRect &rectangle) const
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 setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
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.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
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.
void magnificationChanged(double)
Emitted when the scale of the map changes.
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.
void initFrom(const QWidget *widget)
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)
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)
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 setMagnificationFactor(double factor)
Set the magnification factor.
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)
A class for drawing transient features (e.g.
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)
Returns a string representation of a double.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QDomNodeList elementsByTagName(const QString &tagname) const
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
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)
QGis::UnitType mapUnits() const
Returns the units for the projection used by the CRS.
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 setWheelFactor(double factor)
set wheel zoom factor (should be greater than 1)
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 setSegmentationToleranceType(QgsAbstractGeometryV2::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
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 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 setOutputSize(QSize size, double dpi)
Sets the desired size of the rendered map image.
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
double magnificationFactor() const
Returns the magnification factor.
QgsMapLayer * currentLayer()
returns current layer (set by legend widget)
QMap< QString, QString > layerStyleOverrides() const
Getter for stored overrides of styles for layers.
Q_DECL_DEPRECATED 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.
void combineExtentWith(const QgsRectangle &rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
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 setTopLeft(const QPoint &position)
double outputDpi() const
Return DPI used for conversion between real world units (e.g.
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.
QVariant data(int key) const
QStringList layerSet() const
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.
void setRect(int x, int y, int width, int height)
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
const QChar at(int position) const
static QgsProject * instance()
Returns the QgsProject singleton 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.
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.
void setExtent(const QgsRectangle &r, bool magnified=false)
Set the extent of the map canvas.
void translate(const QPointF &offset)
static const double CANVAS_MAGNIFICATION_MIN
Minimum magnification level allowed in map canvases.
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.
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
virtual void cancelWithoutBlocking()=0
Triggers cancellation of the rendering job without blocking.
double yMaximum() const
Get the y maximum value (top side of rectangle)
void setSelectionColor(const QColor &color)
Set color of selected vector features.
double toDouble(bool *ok) const
QString name
Read property of QString layerName.
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.
void setScaleLocked(bool isLocked)
Lock the scale, so zooming can be performed using magnication.
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
static const double CANVAS_MAGNIFICATION_MAX
Maximum magnification level allowed in map canvases.
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.
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()
Returns a pointer to the QgsCRSCache singleton.
void extentsChanged()
Emitted when the extents of the map change.
QSize outputSize() const
Return the size of the resulting map image.
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void destroyed(QObject *obj)
void setSegmentationToleranceType(QgsAbstractGeometryV2::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
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 setMagnificationFactor(double factor)
Sets the factor of magnification to apply to the map canvas.
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)