QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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...
 
Q_DECL_DEPRECATED double firstLabelXOffset (const QgsScaleBarSettings &settings) const
 Returns the x-offset (in millimeters) used for the first label in the scalebar. More...
 
double firstLabelXOffset (const QgsScaleBarSettings &settings, const QgsRenderContext &context) const
 Returns the x-offset (in render context painter units) 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 38 of file qgsscalebarrenderer.h.

Constructor & Destructor Documentation

QgsScaleBarRenderer::QgsScaleBarRenderer ( )
default

Constructor for QgsScaleBarRenderer.

virtual QgsScaleBarRenderer::~QgsScaleBarRenderer ( )
virtualdefault

Member Function Documentation

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 98 of file qgsscalebarrenderer.cpp.

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.

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 24 of file qgsscalebarrenderer.cpp.

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

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

Definition at line 121 of file qgsscalebarrenderer.cpp.

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

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

Deprecated:
Use the version with QgsRenderContext instead.

Definition at line 133 of file qgsscalebarrenderer.cpp.

double QgsScaleBarRenderer::firstLabelXOffset ( const QgsScaleBarSettings settings,
const QgsRenderContext context 
) 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 141 of file qgsscalebarrenderer.cpp.

virtual QString QgsScaleBarRenderer::name ( ) const
pure virtual
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 147 of file qgsscalebarrenderer.cpp.

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 171 of file qgsscalebarrenderer.cpp.


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