void QgsFillSymbolV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected ) { QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f, 0, mapUnitScale() ); if ( layer != -1 ) { if ( layer >= 0 && layer < mLayers.count() ) { QgsSymbolV2::SymbolType layertype = mLayers.at( layer )->type(); if ( layertype == QgsSymbolV2::Fill ) (( QgsFillSymbolLayerV2* ) mLayers[layer] )->renderPolygon( points, rings, symbolContext ); else if ( layertype == QgsSymbolV2::Line ) (( QgsLineSymbolLayerV2* ) mLayers[layer] )->renderPolygonOutline( points, rings, symbolContext ); } return; } for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it ) { QgsSymbolV2::SymbolType layertype = ( *it )->type(); if ( layertype == QgsSymbolV2::Fill ) { QgsFillSymbolLayerV2* layer = ( QgsFillSymbolLayerV2* ) * it; layer->renderPolygon( points, rings, symbolContext ); } else if ( layertype == QgsSymbolV2::Line ) { QgsLineSymbolLayerV2* layer = ( QgsLineSymbolLayerV2* ) * it; layer->renderPolygonOutline( points, rings, symbolContext ); } } }
void QgsSymbolV2::startRender( QgsRenderContext& context, const QgsVectorLayer* layer ) { QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints ); symbolContext.setLayer( layer ); for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it ) ( *it )->startRender( symbolContext ); }
void QgsSymbolV2::startRender( QgsRenderContext& context, const QgsFields* fields ) { QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints, 0, fields, mapUnitScale() ); for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it ) ( *it )->startRender( symbolContext ); }
void QgsSymbolV2::stopRender( QgsRenderContext& context ) { QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints, 0, 0, mapUnitScale() ); for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it ) ( *it )->stopRender( symbolContext ); mLayer = NULL; }
void QgsSymbolV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const { props[ "alpha" ] = QString::number( alpha() ); double scaleFactor = 1.0; props[ "uom" ] = QgsSymbolLayerV2Utils::encodeSldUom( outputUnit(), &scaleFactor ); props[ "uomScale" ] = scaleFactor != 1 ? QString::number( scaleFactor ) : ""; for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it ) { ( *it )->toSld( doc, element, props ); } }
void QgsLineSymbolV2::renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected ) { QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f ); if ( layer != -1 ) { if ( layer >= 0 && layer < mLayers.count() ) (( QgsLineSymbolLayerV2* ) mLayers[layer] )->renderPolyline( points, symbolContext ); return; } for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it ) { QgsLineSymbolLayerV2* layer = ( QgsLineSymbolLayerV2* ) * it; layer->renderPolyline( points, symbolContext ); } }
void QgsMarkerSymbolV2::renderPoint( const QPointF& point, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected ) { QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f, 0, mapUnitScale() ); if ( layer != -1 ) { if ( layer >= 0 && layer < mLayers.count() ) { renderPointUsingLayer(( QgsMarkerSymbolLayerV2* ) mLayers[layer], point, symbolContext ); } return; } for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it ) { renderPointUsingLayer(( QgsMarkerSymbolLayerV2* ) * it, point, symbolContext ); } }
void QgsLineSymbolV2::renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected ) { //save old painter QPainter* renderPainter = context.painter(); QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f, 0, mapUnitScale() ); if ( layer != -1 ) { if ( layer >= 0 && layer < mLayers.count() ) { renderPolylineUsingLayer(( QgsLineSymbolLayerV2* ) mLayers[layer], points, symbolContext ); } return; } for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it ) { renderPolylineUsingLayer(( QgsLineSymbolLayerV2* ) * it, points, symbolContext ); } context.setPainter( renderPainter ); }
void QgsSymbolV2::drawPreviewIcon( QPainter* painter, QSize size ) { QgsRenderContext context = QgsSymbolLayerV2Utils::createRenderContext( painter ); QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints ); for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it ) { if ( mType == Fill && ( *it )->type() == Line ) { // line symbol layer would normally draw just a line // so we override this case to force it to draw a polygon outline QgsLineSymbolLayerV2* lsl = ( QgsLineSymbolLayerV2* ) * it; // from QgsFillSymbolLayerV2::drawPreviewIcon() QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width() - 1, size.height() - 1 ) ); lsl->startRender( symbolContext ); lsl->renderPolygonOutline( poly, NULL, symbolContext ); lsl->stopRender( symbolContext ); } else ( *it )->drawPreviewIcon( symbolContext, size ); } }