Skip to content

Commit 74ba70a

Browse files
committedOct 1, 2012
Added fine transparency settings for vectors.
Now the user can specify the alpha channel for outlines, border and fill colors of polygons and markers. The overall layer alpha channel is used as multiplier for these values. Selections are not affected. Work done for Regione Toscana-SITA.
1 parent 4b263d6 commit 74ba70a

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed
 

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ QString QgsSimpleFillSymbolLayerV2::layerType() const
6969

7070
void QgsSimpleFillSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
7171
{
72-
mColor.setAlphaF( context.alpha() );
73-
mBrush = QBrush( mColor, mBrushStyle );
72+
QColor fillColor = mColor;
73+
fillColor.setAlphaF( context.alpha() * mColor.alphaF() );
74+
mBrush = QBrush( fillColor, mBrushStyle );
7475

7576
// scale brush content for printout
7677
double rasterScaleFactor = context.renderContext().rasterScaleFactor();
@@ -87,8 +88,10 @@ void QgsSimpleFillSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context
8788
// this would mean symbols with "no fill" look the same whether or not they are selected
8889
if ( selectFillStyle )
8990
mSelBrush.setStyle( mBrushStyle );
90-
mBorderColor.setAlphaF( context.alpha() );
91-
mPen = QPen( mBorderColor );
91+
92+
QColor borderColor = mBorderColor;
93+
borderColor.setAlphaF( context.alpha() * mBorderColor.alphaF());
94+
mPen = QPen( borderColor );
9295
mSelPen = QPen( selPenColor );
9396
mPen.setStyle( mBorderStyle );
9497
mPen.setWidthF( context.outputLineWidth( mBorderWidth ) );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ QString QgsSimpleLineSymbolLayerV2::layerType() const
7676
void QgsSimpleLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
7777
{
7878
QColor penColor = mColor;
79-
penColor.setAlphaF( context.alpha() );
79+
penColor.setAlphaF( mColor.alphaF() * context.alpha() );
8080
mPen.setColor( penColor );
8181
double scaledWidth = context.outputLineWidth( mWidth );
8282
mPen.setWidthF( scaledWidth );

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex
9797
{
9898
QColor brushColor = mColor;
9999
QColor penColor = mBorderColor;
100-
if ( context.alpha() < 1 )
101-
{
102-
penColor.setAlphaF( context.alpha() );
103-
brushColor.setAlphaF( context.alpha() );
104-
}
100+
101+
brushColor.setAlphaF( mColor.alphaF() * context.alpha() );
102+
penColor.setAlphaF( mBorderColor.alphaF() * context.alpha() );
103+
105104
mBrush = QBrush( brushColor );
106105
mPen = QPen( penColor );
107106
mPen.setWidthF( context.outputLineWidth( mPen.widthF() ) );

‎src/gui/symbology-ng/qgssymbollayerv2widget.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ void QgsSimpleLineSymbolLayerV2Widget::colorChanged()
110110
// Native Mac dialog works only for Qt Carbon
111111
// Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
112112
// FIXME need to also check max QT_VERSION when Qt bug fixed
113-
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog );
113+
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
114114
#else
115-
QColor color = QColorDialog::getColor( mLayer->color(), this );
115+
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::ShowAlphaChannel);
116116
#endif
117117
if ( !color.isValid() )
118118
return;
@@ -259,9 +259,9 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setColorBorder()
259259
// Native Mac dialog works only for Qt Carbon
260260
// Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
261261
// FIXME need to also check max QT_VERSION when Qt bug fixed
262-
QColor borderColor = QColorDialog::getColor( mLayer->borderColor(), this, "", QColorDialog::DontUseNativeDialog );
262+
QColor borderColor = QColorDialog::getColor( mLayer->borderColor(), this, "", QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel );
263263
#else
264-
QColor borderColor = QColorDialog::getColor( mLayer->borderColor(), this );
264+
QColor borderColor = QColorDialog::getColor( mLayer->borderColor(), this, "", QColorDialog::ShowAlphaChannel );
265265
#endif
266266
if ( !borderColor.isValid() )
267267
return;
@@ -276,9 +276,9 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setColorFill()
276276
// Native Mac dialog works only for Qt Carbon
277277
// Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
278278
// FIXME need to also check max QT_VERSION when Qt bug fixed
279-
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog );
279+
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel );
280280
#else
281-
QColor color = QColorDialog::getColor( mLayer->color(), this );
281+
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::ShowAlphaChannel );
282282
#endif
283283
if ( !color.isValid() )
284284
return;
@@ -357,9 +357,9 @@ void QgsSimpleFillSymbolLayerV2Widget::setColor()
357357
// Native Mac dialog works only for Qt Carbon
358358
// Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
359359
// FIXME need to also check max QT_VERSION when Qt bug fixed
360-
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog );
360+
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
361361
#else
362-
QColor color = QColorDialog::getColor( mLayer->color(), this );
362+
QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::ShowAlphaChannel);
363363
#endif
364364
if ( !color.isValid() )
365365
return;
@@ -374,9 +374,9 @@ void QgsSimpleFillSymbolLayerV2Widget::setBorderColor()
374374
// Native Mac dialog works only for Qt Carbon
375375
// Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
376376
// FIXME need to also check max QT_VERSION when Qt bug fixed
377-
QColor color = QColorDialog::getColor( mLayer->borderColor(), this, "", QColorDialog::DontUseNativeDialog );
377+
QColor color = QColorDialog::getColor( mLayer->borderColor(), this, "", QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
378378
#else
379-
QColor color = QColorDialog::getColor( mLayer->borderColor(), this );
379+
QColor color = QColorDialog::getColor( mLayer->borderColor(), this, "", QColorDialog::ShowAlphaChannel);
380380
#endif
381381
if ( !color.isValid() )
382382
return;

0 commit comments

Comments
 (0)