Skip to content
Permalink
Browse files

Added "Percentage" option to QgsSymboV2::OutputUnit.

- Added percentage to OutputUnit enum.
- Updated qgssymbolv2utils to include percentage.
- Updated qgsunitselectionwidget to include percentage.
Changed selection widget in its own commit

Added Percentage to OutputUnit enum.

Added percentage to switches in utils
  • Loading branch information
duncan-r authored and nyalldawson committed Jan 11, 2016
1 parent 0ba089e commit a89c1830de72db40ea37f0a2c80cd22aab78a507
@@ -415,6 +415,8 @@ QString QgsSymbolLayerV2Utils::encodeOutputUnit( QgsSymbolV2::OutputUnit unit )
return "MapUnit";
case QgsSymbolV2::Pixel:
return "Pixel";
case QgsSymbolV2::Percentage:
return "Percentage";
default:
return "MM";
}
@@ -434,6 +436,10 @@ QgsSymbolV2::OutputUnit QgsSymbolLayerV2Utils::decodeOutputUnit( const QString&
{
return QgsSymbolV2::Pixel;
}
else if ( str == "Percentage" )
{
return QgsSymbolV2::Percentage;
}

// millimeters are default
return QgsSymbolV2::MM;
@@ -3377,6 +3383,7 @@ double QgsSymbolLayerV2Utils::lineWidthScaleFactor( const QgsRenderContext& c, Q
case QgsSymbolV2::Pixel:
return 1.0 / c.rasterScaleFactor();
case QgsSymbolV2::Mixed:
case QgsSymbolV2::Percentage:
//no sensible value
return 1.0;
}
@@ -3421,6 +3428,7 @@ double QgsSymbolLayerV2Utils::pixelSizeScaleFactor( const QgsRenderContext& c, Q
case QgsSymbolV2::Pixel:
return 1.0;
case QgsSymbolV2::Mixed:
case QgsSymbolV2::Percentage:
//no sensible value
return 1.0;
}
@@ -3440,6 +3448,7 @@ double QgsSymbolLayerV2Utils::mapUnitScaleFactor( const QgsRenderContext &c, Qgs
case QgsSymbolV2::Pixel:
return scale.computeMapUnitsPerPixel( c );
case QgsSymbolV2::Mixed:
case QgsSymbolV2::Percentage:
//no sensible value
return 1.0;
}
@@ -57,10 +57,11 @@ class CORE_EXPORT QgsSymbolV2
*/
enum OutputUnit
{
MM = 0, //!< The output shall be in millimeters
MapUnit, //!< The output shall be in map unitx
Mixed, //!< Mixed units in symbol layers
Pixel //!< The output shall be in pixels
MM = 0, //!< The output shall be in millimeters
MapUnit, //!< The output shall be in map unitx
Mixed, //!< Mixed units in symbol layers
Pixel, //!< The output shall be in pixels
Percentage //!< The ouput shall be in percentage of canvas
};

typedef QList<OutputUnit> OutputUnitList;
@@ -138,6 +138,10 @@ void QgsUnitSelectionWidget::setUnits( const QgsSymbolV2::OutputUnitList &units
{
mUnitCombo->addItem( tr( "Map unit" ), QgsSymbolV2::MapUnit );
}
if ( units.contains( QgsSymbolV2::Percentage ) )
{
mUnitCombo->addItem( tr( "Percentage" ), QgsSymbolV2::Percentage );
}
blockSignals( false );
}

0 comments on commit a89c183

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