QGIS API Documentation  3.0.2-Girona (307d082)
Classes | 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 Member Functions

 QgsScaleBarRenderer ()=default
 Constructor for QgsScaleBarRenderer. More...
 
virtual ~QgsScaleBarRenderer ()=default
 
virtual 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. More...
 
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. More...
 
virtual QString name () const =0
 Returns the unique name for this style. More...
 

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. More...
 
QString firstLabelString (const QgsScaleBarSettings &settings) const
 Returns the text used for the first label in the scalebar. More...
 
double firstLabelXOffset (const QgsScaleBarSettings &settings) const
 Returns the x-offset (in millimeters) used for the first label in the scalebar. More...
 
QList< double > segmentPositions (const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings) const
 Returns a list of positions for each segment within the scalebar. More...
 
QList< double > segmentWidths (const QgsScaleBarRenderer::ScaleBarContext &scaleContext, const QgsScaleBarSettings &settings) const
 Returns a list of widths of each segment of the scalebar. More...
 

Detailed Description

Abstract base class for scale bar renderers.

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

Since
QGIS 3.0

Definition at line 37 of file qgsscalebarrenderer.h.

Constructor & Destructor Documentation

◆ QgsScaleBarRenderer()

QgsScaleBarRenderer::QgsScaleBarRenderer ( )
default

Constructor for QgsScaleBarRenderer.

◆ ~QgsScaleBarRenderer()

virtual QgsScaleBarRenderer::~QgsScaleBarRenderer ( )
virtualdefault

Member Function Documentation

◆ calculateBoxSize()

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.

Reimplemented in QgsNumericScaleBarRenderer.

Definition at line 92 of file qgsscalebarrenderer.cpp.

◆ 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 QgsTicksScaleBarRenderer, QgsSingleBoxScaleBarRenderer, QgsDoubleBoxScaleBarRenderer, and QgsNumericScaleBarRenderer.

◆ 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 23 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 113 of file qgsscalebarrenderer.cpp.

◆ firstLabelXOffset()

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

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

Definition at line 125 of file qgsscalebarrenderer.cpp.

◆ name()

virtual QString QgsScaleBarRenderer::name ( ) const
pure virtual

◆ segmentPositions()

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

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

Definition at line 131 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 154 of file qgsscalebarrenderer.cpp.


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