dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
core.h
Go to the documentation of this file.
1 
13 /*
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, see <http://www.gnu.org/licenses/>
26 */
27 #ifndef CORE_H
28 #define CORE_H
29 
30 #include "debugheader.h"
31 
32 #include "pointlatlng.h"
33 #include "mousewheelzoomtype.h"
34 #include "../core/size.h"
35 #include "../core/point.h"
36 
37 #include "../core/maptype.h"
38 #include "rectangle.h"
39 #include "QThreadPool"
40 #include "tilematrix.h"
41 #include <QQueue>
42 #include "loadtask.h"
43 #include "copyrightstrings.h"
44 #include "rectlatlng.h"
50 #include "../core/geodecoderstatus.h"
51 #include "../core/tlmaps.h"
52 #include "../core/diagnostics.h"
53 
54 #include <QSemaphore>
55 #include <QThread>
56 #include <QDateTime>
57 
58 #include <QObject>
59 #include "../core/corecommon.h"
60 
61 namespace mapcontrol
62 {
63  class TLMapControl;
64  class MapGraphicItem;
65 }
66 
67 namespace internals {
68 
69  class TLMAPWIDGET_EXPORT Core:public QObject,public QRunnable
70  {
71  Q_OBJECT
72 
73  friend class mapcontrol::TLMapControl;
75  public:
76  Core();
77  ~Core();
78  void run();
79  PointLatLng CurrentPosition()const{return currentPosition;}
80 
81  void SetCurrentPosition(const PointLatLng &value);
82 
83  core::Point GetcurrentPositionGPixel(){return currentPositionPixel;}
84  void SetcurrentPositionGPixel(const core::Point &value){currentPositionPixel=value;}
85 
86  core::Point GetrenderOffset(){return renderOffset;}
87  void SetrenderOffset(const core::Point &value){renderOffset=value;}
88 
89  core::Point GetcenterTileXYLocation(){return centerTileXYLocation;}
90  void SetcenterTileXYLocation(const core::Point &value){centerTileXYLocation=value;}
91 
92  core::Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;}
93  void SetcenterTileXYLocationLast(const core::Point &value){centerTileXYLocationLast=value;}
94 
95  core::Point GetdragPoint(){return dragPoint;}
96  void SetdragPoint(const core::Point &value){dragPoint=value;}
97 
98  core::Point GetmouseDown(){return mouseDown;}
99  void SetmouseDown(const core::Point &value){mouseDown=value;}
100 
101  core::Point GetmouseCurrent(){return mouseCurrent;}
102  void SetmouseCurrent(const core::Point &value){mouseCurrent=value;}
103 
104  core::Point GetmouseLastZoom(){return mouseLastZoom;}
105  void SetmouseLastZoom(const core::Point &value){mouseLastZoom=value;}
106 
107  MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;}
108  void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;}
109 
110  PointLatLng GetLastLocationInBounds(){return LastLocationInBounds;}
111  void SetLastLocationInBounds(const PointLatLng &value){LastLocationInBounds=value;}
112 
113  Size GetsizeOfMapArea(){return sizeOfMapArea;}
114  void SetsizeOfMapArea(const Size &value){sizeOfMapArea=value;}
115 
116  Size GetminOfTiles(){return minOfTiles;}
117  void SetminOfTiles(const Size &value){minOfTiles=value;}
118 
119  Size GetmaxOfTiles(){return maxOfTiles;}
120  void SetmaxOfTiles(const Size &value){maxOfTiles=value;}
121 
122  Rectangle GetTileRect(){return tileRect;}
123  void SettileRect(const Rectangle &value){tileRect=value;}
124 
125  core::Point GettilePoint(){return tilePoint;}
126  void SettilePoint(const core::Point &value){tilePoint=value;}
127 
128  Rectangle GetCurrentRegion(){return CurrentRegion;}
129  void SetCurrentRegion(const Rectangle &value){CurrentRegion=value;}
130 
132 
134  {
135  return projection;
136  }
138  {
139  projection=value;
140  tileRect=Rectangle(core::Point(0,0),value->TileSize());
141  }
142  bool IsDragging()const{return isDragging;}
143 
144  int Zoom()const{return zoom;}
145  void SetZoom(int const& value);
146 
147  int MaxZoom()const{return maxzoom;}
148 
149  void UpdateBounds();
150 
151  MapType::Types GetMapType(){return mapType;}
152  void SetMapType(MapType::Types const& value);
153 
154  void SetUserImageHorizontalScale(double hScale);
155  void SetUserImageVerticalScale(double vScale);
156  void SetUserImageLocation(QString mapLocation);
157 
158  void StartSystem();
159 
160  void UpdateCenterTileXYLocation();
161 
162  void OnMapSizeChanged(int const& width, int const& height);//TODO had as slot
163 
164  void OnMapClose();//TODO had as slot
165 
166  GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys);
167 
168  RectLatLng CurrentViewArea();
169 
170  PointLatLng FromLocalToLatLng(qint64 const& x, qint64 const& y);
171 
172  Point FromLatLngToLocal(PointLatLng const& latlng);
173 
174  int GetMaxZoomToFitRect(RectLatLng const& rect);
175 
176  void BeginDrag(core::Point const& pt);
177 
178  void EndDrag();
179 
180  void ReloadMap();
181 
182  void GoToCurrentPosition();
183 
184  void DragOffset(core::Point const& offset);
185 
186  void Drag(core::Point const& pt);
187 
188  void CancelAsyncTasks();
189 
190  void FindTilesAround(QList<core::Point> &list);
191 
192  void UpdateGroundResolution();
193 
195 
196  bool isStarted(){return started;}
197 
198  diagnostics GetDiagnostics();
199 
200  QList<UrlFactory::geoCodingStruct> GetAddressesFromCoordinates(PointLatLng coord, GeoCoderStatusCode::Types &status);
201  QList<UrlFactory::geoCodingStruct> GetCoordinatesFromAddress(const QString &address, GeoCoderStatusCode::Types &status);
202  double GetElevationFromCoordinates(PointLatLng coord, GeoCoderStatusCode::Types &status);
203  signals:
204  void OnCurrentPositionChanged(internals::PointLatLng point);
205  void OnTileLoadComplete();
206  void OnTilesStillToLoad(int number);
207  void OnTileLoadStart();
208  void OnMapDrag();
209  void OnMapZoomChanged();
210  void OnMapTypeChanged(MapType::Types type);
211  void OnEmptyTileError(int zoom, core::Point pos);
212  void OnNeedInvalidation();
213 
214  private:
215  bool started;
216  bool MouseWheelZooming;
217  void keepInBounds();
218  PointLatLng currentPosition;
219  core::Point currentPositionPixel;
220  core::Point renderOffset;
221  core::Point centerTileXYLocation;
222  core::Point centerTileXYLocationLast;
223  core::Point dragPoint;
224  Rectangle tileRect;
225  core::Point mouseDown;
226  bool CanDragMap;
227  core::Point mouseCurrent;
228  PointLatLng LastLocationInBounds;
229  core::Point mouseLastZoom;
230 
231  MouseWheelZoomType::Types mousewheelzoomtype;
232 
233  QString userImageLocation;
234  float userImageHorizontalScale;
235  float userImageVerticalScale;
236 
237  Size sizeOfMapArea;
238  Size minOfTiles;
239  Size maxOfTiles;
240 
241  core::Point tilePoint;
242 
243  Rectangle CurrentRegion;
244 
245  QQueue<LoadTask> tileLoadQueue;
246 
247  int zoom;
248 
249  PureProjection* projection;
250 
251  bool isDragging;
252 
253  QMutex MtileLoadQueue;
254 
255  QMutex Moverlays;
256 
257  QMutex MtileDrawingList;
258 #ifdef DEBUG_CORE
259  QMutex Mdebug;
260  static qlonglong debugcounter;
261 #endif
262  Size TooltipTextPadding;
263 
264  MapType::Types mapType;
265 
266  QSemaphore loaderLimit;
267 
268  QThreadPool ProcessLoadTaskCallback;
269  QMutex MtileToload;
270  int tilesToload;
271 
272  int maxzoom; //Max zoom level in quadtile format
273  QMutex MrunningThreads;
274  int runningThreads;
275  diagnostics diag;
276 
277  protected:
278  qint64 Width;
279  qint64 Height;
280  int pxRes100m; // 100 meters
281  int pxRes1000m; // 1km
282  int pxRes10km; // 10km
283  int pxRes100km; // 100km
284  int pxRes1000km; // 1000km
285  int pxRes5000km; // 5000km
286  void SetCurrentPositionGPixel(core::Point const& value){currentPositionPixel = value;}
287  void GoToCurrentPositionOnZoom();
288 
289  };
290 
291 }
292 #endif // CORE_H
Rectangle GetTileRect()
Definition: core.h:122
qint64 Height
Definition: core.h:279
core::Point GetdragPoint()
Definition: core.h:95
virtual Size TileSize() const =0
void SetProjection(PureProjection *value)
Definition: core.h:137
void SetCurrentPositionGPixel(core::Point const &value)
Definition: core.h:286
void SetsizeOfMapArea(const Size &value)
Definition: core.h:114
int pxRes100km
Definition: core.h:283
void SetmaxOfTiles(const Size &value)
Definition: core.h:120
void SetcurrentPositionGPixel(const core::Point &value)
Definition: core.h:84
PointLatLng CurrentPosition() const
Definition: core.h:79
int pxRes5000km
Definition: core.h:285
QList< core::Point > tileDrawingList
Definition: core.h:131
core::Point GetcenterTileXYLocationLast()
Definition: core.h:92
PointLatLng GetLastLocationInBounds()
Definition: core.h:110
core::Point GetcenterTileXYLocation()
Definition: core.h:89
void SettilePoint(const core::Point &value)
Definition: core.h:126
int MaxZoom() const
Definition: core.h:147
PureProjection * Projection()
Definition: core.h:133
void SetLastLocationInBounds(const PointLatLng &value)
Definition: core.h:111
Rectangle GetCurrentRegion()
Definition: core.h:128
bool IsDragging() const
Definition: core.h:142
core::Point GetrenderOffset()
Definition: core.h:86
core::Point GetcurrentPositionGPixel()
Definition: core.h:83
Size GetminOfTiles()
Definition: core.h:116
void SettileRect(const Rectangle &value)
Definition: core.h:123
void SetcenterTileXYLocation(const core::Point &value)
Definition: core.h:90
MapType::Types GetMapType()
Definition: core.h:151
int Zoom() const
Definition: core.h:144
The main graphicsItem used on the widget, contains the map and map logic.
Size GetsizeOfMapArea()
Definition: core.h:113
MouseWheelZoomType::Types GetMouseWheelZoomType()
Definition: core.h:107
core::Point GettilePoint()
Definition: core.h:125
int pxRes1000km
Definition: core.h:284
qint64 Width
Definition: core.h:278
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value)
Definition: core.h:108
core::Point GetmouseCurrent()
Definition: core.h:101
void SetrenderOffset(const core::Point &value)
Definition: core.h:87
core::Point GetmouseLastZoom()
Definition: core.h:104
void SetmouseDown(const core::Point &value)
Definition: core.h:99
void SetmouseCurrent(const core::Point &value)
Definition: core.h:102
void SetdragPoint(const core::Point &value)
Definition: core.h:96
TileMatrix Matrix
Definition: core.h:194
x
Definition: OPPlots.m:100
void SetcenterTileXYLocationLast(const core::Point &value)
Definition: core.h:93
bool isStarted()
Definition: core.h:196
int pxRes10km
Definition: core.h:282
int pxRes1000m
Definition: core.h:281
core::Point GetmouseDown()
Definition: core.h:98
int pxRes100m
Definition: core.h:280
void SetminOfTiles(const Size &value)
Definition: core.h:117
Size GetmaxOfTiles()
Definition: core.h:119
void SetmouseLastZoom(const core::Point &value)
Definition: core.h:105
void SetCurrentRegion(const Rectangle &value)
Definition: core.h:129
y
Definition: OPPlots.m:101