Skip to content

Commit

Permalink
Revert deprecation of QgsSymbolV2Utils::encode/decodeOutputUnit
Browse files Browse the repository at this point in the history
...as it causes circular dependancies. Defer to 3.0 when we can
move QgsSymbolV2::OutputUnit to QgsUnitTypes
  • Loading branch information
nyalldawson committed Feb 14, 2016
1 parent 9a081df commit 1f2cc3d
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 131 deletions.
15 changes: 0 additions & 15 deletions python/core/qgsunittypes.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

};

6 changes: 2 additions & 4 deletions python/core/symbology-ng/qgssymbollayerv2utils.sip
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ class QgsSymbolLayerV2Utils
static QString encodeSldRealVector( const QVector<qreal>& v );
static QVector<qreal> 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 );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdecorationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ 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()
{
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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/effects/qgsgloweffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/effects/qgsshadoweffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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" ) )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/effects/qgstransformeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) );
Expand All @@ -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" ) );
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsunittypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -501,3 +504,5 @@ QgsSymbolV2::OutputUnit QgsUnitTypes::decodeSymbolUnit( const QString& string, b
// millimeters are default
return QgsSymbolV2::MM;
}

#endif
4 changes: 3 additions & 1 deletion src/core/qgsunittypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -158,6 +159,7 @@ class CORE_EXPORT QgsUnitTypes
* @see encodeUnit()
*/
static QgsSymbolV2::OutputUnit decodeSymbolUnit( const QString& string, bool *ok = 0 );
#endif

};

Expand Down
22 changes: 11 additions & 11 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) )
{
Expand All @@ -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" ) )
{
Expand Down Expand Up @@ -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" ) )
{
Expand Down Expand Up @@ -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" ) )
{
Expand All @@ -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" ) )
{
Expand Down Expand Up @@ -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 );
Expand Down
Loading

0 comments on commit 1f2cc3d

Please sign in to comment.