QGIS API Documentation 3.41.0-Master (d5b93354e9c)
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
QgsScaleBarRenderer Class Referenceabstract

Abstract base class for scale bar renderers. More...

#include <qgsscalebarrenderer.h>

Inheritance diagram for QgsScaleBarRenderer:
Inheritance graph
[legend]

Classes

struct  ScaleBarContext
 Contains parameters regarding scalebar calculations. More...
 

Public Types

enum class  Flag : int {
  FlagUsesLineSymbol = 1 << 0 , FlagUsesFillSymbol = 1 << 1 , FlagUsesAlternateFillSymbol = 1 << 2 , FlagRespectsUnits = 1 << 3 ,
  FlagRespectsMapUnitsPerScaleBarUnit = 1 << 4 , FlagUsesUnitLabel = 1 << 5 , FlagUsesSegments = 1 << 6 , FlagUsesLabelBarSpace = 1 << 7 ,
  FlagUsesLabelVerticalPlacement = 1 << 8 , FlagUsesLabelHorizontalPlacement = 1 << 8 , FlagUsesAlignment = 1 << 9 , FlagUsesSubdivisions = 1 << 10 ,
  FlagUsesDivisionSymbol = 1 << 11 , FlagUsesSubdivisionSymbol = 1 << 12 , FlagUsesSubdivisionsHeight = 1 << 13
}
 Flags which control scalebar renderer behavior. More...
 
typedef QFlags< FlagFlags
 

Public Member Functions

 QgsScaleBarRenderer ()=default
 
virtual ~QgsScaleBarRenderer ()=default
 
virtual bool applyDefaultSettings (QgsScaleBarSettings &settings) const
 Applies any default settings relating to the scalebar to the passed settings object.
 
virtual Q_DECL_DEPRECATED QSizeF calculateBoxSize (const QgsScaleBarSettings &settings, const QgsScaleBarRenderer::ScaleBarContext &scaleContext) const
 Calculates the required box size (in millimeters) for a scalebar using the specified settings and scaleContext.
 
virtual QSizeF calculateBoxSize (QgsRenderContext &context, const QgsScaleBarSettings &settings, const QgsScaleBarRenderer::ScaleBarContext &scaleContext) const
 Calculates the required box size (in millimeters) for a scalebar using the specified settings and scaleContext.
 
virtual QgsScaleBarRendererclone () const =0
 Returns a clone of the renderer.
 
virtual void draw (QgsRenderContext &context, const QgsScaleBarSettings &settings, const QgsScaleBarRenderer::ScaleBarContext &scaleContext) const =0
 Draws the scalebar using the specified settings and scaleContext to a destination render context.
 
virtual Flags flags () const
 Returns the scalebar rendering flags, which dictates the renderer's behavior.
 
virtual QString id () const =0
 Returns the unique ID for this renderer.
 
Q_DECL_DEPRECATED QString name () const
 Returns the unique name for this style.
 
virtual int sortKey () const
 Returns a sorting key value, where renderers with a lower sort key will be shown earlier in lists.
 
virtual QString visibleName () const =0
 Returns the user friendly, translated name for the renderer.
 

Protected Member Functions

void drawDefaultLabels (QgsRenderContext &context, const QgsScaleBarSettings &settings, const QgsScaleBarRenderer::ScaleBarContext &scaleContext) const
 Draws default scalebar labels using the specified settings and scaleContext to a destination render context.
 
QString firstLabelString (const QgsScaleBarSettings &settings) const
 Returns the text used for the first label in the scalebar.
 
Q_DECL_DEPRECATED double firstLabelXOffset (const QgsScaleBarSettings &settings) const
 Returns the x-offset (in millimeters) used for the first label in the scalebar.
 
double firstLabelXOffset (const QgsScaleBarSettings &settings, const QgsRenderContext &context, const ScaleBarContext &scaleContext) const
 Returns the x-offset (in render context painter units) used for the first label in the scalebar.
 
Q_DECL_DEPRECATED QList< double > segmentPositions (const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings) const
 Returns a list of positions for each segment within the scalebar.
 
QList< double > segmentPositions (QgsRenderContext &context, const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings) const
 Returns a list of positions for each segment within the scalebar.
 
QList< double > segmentWidths (const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings) const
 Returns a list of widths of each segment of the scalebar.
 

Detailed Description

Abstract base class for scale bar renderers.

Scalebar renderer subclasses implement custom drawing logic, with the possibility to implement custom labeling.

Definition at line 37 of file qgsscalebarrenderer.h.

Member Typedef Documentation

◆ Flags

typedef QFlags< Flag > QgsScaleBarRenderer::Flags

Definition at line 63 of file qgsscalebarrenderer.h.

Member Enumeration Documentation

◆ Flag

enum class QgsScaleBarRenderer::Flag : int
strong

