2016-08-05 08:08:39 +02:00
|
|
|
class QgsSymbolLayer
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:08:39 +02:00
|
|
|
#include <qgssymbollayer.h>
|
2016-08-07 17:33:22 +02:00
|
|
|
#include <qgslinesymbollayer.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
%ConvertToSubClassCode
|
|
|
|
switch (sipCpp->type())
|
|
|
|
{
|
2016-08-05 08:09:43 +02:00
|
|
|
case QgsSymbol::Marker:
|
2016-10-17 10:19:19 +02:00
|
|
|
if ( sipCpp->layerType() == "EllipseMarker" )
|
|
|
|
sipType = sipType_QgsEllipseSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "FontMarker" )
|
|
|
|
sipType = sipType_QgsFontMarkerSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "SimpleMarker" )
|
|
|
|
sipType = sipType_QgsSimpleMarkerSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "FilledMarker" )
|
|
|
|
sipType = sipType_QgsFilledMarkerSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "SvgMarker" )
|
|
|
|
sipType = sipType_QgsSvgMarkerSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "VectorField" )
|
|
|
|
sipType = sipType_QgsVectorFieldSymbolLayer;
|
2012-10-02 16:19:15 +02:00
|
|
|
else
|
2016-10-17 10:19:19 +02:00
|
|
|
sipType = sipType_QgsMarkerSymbolLayer;
|
2012-10-02 16:19:15 +02:00
|
|
|
break;
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
case QgsSymbol::Line:
|
2016-10-17 10:19:19 +02:00
|
|
|
if ( sipCpp->layerType() == "MarkerLine" )
|
|
|
|
sipType = sipType_QgsMarkerLineSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "SimpleLine" )
|
|
|
|
sipType = sipType_QgsSimpleLineSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "ArrowLine" )
|
|
|
|
sipType = sipType_QgsArrowSymbolLayer;
|
2012-10-02 16:19:15 +02:00
|
|
|
else
|
2016-10-17 10:19:19 +02:00
|
|
|
sipType = sipType_QgsLineSymbolLayer;
|
2012-10-02 16:19:15 +02:00
|
|
|
break;
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
case QgsSymbol::Fill:
|
2016-10-17 10:19:19 +02:00
|
|
|
if ( sipCpp->layerType() == "SimpleFill" )
|
|
|
|
sipType = sipType_QgsSimpleFillSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "LinePatternFill" )
|
|
|
|
sipType = sipType_QgsLinePatternFillSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "PointPatternFill" )
|
|
|
|
sipType = sipType_QgsPointPatternFillSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "SVGFill" )
|
|
|
|
sipType = sipType_QgsSVGFillSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "RasterFill" )
|
|
|
|
sipType = sipType_QgsRasterFillSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "CentroidFill" )
|
|
|
|
sipType = sipType_QgsCentroidFillSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "GradientFill" )
|
|
|
|
sipType = sipType_QgsGradientFillSymbolLayer;
|
|
|
|
else if ( sipCpp->layerType() == "ShapeburstFill" )
|
|
|
|
sipType = sipType_QgsShapeburstFillSymbolLayer;
|
2012-10-02 16:19:15 +02:00
|
|
|
else
|
2016-10-17 10:19:19 +02:00
|
|
|
sipType = sipType_QgsFillSymbolLayer;
|
2012-10-02 16:19:15 +02:00
|
|
|
break;
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
case QgsSymbol::Hybrid:
|
2016-08-06 11:01:42 +02:00
|
|
|
sipType = sipType_QgsGeometryGeneratorSymbolLayer;
|
2012-09-24 02:28:15 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-01-11 10:36:51 +10:00
|
|
|
/**
|
|
|
|
* Data definable properties.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
*/
|
|
|
|
enum Property
|
|
|
|
{
|
|
|
|
PropertySize, //!< Symbol size
|
|
|
|
PropertyAngle, //!< Symbol angle
|
|
|
|
PropertyName, //!< Name, eg shape name for simple markers
|
|
|
|
PropertyFillColor, //!< Fill color
|
|
|
|
PropertyOutlineColor, //!< Outline color
|
|
|
|
PropertyOutlineWidth, //!< Outline width
|
|
|
|
PropertyOutlineStyle, //!< Outline style (eg solid, dashed)
|
|
|
|
PropertyOffset, //!< Symbol offset
|
|
|
|
PropertyCharacter, //!< Character, eg for font marker symbol layers
|
|
|
|
PropertyWidth, //!< Symbol width
|
|
|
|
PropertyHeight, //!< Symbol height
|
|
|
|
PropertyFillStyle, //!< Fill style (eg solid, dots)
|
|
|
|
PropertyJoinStyle, //!< Line join style
|
|
|
|
PropertySecondaryColor, //!< Secondary color (eg for gradient fills)
|
|
|
|
PropertyLineAngle, //!< Line angle
|
|
|
|
PropertyLineDistance, //!< Distance between lines
|
|
|
|
PropertyGradientType, //!< Gradient fill type
|
|
|
|
PropertyCoordinateMode, //!< Gradient coordinate mode
|
|
|
|
PropertyGradientSpread, //!< Gradient spread mode
|
|
|
|
PropertyGradientReference1X, //!< Gradient reference point 1 x
|
|
|
|
PropertyGradientReference1Y, //!< Gradient reference point 1 y
|
|
|
|
PropertyGradientReference2X, //!< Gradient reference point 2 x
|
|
|
|
PropertyGradientReference2Y, //!< Gradient reference point 2 y
|
|
|
|
PropertyGradientReference1IsCentroid, //!< Gradient reference point 1 is centroid
|
|
|
|
PropertyGradientReference2IsCentroid, //!< Gradient reference point 2 is centroid
|
|
|
|
PropertyBlurRadius, //!< Shapeburst blur radius
|
|
|
|
PropertyShapeburstUseWholeShape, //!< Shapeburst use whole shape
|
|
|
|
PropertyShapeburstMaxDistance, //!< Shapeburst fill from edge distance
|
|
|
|
PropertyShapeburstIgnoreRings, //!< Shapeburst ignore rings
|
|
|
|
PropertyFile, //!< Filename, eg for svg files
|
|
|
|
PropertyDistanceX, //!< Horizontal distance between points
|
|
|
|
PropertyDistanceY, //!< Vertical distance between points
|
|
|
|
PropertyDisplacementX, //!< Horizontal displacement
|
|
|
|
PropertyDisplacementY, //!< Vertical displacement
|
|
|
|
PropertyAlpha, //!< Alpha (opacity)
|
|
|
|
PropertyCustomDash, //!< Custom dash pattern
|
|
|
|
PropertyCapStyle, //!< Line cap style
|
|
|
|
PropertyPlacement, //!< Line marker placement
|
|
|
|
PropertyInterval, //!< Line marker interval
|
|
|
|
PropertyOffsetAlongLine, //!< Offset along line
|
|
|
|
PropertyHorizontalAnchor, //!< Horizontal anchor point
|
|
|
|
PropertyVerticalAnchor, //!< Vertical anchor point
|
|
|
|
PropertyLayerEnabled, //!< Whether symbol layer is enabled
|
|
|
|
PropertyArrowWidth, //!< Arrow tail width
|
|
|
|
PropertyArrowStartWidth, //!< Arrow tail start width
|
|
|
|
PropertyArrowHeadLength, //!< Arrow head length
|
|
|
|
PropertyArrowHeadThickness, //!< Arrow head thickness
|
|
|
|
PropertyArrowHeadType, //!< Arrow head type
|
|
|
|
PropertyArrowType, //!< Arrow type
|
|
|
|
};
|
|
|
|
|
2017-01-23 12:22:40 +10:00
|
|
|
static const QgsPropertiesDefinition PROPERTY_DEFINITIONS;
|
|
|
|
|
2016-08-05 08:08:39 +02:00
|
|
|
virtual ~QgsSymbolLayer();
|
2015-04-07 14:27:39 +02:00
|
|
|
|
2016-10-13 07:39:49 +10:00
|
|
|
/**
|
|
|
|
* Returns true if symbol layer is enabled and will be drawn.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
* @see setEnabled()
|
|
|
|
*/
|
|
|
|
bool enabled() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether symbol layer is enabled and should be drawn. Disabled
|
|
|
|
* layers are not drawn, but remain part of the symbol and can be re-enabled
|
|
|
|
* when desired.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
* @see enabled()
|
|
|
|
*/
|
|
|
|
void setEnabled( bool enabled );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* The fill color.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual QColor color() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* The fill color.
|
|
|
|
*/
|
2014-01-26 18:35:21 +01:00
|
|
|
virtual void setColor( const QColor& color );
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/** Set outline color. Supported by marker and fill layers.
|
|
|
|
* @note added in 2.1 */
|
2014-01-12 18:17:20 +01:00
|
|
|
virtual void setOutlineColor( const QColor& color );
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/** Get outline color. Supported by marker and fill layers.
|
|
|
|
* @note added in 2.1 */
|
2014-01-12 18:17:20 +01:00
|
|
|
virtual QColor outlineColor() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/** Set fill color. Supported by marker and fill layers.
|
|
|
|
* @note added in 2.1 */
|
2014-01-12 18:17:20 +01:00
|
|
|
virtual void setFillColor( const QColor& color );
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/** Get fill color. Supported by marker and fill layers.
|
|
|
|
* @note added in 2.1 */
|
2014-01-12 18:17:20 +01:00
|
|
|
virtual QColor fillColor() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Returns a string that represents this layer type. Used for serialization.
|
|
|
|
* Should match with the string used to register this symbol layer in the registry.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual QString layerType() const = 0;
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual void startRender( QgsSymbolRenderContext& context ) = 0;
|
|
|
|
virtual void stopRender( QgsSymbolRenderContext& context ) = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Shall be reimplemented by subclasses to create a deep copy of the instance.
|
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
virtual QgsSymbolLayer* clone() const = 0 /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-10-07 11:55:34 +11:00
|
|
|
virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2013-06-23 16:00:16 +02:00
|
|
|
virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const;
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Should be reimplemented by subclasses to return a string map that
|
|
|
|
* contains the configuration information for the symbol layer. This
|
|
|
|
* is used to serialize a symbol layer perstistently.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual QgsStringMap properties() const = 0;
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual void drawPreviewIcon( QgsSymbolRenderContext& context, QSize size ) = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual QgsSymbol* subSymbol();
|
2016-02-14 03:50:23 +01:00
|
|
|
//! set layer's subsymbol. takes ownership of the passed symbol
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual bool setSubSymbol( QgsSymbol* symbol /Transfer/ );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
QgsSymbol::SymbolType type() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-01-04 22:51:18 +11:00
|
|
|
//! Returns if the layer can be used below the specified symbol
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual bool isCompatibleWithSymbol( QgsSymbol* symbol ) const;
|
2016-01-04 22:51:18 +11:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
void setLocked( bool locked );
|
|
|
|
bool isLocked() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns the estimated maximum distance which the layer style will bleed outside
|
2016-12-30 00:01:08 +01:00
|
|
|
the drawn shape. For example, polygons drawn with an outline will draw half the width
|
2014-01-26 18:35:21 +01:00
|
|
|
of the outline outside of the polygon. This amount is estimated, since it may
|
|
|
|
be affected by data defined symbology rules.*/
|
2017-01-30 12:36:04 +10:00
|
|
|
virtual double estimateMaxBleed( const QgsRenderContext& context ) const;
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-07-18 09:42:45 +10:00
|
|
|
/** Sets the units to use for sizes and widths within the symbol layer. Individual
|
2016-12-30 00:01:08 +01:00
|
|
|
* symbol layer subclasses will interpret this in different ways, e.g., a marker symbol
|
2016-07-18 09:42:45 +10:00
|
|
|
* layer may use it to specify the units for the marker size, while a line symbol
|
|
|
|
* layer may use it to specify the units for the line width.
|
|
|
|
* @param unit output units
|
|
|
|
* @see outputUnit()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
virtual void setOutputUnit( QgsUnitTypes::RenderUnit unit );
|
2016-07-18 09:42:45 +10:00
|
|
|
|
|
|
|
/** Returns the units to use for sizes and widths within the symbol layer. Individual
|
2016-12-30 00:01:08 +01:00
|
|
|
* symbol layer subclasses will interpret this in different ways, e.g., a marker symbol
|
2016-07-18 09:42:45 +10:00
|
|
|
* layer may use it to specify the units for the marker size, while a line symbol
|
|
|
|
* layer may use it to specify the units for the line width.
|
2016-07-25 16:27:15 +10:00
|
|
|
* @returns output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol layer contains mixed units
|
2016-07-18 09:42:45 +10:00
|
|
|
* @see setOutputUnit()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
virtual QgsUnitTypes::RenderUnit outputUnit() const;
|
2014-05-07 19:02:11 +02:00
|
|
|
|
|
|
|
virtual void setMapUnitScale( const QgsMapUnitScale& scale );
|
2014-04-06 21:14:02 +02:00
|
|
|
virtual QgsMapUnitScale mapUnitScale() const;
|
2013-04-19 15:20:44 +02:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
// used only with rending with symbol levels is turned on (0 = first pass, 1 = second, ...)
|
|
|
|
void setRenderingPass( int renderingPass );
|
|
|
|
int renderingPass() const;
|
|
|
|
|
2015-05-06 18:23:07 +10:00
|
|
|
/** Returns the set of attributes referenced by the layer. This includes attributes
|
|
|
|
* required by any data defined properties associated with the layer.
|
|
|
|
*/
|
2017-01-11 10:36:51 +10:00
|
|
|
virtual QSet<QString> usedAttributes( const QgsRenderContext& context ) const;
|
2015-05-06 18:23:07 +10:00
|
|
|
|
|
|
|
/** Sets a data defined property for the layer.
|
2016-02-14 03:50:23 +01:00
|
|
|
* @param property unique property key. Any existing data defined with the same key will be deleted and overridden.
|
|
|
|
* @param dataDefined data defined object to associate with property key. Ownership is transferred to the layer.
|
2015-05-06 18:23:07 +10:00
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see getDataDefinedProperty
|
|
|
|
* @see removeDataDefinedProperty
|
|
|
|
*/
|
2017-01-18 22:47:55 +10:00
|
|
|
virtual void setDataDefinedProperty( Property key, const QgsProperty& property );
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual double dxfWidth( const QgsDxfExport& e, QgsSymbolRenderContext& context ) const;
|
|
|
|
virtual double dxfOffset( const QgsDxfExport& e, QgsSymbolRenderContext& context ) const;
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual QColor dxfColor( QgsSymbolRenderContext& context ) const;
|
|
|
|
virtual double dxfAngle( QgsSymbolRenderContext& context ) const;
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-07-17 22:11:17 +10:00
|
|
|
virtual QVector<qreal> dxfCustomDashPattern( QgsUnitTypes::RenderUnit& unit ) const;
|
2014-01-26 18:35:21 +01:00
|
|
|
virtual Qt::PenStyle dxfPenStyle() const;
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual QColor dxfBrushColor( QgsSymbolRenderContext& context ) const;
|
2014-11-21 01:17:21 +01:00
|
|
|
virtual Qt::BrushStyle dxfBrushStyle() const;
|
2013-04-19 15:20:44 +02:00
|
|
|
|
2015-03-28 20:03:37 +11:00
|
|
|
/** Returns the current paint effect for the layer.
|
|
|
|
* @returns paint effect
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see setPaintEffect
|
|
|
|
*/
|
|
|
|
QgsPaintEffect* paintEffect() const;
|
|
|
|
|
|
|
|
/** Sets the current paint effect for the layer.
|
|
|
|
* @param effect paint effect. Ownership is transferred to the layer.
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see paintEffect
|
|
|
|
*/
|
|
|
|
void setPaintEffect( QgsPaintEffect* effect /Transfer/);
|
|
|
|
|
2015-08-12 07:34:08 +10:00
|
|
|
/** Prepares all data defined property expressions for evaluation. This should
|
|
|
|
* be called prior to evaluating data defined properties.
|
|
|
|
* @param context symbol render context
|
|
|
|
* @note added in QGIS 2.12
|
|
|
|
*/
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual void prepareExpressions( const QgsSymbolRenderContext& context );
|
2015-05-06 18:23:07 +10:00
|
|
|
|
2016-10-17 15:44:19 +10:00
|
|
|
|
2017-01-11 10:36:51 +10:00
|
|
|
/** Returns a reference to the symbol layer's property collection, used for data defined overrides.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
* @see setProperties()
|
|
|
|
*/
|
|
|
|
QgsPropertyCollection& dataDefinedProperties();
|
|
|
|
|
|
|
|
/** Returns a reference to the symbol layer's property collection, used for data defined overrides.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
* @see setProperties()
|
|
|
|
*/
|
|
|
|
//const QgsPropertyCollection& dataDefinedProperties() const { return mProperties; }
|
2016-10-17 15:44:19 +10:00
|
|
|
|
2017-01-11 10:36:51 +10:00
|
|
|
/** Sets the symbol layer's property collection, used for data defined overrides.
|
|
|
|
* @param collection property collection. Existing properties will be replaced.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
* @see properties()
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2017-01-11 10:36:51 +10:00
|
|
|
void setDataDefinedProperties( const QgsPropertyCollection& collection );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QgsSymbolLayer( QgsSymbol::SymbolType type, bool locked = false );
|
2015-05-06 18:23:07 +10:00
|
|
|
|
|
|
|
/** Restores all data defined properties from string map.
|
|
|
|
* @param stringMap source string map
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see saveDataDefinedProperties
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2017-01-11 10:36:51 +10:00
|
|
|
void restoreOldDataDefinedProperties( const QgsStringMap& stringMap );
|
2015-05-06 18:23:07 +10:00
|
|
|
|
|
|
|
/** Copies all data defined properties of this layer to another symbol layer.
|
|
|
|
* @param destLayer destination layer
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
void copyDataDefinedProperties( QgsSymbolLayer* destLayer ) const;
|
2015-05-06 18:23:07 +10:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Copies paint effect of this layer to another symbol layer
|
2015-03-28 20:03:37 +11:00
|
|
|
* @param destLayer destination layer
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
void copyPaintEffect( QgsSymbolLayer* destLayer ) const;
|
2015-03-28 20:03:37 +11:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** \ingroup core
|
2016-08-06 11:01:42 +02:00
|
|
|
* \class QgsMarkerSymbolLayer
|
2016-05-05 16:58:44 +10:00
|
|
|
* \brief Abstract base class for marker symbol layers.
|
|
|
|
*/
|
2016-08-06 11:01:42 +02:00
|
|
|
class QgsMarkerSymbolLayer : QgsSymbolLayer
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:08:39 +02:00
|
|
|
#include <qgssymbollayer.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
public:
|
2014-01-27 09:22:24 +01:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
//! Symbol horizontal anchor points
|
2014-01-26 18:35:21 +01:00
|
|
|
enum HorizontalAnchorPoint
|
|
|
|
{
|
2016-05-05 16:58:44 +10:00
|
|
|
Left, /*!< Align to left side of symbol */
|
|
|
|
HCenter, /*!< Align to horizontal center of symbol */
|
|
|
|
Right, /*!< Align to right side of symbol */
|
2014-01-26 18:35:21 +01:00
|
|
|
};
|
2014-01-27 09:22:24 +01:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
//! Symbol vertical anchor points
|
2014-01-26 18:35:21 +01:00
|
|
|
enum VerticalAnchorPoint
|
|
|
|
{
|
2016-05-05 16:58:44 +10:00
|
|
|
Top, /*!< Align to top of symbol */
|
|
|
|
VCenter, /*!< Align to vertical center of symbol */
|
|
|
|
Bottom, /*!< Align to bottom of symbol */
|
2014-01-26 18:35:21 +01:00
|
|
|
};
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
void startRender( QgsSymbolRenderContext& context );
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Renders a marker at the specified point. Derived classes must implement this to
|
|
|
|
* handle drawing the point.
|
|
|
|
* @param point position at which to render point, in painter units
|
|
|
|
* @param context symbol render context
|
|
|
|
*/
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual void renderPoint( QPointF point, QgsSymbolRenderContext& context ) = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
void drawPreviewIcon( QgsSymbolRenderContext& context, QSize size );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Sets the rotation angle for the marker.
|
|
|
|
* @param angle angle in degrees clockwise from north.
|
|
|
|
* @see angle()
|
|
|
|
* @see setLineAngle()
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setAngle( double angle );
|
2016-05-05 16:58:44 +10:00
|
|
|
|
|
|
|
/** Returns the rotation angle for the marker, in degrees clockwise from north.
|
|
|
|
* @see setAngle()
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
double angle() const;
|
2015-05-24 18:48:22 +02:00
|
|
|
|
|
|
|
/** Sets the line angle modification for the symbol's angle. This angle is added to
|
|
|
|
* the marker's rotation and data defined rotation before rendering the symbol, and
|
2015-05-15 15:53:05 +07:00
|
|
|
* is usually used for orienting symbols to match a line's angle.
|
2016-05-05 16:58:44 +10:00
|
|
|
* @param lineAngle Angle in degrees clockwise from north, valid values are between 0 and 360
|
2015-05-15 15:53:05 +07:00
|
|
|
* @note added in QGIS 2.9
|
2016-05-05 16:58:44 +10:00
|
|
|
* @see setAngle()
|
|
|
|
* @see angle()
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2015-05-15 15:53:05 +07:00
|
|
|
void setLineAngle( double lineAngle );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Sets the symbol size.
|
|
|
|
* @param size symbol size. Units are specified by sizeUnit().
|
|
|
|
* @see size()
|
|
|
|
* @see setSizeUnit()
|
|
|
|
* @see setSizeMapUnitScale()
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setSize( double size );
|
2016-05-05 16:58:44 +10:00
|
|
|
|
|
|
|
/** Returns the symbol size. Units are specified by sizeUnit().
|
|
|
|
* @see setSize()
|
|
|
|
* @see sizeUnit()
|
|
|
|
* @see sizeUnitMapScale()
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
double size() const;
|
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Sets the units for the symbol's size.
|
|
|
|
* @param unit size units
|
|
|
|
* @see sizeUnit()
|
|
|
|
* @see setSize()
|
|
|
|
* @see setSizeMapUnitScale()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
void setSizeUnit( QgsUnitTypes::RenderUnit unit );
|
2016-05-05 16:58:44 +10:00
|
|
|
|
|
|
|
/** Returns the units for the symbol's size.
|
|
|
|
* @see setSizeUnit()
|
|
|
|
* @see size()
|
|
|
|
* @see sizeMapUnitScale()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
QgsUnitTypes::RenderUnit sizeUnit() const;
|
2016-05-05 16:58:44 +10:00
|
|
|
|
|
|
|
/** Sets the map unit scale for the symbol's size.
|
|
|
|
* @param scale size map unit scale
|
|
|
|
* @see sizeMapUnitScale()
|
|
|
|
* @see setSize()
|
|
|
|
* @see setSizeUnit()
|
|
|
|
*/
|
|
|
|
void setSizeMapUnitScale( const QgsMapUnitScale& scale);
|
|
|
|
|
|
|
|
/** Returns the map unit scale for the symbol's size.
|
|
|
|
* @see setSizeMapUnitScale()
|
|
|
|
* @see size()
|
|
|
|
* @see sizeUnit()
|
|
|
|
*/
|
|
|
|
const QgsMapUnitScale& sizeMapUnitScale() const;
|
|
|
|
|
|
|
|
/** Sets the method to use for scaling the marker's size.
|
|
|
|
* @param scaleMethod scale method
|
|
|
|
* @see scaleMethod()
|
|
|
|
*/
|
2016-08-05 08:09:43 +02:00
|
|
|
void setScaleMethod( QgsSymbol::ScaleMethod scaleMethod );
|
2016-05-05 16:58:44 +10:00
|
|
|
|
|
|
|
/** Returns the method to use for scaling the marker's size.
|
|
|
|
* @see setScaleMethod()
|
|
|
|
*/
|
2016-08-05 08:09:43 +02:00
|
|
|
QgsSymbol::ScaleMethod scaleMethod() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker
|
|
|
|
* should have from the original feature's geometry.
|
|
|
|
* @param offset marker offset. Units are specified by offsetUnit()
|
|
|
|
* @see offset()
|
|
|
|
* @see setOffsetUnit()
|
|
|
|
* @see setOffsetMapUnitScale()
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setOffset( QPointF offset );
|
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Returns the marker's offset, which is the horizontal and vertical displacement which the rendered marker
|
|
|
|
* will have from the original feature's geometry. Units are specified by offsetUnit().
|
|
|
|
* @see setOffset()
|
|
|
|
* @see offsetUnit()
|
|
|
|
* @see offsetMapUnitScale()
|
|
|
|
*/
|
|
|
|
QPointF offset();
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Sets the units for the symbol's offset.
|
|
|
|
* @param unit offset units
|
|
|
|
* @see offsetUnit()
|
|
|
|
* @see setOffset()
|
|
|
|
* @see setOffsetMapUnitScale()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
void setOffsetUnit( QgsUnitTypes::RenderUnit unit );
|
2016-05-05 16:58:44 +10:00
|
|
|
|
|
|
|
/** Returns the units for the symbol's offset.
|
|
|
|
* @see setOffsetUnit()
|
|
|
|
* @see offset()
|
|
|
|
* @see offsetMapUnitScale()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
QgsUnitTypes::RenderUnit offsetUnit() const;
|
2014-05-07 19:02:11 +02:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Sets the map unit scale for the symbol's offset.
|
|
|
|
* @param scale offset map unit scale
|
|
|
|
* @see offsetMapUnitScale()
|
|
|
|
* @see setOffset()
|
|
|
|
* @see setOffsetUnit()
|
|
|
|
*/
|
2014-04-06 21:14:02 +02:00
|
|
|
void setOffsetMapUnitScale( const QgsMapUnitScale& scale);
|
2016-05-05 16:58:44 +10:00
|
|
|
|
|
|
|
/** Returns the map unit scale for the symbol's offset.
|
|
|
|
* @see setOffsetMapUnitScale()
|
|
|
|
* @see offset()
|
|
|
|
* @see offsetUnit()
|
|
|
|
*/
|
2014-04-06 21:14:02 +02:00
|
|
|
const QgsMapUnitScale& offsetMapUnitScale() const;
|
2013-04-19 15:20:44 +02:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Sets the horizontal anchor point for positioning the symbol.
|
|
|
|
* @param h anchor point. Symbol will be drawn so that the horizontal anchor point is aligned with
|
|
|
|
* the marker's desired location.
|
|
|
|
* @see horizontalAnchorPoint()
|
|
|
|
* @see setVerticalAnchorPoint()
|
|
|
|
*/
|
|
|
|
void setHorizontalAnchorPoint( HorizontalAnchorPoint h );
|
2014-05-07 19:02:11 +02:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Returns the horizontal anchor point for positioning the symbol. The symbol will be drawn so that
|
|
|
|
* the horizontal anchor point is aligned with the marker's desired location.
|
|
|
|
* @see setHorizontalAnchorPoint()
|
|
|
|
* @see verticalAnchorPoint()
|
|
|
|
*/
|
|
|
|
HorizontalAnchorPoint horizontalAnchorPoint() const;
|
|
|
|
|
|
|
|
/** Sets the vertical anchor point for positioning the symbol.
|
|
|
|
* @param v anchor point. Symbol will be drawn so that the vertical anchor point is aligned with
|
|
|
|
* the marker's desired location.
|
|
|
|
* @see verticalAnchorPoint()
|
|
|
|
* @see setHorizontalAnchorPoint()
|
|
|
|
*/
|
|
|
|
void setVerticalAnchorPoint( VerticalAnchorPoint v );
|
|
|
|
|
|
|
|
/** Returns the vertical anchor point for positioning the symbol. The symbol will be drawn so that
|
|
|
|
* the vertical anchor point is aligned with the marker's desired location.
|
|
|
|
* @see setVerticalAnchorPoint()
|
|
|
|
* @see horizontalAnchorPoint()
|
|
|
|
*/
|
|
|
|
VerticalAnchorPoint verticalAnchorPoint() const;
|
|
|
|
|
|
|
|
virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
|
|
|
|
|
|
|
|
/** Writes the symbol layer definition as a SLD XML element.
|
|
|
|
* @param doc XML document
|
|
|
|
* @param element parent XML element
|
|
|
|
* @param props symbol layer definition (see properties())
|
|
|
|
*/
|
|
|
|
virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
|
2013-04-19 15:20:44 +02:00
|
|
|
|
2016-07-17 22:11:17 +10:00
|
|
|
void setOutputUnit( QgsUnitTypes::RenderUnit unit );
|
|
|
|
QgsUnitTypes::RenderUnit outputUnit() const;
|
2014-05-07 19:02:11 +02:00
|
|
|
|
|
|
|
void setMapUnitScale( const QgsMapUnitScale& scale );
|
2014-04-06 21:14:02 +02:00
|
|
|
QgsMapUnitScale mapUnitScale() const;
|
2013-04-19 15:20:44 +02:00
|
|
|
|
2015-11-20 19:16:15 +11:00
|
|
|
/** Returns the approximate bounding box of the marker symbol layer, taking into account
|
|
|
|
* any data defined overrides and offsets which are set for the marker layer.
|
|
|
|
* @returns approximate symbol bounds, in painter units
|
|
|
|
* @note added in QGIS 2.14
|
|
|
|
*/
|
2016-09-14 08:51:17 +10:00
|
|
|
virtual QRectF bounds( QPointF point, QgsSymbolRenderContext& context ) = 0;
|
2015-11-20 19:16:15 +11:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
protected:
|
2016-05-05 16:58:44 +10:00
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
/** Constructor for QgsMarkerSymbolLayer.
|
2016-05-05 16:58:44 +10:00
|
|
|
* @param locked set to true to lock symbol color
|
|
|
|
*/
|
2016-08-06 11:01:42 +02:00
|
|
|
QgsMarkerSymbolLayer( bool locked = false );
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Calculates the required marker offset, including both the symbol offset
|
|
|
|
* and any displacement required to align with the marker's anchor point.
|
|
|
|
* @param context symbol render context
|
|
|
|
* @param offsetX will be set to required horizontal offset (in painter units)
|
|
|
|
* @param offsetY will be set to required vertical offset (in painter units)
|
|
|
|
*/
|
2016-08-05 08:09:43 +02:00
|
|
|
void markerOffset( QgsSymbolRenderContext& context, double& offsetX, double& offsetY ) const;
|
2014-01-27 09:22:24 +01:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Calculates the required marker offset, including both the symbol offset
|
|
|
|
* and any displacement required to align with the marker's anchor point.
|
|
|
|
* @param context symbol render context
|
|
|
|
* @param width marker width
|
|
|
|
* @param height marker height
|
|
|
|
* @param offsetX will be set to required horizontal offset (in painter units)
|
|
|
|
* @param offsetY will be set to required vertical offset (in painter units)
|
|
|
|
* @note available in python as markerOffsetWithWidthAndHeight
|
|
|
|
*/
|
2016-08-05 08:09:43 +02:00
|
|
|
void markerOffset( QgsSymbolRenderContext& context, double width, double height, double& offsetX, double& offsetY ) const /PyName=markerOffsetWithWidthAndHeight/;
|
2014-11-21 01:17:21 +01:00
|
|
|
|
2014-01-27 09:22:24 +01:00
|
|
|
//! @note available in python bindings as markerOffset2
|
2016-08-05 08:09:43 +02:00
|
|
|
void markerOffset( QgsSymbolRenderContext& context, double width, double height,
|
2016-07-17 22:11:17 +10:00
|
|
|
QgsUnitTypes::RenderUnit widthUnit, QgsUnitTypes::RenderUnit heightUnit,
|
2014-04-06 21:14:02 +02:00
|
|
|
double& offsetX, double& offsetY,
|
2014-05-07 19:02:11 +02:00
|
|
|
const QgsMapUnitScale &widthMapUnitScale, const QgsMapUnitScale &heightMapUnitScale ) const /PyName=markerOffset2/;
|
2014-01-27 09:22:24 +01:00
|
|
|
|
2016-05-05 16:58:44 +10:00
|
|
|
/** Adjusts a marker offset to account for rotation.
|
|
|
|
* @param offset offset prior to rotation
|
|
|
|
* @param angle rotation angle in degrees clockwise from north
|
|
|
|
* @return adjusted offset
|
|
|
|
*/
|
2016-02-02 19:46:18 +11:00
|
|
|
static QPointF _rotatedOffset( QPointF offset, double angle );
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
class QgsLineSymbolLayer : QgsSymbolLayer
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:08:39 +02:00
|
|
|
#include <qgssymbollayer.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual void renderPolyline( const QPolygonF& points, QgsSymbolRenderContext& context ) = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual void renderPolygonOutline( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolRenderContext& context );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
virtual void setWidth( double width );
|
|
|
|
virtual double width() const;
|
|
|
|
|
2015-01-23 09:08:51 +01:00
|
|
|
double offset() const;
|
|
|
|
void setOffset( double offset );
|
|
|
|
|
2016-07-18 09:42:45 +10:00
|
|
|
/** Sets the units for the line's width.
|
|
|
|
* @param unit width units
|
|
|
|
* @see widthUnit()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
void setWidthUnit( QgsUnitTypes::RenderUnit unit );
|
2016-07-18 09:42:45 +10:00
|
|
|
|
|
|
|
/** Returns the units for the line's width.
|
|
|
|
* @see setWidthUnit()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
QgsUnitTypes::RenderUnit widthUnit() const;
|
2014-05-07 19:02:11 +02:00
|
|
|
|
2014-04-06 21:14:02 +02:00
|
|
|
void setWidthMapUnitScale( const QgsMapUnitScale& scale);
|
|
|
|
const QgsMapUnitScale& widthMapUnitScale() const;
|
2013-04-19 15:20:44 +02:00
|
|
|
|
2016-07-18 09:42:45 +10:00
|
|
|
/** Sets the units for the line's offset.
|
|
|
|
* @param unit offset units
|
|
|
|
* @see offsetUnit()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
void setOffsetUnit( QgsUnitTypes::RenderUnit unit );
|
2016-07-18 09:42:45 +10:00
|
|
|
|
|
|
|
/** Returns the units for the line's offset.
|
|
|
|
* @see setOffsetUnit()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
QgsUnitTypes::RenderUnit offsetUnit() const;
|
2015-01-23 09:08:51 +01:00
|
|
|
|
|
|
|
void setOffsetMapUnitScale( const QgsMapUnitScale& scale );
|
|
|
|
const QgsMapUnitScale& offsetMapUnitScale() const;
|
|
|
|
|
2016-07-17 22:11:17 +10:00
|
|
|
void setOutputUnit( QgsUnitTypes::RenderUnit unit );
|
|
|
|
QgsUnitTypes::RenderUnit outputUnit() const;
|
2014-05-07 19:02:11 +02:00
|
|
|
|
|
|
|
void setMapUnitScale( const QgsMapUnitScale& scale );
|
|
|
|
QgsMapUnitScale mapUnitScale() const;
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
void drawPreviewIcon( QgsSymbolRenderContext& context, QSize size );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual double dxfWidth( const QgsDxfExport& e, QgsSymbolRenderContext& context ) const;
|
|
|
|
virtual double dxfOffset( const QgsDxfExport& e, QgsSymbolRenderContext& context ) const;
|
2014-01-27 09:22:24 +01:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
protected:
|
2016-08-06 11:01:42 +02:00
|
|
|
QgsLineSymbolLayer( bool locked = false );
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
class QgsFillSymbolLayer : QgsSymbolLayer
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:08:39 +02:00
|
|
|
#include <qgssymbollayer.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolRenderContext& context ) = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
void drawPreviewIcon( QgsSymbolRenderContext& context, QSize size );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
void setAngle( double angle );
|
|
|
|
double angle() const;
|
|
|
|
|
|
|
|
protected:
|
2016-08-06 11:01:42 +02:00
|
|
|
QgsFillSymbolLayer( bool locked = false );
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Default method to render polygon*/
|
2016-08-05 08:09:43 +02:00
|
|
|
void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings, QgsSymbolRenderContext& context );
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|