QGIS API Documentation  3.0.2-Girona (307d082)
Public Types | Public Member Functions | List of all members
QgsTextBackgroundSettings Class Reference

Container for settings relating to a text background object. More...

#include <qgstextrenderer.h>

Public Types

enum  RotationType { RotationSync = 0, RotationOffset, RotationFixed }
 Methods for determining the rotation of the background shape. More...
 
enum  ShapeType {
  ShapeRectangle = 0, ShapeSquare, ShapeEllipse, ShapeCircle,
  ShapeSVG
}
 Background shape types. More...
 
enum  SizeType { SizeBuffer = 0, SizeFixed, SizePercent }
 Methods for determining the background shape size. More...
 

Public Member Functions

 QgsTextBackgroundSettings ()
 
 QgsTextBackgroundSettings (const QgsTextBackgroundSettings &other)
 Copy constructor. More...
 
 ~QgsTextBackgroundSettings ()
 
QPainter::CompositionMode blendMode () const
 Returns the blending mode used for drawing the background shape. More...
 
bool enabled () const
 Returns whether the background is enabled. More...
 
QColor fillColor () const
 Returns the color used for filing the background shape. More...
 
Qt::PenJoinStyle joinStyle () const
 Returns the join style used for drawing the background shape. More...
 
QPointF offset () const
 Returns the offset used for drawing the background shape. More...
 
QgsMapUnitScale offsetMapUnitScale () const
 Returns the map unit scale object for the shape offset. More...
 
QgsUnitTypes::RenderUnit offsetUnit () const
 Returns the units used for the shape's offset. More...
 
double opacity () const
 Returns the background shape's opacity. More...
 
QgsTextBackgroundSettingsoperator= (const QgsTextBackgroundSettings &other)
 
QgsPaintEffectpaintEffect () const
 Returns the current paint effect for the background shape. More...
 
QSizeF radii () const
 Returns the radii used for rounding the corners of shapes. More...
 
QgsMapUnitScale radiiMapUnitScale () const
 Returns the map unit scale object for the shape radii. More...
 
QgsUnitTypes::RenderUnit radiiUnit () const
 Returns the units used for the shape's radii. More...
 
void readFromLayer (QgsVectorLayer *layer)
 Reads settings from a layer's custom properties (for QGIS 2.x projects). More...
 
void readXml (const QDomElement &elem, const QgsReadWriteContext &context)
 Read settings from a DOM element. More...
 
double rotation () const
 Returns the rotation for the background shape, in degrees clockwise. More...
 
RotationType rotationType () const
 Returns the method used for rotating the background shape. More...
 
void setBlendMode (QPainter::CompositionMode mode)
 Sets the blending mode used for drawing the background shape. More...
 
void setEnabled (bool enabled)
 Sets whether the text background will be drawn. More...
 
void setFillColor (const QColor &color)
 Sets the color used for filing the background shape. More...
 
void setJoinStyle (Qt::PenJoinStyle style)
 Sets the join style used for drawing the background shape. More...
 
void setOffset (QPointF offset)
 Sets the offset used for drawing the background shape. More...
 
void setOffsetMapUnitScale (const QgsMapUnitScale &scale)
 Sets the map unit scale object for the shape offset. More...
 
void setOffsetUnit (QgsUnitTypes::RenderUnit units)
 Sets the units used for the shape's offset. More...
 
void setOpacity (double opacity)
 Sets the background shape's opacity. More...
 
void setPaintEffect (QgsPaintEffect *effect)
 Sets the current paint effect for the background shape. More...
 
void setRadii (QSizeF radii)
 Sets the radii used for rounding the corners of shapes. More...
 
void setRadiiMapUnitScale (const QgsMapUnitScale &scale)
 Sets the map unit scale object for the shape radii. More...
 
void setRadiiUnit (QgsUnitTypes::RenderUnit units)
 Sets the units used for the shape's radii. More...
 
void setRotation (double rotation)
 Sets the rotation for the background shape, in degrees clockwise. More...
 
void setRotationType (RotationType type)
 Sets the method used for rotating the background shape. More...
 
void setSize (QSizeF size)
 Sets the size of the background shape. More...
 
