QGIS/src/core/scalebar/qgsnumericscalebarrenderer.h
Nyall Dawson b40bc0c1f7 Refactor scale bar rendering
Move all scalebar rendering code out of composer and ensure that
all scalebar rendering is done independant of QgsComposerScaleBar

This allows scalebar rendering code to be reused by plugins
and by non-composer code.

Also rename QgsScaleBarStyle -> QgsScaleBarRenderer, (and all
subclasses too). This name better reflects what these classes do.
2017-04-26 11:46:51 +10:00

52 lines
2.0 KiB
C++

/***************************************************************************
qgsnumericscalebarrenderer.h
----------------------------
begin : June 2008
copyright : (C) 2008 by Marco Hugentobler
email : marco.hugentobler@karto.baug.ethz.ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSNUMERICSCALEBARRENDERER_H
#define QGSNUMERICSCALEBARRENDERER_H
#include "qgis_core.h"
#include "qgsscalebarrenderer.h"
#include <QString>
/**
* \class QgsNumericScaleBarRenderer
* \ingroup core
* A scale bar style that draws text in the form of '1:XXXXX'.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsNumericScaleBarRenderer: public QgsScaleBarRenderer
{
public:
QgsNumericScaleBarRenderer() = default;
QString name() const override { return QStringLiteral( "Numeric" ); }
void draw( QgsRenderContext &context,
const QgsScaleBarSettings &settings,
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const override;
QSizeF calculateBoxSize( const QgsScaleBarSettings &settings,
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const override;
private:
//! Returns the text for the scale bar or an empty string in case of error
QString scaleText( double scale ) const;
};
#endif // QGSNUMERICSCALEBARRENDERER_H