Beispiel #1
0
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::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 );
  }
}