void setSizeMapUnitScale (const QgsMapUnitScale &scale)
 Sets the map unit scale object for the shape size. More...
 
void setSizeType (SizeType type)
 Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around text). More...
 
void setSizeUnit (QgsUnitTypes::RenderUnit unit)
 Sets the units used for the shape's size. More...
 
void setStrokeColor (const QColor &color)
 Sets the color used for outlining the background shape. More...
 
void setStrokeWidth (double width)
 Sets the width of the shape's stroke (stroke). More...
 
void setStrokeWidthMapUnitScale (const QgsMapUnitScale &scale)
 Sets the map unit scale object for the shape stroke width. More...
 
void setStrokeWidthUnit (QgsUnitTypes::RenderUnit units)
 Sets the units used for the shape's stroke width. More...
 
void setSvgFile (const QString &file)
 Sets the path to the background SVG file. More...
 
void setType (ShapeType type)
 Sets the type of background shape to draw (e.g., square, ellipse, SVG). More...
 
QSizeF size () const
 Returns the size of the background shape. More...
 
QgsMapUnitScale sizeMapUnitScale () const
 Returns the map unit scale object for the shape size. More...
 
SizeType sizeType () const
 Returns the method used to determine the size of the background shape (e.g., fixed size or buffer around text). More...
 
QgsUnitTypes::RenderUnit sizeUnit () const
 Returns the units used for the shape's size. More...
 
QColor strokeColor () const
 Returns the color used for outlining the background shape. More...
 
double strokeWidth () const
 Returns the width of the shape's stroke (stroke). More...
 
QgsMapUnitScale strokeWidthMapUnitScale () const
 Returns the map unit scale object for the shape stroke width. More...
 
QgsUnitTypes::RenderUnit strokeWidthUnit () const
 Returns the units used for the shape's stroke width. More...
 
QString svgFile () const
 Returns the absolute path to the background SVG file, if set. More...
 
ShapeType type () const
 Returns the type of background shape (e.g., square, ellipse, SVG). More...
 
QDomElement writeXml (QDomDocument &doc, const QgsReadWriteContext &context) const
 Write settings into a DOM element. More...
 

Detailed Description

Container for settings relating to a text background object.

Note
QgsTextBackgroundSettings objects are implicitly shared.
Since
QGIS 3.0

Definition at line 242 of file qgstextrenderer.h.

Member Enumeration Documentation

◆ RotationType

Methods for determining the rotation of the background shape.

Enumerator
RotationSync 

Shape rotation is synced with text rotation.

RotationOffset 

Shape rotation is offset from text rotation.

RotationFixed 

Shape rotation is a fixed angle.

Definition at line 271 of file qgstextrenderer.h.

◆ ShapeType

Background shape types.

Enumerator
ShapeRectangle 

Rectangle.

ShapeSquare 

Square - buffered sizes only.

ShapeEllipse 

Ellipse.

ShapeCircle 

Circle.

ShapeSVG 

SVG file.

Definition at line 249 of file qgstextrenderer.h.

◆ SizeType

Methods for determining the background shape size.

Enumerator
SizeBuffer 

Shape size is determined by adding a buffer margin around text.

SizeFixed 

Fixed size.

SizePercent 

Shape size is determined by percent of text size.

Definition at line 261 of file qgstextrenderer.h.

Constructor & Destructor Documentation

◆ QgsTextBackgroundSettings() [1/2]

QgsTextBackgroundSettings::QgsTextBackgroundSettings ( )

Definition at line 349 of file qgstextrenderer.cpp.

◆ QgsTextBackgroundSettings() [2/2]

QgsTextBackgroundSettings::QgsTextBackgroundSettings ( const QgsTextBackgroundSettings other)

Copy constructor.

Parameters
othersource QgsTextBackgroundSettings

Definition at line 354 of file qgstextrenderer.cpp.

◆ ~QgsTextBackgroundSettings()

QgsTextBackgroundSettings::~QgsTextBackgroundSettings ( )

Definition at line 366 of file qgstextrenderer.cpp.

Member Function Documentation

◆ blendMode()

QPainter::CompositionMode QgsTextBackgroundSettings::blendMode ( ) const

