QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& properties ) { QgsEllipseSymbolLayerV2* layer = new QgsEllipseSymbolLayerV2(); if ( properties.contains( "symbol_name" ) ) { layer->setSymbolName( properties[ "symbol_name" ] ); } if ( properties.contains( "symbol_width" ) ) { layer->setSymbolWidth( properties["symbol_width"].toDouble() ); } if ( properties.contains( "symbol_width_unit" ) ) { layer->setSymbolWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_width_unit"] ) ); } if ( properties.contains( "symbol_width_map_unit_scale" ) ) { layer->setSymbolWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["symbol_width_map_unit_scale"] ) ); } if ( properties.contains( "symbol_height" ) ) { layer->setSymbolHeight( properties["symbol_height"].toDouble() ); } if ( properties.contains( "symbol_height_unit" ) ) { layer->setSymbolHeightUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_height_unit"] ) ); } if ( properties.contains( "symbol_height_map_unit_scale" ) ) { layer->setSymbolHeightMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["symbol_height_map_unit_scale"] ) ); } if ( properties.contains( "angle" ) ) { layer->setAngle( properties["angle"].toDouble() ); } if ( properties.contains( "outline_style" ) ) { layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["outline_style"] ) ); } else if ( properties.contains( "line_style" ) ) { layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["line_style"] ) ); } if ( properties.contains( "outline_width" ) ) { layer->setOutlineWidth( properties["outline_width"].toDouble() ); } else if ( properties.contains( "line_width" ) ) { layer->setOutlineWidth( properties["line_width"].toDouble() ); } if ( properties.contains( "outline_width_unit" ) ) { layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) ); } else if ( properties.contains( "line_width_unit" ) ) { layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["line_width_unit"] ) ); } if ( properties.contains( "outline_width_map_unit_scale" ) ) { layer->setOutlineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["outline_width_map_unit_scale"] ) ); } if ( properties.contains( "fill_color" ) ) { //pre 2.5 projects used "fill_color" layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["fill_color"] ) ); } else if ( properties.contains( "color" ) ) { layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["color"] ) ); } if ( properties.contains( "outline_color" ) ) { layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] ) ); } else if ( properties.contains( "line_color" ) ) { layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["line_color"] ) ); } if ( properties.contains( "size" ) ) { layer->setSize( properties["size"].toDouble() ); } if ( properties.contains( "size_unit" ) ) { layer->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["size_unit"] ) ); } if ( properties.contains( "size_map_unit_scale" ) ) { layer->setSizeMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["size_map_unit_scale"] ) ); } if ( properties.contains( "offset" ) ) { layer->setOffset( QgsSymbolLayerV2Utils::decodePoint( properties["offset"] ) ); } if ( properties.contains( "offset_unit" ) ) { layer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) ); } if ( properties.contains( "offset_map_unit_scale" ) ) { layer->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["offset_map_unit_scale"] ) ); } if ( properties.contains( "horizontal_anchor_point" ) ) { layer->setHorizontalAnchorPoint( QgsMarkerSymbolLayerV2::HorizontalAnchorPoint( properties[ "horizontal_anchor_point" ].toInt() ) ); } if ( properties.contains( "vertical_anchor_point" ) ) { layer->setVerticalAnchorPoint( QgsMarkerSymbolLayerV2::VerticalAnchorPoint( properties[ "vertical_anchor_point" ].toInt() ) ); } //data defined properties layer->restoreDataDefinedProperties( properties ); //compatibility with old project file format if ( !properties["width_field"].isEmpty() ) { layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH, new QgsDataDefined( properties["width_field"] ) ); } if ( !properties["height_field"].isEmpty() ) { layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT, new QgsDataDefined( properties["height_field"] ) ); } if ( !properties["rotation_field"].isEmpty() ) { layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, new QgsDataDefined( properties["rotation_field"] ) ); } if ( !properties["outline_width_field"].isEmpty() ) { layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, new QgsDataDefined( properties[ "outline_width_field" ] ) ); } if ( !properties["fill_color_field"].isEmpty() ) { layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, new QgsDataDefined( properties["fill_color_field"] ) ); } if ( !properties["outline_color_field"].isEmpty() ) { layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, new QgsDataDefined( properties["outline_color_field"] ) ); } if ( !properties["symbol_name_field"].isEmpty() ) { layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, new QgsDataDefined( properties["symbol_name_field"] ) ); } return layer; }
QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& properties ) { QgsEllipseSymbolLayerV2* layer = new QgsEllipseSymbolLayerV2(); if ( properties.contains( "symbol_name" ) ) { layer->setSymbolName( properties[ "symbol_name" ] ); } if ( properties.contains( "symbol_width" ) ) { layer->setSymbolWidth( properties["symbol_width"].toDouble() ); } if ( properties.contains( "symbol_width_unit" ) ) { layer->setSymbolWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_width_unit"] ) ); } if ( properties.contains( "symbol_width_map_unit_scale" ) ) { layer->setSymbolWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["symbol_width_map_unit_scale"] ) ); } if ( properties.contains( "symbol_height" ) ) { layer->setSymbolHeight( properties["symbol_height"].toDouble() ); } if ( properties.contains( "symbol_height_unit" ) ) { layer->setSymbolHeightUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_height_unit"] ) ); } if ( properties.contains( "symbol_height_map_unit_scale" ) ) { layer->setSymbolHeightMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["symbol_height_map_unit_scale"] ) ); } if ( properties.contains( "angle" ) ) { layer->setAngle( properties["angle"].toDouble() ); } if ( properties.contains( "outline_style" ) ) { layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["outline_style"] ) ); } if ( properties.contains( "outline_width" ) ) { layer->setOutlineWidth( properties["outline_width"].toDouble() ); } if ( properties.contains( "outline_width_unit" ) ) { layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) ); } if ( properties.contains( "outline_width_map_unit_scale" ) ) { layer->setOutlineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["outline_width_map_unit_scale"] ) ); } if ( properties.contains( "fill_color" ) ) { layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["fill_color"] ) ); } if ( properties.contains( "outline_color" ) ) { layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] ) ); } if ( properties.contains( "size" ) ) { layer->setSize( properties["size"].toDouble() ); } if ( properties.contains( "size_unit" ) ) { layer->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["size_unit"] ) ); } if ( properties.contains( "size_map_unit_scale" ) ) { layer->setSizeMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["size_map_unit_scale"] ) ); } if ( properties.contains( "offset" ) ) { layer->setOffset( QgsSymbolLayerV2Utils::decodePoint( properties["offset"] ) ); } if ( properties.contains( "offset_unit" ) ) { layer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) ); } if ( properties.contains( "offset_map_unit_scale" ) ) { layer->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["offset_map_unit_scale"] ) ); } if ( properties.contains( "horizontal_anchor_point" ) ) { layer->setHorizontalAnchorPoint( QgsMarkerSymbolLayerV2::HorizontalAnchorPoint( properties[ "horizontal_anchor_point" ].toInt() ) ); } if ( properties.contains( "vertical_anchor_point" ) ) { layer->setVerticalAnchorPoint( QgsMarkerSymbolLayerV2::VerticalAnchorPoint( properties[ "vertical_anchor_point" ].toInt() ) ); } //data defined properties if ( properties.contains( "width_expression" ) ) { layer->setDataDefinedProperty( "width", properties["width_expression"] ); } if ( properties.contains( "height_expression" ) ) { layer->setDataDefinedProperty( "height", properties["height_expression"] ); } if ( properties.contains( "rotation_expression" ) ) { layer->setDataDefinedProperty( "rotation", properties["rotation_expression"] ); } if ( properties.contains( "outline_width_expression" ) ) { layer->setDataDefinedProperty( "outline_width", properties[ "outline_width_expression" ] ); } if ( properties.contains( "fill_color_expression" ) ) { layer->setDataDefinedProperty( "fill_color", properties["fill_color_expression"] ); } if ( properties.contains( "outline_color_expression" ) ) { layer->setDataDefinedProperty( "outline_color", properties["outline_color_expression"] ); } if ( properties.contains( "symbol_name_expression" ) ) { layer->setDataDefinedProperty( "symbol_name", properties["symbol_name_expression"] ); } if ( properties.contains( "offset_expression" ) ) { layer->setDataDefinedProperty( "offset", properties["offset_expression"] ); } if ( properties.contains( "horizontal_anchor_point_expression" ) ) { layer->setDataDefinedProperty( "horizontal_anchor_point", properties[ "horizontal_anchor_point_expression" ] ); } if ( properties.contains( "vertical_anchor_point_expression" ) ) { layer->setDataDefinedProperty( "vertical_anchor_point", properties[ "vertical_anchor_point_expression" ] ); } //compatibility with old project file format if ( !properties["width_field"].isEmpty() ) { layer->setDataDefinedProperty( "width", properties["width_field"] ); } if ( !properties["height_field"].isEmpty() ) { layer->setDataDefinedProperty( "height", properties["height_field"] ); } if ( !properties["rotation_field"].isEmpty() ) { layer->setDataDefinedProperty( "rotation", properties["rotation_field"] ); } if ( !properties["outline_width_field"].isEmpty() ) { layer->setDataDefinedProperty( "outline_width", properties[ "outline_width_field" ] ); } if ( !properties["fill_color_field"].isEmpty() ) { layer->setDataDefinedProperty( "fill_color", properties["fill_color_field"] ); } if ( !properties["outline_color_field"].isEmpty() ) { layer->setDataDefinedProperty( "outline_color", properties["outline_color_field"] ); } if ( !properties["symbol_name_field"].isEmpty() ) { layer->setDataDefinedProperty( "symbol_name", properties["symbol_name_field"] ); } return layer; }