Skip to content
Permalink
Browse files

Remove QgsSymbolLayerV2Utils::encodeOutputUnit() and decodeOutputUnit()

QgsUnitTypes::encodeUnit() and QgsUnitTypes::decodeRenderUnit() should
be used instead.
  • Loading branch information
nyalldawson committed Jul 17, 2016
1 parent ce6bd6c commit 0324de3bf59f38e503bf4181679fcedc859b5d07
@@ -456,6 +456,12 @@ parameters or QgsSymbolV2::OutputUnitList parameters now take QgsUnitTypes::Rend
<li>subsetString() was made const. This has no effect on PyQGIS code, but c++ code implementing derived layer classes will need to update the signature of this method to match.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolLayerV2Utils QgsSymbolLayerV2Utils

<ul>
<li>encodeOutputUnit() and decodeOutputUnit() were removed. QgsUnitTypes::encodeUnit() and QgsUnitTypes::decodeRenderUnit() should be used instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsTreeWidgetItem QgsTreeWidgetItem

<ul>
@@ -51,9 +51,6 @@ class QgsSymbolLayerV2Utils
static QString encodeSldRealVector( const QVector<qreal>& v );
static QVector<qreal> decodeSldRealVector( const QString& s );

static QString encodeOutputUnit( QgsUnitTypes::RenderUnit unit );
static QgsUnitTypes::RenderUnit decodeOutputUnit( const QString& str );

static QString encodeSldUom( QgsUnitTypes::RenderUnit unit, double *scaleFactor );
static QgsUnitTypes::RenderUnit decodeSldUom( const QString& str, double *scaleFactor );

@@ -66,14 +66,14 @@ void QgsDecorationItem::projectRead()
{
mEnabled = QgsProject::instance()->readBoolEntry( mNameConfig, "/Enabled", false );
mPlacement = static_cast< Placement >( QgsProject::instance()->readNumEntry( mNameConfig, "/Placement", static_cast< int >( mPlacement ) ) );
mMarginUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( QgsProject::instance()->readEntry( mNameConfig, "/MarginUnit", QgsSymbolLayerV2Utils::encodeOutputUnit( mMarginUnit ) ) );
mMarginUnit = QgsUnitTypes::decodeRenderUnit( QgsProject::instance()->readEntry( mNameConfig, "/MarginUnit", QgsUnitTypes::encodeUnit( mMarginUnit ) ) );
}

void QgsDecorationItem::saveToProject()
{
QgsProject::instance()->writeEntry( mNameConfig, "/Enabled", mEnabled );
QgsProject::instance()->writeEntry( mNameConfig, "/Placement", static_cast< int >( mPlacement ) );
QgsProject::instance()->writeEntry( mNameConfig, "/MarginUnit", QgsSymbolLayerV2Utils::encodeOutputUnit( mMarginUnit ) );
QgsProject::instance()->writeEntry( mNameConfig, "/MarginUnit", QgsUnitTypes::encodeUnit( mMarginUnit ) );
}

