67 ( scaleFactorX ?
"tostring(" +
QString::number( scaleFactorX ) +
"*(" + exprString +
"))" :
"'0'" ) +
69 ( scaleFactorY ?
"tostring(" +
QString::number( scaleFactorY ) +
"*(" + exprString +
"))" :
"'0'" ) );
81 , mClipFeaturesToExtent( true )
120 if (( *it )->outputUnit() != unit )
144 if (( *it )->mapUnitScale() != scale )
157 ( *it )->setOutputUnit( u );
166 ( *it )->setMapUnitScale( scale );
187 default: defaultSymbol =
"";
break;
189 if ( defaultSymbol !=
"" )
200 default:
QgsDebugMsg(
"unknown layer's geometry type" );
return NULL;
208 if ( defaultSymbol ==
"" ||
297 ( *it )->startRender( symbolContext );
305 ( *it )->stopRender( symbolContext );
314 if ( !( *it )->isLocked() )
315 ( *it )->setColor( color );
324 if ( !( *it )->isLocked() )
325 return ( *it )->color();
351 ( *it )->drawPreviewIcon( symbolContext, size );
357 QImage image( size, QImage::Format_ARGB32_Premultiplied );
371 QImage preview(
QSize( 100, 100 ), QImage::Format_ARGB32_Premultiplied );
392 static_cast<QgsLineSymbolV2*
>( this )->renderPolyline( poly, 0, context );
398 static_cast<QgsFillSymbolV2*
>( this )->renderPolygon( polygon, NULL, 0, context );
418 default: Q_ASSERT( 0 &&
"unknown symbol type" );
432 double scaleFactor = 1.0;
434 props[
"uomScale" ] = scaleFactor != 1 ?
QString::number( scaleFactor ) :
"";
438 ( *it )->toSld( doc, element, props );
463 attributes.
unite(( *sIt )->usedAttributes() );
473 : mRenderContext( c ), mOutputUnit( u ), mMapUnitScale( mapUnitScale ), mAlpha( alpha ), mSelected( selected ), mRenderHints( renderHints ), mFeature( f ), mFields( fields )
550 double origAngle =
angle();
551 double angleDiff = ang - origAngle;
568 return layer->
angle();
582 const double symbolRotation =
angle();
608 const double symbolRotation =
angle();
634 if ( !layerAngleDD || *layerAngleDD != *symbolDD )
640 if ( !layerAngleDD || *layerAngleDD != *( rotatedDD.
data() ) )
650 double origSize =
size();
655 if ( layer->
size() == origSize )
657 else if ( origSize != 0 )
663 if ( origSize != 0 && ( layer->
offset().
x() || layer->
offset().
y() ) )
665 layer->
offset().
y() * s / origSize ) );
676 double lsize = layer->
size();
677 if ( lsize > maxSize )
685 const double symbolSize =
size();
710 layer->
offset().
x() / symbolSize,
711 layer->
offset().
y() / symbolSize, dd ) );
719 const double symbolSize =
size();
747 if ( !layerSizeDD || *layerSizeDD != *symbolDD )
752 if ( symbolSize == 0 )
756 if ( !layerSizeDD || *layerSizeDD != *( scaledDD.
data() ) )
761 if ( layerOffsetDD && *layerOffsetDD != *( scaledOffsetDD.
data() ) )
791 static QPointF nullPoint( 0, 0 );
794 if ( effect && effect->
enabled() )
853 double origWidth =
width();
858 if ( layer->
width() == origWidth )
862 else if ( origWidth != 0 )
868 if ( origWidth != 0 && layer->
offset() )
880 if ( width > maxWidth )
888 const double symbolWidth =
width();
920 const double symbolWidth =
width();
948 if ( !layerWidthDD || *layerWidthDD != *symbolDD )
953 if ( symbolWidth == 0 )
957 if ( !layerWidthDD || *layerWidthDD != *( scaledDD.
data() ) )
962 if ( layerOffsetDD && *layerOffsetDD != *( scaledOffsetDD.
data() ) )
995 if ( effect && effect->
enabled() )
1041 renderPolygonUsingLayer(
mLayers[layer], points, rings, symbolContext );
1048 renderPolygonUsingLayer( *it, points, rings, symbolContext );
1057 if ( effect && effect->
enabled() )
1059 QRectF bounds = polygonBounds( points, rings );
1064 p->translate( bounds.
topLeft() );
1075 delete translatedRings;
1099 for ( ; it != rings->
constEnd(); ++it )
1101 bounds = bounds.
united(( *it ).boundingRect() );
1114 for ( ; it != rings->
constEnd(); ++it )
1116 translatedRings->
append(( *it ).translated( dx, dy ) );
1118 return translatedRings;
void setForceVectorOutput(bool force)
void setLocked(bool locked)
bool deleteSymbolLayer(int index)
delete symbol layer at specified index
QgsSymbolV2RenderContext(QgsRenderContext &c, QgsSymbolV2::OutputUnit u, qreal alpha=1.0, bool selected=false, int renderHints=0, const QgsFeature *f=0, const QgsFields *fields=0, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale())
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
static QgsMarkerSymbolV2 * createSimple(const QgsStringMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent...
QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers)
bool mClipFeaturesToExtent
void setDataDefinedAngle(const QgsDataDefined &dd)
Set data defined angle for whole symbol (including all symbol layers).
A container class for data source field mapping or expression.
virtual double width() const
void setRenderHint(RenderHint hint, bool on)
const QgsVectorLayer * mLayer
QSet< QString > usedAttributes() const
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
static QString encodeSldUom(QgsSymbolV2::OutputUnit unit, double *scaleFactor)
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QgsFillSymbolV2(QgsSymbolLayerV2List layers=QgsSymbolLayerV2List())
QgsDataDefined dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void setOffset(QPointF offset)
QPolygonF translated(qreal dx, qreal dy) const
bool enabled() const
Returns whether the effect is enabled.
Base class for visual effects which can be applied to QPicture drawings.
bool changeSymbolLayer(int index, QgsSymbolLayerV2 *layer)
delete layer at specified index and set a new one
ScaleMethod scaleMethod()
QgsMapUnitScale mapUnitScale() const
Container of fields for a vector layer.
QgsSymbolV2 * symbol(QString name)
return a NEW copy of symbol
QString expressionString() const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void drawLine(const QLineF &line)
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
virtual void removeDataDefinedProperty(const QString &property)
Removes a data defined property from the layer.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
static double pixelSizeScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns scale factor painter units -> pixel dimensions.
void setWidth(double width)
QgsDataDefined * scaleWholeSymbol(double scaleFactor, const QgsDataDefined &dd)
QgsDataDefined dataDefinedWidth() const
Returns data defined size for whole symbol (including all symbol layers).
void setMapUnitScale(const QgsMapUnitScale &scale)
void setAngle(double angle)
const QgsVectorLayer * layer() const
virtual void startRender(QgsSymbolV2RenderContext &context)=0
static QString encodeColor(QColor color)
QColor fromHsv(int h, int s, int v, int a)
void setUseExpression(bool use)
void setColor(const QColor &color)
static QgsRenderContext createRenderContext(QPainter *p)
Creates a render context for a pixel based device.
QString number(int n, int base)
QgsSymbolLayerV2List mLayers
int count(const T &value) const
void append(const T &value)
QgsSymbolLayerV2List cloneLayers() const
void setOffset(double offset)
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
append symbol layer at the end of the list
virtual void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)=0
void fill(uint pixelValue)
QgsLineSymbolV2(QgsSymbolLayerV2List layers=QgsSymbolLayerV2List())
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
void startRender(QgsRenderContext &context, const QgsFields *fields=0)
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
static QgsLineSymbolV2 * createSimple(const QgsStringMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties. ...
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setPen(const QColor &color)
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
void setRenderingPass(int renderingPass)
#define DEFAULT_SCALE_METHOD
void setLayer(const QgsVectorLayer *layer)
virtual void setWidth(double width)
static QgsStyleV2 * defaultStyle()
return default application-wide style
void renderPolyline(const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void setAngle(double angle)
void setAngle(double angle)
virtual QgsSymbolV2 * clone() const override
void setPainter(QPainter *p)
void setSize(double size)
qreal mAlpha
Symbol opacity (in the range 0 - 1)
QgsSymbolV2RenderContext & operator=(const QgsSymbolV2RenderContext &)
QRectF united(const QRectF &rectangle) const
virtual void renderPolygonOutline(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
QgsDataDefined * rotateWholeSymbol(double additionalRotation, const QgsDataDefined &dd)
void renderPoint(const QPointF &point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
QgsSymbolV2::ScaleMethod scaleMethod() const
QgsSymbolV2::SymbolType type() const
bool useExpression() const
virtual QgsSymbolV2 * clone() const override
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
virtual void renderPolyline(const QPolygonF &points, QgsSymbolV2RenderContext &context)=0
~QgsSymbolV2RenderContext()
bool isSymbolLayerCompatible(SymbolType t)
check whether a symbol layer type can be used within the symbol (marker-marker, line-line, fill-fill/line)
void setDataDefinedWidth(const QgsDataDefined &dd)
Set data defined width for whole symbol (including all symbol layers).
QgsMarkerSymbolV2(QgsSymbolLayerV2List layers=QgsSymbolLayerV2List())
Contains information about the context of a rendering operation.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString::null, bool *ok=0) const
QRectF boundingRect() const
QgsDataDefined dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
void stopRender(QgsRenderContext &context)
bool insertSymbolLayer(int index, QgsSymbolLayerV2 *layer)
insert symbol layer to specified index
static double lineWidthScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns the line width scale factor depending on the unit and the paint device.
QSet< T > & unite(const QSet< T > &other)
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
void insert(int i, const T &value)
QgsRenderContext & renderContext()
virtual QgsDataDefined * getDataDefinedProperty(const QString &property) const
Returns the data defined property corresponding to the specified property key.
static QgsProject * instance()
access to canonical QgsProject instance
QgsSymbolV2::OutputUnit outputUnit() const
void translate(const QPointF &offset)
QgsSymbolLayerV2 * takeSymbolLayer(int index)
remove symbol layer from the list and return pointer to it
bool hasDefaultValues() const
Returns whether the data defined container is set to all the default values, ie, disabled, with empty expression and no assigned field.
double outputPixelSize(double size) const
double outputLineWidth(double width) const
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
QImage asImage(QSize size, QgsRenderContext *customContext=0)
const_iterator constEnd() const
const_iterator constBegin() const
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=0)
Draw icon of the symbol that occupyies area given by size using the painter.
void setSize(double size)
void setAngle(double angle)
virtual QgsSymbolV2 * clone() const override
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
void setExpressionString(const QString &expr)
void setOutputUnit(QgsSymbolV2::OutputUnit u)
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
QImage bigSymbolPreviewImage()
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the layer.
virtual Q_DECL_DEPRECATED void setDataDefinedProperty(const QString &property, const QString &expressionString)
Sets a data defined expression for a property.