libosmscout 0.1
Loading...
Searching...
No Matches
osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter > Class Template Reference

#include <LabelLayouter.h>

Classes

struct  LayoutJob
 Layout job initializes separate canvases for icons/symbols, labels and overlay labels. More...
 

Public Types

using ContourLabelType = ContourLabel< NativeGlyph >
 
using LabelInstanceType = LabelInstance< NativeGlyph, NativeLabel >
 
using LabelPtr = std::shared_ptr< LabelType >
 
using LabelType = Label< NativeGlyph, NativeLabel >
 

Public Member Functions

void AssertElementsInsideReach (const Projection &projection, const MapParameter &parameter, const Vertex2D &point, const std::vector< LabelData > &data, const LabelInstanceType &instance) const
 Debug check of the conservative bound the early decision uses: the rectangle of every element a label built has to stay inside the anchor plus the reach of the label.
 
bool CannotReachViewport (const Projection &projection, const MapParameter &parameter, const Vertex2D &point, const LabelData &data) const
 
bool CannotReachViewport (const Projection &projection, const MapParameter &parameter, const Vertex2D &point, const std::vector< LabelData > &data) const
 Returns true when no element of the label can intersect the layout viewport and when the label cannot suppress a label inside it, i.e.
 
const std::vector< ContourLabelType > & ContourLabels () const
 
template<class Painter >
void DrawLabels (const Projection &projection, const MapParameter &parameter, Painter *p)
 
template<class Painter >
void DrawTextLabels (const Projection &, const MapParameter &, Painter *) const
 
 LabelLayouter (TextLayouter *textLayouter)
 
double LabelReach (const Projection &projection, const MapParameter &parameter, const std::vector< LabelData > &data) const
 Upper bound [pixels] of the distance the elements of a label can reach from the anchor position of that label: the measured rectangle of an element stays inside the anchor plus this distance, and the overlap canvases of the layout mark an element with the widest padding of the frame around that rectangle.
 
const std::vector< LabelInstanceType > & Labels () const
 
void Layout (const Projection &projection, const MapParameter &parameter)
 
void ProcessLabel (const Projection &projection, const MapParameter &parameter, const Vertex2D &point, LabelInstanceType &instance, double &offset, const LabelData &data, double objectWidth)
 
void RegisterContourLabel (const Projection &projection, const MapParameter &parameter, bool basemap, const ObjectFileRef &ref, const PathLabelData &labelData, const LabelPath &labelPath)
 
void RegisterLabel (const Projection &projection, const MapParameter &parameter, bool basemap, const ObjectFileRef &ref, const Vertex2D &point, const LabelData &data, double objectWidth=10.0)
 
void RegisterLabel (const Projection &projection, const MapParameter &parameter, bool basemap, const ObjectFileRef &ref, const Vertex2D &point, const std::vector< LabelData > &data, double objectWidth=10.0)
 
void Reset ()
 
void SetLayoutOverlap (uint32_t overlap)
 
void SetViewport (const ScreenVectorRectangle &v)
 

Static Public Member Functions

static bool IsOverlay (const LabelData &labelData)
 

Detailed Description

template<class NativeGlyph, class NativeLabel, class TextLayouter>
class osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >
Template Parameters
NativeGlyph
NativeLabel
TextLayouter- class providing low level text layouting required methods:

// glyph bounding box relative to its base point DoubleScreenRectangle GlyphBoundingBox(const NativeGlyph &) const

// layout text for label std::shared_ptr<Label<NativeGlyph, NativeLabel>> Layout( const Projection& projection, const MapParameter& parameter, const std::string& text, double fontSize, double objectWidth, bool enableWrapping = false, bool contourLabel = false);

Member Typedef Documentation

◆ ContourLabelType

template<class NativeGlyph , class NativeLabel , class TextLayouter >
using osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::ContourLabelType = ContourLabel<NativeGlyph>

◆ LabelInstanceType

template<class NativeGlyph , class NativeLabel , class TextLayouter >
using osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::LabelInstanceType = LabelInstance<NativeGlyph, NativeLabel>

◆ LabelPtr

template<class NativeGlyph , class NativeLabel , class TextLayouter >
using osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::LabelPtr = std::shared_ptr<LabelType>

◆ LabelType

template<class NativeGlyph , class NativeLabel , class TextLayouter >
using osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::LabelType = Label<NativeGlyph, NativeLabel>

Constructor & Destructor Documentation

◆ LabelLayouter()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::LabelLayouter ( TextLayouter *  textLayouter)
inlineexplicit

Member Function Documentation

◆ AssertElementsInsideReach()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
void osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::AssertElementsInsideReach ( const Projection projection,
const MapParameter parameter,
const Vertex2D point,
const std::vector< LabelData > &  data,
const LabelInstanceType instance 
) const
inline

Debug check of the conservative bound the early decision uses: the rectangle of every element a label built has to stay inside the anchor plus the reach of the label.

If an element could leave that box, the early decision could drop a label that the drawing path of the label stage would draw, which would change the rendered output.