void QgsDecorationItem::setName( const char *name )
@@ -124,7 +124,7 @@ QgsStringMap QgsGlowEffect::properties() const
props.insert( "transparency", QString::number( mTransparency ) );
props.insert( "blur_level", QString::number( mBlurLevel ) );
props.insert( "spread", QString::number( mSpread ) );
props.insert( "spread_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mSpreadUnit ) );
props.insert( "spread_unit", QgsUnitTypes::encodeUnit( mSpreadUnit ) );
props.insert( "spread_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mSpreadMapUnitScale ) );
props.insert( "color_type", QString::number( static_cast< int >( mColorType ) ) );
props.insert( "single_color", QgsSymbolLayerV2Utils::encodeColor( mColor ) );
@@ -162,7 +162,7 @@ void QgsGlowEffect::readProperties( const QgsStringMap &props )
{
mSpread = spread;
}
mSpreadUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( props.value( "spread_unit" ) );
mSpreadUnit = QgsUnitTypes::decodeRenderUnit( props.value( "spread_unit" ) );
mSpreadMapUnitScale = QgsSymbolLayerV2Utils::decodeMapUnitScale( props.value( "spread_unit_scale" ) );
QgsGlowEffect::GlowColorType type = static_cast< QgsGlowEffect::GlowColorType >( props.value( "color_type" ).toInt( &ok ) );
if ( ok )
@@ -103,7 +103,7 @@ QgsStringMap QgsShadowEffect::properties() const
props.insert( "blur_level", QString::number( mBlurLevel ) );
props.insert( "offset_angle", QString::number( mOffsetAngle ) );
props.insert( "offset_distance", QString::number( mOffsetDist ) );
props.insert( "offset_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ) );
props.insert( "offset_unit", QgsUnitTypes::encodeUnit( mOffsetUnit ) );
props.insert( "offset_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ) );
props.insert( "color", QgsSymbolLayerV2Utils::encodeColor( mColor ) );
return props;
@@ -139,7 +139,7 @@ void QgsShadowEffect::readProperties( const QgsStringMap &props )
{
mOffsetDist = distance;
}
mOffsetUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( props.value( "offset_unit" ) );
mOffsetUnit = QgsUnitTypes::decodeRenderUnit( props.value( "offset_unit" ) );
mOffsetMapUnitScale = QgsSymbolLayerV2Utils::decodeMapUnitScale( props.value( "offset_unit_scale" ) );
if ( props.contains( "color" ) )
{
@@ -78,7 +78,7 @@ QgsStringMap QgsTransformEffect::properties() const
props.insert( "shear_y", QString::number( mShearY ) );
props.insert( "translate_x", QString::number( mTranslateX ) );
props.insert( "translate_y", QString::number( mTranslateY ) );
props.insert( "translate_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mTranslateUnit ) );
props.insert( "translate_unit", QgsUnitTypes::encodeUnit( mTranslateUnit ) );
props.insert( "translate_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mTranslateMapUnitScale ) );
props.insert( "enabled", mEnabled ? "1" : "0" );
props.insert( "draw_mode", QString::number( int( mDrawMode ) ) );
@@ -96,7 +96,7 @@ void QgsTransformEffect::readProperties( const QgsStringMap &props )
mRotation = props.value( "rotation", "0.0" ).toDouble();
mTranslateX = props.value( "translate_x", "0.0" ).toDouble();
mTranslateY = props.value( "translate_y", "0.0" ).toDouble();
mTranslateUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( props.value( "translate_unit" ) );
mTranslateUnit = QgsUnitTypes::decodeRenderUnit( props.value( "translate_unit" ) );
mTranslateMapUnitScale = QgsSymbolLayerV2Utils::decodeMapUnitScale( props.value( "translate_unit_scale" ) );
}

@@ -197,12 +197,12 @@ void QgsDiagramSettings::readXml( const QDomElement& elem, const QgsVectorLayer*
}
else
{
sizeType = QgsSymbolLayerV2Utils::decodeOutputUnit( elem.attribute( "sizeType" ) );
sizeType = QgsUnitTypes::decodeRenderUnit( elem.attribute( "sizeType" ) );
}
sizeScale = QgsSymbolLayerV2Utils::decodeMapUnitScale( elem.attribute( "sizeScale" ) );

//line width unit type and scale
lineSizeUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( elem.attribute( "lineSizeType" ) );
lineSizeUnit = QgsUnitTypes::decodeRenderUnit( elem.attribute( "lineSizeType" ) );
lineSizeScale = QgsSymbolLayerV2Utils::decodeMapUnitScale( elem.attribute( "lineSizeScale" ) );

//label placement method
@@ -314,11 +314,11 @@ void QgsDiagramSettings::writeXml( QDomElement& rendererElem, QDomDocument& doc,
categoryElem.setAttribute( "transparency", QString::number( transparency ) );

//diagram size unit type and scale
categoryElem.setAttribute( "sizeType", QgsSymbolLayerV2Utils::encodeOutputUnit( sizeType ) );
categoryElem.setAttribute( "sizeType", QgsUnitTypes::encodeUnit( sizeType ) );
categoryElem.setAttribute( "sizeScale", QgsSymbolLayerV2Utils::encodeMapUnitScale( sizeScale ) );

//line width unit type and scale
categoryElem.setAttribute( "lineSizeType", QgsSymbolLayerV2Utils::encodeOutputUnit( lineSizeUnit ) );
categoryElem.setAttribute( "lineSizeType", QgsUnitTypes::encodeUnit( lineSizeUnit ) );
categoryElem.setAttribute( "lineSizeScale", QgsSymbolLayerV2Utils::encodeMapUnitScale( lineSizeScale ) );

// label placement method (text diagram)
@@ -4811,7 +4811,7 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
QgsStringMap map; // for SVG symbology marker
map["name"] = QgsSymbolLayerV2Utils::symbolNameToPath( tmpLyr.shapeSVGFile.trimmed() );
map["size"] = QString::number( sizeOut );
map["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit(
map["size_unit"] = QgsUnitTypes::encodeUnit(
tmpLyr.shapeSizeUnits == QgsPalLayerSettings::MapUnits ? QgsUnitTypes::RenderMapUnits : QgsUnitTypes::RenderMillimeters );
map["angle"] = QString::number( 0.0 ); // angle is handled by this local painter

@@ -63,7 +63,7 @@ QgsSymbolLayerV2* QgsArrowSymbolLayer::create( const QgsStringMap& props )
l->setArrowWidth( props["arrow_width"].toDouble() );

if ( props.contains( "arrow_width_unit" ) )
l->setArrowWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["arrow_width_unit"] ) );
l->setArrowWidthUnit( QgsUnitTypes::decodeRenderUnit( props["arrow_width_unit"] ) );

if ( props.contains( "arrow_width_unit_scale" ) )
l->setArrowWidthUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["arrow_width_unit_scale"] ) );
@@ -72,7 +72,7 @@ QgsSymbolLayerV2* QgsArrowSymbolLayer::create( const QgsStringMap& props )
l->setArrowStartWidth( props["arrow_start_width"].toDouble() );

if ( props.contains( "arrow_start_width_unit" ) )
l->setArrowStartWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["arrow_start_width_unit"] ) );
l->setArrowStartWidthUnit( QgsUnitTypes::decodeRenderUnit( props["arrow_start_width_unit"] ) );

if ( props.contains( "arrow_start_width_unit_scale" ) )
l->setArrowStartWidthUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["arrow_start_width_unit_scale"] ) );
@@ -87,7 +87,7 @@ QgsSymbolLayerV2* QgsArrowSymbolLayer::create( const QgsStringMap& props )
l->setHeadLength( props["head_length"].toDouble() );

