mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-07 00:03:52 -05:00
Move TextOrientation enum from QgsTextFormat and promote to enum class
This commit is contained in:
parent
775e333ec3
commit
ed9dfa9f5a
@ -1305,6 +1305,20 @@ QgsRenderContext.TextFormatAlwaysText.__doc__ = "Always render text as text obje
|
||||
Qgis.TextRenderFormat.__doc__ = 'Options for rendering text.\n\n.. versionadded:: 3.22\n\n' + '* ``TextFormatAlwaysOutlines``: ' + Qgis.TextRenderFormat.AlwaysOutlines.__doc__ + '\n' + '* ``TextFormatAlwaysText``: ' + Qgis.TextRenderFormat.AlwaysText.__doc__
|
||||
# --
|
||||
Qgis.TextRenderFormat.baseClass = Qgis
|
||||
QgsTextFormat.TextOrientation = Qgis.TextOrientation
|
||||
# monkey patching scoped based enum
|
||||
QgsTextFormat.HorizontalOrientation = Qgis.TextOrientation.Horizontal
|
||||
QgsTextFormat.HorizontalOrientation.is_monkey_patched = True
|
||||
QgsTextFormat.HorizontalOrientation.__doc__ = "Horizontally oriented text"
|
||||
QgsTextFormat.VerticalOrientation = Qgis.TextOrientation.Vertical
|
||||
QgsTextFormat.VerticalOrientation.is_monkey_patched = True
|
||||
QgsTextFormat.VerticalOrientation.__doc__ = "Vertically oriented text"
|
||||
QgsTextFormat.RotationBasedOrientation = Qgis.TextOrientation.RotationBased
|
||||
QgsTextFormat.RotationBasedOrientation.is_monkey_patched = True
|
||||
QgsTextFormat.RotationBasedOrientation.__doc__ = "Horizontally or vertically oriented text based on rotation (only available for map labeling)"
|
||||
Qgis.TextOrientation.__doc__ = 'Text orientations.\n\n.. note::\n\n Prior to QGIS 3.28 this was available as :py:class:`QgsTextFormat`.TextOrientation\n\n.. versionadded:: 3.28\n\n' + '* ``HorizontalOrientation``: ' + Qgis.TextOrientation.Horizontal.__doc__ + '\n' + '* ``VerticalOrientation``: ' + Qgis.TextOrientation.Vertical.__doc__ + '\n' + '* ``RotationBasedOrientation``: ' + Qgis.TextOrientation.RotationBased.__doc__
|
||||
# --
|
||||
Qgis.TextOrientation.baseClass = Qgis
|
||||
# monkey patching scoped based enum
|
||||
Qgis.RenderSubcomponentProperty.Generic.__doc__ = "Generic subcomponent property"
|
||||
Qgis.RenderSubcomponentProperty.ShadowOffset.__doc__ = "Shadow offset"
|
||||
|
||||
@ -847,6 +847,13 @@ The development version
|
||||
AlwaysText,
|
||||
};
|
||||
|
||||
enum class TextOrientation
|
||||
{
|
||||
Horizontal,
|
||||
Vertical,
|
||||
RotationBased,
|
||||
};
|
||||
|
||||
enum class RenderSubcomponentProperty
|
||||
{
|
||||
Generic,
|
||||
|
||||
@ -27,13 +27,6 @@ Container for all settings relating to text rendering.
|
||||
%End
|
||||
public:
|
||||
|
||||
enum TextOrientation
|
||||
{
|
||||
HorizontalOrientation,
|
||||
VerticalOrientation,
|
||||
RotationBasedOrientation,
|
||||
};
|
||||
|
||||
QgsTextFormat();
|
||||
%Docstring
|
||||
Default constructor for QgsTextFormat. Creates a text format initially
|
||||
@ -506,7 +499,7 @@ Sets the ``unit`` for the line height for text.
|
||||
.. versionadded:: 3.28
|
||||
%End
|
||||
|
||||
TextOrientation orientation() const;
|
||||
Qgis::TextOrientation orientation() const;
|
||||
%Docstring
|
||||
Returns the orientation of the text.
|
||||
|
||||
@ -515,7 +508,7 @@ Returns the orientation of the text.
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
void setOrientation( TextOrientation orientation );
|
||||
void setOrientation( Qgis::TextOrientation orientation );
|
||||
%Docstring
|
||||
Sets the ``orientation`` for the text.
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsTextRenderer
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
|
||||
@ -41,7 +41,7 @@ Decodes a string representation of a background rotation type to a type.
|
||||
Decodes a string representation of a shadow placement type to a type.
|
||||
%End
|
||||
|
||||
static QString encodeTextOrientation( QgsTextFormat::TextOrientation orientation );
|
||||
static QString encodeTextOrientation( Qgis::TextOrientation orientation );
|
||||
%Docstring
|
||||
Encodes a text ``orientation``.
|
||||
|
||||
@ -50,7 +50,7 @@ Encodes a text ``orientation``.
|
||||
.. seealso:: :py:func:`decodeTextOrientation`
|
||||
%End
|
||||
|
||||
static QgsTextFormat::TextOrientation decodeTextOrientation( const QString &name, bool *ok = 0 );
|
||||
static Qgis::TextOrientation decodeTextOrientation( const QString &name, bool *ok = 0 );
|
||||
%Docstring
|
||||
Attempts to decode a string representation of a text orientation.
|
||||
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
#include "qgsprocessingfeedback.h"
|
||||
|
||||
#include "pal/feature.h"
|
||||
#include "pal/pointset.h"
|
||||
#include "pal/labelposition.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
@ -535,7 +535,7 @@ void QgsPalLayerSettings::startRender( QgsRenderContext &context )
|
||||
if ( placement == Qgis::LabelPlacement::Curved )
|
||||
{
|
||||
// force horizontal orientation, other orientation modes aren't unsupported for curved placement
|
||||
mFormat.setOrientation( QgsTextFormat::HorizontalOrientation );
|
||||
mFormat.setOrientation( Qgis::TextOrientation::Horizontal );
|
||||
mDataDefinedProperties.property( QgsPalLayerSettings::TextOrientation ).setActive( false );
|
||||
}
|
||||
|
||||
@ -1481,7 +1481,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, const QSt
|
||||
QString wrapchr = wrapChar;
|
||||
int evalAutoWrapLength = autoWrapLength;
|
||||
double multilineH = mFormat.lineHeight();
|
||||
QgsTextFormat::TextOrientation orientation = mFormat.orientation();
|
||||
Qgis::TextOrientation orientation = mFormat.orientation();
|
||||
|
||||
bool addDirSymb = mLineSettings.addDirectionSymbol();
|
||||
QString leftDirSymb = mLineSettings.leftDirectionSymbol();
|
||||
@ -1637,7 +1637,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, const QSt
|
||||
|
||||
switch ( orientation )
|
||||
{
|
||||
case QgsTextFormat::HorizontalOrientation:
|
||||
case Qgis::TextOrientation::Horizontal:
|
||||
{
|
||||
h += fm->height() + static_cast< double >( ( lines - 1 ) * ( mFormat.lineHeightUnit() == QgsUnitTypes::RenderPercentage ? ( labelHeight * multilineH ) : lineHeightPainterUnits ) );
|
||||
|
||||
@ -1648,7 +1648,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, const QSt
|
||||
break;
|
||||
}
|
||||
|
||||
case QgsTextFormat::VerticalOrientation:
|
||||
case Qgis::TextOrientation::Vertical:
|
||||
{
|
||||
double letterSpacing = mFormat.scaledFont( *context ).letterSpacing();
|
||||
double labelWidth = fm->maxWidth();
|
||||
@ -1663,7 +1663,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, const QSt
|
||||
break;
|
||||
}
|
||||
|
||||
case QgsTextFormat::RotationBasedOrientation:
|
||||
case Qgis::TextOrientation::RotationBased:
|
||||
{
|
||||
double widthHorizontal = 0.0;
|
||||
for ( const QString &line : std::as_const( multiLineSplit ) )
|
||||
|
||||
@ -1399,6 +1399,21 @@ class CORE_EXPORT Qgis
|
||||
};
|
||||
Q_ENUM( TextRenderFormat )
|
||||
|
||||
/**
|
||||
* Text orientations.
|
||||
*
|
||||
* \note Prior to QGIS 3.28 this was available as QgsTextFormat::TextOrientation
|
||||
*
|
||||
* \since QGIS 3.28
|
||||
*/
|
||||
enum class TextOrientation SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsTextFormat, TextOrientation ) : int
|
||||
{
|
||||
Horizontal SIP_MONKEYPATCH_COMPAT_NAME( HorizontalOrientation ), //!< Horizontally oriented text
|
||||
Vertical SIP_MONKEYPATCH_COMPAT_NAME( VerticalOrientation ), //!< Vertically oriented text
|
||||
RotationBased SIP_MONKEYPATCH_COMPAT_NAME( RotationBasedOrientation ), //!< Horizontally or vertically oriented text based on rotation (only available for map labeling)
|
||||
};
|
||||
Q_ENUM( TextOrientation )
|
||||
|
||||
/**
|
||||
* Rendering subcomponent properties.
|
||||
*
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "qgspainting.h"
|
||||
#include "qgstextrendererutils.h"
|
||||
#include "qgspainteffectregistry.h"
|
||||
#include "qgsapplication.h"
|
||||
|
||||
QgsTextBackgroundSettings::QgsTextBackgroundSettings()
|
||||
{
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "qgspainting.h"
|
||||
#include "qgspainteffectregistry.h"
|
||||
#include "qgstextrendererutils.h"
|
||||
#include "qgsapplication.h"
|
||||
|
||||
QgsTextBufferSettings::QgsTextBufferSettings()
|
||||
{
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include "qgspallabeling.h"
|
||||
#include "qgsconfig.h"
|
||||
#include "qgsfontmanager.h"
|
||||
#include "qgsapplication.h"
|
||||
|
||||
#include <QFontDatabase>
|
||||
#include <QMimeData>
|
||||
@ -360,12 +361,12 @@ void QgsTextFormat::setLineHeightUnit( QgsUnitTypes::RenderUnit unit )
|
||||
d->multilineHeightUnits = unit;
|
||||
}
|
||||
|
||||
QgsTextFormat::TextOrientation QgsTextFormat::orientation() const
|
||||
Qgis::TextOrientation QgsTextFormat::orientation() const
|
||||
{
|
||||
return d->orientation;
|
||||
}
|
||||
|
||||
void QgsTextFormat::setOrientation( TextOrientation orientation )
|
||||
void QgsTextFormat::setOrientation( Qgis::TextOrientation orientation )
|
||||
{
|
||||
d->isValid = true;
|
||||
d->orientation = orientation;
|
||||
|
||||
@ -41,14 +41,6 @@ class CORE_EXPORT QgsTextFormat
|
||||
{
|
||||
public:
|
||||
|
||||
//! Text orientation
|
||||
enum TextOrientation
|
||||
{
|
||||
HorizontalOrientation, //!< Vertically oriented text
|
||||
VerticalOrientation, //!< Horizontally oriented text
|
||||
RotationBasedOrientation, //!< Horizontally or vertically oriented text based on rotation (only available for map labeling)
|
||||
};
|
||||
|
||||
/**
|
||||
* Default constructor for QgsTextFormat. Creates a text format initially
|
||||
* set to an invalid state (see isValid()).
|
||||
@ -466,14 +458,14 @@ class CORE_EXPORT QgsTextFormat
|
||||
* \see setOrientation()
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
TextOrientation orientation() const;
|
||||
Qgis::TextOrientation orientation() const;
|
||||
|
||||
/**
|
||||
* Sets the \a orientation for the text.
|
||||
* \see orientation()
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
void setOrientation( TextOrientation orientation );
|
||||
void setOrientation( Qgis::TextOrientation orientation );
|
||||
|
||||
/**
|
||||
* Returns the text capitalization style.
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "qgspallabeling.h"
|
||||
#include "qgssymbollayerutils.h"
|
||||
#include "qgspainteffectregistry.h"
|
||||
#include "qgsapplication.h"
|
||||
|
||||
QgsTextMaskSettings::QgsTextMaskSettings()
|
||||
{
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgstextrenderer.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgstextformat.h"
|
||||
#include "qgstextdocument.h"
|
||||
#include "qgstextfragment.h"
|
||||
@ -287,20 +286,20 @@ double QgsTextRenderer::drawBuffer( QgsRenderContext &context, const QgsTextRend
|
||||
{
|
||||
QPainter *p = context.painter();
|
||||
|
||||
QgsTextFormat::TextOrientation orientation = format.orientation();
|
||||
if ( format.orientation() == QgsTextFormat::RotationBasedOrientation )
|
||||
Qgis::TextOrientation orientation = format.orientation();
|
||||
if ( format.orientation() == Qgis::TextOrientation::RotationBased )
|
||||
{
|
||||
if ( component.rotation >= -315 && component.rotation < -90 )
|
||||
{
|
||||
orientation = QgsTextFormat::VerticalOrientation;
|
||||
orientation = Qgis::TextOrientation::Vertical;
|
||||
}
|
||||
else if ( component.rotation >= -90 && component.rotation < -45 )
|
||||
{
|
||||
orientation = QgsTextFormat::VerticalOrientation;
|
||||
orientation = Qgis::TextOrientation::Vertical;
|
||||
}
|
||||
else
|
||||
{
|
||||
orientation = QgsTextFormat::HorizontalOrientation;
|
||||
orientation = Qgis::TextOrientation::Horizontal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,7 +331,7 @@ double QgsTextRenderer::drawBuffer( QgsRenderContext &context, const QgsTextRend
|
||||
double advance = 0;
|
||||
switch ( orientation )
|
||||
{
|
||||
case QgsTextFormat::HorizontalOrientation:
|
||||
case Qgis::TextOrientation::Horizontal:
|
||||
{
|
||||
double xOffset = 0;
|
||||
for ( const QgsTextFragment &fragment : component.block )
|
||||
@ -351,8 +350,8 @@ double QgsTextRenderer::drawBuffer( QgsRenderContext &context, const QgsTextRend
|
||||
break;
|
||||
}
|
||||
|
||||
case QgsTextFormat::VerticalOrientation:
|
||||
case QgsTextFormat::RotationBasedOrientation:
|
||||
case Qgis::TextOrientation::Vertical:
|
||||
case Qgis::TextOrientation::RotationBased:
|
||||
{
|
||||
double letterSpacing = font.letterSpacing();
|
||||
double partYOffset = component.offset.y() * scaleFactor;
|
||||
@ -427,7 +426,7 @@ double QgsTextRenderer::drawBuffer( QgsRenderContext &context, const QgsTextRend
|
||||
bufferComponent.picture = buffPict;
|
||||
bufferComponent.pictureBuffer = penSize / 2.0;
|
||||
|
||||
if ( format.orientation() == QgsTextFormat::VerticalOrientation || format.orientation() == QgsTextFormat::RotationBasedOrientation )
|
||||
if ( format.orientation() == Qgis::TextOrientation::Vertical || format.orientation() == Qgis::TextOrientation::RotationBased )
|
||||
{
|
||||
bufferComponent.offset.setY( bufferComponent.offset.y() - bufferComponent.size.height() );
|
||||
}
|
||||
@ -570,7 +569,7 @@ double QgsTextRenderer::textWidth( const QgsRenderContext &context, const QgsTex
|
||||
double width = 0;
|
||||
switch ( format.orientation() )
|
||||
{
|
||||
case QgsTextFormat::HorizontalOrientation:
|
||||
case Qgis::TextOrientation::Horizontal:
|
||||
{
|
||||
double maxLineWidth = 0;
|
||||
for ( const QgsTextBlock &block : document )
|
||||
@ -586,7 +585,7 @@ double QgsTextRenderer::textWidth( const QgsRenderContext &context, const QgsTex
|
||||
break;
|
||||
}
|
||||
|
||||
case QgsTextFormat::VerticalOrientation:
|
||||
case Qgis::TextOrientation::Vertical:
|
||||
{
|
||||
double totalLineWidth = 0;
|
||||
int blockIndex = 0;
|
||||
@ -608,7 +607,7 @@ double QgsTextRenderer::textWidth( const QgsRenderContext &context, const QgsTex
|
||||
break;
|
||||
}
|
||||
|
||||
case QgsTextFormat::RotationBasedOrientation:
|
||||
case Qgis::TextOrientation::RotationBased:
|
||||
{
|
||||
// label mode only
|
||||
break;
|
||||
@ -778,7 +777,7 @@ double QgsTextRenderer::textHeight( const QgsRenderContext &context, const QgsTe
|
||||
|
||||
switch ( format.orientation() )
|
||||
{
|
||||
case QgsTextFormat::HorizontalOrientation:
|
||||
case Qgis::TextOrientation::Horizontal:
|
||||
{
|
||||
int blockIndex = 0;
|
||||
double totalHeight = 0;
|
||||
@ -830,7 +829,7 @@ double QgsTextRenderer::textHeight( const QgsRenderContext &context, const QgsTe
|
||||
return ( totalHeight - lastLineLeading ) / scaleFactor;
|
||||
}
|
||||
|
||||
case QgsTextFormat::VerticalOrientation:
|
||||
case Qgis::TextOrientation::Vertical:
|
||||
{
|
||||
double maxBlockHeight = 0;
|
||||
for ( const QgsTextBlock &block : document )
|
||||
@ -856,7 +855,7 @@ double QgsTextRenderer::textHeight( const QgsRenderContext &context, const QgsTe
|
||||
return maxBlockHeight / scaleFactor;
|
||||
}
|
||||
|
||||
case QgsTextFormat::RotationBasedOrientation:
|
||||
case Qgis::TextOrientation::RotationBased:
|
||||
{
|
||||
// label mode only
|
||||
break;
|
||||
@ -1454,17 +1453,17 @@ void QgsTextRenderer::drawTextInternal( TextPart drawType,
|
||||
}
|
||||
|
||||
double rotation = 0;
|
||||
const QgsTextFormat::TextOrientation orientation = calculateRotationAndOrientationForComponent( format, component, rotation );
|
||||
const Qgis::TextOrientation orientation = calculateRotationAndOrientationForComponent( format, component, rotation );
|
||||
switch ( orientation )
|
||||
{
|
||||
case QgsTextFormat::HorizontalOrientation:
|
||||
case Qgis::TextOrientation::Horizontal:
|
||||
{
|
||||
drawTextInternalHorizontal( context, format, drawType, mode, component, document, fontScale, fontMetrics, alignment, vAlignment, rotation );
|
||||
break;
|
||||
}
|
||||
|
||||
case QgsTextFormat::VerticalOrientation:
|
||||
case QgsTextFormat::RotationBasedOrientation:
|
||||
case Qgis::TextOrientation::Vertical:
|
||||
case Qgis::TextOrientation::RotationBased:
|
||||
{
|
||||
drawTextInternalVertical( context, format, drawType, mode, component, document, fontScale, fontMetrics, alignment, vAlignment, rotation );
|
||||
break;
|
||||
@ -1472,34 +1471,34 @@ void QgsTextRenderer::drawTextInternal( TextPart drawType,
|
||||
}
|
||||
}
|
||||
|
||||
QgsTextFormat::TextOrientation QgsTextRenderer::calculateRotationAndOrientationForComponent( const QgsTextFormat &format, const QgsTextRenderer::Component &component, double &rotation )
|
||||
Qgis::TextOrientation QgsTextRenderer::calculateRotationAndOrientationForComponent( const QgsTextFormat &format, const QgsTextRenderer::Component &component, double &rotation )
|
||||
{
|
||||
rotation = -component.rotation * 180 / M_PI;
|
||||
|
||||
switch ( format.orientation() )
|
||||
{
|
||||
case QgsTextFormat::RotationBasedOrientation:
|
||||
case Qgis::TextOrientation::RotationBased:
|
||||
{
|
||||
// Between 45 to 135 and 235 to 315 degrees, rely on vertical orientation
|
||||
if ( rotation >= -315 && rotation < -90 )
|
||||
{
|
||||
rotation -= 90;
|
||||
return QgsTextFormat::VerticalOrientation;
|
||||
return Qgis::TextOrientation::Vertical;
|
||||
}
|
||||
else if ( rotation >= -90 && rotation < -45 )
|
||||
{
|
||||
rotation += 90;
|
||||
return QgsTextFormat::VerticalOrientation;
|
||||
return Qgis::TextOrientation::Vertical;
|
||||
}
|
||||
|
||||
return QgsTextFormat::HorizontalOrientation;
|
||||
return Qgis::TextOrientation::Horizontal;
|
||||
}
|
||||
|
||||
case QgsTextFormat::HorizontalOrientation:
|
||||
case QgsTextFormat::VerticalOrientation:
|
||||
case Qgis::TextOrientation::Horizontal:
|
||||
case Qgis::TextOrientation::Vertical:
|
||||
return format.orientation();
|
||||
}
|
||||
return QgsTextFormat::HorizontalOrientation;
|
||||
return Qgis::TextOrientation::Horizontal;
|
||||
}
|
||||
|
||||
void QgsTextRenderer::calculateExtraSpacingForLineJustification( const double spaceToDistribute, const QgsTextBlock &block, double &extraWordSpace, double &extraLetterSpace )
|
||||
@ -1945,7 +1944,7 @@ void QgsTextRenderer::drawTextInternalVertical( QgsRenderContext &context, const
|
||||
switch ( mode )
|
||||
{
|
||||
case Label:
|
||||
if ( format.orientation() == QgsTextFormat::RotationBasedOrientation )
|
||||
if ( format.orientation() == Qgis::TextOrientation::RotationBased )
|
||||
{
|
||||
if ( rotation >= -405 && rotation < -180 )
|
||||
{
|
||||
|
||||
@ -19,13 +19,17 @@
|
||||
#include "qgis_sip.h"
|
||||
#include "qgis_core.h"
|
||||
#include "qgstextblock.h"
|
||||
#include "qgstextformat.h"
|
||||
#include "qgsunittypes.h"
|
||||
#include "qgsmapunitscale.h"
|
||||
|
||||
#include <QPicture>
|
||||
|
||||
class QgsTextDocument;
|
||||
class QgsTextFormat;
|
||||
class QgsRenderContext;
|
||||
|
||||
class QFontMetricsF;
|
||||
|
||||
/**
|
||||
* \class QgsTextRenderer
|
||||
* \ingroup core
|
||||
@ -372,7 +376,7 @@ class CORE_EXPORT QgsTextRenderer
|
||||
VAlignment vAlignment,
|
||||
DrawMode mode = Rect );
|
||||
|
||||
static QgsTextFormat::TextOrientation calculateRotationAndOrientationForComponent( const QgsTextFormat &format, const Component &component, double &rotation );
|
||||
static Qgis::TextOrientation calculateRotationAndOrientationForComponent( const QgsTextFormat &format, const Component &component, double &rotation );
|
||||
|
||||
static void calculateExtraSpacingForLineJustification( double spaceToDistribute, const QgsTextBlock &block, double &extraWordSpace, double &extraLetterSpace );
|
||||
static void applyExtraSpacingForLineJustification( QFont &font, double extraWordSpace, double extraLetterSpace );
|
||||
|
||||
@ -22,10 +22,8 @@
|
||||
#include "qgis_core.h"
|
||||
#include "qgstextshadowsettings.h"
|
||||
#include "qgstextbackgroundsettings.h"
|
||||
#include "qgstextformat.h"
|
||||
#include "qgsmapunitscale.h"
|
||||
#include "qgsunittypes.h"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgspainteffect.h"
|
||||
#include "qgssymbollayerreference.h"
|
||||
#include "qgsstringutils.h"
|
||||
@ -301,7 +299,7 @@ class QgsTextSettingsPrivate : public QSharedData
|
||||
QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
|
||||
double multilineHeight = 1.0;
|
||||
QgsUnitTypes::RenderUnit multilineHeightUnits = QgsUnitTypes::RenderPercentage;
|
||||
QgsTextFormat::TextOrientation orientation = QgsTextFormat::HorizontalOrientation;
|
||||
Qgis::TextOrientation orientation = Qgis::TextOrientation::Horizontal;
|
||||
QColor previewBackgroundColor = Qt::white;
|
||||
bool allowHtmlFormatting = false;
|
||||
Qgis::Capitalization capitalization = Qgis::Capitalization::MixedCase;
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
|
||||
#include "qgstextrendererutils.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgslinestring.h"
|
||||
|
||||
QgsTextBackgroundSettings::ShapeType QgsTextRendererUtils::decodeShapeType( const QString &string )
|
||||
{
|
||||
@ -96,21 +95,21 @@ QgsTextShadowSettings::ShadowPlacement QgsTextRendererUtils::decodeShadowPlaceme
|
||||
return shdwtype;
|
||||
}
|
||||
|
||||
QString QgsTextRendererUtils::encodeTextOrientation( QgsTextFormat::TextOrientation orientation )
|
||||
QString QgsTextRendererUtils::encodeTextOrientation( Qgis::TextOrientation orientation )
|
||||
{
|
||||
switch ( orientation )
|
||||
{
|
||||
case QgsTextFormat::HorizontalOrientation:
|
||||
case Qgis::TextOrientation::Horizontal:
|
||||
return QStringLiteral( "horizontal" );
|
||||
case QgsTextFormat::VerticalOrientation:
|
||||
case Qgis::TextOrientation::Vertical:
|
||||
return QStringLiteral( "vertical" );
|
||||
case QgsTextFormat::RotationBasedOrientation:
|
||||
case Qgis::TextOrientation::RotationBased:
|
||||
return QStringLiteral( "rotation-based" );
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QgsTextFormat::TextOrientation QgsTextRendererUtils::decodeTextOrientation( const QString &name, bool *ok )
|
||||
Qgis::TextOrientation QgsTextRendererUtils::decodeTextOrientation( const QString &name, bool *ok )
|
||||
{
|
||||
if ( ok )
|
||||
*ok = true;
|
||||
@ -118,15 +117,15 @@ QgsTextFormat::TextOrientation QgsTextRendererUtils::decodeTextOrientation( cons
|
||||
const QString cleaned = name.toLower().trimmed();
|
||||
|
||||
if ( cleaned == QLatin1String( "horizontal" ) )
|
||||
return QgsTextFormat::HorizontalOrientation;
|
||||
return Qgis::TextOrientation::Horizontal;
|
||||
else if ( cleaned == QLatin1String( "vertical" ) )
|
||||
return QgsTextFormat::VerticalOrientation;
|
||||
return Qgis::TextOrientation::Vertical;
|
||||
else if ( cleaned == QLatin1String( "rotation-based" ) )
|
||||
return QgsTextFormat::RotationBasedOrientation;
|
||||
return Qgis::TextOrientation::RotationBased;
|
||||
|
||||
if ( ok )
|
||||
*ok = false;
|
||||
return QgsTextFormat::HorizontalOrientation;
|
||||
return Qgis::TextOrientation::Horizontal;
|
||||
}
|
||||
|
||||
QgsUnitTypes::RenderUnit QgsTextRendererUtils::convertFromOldLabelUnit( int val )
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#include "qgis_core.h"
|
||||
#include "qgstextbackgroundsettings.h"
|
||||
#include "qgstextshadowsettings.h"
|
||||
#include "qgstextformat.h"
|
||||
#include "qgstextmetrics.h"
|
||||
|
||||
/**
|
||||
@ -58,7 +57,7 @@ class CORE_EXPORT QgsTextRendererUtils
|
||||
* \returns encoded string
|
||||
* \see decodeTextOrientation()
|
||||
*/
|
||||
static QString encodeTextOrientation( QgsTextFormat::TextOrientation orientation );
|
||||
static QString encodeTextOrientation( Qgis::TextOrientation orientation );
|
||||
|
||||
/**
|
||||
* Attempts to decode a string representation of a text orientation.
|
||||
@ -67,7 +66,7 @@ class CORE_EXPORT QgsTextRendererUtils
|
||||
* \returns decoded text orientation
|
||||
* \see encodeTextOrientation()
|
||||
*/
|
||||
static QgsTextFormat::TextOrientation decodeTextOrientation( const QString &name, bool *ok = nullptr );
|
||||
static Qgis::TextOrientation decodeTextOrientation( const QString &name, bool *ok = nullptr );
|
||||
|
||||
/**
|
||||
* Converts a unit from an old (pre 3.0) label unit.
|
||||
|
||||
@ -237,8 +237,8 @@ void QgsTextFormatWidget::initWidget()
|
||||
connect( chkLineBelow, &QAbstractButton::toggled, this, &QgsTextFormatWidget::updateLinePlacementOptions );
|
||||
connect( chkLineOn, &QAbstractButton::toggled, this, &QgsTextFormatWidget::updateLinePlacementOptions );
|
||||
|
||||
mTextOrientationComboBox->addItem( tr( "Horizontal" ), QgsTextFormat::HorizontalOrientation );
|
||||
mTextOrientationComboBox->addItem( tr( "Vertical" ), QgsTextFormat::VerticalOrientation );
|
||||
mTextOrientationComboBox->addItem( tr( "Horizontal" ), static_cast< int >( Qgis::TextOrientation::Horizontal ) );
|
||||
mTextOrientationComboBox->addItem( tr( "Vertical" ), static_cast< int >( Qgis::TextOrientation::Vertical ) );
|
||||
|
||||
populateFontCapitalsComboBox();
|
||||
|
||||
@ -545,7 +545,7 @@ void QgsTextFormatWidget::setWidgetMode( QgsTextFormatWidget::Mode mode )
|
||||
case Labeling:
|
||||
toggleDDButtons( true );
|
||||
mTextFormatsListWidget->setEntityTypes( QList< QgsStyle::StyleEntity >() << QgsStyle::TextFormatEntity << QgsStyle::LabelSettingsEntity );
|
||||
mTextOrientationComboBox->addItem( tr( "Rotation-based" ), QgsTextFormat::RotationBasedOrientation );
|
||||
mTextOrientationComboBox->addItem( tr( "Rotation-based" ), static_cast< int >( Qgis::TextOrientation::RotationBased ) );
|
||||
break;
|
||||
|
||||
case Text:
|
||||
@ -604,7 +604,7 @@ void QgsTextFormatWidget::setWidgetMode( QgsTextFormatWidget::Mode mode )
|
||||
mFontMultiLineAlignComboBox->hide();
|
||||
mFontMultiLineAlignDDBtn->hide();
|
||||
|
||||
mTextOrientationComboBox->removeItem( mTextOrientationComboBox->findData( QgsTextFormat::RotationBasedOrientation ) );
|
||||
mTextOrientationComboBox->removeItem( mTextOrientationComboBox->findData( static_cast< int >( Qgis::TextOrientation::RotationBased ) ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -933,7 +933,7 @@ void QgsTextFormatWidget::updateWidgetForFormat( const QgsTextFormat &format )
|
||||
whileBlocking( mSpinStretch )->setValue( format.stretchFactor() );
|
||||
mTextOpacityWidget->setOpacity( format.opacity() );
|
||||
comboBlendMode->setBlendMode( format.blendMode() );
|
||||
mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData( format.orientation() ) );
|
||||
mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData( static_cast< int >( format.orientation() ) ) );
|
||||
mHtmlFormattingCheckBox->setChecked( format.allowHtmlFormatting() );
|
||||
|
||||
mFontWordSpacingSpinBox->setValue( format.font().wordSpacing() );
|
||||
@ -1077,7 +1077,7 @@ QgsTextFormat QgsTextFormatWidget::format( bool includeDataDefinedProperties ) c
|
||||
format.setLineHeight( mLineHeightUnitWidget->unit() == QgsUnitTypes::RenderPercentage ? ( mFontLineHeightSpinBox->value() / 100 ) : mFontLineHeightSpinBox->value() );
|
||||
format.setLineHeightUnit( mLineHeightUnitWidget->unit() );
|
||||
format.setPreviewBackgroundColor( mPreviewBackgroundColor );
|
||||
format.setOrientation( static_cast< QgsTextFormat::TextOrientation >( mTextOrientationComboBox->currentData().toInt() ) );
|
||||
format.setOrientation( static_cast< Qgis::TextOrientation >( mTextOrientationComboBox->currentData().toInt() ) );
|
||||
format.setAllowHtmlFormatting( mHtmlFormattingCheckBox->isChecked( ) );
|
||||
format.setCapitalization( static_cast< Qgis::Capitalization >( mFontCapitalsComboBox->currentData().toInt() ) );
|
||||
|
||||
|
||||
@ -4614,7 +4614,7 @@ void TestQgsLabelingEngine::testVerticalOrientation()
|
||||
settings.fieldName = QStringLiteral( "Class" );
|
||||
setDefaultLabelParams( settings );
|
||||
QgsTextFormat format = settings.format();
|
||||
format.setOrientation( QgsTextFormat::VerticalOrientation );
|
||||
format.setOrientation( Qgis::TextOrientation::Vertical );
|
||||
settings.setFormat( format );
|
||||
|
||||
vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary!
|
||||
@ -4660,7 +4660,7 @@ void TestQgsLabelingEngine::testVerticalOrientationLetterLineSpacing()
|
||||
settings.isExpression = true;
|
||||
setDefaultLabelParams( settings );
|
||||
QgsTextFormat format = settings.format();
|
||||
format.setOrientation( QgsTextFormat::VerticalOrientation );
|
||||
format.setOrientation( Qgis::TextOrientation::Vertical );
|
||||
format.setLineHeight( 1.5 );
|
||||
QFont font = format.font();
|
||||
font.setLetterSpacing( QFont::AbsoluteSpacing, 3.75 );
|
||||
@ -4710,7 +4710,7 @@ void TestQgsLabelingEngine::testRotationBasedOrientationPoint()
|
||||
setDefaultLabelParams( settings );
|
||||
settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::LabelRotation, QgsProperty::fromExpression( QStringLiteral( "\"Heading\"" ) ) );
|
||||
QgsTextFormat format = settings.format();
|
||||
format.setOrientation( QgsTextFormat::RotationBasedOrientation );
|
||||
format.setOrientation( Qgis::TextOrientation::RotationBased );
|
||||
settings.setFormat( format );
|
||||
|
||||
vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary!
|
||||
@ -4763,7 +4763,7 @@ void TestQgsLabelingEngine::testRotationBasedOrientationLine()
|
||||
settings.placement = Qgis::LabelPlacement::Line;
|
||||
settings.lineSettings().setPlacementFlags( QgsLabeling::LinePlacementFlag::AboveLine );
|
||||
QgsTextFormat format = settings.format();
|
||||
format.setOrientation( QgsTextFormat::RotationBasedOrientation );
|
||||
format.setOrientation( Qgis::TextOrientation::RotationBased );
|
||||
settings.setFormat( format );
|
||||
|
||||
vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user