2008-05-15 08:13:05 +00:00
class QgsRenderContext
{
%TypeHeaderCode
#include <qgsrendercontext.h>
%End
2012-09-24 02:28:15 +02:00
public:
QgsRenderContext();
2017-05-01 16:42:33 +02:00
QgsRenderContext( const QgsRenderContext &rh );
2012-09-24 02:28:15 +02:00
~QgsRenderContext();
2008-05-15 08:13:05 +00:00
2016-02-14 03:50:23 +01:00
/** Enumeration of flags that affect rendering operations.
* @note added in QGIS 2.14
*/
2015-11-14 14:00:59 +11:00
enum Flag
{
2016-02-14 03:50:23 +01: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
2015-11-14 14:00:59 +11:00
UseRenderingOptimization, //!< Enable vector simplification and other rendering optimizations
2016-02-14 03:50:23 +01:00
DrawSelection, //!< Whether vector selections should be shown in the rendered map
DrawSymbolBounds, //!< Draw bounds of symbols (for debugging/testing)
2016-06-07 10:07:23 +10:00
RenderMapTile, //!< Draw map such that there are no problems between adjacent tiles
Antialiasing, //!< Use antialiasing while drawing
2016-09-09 17:01:02 +08:00
RenderPartialOutput, //!< Whether to make extra effort to update map image with partially rendered layers (better for interactive map canvas). Added in QGIS 3.0
2015-11-14 14:00:59 +11:00
};
typedef QFlags<QgsRenderContext::Flag> Flags;
2016-02-14 03:50:23 +01:00
/** Set combination of flags that will be used for rendering.
* @note added in QGIS 2.14
*/
2016-10-24 09:34:13 +10:00
void setFlags( QgsRenderContext::Flags flags );
2016-02-14 03:50:23 +01:00
/** Enable or disable a particular flag (other flags are not affected)
* @note added in QGIS 2.14
*/
2015-11-14 14:00:59 +11:00
void setFlag( Flag flag, bool on = true );
2016-02-14 03:50:23 +01:00
/** Return combination of flags used for rendering.
* @note added in QGIS 2.14
*/
2015-11-14 14:00:59 +11:00
Flags flags() const;
2016-02-14 03:50:23 +01:00
/** Check whether a particular flag is enabled.
* @note added in QGIS 2.14
*/
2015-11-14 14:00:59 +11:00
bool testFlag( Flag flag ) const;
2013-12-05 18:27:45 +07:00
//! create initialized QgsRenderContext instance from given QgsMapSettings
2014-02-21 17:33:09 +07:00
//! @note added in 2.4
2017-05-01 16:42:33 +02:00
static QgsRenderContext fromMapSettings( const QgsMapSettings &mapSettings );
2013-12-05 18:27:45 +07:00
2017-01-15 19:19:51 +10:00
/**
* Creates a default render context given a pixel based QPainter destination.
* If no painter is specified or the painter has no device, then a default
* DPI of 88 will be assumed.
* @note added in QGIS 3.0
*/
2017-05-01 16:42:33 +02:00
static QgsRenderContext fromQPainter( QPainter *painter );
2017-01-15 19:19:51 +10:00
2012-09-24 02:28:15 +02:00
//getters
2008-05-15 08:13:05 +00:00
2017-05-01 16:42:33 +02:00
QPainter *painter();
2008-05-15 08:13:05 +00:00
2016-07-16 20:36:45 +10:00
/** Returns the current coordinate transform for the context, or an invalid
* transform is no coordinate transformation is required.
*/
QgsCoordinateTransform coordinateTransform() const;
2008-05-15 08:13:05 +00:00
2017-05-01 16:42:33 +02:00
const QgsRectangle &extent() const;
2008-05-15 08:13:05 +00:00
2017-05-01 16:42:33 +02:00
const QgsMapToPixel &mapToPixel() const;
2008-05-15 08:13:05 +00:00
2012-09-24 02:28:15 +02:00
double scaleFactor() const;
2008-05-15 08:13:05 +00:00
2012-09-24 02:28:15 +02:00
bool renderingStopped() const;
2008-05-15 08:13:05 +00:00
2012-09-24 02:28:15 +02:00
bool forceVectorOutput() const;
2008-05-15 08:13:05 +00:00
2016-02-14 03:50:23 +01:00
/** Returns true if advanced effects such as blend modes such be used
*/
2014-01-26 18:35:21 +01:00
bool useAdvancedEffects() const;
2015-11-14 14:00:59 +11:00
2016-02-14 03:50:23 +01:00
/** Used to enable or disable advanced effects such as blend modes
*/
2014-01-26 18:35:21 +01:00
void setUseAdvancedEffects( bool enabled );
2012-09-24 02:28:15 +02:00
bool drawEditingInformation() const;
2008-11-17 16:04:30 +00:00
2012-09-24 02:28:15 +02:00
double rendererScale() const;
2009-11-18 18:46:12 +00:00
2016-02-14 03:50:23 +01:00
//! Get access to new labeling engine (may be nullptr)
//! @note not available in Python bindings
2017-05-01 16:42:33 +02:00
// QgsLabelingEngine *labelingEngine() const;
2016-02-14 03:50:23 +01:00
2013-04-12 00:35:21 +02:00
QColor selectionColor() const;
2014-06-02 21:00:51 +02:00
2015-07-29 11:52:14 +02:00
/** Returns true if vector selections should be shown in the rendered map
2014-06-02 16:37:06 +10:00
* @returns true if selections should be shown
* @see setShowSelection
* @see selectionColor
* @note Added in QGIS v2.4
2016-02-14 03:50:23 +01:00
*/
2014-06-02 16:37:06 +10:00
bool showSelection() const;
2013-04-12 00:35:21 +02:00
2012-09-24 02:28:15 +02:00
//setters
2016-07-16 20:36:45 +10:00
/** Sets coordinate transformation.*/
2017-05-01 16:42:33 +02:00
void setCoordinateTransform( const QgsCoordinateTransform &t );
2016-07-16 20:36:45 +10:00
2017-05-01 16:42:33 +02:00
void setMapToPixel( const QgsMapToPixel &mtp );
void setExtent( const QgsRectangle &extent );
2015-11-14 14:00:59 +11:00
2012-09-24 02:28:15 +02:00
void setDrawEditingInformation( bool b );
2015-11-14 14:00:59 +11:00
2012-09-24 02:28:15 +02:00
void setRenderingStopped( bool stopped );
void setScaleFactor( double factor );
void setRendererScale( double scale );
2017-05-01 16:42:33 +02:00
void setPainter( QPainter *p );
2015-11-14 14:00:59 +11:00
2012-09-24 02:28:15 +02:00
void setForceVectorOutput( bool force );
2015-11-14 14:00:59 +11:00
2016-02-14 03:50:23 +01:00
//! Assign new labeling engine
//! @note not available in Python bindings
2017-05-01 16:42:33 +02:00
// void setLabelingEngine( QgsLabelingEngine *engine2 );
void setSelectionColor( const QColor &color );
2014-06-02 21:00:51 +02:00
2015-07-29 11:52:14 +02:00
/** Sets whether vector selections should be shown in the rendered map
2014-06-02 16:37:06 +10:00
* @param showSelection set to true if selections should be shown
* @see showSelection
* @see setSelectionColor
* @note Added in QGIS v2.4
2016-02-14 03:50:23 +01:00
*/
2014-06-02 16:37:06 +10:00
void setShowSelection( const bool showSelection );
2014-01-26 18:35:21 +01:00
2016-02-14 03:50:23 +01:00
/** Returns true if the rendering optimization (geometry simplification) can be executed
*/
2014-01-26 18:35:21 +01:00
bool useRenderingOptimization() const;
2015-11-14 14:00:59 +11:00
2014-01-26 18:35:21 +01:00
void setUseRenderingOptimization( bool enabled );
2014-05-26 17:30:41 +02:00
//! Added in QGIS v2.4
2017-05-01 16:42:33 +02:00
const QgsVectorSimplifyMethod &vectorSimplifyMethod() const;
void setVectorSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod );
2015-09-04 17:23:41 +02:00
2015-11-14 14:00:59 +11:00
/** Sets the expression context. This context is used for all expression evaluation
* associated with this render context.
* @see expressionContext()
* @note added in QGIS 2.12
*/
2017-05-01 16:42:33 +02:00
void setExpressionContext( const QgsExpressionContext &context );
2015-11-14 14:00:59 +11:00
/** Gets the expression context. This context should be used for all expression evaluation
* associated with this render context.
* @see setExpressionContext()
* @note added in QGIS 2.12
*/
2017-05-01 16:42:33 +02:00
QgsExpressionContext &expressionContext();
2015-11-14 14:00:59 +11:00
/** Gets the expression context (const version). This context should be used for all expression evaluation
* associated with this render context.
* @see setExpressionContext()
* @note added in QGIS 2.12
* @note not available in Python bindings
*/
2017-05-01 16:42:33 +02:00
//const QgsExpressionContext &expressionContext() const;
2015-11-14 14:00:59 +11:00
2016-02-14 03:50:23 +01:00
/** Returns pointer to the unsegmentized geometry*/
2017-05-01 16:42:33 +02:00
const QgsAbstractGeometry *geometry() const;
2016-02-14 03:50:23 +01:00
/** Sets pointer to original (unsegmentized) geometry*/
2017-05-01 16:42:33 +02:00
void setGeometry( const QgsAbstractGeometry *geometry );
2015-11-20 10:38:34 +11:00
/** Set a filter feature provider used for additional filtering of rendered features.
* @param ffp the filter feature provider
* @note added in QGIS 2.14
* @see featureFilterProvider()
*/
2017-05-01 16:42:33 +02:00
void setFeatureFilterProvider( const QgsFeatureFilterProvider *ffp );
2015-11-20 10:38:34 +11:00
/** Get the filter feature provider used for additional filtering of rendered features.
* @return the filter feature provider
* @note added in QGIS 2.14
* @see setFeatureFilterProvider()
*/
2017-05-01 16:42:33 +02:00
const QgsFeatureFilterProvider *featureFilterProvider() const;
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;
2017-01-22 18:08:59 +10:00
2017-05-01 16:42:33 +02:00
double convertToPainterUnits( double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale = QgsMapUnitScale() ) const;
double convertToMapUnits( double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale = QgsMapUnitScale() ) const;
2017-01-22 18:08:59 +10:00
double convertFromMapUnits( double sizeInMapUnits, QgsUnitTypes::RenderUnit outputUnit ) const;
2008-05-15 08:13:05 +00:00
};