References osmscout::Vertex2D::GetX(), osmscout::Vertex2D::GetY(), osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::LabelReach(), and osmscout::LabelData::Text.

Referenced by osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::RegisterLabel(), and osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::RegisterLabel().

◆ CannotReachViewport() [1/2]

template<class NativeGlyph , class NativeLabel , class TextLayouter >
bool osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::CannotReachViewport ( const Projection projection,
const MapParameter parameter,
const Vertex2D point,
const LabelData data 
) const
inline

◆ CannotReachViewport() [2/2]

template<class NativeGlyph , class NativeLabel , class TextLayouter >
bool osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::CannotReachViewport ( const Projection projection,
const MapParameter parameter,
const Vertex2D point,
const std::vector< LabelData > &  data 
) const
inline

Returns true when no element of the label can intersect the layout viewport and when the label cannot suppress a label inside it, i.e.

when the label provably has no effect on the frame and does not have to be measured, stored or laid out.

References osmscout::Vertex2D::GetX(), osmscout::Vertex2D::GetY(), osmscout::ScreenVectorRectangle::Intersects(), and osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::LabelReach().

Referenced by osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::CannotReachViewport(), osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::RegisterLabel(), and osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::RegisterLabel().

◆ ContourLabels()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
const std::vector< ContourLabelType > & osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::ContourLabels ( ) const
inline

◆ DrawLabels()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
template<class Painter >
void osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::DrawLabels ( const Projection projection,
const MapParameter parameter,
Painter *  p 
)
inline
Template Parameters
Painterrequired methods:
void DrawSymbol(const Projection& projection,
                const MapParameter& parameter,
                onst Symbol& symbol,
                double x, double y) override;

void DrawIcon(const IconStyle* style,
              double centerX, double centerY,
              double width, double height) override;

void DrawLabel(const Projection& projection,
               const MapParameter& parameter,
               const DoubleScreenRectangle& labelRectangle,
               const LabelData& label,
               const std::shared_ptr<NativeLabel>& layout);

void DrawGlyphs(const Projection &projection,
                const MapParameter &parameter,
                const osmscout::PathTextStyleRef style,
                const std::vector<Glyph<NativeGlyph>> &glyphs);
Parameters
projection
parameter
p- painter pointer

References osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::ContourLabels(), osmscout::LabelData::Icon, osmscout::ScreenVectorRectangle::Intersects(), osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::IsOverlay(), osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::Labels(), osmscout::ScreenVectorRectangle::Set(), osmscout::LabelData::Symbol, and osmscout::LabelData::Text.

Referenced by osmscout::MapPainterAgg::DrawLabels(), osmscout::MapPainterCairo::DrawLabels(), osmscout::MapPainterQt::DrawLabels(), and osmscout::MapPainterSVG::DrawLabels().

◆ DrawTextLabels()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
template<class Painter >
void osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::DrawTextLabels ( const Projection ,
const MapParameter ,
Painter *   
) const
inline

◆ IsOverlay()

◆ LabelReach()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
double osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::LabelReach ( const Projection projection,
const MapParameter parameter,
const std::vector< LabelData > &  data 
) const
inline

Upper bound [pixels] of the distance the elements of a label can reach from the anchor position of that label: the measured rectangle of an element stays inside the anchor plus this distance, and the overlap canvases of the layout mark an element with the widest padding of the frame around that rectangle.

A label that is farther away from the layout viewport than this bound can therefore be dropped before it is measured, without changing which labels the drawing path draws and which labels the layout suppresses.

The bound is summed over the elements, because the elements of a label are stacked at its anchor, and it uses the conservative label extent bound of the label helper for text elements.

References osmscout::Projection::ConvertWidthToPixel(), osmscout::CountLabelWords(), osmscout::MapParameter::GetFontSize(), osmscout::GetLabelExtentBound(), osmscout::GetMaxLabelPaddingPixel(), and osmscout::LabelData::Text.

Referenced by osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::AssertElementsInsideReach(), and osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::CannotReachViewport().

◆ Labels()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
const std::vector< LabelInstanceType > & osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::Labels ( ) const
inline

◆ Layout()

◆ ProcessLabel()

◆ RegisterContourLabel()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
void osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::RegisterContourLabel ( const Projection projection,
const MapParameter parameter,
bool  basemap,
const ObjectFileRef ref,
const PathLabelData labelData,
const LabelPath labelPath 
)
inline

◆ RegisterLabel() [1/2]

◆ RegisterLabel() [2/2]

template<class NativeGlyph , class NativeLabel , class TextLayouter >
void osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::RegisterLabel ( const Projection projection,
const MapParameter parameter,
bool  basemap,
const ObjectFileRef ref,
const Vertex2D point,
const std::vector< LabelData > &  data,
double  objectWidth = 10.0 
)
inline

◆ Reset()

template<class NativeGlyph , class NativeLabel , class TextLayouter >
void osmscout::LabelLayouter< NativeGlyph, NativeLabel, TextLayouter >::Reset ( )
inline

◆ SetLayoutOverlap()

◆ SetViewport()


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