mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Flip symbology from alpha/transparency to opacity
This commit is contained in:
parent
233a95e99b
commit
a3262240fe
@ -1837,6 +1837,12 @@ QProgressDialog argument will need to be updated using manually created connecti
|
||||
signals and the updates to the progress dialog.
|
||||
|
||||
|
||||
QgsRasterFillSymbolLayer {#qgis_api_break_3_0_QgsRasterFillSymbolLayer}
|
||||
-----------------
|
||||
|
||||
- alpha() and setAlpha() were removed. Use opacity() and setOpacity() instead.
|
||||
|
||||
|
||||
QgsRasterInterface {#qgis_api_break_3_0_QgsRasterInterface}
|
||||
------------------
|
||||
|
||||
@ -2108,6 +2114,7 @@ than an integer value
|
||||
- usedAttributes() now requires a QgsRenderContext argument.
|
||||
- setDataDefinedAngle(), dataDefinedAngle(), setDataDefinedSize(), dataDefinedSize(), setDataDefinedWidth() and dataDefinedWidth()
|
||||
now work with QgsProperty objects instead of QgsDataDefined.
|
||||
- alpha() and setAlpha() were removed. Use opacity() and setOpacity() instead.
|
||||
|
||||
|
||||
QgsSymbolLayer (renamed from QgsSymbolLayerV2) {#qgis_api_break_3_0_QgsSymbolLayer}
|
||||
@ -2146,6 +2153,7 @@ QgsSymbolRenderContext (renamed from QgsSymbolV2RenderContext) {#qgis_api
|
||||
- The constructor, setRenderHints() and renderHints() now accept and return a QgsSymbol::RenderHints flag rather
|
||||
than an integer value
|
||||
- fields() now returns a QgsFields value, not a pointer.
|
||||
- alpha() and setAlpha() were removed. Use opacity() and setOpacity() instead.
|
||||
|
||||
|
||||
QgsSymbolLayerUtils (renamed from QgsSymbolLayerUtilsV2) {#qgis_api_break_3_0_QgsSymbolLayerUtils}
|
||||
|
@ -550,16 +550,8 @@ class QgsRasterFillSymbolLayer: QgsImageFillSymbolLayer
|
||||
*/
|
||||
FillCoordinateMode coordinateMode() const;
|
||||
|
||||
/** Sets the opacity for the raster image used in the fill.
|
||||
* @param alpha opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* @see alpha
|
||||
*/
|
||||
void setAlpha( const double alpha );
|
||||
/** The opacity for the raster image used in the fill.
|
||||
* @returns opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* @see setAlpha
|
||||
*/
|
||||
double alpha() const;
|
||||
void setOpacity( const double opacity );
|
||||
double opacity() const;
|
||||
|
||||
/** Sets the offset for the fill.
|
||||
* @param offset offset for fill
|
||||
|
@ -175,10 +175,8 @@ class QgsSymbol
|
||||
QgsMapUnitScale mapUnitScale() const;
|
||||
void setMapUnitScale( const QgsMapUnitScale &scale );
|
||||
|
||||
//! Get alpha transparency 1 for opaque, 0 for invisible
|
||||
qreal alpha() const;
|
||||
//! Set alpha transparency 1 for opaque, 0 for invisible
|
||||
void setAlpha( qreal alpha );
|
||||
qreal opacity() const;
|
||||
void setOpacity( qreal opacity );
|
||||
|
||||
/** Sets rendering hint flags for the symbol.
|
||||
* @see renderHints()
|
||||
@ -303,17 +301,7 @@ class QgsSymbolRenderContext
|
||||
|
||||
public:
|
||||
|
||||
/** Constructor for QgsSymbolRenderContext
|
||||
* @param c
|
||||
* @param u
|
||||
* @param alpha
|
||||
* @param selected set to true if symbol should be drawn in a "selected" state
|
||||
* @param renderHints flags controlling rendering behavior
|
||||
* @param f
|
||||
* @param fields
|
||||
* @param mapUnitScale
|
||||
*/
|
||||
QgsSymbolRenderContext( QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal alpha = 1.0, bool selected = false, QgsSymbol::RenderHints renderHints = 0, const QgsFeature *f = 0, const QgsFields &fields = QgsFields(), const QgsMapUnitScale &mapUnitScale = QgsMapUnitScale() );
|
||||
QgsSymbolRenderContext( QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal opacity = 1.0, bool selected = false, QgsSymbol::RenderHints renderHints = 0, const QgsFeature *f = 0, const QgsFields &fields = QgsFields(), const QgsMapUnitScale &mapUnitScale = QgsMapUnitScale() );
|
||||
~QgsSymbolRenderContext();
|
||||
|
||||
QgsRenderContext &renderContext();
|
||||
@ -335,10 +323,8 @@ class QgsSymbolRenderContext
|
||||
QgsMapUnitScale mapUnitScale() const;
|
||||
void setMapUnitScale( const QgsMapUnitScale &scale );
|
||||
|
||||
//! Get alpha transparency 1 for opaque, 0 for invisible
|
||||
qreal alpha() const;
|
||||
//! Set alpha transparency 1 for opaque, 0 for invisible
|
||||
void setAlpha( qreal alpha );
|
||||
qreal opacity() const;
|
||||
void setOpacity( qreal opacity );
|
||||
|
||||
bool selected() const;
|
||||
void setSelected( bool selected );
|
||||
|
@ -35,7 +35,6 @@ class QgsSymbolsListWidget : QWidget
|
||||
void saveSymbol();
|
||||
void symbolAddedToStyle( const QString &name, QgsSymbol *symbol );
|
||||
void on_mSymbolUnitWidget_changed();
|
||||
void on_mTransparencySlider_valueChanged( int value );
|
||||
|
||||
//! Pupulates the groups combo box with available tags and smartgroups
|
||||
void populateGroups();
|
||||
|
@ -1133,7 +1133,7 @@ void QgsProjectProperties::apply()
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Line" ), cboStyleLine->currentText() );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Fill" ), cboStyleFill->currentText() );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/ColorRamp" ), cboStyleColorRamp->currentText() );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/AlphaInt" ), ( int )( 255 - ( mTransparencySlider->value() * 2.55 ) ) );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Opacity" ), 1.0 - mTransparencySlider->value() / 100.0 );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/RandomColors" ), cbxStyleRandomColors->isChecked() );
|
||||
if ( mTreeProjectColors->isDirty() )
|
||||
{
|
||||
@ -1687,7 +1687,15 @@ void QgsProjectProperties::populateStyles()
|
||||
cbxStyleRandomColors->setChecked( QgsProject::instance()->readBoolEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/RandomColors" ), true ) );
|
||||
|
||||
// alpha transparency
|
||||
int transparencyInt = ( 255 - QgsProject::instance()->readNumEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/AlphaInt" ), 255 ) ) / 2.55;
|
||||
int transparencyInt = 255;
|
||||
bool ok = false;
|
||||
double alpha = QgsProject::instance()->readDoubleEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/AlphaInt" ), 255, &ok );
|
||||
if ( ok )
|
||||
transparencyInt = alpha;
|
||||
double newOpacity = QgsProject::instance()->readDoubleEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Opacity" ), 1.0, &ok );
|
||||
if ( ok )
|
||||
transparencyInt = 255 - newOpacity * 255.0;
|
||||
|
||||
mTransparencySlider->setValue( transparencyInt );
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ void QgsComposerMapOverview::createDefaultFrameSymbol()
|
||||
properties.insert( QStringLiteral( "style" ), QStringLiteral( "solid" ) );
|
||||
properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "no" ) );
|
||||
mFrameSymbol = QgsFillSymbol::createSimple( properties );
|
||||
mFrameSymbol->setAlpha( 0.3 );
|
||||
mFrameSymbol->setOpacity( 0.3 );
|
||||
}
|
||||
|
||||
QgsComposerMapOverview::~QgsComposerMapOverview()
|
||||
|
@ -897,7 +897,7 @@ void QgsDxfExport::writeBlocks()
|
||||
continue;
|
||||
|
||||
// if point symbol layer and no data defined properties: write block
|
||||
QgsSymbolRenderContext ctx( ct, QgsUnitTypes::RenderMapUnits, slIt->second->alpha(), false, slIt->second->renderHints(), nullptr );
|
||||
QgsSymbolRenderContext ctx( ct, QgsUnitTypes::RenderMapUnits, slIt->second->opacity(), false, slIt->second->renderHints(), nullptr );
|
||||
ml->startRender( ctx );
|
||||
|
||||
// markers with data defined properties are inserted inline
|
||||
|
@ -232,12 +232,12 @@ QString QgsSimpleFillSymbolLayer::layerType() const
|
||||
void QgsSimpleFillSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
{
|
||||
QColor fillColor = mColor;
|
||||
fillColor.setAlphaF( context.alpha() * mColor.alphaF() );
|
||||
fillColor.setAlphaF( context.opacity() * mColor.alphaF() );
|
||||
mBrush = QBrush( fillColor, mBrushStyle );
|
||||
|
||||
QColor selColor = context.renderContext().selectionColor();
|
||||
QColor selPenColor = selColor == mColor ? selColor : mStrokeColor;
|
||||
if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF( context.alpha() );
|
||||
if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF( context.opacity() );
|
||||
mSelBrush = QBrush( selColor );
|
||||
// N.B. unless a "selection line color" is implemented in addition to the "selection color" option
|
||||
// this would mean symbols with "no fill" look the same whether or not they are selected
|
||||
@ -245,7 +245,7 @@ void QgsSimpleFillSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
mSelBrush.setStyle( mBrushStyle );
|
||||
|
||||
QColor strokeColor = mStrokeColor;
|
||||
strokeColor.setAlphaF( context.alpha() * mStrokeColor.alphaF() );
|
||||
strokeColor.setAlphaF( context.opacity() * mStrokeColor.alphaF() );
|
||||
mPen = QPen( strokeColor );
|
||||
mSelPen = QPen( selPenColor );
|
||||
mPen.setStyle( mStrokeStyle );
|
||||
@ -767,9 +767,9 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
|
||||
{
|
||||
//update alpha of gradient colors
|
||||
QColor fillColor = color;
|
||||
fillColor.setAlphaF( context.alpha() * fillColor.alphaF() );
|
||||
fillColor.setAlphaF( context.opacity() * fillColor.alphaF() );
|
||||
QColor fillColor2 = color2;
|
||||
fillColor2.setAlphaF( context.alpha() * fillColor2.alphaF() );
|
||||
fillColor2.setAlphaF( context.opacity() * fillColor2.alphaF() );
|
||||
|
||||
//rotate reference points
|
||||
QPointF rotatedReferencePoint1 = !qgsDoubleNear( angle, 0.0 ) ? rotateReferencePoint( referencePoint1, angle ) : referencePoint1;
|
||||
@ -817,7 +817,7 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
|
||||
{
|
||||
//color ramp gradient
|
||||
QgsGradientColorRamp *gradRamp = static_cast<QgsGradientColorRamp *>( gradientRamp );
|
||||
gradRamp->addStopsToGradient( &gradient, context.alpha() );
|
||||
gradRamp->addStopsToGradient( &gradient, context.opacity() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -833,7 +833,8 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
|
||||
void QgsGradientFillSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
{
|
||||
QColor selColor = context.renderContext().selectionColor();
|
||||
if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF( context.alpha() );
|
||||
if ( ! SELECTION_IS_OPAQUE )
|
||||
selColor.setAlphaF( context.opacity() );
|
||||
mSelBrush = QBrush( selColor );
|
||||
}
|
||||
|
||||
@ -1125,7 +1126,8 @@ void QgsShapeburstFillSymbolLayer::startRender( QgsSymbolRenderContext &context
|
||||
{
|
||||
//TODO - check this
|
||||
QColor selColor = context.renderContext().selectionColor();
|
||||
if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF( context.alpha() );
|
||||
if ( ! SELECTION_IS_OPAQUE )
|
||||
selColor.setAlphaF( context.opacity() );
|
||||
mSelBrush = QBrush( selColor );
|
||||
}
|
||||
|
||||
@ -1237,7 +1239,7 @@ void QgsShapeburstFillSymbolLayer::renderPolygon( const QPolygonF &points, QList
|
||||
|
||||
//copy distance transform values back to QImage, shading by appropriate color ramp
|
||||
dtArrayToQImage( dtArray, fillImage, mColorType == QgsShapeburstFillSymbolLayer::SimpleTwoColor ? mTwoColorGradientRamp : mGradientRamp,
|
||||
context.alpha(), useWholeShape, outputPixelMaxDist );
|
||||
context.opacity(), useWholeShape, outputPixelMaxDist );
|
||||
|
||||
//clean up some variables
|
||||
delete [] dtArray;
|
||||
@ -1962,10 +1964,10 @@ void QgsSVGFillSymbolLayer::applyPattern( QBrush &brush, const QString &svgFileP
|
||||
}
|
||||
|
||||
QTransform brushTransform;
|
||||
if ( !qgsDoubleNear( context.alpha(), 1.0 ) )
|
||||
if ( !qgsDoubleNear( context.opacity(), 1.0 ) )
|
||||
{
|
||||
QImage transparentImage = fitsInCache ? patternImage.copy() : mSvgPattern->copy();
|
||||
QgsSymbolLayerUtils::multiplyImageOpacity( &transparentImage, context.alpha() );
|
||||
QgsSymbolLayerUtils::multiplyImageOpacity( &transparentImage, context.opacity() );
|
||||
brush.setTextureImage( transparentImage );
|
||||
}
|
||||
else
|
||||
@ -2771,10 +2773,10 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext &
|
||||
patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
|
||||
|
||||
//set image to mBrush
|
||||
if ( !qgsDoubleNear( context.alpha(), 1.0 ) )
|
||||
if ( !qgsDoubleNear( context.opacity(), 1.0 ) )
|
||||
{
|
||||
QImage transparentImage = patternImage.copy();
|
||||
QgsSymbolLayerUtils::multiplyImageOpacity( &transparentImage, context.alpha() );
|
||||
QgsSymbolLayerUtils::multiplyImageOpacity( &transparentImage, context.opacity() );
|
||||
brush.setTextureImage( transparentImage );
|
||||
}
|
||||
else
|
||||
@ -3185,10 +3187,10 @@ void QgsPointPatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext
|
||||
mMarkerSymbol->stopRender( pointRenderContext );
|
||||
}
|
||||
|
||||
if ( !qgsDoubleNear( context.alpha(), 1.0 ) )
|
||||
if ( !qgsDoubleNear( context.opacity(), 1.0 ) )
|
||||
{
|
||||
QImage transparentImage = patternImage.copy();
|
||||
QgsSymbolLayerUtils::multiplyImageOpacity( &transparentImage, context.alpha() );
|
||||
QgsSymbolLayerUtils::multiplyImageOpacity( &transparentImage, context.opacity() );
|
||||
brush.setTextureImage( transparentImage );
|
||||
}
|
||||
else
|
||||
@ -3418,7 +3420,7 @@ QColor QgsCentroidFillSymbolLayer::color() const
|
||||
|
||||
void QgsCentroidFillSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
{
|
||||
mMarker->setAlpha( context.alpha() );
|
||||
mMarker->setOpacity( context.opacity() );
|
||||
mMarker->startRender( context.renderContext(), context.fields() );
|
||||
|
||||
mCurrentFeatureId = -1;
|
||||
@ -3590,7 +3592,6 @@ QgsRasterFillSymbolLayer::QgsRasterFillSymbolLayer( const QString &imageFilePath
|
||||
: QgsImageFillSymbolLayer()
|
||||
, mImageFilePath( imageFilePath )
|
||||
, mCoordinateMode( QgsRasterFillSymbolLayer::Feature )
|
||||
, mAlpha( 1.0 )
|
||||
, mOffsetUnit( QgsUnitTypes::RenderMillimeters )
|
||||
, mWidth( 0.0 )
|
||||
, mWidthUnit( QgsUnitTypes::RenderPixels )
|
||||
@ -3633,7 +3634,7 @@ QgsSymbolLayer *QgsRasterFillSymbolLayer::create( const QgsStringMap &properties
|
||||
}
|
||||
QgsRasterFillSymbolLayer *symbolLayer = new QgsRasterFillSymbolLayer( imagePath );
|
||||
symbolLayer->setCoordinateMode( mode );
|
||||
symbolLayer->setAlpha( alpha );
|
||||
symbolLayer->setOpacity( alpha );
|
||||
symbolLayer->setOffset( offset );
|
||||
symbolLayer->setAngle( angle );
|
||||
symbolLayer->setWidth( width );
|
||||
@ -3701,7 +3702,7 @@ void QgsRasterFillSymbolLayer::renderPolygon( const QPolygonF &points, QList<QPo
|
||||
|
||||
void QgsRasterFillSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
{
|
||||
applyPattern( mBrush, mImageFilePath, mWidth, mAlpha, context );
|
||||
applyPattern( mBrush, mImageFilePath, mWidth, mOpacity, context );
|
||||
}
|
||||
|
||||
void QgsRasterFillSymbolLayer::stopRender( QgsSymbolRenderContext &context )
|
||||
@ -3714,7 +3715,7 @@ QgsStringMap QgsRasterFillSymbolLayer::properties() const
|
||||
QgsStringMap map;
|
||||
map[QStringLiteral( "imageFile" )] = mImageFilePath;
|
||||
map[QStringLiteral( "coordinate_mode" )] = QString::number( mCoordinateMode );
|
||||
map[QStringLiteral( "alpha" )] = QString::number( mAlpha );
|
||||
map[QStringLiteral( "alpha" )] = QString::number( mOpacity );
|
||||
map[QStringLiteral( "offset" )] = QgsSymbolLayerUtils::encodePoint( mOffset );
|
||||
map[QStringLiteral( "offset_unit" )] = QgsUnitTypes::encodeUnit( mOffsetUnit );
|
||||
map[QStringLiteral( "offset_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mOffsetMapUnitScale );
|
||||
@ -3729,7 +3730,7 @@ QgsRasterFillSymbolLayer *QgsRasterFillSymbolLayer::clone() const
|
||||
{
|
||||
QgsRasterFillSymbolLayer *sl = new QgsRasterFillSymbolLayer( mImageFilePath );
|
||||
sl->setCoordinateMode( mCoordinateMode );
|
||||
sl->setAlpha( mAlpha );
|
||||
sl->setOpacity( mOpacity );
|
||||
sl->setOffset( mOffset );
|
||||
sl->setOffsetUnit( mOffsetUnit );
|
||||
sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
|
||||
@ -3757,9 +3758,9 @@ void QgsRasterFillSymbolLayer::setCoordinateMode( const QgsRasterFillSymbolLayer
|
||||
mCoordinateMode = mode;
|
||||
}
|
||||
|
||||
void QgsRasterFillSymbolLayer::setAlpha( const double alpha )
|
||||
void QgsRasterFillSymbolLayer::setOpacity( const double opacity )
|
||||
{
|
||||
mAlpha = alpha;
|
||||
mOpacity = opacity;
|
||||
}
|
||||
|
||||
void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext &context )
|
||||
@ -3769,10 +3770,10 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
|
||||
|
||||
bool hasWidthExpression = mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyWidth );
|
||||
bool hasFileExpression = mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyFile );
|
||||
bool hasAlphaExpression = mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyAlpha );
|
||||
bool hasOpacityExpression = mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyOpacity );
|
||||
bool hasAngleExpression = mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyAngle );
|
||||
|
||||
if ( !hasWidthExpression && !hasAngleExpression && !hasAlphaExpression && !hasFileExpression )
|
||||
if ( !hasWidthExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
|
||||
{
|
||||
return; //no data defined settings
|
||||
}
|
||||
@ -3786,7 +3787,7 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
|
||||
mNextAngle = nextAngle;
|
||||
}
|
||||
|
||||
if ( !hasWidthExpression && !hasAlphaExpression && !hasFileExpression )
|
||||
if ( !hasWidthExpression && !hasOpacityExpression && !hasFileExpression )
|
||||
{
|
||||
return; //nothing further to do
|
||||
}
|
||||
@ -3797,11 +3798,11 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
|
||||
context.setOriginalValueVariable( mWidth );
|
||||
width = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyWidth, context.renderContext().expressionContext(), width );
|
||||
}
|
||||
double alpha = mAlpha;
|
||||
if ( hasAlphaExpression )
|
||||
double opacity = mOpacity;
|
||||
if ( hasOpacityExpression )
|
||||
{
|
||||
context.setOriginalValueVariable( mAlpha );
|
||||
alpha = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyAlpha, context.renderContext().expressionContext(), alpha );
|
||||
context.setOriginalValueVariable( mOpacity );
|
||||
opacity = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyOpacity, context.renderContext().expressionContext(), opacity * 100 ) / 100.0;
|
||||
}
|
||||
QString file = mImageFilePath;
|
||||
if ( hasFileExpression )
|
||||
@ -3809,7 +3810,7 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
|
||||
context.setOriginalValueVariable( mImageFilePath );
|
||||
file = mDataDefinedProperties.valueAsString( QgsSymbolLayer::PropertyFile, context.renderContext().expressionContext(), file );
|
||||
}
|
||||
applyPattern( mBrush, file, width, alpha, context );
|
||||
applyPattern( mBrush, file, width, opacity, context );
|
||||
}
|
||||
|
||||
void QgsRasterFillSymbolLayer::applyPattern( QBrush &brush, const QString &imageFilePath, const double width, const double alpha, const QgsSymbolRenderContext &context )
|
||||
|
@ -694,17 +694,19 @@ class CORE_EXPORT QgsRasterFillSymbolLayer: public QgsImageFillSymbolLayer
|
||||
*/
|
||||
FillCoordinateMode coordinateMode() const { return mCoordinateMode; }
|
||||
|
||||
/** Sets the opacity for the raster image used in the fill.
|
||||
* \param alpha opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* \see alpha
|
||||
/**
|
||||
* Sets the \a opacity for the raster image used in the fill.
|
||||
* \param opacity opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* \see opacity()
|
||||
*/
|
||||
void setAlpha( const double alpha );
|
||||
void setOpacity( const double opacity );
|
||||
|
||||
/** The opacity for the raster image used in the fill.
|
||||
/**
|
||||
* Returns the opacity for the raster image used in the fill.
|
||||
* \returns opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* \see setAlpha
|
||||
* \see setOpacity()
|
||||
*/
|
||||
double alpha() const { return mAlpha; }
|
||||
double opacity() const { return mOpacity; }
|
||||
|
||||
/** Sets the offset for the fill.
|
||||
* \param offset offset for fill
|
||||
@ -809,7 +811,7 @@ class CORE_EXPORT QgsRasterFillSymbolLayer: public QgsImageFillSymbolLayer
|
||||
//! Path to the image file
|
||||
QString mImageFilePath;
|
||||
FillCoordinateMode mCoordinateMode;
|
||||
double mAlpha;
|
||||
double mOpacity = 1.0;
|
||||
|
||||
QPointF mOffset;
|
||||
QgsUnitTypes::RenderUnit mOffsetUnit;
|
||||
@ -824,7 +826,7 @@ class CORE_EXPORT QgsRasterFillSymbolLayer: public QgsImageFillSymbolLayer
|
||||
private:
|
||||
|
||||
//! Applies the image pattern to the brush
|
||||
void applyPattern( QBrush &brush, const QString &imageFilePath, const double width, const double alpha,
|
||||
void applyPattern( QBrush &brush, const QString &imageFilePath, const double width, const double opacity,
|
||||
const QgsSymbolRenderContext &context );
|
||||
};
|
||||
|
||||
|
@ -190,7 +190,7 @@ QString QgsSimpleLineSymbolLayer::layerType() const
|
||||
void QgsSimpleLineSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
{
|
||||
QColor penColor = mColor;
|
||||
penColor.setAlphaF( mColor.alphaF() * context.alpha() );
|
||||
penColor.setAlphaF( mColor.alphaF() * context.opacity() );
|
||||
mPen.setColor( penColor );
|
||||
double scaledWidth = context.renderContext().convertToPainterUnits( mWidth, mWidthUnit, mWidthMapUnitScale );
|
||||
mPen.setWidthF( scaledWidth );
|
||||
@ -227,7 +227,7 @@ void QgsSimpleLineSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
mSelPen = mPen;
|
||||
QColor selColor = context.renderContext().selectionColor();
|
||||
if ( ! SELECTION_IS_OPAQUE )
|
||||
selColor.setAlphaF( context.alpha() );
|
||||
selColor.setAlphaF( context.opacity() );
|
||||
mSelPen.setColor( selColor );
|
||||
}
|
||||
|
||||
@ -800,7 +800,7 @@ QColor QgsMarkerLineSymbolLayer::color() const
|
||||
|
||||
void QgsMarkerLineSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
{
|
||||
mMarker->setAlpha( context.alpha() );
|
||||
mMarker->setOpacity( context.opacity() );
|
||||
|
||||
// if being rotated, it gets initialized with every line segment
|
||||
QgsSymbol::RenderHints hints = 0;
|
||||
|
@ -802,8 +802,8 @@ void QgsSimpleMarkerSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
QColor brushColor = mColor;
|
||||
QColor penColor = mStrokeColor;
|
||||
|
||||
brushColor.setAlphaF( mColor.alphaF() * context.alpha() );
|
||||
penColor.setAlphaF( mStrokeColor.alphaF() * context.alpha() );
|
||||
brushColor.setAlphaF( mColor.alphaF() * context.opacity() );
|
||||
penColor.setAlphaF( mStrokeColor.alphaF() * context.opacity() );
|
||||
|
||||
mBrush = QBrush( brushColor );
|
||||
mPen = QPen( penColor );
|
||||
@ -813,10 +813,10 @@ void QgsSimpleMarkerSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
|
||||
QColor selBrushColor = context.renderContext().selectionColor();
|
||||
QColor selPenColor = selBrushColor == mColor ? selBrushColor : mStrokeColor;
|
||||
if ( context.alpha() < 1 )
|
||||
if ( context.opacity() < 1 )
|
||||
{
|
||||
selBrushColor.setAlphaF( context.alpha() );
|
||||
selPenColor.setAlphaF( context.alpha() );
|
||||
selBrushColor.setAlphaF( context.opacity() );
|
||||
selPenColor.setAlphaF( context.opacity() );
|
||||
}
|
||||
mSelBrush = QBrush( selBrushColor );
|
||||
mSelPen = QPen( selPenColor );
|
||||
@ -1979,10 +1979,10 @@ void QgsSvgMarkerSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContext
|
||||
if ( fitsInCache && img.width() > 1 )
|
||||
{
|
||||
//consider transparency
|
||||
if ( !qgsDoubleNear( context.alpha(), 1.0 ) )
|
||||
if ( !qgsDoubleNear( context.opacity(), 1.0 ) )
|
||||
{
|
||||
QImage transparentImage = img.copy();
|
||||
QgsSymbolLayerUtils::multiplyImageOpacity( &transparentImage, context.alpha() );
|
||||
QgsSymbolLayerUtils::multiplyImageOpacity( &transparentImage, context.opacity() );
|
||||
p->drawImage( -transparentImage.width() / 2.0, -transparentImage.height() / 2.0, transparentImage );
|
||||
hwRatio = static_cast< double >( transparentImage.height() ) / static_cast< double >( transparentImage.width() );
|
||||
}
|
||||
@ -1996,7 +1996,7 @@ void QgsSvgMarkerSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContext
|
||||
|
||||
if ( usePict || !fitsInCache )
|
||||
{
|
||||
p->setOpacity( context.alpha() );
|
||||
p->setOpacity( context.opacity() );
|
||||
const QPicture &pct = QgsApplication::svgCache()->svgAsPicture( path, size, fillColor, strokeColor, strokeWidth,
|
||||
context.renderContext().scaleFactor(), context.renderContext().forceVectorOutput() );
|
||||
|
||||
@ -2540,8 +2540,8 @@ void QgsFontMarkerSymbolLayer::startRender( QgsSymbolRenderContext &context )
|
||||
QColor brushColor = mColor;
|
||||
QColor penColor = mStrokeColor;
|
||||
|
||||
brushColor.setAlphaF( mColor.alphaF() * context.alpha() );
|
||||
penColor.setAlphaF( mStrokeColor.alphaF() * context.alpha() );
|
||||
brushColor.setAlphaF( mColor.alphaF() * context.opacity() );
|
||||
penColor.setAlphaF( mStrokeColor.alphaF() * context.opacity() );
|
||||
|
||||
mBrush = QBrush( brushColor );
|
||||
mPen = QPen( penColor );
|
||||
@ -2667,7 +2667,7 @@ void QgsFontMarkerSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContex
|
||||
brushColor = mDataDefinedProperties.valueAsColor( QgsSymbolLayer::PropertyFillColor, context.renderContext().expressionContext(), brushColor );
|
||||
}
|
||||
brushColor = context.selected() ? context.renderContext().selectionColor() : brushColor;
|
||||
brushColor.setAlphaF( brushColor.alphaF() * context.alpha() );
|
||||
brushColor.setAlphaF( brushColor.alphaF() * context.opacity() );
|
||||
mBrush.setColor( brushColor );
|
||||
|
||||
QColor penColor = mStrokeColor;
|
||||
@ -2676,7 +2676,7 @@ void QgsFontMarkerSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContex
|
||||
context.setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( mStrokeColor ) );
|
||||
penColor = mDataDefinedProperties.valueAsColor( QgsSymbolLayer::PropertyStrokeColor, context.renderContext().expressionContext(), penColor );
|
||||
}
|
||||
penColor.setAlphaF( penColor.alphaF() * context.alpha() );
|
||||
penColor.setAlphaF( penColor.alphaF() * context.opacity() );
|
||||
|
||||
double penWidth = context.renderContext().convertToPainterUnits( mStrokeWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale );
|
||||
if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyStrokeWidth ) )
|
||||
|
@ -79,7 +79,6 @@ QgsProperty scaleWholeSymbol( double scaleFactorX, double scaleFactorY, const Qg
|
||||
QgsSymbol::QgsSymbol( SymbolType type, const QgsSymbolLayerList &layers )
|
||||
: mType( type )
|
||||
, mLayers( layers )
|
||||
, mAlpha( 1.0 )
|
||||
, mRenderHints( 0 )
|
||||
, mClipFeaturesToExtent( true )
|
||||
, mLayer( nullptr )
|
||||
@ -296,8 +295,17 @@ QgsSymbol *QgsSymbol::defaultSymbol( QgsWkbTypes::GeometryType geomType )
|
||||
}
|
||||
}
|
||||
|
||||
// set alpha transparency
|
||||
s->setAlpha( QgsProject::instance()->readDoubleEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/AlphaInt" ), 255 ) / 255.0 );
|
||||
// set opacity
|
||||
double opacity = 1.0;
|
||||
bool ok = false;
|
||||
// upgrade old setting
|
||||
double alpha = QgsProject::instance()->readDoubleEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/AlphaInt" ), 255, &ok );
|
||||
if ( ok )
|
||||
opacity = alpha / 255.0;
|
||||
double newOpacity = QgsProject::instance()->readDoubleEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/Opacity" ), 1.0, &ok );
|
||||
if ( ok )
|
||||
opacity = newOpacity;
|
||||
s->setOpacity( opacity );
|
||||
|
||||
// set random color, it project prefs allow
|
||||
if ( defaultSymbol == QLatin1String( "" ) ||
|
||||
@ -375,9 +383,9 @@ bool QgsSymbol::changeSymbolLayer( int index, QgsSymbolLayer *layer )
|
||||
|
||||
void QgsSymbol::startRender( QgsRenderContext &context, const QgsFields &fields )
|
||||
{
|
||||
mSymbolRenderContext.reset( new QgsSymbolRenderContext( context, outputUnit(), mAlpha, false, mRenderHints, nullptr, fields, mapUnitScale() ) );
|
||||
mSymbolRenderContext.reset( new QgsSymbolRenderContext( context, outputUnit(), mOpacity, false, mRenderHints, nullptr, fields, mapUnitScale() ) );
|
||||
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints, nullptr, fields, mapUnitScale() );
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mOpacity, false, mRenderHints, nullptr, fields, mapUnitScale() );
|
||||
|
||||
std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::updateSymbolScope( this, new QgsExpressionContextScope() ) );
|
||||
mSymbolRenderContext->setExpressionContextScope( scope.release() );
|
||||
@ -435,7 +443,7 @@ void QgsSymbol::drawPreviewIcon( QPainter *painter, QSize size, QgsRenderContext
|
||||
{
|
||||
QgsRenderContext context = customContext ? *customContext : QgsRenderContext::fromQPainter( painter );
|
||||
context.setForceVectorOutput( true );
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints, nullptr, QgsFields(), mapUnitScale() );
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mOpacity, false, mRenderHints, nullptr, QgsFields(), mapUnitScale() );
|
||||
|
||||
Q_FOREACH ( QgsSymbolLayer *layer, mLayers )
|
||||
{
|
||||
@ -568,7 +576,7 @@ QString QgsSymbol::dump() const
|
||||
|
||||
void QgsSymbol::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
|
||||
{
|
||||
props[ QStringLiteral( "alpha" )] = QString::number( alpha() );
|
||||
props[ QStringLiteral( "alpha" )] = QString::number( opacity() );
|
||||
double scaleFactor = 1.0;
|
||||
props[ QStringLiteral( "uom" )] = QgsSymbolLayerUtils::encodeSldUom( outputUnit(), &scaleFactor );
|
||||
props[ QStringLiteral( "uomScale" )] = ( !qgsDoubleNear( scaleFactor, 1.0 ) ? qgsDoubleToString( scaleFactor ) : QLatin1String( "" ) );
|
||||
@ -991,11 +999,11 @@ void QgsSymbol::renderVertexMarker( QPointF pt, QgsRenderContext &context, int c
|
||||
////////////////////
|
||||
|
||||
|
||||
QgsSymbolRenderContext::QgsSymbolRenderContext( QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal alpha, bool selected, QgsSymbol::RenderHints renderHints, const QgsFeature *f, const QgsFields &fields, const QgsMapUnitScale &mapUnitScale )
|
||||
QgsSymbolRenderContext::QgsSymbolRenderContext( QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal opacity, bool selected, QgsSymbol::RenderHints renderHints, const QgsFeature *f, const QgsFields &fields, const QgsMapUnitScale &mapUnitScale )
|
||||
: mRenderContext( c )
|
||||
, mOutputUnit( u )
|
||||
, mMapUnitScale( mapUnitScale )
|
||||
, mAlpha( alpha )
|
||||
, mOpacity( opacity )
|
||||
, mSelected( selected )
|
||||
, mRenderHints( renderHints )
|
||||
, mFeature( f )
|
||||
@ -1432,7 +1440,7 @@ void QgsMarkerSymbol::renderPointUsingLayer( QgsMarkerSymbolLayer *layer, QPoint
|
||||
|
||||
void QgsMarkerSymbol::renderPoint( QPointF point, const QgsFeature *f, QgsRenderContext &context, int layerIdx, bool selected )
|
||||
{
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f, QgsFields(), mapUnitScale() );
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mOpacity, selected, mRenderHints, f, QgsFields(), mapUnitScale() );
|
||||
symbolContext.setGeometryPartCount( symbolRenderContext()->geometryPartCount() );
|
||||
symbolContext.setGeometryPartNum( symbolRenderContext()->geometryPartNum() );
|
||||
|
||||
@ -1469,7 +1477,7 @@ void QgsMarkerSymbol::renderPoint( QPointF point, const QgsFeature *f, QgsRender
|
||||
|
||||
QRectF QgsMarkerSymbol::bounds( QPointF point, QgsRenderContext &context, const QgsFeature &feature ) const
|
||||
{
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints, &feature, feature.fields(), mapUnitScale() );
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mOpacity, false, mRenderHints, &feature, feature.fields(), mapUnitScale() );
|
||||
|
||||
QRectF bound;
|
||||
Q_FOREACH ( QgsSymbolLayer *layer, mLayers )
|
||||
@ -1489,7 +1497,7 @@ QRectF QgsMarkerSymbol::bounds( QPointF point, QgsRenderContext &context, const
|
||||
QgsMarkerSymbol *QgsMarkerSymbol::clone() const
|
||||
{
|
||||
QgsMarkerSymbol *cloneSymbol = new QgsMarkerSymbol( cloneLayers() );
|
||||
cloneSymbol->setAlpha( mAlpha );
|
||||
cloneSymbol->setOpacity( mOpacity );
|
||||
cloneSymbol->setLayer( mLayer );
|
||||
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
|
||||
return cloneSymbol;
|
||||
@ -1643,7 +1651,7 @@ void QgsLineSymbol::renderPolyline( const QPolygonF &points, const QgsFeature *f
|
||||
{
|
||||
//save old painter
|
||||
QPainter *renderPainter = context.painter();
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f, QgsFields(), mapUnitScale() );
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mOpacity, selected, mRenderHints, f, QgsFields(), mapUnitScale() );
|
||||
symbolContext.setOriginalGeometryType( QgsWkbTypes::LineGeometry );
|
||||
symbolContext.setGeometryPartCount( symbolRenderContext()->geometryPartCount() );
|
||||
symbolContext.setGeometryPartNum( symbolRenderContext()->geometryPartNum() );
|
||||
@ -1706,7 +1714,7 @@ void QgsLineSymbol::renderPolylineUsingLayer( QgsLineSymbolLayer *layer, const Q
|
||||
QgsLineSymbol *QgsLineSymbol::clone() const
|
||||
{
|
||||
QgsLineSymbol *cloneSymbol = new QgsLineSymbol( cloneLayers() );
|
||||
cloneSymbol->setAlpha( mAlpha );
|
||||
cloneSymbol->setOpacity( mOpacity );
|
||||
cloneSymbol->setLayer( mLayer );
|
||||
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
|
||||
return cloneSymbol;
|
||||
@ -1724,7 +1732,7 @@ QgsFillSymbol::QgsFillSymbol( const QgsSymbolLayerList &layers )
|
||||
|
||||
void QgsFillSymbol::renderPolygon( const QPolygonF &points, QList<QPolygonF> *rings, const QgsFeature *f, QgsRenderContext &context, int layerIdx, bool selected )
|
||||
{
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f, QgsFields(), mapUnitScale() );
|
||||
QgsSymbolRenderContext symbolContext( context, outputUnit(), mOpacity, selected, mRenderHints, f, QgsFields(), mapUnitScale() );
|
||||
symbolContext.setOriginalGeometryType( QgsWkbTypes::PolygonGeometry );
|
||||
symbolContext.setGeometryPartCount( symbolRenderContext()->geometryPartCount() );
|
||||
symbolContext.setGeometryPartNum( symbolRenderContext()->geometryPartNum() );
|
||||
@ -1824,7 +1832,7 @@ QList<QPolygonF> *QgsFillSymbol::translateRings( const QList<QPolygonF> *rings,
|
||||
QgsFillSymbol *QgsFillSymbol::clone() const
|
||||
{
|
||||
QgsFillSymbol *cloneSymbol = new QgsFillSymbol( cloneLayers() );
|
||||
cloneSymbol->setAlpha( mAlpha );
|
||||
cloneSymbol->setOpacity( mOpacity );
|
||||
cloneSymbol->setLayer( mLayer );
|
||||
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
|
||||
return cloneSymbol;
|
||||
|
@ -225,10 +225,19 @@ class CORE_EXPORT QgsSymbol
|
||||
QgsMapUnitScale mapUnitScale() const;
|
||||
void setMapUnitScale( const QgsMapUnitScale &scale );
|
||||
|
||||
//! Get alpha transparency 1 for opaque, 0 for invisible
|
||||
qreal alpha() const { return mAlpha; }
|
||||
//! Set alpha transparency 1 for opaque, 0 for invisible
|
||||
void setAlpha( qreal alpha ) { mAlpha = alpha; }
|
||||
/**
|
||||
* Returns the opacity for the symbol.
|
||||
* \returns opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* \see setOpacity()
|
||||
*/
|
||||
qreal opacity() const { return mOpacity; }
|
||||
|
||||
/**
|
||||
* Sets the \a opacity for the symbol.
|
||||
* \param opacity opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* \see opacity()
|
||||
*/
|
||||
void setOpacity( qreal opacity ) { mOpacity = opacity; }
|
||||
|
||||
/** Sets rendering hint flags for the symbol.
|
||||
* \see renderHints()
|
||||
@ -354,7 +363,7 @@ class CORE_EXPORT QgsSymbol
|
||||
QgsSymbolLayerList mLayers;
|
||||
|
||||
//! Symbol opacity (in the range 0 - 1)
|
||||
qreal mAlpha;
|
||||
qreal mOpacity = 1.0;
|
||||
|
||||
RenderHints mRenderHints;
|
||||
bool mClipFeaturesToExtent;
|
||||
@ -383,14 +392,14 @@ class CORE_EXPORT QgsSymbolRenderContext
|
||||
/** Constructor for QgsSymbolRenderContext
|
||||
* \param c
|
||||
* \param u
|
||||
* \param alpha
|
||||
* \param opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* \param selected set to true if symbol should be drawn in a "selected" state
|
||||
* \param renderHints flags controlling rendering behavior
|
||||
* \param f
|
||||
* \param fields
|
||||
* \param mapUnitScale
|
||||
*/
|
||||
QgsSymbolRenderContext( QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal alpha = 1.0, bool selected = false, QgsSymbol::RenderHints renderHints = 0, const QgsFeature *f = nullptr, const QgsFields &fields = QgsFields(), const QgsMapUnitScale &mapUnitScale = QgsMapUnitScale() );
|
||||
QgsSymbolRenderContext( QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal opacity = 1.0, bool selected = false, QgsSymbol::RenderHints renderHints = 0, const QgsFeature *f = nullptr, const QgsFields &fields = QgsFields(), const QgsMapUnitScale &mapUnitScale = QgsMapUnitScale() );
|
||||
|
||||
QgsRenderContext &renderContext() { return mRenderContext; }
|
||||
const QgsRenderContext &renderContext() const { return mRenderContext; }
|
||||
@ -411,10 +420,19 @@ class CORE_EXPORT QgsSymbolRenderContext
|
||||
QgsMapUnitScale mapUnitScale() const { return mMapUnitScale; }
|
||||
void setMapUnitScale( const QgsMapUnitScale &scale ) { mMapUnitScale = scale; }
|
||||
|
||||
//! Get alpha transparency 1 for opaque, 0 for invisible
|
||||
qreal alpha() const { return mAlpha; }
|
||||
//! Set alpha transparency 1 for opaque, 0 for invisible
|
||||
void setAlpha( qreal alpha ) { mAlpha = alpha; }
|
||||
/**
|
||||
* Returns the opacity for the symbol.
|
||||
* \returns opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* \see setOpacity()
|
||||
*/
|
||||
qreal opacity() const { return mOpacity; }
|
||||
|
||||
/**
|
||||
* Sets the \a opacity for the symbol.
|
||||
* \param opacity opacity value between 0 (fully transparent) and 1 (fully opaque)
|
||||
* \see opacity()
|
||||
*/
|
||||
void setOpacity( qreal opacity ) { mOpacity = opacity; }
|
||||
|
||||
bool selected() const { return mSelected; }
|
||||
void setSelected( bool selected ) { mSelected = selected; }
|
||||
@ -503,7 +521,7 @@ class CORE_EXPORT QgsSymbolRenderContext
|
||||
std::unique_ptr< QgsExpressionContextScope > mExpressionContextScope;
|
||||
QgsUnitTypes::RenderUnit mOutputUnit;
|
||||
QgsMapUnitScale mMapUnitScale;
|
||||
qreal mAlpha;
|
||||
qreal mOpacity = 1.0;
|
||||
bool mSelected;
|
||||
QgsSymbol::RenderHints mRenderHints;
|
||||
const QgsFeature *mFeature; //current feature
|
||||
|
@ -74,7 +74,7 @@ void QgsSymbolLayer::initPropertyDefinitions()
|
||||
{ QgsSymbolLayer::PropertyDistanceY, QgsPropertyDefinition( "distanceY", QObject::tr( "Vertical distance between markers" ), QgsPropertyDefinition::DoublePositive )},
|
||||
{ QgsSymbolLayer::PropertyDisplacementX, QgsPropertyDefinition( "displacementX", QObject::tr( "Horizontal displacement between rows" ), QgsPropertyDefinition::DoublePositive )},
|
||||
{ QgsSymbolLayer::PropertyDisplacementY, QgsPropertyDefinition( "displacementY", QObject::tr( "Vertical displacement between columns" ), QgsPropertyDefinition::DoublePositive )},
|
||||
{ QgsSymbolLayer::PropertyAlpha, QgsPropertyDefinition( "alpha", QObject::tr( "Opacity" ), QgsPropertyDefinition::Double0To1 )},
|
||||
{ QgsSymbolLayer::PropertyOpacity, QgsPropertyDefinition( "alpha", QObject::tr( "Opacity" ), QgsPropertyDefinition::Opacity )},
|
||||
{ QgsSymbolLayer::PropertyCustomDash, QgsPropertyDefinition( "customDash", QgsPropertyDefinition::DataTypeString, QObject::tr( "Custom dash pattern" ), QObject::tr( "[<b><dash>;<space></b>] e.g. '8;2;1;2'" ) )},
|
||||
{ QgsSymbolLayer::PropertyCapStyle, QgsPropertyDefinition( "capStyle", QObject::tr( "Line cap style" ), QgsPropertyDefinition::CapStyle )},
|
||||
{ QgsSymbolLayer::PropertyPlacement, QgsPropertyDefinition( "placement", QgsPropertyDefinition::DataTypeString, QObject::tr( "Marker placement" ), QObject::tr( "string " ) + "[<b>interval</b>|<b>vertex</b>|<b>lastvertex</b>|<b>firstvertex</b>|<b>centerpoint</b>|<b>curvepoint</b>]" )},
|
||||
@ -296,7 +296,7 @@ static const QMap< QString, QgsSymbolLayer::Property > OLD_PROPS
|
||||
{ "displacement_x", QgsSymbolLayer::PropertyDisplacementX },
|
||||
{ "displacement_y", QgsSymbolLayer::PropertyDisplacementY },
|
||||
{ "file", QgsSymbolLayer::PropertyFile },
|
||||
{ "alpha", QgsSymbolLayer::PropertyAlpha },
|
||||
{ "alpha", QgsSymbolLayer::PropertyOpacity },
|
||||
{ "customdash", QgsSymbolLayer::PropertyCustomDash },
|
||||
{ "line_style", QgsSymbolLayer::PropertyStrokeStyle },
|
||||
{ "joinstyle", QgsSymbolLayer::PropertyJoinStyle },
|
||||
|
@ -93,7 +93,7 @@ class CORE_EXPORT QgsSymbolLayer
|
||||
PropertyDistanceY, //!< Vertical distance between points
|
||||
PropertyDisplacementX, //!< Horizontal displacement
|
||||
PropertyDisplacementY, //!< Vertical displacement
|
||||
PropertyAlpha, //!< Alpha (opacity)
|
||||
PropertyOpacity, //!< Opacity
|
||||
PropertyCustomDash, //!< Custom dash pattern
|
||||
PropertyCapStyle, //!< Line cap style
|
||||
PropertyPlacement, //!< Line marker placement
|
||||
|
@ -874,7 +874,7 @@ QgsSymbol *QgsSymbolLayerUtils::loadSymbol( const QDomElement &element, const Qg
|
||||
mapUnitScale.maxScale = element.attribute( QStringLiteral( "mapUnitMaxScale" ), QStringLiteral( "0.0" ) ).toDouble();
|
||||
symbol->setMapUnitScale( mapUnitScale );
|
||||
}
|
||||
symbol->setAlpha( element.attribute( QStringLiteral( "alpha" ), QStringLiteral( "1.0" ) ).toDouble() );
|
||||
symbol->setOpacity( element.attribute( QStringLiteral( "alpha" ), QStringLiteral( "1.0" ) ).toDouble() );
|
||||
symbol->setClipFeaturesToExtent( element.attribute( QStringLiteral( "clip_to_extent" ), QStringLiteral( "1" ) ).toInt() );
|
||||
|
||||
return symbol;
|
||||
@ -945,7 +945,7 @@ QDomElement QgsSymbolLayerUtils::saveSymbol( const QString &name, QgsSymbol *sym
|
||||
QDomElement symEl = doc.createElement( QStringLiteral( "symbol" ) );
|
||||
symEl.setAttribute( QStringLiteral( "type" ), _nameForSymbolType( symbol->type() ) );
|
||||
symEl.setAttribute( QStringLiteral( "name" ), name );
|
||||
symEl.setAttribute( QStringLiteral( "alpha" ), QString::number( symbol->alpha() ) );
|
||||
symEl.setAttribute( QStringLiteral( "alpha" ), QString::number( symbol->opacity() ) );
|
||||
symEl.setAttribute( QStringLiteral( "clip_to_extent" ), symbol->clipFeaturesToExtent() ? "1" : "0" );
|
||||
//QgsDebugMsg( "num layers " + QString::number( symbol->symbolLayerCount() ) );
|
||||
|
||||
@ -3373,7 +3373,7 @@ QColor QgsSymbolLayerUtils::parseColorWithAlpha( const QString &colorStr, bool &
|
||||
return QColor();
|
||||
}
|
||||
|
||||
void QgsSymbolLayerUtils::multiplyImageOpacity( QImage *image, qreal alpha )
|
||||
void QgsSymbolLayerUtils::multiplyImageOpacity( QImage *image, qreal opacity )
|
||||
{
|
||||
if ( !image )
|
||||
{
|
||||
@ -3396,9 +3396,9 @@ void QgsSymbolLayerUtils::multiplyImageOpacity( QImage *image, qreal alpha )
|
||||
{
|
||||
myRgb = scanLine[widthIndex];
|
||||
if ( format == QImage::Format_ARGB32_Premultiplied )
|
||||
scanLine[widthIndex] = qRgba( alpha * qRed( myRgb ), alpha * qGreen( myRgb ), alpha * qBlue( myRgb ), alpha * qAlpha( myRgb ) );
|
||||
scanLine[widthIndex] = qRgba( opacity * qRed( myRgb ), opacity * qGreen( myRgb ), opacity * qBlue( myRgb ), opacity * qAlpha( myRgb ) );
|
||||
else
|
||||
scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), alpha * qAlpha( myRgb ) );
|
||||
scanLine[widthIndex] = qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), opacity * qAlpha( myRgb ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -492,8 +492,10 @@ class CORE_EXPORT QgsSymbolLayerUtils
|
||||
*/
|
||||
static QColor parseColorWithAlpha( const QString &colorStr, bool &containsAlpha, bool strictEval = false );
|
||||
|
||||
//! Multiplies opacity of image pixel values with a (global) transparency value
|
||||
static void multiplyImageOpacity( QImage *image, qreal alpha );
|
||||
/**
|
||||
* Multiplies opacity of image pixel values with a (global) transparency value.
|
||||
*/
|
||||
static void multiplyImageOpacity( QImage *image, qreal opacity );
|
||||
|
||||
//! Blurs an image in place, e.g. creating Qt-independent drop shadows
|
||||
static void blurImageInPlace( QImage &image, QRect rect, int radius, bool alphaOnly );
|
||||
|
@ -113,14 +113,14 @@ void QgsRendererWidget::changeSymbolTransparency()
|
||||
return;
|
||||
|
||||
bool ok;
|
||||
double oldTransparency = ( 1 - firstSymbol->alpha() ) * 100; // convert to percents
|
||||
double oldTransparency = ( 1 - firstSymbol->opacity() ) * 100; // convert to percents
|
||||
double transparency = QInputDialog::getDouble( this, tr( "Transparency" ), tr( "Change symbol transparency [%]" ), oldTransparency, 0.0, 100.0, 0, &ok );
|
||||
if ( ok )
|
||||
{
|
||||
Q_FOREACH ( QgsSymbol *symbol, symbolList )
|
||||
{
|
||||
if ( symbol )
|
||||
symbol->setAlpha( 1 - transparency / 100 );
|
||||
symbol->setOpacity( 1 - transparency / 100 );
|
||||
}
|
||||
refreshSymbolView();
|
||||
}
|
||||
|
@ -2918,12 +2918,16 @@ QgsRasterFillSymbolLayerWidget::QgsRasterFillSymbolLayerWidget( const QgsVectorL
|
||||
|
||||
mSpinOffsetX->setClearValue( 0.0 );
|
||||
mSpinOffsetY->setClearValue( 0.0 );
|
||||
mSpinOpacity->setClearValue( 100.0 );
|
||||
|
||||
connect( mSliderOpacity, &QSlider::valueChanged, this, [ = ]( int value ) { mSpinOpacity->setValue( value / 10.0 ); } );
|
||||
connect( mSpinOpacity, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value ) { whileBlocking( mSliderOpacity )->setValue( value * 10 ); } );
|
||||
connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterFillSymbolLayerWidget::setCoordinateMode );
|
||||
connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
|
||||
connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
|
||||
}
|
||||
|
||||
|
||||
void QgsRasterFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
|
||||
{
|
||||
if ( !layer )
|
||||
@ -2958,12 +2962,12 @@ void QgsRasterFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
|
||||
break;
|
||||
}
|
||||
cboCoordinateMode->blockSignals( false );
|
||||
mSpinTransparency->blockSignals( true );
|
||||
mSpinTransparency->setValue( mLayer->alpha() * 100.0 );
|
||||
mSpinTransparency->blockSignals( false );
|
||||
mSliderTransparency->blockSignals( true );
|
||||
mSliderTransparency->setValue( mLayer->alpha() * 100.0 );
|
||||
mSliderTransparency->blockSignals( false );
|
||||
mSpinOpacity->blockSignals( true );
|
||||
mSpinOpacity->setValue( mLayer->opacity() * 100.0 );
|
||||
mSpinOpacity->blockSignals( false );
|
||||
mSliderOpacity->blockSignals( true );
|
||||
mSliderOpacity->setValue( mLayer->opacity() * 1000.0 );
|
||||
mSliderOpacity->blockSignals( false );
|
||||
mRotationSpinBox->blockSignals( true );
|
||||
mRotationSpinBox->setValue( mLayer->angle() );
|
||||
mRotationSpinBox->blockSignals( false );
|
||||
@ -2989,7 +2993,7 @@ void QgsRasterFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
|
||||
updatePreviewImage();
|
||||
|
||||
registerDataDefinedButton( mFilenameDDBtn, QgsSymbolLayer::PropertyFile );
|
||||
registerDataDefinedButton( mOpacityDDBtn, QgsSymbolLayer::PropertyAlpha );
|
||||
registerDataDefinedButton( mOpacityDDBtn, QgsSymbolLayer::PropertyOpacity );
|
||||
registerDataDefinedButton( mRotationDDBtn, QgsSymbolLayer::PropertyAngle );
|
||||
registerDataDefinedButton( mWidthDDBtn, QgsSymbolLayer::PropertyWidth );
|
||||
}
|
||||
@ -3075,14 +3079,14 @@ void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void QgsRasterFillSymbolLayerWidget::on_mSpinTransparency_valueChanged( int value )
|
||||
void QgsRasterFillSymbolLayerWidget::on_mSpinOpacity_valueChanged( double value )
|
||||
{
|
||||
if ( !mLayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mLayer->setAlpha( value / 100.0 );
|
||||
mLayer->setOpacity( value / 100.0 );
|
||||
emit changed();
|
||||
updatePreviewImage();
|
||||
}
|
||||
@ -3171,9 +3175,9 @@ void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
|
||||
checkerBrush.setTexture( pix );
|
||||
p.fillRect( imageRect, checkerBrush );
|
||||
|
||||
if ( mLayer->alpha() < 1.0 )
|
||||
if ( mLayer->opacity() < 1.0 )
|
||||
{
|
||||
p.setOpacity( mLayer->alpha() );
|
||||
p.setOpacity( mLayer->opacity() );
|
||||
}
|
||||
|
||||
p.drawImage( imageRect.left(), imageRect.top(), image );
|
||||
|
@ -499,7 +499,7 @@ class GUI_EXPORT QgsRasterFillSymbolLayerWidget : public QgsSymbolLayerWidget, p
|
||||
void on_mBrowseToolButton_clicked();
|
||||
void on_mImageLineEdit_editingFinished();
|
||||
void setCoordinateMode( int index );
|
||||
void on_mSpinTransparency_valueChanged( int value );
|
||||
void on_mSpinOpacity_valueChanged( double value );
|
||||
void offsetChanged();
|
||||
void on_mOffsetUnitWidget_changed();
|
||||
void on_mRotationSpinBox_valueChanged( double d );
|
||||
|
@ -54,6 +54,7 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style,
|
||||
|
||||
mSymbolUnitWidget->setUnits( QgsUnitTypes::RenderUnitList() << QgsUnitTypes::RenderMillimeters << QgsUnitTypes::RenderMapUnits << QgsUnitTypes::RenderPixels
|
||||
<< QgsUnitTypes::RenderPoints << QgsUnitTypes::RenderInches );
|
||||
mOpacitySpinBox->setClearValue( 100.0 );
|
||||
|
||||
btnAdvanced->hide(); // advanced button is hidden by default
|
||||
if ( menu ) // show it if there is a menu pointer
|
||||
@ -112,6 +113,9 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style,
|
||||
btnColor->setColorDialogTitle( tr( "Select color" ) );
|
||||
btnColor->setContext( QStringLiteral( "symbology" ) );
|
||||
|
||||
connect( mOpacitySlider, &QSlider::valueChanged, this, [ = ]( int value ) { whileBlocking( mOpacitySpinBox )->setValue( value / 10.0 ); } );
|
||||
connect( mOpacitySpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value ) { mOpacitySlider->setValue( value * 10 ); } );
|
||||
|
||||
connect( btnSaveSymbol, &QPushButton::clicked, this, &QgsSymbolsListWidget::saveSymbol );
|
||||
}
|
||||
|
||||
@ -453,23 +457,16 @@ void QgsSymbolsListWidget::on_mSymbolUnitWidget_changed()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSymbolsListWidget::on_mTransparencySlider_valueChanged( int value )
|
||||
void QgsSymbolsListWidget::on_mOpacitySlider_valueChanged( int value )
|
||||
{
|
||||
if ( mSymbol )
|
||||
{
|
||||
double alpha = 1 - ( value / 255.0 );
|
||||
mSymbol->setAlpha( alpha );
|
||||
displayTransparency( alpha );
|
||||
double opacity = value / 1000.0;
|
||||
mSymbol->setOpacity( opacity );
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSymbolsListWidget::displayTransparency( double alpha )
|
||||
{
|
||||
double transparencyPercent = ( 1 - alpha ) * 100;
|
||||
mTransparencyLabel->setText( tr( "Transparency %1%" ).arg( ( int ) transparencyPercent ) );
|
||||
}
|
||||
|
||||
void QgsSymbolsListWidget::updateSymbolColor()
|
||||
{
|
||||
btnColor->blockSignals( true );
|
||||
@ -551,11 +548,8 @@ void QgsSymbolsListWidget::updateSymbolInfo()
|
||||
mSymbolUnitWidget->setMapUnitScale( mSymbol->mapUnitScale() );
|
||||
mSymbolUnitWidget->blockSignals( false );
|
||||
|
||||
mTransparencySlider->blockSignals( true );
|
||||
double transparency = 1 - mSymbol->alpha();
|
||||
mTransparencySlider->setValue( transparency * 255 );
|
||||
displayTransparency( mSymbol->alpha() );
|
||||
mTransparencySlider->blockSignals( false );
|
||||
whileBlocking( mOpacitySlider )->setValue( mSymbol->opacity() * 1000 );
|
||||
whileBlocking( mOpacitySpinBox )->setValue( mSymbol->opacity() * 100 );
|
||||
|
||||
if ( mSymbol->type() == QgsSymbol::Line || mSymbol->type() == QgsSymbol::Fill )
|
||||
{
|
||||
@ -588,7 +582,7 @@ void QgsSymbolsListWidget::setSymbolFromStyle( const QModelIndex &index )
|
||||
QgsSymbolLayer *sl = s->takeSymbolLayer( 0 );
|
||||
mSymbol->appendSymbolLayer( sl );
|
||||
}
|
||||
mSymbol->setAlpha( s->alpha() );
|
||||
mSymbol->setOpacity( s->opacity() );
|
||||
|
||||
// delete the temporary symbol
|
||||
delete s;
|
||||
|
@ -73,7 +73,6 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
|
||||
void symbolAddedToStyle( const QString &name, QgsSymbol *symbol );
|
||||
|
||||
void on_mSymbolUnitWidget_changed();
|
||||
void on_mTransparencySlider_valueChanged( int value );
|
||||
|
||||
//! Pupulates the groups combo box with available tags and smartgroups
|
||||
void populateGroups();
|
||||
@ -92,6 +91,7 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
|
||||
private slots:
|
||||
|
||||
void updateAssistantSymbol();
|
||||
void on_mOpacitySlider_valueChanged( int value );
|
||||
|
||||
private:
|
||||
QgsSymbol *mSymbol = nullptr;
|
||||
@ -106,10 +106,6 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
|
||||
void populateSymbols( const QStringList &symbols );
|
||||
void updateSymbolColor();
|
||||
void updateSymbolInfo();
|
||||
|
||||
//! Displays alpha value as transparency in mTransparencyLabel
|
||||
void displayTransparency( double alpha );
|
||||
|
||||
QgsSymbolWidgetContext mContext;
|
||||
|
||||
QgsExpressionContext createExpressionContext() const override;
|
||||
|
@ -2180,7 +2180,7 @@ namespace QgsWms
|
||||
QgsSymbolList symbolList = renderer->symbols( context );
|
||||
for ( auto symbolIt = symbolList.begin(); symbolIt != symbolList.end(); ++symbolIt )
|
||||
{
|
||||
( *symbolIt )->setAlpha( ( *symbolIt )->alpha() * opacityRatio );
|
||||
( *symbolIt )->setOpacity( ( *symbolIt )->opacity() * opacityRatio );
|
||||
}
|
||||
|
||||
//labeling
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>290</width>
|
||||
<height>417</height>
|
||||
<width>310</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -242,7 +242,7 @@
|
||||
<string>Opacity</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>mSliderTransparency</cstring>
|
||||
<cstring>mSliderOpacity</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -291,7 +291,7 @@
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,0">
|
||||
<item>
|
||||
<widget class="QSlider" name="mSliderTransparency">
|
||||
<widget class="QSlider" name="mSliderOpacity">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -299,10 +299,16 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -310,18 +316,21 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="mSpinTransparency">
|
||||
<widget class="QgsDoubleSpinBox" name="mSpinOpacity">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
<string> %</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -366,44 +375,11 @@
|
||||
<tabstop>mWidthSpinBox</tabstop>
|
||||
<tabstop>mRotationSpinBox</tabstop>
|
||||
<tabstop>cboCoordinateMode</tabstop>
|
||||
<tabstop>mSliderTransparency</tabstop>
|
||||
<tabstop>mSpinTransparency</tabstop>
|
||||
<tabstop>mSliderOpacity</tabstop>
|
||||
<tabstop>mSpinOpacity</tabstop>
|
||||
<tabstop>mSpinOffsetX</tabstop>
|
||||
<tabstop>mSpinOffsetY</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>mSliderTransparency</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>mSpinTransparency</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>311</x>
|
||||
<y>160</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>392</x>
|
||||
<y>160</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>mSpinTransparency</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>mSliderTransparency</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>392</x>
|
||||
<y>160</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>311</x>
|
||||
<y>160</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -14,12 +14,21 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
@ -152,13 +161,10 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="mSymbolUnitLabel">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>btnColor</cstring>
|
||||
<string>Unit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -172,38 +178,76 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>btnColor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="mTransparencyLabel">
|
||||
<property name="text">
|
||||
<string>Opacity</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>mTransparencySlider</cstring>
|
||||
<cstring>mOpacitySlider</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSlider" name="mTransparencySlider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="mSymbolUnitLabel">
|
||||
<property name="text">
|
||||
<string>Unit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QSlider" name="mOpacitySlider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDoubleSpinBox" name="mOpacitySpinBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> %</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QgsColorButton" name="btnColor">
|
||||
@ -245,7 +289,16 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="pageMarker">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
@ -341,7 +394,16 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageLine">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
@ -391,7 +453,16 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageFill">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
@ -427,13 +498,20 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>mTransparencySlider</tabstop>
|
||||
<tabstop>mOpacitySlider</tabstop>
|
||||
<tabstop>mOpacitySpinBox</tabstop>
|
||||
<tabstop>btnColor</tabstop>
|
||||
<tabstop>groupsCombo</tabstop>
|
||||
<tabstop>openStyleManagerButton</tabstop>
|
||||
<tabstop>viewSymbols</tabstop>
|
||||
<tabstop>btnSaveSymbol</tabstop>
|
||||
<tabstop>btnAdvanced</tabstop>
|
||||
<tabstop>spinSize</tabstop>
|
||||
<tabstop>mSizeDDBtn</tabstop>
|
||||
<tabstop>spinAngle</tabstop>
|
||||
<tabstop>mRotationDDBtn</tabstop>
|
||||
<tabstop>spinWidth</tabstop>
|
||||
<tabstop>mWidthDDBtn</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -505,9 +505,9 @@ void TestQgsComposerUtils::readOldDataDefinedPropertyMap()
|
||||
QVERIFY( ( dataDefinedProperties.property( QgsComposerObject::BlendMode ) ).isActive() );
|
||||
QCOMPARE( ( dataDefinedProperties.property( QgsComposerObject::BlendMode ) ).propertyType(), QgsProperty::ExpressionBasedProperty );
|
||||
QCOMPARE( dataDefinedProperties.property( QgsComposerObject::BlendMode ).expressionString(), QString( "test expression" ) );
|
||||
QVERIFY( !( dataDefinedProperties.property( QgsComposerObject::Transparency ) ).isActive() );
|
||||
QCOMPARE( ( dataDefinedProperties.property( QgsComposerObject::Transparency ) ).propertyType(), QgsProperty::FieldBasedProperty );
|
||||
QCOMPARE( dataDefinedProperties.property( QgsComposerObject::Transparency ).field(), QString( "test field 2" ) );
|
||||
QVERIFY( !( dataDefinedProperties.property( QgsComposerObject::Opacity ) ).isActive() );
|
||||
QCOMPARE( ( dataDefinedProperties.property( QgsComposerObject::Opacity ) ).propertyType(), QgsProperty::FieldBasedProperty );
|
||||
QCOMPARE( dataDefinedProperties.property( QgsComposerObject::Opacity ).field(), QString( "test field 2" ) );
|
||||
QVERIFY( ( dataDefinedProperties.property( QgsComposerObject::TestProperty ) ).isActive() );
|
||||
QCOMPARE( ( dataDefinedProperties.property( QgsComposerObject::TestProperty ) ).propertyType(), QgsProperty::FieldBasedProperty );
|
||||
QCOMPARE( dataDefinedProperties.property( QgsComposerObject::TestProperty ).field(), QString( "test field 3" ) );
|
||||
|
@ -139,7 +139,7 @@ void TestQgsRasterFill::init()
|
||||
mRasterFill->setWidth( 30.0 );
|
||||
mRasterFill->setWidthUnit( QgsUnitTypes::RenderPixels );
|
||||
mRasterFill->setCoordinateMode( QgsRasterFillSymbolLayer::Feature );
|
||||
mRasterFill->setAlpha( 1.0 );
|
||||
mRasterFill->setOpacity( 1.0 );
|
||||
mRasterFill->setOffset( QPointF( 0, 0 ) );
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ void TestQgsRasterFill::coordinateMode()
|
||||
void TestQgsRasterFill::alpha()
|
||||
{
|
||||
mReport += QLatin1String( "<h2>Raster fill alpha</h2>\n" );
|
||||
mRasterFill->setAlpha( 0.5 );
|
||||
mRasterFill->setOpacity( 0.5 );
|
||||
bool result = imageCheck( QStringLiteral( "rasterfill_alpha" ) );
|
||||
QVERIFY( result );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user