Returns the blending mode used for drawing the background shape.

See also
setBlendMode()

Definition at line 531 of file qgstextrenderer.cpp.

◆ enabled()

bool QgsTextBackgroundSettings::enabled ( ) const

Returns whether the background is enabled.

See also
setEnabled()

Definition at line 371 of file qgstextrenderer.cpp.

◆ fillColor()

QColor QgsTextBackgroundSettings::fillColor ( ) const

Returns the color used for filing the background shape.

See also
setFillColor()
strokeColor()

Definition at line 541 of file qgstextrenderer.cpp.

◆ joinStyle()

Qt::PenJoinStyle QgsTextBackgroundSettings::joinStyle ( ) const

Returns the join style used for drawing the background shape.

See also
setJoinStyle

Definition at line 591 of file qgstextrenderer.cpp.

◆ offset()

QPointF QgsTextBackgroundSettings::offset ( ) const

Returns the offset used for drawing the background shape.

Units are determined via offsetUnit().

See also
setOffset()
offsetUnit()

Definition at line 461 of file qgstextrenderer.cpp.

◆ offsetMapUnitScale()

QgsMapUnitScale QgsTextBackgroundSettings::offsetMapUnitScale ( ) const

Returns the map unit scale object for the shape offset.

This is only used if the offsetUnit() is set to QgsUnitTypes::RenderMapUnit.

See also
setOffsetMapUnitScale()
offsetUnit()

Definition at line 481 of file qgstextrenderer.cpp.

◆ offsetUnit()

QgsUnitTypes::RenderUnit QgsTextBackgroundSettings::offsetUnit ( ) const

Returns the units used for the shape's offset.

See also
setOffsetUnit()
offset()

Definition at line 471 of file qgstextrenderer.cpp.

◆ opacity()

double QgsTextBackgroundSettings::opacity ( ) const

Returns the background shape's opacity.

The opacity is a double value between 0 (fully transparent) and 1 (totally opaque).

See also
setOpacity()

Definition at line 521 of file qgstextrenderer.cpp.

◆ operator=()

QgsTextBackgroundSettings & QgsTextBackgroundSettings::operator= ( const QgsTextBackgroundSettings other)

Definition at line 360 of file qgstextrenderer.cpp.

◆ paintEffect()

QgsPaintEffect * QgsTextBackgroundSettings::paintEffect ( ) const

Returns the current paint effect for the background shape.

Returns
paint effect
See also
setPaintEffect()

Definition at line 601 of file qgstextrenderer.cpp.

◆ radii()

QSizeF QgsTextBackgroundSettings::radii ( ) const

Returns the radii used for rounding the corners of shapes.

Units are retrieved through radiiUnit().

See also
setRadii()
radiiUnit()

Definition at line 491 of file qgstextrenderer.cpp.

◆ radiiMapUnitScale()

QgsMapUnitScale QgsTextBackgroundSettings::radiiMapUnitScale ( ) const

Returns the map unit scale object for the shape radii.

This is only used if the radiiUnit() is set to QgsUnitTypes::RenderMapUnit.

See also
setRadiiMapUnitScale()
radiiUnit()

Definition at line 511 of file qgstextrenderer.cpp.

◆ radiiUnit()

QgsUnitTypes::RenderUnit QgsTextBackgroundSettings::radiiUnit ( ) const

Returns the units used for the shape's radii.

See also
setRadiiUnit()
radii()

Definition at line 501 of file qgstextrenderer.cpp.

◆ readFromLayer()

void QgsTextBackgroundSettings::readFromLayer ( QgsVectorLayer layer)

Reads settings from a layer's custom properties (for QGIS 2.x projects).

Parameters
layersource vector layer

Definition at line 612 of file qgstextrenderer.cpp.

◆ readXml()

void QgsTextBackgroundSettings::readXml ( const QDomElement &  elem,
const QgsReadWriteContext context 
)

Read settings from a DOM element.

See also
writeXml()

Definition at line 740 of file qgstextrenderer.cpp.

◆ rotation()

double QgsTextBackgroundSettings::rotation ( ) const

Returns the rotation for the background shape, in degrees clockwise.

