libosmscout 1.1.1
Loading...
Searching...
No Matches
BatchMapPainter.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_MAP_BATCH_MAP_PAINTER_H
2#define OSMSCOUT_MAP_BATCH_MAP_PAINTER_H
3
4/*
5 This source is part of the libosmscout-map library
6 Copyright (C) 2023 Tim Teulings
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#include <vector>
24
26
28
29#include <osmscoutmap/MapData.h>
32
33namespace osmscout {
34
41 template <class PainterType>
43 protected:
44 std::vector<MapDataRef> data;
45 std::vector<PainterType> painters;
46
47 protected:
48
57 bool BatchPaintInternal(const Projection& projection,
58 const MapParameter& parameter)
59 {
60 bool success=true;
61 for (auto step=static_cast<size_t>(osmscout::RenderSteps::FirstStep);
62 step<=static_cast<size_t>(osmscout::RenderSteps::LastStep);
63 ++step){
64
65 for (size_t i=0;i<data.size(); ++i){
66 const MapData &d=*(data[i]);
67 auto renderStep=static_cast<RenderSteps>(step);
68 if (!painters[i]->Draw(projection,
69 parameter,
70 d,
71 renderStep,
72 renderStep)) {
73 success=false;
74 }
75 }
76 }
77 return success;
78 }
79
80 public:
81 explicit BatchMapPainter(size_t expectedCount)
82 {
83 data.reserve(expectedCount);
84 painters.reserve(expectedCount);
85 }
86
87 virtual ~BatchMapPainter() = default;
88
89 void AddData(const MapDataRef &d, PainterType &painter)
90 {
91 data.push_back(d);
92 painters.push_back(painter);
93 }
94 };
95
101}
102
103#endif
std::vector< MapDataRef > data
Definition BatchMapPainter.h:44
BatchMapPainter(size_t expectedCount)
Definition BatchMapPainter.h:81
bool BatchPaintInternal(const Projection &projection, const MapParameter &parameter)
Definition BatchMapPainter.h:57
void AddData(const MapDataRef &d, PainterType &painter)
Definition BatchMapPainter.h:89
virtual ~BatchMapPainter()=default
std::vector< PainterType > painters
Definition BatchMapPainter.h:45
Definition Projection.h:46
Definition Area.h:39
std::shared_ptr< MapData > MapDataRef
Definition MapData.h:63
RenderSteps
Definition MapPainter.h:64
@ LastStep
Definition MapPainter.h:92
@ FirstStep
Definition MapPainter.h:65