Skip to content

Commit

Permalink
Added "Percentage" option to QgsSymboV2::OutputUnit.
Browse files Browse the repository at this point in the history
- 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 12, 2016
1 parent 0ba089e commit a89c183
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Expand Up @@ -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";
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
9 changes: 5 additions & 4 deletions src/core/symbology-ng/qgssymbolv2.h
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsunitselectionwidget.cpp
Expand Up @@ -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 );
}

Expand Down

0 comments on commit a89c183

Please sign in to comment.