mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
OP111/OP112/CC38/GCS
CC-38 - Map now has Dragons. OP-111 - Added the capability to plot trail lines. Trail dots/lines can now be shown/not_shown by selecting the option on the maps context menu. OP-112 - UAV icon on the map is know selectable on the maps options page. Also fixed an issue with the UAV/Trails not being shown while replaying logs. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3117 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
8a49dbb6ab
commit
fca5a42949
@ -1,199 +1,220 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpsitem.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a UAV
|
||||
* @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
|
||||
*/
|
||||
#include "../internals/pureprojection.h"
|
||||
#include "gpsitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
GPSItem::GPSItem(MapGraphicItem* map,OPMapWidget* parent):map(map),mapwidget(parent),showtrail(true),trailtime(5),traildistance(50),autosetreached(true)
|
||||
,autosetdistance(100)
|
||||
{
|
||||
pic.load(QString::fromUtf8(":/markers/images/mapquad.png"));
|
||||
// Don't scale but trust the image we are given
|
||||
// pic=pic.scaled(50,33,Qt::IgnoreAspectRatio);
|
||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
this->setZValue(4);
|
||||
trail=new QGraphicsItemGroup();
|
||||
trail->setParentItem(map);
|
||||
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||
mapfollowtype=UAVMapFollowType::None;
|
||||
trailtype=UAVTrailType::ByDistance;
|
||||
timer.start();
|
||||
|
||||
// rect=QRectF(0,0,renderer.defaultSize().width()*0.05,renderer.defaultSize().height()*0.05);
|
||||
|
||||
}
|
||||
GPSItem::~GPSItem()
|
||||
{
|
||||
delete trail;
|
||||
}
|
||||
|
||||
void GPSItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
// painter->rotate(-90);
|
||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||
// painter->drawRect(QRectF(-pic.width()/2,-pic.height()/2,pic.width()-1,pic.height()-1));
|
||||
}
|
||||
QRectF GPSItem::boundingRect()const
|
||||
{
|
||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||
}
|
||||
void GPSItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
||||
{
|
||||
if(coord.IsEmpty())
|
||||
lastcoord=coord;
|
||||
if(coord!=position)
|
||||
{
|
||||
|
||||
if(trailtype==UAVTrailType::ByTimeElapsed)
|
||||
{
|
||||
if(timer.elapsed()>trailtime*1000)
|
||||
{
|
||||
trail->addToGroup(new TrailItem(position,altitude,Qt::green,this));
|
||||
timer.restart();
|
||||
}
|
||||
|
||||
}
|
||||
else if(trailtype==UAVTrailType::ByDistance)
|
||||
{
|
||||
if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance)
|
||||
{
|
||||
trail->addToGroup(new TrailItem(position,altitude,Qt::green,this));
|
||||
lastcoord=position;
|
||||
}
|
||||
}
|
||||
coord=position;
|
||||
this->altitude=altitude;
|
||||
RefreshPos();
|
||||
/*if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap||mapfollowtype==UAVMapFollowType::CenterMap)
|
||||
{
|
||||
mapwidget->SetCurrentPosition(coord);
|
||||
}*/
|
||||
this->update();
|
||||
/*if(autosetreached)
|
||||
{
|
||||
foreach(QGraphicsItem* i,map->childItems())
|
||||
{
|
||||
WayPointItem* wp=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(wp)
|
||||
{
|
||||
if(Distance3D(wp->Coord(),wp->Altitude())<autosetdistance)
|
||||
{
|
||||
wp->SetReached(true);
|
||||
emit UAVReachedWayPoint(wp->Number(),wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mapwidget->Home!=0)
|
||||
{
|
||||
//verify if the UAV is inside the safety bouble
|
||||
if(Distance3D(mapwidget->Home->Coord(),mapwidget->Home->Altitude())>mapwidget->Home->SafeArea())
|
||||
{
|
||||
if(mapwidget->Home->safe!=false)
|
||||
{
|
||||
mapwidget->Home->safe=false;
|
||||
mapwidget->Home->update();
|
||||
emit UAVLeftSafetyBouble(this->coord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mapwidget->Home->safe!=true)
|
||||
{
|
||||
mapwidget->Home->safe=true;
|
||||
mapwidget->Home->update();
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the UAV Icon on the map, or rotate the map
|
||||
* depending on the display mode
|
||||
*/
|
||||
void GPSItem::SetUAVHeading(const qreal &value)
|
||||
{
|
||||
if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap)
|
||||
{
|
||||
mapwidget->SetRotate(-value);
|
||||
}
|
||||
else {
|
||||
if (this->rotation() != value)
|
||||
this->setRotation(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GPSItem::type()const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
||||
void GPSItem::RefreshPos()
|
||||
{
|
||||
localposition=map->FromLatLngToLocal(coord);
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
{
|
||||
TrailItem* w=qgraphicsitem_cast<TrailItem*>(i);
|
||||
if(w)
|
||||
w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y());
|
||||
//this->update();
|
||||
}
|
||||
|
||||
}
|
||||
void GPSItem::SetTrailType(const UAVTrailType::Types &value)
|
||||
{
|
||||
trailtype=value;
|
||||
if(trailtype==UAVTrailType::ByTimeElapsed)
|
||||
timer.restart();
|
||||
}
|
||||
void GPSItem::SetShowTrail(const bool &value)
|
||||
{
|
||||
showtrail=value;
|
||||
trail->setVisible(value);
|
||||
}
|
||||
void GPSItem::DeleteTrail()const
|
||||
{
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
delete i;
|
||||
}
|
||||
double GPSItem::Distance3D(const internals::PointLatLng &coord, const int &altitude)
|
||||
{
|
||||
return sqrt(pow(internals::PureProjection::DistanceBetweenLatLng(this->coord,coord)*1000,2)+
|
||||
pow(this->altitude-altitude,2));
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpsitem.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a UAV
|
||||
* @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
|
||||
*/
|
||||
#include "../internals/pureprojection.h"
|
||||
#include "gpsitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
GPSItem::GPSItem(MapGraphicItem* map,OPMapWidget* parent,QString uavPic):map(map),mapwidget(parent),showtrail(true),showtrailline(true),trailtime(5),traildistance(50),autosetreached(true)
|
||||
,autosetdistance(100)
|
||||
{
|
||||
pic.load(uavPic);
|
||||
// Don't scale but trust the image we are given
|
||||
// pic=pic.scaled(50,33,Qt::IgnoreAspectRatio);
|
||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
this->setZValue(4);
|
||||
trail=new QGraphicsItemGroup();
|
||||
trail->setParentItem(map);
|
||||
trailLine=new QGraphicsItemGroup();
|
||||
trailLine->setParentItem(map);
|
||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||
mapfollowtype=UAVMapFollowType::None;
|
||||
trailtype=UAVTrailType::ByDistance;
|
||||
timer.start();
|
||||
}
|
||||
GPSItem::~GPSItem()
|
||||
{
|
||||
delete trail;
|
||||
}
|
||||
|
||||
void GPSItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
// painter->rotate(-90);
|
||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||
// painter->drawRect(QRectF(-pic.width()/2,-pic.height()/2,pic.width()-1,pic.height()-1));
|
||||
}
|
||||
QRectF GPSItem::boundingRect()const
|
||||
{
|
||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||
}
|
||||
void GPSItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
||||
{
|
||||
if(coord.IsEmpty())
|
||||
lastcoord=coord;
|
||||
if(coord!=position)
|
||||
{
|
||||
|
||||
if(trailtype==UAVTrailType::ByTimeElapsed)
|
||||
{
|
||||
if(timer.elapsed()>trailtime*1000)
|
||||
{
|
||||
trail->addToGroup(new TrailItem(position,altitude,Qt::green,this));
|
||||
if(!lasttrailline.IsEmpty())
|
||||
trailLine->addToGroup((new TrailLineItem(lasttrailline,position,Qt::green,map)));
|
||||
lasttrailline=position;
|
||||
timer.restart();
|
||||
}
|
||||
|
||||
}
|
||||
else if(trailtype==UAVTrailType::ByDistance)
|
||||
{
|
||||
if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance)
|
||||
{
|
||||
trail->addToGroup(new TrailItem(position,altitude,Qt::green,this));
|
||||
if(!lasttrailline.IsEmpty())
|
||||
|
||||
trailLine->addToGroup((new TrailLineItem(lasttrailline,position,Qt::green,this)));
|
||||
lasttrailline=position;
|
||||
lastcoord=position;
|
||||
}
|
||||
}
|
||||
coord=position;
|
||||
this->altitude=altitude;
|
||||
RefreshPos();
|
||||
/*if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap||mapfollowtype==UAVMapFollowType::CenterMap)
|
||||
{
|
||||
mapwidget->SetCurrentPosition(coord);
|
||||
}*/
|
||||
this->update();
|
||||
/*if(autosetreached)
|
||||
{
|
||||
foreach(QGraphicsItem* i,map->childItems())
|
||||
{
|
||||
WayPointItem* wp=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(wp)
|
||||
{
|
||||
if(Distance3D(wp->Coord(),wp->Altitude())<autosetdistance)
|
||||
{
|
||||
wp->SetReached(true);
|
||||
emit UAVReachedWayPoint(wp->Number(),wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mapwidget->Home!=0)
|
||||
{
|
||||
//verify if the UAV is inside the safety bouble
|
||||
if(Distance3D(mapwidget->Home->Coord(),mapwidget->Home->Altitude())>mapwidget->Home->SafeArea())
|
||||
{
|
||||
if(mapwidget->Home->safe!=false)
|
||||
{
|
||||
mapwidget->Home->safe=false;
|
||||
mapwidget->Home->update();
|
||||
emit UAVLeftSafetyBouble(this->coord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mapwidget->Home->safe!=true)
|
||||
{
|
||||
mapwidget->Home->safe=true;
|
||||
mapwidget->Home->update();
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the UAV Icon on the map, or rotate the map
|
||||
* depending on the display mode
|
||||
*/
|
||||
void GPSItem::SetUAVHeading(const qreal &value)
|
||||
{
|
||||
if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap)
|
||||
{
|
||||
mapwidget->SetRotate(-value);
|
||||
}
|
||||
else {
|
||||
if (this->rotation() != value)
|
||||
this->setRotation(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GPSItem::type()const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
||||
void GPSItem::RefreshPos()
|
||||
{
|
||||
localposition=map->FromLatLngToLocal(coord);
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
{
|
||||
TrailItem* w=qgraphicsitem_cast<TrailItem*>(i);
|
||||
if(w)
|
||||
w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y());
|
||||
}
|
||||
foreach(QGraphicsItem* i,trailLine->childItems())
|
||||
{
|
||||
TrailLineItem* ww=qgraphicsitem_cast<TrailLineItem*>(i);
|
||||
if(ww)
|
||||
ww->setLine(map->FromLatLngToLocal(ww->coord1).X(),map->FromLatLngToLocal(ww->coord1).Y(),map->FromLatLngToLocal(ww->coord2).X(),map->FromLatLngToLocal(ww->coord2).Y());
|
||||
}
|
||||
|
||||
}
|
||||
void GPSItem::SetTrailType(const UAVTrailType::Types &value)
|
||||
{
|
||||
trailtype=value;
|
||||
if(trailtype==UAVTrailType::ByTimeElapsed)
|
||||
timer.restart();
|
||||
}
|
||||
void GPSItem::SetShowTrail(const bool &value)
|
||||
{
|
||||
showtrail=value;
|
||||
trail->setVisible(value);
|
||||
|
||||
}
|
||||
void GPSItem::SetShowTrailLine(const bool &value)
|
||||
{
|
||||
showtrailline=value;
|
||||
trailLine->setVisible(value);
|
||||
}
|
||||
void GPSItem::DeleteTrail()const
|
||||
{
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
delete i;
|
||||
foreach(QGraphicsItem* i,trailLine->childItems())
|
||||
delete i;
|
||||
}
|
||||
double GPSItem::Distance3D(const internals::PointLatLng &coord, const int &altitude)
|
||||
{
|
||||
return sqrt(pow(internals::PureProjection::DistanceBetweenLatLng(this->coord,coord)*1000,2)+
|
||||
pow(this->altitude-altitude,2));
|
||||
|
||||
}
|
||||
void GPSItem::SetUavPic(QString UAVPic)
|
||||
{
|
||||
pic.load(":/uavs/images/"+UAVPic);
|
||||
}
|
||||
}
|
||||
|
@ -1,209 +1,227 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpsitem.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a WayPoint
|
||||
* @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 GPSITEM_H
|
||||
#define GPSITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "../internals/pointlatlng.h"
|
||||
#include "mapgraphicitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include <QObject>
|
||||
#include "uavmapfollowtype.h"
|
||||
#include "uavtrailtype.h"
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include "opmapwidget.h"
|
||||
#include "trailitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
class WayPointItem;
|
||||
class OPMapWidget;
|
||||
/**
|
||||
* @brief A QGraphicsItem representing the UAV
|
||||
*
|
||||
* @class UAVItem gpsitem.h "mapwidget/gpsitem.h"
|
||||
*/
|
||||
class GPSItem:public QObject,public QGraphicsItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 2 };
|
||||
GPSItem(MapGraphicItem* map,OPMapWidget* parent);
|
||||
~GPSItem();
|
||||
/**
|
||||
* @brief Sets the UAV position
|
||||
*
|
||||
* @param position LatLng point
|
||||
* @param altitude altitude in meters
|
||||
*/
|
||||
void SetUAVPos(internals::PointLatLng const& position,int const& altitude);
|
||||
/**
|
||||
* @brief Sets the UAV heading
|
||||
*
|
||||
* @param value heading angle (north=0deg)
|
||||
*/
|
||||
void SetUAVHeading(qreal const& value);
|
||||
/**
|
||||
* @brief Returns the UAV position
|
||||
*
|
||||
* @return internals::PointLatLng
|
||||
*/
|
||||
internals::PointLatLng UAVPos()const{return coord;}
|
||||
/**
|
||||
* @brief Sets the Map follow type
|
||||
*
|
||||
* @param value can be "none"(map doesnt follow UAV), "CenterMap"(map moves to keep UAV centered) or "CenterAndRotateMap"(map moves and rotates to keep UAV centered and straight)
|
||||
*/
|
||||
void SetMapFollowType(UAVMapFollowType::Types const& value){mapfollowtype=value;}
|
||||
/**
|
||||
* @brief Sets the trail type
|
||||
*
|
||||
* @param value can be "NoTrail"(no trail is plotted), "ByTimeElapsed"(a trail point is plotted each TrailTime()) or ByDistance(a trail point is plotted if the distance between the UAV and the last trail point is bigger than TrailDistance())
|
||||
*/
|
||||
void SetTrailType(UAVTrailType::Types const& value);
|
||||
/**
|
||||
* @brief Returns the map follow method used
|
||||
*
|
||||
* @return UAVMapFollowType::Types
|
||||
*/
|
||||
UAVMapFollowType::Types GetMapFollowType()const{return mapfollowtype;}
|
||||
/**
|
||||
* @brief Returns the UAV trail type. It can be plotted by time elapsed or distance
|
||||
*
|
||||
* @return UAVTrailType::Types
|
||||
*/
|
||||
UAVTrailType::Types GetTrailType()const{return trailtype;}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
void RefreshPos();
|
||||
QRectF boundingRect() const;
|
||||
/**
|
||||
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
|
||||
*
|
||||
* @param seconds the UAV trail time elapsed value. If the trail type is time elapsed
|
||||
* a trail point will be plotted each "value returned" seconds.
|
||||
*/
|
||||
void SetTrailTime(int const& seconds){trailtime=seconds;}
|
||||
/**
|
||||
* @brief Returns the UAV trail time elapsed value. If the trail type is time elapsed
|
||||
* a trail point will be plotted each "value returned" seconds.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int TrailTime()const{return trailtime;}
|
||||
/**
|
||||
* @brief Sets the trail distance to be used if TrailType is ByDistance
|
||||
*
|
||||
* @param distance the UAV trail plot distance.
|
||||
* If the trail type is ByDistance a trail dot is plotted if
|
||||
* the distance between the current UAV position and the last trail point
|
||||
* is bigger than the returned value
|
||||
*/
|
||||
void SetTrailDistance(int const& distance){traildistance=distance;}
|
||||
/**
|
||||
* @brief Returns the UAV trail plot distance.
|
||||
* If the trail type is distance diference a trail dot is plotted if
|
||||
* the distance between the current UAV position and the last trail point
|
||||
* is bigger than the returned value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int TrailDistance()const{return traildistance;}
|
||||
/**
|
||||
* @brief Returns true if UAV trail is shown
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool ShowTrail()const{return showtrail;}
|
||||
/**
|
||||
* @brief Used to define if the UAV displays a trail
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetShowTrail(bool const& value);
|
||||
/**
|
||||
* @brief Deletes all the trail points
|
||||
*/
|
||||
void DeleteTrail()const;
|
||||
/**
|
||||
* @brief Returns true if the UAV automaticaly sets WP reached value (changing its color)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool AutoSetReached()const{return autosetreached;}
|
||||
/**
|
||||
* @brief Defines if the UAV can set the WP's "reached" value automaticaly.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAutoSetReached(bool const& value){autosetreached=value;}
|
||||
/**
|
||||
* @brief Returns the 3D distance in meters necessary for the UAV to set WP's to "reached"
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
double AutoSetDistance()const{return autosetdistance;}
|
||||
/**
|
||||
* @brief Sets the the 3D distance in meters necessary for the UAV to set WP's to "reached"
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAutoSetDistance(double const& value){autosetdistance=value;}
|
||||
|
||||
int type() const;
|
||||
private:
|
||||
MapGraphicItem* map;
|
||||
|
||||
int altitude;
|
||||
UAVMapFollowType::Types mapfollowtype;
|
||||
UAVTrailType::Types trailtype;
|
||||
internals::PointLatLng coord;
|
||||
internals::PointLatLng lastcoord;
|
||||
QPixmap pic;
|
||||
core::Point localposition;
|
||||
OPMapWidget* mapwidget;
|
||||
QGraphicsItemGroup* trail;
|
||||
QTime timer;
|
||||
bool showtrail;
|
||||
int trailtime;
|
||||
int traildistance;
|
||||
bool autosetreached;
|
||||
double Distance3D(internals::PointLatLng const& coord, int const& altitude);
|
||||
double autosetdistance;
|
||||
// QRectF rect;
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
||||
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
||||
};
|
||||
}
|
||||
#endif // GPSITEM_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpsitem.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a WayPoint
|
||||
* @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 GPSITEM_H
|
||||
#define GPSITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "../internals/pointlatlng.h"
|
||||
#include "mapgraphicitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include <QObject>
|
||||
#include "uavmapfollowtype.h"
|
||||
#include "uavtrailtype.h"
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include "opmapwidget.h"
|
||||
#include "trailitem.h"
|
||||
#include "traillineitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
class WayPointItem;
|
||||
class OPMapWidget;
|
||||
/**
|
||||
* @brief A QGraphicsItem representing the UAV
|
||||
*
|
||||
* @class UAVItem gpsitem.h "mapwidget/gpsitem.h"
|
||||
*/
|
||||
class GPSItem:public QObject,public QGraphicsItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 6 };
|
||||
GPSItem(MapGraphicItem* map,OPMapWidget* parent, QString uavPic=QString::fromUtf8(":/uavs/images/mapquad.png"));
|
||||
~GPSItem();
|
||||
/**
|
||||
* @brief Sets the UAV position
|
||||
*
|
||||
* @param position LatLng point
|
||||
* @param altitude altitude in meters
|
||||
*/
|
||||
void SetUAVPos(internals::PointLatLng const& position,int const& altitude);
|
||||
/**
|
||||
* @brief Sets the UAV heading
|
||||
*
|
||||
* @param value heading angle (north=0deg)
|
||||
*/
|
||||
void SetUAVHeading(qreal const& value);
|
||||
/**
|
||||
* @brief Returns the UAV position
|
||||
*
|
||||
* @return internals::PointLatLng
|
||||
*/
|
||||
internals::PointLatLng UAVPos()const{return coord;}
|
||||
/**
|
||||
* @brief Sets the Map follow type
|
||||
*
|
||||
* @param value can be "none"(map doesnt follow UAV), "CenterMap"(map moves to keep UAV centered) or "CenterAndRotateMap"(map moves and rotates to keep UAV centered and straight)
|
||||
*/
|
||||
void SetMapFollowType(UAVMapFollowType::Types const& value){mapfollowtype=value;}
|
||||
/**
|
||||
* @brief Sets the trail type
|
||||
*
|
||||
* @param value can be "NoTrail"(no trail is plotted), "ByTimeElapsed"(a trail point is plotted each TrailTime()) or ByDistance(a trail point is plotted if the distance between the UAV and the last trail point is bigger than TrailDistance())
|
||||
*/
|
||||
void SetTrailType(UAVTrailType::Types const& value);
|
||||
/**
|
||||
* @brief Returns the map follow method used
|
||||
*
|
||||
* @return UAVMapFollowType::Types
|
||||
*/
|
||||
UAVMapFollowType::Types GetMapFollowType()const{return mapfollowtype;}
|
||||
/**
|
||||
* @brief Returns the UAV trail type. It can be plotted by time elapsed or distance
|
||||
*
|
||||
* @return UAVTrailType::Types
|
||||
*/
|
||||
UAVTrailType::Types GetTrailType()const{return trailtype;}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
void RefreshPos();
|
||||
QRectF boundingRect() const;
|
||||
/**
|
||||
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
|
||||
*
|
||||
* @param seconds the UAV trail time elapsed value. If the trail type is time elapsed
|
||||
* a trail point will be plotted each "value returned" seconds.
|
||||
*/
|
||||
void SetTrailTime(int const& seconds){trailtime=seconds;}
|
||||
/**
|
||||
* @brief Returns the UAV trail time elapsed value. If the trail type is time elapsed
|
||||
* a trail point will be plotted each "value returned" seconds.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int TrailTime()const{return trailtime;}
|
||||
/**
|
||||
* @brief Sets the trail distance to be used if TrailType is ByDistance
|
||||
*
|
||||
* @param distance the UAV trail plot distance.
|
||||
* If the trail type is ByDistance a trail dot is plotted if
|
||||
* the distance between the current UAV position and the last trail point
|
||||
* is bigger than the returned value
|
||||
*/
|
||||
void SetTrailDistance(int const& distance){traildistance=distance;}
|
||||
/**
|
||||
* @brief Returns the UAV trail plot distance.
|
||||
* If the trail type is distance diference a trail dot is plotted if
|
||||
* the distance between the current UAV position and the last trail point
|
||||
* is bigger than the returned value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int TrailDistance()const{return traildistance;}
|
||||
/**
|
||||
* @brief Returns true if UAV trail is shown
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool ShowTrail()const{return showtrail;}
|
||||
/**
|
||||
* @brief Returns true if UAV trail line is shown
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool ShowTrailLine()const{return showtrailline;}
|
||||
/**
|
||||
* @brief Used to define if the UAV displays a trail
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetShowTrail(bool const& value);
|
||||
/**
|
||||
* @brief Used to define if the UAV displays a trail line
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetShowTrailLine(bool const& value);
|
||||
/**
|
||||
* @brief Deletes all the trail points
|
||||
*/
|
||||
void DeleteTrail()const;
|
||||
/**
|
||||
* @brief Returns true if the UAV automaticaly sets WP reached value (changing its color)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool AutoSetReached()const{return autosetreached;}
|
||||
/**
|
||||
* @brief Defines if the UAV can set the WP's "reached" value automaticaly.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAutoSetReached(bool const& value){autosetreached=value;}
|
||||
/**
|
||||
* @brief Returns the 3D distance in meters necessary for the UAV to set WP's to "reached"
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
double AutoSetDistance()const{return autosetdistance;}
|
||||
/**
|
||||
* @brief Sets the the 3D distance in meters necessary for the UAV to set WP's to "reached"
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAutoSetDistance(double const& value){autosetdistance=value;}
|
||||
|
||||
int type() const;
|
||||
|
||||
void SetUavPic(QString UAVPic);
|
||||
private:
|
||||
MapGraphicItem* map;
|
||||
|
||||
int altitude;
|
||||
UAVMapFollowType::Types mapfollowtype;
|
||||
UAVTrailType::Types trailtype;
|
||||
internals::PointLatLng coord;
|
||||
internals::PointLatLng lastcoord;
|
||||
QPixmap pic;
|
||||
core::Point localposition;
|
||||
OPMapWidget* mapwidget;
|
||||
QGraphicsItemGroup* trail;
|
||||
QGraphicsItemGroup * trailLine;
|
||||
internals::PointLatLng lasttrailline;
|
||||
QTime timer;
|
||||
bool showtrail;
|
||||
bool showtrailline;
|
||||
int trailtime;
|
||||
int traildistance;
|
||||
bool autosetreached;
|
||||
double Distance3D(internals::PointLatLng const& coord, int const& altitude);
|
||||
double autosetdistance;
|
||||
// QRectF rect;
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
||||
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
||||
};
|
||||
}
|
||||
#endif // GPSITEM_H
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 168 KiB |
Binary file not shown.
After Width: | Height: | Size: 91 KiB |
@ -1,583 +1,584 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mapgraphicitem.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||
* @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
|
||||
*/
|
||||
#include "uavitem.h"
|
||||
#include "gpsitem.h"
|
||||
#include "homeitem.h"
|
||||
#include "mapgraphicitem.h"
|
||||
|
||||
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),zoomDigi(0)
|
||||
{
|
||||
|
||||
showTileGridLines=false;
|
||||
isMouseOverMarker=false;
|
||||
maprect=QRectF(0,0,1022,680);
|
||||
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
|
||||
core->SetMapType(MapType::GoogleHybrid);
|
||||
this->SetZoom(2);
|
||||
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
|
||||
connect(core,SIGNAL(OnMapDrag()),this,SLOT(ChildPosRefresh()));
|
||||
connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(ChildPosRefresh()));
|
||||
//resize();
|
||||
}
|
||||
void MapGraphicItem::start()
|
||||
{
|
||||
core->StartSystem();
|
||||
}
|
||||
|
||||
void MapGraphicItem::resize(const QRectF &rect)
|
||||
{
|
||||
Q_UNUSED(rect);
|
||||
{
|
||||
this->prepareGeometryChange();
|
||||
maprect=boundingBox(scene()->sceneRect(),rotation);
|
||||
this->setTransform(QTransform().translate(-(maprect.width()-scene()->width())/2,-(maprect.height()-scene()->height())/2));
|
||||
this->setTransformOriginPoint(maprect.center().x(),maprect.center().y());
|
||||
this->setRotation(rotation);
|
||||
}
|
||||
|
||||
core->OnMapSizeChanged(maprect.width(),maprect.height());
|
||||
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
|
||||
if(isVisible())
|
||||
{
|
||||
core->GoToCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
||||
QRectF MapGraphicItem::boundingRect() const
|
||||
{
|
||||
const int Margin = 1;
|
||||
return maprect.adjusted(-Margin, -Margin, +Margin, +Margin);
|
||||
}
|
||||
void MapGraphicItem::Core_OnNeedInvalidation()
|
||||
{
|
||||
this->update();
|
||||
foreach(QGraphicsItem* i,this->childItems())
|
||||
{
|
||||
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(w)
|
||||
w->RefreshPos();
|
||||
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
|
||||
if(ww)
|
||||
ww->RefreshPos();
|
||||
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
|
||||
if(www)
|
||||
www->RefreshPos();
|
||||
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
|
||||
if(wwww)
|
||||
wwww->RefreshPos();
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::ChildPosRefresh()
|
||||
{
|
||||
foreach(QGraphicsItem* i,this->childItems())
|
||||
{
|
||||
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(w)
|
||||
w->RefreshPos();
|
||||
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
|
||||
if(ww)
|
||||
ww->RefreshPos();
|
||||
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
|
||||
if(www)
|
||||
www->RefreshPos();
|
||||
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
|
||||
if(wwww)
|
||||
wwww->RefreshPos();
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
|
||||
{
|
||||
QImage temp;
|
||||
QSize size=boundingRect().size().toSize();
|
||||
size.setWidth(size.width()*2*zoomdiff);
|
||||
size.setHeight(size.height()*2*zoomdiff);
|
||||
temp=QImage(size,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
temp.fill(0);
|
||||
QPainter imagePainter(&temp);
|
||||
imagePainter.translate(-boundingRect().topLeft());
|
||||
imagePainter.scale(2*zoomdiff,2*zoomdiff);
|
||||
paintImage(&imagePainter);
|
||||
imagePainter.end();
|
||||
lastimagepoint=Point(core->GetrenderOffset().X()*2*zoomdiff,core->GetrenderOffset().Y()*2*zoomdiff);
|
||||
lastimage=temp;
|
||||
}
|
||||
void MapGraphicItem::paintImage(QPainter *painter)
|
||||
{
|
||||
|
||||
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);
|
||||
}
|
||||
painter->resetTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawMap2D(painter);
|
||||
}
|
||||
//painter->drawRect(maprect);
|
||||
}
|
||||
void MapGraphicItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
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);
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform,true);
|
||||
painter->setRenderHint(QPainter::HighQualityAntialiasing,true);
|
||||
|
||||
{
|
||||
DrawMap2D(painter);
|
||||
}
|
||||
painter->resetTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawMap2D(painter);
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(core->IsDragging())
|
||||
{
|
||||
if(MapRenderTransform!=1)
|
||||
{
|
||||
qreal dx= (event->pos().x()-core->mouseDown.X())/(MapRenderTransform);
|
||||
qreal dy= (event->pos().y()-core->mouseDown.Y())/(MapRenderTransform);
|
||||
qreal nx=core->mouseDown.X()+dx;
|
||||
qreal ny=core->mouseDown.Y()+dy;
|
||||
core->mouseCurrent.SetX(nx);
|
||||
core->mouseCurrent.SetY(ny);
|
||||
}
|
||||
else
|
||||
{
|
||||
core->mouseCurrent.SetX(event->pos().x());
|
||||
core->mouseCurrent.SetY(event->pos().y());
|
||||
}
|
||||
{
|
||||
core->Drag(core->mouseCurrent);
|
||||
}
|
||||
|
||||
}
|
||||
else if(isSelected && !selectionStart.IsEmpty() && (event->modifiers() == Qt::AltModifier || event->modifiers() == Qt::ShiftModifier))
|
||||
{
|
||||
selectionEnd = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||
{
|
||||
internals::PointLatLng p1 = selectionStart;
|
||||
internals::PointLatLng p2 = selectionEnd;
|
||||
|
||||
double x1 = qMin(p1.Lng(), p2.Lng());
|
||||
double y1 = qMax(p1.Lat(), p2.Lat());
|
||||
double x2 = qMax(p1.Lng(), p2.Lng());
|
||||
double y2 = qMin(p1.Lat(), p2.Lat());
|
||||
|
||||
SetSelectedArea(internals::RectLatLng(y1, x1, x2 - x1, y1 - y2));
|
||||
}
|
||||
}
|
||||
QGraphicsItem::mouseMoveEvent(event);
|
||||
}
|
||||
void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if(!IsMouseOverMarker())
|
||||
{
|
||||
if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
||||
{
|
||||
core->mouseDown.SetX(event->pos().x());
|
||||
core->mouseDown.SetY(event->pos().y());
|
||||
|
||||
|
||||
this->setCursor(Qt::SizeAllCursor);
|
||||
|
||||
core->BeginDrag(core->mouseDown);
|
||||
this->update();
|
||||
|
||||
}
|
||||
else if(!isSelected && ((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
||||
{
|
||||
isSelected = true;
|
||||
SetSelectedArea (internals::RectLatLng::Empty);
|
||||
selectionEnd = internals::PointLatLng::Empty;
|
||||
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
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() && event->modifiers() == Qt::ShiftModifier)
|
||||
{
|
||||
SetZoomToFitRect(SelectedArea());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
bool MapGraphicItem::SetZoomToFitRect(internals::RectLatLng const& rect)
|
||||
{
|
||||
int maxZoom = core->GetMaxZoomToFitRect(rect);
|
||||
if(maxZoom > 0)
|
||||
{
|
||||
internals::PointLatLng center=internals::PointLatLng(rect.Lat()-(rect.HeightLat()/2), rect.Lng()+(rect.WidthLng()/2));
|
||||
core->SetCurrentPosition(center);
|
||||
|
||||
if(maxZoom > MaxZoom())
|
||||
{
|
||||
maxZoom = MaxZoom();
|
||||
}
|
||||
|
||||
if((int) Zoom() != maxZoom)
|
||||
{
|
||||
SetZoom(maxZoom);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
|
||||
{
|
||||
|
||||
if(!IsMouseOverMarker() && !IsDragging())
|
||||
{
|
||||
if(core->GetmouseLastZoom().X() != event->pos().x() && core->mouseLastZoom.Y() != event->pos().y())
|
||||
{
|
||||
if(GetMouseWheelZoomType() == internals::MouseWheelZoomType::MousePositionAndCenter)
|
||||
{
|
||||
core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
|
||||
}
|
||||
else if(GetMouseWheelZoomType() == internals::MouseWheelZoomType::ViewCenter)
|
||||
{
|
||||
core->SetCurrentPosition(FromLocalToLatLng((int) maprect.width()/2, (int) maprect.height()/2));
|
||||
}
|
||||
else if(GetMouseWheelZoomType() == internals::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() != internals::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(ZoomTotal()+1);
|
||||
}
|
||||
else if(event->delta() < 0)
|
||||
{
|
||||
SetZoom(ZoomTotal()-1);
|
||||
}
|
||||
|
||||
core->MouseWheelZooming = false;
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::DrawMap2D(QPainter *painter)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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));
|
||||
{
|
||||
internals::Tile* t = core->Matrix.TileAt(core->GettilePoint());
|
||||
if(true)
|
||||
{
|
||||
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)
|
||||
if(t!=0)
|
||||
{
|
||||
foreach(QByteArray img,t->Overlays)
|
||||
{
|
||||
if(img.count()!=0)
|
||||
{
|
||||
if(!found)
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(showTileGridLines)
|
||||
{
|
||||
painter->setPen(config->EmptyTileBorders);
|
||||
painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
|
||||
{
|
||||
painter->setFont(config->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(false)
|
||||
{
|
||||
|
||||
painter->fillRect(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),config->EmptytileBrush);
|
||||
painter->setFont(config->MissingDataFont);
|
||||
painter->drawText(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),config->EmptyTileText);
|
||||
|
||||
|
||||
|
||||
painter->setPen(config->EmptyTileBorders);
|
||||
painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
|
||||
|
||||
// raise error
|
||||
|
||||
}
|
||||
if(!SelectedArea().IsEmpty())
|
||||
{
|
||||
core::Point p1 = FromLatLngToLocal(SelectedArea().LocationTopLeft());
|
||||
core::Point p2 = FromLatLngToLocal(SelectedArea().LocationRightBottom());
|
||||
int x1 = p1.X();
|
||||
int y1 = p1.Y();
|
||||
int x2 = p2.X();
|
||||
int y2 = p2.Y();
|
||||
painter->setPen(Qt::black);
|
||||
painter->setBrush(QBrush(QColor(50,50,100,20)));
|
||||
painter->drawRect(x1,y1,x2-x1,y2-y1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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));
|
||||
}
|
||||
|
||||
|
||||
core::Point MapGraphicItem::FromLatLngToLocal(internals::PointLatLng const& point)
|
||||
{
|
||||
core::Point ret = core->FromLatLngToLocal(point);
|
||||
if(MapRenderTransform!=1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
double MapGraphicItem::Zoom()
|
||||
{
|
||||
return zoomReal;
|
||||
}
|
||||
double MapGraphicItem::ZoomDigi()
|
||||
{
|
||||
return zoomDigi;
|
||||
}
|
||||
double MapGraphicItem::ZoomTotal()
|
||||
{
|
||||
return zoomDigi+zoomReal;
|
||||
}
|
||||
|
||||
void MapGraphicItem::SetZoom(double const& 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;
|
||||
}
|
||||
double integer;
|
||||
double remainder = modf (value , &integer);
|
||||
if(zoomDigi!=0||remainder != 0)
|
||||
{
|
||||
float scaleValue = zoomDigi+remainder + 1;
|
||||
{
|
||||
MapRenderTransform = scaleValue;
|
||||
// qDebug()<<"scale="<<scaleValue<<"zoomdigi:"<<ZoomDigi()<<"integer:"<<integer;
|
||||
}
|
||||
if(integer>MaxZoom())
|
||||
integer=MaxZoom();
|
||||
SetZoomStep((qint32)(integer));
|
||||
// core->GoToCurrentPositionOnZoom();
|
||||
this->update();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
MapRenderTransform = 1;
|
||||
|
||||
SetZoomStep ((qint32)(value));
|
||||
zoomReal = ZoomStep();
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
int MapGraphicItem::ZoomStep()const
|
||||
{
|
||||
return core->Zoom();
|
||||
}
|
||||
void MapGraphicItem::SetZoomStep(int const& value)
|
||||
{
|
||||
if(value-core->Zoom()>0 && value<= MaxZoom())
|
||||
ConstructLastImage(value-core->Zoom());
|
||||
else if(value!=MaxZoom())
|
||||
lastimage=QImage();
|
||||
if(value > MaxZoom())
|
||||
{
|
||||
core->SetZoom(MaxZoom());
|
||||
emit zoomChanged(MaxZoom()+ZoomDigi(),Zoom(),ZoomDigi());
|
||||
}
|
||||
else if(value < MinZoom())
|
||||
{
|
||||
core->SetZoom(MinZoom());
|
||||
emit zoomChanged(MinZoom()+ZoomDigi(),Zoom(),ZoomDigi());
|
||||
}
|
||||
else
|
||||
{
|
||||
core->SetZoom(value);
|
||||
emit zoomChanged(value+ZoomDigi(),Zoom(),ZoomDigi());;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MapGraphicItem::Offset(int const& x, int const& y)
|
||||
{
|
||||
core->DragOffset(Point(x, y));
|
||||
}
|
||||
void MapGraphicItem::mapRotate(qreal angle)
|
||||
{
|
||||
if (rotation != angle) {
|
||||
rotation=angle;
|
||||
resize(scene()->sceneRect());
|
||||
}
|
||||
}
|
||||
QRectF MapGraphicItem::boundingBox(const QRectF &rect, const qreal &angle)
|
||||
{
|
||||
QRectF ret(rect);
|
||||
float c=cos(angle*2*M_PI/360);
|
||||
float s=sin(angle*2*M_PI/360);
|
||||
ret.setHeight(rect.height()*fabs(c)+rect.width()*fabs(s));
|
||||
ret.setWidth(rect.width()*fabs(c)+rect.height()*fabs(s));
|
||||
return ret;
|
||||
}
|
||||
QSize MapGraphicItem::sizeHint()const
|
||||
{
|
||||
core::Size size=core->projection->GetTileMatrixMaxXY(MinZoom());
|
||||
core::Size tilesize=core->projection->TileSize();
|
||||
QSize rsize((size.Width()+1)*tilesize.Width(),(size.Height()+1)*tilesize.Height());
|
||||
return rsize;
|
||||
}
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mapgraphicitem.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||
* @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
|
||||
*/
|
||||
#include "uavitem.h"
|
||||
#include "gpsitem.h"
|
||||
#include "homeitem.h"
|
||||
#include "mapgraphicitem.h"
|
||||
|
||||
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),zoomDigi(0)
|
||||
{
|
||||
dragons.load(QString::fromUtf8(":/markers/images/dragons1.jpg"));
|
||||
showTileGridLines=false;
|
||||
isMouseOverMarker=false;
|
||||
maprect=QRectF(0,0,1022,680);
|
||||
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
|
||||
core->SetMapType(MapType::GoogleHybrid);
|
||||
this->SetZoom(2);
|
||||
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
|
||||
connect(core,SIGNAL(OnMapDrag()),this,SLOT(ChildPosRefresh()));
|
||||
connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(ChildPosRefresh()));
|
||||
//resize();
|
||||
}
|
||||
void MapGraphicItem::start()
|
||||
{
|
||||
core->StartSystem();
|
||||
}
|
||||
|
||||
void MapGraphicItem::resize(const QRectF &rect)
|
||||
{
|
||||
Q_UNUSED(rect);
|
||||
{
|
||||
this->prepareGeometryChange();
|
||||
maprect=boundingBox(scene()->sceneRect(),rotation);
|
||||
this->setTransform(QTransform().translate(-(maprect.width()-scene()->width())/2,-(maprect.height()-scene()->height())/2));
|
||||
this->setTransformOriginPoint(maprect.center().x(),maprect.center().y());
|
||||
this->setRotation(rotation);
|
||||
}
|
||||
|
||||
core->OnMapSizeChanged(maprect.width(),maprect.height());
|
||||
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
|
||||
if(isVisible())
|
||||
{
|
||||
core->GoToCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
||||
QRectF MapGraphicItem::boundingRect() const
|
||||
{
|
||||
const int Margin = 1;
|
||||
return maprect.adjusted(-Margin, -Margin, +Margin, +Margin);
|
||||
}
|
||||
void MapGraphicItem::Core_OnNeedInvalidation()
|
||||
{
|
||||
this->update();
|
||||
foreach(QGraphicsItem* i,this->childItems())
|
||||
{
|
||||
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(w)
|
||||
w->RefreshPos();
|
||||
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
|
||||
if(ww)
|
||||
ww->RefreshPos();
|
||||
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
|
||||
if(www)
|
||||
www->RefreshPos();
|
||||
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
|
||||
if(wwww)
|
||||
wwww->RefreshPos();
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::ChildPosRefresh()
|
||||
{
|
||||
foreach(QGraphicsItem* i,this->childItems())
|
||||
{
|
||||
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(w)
|
||||
w->RefreshPos();
|
||||
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
|
||||
if(ww)
|
||||
ww->RefreshPos();
|
||||
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
|
||||
if(www)
|
||||
www->RefreshPos();
|
||||
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
|
||||
if(wwww)
|
||||
wwww->RefreshPos();
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
|
||||
{
|
||||
QImage temp;
|
||||
QSize size=boundingRect().size().toSize();
|
||||
size.setWidth(size.width()*2*zoomdiff);
|
||||
size.setHeight(size.height()*2*zoomdiff);
|
||||
temp=QImage(size,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
temp.fill(0);
|
||||
QPainter imagePainter(&temp);
|
||||
imagePainter.translate(-boundingRect().topLeft());
|
||||
imagePainter.scale(2*zoomdiff,2*zoomdiff);
|
||||
paintImage(&imagePainter);
|
||||
imagePainter.end();
|
||||
lastimagepoint=Point(core->GetrenderOffset().X()*2*zoomdiff,core->GetrenderOffset().Y()*2*zoomdiff);
|
||||
lastimage=temp;
|
||||
}
|
||||
void MapGraphicItem::paintImage(QPainter *painter)
|
||||
{
|
||||
|
||||
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);
|
||||
}
|
||||
painter->resetTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawMap2D(painter);
|
||||
}
|
||||
//painter->drawRect(maprect);
|
||||
}
|
||||
void MapGraphicItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
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);
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform,true);
|
||||
painter->setRenderHint(QPainter::HighQualityAntialiasing,true);
|
||||
|
||||
{
|
||||
DrawMap2D(painter);
|
||||
}
|
||||
painter->resetTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawMap2D(painter);
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(core->IsDragging())
|
||||
{
|
||||
if(MapRenderTransform!=1)
|
||||
{
|
||||
qreal dx= (event->pos().x()-core->mouseDown.X())/(MapRenderTransform);
|
||||
qreal dy= (event->pos().y()-core->mouseDown.Y())/(MapRenderTransform);
|
||||
qreal nx=core->mouseDown.X()+dx;
|
||||
qreal ny=core->mouseDown.Y()+dy;
|
||||
core->mouseCurrent.SetX(nx);
|
||||
core->mouseCurrent.SetY(ny);
|
||||
}
|
||||
else
|
||||
{
|
||||
core->mouseCurrent.SetX(event->pos().x());
|
||||
core->mouseCurrent.SetY(event->pos().y());
|
||||
}
|
||||
{
|
||||
core->Drag(core->mouseCurrent);
|
||||
}
|
||||
|
||||
}
|
||||
else if(isSelected && !selectionStart.IsEmpty() && (event->modifiers() == Qt::AltModifier || event->modifiers() == Qt::ShiftModifier))
|
||||
{
|
||||
selectionEnd = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||
{
|
||||
internals::PointLatLng p1 = selectionStart;
|
||||
internals::PointLatLng p2 = selectionEnd;
|
||||
|
||||
double x1 = qMin(p1.Lng(), p2.Lng());
|
||||
double y1 = qMax(p1.Lat(), p2.Lat());
|
||||
double x2 = qMax(p1.Lng(), p2.Lng());
|
||||
double y2 = qMin(p1.Lat(), p2.Lat());
|
||||
|
||||
SetSelectedArea(internals::RectLatLng(y1, x1, x2 - x1, y1 - y2));
|
||||
}
|
||||
}
|
||||
QGraphicsItem::mouseMoveEvent(event);
|
||||
}
|
||||
void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if(!IsMouseOverMarker())
|
||||
{
|
||||
if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
||||
{
|
||||
core->mouseDown.SetX(event->pos().x());
|
||||
core->mouseDown.SetY(event->pos().y());
|
||||
|
||||
|
||||
this->setCursor(Qt::SizeAllCursor);
|
||||
|
||||
core->BeginDrag(core->mouseDown);
|
||||
this->update();
|
||||
|
||||
}
|
||||
else if(!isSelected && ((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
||||
{
|
||||
isSelected = true;
|
||||
SetSelectedArea (internals::RectLatLng::Empty);
|
||||
selectionEnd = internals::PointLatLng::Empty;
|
||||
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
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() && event->modifiers() == Qt::ShiftModifier)
|
||||
{
|
||||
SetZoomToFitRect(SelectedArea());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
bool MapGraphicItem::SetZoomToFitRect(internals::RectLatLng const& rect)
|
||||
{
|
||||
int maxZoom = core->GetMaxZoomToFitRect(rect);
|
||||
if(maxZoom > 0)
|
||||
{
|
||||
internals::PointLatLng center=internals::PointLatLng(rect.Lat()-(rect.HeightLat()/2), rect.Lng()+(rect.WidthLng()/2));
|
||||
core->SetCurrentPosition(center);
|
||||
|
||||
if(maxZoom > MaxZoom())
|
||||
{
|
||||
maxZoom = MaxZoom();
|
||||
}
|
||||
|
||||
if((int) Zoom() != maxZoom)
|
||||
{
|
||||
SetZoom(maxZoom);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
|
||||
{
|
||||
|
||||
if(!IsMouseOverMarker() && !IsDragging())
|
||||
{
|
||||
if(core->GetmouseLastZoom().X() != event->pos().x() && core->mouseLastZoom.Y() != event->pos().y())
|
||||
{
|
||||
if(GetMouseWheelZoomType() == internals::MouseWheelZoomType::MousePositionAndCenter)
|
||||
{
|
||||
core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
|
||||
}
|
||||
else if(GetMouseWheelZoomType() == internals::MouseWheelZoomType::ViewCenter)
|
||||
{
|
||||
core->SetCurrentPosition(FromLocalToLatLng((int) maprect.width()/2, (int) maprect.height()/2));
|
||||
}
|
||||
else if(GetMouseWheelZoomType() == internals::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() != internals::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(ZoomTotal()+1);
|
||||
}
|
||||
else if(event->delta() < 0)
|
||||
{
|
||||
SetZoom(ZoomTotal()-1);
|
||||
}
|
||||
|
||||
core->MouseWheelZooming = false;
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::DrawMap2D(QPainter *painter)
|
||||
{
|
||||
painter->drawImage(this->boundingRect(),dragons.toImage());
|
||||
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++)
|
||||
{
|
||||
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));
|
||||
{
|
||||
internals::Tile* t = core->Matrix.TileAt(core->GettilePoint());
|
||||
if(true)
|
||||
{
|
||||
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)
|
||||
if(t!=0)
|
||||
{
|
||||
foreach(QByteArray img,t->Overlays)
|
||||
{
|
||||
if(img.count()!=0)
|
||||
{
|
||||
if(!found)
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(showTileGridLines)
|
||||
{
|
||||
painter->setPen(config->EmptyTileBorders);
|
||||
painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
|
||||
{
|
||||
painter->setFont(config->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(false)
|
||||
{
|
||||
|
||||
painter->fillRect(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),config->EmptytileBrush);
|
||||
painter->setFont(config->MissingDataFont);
|
||||
painter->drawText(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),config->EmptyTileText);
|
||||
|
||||
|
||||
|
||||
painter->setPen(config->EmptyTileBorders);
|
||||
painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
|
||||
|
||||
// raise error
|
||||
|
||||
}
|
||||
if(!SelectedArea().IsEmpty())
|
||||
{
|
||||
core::Point p1 = FromLatLngToLocal(SelectedArea().LocationTopLeft());
|
||||
core::Point p2 = FromLatLngToLocal(SelectedArea().LocationRightBottom());
|
||||
int x1 = p1.X();
|
||||
int y1 = p1.Y();
|
||||
int x2 = p2.X();
|
||||
int y2 = p2.Y();
|
||||
painter->setPen(Qt::black);
|
||||
painter->setBrush(QBrush(QColor(50,50,100,20)));
|
||||
painter->drawRect(x1,y1,x2-x1,y2-y1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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));
|
||||
}
|
||||
|
||||
|
||||
core::Point MapGraphicItem::FromLatLngToLocal(internals::PointLatLng const& point)
|
||||
{
|
||||
core::Point ret = core->FromLatLngToLocal(point);
|
||||
if(MapRenderTransform!=1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
double MapGraphicItem::Zoom()
|
||||
{
|
||||
return zoomReal;
|
||||
}
|
||||
double MapGraphicItem::ZoomDigi()
|
||||
{
|
||||
return zoomDigi;
|
||||
}
|
||||
double MapGraphicItem::ZoomTotal()
|
||||
{
|
||||
return zoomDigi+zoomReal;
|
||||
}
|
||||
|
||||
void MapGraphicItem::SetZoom(double const& 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;
|
||||
}
|
||||
double integer;
|
||||
double remainder = modf (value , &integer);
|
||||
if(zoomDigi!=0||remainder != 0)
|
||||
{
|
||||
float scaleValue = zoomDigi+remainder + 1;
|
||||
{
|
||||
MapRenderTransform = scaleValue;
|
||||
// qDebug()<<"scale="<<scaleValue<<"zoomdigi:"<<ZoomDigi()<<"integer:"<<integer;
|
||||
}
|
||||
if(integer>MaxZoom())
|
||||
integer=MaxZoom();
|
||||
SetZoomStep((qint32)(integer));
|
||||
// core->GoToCurrentPositionOnZoom();
|
||||
this->update();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
MapRenderTransform = 1;
|
||||
|
||||
SetZoomStep ((qint32)(value));
|
||||
zoomReal = ZoomStep();
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
int MapGraphicItem::ZoomStep()const
|
||||
{
|
||||
return core->Zoom();
|
||||
}
|
||||
void MapGraphicItem::SetZoomStep(int const& value)
|
||||
{
|
||||
if(value-core->Zoom()>0 && value<= MaxZoom())
|
||||
ConstructLastImage(value-core->Zoom());
|
||||
else if(value!=MaxZoom())
|
||||
lastimage=QImage();
|
||||
if(value > MaxZoom())
|
||||
{
|
||||
core->SetZoom(MaxZoom());
|
||||
emit zoomChanged(MaxZoom()+ZoomDigi(),Zoom(),ZoomDigi());
|
||||
}
|
||||
else if(value < MinZoom())
|
||||
{
|
||||
core->SetZoom(MinZoom());
|
||||
emit zoomChanged(MinZoom()+ZoomDigi(),Zoom(),ZoomDigi());
|
||||
}
|
||||
else
|
||||
{
|
||||
core->SetZoom(value);
|
||||
emit zoomChanged(value+ZoomDigi(),Zoom(),ZoomDigi());;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MapGraphicItem::Offset(int const& x, int const& y)
|
||||
{
|
||||
core->DragOffset(Point(x, y));
|
||||
}
|
||||
void MapGraphicItem::mapRotate(qreal angle)
|
||||
{
|
||||
if (rotation != angle) {
|
||||
rotation=angle;
|
||||
resize(scene()->sceneRect());
|
||||
}
|
||||
}
|
||||
QRectF MapGraphicItem::boundingBox(const QRectF &rect, const qreal &angle)
|
||||
{
|
||||
QRectF ret(rect);
|
||||
float c=cos(angle*2*M_PI/360);
|
||||
float s=sin(angle*2*M_PI/360);
|
||||
ret.setHeight(rect.height()*fabs(c)+rect.width()*fabs(s));
|
||||
ret.setWidth(rect.width()*fabs(c)+rect.height()*fabs(s));
|
||||
return ret;
|
||||
}
|
||||
QSize MapGraphicItem::sizeHint()const
|
||||
{
|
||||
core::Size size=core->projection->GetTileMatrixMaxXY(MinZoom());
|
||||
core::Size tilesize=core->projection->TileSize();
|
||||
QSize rsize((size.Width()+1)*tilesize.Width(),(size.Height()+1)*tilesize.Height());
|
||||
return rsize;
|
||||
}
|
||||
}
|
||||
|
@ -121,8 +121,14 @@ namespace mapcontrol
|
||||
*/
|
||||
void SetZoomStep(int const& value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Ask Stacey
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetShowDragons(bool const& value);
|
||||
private:
|
||||
bool showDragons;
|
||||
bool SetZoomToFitRect(internals::RectLatLng const& rect);
|
||||
internals::Core *core;
|
||||
Configuration *config;
|
||||
@ -149,6 +155,7 @@ namespace mapcontrol
|
||||
QRectF maprect;
|
||||
bool isSelected;
|
||||
bool isMouseOverMarker;
|
||||
QPixmap dragons;
|
||||
void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
|
||||
|
||||
qreal rotation;
|
||||
|
@ -1,14 +1,21 @@
|
||||
<RCC>
|
||||
<qresource prefix="/markers">
|
||||
<file>images/bigMarkerGreen.png</file>
|
||||
<file>images/marker.png</file>
|
||||
<file>images/compas.svg</file>
|
||||
<file>images/airplane.svg</file>
|
||||
<file>images/home.png</file>
|
||||
<file>images/home.svg</file>
|
||||
<file>images/home2.svg</file>
|
||||
<file>images/airplanepip.png</file>
|
||||
<file>images/EasystarBlue.png</file>
|
||||
<file>images/mapquad.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
<RCC>
|
||||
<qresource prefix="/markers">
|
||||
<file>images/bigMarkerGreen.png</file>
|
||||
<file>images/marker.png</file>
|
||||
<file>images/compas.svg</file>
|
||||
<file>images/airplane.svg</file>
|
||||
<file>images/home.png</file>
|
||||
<file>images/home.svg</file>
|
||||
<file>images/home2.svg</file>
|
||||
<file>images/airplanepip.png</file>
|
||||
<file>images/EasystarBlue.png</file>
|
||||
<file>images/mapquad.png</file>
|
||||
<file>images/dragons1.jpg</file>
|
||||
<file>images/dragons2.jpeg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/uavs">
|
||||
<file>images/airplanepip.png</file>
|
||||
<file>images/EasystarBlue.png</file>
|
||||
<file>images/mapquad.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -13,7 +13,8 @@ SOURCES += mapgraphicitem.cpp \
|
||||
trailitem.cpp \
|
||||
homeitem.cpp \
|
||||
mapripform.cpp \
|
||||
mapripper.cpp
|
||||
mapripper.cpp \
|
||||
traillineitem.cpp
|
||||
LIBS += -L../build \
|
||||
-lcore \
|
||||
-linternals \
|
||||
@ -33,7 +34,8 @@ HEADERS += mapgraphicitem.h \
|
||||
trailitem.h \
|
||||
homeitem.h \
|
||||
mapripform.h \
|
||||
mapripper.h
|
||||
mapripper.h \
|
||||
traillineitem.h
|
||||
QT += opengl
|
||||
QT += network
|
||||
QT += sql
|
||||
|
@ -78,6 +78,15 @@ namespace mapcontrol
|
||||
diagTimer->start(500);
|
||||
}
|
||||
|
||||
}
|
||||
void OPMapWidget::SetUavPic(QString UAVPic)
|
||||
{
|
||||
if(UAV!=0)
|
||||
UAV->SetUavPic(UAVPic);
|
||||
if(GPS!=0)
|
||||
GPS->SetUavPic(UAVPic);
|
||||
|
||||
|
||||
}
|
||||
void OPMapWidget::SetShowUAV(const bool &value)
|
||||
{
|
||||
|
@ -348,6 +348,7 @@ namespace mapcontrol
|
||||
void SetShowHome(bool const& value);
|
||||
bool ShowHome()const{return showhome;}
|
||||
void SetShowDiagnostics(bool const& value);
|
||||
void SetUavPic(QString UAVPic);
|
||||
private:
|
||||
internals::Core *core;
|
||||
MapGraphicItem *map;
|
||||
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file trailitem.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a trail point
|
||||
* @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
|
||||
*/
|
||||
#include "traillineitem.h"
|
||||
|
||||
namespace mapcontrol
|
||||
{
|
||||
TrailLineItem::TrailLineItem(internals::PointLatLng const& coord1,internals::PointLatLng const& coord2, QBrush color, QGraphicsItem* parent):QGraphicsLineItem(parent),coord1(coord1),coord2(coord2)
|
||||
{
|
||||
m_brush=color;
|
||||
QPen pen;
|
||||
pen.setBrush(m_brush);
|
||||
pen.setWidth(1);
|
||||
this->setPen(pen);
|
||||
}
|
||||
/*
|
||||
void TrailLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
// painter->drawRect(QRectF(-3,-3,6,6));
|
||||
painter->setBrush(m_brush);
|
||||
QPen pen;
|
||||
pen.setBrush(m_brush);
|
||||
pen.setWidth(2);
|
||||
painter->drawLine(this->line().x1(),this->line().y1(),this->line().x2(),this->line().y2());
|
||||
}
|
||||
*/
|
||||
int TrailLineItem::type()const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file traillineitem.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a WayPoint
|
||||
* @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 TAILLINEITEM_H
|
||||
#define TAILLINEITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "../internals/pointlatlng.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace mapcontrol
|
||||
{
|
||||
|
||||
class TrailLineItem:public QObject,public QGraphicsLineItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 7 };
|
||||
TrailLineItem(internals::PointLatLng const& coord1,internals::PointLatLng const& coord2, QBrush color, QGraphicsItem* parent);
|
||||
int type() const;
|
||||
// void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
// QWidget *widget);
|
||||
internals::PointLatLng coord1;
|
||||
internals::PointLatLng coord2;
|
||||
private:
|
||||
QBrush m_brush;
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TAILLINEITEM_H
|
@ -1,199 +1,220 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavitem.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a UAV
|
||||
* @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
|
||||
*/
|
||||
#include "../internals/pureprojection.h"
|
||||
#include "uavitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
UAVItem::UAVItem(MapGraphicItem* map,OPMapWidget* parent):map(map),mapwidget(parent),showtrail(true),trailtime(5),traildistance(50),autosetreached(true)
|
||||
,autosetdistance(100)
|
||||
{
|
||||
pic.load(QString::fromUtf8(":/markers/images/mapquad.png"));
|
||||
// Don't scale but trust the image we are given
|
||||
// pic=pic.scaled(50,33,Qt::IgnoreAspectRatio);
|
||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
this->setZValue(4);
|
||||
trail=new QGraphicsItemGroup();
|
||||
trail->setParentItem(map);
|
||||
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||
mapfollowtype=UAVMapFollowType::None;
|
||||
trailtype=UAVTrailType::ByDistance;
|
||||
timer.start();
|
||||
|
||||
// rect=QRectF(0,0,renderer.defaultSize().width()*0.05,renderer.defaultSize().height()*0.05);
|
||||
|
||||
}
|
||||
UAVItem::~UAVItem()
|
||||
{
|
||||
delete trail;
|
||||
}
|
||||
|
||||
void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
// painter->rotate(-90);
|
||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||
// painter->drawRect(QRectF(-pic.width()/2,-pic.height()/2,pic.width()-1,pic.height()-1));
|
||||
}
|
||||
QRectF UAVItem::boundingRect()const
|
||||
{
|
||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||
}
|
||||
void UAVItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
||||
{
|
||||
if(coord.IsEmpty())
|
||||
lastcoord=coord;
|
||||
if(coord!=position)
|
||||
{
|
||||
|
||||
if(trailtype==UAVTrailType::ByTimeElapsed)
|
||||
{
|
||||
if(timer.elapsed()>trailtime*1000)
|
||||
{
|
||||
trail->addToGroup(new TrailItem(position,altitude,Qt::red,this));
|
||||
timer.restart();
|
||||
}
|
||||
|
||||
}
|
||||
else if(trailtype==UAVTrailType::ByDistance)
|
||||
{
|
||||
if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance)
|
||||
{
|
||||
trail->addToGroup(new TrailItem(position,altitude,Qt::red,this));
|
||||
lastcoord=position;
|
||||
}
|
||||
}
|
||||
coord=position;
|
||||
this->altitude=altitude;
|
||||
RefreshPos();
|
||||
if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap||mapfollowtype==UAVMapFollowType::CenterMap)
|
||||
{
|
||||
mapwidget->SetCurrentPosition(coord);
|
||||
}
|
||||
this->update();
|
||||
if(autosetreached)
|
||||
{
|
||||
foreach(QGraphicsItem* i,map->childItems())
|
||||
{
|
||||
WayPointItem* wp=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(wp)
|
||||
{
|
||||
if(Distance3D(wp->Coord(),wp->Altitude())<autosetdistance)
|
||||
{
|
||||
wp->SetReached(true);
|
||||
emit UAVReachedWayPoint(wp->Number(),wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mapwidget->Home!=0)
|
||||
{
|
||||
//verify if the UAV is inside the safety bouble
|
||||
if(Distance3D(mapwidget->Home->Coord(),mapwidget->Home->Altitude())>mapwidget->Home->SafeArea())
|
||||
{
|
||||
if(mapwidget->Home->safe!=false)
|
||||
{
|
||||
mapwidget->Home->safe=false;
|
||||
mapwidget->Home->update();
|
||||
emit UAVLeftSafetyBouble(this->coord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mapwidget->Home->safe!=true)
|
||||
{
|
||||
mapwidget->Home->safe=true;
|
||||
mapwidget->Home->update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the UAV Icon on the map, or rotate the map
|
||||
* depending on the display mode
|
||||
*/
|
||||
void UAVItem::SetUAVHeading(const qreal &value)
|
||||
{
|
||||
if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap)
|
||||
{
|
||||
mapwidget->SetRotate(-value);
|
||||
}
|
||||
else {
|
||||
if (this->rotation() != value)
|
||||
this->setRotation(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int UAVItem::type()const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
||||
void UAVItem::RefreshPos()
|
||||
{
|
||||
localposition=map->FromLatLngToLocal(coord);
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
{
|
||||
TrailItem* w=qgraphicsitem_cast<TrailItem*>(i);
|
||||
if(w)
|
||||
w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y());
|
||||
//this->update();
|
||||
}
|
||||
|
||||
}
|
||||
void UAVItem::SetTrailType(const UAVTrailType::Types &value)
|
||||
{
|
||||
trailtype=value;
|
||||
if(trailtype==UAVTrailType::ByTimeElapsed)
|
||||
timer.restart();
|
||||
}
|
||||
void UAVItem::SetShowTrail(const bool &value)
|
||||
{
|
||||
showtrail=value;
|
||||
trail->setVisible(value);
|
||||
}
|
||||
void UAVItem::DeleteTrail()const
|
||||
{
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
delete i;
|
||||
}
|
||||
double UAVItem::Distance3D(const internals::PointLatLng &coord, const int &altitude)
|
||||
{
|
||||
return sqrt(pow(internals::PureProjection::DistanceBetweenLatLng(this->coord,coord)*1000,2)+
|
||||
pow(this->altitude-altitude,2));
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavitem.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a UAV
|
||||
* @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
|
||||
*/
|
||||
#include "../internals/pureprojection.h"
|
||||
#include "uavitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
UAVItem::UAVItem(MapGraphicItem* map,OPMapWidget* parent,QString uavPic):map(map),mapwidget(parent),showtrail(true),showtrailline(true),trailtime(5),traildistance(50),autosetreached(true)
|
||||
,autosetdistance(100)
|
||||
{
|
||||
//QDir dir(":/uavs/images/");
|
||||
//QStringList list=dir.entryList();
|
||||
pic.load(uavPic);
|
||||
// Don't scale but trust the image we are given
|
||||
// pic=pic.scaled(50,33,Qt::IgnoreAspectRatio);
|
||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
this->setZValue(4);
|
||||
trail=new QGraphicsItemGroup();
|
||||
trail->setParentItem(map);
|
||||
trailLine=new QGraphicsItemGroup();
|
||||
trailLine->setParentItem(map);
|
||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||
mapfollowtype=UAVMapFollowType::None;
|
||||
trailtype=UAVTrailType::ByDistance;
|
||||
timer.start();
|
||||
}
|
||||
UAVItem::~UAVItem()
|
||||
{
|
||||
delete trail;
|
||||
}
|
||||
|
||||
void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
// painter->rotate(-90);
|
||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||
// painter->drawRect(QRectF(-pic.width()/2,-pic.height()/2,pic.width()-1,pic.height()-1));
|
||||
}
|
||||
QRectF UAVItem::boundingRect()const
|
||||
{
|
||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||
}
|
||||
void UAVItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
||||
{
|
||||
if(coord.IsEmpty())
|
||||
lastcoord=coord;
|
||||
if(coord!=position)
|
||||
{
|
||||
|
||||
if(trailtype==UAVTrailType::ByTimeElapsed)
|
||||
{
|
||||
if(timer.elapsed()>trailtime*1000)
|
||||
{
|
||||
trail->addToGroup(new TrailItem(position,altitude,Qt::red,this));
|
||||
if(!lasttrailline.IsEmpty())
|
||||
trailLine->addToGroup((new TrailLineItem(lasttrailline,position,Qt::red,map)));
|
||||
lasttrailline=position;
|
||||
timer.restart();
|
||||
}
|
||||
|
||||
}
|
||||
else if(trailtype==UAVTrailType::ByDistance)
|
||||
{
|
||||
if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance)
|
||||
{
|
||||
trail->addToGroup(new TrailItem(position,altitude,Qt::red,this));
|
||||
if(!lasttrailline.IsEmpty())
|
||||
trailLine->addToGroup((new TrailLineItem(lasttrailline,position,Qt::red,map)));
|
||||
lasttrailline=position;
|
||||
lastcoord=position;
|
||||
}
|
||||
}
|
||||
coord=position;
|
||||
this->altitude=altitude;
|
||||
RefreshPos();
|
||||
if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap||mapfollowtype==UAVMapFollowType::CenterMap)
|
||||
{
|
||||
mapwidget->SetCurrentPosition(coord);
|
||||
}
|
||||
this->update();
|
||||
if(autosetreached)
|
||||
{
|
||||
foreach(QGraphicsItem* i,map->childItems())
|
||||
{
|
||||
WayPointItem* wp=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(wp)
|
||||
{
|
||||
if(Distance3D(wp->Coord(),wp->Altitude())<autosetdistance)
|
||||
{
|
||||
wp->SetReached(true);
|
||||
emit UAVReachedWayPoint(wp->Number(),wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mapwidget->Home!=0)
|
||||
{
|
||||
//verify if the UAV is inside the safety bouble
|
||||
if(Distance3D(mapwidget->Home->Coord(),mapwidget->Home->Altitude())>mapwidget->Home->SafeArea())
|
||||
{
|
||||
if(mapwidget->Home->safe!=false)
|
||||
{
|
||||
mapwidget->Home->safe=false;
|
||||
mapwidget->Home->update();
|
||||
emit UAVLeftSafetyBouble(this->coord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mapwidget->Home->safe!=true)
|
||||
{
|
||||
mapwidget->Home->safe=true;
|
||||
mapwidget->Home->update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the UAV Icon on the map, or rotate the map
|
||||
* depending on the display mode
|
||||
*/
|
||||
void UAVItem::SetUAVHeading(const qreal &value)
|
||||
{
|
||||
if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap)
|
||||
{
|
||||
mapwidget->SetRotate(-value);
|
||||
}
|
||||
else {
|
||||
if (this->rotation() != value)
|
||||
this->setRotation(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int UAVItem::type()const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
||||
void UAVItem::RefreshPos()
|
||||
{
|
||||
localposition=map->FromLatLngToLocal(coord);
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
{
|
||||
TrailItem* w=qgraphicsitem_cast<TrailItem*>(i);
|
||||
if(w)
|
||||
w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y());
|
||||
}
|
||||
foreach(QGraphicsItem* i,trailLine->childItems())
|
||||
{
|
||||
TrailLineItem* ww=qgraphicsitem_cast<TrailLineItem*>(i);
|
||||
if(ww)
|
||||
ww->setLine(map->FromLatLngToLocal(ww->coord1).X(),map->FromLatLngToLocal(ww->coord1).Y(),map->FromLatLngToLocal(ww->coord2).X(),map->FromLatLngToLocal(ww->coord2).Y());
|
||||
}
|
||||
|
||||
}
|
||||
void UAVItem::SetTrailType(const UAVTrailType::Types &value)
|
||||
{
|
||||
trailtype=value;
|
||||
if(trailtype==UAVTrailType::ByTimeElapsed)
|
||||
timer.restart();
|
||||
}
|
||||
void UAVItem::SetShowTrail(const bool &value)
|
||||
{
|
||||
showtrail=value;
|
||||
trail->setVisible(value);
|
||||
}
|
||||
void UAVItem::SetShowTrailLine(const bool &value)
|
||||
{
|
||||
showtrailline=value;
|
||||
trailLine->setVisible(value);
|
||||
}
|
||||
|
||||
void UAVItem::DeleteTrail()const
|
||||
{
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
delete i;
|
||||
foreach(QGraphicsItem* i,trailLine->childItems())
|
||||
delete i;
|
||||
}
|
||||
double UAVItem::Distance3D(const internals::PointLatLng &coord, const int &altitude)
|
||||
{
|
||||
return sqrt(pow(internals::PureProjection::DistanceBetweenLatLng(this->coord,coord)*1000,2)+
|
||||
pow(this->altitude-altitude,2));
|
||||
}
|
||||
void UAVItem::SetUavPic(QString UAVPic)
|
||||
{
|
||||
pic.load(":/uavs/images/"+UAVPic);
|
||||
}
|
||||
}
|
||||
|
@ -1,209 +1,227 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavitem.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a WayPoint
|
||||
* @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 UAVITEM_H
|
||||
#define UAVITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "../internals/pointlatlng.h"
|
||||
#include "mapgraphicitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include <QObject>
|
||||
#include "uavmapfollowtype.h"
|
||||
#include "uavtrailtype.h"
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include "opmapwidget.h"
|
||||
#include "trailitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
class WayPointItem;
|
||||
class OPMapWidget;
|
||||
/**
|
||||
* @brief A QGraphicsItem representing the UAV
|
||||
*
|
||||
* @class UAVItem uavitem.h "mapwidget/uavitem.h"
|
||||
*/
|
||||
class UAVItem:public QObject,public QGraphicsItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 2 };
|
||||
UAVItem(MapGraphicItem* map,OPMapWidget* parent);
|
||||
~UAVItem();
|
||||
/**
|
||||
* @brief Sets the UAV position
|
||||
*
|
||||
* @param position LatLng point
|
||||
* @param altitude altitude in meters
|
||||
*/
|
||||
void SetUAVPos(internals::PointLatLng const& position,int const& altitude);
|
||||
/**
|
||||
* @brief Sets the UAV heading
|
||||
*
|
||||
* @param value heading angle (north=0deg)
|
||||
*/
|
||||
void SetUAVHeading(qreal const& value);
|
||||
/**
|
||||
* @brief Returns the UAV position
|
||||
*
|
||||
* @return internals::PointLatLng
|
||||
*/
|
||||
internals::PointLatLng UAVPos()const{return coord;}
|
||||
/**
|
||||
* @brief Sets the Map follow type
|
||||
*
|
||||
* @param value can be "none"(map doesnt follow UAV), "CenterMap"(map moves to keep UAV centered) or "CenterAndRotateMap"(map moves and rotates to keep UAV centered and straight)
|
||||
*/
|
||||
void SetMapFollowType(UAVMapFollowType::Types const& value){mapfollowtype=value;}
|
||||
/**
|
||||
* @brief Sets the trail type
|
||||
*
|
||||
* @param value can be "NoTrail"(no trail is plotted), "ByTimeElapsed"(a trail point is plotted each TrailTime()) or ByDistance(a trail point is plotted if the distance between the UAV and the last trail point is bigger than TrailDistance())
|
||||
*/
|
||||
void SetTrailType(UAVTrailType::Types const& value);
|
||||
/**
|
||||
* @brief Returns the map follow method used
|
||||
*
|
||||
* @return UAVMapFollowType::Types
|
||||
*/
|
||||
UAVMapFollowType::Types GetMapFollowType()const{return mapfollowtype;}
|
||||
/**
|
||||
* @brief Returns the UAV trail type. It can be plotted by time elapsed or distance
|
||||
*
|
||||
* @return UAVTrailType::Types
|
||||
*/
|
||||
UAVTrailType::Types GetTrailType()const{return trailtype;}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
void RefreshPos();
|
||||
QRectF boundingRect() const;
|
||||
/**
|
||||
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
|
||||
*
|
||||
* @param seconds the UAV trail time elapsed value. If the trail type is time elapsed
|
||||
* a trail point will be plotted each "value returned" seconds.
|
||||
*/
|
||||
void SetTrailTime(int const& seconds){trailtime=seconds;}
|
||||
/**
|
||||
* @brief Returns the UAV trail time elapsed value. If the trail type is time elapsed
|
||||
* a trail point will be plotted each "value returned" seconds.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int TrailTime()const{return trailtime;}
|
||||
/**
|
||||
* @brief Sets the trail distance to be used if TrailType is ByDistance
|
||||
*
|
||||
* @param distance the UAV trail plot distance.
|
||||
* If the trail type is ByDistance a trail dot is plotted if
|
||||
* the distance between the current UAV position and the last trail point
|
||||
* is bigger than the returned value
|
||||
*/
|
||||
void SetTrailDistance(int const& distance){traildistance=distance;}
|
||||
/**
|
||||
* @brief Returns the UAV trail plot distance.
|
||||
* If the trail type is distance diference a trail dot is plotted if
|
||||
* the distance between the current UAV position and the last trail point
|
||||
* is bigger than the returned value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int TrailDistance()const{return traildistance;}
|
||||
/**
|
||||
* @brief Returns true if UAV trail is shown
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool ShowTrail()const{return showtrail;}
|
||||
/**
|
||||
* @brief Used to define if the UAV displays a trail
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetShowTrail(bool const& value);
|
||||
/**
|
||||
* @brief Deletes all the trail points
|
||||
*/
|
||||
void DeleteTrail()const;
|
||||
/**
|
||||
* @brief Returns true if the UAV automaticaly sets WP reached value (changing its color)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool AutoSetReached()const{return autosetreached;}
|
||||
/**
|
||||
* @brief Defines if the UAV can set the WP's "reached" value automaticaly.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAutoSetReached(bool const& value){autosetreached=value;}
|
||||
/**
|
||||
* @brief Returns the 3D distance in meters necessary for the UAV to set WP's to "reached"
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
double AutoSetDistance()const{return autosetdistance;}
|
||||
/**
|
||||
* @brief Sets the the 3D distance in meters necessary for the UAV to set WP's to "reached"
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAutoSetDistance(double const& value){autosetdistance=value;}
|
||||
|
||||
int type() const;
|
||||
private:
|
||||
MapGraphicItem* map;
|
||||
|
||||
int altitude;
|
||||
UAVMapFollowType::Types mapfollowtype;
|
||||
UAVTrailType::Types trailtype;
|
||||
internals::PointLatLng coord;
|
||||
internals::PointLatLng lastcoord;
|
||||
QPixmap pic;
|
||||
core::Point localposition;
|
||||
OPMapWidget* mapwidget;
|
||||
QGraphicsItemGroup* trail;
|
||||
QTime timer;
|
||||
bool showtrail;
|
||||
int trailtime;
|
||||
int traildistance;
|
||||
bool autosetreached;
|
||||
double Distance3D(internals::PointLatLng const& coord, int const& altitude);
|
||||
double autosetdistance;
|
||||
// QRectF rect;
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
||||
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
||||
};
|
||||
}
|
||||
#endif // UAVITEM_H
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavitem.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief A graphicsItem representing a WayPoint
|
||||
* @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 UAVITEM_H
|
||||
#define UAVITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "../internals/pointlatlng.h"
|
||||
#include "mapgraphicitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include <QObject>
|
||||
#include "uavmapfollowtype.h"
|
||||
#include "uavtrailtype.h"
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include "opmapwidget.h"
|
||||
#include "trailitem.h"
|
||||
#include "traillineitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
class WayPointItem;
|
||||
class OPMapWidget;
|
||||
/**
|
||||
* @brief A QGraphicsItem representing the UAV
|
||||
*
|
||||
* @class UAVItem uavitem.h "mapwidget/uavitem.h"
|
||||
*/
|
||||
class UAVItem:public QObject,public QGraphicsItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 2 };
|
||||
UAVItem(MapGraphicItem* map,OPMapWidget* parent, QString uavPic=QString::fromUtf8(":/uavs/images/mapquad.png"));
|
||||
~UAVItem();
|
||||
/**
|
||||
* @brief Sets the UAV position
|
||||
*
|
||||
* @param position LatLng point
|
||||
* @param altitude altitude in meters
|
||||
*/
|
||||
void SetUAVPos(internals::PointLatLng const& position,int const& altitude);
|
||||
/**
|
||||
* @brief Sets the UAV heading
|
||||
*
|
||||
* @param value heading angle (north=0deg)
|
||||
*/
|
||||
void SetUAVHeading(qreal const& value);
|
||||
/**
|
||||
* @brief Returns the UAV position
|
||||
*
|
||||
* @return internals::PointLatLng
|
||||
*/
|
||||
internals::PointLatLng UAVPos()const{return coord;}
|
||||
/**
|
||||
* @brief Sets the Map follow type
|
||||
*
|
||||
* @param value can be "none"(map doesnt follow UAV), "CenterMap"(map moves to keep UAV centered) or "CenterAndRotateMap"(map moves and rotates to keep UAV centered and straight)
|
||||
*/
|
||||
void SetMapFollowType(UAVMapFollowType::Types const& value){mapfollowtype=value;}
|
||||
/**
|
||||
* @brief Sets the trail type
|
||||
*
|
||||
* @param value can be "NoTrail"(no trail is plotted), "ByTimeElapsed"(a trail point is plotted each TrailTime()) or ByDistance(a trail point is plotted if the distance between the UAV and the last trail point is bigger than TrailDistance())
|
||||
*/
|
||||
void SetTrailType(UAVTrailType::Types const& value);
|
||||
/**
|
||||
* @brief Returns the map follow method used
|
||||
*
|
||||
* @return UAVMapFollowType::Types
|
||||
*/
|
||||
UAVMapFollowType::Types GetMapFollowType()const{return mapfollowtype;}
|
||||
/**
|
||||
* @brief Returns the UAV trail type. It can be plotted by time elapsed or distance
|
||||
*
|
||||
* @return UAVTrailType::Types
|
||||
*/
|
||||
UAVTrailType::Types GetTrailType()const{return trailtype;}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
void RefreshPos();
|
||||
QRectF boundingRect() const;
|
||||
/**
|
||||
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
|
||||
*
|
||||
* @param seconds the UAV trail time elapsed value. If the trail type is time elapsed
|
||||
* a trail point will be plotted each "value returned" seconds.
|
||||
*/
|
||||
void SetTrailTime(int const& seconds){trailtime=seconds;}
|
||||
/**
|
||||
* @brief Returns the UAV trail time elapsed value. If the trail type is time elapsed
|
||||
* a trail point will be plotted each "value returned" seconds.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int TrailTime()const{return trailtime;}
|
||||
/**
|
||||
* @brief Sets the trail distance to be used if TrailType is ByDistance
|
||||
*
|
||||
* @param distance the UAV trail plot distance.
|
||||
* If the trail type is ByDistance a trail dot is plotted if
|
||||
* the distance between the current UAV position and the last trail point
|
||||
* is bigger than the returned value
|
||||
*/
|
||||
void SetTrailDistance(int const& distance){traildistance=distance;}
|
||||
/**
|
||||
* @brief Returns the UAV trail plot distance.
|
||||
* If the trail type is distance diference a trail dot is plotted if
|
||||
* the distance between the current UAV position and the last trail point
|
||||
* is bigger than the returned value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int TrailDistance()const{return traildistance;}
|
||||
/**
|
||||
* @brief Returns true if UAV trail is shown
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool ShowTrail()const{return showtrail;}
|
||||
/**
|
||||
* @brief Returns true if UAV trail line is shown
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool ShowTrailLine()const{return showtrailline;}
|
||||
/**
|
||||
* @brief Used to define if the UAV displays a trail
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetShowTrail(bool const& value);
|
||||
/**
|
||||
* @brief Used to define if the UAV displays a trail line
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetShowTrailLine(bool const& value);
|
||||
/**
|
||||
* @brief Deletes all the trail points
|
||||
*/
|
||||
void DeleteTrail()const;
|
||||
/**
|
||||
* @brief Returns true if the UAV automaticaly sets WP reached value (changing its color)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool AutoSetReached()const{return autosetreached;}
|
||||
/**
|
||||
* @brief Defines if the UAV can set the WP's "reached" value automaticaly.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAutoSetReached(bool const& value){autosetreached=value;}
|
||||
/**
|
||||
* @brief Returns the 3D distance in meters necessary for the UAV to set WP's to "reached"
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
double AutoSetDistance()const{return autosetdistance;}
|
||||
/**
|
||||
* @brief Sets the the 3D distance in meters necessary for the UAV to set WP's to "reached"
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAutoSetDistance(double const& value){autosetdistance=value;}
|
||||
|
||||
int type() const;
|
||||
|
||||
void SetUavPic(QString UAVPic);
|
||||
private:
|
||||
MapGraphicItem* map;
|
||||
|
||||
int altitude;
|
||||
UAVMapFollowType::Types mapfollowtype;
|
||||
UAVTrailType::Types trailtype;
|
||||
internals::PointLatLng coord;
|
||||
internals::PointLatLng lastcoord;
|
||||
QPixmap pic;
|
||||
core::Point localposition;
|
||||
OPMapWidget* mapwidget;
|
||||
QGraphicsItemGroup* trail;
|
||||
QGraphicsItemGroup * trailLine;
|
||||
internals::PointLatLng lasttrailline;
|
||||
QTime timer;
|
||||
bool showtrail;
|
||||
bool showtrailline;
|
||||
int trailtime;
|
||||
int traildistance;
|
||||
bool autosetreached;
|
||||
double Distance3D(internals::PointLatLng const& coord, int const& altitude);
|
||||
double autosetdistance;
|
||||
// QRectF rect;
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
||||
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
||||
};
|
||||
}
|
||||
#endif // UAVITEM_H
|
||||
|
@ -51,5 +51,6 @@ void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||
m_widget->setAccessMode(m->accessMode());
|
||||
m_widget->setUseMemoryCache(m->useMemoryCache());
|
||||
m_widget->setCacheLocation(m->cacheLocation());
|
||||
m_widget->SetUavPic(m->uavSymbol());
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,8 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings*
|
||||
m_showTileGridLines(false),
|
||||
m_accessMode("ServerAndCache"),
|
||||
m_useMemoryCache(true),
|
||||
m_cacheLocation(Utils::PathUtils().GetStoragePath() + "mapscache" + QDir::separator())
|
||||
m_cacheLocation(Utils::PathUtils().GetStoragePath() + "mapscache" + QDir::separator()),
|
||||
m_uavSymbol(QString::fromUtf8(":/uavs/images/mapquad.png"))
|
||||
{
|
||||
QSettings set(QSettings::IniFormat, QSettings::UserScope,QLatin1String("OpenPilot"), QLatin1String("OpenPilotGCS"));
|
||||
QDir dir(set.fileName());
|
||||
@ -58,14 +59,14 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings*
|
||||
QString accessMode= qSettings->value("accessMode").toString();
|
||||
bool useMemoryCache= qSettings->value("useMemoryCache").toBool();
|
||||
QString cacheLocation= qSettings->value("cacheLocation").toString();
|
||||
|
||||
QString uavSymbol=qSettings->value("uavSymbol").toString();
|
||||
if (!mapProvider.isEmpty()) m_mapProvider = mapProvider;
|
||||
m_defaultZoom = zoom;
|
||||
m_defaultLatitude = latitude;
|
||||
m_defaultLongitude = longitude;
|
||||
m_useOpenGL = useOpenGL;
|
||||
m_showTileGridLines = showTileGridLines;
|
||||
|
||||
m_uavSymbol=uavSymbol;
|
||||
if (!accessMode.isEmpty()) m_accessMode = accessMode;
|
||||
m_useMemoryCache = useMemoryCache;
|
||||
if (!cacheLocation.isEmpty()) m_cacheLocation = Utils::PathUtils().InsertStoragePath(cacheLocation);
|
||||
@ -85,7 +86,7 @@ IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
|
||||
m->m_accessMode = m_accessMode;
|
||||
m->m_useMemoryCache = m_useMemoryCache;
|
||||
m->m_cacheLocation = m_cacheLocation;
|
||||
|
||||
m->m_uavSymbol=m_uavSymbol;
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -98,6 +99,7 @@ void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("showTileGridLines", m_showTileGridLines);
|
||||
qSettings->setValue("accessMode", m_accessMode);
|
||||
qSettings->setValue("useMemoryCache", m_useMemoryCache);
|
||||
qSettings->setValue("uavSymbol", m_uavSymbol);
|
||||
qSettings->setValue("cacheLocation", Utils::PathUtils().RemoveStoragePath(m_cacheLocation));
|
||||
}
|
||||
void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation){
|
||||
|
@ -46,6 +46,7 @@ Q_PROPERTY(bool showTileGridLines READ showTileGridLines WRITE setShowTileGridLi
|
||||
Q_PROPERTY(QString accessMode READ accessMode WRITE setAccessMode)
|
||||
Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache)
|
||||
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
|
||||
Q_PROPERTY(QString uavSymbol READ uavSymbol WRITE setUavSymbol)
|
||||
|
||||
public:
|
||||
explicit OPMapGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
@ -62,6 +63,7 @@ public:
|
||||
QString accessMode() const { return m_accessMode; }
|
||||
bool useMemoryCache() const { return m_useMemoryCache; }
|
||||
QString cacheLocation() const { return m_cacheLocation; }
|
||||
QString uavSymbol() const { return m_uavSymbol; }
|
||||
|
||||
public slots:
|
||||
void setMapProvider(QString provider) { m_mapProvider = provider; }
|
||||
@ -73,7 +75,7 @@ public slots:
|
||||
void setAccessMode(QString accessMode) { m_accessMode = accessMode; }
|
||||
void setUseMemoryCache(bool useMemoryCache) { m_useMemoryCache = useMemoryCache; }
|
||||
void setCacheLocation(QString cacheLocation);
|
||||
|
||||
void setUavSymbol(QString symbol){m_uavSymbol=symbol;}
|
||||
private:
|
||||
QString m_mapProvider;
|
||||
int m_defaultZoom;
|
||||
@ -84,6 +86,7 @@ private:
|
||||
QString m_accessMode;
|
||||
bool m_useMemoryCache;
|
||||
QString m_cacheLocation;
|
||||
QString m_uavSymbol;
|
||||
|
||||
};
|
||||
|
||||
|
@ -82,6 +82,21 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
|
||||
m_page->lineEditCacheLocation->setPromptDialogTitle(tr("Choose Cache Directory"));
|
||||
m_page->lineEditCacheLocation->setPath(m_config->cacheLocation());
|
||||
|
||||
QDir dir(":/uavs/images/");
|
||||
QStringList list=dir.entryList();
|
||||
foreach(QString i,list)
|
||||
{
|
||||
QIcon icon(QPixmap(":/uavs/images/"+i));
|
||||
m_page->uavSymbolComboBox->addItem(icon,QString(),i);
|
||||
}
|
||||
for(int x=0;x<m_page->uavSymbolComboBox->count();++x)
|
||||
{
|
||||
if(m_page->uavSymbolComboBox->itemData(x).toString()==m_config->uavSymbol())
|
||||
{
|
||||
m_page->uavSymbolComboBox->setCurrentIndex(x);
|
||||
}
|
||||
}
|
||||
|
||||
connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked()));
|
||||
|
||||
return w;
|
||||
@ -113,6 +128,7 @@ void OPMapGadgetOptionsPage::apply()
|
||||
m_config->setAccessMode(m_page->accessModeComboBox->currentText());
|
||||
m_config->setUseMemoryCache(m_page->checkBoxUseMemoryCache->isChecked());
|
||||
m_config->setCacheLocation(m_page->lineEditCacheLocation->path());
|
||||
m_config->setUavSymbol(m_page->uavSymbolComboBox->itemData(m_page->uavSymbolComboBox->currentIndex()).toString());
|
||||
}
|
||||
|
||||
void OPMapGadgetOptionsPage::finish()
|
||||
|
@ -410,6 +410,46 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>UAV Symbol</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="uavSymbolComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -511,6 +511,10 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
uavTrailDistanceSubMenu.addAction(uavTrailDistanceAct.at(i));
|
||||
menu.addMenu(&uavTrailDistanceSubMenu);
|
||||
|
||||
menu.addAction(showTrailAct);
|
||||
|
||||
menu.addAction(showTrailLineAct);
|
||||
|
||||
menu.addAction(clearUAVtrailAct);
|
||||
|
||||
// ****
|
||||
@ -621,9 +625,9 @@ void OPMapGadgetWidget::updatePosition()
|
||||
return;
|
||||
|
||||
QMutexLocker locker(&m_map_mutex);
|
||||
|
||||
if (!telemetry_connected)
|
||||
return;
|
||||
//Pip I'm sorry, I know this was here with a purpose vvv
|
||||
//if (!telemetry_connected)
|
||||
// return;
|
||||
|
||||
double latitude;
|
||||
double longitude;
|
||||
@ -651,6 +655,7 @@ void OPMapGadgetWidget::updatePosition()
|
||||
m_widget->labelUAVPos->setText(str);
|
||||
|
||||
m_map->UAV->SetUAVPos(uav_pos, uav_altitude_meters); // set the maps UAV position
|
||||
// qDebug()<<"UAVPOSITION"<<uav_pos.ToString();
|
||||
m_map->UAV->SetUAVHeading(uav_heading_degrees); // set the maps UAV heading
|
||||
|
||||
if (!getGPSPosition(latitude, longitude, altitude))
|
||||
@ -1545,6 +1550,18 @@ void OPMapGadgetWidget::createActions()
|
||||
uavTrailTypeAct.append(uavTrailType_act);
|
||||
}
|
||||
|
||||
showTrailAct = new QAction(tr("Show Trail dots"), this);
|
||||
showTrailAct->setStatusTip(tr("Show/Hide the Trail dots"));
|
||||
showTrailAct->setCheckable(true);
|
||||
showTrailAct->setChecked(true);
|
||||
connect(showTrailAct, SIGNAL(toggled(bool)), this, SLOT(onShowTrailAct_toggled(bool)));
|
||||
|
||||
showTrailLineAct = new QAction(tr("Show Trail lines"), this);
|
||||
showTrailLineAct->setStatusTip(tr("Show/Hide the Trail lines"));
|
||||
showTrailLineAct->setCheckable(true);
|
||||
showTrailLineAct->setChecked(true);
|
||||
connect(showTrailLineAct, SIGNAL(toggled(bool)), this, SLOT(onShowTrailLineAct_toggled(bool)));
|
||||
|
||||
clearUAVtrailAct = new QAction(tr("Clear UAV trail"), this);
|
||||
clearUAVtrailAct->setStatusTip(tr("Clear the UAV trail"));
|
||||
connect(clearUAVtrailAct, SIGNAL(triggered()), this, SLOT(onClearUAVtrailAct_triggered()));
|
||||
@ -1643,6 +1660,24 @@ void OPMapGadgetWidget::onShowUAVAct_toggled(bool show)
|
||||
m_map->GPS->setVisible(show);
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::onShowTrailAct_toggled(bool show)
|
||||
{
|
||||
if (!m_widget || !m_map)
|
||||
return;
|
||||
|
||||
m_map->UAV->SetShowTrail(show);
|
||||
m_map->GPS->SetShowTrail(show);
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::onShowTrailLineAct_toggled(bool show)
|
||||
{
|
||||
if (!m_widget || !m_map)
|
||||
return;
|
||||
|
||||
m_map->UAV->SetShowTrailLine(show);
|
||||
m_map->GPS->SetShowTrailLine(show);
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::onMapModeActGroup_triggered(QAction *action)
|
||||
{
|
||||
if (!m_widget || !m_map || !action)
|
||||
@ -2329,3 +2364,8 @@ bool OPMapGadgetWidget::setHomeLocationObject()
|
||||
}
|
||||
|
||||
// *************************************************************************************
|
||||
|
||||
void OPMapGadgetWidget::SetUavPic(QString UAVPic)
|
||||
{
|
||||
m_map->SetUavPic(UAVPic);
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ public:
|
||||
void setUseMemoryCache(bool useMemoryCache);
|
||||
void setCacheLocation(QString cacheLocation);
|
||||
void setMapMode(opMapModeType mode);
|
||||
void SetUavPic(QString UAVPic);
|
||||
|
||||
public slots:
|
||||
void homePositionUpdated(UAVObject *);
|
||||
@ -193,6 +194,8 @@ private slots:
|
||||
void onShowDiagnostics_toggled(bool show);
|
||||
void onShowUAVAct_toggled(bool show);
|
||||
void onShowHomeAct_toggled(bool show);
|
||||
void onShowTrailLineAct_toggled(bool show);
|
||||
void onShowTrailAct_toggled(bool show);
|
||||
void onGoZoomInAct_triggered();
|
||||
void onGoZoomOutAct_triggered();
|
||||
void onGoMouseClickAct_triggered();
|
||||
@ -304,6 +307,8 @@ private:
|
||||
QList<QAction *> uavTrailTypeAct;
|
||||
QAction *clearUAVtrailAct;
|
||||
QActionGroup *uavTrailTimeActGroup;
|
||||
QAction *showTrailLineAct;
|
||||
QAction *showTrailAct;
|
||||
QList<QAction *> uavTrailTimeAct;
|
||||
QActionGroup *uavTrailDistanceActGroup;
|
||||
QList<QAction *> uavTrailDistanceAct;
|
||||
|
Loading…
x
Reference in New Issue
Block a user