Skip to content
Permalink
Browse files

[FEATURE][layouts] Also allow full fill symbols to be used for single…

… box

and double box fill styles

Sponsored by SLYR
  • Loading branch information
nyalldawson committed Mar 21, 2020
1 parent 9378dcd commit e82a2e4df1dadebcdca2b7cb93e146445d83b0ce
@@ -228,6 +228,56 @@ transferred to the scalebar.

.. seealso:: :py:func:`lineSymbol`

.. versionadded:: 3.14
%End

QgsFillSymbol *fillSymbol1() const;
%Docstring
Returns the primary fill symbol used to render the scalebar (only used for some scalebar types).

Ownership is not transferred.

.. seealso:: :py:func:`setFillSymbol1`

.. seealso:: :py:func:`fillSymbol2`

.. versionadded:: 3.14
%End

void setFillSymbol1( QgsFillSymbol *symbol /Transfer/ );
%Docstring
Sets the primary fill ``symbol`` used to render the scalebar (only used for some scalebar types). Ownership of ``symbol`` is
transferred to the scalebar.

.. seealso:: :py:func:`fillSymbol1`

.. seealso:: :py:func:`setFillSymbol2`

.. versionadded:: 3.14
%End

QgsFillSymbol *fillSymbol2() const;
%Docstring
Returns the secondary fill symbol used to render the scalebar (only used for some scalebar types).

Ownership is not transferred.

.. seealso:: :py:func:`setFillSymbol2`

.. seealso:: :py:func:`fillSymbol1`

.. versionadded:: 3.14
%End

void setFillSymbol2( QgsFillSymbol *symbol /Transfer/ );
%Docstring
Sets the secondary fill ``symbol`` used to render the scalebar (only used for some scalebar types). Ownership of ``symbol`` is
transferred to the scalebar.

.. seealso:: :py:func:`fillSymbol2`

.. seealso:: :py:func:`setFillSymbol1`

.. versionadded:: 3.14
%End

@@ -275,40 +325,52 @@ Sets the ``color`` used for drawing text in the scalebar.
use setTextFormat() instead
%End

QColor fillColor() const;
QColor fillColor() const /Deprecated/;
%Docstring
Returns the color used for fills in the scalebar.

.. seealso:: :py:func:`setFillColor`

.. seealso:: :py:func:`fillColor2`

.. deprecated::
use fillSymbol1() instead
%End

void setFillColor( const QColor &color );
void setFillColor( const QColor &color ) /Deprecated/;
%Docstring
Sets the ``color`` used for fills in the scalebar.

.. seealso:: :py:func:`fillColor`

.. seealso:: :py:func:`setFillColor2`

.. deprecated::
use setFillSymbol1() instead
%End

QColor fillColor2() const;
QColor fillColor2() const /Deprecated/;
%Docstring
Returns the secondary color used for fills in the scalebar.

.. seealso:: :py:func:`setFillColor2`

.. seealso:: :py:func:`fillColor`

.. deprecated::
use fillSymbol2() instead
%End

void setFillColor2( const QColor &color );
void setFillColor2( const QColor &color ) /Deprecated/;
%Docstring
Sets the secondary ``color`` used for fills in the scalebar.

.. seealso:: :py:func:`fillColor2`

.. seealso:: :py:func:`setFillColor2`

.. deprecated::
use setFillSymbol2() instead
%End

QColor lineColor() const /Deprecated/;
@@ -361,7 +423,7 @@ Returns the pen used for drawing outlines in the scalebar.
use lineSymbol() instead
%End

QBrush brush() const;
QBrush brush() const /Deprecated/;
%Docstring
Returns the primary brush for the scalebar.

@@ -370,16 +432,22 @@ Returns the primary brush for the scalebar.
.. seealso:: :py:func:`brush2`

.. seealso:: :py:func:`pen`

.. deprecated::
use fillSymbol1() instead
%End

