2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:08:39 +02:00
|
|
|
typedef QList<QgsSymbolLayer*> QgsSymbolLayerList;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
class QgsSymbol
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:09:43 +02:00
|
|
|
#include <qgssymbol.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
%ConvertToSubClassCode
|
|
|
|
switch (sipCpp->type())
|
|
|
|
{
|
2016-08-06 11:01:42 +02:00
|
|
|
case QgsSymbol::Marker: sipType = sipType_QgsMarkerSymbol; break;
|
|
|
|
case QgsSymbol::Line: sipType = sipType_QgsLineSymbol; break;
|
|
|
|
case QgsSymbol::Fill: sipType = sipType_QgsFillSymbol; break;
|
2015-10-20 18:09:33 +02:00
|
|
|
default: sipType = 0; break;
|
2012-09-24 02:28:15 +02:00
|
|
|
}
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-01-13 07:49:36 +11:00
|
|
|
/**
|
|
|
|
* Type of the symbol
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
enum SymbolType
|
|
|
|
{
|
2016-01-13 07:49:36 +11:00
|
|
|
Marker, //!< Marker symbol
|
|
|
|
Line, //!< Line symbol
|
|
|
|
Fill, //!< Fill symbol
|
|
|
|
Hybrid //!< Hybrid symbol
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
2016-01-13 07:49:36 +11:00
|
|
|
/**
|
|
|
|
* Scale method
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
enum ScaleMethod
|
|
|
|
{
|
2016-01-13 07:49:36 +11:00
|
|
|
ScaleArea, //!< Calculate scale by the area
|
|
|
|
ScaleDiameter //!< Calculate scale by the diameter
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
2016-09-14 08:49:12 +10:00
|
|
|
//! Flags controlling behaviour of symbols during rendering
|
2012-09-24 02:28:15 +02:00
|
|
|
enum RenderHint
|
|
|
|
{
|
2016-09-14 08:49:12 +10:00
|
|
|
DynamicRotation, //!< Rotation of symbol may be changed during rendering and symbol should not be cached
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
2016-09-14 08:49:12 +10:00
|
|
|
typedef QFlags<QgsSymbol::RenderHint> RenderHints;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual ~QgsSymbol();
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! return new default symbol for specified geometry type
|
2016-08-05 08:09:43 +02:00
|
|
|
static QgsSymbol* defaultSymbol( QgsWkbTypes::GeometryType geomType ) /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
SymbolType type() const;
|
|
|
|
|
|
|
|
// symbol layers handling
|
2014-11-30 10:26:17 +01:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns list of symbol layers contained in the symbol.
|
2014-11-24 20:44:33 +11:00
|
|
|
* @returns symbol layers list
|
|
|
|
* @note added in QGIS 2.7
|
|
|
|
* @see symbolLayer
|
|
|
|
* @see symbolLayerCount
|
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
QgsSymbolLayerList symbolLayers();
|
2014-11-24 20:44:33 +11:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns a specific symbol layers contained in the symbol.
|
2014-11-24 20:44:33 +11:00
|
|
|
* @param layer layer number
|
|
|
|
* @returns corresponding symbol layer
|
|
|
|
* @note added in QGIS 2.7
|
|
|
|
* @see symbolLayers
|
|
|
|
* @see symbolLayerCount
|
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
QgsSymbolLayer* symbolLayer( int layer );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns total number of symbol layers contained in the symbol.
|
2014-11-24 20:44:33 +11:00
|
|
|
* @returns count of symbol layers
|
|
|
|
* @note added in QGIS 2.7
|
|
|
|
* @see symbolLayers
|
|
|
|
* @see symbolLayer
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
int symbolLayerCount();
|
|
|
|
|
2016-01-28 10:30:06 +01:00
|
|
|
/**
|
|
|
|
* Insert symbol layer to specified index
|
|
|
|
* Ownership will be transferred.
|
|
|
|
* @param index The index at which the layer should be added
|
|
|
|
* @param layer The symbol layer to add
|
|
|
|
* @return True if the layer is added, False if the index or the layer is bad
|
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
bool insertSymbolLayer( int index, QgsSymbolLayer* layer /Transfer/ );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-01-28 10:30:06 +01:00
|
|
|
/**
|
|
|
|
* Append symbol layer at the end of the list
|
|
|
|
* Ownership will be transferred.
|
|
|
|
* @param layer The layer to add
|
|
|
|
* @return True if the layer is added, False if the layer is bad
|
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
bool appendSymbolLayer( QgsSymbolLayer* layer /Transfer/ );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! delete symbol layer at specified index
|
|
|
|
bool deleteSymbolLayer( int index );
|
|
|
|
|
2016-01-28 10:30:06 +01:00
|
|
|
/**
|
|
|
|
* Remove symbol layer from the list and return pointer to it.
|
|
|
|
* Ownership is handed to the caller.
|
|
|
|
* @param index The index of the layer to remove
|
|
|
|
* @return A pointer to the removed layer
|
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
QgsSymbolLayer* takeSymbolLayer( int index ) /TransferBack/;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! delete layer at specified index and set a new one
|
2016-08-05 08:08:39 +02:00
|
|
|
bool changeSymbolLayer( int index, QgsSymbolLayer *layer /Transfer/ );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-02 13:26:51 +10:00
|
|
|
/** Begins the rendering process for the symbol. This must be called before renderFeature(),
|
|
|
|
* and should be followed by a call to stopRender().
|
|
|
|
* @param context render context which symbol will be drawn using
|
|
|
|
* @param fields fields for features to be rendered (usually the associated
|
|
|
|
* vector layer's fields). Required for correct calculation of data defined
|
|
|
|
* overrides.
|
|
|
|
* @see stopRender()
|
|
|
|
*/
|
2016-08-02 10:43:15 +10:00
|
|
|
void startRender( QgsRenderContext& context, const QgsFields& fields = QgsFields() );
|
2016-08-02 13:26:51 +10:00
|
|
|
|
|
|
|
/** Ends the rendering process. This should be called after rendering all desired features.
|
|
|
|
* @param context render context, must match the context specified when startRender()
|
|
|
|
* was called.
|
|
|
|
* @see startRender()
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void stopRender( QgsRenderContext& context );
|
|
|
|
|
|
|
|
void setColor( const QColor& color );
|
2014-01-26 18:35:21 +01:00
|
|
|
QColor color() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2014-08-25 21:17:38 +07:00
|
|
|
//! Draw icon of the symbol that occupyies area given by size using the painter.
|
|
|
|
//! Optionally custom context may be given in order to get rendering of symbols that use map units right.
|
|
|
|
//! @note customContext parameter added in 2.6
|
|
|
|
void drawPreviewIcon( QPainter* painter, QSize size, QgsRenderContext* customContext = 0 );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-07 21:59:22 +10:00
|
|
|
//! export symbol as image format. PNG and SVG supported
|
2016-02-02 19:46:18 +11:00
|
|
|
void exportImage( const QString& path, const QString& format, QSize size );
|
2015-07-07 21:59:22 +10:00
|
|
|
|
|
|
|
//! Generate symbol as image
|
2014-09-19 21:21:04 +10:00
|
|
|
QImage asImage( QSize size, QgsRenderContext* customContext = 0 );
|
|
|
|
|
2015-09-03 22:46:37 +10:00
|
|
|
/** Returns a large (roughly 100x100 pixel) preview image for the symbol.
|
|
|
|
* @param expressionContext optional expression context, for evaluation of
|
|
|
|
* data defined symbol properties
|
|
|
|
*/
|
|
|
|
QImage bigSymbolPreviewImage( QgsExpressionContext* expressionContext = 0 );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2013-07-22 21:41:44 +02:00
|
|
|
QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
virtual QgsSymbol* clone() const = 0 /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
|
|
|
|
|
2016-07-18 09:42:45 +10:00
|
|
|
/** Returns the units to use for sizes and widths within the symbol. Individual
|
|
|
|
* symbol layer definitions will interpret this in different ways, eg a marker symbol
|
|
|
|
* may use it to specify the units for the marker size, while a line symbol
|
|
|
|
* 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 contains mixed units
|
2016-07-18 09:42:45 +10:00
|
|
|
* @see setOutputUnit()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
QgsUnitTypes::RenderUnit outputUnit() const;
|
2016-07-18 09:42:45 +10:00
|
|
|
|
|
|
|
/** Sets the units to use for sizes and widths within the symbol. Individual
|
|
|
|
* symbol definitions will interpret this in different ways, eg a marker symbol
|
|
|
|
* may use it to specify the units for the marker size, while a line symbol
|
|
|
|
* may use it to specify the units for the line width.
|
|
|
|
* @param unit output units
|
|
|
|
* @see outputUnit()
|
|
|
|
*/
|
2016-07-26 09:24:14 +10:00
|
|
|
void setOutputUnit( QgsUnitTypes::RenderUnit unit );
|
2014-05-07 19:02:11 +02:00
|
|
|
|
2014-04-06 21:14:02 +02:00
|
|
|
QgsMapUnitScale mapUnitScale() const;
|
|
|
|
void setMapUnitScale( const QgsMapUnitScale& scale );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! Get alpha transparency 1 for opaque, 0 for invisible
|
|
|
|
qreal alpha() const;
|
|
|
|
//! Set alpha transparency 1 for opaque, 0 for invisible
|
|
|
|
void setAlpha( qreal alpha );
|
|
|
|
|
2016-09-14 08:49:12 +10:00
|
|
|
/** Sets rendering hint flags for the symbol.
|
|
|
|
* @see renderHints()
|
|
|
|
*/
|
|
|
|
void setRenderHints( RenderHints hints );
|
|
|
|
|
|
|
|
/** Returns the rendering hint flags for the symbol.
|
|
|
|
* @see setRenderHints()
|
|
|
|
*/
|
|
|
|
RenderHints renderHints() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Sets whether features drawn by the symbol should be clipped to the render context's
|
2015-03-24 23:01:25 +11:00
|
|
|
* extent. If this option is enabled then features which are partially outside the extent
|
|
|
|
* will be clipped. This speeds up rendering of the feature, but may have undesirable
|
|
|
|
* side effects for certain symbol types.
|
|
|
|
* @param clipFeaturesToExtent set to true to enable clipping (defaults to true)
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see clipFeaturesToExtent
|
|
|
|
*/
|
|
|
|
void setClipFeaturesToExtent( bool clipFeaturesToExtent );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns whether features drawn by the symbol will be clipped to the render context's
|
2015-03-24 23:01:25 +11:00
|
|
|
* extent. If this option is enabled then features which are partially outside the extent
|
|
|
|
* will be clipped. This speeds up rendering of the feature, but may have undesirable
|
|
|
|
* side effects for certain symbol types.
|
|
|
|
* @returns true if features will be clipped
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see setClipFeaturesToExtent
|
|
|
|
*/
|
2015-10-05 18:43:18 +11:00
|
|
|
bool clipFeaturesToExtent() const;
|
2015-03-24 23:01:25 +11:00
|
|
|
|
2015-12-04 13:20:23 +01:00
|
|
|
/**
|
|
|
|
* Return a list of attributes required to render this feature.
|
|
|
|
* This should include any attributes required by the symbology including
|
|
|
|
* the ones required by expressions.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
QSet<QString> usedAttributes() const;
|
|
|
|
|
2015-11-04 16:03:46 +11:00
|
|
|
/** Returns whether the symbol utilises any data defined properties.
|
|
|
|
* @note added in QGIS 2.12
|
|
|
|
*/
|
|
|
|
bool hasDataDefinedProperties() const;
|
|
|
|
|
2016-01-28 10:30:06 +01:00
|
|
|
//! @note the layer will be NULL after stopRender
|
2014-01-26 18:35:21 +01:00
|
|
|
void setLayer( const QgsVectorLayer* layer );
|
|
|
|
const QgsVectorLayer* layer() const;
|
|
|
|
|
2015-12-04 13:20:23 +01:00
|
|
|
/**
|
2016-08-02 13:26:51 +10:00
|
|
|
* Render a feature. Before calling this the startRender() method should be called to initialise
|
|
|
|
* the rendering process. After rendering all features stopRender() must be called.
|
2015-12-04 13:20:23 +01:00
|
|
|
*/
|
|
|
|
void renderFeature( const QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false, int currentVertexMarkerType = 0, int currentVertexMarkerSize = 0 );
|
|
|
|
|
2016-01-08 13:42:53 +01:00
|
|
|
/**
|
|
|
|
* Returns the symbol render context. Only valid between startRender and stopRender calls.
|
|
|
|
*
|
|
|
|
* @return The symbol render context
|
|
|
|
*/
|
2016-08-05 08:09:43 +02:00
|
|
|
QgsSymbolRenderContext* symbolRenderContext();
|
2016-01-08 13:42:53 +01:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
protected:
|
2016-08-05 08:09:43 +02:00
|
|
|
QgsSymbol( SymbolType type, const QgsSymbolLayerList& layers /Transfer/ ); // can't be instantiated
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-12-04 13:20:23 +01:00
|
|
|
/**
|
2016-01-28 10:30:06 +01:00
|
|
|
* Creates a point in screen coordinates from a QgsPointV2 in map coordinates
|
2015-12-04 13:20:23 +01:00
|
|
|
*/
|
2016-08-21 18:21:01 +02:00
|
|
|
static QPointF _getPoint( QgsRenderContext& context, const QgsPointV2& point );
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2016-02-17 11:04:24 +01:00
|
|
|
/**
|
2016-08-21 18:21:01 +02:00
|
|
|
* Creates a line string in screen coordinates from a QgsCurve in map
|
2016-02-17 11:04:24 +01:00
|
|
|
* coordinates
|
|
|
|
*/
|
2016-08-21 18:21:01 +02:00
|
|
|
static QPolygonF _getLineString( QgsRenderContext& context, const QgsCurve& curve, bool clipToExtent = true );
|
2016-02-17 11:04:24 +01:00
|
|
|
|
2015-12-04 13:20:23 +01:00
|
|
|
/**
|
2016-08-21 18:21:01 +02:00
|
|
|
* Creates a polygon ring in screen coordinates from a QgsCurve in map
|
2015-12-04 13:20:23 +01:00
|
|
|
* coordinates
|
|
|
|
*/
|
2016-08-21 18:21:01 +02:00
|
|
|
static QPolygonF _getPolygonRing( QgsRenderContext& context, const QgsCurve& curve, bool clipToExtent );
|
2016-01-28 10:30:06 +01:00
|
|
|
|
2015-12-04 13:20:23 +01:00
|
|
|
/**
|
2016-08-21 18:21:01 +02:00
|
|
|
* Creates a polygon in screen coordinates from a QgsPolygonV2 in map
|
2015-12-04 13:20:23 +01:00
|
|
|
* coordinates
|
|
|
|
*/
|
2016-08-21 18:21:01 +02:00
|
|
|
static void _getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const QgsPolygonV2& polygon, bool clipToExtent = true );
|
2015-12-04 13:20:23 +01:00
|
|
|
|
2016-01-28 10:30:06 +01:00
|
|
|
/**
|
|
|
|
* Retrieve a cloned list of all layers that make up this symbol.
|
|
|
|
* Ownership is transferred to the caller.
|
|
|
|
*/
|
2016-08-05 08:08:39 +02:00
|
|
|
QgsSymbolLayerList cloneLayers() const /Factory/;
|
2016-01-28 10:30:06 +01:00
|
|
|
|
2015-12-04 13:20:23 +01:00
|
|
|
/**
|
|
|
|
* Renders a context using a particular symbol layer without passing in a
|
|
|
|
* geometry. This is used as fallback, if the symbol being rendered is not
|
|
|
|
* compatible with the specified layer. In such a case, this method can be
|
|
|
|
* called and will call the layer's rendering method anyway but the
|
|
|
|
* geometry passed to the layer will be empty.
|
|
|
|
* This is required for layers that generate their own geometry from other
|
|
|
|
* information in the rendering context.
|
|
|
|
*/
|
2016-08-05 08:09:43 +02:00
|
|
|
void renderUsingLayer( QgsSymbolLayer* layer, QgsSymbolRenderContext& context );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-05-24 05:26:46 +10:00
|
|
|
//! Render editing vertex marker at specified point
|
|
|
|
//! @note added in QGIS 2.16
|
|
|
|
void renderVertexMarker( QPointF pt, QgsRenderContext& context, int currentVertexMarkerType, int currentVertexMarkerSize );
|
|
|
|
|
2015-12-22 16:38:52 +01:00
|
|
|
private:
|
2016-08-05 08:09:43 +02:00
|
|
|
QgsSymbol( const QgsSymbol& );
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
2016-09-14 08:49:12 +10:00
|
|
|
QFlags<QgsSymbol::RenderHint> operator|(QgsSymbol::RenderHint f1, QFlags<QgsSymbol::RenderHint> f2);
|
|
|
|
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
///////////////////////
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
class QgsSymbolRenderContext
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:09:43 +02:00
|
|
|
#include <qgssymbol.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2016-07-18 09:42:45 +10:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
/** Constructor for QgsSymbolRenderContext
|
2016-07-18 09:42:45 +10:00
|
|
|
* @param c
|
|
|
|
* @param u
|
|
|
|
* @param alpha
|
|
|
|
* @param selected set to true if symbol should be drawn in a "selected" state
|
2016-09-14 08:49:12 +10:00
|
|
|
* @param renderHints flags controlling rendering behaviour
|
2016-07-18 09:42:45 +10:00
|
|
|
* @param f
|
|
|
|
* @param fields
|
|
|
|
* @param mapUnitScale
|
|
|
|
*/
|
2016-09-14 08:49:12 +10:00
|
|
|
QgsSymbolRenderContext( QgsRenderContext& c, QgsUnitTypes::RenderUnit u, qreal alpha = 1.0, bool selected = false, QgsSymbol::RenderHints renderHints = 0, const QgsFeature* f = 0, const QgsFields& fields = QgsFields(), const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() );
|
2016-08-05 08:09:43 +02:00
|
|
|
~QgsSymbolRenderContext();
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
QgsRenderContext& renderContext();
|
2016-01-28 10:30:06 +01:00
|
|
|
// const QgsRenderContext& renderContext() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-10-01 15:41:19 +10:00
|
|
|
/** Sets the original value variable value for data defined symbology
|
|
|
|
* @param value value for original value variable. This usually represents the symbol property value
|
|
|
|
* before any data defined overrides have been applied.
|
|
|
|
* @note added in QGIS 2.12
|
|
|
|
*/
|
|
|
|
void setOriginalValueVariable( const QVariant& value );
|
|
|
|
|
2016-07-18 09:42:45 +10:00
|
|
|
//! Returns the output unit for the context
|
2016-07-17 22:11:17 +10:00
|
|
|
QgsUnitTypes::RenderUnit outputUnit() const;
|
2016-07-18 09:42:45 +10:00
|
|
|
|
|
|
|
//! Sets the output unit for the context
|
2016-07-17 22:11:17 +10:00
|
|
|
void setOutputUnit( QgsUnitTypes::RenderUnit u );
|
2014-05-07 19:02:11 +02:00
|
|
|
|
2014-04-06 21:14:02 +02:00
|
|
|
QgsMapUnitScale mapUnitScale() const;
|
2016-01-28 10:30:06 +01:00
|
|
|
void setMapUnitScale( const QgsMapUnitScale& scale );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! Get alpha transparency 1 for opaque, 0 for invisible
|
|
|
|
qreal alpha() const;
|
|
|
|
//! Set alpha transparency 1 for opaque, 0 for invisible
|
|
|
|
void setAlpha( qreal alpha );
|
|
|
|
|
|
|
|
bool selected() const;
|
|
|
|
void setSelected( bool selected );
|
|
|
|
|
2016-09-14 08:49:12 +10:00
|
|
|
/** Returns the rendering hint flags for the symbol.
|
|
|
|
* @see setRenderHints()
|
|
|
|
*/
|
|
|
|
QgsSymbol::RenderHints renderHints() const;
|
|
|
|
|
|
|
|
/** Sets rendering hint flags for the symbol.
|
|
|
|
* @see renderHints()
|
|
|
|
*/
|
|
|
|
void setRenderHints( QgsSymbol::RenderHints hints );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
void setFeature( const QgsFeature* f );
|
2013-12-05 18:27:45 +07:00
|
|
|
//! Current feature being rendered - may be null
|
2012-09-24 02:28:15 +02:00
|
|
|
const QgsFeature* feature() const;
|
|
|
|
|
2013-12-05 18:27:45 +07:00
|
|
|
//! Fields of the layer. Currently only available in startRender() calls
|
|
|
|
//! to allow symbols with data-defined properties prepare the expressions
|
|
|
|
//! (other times fields() returns null)
|
2014-02-21 17:33:09 +07:00
|
|
|
//! @note added in 2.4
|
2016-08-02 10:43:15 +10:00
|
|
|
QgsFields fields() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-04-23 21:40:36 +07:00
|
|
|
/** Part count of current geometry
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
*/
|
|
|
|
int geometryPartCount() const;
|
|
|
|
/** Sets the part count of current geometry
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
*/
|
|
|
|
void setGeometryPartCount( int count );
|
|
|
|
|
|
|
|
/** Part number of current geometry
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
*/
|
|
|
|
int geometryPartNum() const;
|
|
|
|
/** Sets the part number of current geometry
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
*/
|
|
|
|
void setGeometryPartNum( int num );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
double outputLineWidth( double width ) const;
|
|
|
|
double outputPixelSize( double size ) const;
|
|
|
|
|
|
|
|
// workaround for sip 4.7. Don't use assignment - will fail with assertion error
|
2016-08-05 08:09:43 +02:00
|
|
|
// QgsSymbolRenderContext& operator=( const QgsSymbolRenderContext& );
|
2016-01-08 13:42:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This scope is always available when a symbol of this type is being rendered.
|
|
|
|
*
|
|
|
|
* @return An expression scope for details about this symbol
|
|
|
|
*/
|
|
|
|
QgsExpressionContextScope* expressionContextScope();
|
|
|
|
/**
|
|
|
|
* Set an expression scope for this symbol.
|
|
|
|
*
|
|
|
|
* Will take ownership.
|
|
|
|
*
|
|
|
|
* @param contextScope An expression scope for details about this symbol
|
|
|
|
*/
|
|
|
|
void setExpressionContextScope( QgsExpressionContextScope* contextScope /Transfer/);
|
2016-01-22 18:45:45 +11:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
QgsSymbolRenderContext( const QgsSymbolRenderContext& rh );
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
class QgsMarkerSymbol : QgsSymbol
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:09:43 +02:00
|
|
|
#include <qgssymbol.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
|
|
|
|
This is a convenience method for easier creation of marker symbols.
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2016-08-06 11:01:42 +02:00
|
|
|
static QgsMarkerSymbol* createSimple( const QgsStringMap& properties ) /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
QgsMarkerSymbol( const QgsSymbolLayerList& layers /Transfer/ = QgsSymbolLayerList() );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-04-11 14:11:15 +10:00
|
|
|
/** Sets the angle for the whole symbol. Individual symbol layer sizes
|
|
|
|
* will be rotated to maintain their current relative angle to the whole symbol angle.
|
|
|
|
* @param angle new symbol angle
|
|
|
|
* @see angle()
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setAngle( double angle );
|
2016-04-11 14:11:15 +10:00
|
|
|
|
|
|
|
/** Returns the marker angle for the whole symbol. Note that for symbols with
|
|
|
|
* multiple symbol layers, this will correspond just to the angle of
|
|
|
|
* the first symbol layer.
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
* @see setAngle()
|
|
|
|
*/
|
2015-08-13 17:48:56 +02:00
|
|
|
double angle() const;
|
|
|
|
|
|
|
|
/** Set data defined angle for whole symbol (including all symbol layers).
|
|
|
|
* @param dd data defined angle
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see dataDefinedAngle
|
|
|
|
*/
|
|
|
|
void setDataDefinedAngle( const QgsDataDefined& dd );
|
|
|
|
|
|
|
|
/** Returns data defined angle for whole symbol (including all symbol layers).
|
|
|
|
* @returns data defined angle, or empty data defined if angle is not set
|
|
|
|
* at the marker level
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see setDataDefinedAngle
|
|
|
|
*/
|
|
|
|
QgsDataDefined dataDefinedAngle() 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.
|
2015-08-13 17:48:56 +02:00
|
|
|
* @param lineAngle Angle in degrees, valid values are between 0 and 360
|
2015-05-15 15:53:05 +07:00
|
|
|
* @note added in QGIS 2.9
|
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-04-11 14:11:15 +10:00
|
|
|
/** Sets the size for the whole symbol. Individual symbol layer sizes
|
|
|
|
* will be scaled to maintain their current relative size to the whole symbol size.
|
|
|
|
* @param size new symbol size
|
|
|
|
* @see size()
|
|
|
|
* @see setSizeUnit()
|
|
|
|
* @see setSizeMapUnitScale()
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setSize( double size );
|
2016-04-11 14:11:15 +10:00
|
|
|
|
|
|
|
/** Returns the size for the whole symbol, which is the maximum size of
|
|
|
|
* all marker symbol layers in the symbol.
|
|
|
|
* @see setSize()
|
|
|
|
* @see sizeUnit()
|
|
|
|
* @see sizeMapUnitScale()
|
|
|
|
*/
|
2015-08-13 17:48:56 +02:00
|
|
|
double size() const;
|
|
|
|
|
2016-04-11 14:11:15 +10:00
|
|
|
/** Sets the size units for the whole symbol (including all symbol layers).
|
|
|
|
* @param unit size units
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
* @see sizeUnit()
|
|
|
|
* @see setSizeMapUnitScale()
|
|
|
|
* @see setSize()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
void setSizeUnit( QgsUnitTypes::RenderUnit unit );
|
2016-04-11 14:11:15 +10:00
|
|
|
|
|
|
|
/** Returns the size units for the whole symbol (including all symbol layers).
|
|
|
|
* @returns size units, or mixed units if symbol layers have different units
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
* @see setSizeUnit()
|
|
|
|
* @see sizeMapUnitScale()
|
|
|
|
* @see size()
|
|
|
|
*/
|
2016-07-17 22:11:17 +10:00
|
|
|
QgsUnitTypes::RenderUnit sizeUnit() const;
|
2016-04-11 14:11:15 +10:00
|
|
|
|
|
|
|
/** Sets the size map unit scale for the whole symbol (including all symbol layers).
|
|
|
|
* @param scale map unit scale
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
* @see sizeMapUnitScale()
|
|
|
|
* @see setSizeUnit()
|
|
|
|
* @see setSize()
|
|
|
|
*/
|
|
|
|
void setSizeMapUnitScale( const QgsMapUnitScale& scale );
|
|
|
|
|
|
|
|
/** Returns the size map unit scale for the whole symbol. Note that for symbols with
|
|
|
|
* multiple symbol layers, this will correspond just to the map unit scale
|
|
|
|
* for the first symbol layer.
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
* @see setSizeMapUnitScale()
|
|
|
|
* @see sizeUnit()
|
|
|
|
* @see size()
|
|
|
|
*/
|
|
|
|
QgsMapUnitScale sizeMapUnitScale() const;
|
|
|
|
|
2015-08-13 17:48:56 +02:00
|
|
|
/** Set data defined size for whole symbol (including all symbol layers).
|
|
|
|
* @param dd data defined size
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see dataDefinedSize
|
|
|
|
*/
|
|
|
|
void setDataDefinedSize( const QgsDataDefined& dd );
|
|
|
|
|
|
|
|
/** Returns data defined size for whole symbol (including all symbol layers).
|
|
|
|
* @returns data defined size, or empty data defined if size is not set
|
|
|
|
* at the marker level
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see setDataDefinedSize
|
|
|
|
*/
|
|
|
|
QgsDataDefined dataDefinedSize() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-05 08:09:43 +02:00
|
|
|
void setScaleMethod( QgsSymbol::ScaleMethod scaleMethod );
|
2012-09-24 02:28:15 +02:00
|
|
|
ScaleMethod scaleMethod();
|
|
|
|
|
2016-02-02 19:46:18 +11:00
|
|
|
void renderPoint( QPointF point, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-11-20 19:16:15 +11:00
|
|
|
/** Returns the approximate bounding box of the marker symbol, which includes the bounding box
|
2016-04-29 17:36:52 +10:00
|
|
|
* of all symbol layers for the symbol. It is recommended to use this method only between startRender()
|
|
|
|
* and stopRender() calls, or data defined rotation and offset will not be correctly calculated.
|
|
|
|
* @param point location of rendered point in painter units
|
|
|
|
* @param context render context
|
|
|
|
* @param feature feature being rendered at point (optional). If not specified, the bounds calculation will not
|
|
|
|
* include data defined parameters such as offset and rotation
|
2015-11-20 19:16:15 +11:00
|
|
|
* @returns approximate symbol bounds, in painter units
|
2016-04-11 14:11:15 +10:00
|
|
|
* @note added in QGIS 2.14
|
2016-04-29 17:36:52 +10:00
|
|
|
*/
|
|
|
|
QRectF bounds(QPointF point, QgsRenderContext& context, const QgsFeature &feature = QgsFeature() ) const;
|
2015-11-20 19:16:15 +11:00
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
virtual QgsMarkerSymbol* clone() const /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
class QgsLineSymbol : QgsSymbol
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:09:43 +02:00
|
|
|
#include <qgssymbol.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Create a line symbol with one symbol layer: SimpleLine with specified properties.
|
2016-02-14 03:50:23 +01:00
|
|
|
* This is a convenience method for easier creation of line symbols.
|
|
|
|
*/
|
2016-08-06 11:01:42 +02:00
|
|
|
static QgsLineSymbol* createSimple( const QgsStringMap& properties ) /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
QgsLineSymbol( const QgsSymbolLayerList& layers /Transfer/ = QgsSymbolLayerList() );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
void setWidth( double width );
|
2015-08-13 17:48:56 +02:00
|
|
|
double width() const;
|
|
|
|
|
|
|
|
/** Set data defined width for whole symbol (including all symbol layers).
|
|
|
|
* @param dd data defined width
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see dataDefinedWidth
|
|
|
|
*/
|
|
|
|
void setDataDefinedWidth( const QgsDataDefined& dd );
|
|
|
|
|
|
|
|
/** Returns data defined size for whole symbol (including all symbol layers).
|
|
|
|
* @returns data defined size, or empty data defined if size is not set
|
|
|
|
* at the line level
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see setDataDefinedWidth
|
|
|
|
*/
|
|
|
|
QgsDataDefined dataDefinedWidth() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
void renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );
|
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
virtual QgsLineSymbol* clone() const /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
class QgsFillSymbol : QgsSymbol
|
2012-09-24 02:28:15 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2016-08-05 08:09:43 +02:00
|
|
|
#include <qgssymbol.h>
|
2012-09-24 02:28:15 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Create a fill symbol with one symbol layer: SimpleFill with specified properties.
|
2016-02-14 03:50:23 +01:00
|
|
|
* This is a convenience method for easier creation of fill symbols.
|
|
|
|
*/
|
2016-08-06 11:01:42 +02:00
|
|
|
static QgsFillSymbol* createSimple( const QgsStringMap& properties ) /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
QgsFillSymbol( const QgsSymbolLayerList& layers /Transfer/ = QgsSymbolLayerList() );
|
2012-09-24 02:28:15 +02:00
|
|
|
void setAngle( double angle );
|
|
|
|
void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );
|
|
|
|
|
2016-08-06 11:01:42 +02:00
|
|
|
virtual QgsFillSymbol* clone() const /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|