mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-08 00:06:51 -05:00
restore default scalebar style only if fill symbol is invisible
This commit is contained in:
parent
1f7d1ad3d0
commit
2fd017500b
@ -38,13 +38,6 @@ Double box with alternating colors.
|
||||
|
||||
virtual bool applyDefaultSettings( QgsScaleBarSettings &settings ) const;
|
||||
|
||||
%Docstring
|
||||
Applies any default settings relating to the scalebar to the passed ``settings`` object.
|
||||
|
||||
Returns ``True`` if settings were applied.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
||||
@ -39,13 +39,6 @@ color for the segments.
|
||||
|
||||
virtual bool applyDefaultSettings( QgsScaleBarSettings &settings ) const;
|
||||
|
||||
%Docstring
|
||||
Applies any default settings relating to the scalebar to the passed ``settings`` object.
|
||||
|
||||
Returns ``True`` if settings were applied.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
||||
@ -38,13 +38,6 @@ Double box with alternating colors.
|
||||
|
||||
virtual bool applyDefaultSettings( QgsScaleBarSettings &settings ) const;
|
||||
|
||||
%Docstring
|
||||
Applies any default settings relating to the scalebar to the passed ``settings`` object.
|
||||
|
||||
Returns ``True`` if settings were applied.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
||||
@ -39,13 +39,6 @@ color for the segments.
|
||||
|
||||
virtual bool applyDefaultSettings( QgsScaleBarSettings &settings ) const;
|
||||
|
||||
%Docstring
|
||||
Applies any default settings relating to the scalebar to the passed ``settings`` object.
|
||||
|
||||
Returns ``True`` if settings were applied.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
||||
@ -194,21 +194,26 @@ void QgsDoubleBoxScaleBarRenderer::draw( QgsRenderContext &context, const QgsSca
|
||||
|
||||
bool QgsDoubleBoxScaleBarRenderer::applyDefaultSettings( QgsScaleBarSettings &settings ) const
|
||||
{
|
||||
// restore the fill symbols by default
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
std::unique_ptr< QgsSimpleFillSymbolLayer > fillSymbolLayer = std::make_unique< QgsSimpleFillSymbolLayer >();
|
||||
fillSymbolLayer->setColor( QColor( 0, 0, 0 ) );
|
||||
fillSymbolLayer->setBrushStyle( Qt::SolidPattern );
|
||||
fillSymbolLayer->setStrokeStyle( Qt::SolidLine );
|
||||
fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() );
|
||||
settings.setFillSymbol( fillSymbol.release() );
|
||||
QgsSimpleFillSymbolLayer *fill = qgis::down_cast< QgsSimpleFillSymbolLayer * >( settings.fillSymbol()->symbolLayers().at( 0 ) );
|
||||
|
||||
fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
fillSymbolLayer = std::make_unique< QgsSimpleFillSymbolLayer >();
|
||||
fillSymbolLayer->setColor( QColor( 255, 255, 255 ) );
|
||||
fillSymbolLayer->setStrokeStyle( Qt::NoPen );
|
||||
fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() );
|
||||
settings.setAlternateFillSymbol( fillSymbol.release() );
|
||||
// restore the fill symbols by default
|
||||
if ( fill && fill->brushStyle() == Qt::NoBrush )
|
||||
{
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
std::unique_ptr< QgsSimpleFillSymbolLayer > fillSymbolLayer = std::make_unique< QgsSimpleFillSymbolLayer >();
|
||||
fillSymbolLayer->setColor( QColor( 0, 0, 0 ) );
|
||||
fillSymbolLayer->setBrushStyle( Qt::SolidPattern );
|
||||
fillSymbolLayer->setStrokeStyle( Qt::SolidLine );
|
||||
fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() );
|
||||
settings.setFillSymbol( fillSymbol.release() );
|
||||
|
||||
fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
fillSymbolLayer = std::make_unique< QgsSimpleFillSymbolLayer >();
|
||||
fillSymbolLayer->setColor( QColor( 255, 255, 255 ) );
|
||||
fillSymbolLayer->setStrokeStyle( Qt::NoPen );
|
||||
fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() );
|
||||
settings.setAlternateFillSymbol( fillSymbol.release() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -42,13 +42,6 @@ class CORE_EXPORT QgsDoubleBoxScaleBarRenderer: public QgsScaleBarRenderer
|
||||
const QgsScaleBarSettings &settings,
|
||||
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const override;
|
||||
|
||||
/**
|
||||
* Applies any default settings relating to the scalebar to the passed \a settings object.
|
||||
*
|
||||
* Returns TRUE if settings were applied.
|
||||
*
|
||||
* \since QGIS 3.42
|
||||
*/
|
||||
bool applyDefaultSettings( QgsScaleBarSettings &settings ) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -160,21 +160,26 @@ void QgsSingleBoxScaleBarRenderer::draw( QgsRenderContext &context, const QgsSca
|
||||
|
||||
bool QgsSingleBoxScaleBarRenderer::applyDefaultSettings( QgsScaleBarSettings &settings ) const
|
||||
{
|
||||
// restore the fill symbols by default
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
std::unique_ptr< QgsSimpleFillSymbolLayer > fillSymbolLayer = std::make_unique< QgsSimpleFillSymbolLayer >();
|
||||
fillSymbolLayer->setColor( QColor( 0, 0, 0 ) );
|
||||
fillSymbolLayer->setBrushStyle( Qt::SolidPattern );
|
||||
fillSymbolLayer->setStrokeStyle( Qt::SolidLine );
|
||||
fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() );
|
||||
settings.setFillSymbol( fillSymbol.release() );
|
||||
QgsSimpleFillSymbolLayer *fill = qgis::down_cast< QgsSimpleFillSymbolLayer * >( settings.fillSymbol()->symbolLayers().at( 0 ) );
|
||||
|
||||
fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
fillSymbolLayer = std::make_unique< QgsSimpleFillSymbolLayer >();
|
||||
fillSymbolLayer->setColor( QColor( 255, 255, 255 ) );
|
||||
fillSymbolLayer->setStrokeStyle( Qt::NoPen );
|
||||
fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() );
|
||||
settings.setAlternateFillSymbol( fillSymbol.release() );
|
||||
// restore the fill symbols by default
|
||||
if ( fill && fill->brushStyle() == Qt::NoBrush )
|
||||
{
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
std::unique_ptr< QgsSimpleFillSymbolLayer > fillSymbolLayer = std::make_unique< QgsSimpleFillSymbolLayer >();
|
||||
fillSymbolLayer->setColor( QColor( 0, 0, 0 ) );
|
||||
fillSymbolLayer->setBrushStyle( Qt::SolidPattern );
|
||||
fillSymbolLayer->setStrokeStyle( Qt::SolidLine );
|
||||
fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() );
|
||||
settings.setFillSymbol( fillSymbol.release() );
|
||||
|
||||
fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
fillSymbolLayer = std::make_unique< QgsSimpleFillSymbolLayer >();
|
||||
fillSymbolLayer->setColor( QColor( 255, 255, 255 ) );
|
||||
fillSymbolLayer->setStrokeStyle( Qt::NoPen );
|
||||
fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() );
|
||||
settings.setAlternateFillSymbol( fillSymbol.release() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -43,13 +43,6 @@ class CORE_EXPORT QgsSingleBoxScaleBarRenderer: public QgsScaleBarRenderer
|
||||
const QgsScaleBarSettings &settings,
|
||||
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const override;
|
||||
|
||||
/**
|
||||
* Applies any default settings relating to the scalebar to the passed \a settings object.
|
||||
*
|
||||
* Returns TRUE if settings were applied.
|
||||
*
|
||||
* \since QGIS 3.42
|
||||
*/
|
||||
bool applyDefaultSettings( QgsScaleBarSettings &settings ) const override;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user