alaCarte Maps
Renderer for OpenStreetMap tiles
way_renderer.hpp
Go to the documentation of this file.
1 
21 #ifndef WAY_RENDERER_HPP
22 #define WAY_RENDERER_HPP
23 /*
24  * =====================================================================================
25  *
26  * Filename: way_renderer.hpp
27  *
28  * Description: Wrapper for way rendering operations.
29  *
30  * =====================================================================================
31  */
32 #include "settings.hpp"
33 
34 #include <cairo.h>
35 
36 #include "object_renderer.hpp"
37 
38 class Geodata;
39 class Node;
40 class Way;
41 class Style;
42 class Label;
43 class AssetCache;
44 
46 {
47 private:
48  cairo_path_t* path;
49  Way* way;
50 
51  void addWayPath(cairo_t* cr);
52  inline void setLineCap(cairo_t* cr, Style::LineCap cap)
53  {
54  switch(cap) {
55  case Style::CAP_NONE:
56  cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
57  break;
58  case Style::CAP_ROUND:
59  cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
60  break;
61  case Style::CAP_SQUARE:
62  cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE);
63  break;
64  }
65  }
66  inline void setLineJoin(cairo_t* cr, Style::LineJoin join)
67  {
68  switch(join) {
69  case Style::JOIN_MITER:
70  cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
71  break;
72  case Style::JOIN_BEVEL:
73  cairo_set_line_join(cr, CAIRO_LINE_JOIN_BEVEL);
74  break;
75  case Style::JOIN_ROUND:
76  cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
77  break;
78  }
79  }
80  bool getTextPosition(cairo_path_t* transformedPath, int width, FloatPoint& best, double& angle);
81  void getShieldPosition(cairo_path_t* transformedPath, std::list<FloatPoint>& positions);
82 
83 public:
84  WayRenderer(const shared_ptr<Geodata>& data,
85  WayId wid,
86  const Style* s,
87  const cairo_matrix_t* transform);
88  virtual ~WayRenderer();
89 
90  void fill(cairo_t* cr, AssetCache& cache);
91  void casing(cairo_t* cr);
92  void stroke(cairo_t* cr, AssetCache& cache);
93  void label(cairo_t* cr,
94  std::list<shared_ptr<Label> >& labels, AssetCache& cache);
95  void shield(cairo_t* cr,
96  std::list<shared_ptr<Shield> >& shields,
97  AssetCache& cache);
98 };
99 
100 #endif
void setLineCap(cairo_t *cr, Style::LineCap cap)
void casing(cairo_t *cr)
bool getTextPosition(cairo_path_t *transformedPath, int width, FloatPoint &best, double &angle)
Find the best fitting segment on a cairo path and return angle.
void stroke(cairo_t *cr, AssetCache &cache)
const cairo_matrix_t * transform
Definition: node.hpp:28
void fill(cairo_t *cr, AssetCache &cache)
cairo_path_t * path
const shared_ptr< Geodata > & data
Stores bounding box and style of a label that needs to be placed.
void label(cairo_t *cr, std::list< shared_ptr< Label > > &labels, AssetCache &cache)
void shield(cairo_t *cr, std::list< shared_ptr< Shield > > &shields, AssetCache &cache)
A Style stores the MapCSS properties for a single Node or Way, or a Relation of type multipolygon...
Definition: style.hpp:35
LineCap
Definition: style.hpp:43
WayRenderer(const shared_ptr< Geodata > &data, WayId wid, const Style *s, const cairo_matrix_t *transform)
void setLineJoin(cairo_t *cr, Style::LineJoin join)
LineJoin
Definition: style.hpp:48
void addWayPath(cairo_t *cr)
This file is part of alaCarte.
void getShieldPosition(cairo_path_t *transformedPath, std::list< FloatPoint > &positions)
Find the best fitting segment on a cairo path for a shield.
virtual ~WayRenderer()
Definition: way.hpp:31
const Style * s