37 : mType( type ), mLayers( layers ), mAlpha( 1.0 ), mRenderHints( 0 ), mLayer( NULL )
41 for (
int i = 0; i <
mLayers.count(); i++ )
59 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
70 QgsSymbolLayerV2List::const_iterator it =
mLayers.constBegin();
74 for ( ; it !=
mLayers.constEnd(); ++it )
76 if (( *it )->outputUnit() != unit )
91 QgsSymbolLayerV2List::const_iterator it =
mLayers.constBegin();
98 for ( ; it !=
mLayers.constEnd(); ++it )
100 if (( *it )->mapUnitScale() != scale )
110 QgsSymbolLayerV2List::iterator it =
mLayers.begin();
111 for ( ; it !=
mLayers.end(); ++it )
113 ( *it )->setOutputUnit( u );
119 QgsSymbolLayerV2List::iterator it =
mLayers.begin();
120 for ( ; it !=
mLayers.end(); ++it )
122 ( *it )->setMapUnitScale( scale );
143 default: defaultSymbol =
"";
break;
145 if ( defaultSymbol !=
"" )
156 default:
QgsDebugMsg(
"unknown layer's geometry type" );
return NULL;
164 if ( defaultSymbol ==
"" ||
167 s->
setColor( QColor::fromHsv( rand() % 360, 64 + rand() % 192, 128 + rand() % 128 ) );
175 if ( layer < 0 || layer >=
mLayers.count() )
194 if ( index < 0 || index >
mLayers.count() )
199 mLayers.insert( index, layer );
216 if ( index < 0 || index >=
mLayers.count() )
227 if ( index < 0 || index >=
mLayers.count() )
230 return mLayers.takeAt( index );
236 if ( index < 0 || index >=
mLayers.count() )
252 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
253 ( *it )->startRender( symbolContext );
260 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
261 ( *it )->stopRender( symbolContext );
268 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
270 if ( !( *it )->isLocked() )
271 ( *it )->setColor( color );
277 for ( QgsSymbolLayerV2List::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
280 if ( !( *it )->isLocked() )
281 return ( *it )->color();
283 return QColor( 0, 0, 0 );
291 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
300 QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width() - 1, size.height() - 1 ) );
306 ( *it )->drawPreviewIcon( symbolContext, size );
313 QImage preview( QSize( 100, 100 ), QImage::Format_ARGB32_Premultiplied );
316 QPainter p( &preview );
317 p.setRenderHint( QPainter::Antialiasing );
318 p.translate( 0.5, 0.5 );
322 p.setPen( QPen( Qt::gray ) );
323 p.drawLine( 0, 50, 100, 50 );
324 p.drawLine( 50, 0, 50, 100 );
333 poly << QPointF( 0, 50 ) << QPointF( 99, 50 );
334 static_cast<QgsLineSymbolV2*
>( this )->renderPolyline( poly, 0, context );
339 polygon << QPointF( 20, 20 ) << QPointF( 80, 20 ) << QPointF( 80, 80 ) << QPointF( 20, 80 ) << QPointF( 20, 20 );
340 static_cast<QgsFillSymbolV2*
>( this )->renderPolygon( polygon, NULL, 0, context );
344 static_cast<QgsMarkerSymbolV2*
>( this )->renderPoint( QPointF( 50, 50 ), 0, context );
360 default: Q_ASSERT( 0 &&
"unknown symbol type" );
364 for ( QgsSymbolLayerV2List::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
373 props[
"alpha" ] = QString::number(
alpha() );
374 double scaleFactor = 1.0;
376 props[
"uomScale" ] = scaleFactor != 1 ? QString::number( scaleFactor ) :
"";
378 for ( QgsSymbolLayerV2List::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
380 ( *it )->toSld( doc, element, props );
387 for ( QgsSymbolLayerV2List::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
399 QSet<QString> attributes;
400 QgsSymbolLayerV2List::const_iterator sIt =
mLayers.constBegin();
401 for ( ; sIt !=
mLayers.constEnd(); ++sIt )
405 attributes.unite(( *sIt )->usedAttributes() );
415 : mRenderContext( c ), mOutputUnit( u ), mMapUnitScale( mapUnitScale ), mAlpha( alpha ), mSelected( selected ), mRenderHints( renderHints ), mFeature( f ), mFields( fields )
493 double origAngle =
angle();
494 double angleDiff = ang - origAngle;
495 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
504 QgsSymbolLayerV2List::const_iterator it =
mLayers.begin();
511 return layer->
angle();
516 double origSize =
size();
518 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
521 if ( layer->
size() == origSize )
536 for ( QgsSymbolLayerV2List::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
539 double lsize = layer->
size();
540 if ( lsize > maxSize )
549 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
558 QgsSymbolLayerV2List::const_iterator it =
mLayers.begin();
574 if ( layer >= 0 && layer <
mLayers.count() )
579 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
606 double origWidth =
width();
608 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
611 if ( layer->
width() == origWidth )
618 if ( origWidth != 0 )
627 for ( QgsSymbolLayerV2List::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
631 if ( width > maxWidth )
643 if ( layer >= 0 && layer <
mLayers.count() )
648 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
679 if ( layer >= 0 && layer <
mLayers.count() )
690 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
716 for ( QgsSymbolLayerV2List::iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
void setLocked(bool locked)
bool deleteSymbolLayer(int index)
delete symbol layer at specified index
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.
QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers)
virtual double width() const
const QgsVectorLayer * mLayer
QSet< QString > usedAttributes() const
void drawPreviewIcon(QPainter *painter, QSize size)
static QString encodeSldUom(QgsSymbolV2::OutputUnit unit, double *scaleFactor)
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QgsFillSymbolV2(QgsSymbolLayerV2List layers=QgsSymbolLayerV2List())
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
QgsMapUnitScale mMapUnitScale
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.
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)=0
QgsSymbolV2 * symbol(QString name)
return a NEW copy of symbol
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
QMap< QString, QString > QgsStringMap
static double pixelSizeScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns scale factor painter units -> pixel dimensions.
void setWidth(double width)
void setMapUnitScale(const QgsMapUnitScale &scale)
void setAngle(double angle)
const QgsVectorLayer * layer() const
virtual void startRender(QgsSymbolV2RenderContext &context)=0
static QString encodeColor(QColor color)
void setColor(const QColor &color)
static QgsRenderContext createRenderContext(QPainter *p)
Creates a render context for a pixel based device.
QgsSymbolLayerV2List mLayers
QgsSymbolLayerV2List cloneLayers() const
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
append symbol layer at the end of the list
virtual void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)=0
QgsLineSymbolV2(QgsSymbolLayerV2List layers=QgsSymbolLayerV2List())
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 toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
void setRenderingPass(int renderingPass)
#define DEFAULT_SCALE_METHOD
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)
void setSize(double size)
qreal mAlpha
Symbol opacity (in the range 0 - 1)
QgsSymbolV2RenderContext & operator=(const QgsSymbolV2RenderContext &)
virtual void renderPolygonOutline(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
void renderPoint(const QPointF &point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
QgsSymbolV2::ScaleMethod scaleMethod() const
QgsSymbolV2::SymbolType type() const
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
virtual QgsSymbolV2 * clone() const
~QgsSymbolV2RenderContext()
bool isSymbolLayerCompatible(SymbolType t)
check whether a symbol layer type can be used within the symbol (marker-marker, line-line, fill-fill/line)
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
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.
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
virtual QgsSymbolV2 * clone() const
QList< QgsSymbolLayerV2 * > QgsSymbolLayerV2List
QgsSymbolV2RenderContext(QgsRenderContext &c, QgsSymbolV2::OutputUnit u, qreal alpha=1.0, bool selected=false, int renderHints=0, const QgsFeature *f=0, const QgsFields *=0, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale())
static QgsProject * instance()
access to canonical QgsProject instance
QgsRenderContext & mRenderContext
QgsSymbolV2::OutputUnit outputUnit() const
virtual QgsSymbolV2 * clone() const
QgsSymbolLayerV2 * takeSymbolLayer(int index)
remove symbol layer from the list and return pointer to it
double outputPixelSize(double size) const
double outputLineWidth(double width) const
QgsSymbolLayerV2 * symbolLayer(int layer)
void setSize(double size)
void setAngle(double angle)
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
QgsSymbolV2::OutputUnit mOutputUnit
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())