if ( props.contains( "head_length_unit" ) )
l->setHeadLengthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_length_unit"] ) );
l->setHeadLengthUnit( QgsUnitTypes::decodeRenderUnit( props["head_length_unit"] ) );

if ( props.contains( "head_length_unit_scale" ) )
l->setHeadLengthUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_length_unit_scale"] ) );
@@ -96,7 +96,7 @@ QgsSymbolLayerV2* QgsArrowSymbolLayer::create( const QgsStringMap& props )
l->setHeadThickness( props["head_thickness"].toDouble() );

if ( props.contains( "head_thickness_unit" ) )
l->setHeadThicknessUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["head_thickness_unit"] ) );
l->setHeadThicknessUnit( QgsUnitTypes::decodeRenderUnit( props["head_thickness_unit"] ) );

if ( props.contains( "head_thickness_unit_scale" ) )
l->setHeadThicknessUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["head_thickness_unit_scale"] ) );
@@ -111,7 +111,7 @@ QgsSymbolLayerV2* QgsArrowSymbolLayer::create( const QgsStringMap& props )
l->setOffset( props["offset"].toDouble() );

if ( props.contains( "offset_unit" ) )
l->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) );
l->setOffsetUnit( QgsUnitTypes::decodeRenderUnit( props["offset_unit"] ) );

if ( props.contains( "offset_unit_scale" ) )
l->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["offset_unit_scale"] ) );
@@ -142,29 +142,29 @@ QgsStringMap QgsArrowSymbolLayer::properties() const
QgsStringMap map;