Flags which control scalebar renderer behavior.

Since
QGIS 3.14
Enumerator
FlagUsesLineSymbol 

Renderer utilizes the scalebar line symbol (see QgsScaleBarSettings::lineSymbol() )

FlagUsesFillSymbol 

Renderer utilizes the scalebar fill symbol (see QgsScaleBarSettings::fillSymbol() )

FlagUsesAlternateFillSymbol 

Renderer utilizes the alternate scalebar fill symbol (see QgsScaleBarSettings::alternateFillSymbol() )

FlagRespectsUnits 

Renderer respects the QgsScaleBarSettings::units() setting.

FlagRespectsMapUnitsPerScaleBarUnit 

Renderer respects the QgsScaleBarSettings::mapUnitsPerScaleBarUnit() setting.

FlagUsesUnitLabel 

Renderer uses the QgsScaleBarSettings::unitLabel() setting.

FlagUsesSegments 

Renderer uses the scalebar segments.

FlagUsesLabelBarSpace 

Renderer uses the QgsScaleBarSettings::labelBarSpace() setting.

FlagUsesLabelVerticalPlacement 

Renderer uses the QgsScaleBarSettings::labelVerticalPlacement() setting.

FlagUsesLabelHorizontalPlacement 

Renderer uses the QgsScaleBarSettings::labelHorizontalPlacement() setting.

FlagUsesAlignment 

Renderer uses the QgsScaleBarSettings::alignment() setting.

FlagUsesSubdivisions 

Renderer uses the scalebar subdivisions (see QgsScaleBarSettings::numberOfSubdivisions() )

FlagUsesDivisionSymbol 

Renderer utilizes the scalebar division symbol (see QgsScaleBarSettings::divisionLineSymbol() )

FlagUsesSubdivisionSymbol 

Renderer utilizes the scalebar subdivision symbol (see QgsScaleBarSettings::subdivisionLineSymbol() )

FlagUsesSubdivisionsHeight 

Renderer uses the scalebar subdivisions height (see QgsScaleBarSettings::subdivisionsHeight() )

Definition at line 45 of file qgsscalebarrenderer.h.

Constructor & Destructor Documentation

◆ QgsScaleBarRenderer()

QgsScaleBarRenderer::QgsScaleBarRenderer ( )
default

◆ ~QgsScaleBarRenderer()

virtual QgsScaleBarRenderer::~QgsScaleBarRenderer ( )
virtualdefault

Member Function Documentation

◆ applyDefaultSettings()

bool QgsScaleBarRenderer::applyDefaultSettings ( QgsScaleBarSettings settings) const
virtual

Applies any default settings relating to the scalebar to the passed settings object.

Returns true if settings were applied.

Since
QGIS 3.14

Reimplemented in QgsHollowScaleBarRenderer.

Definition at line 296 of file qgsscalebarrenderer.cpp.

◆ calculateBoxSize() [1/2]

QSizeF QgsScaleBarRenderer::calculateBoxSize ( const QgsScaleBarSettings settings,
const QgsScaleBarRenderer::ScaleBarContext scaleContext 
) const
virtual

Calculates the required box size (in millimeters) for a scalebar using the specified settings and scaleContext.

Deprecated:
QGIS 3.40. Use the version with a QgsRenderContext instead.

Reimplemented in QgsNumericScaleBarRenderer.

Definition at line 168 of file qgsscalebarrenderer.cpp.

◆ calculateBoxSize() [2/2]

QSizeF QgsScaleBarRenderer::calculateBoxSize ( QgsRenderContext context,
const QgsScaleBarSettings settings,
const QgsScaleBarRenderer::ScaleBarContext scaleContext 
) const
virtual

Calculates the required box size (in millimeters) for a scalebar using the specified settings and scaleContext.

Since
QGIS 3.14

Reimplemented in QgsNumericScaleBarRenderer.

Definition at line 225 of file qgsscalebarrenderer.cpp.

◆ clone()

virtual QgsScaleBarRenderer * QgsScaleBarRenderer::clone ( ) const
pure virtual

Returns a clone of the renderer.

The caller takes ownership of the returned value.

Implemented in QgsDoubleBoxScaleBarRenderer, QgsHollowScaleBarRenderer, QgsNumericScaleBarRenderer, QgsSingleBoxScaleBarRenderer, QgsSteppedLineScaleBarRenderer, and QgsTicksScaleBarRenderer.

◆ draw()

virtual void QgsScaleBarRenderer::draw ( QgsRenderContext context,
const QgsScaleBarSettings settings,
const QgsScaleBarRenderer::ScaleBarContext scaleContext 
) const
pure virtual

Draws the scalebar using the specified settings and scaleContext to a destination render context.

