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>
92 , mRenderer( renderer )
93 , mSyncingExtent( false )
188 , mJobCancelled( false )
189 , mLabelingResults( 0 )
190 , mUseParallelRendering( false )
191 , mDrawRenderingStats( false )
193 , mPreviewEffect( 0 )
194 , mSnappingUtils( 0 )
201 mLastExtentIndex = -1;
202 mCurrentLayer = NULL;
205 mLastNonZoomMapTool = NULL;
208 mRefreshScheduled =
false;
220 mResizeTimer =
new QTimer(
this );
222 connect( mResizeTimer, SIGNAL( timeout() ),
this, SLOT(
refresh() ) );
248 connect( &mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) );
275 mLastNonZoomMapTool = NULL;
282 while ( it != list.
end() )
298 Q_ASSERT( mJob == 0 );
303 delete mLabelingResults;
334 if ( index >= 0 && index < (
int ) layers.
size() )
343 mCurrentLayer =
layer;
384 for ( i = 0; i < layers.
size(); i++ )
405 bool layerSetChanged = layerSetOld != layerSet;
408 if ( layerSetChanged )
419 disconnect( currentLayer, SIGNAL( repaintRequested() ),
this, SLOT(
refresh() ) );
435 connect( currentLayer, SIGNAL( repaintRequested() ),
this, SLOT(
refresh() ) );
455 if ( layerSetOvOld != layerSetOverview )
474 mMapOverview, SLOT( destinationSrsChanged() ) );
479 mMapOverview = overview;
487 overview, SLOT( destinationSrsChanged() ) );
536 QgsDebugMsg(
"refreshing after destination CRS changed" );
549 return mLabelingResults;
587 mUseParallelRendering =
enabled;
592 return mUseParallelRendering;
618 return mCurrentLayer;
626 QgsDebugMsg(
"CANVAS refresh - invalid settings -> nothing to do" );
630 if ( !mRenderFlag || mFrozen )
636 if ( mRefreshScheduled )
642 mRefreshScheduled =
true;
650 void QgsMapCanvas::refreshMap()
652 Q_ASSERT( mRefreshScheduled );
659 mRefreshScheduled =
false;
671 Q_ASSERT( mJob == 0 );
672 mJobCancelled =
false;
673 if ( mUseParallelRendering )
677 connect( mJob, SIGNAL( finished() ), SLOT( rendererJobFinished() ) );
685 if ( vl->isEditable() )
686 layersForGeometryCache <<
id;
693 mMapUpdateTimer.
start();
699 void QgsMapCanvas::rendererJobFinished()
703 mMapUpdateTimer.
stop();
711 if ( !mJobCancelled )
715 delete mLabelingResults;
725 if ( settings.
value(
"/Map/logCanvasRefreshEvent",
false ).
toBool() )
731 if ( mDrawRenderingStats )
734 QFont fnt = p.font();
737 int lh = p.fontMetrics().height() * 2;
738 QRect r( 0, h - lh, w, lh );
739 p.setPen( Qt::NoPen );
740 p.setBrush(
QColor( 0, 0, 0, 110 ) );
742 p.setPen( Qt::white );
744 p.drawText( r, msg,
QTextOption( Qt::AlignCenter ) );
771 void QgsMapCanvas::mapUpdateTimeout()
782 mJobCancelled =
true;
784 Q_ASSERT( mJob == 0 );
798 if ( theQPixmap != NULL )
802 painter.
begin( theQPixmap );
822 myHeader +=
"0 \r\n";
824 myHeader +=
"0 \r\n";
835 QFile myWorldFile( myWorldFileName );
836 if ( !myWorldFile.
open( QIODevice::WriteOnly ) )
841 myStream << myHeader;
874 QgsDebugMsg(
"Empty extent - keeping old scale with new center!" );
883 if ( mLastExtent.
size() > 20 )
887 for (
int i = mLastExtent.
size() - 1; i > mLastExtentIndex; i-- )
895 if ( mLastExtent.
size() > 20 )
901 mLastExtentIndex = mLastExtent.
size() - 1;
914 double x = center.
x();
915 double y = center.
y();
943 if ( degrees == current )
976 extent.
scale( 1.05 );
987 if ( mLastExtentIndex > 0 )
990 mSettings.
setExtent( mLastExtent[mLastExtentIndex] );
1005 if ( mLastExtentIndex < mLastExtent.
size() - 1 )
1008 mSettings.
setExtent( mLastExtent[mLastExtentIndex] );
1022 mLastExtent.
clear();
1024 mLastExtentIndex = mLastExtent.
size() - 1;
1038 if ( layer == NULL )
1044 if ( layer == NULL )
1063 rect.
scale( 1.0, &c );
1080 if ( layer == NULL )
1086 if ( layer == NULL )
1110 QPen pen( Qt::gray );
1118 double dx = qAbs(( currentExtent.
xMaximum() - currentExtent.
xMinimum() ) / 4 );
1119 double dy = qAbs(( currentExtent.
yMaximum() - currentExtent.
yMinimum() ) / 4 );
1172 case Qt::Key_PageUp:
1177 case Qt::Key_PageDown:
1184 mUseParallelRendering = !mUseParallelRendering;
1189 mDrawRenderingStats = !mDrawRenderingStats;
1256 if ( e->
button() == Qt::MidButton )
1286 if ( e->
button() == Qt::MidButton )
1299 QgsDebugMsg(
"Right click in map tool zoom or pan, last tool is " +
1300 QString( mLastNonZoomMapTool ?
"not null." :
"null." ) );
1305 if ( mLastNonZoomMapTool
1309 mLastNonZoomMapTool = NULL;
1330 mResizeTimer->
start( 500 );
1362 while ( it != list.
end() )
1394 switch ( mWheelAction )
1398 if ( e->
delta() > 0 )
1412 double scaleFactor = e->
delta() > 0 ? 1 / mWheelZoomFactor : mWheelZoomFactor;
1416 QgsPoint newCenter( mousePos.
x() + (( oldCenter.
x() - mousePos.
x() ) * scaleFactor ),
1417 mousePos.
y() + (( oldCenter.
y() - mousePos.
y() ) * scaleFactor ) );
1431 mWheelAction = action;
1432 mWheelZoomFactor = factor;
1452 double scaleFactor = ( zoomIn ? 1 / mWheelZoomFactor : mWheelZoomFactor );
1457 r.
scale( scaleFactor, ¢er );
1505 mLastNonZoomMapTool = mMapTool;
1509 mLastNonZoomMapTool = NULL;
1518 connect( mMapTool, SIGNAL(
destroyed() ),
this, SLOT( mapToolDestroyed() ) );
1528 if ( mMapTool && mMapTool == tool )
1537 if ( mLastNonZoomMapTool && mLastNonZoomMapTool == tool )
1539 mLastNonZoomMapTool = NULL;
1550 QBrush bgBrush( theColor );
1672 mRenderFlag = theFlag;
1729 double dx = end.
x() - start.
x();
1730 double dy = end.
y() - start.
y();
1732 c.
set( c.
x() - dx, c.
y() - dy );
1757 Q_UNUSED( mapLayer );
1767 if ( !mPreviewEffect )
1772 mPreviewEffect->
setEnabled( previewEnabled );
1777 if ( !mPreviewEffect )
1787 if ( !mPreviewEffect )
1792 mPreviewEffect->
setMode( mode );
1797 if ( !mPreviewEffect )
1802 return mPreviewEffect->
mode();
1807 if ( !mSnappingUtils )
1813 return mSnappingUtils;
1818 mSnappingUtils = utils;
1824 if ( nodes.
count() )
1841 QgsDebugMsg(
"Couldn't read mapcanvas information from project" );
1852 QgsDebugMsg(
"Unable to find qgis element in project file" );
1860 mSettings.
writeXML( mapcanvasNode, doc );
1874 QString settingsString =
"/Projections/" + srcAuthId +
"//" + destAuthId;
1875 QVariant defaultSrcTransform = s.
value( settingsString +
"_srcTransform" );
1876 QVariant defaultDestTransform = s.
value( settingsString +
"_destTransform" );
1877 if ( defaultSrcTransform.
isValid() && defaultDestTransform.
isValid() )
1887 if ( !s.
value(
"/Projections/showDatumTransformDialog",
false ).
toBool() )
1897 if ( dt.
size() < 2 )
1905 if ( d.exec() == QDialog::Accepted )
1907 int srcTransform = -1;
1908 int destTransform = -1;
1912 srcTransform = t.
at( 0 );
1916 destTransform = t.
at( 1 );
1920 if ( d.rememberSelection() )
1922 s.
setValue( settingsString +
"_srcTransform", srcTransform );
1923 s.
setValue( settingsString +
"_destTransform", destTransform );
1936 r.
scale( scaleFactor, center );
1957 void QgsMapCanvas::mapToolDestroyed()
1967 if ( e->
type() == QEvent::Gesture )
1972 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 zoomToSelected(QgsVectorLayer *layer=NULL)
Zoom to the extent of the selected features of current (vector) layer.
void setRequestedGeometryCacheForLayers(const QStringList &layerIds)
Set which vector layers should be cached while rendering.
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.
const QgsDatumTransformStore & datumTransformStore() const
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
QPoint mouseLastXY
Last seen point of the mouse.
virtual QColor canvasColor() const
Read property of QColor bgColor.
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.
const QgsCoordinateReferenceSystem & crsByAuthId(const QString &authid)
Returns the CRS for authid, e.g.
bool isEmpty() const
test if rectangle is empty.
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.
Q_DECL_DEPRECATED bool isDirty() const
Return the state of the canvas (dirty or not)
void freeze(bool frz=true)
Freeze/thaw the map canvas.
virtual void setCanvasColor(const QColor &_newVal)
Write property of QColor bgColor.
void enableOverviewMode(QgsMapOverviewCanvas *overview)
double scale() const
Return the calculated scale of the map.
void zoomByFactor(double scaleFactor, const QgsPoint *center=0)
Zoom with the factor supplied.
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
Qt::KeyboardModifiers keyboardModifiers()
int layerCount() const
return number of layers on the map
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)
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void setXMaximum(double x)
Set the maximum x value.
void clearExtentHistory()
void setColor(ColorGroup group, ColorRole role, const QColor &color)
void readXML(QDomNode &theNode)
QgsRectangle fullExtent() const
returns current extent of layer set
void push_back(const T &value)
bool mouseButtonDown
Flag to indicate status of mouse button.
void wheelEvent(QWheelEvent *e) override
Overridden mouse wheel event.
double yMaximum() const
Get the y maximum value (top side of rectangle)
QList< QGraphicsItem * > items() const
UnitType
Map units that qgis supports.
void stopRendering()
stop rendering (if there is any right now)
bool save(const QString &fileName, const char *format, int quality) const
double rotation() const
Get the current map canvas rotation in clockwise degrees.
QgsRectangle extent() const
returns current extent
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.
const T & at(int i) const
virtual void reload()
Synchronises with changes in the datasource.
void setBackgroundBrush(const QBrush &brush)
#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 previewModeEnabled() const
Returns whether a preview mode is enabled for the map canvas.
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
QList< QgsMapLayer * > layers() const
return list of layers within map canvas.
QMap< QString, QString > layerStyleOverrides() const
Get map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
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.
void setSceneRect(const QRectF &rect)
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
QgsRectangle layerExtentToOutputExtent(QgsMapLayer *theLayer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
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.
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 QgsMapToPixel & mapToPixel() const
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.
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
bool isAutoRepeat() const
void setLayerSet(const QStringList &layers)
change current layer set
const QgsLabelingResults * labelingResults() const
Get access to the labeling results (may be null)
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.
QMap< QString, QString > layerStyleOverrides() const
Getter for stored overrides of styles for layers.
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.
void setEnabled(bool enable)
QString tr(const char *sourceText, const char *disambiguation, int n)
virtual QImage renderedImage()=0
Get a preview/resulting image.
Map canvas is a class for displaying all GIS data types on a canvas.
double x() const
Get the x value of the point.
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.
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.
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)
const QString & name() const
Get the display name of the layer.
void setValue(const QString &key, const QVariant &value)
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
QgsMapRenderer * mRenderer
Perform transforms between map coordinates and device coordinates.
void setSnappingUtils(QgsSnappingUtils *utils)
Assign an instance of snapping utils to the map canvas.
int outputDpi() const
Return DPI used for conversion between real world units (e.g.
QString number(int n, int base)
void append(const T &value)
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.
QgsSnappingUtils * snappingUtils() const
Return snapping utility class that is associated with map canvas.
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 yMinimum() const
Get the y minimum value (bottom side of rectangle)
double scale()
Get the last reported scale of the canvas.
void rotationChanged(double)
Emitted when the rotation of the map changes.
double xMaximum() const
Get the x maximum value (right side of rectangle)
void setInteractive(bool allowed)
void zoomNextStatusChanged(bool)
Emitted when zoom next status changed.
void setRotation(double degrees)
Set the rotation of the resulting map image Units are clockwise degrees.
virtual bool event(QEvent *event)
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
bool hasValidSettings() const
Check whether the map settings are valid and can be used for rendering.
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)
void setMapUnits(QGis::UnitType u)
Set units of map's geographical coordinates - used for scale calculation.
Job implementation that renders all layers in parallel.
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void panToSelected(QgsVectorLayer *layer=NULL)
Pan to the selected features of current (vector) layer keeping same extent.
void setLayerSet(QList< QgsMapCanvasLayer > &layers)
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void setYMinimum(double y)
Set the minimum y value.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QDomNodeList elementsByTagName(const QString &tagname) const
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.
bool setExtent(const QgsRectangle &extent)
sets extent and checks whether suitable (returns false if not)
Enable anti-aliasin for map rendering.
const QgsMapSettings & mapSettings() const
Return map settings with which this job was started.
void setMapUnits(QGis::UnitType u)
void getDatumTransformInfo(const QgsMapLayer *ml, const QString &srcAuthId, const QString &destAuthId)
ask user about datum transformation
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
double mapUnitsPerPixel() const
Return the distance in geographical coordinates that equals to one pixel in the map.
void setScene(QGraphicsScene *scene)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void destinationCrsChanged()
Emitted when map CRS has changed.
double rotation() const
returns current rotation in clockwise degrees
double mapUnitsPerPixel() const
Return current map units per pixel.
int mapUpdateInterval() const
Find out how often map preview should be updated while it is being rendered (in milliseconds) ...
void updateDatumTransformEntries()
Make sure the datum transform store is properly populated.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
void setRenderFlag(bool theFlag)
Whether to suppress rendering or not.
QGis::UnitType mapUnits() const
Get units of map's geographical coordinates - used for scale calculation.
QGis::UnitType mapUnits() const
Get the current canvas map units.
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.
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.
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.
QgsPreviewEffect::PreviewMode previewMode() const
Returns the current preview mode for the map canvas.
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.
QString qgsDoubleToString(const double &a, const int &precision=17)
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)
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 isCachingEnabled() const
Check whether images of rendered layers are curerently being cached.
QgsPoint toMapCoordinates(int x, int y) const
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)
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.
QVariant value(const QString &key, const QVariant &defaultValue) const
void mouseReleaseEvent(QMouseEvent *e) override
Overridden mouse release event.
QImage contentImage() const
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.
Q_DECL_DEPRECATED void useImageToRender(bool theFlag)
Select which Qt class to render with.
void setContent(const QImage &image, const QgsRectangle &rect)
bool isInOverview() const
void saveAsImage(const QString &theFileName, QPixmap *QPixmap=0, const QString &="PNG")
Save the convtents of the map canvas to disk as an image.
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 setOutputSize(const QSize &size)
Set the size of the resulting map image.
void setYMaximum(double y)
Set the maximum y value.
QgsPoint center() const
Get map center, in geographical coordinates.
void writeProject(QDomDocument &)
called to write map canvas settings to project
void panAction(QMouseEvent *event)
Called when mouse is moving and pan is activated.
static QgsProject * instance()
access to canonical QgsProject instance
Q_DECL_DEPRECATED QgsMapRenderer * mapRenderer()
void zoomToFullExtent()
Zoom to the full extent of all layers.
Class for storing a coordinate reference system (CRS)
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...
QgsMapCanvasRendererSync(QgsMapCanvas *canvas, QgsMapRenderer *renderer)
void refreshAllLayers()
Reload all layers, clear the cache and refresh the canvas.
QgsRectangle extent() const
Return geographical coordinates of the rectangle that should be rendered.
QString authid() const
Get the authority identifier for this srs.
void zoomScale(double scale)
Zoom to a specific scale.
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
double y() const
Get the y value of the point.
void setCenter(const QgsPoint ¢er)
Set the center of the map canvas, in geographical coordinates.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
virtual void cancel()=0
Stop the rendering job - does not return until the job has terminated.
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
void enableAntiAliasing(bool theFlag)
used to determine if anti-aliasing is enabled or not
void setSelectionColor(const QColor &color)
Set color of selected vector features.
void paintEvent(QPaintEvent *e) override
Overridden paint event.
void setMapUpdateInterval(int timeMiliseconds)
Set how often map preview should be updated while it is being rendered (in milliseconds) ...
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.
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
This class is responsible for keeping cache of rendered images of individual layers.
QgsMapCanvas(QWidget *parent=0, const char *name=0)
Constructor.
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
bool isParallelRenderingEnabled() const
Check whether the layers are rendered in parallel or sequentially.
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
PreviewMode mode() const
Returns the mode used for the preview effect.
Q_DECL_DEPRECATED void setDirty(bool _dirty)
Flag the canvas as dirty and needed a refresh.
QDomElement createElement(const QString &tagName)
QPoint rubberStartPoint
Beginning point of a rubber band.
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
Class that does synchronization between QgsMapCanvas and its associated QgsMapRenderer: ...
QString absolutePath() const
double width() const
Width of the rectangle.
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.
QGis::UnitType mapUnits() const
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
int selectedFeatureCount()
The number of features that are selected in this layer.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double xMinimum() const
Get the x minimum value (left side of rectangle)
static QgsCRSCache * instance()
QgsPoint center() const
Center point of the rectangle.
void extentsChanged()
Emitted when the extents of the map change.
int renderingTime() const
Find out how log it took to finish the job (in miliseconds)
void destroyed(QObject *obj)
QgsMapLayer * layer(int index)
return the map layer at position index in the layer stack
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
Q_DECL_DEPRECATED void updateMap()
void setXMinimum(double x)
Set the minimum x value.
double height() const
Height of the rectangle.
QgsPoint toMapPoint(double x, double y) const
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()
Emmitted when map units are changed.
QStringList layerSet() const
QgsRectangle fullExtent() const
Returns the combined exent for all layers on 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.
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.
virtual void resizeEvent(QResizeEvent *event)