QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create( const QgsStringMap& props ) { QString name = DEFAULT_SVGMARKER_NAME; double size = DEFAULT_SVGMARKER_SIZE; double angle = DEFAULT_SVGMARKER_ANGLE; if ( props.contains( "name" ) ) name = props["name"]; if ( props.contains( "size" ) ) size = props["size"].toDouble(); if ( props.contains( "angle" ) ) angle = props["angle"].toDouble(); QgsSvgMarkerSymbolLayerV2* m = new QgsSvgMarkerSymbolLayerV2( name, size, angle ); //we only check the svg default parameters if necessary, since it could be expensive if ( !props.contains( "fill" ) && !props.contains( "outline" ) && !props.contains( "outline-width" ) ) { QColor fillColor, outlineColor; double outlineWidth; bool hasFillParam, hasOutlineParam, hasOutlineWidthParam; QgsSvgCache::instance()->containsParams( name, hasFillParam, fillColor, hasOutlineParam, outlineColor, hasOutlineWidthParam, outlineWidth ); if ( hasFillParam ) { m->setFillColor( fillColor ); } if ( hasOutlineParam ) { m->setOutlineColor( outlineColor ); } if ( hasOutlineWidthParam ) { m->setOutlineWidth( outlineWidth ); } } if ( props.contains( "offset" ) ) m->setOffset( QgsSymbolLayerV2Utils::decodePoint( props["offset"] ) ); if ( props.contains( "fill" ) ) m->setFillColor( QColor( props["fill"] ) ); if ( props.contains( "outline" ) ) m->setOutlineColor( QColor( props["outline"] ) ); if ( props.contains( "outline-width" ) ) m->setOutlineWidth( props["outline-width"].toDouble() ); return m; }
QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::clone() const { QgsSvgMarkerSymbolLayerV2* m = new QgsSvgMarkerSymbolLayerV2( mPath, mSize, mAngle ); m->setFillColor( mFillColor ); m->setOutlineColor( mOutlineColor ); m->setOutlineWidth( mOutlineWidth ); m->setOffset( mOffset ); return m; }
QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::clone() const { QgsSvgMarkerSymbolLayerV2* m = new QgsSvgMarkerSymbolLayerV2( mPath, mSize, mAngle ); m->setFillColor( mFillColor ); m->setOutlineColor( mOutlineColor ); m->setOutlineWidth( mOutlineWidth ); m->setOutlineWidthUnit( mOutlineWidthUnit ); m->setOffset( mOffset ); m->setOffsetUnit( mOffsetUnit ); m->setSizeUnit( mSizeUnit ); m->setHorizontalAnchorPoint( mHorizontalAnchorPoint ); m->setVerticalAnchorPoint( mVerticalAnchorPoint ); copyDataDefinedProperties( m ); return m; }
QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create( const QgsStringMap& props ) { QString name = DEFAULT_SVGMARKER_NAME; double size = DEFAULT_SVGMARKER_SIZE; double angle = DEFAULT_SVGMARKER_ANGLE; if ( props.contains( "name" ) ) name = props["name"]; if ( props.contains( "size" ) ) size = props["size"].toDouble(); if ( props.contains( "angle" ) ) angle = props["angle"].toDouble(); QgsSvgMarkerSymbolLayerV2* m = new QgsSvgMarkerSymbolLayerV2( name, size, angle ); //we only check the svg default parameters if necessary, since it could be expensive if ( !props.contains( "fill" ) && !props.contains( "outline" ) && !props.contains( "outline-width" ) ) { QColor fillColor, outlineColor; double outlineWidth; bool hasFillParam, hasOutlineParam, hasOutlineWidthParam; QgsSvgCache::instance()->containsParams( name, hasFillParam, fillColor, hasOutlineParam, outlineColor, hasOutlineWidthParam, outlineWidth ); if ( hasFillParam ) { m->setFillColor( fillColor ); } if ( hasOutlineParam ) { m->setOutlineColor( outlineColor ); } if ( hasOutlineWidthParam ) { m->setOutlineWidth( outlineWidth ); } } if ( props.contains( "size_unit" ) ) m->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["size_unit"] ) ); if ( props.contains( "offset" ) ) m->setOffset( QgsSymbolLayerV2Utils::decodePoint( props["offset"] ) ); if ( props.contains( "offset_unit" ) ) m->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) ); if ( props.contains( "fill" ) ) m->setFillColor( QColor( props["fill"] ) ); if ( props.contains( "outline" ) ) m->setOutlineColor( QColor( props["outline"] ) ); if ( props.contains( "outline-width" ) ) m->setOutlineWidth( props["outline-width"].toDouble() ); if ( props.contains( "outline_width_unit" ) ) m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) ); if ( props.contains( "horizontal_anchor_point" ) ) { m->setHorizontalAnchorPoint( QgsMarkerSymbolLayerV2::HorizontalAnchorPoint( props[ "horizontal_anchor_point" ].toInt() ) ); } if ( props.contains( "vertical_anchor_point" ) ) { m->setVerticalAnchorPoint( QgsMarkerSymbolLayerV2::VerticalAnchorPoint( props[ "vertical_anchor_point" ].toInt() ) ); } //data defined properties if ( props.contains( "size_expression" ) ) { m->setDataDefinedProperty( "size", props["size_expression"] ); } if ( props.contains( "outline-width_expression" ) ) { m->setDataDefinedProperty( "outline-width", props["outline-width_expression"] ); } if ( props.contains( "angle_expression" ) ) { m->setDataDefinedProperty( "angle", props["angle_expression"] ); } if ( props.contains( "offset_expression" ) ) { m->setDataDefinedProperty( "offset", props["offset_expression"] ); } if ( props.contains( "name_expression" ) ) { m->setDataDefinedProperty( "name", props["name_expression"] ); } if ( props.contains( "fill_expression" ) ) { m->setDataDefinedProperty( "fill", props["fill_expression"] ); } if ( props.contains( "outline_expression" ) ) { m->setDataDefinedProperty( "outline", props["outline_expression"] ); } if ( props.contains( "horizontal_anchor_point_expression" ) ) { m->setDataDefinedProperty( "horizontal_anchor_point", props[ "horizontal_anchor_point_expression" ] ); } if ( props.contains( "vertical_anchor_point_expression" ) ) { m->setDataDefinedProperty( "vertical_anchor_point", props[ "vertical_anchor_point_expression" ] ); } return m; }