Implemented in QgsDoubleBoxScaleBarRenderer, QgsHollowScaleBarRenderer, QgsNumericScaleBarRenderer, QgsSingleBoxScaleBarRenderer, QgsSteppedLineScaleBarRenderer, and QgsTicksScaleBarRenderer.

◆ drawDefaultLabels()

void QgsScaleBarRenderer::drawDefaultLabels ( QgsRenderContext context,
const QgsScaleBarSettings settings,
const QgsScaleBarRenderer::ScaleBarContext scaleContext 
) const
protected

Draws default scalebar labels using the specified settings and scaleContext to a destination render context.

Definition at line 30 of file qgsscalebarrenderer.cpp.

◆ firstLabelString()

QString QgsScaleBarRenderer::firstLabelString ( const QgsScaleBarSettings settings) const
protected

Returns the text used for the first label in the scalebar.

Definition at line 301 of file qgsscalebarrenderer.cpp.

◆ firstLabelXOffset() [1/2]

double QgsScaleBarRenderer::firstLabelXOffset ( const QgsScaleBarSettings settings) const
protected

Returns the x-offset (in millimeters) used for the first label in the scalebar.

Deprecated:
QGIS 3.40. Use the version with QgsRenderContext instead.

Definition at line 313 of file qgsscalebarrenderer.cpp.

◆ firstLabelXOffset() [2/2]

double QgsScaleBarRenderer::firstLabelXOffset ( const QgsScaleBarSettings settings,
const QgsRenderContext context,
const ScaleBarContext scaleContext 
) const
protected

Returns the x-offset (in render context painter units) used for the first label in the scalebar.

Since
QGIS 3.2

Definition at line 321 of file qgsscalebarrenderer.cpp.

◆ flags()

QgsScaleBarRenderer::Flags QgsScaleBarRenderer::flags ( ) const
virtual

Returns the scalebar rendering flags, which dictates the renderer's behavior.

Since
QGIS 3.14

Reimplemented in QgsDoubleBoxScaleBarRenderer, QgsHollowScaleBarRenderer, QgsNumericScaleBarRenderer, QgsSingleBoxScaleBarRenderer, QgsSteppedLineScaleBarRenderer, and QgsTicksScaleBarRenderer.

Definition at line 158 of file qgsscalebarrenderer.cpp.

◆ id()

virtual QString QgsScaleBarRenderer::id ( ) const
pure virtual

◆ name()

Q_DECL_DEPRECATED QString QgsScaleBarRenderer::name ( ) const
inline

Returns the unique name for this style.

Deprecated:
QGIS 3.40. Use id() instead.

Definition at line 107 of file qgsscalebarrenderer.h.

◆ segmentPositions() [1/2]

QList< double > QgsScaleBarRenderer::segmentPositions ( const QgsScaleBarRenderer::ScaleBarContext scaleContext,
const QgsScaleBarSettings settings 
) const
protected

Returns a list of positions for each segment within the scalebar.

Deprecated:
QGIS 3.40. Use the version with a QgsRenderContext instead.

Definition at line 343 of file qgsscalebarrenderer.cpp.

◆ segmentPositions() [2/2]

QList< double > QgsScaleBarRenderer::segmentPositions ( QgsRenderContext context,
const QgsScaleBarRenderer::ScaleBarContext scaleContext,
const QgsScaleBarSettings settings 
) const
protected

Returns a list of positions for each segment within the scalebar.

Since
QGIS 3.14

Definition at line 370 of file qgsscalebarrenderer.cpp.

◆ segmentWidths()

QList< double > QgsScaleBarRenderer::segmentWidths ( const QgsScaleBarRenderer::ScaleBarContext scaleContext,
const QgsScaleBarSettings settings 
) const
protected

Returns a list of widths of each segment of the scalebar.

Definition at line 398 of file qgsscalebarrenderer.cpp.

◆ sortKey()

int QgsScaleBarRenderer::sortKey ( ) const
virtual

Returns a sorting key value, where renderers with a lower sort key will be shown earlier in lists.

Generally, subclasses should return QgsScaleBarRenderer::sortKey() as their sorting key.

Reimplemented in QgsDoubleBoxScaleBarRenderer, QgsHollowScaleBarRenderer, QgsNumericScaleBarRenderer, QgsSingleBoxScaleBarRenderer, QgsSteppedLineScaleBarRenderer, and QgsTicksScaleBarRenderer.

Definition at line 163 of file qgsscalebarrenderer.cpp.

◆ visibleName()

virtual QString QgsScaleBarRenderer::visibleName ( ) const
pure virtual

Returns the user friendly, translated name for the renderer.

Since
QGIS 3.14

Implemented in QgsDoubleBoxScaleBarRenderer, QgsHollowScaleBarRenderer, QgsNumericScaleBarRenderer, QgsSingleBoxScaleBarRenderer, QgsSteppedLineScaleBarRenderer, and QgsTicksScaleBarRenderer.


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