QBrush brush2() const;
QBrush brush2() const /Deprecated/;
%Docstring
Returns the secondary brush for the scalebar. This is used for alternating color style scalebars, such
as single and double box styles.

:return: QBrush used for secondary color areas

.. seealso:: :py:func:`brush`

.. deprecated::
use fillSymbol2() instead
%End

double height() const;
@@ -9,7 +9,6 @@




class QgsScaleBarSettings
{
%Docstring
@@ -291,40 +290,52 @@ Sets the ``color`` used for drawing text in the scalebar.
use textFormat() instead
%End

QColor fillColor() const;
QColor fillColor() const /Deprecated/;
%Docstring
Returns the color used for fills in the scalebar.

.. seealso:: :py:func:`setFillColor`

.. seealso:: :py:func:`fillColor2`

.. deprecated::
use fillSymbol1() instead.
%End

void setFillColor( const QColor &color );
void setFillColor( const QColor &color ) /Deprecated/;
%Docstring
Sets the ``color`` used for fills in the scalebar.

.. seealso:: :py:func:`fillColor`

.. seealso:: :py:func:`setFillColor2`

.. deprecated::
use setFillSymbol1() instead.
%End

QColor fillColor2() const;
QColor fillColor2() const /Deprecated/;
%Docstring
Returns the secondary color used for fills in the scalebar.

.. seealso:: :py:func:`setFillColor2`

.. seealso:: :py:func:`fillColor`

.. deprecated::
use fillSymbol2() instead
%End

void setFillColor2( const QColor &color );
void setFillColor2( const QColor &color ) /Deprecated/;
%Docstring
Sets the secondary ``color`` used for fills in the scalebar.

.. seealso:: :py:func:`fillColor2`

.. seealso:: :py:func:`setFillColor2`

.. deprecated::
use setFillSymbol2() instead.
%End

QColor lineColor() const /Deprecated/;
@@ -410,7 +421,58 @@ transferred to the scalebar.
.. versionadded:: 3.14
%End

QBrush brush() const;
QgsFillSymbol *fillSymbol1() const;
%Docstring
Returns the primary fill symbol used to render the scalebar (only used for some scalebar types).

Ownership is not transferred.

.. seealso:: :py:func:`setFillSymbol1`

.. seealso:: :py:func:`fillSymbol2`

.. versionadded:: 3.14
%End

void setFillSymbol1( QgsFillSymbol *symbol /Transfer/ );
%Docstring
Sets the primary fill ``symbol`` used to render the scalebar (only used for some scalebar types). Ownership of ``symbol`` is
transferred to the scalebar.

.. seealso:: :py:func:`fillSymbol1`

.. seealso:: :py:func:`setFillSymbol2`

.. versionadded:: 3.14
%End


QgsFillSymbol *fillSymbol2() const;
%Docstring
Returns the secondary fill symbol used to render the scalebar (only used for some scalebar types).

Ownership is not transferred.

.. seealso:: :py:func:`setFillSymbol2`

.. seealso:: :py:func:`fillSymbol1`

.. versionadded:: 3.14
%End

void setFillSymbol2( QgsFillSymbol *symbol /Transfer/ );
%Docstring
Sets the secondary fill ``symbol`` used to render the scalebar (only used for some scalebar types). Ownership of ``symbol`` is
transferred to the scalebar.

.. seealso:: :py:func:`fillSymbol2`

.. seealso:: :py:func:`setFillSymbol1`

.. versionadded:: 3.14
%End

QBrush brush() const /Deprecated/;
%Docstring
Returns the primary brush used for filling the scalebar.

@@ -419,30 +481,42 @@ Returns the primary brush used for filling the scalebar.
.. seealso:: :py:func:`brush2`

.. seealso:: :py:func:`pen`

.. deprecated::
use fillSymbol1() instead
%End

void setBrush( const QBrush &brush );
void setBrush( const QBrush &brush ) /Deprecated/;
%Docstring
Sets the primary brush used for filling the scalebar.

.. seealso:: :py:func:`brush`

.. deprecated::
use setFillSymbol1() instead
%End

QBrush brush2() const;
QBrush brush2() const /Deprecated/;
%Docstring
Returns the secondary brush for the scalebar. This is used for alternating color style scalebars, such
as single and double box styles.

.. seealso:: :py:func:`setBrush2`

.. seealso:: :py:func:`brush`

.. deprecated::
use fillSymbol2() instead
%End

void setBrush2( const QBrush &brush );
void setBrush2( const QBrush &brush ) /Deprecated/;
%Docstring
Sets the secondary brush used for filling the scalebar.

.. seealso:: :py:func:`brush`

.. deprecated::
use setFillSymbol2() instead
%End

double height() const;
@@ -35,6 +35,7 @@ email : sbr00pwb@users.sourceforge.net
#include "qgsunittypes.h"
#include "qgssettings.h"
#include "qgssymbollayerutils.h"
#include "qgsfillsymbollayer.h"

#include "qgsdoubleboxscalebarrenderer.h"
#include "qgsnumericscalebarrenderer.h"
@@ -153,7 +154,15 @@ void QgsDecorationScaleBar::setupScaleBar()
std::unique_ptr< QgsTicksScaleBarRenderer > tickStyle = qgis::make_unique< QgsTicksScaleBarRenderer >();
tickStyle->setTickPosition( mStyleIndex == 0 ? QgsTicksScaleBarRenderer::TicksDown : QgsTicksScaleBarRenderer::TicksUp );
mStyle = std::move( tickStyle );
mSettings.setFillColor( mColor );

std::unique_ptr< QgsFillSymbol > fillSymbol = qgis::make_unique< QgsFillSymbol >();
fillSymbol->setColor( mColor ); // Compatibility with pre 3.2 configuration
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol->symbolLayer( 0 ) ) )
{
fill->setStrokeStyle( Qt::NoPen );
}
mSettings.setFillSymbol1( fillSymbol.release() );