See also
rotationType()
setRotation()

Definition at line 451 of file qgstextrenderer.cpp.

◆ rotationType()

QgsTextBackgroundSettings::RotationType QgsTextBackgroundSettings::rotationType ( ) const

Returns the method used for rotating the background shape.

See also
setRotationType()
rotation()

Definition at line 441 of file qgstextrenderer.cpp.

◆ setBlendMode()

void QgsTextBackgroundSettings::setBlendMode ( QPainter::CompositionMode  mode)

Sets the blending mode used for drawing the background shape.

Parameters
modeblending mode
See also
blendMode()

Definition at line 536 of file qgstextrenderer.cpp.

◆ setEnabled()

void QgsTextBackgroundSettings::setEnabled ( bool  enabled)

Sets whether the text background will be drawn.

Parameters
enabledset to true to draw background
See also
enabled()

Definition at line 376 of file qgstextrenderer.cpp.

◆ setFillColor()

void QgsTextBackgroundSettings::setFillColor ( const QColor &  color)

Sets the color used for filing the background shape.

Parameters
colorbackground color
See also
fillColor()
setStrokeColor()

Definition at line 546 of file qgstextrenderer.cpp.

◆ setJoinStyle()

void QgsTextBackgroundSettings::setJoinStyle ( Qt::PenJoinStyle  style)

Sets the join style used for drawing the background shape.

Parameters
stylejoin style
See also
joinStyle()

Definition at line 596 of file qgstextrenderer.cpp.

◆ setOffset()

void QgsTextBackgroundSettings::setOffset ( QPointF  offset)

Sets the offset used for drawing the background shape.

Units are specified using setOffsetUnit().

Parameters
offsetoffset for shape
See also
offset()
setOffsetUnit()

Definition at line 466 of file qgstextrenderer.cpp.

◆ setOffsetMapUnitScale()

void QgsTextBackgroundSettings::setOffsetMapUnitScale ( const QgsMapUnitScale scale)

Sets the map unit scale object for the shape offset.

This is only used if the offsetUnit() is set to QgsUnitTypes::RenderMapUnit.

Parameters
scalescale for shape offset
See also
offsetMapUnitScale()
setOffsetUnit()

Definition at line 486 of file qgstextrenderer.cpp.

◆ setOffsetUnit()

void QgsTextBackgroundSettings::setOffsetUnit ( QgsUnitTypes::RenderUnit  units)

Sets the units used for the shape's offset.

Parameters
unitsoffset units
See also
offsetUnit()
setOffset()

Definition at line 476 of file qgstextrenderer.cpp.

◆ setOpacity()

void QgsTextBackgroundSettings::setOpacity ( double  opacity)

Sets the background shape's opacity.

Parameters
opacityopacity as a double value between 0 (fully transparent) and 1 (totally opaque)
See also
opacity()

Definition at line 526 of file qgstextrenderer.cpp.

◆ setPaintEffect()

void QgsTextBackgroundSettings::setPaintEffect ( QgsPaintEffect effect)

Sets the current paint effect for the background shape.

Parameters
effectpaint effect. Ownership is transferred to the background settings.
See also
paintEffect()

Definition at line 606 of file qgstextrenderer.cpp.

◆ setRadii()

void QgsTextBackgroundSettings::setRadii ( QSizeF  radii)

Sets the radii used for rounding the corners of shapes.

This is only used if type() is set to QgsTextBackgroundSettings::ShapeRectangle or QgsTextBackgroundSettings::ShapeSquare.

Parameters
radiiQSizeF representing horizontal and vertical radii for rounded corners. Units are specified through setRadiiUnit()
See also
radii()
setRadiiUnit()

Definition at line 496 of file qgstextrenderer.cpp.

◆ setRadiiMapUnitScale()

void QgsTextBackgroundSettings::setRadiiMapUnitScale ( const QgsMapUnitScale scale)

Sets the map unit scale object for the shape radii.

This is only used if the radiiUnit() is set to QgsUnitTypes::RenderMapUnit.

Parameters
scalescale for shape radii
See also
radiiMapUnitScale()
setRadiiUnit()

Definition at line 516 of file qgstextrenderer.cpp.

