mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Move some more line label related settings to QgsLabelLineSettings
This commit is contained in:
parent
d93d881192
commit
5dfbfaa89e
@ -61,6 +61,98 @@ prior to generating label positions.
|
||||
%Docstring
|
||||
Updates the thinning settings to respect any data defined properties
|
||||
set within the specified ``properties`` collection.
|
||||
%End
|
||||
|
||||
bool addDirectionSymbol() const;
|
||||
%Docstring
|
||||
Returns ``True`` if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol)
|
||||
will be automatically added to the label text, pointing in the
|
||||
direction of the line or polygon ring.
|
||||
|
||||
.. seealso:: :py:func:`setAddDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`leftDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`rightDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`placeDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`reverseDirectionSymbol`
|
||||
%End
|
||||
|
||||
void setAddDirectionSymbol( bool enabled );
|
||||
%Docstring
|
||||
Sets whether '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol)
|
||||
will be automatically added to the label text, pointing in the
|
||||
direction of the line or polygon ring.
|
||||
|
||||
.. seealso:: :py:func:`addDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setLeftDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setRightDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setPlaceDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`setReverseDirectionSymbol`
|
||||
%End
|
||||
|
||||
QString leftDirectionSymbol() const;
|
||||
%Docstring
|
||||
Returns the string to use for left direction arrows.
|
||||
|
||||
.. seealso:: :py:func:`setLeftDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`addDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`rightDirectionSymbol`
|
||||
%End
|
||||
|
||||
void setLeftDirectionSymbol( const QString &symbol );
|
||||
%Docstring
|
||||
Sets the string to use for left direction arrows.
|
||||
|
||||
.. seealso:: :py:func:`leftDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`addDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`rightDirectionSymbol`
|
||||
%End
|
||||
|
||||
QString rightDirectionSymbol() const;
|
||||
%Docstring
|
||||
Returns the string to use for right direction arrows.
|
||||
|
||||
.. seealso:: :py:func:`setRightDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`addDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`leftDirectionSymbol`
|
||||
%End
|
||||
|
||||
void setRightDirectionSymbol( const QString &symbol );
|
||||
%Docstring
|
||||
Sets the string to use for right direction arrows.
|
||||
|
||||
.. seealso:: :py:func:`setLeftDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`addDirectionSymbol`
|
||||
|
||||
.. seealso:: :py:func:`rightDirectionSymbol`
|
||||
%End
|
||||
|
||||
bool reverseDirectionSymbol() const;
|
||||
%Docstring
|
||||
Returns ``True`` if direction symbols should be reversed.
|
||||
|
||||
.. seealso:: :py:func:`setReverseDirectionSymbol`
|
||||
%End
|
||||
|
||||
void setReverseDirectionSymbol( bool reversed );
|
||||
%Docstring
|
||||
Sets whether the direction symbols should be ``reversed``.
|
||||
|
||||
.. seealso:: :py:func:`reverseDirectionSymbol`
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
@ -384,16 +384,8 @@ Returns the QgsExpression for this label settings. May be ``None`` if isExpressi
|
||||
|
||||
MultiLineAlign multilineAlign;
|
||||
|
||||
bool addDirectionSymbol;
|
||||
|
||||
QString leftDirectionSymbol;
|
||||
|
||||
QString rightDirectionSymbol;
|
||||
|
||||
DirectionSymbols placeDirectionSymbol;
|
||||
|
||||
bool reverseDirectionSymbol;
|
||||
|
||||
bool formatNumbers;
|
||||
|
||||
int decimals;
|
||||
@ -497,6 +489,11 @@ Sets the polygon placement ``flags``, which dictate how polygon labels can be pl
|
||||
%Property( name = placementFlags, get = _getLinePlacementFlags, set = _setLinePlacementFlags )
|
||||
%Property( name = mergeLines, get = _getMergeLines, set = _setMergeLines )
|
||||
|
||||
%Property( name = addDirectionSymbol, get = _getAddDirectionSymbol, set = _setAddDirectionSymbol )
|
||||
%Property( name = leftDirectionSymbol, get = _getLeftDirectionSymbol, set = _setLeftDirectionSymbol )
|
||||
%Property( name = rightDirectionSymbol, get = _getRightDirectionSymbol, set = _setRightDirectionSymbol )
|
||||
%Property( name = reverseDirectionSymbol, get = _getReverseDirectionSymbol, set = _setReverseDirectionSymbol )
|
||||
|
||||
bool _limitNumLabels() const;
|
||||
void _setLimitNumLabels( bool limit );
|
||||
int _maxNumLabels() const;
|
||||
@ -513,6 +510,14 @@ Sets the polygon placement ``flags``, which dictate how polygon labels can be pl
|
||||
void _setLinePlacementFlags( unsigned int flags );
|
||||
bool _getMergeLines() const;
|
||||
void _setMergeLines( bool merge );
|
||||
bool _getAddDirectionSymbol() const;
|
||||
void _setAddDirectionSymbol( bool add );
|
||||
QString _getLeftDirectionSymbol() const;
|
||||
void _setLeftDirectionSymbol( const QString &symbol );
|
||||
QString _getRightDirectionSymbol() const;
|
||||
void _setRightDirectionSymbol( const QString &symbol );
|
||||
bool _getReverseDirectionSymbol() const;
|
||||
void _setReverseDirectionSymbol( bool reverse );
|
||||
|
||||
double zIndex;
|
||||
|
||||
|
||||
@ -2271,28 +2271,28 @@ void QgsDxfExport::drawLabel( const QString &layerId, QgsRenderContext &context,
|
||||
QString wrapchr = tmpLyr.wrapChar.isEmpty() ? QStringLiteral( "\n" ) : tmpLyr.wrapChar;
|
||||
|
||||
//add the direction symbol if needed
|
||||
if ( !txt.isEmpty() && tmpLyr.placement == QgsPalLayerSettings::Line && tmpLyr.addDirectionSymbol )
|
||||
if ( !txt.isEmpty() && tmpLyr.placement == QgsPalLayerSettings::Line && tmpLyr.lineSettings().addDirectionSymbol() )
|
||||
{
|
||||
bool prependSymb = false;
|
||||
QString symb = tmpLyr.rightDirectionSymbol;
|
||||
QString symb = tmpLyr.lineSettings().rightDirectionSymbol();
|
||||
|
||||
if ( label->getReversed() )
|
||||
{
|
||||
prependSymb = true;
|
||||
symb = tmpLyr.leftDirectionSymbol;
|
||||
symb = tmpLyr.lineSettings().leftDirectionSymbol();
|
||||
}
|
||||
|
||||
if ( tmpLyr.reverseDirectionSymbol )
|
||||
if ( tmpLyr.lineSettings().reverseDirectionSymbol() )
|
||||
{
|
||||
if ( symb == tmpLyr.rightDirectionSymbol )
|
||||
if ( symb == tmpLyr.lineSettings().rightDirectionSymbol() )
|
||||
{
|
||||
prependSymb = true;
|
||||
symb = tmpLyr.leftDirectionSymbol;
|
||||
symb = tmpLyr.lineSettings().leftDirectionSymbol();
|
||||
}
|
||||
else
|
||||
{
|
||||
prependSymb = false;
|
||||
symb = tmpLyr.rightDirectionSymbol;
|
||||
symb = tmpLyr.lineSettings().rightDirectionSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -32,4 +32,3 @@ void QgsLabelLineSettings::updateDataDefinedProperties( const QgsPropertyCollect
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "qgis_core.h"
|
||||
#include "qgis_sip.h"
|
||||
#include "qgslabeling.h"
|
||||
#include <QString>
|
||||
|
||||
class QgsPropertyCollection;
|
||||
class QgsExpressionContext;
|
||||
@ -75,9 +76,89 @@ class CORE_EXPORT QgsLabelLineSettings
|
||||
*/
|
||||
void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context );
|
||||
|
||||
/**
|
||||
* Returns TRUE if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol)
|
||||
* will be automatically added to the label text, pointing in the
|
||||
* direction of the line or polygon ring.
|
||||
*
|
||||
* \see setAddDirectionSymbol()
|
||||
* \see leftDirectionSymbol()
|
||||
* \see rightDirectionSymbol()
|
||||
* \see placeDirectionSymbol()
|
||||
* \see reverseDirectionSymbol()
|
||||
*/
|
||||
bool addDirectionSymbol() const { return mAddDirectionSymbol; }
|
||||
|
||||
/**
|
||||
* Sets whether '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol)
|
||||
* will be automatically added to the label text, pointing in the
|
||||
* direction of the line or polygon ring.
|
||||
*
|
||||
* \see addDirectionSymbol()
|
||||
* \see setLeftDirectionSymbol()
|
||||
* \see setRightDirectionSymbol()
|
||||
* \see setPlaceDirectionSymbol()
|
||||
* \see setReverseDirectionSymbol()
|
||||
*/
|
||||
void setAddDirectionSymbol( bool enabled ) { mAddDirectionSymbol = enabled; }
|
||||
|
||||
/**
|
||||
* Returns the string to use for left direction arrows.
|
||||
*
|
||||
* \see setLeftDirectionSymbol()
|
||||
* \see addDirectionSymbol()
|
||||
* \see rightDirectionSymbol()
|
||||
*/
|
||||
QString leftDirectionSymbol() const { return mLeftDirectionSymbol; }
|
||||
|
||||
/**
|
||||
* Sets the string to use for left direction arrows.
|
||||
*
|
||||
* \see leftDirectionSymbol()
|
||||
* \see addDirectionSymbol()
|
||||
* \see rightDirectionSymbol()
|
||||
*/
|
||||
void setLeftDirectionSymbol( const QString &symbol ) { mLeftDirectionSymbol = symbol; }
|
||||
|
||||
/**
|
||||
* Returns the string to use for right direction arrows.
|
||||
*
|
||||
* \see setRightDirectionSymbol()
|
||||
* \see addDirectionSymbol()
|
||||
* \see leftDirectionSymbol()
|
||||
*/
|
||||
QString rightDirectionSymbol() const { return mRightDirectionSymbol; }
|
||||
|
||||
/**
|
||||
* Sets the string to use for right direction arrows.
|
||||
*
|
||||
* \see setLeftDirectionSymbol()
|
||||
* \see addDirectionSymbol()
|
||||
* \see rightDirectionSymbol()
|
||||
*/
|
||||
void setRightDirectionSymbol( const QString &symbol ) { mRightDirectionSymbol = symbol; }
|
||||
|
||||
/**
|
||||
* Returns TRUE if direction symbols should be reversed.
|
||||
*
|
||||
* \see setReverseDirectionSymbol()
|
||||
*/
|
||||
bool reverseDirectionSymbol() const { return mReverseDirectionSymbol; }
|
||||
|
||||
/**
|
||||
* Sets whether the direction symbols should be \a reversed.
|
||||
*
|
||||
* \see reverseDirectionSymbol()
|
||||
*/
|
||||
void setReverseDirectionSymbol( bool reversed ) { mReverseDirectionSymbol = reversed; }
|
||||
|
||||
private:
|
||||
QgsLabeling::LinePlacementFlags mPlacementFlags = QgsLabeling::LinePlacementFlag::AboveLine | QgsLabeling::LinePlacementFlag::MapOrientation;
|
||||
bool mMergeLines = false;
|
||||
bool mAddDirectionSymbol = false;
|
||||
QString mLeftDirectionSymbol = QString( '<' );
|
||||
QString mRightDirectionSymbol = QString( '>' );
|
||||
bool mReverseDirectionSymbol = false;
|
||||
};
|
||||
|
||||
#endif // QGSLABELLINESETTINGS_H
|
||||
|
||||
@ -298,10 +298,6 @@ QgsPalLayerSettings &QgsPalLayerSettings::operator=( const QgsPalLayerSettings &
|
||||
autoWrapLength = s.autoWrapLength;
|
||||
useMaxLineLengthForAutoWrap = s.useMaxLineLengthForAutoWrap;
|
||||
multilineAlign = s.multilineAlign;
|
||||
addDirectionSymbol = s.addDirectionSymbol;
|
||||
leftDirectionSymbol = s.leftDirectionSymbol;
|
||||
rightDirectionSymbol = s.rightDirectionSymbol;
|
||||
reverseDirectionSymbol = s.reverseDirectionSymbol;
|
||||
placeDirectionSymbol = s.placeDirectionSymbol;
|
||||
formatNumbers = s.formatNumbers;
|
||||
decimals = s.decimals;
|
||||
@ -715,10 +711,10 @@ void QgsPalLayerSettings::readFromLayerCustomProperties( QgsVectorLayer *layer )
|
||||
useMaxLineLengthForAutoWrap = layer->customProperty( QStringLiteral( "labeling/useMaxLineLengthForAutoWrap" ), QStringLiteral( "1" ) ).toBool();
|
||||
|
||||
multilineAlign = static_cast< MultiLineAlign >( layer->customProperty( QStringLiteral( "labeling/multilineAlign" ), QVariant( MultiFollowPlacement ) ).toUInt() );
|
||||
addDirectionSymbol = layer->customProperty( QStringLiteral( "labeling/addDirectionSymbol" ) ).toBool();
|
||||
leftDirectionSymbol = layer->customProperty( QStringLiteral( "labeling/leftDirectionSymbol" ), QVariant( "<" ) ).toString();
|
||||
rightDirectionSymbol = layer->customProperty( QStringLiteral( "labeling/rightDirectionSymbol" ), QVariant( ">" ) ).toString();
|
||||
reverseDirectionSymbol = layer->customProperty( QStringLiteral( "labeling/reverseDirectionSymbol" ) ).toBool();
|
||||
mLineSettings.setAddDirectionSymbol( layer->customProperty( QStringLiteral( "labeling/addDirectionSymbol" ) ).toBool() );
|
||||
mLineSettings.setLeftDirectionSymbol( layer->customProperty( QStringLiteral( "labeling/leftDirectionSymbol" ), QVariant( "<" ) ).toString() );
|
||||
mLineSettings.setRightDirectionSymbol( layer->customProperty( QStringLiteral( "labeling/rightDirectionSymbol" ), QVariant( ">" ) ).toString() );
|
||||
mLineSettings.setReverseDirectionSymbol( layer->customProperty( QStringLiteral( "labeling/reverseDirectionSymbol" ) ).toBool() );
|
||||
placeDirectionSymbol = static_cast< DirectionSymbols >( layer->customProperty( QStringLiteral( "labeling/placeDirectionSymbol" ), QVariant( SymbolLeftRight ) ).toUInt() );
|
||||
formatNumbers = layer->customProperty( QStringLiteral( "labeling/formatNumbers" ) ).toBool();
|
||||
decimals = layer->customProperty( QStringLiteral( "labeling/decimals" ) ).toInt();
|
||||
@ -926,10 +922,10 @@ void QgsPalLayerSettings::readXml( const QDomElement &elem, const QgsReadWriteCo
|
||||
autoWrapLength = textFormatElem.attribute( QStringLiteral( "autoWrapLength" ), QStringLiteral( "0" ) ).toInt();
|
||||
useMaxLineLengthForAutoWrap = textFormatElem.attribute( QStringLiteral( "useMaxLineLengthForAutoWrap" ), QStringLiteral( "1" ) ).toInt();
|
||||
multilineAlign = static_cast< MultiLineAlign >( textFormatElem.attribute( QStringLiteral( "multilineAlign" ), QString::number( MultiFollowPlacement ) ).toUInt() );
|
||||
addDirectionSymbol = textFormatElem.attribute( QStringLiteral( "addDirectionSymbol" ) ).toInt();
|
||||
leftDirectionSymbol = textFormatElem.attribute( QStringLiteral( "leftDirectionSymbol" ), QStringLiteral( "<" ) );
|
||||
rightDirectionSymbol = textFormatElem.attribute( QStringLiteral( "rightDirectionSymbol" ), QStringLiteral( ">" ) );
|
||||
reverseDirectionSymbol = textFormatElem.attribute( QStringLiteral( "reverseDirectionSymbol" ) ).toInt();
|
||||
mLineSettings.setAddDirectionSymbol( textFormatElem.attribute( QStringLiteral( "addDirectionSymbol" ) ).toInt() );
|
||||
mLineSettings.setLeftDirectionSymbol( textFormatElem.attribute( QStringLiteral( "leftDirectionSymbol" ), QStringLiteral( "<" ) ) );
|
||||
mLineSettings.setRightDirectionSymbol( textFormatElem.attribute( QStringLiteral( "rightDirectionSymbol" ), QStringLiteral( ">" ) ) );
|
||||
mLineSettings.setReverseDirectionSymbol( textFormatElem.attribute( QStringLiteral( "reverseDirectionSymbol" ) ).toInt() );
|
||||
placeDirectionSymbol = static_cast< DirectionSymbols >( textFormatElem.attribute( QStringLiteral( "placeDirectionSymbol" ), QString::number( SymbolLeftRight ) ).toUInt() );
|
||||
formatNumbers = textFormatElem.attribute( QStringLiteral( "formatNumbers" ) ).toInt();
|
||||
decimals = textFormatElem.attribute( QStringLiteral( "decimals" ) ).toInt();
|
||||
@ -1162,10 +1158,10 @@ QDomElement QgsPalLayerSettings::writeXml( QDomDocument &doc, const QgsReadWrite
|
||||
textFormatElem.setAttribute( QStringLiteral( "autoWrapLength" ), autoWrapLength );
|
||||
textFormatElem.setAttribute( QStringLiteral( "useMaxLineLengthForAutoWrap" ), useMaxLineLengthForAutoWrap );
|
||||
textFormatElem.setAttribute( QStringLiteral( "multilineAlign" ), static_cast< unsigned int >( multilineAlign ) );
|
||||
textFormatElem.setAttribute( QStringLiteral( "addDirectionSymbol" ), addDirectionSymbol );
|
||||
textFormatElem.setAttribute( QStringLiteral( "leftDirectionSymbol" ), leftDirectionSymbol );
|
||||
textFormatElem.setAttribute( QStringLiteral( "rightDirectionSymbol" ), rightDirectionSymbol );
|
||||
textFormatElem.setAttribute( QStringLiteral( "reverseDirectionSymbol" ), reverseDirectionSymbol );
|
||||
textFormatElem.setAttribute( QStringLiteral( "addDirectionSymbol" ), mLineSettings.addDirectionSymbol() );
|
||||
textFormatElem.setAttribute( QStringLiteral( "leftDirectionSymbol" ), mLineSettings.leftDirectionSymbol() );
|
||||
textFormatElem.setAttribute( QStringLiteral( "rightDirectionSymbol" ), mLineSettings.rightDirectionSymbol() );
|
||||
textFormatElem.setAttribute( QStringLiteral( "reverseDirectionSymbol" ), mLineSettings.reverseDirectionSymbol() );
|
||||
textFormatElem.setAttribute( QStringLiteral( "placeDirectionSymbol" ), static_cast< unsigned int >( placeDirectionSymbol ) );
|
||||
textFormatElem.setAttribute( QStringLiteral( "formatNumbers" ), formatNumbers );
|
||||
textFormatElem.setAttribute( QStringLiteral( "decimals" ), decimals );
|
||||
@ -1403,9 +1399,9 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, const QSt
|
||||
double multilineH = mFormat.lineHeight();
|
||||
QgsTextFormat::TextOrientation orientation = mFormat.orientation();
|
||||
|
||||
bool addDirSymb = addDirectionSymbol;
|
||||
QString leftDirSymb = leftDirectionSymbol;
|
||||
QString rightDirSymb = rightDirectionSymbol;
|
||||
bool addDirSymb = mLineSettings.addDirectionSymbol();
|
||||
QString leftDirSymb = mLineSettings.leftDirectionSymbol();
|
||||
QString rightDirSymb = mLineSettings.rightDirectionSymbol();
|
||||
QgsPalLayerSettings::DirectionSymbols placeDirSymb = placeDirectionSymbol;
|
||||
|
||||
if ( f == mCurFeat ) // called internally, use any stored data defined values
|
||||
@ -3205,8 +3201,8 @@ void QgsPalLayerSettings::parseTextFormatting( QgsRenderContext &context )
|
||||
}
|
||||
|
||||
// data defined direction symbol?
|
||||
bool drawDirSymb = addDirectionSymbol;
|
||||
if ( dataDefinedValEval( DDBool, QgsPalLayerSettings::DirSymbDraw, exprVal, context.expressionContext(), addDirectionSymbol ) )
|
||||
bool drawDirSymb = mLineSettings.addDirectionSymbol();
|
||||
if ( dataDefinedValEval( DDBool, QgsPalLayerSettings::DirSymbDraw, exprVal, context.expressionContext(), drawDirSymb ) )
|
||||
{
|
||||
drawDirSymb = exprVal.toBool();
|
||||
}
|
||||
@ -3214,10 +3210,10 @@ void QgsPalLayerSettings::parseTextFormatting( QgsRenderContext &context )
|
||||
if ( drawDirSymb )
|
||||
{
|
||||
// data defined direction left symbol?
|
||||
dataDefinedValEval( DDString, QgsPalLayerSettings::DirSymbLeft, exprVal, context.expressionContext(), leftDirectionSymbol );
|
||||
dataDefinedValEval( DDString, QgsPalLayerSettings::DirSymbLeft, exprVal, context.expressionContext(), mLineSettings.leftDirectionSymbol() );
|
||||
|
||||
// data defined direction right symbol?
|
||||
dataDefinedValEval( DDString, QgsPalLayerSettings::DirSymbRight, exprVal, context.expressionContext(), rightDirectionSymbol );
|
||||
dataDefinedValEval( DDString, QgsPalLayerSettings::DirSymbRight, exprVal, context.expressionContext(), mLineSettings.rightDirectionSymbol() );
|
||||
|
||||
// data defined direction symbol placement?
|
||||
exprVal = mDataDefinedProperties.value( QgsPalLayerSettings::DirSymbPlacement, context.expressionContext() );
|
||||
@ -3244,7 +3240,7 @@ void QgsPalLayerSettings::parseTextFormatting( QgsRenderContext &context )
|
||||
}
|
||||
|
||||
// data defined direction symbol reversed?
|
||||
dataDefinedValEval( DDBool, QgsPalLayerSettings::DirSymbReverse, exprVal, context.expressionContext(), reverseDirectionSymbol );
|
||||
dataDefinedValEval( DDBool, QgsPalLayerSettings::DirSymbReverse, exprVal, context.expressionContext(), mLineSettings.reverseDirectionSymbol() );
|
||||
}
|
||||
|
||||
// formatting for numbers is inline with generation of base label text and not passed to label painting
|
||||
@ -3824,19 +3820,19 @@ void QgsPalLabeling::dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
|
||||
|
||||
if ( ddValues.contains( QgsPalLayerSettings::DirSymbDraw ) )
|
||||
{
|
||||
tmpLyr.addDirectionSymbol = ddValues.value( QgsPalLayerSettings::DirSymbDraw ).toBool();
|
||||
tmpLyr.lineSettings().setAddDirectionSymbol( ddValues.value( QgsPalLayerSettings::DirSymbDraw ).toBool() );
|
||||
}
|
||||
|
||||
if ( tmpLyr.addDirectionSymbol )
|
||||
if ( tmpLyr.lineSettings().addDirectionSymbol() )
|
||||
{
|
||||
|
||||
if ( ddValues.contains( QgsPalLayerSettings::DirSymbLeft ) )
|
||||
{
|
||||
tmpLyr.leftDirectionSymbol = ddValues.value( QgsPalLayerSettings::DirSymbLeft ).toString();
|
||||
tmpLyr.lineSettings().setLeftDirectionSymbol( ddValues.value( QgsPalLayerSettings::DirSymbLeft ).toString() );
|
||||
}
|
||||
if ( ddValues.contains( QgsPalLayerSettings::DirSymbRight ) )
|
||||
{
|
||||
tmpLyr.rightDirectionSymbol = ddValues.value( QgsPalLayerSettings::DirSymbRight ).toString();
|
||||
tmpLyr.lineSettings().setRightDirectionSymbol( ddValues.value( QgsPalLayerSettings::DirSymbRight ).toString() );
|
||||
}
|
||||
|
||||
if ( ddValues.contains( QgsPalLayerSettings::DirSymbPlacement ) )
|
||||
@ -3846,7 +3842,7 @@ void QgsPalLabeling::dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
|
||||
|
||||
if ( ddValues.contains( QgsPalLayerSettings::DirSymbReverse ) )
|
||||
{
|
||||
tmpLyr.reverseDirectionSymbol = ddValues.value( QgsPalLayerSettings::DirSymbReverse ).toBool();
|
||||
tmpLyr.lineSettings().setReverseDirectionSymbol( ddValues.value( QgsPalLayerSettings::DirSymbReverse ).toBool() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -587,41 +587,12 @@ class CORE_EXPORT QgsPalLayerSettings
|
||||
//! Horizontal alignment of multi-line labels.
|
||||
MultiLineAlign multilineAlign = MultiFollowPlacement;
|
||||
|
||||
/**
|
||||
* If TRUE, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol)
|
||||
* will be automatically added to the label text, pointing in the
|
||||
* direction of the line or polygon ring.
|
||||
* This setting only affects line or perimeter based labels.
|
||||
* \see leftDirectionSymbol
|
||||
* \see rightDirectionSymbol
|
||||
* \see placeDirectionSymbol
|
||||
* \see reverseDirectionSymbol
|
||||
*/
|
||||
bool addDirectionSymbol = false;
|
||||
|
||||
/**
|
||||
* String to use for left direction arrows.
|
||||
* \see addDirectionSymbol
|
||||
* \see rightDirectionSymbol
|
||||
*/
|
||||
QString leftDirectionSymbol = QString( '<' );
|
||||
|
||||
/**
|
||||
* String to use for right direction arrows.
|
||||
* \see addDirectionSymbol
|
||||
* \see leftDirectionSymbol
|
||||
*/
|
||||
QString rightDirectionSymbol = QString( '>' );
|
||||
|
||||
/**
|
||||
* Placement option for direction symbols. Controls whether to place symbols to the left/right, above or below label.
|
||||
* \see addDirectionSymbol
|
||||
*/
|
||||
DirectionSymbols placeDirectionSymbol = SymbolLeftRight;
|
||||
|
||||
//! True if direction symbols should be reversed
|
||||
bool reverseDirectionSymbol = false;
|
||||
|
||||
/**
|
||||
* Set to TRUE to format numeric label text as numbers (e.g. inserting thousand separators
|
||||
* and fixed number of decimal places).
|
||||
@ -897,6 +868,11 @@ class CORE_EXPORT QgsPalLayerSettings
|
||||
SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
|
||||
SIP_PROPERTY( name = placementFlags, get = _getLinePlacementFlags, set = _setLinePlacementFlags )
|
||||
SIP_PROPERTY( name = mergeLines, get = _getMergeLines, set = _setMergeLines )
|
||||
|
||||
SIP_PROPERTY( name = addDirectionSymbol, get = _getAddDirectionSymbol, set = _setAddDirectionSymbol )
|
||||
SIP_PROPERTY( name = leftDirectionSymbol, get = _getLeftDirectionSymbol, set = _setLeftDirectionSymbol )
|
||||
SIP_PROPERTY( name = rightDirectionSymbol, get = _getRightDirectionSymbol, set = _setRightDirectionSymbol )
|
||||
SIP_PROPERTY( name = reverseDirectionSymbol, get = _getReverseDirectionSymbol, set = _setReverseDirectionSymbol )
|
||||
#endif
|
||||
|
||||
///@cond PRIVATE
|
||||
@ -916,6 +892,14 @@ class CORE_EXPORT QgsPalLayerSettings
|
||||
void _setLinePlacementFlags( unsigned int flags ) { mLineSettings.setPlacementFlags( static_cast< QgsLabeling::LinePlacementFlags >( flags ) ); }
|
||||
bool _getMergeLines() const { return mLineSettings.mergeLines(); }
|
||||
void _setMergeLines( bool merge ) { mLineSettings.setMergeLines( merge ); }
|
||||
bool _getAddDirectionSymbol() const { return mLineSettings.addDirectionSymbol(); }
|
||||
void _setAddDirectionSymbol( bool add ) { mLineSettings.setAddDirectionSymbol( add ); }
|
||||
QString _getLeftDirectionSymbol() const { return mLineSettings.leftDirectionSymbol(); }
|
||||
void _setLeftDirectionSymbol( const QString &symbol ) { mLineSettings.setLeftDirectionSymbol( symbol ); }
|
||||
QString _getRightDirectionSymbol() const { return mLineSettings.rightDirectionSymbol(); }
|
||||
void _setRightDirectionSymbol( const QString &symbol ) { mLineSettings.setRightDirectionSymbol( symbol ); }
|
||||
bool _getReverseDirectionSymbol() const { return mLineSettings.reverseDirectionSymbol(); }
|
||||
void _setReverseDirectionSymbol( bool reverse ) { mLineSettings.setReverseDirectionSymbol( reverse ); }
|
||||
///@endcond
|
||||
|
||||
//! Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-index
|
||||
|
||||
@ -82,7 +82,7 @@ void QgsVectorLayerLabelProvider::init()
|
||||
mFlags |= DrawLabels;
|
||||
if ( mSettings.displayAll )
|
||||
mFlags |= DrawAllLabels;
|
||||
if ( mSettings.lineSettings().mergeLines() && !mSettings.addDirectionSymbol )
|
||||
if ( mSettings.lineSettings().mergeLines() && !mSettings.lineSettings().addDirectionSymbol() )
|
||||
mFlags |= MergeConnectedLines;
|
||||
if ( mSettings.centroidInside )
|
||||
mFlags |= CentroidMustBeInside;
|
||||
@ -566,28 +566,28 @@ void QgsVectorLayerLabelProvider::drawLabelPrivate( pal::LabelPosition *label, Q
|
||||
|
||||
//add the direction symbol if needed
|
||||
if ( !txt.isEmpty() && tmpLyr.placement == QgsPalLayerSettings::Line &&
|
||||
tmpLyr.addDirectionSymbol )
|
||||
tmpLyr.lineSettings().addDirectionSymbol() )
|
||||
{
|
||||
bool prependSymb = false;
|
||||
QString symb = tmpLyr.rightDirectionSymbol;
|
||||
QString symb = tmpLyr.lineSettings().rightDirectionSymbol();
|
||||
|
||||
if ( label->getReversed() )
|
||||
{
|
||||
prependSymb = true;
|
||||
symb = tmpLyr.leftDirectionSymbol;
|
||||
symb = tmpLyr.lineSettings().leftDirectionSymbol();
|
||||
}
|
||||
|
||||
if ( tmpLyr.reverseDirectionSymbol )
|
||||
if ( tmpLyr.lineSettings().reverseDirectionSymbol() )
|
||||
{
|
||||
if ( symb == tmpLyr.rightDirectionSymbol )
|
||||
if ( symb == tmpLyr.lineSettings().rightDirectionSymbol() )
|
||||
{
|
||||
prependSymb = true;
|
||||
symb = tmpLyr.leftDirectionSymbol;
|
||||
symb = tmpLyr.lineSettings().leftDirectionSymbol();
|
||||
}
|
||||
else
|
||||
{
|
||||
prependSymb = false;
|
||||
symb = tmpLyr.rightDirectionSymbol;
|
||||
symb = tmpLyr.lineSettings().rightDirectionSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -362,10 +362,10 @@ void QgsLabelingGui::setLayer( QgsMapLayer *mapLayer )
|
||||
mLimitLabelSpinBox->setValue( mSettings.thinningSettings().maximumNumberLabels() );
|
||||
|
||||
// direction symbol(s)
|
||||
mDirectSymbChkBx->setChecked( mSettings.addDirectionSymbol );
|
||||
mDirectSymbLeftLineEdit->setText( mSettings.leftDirectionSymbol );
|
||||
mDirectSymbRightLineEdit->setText( mSettings.rightDirectionSymbol );
|
||||
mDirectSymbRevChkBx->setChecked( mSettings.reverseDirectionSymbol );
|
||||
mDirectSymbChkBx->setChecked( mSettings.lineSettings().addDirectionSymbol() );
|
||||
mDirectSymbLeftLineEdit->setText( mSettings.lineSettings().leftDirectionSymbol() );
|
||||
mDirectSymbRightLineEdit->setText( mSettings.lineSettings().rightDirectionSymbol() );
|
||||
mDirectSymbRevChkBx->setChecked( mSettings.lineSettings().reverseDirectionSymbol() );
|
||||
|
||||
mDirectSymbBtnGrp->button( static_cast<int>( mSettings.placeDirectionSymbol ) )->setChecked( true );
|
||||
mUpsidedownBtnGrp->button( static_cast<int>( mSettings.upsidedownLabels ) )->setChecked( true );
|
||||
@ -584,10 +584,10 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
|
||||
lyr.plusSign = mFormatNumPlusSignChkBx->isChecked();
|
||||
|
||||
// direction symbol(s)
|
||||
lyr.addDirectionSymbol = mDirectSymbChkBx->isChecked();
|
||||
lyr.leftDirectionSymbol = mDirectSymbLeftLineEdit->text();
|
||||
lyr.rightDirectionSymbol = mDirectSymbRightLineEdit->text();
|
||||
lyr.reverseDirectionSymbol = mDirectSymbRevChkBx->isChecked();
|
||||
lyr.lineSettings().setAddDirectionSymbol( mDirectSymbChkBx->isChecked() );
|
||||
lyr.lineSettings().setLeftDirectionSymbol( mDirectSymbLeftLineEdit->text() );
|
||||
lyr.lineSettings().setRightDirectionSymbol( mDirectSymbRightLineEdit->text() );
|
||||
lyr.lineSettings().setReverseDirectionSymbol( mDirectSymbRevChkBx->isChecked() );
|
||||
if ( mDirectSymbBtnGrp )
|
||||
{
|
||||
lyr.placeDirectionSymbol = ( QgsPalLayerSettings::DirectionSymbols )mDirectSymbBtnGrp->checkedId();
|
||||
|
||||
@ -43,6 +43,19 @@ class TestQgsLabelLineSettings(unittest.TestCase):
|
||||
settings.setMergeLines(False)
|
||||
self.assertFalse(settings.mergeLines())
|
||||
|
||||
settings.setAddDirectionSymbol(True)
|
||||
self.assertTrue(settings.addDirectionSymbol())
|
||||
settings.setAddDirectionSymbol(False)
|
||||
self.assertFalse(settings.addDirectionSymbol())
|
||||
settings.setLeftDirectionSymbol('left')
|
||||
self.assertEqual(settings.leftDirectionSymbol(), 'left')
|
||||
settings.setRightDirectionSymbol('right')
|
||||
self.assertEqual(settings.rightDirectionSymbol(), 'right')
|
||||
settings.setReverseDirectionSymbol(True)
|
||||
self.assertTrue(settings.reverseDirectionSymbol())
|
||||
settings.setReverseDirectionSymbol(False)
|
||||
self.assertFalse(settings.reverseDirectionSymbol())
|
||||
|
||||
# check that compatibility code works
|
||||
pal_settings = QgsPalLayerSettings()
|
||||
pal_settings.placementFlags = QgsPalLayerSettings.OnLine | QgsPalLayerSettings.MapOrientation
|
||||
@ -56,6 +69,27 @@ class TestQgsLabelLineSettings(unittest.TestCase):
|
||||
self.assertFalse(pal_settings.mergeLines)
|
||||
self.assertFalse(pal_settings.lineSettings().mergeLines())
|
||||
|
||||
pal_settings.addDirectionSymbol = True
|
||||
self.assertTrue(pal_settings.addDirectionSymbol)
|
||||
self.assertTrue(pal_settings.lineSettings().addDirectionSymbol())
|
||||
pal_settings.addDirectionSymbol = False
|
||||
self.assertFalse(pal_settings.addDirectionSymbol)
|
||||
self.assertFalse(pal_settings.lineSettings().addDirectionSymbol())
|
||||
|
||||
pal_settings.leftDirectionSymbol = 'l'
|
||||
self.assertEqual(pal_settings.leftDirectionSymbol, 'l')
|
||||
self.assertEqual(pal_settings.lineSettings().leftDirectionSymbol(), 'l')
|
||||
pal_settings.rightDirectionSymbol = 'r'
|
||||
self.assertEqual(pal_settings.rightDirectionSymbol, 'r')
|
||||
self.assertEqual(pal_settings.lineSettings().rightDirectionSymbol(), 'r')
|
||||
|
||||
pal_settings.reverseDirectionSymbol = True
|
||||
self.assertTrue(pal_settings.reverseDirectionSymbol)
|
||||
self.assertTrue(pal_settings.lineSettings().reverseDirectionSymbol())
|
||||
pal_settings.reverseDirectionSymbol = False
|
||||
self.assertFalse(pal_settings.reverseDirectionSymbol)
|
||||
self.assertFalse(pal_settings.lineSettings().reverseDirectionSymbol())
|
||||
|
||||
def testUpdateDataDefinedProps(self):
|
||||
settings = QgsLabelLineSettings()
|
||||
settings.setPlacementFlags(QgsLabeling.LinePlacementFlag.OnLine)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user