1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01: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()
{
// VersionGoogleMap = "m@132";
// VersionGoogleSatellite = "69";
// VersionGoogleLabels = "h@132";
// VersionGoogleTerrain = "t@125,r@132";
// Google version strings
VersionGoogleMap = "m@130";
VersionGoogleSatellite = "66";
VersionGoogleLabels = "h@130";
VersionGoogleTerrain = "t@125,r@130";
VersionGoogleMap = "m@132";
VersionGoogleSatellite = "69";
VersionGoogleLabels = "h@132";
VersionGoogleTerrain = "t@125,r@132";
SecGoogleWord = "Galileo";
// Google (China) version strings
VersionGoogleMapChina = "m@130";
VersionGoogleSatelliteChina = "s@66";
VersionGoogleLabelsChina = "h@130";
VersionGoogleTerrainChina = "t@125,r@130";
VersionGoogleMapChina = "m@132";
VersionGoogleSatelliteChina = "s@69";
VersionGoogleLabelsChina = "h@132";
VersionGoogleTerrainChina = "t@125,r@132";
// Google (Korea) version strings
VersionGoogleMapKorea = "kr1.12";

View File

@ -30,7 +30,7 @@
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;
@ -128,6 +128,7 @@ namespace mapcontrol
if(MapRenderTransform!=1)
{
QTransform transform;
transform.translate(-((boundingRect().width()*MapRenderTransform)-(boundingRect().width()))/2,-((boundingRect().height()*MapRenderTransform)-(boundingRect().height()))/2);
transform.scale(MapRenderTransform,MapRenderTransform);
painter->setWorldTransform(transform);
{
@ -149,7 +150,9 @@ namespace mapcontrol
if(MapRenderTransform!=1)
{
QTransform transform;
transform.translate(-((boundingRect().width()*MapRenderTransform)-(boundingRect().width()))/2,-((boundingRect().height()*MapRenderTransform)-(boundingRect().height()))/2);
transform.scale(MapRenderTransform,MapRenderTransform);
painter->setWorldTransform(transform);
{
DrawMap2D(painter);
@ -276,6 +279,7 @@ namespace mapcontrol
void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if(!IsMouseOverMarker() && !IsDragging())
{
if(core->GetmouseLastZoom().X() != event->pos().x() && core->mouseLastZoom.Y() != event->pos().y())
@ -311,11 +315,11 @@ namespace mapcontrol
if(event->delta() > 0)
{
SetZoom(Zoom()+1);
SetZoom(ZoomTotal()+1);
}
else if(event->delta() < 0)
{
SetZoom(Zoom()-1);
SetZoom(ZoomTotal()-1);
}
core->MouseWheelZooming = false;
@ -323,8 +327,7 @@ namespace mapcontrol
}
void MapGraphicItem::DrawMap2D(QPainter *painter)
{
if(!lastimage.isNull())
if(!lastimage.isNull())
painter->drawImage(core->GetrenderOffset().X()-lastimagepoint.X(),core->GetrenderOffset().Y()-lastimagepoint.Y(),lastimage);
for(int i = -core->GetsizeOfMapArea().Width(); i <= core->GetsizeOfMapArea().Width(); i++)
@ -333,21 +336,13 @@ namespace mapcontrol
{
core->SettilePoint (core->GetcenterTileXYLocation());
core->SettilePoint(Point(core->GettilePoint().X()+ i,core->GettilePoint().Y()+j));
{
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)
{
//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());
//qDebug()<<core->GetrenderOffset().ToString();
if(core->GetCurrentRegion().IntersectsWith(core->tileRect))
{
bool found = false;
@ -364,7 +359,7 @@ namespace mapcontrol
found = true;
{
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->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);
if(MapRenderTransform!=1)
{
ret.SetX((int) (ret.X() / MapRenderTransform));
ret.SetY((int) (ret.Y() / MapRenderTransform));
ret.SetX((int) (ret.X() * 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;
}
internals::PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y)
{
if(MapRenderTransform!=-1)
if(MapRenderTransform!=1)
{
x = (int) (x * MapRenderTransform);
y = (int) (y * MapRenderTransform);
x=x+((boundingRect().width()*MapRenderTransform)-(boundingRect().width()))/2;
y=y+((boundingRect().height()*MapRenderTransform)-(boundingRect().height()))/2;
x = (int) (x / MapRenderTransform);
y = (int) (y / MapRenderTransform);
}
return core->FromLocalToLatLng(x, y);
}
@ -443,34 +449,48 @@ namespace mapcontrol
{
return zoomReal;
}
double MapGraphicItem::ZoomDigi()
{
return zoomDigi;
}
double MapGraphicItem::ZoomTotal()
{
return zoomDigi+zoomReal;
}
void MapGraphicItem::SetZoom(double const& value)
{
if(zoomReal != value)
if(ZoomTotal() != value)
{
if(value > MaxZoom())
{
zoomReal = MaxZoom();
zoomDigi =value-MaxZoom();
}
else
if(value < MinZoom())
{
zoomDigi=0;
zoomReal = MinZoom();
}
else
{
zoomDigi=0;
zoomReal = value;
}
float remainder = (float)std::fmod((float) value, (float) 1);
if(remainder != 0)
double integer;
double remainder = modf (value , &integer);
if(zoomDigi!=0||remainder != 0)
{
float scaleValue = remainder + 1;
float scaleValue = zoomDigi+remainder + 1;
{
MapRenderTransform = scaleValue;
// qDebug()<<"scale="<<scaleValue<<"zoomdigi:"<<ZoomDigi()<<"integer:"<<integer;
}
SetZoomStep((qint32)(value - remainder));
if(integer>MaxZoom())
integer=MaxZoom();
SetZoomStep((qint32)(integer));
// core->GoToCurrentPositionOnZoom();
this->update();
}
@ -491,24 +511,26 @@ namespace mapcontrol
}
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());
else
lastimage=QImage();
if(value > MaxZoom())
{
core->SetZoom(MaxZoom());
emit zoomChanged(MaxZoom());
emit zoomChanged(MaxZoom()+ZoomDigi(),Zoom(),ZoomDigi());
}
else if(value < MinZoom())
{
core->SetZoom(MinZoom());
emit zoomChanged(MinZoom());
emit zoomChanged(MinZoom()+ZoomDigi(),Zoom(),ZoomDigi());
}
else
{
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);
internals::PureProjection* Projection()const{return core->Projection();}
double Zoom();
double ZoomDigi();
double ZoomTotal();
protected:
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
@ -142,6 +145,7 @@ namespace mapcontrol
internals::PointLatLng selectionStart;
internals::PointLatLng selectionEnd;
double zoomReal;
double zoomDigi;
QRectF maprect;
bool isSelected;
bool isMouseOverMarker;
@ -200,7 +204,7 @@ namespace mapcontrol
*
* @param zoom
*/
void zoomChanged(double zoom);
void zoomChanged(double zoomtotal,double zoomreal,double zoomdigi);
};
}
#endif // MAPGRAPHICITEM_H

View File

@ -41,7 +41,7 @@ namespace mapcontrol
mscene.addItem(map);
this->setScene(&mscene);
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(OnEmptyTileError(int,core::Point)),this,SIGNAL(OnEmptyTileError(int,core::Point)));
connect(map->core,SIGNAL(OnMapDrag()),this,SIGNAL(OnMapDrag()));
@ -142,6 +142,7 @@ namespace mapcontrol
{
return currentmouseposition;
}
void OPMapWidget::mouseMoveEvent(QMouseEvent *event)
{
QGraphicsView::mouseMoveEvent(event);

View File

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