2013-12-05 18:27:45 +07:00
|
|
|
|
|
|
|
class QgsMapSettings
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsmapsettings.h>
|
|
|
|
%End
|
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
public:
|
|
|
|
QgsMapSettings();
|
|
|
|
|
2014-06-21 23:48:52 +07:00
|
|
|
//! Return geographical coordinates of the rectangle that should be rendered.
|
|
|
|
//! The actual visible extent used for rendering could be slightly different
|
|
|
|
//! since the given extent may be expanded in order to fit the aspect ratio
|
|
|
|
//! of output size. Use visibleExtent() to get the resulting extent.
|
2014-05-27 23:22:50 +02:00
|
|
|
QgsRectangle extent() const;
|
2014-06-21 23:48:52 +07:00
|
|
|
//! Set coordinates of the rectangle which should be rendered.
|
|
|
|
//! The actual visible extent used for rendering could be slightly different
|
|
|
|
//! since the given extent may be expanded in order to fit the aspect ratio
|
|
|
|
//! of output size. Use visibleExtent() to get the resulting extent.
|
2016-05-18 14:36:02 +02:00
|
|
|
void setExtent( const QgsRectangle& rect, bool magnified = true );
|
2014-05-27 23:22:50 +02:00
|
|
|
|
2014-06-21 23:48:52 +07:00
|
|
|
//! Return the size of the resulting map image
|
2014-05-27 23:22:50 +02:00
|
|
|
QSize outputSize() const;
|
2014-06-21 23:48:52 +07:00
|
|
|
//! Set the size of the resulting map image
|
2016-02-02 19:46:18 +11:00
|
|
|
void setOutputSize( QSize size );
|
2014-05-27 23:22:50 +02:00
|
|
|
|
2014-12-09 09:53:56 +01:00
|
|
|
//! Return the rotation of the resulting map image
|
|
|
|
//! Units are clockwise degrees
|
|
|
|
//! @note added in 2.8
|
|
|
|
double rotation() const;
|
|
|
|
//! Set the rotation of the resulting map image
|
|
|
|
//! Units are clockwise degrees
|
|
|
|
//! @note added in 2.8
|
|
|
|
void setRotation( double degrees );
|
|
|
|
|
2014-06-21 23:48:52 +07:00
|
|
|
//! Return DPI used for conversion between real world units (e.g. mm) and pixels
|
|
|
|
//! Default value is 96
|
2016-05-28 17:22:22 +02:00
|
|
|
double outputDpi() const;
|
2014-06-21 23:48:52 +07:00
|
|
|
//! Set DPI used for conversion between real world units (e.g. mm) and pixels
|
2016-05-28 17:22:22 +02:00
|
|
|
void setOutputDpi( double dpi );
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2016-05-28 13:41:59 +02:00
|
|
|
/**
|
2016-05-29 08:10:23 +10:00
|
|
|
* Set the magnification factor.
|
2016-05-28 13:41:59 +02:00
|
|
|
* @param factor the factor of magnification
|
|
|
|
* @note added in 2.16
|
2016-05-29 08:10:23 +10:00
|
|
|
* @see magnificationFactor()
|
2016-05-28 13:41:59 +02:00
|
|
|
*/
|
2016-05-29 08:10:23 +10:00
|
|
|
void setMagnificationFactor( double factor );
|
2016-05-28 13:41:59 +02:00
|
|
|
|
2016-05-29 08:10:23 +10:00
|
|
|
//! Return the magnification factor.
|
2016-05-18 14:36:02 +02:00
|
|
|
//! @note added in 2.16
|
2016-05-29 08:10:23 +10:00
|
|
|
//! @see setMagnificationFactor()
|
|
|
|
double magnificationFactor() const;
|
2016-05-18 14:36:02 +02:00
|
|
|
|
2014-06-21 23:48:52 +07:00
|
|
|
//! Get list of layer IDs for map rendering
|
|
|
|
//! The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
|
2014-05-27 23:22:50 +02:00
|
|
|
QStringList layers() const;
|
2014-06-21 23:48:52 +07:00
|
|
|
//! Set list of layer IDs for map rendering. The layers must be registered in QgsMapLayerRegistry.
|
|
|
|
//! The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
|
2014-05-27 23:22:50 +02:00
|
|
|
void setLayers( const QStringList& layers );
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2015-01-09 21:41:50 +07:00
|
|
|
//! Get map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
|
|
|
|
//! @note added in 2.8
|
|
|
|
QMap<QString, QString> layerStyleOverrides() const;
|
|
|
|
//! Set map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
|
|
|
|
//! @note added in 2.8
|
|
|
|
void setLayerStyleOverrides( const QMap<QString, QString>& overrides );
|
|
|
|
|
2016-05-30 14:33:40 +10:00
|
|
|
/** Get custom rendering flags. Layers might honour these to alter their rendering.
|
|
|
|
* @returns custom flags strings, separated by ';'
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
* @see setCustomRenderFlags()
|
|
|
|
*/
|
|
|
|
QString customRenderFlags() const;
|
|
|
|
|
|
|
|
/** Sets the custom rendering flags. Layers might honour these to alter their rendering.
|
|
|
|
* @param customRenderFlags custom flags strings, separated by ';'
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
* @see customRenderFlags()
|
|
|
|
*/
|
2016-05-26 23:23:45 +02:00
|
|
|
void setCustomRenderFlags( const QString& customRenderFlags );
|
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
//! sets whether to use projections for this layer set
|
|
|
|
void setCrsTransformEnabled( bool enabled );
|
|
|
|
//! returns true if projections are enabled for this layer set
|
|
|
|
bool hasCrsTransformEnabled() const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
//! sets destination coordinate reference system
|
|
|
|
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
|
|
|
|
//! returns CRS of destination coordinate reference system
|
2016-07-11 16:04:50 +10:00
|
|
|
QgsCoordinateReferenceSystem destinationCrs() const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Get units of map's geographical coordinates - used for scale calculation
|
2016-07-17 14:56:05 +10:00
|
|
|
QgsUnitTypes::DistanceUnit mapUnits() const;
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Set units of map's geographical coordinates - used for scale calculation
|
2016-07-17 14:56:05 +10:00
|
|
|
void setMapUnits( QgsUnitTypes::DistanceUnit u );
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Set the background color of the map
|
2014-05-27 23:22:50 +02:00
|
|
|
void setBackgroundColor( const QColor& color );
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Get the background color of the map
|
2014-05-27 23:22:50 +02:00
|
|
|
QColor backgroundColor() const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Set color that is used for drawing of selected vector features
|
2014-05-27 23:22:50 +02:00
|
|
|
void setSelectionColor( const QColor& color );
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Get color that is used for drawing of selected vector features
|
2014-05-27 23:22:50 +02:00
|
|
|
QColor selectionColor() const;
|
2014-06-02 21:00:51 +02:00
|
|
|
|
2016-06-07 10:07:23 +10:00
|
|
|
//! Enumeration of flags that adjust the way the map is rendered
|
2014-05-27 23:22:50 +02:00
|
|
|
enum Flag
|
|
|
|
{
|
2016-06-07 10:07:23 +10:00
|
|
|
Antialiasing, //!< Enable anti-aliasing for map rendering
|
2014-06-22 00:15:37 +07:00
|
|
|
DrawEditingInfo, //!< Enable drawing of vertex markers for layers in editing mode
|
|
|
|
ForceVectorOutput, //!< Vector graphics should not be cached and drawn as raster images
|
|
|
|
UseAdvancedEffects, //!< Enable layer transparency and blending effects
|
|
|
|
DrawLabeling, //!< Enable drawing of labels on top of the map
|
2016-02-14 03:50:23 +01:00
|
|
|
UseRenderingOptimization, //!< Enable vector simplification and other rendering optimizations
|
2014-06-22 00:58:16 +07:00
|
|
|
DrawSelection, //!< Whether vector selections should be shown in the rendered map
|
2015-11-20 19:16:15 +11:00
|
|
|
DrawSymbolBounds, //!< Draw bounds of symbols (for debugging/testing)
|
2016-02-14 03:50:23 +01:00
|
|
|
RenderMapTile //!< Draw map such that there are no problems between adjacent tiles
|
2014-05-27 23:22:50 +02:00
|
|
|
};
|
|
|
|
typedef QFlags<QgsMapSettings::Flag> Flags;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Set combination of flags that will be used for rendering
|
2015-10-07 11:55:34 +11:00
|
|
|
void setFlags( const Flags& flags );
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Enable or disable a particular flag (other flags are not affected)
|
2014-05-27 23:22:50 +02:00
|
|
|
void setFlag( Flag flag, bool on = true );
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Return combination of flags used for rendering
|
2014-05-27 23:22:50 +02:00
|
|
|
Flags flags() const;
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Check whether a particular flag is enabled
|
2014-05-27 23:22:50 +02:00
|
|
|
bool testFlag( Flag flag ) const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-03-31 21:51:21 -06:00
|
|
|
//! sets format of internal QImage
|
|
|
|
void setOutputImageFormat( QImage::Format format );
|
|
|
|
//! format of internal QImage, default QImage::Format_ARGB32_Premultiplied
|
|
|
|
QImage::Format outputImageFormat() const;
|
|
|
|
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Check whether the map settings are valid and can be used for rendering
|
2014-05-27 23:22:50 +02:00
|
|
|
bool hasValidSettings() const;
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Return the actual extent derived from requested extent that takes takes output image size into account
|
2014-05-27 23:22:50 +02:00
|
|
|
QgsRectangle visibleExtent() const;
|
2015-02-07 15:05:00 +01:00
|
|
|
//! Return the visible area as a polygon (may be rotated)
|
|
|
|
//! @note added in 2.8
|
|
|
|
QPolygonF visiblePolygon() const;
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Return the distance in geographical coordinates that equals to one pixel in the map
|
2014-05-27 23:22:50 +02:00
|
|
|
double mapUnitsPerPixel() const;
|
2014-06-22 00:15:37 +07:00
|
|
|
//! Return the calculated scale of the map
|
2014-05-27 23:22:50 +02:00
|
|
|
double scale() const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2015-08-13 10:10:26 +10:00
|
|
|
/** Sets the expression context. This context is used for all expression evaluation
|
|
|
|
* associated with this map settings.
|
|
|
|
* @see expressionContext()
|
|
|
|
* @note added in QGIS 2.12
|
|
|
|
*/
|
|
|
|
void setExpressionContext( const QgsExpressionContext& context );
|
|
|
|
|
|
|
|
/** Gets the expression context. This context should be used for all expression evaluation
|
|
|
|
* associated with this map settings.
|
|
|
|
* @see setExpressionContext()
|
|
|
|
* @note added in QGIS 2.12
|
|
|
|
*/
|
|
|
|
const QgsExpressionContext& expressionContext() const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
// -- utility functions --
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! @note not available in python bindings
|
2014-06-05 20:23:34 +07:00
|
|
|
//const QgsDatumTransformStore& datumTransformStore() const;
|
|
|
|
QgsDatumTransformStore& datumTransformStore();
|
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
const QgsMapToPixel& mapToPixel() const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2015-09-12 23:04:17 +02:00
|
|
|
/** Computes an *estimated* conversion factor between layer and map units: layerUnits * layerToMapUnits = mapUnits
|
|
|
|
* @param theLayer The layer
|
|
|
|
* @param referenceExtent A reference extent based on which to perform the computation. If not specified, the layer extent is used
|
|
|
|
* @note added in QGIS 2.12
|
|
|
|
*/
|
2015-09-09 17:45:31 +02:00
|
|
|
double layerToMapUnits( QgsMapLayer* theLayer, const QgsRectangle& referenceExtent = QgsRectangle() ) const;
|
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
/**
|
|
|
|
* @brief transform bounding box from layer's CRS to output CRS
|
|
|
|
* @see layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) if you want to transform a rectangle
|
|
|
|
* @return a bounding box (aligned rectangle) containing the transformed extent
|
|
|
|
*/
|
|
|
|
QgsRectangle layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
/**
|
|
|
|
* @brief transform bounding box from output CRS to layer's CRS
|
|
|
|
* @see mapToLayerCoordinates( QgsMapLayer* theLayer,QgsRectangle rect ) if you want to transform a rectangle
|
|
|
|
* @return a bounding box (aligned rectangle) containing the transformed extent
|
|
|
|
*/
|
|
|
|
QgsRectangle outputExtentToLayerExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
/**
|
|
|
|
* @brief transform point coordinates from layer's CRS to output CRS
|
|
|
|
* @return the transformed point
|
|
|
|
*/
|
|
|
|
QgsPoint layerToMapCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
/**
|
|
|
|
* @brief transform rectangle from layer's CRS to output CRS
|
|
|
|
* @see layerExtentToOutputExtent() if you want to transform a bounding box
|
|
|
|
* @return the transformed rectangle
|
|
|
|
*/
|
|
|
|
QgsRectangle layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
/**
|
|
|
|
* @brief transform point coordinates from output CRS to layer's CRS
|
|
|
|
* @return the transformed point
|
|
|
|
*/
|
|
|
|
QgsPoint mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
/**
|
|
|
|
* @brief transform rectangle from output CRS to layer's CRS
|
|
|
|
* @see outputExtentToLayerExtent() if you want to transform a bounding box
|
|
|
|
* @return the transformed rectangle
|
|
|
|
*/
|
|
|
|
QgsRectangle mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-06-05 20:23:34 +07:00
|
|
|
/**
|
|
|
|
* @brief Return coordinate transform from layer's CRS to destination CRS
|
|
|
|
* @param layer
|
2016-07-16 20:36:45 +10:00
|
|
|
* @return transform - may be invalid if the transform is not needed
|
2014-06-05 20:23:34 +07:00
|
|
|
*/
|
2016-07-16 20:36:45 +10:00
|
|
|
QgsCoordinateTransform layerTransform( QgsMapLayer *layer ) const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
//! returns current extent of layer set
|
|
|
|
QgsRectangle fullExtent() const;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
/* serialization */
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2016-07-19 11:45:47 +10:00
|
|
|
void readXml( QDomNode& theNode );
|
2014-05-27 23:22:50 +02:00
|
|
|
|
2016-07-19 11:45:47 +10:00
|
|
|
void writeXml( QDomNode& theNode, QDomDocument& theDoc );
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2016-05-17 18:09:16 +02:00
|
|
|
/** Sets the segmentation tolerance applied when rendering curved geometries
|
|
|
|
@param tolerance the segmentation tolerance*/
|
|
|
|
void setSegmentationTolerance( double tolerance );
|
|
|
|
/** Gets the segmentation tolerance applied when rendering curved geometries*/
|
|
|
|
double segmentationTolerance() const;
|
|
|
|
/** Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)
|
|
|
|
@param type the segmentation tolerance typename*/
|
2016-08-06 11:01:42 +02:00
|
|
|
void setSegmentationToleranceType( QgsAbstractGeometry::SegmentationToleranceType type );
|
2016-05-17 18:09:16 +02:00
|
|
|
/** Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation)*/
|
2016-08-06 11:01:42 +02:00
|
|
|
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const;
|
2016-05-17 18:09:16 +02:00
|
|
|
|
|
|
|
|
2016-01-04 22:51:18 +11:00
|
|
|
protected:
|
|
|
|
|
|
|
|
void updateDerived();
|
2013-12-05 18:27:45 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
QFlags<QgsMapSettings::Flag> operator|(QgsMapSettings::Flag f1, QFlags<QgsMapSettings::Flag> f2);
|