Skip to content

Commit a89c183

Browse files
duncan-rnyalldawson
authored andcommittedJan 12, 2016
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
1 parent 0ba089e commit a89c183

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed
 

‎src/core/symbology-ng/qgssymbollayerv2utils.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ QString QgsSymbolLayerV2Utils::encodeOutputUnit( QgsSymbolV2::OutputUnit unit )
415415
return "MapUnit";
416416
case QgsSymbolV2::Pixel:
417417
return "Pixel";
418+
case QgsSymbolV2::Percentage:
419+
return "Percentage";
418420
default:
419421
return "MM";
420422
}
@@ -434,6 +436,10 @@ QgsSymbolV2::OutputUnit QgsSymbolLayerV2Utils::decodeOutputUnit( const QString&
434436
{
435437
return QgsSymbolV2::Pixel;
436438
}
439+
else if ( str == "Percentage" )
440+
{
441+
return QgsSymbolV2::Percentage;
442+
}
437443

438444
// millimeters are default
439445
return QgsSymbolV2::MM;
@@ -3377,6 +3383,7 @@ double QgsSymbolLayerV2Utils::lineWidthScaleFactor( const QgsRenderContext& c, Q
33773383
case QgsSymbolV2::Pixel:
33783384
return 1.0 / c.rasterScaleFactor();
33793385
case QgsSymbolV2::Mixed:
3386+
case QgsSymbolV2::Percentage:
33803387
//no sensible value
33813388
return 1.0;
33823389
}
@@ -3421,6 +3428,7 @@ double QgsSymbolLayerV2Utils::pixelSizeScaleFactor( const QgsRenderContext& c, Q
34213428
case QgsSymbolV2::Pixel:
34223429
return 1.0;
34233430
case QgsSymbolV2::Mixed:
3431+
case QgsSymbolV2::Percentage:
34243432
//no sensible value
34253433
return 1.0;
34263434
}
@@ -3440,6 +3448,7 @@ double QgsSymbolLayerV2Utils::mapUnitScaleFactor( const QgsRenderContext &c, Qgs
34403448
case QgsSymbolV2::Pixel:
34413449
return scale.computeMapUnitsPerPixel( c );
34423450
case QgsSymbolV2::Mixed:
3451+
case QgsSymbolV2::Percentage:
34433452
//no sensible value
34443453
return 1.0;
34453454
}

‎src/core/symbology-ng/qgssymbolv2.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ class CORE_EXPORT QgsSymbolV2
5757
*/
5858
enum OutputUnit
5959
{
60-
MM = 0, //!< The output shall be in millimeters
61-
MapUnit, //!< The output shall be in map unitx
62-
Mixed, //!< Mixed units in symbol layers
63-
Pixel //!< The output shall be in pixels
60+
MM = 0, //!< The output shall be in millimeters
61+
MapUnit, //!< The output shall be in map unitx
62+
Mixed, //!< Mixed units in symbol layers
63+
Pixel, //!< The output shall be in pixels
64+
Percentage //!< The ouput shall be in percentage of canvas
6465
};
6566

6667
typedef QList<OutputUnit> OutputUnitList;

‎src/gui/qgsunitselectionwidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ void QgsUnitSelectionWidget::setUnits( const QgsSymbolV2::OutputUnitList &units
138138
{
139139
mUnitCombo->addItem( tr( "Map unit" ), QgsSymbolV2::MapUnit );
140140
}
141+
if ( units.contains( QgsSymbolV2::Percentage ) )
142+
{
143+
mUnitCombo->addItem( tr( "Percentage" ), QgsSymbolV2::Percentage );
144+
}
141145
blockSignals( false );
142146
}
143147

0 commit comments

Comments
 (0)
Please sign in to comment.