◆ setRadiiUnit()

void QgsTextBackgroundSettings::setRadiiUnit ( QgsUnitTypes::RenderUnit  units)

Sets the units used for the shape's radii.

Parameters
unitsradii units
See also
radiiUnit()
setRadii()

Definition at line 506 of file qgstextrenderer.cpp.

◆ setRotation()

void QgsTextBackgroundSettings::setRotation ( double  rotation)

Sets the rotation for the background shape, in degrees clockwise.

See also
rotation()
setRotationType()

Definition at line 456 of file qgstextrenderer.cpp.

◆ setRotationType()

void QgsTextBackgroundSettings::setRotationType ( QgsTextBackgroundSettings::RotationType  type)

Sets the method used for rotating the background shape.

Parameters
typerotation method
See also
rotationType()
setRotation()

Definition at line 446 of file qgstextrenderer.cpp.

◆ setSize()

void QgsTextBackgroundSettings::setSize ( QSizeF  size)

Sets the size of the background shape.

The meaning of the size depends on the current sizeType(), e.g., for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and height of the shape, for QgsTextBackgroundSettings::SizeBuffer the size will represent the horizontal and vertical margins to add to the text when calculating the size of the shape.

Parameters
sizeQSizeF representing horizontal and vertical size components for shape
See also
size()
setSizeType()

Definition at line 416 of file qgstextrenderer.cpp.

◆ setSizeMapUnitScale()

void QgsTextBackgroundSettings::setSizeMapUnitScale ( const QgsMapUnitScale scale)

Sets the map unit scale object for the shape size.

This is only used if the sizeUnit() is set to QgsUnitTypes::RenderMapUnit.

Parameters
scalescale for shape size
See also
sizeMapUnitScale()
setSizeUnit()

Definition at line 436 of file qgstextrenderer.cpp.

◆ setSizeType()

void QgsTextBackgroundSettings::setSizeType ( QgsTextBackgroundSettings::SizeType  type)

Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around text).

Parameters
typesize method
See also
sizeType()
setSize()

Definition at line 406 of file qgstextrenderer.cpp.

◆ setSizeUnit()

void QgsTextBackgroundSettings::setSizeUnit ( QgsUnitTypes::RenderUnit  unit)

Sets the units used for the shape's size.

This value has no meaning if the sizeType() is set to QgsTextBackgroundSettings::SizePercent.

Parameters
unitsize units
See also
sizeUnit()
setSizeType()
setSize()

Definition at line 426 of file qgstextrenderer.cpp.

◆ setStrokeColor()

void QgsTextBackgroundSettings::setStrokeColor ( const QColor &  color)

Sets the color used for outlining the background shape.

Parameters
colorstroke color
See also
strokeColor()
setFillColor()

Definition at line 556 of file qgstextrenderer.cpp.

◆ setStrokeWidth()

void QgsTextBackgroundSettings::setStrokeWidth ( double  width)

Sets the width of the shape's stroke (stroke).

Units are specified through setStrokeWidthUnit().

See also
strokeWidth()
setStrokeWidthUnit()

Definition at line 566 of file qgstextrenderer.cpp.

◆ setStrokeWidthMapUnitScale()

void QgsTextBackgroundSettings::setStrokeWidthMapUnitScale ( const QgsMapUnitScale scale)

Sets the map unit scale object for the shape stroke width.

This is only used if the strokeWidthUnit() is set to QgsUnitTypes::RenderMapUnit.

Parameters
scalescale for shape stroke width
See also
strokeWidthMapUnitScale()
setStrokeWidthUnit()

Definition at line 586 of file qgstextrenderer.cpp.

◆ setStrokeWidthUnit()

void QgsTextBackgroundSettings::setStrokeWidthUnit ( QgsUnitTypes::RenderUnit  units)

Sets the units used for the shape's stroke width.

Parameters
unitsstroke width units
See also
strokeWidthUnit()
setStrokeWidth()

Definition at line 576 of file qgstextrenderer.cpp.

◆ setSvgFile()

void QgsTextBackgroundSettings::setSvgFile ( const QString &  file)

Sets the path to the background SVG file.

