1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-04-11 03:02:20 +02:00

OP37/GCS MapLib - Upgraded to new google versions.

Zoom now as no limit.
Other changes:
OPMapWidget:
SetZoom(double) accepts any value. Ex:19.4
double ZoomReal() returns the true zoom.
double ZoomDigi() returns the current digital zoom.
double ZoomTotal() returns digital+true zoom.
SIGNAL:
void zoomChanged(double ZoomTotal,double ZoomReal,double ZoomDigi);

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1727 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-09-23 21:13:18 +00:00 committed by zedamota
parent 7598973824
commit aec96a3867
5 changed files with 539 additions and 506 deletions

View File

@ -37,18 +37,22 @@ namespace core {
ProviderStrings::ProviderStrings() ProviderStrings::ProviderStrings()
{ {
// VersionGoogleMap = "m@132";
// VersionGoogleSatellite = "69";
// VersionGoogleLabels = "h@132";
// VersionGoogleTerrain = "t@125,r@132";
// Google version strings // Google version strings
VersionGoogleMap = "m@130"; VersionGoogleMap = "m@132";
VersionGoogleSatellite = "66"; VersionGoogleSatellite = "69";
VersionGoogleLabels = "h@130"; VersionGoogleLabels = "h@132";
VersionGoogleTerrain = "t@125,r@130"; VersionGoogleTerrain = "t@125,r@132";
SecGoogleWord = "Galileo"; SecGoogleWord = "Galileo";
// Google (China) version strings // Google (China) version strings
VersionGoogleMapChina = "m@130"; VersionGoogleMapChina = "m@132";
VersionGoogleSatelliteChina = "s@66"; VersionGoogleSatelliteChina = "s@69";
VersionGoogleLabelsChina = "h@130"; VersionGoogleLabelsChina = "h@132";
VersionGoogleTerrainChina = "t@125,r@130"; VersionGoogleTerrainChina = "t@125,r@132";
// Google (Korea) version strings // Google (Korea) version strings
VersionGoogleMapKorea = "kr1.12"; VersionGoogleMapKorea = "kr1.12";

View File

@ -30,7 +30,7 @@
namespace mapcontrol namespace mapcontrol
{ {
MapGraphicItem::MapGraphicItem(internals::Core *core, Configuration *configuration):core(core),config(configuration),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false),rotation(0) MapGraphicItem::MapGraphicItem(internals::Core *core, Configuration *configuration):core(core),config(configuration),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false),rotation(0),zoomDigi(0)
{ {
showTileGridLines=false; showTileGridLines=false;
@ -128,6 +128,7 @@ namespace mapcontrol
if(MapRenderTransform!=1) if(MapRenderTransform!=1)
{ {
QTransform transform; QTransform transform;
transform.translate(-((boundingRect().width()*MapRenderTransform)-(boundingRect().width()))/2,-((boundingRect().height()*MapRenderTransform)-(boundingRect().height()))/2);
transform.scale(MapRenderTransform,MapRenderTransform); transform.scale(MapRenderTransform,MapRenderTransform);
painter->setWorldTransform(transform); painter->setWorldTransform(transform);
{ {
@ -149,7 +150,9 @@ namespace mapcontrol
if(MapRenderTransform!=1) if(MapRenderTransform!=1)
{ {
QTransform transform; QTransform transform;
transform.translate(-((boundingRect().width()*MapRenderTransform)-(boundingRect().width()))/2,-((boundingRect().height()*MapRenderTransform)-(boundingRect().height()))/2);
transform.scale(MapRenderTransform,MapRenderTransform); transform.scale(MapRenderTransform,MapRenderTransform);
painter->setWorldTransform(transform); painter->setWorldTransform(transform);
{ {
DrawMap2D(painter); DrawMap2D(painter);
@ -276,6 +279,7 @@ namespace mapcontrol
void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event) void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
if(!IsMouseOverMarker() && !IsDragging()) if(!IsMouseOverMarker() && !IsDragging())
{ {
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())
@ -311,11 +315,11 @@ namespace mapcontrol
if(event->delta() > 0) if(event->delta() > 0)
{ {
SetZoom(Zoom()+1); SetZoom(ZoomTotal()+1);
} }
else if(event->delta() < 0) else if(event->delta() < 0)
{ {
SetZoom(Zoom()-1); SetZoom(ZoomTotal()-1);
} }
core->MouseWheelZooming = false; core->MouseWheelZooming = false;
@ -323,8 +327,7 @@ namespace mapcontrol
} }
void MapGraphicItem::DrawMap2D(QPainter *painter) void MapGraphicItem::DrawMap2D(QPainter *painter)
{ {
if(!lastimage.isNull())
if(!lastimage.isNull())
painter->drawImage(core->GetrenderOffset().X()-lastimagepoint.X(),core->GetrenderOffset().Y()-lastimagepoint.Y(),lastimage); painter->drawImage(core->GetrenderOffset().X()-lastimagepoint.X(),core->GetrenderOffset().Y()-lastimagepoint.Y(),lastimage);
for(int i = -core->GetsizeOfMapArea().Width(); i <= core->GetsizeOfMapArea().Width(); i++) for(int i = -core->GetsizeOfMapArea().Width(); i <= core->GetsizeOfMapArea().Width(); i++)
@ -333,21 +336,13 @@ namespace mapcontrol
{ {
core->SettilePoint (core->GetcenterTileXYLocation()); core->SettilePoint (core->GetcenterTileXYLocation());
core->SettilePoint(Point(core->GettilePoint().X()+ i,core->GettilePoint().Y()+j)); core->SettilePoint(Point(core->GettilePoint().X()+ i,core->GettilePoint().Y()+j));
{ {
internals::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";
//Tile t = core->Matrix[tileToDraw];
if(true) if(true)
{ {
//qDebug()<< "opmapcontrol:draw2d TileHasValue:"<<t->GetPos().ToString();
core->tileRect.SetX(core->GettilePoint().X()*core->tileRect.Width()); core->tileRect.SetX(core->GettilePoint().X()*core->tileRect.Width());
core->tileRect.SetY(core->GettilePoint().Y()*core->tileRect.Height()); core->tileRect.SetY(core->GettilePoint().Y()*core->tileRect.Height());
core->tileRect.Offset(core->GetrenderOffset()); core->tileRect.Offset(core->GetrenderOffset());
//qDebug()<<core->GetrenderOffset().ToString();
if(core->GetCurrentRegion().IntersectsWith(core->tileRect)) if(core->GetCurrentRegion().IntersectsWith(core->tileRect))
{ {
bool found = false; bool found = false;
@ -364,7 +359,7 @@ namespace mapcontrol
found = true; found = true;
{ {
painter->drawPixmap(core->tileRect.X(),core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height(),PureImageProxy::FromStream(img)); painter->drawPixmap(core->tileRect.X(),core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height(),PureImageProxy::FromStream(img));
// qDebug()<<"tile:"<<core->tileRect.X()<<core->tileRect.Y();
} }
} }
} }
@ -416,6 +411,10 @@ namespace mapcontrol
} }
} }
// painter->drawRect(core->GetrenderOffset().X()-lastimagepoint.X()-3,core->GetrenderOffset().Y()-lastimagepoint.Y()-3,lastimage.width(),lastimage.height()); // painter->drawRect(core->GetrenderOffset().X()-lastimagepoint.X()-3,core->GetrenderOffset().Y()-lastimagepoint.Y()-3,lastimage.width(),lastimage.height());
// painter->setPen(Qt::red);
// painter->drawLine(-10,-10,10,10);
// painter->drawLine(10,10,-10,-10);
// painter->drawRect(boundingRect().adjusted(100,100,-100,-100));
} }
@ -424,17 +423,24 @@ namespace mapcontrol
core::Point ret = core->FromLatLngToLocal(point); core::Point ret = core->FromLatLngToLocal(point);
if(MapRenderTransform!=1) if(MapRenderTransform!=1)
{ {
ret.SetX((int) (ret.X() / MapRenderTransform)); ret.SetX((int) (ret.X() * MapRenderTransform));
ret.SetY((int) (ret.Y() / MapRenderTransform)); ret.SetY((int) (ret.Y() * MapRenderTransform));
ret.SetX(ret.X()-((boundingRect().width()*MapRenderTransform)-(boundingRect().width()))/2);
ret.SetY(ret.Y()-((boundingRect().height()*MapRenderTransform)-(boundingRect().height()))/2);
} }
return ret; return ret;
} }
internals::PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y) internals::PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y)
{ {
if(MapRenderTransform!=-1) if(MapRenderTransform!=1)
{ {
x = (int) (x * MapRenderTransform); x=x+((boundingRect().width()*MapRenderTransform)-(boundingRect().width()))/2;
y = (int) (y * MapRenderTransform); y=y+((boundingRect().height()*MapRenderTransform)-(boundingRect().height()))/2;
x = (int) (x / MapRenderTransform);
y = (int) (y / MapRenderTransform);
} }
return core->FromLocalToLatLng(x, y); return core->FromLocalToLatLng(x, y);
} }
@ -443,34 +449,48 @@ namespace mapcontrol
{ {
return zoomReal; return zoomReal;
} }
double MapGraphicItem::ZoomDigi()
{
return zoomDigi;
}
double MapGraphicItem::ZoomTotal()
{
return zoomDigi+zoomReal;
}
void MapGraphicItem::SetZoom(double const& value) void MapGraphicItem::SetZoom(double const& value)
{ {
if(zoomReal != value) if(ZoomTotal() != value)
{ {
if(value > MaxZoom()) if(value > MaxZoom())
{ {
zoomReal = MaxZoom(); zoomReal = MaxZoom();
zoomDigi =value-MaxZoom();
} }
else else
if(value < MinZoom()) if(value < MinZoom())
{ {
zoomDigi=0;
zoomReal = MinZoom(); zoomReal = MinZoom();
} }
else else
{ {
zoomDigi=0;
zoomReal = value; zoomReal = value;
} }
double integer;
float remainder = (float)std::fmod((float) value, (float) 1); double remainder = modf (value , &integer);
if(remainder != 0) if(zoomDigi!=0||remainder != 0)
{ {
float scaleValue = remainder + 1; float scaleValue = zoomDigi+remainder + 1;
{ {
MapRenderTransform = scaleValue; MapRenderTransform = scaleValue;
// qDebug()<<"scale="<<scaleValue<<"zoomdigi:"<<ZoomDigi()<<"integer:"<<integer;
} }
if(integer>MaxZoom())
SetZoomStep((qint32)(value - remainder)); integer=MaxZoom();
SetZoomStep((qint32)(integer));
// core->GoToCurrentPositionOnZoom();
this->update(); this->update();
} }
@ -491,24 +511,26 @@ namespace mapcontrol
} }
void MapGraphicItem::SetZoomStep(int const& value) void MapGraphicItem::SetZoomStep(int const& value)
{ {
if(value-core->Zoom()>0 && value<= MaxZoom()) double integer;
double remainder = modf (value , &integer);
if(integer-core->Zoom()>0 && value<= MaxZoom())
ConstructLastImage(value-core->Zoom()); ConstructLastImage(value-core->Zoom());
else else
lastimage=QImage(); lastimage=QImage();
if(value > MaxZoom()) if(value > MaxZoom())
{ {
core->SetZoom(MaxZoom()); core->SetZoom(MaxZoom());
emit zoomChanged(MaxZoom()); emit zoomChanged(MaxZoom()+ZoomDigi(),Zoom(),ZoomDigi());
} }
else if(value < MinZoom()) else if(value < MinZoom())
{ {
core->SetZoom(MinZoom()); core->SetZoom(MinZoom());
emit zoomChanged(MinZoom()); emit zoomChanged(MinZoom()+ZoomDigi(),Zoom(),ZoomDigi());
} }
else else
{ {
core->SetZoom(value); core->SetZoom(value);
emit zoomChanged(value); emit zoomChanged(value+ZoomDigi(),Zoom(),ZoomDigi());;
} }
} }

View File

@ -98,6 +98,9 @@ namespace mapcontrol
void ConstructLastImage(int const& zoomdiff); void ConstructLastImage(int const& zoomdiff);
internals::PureProjection* Projection()const{return core->Projection();} internals::PureProjection* Projection()const{return core->Projection();}
double Zoom(); double Zoom();
double ZoomDigi();
double ZoomTotal();
protected: protected:
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event ); void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
void mousePressEvent ( QGraphicsSceneMouseEvent * event ); void mousePressEvent ( QGraphicsSceneMouseEvent * event );
@ -142,6 +145,7 @@ namespace mapcontrol
internals::PointLatLng selectionStart; internals::PointLatLng selectionStart;
internals::PointLatLng selectionEnd; internals::PointLatLng selectionEnd;
double zoomReal; double zoomReal;
double zoomDigi;
QRectF maprect; QRectF maprect;
bool isSelected; bool isSelected;
bool isMouseOverMarker; bool isMouseOverMarker;
@ -200,7 +204,7 @@ namespace mapcontrol
* *
* @param zoom * @param zoom
*/ */
void zoomChanged(double zoom); void zoomChanged(double zoomtotal,double zoomreal,double zoomdigi);
}; };
} }
#endif // MAPGRAPHICITEM_H #endif // MAPGRAPHICITEM_H

View File

@ -41,7 +41,7 @@ namespace mapcontrol
mscene.addItem(map); mscene.addItem(map);
this->setScene(&mscene); this->setScene(&mscene);
this->adjustSize(); this->adjustSize();
connect(map,SIGNAL(zoomChanged(double)),this,SIGNAL(zoomChanged(double))); connect(map,SIGNAL(zoomChanged(double,double,double)),this,SIGNAL(zoomChanged(double,double,double)));
connect(map->core,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)),this,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng))); connect(map->core,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)),this,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)));
connect(map->core,SIGNAL(OnEmptyTileError(int,core::Point)),this,SIGNAL(OnEmptyTileError(int,core::Point))); connect(map->core,SIGNAL(OnEmptyTileError(int,core::Point)),this,SIGNAL(OnEmptyTileError(int,core::Point)));
connect(map->core,SIGNAL(OnMapDrag()),this,SIGNAL(OnMapDrag())); connect(map->core,SIGNAL(OnMapDrag()),this,SIGNAL(OnMapDrag()));
@ -142,6 +142,7 @@ namespace mapcontrol
{ {
return currentmouseposition; return currentmouseposition;
} }
void OPMapWidget::mouseMoveEvent(QMouseEvent *event) void OPMapWidget::mouseMoveEvent(QMouseEvent *event)
{ {
QGraphicsView::mouseMoveEvent(event); QGraphicsView::mouseMoveEvent(event);

View File

@ -1,465 +1,467 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file opmapwidget.h * @file opmapwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief The Map Widget, this is the part exposed to the user * @brief The Map Widget, this is the part exposed to the user
* @see The GNU Public License (GPL) Version 3 * @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget * @defgroup OPMapWidget
* @{ * @{
* *
*****************************************************************************/ *****************************************************************************/
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* 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 OPMAPWIDGET_H #ifndef OPMAPWIDGET_H
#define OPMAPWIDGET_H #define OPMAPWIDGET_H
#include "../mapwidget/mapgraphicitem.h" #include "../mapwidget/mapgraphicitem.h"
#include "../core/geodecoderstatus.h" #include "../core/geodecoderstatus.h"
#include "../core/maptype.h" #include "../core/maptype.h"
#include "../core/languagetype.h" #include "../core/languagetype.h"
#include "configuration.h" #include "configuration.h"
#include <QObject> #include <QObject>
#include <QtOpenGL/QGLWidget> #include <QtOpenGL/QGLWidget>
#include "waypointitem.h" #include "waypointitem.h"
#include "QtSvg/QGraphicsSvgItem" #include "QtSvg/QGraphicsSvgItem"
#include "uavitem.h" #include "uavitem.h"
#include "homeitem.h" #include "homeitem.h"
#include "mapripper.h" #include "mapripper.h"
namespace mapcontrol namespace mapcontrol
{ {
class UAVItem; class UAVItem;
class HomeItem; class HomeItem;
/** /**
* @brief Collection of static functions to help dealing with various enums used * @brief Collection of static functions to help dealing with various enums used
* Contains functions for enumToString conversio, StringToEnum, QStringList of enum values... * Contains functions for enumToString conversio, StringToEnum, QStringList of enum values...
* *
* @class Helper opmapwidget.h "opmapwidget.h" * @class Helper opmapwidget.h "opmapwidget.h"
*/ */
class Helper class Helper
{ {
public: public:
/** /**
* @brief Converts from String to Type * @brief Converts from String to Type
* *
* @param value String to convert * @param value String to convert
* @return * @return
*/ */
static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);} static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
/** /**
* @brief Converts from Type to String * @brief Converts from Type to String
*/ */
static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);} static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
/** /**
* @brief Returns QStringList with string representing all the enum values * @brief Returns QStringList with string representing all the enum values
*/ */
static QStringList MapTypes(){return MapType::TypesList();} static QStringList MapTypes(){return MapType::TypesList();}
/** /**
* @brief Converts from String to Type * @brief Converts from String to Type
*/ */
static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);} static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
/** /**
* @brief Converts from Type to String * @brief Converts from Type to String
*/ */
static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);} static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
/** /**
* @brief Returns QStringList with string representing all the enum values * @brief Returns QStringList with string representing all the enum values
*/ */
static QStringList GeoCoderTypes(){return GeoCoderStatusCode::TypesList();} static QStringList GeoCoderTypes(){return GeoCoderStatusCode::TypesList();}
/** /**
* @brief Converts from String to Type * @brief Converts from String to Type
*/ */
static internals::MouseWheelZoomType::Types MouseWheelZoomTypeFromString(QString const& value){return internals::MouseWheelZoomType::TypeByStr(value);} static internals::MouseWheelZoomType::Types MouseWheelZoomTypeFromString(QString const& value){return internals::MouseWheelZoomType::TypeByStr(value);}
/** /**
* @brief Converts from Type to String * @brief Converts from Type to String
*/ */
static QString StrFromMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){return internals::MouseWheelZoomType::StrByType(value);} static QString StrFromMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){return internals::MouseWheelZoomType::StrByType(value);}
/** /**
* @brief Returns QStringList with string representing all the enum values * @brief Returns QStringList with string representing all the enum values
*/ */
static QStringList MouseWheelZoomTypes(){return internals::MouseWheelZoomType::TypesList();} static QStringList MouseWheelZoomTypes(){return internals::MouseWheelZoomType::TypesList();}
/** /**
* @brief Converts from String to Type * @brief Converts from String to Type
*/ */
static core::LanguageType::Types LanguageTypeFromString(QString const& value){return core::LanguageType::TypeByStr(value);} static core::LanguageType::Types LanguageTypeFromString(QString const& value){return core::LanguageType::TypeByStr(value);}
/** /**
* @brief Converts from Type to String * @brief Converts from Type to String
*/ */
static QString StrFromLanguageType(core::LanguageType::Types const& value){return core::LanguageType::StrByType(value);} static QString StrFromLanguageType(core::LanguageType::Types const& value){return core::LanguageType::StrByType(value);}
/** /**
* @brief Returns QStringList with string representing all the enum values * @brief Returns QStringList with string representing all the enum values
*/ */
static QStringList LanguageTypes(){return core::LanguageType::TypesList();} static QStringList LanguageTypes(){return core::LanguageType::TypesList();}
/** /**
* @brief Converts from String to Type * @brief Converts from String to Type
*/ */
static core::AccessMode::Types AccessModeFromString(QString const& value){return core::AccessMode::TypeByStr(value);} static core::AccessMode::Types AccessModeFromString(QString const& value){return core::AccessMode::TypeByStr(value);}
/** /**
* @brief Converts from Type to String * @brief Converts from Type to String
*/ */
static QString StrFromAccessMode(core::AccessMode::Types const& value){return core::AccessMode::StrByType(value);} static QString StrFromAccessMode(core::AccessMode::Types const& value){return core::AccessMode::StrByType(value);}
/** /**
* @brief Returns QStringList with string representing all the enum values * @brief Returns QStringList with string representing all the enum values
*/ */
static QStringList AccessModeTypes(){return core::AccessMode::TypesList();} static QStringList AccessModeTypes(){return core::AccessMode::TypesList();}
/** /**
* @brief Converts from String to Type * @brief Converts from String to Type
*/ */
static UAVMapFollowType::Types UAVMapFollowFromString(QString const& value){return UAVMapFollowType::TypeByStr(value);} static UAVMapFollowType::Types UAVMapFollowFromString(QString const& value){return UAVMapFollowType::TypeByStr(value);}
/** /**
* @brief Converts from Type to String * @brief Converts from Type to String
*/ */
static QString StrFromUAVMapFollow(UAVMapFollowType::Types const& value){return UAVMapFollowType::StrByType(value);} static QString StrFromUAVMapFollow(UAVMapFollowType::Types const& value){return UAVMapFollowType::StrByType(value);}
/** /**
* @brief Returns QStringList with string representing all the enum values * @brief Returns QStringList with string representing all the enum values
*/ */
static QStringList UAVMapFollowTypes(){return UAVMapFollowType::TypesList();} static QStringList UAVMapFollowTypes(){return UAVMapFollowType::TypesList();}
/** /**
* @brief Converts from String to Type * @brief Converts from String to Type
*/ */
static UAVTrailType::Types UAVTrailTypeFromString(QString const& value){return UAVTrailType::TypeByStr(value);} static UAVTrailType::Types UAVTrailTypeFromString(QString const& value){return UAVTrailType::TypeByStr(value);}
/** /**
* @brief Converts from Type to String * @brief Converts from Type to String
*/ */
static QString StrFromUAVTrailType(UAVTrailType::Types const& value){return UAVTrailType::StrByType(value);} static QString StrFromUAVTrailType(UAVTrailType::Types const& value){return UAVTrailType::StrByType(value);}
/** /**
* @brief Returns QStringList with string representing all the enum values * @brief Returns QStringList with string representing all the enum values
*/ */
static QStringList UAVTrailTypes(){return UAVTrailType::TypesList();} static QStringList UAVTrailTypes(){return UAVTrailType::TypesList();}
}; };
class OPMapWidget:public QGraphicsView class OPMapWidget:public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
// Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom) // Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom) Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines) Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom) Q_PROPERTY(double Zoom READ ZoomTotal WRITE SetZoom)
Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate) Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
Q_ENUMS(internals::MouseWheelZoomType::Types) Q_ENUMS(internals::MouseWheelZoomType::Types)
Q_ENUMS(internals::GeoCoderStatusCode::Types) Q_ENUMS(internals::GeoCoderStatusCode::Types)
public: public:
QSize sizeHint() const; QSize sizeHint() const;
/** /**
* @brief Constructor * @brief Constructor
* *
* @param parent parent widget * @param parent parent widget
* @param config pointer to configuration classed to be used * @param config pointer to configuration classed to be used
* @return * @return
*/ */
OPMapWidget(QWidget *parent=0,Configuration *config=new Configuration); OPMapWidget(QWidget *parent=0,Configuration *config=new Configuration);
~OPMapWidget(); ~OPMapWidget();
/** /**
* @brief Returns true if map is showing gridlines * @brief Returns true if map is showing gridlines
* *
* @return bool * @return bool
*/ */
bool ShowTileGridLines()const {return map->showTileGridLines;} bool ShowTileGridLines()const {return map->showTileGridLines;}
/** /**
* @brief Defines if map is to show gridlines * @brief Defines if map is to show gridlines
* *
* @param value * @param value
* @return * @return
*/ */
void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();} void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();}
/** /**
* @brief Returns the maximum zoom for the map * @brief Returns the maximum zoom for the map
* *
*/ */
int MaxZoom()const{return map->MaxZoom();} int MaxZoom()const{return map->MaxZoom();}
// void SetMaxZoom(int const& value){map->maxZoom = value;} // void SetMaxZoom(int const& value){map->maxZoom = value;}
/** /**
* @brief * @brief
* *
*/ */
int MinZoom()const{return map->minZoom;} int MinZoom()const{return map->minZoom;}
/** /**
* @brief * @brief
* *
* @param value * @param value
*/ */
void SetMinZoom(int const& value){map->minZoom = value;} void SetMinZoom(int const& value){map->minZoom = value;}
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();} internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
void SetMouseWheelZoomType(internals::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(internals::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();}
internals::RectLatLng SelectedArea()const{return map->selectedArea;} internals::RectLatLng SelectedArea()const{return map->selectedArea;}
void SetSelectedArea(internals::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);}
internals::PointLatLng CurrentPosition()const{return map->core->CurrentPosition();} internals::PointLatLng CurrentPosition()const{return map->core->CurrentPosition();}
void SetCurrentPosition(internals::PointLatLng const& value){map->core->SetCurrentPosition(value);} void SetCurrentPosition(internals::PointLatLng const& value){map->core->SetCurrentPosition(value);}
double Zoom(){return map->Zoom();} double ZoomReal(){return map->Zoom();}
void SetZoom(double const& value){map->SetZoom(value);} double ZoomDigi(){return map->ZoomDigi();}
double ZoomTotal(){return map->ZoomTotal();}
qreal Rotate(){return map->rotation;} void SetZoom(double const& value){map->SetZoom(value);}
void SetRotate(qreal const& value);
qreal Rotate(){return map->rotation;}
void ReloadMap(){map->ReloadMap(); map->resize();} void SetRotate(qreal const& value);
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return map->SetCurrentPositionByKeywords(keys);} void ReloadMap(){map->ReloadMap(); map->resize();}
bool UseOpenGL(){return useOpenGL;} GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return map->SetCurrentPositionByKeywords(keys);}
void SetUseOpenGL(bool const& value);
bool UseOpenGL(){return useOpenGL;}
MapType::Types GetMapType(){return map->core->GetMapType();} void SetUseOpenGL(bool const& value);
void SetMapType(MapType::Types const& value){map->lastimage=QImage(); map->core->SetMapType(value);}
MapType::Types GetMapType(){return map->core->GetMapType();}
bool isStarted(){return map->core->isStarted();} void SetMapType(MapType::Types const& value){map->lastimage=QImage(); map->core->SetMapType(value);}
Configuration* configuration; bool isStarted(){return map->core->isStarted();}
internals::PointLatLng currentMousePosition(); Configuration* configuration;
void SetFollowMouse(bool const& value){followmouse=value;this->setMouseTracking(followmouse);} internals::PointLatLng currentMousePosition();
bool FollowMouse(){return followmouse;}
void SetFollowMouse(bool const& value){followmouse=value;this->setMouseTracking(followmouse);}
/** bool FollowMouse(){return followmouse;}
* @brief Creates a new WayPoint on the center of the map
* /**
* @return WayPointItem a pointer to the WayPoint created * @brief Creates a new WayPoint on the center of the map
*/ *
WayPointItem* WPCreate(); * @return WayPointItem a pointer to the WayPoint created
/** */
* @brief Creates a new WayPoint WayPointItem* WPCreate();
* /**
* @param item the WayPoint to create * @brief Creates a new WayPoint
*/ *
void WPCreate(WayPointItem* item); * @param item the WayPoint to create
/** */
* @brief Creates a new WayPoint void WPCreate(WayPointItem* item);
* /**
* @param coord the coordinates in LatLng of the WayPoint * @brief Creates a new WayPoint
* @param altitude the Altitude of the WayPoint *
* @return WayPointItem a pointer to the WayPoint created * @param coord the coordinates in LatLng of the WayPoint
*/ * @param altitude the Altitude of the WayPoint
WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude); * @return WayPointItem a pointer to the WayPoint created
/** */
* @brief Creates a new WayPoint WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude);
* /**
* @param coord the coordinates in LatLng of the WayPoint * @brief Creates a new WayPoint
* @param altitude the Altitude of the WayPoint *
* @param description the description of the WayPoint * @param coord the coordinates in LatLng of the WayPoint
* @return WayPointItem a pointer to the WayPoint created * @param altitude the Altitude of the WayPoint
*/ * @param description the description of the WayPoint
WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description); * @return WayPointItem a pointer to the WayPoint created
/** */
* @brief Inserts a new WayPoint on the specified position WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description);
* /**
* @param position index of the WayPoint * @brief Inserts a new WayPoint on the specified position
* @return WayPointItem a pointer to the WayPoint created *
*/ * @param position index of the WayPoint
WayPointItem* WPInsert(int const& position); * @return WayPointItem a pointer to the WayPoint created
/** */
* @brief Inserts a new WayPoint on the specified position WayPointItem* WPInsert(int const& position);
* /**
* @param item the WayPoint to Insert * @brief Inserts a new WayPoint on the specified position
* @param position index of the WayPoint *
*/ * @param item the WayPoint to Insert
void WPInsert(WayPointItem* item,int const& position); * @param position index of the WayPoint
/** */
* @brief Inserts a new WayPoint on the specified position void WPInsert(WayPointItem* item,int const& position);
* /**
* @param coord the coordinates in LatLng of the WayPoint * @brief Inserts a new WayPoint on the specified position
* @param altitude the Altitude of the WayPoint *
* @param position index of the WayPoint * @param coord the coordinates in LatLng of the WayPoint
* @return WayPointItem a pointer to the WayPoint Inserted * @param altitude the Altitude of the WayPoint
*/ * @param position index of the WayPoint
WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude,int const& position); * @return WayPointItem a pointer to the WayPoint Inserted
/** */
* @brief Inserts a new WayPoint on the specified position WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude,int const& position);
* /**
* @param coord the coordinates in LatLng of the WayPoint * @brief Inserts a new WayPoint on the specified position
* @param altitude the Altitude of the WayPoint *
* @param description the description of the WayPoint * @param coord the coordinates in LatLng of the WayPoint
* @param position index of the WayPoint * @param altitude the Altitude of the WayPoint
* @return WayPointItem a pointer to the WayPoint Inserted * @param description the description of the WayPoint
*/ * @param position index of the WayPoint
WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,int const& position); * @return WayPointItem a pointer to the WayPoint Inserted
*/
/** WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,int const& position);
* @brief Deletes the WayPoint
* /**
* @param item the WayPoint to delete * @brief Deletes the WayPoint
*/ *
void WPDelete(WayPointItem* item); * @param item the WayPoint to delete
/** */
* @brief deletes all WayPoints void WPDelete(WayPointItem* item);
* /**
*/ * @brief deletes all WayPoints
void WPDeleteAll(); *
/** */
* @brief Returns the currently selected WayPoints void WPDeleteAll();
* /**
* @return @return QList<WayPointItem *> * @brief Returns the currently selected WayPoints
*/ *
QList<WayPointItem*> WPSelected(); * @return @return QList<WayPointItem *>
*/
/** QList<WayPointItem*> WPSelected();
* @brief Renumbers the WayPoint and all others as needed
* /**
* @param item the WayPoint to renumber * @brief Renumbers the WayPoint and all others as needed
* @param newnumber the WayPoint's new number *
*/ * @param item the WayPoint to renumber
void WPRenumber(WayPointItem* item,int const& newnumber); * @param newnumber the WayPoint's new number
*/
void SetShowCompass(bool const& value); void WPRenumber(WayPointItem* item,int const& newnumber);
UAVItem* UAV; void SetShowCompass(bool const& value);
HomeItem* Home;
void SetShowUAV(bool const& value); UAVItem* UAV;
bool ShowUAV()const{return showuav;} HomeItem* Home;
void SetShowHome(bool const& value); void SetShowUAV(bool const& value);
bool ShowHome()const{return showhome;} bool ShowUAV()const{return showuav;}
private: void SetShowHome(bool const& value);
internals::Core *core; bool ShowHome()const{return showhome;}
MapGraphicItem *map; private:
QGraphicsScene mscene; internals::Core *core;
bool useOpenGL; MapGraphicItem *map;
GeoCoderStatusCode x; QGraphicsScene mscene;
MapType y; bool useOpenGL;
core::AccessMode xx; GeoCoderStatusCode x;
internals::PointLatLng currentmouseposition; MapType y;
bool followmouse; core::AccessMode xx;
void ConnectWP(WayPointItem* item); internals::PointLatLng currentmouseposition;
QGraphicsSvgItem *compass; bool followmouse;
bool showuav; void ConnectWP(WayPointItem* item);
bool showhome; QGraphicsSvgItem *compass;
// WayPointItem* item;//apagar bool showuav;
protected: bool showhome;
void resizeEvent(QResizeEvent *event); // WayPointItem* item;//apagar
void showEvent ( QShowEvent * event ); protected:
void closeEvent(QCloseEvent *event); void resizeEvent(QResizeEvent *event);
void mouseMoveEvent ( QMouseEvent * event ); void showEvent ( QShowEvent * event );
// private slots: void closeEvent(QCloseEvent *event);
signals: void mouseMoveEvent ( QMouseEvent * event );
void zoomChanged(double zoom); // private slots:
/** signals:
* @brief fires when one of the WayPoints numbers changes (not fired if due to a auto-renumbering) void zoomChanged(double zoomt,double zoom, double zoomd);
* /**
* @param oldnumber WayPoint old number * @brief fires when one of the WayPoints numbers changes (not fired if due to a auto-renumbering)
* @param newnumber WayPoint new number *
* @param waypoint a pointer to the WayPoint that was renumbered * @param oldnumber WayPoint old number
*/ * @param newnumber WayPoint new number
void WPNumberChanged(int const& oldnumber,int const& newnumber,WayPointItem* waypoint); * @param waypoint a pointer to the WayPoint that was renumbered
/** */
* @brief Fired when the description, altitude or coordinates of a WayPoint changed void WPNumberChanged(int const& oldnumber,int const& newnumber,WayPointItem* waypoint);
* /**
* @param waypoint a pointer to the WayPoint * @brief Fired when the description, altitude or coordinates of a WayPoint changed
*/ *
void WPValuesChanged(WayPointItem* waypoint); * @param waypoint a pointer to the WayPoint
/** */
* @brief Fires when a new WayPoint is inserted void WPValuesChanged(WayPointItem* waypoint);
* /**
* @param number new WayPoint number * @brief Fires when a new WayPoint is inserted
* @param waypoint WayPoint inserted *
*/ * @param number new WayPoint number
void WPReached(WayPointItem* waypoint); * @param waypoint WayPoint inserted
/** */
* @brief Fires when a new WayPoint is inserted void WPReached(WayPointItem* waypoint);
* /**
* @param number new WayPoint number * @brief Fires when a new WayPoint is inserted
* @param waypoint WayPoint inserted *
*/ * @param number new WayPoint number
void WPInserted(int const& number,WayPointItem* waypoint); * @param waypoint WayPoint inserted
/** */
* @brief Fires When a WayPoint is deleted void WPInserted(int const& number,WayPointItem* waypoint);
* /**
* @param number number of the deleted WayPoint * @brief Fires When a WayPoint is deleted
*/ *
void WPDeleted(int const& number); * @param number number of the deleted WayPoint
/** */
* @brief Fires When a WayPoint is Reached void WPDeleted(int const& number);
* /**
* @param number number of the Reached WayPoint * @brief Fires When a WayPoint is Reached
*/ *
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint); * @param number number of the Reached WayPoint
/** */
* @brief Fires When the UAV lives the safety bouble void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
* /**
* @param position the position of the UAV * @brief Fires When the UAV lives the safety bouble
*/ *
void UAVLeftSafetyBouble(internals::PointLatLng const& position); * @param position the position of the UAV
*/
/** void UAVLeftSafetyBouble(internals::PointLatLng const& position);
* @brief Fires when map position changes
* /**
* @param point the point in LatLng of the new center of the map * @brief Fires when map position changes
*/ *
void OnCurrentPositionChanged(internals::PointLatLng point); * @param point the point in LatLng of the new center of the map
/** */
* @brief Fires when there are no more tiles to load void OnCurrentPositionChanged(internals::PointLatLng point);
* /**
*/ * @brief Fires when there are no more tiles to load
void OnTileLoadComplete(); *
/** */
* @brief Fires when tiles loading begins void OnTileLoadComplete();
* /**
*/ * @brief Fires when tiles loading begins
void OnTileLoadStart(); *
/** */
* @brief Fires when the map is dragged void OnTileLoadStart();
* /**
*/ * @brief Fires when the map is dragged
void OnMapDrag(); *
/** */
* @brief Fires when map zoom changes void OnMapDrag();
* /**
*/ * @brief Fires when map zoom changes
void OnMapZoomChanged(); *
/** */
* @brief Fires when map type changes void OnMapZoomChanged();
* /**
* @param type The maps new type * @brief Fires when map type changes
*/ *
void OnMapTypeChanged(MapType::Types type); * @param type The maps new type
/** */
* @brief Fires when an error ocurred while loading a tile void OnMapTypeChanged(MapType::Types type);
* /**
* @param zoom tile zoom * @brief Fires when an error ocurred while loading a tile
* @param pos tile position *
*/ * @param zoom tile zoom
void OnEmptyTileError(int zoom, core::Point pos); * @param pos tile position
/** */
* @brief Fires when the number of tiles in the load queue changes void OnEmptyTileError(int zoom, core::Point pos);
* /**
* @param number the number of tiles still in the queue * @brief Fires when the number of tiles in the load queue changes
*/ *
void OnTilesStillToLoad(int number); * @param number the number of tiles still in the queue
public slots: */
/** void OnTilesStillToLoad(int number);
* @brief Ripps the current selection to the DB public slots:
*/ /**
void RipMap(); * @brief Ripps the current selection to the DB
*/
}; void RipMap();
}
#endif // OPMAPWIDGET_H };
}
#endif // OPMAPWIDGET_H