mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
[FEATURE][layouts] Allow customisation of division and subdivision symbol
as distinct symbols vs the scalebar line symbol Allows for styling division and subdivision symbols in a different way compared with the horizontal line symbol in a tick scalebar Sponsored by SLYR
This commit is contained in:
parent
870b5e55fd
commit
8699f83d98
@ -12,5 +12,7 @@ QgsScaleBarRenderer.Flag.FlagUsesLabelVerticalPlacement.__doc__ = "Renderer uses
|
||||
QgsScaleBarRenderer.Flag.FlagUsesLabelHorizontalPlacement.__doc__ = "Renderer uses the QgsScaleBarSettings::labelHorizontalPlacement() setting"
|
||||
QgsScaleBarRenderer.Flag.FlagUsesAlignment.__doc__ = "Renderer uses the QgsScaleBarSettings::alignment() setting"
|
||||
QgsScaleBarRenderer.Flag.FlagUsesSubdivisions.__doc__ = "Renderer uses the scalebar subdivisions"
|
||||
QgsScaleBarRenderer.Flag.__doc__ = 'Flags which control scalebar renderer behavior.\n\n.. versionadded:: 3.14\n\n' + '* ``FlagUsesLineSymbol``: ' + QgsScaleBarRenderer.Flag.FlagUsesLineSymbol.__doc__ + '\n' + '* ``FlagUsesFillSymbol``: ' + QgsScaleBarRenderer.Flag.FlagUsesFillSymbol.__doc__ + '\n' + '* ``FlagUsesAlternateFillSymbol``: ' + QgsScaleBarRenderer.Flag.FlagUsesAlternateFillSymbol.__doc__ + '\n' + '* ``FlagRespectsUnits``: ' + QgsScaleBarRenderer.Flag.FlagRespectsUnits.__doc__ + '\n' + '* ``FlagRespectsMapUnitsPerScaleBarUnit``: ' + QgsScaleBarRenderer.Flag.FlagRespectsMapUnitsPerScaleBarUnit.__doc__ + '\n' + '* ``FlagUsesUnitLabel``: ' + QgsScaleBarRenderer.Flag.FlagUsesUnitLabel.__doc__ + '\n' + '* ``FlagUsesSegments``: ' + QgsScaleBarRenderer.Flag.FlagUsesSegments.__doc__ + '\n' + '* ``FlagUsesLabelBarSpace``: ' + QgsScaleBarRenderer.Flag.FlagUsesLabelBarSpace.__doc__ + '\n' + '* ``FlagUsesLabelVerticalPlacement``: ' + QgsScaleBarRenderer.Flag.FlagUsesLabelVerticalPlacement.__doc__ + '\n' + '* ``FlagUsesLabelHorizontalPlacement``: ' + QgsScaleBarRenderer.Flag.FlagUsesLabelHorizontalPlacement.__doc__ + '\n' + '* ``FlagUsesAlignment``: ' + QgsScaleBarRenderer.Flag.FlagUsesAlignment.__doc__ + '\n' + '* ``FlagUsesSubdivisions``: ' + QgsScaleBarRenderer.Flag.FlagUsesSubdivisions.__doc__
|
||||
QgsScaleBarRenderer.Flag.FlagUsesDivisionSymbol.__doc__ = "Renderer utilizes the scalebar division symbol (see QgsScaleBarSettings::divisionLineSymbol() )"
|
||||
QgsScaleBarRenderer.Flag.FlagUsesSubdivisionSymbol.__doc__ = "Renderer utilizes the scalebar subdivision symbol (see QgsScaleBarSettings::subdivisionLineSymbol() )"
|
||||
QgsScaleBarRenderer.Flag.__doc__ = 'Flags which control scalebar renderer behavior.\n\n.. versionadded:: 3.14\n\n' + '* ``FlagUsesLineSymbol``: ' + QgsScaleBarRenderer.Flag.FlagUsesLineSymbol.__doc__ + '\n' + '* ``FlagUsesFillSymbol``: ' + QgsScaleBarRenderer.Flag.FlagUsesFillSymbol.__doc__ + '\n' + '* ``FlagUsesAlternateFillSymbol``: ' + QgsScaleBarRenderer.Flag.FlagUsesAlternateFillSymbol.__doc__ + '\n' + '* ``FlagRespectsUnits``: ' + QgsScaleBarRenderer.Flag.FlagRespectsUnits.__doc__ + '\n' + '* ``FlagRespectsMapUnitsPerScaleBarUnit``: ' + QgsScaleBarRenderer.Flag.FlagRespectsMapUnitsPerScaleBarUnit.__doc__ + '\n' + '* ``FlagUsesUnitLabel``: ' + QgsScaleBarRenderer.Flag.FlagUsesUnitLabel.__doc__ + '\n' + '* ``FlagUsesSegments``: ' + QgsScaleBarRenderer.Flag.FlagUsesSegments.__doc__ + '\n' + '* ``FlagUsesLabelBarSpace``: ' + QgsScaleBarRenderer.Flag.FlagUsesLabelBarSpace.__doc__ + '\n' + '* ``FlagUsesLabelVerticalPlacement``: ' + QgsScaleBarRenderer.Flag.FlagUsesLabelVerticalPlacement.__doc__ + '\n' + '* ``FlagUsesLabelHorizontalPlacement``: ' + QgsScaleBarRenderer.Flag.FlagUsesLabelHorizontalPlacement.__doc__ + '\n' + '* ``FlagUsesAlignment``: ' + QgsScaleBarRenderer.Flag.FlagUsesAlignment.__doc__ + '\n' + '* ``FlagUsesSubdivisions``: ' + QgsScaleBarRenderer.Flag.FlagUsesSubdivisions.__doc__ + '\n' + '* ``FlagUsesDivisionSymbol``: ' + QgsScaleBarRenderer.Flag.FlagUsesDivisionSymbol.__doc__ + '\n' + '* ``FlagUsesSubdivisionSymbol``: ' + QgsScaleBarRenderer.Flag.FlagUsesSubdivisionSymbol.__doc__
|
||||
# --
|
||||
|
||||
@ -256,6 +256,7 @@ Sets the text ``format`` used for drawing text in the scalebar.
|
||||
.. versionadded:: 3.2
|
||||
%End
|
||||
|
||||
|
||||
QgsLineSymbol *lineSymbol() const;
|
||||
%Docstring
|
||||
Returns the line symbol used to render the scalebar (only used for some scalebar types).
|
||||
@ -264,6 +265,10 @@ Ownership is not transferred.
|
||||
|
||||
.. seealso:: :py:func:`setLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`divisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`subdivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
@ -274,6 +279,68 @@ transferred to the scalebar.
|
||||
|
||||
.. seealso:: :py:func:`lineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setDivisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setSubdivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
QgsLineSymbol *divisionLineSymbol() const;
|
||||
%Docstring
|
||||
Returns the line symbol used to render the scalebar divisions (only used for some scalebar types).
|
||||
|
||||
Ownership is not transferred.
|
||||
|
||||
.. seealso:: :py:func:`setDivisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`lineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`subdivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void setDivisionLineSymbol( QgsLineSymbol *symbol /Transfer/ );
|
||||
%Docstring
|
||||
Sets the line ``symbol`` used to render the scalebar divisions (only used for some scalebar types). Ownership of ``symbol`` is
|
||||
transferred to the scalebar.
|
||||
|
||||
.. seealso:: :py:func:`divisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setSubdivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
QgsLineSymbol *subdivisionLineSymbol() const;
|
||||
%Docstring
|
||||
Returns the line symbol used to render the scalebar subdivisions (only used for some scalebar types).
|
||||
|
||||
Ownership is not transferred.
|
||||
|
||||
.. seealso:: :py:func:`setSubdivisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`lineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`divisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void setSubdivisionLineSymbol( QgsLineSymbol *symbol /Transfer/ );
|
||||
%Docstring
|
||||
Sets the line ``symbol`` used to render the scalebar subdivisions (only used for some scalebar types). Ownership of ``symbol`` is
|
||||
transferred to the scalebar.
|
||||
|
||||
.. seealso:: :py:func:`subdivisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setDivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
|
||||
@ -50,6 +50,8 @@ custom labeling.
|
||||
FlagUsesLabelHorizontalPlacement,
|
||||
FlagUsesAlignment,
|
||||
FlagUsesSubdivisions,
|
||||
FlagUsesDivisionSymbol,
|
||||
FlagUsesSubdivisionSymbol,
|
||||
};
|
||||
typedef QFlags<QgsScaleBarRenderer::Flag> Flags;
|
||||
|
||||
|
||||
@ -454,6 +454,10 @@ Ownership is not transferred.
|
||||
|
||||
.. seealso:: :py:func:`setLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`divisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`subdivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
@ -464,6 +468,68 @@ transferred to the scalebar.
|
||||
|
||||
.. seealso:: :py:func:`lineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setDivisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setSubdivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
QgsLineSymbol *divisionLineSymbol() const;
|
||||
%Docstring
|
||||
Returns the line symbol used to render the scalebar divisions (only used for some scalebar types).
|
||||
|
||||
Ownership is not transferred.
|
||||
|
||||
.. seealso:: :py:func:`setDivisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`lineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`subdivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void setDivisionLineSymbol( QgsLineSymbol *symbol /Transfer/ );
|
||||
%Docstring
|
||||
Sets the line ``symbol`` used to render the scalebar divisions (only used for some scalebar types). Ownership of ``symbol`` is
|
||||
transferred to the scalebar.
|
||||
|
||||
.. seealso:: :py:func:`divisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setSubdivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
QgsLineSymbol *subdivisionLineSymbol() const;
|
||||
%Docstring
|
||||
Returns the line symbol used to render the scalebar subdivisions (only used for some scalebar types).
|
||||
|
||||
Ownership is not transferred.
|
||||
|
||||
.. seealso:: :py:func:`setSubdivisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`lineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`divisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void setSubdivisionLineSymbol( QgsLineSymbol *symbol /Transfer/ );
|
||||
%Docstring
|
||||
Sets the line ``symbol`` used to render the scalebar subdivisions (only used for some scalebar types). Ownership of ``symbol`` is
|
||||
transferred to the scalebar.
|
||||
|
||||
.. seealso:: :py:func:`subdivisionLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setLineSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setDivisionLineSymbol`
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
|
||||
@ -1118,6 +1118,8 @@ bool QgsCompositionConverter::readScaleBarXml( QgsLayoutItemScaleBar *layoutItem
|
||||
lineSymbolLayer->setColor( QColor( itemElem.attribute( QStringLiteral( "penColor" ), QStringLiteral( "#000000" ) ) ) );
|
||||
}
|
||||
lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() );
|
||||
layoutItem->setDivisionLineSymbol( lineSymbol->clone() );
|
||||
layoutItem->setSubdivisionLineSymbol( lineSymbol->clone() );
|
||||
layoutItem->setLineSymbol( lineSymbol.release() );
|
||||
|
||||
//font color
|
||||
|
||||
@ -194,6 +194,26 @@ void QgsLayoutItemScaleBar::setLineSymbol( QgsLineSymbol *symbol )
|
||||
mSettings.setLineSymbol( symbol );
|
||||
}
|
||||
|
||||
QgsLineSymbol *QgsLayoutItemScaleBar::divisionLineSymbol() const
|
||||
{
|
||||
return mSettings.divisionLineSymbol();
|
||||
}
|
||||
|
||||
void QgsLayoutItemScaleBar::setDivisionLineSymbol( QgsLineSymbol *symbol )
|
||||
{
|
||||
mSettings.setDivisionLineSymbol( symbol );
|
||||
}
|
||||
|
||||
QgsLineSymbol *QgsLayoutItemScaleBar::subdivisionLineSymbol() const
|
||||
{
|
||||
return mSettings.subdivisionLineSymbol();
|
||||
}
|
||||
|
||||
void QgsLayoutItemScaleBar::setSubdivisionLineSymbol( QgsLineSymbol *symbol )
|
||||
{
|
||||
mSettings.setSubdivisionLineSymbol( symbol );
|
||||
}
|
||||
|
||||
QgsFillSymbol *QgsLayoutItemScaleBar::fillSymbol() const
|
||||
{
|
||||
return mSettings.fillSymbol();
|
||||
@ -813,6 +833,22 @@ bool QgsLayoutItemScaleBar::writePropertiesToElement( QDomElement &composerScale
|
||||
lineSymbol.appendChild( symbolElem );
|
||||
composerScaleBarElem.appendChild( lineSymbol );
|
||||
|
||||
QDomElement divisionSymbol = doc.createElement( QStringLiteral( "divisionLineSymbol" ) );
|
||||
const QDomElement divisionSymbolElem = QgsSymbolLayerUtils::saveSymbol( QString(),
|
||||
mSettings.divisionLineSymbol(),
|
||||
doc,
|
||||
rwContext );
|
||||
divisionSymbol.appendChild( divisionSymbolElem );
|
||||
composerScaleBarElem.appendChild( divisionSymbol );
|
||||
|
||||
QDomElement subdivisionSymbol = doc.createElement( QStringLiteral( "subdivisionLineSymbol" ) );
|
||||
const QDomElement subdivisionSymbolElem = QgsSymbolLayerUtils::saveSymbol( QString(),
|
||||
mSettings.subdivisionLineSymbol(),
|
||||
doc,
|
||||
rwContext );
|
||||
subdivisionSymbol.appendChild( subdivisionSymbolElem );
|
||||
composerScaleBarElem.appendChild( subdivisionSymbol );
|
||||
|
||||
QDomElement fillSymbol1Elem = doc.createElement( QStringLiteral( "fillSymbol1" ) );
|
||||
const QDomElement symbol1Elem = QgsSymbolLayerUtils::saveSymbol( QString(),
|
||||
mSettings.fillSymbol(),
|
||||
@ -860,6 +896,35 @@ bool QgsLayoutItemScaleBar::readPropertiesFromElement( const QDomElement &itemEl
|
||||
foundLineSymbol = true;
|
||||
}
|
||||
}
|
||||
QDomElement divisionSymbolElem = itemElem.firstChildElement( QStringLiteral( "divisionLineSymbol" ) );
|
||||
if ( !divisionSymbolElem.isNull() )
|
||||
{
|
||||
QDomElement symbolElem = divisionSymbolElem.firstChildElement( QStringLiteral( "symbol" ) );
|
||||
std::unique_ptr< QgsLineSymbol > lineSymbol( QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( symbolElem, context ) );
|
||||
if ( lineSymbol )
|
||||
{
|
||||
mSettings.setDivisionLineSymbol( lineSymbol.release() );
|
||||
}
|
||||
}
|
||||
else if ( foundLineSymbol )
|
||||
{
|
||||
mSettings.setDivisionLineSymbol( mSettings.lineSymbol()->clone() );
|
||||
}
|
||||
QDomElement subdivisionSymbolElem = itemElem.firstChildElement( QStringLiteral( "subdivisionLineSymbol" ) );
|
||||
if ( !subdivisionSymbolElem.isNull() )
|
||||
{
|
||||
QDomElement symbolElem = subdivisionSymbolElem.firstChildElement( QStringLiteral( "symbol" ) );
|
||||
std::unique_ptr< QgsLineSymbol > lineSymbol( QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( symbolElem, context ) );
|
||||
if ( lineSymbol )
|
||||
{
|
||||
mSettings.setSubdivisionLineSymbol( lineSymbol.release() );
|
||||
}
|
||||
}
|
||||
else if ( foundLineSymbol )
|
||||
{
|
||||
mSettings.setSubdivisionLineSymbol( mSettings.lineSymbol()->clone() );
|
||||
}
|
||||
|
||||
if ( !foundLineSymbol )
|
||||
{
|
||||
// old project compatibility
|
||||
@ -901,7 +966,9 @@ bool QgsLayoutItemScaleBar::readPropertiesFromElement( const QDomElement &itemEl
|
||||
dataDefinedProperties().setProperty( QgsLayoutObject::ScalebarLineColor, QgsProperty() );
|
||||
|
||||
lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() );
|
||||
mSettings.setLineSymbol( lineSymbol.release() );
|
||||
mSettings.setLineSymbol( lineSymbol->clone() );
|
||||
mSettings.setDivisionLineSymbol( lineSymbol->clone() );
|
||||
mSettings.setSubdivisionLineSymbol( lineSymbol.release() );
|
||||
}
|
||||
|
||||
mSettings.setUnitLabel( itemElem.attribute( QStringLiteral( "unitLabel" ) ) );
|
||||
|
||||
@ -224,12 +224,15 @@ class CORE_EXPORT QgsLayoutItemScaleBar: public QgsLayoutItem
|
||||
*/
|
||||
void setTextFormat( const QgsTextFormat &format );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the line symbol used to render the scalebar (only used for some scalebar types).
|
||||
*
|
||||
* Ownership is not transferred.
|
||||
*
|
||||
* \see setLineSymbol()
|
||||
* \see divisionLineSymbol()
|
||||
* \see subdivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
QgsLineSymbol *lineSymbol() const;
|
||||
@ -239,10 +242,58 @@ class CORE_EXPORT QgsLayoutItemScaleBar: public QgsLayoutItem
|
||||
* transferred to the scalebar.
|
||||
*
|
||||
* \see lineSymbol()
|
||||
* \see setDivisionLineSymbol()
|
||||
* \see setSubdivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Returns the line symbol used to render the scalebar divisions (only used for some scalebar types).
|
||||
*
|
||||
* Ownership is not transferred.
|
||||
*
|
||||
* \see setDivisionLineSymbol()
|
||||
* \see lineSymbol()
|
||||
* \see subdivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
QgsLineSymbol *divisionLineSymbol() const;
|
||||
|
||||
/**
|
||||
* Sets the line \a symbol used to render the scalebar divisions (only used for some scalebar types). Ownership of \a symbol is
|
||||
* transferred to the scalebar.
|
||||
*
|
||||
* \see divisionLineSymbol()
|
||||
* \see setLineSymbol()
|
||||
* \see setSubdivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setDivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Returns the line symbol used to render the scalebar subdivisions (only used for some scalebar types).
|
||||
*
|
||||
* Ownership is not transferred.
|
||||
*
|
||||
* \see setSubdivisionLineSymbol()
|
||||
* \see lineSymbol()
|
||||
* \see divisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
QgsLineSymbol *subdivisionLineSymbol() const;
|
||||
|
||||
/**
|
||||
* Sets the line \a symbol used to render the scalebar subdivisions (only used for some scalebar types). Ownership of \a symbol is
|
||||
* transferred to the scalebar.
|
||||
*
|
||||
* \see subdivisionLineSymbol()
|
||||
* \see setLineSymbol()
|
||||
* \see setDivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setSubdivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Returns the primary fill symbol used to render the scalebar (only used for some scalebar types).
|
||||
*
|
||||
|
||||
@ -82,6 +82,8 @@ class CORE_EXPORT QgsScaleBarRenderer
|
||||
FlagUsesLabelHorizontalPlacement = 1 << 8, //!< Renderer uses the QgsScaleBarSettings::labelHorizontalPlacement() setting
|
||||
FlagUsesAlignment = 1 << 9, //!< Renderer uses the QgsScaleBarSettings::alignment() setting
|
||||
FlagUsesSubdivisions = 1 << 10, //!< Renderer uses the scalebar subdivisions
|
||||
FlagUsesDivisionSymbol = 1 << 11, //!< Renderer utilizes the scalebar division symbol (see QgsScaleBarSettings::divisionLineSymbol() )
|
||||
FlagUsesSubdivisionSymbol = 1 << 12, //!< Renderer utilizes the scalebar subdivision symbol (see QgsScaleBarSettings::subdivisionLineSymbol() )
|
||||
};
|
||||
Q_DECLARE_FLAGS( Flags, Flag )
|
||||
|
||||
|
||||
@ -39,6 +39,8 @@ QgsScaleBarSettings::QgsScaleBarSettings()
|
||||
line->setPenCapStyle( Qt::SquareCap );
|
||||
}
|
||||
mLineSymbol->setOutputUnit( QgsUnitTypes::RenderMillimeters );
|
||||
mDivisionLineSymbol.reset( mLineSymbol->clone() );
|
||||
mSubdivisionLineSymbol.reset( mLineSymbol->clone() );
|
||||
|
||||
mFillSymbol = qgis::make_unique< QgsFillSymbol >();
|
||||
mFillSymbol->setColor( QColor( 0, 0, 0 ) );
|
||||
@ -68,6 +70,8 @@ QgsScaleBarSettings::QgsScaleBarSettings( const QgsScaleBarSettings &other )
|
||||
, mTextFormat( other.mTextFormat )
|
||||
, mHeight( other.mHeight )
|
||||
, mLineSymbol( other.mLineSymbol->clone() )
|
||||
, mDivisionLineSymbol( other.mDivisionLineSymbol->clone() )
|
||||
, mSubdivisionLineSymbol( other.mSubdivisionLineSymbol->clone() )
|
||||
, mFillSymbol( other.mFillSymbol->clone() )
|
||||
, mAlternateFillSymbol( other.mAlternateFillSymbol->clone() )
|
||||
, mLabelBarSpace( other.mLabelBarSpace )
|
||||
@ -95,6 +99,8 @@ QgsScaleBarSettings &QgsScaleBarSettings::operator=( const QgsScaleBarSettings &
|
||||
mUnitLabeling = other.mUnitLabeling;
|
||||
mTextFormat = other.mTextFormat;
|
||||
mLineSymbol.reset( other.mLineSymbol->clone() );
|
||||
mDivisionLineSymbol.reset( other.mDivisionLineSymbol->clone() );
|
||||
mSubdivisionLineSymbol.reset( other.mSubdivisionLineSymbol->clone() );
|
||||
mFillSymbol.reset( other.mFillSymbol->clone() );
|
||||
mAlternateFillSymbol.reset( other.mAlternateFillSymbol->clone() );
|
||||
mHeight = other.mHeight;
|
||||
@ -135,7 +141,10 @@ QColor QgsScaleBarSettings::lineColor() const
|
||||
|
||||
void QgsScaleBarSettings::setLineColor( const QColor &color )
|
||||
{
|
||||
mLineSymbol->setColor( color );
|
||||
for ( QgsLineSymbol *symbol : { mLineSymbol.get(), mDivisionLineSymbol.get(), mSubdivisionLineSymbol.get() } )
|
||||
{
|
||||
symbol->setColor( color );
|
||||
}
|
||||
}
|
||||
|
||||
double QgsScaleBarSettings::lineWidth() const
|
||||
@ -145,8 +154,11 @@ double QgsScaleBarSettings::lineWidth() const
|
||||
|
||||
void QgsScaleBarSettings::setLineWidth( double width )
|
||||
{
|
||||
mLineSymbol->setWidth( width );
|
||||
mLineSymbol->setOutputUnit( QgsUnitTypes::RenderMillimeters );
|
||||
for ( QgsLineSymbol *symbol : { mLineSymbol.get(), mDivisionLineSymbol.get(), mSubdivisionLineSymbol.get() } )
|
||||
{
|
||||
symbol->setWidth( width );
|
||||
symbol->setOutputUnit( QgsUnitTypes::RenderMillimeters );
|
||||
}
|
||||
}
|
||||
|
||||
QPen QgsScaleBarSettings::pen() const
|
||||
@ -163,13 +175,16 @@ QPen QgsScaleBarSettings::pen() const
|
||||
|
||||
void QgsScaleBarSettings::setPen( const QPen &pen )
|
||||
{
|
||||
mLineSymbol->setColor( pen.color() );
|
||||
mLineSymbol->setWidth( pen.widthF() );
|
||||
mLineSymbol->setOutputUnit( QgsUnitTypes::RenderMillimeters );
|
||||
if ( QgsSimpleLineSymbolLayer *line = dynamic_cast< QgsSimpleLineSymbolLayer * >( mLineSymbol->symbolLayer( 0 ) ) )
|
||||
for ( QgsLineSymbol *symbol : { mLineSymbol.get(), mDivisionLineSymbol.get(), mSubdivisionLineSymbol.get() } )
|
||||
{
|
||||
line->setPenJoinStyle( pen.joinStyle() );
|
||||
line->setPenCapStyle( pen.capStyle() );
|
||||
symbol->setColor( pen.color() );
|
||||
symbol->setWidth( pen.widthF() );
|
||||
symbol->setOutputUnit( QgsUnitTypes::RenderMillimeters );
|
||||
if ( QgsSimpleLineSymbolLayer *line = dynamic_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) ) )
|
||||
{
|
||||
line->setPenJoinStyle( pen.joinStyle() );
|
||||
line->setPenCapStyle( pen.capStyle() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,6 +198,26 @@ void QgsScaleBarSettings::setLineSymbol( QgsLineSymbol *symbol )
|
||||
mLineSymbol.reset( symbol );
|
||||
}
|
||||
|
||||
QgsLineSymbol *QgsScaleBarSettings::divisionLineSymbol() const
|
||||
{
|
||||
return mDivisionLineSymbol.get();
|
||||
}
|
||||
|
||||
void QgsScaleBarSettings::setDivisionLineSymbol( QgsLineSymbol *symbol )
|
||||
{
|
||||
mDivisionLineSymbol.reset( symbol );
|
||||
}
|
||||
|
||||
QgsLineSymbol *QgsScaleBarSettings::subdivisionLineSymbol() const
|
||||
{
|
||||
return mSubdivisionLineSymbol.get();
|
||||
}
|
||||
|
||||
void QgsScaleBarSettings::setSubdivisionLineSymbol( QgsLineSymbol *symbol )
|
||||
{
|
||||
mSubdivisionLineSymbol.reset( symbol );
|
||||
}
|
||||
|
||||
QgsFillSymbol *QgsScaleBarSettings::fillSymbol() const
|
||||
{
|
||||
return mFillSymbol.get();
|
||||
@ -256,9 +291,12 @@ Qt::PenJoinStyle QgsScaleBarSettings::lineJoinStyle() const
|
||||
|
||||
void QgsScaleBarSettings::setLineJoinStyle( Qt::PenJoinStyle style )
|
||||
{
|
||||
if ( QgsSimpleLineSymbolLayer *line = dynamic_cast< QgsSimpleLineSymbolLayer * >( mLineSymbol->symbolLayer( 0 ) ) )
|
||||
for ( QgsLineSymbol *symbol : { mLineSymbol.get(), mDivisionLineSymbol.get(), mSubdivisionLineSymbol.get() } )
|
||||
{
|
||||
line->setPenJoinStyle( style );
|
||||
if ( QgsSimpleLineSymbolLayer *line = dynamic_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) ) )
|
||||
{
|
||||
line->setPenJoinStyle( style );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,9 +311,12 @@ Qt::PenCapStyle QgsScaleBarSettings::lineCapStyle() const
|
||||
|
||||
void QgsScaleBarSettings::setLineCapStyle( Qt::PenCapStyle style )
|
||||
{
|
||||
if ( QgsSimpleLineSymbolLayer *line = dynamic_cast< QgsSimpleLineSymbolLayer * >( mLineSymbol->symbolLayer( 0 ) ) )
|
||||
for ( QgsLineSymbol *symbol : { mLineSymbol.get(), mDivisionLineSymbol.get(), mSubdivisionLineSymbol.get() } )
|
||||
{
|
||||
line->setPenCapStyle( style );
|
||||
if ( QgsSimpleLineSymbolLayer *line = dynamic_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) ) )
|
||||
{
|
||||
line->setPenCapStyle( style );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -394,7 +394,7 @@ class CORE_EXPORT QgsScaleBarSettings
|
||||
|
||||
/**
|
||||
* Sets the pen used for drawing outlines in the scalebar.
|
||||
* \see pen()
|
||||
* \see pen() mSubdivisionsHeightSpinBox->setMaximum( d );
|
||||
* \deprecated use setLineSymbol() instead.
|
||||
*/
|
||||
Q_DECL_DEPRECATED void setPen( const QPen &pen ) SIP_DEPRECATED;
|
||||
@ -405,6 +405,8 @@ class CORE_EXPORT QgsScaleBarSettings
|
||||
* Ownership is not transferred.
|
||||
*
|
||||
* \see setLineSymbol()
|
||||
* \see divisionLineSymbol()
|
||||
* \see subdivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
QgsLineSymbol *lineSymbol() const;
|
||||
@ -414,10 +416,58 @@ class CORE_EXPORT QgsScaleBarSettings
|
||||
* transferred to the scalebar.
|
||||
*
|
||||
* \see lineSymbol()
|
||||
* \see setDivisionLineSymbol()
|
||||
* \see setSubdivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Returns the line symbol used to render the scalebar divisions (only used for some scalebar types).
|
||||
*
|
||||
* Ownership is not transferred.
|
||||
*
|
||||
* \see setDivisionLineSymbol()
|
||||
* \see lineSymbol()
|
||||
* \see subdivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
QgsLineSymbol *divisionLineSymbol() const;
|
||||
|
||||
/**
|
||||
* Sets the line \a symbol used to render the scalebar divisions (only used for some scalebar types). Ownership of \a symbol is
|
||||
* transferred to the scalebar.
|
||||
*
|
||||
* \see divisionLineSymbol()
|
||||
* \see setLineSymbol()
|
||||
* \see setSubdivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setDivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Returns the line symbol used to render the scalebar subdivisions (only used for some scalebar types).
|
||||
*
|
||||
* Ownership is not transferred.
|
||||
*
|
||||
* \see setSubdivisionLineSymbol()
|
||||
* \see lineSymbol()
|
||||
* \see divisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
QgsLineSymbol *subdivisionLineSymbol() const;
|
||||
|
||||
/**
|
||||
* Sets the line \a symbol used to render the scalebar subdivisions (only used for some scalebar types). Ownership of \a symbol is
|
||||
* transferred to the scalebar.
|
||||
*
|
||||
* \see subdivisionLineSymbol()
|
||||
* \see setLineSymbol()
|
||||
* \see setDivisionLineSymbol()
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
void setSubdivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Returns the primary fill symbol used to render the scalebar (only used for some scalebar types).
|
||||
*
|
||||
@ -646,6 +696,8 @@ class CORE_EXPORT QgsScaleBarSettings
|
||||
double mHeight = 3.0;
|
||||
|
||||
std::unique_ptr< QgsLineSymbol > mLineSymbol;
|
||||
std::unique_ptr< QgsLineSymbol > mDivisionLineSymbol;
|
||||
std::unique_ptr< QgsLineSymbol > mSubdivisionLineSymbol;
|
||||
std::unique_ptr< QgsFillSymbol > mFillSymbol;
|
||||
std::unique_ptr< QgsFillSymbol > mAlternateFillSymbol;
|
||||
|
||||
|
||||
@ -72,6 +72,8 @@ int QgsTicksScaleBarRenderer::sortKey() const
|
||||
QgsScaleBarRenderer::Flags QgsTicksScaleBarRenderer::flags() const
|
||||
{
|
||||
return Flag::FlagUsesLineSymbol |
|
||||
Flag::FlagUsesDivisionSymbol |
|
||||
Flag::FlagUsesSubdivisionSymbol |
|
||||
Flag::FlagRespectsUnits |
|
||||
Flag::FlagRespectsMapUnitsPerScaleBarUnit |
|
||||
Flag::FlagUsesUnitLabel |
|
||||
@ -111,18 +113,36 @@ void QgsTicksScaleBarRenderer::draw( QgsRenderContext &context, const QgsScaleBa
|
||||
std::unique_ptr< QgsLineSymbol > symbol( settings.lineSymbol()->clone() );
|
||||
symbol->startRender( context );
|
||||
|
||||
std::unique_ptr< QgsLineSymbol > divisionSymbol( settings.divisionLineSymbol()->clone() );
|
||||
divisionSymbol->startRender( context );
|
||||
|
||||
std::unique_ptr< QgsLineSymbol > subdivisionSymbol( settings.subdivisionLineSymbol()->clone() );
|
||||
subdivisionSymbol->startRender( context );
|
||||
|
||||
const QList<double> positions = segmentPositions( context, scaleContext, settings );
|
||||
|
||||
int symbolLayerCount = symbol->symbolLayerCount();
|
||||
symbolLayerCount = std::max( symbolLayerCount, divisionSymbol->symbolLayerCount() );
|
||||
symbolLayerCount = std::max( symbolLayerCount, subdivisionSymbol->symbolLayerCount() );
|
||||
|
||||
// we render the bar symbol-layer-by-symbol-layer, to avoid ugliness where the lines overlap in multi-layer symbols
|
||||
for ( int layer = 0; layer < symbol->symbolLayerCount(); ++ layer )
|
||||
for ( int layer = 0; layer < symbolLayerCount; ++ layer )
|
||||
{
|
||||
// first draw the vertical lines for segments
|
||||
for ( int i = 0; i < positions.size(); ++i )
|
||||
const bool drawDivisionsForThisSymbolLayer = layer < divisionSymbol->symbolLayerCount();
|
||||
const bool drawSubdivisionsForThisSymbolLayer = layer < subdivisionSymbol->symbolLayerCount();
|
||||
const bool drawLineForThisSymbolLayer = layer < symbol->symbolLayerCount();
|
||||
|
||||
if ( drawDivisionsForThisSymbolLayer )
|
||||
{
|
||||
const double thisX = context.convertToPainterUnits( positions.at( i ), QgsUnitTypes::RenderMillimeters ) + xOffset;
|
||||
symbol->renderPolyline( QPolygonF() << QPointF( thisX, barTopPosition )
|
||||
<< QPointF( thisX, bottomPosition ), nullptr, context, layer );
|
||||
// first draw the vertical lines for segments
|
||||
for ( int i = 0; i < positions.size(); ++i )
|
||||
{
|
||||
const double thisX = context.convertToPainterUnits( positions.at( i ), QgsUnitTypes::RenderMillimeters ) + xOffset;
|
||||
divisionSymbol->renderPolyline( QPolygonF() << QPointF( thisX, barTopPosition )
|
||||
<< QPointF( thisX, bottomPosition ), nullptr, context, layer );
|
||||
}
|
||||
}
|
||||
|
||||
// vertical positions
|
||||
double verticalPos = 0.0;
|
||||
QList<double> subTickPositionsY;
|
||||
@ -145,13 +165,16 @@ void QgsTicksScaleBarRenderer::draw( QgsRenderContext &context, const QgsScaleBa
|
||||
break;
|
||||
}
|
||||
// draw the vertical lines for right subdivisions
|
||||
for ( int i = settings.numberOfSegmentsLeft(); i < positions.size(); ++i )
|
||||
if ( drawSubdivisionsForThisSymbolLayer )
|
||||
{
|
||||
for ( int j = 1; j < settings.numberOfSubdivisions(); ++j )
|
||||
for ( int i = settings.numberOfSegmentsLeft(); i < positions.size(); ++i )
|
||||
{
|
||||
const double thisSubX = context.convertToPainterUnits( positions.at( i ) + j * scaleContext.segmentWidth / settings.numberOfSubdivisions(), QgsUnitTypes::RenderMillimeters ) + xOffset;
|
||||
symbol->renderPolyline( QPolygonF() << QPointF( thisSubX, subTickPositionsY.at( 0 ) )
|
||||
<< QPointF( thisSubX, subTickPositionsY.at( 1 ) ), nullptr, context, layer );
|
||||
for ( int j = 1; j < settings.numberOfSubdivisions(); ++j )
|
||||
{
|
||||
const double thisSubX = context.convertToPainterUnits( positions.at( i ) + j * scaleContext.segmentWidth / settings.numberOfSubdivisions(), QgsUnitTypes::RenderMillimeters ) + xOffset;
|
||||
subdivisionSymbol->renderPolyline( QPolygonF() << QPointF( thisSubX, subTickPositionsY.at( 0 ) )
|
||||
<< QPointF( thisSubX, subTickPositionsY.at( 1 ) ), nullptr, context, layer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,17 +184,25 @@ void QgsTicksScaleBarRenderer::draw( QgsRenderContext &context, const QgsScaleBa
|
||||
double lastTickPositionX = context.convertToPainterUnits( positions.at( positions.size() - 1 ) + scaleContext.segmentWidth, QgsUnitTypes::RenderMillimeters ) + xOffset;
|
||||
|
||||
//last vertical line
|
||||
symbol->renderPolyline( QPolygonF() << QPointF( lastTickPositionX, barTopPosition )
|
||||
<< QPointF( lastTickPositionX, bottomPosition ),
|
||||
nullptr, context, layer );
|
||||
if ( drawDivisionsForThisSymbolLayer )
|
||||
{
|
||||
divisionSymbol->renderPolyline( QPolygonF() << QPointF( lastTickPositionX, barTopPosition )
|
||||
<< QPointF( lastTickPositionX, bottomPosition ),
|
||||
nullptr, context, layer );
|
||||
}
|
||||
|
||||
//horizontal line
|
||||
symbol->renderPolyline( QPolygonF() << QPointF( xOffset + context.convertToPainterUnits( positions.at( 0 ), QgsUnitTypes::RenderMillimeters ), verticalPos )
|
||||
<< QPointF( lastTickPositionX, verticalPos ), nullptr, context, layer );
|
||||
if ( drawLineForThisSymbolLayer )
|
||||
{
|
||||
symbol->renderPolyline( QPolygonF() << QPointF( xOffset + context.convertToPainterUnits( positions.at( 0 ), QgsUnitTypes::RenderMillimeters ), verticalPos )
|
||||
<< QPointF( lastTickPositionX, verticalPos ), nullptr, context, layer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
symbol->stopRender( context );
|
||||
divisionSymbol->stopRender( context );
|
||||
subdivisionSymbol->stopRender( context );
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
@ -100,6 +100,12 @@ QgsLayoutScaleBarWidget::QgsLayoutScaleBarWidget( QgsLayoutItemScaleBar *scaleBa
|
||||
mLineStyleButton->setSymbolType( QgsSymbol::Line );
|
||||
connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::lineSymbolChanged );
|
||||
|
||||
mDivisionStyleButton->setSymbolType( QgsSymbol::Line );
|
||||
connect( mDivisionStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::divisionSymbolChanged );
|
||||
|
||||
mSubdivisionStyleButton->setSymbolType( QgsSymbol::Line );
|
||||
connect( mSubdivisionStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::subdivisionSymbolChanged );
|
||||
|
||||
mFillSymbol1Button->setSymbolType( QgsSymbol::Fill );
|
||||
connect( mFillSymbol1Button, &QgsSymbolButton::changed, this, &QgsLayoutScaleBarWidget::fillSymbol1Changed );
|
||||
|
||||
@ -126,6 +132,10 @@ QgsLayoutScaleBarWidget::QgsLayoutScaleBarWidget( QgsLayoutItemScaleBar *scaleBa
|
||||
|
||||
mLineStyleButton->registerExpressionContextGenerator( mScalebar );
|
||||
mLineStyleButton->setLayer( coverageLayer() );
|
||||
mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
|
||||
mDivisionStyleButton->setLayer( coverageLayer() );
|
||||
mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
|
||||
mSubdivisionStyleButton->setLayer( coverageLayer() );
|
||||
mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
|
||||
mFillSymbol1Button->setLayer( coverageLayer() );
|
||||
mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
|
||||
@ -137,6 +147,8 @@ QgsLayoutScaleBarWidget::QgsLayoutScaleBarWidget( QgsLayoutItemScaleBar *scaleBa
|
||||
{
|
||||
connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFontButton, &QgsFontButton::setLayer );
|
||||
connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mLineStyleButton, &QgsSymbolButton::setLayer );
|
||||
connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mDivisionStyleButton, &QgsSymbolButton::setLayer );
|
||||
connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mSubdivisionStyleButton, &QgsSymbolButton::setLayer );
|
||||
connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFillSymbol1Button, &QgsSymbolButton::setLayer );
|
||||
connect( &mScalebar->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFillSymbol2Button, &QgsSymbolButton::setLayer );
|
||||
}
|
||||
@ -174,6 +186,8 @@ bool QgsLayoutScaleBarWidget::setNewItem( QgsLayoutItem *item )
|
||||
mFillSymbol1Button->registerExpressionContextGenerator( mScalebar );
|
||||
mFillSymbol2Button->registerExpressionContextGenerator( mScalebar );
|
||||
mLineStyleButton->registerExpressionContextGenerator( mScalebar );
|
||||
mDivisionStyleButton->registerExpressionContextGenerator( mScalebar );
|
||||
mSubdivisionStyleButton->registerExpressionContextGenerator( mScalebar );
|
||||
}
|
||||
|
||||
setGuiElements();
|
||||
@ -192,6 +206,28 @@ void QgsLayoutScaleBarWidget::lineSymbolChanged()
|
||||
mScalebar->layout()->undoStack()->endCommand();
|
||||
}
|
||||
|
||||
void QgsLayoutScaleBarWidget::divisionSymbolChanged()
|
||||
{
|
||||
if ( !mScalebar )
|
||||
return;
|
||||
|
||||
mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Division Style" ), QgsLayoutItem::UndoShapeStyle );
|
||||
mScalebar->setDivisionLineSymbol( mDivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
|
||||
mScalebar->update();
|
||||
mScalebar->layout()->undoStack()->endCommand();
|
||||
}
|
||||
|
||||
void QgsLayoutScaleBarWidget::subdivisionSymbolChanged()
|
||||
{
|
||||
if ( !mScalebar )
|
||||
return;
|
||||
|
||||
mScalebar->layout()->undoStack()->beginCommand( mScalebar, tr( "Change Scalebar Subdivision Style" ), QgsLayoutItem::UndoShapeStyle );
|
||||
mScalebar->setSubdivisionLineSymbol( mSubdivisionStyleButton->clonedSymbol<QgsLineSymbol>() );
|
||||
mScalebar->update();
|
||||
mScalebar->layout()->undoStack()->endCommand();
|
||||
}
|
||||
|
||||
void QgsLayoutScaleBarWidget::fillSymbol1Changed()
|
||||
{
|
||||
if ( !mScalebar )
|
||||
@ -235,6 +271,8 @@ void QgsLayoutScaleBarWidget::setGuiElements()
|
||||
mFontButton->setTextFormat( mScalebar->textFormat() );
|
||||
|
||||
whileBlocking( mLineStyleButton )->setSymbol( mScalebar->lineSymbol()->clone() );
|
||||
whileBlocking( mDivisionStyleButton )->setSymbol( mScalebar->divisionLineSymbol()->clone() );
|
||||
whileBlocking( mSubdivisionStyleButton )->setSymbol( mScalebar->subdivisionLineSymbol()->clone() );
|
||||
whileBlocking( mFillSymbol1Button )->setSymbol( mScalebar->fillSymbol()->clone() );
|
||||
whileBlocking( mFillSymbol2Button )->setSymbol( mScalebar->alternateFillSymbol()->clone() );
|
||||
|
||||
@ -503,6 +541,8 @@ void QgsLayoutScaleBarWidget::toggleStyleSpecificControls( const QString &style
|
||||
mFillSymbol1Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesFillSymbol : true );
|
||||
mFillSymbol2Button->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesAlternateFillSymbol : true );
|
||||
mLineStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesLineSymbol : true );
|
||||
mDivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesDivisionSymbol : true );
|
||||
mSubdivisionStyleButton->setEnabled( renderer ? renderer->flags() & QgsScaleBarRenderer::Flag::FlagUsesSubdivisionSymbol : true );
|
||||
}
|
||||
|
||||
void QgsLayoutScaleBarWidget::mLabelBarSpaceSpinBox_valueChanged( double d )
|
||||
@ -621,6 +661,8 @@ void QgsLayoutScaleBarWidget::blockMemberSignals( bool block )
|
||||
mMapUnitsPerBarUnitSpinBox->blockSignals( block );
|
||||
mHeightSpinBox->blockSignals( block );
|
||||
mLineStyleButton->blockSignals( block );
|
||||
mDivisionStyleButton->blockSignals( block );
|
||||
mSubdivisionStyleButton->blockSignals( block );
|
||||
mLabelBarSpaceSpinBox->blockSignals( block );
|
||||
mBoxSizeSpinBox->blockSignals( block );
|
||||
mLabelVerticalPlacementComboBox->blockSignals( block );
|
||||
|
||||
@ -51,6 +51,8 @@ class GUI_EXPORT QgsLayoutScaleBarWidget: public QgsLayoutItemBaseWidget, public
|
||||
|
||||
private slots:
|
||||
void lineSymbolChanged();
|
||||
void divisionSymbolChanged();
|
||||
void subdivisionSymbolChanged();
|
||||
void fillSymbol1Changed();
|
||||
void fillSymbol2Changed();
|
||||
void mHeightSpinBox_valueChanged( double d );
|
||||
|
||||
@ -60,9 +60,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<y>-453</y>
|
||||
<width>451</width>
|
||||
<height>1012</height>
|
||||
<height>1076</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="mainLayout">
|
||||
@ -399,12 +399,6 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0">
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QComboBox" name="mLabelVerticalPlacementComboBox"/>
|
||||
</item>
|
||||
<item row="11" column="1" colspan="2">
|
||||
<widget class="QgsAlignmentComboBox" name="mAlignmentComboBox"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
@ -412,8 +406,11 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="2">
|
||||
<widget class="QgsSymbolButton" name="mLineStyleButton">
|
||||
<item row="13" column="1" colspan="2">
|
||||
<widget class="QgsAlignmentComboBox" name="mAlignmentComboBox"/>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="2">
|
||||
<widget class="QgsSymbolButton" name="mFillSymbol2Button">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -421,20 +418,37 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Line Style…</string>
|
||||
<string>Fill Style…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3">
|
||||
<widget class="QComboBox" name="mLabelHorizontalPlacementComboBox"/>
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="mAlignmentLabel_2">
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="mAlignmentLabel">
|
||||
<property name="text">
|
||||
<string>Alignment</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1" colspan="2">
|
||||
<widget class="QgsFontButton" name="mFontButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QgsDoubleSpinBox" name="mLabelBarSpaceSpinBox">
|
||||
<property name="prefix">
|
||||
@ -452,6 +466,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="2">
|
||||
<widget class="QgsSymbolButton" name="mFillSymbol1Button">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fill Style…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
@ -459,6 +486,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Division style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Line style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="text">
|
||||
<string>Vertical label placement</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
@ -466,13 +514,25 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_22">
|
||||
<item row="9" column="1" colspan="2">
|
||||
<widget class="QgsSymbolButton" name="mLineStyleButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Vertical label placement</string>
|
||||
<string>Line Style…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QComboBox" name="mLabelVerticalPlacementComboBox"/>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3">
|
||||
<widget class="QComboBox" name="mLabelHorizontalPlacementComboBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
@ -490,56 +550,36 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Line style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="mAlignmentLabel_2">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="2">
|
||||
<widget class="QgsSymbolButton" name="mFillSymbol1Button">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fill Style…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="2">
|
||||
<widget class="QgsSymbolButton" name="mFillSymbol2Button">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fill Style…</string>
|
||||
<string>Subdivision style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1" colspan="2">
|
||||
<widget class="QgsFontButton" name="mFontButton">
|
||||
<widget class="QgsSymbolButton" name="mSubdivisionStyleButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
<string>Subdivision Style…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1" colspan="2">
|
||||
<widget class="QgsSymbolButton" name="mDivisionStyleButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Division Style…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -560,10 +600,15 @@
|
||||
<header>qgsscrollarea.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>qgsspinbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsCollapsibleGroupBoxBasic</class>
|
||||
<extends>QGroupBox</extends>
|
||||
<header>qgscollapsiblegroupbox.h</header>
|
||||
<header location="global">qgscollapsiblegroupbox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
@ -581,11 +626,6 @@
|
||||
<extends>QToolButton</extends>
|
||||
<header>qgsfontbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>qgsspinbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsAlignmentComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
@ -626,6 +666,8 @@
|
||||
<tabstop>mFillSymbol1Button</tabstop>
|
||||
<tabstop>mFillSymbol2Button</tabstop>
|
||||
<tabstop>mLineStyleButton</tabstop>
|
||||
<tabstop>mDivisionStyleButton</tabstop>
|
||||
<tabstop>mSubdivisionStyleButton</tabstop>
|
||||
<tabstop>mAlignmentComboBox</tabstop>
|
||||
<tabstop>mFontButton</tabstop>
|
||||
</tabstops>
|
||||
|
||||
@ -580,7 +580,11 @@ void TestQgsLayoutScaleBar::tickLineSymbol()
|
||||
lineSymbolLayer->setColor( QColor( 255, 255, 0 ) );
|
||||
lineSymbol->appendSymbolLayer( lineSymbolLayer.release() );
|
||||
|
||||
scalebar->setLineSymbol( lineSymbol.release() );
|
||||
scalebar->setLineSymbol( lineSymbol->clone() );
|
||||
|
||||
dynamic_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setWidth( 5 );
|
||||
dynamic_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 255, 0 ) );
|
||||
scalebar->setDivisionLineSymbol( lineSymbol->clone() );
|
||||
|
||||
dynamic_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false );
|
||||
|
||||
@ -922,7 +926,15 @@ void TestQgsLayoutScaleBar::tickSubdivisions()
|
||||
lineSymbolLayer->setColor( QColor( 255, 255, 0 ) );
|
||||
lineSymbol->appendSymbolLayer( lineSymbolLayer.release() );
|
||||
|
||||
scalebar->setLineSymbol( lineSymbol.release() );
|
||||
scalebar->setLineSymbol( lineSymbol->clone() );
|
||||
|
||||
dynamic_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setWidth( 5 );
|
||||
dynamic_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 255, 0 ) );
|
||||
scalebar->setDivisionLineSymbol( lineSymbol->clone() );
|
||||
|
||||
dynamic_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setWidth( 6 );
|
||||
dynamic_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 0, 255 ) );
|
||||
scalebar->setSubdivisionLineSymbol( lineSymbol->clone() );
|
||||
|
||||
dynamic_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false );
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.4 KiB |
Loading…
x
Reference in New Issue
Block a user