1#ifndef OSMSCOUT_MAP_MAPPAINTERDIRECTX_H
2#define OSMSCOUT_MAP_MAPPAINTERDIRECTX_H
23#include <unordered_map>
25#include <osmscoutmapdirectx/MapDirectXFeatures.h>
39#if defined(UNICODE) || defined(_UNICODE) || defined(_MBCS) || defined(MBCS)
71 IDWriteTextFormat* font,
72 const std::string& text);
80 friend DirectXLabelLayouter;
83 using FontMap = std::unordered_map<uint32_t, IDWriteTextFormat *>;
85 using BrushMap = std::unordered_map<uint32_t, ID2D1SolidColorBrush *>;
87 using GeometryMap = std::unordered_map<uint64_t, ID2D1PathGeometry *>;
88 GeometryMap m_Geometries;
89 GeometryMap m_Polygons;
90 using BitmapMap = std::unordered_map<uint64_t, ID2D1Bitmap *>;
92 using StrokeStyleMap = std::unordered_map<uint64_t, ID2D1StrokeStyle *>;
93 StrokeStyleMap m_StrokeStyles;
94 ID2D1StrokeStyle* m_dashLessStrokeStyle;
96 ID2D1Factory* m_pDirect2dFactory;
97 IDWriteFactory* m_pWriteFactory;
98 ID2D1RenderTarget* m_pRenderTarget;
99 IWICImagingFactory* m_pImagingFactory;
100 IDWriteRenderingParams* m_pRenderingParams;
103 std::map<double, double> fontHeightMap;
106 DirectXLabelLayouter m_LabelLayouter;
109 D2D1_COLOR_F GetColorValue(
const Color& color);
110 ID2D1SolidColorBrush* GetColorBrush(
const Color& color);
111 ID2D1SolidColorBrush* GetColorBrush(D2D1_COLOR_F& color);
112 ID2D1StrokeStyle* GetStrokeStyle(
const std::vector<double>& dash);
113 void _DrawText(
double x,
double y,
const Color& color,
const DirectXTextLayout& textLayout);
114 bool LoadBitmapFromFile(PCWSTR uri, ID2D1Bitmap **ppBitmap);
115 IDWriteTextFormat* GetFont(
const Projection& projection,
const MapParameter& parameter,
double fontSize);
120 const MapParameter ¶meter,
121 const MapData &data)
override;
125 const MapParameter ¶meter,
126 const MapData &data)
override;
130 const MapParameter ¶meter,
131 const MapData &data)
override;
135 const MapParameter ¶meter,
136 IconStyle &style)
override;
140 const MapParameter ¶meter,
141 double fontSize)
override;
144 const MapParameter& parameter,
147 const std::string& text);
150 const MapParameter ¶meter,
151 const FillStyle &style)
override;
154 const MapParameter& parameter,
160 const MapParameter ¶meter,
169 const MapParameter ¶meter,
170 const ObjectFileRef& ref,
171 const std::vector<LabelData> &labels,
172 const Vertex2D &position,
173 double objectWidth)
override;
179 const MapParameter ¶meter,
180 const ObjectFileRef& ref,
185 const MapParameter ¶meter,
186 const MapData &data)
override;
189 const Vertex2D& centerPos,
190 double width,
double height)
override;
193 const MapParameter ¶meter,
194 const Symbol &symbol,
195 const Vertex2D& screenPos,
196 double scaleFactor)
override;
199 const MapParameter ¶meter,
202 const std::vector<double> &dash,
203 LineStyle::CapStyle startCap,
204 LineStyle::CapStyle endCap,
205 const CoordBufferRange& coordRange)
override;
208 const MapParameter& parameter,
209 const std::string& text,
212 bool enableWrapping =
false,
213 bool contourLabel =
false);
227 const MapParameter ¶meter,
228 const Symbol &symbol,
232 const MapParameter ¶meter,
237 ID2D1Factory *pDirect2dFactory,
238 IDWriteFactory *pWriteFactory);
245 const MapParameter& parameter,
247 ID2D1RenderTarget* renderTarget);
#define OSMSCOUT_MAP_DIRECTX_API
Definition MapDirectXImportExport.h:45
Definition PathTextRenderer.h:68
Definition LabelLayouter.h:103
Definition LabelLayouter.h:57
Definition LabelLayouter.h:119
Definition LabelLayouter.h:230
Definition LabelPath.h:44
Definition MapPainterDirectX.h:61
FLOAT m_fSize
Definition MapPainterDirectX.h:64
DirectXTextLayout(IDWriteFactory *m_pWriteFactory, double fontSize, IDWriteTextFormat *font, const std::string &text)
IDWriteFactory * m_pWriteFactory
Definition MapPainterDirectX.h:63
IDWriteTextLayout * m_pDWriteTextLayout
Definition MapPainterDirectX.h:65
DWRITE_TEXT_METRICS m_TextMetrics
Definition MapPainterDirectX.h:66
bool DrawMap(const Projection &projection, const MapParameter ¶meter, const MapData &data, ID2D1RenderTarget *renderTarget)
void RegisterContourLabel(const Projection &projection, const MapParameter ¶meter, const ObjectFileRef &ref, const PathLabelData &label, const LabelPath &labelPath) override
void BeforeDrawing(const StyleConfig &styleConfig, const Projection &projection, const MapParameter ¶meter, const MapData &data) override
double GetFontHeight(const Projection &projection, const MapParameter ¶meter, double fontSize) override
osmscout::ScreenVectorRectangle GlyphBoundingBox(const DirectXNativeGlyph &glyph) const
~MapPainterDirectX() override
void DiscardDeviceResources()
Glyph< DirectXNativeGlyph > DirectXGlyph
Definition MapPainterDirectX.h:58
void DrawPath(const Projection &projection, const MapParameter ¶meter, const Color &color, double width, const std::vector< double > &dash, LineStyle::CapStyle startCap, LineStyle::CapStyle endCap, const CoordBufferRange &coordRange) override
bool HasIcon(const StyleConfig &styleConfig, const Projection &projection, const MapParameter ¶meter, IconStyle &style) override
void DrawGlyphs(const Projection &projection, const MapParameter ¶meter, const osmscout::PathTextStyleRef &style, const std::vector< osmscout::Glyph< DirectXNativeGlyph > > &glyphs)
void AfterDrawing(const StyleConfig &styleConfig, const Projection &projection, const MapParameter ¶meter, const MapData &data) override
void DrawContourSymbol(const Projection &projection, const MapParameter ¶meter, const Symbol &symbol, const ContourSymbolData &data) override
void DrawSymbol(const Projection &projection, const MapParameter ¶meter, const Symbol &symbol, const Vertex2D &screenPos, double scaleFactor) override
ScreenVectorRectangle GetTextDimension(const Projection &projection, const MapParameter ¶meter, double objectWidth, double fontSize, const std::string &text)
MapPainterDirectX(const StyleConfigRef &styleConfig, ID2D1Factory *pDirect2dFactory, IDWriteFactory *pWriteFactory)
void RegisterRegularLabel(const Projection &projection, const MapParameter ¶meter, const ObjectFileRef &ref, const std::vector< LabelData > &labels, const Vertex2D &position, double objectWidth) override
void DrawArea(const Projection &projection, const MapParameter ¶meter, const AreaData &area) override
std::shared_ptr< DirectXLabel > Layout(const Projection &projection, const MapParameter ¶meter, const std::string &text, double fontSize, double objectWidth, bool enableWrapping=false, bool contourLabel=false)
void DrawGround(const Projection &projection, const MapParameter ¶meter, const FillStyle &style) override
void AfterPreprocessing(const StyleConfig &styleConfig, const Projection &projection, const MapParameter ¶meter, const MapData &data) override
Label< DirectXNativeGlyph, DirectXTextLayout > DirectXLabel
Definition MapPainterDirectX.h:76
void DrawIcon(const IconStyle *style, const Vertex2D ¢erPos, double width, double height) override
void DrawLabels(const Projection &projection, const MapParameter ¶meter, const MapData &data) override
void DrawLabel(const Projection &projection, const MapParameter ¶meter, const ScreenVectorRectangle &labelRectangle, const LabelData &label, const DirectXTextLayout &textLayout)
MapPainter(const StyleConfigRef &styleConfig)
StyleConfigRef styleConfig
Reference to the style configuration to be used.
Definition MapPainter.h:250
Definition LabelLayouter.h:46
Definition Projection.h:46
Index selectors by type and level.
Definition StyleConfig.h:552
std::shared_ptr< TypeConfig > TypeConfigRef
Definition TypeConfig.h:1396
std::shared_ptr< PathTextStyle > PathTextStyleRef
Definition Styles.h:890
std::shared_ptr< StyleConfig > StyleConfigRef
Definition StyleConfig.h:859
Definition MapPainter.h:174
Definition MapPainter.h:200
Definition MapPainterDirectX.h:48
double height
Definition MapPainterDirectX.h:55
double width
Definition MapPainterDirectX.h:54
std::string character
Definition MapPainterDirectX.h:52
Definition LabelLayouterHelper.h:73