mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-37 GCS/MapPlugin New map library-Fully qualified some classes instead of using "using namespace" to avoid ambiguities with other classes and namespaces already in use.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@778 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
ea3f3446e2
commit
5b323897f6
@ -29,7 +29,7 @@
|
|||||||
#define CACHEITEMQUEUE_H
|
#define CACHEITEMQUEUE_H
|
||||||
|
|
||||||
#include "maptype.h"
|
#include "maptype.h"
|
||||||
#include "point.h"
|
#include "Point.h"
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ namespace core {
|
|||||||
class CacheItemQueue
|
class CacheItemQueue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CacheItemQueue(const MapType::Types &Type,const Point &Pos,const QByteArray &Img,const int &Zoom);
|
CacheItemQueue(const MapType::Types &Type,const core::Point &Pos,const QByteArray &Img,const int &Zoom);
|
||||||
CacheItemQueue(){};
|
CacheItemQueue(){};
|
||||||
CacheItemQueue(const CacheItemQueue &cSource)
|
CacheItemQueue(const CacheItemQueue &cSource)
|
||||||
{
|
{
|
||||||
@ -50,10 +50,10 @@ namespace core {
|
|||||||
CacheItemQueue& operator= (const CacheItemQueue &cSource);
|
CacheItemQueue& operator= (const CacheItemQueue &cSource);
|
||||||
bool operator== (const CacheItemQueue &cSource);
|
bool operator== (const CacheItemQueue &cSource);
|
||||||
void SetMapType(const MapType::Types &value);
|
void SetMapType(const MapType::Types &value);
|
||||||
void SetPosition(const Point &value);
|
void SetPosition(const core::Point &value);
|
||||||
void SetImg(const QByteArray &value);
|
void SetImg(const QByteArray &value);
|
||||||
MapType::Types GetMapType();
|
MapType::Types GetMapType();
|
||||||
Point GetPosition();
|
core::Point GetPosition();
|
||||||
QByteArray GetImg();
|
QByteArray GetImg();
|
||||||
int GetZoom(){return zoom;};
|
int GetZoom(){return zoom;};
|
||||||
void SetZoom(const int &value) {zoom=value;};
|
void SetZoom(const int &value) {zoom=value;};
|
||||||
@ -61,7 +61,7 @@ namespace core {
|
|||||||
|
|
||||||
|
|
||||||
MapType::Types type;
|
MapType::Types type;
|
||||||
Point pos;
|
core::Point pos;
|
||||||
QByteArray img;
|
QByteArray img;
|
||||||
int zoom;
|
int zoom;
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,7 @@ namespace core {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
|
|
||||||
QByteArray GetImageFrom(const MapType::Types &type,const Point &pos,const int &zoom);
|
QByteArray GetImageFrom(const MapType::Types &type,const core::Point &pos,const int &zoom);
|
||||||
bool UseMemoryCache();//TODO
|
bool UseMemoryCache();//TODO
|
||||||
void setUseMemoryCache(const bool& value){useMemoryCache=value;}
|
void setUseMemoryCache(const bool& value){useMemoryCache=value;}
|
||||||
void setLanguage(const LanguageType::Types& language);//TODO
|
void setLanguage(const LanguageType::Types& language);//TODO
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#ifndef POINT_H
|
#ifndef OPOINT_H
|
||||||
#define POINT_H
|
#define OPOINT_H
|
||||||
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -50,8 +50,8 @@ namespace core {
|
|||||||
public:
|
public:
|
||||||
PureImageCache();
|
PureImageCache();
|
||||||
static bool CreateEmptyDB(const QString &file);
|
static bool CreateEmptyDB(const QString &file);
|
||||||
bool PutImageToCache(const QByteArray &tile,const MapType::Types &type,const Point &pos, const int &zoom);
|
bool PutImageToCache(const QByteArray &tile,const MapType::Types &type,const core::Point &pos, const int &zoom);
|
||||||
QByteArray GetImageFromCache(MapType::Types type, Point pos, int zoom);
|
QByteArray GetImageFromCache(MapType::Types type, core::Point pos, int zoom);
|
||||||
QString GtileCache();
|
QString GtileCache();
|
||||||
void setGtileCache(const QString &value);
|
void setGtileCache(const QString &value);
|
||||||
static bool ExportMapDataToDB(QString sourceFile, QString destFile);
|
static bool ExportMapDataToDB(QString sourceFile, QString destFile);
|
||||||
|
@ -40,17 +40,17 @@ namespace core {
|
|||||||
friend bool operator==(RawTile const& lhs,RawTile const& rhs);
|
friend bool operator==(RawTile const& lhs,RawTile const& rhs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RawTile(const MapType::Types &Type,const Point &Pos,const int &Zoom);
|
RawTile(const MapType::Types &Type,const core::Point &Pos,const int &Zoom);
|
||||||
QString ToString(void);
|
QString ToString(void);
|
||||||
MapType::Types Type();
|
MapType::Types Type();
|
||||||
Point Pos();
|
core::Point Pos();
|
||||||
int Zoom();
|
int Zoom();
|
||||||
void setType(const MapType::Types &value);
|
void setType(const MapType::Types &value);
|
||||||
void setPos(const Point &value);
|
void setPos(const core::Point &value);
|
||||||
void setZoom(const int &value);
|
void setZoom(const int &value);
|
||||||
private:
|
private:
|
||||||
MapType::Types type;
|
MapType::Types type;
|
||||||
Point pos;
|
core::Point pos;
|
||||||
int zoom;
|
int zoom;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ namespace core {
|
|||||||
private:
|
private:
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
Point p;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // SIZE_H
|
#endif // SIZE_H
|
||||||
|
@ -560,23 +560,23 @@ QString UrlFactory::MakeGeocoderUrl(QString keywords)
|
|||||||
QString key = keywords.replace(' ', '+');
|
QString key = keywords.replace(' ', '+');
|
||||||
return QString("http://maps.google.com/maps/geo?q=%1&output=csv&key=%2").arg(key).arg(GoogleMapsAPIKey);
|
return QString("http://maps.google.com/maps/geo?q=%1&output=csv&key=%2").arg(key).arg(GoogleMapsAPIKey);
|
||||||
}
|
}
|
||||||
QString UrlFactory::MakeReverseGeocoderUrl(PointLatLng &pt,const QString &language)
|
QString UrlFactory::MakeReverseGeocoderUrl(internals::PointLatLng &pt,const QString &language)
|
||||||
{
|
{
|
||||||
|
|
||||||
return QString("http://maps.google.com/maps/geo?hl=%1&ll=%2,%3&output=csv&key=%4").arg(language).arg(QString::number(pt.Lat())).arg(QString::number(pt.Lng())).arg(GoogleMapsAPIKey);
|
return QString("http://maps.google.com/maps/geo?hl=%1&ll=%2,%3&output=csv&key=%4").arg(language).arg(QString::number(pt.Lat())).arg(QString::number(pt.Lng())).arg(GoogleMapsAPIKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, GeoCoderStatusCode::Types &status)
|
internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, GeoCoderStatusCode::Types &status)
|
||||||
{
|
{
|
||||||
return GetLatLngFromGeocoderUrl(MakeGeocoderUrl(keywords),UseGeocoderCache,status);
|
return GetLatLngFromGeocoderUrl(MakeGeocoderUrl(keywords),UseGeocoderCache,status);
|
||||||
}
|
}
|
||||||
PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, GeoCoderStatusCode::Types &status)
|
internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, GeoCoderStatusCode::Types &status)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_URLFACTORY
|
#ifdef DEBUG_URLFACTORY
|
||||||
qDebug()<<"Entered GetLatLngFromGeocoderUrl:";
|
qDebug()<<"Entered GetLatLngFromGeocoderUrl:";
|
||||||
#endif //DEBUG_URLFACTORY
|
#endif //DEBUG_URLFACTORY
|
||||||
status = GeoCoderStatusCode::Unknow;
|
status = GeoCoderStatusCode::Unknow;
|
||||||
PointLatLng ret(0,0);
|
internals::PointLatLng ret(0,0);
|
||||||
QString urlEnd = url.right(url.indexOf("geo?q="));
|
QString urlEnd = url.right(url.indexOf("geo?q="));
|
||||||
urlEnd.replace( QRegExp(
|
urlEnd.replace( QRegExp(
|
||||||
"[^"
|
"[^"
|
||||||
@ -616,7 +616,7 @@ PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool
|
|||||||
#ifdef DEBUG_URLFACTORY
|
#ifdef DEBUG_URLFACTORY
|
||||||
qDebug()<<"GetLatLngFromGeocoderUrl::Network error";
|
qDebug()<<"GetLatLngFromGeocoderUrl::Network error";
|
||||||
#endif //DEBUG_URLFACTORY
|
#endif //DEBUG_URLFACTORY
|
||||||
return PointLatLng(0,0);
|
return internals::PointLatLng(0,0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_URLFACTORY
|
#ifdef DEBUG_URLFACTORY
|
||||||
@ -648,7 +648,7 @@ PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool
|
|||||||
double lat = QString(values[2]).toDouble();
|
double lat = QString(values[2]).toDouble();
|
||||||
double lng = QString(values[3]).toDouble();
|
double lng = QString(values[3]).toDouble();
|
||||||
|
|
||||||
ret = PointLatLng(lat, lng);
|
ret = internals::PointLatLng(lat, lng);
|
||||||
#ifdef DEBUG_URLFACTORY
|
#ifdef DEBUG_URLFACTORY
|
||||||
qDebug()<<"Lat="<<lat<<" Lng="<<lng;
|
qDebug()<<"Lat="<<lat<<" Lng="<<lng;
|
||||||
#endif //DEBUG_URLFACTORY
|
#endif //DEBUG_URLFACTORY
|
||||||
@ -658,7 +658,7 @@ PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Placemark UrlFactory::GetPlacemarkFromGeocoder(PointLatLng location)
|
Placemark UrlFactory::GetPlacemarkFromGeocoder(internals::PointLatLng location)
|
||||||
{
|
{
|
||||||
return GetPlacemarkFromReverseGeocoderUrl(MakeReverseGeocoderUrl(location, LanguageStr), UsePlacemarkCache);
|
return GetPlacemarkFromReverseGeocoderUrl(MakeReverseGeocoderUrl(location, LanguageStr), UsePlacemarkCache);
|
||||||
}
|
}
|
||||||
@ -744,7 +744,7 @@ Placemark UrlFactory::GetPlacemarkFromReverseGeocoderUrl(const QString &url, con
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
double UrlFactory::GetDistance(PointLatLng p1, PointLatLng p2)
|
double UrlFactory::GetDistance(internals::PointLatLng p1, internals::PointLatLng p2)
|
||||||
{
|
{
|
||||||
double dLat1InRad = p1.Lat() * (M_PI / 180);
|
double dLat1InRad = p1.Lat() * (M_PI / 180);
|
||||||
double dLong1InRad = p1.Lng() * (M_PI / 180);
|
double dLong1InRad = p1.Lng() * (M_PI / 180);
|
||||||
|
@ -45,8 +45,6 @@
|
|||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include "cmath"
|
#include "cmath"
|
||||||
|
|
||||||
using namespace internals;
|
|
||||||
|
|
||||||
namespace core {
|
namespace core {
|
||||||
class UrlFactory: public QObject,public ProviderStrings
|
class UrlFactory: public QObject,public ProviderStrings
|
||||||
{
|
{
|
||||||
@ -59,13 +57,13 @@ namespace core {
|
|||||||
QNetworkProxy Proxy;
|
QNetworkProxy Proxy;
|
||||||
UrlFactory();
|
UrlFactory();
|
||||||
~UrlFactory();
|
~UrlFactory();
|
||||||
QString MakeImageUrl(const MapType::Types &type,const Point &pos,const int &zoom,const QString &language);
|
QString MakeImageUrl(const MapType::Types &type,const core::Point &pos,const int &zoom,const QString &language);
|
||||||
PointLatLng GetLatLngFromGeodecoder(const QString &keywords,GeoCoderStatusCode::Types &status);
|
internals::PointLatLng GetLatLngFromGeodecoder(const QString &keywords,GeoCoderStatusCode::Types &status);
|
||||||
Placemark GetPlacemarkFromGeocoder(PointLatLng location);
|
Placemark GetPlacemarkFromGeocoder(internals::PointLatLng location);
|
||||||
int Timeout;
|
int Timeout;
|
||||||
private:
|
private:
|
||||||
void GetSecGoogleWords(const Point &pos, QString &sec1, QString &sec2);
|
void GetSecGoogleWords(const core::Point &pos, QString &sec1, QString &sec2);
|
||||||
int GetServerNum(const Point &pos,const int &max) const;
|
int GetServerNum(const core::Point &pos,const int &max) const;
|
||||||
void TryCorrectGoogleVersions();
|
void TryCorrectGoogleVersions();
|
||||||
bool isCorrectedGoogleVersions;
|
bool isCorrectedGoogleVersions;
|
||||||
QString TileXYToQuadKey(const int &tileX,const int &tileY,const int &levelOfDetail) const;
|
QString TileXYToQuadKey(const int &tileX,const int &tileY,const int &levelOfDetail) const;
|
||||||
@ -73,7 +71,7 @@ namespace core {
|
|||||||
bool UseGeocoderCache; //TODO GetSet
|
bool UseGeocoderCache; //TODO GetSet
|
||||||
bool UsePlacemarkCache;//TODO GetSet
|
bool UsePlacemarkCache;//TODO GetSet
|
||||||
static const double EarthRadiusKm = 6378.137; // WGS-84
|
static const double EarthRadiusKm = 6378.137; // WGS-84
|
||||||
double GetDistance(PointLatLng p1,PointLatLng p2);
|
double GetDistance(internals::PointLatLng p1,internals::PointLatLng p2);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static short timelapse;
|
static short timelapse;
|
||||||
@ -81,8 +79,8 @@ namespace core {
|
|||||||
bool IsCorrectGoogleVersions();
|
bool IsCorrectGoogleVersions();
|
||||||
void setIsCorrectGoogleVersions(bool value);
|
void setIsCorrectGoogleVersions(bool value);
|
||||||
QString MakeGeocoderUrl(QString keywords);
|
QString MakeGeocoderUrl(QString keywords);
|
||||||
QString MakeReverseGeocoderUrl(PointLatLng &pt,const QString &language);
|
QString MakeReverseGeocoderUrl(internals::PointLatLng &pt,const QString &language);
|
||||||
PointLatLng GetLatLngFromGeocoderUrl(const QString &url,const bool &useCache, GeoCoderStatusCode::Types &status);
|
internals::PointLatLng GetLatLngFromGeocoderUrl(const QString &url,const bool &useCache, GeoCoderStatusCode::Types &status);
|
||||||
Placemark GetPlacemarkFromReverseGeocoderUrl(const QString &url,const bool &useCache);
|
Placemark GetPlacemarkFromReverseGeocoderUrl(const QString &url,const bool &useCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "../internals/pointlatlng.h"
|
#include "../internals/pointlatlng.h"
|
||||||
#include "mousewheelzoomtype.h"
|
#include "mousewheelzoomtype.h"
|
||||||
#include "../core/size.h"
|
#include "../core/size.h"
|
||||||
|
#include "../core/point.h"
|
||||||
|
|
||||||
#include "../core/maptype.h"
|
#include "../core/maptype.h"
|
||||||
#include "rectangle.h"
|
#include "rectangle.h"
|
||||||
#include "QThreadPool"
|
#include "QThreadPool"
|
||||||
@ -74,29 +76,29 @@ public:
|
|||||||
PointLatLng CurrentPosition()const{return currentPosition;};
|
PointLatLng CurrentPosition()const{return currentPosition;};
|
||||||
void SetCurrentPosition(const PointLatLng &value);
|
void SetCurrentPosition(const PointLatLng &value);
|
||||||
|
|
||||||
Point GetcurrentPositionGPixel(){return currentPositionPixel;};
|
core::Point GetcurrentPositionGPixel(){return currentPositionPixel;};
|
||||||
void SetcurrentPositionGPixel(const Point &value){currentPositionPixel=value;};
|
void SetcurrentPositionGPixel(const core::Point &value){currentPositionPixel=value;};
|
||||||
|
|
||||||
Point GetrenderOffset(){return renderOffset;};
|
core::Point GetrenderOffset(){return renderOffset;};
|
||||||
void SetrenderOffset(const Point &value){renderOffset=value;};
|
void SetrenderOffset(const core::Point &value){renderOffset=value;};
|
||||||
|
|
||||||
Point GetcenterTileXYLocation(){return centerTileXYLocation;};
|
core::Point GetcenterTileXYLocation(){return centerTileXYLocation;};
|
||||||
void SetcenterTileXYLocation(const Point &value){centerTileXYLocation=value;};
|
void SetcenterTileXYLocation(const core::Point &value){centerTileXYLocation=value;};
|
||||||
|
|
||||||
Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;};
|
core::Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;};
|
||||||
void SetcenterTileXYLocationLast(const Point &value){centerTileXYLocationLast=value;};
|
void SetcenterTileXYLocationLast(const core::Point &value){centerTileXYLocationLast=value;};
|
||||||
|
|
||||||
Point GetdragPoint(){return dragPoint;};
|
core::Point GetdragPoint(){return dragPoint;};
|
||||||
void SetdragPoint(const Point &value){dragPoint=value;};
|
void SetdragPoint(const core::Point &value){dragPoint=value;};
|
||||||
|
|
||||||
Point GetmouseDown(){return mouseDown;};
|
core::Point GetmouseDown(){return mouseDown;};
|
||||||
void SetmouseDown(const Point &value){mouseDown=value;};
|
void SetmouseDown(const core::Point &value){mouseDown=value;};
|
||||||
|
|
||||||
Point GetmouseCurrent(){return mouseCurrent;};
|
core::Point GetmouseCurrent(){return mouseCurrent;};
|
||||||
void SetmouseCurrent(const Point &value){mouseCurrent=value;};
|
void SetmouseCurrent(const core::Point &value){mouseCurrent=value;};
|
||||||
|
|
||||||
Point GetmouseLastZoom(){return mouseLastZoom;};
|
core::Point GetmouseLastZoom(){return mouseLastZoom;};
|
||||||
void SetmouseLastZoom(const Point &value){mouseLastZoom=value;};
|
void SetmouseLastZoom(const core::Point &value){mouseLastZoom=value;};
|
||||||
|
|
||||||
MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;};
|
MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;};
|
||||||
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;};
|
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;};
|
||||||
@ -116,13 +118,13 @@ public:
|
|||||||
Rectangle GettileRect(){return tileRect;}
|
Rectangle GettileRect(){return tileRect;}
|
||||||
void SettileRect(const Rectangle &value){tileRect=value;}
|
void SettileRect(const Rectangle &value){tileRect=value;}
|
||||||
|
|
||||||
Point GettilePoint(){return tilePoint;}
|
core::Point GettilePoint(){return tilePoint;}
|
||||||
void SettilePoint(const Point &value){tilePoint=value;}
|
void SettilePoint(const core::Point &value){tilePoint=value;}
|
||||||
|
|
||||||
Rectangle GetCurrentRegion(){return CurrentRegion;}
|
Rectangle GetCurrentRegion(){return CurrentRegion;}
|
||||||
void SetCurrentRegion(const Rectangle &value){CurrentRegion=value;}
|
void SetCurrentRegion(const Rectangle &value){CurrentRegion=value;}
|
||||||
|
|
||||||
QList<Point> tileDrawingList;
|
QList<core::Point> tileDrawingList;
|
||||||
|
|
||||||
PureProjection* Projection()
|
PureProjection* Projection()
|
||||||
{
|
{
|
||||||
@ -131,7 +133,7 @@ public:
|
|||||||
void SetProjection(PureProjection* value)
|
void SetProjection(PureProjection* value)
|
||||||
{
|
{
|
||||||
projection=value;
|
projection=value;
|
||||||
tileRect=Rectangle(Point(0,0),value->TileSize());
|
tileRect=Rectangle(core::Point(0,0),value->TileSize());
|
||||||
}
|
}
|
||||||
bool IsDragging()const{return isDragging;}
|
bool IsDragging()const{return isDragging;}
|
||||||
|
|
||||||
@ -164,7 +166,7 @@ public:
|
|||||||
|
|
||||||
int GetMaxZoomToFitRect(RectLatLng const& rect);
|
int GetMaxZoomToFitRect(RectLatLng const& rect);
|
||||||
|
|
||||||
void BeginDrag(Point const& pt);
|
void BeginDrag(core::Point const& pt);
|
||||||
|
|
||||||
void EndDrag();
|
void EndDrag();
|
||||||
|
|
||||||
@ -174,13 +176,13 @@ public:
|
|||||||
|
|
||||||
bool MouseWheelZooming;
|
bool MouseWheelZooming;
|
||||||
|
|
||||||
void DragOffset(Point const& offset);
|
void DragOffset(core::Point const& offset);
|
||||||
|
|
||||||
void Drag(Point const& pt);
|
void Drag(core::Point const& pt);
|
||||||
|
|
||||||
void CancelAsyncTasks();
|
void CancelAsyncTasks();
|
||||||
|
|
||||||
void FindTilesAround(QList<Point> &list);
|
void FindTilesAround(QList<core::Point> &list);
|
||||||
|
|
||||||
void UpdateGroundResolution();
|
void UpdateGroundResolution();
|
||||||
|
|
||||||
@ -196,24 +198,24 @@ signals:
|
|||||||
void OnMapDrag();
|
void OnMapDrag();
|
||||||
void OnMapZoomChanged();
|
void OnMapZoomChanged();
|
||||||
void OnMapTypeChanged(MapType::Types type);
|
void OnMapTypeChanged(MapType::Types type);
|
||||||
void OnEmptyTileError(int zoom, Point pos);
|
void OnEmptyTileError(int zoom, core::Point pos);
|
||||||
void OnNeedInvalidation();
|
void OnNeedInvalidation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
PointLatLng currentPosition;
|
PointLatLng currentPosition;
|
||||||
Point currentPositionPixel;
|
core::Point currentPositionPixel;
|
||||||
Point renderOffset;
|
core::Point renderOffset;
|
||||||
Point centerTileXYLocation;
|
core::Point centerTileXYLocation;
|
||||||
Point centerTileXYLocationLast;
|
core::Point centerTileXYLocationLast;
|
||||||
Point dragPoint;
|
core::Point dragPoint;
|
||||||
Rectangle tileRect;
|
Rectangle tileRect;
|
||||||
Point mouseDown;
|
core::Point mouseDown;
|
||||||
bool CanDragMap;
|
bool CanDragMap;
|
||||||
Point mouseCurrent;
|
core::Point mouseCurrent;
|
||||||
PointLatLng LastLocationInBounds;
|
PointLatLng LastLocationInBounds;
|
||||||
Point mouseLastZoom;
|
core::Point mouseLastZoom;
|
||||||
|
|
||||||
MouseWheelZoomType::Types mousewheelzoomtype;
|
MouseWheelZoomType::Types mousewheelzoomtype;
|
||||||
|
|
||||||
@ -224,7 +226,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Point tilePoint;
|
core::Point tilePoint;
|
||||||
|
|
||||||
Rectangle CurrentRegion;
|
Rectangle CurrentRegion;
|
||||||
|
|
||||||
@ -265,7 +267,7 @@ protected:
|
|||||||
int pxRes100km; // 100km
|
int pxRes100km; // 100km
|
||||||
int pxRes1000km; // 1000km
|
int pxRes1000km; // 1000km
|
||||||
int pxRes5000km; // 5000km
|
int pxRes5000km; // 5000km
|
||||||
void SetCurrentPositionGPixel(Point const& value){currentPositionPixel = value;}
|
void SetCurrentPositionGPixel(core::Point const& value){currentPositionPixel = value;}
|
||||||
void GoToCurrentPositionOnZoom();
|
void GoToCurrentPositionOnZoom();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,7 @@ struct LoadTask
|
|||||||
{
|
{
|
||||||
friend bool operator==(LoadTask const& lhs,LoadTask const& rhs);
|
friend bool operator==(LoadTask const& lhs,LoadTask const& rhs);
|
||||||
public:
|
public:
|
||||||
Point Pos;
|
core::Point Pos;
|
||||||
int Zoom;
|
int Zoom;
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ struct LoadTask
|
|||||||
}
|
}
|
||||||
LoadTask()
|
LoadTask()
|
||||||
{
|
{
|
||||||
Pos=Point(-1,-1);
|
Pos=core::Point(-1,-1);
|
||||||
Zoom=-1;
|
Zoom=-1;
|
||||||
}
|
}
|
||||||
bool HasValue()
|
bool HasValue()
|
||||||
|
@ -71,9 +71,9 @@ Point LKS94Projection::FromLatLngToPixel(double lat, double lng, int const& zoo
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointLatLng LKS94Projection::FromPixelToLatLng(int const& x, int const& y, int const& zoom)
|
internals::PointLatLng LKS94Projection::FromPixelToLatLng(int const& x, int const& y, int const& zoom)
|
||||||
{
|
{
|
||||||
PointLatLng ret;// = PointLatLng::Empty;
|
internals::PointLatLng ret;// = internals::PointLatLng::Empty;
|
||||||
|
|
||||||
double res = GetTileMatrixResolution(zoom);
|
double res = GetTileMatrixResolution(zoom);
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "cmath"
|
#include "cmath"
|
||||||
#include "../pureprojection.h"
|
#include "../pureprojection.h"
|
||||||
|
|
||||||
using namespace internals;
|
|
||||||
|
|
||||||
namespace projections {
|
namespace projections {
|
||||||
class LKS94Projection:public internals::PureProjection
|
class LKS94Projection:public internals::PureProjection
|
||||||
@ -43,8 +42,8 @@ public:
|
|||||||
virtual Size TileSize() const;
|
virtual Size TileSize() const;
|
||||||
virtual double Axis() const;
|
virtual double Axis() const;
|
||||||
virtual double Flattening() const;
|
virtual double Flattening() const;
|
||||||
virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
virtual core::Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
||||||
virtual PointLatLng FromPixelToLatLng(int const& x, int const& y, int const& zoom);
|
virtual internals::PointLatLng FromPixelToLatLng(int const& x, int const& y, int const& zoom);
|
||||||
virtual double GetGroundResolution(int const& zoom, double const& latitude);
|
virtual double GetGroundResolution(int const& zoom, double const& latitude);
|
||||||
virtual Size GetTileMatrixMinXY(int const& zoom);
|
virtual Size GetTileMatrixMinXY(int const& zoom);
|
||||||
virtual Size GetTileMatrixMaxXY(int const& zoom);
|
virtual Size GetTileMatrixMaxXY(int const& zoom);
|
||||||
|
@ -53,9 +53,9 @@ Point MercatorProjection::FromLatLngToPixel(double lat, double lng, const int &z
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
PointLatLng MercatorProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
|
internals::PointLatLng MercatorProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
|
||||||
{
|
{
|
||||||
PointLatLng ret;// = PointLatLng.Empty;
|
internals::PointLatLng ret;// = internals::PointLatLng.Empty;
|
||||||
|
|
||||||
Size s = GetTileMatrixSizePixel(zoom);
|
Size s = GetTileMatrixSizePixel(zoom);
|
||||||
double mapSizeX = s.Width();
|
double mapSizeX = s.Width();
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#define MERCATORPROJECTION_H
|
#define MERCATORPROJECTION_H
|
||||||
#include "../pureprojection.h"
|
#include "../pureprojection.h"
|
||||||
|
|
||||||
using namespace internals;
|
|
||||||
|
|
||||||
namespace projections {
|
namespace projections {
|
||||||
class MercatorProjection:public internals::PureProjection
|
class MercatorProjection:public internals::PureProjection
|
||||||
@ -40,8 +39,8 @@ public:
|
|||||||
virtual Size TileSize() const;
|
virtual Size TileSize() const;
|
||||||
virtual double Axis() const;
|
virtual double Axis() const;
|
||||||
virtual double Flattening()const;
|
virtual double Flattening()const;
|
||||||
virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
virtual core::Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
||||||
virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
|
virtual internals::PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
|
||||||
virtual Size GetTileMatrixMinXY(const int &zoom);
|
virtual Size GetTileMatrixMinXY(const int &zoom);
|
||||||
virtual Size GetTileMatrixMaxXY(const int &zoom);
|
virtual Size GetTileMatrixMaxXY(const int &zoom);
|
||||||
private:
|
private:
|
||||||
|
@ -58,7 +58,7 @@ Point MercatorProjectionYandex::FromLatLngToPixel(double lat, double lng, const
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
PointLatLng MercatorProjectionYandex::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
|
internals::PointLatLng MercatorProjectionYandex::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
|
||||||
{
|
{
|
||||||
Size s = GetTileMatrixSizePixel(zoom);
|
Size s = GetTileMatrixSizePixel(zoom);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ PointLatLng MercatorProjectionYandex::FromPixelToLatLng(const int &x, const int
|
|||||||
double g = M_PI /2 - 2 *atan(1 / exp(mercY /a));
|
double g = M_PI /2 - 2 *atan(1 / exp(mercY /a));
|
||||||
double z = g + c1 * sin(2 * g) + c2 * sin(4 * g) + c3 * sin(6 * g) + c4 * sin(8 * g);
|
double z = g + c1 * sin(2 * g) + c2 * sin(4 * g) + c3 * sin(6 * g) + c4 * sin(8 * g);
|
||||||
|
|
||||||
PointLatLng ret;// = PointLatLng.Empty;
|
internals::PointLatLng ret;// = internals::PointLatLng.Empty;
|
||||||
ret.SetLat(z * RAD_DEG);
|
ret.SetLat(z * RAD_DEG);
|
||||||
ret.SetLng (mercX / a * RAD_DEG);
|
ret.SetLng (mercX / a * RAD_DEG);
|
||||||
|
|
||||||
|
@ -30,10 +30,9 @@
|
|||||||
|
|
||||||
#include "../pureprojection.h"
|
#include "../pureprojection.h"
|
||||||
|
|
||||||
using namespace internals;
|
|
||||||
|
|
||||||
namespace projections {
|
namespace projections {
|
||||||
class MercatorProjectionYandex:public PureProjection
|
class MercatorProjectionYandex:public internals::PureProjection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MercatorProjectionYandex();
|
MercatorProjectionYandex();
|
||||||
@ -41,8 +40,8 @@ public:
|
|||||||
virtual Size TileSize() const;
|
virtual Size TileSize() const;
|
||||||
virtual double Axis() const;
|
virtual double Axis() const;
|
||||||
virtual double Flattening()const;
|
virtual double Flattening()const;
|
||||||
virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
virtual core::Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
||||||
virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
|
virtual internals::PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
|
||||||
virtual Size GetTileMatrixMinXY(const int &zoom);
|
virtual Size GetTileMatrixMinXY(const int &zoom);
|
||||||
virtual Size GetTileMatrixMaxXY(const int &zoom);
|
virtual Size GetTileMatrixMaxXY(const int &zoom);
|
||||||
private:
|
private:
|
||||||
|
@ -53,9 +53,9 @@ Point PlateCarreeProjection::FromLatLngToPixel(double lat, double lng, const int
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
PointLatLng PlateCarreeProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
|
internals::PointLatLng PlateCarreeProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
|
||||||
{
|
{
|
||||||
PointLatLng ret;// = PointLatLng.Empty;
|
internals::PointLatLng ret;// = internals::PointLatLng.Empty;
|
||||||
|
|
||||||
Size s = GetTileMatrixSizePixel(zoom);
|
Size s = GetTileMatrixSizePixel(zoom);
|
||||||
double mapSizeX = s.Width();
|
double mapSizeX = s.Width();
|
||||||
|
@ -30,10 +30,9 @@
|
|||||||
|
|
||||||
#include "../pureprojection.h"
|
#include "../pureprojection.h"
|
||||||
|
|
||||||
using namespace internals;
|
|
||||||
|
|
||||||
namespace projections {
|
namespace projections {
|
||||||
class PlateCarreeProjection:public PureProjection
|
class PlateCarreeProjection:public internals::PureProjection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlateCarreeProjection();
|
PlateCarreeProjection();
|
||||||
@ -41,8 +40,8 @@ public:
|
|||||||
virtual Size TileSize() const;
|
virtual Size TileSize() const;
|
||||||
virtual double Axis() const;
|
virtual double Axis() const;
|
||||||
virtual double Flattening()const;
|
virtual double Flattening()const;
|
||||||
virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
virtual core::Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
||||||
virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
|
virtual internals::PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
|
||||||
virtual Size GetTileMatrixMinXY(const int &zoom);
|
virtual Size GetTileMatrixMinXY(const int &zoom);
|
||||||
virtual Size GetTileMatrixMaxXY(const int &zoom);
|
virtual Size GetTileMatrixMaxXY(const int &zoom);
|
||||||
private:
|
private:
|
||||||
|
@ -51,9 +51,9 @@ Point PlateCarreeProjectionPergo::FromLatLngToPixel(double lat, double lng, cons
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
PointLatLng PlateCarreeProjectionPergo::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
|
internals::PointLatLng PlateCarreeProjectionPergo::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
|
||||||
{
|
{
|
||||||
PointLatLng ret;// = PointLatLng.Empty;
|
internals::PointLatLng ret;// = internals::PointLatLng.Empty;
|
||||||
|
|
||||||
Size s = GetTileMatrixSizePixel(zoom);
|
Size s = GetTileMatrixSizePixel(zoom);
|
||||||
double mapSizeX = s.Width();
|
double mapSizeX = s.Width();
|
||||||
|
@ -30,10 +30,9 @@
|
|||||||
|
|
||||||
#include "../pureprojection.h"
|
#include "../pureprojection.h"
|
||||||
|
|
||||||
using namespace internals;
|
|
||||||
|
|
||||||
namespace projections {
|
namespace projections {
|
||||||
class PlateCarreeProjectionPergo:public PureProjection
|
class PlateCarreeProjectionPergo:public internals::PureProjection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlateCarreeProjectionPergo();
|
PlateCarreeProjectionPergo();
|
||||||
@ -41,8 +40,8 @@ public:
|
|||||||
virtual Size TileSize() const;
|
virtual Size TileSize() const;
|
||||||
virtual double Axis() const;
|
virtual double Axis() const;
|
||||||
virtual double Flattening()const;
|
virtual double Flattening()const;
|
||||||
virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
virtual core::Point FromLatLngToPixel(double lat, double lng, int const& zoom);
|
||||||
virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
|
virtual internals::PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
|
||||||
virtual Size GetTileMatrixMinXY(const int &zoom);
|
virtual Size GetTileMatrixMinXY(const int &zoom);
|
||||||
virtual Size GetTileMatrixMaxXY(const int &zoom);
|
virtual Size GetTileMatrixMaxXY(const int &zoom);
|
||||||
private:
|
private:
|
||||||
|
@ -51,22 +51,22 @@ public:
|
|||||||
|
|
||||||
virtual double Flattening()const=0;
|
virtual double Flattening()const=0;
|
||||||
|
|
||||||
virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom)=0;
|
virtual core::Point FromLatLngToPixel(double lat, double lng, int const& zoom)=0;
|
||||||
|
|
||||||
virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom)=0;
|
virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom)=0;
|
||||||
|
|
||||||
virtual QString Type(){return "PureProjection";}
|
virtual QString Type(){return "PureProjection";}
|
||||||
Point FromLatLngToPixel(const PointLatLng &p,const int &zoom);
|
core::Point FromLatLngToPixel(const PointLatLng &p,const int &zoom);
|
||||||
|
|
||||||
PointLatLng FromPixelToLatLng(const Point &p,const int &zoom);
|
PointLatLng FromPixelToLatLng(const Point &p,const int &zoom);
|
||||||
virtual Point FromPixelToTileXY(const Point &p);
|
virtual core::Point FromPixelToTileXY(const core::Point &p);
|
||||||
virtual Point FromTileXYToPixel(const Point &p);
|
virtual core::Point FromTileXYToPixel(const core::Point &p);
|
||||||
virtual Size GetTileMatrixMinXY(const int &zoom)=0;
|
virtual Size GetTileMatrixMinXY(const int &zoom)=0;
|
||||||
virtual Size GetTileMatrixMaxXY(const int &zoom)=0;
|
virtual Size GetTileMatrixMaxXY(const int &zoom)=0;
|
||||||
virtual Size GetTileMatrixSizeXY(const int &zoom);
|
virtual Size GetTileMatrixSizeXY(const int &zoom);
|
||||||
int GetTileMatrixItemCount(const int &zoom);
|
int GetTileMatrixItemCount(const int &zoom);
|
||||||
virtual Size GetTileMatrixSizePixel(const int &zoom);
|
virtual Size GetTileMatrixSizePixel(const int &zoom);
|
||||||
QList<Point> GetAreaTileList(const RectLatLng &rect,const int &zoom,const int &padding);
|
QList<core::Point> GetAreaTileList(const RectLatLng &rect,const int &zoom,const int &padding);
|
||||||
virtual double GetGroundResolution(const int &zoom,const double &latitude);
|
virtual double GetGroundResolution(const int &zoom,const double &latitude);
|
||||||
|
|
||||||
double DegreesToRadians(const double °)const
|
double DegreesToRadians(const double °)const
|
||||||
|
@ -49,17 +49,17 @@ public:
|
|||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
}
|
}
|
||||||
Rectangle(Point location, Size size)
|
Rectangle(core::Point location, core::Size size)
|
||||||
{
|
{
|
||||||
this->x = location.X();
|
this->x = location.X();
|
||||||
this->y = location.Y();
|
this->y = location.Y();
|
||||||
this->width = size.Width();
|
this->width = size.Width();
|
||||||
this->height = size.Height();
|
this->height = size.Height();
|
||||||
}
|
}
|
||||||
Point GetLocation() {
|
core::Point GetLocation() {
|
||||||
return Point(x, y);
|
return core::Point(x, y);
|
||||||
}
|
}
|
||||||
void SetLocation(const Point &value)
|
void SetLocation(const core::Point &value)
|
||||||
{
|
{
|
||||||
x = value.X();
|
x = value.X();
|
||||||
y = value.Y();
|
y = value.Y();
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
{
|
{
|
||||||
return this->x<=x && x<this->x+this->width && this->y<=y && y<this->y+this->height;
|
return this->x<=x && x<this->x+this->width && this->y<=y && y<this->y+this->height;
|
||||||
}
|
}
|
||||||
bool Contains(const Point &pt)
|
bool Contains(const core::Point &pt)
|
||||||
{
|
{
|
||||||
return Contains(pt.X(),pt.Y());
|
return Contains(pt.X(),pt.Y());
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
(this->y < rect.y + rect.height);
|
(this->y < rect.y + rect.height);
|
||||||
}
|
}
|
||||||
static Rectangle Union(const Rectangle &a,const Rectangle &b);
|
static Rectangle Union(const Rectangle &a,const Rectangle &b);
|
||||||
void Offset(const Point &pos)
|
void Offset(const core::Point &pos)
|
||||||
{
|
{
|
||||||
Offset(pos.X(), pos.Y());
|
Offset(pos.X(), pos.Y());
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,13 @@ namespace internals
|
|||||||
class Tile
|
class Tile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Tile(int zoom,Point pos);
|
Tile(int zoom,core::Point pos);
|
||||||
Tile();
|
Tile();
|
||||||
void Clear();
|
void Clear();
|
||||||
int GetZoom(){return zoom;}
|
int GetZoom(){return zoom;}
|
||||||
Point GetPos(){return pos;}
|
core::Point GetPos(){return pos;}
|
||||||
void SetZoom(const int &value){zoom=value;}
|
void SetZoom(const int &value){zoom=value;}
|
||||||
void SetPos(const Point &value){pos=value;}
|
void SetPos(const core::Point &value){pos=value;}
|
||||||
Tile& operator= (const Tile &cSource);
|
Tile& operator= (const Tile &cSource);
|
||||||
Tile(const Tile &cSource)
|
Tile(const Tile &cSource)
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ protected:
|
|||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
private:
|
private:
|
||||||
int zoom;
|
int zoom;
|
||||||
Point pos;
|
core::Point pos;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -39,13 +39,13 @@ class TileMatrix
|
|||||||
public:
|
public:
|
||||||
TileMatrix();
|
TileMatrix();
|
||||||
void Clear();
|
void Clear();
|
||||||
void ClearPointsNotIn(QList<Point> list);
|
void ClearPointsNotIn(QList<core::Point> list);
|
||||||
Tile* TileAt(const Point &p);
|
Tile* TileAt(const core::Point &p);
|
||||||
void SetTileAt(const Point &p,Tile* tile);
|
void SetTileAt(const core::Point &p,Tile* tile);
|
||||||
int count()const{return matrix.count();}
|
int count()const{return matrix.count();}
|
||||||
protected:
|
protected:
|
||||||
QHash<Point,Tile*> matrix;
|
QHash<core::Point,Tile*> matrix;
|
||||||
QList<Point> removals;
|
QList<core::Point> removals;
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "mapgraphicitem.h"
|
#include "mapgraphicitem.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
MapGraphicItem::MapGraphicItem(Core *core):core(core),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false),rotation(0)
|
MapGraphicItem::MapGraphicItem(internals::Core *core):core(core),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false),rotation(0)
|
||||||
{
|
{
|
||||||
EmptytileBrush = Qt::cyan;
|
EmptytileBrush = Qt::cyan;
|
||||||
MissingDataFont =QFont ("Times",10,QFont::Bold);
|
MissingDataFont =QFont ("Times",10,QFont::Bold);
|
||||||
@ -14,10 +14,9 @@ namespace mapcontrol
|
|||||||
DragButton = Qt::RightButton;
|
DragButton = Qt::RightButton;
|
||||||
isMouseOverMarker=false;
|
isMouseOverMarker=false;
|
||||||
maprect=QRectF(0,0,1022,680);
|
maprect=QRectF(0,0,1022,680);
|
||||||
core->SetCurrentRegion(Rectangle(0, 0, maprect.width(), maprect.height()));
|
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
|
||||||
core->SetMapType(MapType::GoogleHybrid);
|
core->SetMapType(MapType::GoogleHybrid);
|
||||||
this->SetZoom(2);
|
this->SetZoom(2);
|
||||||
|
|
||||||
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
|
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
|
|
||||||
core->OnMapSizeChanged(maprect.width(),maprect.height());
|
core->OnMapSizeChanged(maprect.width(),maprect.height());
|
||||||
core->SetCurrentRegion(Rectangle(0, 0, maprect.width(), maprect.height()));
|
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
|
||||||
if(isVisible())
|
if(isVisible())
|
||||||
{
|
{
|
||||||
core->GoToCurrentPosition();
|
core->GoToCurrentPosition();
|
||||||
@ -106,8 +105,8 @@ namespace mapcontrol
|
|||||||
else if(!isSelected)
|
else if(!isSelected)
|
||||||
{
|
{
|
||||||
isSelected = true;
|
isSelected = true;
|
||||||
SetSelectedArea (RectLatLng::Empty);
|
SetSelectedArea (internals::RectLatLng::Empty);
|
||||||
selectionEnd = PointLatLng::Empty;
|
selectionEnd = internals::PointLatLng::Empty;
|
||||||
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,15 +149,15 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
if(core->GetmouseLastZoom().X() != event->pos().x() && core->mouseLastZoom.Y() != event->pos().y())
|
if(core->GetmouseLastZoom().X() != event->pos().x() && core->mouseLastZoom.Y() != event->pos().y())
|
||||||
{
|
{
|
||||||
if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionAndCenter)
|
if(GetMouseWheelZoomType() == internals::MouseWheelZoomType::MousePositionAndCenter)
|
||||||
{
|
{
|
||||||
core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
|
core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
|
||||||
}
|
}
|
||||||
else if(GetMouseWheelZoomType() == MouseWheelZoomType::ViewCenter)
|
else if(GetMouseWheelZoomType() == internals::MouseWheelZoomType::ViewCenter)
|
||||||
{
|
{
|
||||||
core->SetCurrentPosition(FromLocalToLatLng((int) maprect.width()/2, (int) maprect.height()/2));
|
core->SetCurrentPosition(FromLocalToLatLng((int) maprect.width()/2, (int) maprect.height()/2));
|
||||||
}
|
}
|
||||||
else if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionWithoutCenter)
|
else if(GetMouseWheelZoomType() == internals::MouseWheelZoomType::MousePositionWithoutCenter)
|
||||||
{
|
{
|
||||||
core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
|
core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
|
||||||
|
|
||||||
@ -169,7 +168,7 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set mouse position to map center
|
// set mouse position to map center
|
||||||
if(GetMouseWheelZoomType() != MouseWheelZoomType::MousePositionWithoutCenter)
|
if(GetMouseWheelZoomType() != internals::MouseWheelZoomType::MousePositionWithoutCenter)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// System.Drawing.Point p = PointToScreen(new System.Drawing.Point(Width/2, Height/2));
|
// System.Drawing.Point p = PointToScreen(new System.Drawing.Point(Width/2, Height/2));
|
||||||
@ -205,7 +204,7 @@ namespace mapcontrol
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Tile* t = core->Matrix.TileAt(core->GettilePoint());
|
internals::Tile* t = core->Matrix.TileAt(core->GettilePoint());
|
||||||
//qDebug()<<"OPMapControl::DrawMap2D tile:"<<t->GetPos().ToString()<<" as "<<t->Overlays.count()<<" overlays";
|
//qDebug()<<"OPMapControl::DrawMap2D tile:"<<t->GetPos().ToString()<<" as "<<t->Overlays.count()<<" overlays";
|
||||||
//Tile t = core->Matrix[tileToDraw];
|
//Tile t = core->Matrix[tileToDraw];
|
||||||
if(t!=0)
|
if(t!=0)
|
||||||
@ -270,7 +269,7 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y)
|
internals::PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y)
|
||||||
{
|
{
|
||||||
if(MapRenderTransform!=-1)
|
if(MapRenderTransform!=-1)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ class MapGraphicItem:public QObject,public QGraphicsItem
|
|||||||
friend class mapcontrol::OPMapWidget;
|
friend class mapcontrol::OPMapWidget;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MapGraphicItem(Core *core);
|
MapGraphicItem(internals::Core *core);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
@ -36,22 +36,22 @@ protected:
|
|||||||
void SetZoomStep(int const& value);
|
void SetZoomStep(int const& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core *core;
|
internals::Core *core;
|
||||||
bool showTileGridLines;
|
bool showTileGridLines;
|
||||||
qreal MapRenderTransform;
|
qreal MapRenderTransform;
|
||||||
void DrawMap2D(QPainter *painter);
|
void DrawMap2D(QPainter *painter);
|
||||||
QFont MissingDataFont;
|
QFont MissingDataFont;
|
||||||
int maxZoom;
|
int maxZoom;
|
||||||
int minZoom;
|
int minZoom;
|
||||||
RectLatLng selectedArea;
|
internals::RectLatLng selectedArea;
|
||||||
PointLatLng selectionStart;
|
internals::PointLatLng selectionStart;
|
||||||
PointLatLng selectionEnd;
|
internals::PointLatLng selectionEnd;
|
||||||
double zoomReal;
|
double zoomReal;
|
||||||
QRectF maprect;
|
QRectF maprect;
|
||||||
bool isSelected;
|
bool isSelected;
|
||||||
bool isMouseOverMarker;
|
bool isMouseOverMarker;
|
||||||
void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
|
void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
|
||||||
PointLatLng FromLocalToLatLng(int x, int y);
|
internals::PointLatLng FromLocalToLatLng(int x, int y);
|
||||||
qreal rotation;
|
qreal rotation;
|
||||||
QRectF boundingBox(QRectF const& rect, qreal const& angle);
|
QRectF boundingBox(QRectF const& rect, qreal const& angle);
|
||||||
|
|
||||||
@ -62,12 +62,12 @@ private:
|
|||||||
QPen SelectionPen;
|
QPen SelectionPen;
|
||||||
int MaxZoom()const{return maxZoom;}
|
int MaxZoom()const{return maxZoom;}
|
||||||
int MinZoom()const{return minZoom;}
|
int MinZoom()const{return minZoom;}
|
||||||
MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
|
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
|
||||||
QString GetMouseWheelZoomTypeStr(){return MouseWheelZoomType::TypesStrList().at((int)core->GetMouseWheelZoomType());}
|
QString GetMouseWheelZoomTypeStr(){return internals::MouseWheelZoomType::TypesStrList().at((int)core->GetMouseWheelZoomType());}
|
||||||
bool MapScaleInfoEnabled;
|
bool MapScaleInfoEnabled;
|
||||||
Qt::MouseButton DragButton;
|
Qt::MouseButton DragButton;
|
||||||
void SetSelectedArea(RectLatLng const& value){selectedArea = value;this->update();}
|
void SetSelectedArea(internals::RectLatLng const& value){selectedArea = value;this->update();}
|
||||||
RectLatLng BoundsOfMap;
|
internals::RectLatLng BoundsOfMap;
|
||||||
void Offset(int const& x, int const& y);
|
void Offset(int const& x, int const& y);
|
||||||
bool CanDragMap()const{return core->CanDragMap;}
|
bool CanDragMap()const{return core->CanDragMap;}
|
||||||
void SetCanDragMap(bool const& value){core->CanDragMap = value;}
|
void SetCanDragMap(bool const& value){core->CanDragMap = value;}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<RCC/>
|
|
@ -1,16 +1,14 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = OPMapWidget
|
TARGET = opmapwidget
|
||||||
DEFINES += OPMAPWIDGET_LIBRARY
|
DEFINES += OPMAPWIDGET_LIBRARY
|
||||||
|
|
||||||
include(../../../../openpilotgcslibrary.pri)
|
include(../../../../openpilotgcslibrary.pri)
|
||||||
|
#DESTDIR = ../build
|
||||||
SOURCES += opmapcontrol.cpp \
|
SOURCES += mapgraphicitem.cpp \
|
||||||
mapgraphicitem.cpp \
|
|
||||||
opmapwidget.cpp
|
opmapwidget.cpp
|
||||||
|
|
||||||
LIBS += -L../build -lcore -linternals -lcore
|
LIBS += -L../build -lcore -linternals -lcore
|
||||||
HEADERS += opmapcontrol.h \
|
HEADERS += mapgraphicitem.h \
|
||||||
mapgraphicitem.h \
|
|
||||||
opmapwidget.h
|
opmapwidget.h
|
||||||
|
|
||||||
QT += opengl
|
QT += opengl
|
||||||
|
@ -1,366 +0,0 @@
|
|||||||
#include "opmapcontrol.h"
|
|
||||||
#include <QImage>
|
|
||||||
namespace mapcontrol
|
|
||||||
{
|
|
||||||
OPMapControl::OPMapControl(QWidget *parent):QWidget(parent),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false)
|
|
||||||
{
|
|
||||||
EmptytileBrush = Qt::cyan;
|
|
||||||
MissingDataFont =QFont ("Times",10,QFont::Bold);
|
|
||||||
EmptyTileText = "We are sorry, but we don't\nhave imagery at this zoom\nlevel for this region.";
|
|
||||||
EmptyTileBorders = QPen(Qt::white);
|
|
||||||
ScalePen = QPen(Qt::blue);
|
|
||||||
SelectionPen = QPen(Qt::blue);
|
|
||||||
MapScaleInfoEnabled = true;
|
|
||||||
showTileGridLines=true;
|
|
||||||
DragButton = Qt::RightButton;
|
|
||||||
isMouseOverMarker=false;
|
|
||||||
core.SetCurrentRegion(Rectangle(-50, -50, this->width()+100, this->height()+100));
|
|
||||||
core.SetMapType(MapType::GoogleHybrid);
|
|
||||||
core.SetZoom(3);
|
|
||||||
|
|
||||||
connect(&core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
void OPMapControl::showEvent(QShowEvent *event)
|
|
||||||
{
|
|
||||||
QWidget::showEvent(event);
|
|
||||||
core.StartSystem();
|
|
||||||
resize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPMapControl::Core_OnNeedInvalidation()
|
|
||||||
{
|
|
||||||
this->repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPMapControl::paintEvent(QPaintEvent* evnt)
|
|
||||||
{
|
|
||||||
QWidget::paintEvent(evnt);
|
|
||||||
QPainter painter(this);
|
|
||||||
// painter.setBrush(palette().foreground().color());
|
|
||||||
// painter.fillRect(this->rect(),painter.background());
|
|
||||||
if(MapRenderTransform!=1)
|
|
||||||
{
|
|
||||||
QTransform transform;
|
|
||||||
transform.scale(MapRenderTransform,MapRenderTransform);
|
|
||||||
painter.setWorldTransform(transform);
|
|
||||||
{
|
|
||||||
DrawMap2D(painter);
|
|
||||||
}
|
|
||||||
painter.resetTransform();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DrawMap2D(painter);
|
|
||||||
}
|
|
||||||
// painter.drawText(10,10,"TESTE");
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPMapControl::DrawMap2D(QPainter &painter)
|
|
||||||
{
|
|
||||||
// qDebug()<<core.Matrix.count();
|
|
||||||
// painter.drawText(10,10,"TESTE");
|
|
||||||
for(int i = -core.GetsizeOfMapArea().Width(); i <= core.GetsizeOfMapArea().Width(); i++)
|
|
||||||
{
|
|
||||||
for(int j = -core.GetsizeOfMapArea().Height(); j <= core.GetsizeOfMapArea().Height(); j++)
|
|
||||||
{
|
|
||||||
core.SettilePoint (core.GetcenterTileXYLocation());
|
|
||||||
core.SettilePoint(Point(core.GettilePoint().X()+ i,core.GettilePoint().Y()+j));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
Tile* t = core.Matrix.TileAt(core.GettilePoint());
|
|
||||||
//qDebug()<<"OPMapControl::DrawMap2D tile:"<<t->GetPos().ToString()<<" as "<<t->Overlays.count()<<" overlays";
|
|
||||||
//Tile t = Core.Matrix[tileToDraw];
|
|
||||||
if(t!=0)
|
|
||||||
{
|
|
||||||
//qDebug()<< "opmapcontrol:draw2d TileHasValue:"<<t->GetPos().ToString();
|
|
||||||
core.tileRect.SetX(core.GettilePoint().X()*core.tileRect.Width());
|
|
||||||
core.tileRect.SetY(core.GettilePoint().Y()*core.tileRect.Height());
|
|
||||||
core.tileRect.Offset(core.GetrenderOffset());
|
|
||||||
|
|
||||||
if(core.GetCurrentRegion().IntersectsWith(core.tileRect))
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
// render tile
|
|
||||||
//lock(t.Overlays)
|
|
||||||
{
|
|
||||||
foreach(QByteArray img,t->Overlays)
|
|
||||||
{
|
|
||||||
if(img.count()!=0)
|
|
||||||
{
|
|
||||||
if(!found)
|
|
||||||
found = true;
|
|
||||||
{
|
|
||||||
painter.drawImage(QRectF(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height()),QImage::fromData(img));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(showTileGridLines)
|
|
||||||
{
|
|
||||||
painter.setPen(EmptyTileBorders);
|
|
||||||
painter.drawRect(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height());
|
|
||||||
{
|
|
||||||
painter.setFont(MissingDataFont);
|
|
||||||
painter.setPen(Qt::red);
|
|
||||||
painter.drawText(QRectF(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height()),Qt::AlignCenter,(core.GettilePoint() == core.GetcenterTileXYLocation()? "CENTER: " :"TILE: ")+core.GettilePoint().ToString());
|
|
||||||
//qDebug()<<"ShowTileGridLine:"<<core.GettilePoint().ToString()<<"=="<<core.GetcenterTileXYLocation().ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add text if tile is missing
|
|
||||||
if(!found)
|
|
||||||
{
|
|
||||||
|
|
||||||
painter.fillRect(QRectF(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height()),EmptytileBrush);
|
|
||||||
painter.setFont(MissingDataFont);
|
|
||||||
painter.drawText(QRectF(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height()),EmptyTileText);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
painter.setPen(EmptyTileBorders);
|
|
||||||
painter.drawRect(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height());
|
|
||||||
|
|
||||||
// raise error
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPMapControl::mousePressEvent ( QMouseEvent* evnt )
|
|
||||||
{
|
|
||||||
if(!IsMouseOverMarker())
|
|
||||||
{
|
|
||||||
if(evnt->button() == DragButton && core.CanDragMap)
|
|
||||||
{
|
|
||||||
core.mouseDown.SetX(evnt->x());
|
|
||||||
core.mouseDown.SetY(evnt->y());
|
|
||||||
|
|
||||||
|
|
||||||
this->setCursor(Qt::SizeAllCursor);
|
|
||||||
|
|
||||||
core.BeginDrag(core.mouseDown);
|
|
||||||
this->repaint();
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(!isSelected)
|
|
||||||
{
|
|
||||||
isSelected = true;
|
|
||||||
SetSelectedArea (RectLatLng::Empty);
|
|
||||||
selectionEnd = PointLatLng::Empty;
|
|
||||||
selectionStart = FromLocalToLatLng(evnt->x(), evnt->y());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget::mousePressEvent(evnt);
|
|
||||||
}
|
|
||||||
PointLatLng OPMapControl::FromLocalToLatLng(int x, int y)
|
|
||||||
{
|
|
||||||
if(MapRenderTransform!=-1)
|
|
||||||
{
|
|
||||||
x = (int) (x * MapRenderTransform);
|
|
||||||
y = (int) (y * MapRenderTransform);
|
|
||||||
}
|
|
||||||
return core.FromLocalToLatLng(x, y);
|
|
||||||
}
|
|
||||||
void OPMapControl::mouseReleaseEvent ( QMouseEvent* evnt )
|
|
||||||
{
|
|
||||||
QWidget::mouseReleaseEvent(evnt);
|
|
||||||
|
|
||||||
if(isSelected)
|
|
||||||
{
|
|
||||||
isSelected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(core.IsDragging())
|
|
||||||
{
|
|
||||||
core.EndDrag();
|
|
||||||
|
|
||||||
this->setCursor(Qt::ArrowCursor);
|
|
||||||
if(!BoundsOfMap.IsEmpty() && !BoundsOfMap.Contains(core.CurrentPosition()))
|
|
||||||
{
|
|
||||||
if(!core.LastLocationInBounds.IsEmpty())
|
|
||||||
{
|
|
||||||
core.SetCurrentPosition(core.LastLocationInBounds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!selectionEnd.IsEmpty() && !selectionStart.IsEmpty())
|
|
||||||
{
|
|
||||||
if(!selectedArea.IsEmpty() && evnt->modifiers() == Qt::ShiftModifier)
|
|
||||||
{
|
|
||||||
// SetZoomToFitRect(SelectedArea());TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPMapControl::mouseMoveEvent ( QMouseEvent* evnt )
|
|
||||||
{
|
|
||||||
if(core.IsDragging())
|
|
||||||
{
|
|
||||||
core.mouseCurrent.SetX(evnt->x());
|
|
||||||
core.mouseCurrent.SetY(evnt->y());
|
|
||||||
|
|
||||||
{
|
|
||||||
core.Drag(core.mouseCurrent);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void OPMapControl::resizeEvent ( QResizeEvent * event )
|
|
||||||
{
|
|
||||||
QWidget::resizeEvent(event);
|
|
||||||
resize();
|
|
||||||
}
|
|
||||||
void OPMapControl::resize()
|
|
||||||
{
|
|
||||||
|
|
||||||
core.OnMapSizeChanged(this->width(),this->height());
|
|
||||||
core.SetCurrentRegion(Rectangle(-50, -50, this->width()+100, this->height()+100));
|
|
||||||
if(isVisible())
|
|
||||||
{
|
|
||||||
core.GoToCurrentPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void OPMapControl::wheelEvent(QWheelEvent *event)
|
|
||||||
{
|
|
||||||
QWidget::wheelEvent(event);
|
|
||||||
|
|
||||||
if(!IsMouseOverMarker() && !IsDragging())
|
|
||||||
{
|
|
||||||
if(core.GetmouseLastZoom().X() != event->pos().x() && core.mouseLastZoom.Y() != event->pos().y())
|
|
||||||
{
|
|
||||||
if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionAndCenter)
|
|
||||||
{
|
|
||||||
core.SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
|
|
||||||
}
|
|
||||||
else if(GetMouseWheelZoomType() == MouseWheelZoomType::ViewCenter)
|
|
||||||
{
|
|
||||||
core.SetCurrentPosition(FromLocalToLatLng((int) width()/2, (int) height()/2));
|
|
||||||
}
|
|
||||||
else if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionWithoutCenter)
|
|
||||||
{
|
|
||||||
core.SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
core.mouseLastZoom.SetX((event->pos().x()));
|
|
||||||
core.mouseLastZoom.SetY((event->pos().y()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// set mouse position to map center
|
|
||||||
if(GetMouseWheelZoomType() != MouseWheelZoomType::MousePositionWithoutCenter)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
// System.Drawing.Point p = PointToScreen(new System.Drawing.Point(Width/2, Height/2));
|
|
||||||
// Stuff.SetCursorPos((int) p.X, (int) p.Y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.MouseWheelZooming = true;
|
|
||||||
|
|
||||||
if(event->delta() > 0)
|
|
||||||
{
|
|
||||||
SetZoom(Zoom()+1);
|
|
||||||
}
|
|
||||||
else if(event->delta() < 0)
|
|
||||||
{
|
|
||||||
SetZoom(Zoom()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
core.MouseWheelZooming = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
double OPMapControl::Zoom()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
return zoomReal;
|
|
||||||
}
|
|
||||||
void OPMapControl::SetZoom(double const& value)
|
|
||||||
{
|
|
||||||
if(zoomReal != value)
|
|
||||||
{
|
|
||||||
if(value > MaxZoom())
|
|
||||||
{
|
|
||||||
zoomReal = MaxZoom();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(value < MinZoom())
|
|
||||||
{
|
|
||||||
zoomReal = MinZoom();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
zoomReal = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
float remainder = (float)std::fmod((float) value, (float) 1);
|
|
||||||
if(remainder != 0)
|
|
||||||
{
|
|
||||||
float scaleValue = remainder + 1;
|
|
||||||
{
|
|
||||||
MapRenderTransform = scaleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetZoomStep((qint32)(value - remainder));
|
|
||||||
|
|
||||||
this->repaint();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
MapRenderTransform = 1;
|
|
||||||
|
|
||||||
SetZoomStep ((qint32)(value));
|
|
||||||
zoomReal = ZoomStep();
|
|
||||||
this->repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int OPMapControl::ZoomStep()const
|
|
||||||
{
|
|
||||||
return core.Zoom();
|
|
||||||
}
|
|
||||||
void OPMapControl::SetZoomStep(int const& value)
|
|
||||||
{
|
|
||||||
if(value > MaxZoom())
|
|
||||||
{
|
|
||||||
core.SetZoom(MaxZoom());
|
|
||||||
}
|
|
||||||
else if(value < MinZoom())
|
|
||||||
{
|
|
||||||
core.SetZoom(MinZoom());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
core.SetZoom(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OPMapControl::Offset(int const& x, int const& y)
|
|
||||||
{
|
|
||||||
core.DragOffset(Point(x, y));
|
|
||||||
}
|
|
||||||
void OPMapControl::closeEvent(QCloseEvent *event)
|
|
||||||
{
|
|
||||||
core.OnMapClose();
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
#ifndef OPMAPCONTROL_H
|
|
||||||
#define OPMAPCONTROL_H
|
|
||||||
|
|
||||||
#include "../internals/core.h"
|
|
||||||
#include <QtGui>
|
|
||||||
#include <QTransform>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QBrush>
|
|
||||||
#include <QFont>
|
|
||||||
|
|
||||||
namespace mapcontrol
|
|
||||||
{
|
|
||||||
|
|
||||||
using namespace core;
|
|
||||||
//using namespace internals;
|
|
||||||
|
|
||||||
class internals::Core;
|
|
||||||
|
|
||||||
class OPMapControl:public QWidget
|
|
||||||
{
|
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
// Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
|
|
||||||
// Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
|
|
||||||
// Q_PROPERTY(internals::MouseWheelZoomType::Types MouseWheelZoom READ GetMouseWheelZoomType WRITE SetMouseWheelZoomType)
|
|
||||||
// Q_PROPERTY(QString MouseWheelZoomStr READ GetMouseWheelZoomTypeStr WRITE SetMouseWheelZoomTypeByStr)
|
|
||||||
// Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
|
|
||||||
// Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
|
|
||||||
public:
|
|
||||||
OPMapControl(QWidget *parent=0);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent ( QPaintEvent* evnt );
|
|
||||||
void mousePressEvent ( QMouseEvent* evnt );
|
|
||||||
void mouseReleaseEvent ( QMouseEvent* evnt );
|
|
||||||
void mouseMoveEvent ( QMouseEvent* evnt );
|
|
||||||
void resizeEvent ( QResizeEvent * event );
|
|
||||||
void showEvent ( QShowEvent * event );
|
|
||||||
void closeEvent ( QCloseEvent * event );
|
|
||||||
bool IsDragging()const{return core.IsDragging();}
|
|
||||||
bool IsMouseOverMarker()const{return isMouseOverMarker;}
|
|
||||||
void wheelEvent ( QWheelEvent * event );
|
|
||||||
int ZoomStep()const;
|
|
||||||
void SetZoomStep(int const& value);
|
|
||||||
private:
|
|
||||||
QBrush EmptytileBrush;
|
|
||||||
QString EmptyTileText;
|
|
||||||
QPen EmptyTileBorders;
|
|
||||||
QPen ScalePen;
|
|
||||||
QPen SelectionPen;
|
|
||||||
// bool ShowTileGridLines()const {return showTileGridLines;}
|
|
||||||
// void SetShowTileGridLines(bool const& value){showTileGridLines=value;this->repaint();}
|
|
||||||
int MaxZoom()const{return maxZoom;}
|
|
||||||
// void SetMaxZoom(int const& value){maxZoom = value;}
|
|
||||||
int MinZoom()const{return minZoom;}
|
|
||||||
// void SetMinZoom(int const& value){minZoom = value;}
|
|
||||||
MouseWheelZoomType::Types GetMouseWheelZoomType(){return core.GetMouseWheelZoomType();}
|
|
||||||
// void SetMouseWheelZoomType(MouseWheelZoomType::Types const& value){core.SetMouseWheelZoomType(value);}
|
|
||||||
// void SetMouseWheelZoomTypeByStr(const QString &value){core.SetMouseWheelZoomType(MouseWheelZoomType::TypeByStr(value));}
|
|
||||||
QString GetMouseWheelZoomTypeStr(){return MouseWheelZoomType::TypesStrList().at((int)core.GetMouseWheelZoomType());}
|
|
||||||
bool MapScaleInfoEnabled;
|
|
||||||
Qt::MouseButton DragButton;
|
|
||||||
// RectLatLng SelectedArea()const{return selectedArea;}
|
|
||||||
void SetSelectedArea(RectLatLng const& value){selectedArea = value;this->update();}
|
|
||||||
RectLatLng BoundsOfMap;
|
|
||||||
void Offset(int const& x, int const& y);
|
|
||||||
bool CanDragMap()const{return core.CanDragMap;}
|
|
||||||
void SetCanDragMap(bool const& value){core.CanDragMap = value;}
|
|
||||||
// PointLatLng CurrentPosition()const{return core.CurrentPosition();}
|
|
||||||
// void SetCurrentPosition(PointLatLng const& value){core.SetCurrentPosition(value);}
|
|
||||||
double Zoom();
|
|
||||||
void SetZoom(double const& value);
|
|
||||||
bool showTileGridLines;
|
|
||||||
Core core;
|
|
||||||
qreal MapRenderTransform;
|
|
||||||
void DrawMap2D(QPainter &painter);
|
|
||||||
QFont MissingDataFont;
|
|
||||||
void resize();
|
|
||||||
int maxZoom;
|
|
||||||
int minZoom;
|
|
||||||
RectLatLng selectedArea;
|
|
||||||
PointLatLng selectionStart;
|
|
||||||
PointLatLng selectionEnd;
|
|
||||||
double zoomReal;
|
|
||||||
bool isSelected;
|
|
||||||
bool isMouseOverMarker;
|
|
||||||
void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
|
|
||||||
PointLatLng FromLocalToLatLng(int x, int y);
|
|
||||||
private slots:
|
|
||||||
void Core_OnNeedInvalidation();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // OPMAPCONTROL_H
|
|
@ -7,7 +7,7 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
|
|
||||||
core=new Core;
|
core=new internals::Core;
|
||||||
map=new MapGraphicItem(core);
|
map=new MapGraphicItem(core);
|
||||||
//text.setZValue(20);
|
//text.setZValue(20);
|
||||||
//QGraphicsTextItem *t=new QGraphicsTextItem(map);
|
//QGraphicsTextItem *t=new QGraphicsTextItem(map);
|
||||||
|
@ -44,16 +44,16 @@ namespace mapcontrol
|
|||||||
void SetMaxZoom(int const& value){map->maxZoom = value;}
|
void SetMaxZoom(int const& value){map->maxZoom = value;}
|
||||||
int MinZoom()const{return map->minZoom;}
|
int MinZoom()const{return map->minZoom;}
|
||||||
void SetMinZoom(int const& value){map->minZoom = value;}
|
void SetMinZoom(int const& value){map->minZoom = value;}
|
||||||
MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
|
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
|
||||||
void SetMouseWheelZoomType(MouseWheelZoomType::Types const& value){map->core->SetMouseWheelZoomType(value);}
|
void SetMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){map->core->SetMouseWheelZoomType(value);}
|
||||||
void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(MouseWheelZoomType::TypeByStr(value));}
|
void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(internals::MouseWheelZoomType::TypeByStr(value));}
|
||||||
QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
|
QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
|
||||||
RectLatLng SelectedArea()const{return map->selectedArea;}
|
internals::RectLatLng SelectedArea()const{return map->selectedArea;}
|
||||||
void SetSelectedArea(RectLatLng const& value){ map->selectedArea = value;this->update();}
|
void SetSelectedArea(internals::RectLatLng const& value){ map->selectedArea = value;this->update();}
|
||||||
bool CanDragMap()const{return map->CanDragMap();}
|
bool CanDragMap()const{return map->CanDragMap();}
|
||||||
void SetCanDragMap(bool const& value){map->SetCanDragMap(value);}
|
void SetCanDragMap(bool const& value){map->SetCanDragMap(value);}
|
||||||
PointLatLng CurrentPosition()const{return map->core->CurrentPosition();}
|
internals::PointLatLng CurrentPosition()const{return map->core->CurrentPosition();}
|
||||||
void SetCurrentPosition(PointLatLng const& value){map->core->SetCurrentPosition(value);}
|
void SetCurrentPosition(internals::PointLatLng const& value){map->core->SetCurrentPosition(value);}
|
||||||
double Zoom(){return map->Zoom();}
|
double Zoom(){return map->Zoom();}
|
||||||
void SetZoom(double const& value){map->SetZoom(value);}
|
void SetZoom(double const& value){map->SetZoom(value);}
|
||||||
qreal Rotate(){return map->rotation;}
|
qreal Rotate(){return map->rotation;}
|
||||||
@ -67,7 +67,7 @@ namespace mapcontrol
|
|||||||
bool isStarted(){return map->core->isStarted();}
|
bool isStarted(){return map->core->isStarted();}
|
||||||
void X(){map->core->GoToCurrentPosition();}
|
void X(){map->core->GoToCurrentPosition();}
|
||||||
private:
|
private:
|
||||||
Core *core;
|
internals::Core *core;
|
||||||
MapGraphicItem *map;
|
MapGraphicItem *map;
|
||||||
QGraphicsScene mscene;
|
QGraphicsScene mscene;
|
||||||
bool useOpenGL;
|
bool useOpenGL;
|
||||||
|
@ -3,3 +3,4 @@ CONFIG += ordered
|
|||||||
SUBDIRS = core
|
SUBDIRS = core
|
||||||
SUBDIRS += internals
|
SUBDIRS += internals
|
||||||
SUBDIRS += mapwidget
|
SUBDIRS += mapwidget
|
||||||
|
#SUBDIRS +=finaltest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user