Ejemplo n.º 1
0
QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::clone() const
{
  QgsSimpleLineSymbolLayerV2* l = new QgsSimpleLineSymbolLayerV2( mColor, mWidth, mPenStyle );
  l->setWidthUnit( mWidthUnit );
  l->setOffsetUnit( mOffsetUnit );
  l->setCustomDashPatternUnit( mCustomDashPatternUnit );
  l->setOffset( mOffset );
  l->setPenJoinStyle( mPenJoinStyle );
  l->setPenCapStyle( mPenCapStyle );
  l->setUseCustomDashPattern( mUseCustomDashPattern );
  l->setCustomDashVector( mCustomDashVector );

  //data defined properties
  if ( mStrokeColorExpression )
    l->setDataDefinedProperty( "color", mStrokeColorExpression->dump() );
  if ( mStrokeWidthExpression )
    l->setDataDefinedProperty( "width", mStrokeWidthExpression->dump() );
  if ( mLineOffsetExpression )
    l->setDataDefinedProperty( "offset", mLineOffsetExpression->dump() );
  if ( mDashPatternExpression )
    l->setDataDefinedProperty( "customdash", mDashPatternExpression->dump() );
  if ( mJoinStyleExpression )
    l->setDataDefinedProperty( "joinstyle", mJoinStyleExpression->dump() );
  if ( mCapStyleExpression )
    l->setDataDefinedProperty( "capstyle", mCapStyleExpression->dump() );

  return l;
}
Ejemplo n.º 2
0
QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::create( const QgsStringMap& props )
{
  QColor color = DEFAULT_SIMPLELINE_COLOR;
  double width = DEFAULT_SIMPLELINE_WIDTH;
  Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE;

  if ( props.contains( "color" ) )
    color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
  if ( props.contains( "width" ) )
    width = props["width"].toDouble();
  if ( props.contains( "penstyle" ) )
    penStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["penstyle"] );


  QgsSimpleLineSymbolLayerV2* l = new QgsSimpleLineSymbolLayerV2( color, width, penStyle );
  if ( props.contains( "width_unit" ) )
    l->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["width_unit"] ) );
  if ( props.contains( "offset" ) )
    l->setOffset( props["offset"].toDouble() );
  if ( props.contains( "offset_unit" ) )
    l->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) );
  if ( props.contains( "joinstyle" ) )
    l->setPenJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( props["joinstyle"] ) );
  if ( props.contains( "capstyle" ) )
    l->setPenCapStyle( QgsSymbolLayerV2Utils::decodePenCapStyle( props["capstyle"] ) );

  if ( props.contains( "use_custom_dash" ) )
  {
    l->setUseCustomDashPattern( props["use_custom_dash"].toInt() );
  }
  if ( props.contains( "customdash" ) )
  {
    l->setCustomDashVector( QgsSymbolLayerV2Utils::decodeRealVector( props["customdash"] ) );
  }
  if ( props.contains( "customdash_unit" ) )
  {
    l->setCustomDashPatternUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["customdash_unit"] ) );
  }

  if ( props.contains( "draw_inside_polygon" ) )
  {
    l->setDrawInsidePolygon( props["draw_inside_polygon"].toInt() );
  }

  //data defined properties
  if ( props.contains( "color_expression" ) )
    l->setDataDefinedProperty( "color", props["color_expression"] );
  if ( props.contains( "width_expression" ) )
    l->setDataDefinedProperty( "width", props["width_expression"] );
  if ( props.contains( "offset_expression" ) )
    l->setDataDefinedProperty( "offset", props["offset_expression"] );
  if ( props.contains( "customdash_expression" ) )
    l->setDataDefinedProperty( "customdash", props["customdash_expression"] );
  if ( props.contains( "joinstyle_expression" ) )
    l->setDataDefinedProperty( "joinstyle", props["joinstyle_expression"] );
  if ( props.contains( "capstyle_expression" ) )
    l->setDataDefinedProperty( "capstyle", props["capstyle_expression"] );

  return l;
}