std::unique_ptr< QgsLineSymbol > lineSymbol = qgis::make_unique< QgsLineSymbol >();
lineSymbol->setColor( mColor ); // Compatibility with pre 3.2 configuration
lineSymbol->setWidth( 0.3 );
@@ -164,9 +173,26 @@ void QgsDecorationScaleBar::setupScaleBar()
}
case 2:
case 3:
{
mStyle = qgis::make_unique< QgsSingleBoxScaleBarRenderer >();
mSettings.setFillColor( mColor );
mSettings.setFillColor2( QColor( "transparent" ) );


std::unique_ptr< QgsFillSymbol > fillSymbol = qgis::make_unique< QgsFillSymbol >();
fillSymbol->setColor( mColor );
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol->symbolLayer( 0 ) ) )
{
fill->setStrokeStyle( Qt::NoPen );
}
mSettings.setFillSymbol1( fillSymbol.release() );

std::unique_ptr< QgsFillSymbol > fillSymbol2 = qgis::make_unique< QgsFillSymbol >();
fillSymbol2->setColor( QColor( 255, 255, 255, 0 ) );
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol2->symbolLayer( 0 ) ) )
{
fill->setStrokeStyle( Qt::NoPen );
}
mSettings.setFillSymbol2( fillSymbol2.release() );

mSettings.setHeight( mStyleIndex == 2 ? 1 : 3 );
std::unique_ptr< QgsLineSymbol > lineSymbol = qgis::make_unique< QgsLineSymbol >();
lineSymbol->setColor( mOutlineColor ); // Compatibility with pre 3.2 configuration
@@ -175,6 +201,7 @@ void QgsDecorationScaleBar::setupScaleBar()
mSettings.setLineSymbol( lineSymbol.release() );

break;
}
}
mSettings.setLabelBarSpace( 1.8 );
}

0 comments on commit e82a2e4

Please sign in to comment.
You can’t perform that action at this time.