diff --git a/python/core/qgsunittypes.sip b/python/core/qgsunittypes.sip index 1944711913e..2e050937970 100644 --- a/python/core/qgsunittypes.sip +++ b/python/core/qgsunittypes.sip @@ -113,20 +113,5 @@ class QgsUnitTypes */ static double fromUnitToUnitFactor( AreaUnit fromUnit, AreaUnit toUnit ); - /** Encodes a symbol unit to a string. - * @param unit unit to encode - * @returns encoded string - * @see decodeSymbolUnit() - */ - static QString encodeUnit( QgsSymbolV2::OutputUnit unit ); - - /** Decodes a symbol unit from a string. - * @param string string to decode - * @param ok optional boolean, will be set to true if string was converted successfully - * @returns decoded units - * @see encodeUnit() - */ - static QgsSymbolV2::OutputUnit decodeSymbolUnit( const QString& string, bool *ok = 0 ); - }; diff --git a/python/core/symbology-ng/qgssymbollayerv2utils.sip b/python/core/symbology-ng/qgssymbollayerv2utils.sip index 335a2275b80..e605fdd4a1c 100644 --- a/python/core/symbology-ng/qgssymbollayerv2utils.sip +++ b/python/core/symbology-ng/qgssymbollayerv2utils.sip @@ -51,10 +51,8 @@ class QgsSymbolLayerV2Utils static QString encodeSldRealVector( const QVector& v ); static QVector decodeSldRealVector( const QString& s ); - //! @deprecated use QgsUnitTypes::encodeUnit() instead - static QString encodeOutputUnit( QgsSymbolV2::OutputUnit unit ) /Deprecated/; - //! @deprecated use QgsUnitTypes::decodeSymbolUnit() instead - static QgsSymbolV2::OutputUnit decodeOutputUnit( const QString& str ) /Deprecated/; + static QString encodeOutputUnit( QgsSymbolV2::OutputUnit unit ); + static QgsSymbolV2::OutputUnit decodeOutputUnit( const QString& str ); static QString encodeSldUom( QgsSymbolV2::OutputUnit unit, double *scaleFactor ); static QgsSymbolV2::OutputUnit decodeSldUom( const QString& str, double *scaleFactor ); diff --git a/src/app/qgsdecorationitem.cpp b/src/app/qgsdecorationitem.cpp index d20e52cf347..ace8308bb41 100644 --- a/src/app/qgsdecorationitem.cpp +++ b/src/app/qgsdecorationitem.cpp @@ -67,7 +67,7 @@ void QgsDecorationItem::projectRead() QgsDebugMsg( "Entered" ); mEnabled = QgsProject::instance()->readBoolEntry( mNameConfig, "/Enabled", false ); mPlacement = static_cast< Placement >( QgsProject::instance()->readNumEntry( mNameConfig, "/Placement", static_cast< int >( mPlacement ) ) ); - mMarginUnit = QgsUnitTypes::decodeSymbolUnit( QgsProject::instance()->readEntry( mNameConfig, "/MarginUnit", QgsUnitTypes::encodeUnit( mMarginUnit ) ) ); + mMarginUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( QgsProject::instance()->readEntry( mNameConfig, "/MarginUnit", QgsSymbolLayerV2Utils::encodeOutputUnit( mMarginUnit ) ) ); } void QgsDecorationItem::saveToProject() @@ -75,7 +75,7 @@ void QgsDecorationItem::saveToProject() QgsDebugMsg( "Entered" ); QgsProject::instance()->writeEntry( mNameConfig, "/Enabled", mEnabled ); QgsProject::instance()->writeEntry( mNameConfig, "/Placement", static_cast< int >( mPlacement ) ); - QgsProject::instance()->writeEntry( mNameConfig, "/MarginUnit", QgsUnitTypes::encodeUnit( mMarginUnit ) ); + QgsProject::instance()->writeEntry( mNameConfig, "/MarginUnit", QgsSymbolLayerV2Utils::encodeOutputUnit( mMarginUnit ) ); } void QgsDecorationItem::setName( const char *name ) diff --git a/src/core/effects/qgsgloweffect.cpp b/src/core/effects/qgsgloweffect.cpp index 46c7da765e5..33b5d9f1a3d 100644 --- a/src/core/effects/qgsgloweffect.cpp +++ b/src/core/effects/qgsgloweffect.cpp @@ -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", QgsUnitTypes::encodeUnit( mSpreadUnit ) ); + props.insert( "spread_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( 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 = QgsUnitTypes::decodeSymbolUnit( props.value( "spread_unit" ) ); + mSpreadUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( 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 ) diff --git a/src/core/effects/qgsshadoweffect.cpp b/src/core/effects/qgsshadoweffect.cpp index c0f63e35818..e0b9ef5a391 100644 --- a/src/core/effects/qgsshadoweffect.cpp +++ b/src/core/effects/qgsshadoweffect.cpp @@ -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", QgsUnitTypes::encodeUnit( mOffsetUnit ) ); + props.insert( "offset_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( 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 = QgsUnitTypes::decodeSymbolUnit( props.value( "offset_unit" ) ); + mOffsetUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( props.value( "offset_unit" ) ); mOffsetMapUnitScale = QgsSymbolLayerV2Utils::decodeMapUnitScale( props.value( "offset_unit_scale" ) ); if ( props.contains( "color" ) ) { diff --git a/src/core/effects/qgstransformeffect.cpp b/src/core/effects/qgstransformeffect.cpp index d9b0d6aab21..2decba9b7b4 100644 --- a/src/core/effects/qgstransformeffect.cpp +++ b/src/core/effects/qgstransformeffect.cpp @@ -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", QgsUnitTypes::encodeUnit( mTranslateUnit ) ); + props.insert( "translate_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( 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 = QgsUnitTypes::decodeSymbolUnit( props.value( "translate_unit" ) ); + mTranslateUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( props.value( "translate_unit" ) ); mTranslateMapUnitScale = QgsSymbolLayerV2Utils::decodeMapUnitScale( props.value( "translate_unit_scale" ) ); } diff --git a/src/core/qgspallabeling.cpp b/src/core/qgspallabeling.cpp index e9c751f2344..d1d8afba38c 100644 --- a/src/core/qgspallabeling.cpp +++ b/src/core/qgspallabeling.cpp @@ -4627,7 +4627,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"] = QgsUnitTypes::encodeUnit( + map["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( tmpLyr.shapeSizeUnits == QgsPalLayerSettings::MapUnits ? QgsSymbolV2::MapUnit : QgsSymbolV2::MM ); map["angle"] = QString::number( 0.0 ); // angle is handled by this local painter diff --git a/src/core/qgsunittypes.cpp b/src/core/qgsunittypes.cpp index 8ddf5389a83..450351fefe6 100644 --- a/src/core/qgsunittypes.cpp +++ b/src/core/qgsunittypes.cpp @@ -462,6 +462,9 @@ double QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaUnit fromUnit, QgsU return 1.0; } +// enable for QGIS 3.0 +#if 0 + QString QgsUnitTypes::encodeUnit( QgsSymbolV2::OutputUnit unit ) { switch ( unit ) @@ -501,3 +504,5 @@ QgsSymbolV2::OutputUnit QgsUnitTypes::decodeSymbolUnit( const QString& string, b // millimeters are default return QgsSymbolV2::MM; } + +#endif diff --git a/src/core/qgsunittypes.h b/src/core/qgsunittypes.h index 3a694eaeeb4..3f2e717e065 100644 --- a/src/core/qgsunittypes.h +++ b/src/core/qgsunittypes.h @@ -19,7 +19,6 @@ #define QGSUNITTYPES_H #include "qgis.h" -#include "symbology-ng/qgssymbolv2.h" /*************************************************************************** * This class is considered CRITICAL and any change MUST be accompanied with @@ -142,6 +141,8 @@ class CORE_EXPORT QgsUnitTypes */ static double fromUnitToUnitFactor( AreaUnit fromUnit, AreaUnit toUnit ); + //TODO QGIS 3.0 - enable and move symbol units here! Otherwise creates circular dependancies... +#if 0 // SYMBOL UNITS /** Encodes a symbol unit to a string. @@ -158,6 +159,7 @@ class CORE_EXPORT QgsUnitTypes * @see encodeUnit() */ static QgsSymbolV2::OutputUnit decodeSymbolUnit( const QString& string, bool *ok = 0 ); +#endif }; diff --git a/src/core/symbology-ng/qgsellipsesymbollayerv2.cpp b/src/core/symbology-ng/qgsellipsesymbollayerv2.cpp index 4c2536b775a..86bb8054b7e 100644 --- a/src/core/symbology-ng/qgsellipsesymbollayerv2.cpp +++ b/src/core/symbology-ng/qgsellipsesymbollayerv2.cpp @@ -68,7 +68,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie } if ( properties.contains( "symbol_width_unit" ) ) { - layer->setSymbolWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["symbol_width_unit"] ) ); + layer->setSymbolWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( 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( QgsUnitTypes::decodeSymbolUnit( properties["symbol_height_unit"] ) ); + layer->setSymbolHeightUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_height_unit"] ) ); } if ( properties.contains( "symbol_height_map_unit_scale" ) ) { @@ -108,11 +108,11 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie } if ( properties.contains( "outline_width_unit" ) ) { - layer->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["outline_width_unit"] ) ); + layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) ); } else if ( properties.contains( "line_width_unit" ) ) { - layer->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["line_width_unit"] ) ); + layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["line_width_unit"] ) ); } if ( properties.contains( "outline_width_map_unit_scale" ) ) { @@ -141,7 +141,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie } if ( properties.contains( "size_unit" ) ) { - layer->setSizeUnit( QgsUnitTypes::decodeSymbolUnit( properties["size_unit"] ) ); + layer->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["size_unit"] ) ); } if ( properties.contains( "size_map_unit_scale" ) ) { @@ -153,7 +153,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie } if ( properties.contains( "offset_unit" ) ) { - layer->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( properties["offset_unit"] ) ); + layer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) ); } if ( properties.contains( "offset_map_unit_scale" ) ) { @@ -471,23 +471,23 @@ QgsStringMap QgsEllipseSymbolLayerV2::properties() const QgsStringMap map; map["symbol_name"] = mSymbolName; map["symbol_width"] = QString::number( mSymbolWidth ); - map["symbol_width_unit"] = QgsUnitTypes::encodeUnit( mSymbolWidthUnit ); + map["symbol_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSymbolWidthUnit ); map["symbol_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSymbolWidthMapUnitScale ); map["symbol_height"] = QString::number( mSymbolHeight ); - map["symbol_height_unit"] = QgsUnitTypes::encodeUnit( mSymbolHeightUnit ); + map["symbol_height_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( 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"] = QgsUnitTypes::encodeUnit( mOutlineWidthUnit ); + map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit ); map["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale ); map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor ); map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ); map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); map["size"] = QString::number( mSize ); - map["size_unit"] = QgsUnitTypes::encodeUnit( mSizeUnit ); + map["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSizeUnit ); map["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale ); map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint ); map["vertical_anchor_point"] = QString::number( mVerticalAnchorPoint ); diff --git a/src/core/symbology-ng/qgsfillsymbollayerv2.cpp b/src/core/symbology-ng/qgsfillsymbollayerv2.cpp index 8060208875a..ec27bd5b4f0 100644 --- a/src/core/symbology-ng/qgsfillsymbollayerv2.cpp +++ b/src/core/symbology-ng/qgsfillsymbollayerv2.cpp @@ -198,18 +198,18 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props sl->setOffset( offset ); if ( props.contains( "border_width_unit" ) ) { - sl->setBorderWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["border_width_unit"] ) ); + sl->setBorderWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["border_width_unit"] ) ); } else if ( props.contains( "outline_width_unit" ) ) { - sl->setBorderWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["outline_width_unit"] ) ); + sl->setBorderWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) ); } else if ( props.contains( "line_width_unit" ) ) { - sl->setBorderWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["line_width_unit"] ) ); + sl->setBorderWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["line_width_unit"] ) ); } if ( props.contains( "offset_unit" ) ) - sl->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_unit"] ) ); + sl->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) ); if ( props.contains( "border_width_map_unit_scale" ) ) sl->setBorderWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["border_width_map_unit_scale"] ) ); @@ -301,11 +301,11 @@ QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor ); map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mBorderStyle ); map["outline_width"] = QString::number( mBorderWidth ); - map["outline_width_unit"] = QgsUnitTypes::encodeUnit( mBorderWidthUnit ); + map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mBorderWidthUnit ); map["border_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mBorderWidthMapUnitScale ); map["joinstyle"] = QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle ); map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); saveDataDefinedProperties( map ); return map; @@ -530,7 +530,7 @@ QgsSymbolLayerV2* QgsGradientFillSymbolLayerV2::create( const QgsStringMap& prop QgsGradientFillSymbolLayerV2* sl = new QgsGradientFillSymbolLayerV2( color, color2, colorType, type, coordinateMode, gradientSpread ); sl->setOffset( offset ); if ( props.contains( "offset_unit" ) ) - sl->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_unit"] ) ); + sl->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) ); if ( props.contains( "offset_map_unit_scale" ) ) sl->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["offset_map_unit_scale"] ) ); sl->setReferencePoint1( referencePoint1 ); @@ -877,7 +877,7 @@ QgsStringMap QgsGradientFillSymbolLayerV2::properties() const map["reference_point2_iscentroid"] = QString::number( mReferencePoint2IsCentroid ); map["angle"] = QString::number( mAngle ); map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); saveDataDefinedProperties( map ); if ( mGradientRamp ) @@ -1014,11 +1014,11 @@ QgsSymbolLayerV2* QgsShapeburstFillSymbolLayerV2::create( const QgsStringMap& pr sl->setOffset( offset ); if ( props.contains( "offset_unit" ) ) { - sl->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_unit"] ) ); + sl->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) ); } if ( props.contains( "distance_unit" ) ) { - sl->setDistanceUnit( QgsUnitTypes::decodeSymbolUnit( props["distance_unit"] ) ); + sl->setDistanceUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["distance_unit"] ) ); } if ( props.contains( "offset_map_unit_scale" ) ) { @@ -1473,11 +1473,11 @@ QgsStringMap QgsShapeburstFillSymbolLayerV2::properties() const map["blur_radius"] = QString::number( mBlurRadius ); map["use_whole_shape"] = QString::number( mUseWholeShape ); map["max_distance"] = QString::number( mMaxDistance ); - map["distance_unit"] = QgsUnitTypes::encodeUnit( mDistanceUnit ); + map["distance_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mDistanceUnit ); map["distance_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mDistanceMapUnitScale ); map["ignore_rings"] = QString::number( mIgnoreRings ); map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); saveDataDefinedProperties( map ); @@ -1880,7 +1880,7 @@ QgsSymbolLayerV2* QgsSVGFillSymbolLayer::create( const QgsStringMap& properties //units if ( properties.contains( "pattern_width_unit" ) ) { - symbolLayer->setPatternWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["pattern_width_unit"] ) ); + symbolLayer->setPatternWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["pattern_width_unit"] ) ); } if ( properties.contains( "pattern_width_map_unit_scale" ) ) { @@ -1888,7 +1888,7 @@ QgsSymbolLayerV2* QgsSVGFillSymbolLayer::create( const QgsStringMap& properties } if ( properties.contains( "svg_outline_width_unit" ) ) { - symbolLayer->setSvgOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["svg_outline_width_unit"] ) ); + symbolLayer->setSvgOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["svg_outline_width_unit"] ) ); } if ( properties.contains( "svg_outline_width_map_unit_scale" ) ) { @@ -1896,7 +1896,7 @@ QgsSymbolLayerV2* QgsSVGFillSymbolLayer::create( const QgsStringMap& properties } if ( properties.contains( "outline_width_unit" ) ) { - symbolLayer->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["outline_width_unit"] ) ); + symbolLayer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) ); } if ( properties.contains( "outline_width_map_unit_scale" ) ) { @@ -2012,11 +2012,11 @@ QgsStringMap QgsSVGFillSymbolLayer::properties() const map.insert( "outline_width", QString::number( mSvgOutlineWidth ) ); //units - map.insert( "pattern_width_unit", QgsUnitTypes::encodeUnit( mPatternWidthUnit ) ); + map.insert( "pattern_width_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mPatternWidthUnit ) ); map.insert( "pattern_width_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mPatternWidthMapUnitScale ) ); - map.insert( "svg_outline_width_unit", QgsUnitTypes::encodeUnit( mSvgOutlineWidthUnit ) ); + map.insert( "svg_outline_width_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mSvgOutlineWidthUnit ) ); map.insert( "svg_outline_width_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mSvgOutlineWidthMapUnitScale ) ); - map.insert( "outline_width_unit", QgsUnitTypes::encodeUnit( mOutlineWidthUnit ) ); + map.insert( "outline_width_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit ) ); map.insert( "outline_width_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale ) ); saveDataDefinedProperties( map ); @@ -2465,7 +2465,7 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::create( const QgsStringMap& pro if ( properties.contains( "distance_unit" ) ) { - patternLayer->setDistanceUnit( QgsUnitTypes::decodeSymbolUnit( properties["distance_unit"] ) ); + patternLayer->setDistanceUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["distance_unit"] ) ); } if ( properties.contains( "distance_map_unit_scale" ) ) { @@ -2473,11 +2473,11 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::create( const QgsStringMap& pro } if ( properties.contains( "line_width_unit" ) ) { - patternLayer->setLineWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["line_width_unit"] ) ); + patternLayer->setLineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["line_width_unit"] ) ); } else if ( properties.contains( "outline_width_unit" ) ) { - patternLayer->setLineWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["outline_width_unit"] ) ); + patternLayer->setLineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) ); } if ( properties.contains( "line_width_map_unit_scale" ) ) { @@ -2485,7 +2485,7 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::create( const QgsStringMap& pro } if ( properties.contains( "offset_unit" ) ) { - patternLayer->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( properties["offset_unit"] ) ); + patternLayer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) ); } if ( properties.contains( "offset_map_unit_scale" ) ) { @@ -2493,7 +2493,7 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::create( const QgsStringMap& pro } if ( properties.contains( "outline_width_unit" ) ) { - patternLayer->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["outline_width_unit"] ) ); + patternLayer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) ); } if ( properties.contains( "outline_width_map_unit_scale" ) ) { @@ -2823,13 +2823,13 @@ QgsStringMap QgsLinePatternFillSymbolLayer::properties() const map.insert( "line_width", QString::number( mLineWidth ) ); map.insert( "color", QgsSymbolLayerV2Utils::encodeColor( mColor ) ); map.insert( "offset", QString::number( mOffset ) ); - map.insert( "distance_unit", QgsUnitTypes::encodeUnit( mDistanceUnit ) ); - map.insert( "line_width_unit", QgsUnitTypes::encodeUnit( mLineWidthUnit ) ); - map.insert( "offset_unit", QgsUnitTypes::encodeUnit( mOffsetUnit ) ); + map.insert( "distance_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mDistanceUnit ) ); + map.insert( "line_width_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mLineWidthUnit ) ); + map.insert( "offset_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ) ); map.insert( "distance_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mDistanceMapUnitScale ) ); map.insert( "line_width_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mLineWidthMapUnitScale ) ); map.insert( "offset_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ) ); - map.insert( "outline_width_unit", QgsUnitTypes::encodeUnit( mOutlineWidthUnit ) ); + map.insert( "outline_width_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit ) ); map.insert( "outline_width_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale ) ); saveDataDefinedProperties( map ); return map; @@ -3092,7 +3092,7 @@ QgsSymbolLayerV2* QgsPointPatternFillSymbolLayer::create( const QgsStringMap& pr if ( properties.contains( "distance_x_unit" ) ) { - layer->setDistanceXUnit( QgsUnitTypes::decodeSymbolUnit( properties["distance_x_unit"] ) ); + layer->setDistanceXUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["distance_x_unit"] ) ); } if ( properties.contains( "distance_x_map_unit_scale" ) ) { @@ -3100,7 +3100,7 @@ QgsSymbolLayerV2* QgsPointPatternFillSymbolLayer::create( const QgsStringMap& pr } if ( properties.contains( "distance_y_unit" ) ) { - layer->setDistanceYUnit( QgsUnitTypes::decodeSymbolUnit( properties["distance_y_unit"] ) ); + layer->setDistanceYUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["distance_y_unit"] ) ); } if ( properties.contains( "distance_y_map_unit_scale" ) ) { @@ -3108,7 +3108,7 @@ QgsSymbolLayerV2* QgsPointPatternFillSymbolLayer::create( const QgsStringMap& pr } if ( properties.contains( "displacement_x_unit" ) ) { - layer->setDisplacementXUnit( QgsUnitTypes::decodeSymbolUnit( properties["displacement_x_unit"] ) ); + layer->setDisplacementXUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["displacement_x_unit"] ) ); } if ( properties.contains( "displacement_x_map_unit_scale" ) ) { @@ -3116,7 +3116,7 @@ QgsSymbolLayerV2* QgsPointPatternFillSymbolLayer::create( const QgsStringMap& pr } if ( properties.contains( "displacement_y_unit" ) ) { - layer->setDisplacementYUnit( QgsUnitTypes::decodeSymbolUnit( properties["displacement_y_unit"] ) ); + layer->setDisplacementYUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["displacement_y_unit"] ) ); } if ( properties.contains( "displacement_y_map_unit_scale" ) ) { @@ -3124,7 +3124,7 @@ QgsSymbolLayerV2* QgsPointPatternFillSymbolLayer::create( const QgsStringMap& pr } if ( properties.contains( "outline_width_unit" ) ) { - layer->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["outline_width_unit"] ) ); + layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) ); } if ( properties.contains( "outline_width_map_unit_scale" ) ) { @@ -3235,15 +3235,15 @@ QgsStringMap QgsPointPatternFillSymbolLayer::properties() const map.insert( "distance_y", QString::number( mDistanceY ) ); map.insert( "displacement_x", QString::number( mDisplacementX ) ); map.insert( "displacement_y", QString::number( mDisplacementY ) ); - map.insert( "distance_x_unit", QgsUnitTypes::encodeUnit( mDistanceXUnit ) ); - map.insert( "distance_y_unit", QgsUnitTypes::encodeUnit( mDistanceYUnit ) ); - map.insert( "displacement_x_unit", QgsUnitTypes::encodeUnit( mDisplacementXUnit ) ); - map.insert( "displacement_y_unit", QgsUnitTypes::encodeUnit( mDisplacementYUnit ) ); + map.insert( "distance_x_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mDistanceXUnit ) ); + map.insert( "distance_y_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mDistanceYUnit ) ); + map.insert( "displacement_x_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mDisplacementXUnit ) ); + map.insert( "displacement_y_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mDisplacementYUnit ) ); map.insert( "distance_x_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mDistanceXMapUnitScale ) ); map.insert( "distance_y_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mDistanceYMapUnitScale ) ); map.insert( "displacement_x_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mDisplacementXMapUnitScale ) ); map.insert( "displacement_y_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mDisplacementYMapUnitScale ) ); - map.insert( "outline_width_unit", QgsUnitTypes::encodeUnit( mOutlineWidthUnit ) ); + map.insert( "outline_width_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit ) ); map.insert( "outline_width_map_unit_scale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale ) ); saveDataDefinedProperties( map ); return map; @@ -3591,7 +3591,7 @@ QgsSymbolLayerV2 *QgsRasterFillSymbolLayer::create( const QgsStringMap &properti symbolLayer->setWidth( width ); if ( properties.contains( "offset_unit" ) ) { - symbolLayer->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( properties["offset_unit"] ) ); + symbolLayer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) ); } if ( properties.contains( "offset_map_unit_scale" ) ) { @@ -3599,7 +3599,7 @@ QgsSymbolLayerV2 *QgsRasterFillSymbolLayer::create( const QgsStringMap &properti } if ( properties.contains( "width_unit" ) ) { - symbolLayer->setWidthUnit( QgsUnitTypes::decodeSymbolUnit( properties["width_unit"] ) ); + symbolLayer->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["width_unit"] ) ); } if ( properties.contains( "width_map_unit_scale" ) ) { @@ -3669,11 +3669,11 @@ QgsStringMap QgsRasterFillSymbolLayer::properties() const map["coordinate_mode"] = QString::number( mCoordinateMode ); map["alpha"] = QString::number( mAlpha ); map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); map["angle"] = QString::number( mAngle ); map["width"] = QString::number( mWidth ); - map["width_unit"] = QgsUnitTypes::encodeUnit( mWidthUnit ); + map["width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mWidthUnit ); map["width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mWidthMapUnitScale ); saveDataDefinedProperties( map ); diff --git a/src/core/symbology-ng/qgslinesymbollayerv2.cpp b/src/core/symbology-ng/qgslinesymbollayerv2.cpp index 8413c07f0cc..26b68436784 100644 --- a/src/core/symbology-ng/qgslinesymbollayerv2.cpp +++ b/src/core/symbology-ng/qgslinesymbollayerv2.cpp @@ -129,23 +129,23 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::create( const QgsStringMap& props QgsSimpleLineSymbolLayerV2* l = new QgsSimpleLineSymbolLayerV2( color, width, penStyle ); if ( props.contains( "line_width_unit" ) ) { - l->setWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["line_width_unit"] ) ); + l->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["line_width_unit"] ) ); } else if ( props.contains( "outline_width_unit" ) ) { - l->setWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["outline_width_unit"] ) ); + l->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) ); } else if ( props.contains( "width_unit" ) ) { //pre 2.5 projects used "width_unit" - l->setWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["width_unit"] ) ); + l->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["width_unit"] ) ); } if ( props.contains( "width_map_unit_scale" ) ) l->setWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["width_map_unit_scale"] ) ); if ( props.contains( "offset" ) ) l->setOffset( props["offset"].toDouble() ); if ( props.contains( "offset_unit" ) ) - l->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_unit"] ) ); + l->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) ); if ( props.contains( "offset_map_unit_scale" ) ) l->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["offset_map_unit_scale"] ) ); if ( props.contains( "joinstyle" ) ) @@ -163,7 +163,7 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::create( const QgsStringMap& props } if ( props.contains( "customdash_unit" ) ) { - l->setCustomDashPatternUnit( QgsUnitTypes::decodeSymbolUnit( props["customdash_unit"] ) ); + l->setCustomDashPatternUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["customdash_unit"] ) ); } if ( props.contains( "customdash_map_unit_scale" ) ) { @@ -355,17 +355,17 @@ QgsStringMap QgsSimpleLineSymbolLayerV2::properties() const QgsStringMap map; map["line_color"] = QgsSymbolLayerV2Utils::encodeColor( mColor ); map["line_width"] = QString::number( mWidth ); - map["line_width_unit"] = QgsUnitTypes::encodeUnit( mWidthUnit ); + map["line_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mWidthUnit ); map["width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mWidthMapUnitScale ); map["line_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mPenStyle ); map["joinstyle"] = QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle ); map["capstyle"] = QgsSymbolLayerV2Utils::encodePenCapStyle( mPenCapStyle ); map["offset"] = QString::number( mOffset ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); map["use_custom_dash"] = ( mUseCustomDashPattern ? "1" : "0" ); map["customdash"] = QgsSymbolLayerV2Utils::encodeRealVector( mCustomDashVector ); - map["customdash_unit"] = QgsUnitTypes::encodeUnit( mCustomDashPatternUnit ); + map["customdash_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mCustomDashPatternUnit ); map["customdash_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mCustomDashPatternMapUnitScale ); map["draw_inside_polygon"] = ( mDrawInsidePolygon ? "1" : "0" ); saveDataDefinedProperties( map ); @@ -749,11 +749,11 @@ QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2::create( const QgsStringMap& props } if ( props.contains( "offset_unit" ) ) { - x->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_unit"] ) ); + x->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) ); } if ( props.contains( "interval_unit" ) ) { - x->setIntervalUnit( QgsUnitTypes::decodeSymbolUnit( props["interval_unit"] ) ); + x->setIntervalUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["interval_unit"] ) ); } if ( props.contains( "offset_along_line" ) ) { @@ -761,7 +761,7 @@ QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2::create( const QgsStringMap& props } if ( props.contains( "offset_along_line_unit" ) ) { - x->setOffsetAlongLineUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_along_line_unit"] ) ); + x->setOffsetAlongLineUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_along_line_unit"] ) ); } if ( props.contains(( "offset_along_line_map_unit_scale" ) ) ) { @@ -1315,11 +1315,11 @@ QgsStringMap QgsMarkerLineSymbolLayerV2::properties() const map["interval"] = QString::number( mInterval ); map["offset"] = QString::number( mOffset ); map["offset_along_line"] = QString::number( mOffsetAlongLine ); - map["offset_along_line_unit"] = QgsUnitTypes::encodeUnit( mOffsetAlongLineUnit ); + map["offset_along_line_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetAlongLineUnit ); map["offset_along_line_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetAlongLineMapUnitScale ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); - map["interval_unit"] = QgsUnitTypes::encodeUnit( mIntervalUnit ); + map["interval_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mIntervalUnit ); map["interval_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mIntervalMapUnitScale ); if ( mPlacement == Vertex ) map["placement"] = "vertex"; diff --git a/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp b/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp index 6ba76dd73a3..4f849c4530f 100644 --- a/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp +++ b/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp @@ -100,11 +100,11 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create( const QgsStringMap& prop if ( props.contains( "offset" ) ) m->setOffset( QgsSymbolLayerV2Utils::decodePoint( props["offset"] ) ); if ( props.contains( "offset_unit" ) ) - m->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_unit"] ) ); + m->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) ); if ( props.contains( "offset_map_unit_scale" ) ) m->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["offset_map_unit_scale"] ) ); if ( props.contains( "size_unit" ) ) - m->setSizeUnit( QgsUnitTypes::decodeSymbolUnit( props["size_unit"] ) ); + m->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["size_unit"] ) ); if ( props.contains( "size_map_unit_scale" ) ) m->setSizeMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["size_map_unit_scale"] ) ); @@ -126,11 +126,11 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create( const QgsStringMap& prop } if ( props.contains( "outline_width_unit" ) ) { - m->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["outline_width_unit"] ) ); + m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) ); } if ( props.contains( "line_width_unit" ) ) { - m->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["line_width_unit"] ) ); + m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["line_width_unit"] ) ); } if ( props.contains( "outline_width_map_unit_scale" ) ) { @@ -653,16 +653,16 @@ QgsStringMap QgsSimpleMarkerSymbolLayerV2::properties() const map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor ); map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor ); map["size"] = QString::number( mSize ); - map["size_unit"] = QgsUnitTypes::encodeUnit( mSizeUnit ); + map["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSizeUnit ); map["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale ); map["angle"] = QString::number( mAngle ); map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); map["scale_method"] = QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod ); map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle ); map["outline_width"] = QString::number( mOutlineWidth ); - map["outline_width_unit"] = QgsUnitTypes::encodeUnit( mOutlineWidthUnit ); + map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit ); map["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale ); map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint ); map["vertical_anchor_point"] = QString::number( mVerticalAnchorPoint ); @@ -1187,13 +1187,13 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create( const QgsStringMap& props ) } if ( props.contains( "size_unit" ) ) - m->setSizeUnit( QgsUnitTypes::decodeSymbolUnit( props["size_unit"] ) ); + m->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["size_unit"] ) ); if ( props.contains( "size_map_unit_scale" ) ) m->setSizeMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["size_map_unit_scale"] ) ); if ( props.contains( "offset" ) ) m->setOffset( QgsSymbolLayerV2Utils::decodePoint( props["offset"] ) ); if ( props.contains( "offset_unit" ) ) - m->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_unit"] ) ); + m->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) ); if ( props.contains( "offset_map_unit_scale" ) ) m->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["offset_map_unit_scale"] ) ); if ( props.contains( "fill" ) ) @@ -1235,11 +1235,11 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create( const QgsStringMap& props ) if ( props.contains( "outline_width_unit" ) ) { - m->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["outline_width_unit"] ) ); + m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) ); } else if ( props.contains( "line_width_unit" ) ) { - m->setOutlineWidthUnit( QgsUnitTypes::decodeSymbolUnit( props["line_width_unit"] ) ); + m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["line_width_unit"] ) ); } if ( props.contains( "outline_width_map_unit_scale" ) ) m->setOutlineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["outline_width_map_unit_scale"] ) ); @@ -1517,17 +1517,17 @@ QgsStringMap QgsSvgMarkerSymbolLayerV2::properties() const QgsStringMap map; map["name"] = QgsSymbolLayerV2Utils::symbolPathToName( mPath ); map["size"] = QString::number( mSize ); - map["size_unit"] = QgsUnitTypes::encodeUnit( mSizeUnit ); + map["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSizeUnit ); map["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale ); map["angle"] = QString::number( mAngle ); map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - map["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); map["scale_method"] = QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod ); map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor ); map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ); map["outline_width"] = QString::number( mOutlineWidth ); - map["outline_width_unit"] = QgsUnitTypes::encodeUnit( mOutlineWidthUnit ); + map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit ); map["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale ); map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint ); map["vertical_anchor_point"] = QString::number( mVerticalAnchorPoint ); @@ -1913,11 +1913,11 @@ QgsSymbolLayerV2* QgsFontMarkerSymbolLayerV2::create( const QgsStringMap& props if ( props.contains( "offset" ) ) m->setOffset( QgsSymbolLayerV2Utils::decodePoint( props["offset"] ) ); if ( props.contains( "offset_unit" ) ) - m->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( props["offset_unit" ] ) ); + m->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit" ] ) ); if ( props.contains( "offset_map_unit_scale" ) ) m->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["offset_map_unit_scale" ] ) ); if ( props.contains( "size_unit" ) ) - m->setSizeUnit( QgsUnitTypes::decodeSymbolUnit( props["size_unit"] ) ); + m->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["size_unit"] ) ); if ( props.contains( "size_map_unit_scale" ) ) m->setSizeMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["size_map_unit_scale"] ) ); if ( props.contains( "horizontal_anchor_point" ) ) @@ -2100,12 +2100,12 @@ QgsStringMap QgsFontMarkerSymbolLayerV2::properties() const props["font"] = mFontFamily; props["chr"] = mChr; props["size"] = QString::number( mSize ); - props["size_unit"] = QgsUnitTypes::encodeUnit( mSizeUnit ); + props["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSizeUnit ); props["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale ); props["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor ); props["angle"] = QString::number( mAngle ); props["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - props["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + props["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); props["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); props["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint ); props["vertical_anchor_point"] = QString::number( mVerticalAnchorPoint ); diff --git a/src/core/symbology-ng/qgspointdisplacementrenderer.cpp b/src/core/symbology-ng/qgspointdisplacementrenderer.cpp index 1b815f874b9..4338ea4d998 100644 --- a/src/core/symbology-ng/qgspointdisplacementrenderer.cpp +++ b/src/core/symbology-ng/qgspointdisplacementrenderer.cpp @@ -370,7 +370,7 @@ QgsFeatureRendererV2* QgsPointDisplacementRenderer::create( QDomElement& symbolo r->setCircleRadiusAddition( symbologyElem.attribute( "circleRadiusAddition", "0.0" ).toDouble() ); r->setMaxLabelScaleDenominator( symbologyElem.attribute( "maxLabelScaleDenominator", "-1" ).toDouble() ); r->setTolerance( symbologyElem.attribute( "tolerance", "0.00001" ).toDouble() ); - r->setToleranceUnit( QgsUnitTypes::decodeSymbolUnit( symbologyElem.attribute( "toleranceUnit", "MapUnit" ) ) ); + r->setToleranceUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( symbologyElem.attribute( "toleranceUnit", "MapUnit" ) ) ); r->setToleranceMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( symbologyElem.attribute( "toleranceUnitScale" ) ) ); //look for an embedded renderer @@ -403,7 +403,7 @@ QDomElement QgsPointDisplacementRenderer::save( QDomDocument& doc ) rendererElement.setAttribute( "placement", static_cast< int >( mPlacement ) ); rendererElement.setAttribute( "maxLabelScaleDenominator", QString::number( mMaxLabelScaleDenominator ) ); rendererElement.setAttribute( "tolerance", QString::number( mTolerance ) ); - rendererElement.setAttribute( "toleranceUnit", QgsUnitTypes::encodeUnit( mToleranceUnit ) ); + rendererElement.setAttribute( "toleranceUnit", QgsSymbolLayerV2Utils::encodeOutputUnit( mToleranceUnit ) ); rendererElement.setAttribute( "toleranceUnitScale", QgsSymbolLayerV2Utils::encodeMapUnitScale( mToleranceMapUnitScale ) ); if ( mRenderer ) diff --git a/src/core/symbology-ng/qgssymbollayerv2utils.cpp b/src/core/symbology-ng/qgssymbollayerv2utils.cpp index 25790c5380f..d79afe712fc 100644 --- a/src/core/symbology-ng/qgssymbollayerv2utils.cpp +++ b/src/core/symbology-ng/qgssymbollayerv2utils.cpp @@ -408,14 +408,36 @@ QgsMapUnitScale QgsSymbolLayerV2Utils::decodeMapUnitScale( const QString& str ) QString QgsSymbolLayerV2Utils::encodeOutputUnit( QgsSymbolV2::OutputUnit unit ) { - return QgsUnitTypes::encodeUnit( unit ); + switch ( unit ) + { + case QgsSymbolV2::MM: + return "MM"; + case QgsSymbolV2::MapUnit: + return "MapUnit"; + case QgsSymbolV2::Pixel: + return "Pixel"; + case QgsSymbolV2::Percentage: + return "Percentage"; + default: + return "MM"; + } } -QgsSymbolV2::OutputUnit QgsSymbolLayerV2Utils::decodeOutputUnit( const QString& str ) +QgsSymbolV2::OutputUnit QgsSymbolLayerV2Utils::decodeOutputUnit( const QString& string ) { - bool ok = false; - QgsSymbolV2::OutputUnit unit = QgsUnitTypes::decodeSymbolUnit( str, &ok ); - return ok ? unit : QgsSymbolV2::MM; + QString normalized = string.trimmed().toLower(); + + if ( normalized == encodeOutputUnit( QgsSymbolV2::MM ).toLower() ) + return QgsSymbolV2::MM; + if ( normalized == encodeOutputUnit( QgsSymbolV2::MapUnit ).toLower() ) + return QgsSymbolV2::MapUnit; + if ( normalized == encodeOutputUnit( QgsSymbolV2::Pixel ).toLower() ) + return QgsSymbolV2::Pixel; + if ( normalized == encodeOutputUnit( QgsSymbolV2::Percentage ).toLower() ) + return QgsSymbolV2::Percentage; + + // millimeters are default + return QgsSymbolV2::MM; } QString QgsSymbolLayerV2Utils::encodeSldUom( QgsSymbolV2::OutputUnit unit, double *scaleFactor ) @@ -981,7 +1003,7 @@ QgsSymbolV2* QgsSymbolLayerV2Utils::loadSymbol( const QDomElement &element ) if ( element.hasAttribute( "outputUnit" ) ) { - symbol->setOutputUnit( QgsUnitTypes::decodeSymbolUnit( element.attribute( "outputUnit" ) ) ); + symbol->setOutputUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( element.attribute( "outputUnit" ) ) ); } if ( element.hasAttribute(( "mapUnitScale" ) ) ) { diff --git a/src/core/symbology-ng/qgssymbollayerv2utils.h b/src/core/symbology-ng/qgssymbollayerv2utils.h index 0ab425369a8..0bde83197c4 100644 --- a/src/core/symbology-ng/qgssymbollayerv2utils.h +++ b/src/core/symbology-ng/qgssymbollayerv2utils.h @@ -91,10 +91,8 @@ class CORE_EXPORT QgsSymbolLayerV2Utils static QString encodeSldRealVector( const QVector& v ); static QVector decodeSldRealVector( const QString& s ); - //! @deprecated use QgsUnitTypes::encodeUnit() instead - Q_DECL_DEPRECATED static QString encodeOutputUnit( QgsSymbolV2::OutputUnit unit ); - //! @deprecated use QgsUnitTypes::decodeSymbolUnit() instead - Q_DECL_DEPRECATED static QgsSymbolV2::OutputUnit decodeOutputUnit( const QString& str ); + static QString encodeOutputUnit( QgsSymbolV2::OutputUnit unit ); + static QgsSymbolV2::OutputUnit decodeOutputUnit( const QString& str ); static QString encodeSldUom( QgsSymbolV2::OutputUnit unit, double *scaleFactor ); static QgsSymbolV2::OutputUnit decodeSldUom( const QString& str, double *scaleFactor ); diff --git a/src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp b/src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp index 221d5e3f36a..c39a0d7517f 100644 --- a/src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp +++ b/src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp @@ -82,7 +82,7 @@ QgsSymbolLayerV2* QgsVectorFieldSymbolLayer::create( const QgsStringMap& propert } if ( properties.contains( "distance_unit" ) ) { - symbolLayer->setDistanceUnit( QgsUnitTypes::decodeSymbolUnit( properties["distance_unit"] ) ); + symbolLayer->setDistanceUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["distance_unit"] ) ); } if ( properties.contains( "distance_map_unit_scale" ) ) { @@ -110,7 +110,7 @@ QgsSymbolLayerV2* QgsVectorFieldSymbolLayer::create( const QgsStringMap& propert } if ( properties.contains( "size_unit" ) ) { - symbolLayer->setSizeUnit( QgsUnitTypes::decodeSymbolUnit( properties["size_unit"] ) ); + symbolLayer->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["size_unit"] ) ); } if ( properties.contains( "size_map_unit_scale" ) ) { @@ -122,7 +122,7 @@ QgsSymbolLayerV2* QgsVectorFieldSymbolLayer::create( const QgsStringMap& propert } if ( properties.contains( "offset_unit" ) ) { - symbolLayer->setOffsetUnit( QgsUnitTypes::decodeSymbolUnit( properties["offset_unit"] ) ); + symbolLayer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) ); } if ( properties.contains( "offset_map_unit_scale" ) ) { @@ -246,17 +246,17 @@ QgsStringMap QgsVectorFieldSymbolLayer::properties() const QgsStringMap properties; properties["x_attribute"] = mXAttribute; properties["y_attribute"] = mYAttribute; - properties["distance_unit"] = QgsUnitTypes::encodeUnit( mDistanceUnit ); + properties["distance_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mDistanceUnit ); properties["distance_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mDistanceMapUnitScale ); properties["scale"] = QString::number( mScale ); properties["vector_field_type"] = QString::number( mVectorFieldType ); properties["angle_orientation"] = QString::number( mAngleOrientation ); properties["angle_units"] = QString::number( mAngleUnits ); properties["size"] = QString::number( mSize ); - properties["size_unit"] = QgsUnitTypes::encodeUnit( mSizeUnit ); + properties["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSizeUnit ); properties["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale ); properties["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset ); - properties["offset_unit"] = QgsUnitTypes::encodeUnit( mOffsetUnit ); + properties["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit ); properties["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale ); return properties; } diff --git a/tests/src/python/test_qgsunittypes.py b/tests/src/python/test_qgsunittypes.py index 253fdad3d89..85653ddf09a 100644 --- a/tests/src/python/test_qgsunittypes.py +++ b/tests/src/python/test_qgsunittypes.py @@ -153,6 +153,7 @@ class TestQgsUnitTypes(unittest.TestCase): assert ok self.assertEqual(res, QgsUnitTypes.SquareMiles) + @unittest.skip("enable for 3.0") def testEncodeDecodeSymbolUnits(self): """Test encoding and decoding symbol units""" units = [QgsSymbolV2.MM,