This is only used if type() is set to QgsTextBackgroundSettings::ShapeSVG. The path must be absolute.

Parameters
fileAbsolute SVG file path
See also
svgFile()

Definition at line 396 of file qgstextrenderer.cpp.

◆ setType()

void QgsTextBackgroundSettings::setType ( QgsTextBackgroundSettings::ShapeType  type)

Sets the type of background shape to draw (e.g., square, ellipse, SVG).

Parameters
typeshape type
See also
type()

Definition at line 386 of file qgstextrenderer.cpp.

◆ size()

QSizeF QgsTextBackgroundSettings::size ( ) const

Returns the size of the background shape.

The meaning of the size depends on the current sizeType(), e.g., for size types of QgsTextBackgroundSettings::SizeFixed the size will represent the actual width and height of the shape, for QgsTextBackgroundSettings::SizeBuffer the size will represent the horizontal and vertical margins to add to the text when calculating the size of the shape.

See also
setSize()
sizeType()

Definition at line 411 of file qgstextrenderer.cpp.

◆ sizeMapUnitScale()

QgsMapUnitScale QgsTextBackgroundSettings::sizeMapUnitScale ( ) const

Returns the map unit scale object for the shape size.

This is only used if the sizeUnit() is set to QgsUnitTypes::RenderMapUnit.

See also
setSizeMapUnitScale()
sizeUnit()

Definition at line 431 of file qgstextrenderer.cpp.

◆ sizeType()

QgsTextBackgroundSettings::SizeType QgsTextBackgroundSettings::sizeType ( ) const

Returns the method used to determine the size of the background shape (e.g., fixed size or buffer around text).

See also
setSizeType()
size()

Definition at line 401 of file qgstextrenderer.cpp.

◆ sizeUnit()

QgsUnitTypes::RenderUnit QgsTextBackgroundSettings::sizeUnit ( ) const

Returns the units used for the shape's size.

This value has no meaning if the sizeType() is set to QgsTextBackgroundSettings::SizePercent.

See also
setSizeUnit()
sizeType()
size()

Definition at line 421 of file qgstextrenderer.cpp.

◆ strokeColor()

QColor QgsTextBackgroundSettings::strokeColor ( ) const

Returns the color used for outlining the background shape.

See also
setStrokeColor()
fillColor()

Definition at line 551 of file qgstextrenderer.cpp.

◆ strokeWidth()

double QgsTextBackgroundSettings::strokeWidth ( ) const

Returns the width of the shape's stroke (stroke).

Units are retrieved through strokeWidthUnit().

See also
setStrokeWidth()
strokeWidthUnit()

Definition at line 561 of file qgstextrenderer.cpp.

◆ strokeWidthMapUnitScale()

QgsMapUnitScale QgsTextBackgroundSettings::strokeWidthMapUnitScale ( ) const

Returns the map unit scale object for the shape stroke width.

This is only used if the strokeWidthUnit() is set to QgsUnitTypes::RenderMapUnit.

See also
setStrokeWidthMapUnitScale()
strokeWidthUnit()

Definition at line 581 of file qgstextrenderer.cpp.

◆ strokeWidthUnit()

QgsUnitTypes::RenderUnit QgsTextBackgroundSettings::strokeWidthUnit ( ) const

Returns the units used for the shape's stroke width.

See also
setStrokeWidthUnit()
strokeWidth()

Definition at line 571 of file qgstextrenderer.cpp.

◆ svgFile()

QString QgsTextBackgroundSettings::svgFile ( ) const

Returns the absolute path to the background SVG file, if set.

See also
setSvgFile()

Definition at line 391 of file qgstextrenderer.cpp.

◆ type()

QgsTextBackgroundSettings::ShapeType QgsTextBackgroundSettings::type ( ) const

Returns the type of background shape (e.g., square, ellipse, SVG).

See also
setType()

Definition at line 381 of file qgstextrenderer.cpp.

◆ writeXml()

QDomElement QgsTextBackgroundSettings::writeXml ( QDomDocument &  doc,
const QgsReadWriteContext context 
) const

Write settings into a DOM element.

See also
readXml()

Definition at line 865 of file qgstextrenderer.cpp.


The documentation for this class was generated from the following files: