libosmscout  1.1.1
PlaneMapRenderer.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_PLANEMAPRENDERER_H
2 #define OSMSCOUT_CLIENT_QT_PLANEMAPRENDERER_H
3 
4 /*
5  OSMScout - a Qt backend for libosmscout and libosmscout-map
6  Copyright (C) 2010 Tim Teulings
7  Copyright (C) 2017 Lukas Karas
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #include <QObject>
25 #include <QSettings>
26 #include <QElapsedTimer>
27 
28 #include <osmscout/DataTileCache.h>
29 #include <osmscout/DBThread.h>
30 #include <osmscout/MapRenderer.h>
31 
33 
34 namespace osmscout {
35 
37  Q_OBJECT
38 
39 private:
40  double canvasOverrun; // scale of rendered canvas, relative to screen dimensions
42 
43  mutable QMutex lastRequestMutex;
44  MapViewStruct lastRequest;
45 
46  DBLoadJob *loadJob;
47 
48  QElapsedTimer lastRendering;
49  QTimer pendingRenderingTimer;
50 
51  QImage *currentImage;
52  size_t currentWidth;
53  size_t currentHeight;
54  osmscout::GeoCoord currentCoord;
55  double currentAngle; // radians
56  osmscout::Magnification currentMagnification;
57  size_t currentEpoch{0};
58 
59  mutable QMutex finishedMutex; // mutex protecting access to finished* variables
60  // to avoid deadlock, we should not acquire global mutex when holding finishedMutex
61  // reverse order is possible
62  QImage *finishedImage;
63  size_t finishedEpoch{0};
64  osmscout::GeoCoord finishedCoord;
65  double finishedAngle;
66  osmscout::Magnification finishedMagnification;
67  osmscout::FillStyleRef finishedUnknownFillStyle;
68 
74  size_t epoch{0};
75 
76 signals:
77  //void TileStatusChanged(const osmscout::TileRef& tile);
78  void TriggerMapRenderingSignal(const MapViewStruct& request, size_t requestEpoch);
79  void TriggerInitialRendering();
80 
81 public slots:
82  virtual void Initialize();
83  virtual void InvalidateVisualCache();
84  void DrawMap();
85  void HandleTileStatusChanged(QString dbPath,const osmscout::TileRef tile);
86  void onLoadJobFinished(QMap<QString,QMap<osmscout::TileKey,osmscout::TileRef>>);
87  void TriggerMapRendering(const MapViewStruct& request, size_t requestEpoch);
88  void HandleInitialRenderingRequest();
89  virtual void onStylesheetFilenameChanged();
90 
91 public:
92  PlaneMapRenderer(QThread *thread,
93  SettingsRef settings,
94  DBThreadRef dbThread,
95  QString iconDirectory);
96 
97  virtual ~PlaneMapRenderer();
98 
105  virtual bool RenderMap(QPainter& painter,
106  const MapViewStruct& request);
107 
108 private:
109  double computeScale(const osmscout::MercatorProjection &previousProjection,
110  const osmscout::MercatorProjection &currentProjection);
111 };
112 
113 }
114 
115 #endif /* OSMSCOUT_CLIENT_QT_PLANEMAPRENDERER_H */
std::shared_ptr< Settings > SettingsRef
Definition: Settings.h:171
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
std::shared_ptr< FillStyle > FillStyleRef
Definition: Styles.h:349
std::shared_ptr< Tile > TileRef
Definition: DataTileCache.h:443
Definition: Projection.h:333
Definition: PlaneMapRenderer.h:36
Definition: Area.h:38
Definition: MapRenderer.h:72
Definition: DBThread.h:51
std::shared_ptr< DBThread > DBThreadRef
Definition: DBThread.h:239
Setup internal state of renderer for executing next steps with current projection and parameters...
Definition: MapPainter.h:57
Definition: DBJob.h:58