libosmscout  1.1.1
MapPainterGDI.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_MAP_MAPPAINTERGDI_H
2 #define OSMSCOUT_MAP_MAPPAINTERGDI_H
3 
4 /*
5  This source is part of the libosmscout-map-gdi library
6  Copyright (C) 2020 Transporter
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #ifndef UNICODE
24 #define UNICODE
25 #endif
26 #define WIN32_LEAN_AND_MEAN
27 #ifndef NOMINMAX
28 #define NOMINMAX
29 #endif
30 #include <Windows.h>
31 
33 #include <osmscout/MapPainter.h>
34 
35 namespace osmscout {
36 
38  {
39  public:
40  struct NativeLabel {
41  std::wstring wstr;
42  void* font;
43  void* render;
44  };
45  struct NativeGlyph {
46  std::string character;
47  double width;
48  double height;
49  };
51 
52  private:
56  friend GdiLabelLayouter;
57 
58  GdiLabelLayouter m_labelLayouter;
59  void* m_pBuffer;
60  static ULONG_PTR m_gdiplusToken;
61  static DWORD m_gdiplusInstCount;
62 
63  private:
64  osmscout::DoubleRectangle GlyphBoundingBox(const NativeGlyph &glyph) const;
65 
66  std::shared_ptr<GdiLabel> Layout(const Projection& projection,
67  const MapParameter& parameter,
68  const std::string& text,
69  double fontSize,
70  double objectWidth,
71  bool enableWrapping = false,
72  bool contourLabel = false);
73 
74  void DrawLabel(const Projection& projection,
75  const MapParameter& parameter,
76  const DoubleRectangle& labelRectangle,
77  const LabelData& label,
78  const NativeLabel& layout);
79 
80  void DrawGlyphs(const Projection &projection,
81  const MapParameter &parameter,
82  const osmscout::PathTextStyleRef style,
83  const std::vector<GdiGlyph> &glyphs);
84 
85  protected:
86  void AfterPreprocessing(const StyleConfig& styleConfig,
87  const Projection& projection,
88  const MapParameter& parameter,
89  const MapData& data) override;
90 
91  void BeforeDrawing(const StyleConfig& styleConfig,
92  const Projection& projection,
93  const MapParameter& parameter,
94  const MapData& data) override;
95 
96  void AfterDrawing(const StyleConfig& styleConfig,
97  const Projection& projection,
98  const MapParameter& parameter,
99  const MapData& data) override;
100 
101  bool HasIcon(const StyleConfig& styleConfig,
102  const Projection& projection,
103  const MapParameter& parameter,
104  IconStyle& style) override;
105 
106  double GetFontHeight(const Projection& projection,
107  const MapParameter& parameter,
108  double fontSize) override;
109 
110  void DrawGround(const Projection& projection,
111  const MapParameter& parameter,
112  const FillStyle& style) override;
113 
118  virtual void RegisterRegularLabel(const Projection &projection,
119  const MapParameter &parameter,
120  const std::vector<LabelData> &labels,
121  const Vertex2D &position,
122  double objectWidth) override;
123 
127  virtual void RegisterContourLabel(const Projection &projection,
128  const MapParameter &parameter,
129  const PathLabelData &label,
130  const LabelPath &labelPath) override;
131 
132  virtual void DrawLabels(const Projection& projection,
133  const MapParameter& parameter,
134  const MapData& data) override;
135 
136  void DrawSymbol(const Projection& projection,
137  const MapParameter& parameter,
138  const Symbol& style,
139  double x, double y) override;
140 
141  void DrawIcon(const IconStyle* style,
142  double centerX, double centerY,
143  double width, double height) override;
144 
145  void DrawPath(const Projection& projection,
146  const MapParameter& parameter,
147  const Color& color,
148  double width,
149  const std::vector<double>& dash,
150  LineStyle::CapStyle startCap,
151  LineStyle::CapStyle endCap,
152  size_t transStart, size_t transEnd) override;
153 
154  void DrawWayOutline(const StyleConfig& styleConfig,
155  const Projection& projection,
156  const MapParameter& parameter,
157  const WayData& data);
158 
159  void DrawWay(const StyleConfig& styleConfig,
160  const Projection& projection,
161  const MapParameter& parameter,
162  const WayData& data) override;
163 
164  void DrawContourSymbol(const Projection& projection,
165  const MapParameter& parameter,
166  const Symbol& symbol,
167  double space,
168  size_t transStart, size_t transEnd) override;
169 
170  void DrawArea(const Projection& projection,
171  const MapParameter& parameter,
172  const AreaData& area) override;
173 
174  public:
175  bool DrawMap(const Projection& projection, const MapParameter& parameter, const MapData& data, HDC hdc, RECT paintRect);
176 
182  explicit MapPainterGDI(const StyleConfigRef& styleConfig);
183  ~MapPainterGDI() override;
184  };
185 }
186 
187 #endif
Definition: LabelLayouter.h:144
double height
Definition: MapPainterGDI.h:48
#define OSMSCOUT_MAP_GDI_API
Definition: MapGDIImportExport.h:43
Definition: Styles.h:884
Index selectors by type and level.
Definition: StyleConfig.h:553
void * render
Definition: MapPainterGDI.h:43
Definition: LabelLayouter.h:87
Definition: LabelLayouter.h:172
Definition: MapPainterGDI.h:45
void * font
Definition: MapPainterGDI.h:42
Definition: Projection.h:43
Definition: MapPainter.h:75
std::shared_ptr< PathTextStyle > PathTextStyleRef
Definition: Styles.h:877
Definition: Area.h:38
Definition: Styles.h:1135
std::wstring wstr
Definition: MapPainterGDI.h:41
Definition: MapPainterGDI.h:37
Definition: LabelPath.h:42
Definition: LabelLayouter.h:98
std::shared_ptr< StyleConfig > StyleConfigRef
Definition: StyleConfig.h:849
Definition: MapPainter.h:87
Definition: LabelLayouter.h:129
Definition: MapPainter.h:114
Definition: Styles.h:280
Definition: MapPainterGDI.h:40
Definition: MapPainter.h:179
std::string character
Definition: MapPainterGDI.h:46
double width
Definition: MapPainterGDI.h:47
CapStyle
Definition: Styles.h:69