map["arrow_width"] = QString::number( arrowWidth() );
map["arrow_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( arrowWidthUnit() );
map["arrow_width_unit"] = QgsUnitTypes::encodeUnit( arrowWidthUnit() );
map["arrow_width_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( arrowWidthUnitScale() );

map["arrow_start_width"] = QString::number( arrowStartWidth() );
map["arrow_start_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( arrowStartWidthUnit() );
map["arrow_start_width_unit"] = QgsUnitTypes::encodeUnit( arrowStartWidthUnit() );
map["arrow_start_width_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( arrowStartWidthUnitScale() );

map["is_curved"] = QString::number( isCurved() ? 1 : 0 );
map["is_repeated"] = QString::number( isRepeated() ? 1 : 0 );

map["head_length"] = QString::number( headLength() );
map["head_length_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headLengthUnit() );
map["head_length_unit"] = QgsUnitTypes::encodeUnit( headLengthUnit() );
map["head_length_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headLengthUnitScale() );

map["head_thickness"] = QString::number( headThickness() );
map["head_thickness_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( headThicknessUnit() );
map["head_thickness_unit"] = QgsUnitTypes::encodeUnit( headThicknessUnit() );
map["head_thickness_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( headThicknessUnitScale() );

map["head_type"] = QString::number( headType() );
map["arrow_type"] = QString::number( arrowType() );

map["offset"] = QString::number( offset() );
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( offsetUnit() );
map["offset_unit"] = QgsUnitTypes::encodeUnit( offsetUnit() );
map["offset_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( offsetMapUnitScale() );

saveDataDefinedProperties( map );
@@ -68,7 +68,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
}
if ( properties.contains( "symbol_width_unit" ) )
{
layer->setSymbolWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_width_unit"] ) );
layer->setSymbolWidthUnit( QgsUnitTypes::decodeRenderUnit( properties["symbol_width_unit"] ) );
}
if ( properties.contains( "symbol_width_map_unit_scale" ) )
{
@@ -80,7 +80,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
}
if ( properties.contains( "symbol_height_unit" ) )
{
layer->setSymbolHeightUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_height_unit"] ) );
layer->setSymbolHeightUnit( QgsUnitTypes::decodeRenderUnit( properties["symbol_height_unit"] ) );
}
if ( properties.contains( "symbol_height_map_unit_scale" ) )
{
@@ -112,11 +112,11 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
}
if ( properties.contains( "outline_width_unit" ) )
{
layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) );
layer->setOutlineWidthUnit( QgsUnitTypes::decodeRenderUnit( properties["outline_width_unit"] ) );
}
else if ( properties.contains( "line_width_unit" ) )
{
layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["line_width_unit"] ) );
layer->setOutlineWidthUnit( QgsUnitTypes::decodeRenderUnit( properties["line_width_unit"] ) );
}
if ( properties.contains( "outline_width_map_unit_scale" ) )
{
@@ -145,7 +145,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
}
if ( properties.contains( "size_unit" ) )
{
layer->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["size_unit"] ) );
layer->setSizeUnit( QgsUnitTypes::decodeRenderUnit( properties["size_unit"] ) );
}
if ( properties.contains( "size_map_unit_scale" ) )
{
@@ -157,7 +157,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
}
if ( properties.contains( "offset_unit" ) )
{
layer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) );
layer->setOffsetUnit( QgsUnitTypes::decodeRenderUnit( properties["offset_unit"] ) );
}
if ( properties.contains( "offset_map_unit_scale" ) )
{
@@ -510,24 +510,24 @@ QgsStringMap QgsEllipseSymbolLayerV2::properties() const
QgsStringMap map;
map["symbol_name"] = mSymbolName;
map["symbol_width"] = QString::number( mSymbolWidth );
map["symbol_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSymbolWidthUnit );
map["symbol_width_unit"] = QgsUnitTypes::encodeUnit( mSymbolWidthUnit );
map["symbol_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSymbolWidthMapUnitScale );
map["symbol_height"] = QString::number( mSymbolHeight );
map["symbol_height_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSymbolHeightUnit );
map["symbol_height_unit"] = QgsUnitTypes::encodeUnit( mSymbolHeightUnit );
map["symbol_height_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSymbolHeightMapUnitScale );
map["angle"] = QString::number( mAngle );
map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle );
map["outline_width"] = QString::number( mOutlineWidth );
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
map["outline_width_unit"] = QgsUnitTypes::encodeUnit( mOutlineWidthUnit );
map["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale );
map["joinstyle"] = QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle );
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor );
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit );
map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale );
map["size"] = QString::number( mSize );
map["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSizeUnit );
map["size_unit"] = QgsUnitTypes::encodeUnit( mSizeUnit );
map["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale );
map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint );
map["vertical_anchor_point"] = QString::number( mVerticalAnchorPoint );

0 comments on commit 0324de3

Please sign in to comment.
You can’t perform that action at this time.