mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
GCS/MapLib - Added path plan manager.
This commit is contained in:
parent
3b8ca57eef
commit
d0e012cbdb
@ -101,17 +101,32 @@ namespace mapcontrol
|
||||
UAV->SetUavPic(UAVPic);
|
||||
if(GPS!=0)
|
||||
GPS->SetUavPic(UAVPic);
|
||||
|
||||
|
||||
}
|
||||
|
||||
WayPointLine * OPMapWidget::WPLineCreate(WayPointItem *from, WayPointItem *to)
|
||||
{
|
||||
if(!from|!to)
|
||||
return NULL;
|
||||
return new WayPointLine(from,to,map);
|
||||
}
|
||||
WayPointCircle * OPMapWidget::WPCircleCreate(WayPointItem *from, WayPointItem *to, bool clockwise)
|
||||
WayPointLine * OPMapWidget::WPLineCreate(HomeItem *from, WayPointItem *to)
|
||||
{
|
||||
return new WayPointCircle(from,to,clockwise,map);
|
||||
if(!from|!to)
|
||||
return NULL;
|
||||
return new WayPointLine(from,to,map);
|
||||
}
|
||||
WayPointCircle * OPMapWidget::WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise)
|
||||
{
|
||||
if(!center|!radius)
|
||||
return NULL;
|
||||
return new WayPointCircle(center,radius,clockwise,map);
|
||||
}
|
||||
|
||||
WayPointCircle *OPMapWidget::WPCircleCreate(HomeItem *center, WayPointItem *radius, bool clockwise)
|
||||
{
|
||||
if(!center|!radius)
|
||||
return NULL;
|
||||
return new WayPointCircle(center,radius,clockwise,map);
|
||||
}
|
||||
void OPMapWidget::SetShowUAV(const bool &value)
|
||||
{
|
||||
@ -201,18 +216,24 @@ namespace mapcontrol
|
||||
WayPointItem* item=new WayPointItem(this->CurrentPosition(),0,map);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
return item;
|
||||
}
|
||||
void OPMapWidget::WPCreate(WayPointItem* item)
|
||||
{
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude)
|
||||
{
|
||||
WayPointItem* item=new WayPointItem(coord,altitude,map);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description)
|
||||
@ -220,6 +241,8 @@ namespace mapcontrol
|
||||
WayPointItem* item=new WayPointItem(coord,altitude,description,map);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPCreate(const distBearing &relativeCoord, const int &altitude, const QString &description)
|
||||
@ -227,6 +250,8 @@ namespace mapcontrol
|
||||
WayPointItem* item=new WayPointItem(relativeCoord,altitude,description,map);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPInsert(const int &position)
|
||||
@ -266,7 +291,7 @@ namespace mapcontrol
|
||||
}
|
||||
void OPMapWidget::WPDelete(WayPointItem *item)
|
||||
{
|
||||
emit WPDeleted(item->Number());
|
||||
emit WPDeleted(item->Number(),item);
|
||||
delete item;
|
||||
}
|
||||
void OPMapWidget::WPDeleteAll()
|
||||
@ -278,6 +303,21 @@ namespace mapcontrol
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
void OPMapWidget::deleteAllOverlays()
|
||||
{
|
||||
foreach(QGraphicsItem* i,map->childItems())
|
||||
{
|
||||
WayPointLine* w=qgraphicsitem_cast<WayPointLine*>(i);
|
||||
if(w)
|
||||
delete w;
|
||||
else
|
||||
{
|
||||
WayPointCircle* ww=qgraphicsitem_cast<WayPointCircle*>(i);
|
||||
if(ww)
|
||||
delete ww;
|
||||
}
|
||||
}
|
||||
}
|
||||
QList<WayPointItem*> OPMapWidget::WPSelected()
|
||||
{
|
||||
QList<WayPointItem*> list;
|
||||
@ -300,7 +340,7 @@ namespace mapcontrol
|
||||
connect(item,SIGNAL(WPValuesChanged(WayPointItem*)),this,SIGNAL(WPValuesChanged(WayPointItem*)));
|
||||
connect(this,SIGNAL(WPInserted(int,WayPointItem*)),item,SLOT(WPInserted(int,WayPointItem*)));
|
||||
connect(this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),item,SLOT(WPRenumbered(int,int,WayPointItem*)));
|
||||
connect(this,SIGNAL(WPDeleted(int)),item,SLOT(WPDeleted(int)));
|
||||
connect(this,SIGNAL(WPDeleted(int,WayPointItem*)),item,SLOT(WPDeleted(int,WayPointItem*)));
|
||||
}
|
||||
void OPMapWidget::diagRefresh()
|
||||
{
|
||||
|
@ -362,7 +362,10 @@ namespace mapcontrol
|
||||
void SetShowDiagnostics(bool const& value);
|
||||
void SetUavPic(QString UAVPic);
|
||||
WayPointLine * WPLineCreate(WayPointItem *from,WayPointItem *to);
|
||||
WayPointCircle *WPCircleCreate(WayPointItem *from, WayPointItem *to,bool clockwise);
|
||||
WayPointLine * WPLineCreate(HomeItem *from,WayPointItem *to);
|
||||
WayPointCircle *WPCircleCreate(WayPointItem *center, WayPointItem *radius,bool clockwise);
|
||||
WayPointCircle *WPCircleCreate(HomeItem *center, WayPointItem *radius,bool clockwise);
|
||||
void deleteAllOverlays();
|
||||
private:
|
||||
internals::Core *core;
|
||||
MapGraphicItem *map;
|
||||
@ -412,6 +415,9 @@ namespace mapcontrol
|
||||
* @param waypoint WayPoint inserted
|
||||
*/
|
||||
void WPReached(WayPointItem* waypoint);
|
||||
|
||||
void WPCreated(int const& number,WayPointItem* waypoint);
|
||||
|
||||
/**
|
||||
* @brief Fires when a new WayPoint is inserted
|
||||
*
|
||||
@ -424,7 +430,7 @@ namespace mapcontrol
|
||||
*
|
||||
* @param number number of the deleted WayPoint
|
||||
*/
|
||||
void WPDeleted(int const& number);
|
||||
void WPDeleted(int const& number,WayPointItem* waypoint);
|
||||
/**
|
||||
* @brief Fires When a WayPoint is Reached
|
||||
*
|
||||
|
@ -26,21 +26,28 @@
|
||||
*/
|
||||
#include "waypointcircle.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "homeitem.h"
|
||||
const qreal Pi = 3.14;
|
||||
|
||||
namespace mapcontrol
|
||||
{
|
||||
WayPointCircle::WayPointCircle(WayPointItem *from, WayPointItem *to,bool clockwise, MapGraphicItem *map,QColor color):source(from),
|
||||
destination(to),my_map(map),QGraphicsEllipseItem(map),myColor(color),myClockWise(clockwise)
|
||||
WayPointCircle::WayPointCircle(WayPointItem *center, WayPointItem *radius,bool clockwise, MapGraphicItem *map,QColor color):my_center(center),
|
||||
my_radius(radius),my_map(map),QGraphicsEllipseItem(map),myColor(color),myClockWise(clockwise)
|
||||
{
|
||||
QLineF line(from->pos(),to->pos());
|
||||
this->setRect(from->pos().x(),from->pos().y(),2*line.length(),2*line.length());
|
||||
connect(source,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(destination,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(source,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
connect(destination,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
connect(center,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(radius,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(center,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
connect(radius,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
}
|
||||
|
||||
WayPointCircle::WayPointCircle(HomeItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color):my_center(center),
|
||||
my_radius(radius),my_map(map),QGraphicsEllipseItem(map),myColor(color),myClockWise(clockwise)
|
||||
{
|
||||
connect(center,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(refreshLocations()));
|
||||
connect(radius,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(radius,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
}
|
||||
|
||||
int WayPointCircle::type() const
|
||||
{
|
||||
// Enable the use of qgraphicsitem_cast with this item.
|
||||
@ -54,28 +61,40 @@ QPainterPath WayPointCircle::shape() const
|
||||
}
|
||||
void WayPointCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QLineF line(destination->pos(),source->pos());
|
||||
QPointF p1;
|
||||
QPointF p2;
|
||||
p1=my_center->pos();
|
||||
p2=my_center->pos();
|
||||
QLineF line(my_radius->pos(),my_center->pos());
|
||||
p1.ry()=p1.ry()+line.length();
|
||||
p2.ry()=p2.ry()-line.length();
|
||||
QPen myPen = pen();
|
||||
myPen.setColor(myColor);
|
||||
qreal arrowSize = 10;
|
||||
painter->setPen(myPen);
|
||||
QBrush brush=painter->brush();
|
||||
painter->setBrush(myColor);
|
||||
|
||||
double angle = ::acos(line.dx() / line.length());
|
||||
angle=angle+90*2*Pi/360;
|
||||
double angle =0;
|
||||
if(myClockWise)
|
||||
angle+=Pi;
|
||||
if (line.dy() >= 0)
|
||||
angle = (Pi) - angle;
|
||||
|
||||
QPointF arrowP1 = line.p1() + QPointF(sin(angle + Pi / 3) * arrowSize,
|
||||
QPointF arrowP1 = p1 + QPointF(sin(angle + Pi / 3) * arrowSize,
|
||||
cos(angle + Pi / 3) * arrowSize);
|
||||
QPointF arrowP2 = line.p1() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
|
||||
QPointF arrowP2 = p1 + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
|
||||
cos(angle + Pi - Pi / 3) * arrowSize);
|
||||
|
||||
QPointF arrowP21 = p2 + QPointF(sin(angle + Pi + Pi / 3) * arrowSize,
|
||||
cos(angle + Pi + Pi / 3) * arrowSize);
|
||||
QPointF arrowP22 = p2 + QPointF(sin(angle + Pi + Pi - Pi / 3) * arrowSize,
|
||||
cos(angle + Pi + Pi - Pi / 3) * arrowSize);
|
||||
|
||||
arrowHead.clear();
|
||||
arrowHead << line.p1() << arrowP1 << arrowP2;
|
||||
arrowHead << p1 << arrowP1 << arrowP2;
|
||||
painter->drawPolygon(arrowHead);
|
||||
arrowHead.clear();
|
||||
arrowHead << p2 << arrowP21 << arrowP22;
|
||||
painter->drawPolygon(arrowHead);
|
||||
painter->translate(-line.length(),-line.length());
|
||||
painter->setBrush(brush);
|
||||
@ -85,8 +104,8 @@ void WayPointCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
|
||||
void WayPointCircle::refreshLocations()
|
||||
{
|
||||
QLineF line(source->pos(),destination->pos());
|
||||
this->setRect(source->pos().x(),source->pos().y(),2*line.length(),2*line.length());
|
||||
QLineF line(my_center->pos(),my_radius->pos());
|
||||
this->setRect(my_center->pos().x(),my_center->pos().y(),2*line.length(),2*line.length());
|
||||
}
|
||||
|
||||
void WayPointCircle::waypointdeleted()
|
||||
|
@ -44,14 +44,15 @@ class WayPointCircle:public QObject,public QGraphicsEllipseItem
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 9 };
|
||||
WayPointCircle(WayPointItem * from, WayPointItem * to,bool clockwise,MapGraphicItem * map,QColor color=Qt::green);
|
||||
WayPointCircle(WayPointItem * center, WayPointItem * radius,bool clockwise,MapGraphicItem * map,QColor color=Qt::green);
|
||||
WayPointCircle(HomeItem * center, WayPointItem * radius,bool clockwise,MapGraphicItem * map,QColor color=Qt::green);
|
||||
int type() const;
|
||||
QPainterPath shape() const;
|
||||
void setColor(const QColor &color)
|
||||
{ myColor = color; }
|
||||
private:
|
||||
WayPointItem * source;
|
||||
WayPointItem * destination;
|
||||
QGraphicsItem * my_center;
|
||||
QGraphicsItem * my_radius;
|
||||
MapGraphicItem * my_map;
|
||||
QPolygonF arrowHead;
|
||||
QColor myColor;
|
||||
|
@ -247,12 +247,14 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitu
|
||||
}
|
||||
void WayPointItem::SetNumber(const int &value)
|
||||
{
|
||||
emit WPNumberChanged(number,value,this);
|
||||
int oldnumber=number;
|
||||
number=value;
|
||||
RefreshToolTip();
|
||||
numberI->setText(QString::number(number));
|
||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
||||
this->update();
|
||||
qDebug()<<"emit"<<oldnumber<<value;
|
||||
emit WPNumberChanged(oldnumber,value,this);
|
||||
}
|
||||
void WayPointItem::SetReached(const bool &value)
|
||||
{
|
||||
@ -288,22 +290,16 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitu
|
||||
}
|
||||
this->update();
|
||||
}
|
||||
void WayPointItem::WPDeleted(const int &onumber)
|
||||
void WayPointItem::WPDeleted(const int &onumber,WayPointItem *waypoint)
|
||||
{
|
||||
if(number>onumber) --number;
|
||||
numberI->setText(QString::number(number));
|
||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
||||
RefreshToolTip();
|
||||
this->update();
|
||||
Q_UNUSED(waypoint);
|
||||
if(number>onumber) SetNumber(--number);
|
||||
}
|
||||
void WayPointItem::WPInserted(const int &onumber, WayPointItem *waypoint)
|
||||
{
|
||||
if(waypoint!=this)
|
||||
{
|
||||
if(onumber<=number) ++number;
|
||||
numberI->setText(QString::number(number));
|
||||
RefreshToolTip();
|
||||
this->update();
|
||||
if(onumber<=number) SetNumber(++number);
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,25 +320,16 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitu
|
||||
{
|
||||
if(((oldnumber>number) && (newnumber<=number)))
|
||||
{
|
||||
++number;
|
||||
numberI->setText(QString::number(number));
|
||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
||||
RefreshToolTip();
|
||||
SetNumber(++number);
|
||||
}
|
||||
else if (((oldnumber<number) && (newnumber>number)))
|
||||
{
|
||||
--number;
|
||||
numberI->setText(QString::number(number));
|
||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
||||
RefreshToolTip();
|
||||
SetNumber(--number);
|
||||
}
|
||||
else if (newnumber==number)
|
||||
{
|
||||
++number;
|
||||
numberI->setText(QString::number(number));
|
||||
RefreshToolTip();
|
||||
SetNumber(++number);
|
||||
}
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
int WayPointItem::type() const
|
||||
|
@ -196,7 +196,7 @@ public slots:
|
||||
*
|
||||
* @param number number of the WayPoint that was deleted
|
||||
*/
|
||||
void WPDeleted(int const& number);
|
||||
void WPDeleted(int const& number,WayPointItem *waypoint);
|
||||
/**
|
||||
* @brief Called when a WayPoint is renumbered
|
||||
*
|
||||
|
@ -26,7 +26,7 @@
|
||||
*/
|
||||
#include "waypointline.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "homeitem.h"
|
||||
const qreal Pi = 3.14;
|
||||
|
||||
namespace mapcontrol
|
||||
@ -35,10 +35,19 @@ WayPointLine::WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem
|
||||
destination(to),my_map(map),QGraphicsLineItem(map),myColor(color)
|
||||
{
|
||||
this->setLine(to->pos().x(),to->pos().y(),from->pos().x(),from->pos().y());
|
||||
connect(source,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(destination,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(source,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
connect(destination,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
connect(from,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(to,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(from,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
connect(to,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
}
|
||||
|
||||
WayPointLine::WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color):source(from),
|
||||
destination(to),my_map(map),QGraphicsLineItem(map),myColor(color)
|
||||
{
|
||||
this->setLine(to->pos().x(),to->pos().y(),from->pos().x(),from->pos().y());
|
||||
connect(from,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(refreshLocations()));
|
||||
connect(to,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(to,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
}
|
||||
int WayPointLine::type() const
|
||||
{
|
||||
|
@ -44,13 +44,14 @@ class WayPointLine:public QObject,public QGraphicsLineItem
|
||||
public:
|
||||
enum { Type = UserType + 8 };
|
||||
WayPointLine(WayPointItem * from, WayPointItem * to,MapGraphicItem * map,QColor color=Qt::green);
|
||||
WayPointLine(HomeItem * from, WayPointItem * to,MapGraphicItem * map,QColor color=Qt::green);
|
||||
int type() const;
|
||||
QPainterPath shape() const;
|
||||
void setColor(const QColor &color)
|
||||
{ myColor = color; }
|
||||
private:
|
||||
WayPointItem * source;
|
||||
WayPointItem * destination;
|
||||
QGraphicsItem * source;
|
||||
QGraphicsItem * destination;
|
||||
MapGraphicItem * my_map;
|
||||
QPolygonF arrowHead;
|
||||
QColor myColor;
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
#include "positionactual.h"
|
||||
#include "homelocation.h"
|
||||
|
||||
#include "pathplanmanager.h"
|
||||
#define allow_manual_home_location_move
|
||||
|
||||
// *************************************************************************************
|
||||
@ -263,13 +263,18 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
connect(m_map, SIGNAL(WPNumberChanged(int const&,int const&,WayPointItem*)), this, SLOT(WPNumberChanged(int const&,int const&,WayPointItem*)));
|
||||
connect(m_map, SIGNAL(WPValuesChanged(WayPointItem*)), this, SLOT(WPValuesChanged(WayPointItem*)));
|
||||
connect(m_map, SIGNAL(WPInserted(int const&, WayPointItem*)), this, SLOT(WPInserted(int const&, WayPointItem*)));
|
||||
connect(m_map, SIGNAL(WPDeleted(int const&)), this, SLOT(WPDeleted(int const&)));
|
||||
connect(m_map, SIGNAL(WPDeleted(int,WayPointItem*)), this, SLOT(WPDeleted(int,WayPointItem*)));
|
||||
connect(m_map,SIGNAL(OnWayPointDoubleClicked(WayPointItem*)),this,SLOT(wpDoubleClickEvent(WayPointItem*)));
|
||||
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
|
||||
m_map->Home->SetCoord(m_home_position.coord); // set the HOME position
|
||||
m_map->UAV->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
||||
if(m_map->GPS)
|
||||
m_map->GPS->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
||||
|
||||
|
||||
pathPlanManager * plan=new pathPlanManager(new QWidget(),m_map);
|
||||
plan->show();
|
||||
|
||||
distBearing db;
|
||||
db.distance=100;
|
||||
db.bearing=0;
|
||||
@ -285,6 +290,7 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
wp=new t_waypoint;
|
||||
wp->map_wp_item=p2;
|
||||
m_waypoint_list.append(wp);
|
||||
|
||||
// **************
|
||||
// create various context menu (mouse right click menu) actions
|
||||
|
||||
@ -959,9 +965,10 @@ void OPMapGadgetWidget::WPInserted(int const &number, WayPointItem *waypoint)
|
||||
/**
|
||||
TODO: slot to do something upon Waypoint deletion
|
||||
*/
|
||||
void OPMapGadgetWidget::WPDeleted(int const &number)
|
||||
void OPMapGadgetWidget::WPDeleted(int const &number, WayPointItem *waypoint)
|
||||
{
|
||||
Q_UNUSED(number);
|
||||
Q_UNUSED(waypoint);
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,7 +176,7 @@ private slots:
|
||||
void WPNumberChanged(int const& oldnumber,int const& newnumber, WayPointItem* waypoint);
|
||||
void WPValuesChanged(WayPointItem* waypoint);
|
||||
void WPInserted(int const& number, WayPointItem* waypoint);
|
||||
void WPDeleted(int const& number);
|
||||
void WPDeleted(int const& number, WayPointItem* waypoint);
|
||||
|
||||
/**
|
||||
* @brief mouse right click context menu signals
|
||||
|
@ -28,27 +28,37 @@
|
||||
#include "ui_pathplanmanager.h"
|
||||
|
||||
pathPlanManager::pathPlanManager(QWidget *parent,OPMapWidget *map):
|
||||
QWidget(parent),myMap(map),
|
||||
QDialog(parent, Qt::Dialog),myMap(map),
|
||||
ui(new Ui::pathPlanManager)
|
||||
{
|
||||
waypoints=new QList<WayPointItem*>();
|
||||
ui->setupUi(this);
|
||||
connect(myMap,SIGNAL(WPDeleted(int)),this,SLOT(on_WPDeleted(int)));
|
||||
connect(myMap,SIGNAL(WPDeleted(int,WayPointItem*)),this,SLOT(on_WPDeleted(int,WayPointItem*)));
|
||||
connect(myMap,SIGNAL(WPInserted(int,WayPointItem*)),this,SLOT(on_WPInserted(int,WayPointItem*)));
|
||||
connect(myMap,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),this,SLOT(on_WPNumberChanged(int,int,WayPointItem*)));
|
||||
connect(myMap,SIGNAL(WPValuesChanged(WayPointItem*)),this,SLOT(on_WPValuesChanged(WayPointItem*)));
|
||||
|
||||
}
|
||||
connect(myMap,SIGNAL(WPCreated(int,WayPointItem*)),this,SLOT(on_WPInserted(int,WayPointItem*)));
|
||||
connect(myMap,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),this,SLOT(refreshOverlays()));
|
||||
connect(myMap,SIGNAL(WPValuesChanged(WayPointItem*)),this,SLOT(refreshOverlays()));
|
||||
}
|
||||
|
||||
pathPlanManager::~pathPlanManager()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void pathPlanManager::on_WPDeleted(int wp_number)
|
||||
void pathPlanManager::on_WPDeleted(int wp_numberint,WayPointItem * wp)
|
||||
{
|
||||
waypoints->removeOne(wp);
|
||||
}
|
||||
|
||||
void pathPlanManager::on_WPInserted(int wp_number, WayPointItem * wp)
|
||||
{
|
||||
qDebug()<<"pathplanner waypoint added";
|
||||
waypoints->append(wp);
|
||||
customData data;
|
||||
data.mode=PathAction::MODE_FLYENDPOINT;
|
||||
data.condition=PathAction::ENDCONDITION_NONE;
|
||||
data.velocity=0;
|
||||
wp->customData().setValue(data);
|
||||
refreshOverlays();
|
||||
}
|
||||
|
||||
void pathPlanManager::on_WPNumberChanged(int oldNumber, int newNumber, WayPointItem * wp)
|
||||
@ -58,3 +68,52 @@ void pathPlanManager::on_WPNumberChanged(int oldNumber, int newNumber, WayPointI
|
||||
void pathPlanManager::on_WPValuesChanged(WayPointItem * wp)
|
||||
{
|
||||
}
|
||||
//typedef enum { MODE_FLYENDPOINT=0, MODE_FLYVECTOR=1, MODE_FLYCIRCLERIGHT=2,
|
||||
//MODE_FLYCIRCLELEFT=3, MODE_DRIVEENDPOINT=4, MODE_DRIVEVECTOR=5, MODE_DRIVECIRCLELEFT=6,
|
||||
//MODE_DRIVECIRCLERIGHT=7, MODE_FIXEDATTITUDE=8, MODE_SETACCESSORY=9, MODE_DISARMALARM=10 } ModeOptions;
|
||||
|
||||
void pathPlanManager::refreshOverlays()
|
||||
{
|
||||
myMap->deleteAllOverlays();
|
||||
qDebug()<<"foreach start";
|
||||
foreach(WayPointItem * wp,*waypoints)
|
||||
{
|
||||
qDebug()<<"wp:"<<wp->Number();
|
||||
customData data=wp->customData().value<customData>();
|
||||
switch(data.mode)
|
||||
{
|
||||
case PathAction::MODE_FLYENDPOINT:
|
||||
case PathAction::MODE_FLYVECTOR:
|
||||
case PathAction::MODE_DRIVEENDPOINT:
|
||||
case PathAction::MODE_DRIVEVECTOR:
|
||||
qDebug()<<"addline";
|
||||
if(wp->Number()==0)
|
||||
myMap->WPLineCreate((HomeItem*)myMap->Home,wp);
|
||||
else
|
||||
myMap->WPLineCreate(findWayPointNumber(wp->Number()-1),wp);
|
||||
break;
|
||||
case PathAction::MODE_FLYCIRCLERIGHT:
|
||||
case PathAction::MODE_DRIVECIRCLERIGHT:
|
||||
myMap->WPCircleCreate(findWayPointNumber(wp->Number()-1),wp,true);
|
||||
break;
|
||||
case PathAction::MODE_FLYCIRCLELEFT:
|
||||
case PathAction::MODE_DRIVECIRCLELEFT:
|
||||
myMap->WPCircleCreate(findWayPointNumber(wp->Number()-1),wp,false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
qDebug()<<"foreach end";
|
||||
}
|
||||
|
||||
WayPointItem * pathPlanManager::findWayPointNumber(int number)
|
||||
{
|
||||
foreach(WayPointItem * wp,*waypoints)
|
||||
{
|
||||
if(wp->Number()==number)
|
||||
return wp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -30,14 +30,10 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include "opmapcontrol/opmapcontrol.h"
|
||||
|
||||
namespace Ui {
|
||||
class pathPlanManager;
|
||||
}
|
||||
using namespace mapcontrol;
|
||||
class pathPlanManager : public QWidget
|
||||
#include "pathaction.h"
|
||||
#include "waypoint.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
Q_OBJECT
|
||||
struct customData
|
||||
{
|
||||
float velocity;
|
||||
@ -49,17 +45,30 @@ class pathPlanManager : public QWidget
|
||||
int jumpdestination;
|
||||
int errordestination;
|
||||
};
|
||||
|
||||
}
|
||||
Q_DECLARE_METATYPE(mapcontrol::customData)
|
||||
namespace Ui {
|
||||
class pathPlanManager;
|
||||
}
|
||||
using namespace mapcontrol;
|
||||
class pathPlanManager : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit pathPlanManager(QWidget *parent,OPMapWidget * map);
|
||||
~pathPlanManager();
|
||||
WayPointItem *findWayPointNumber(int number);
|
||||
private slots:
|
||||
void on_WPDeleted(int);
|
||||
void refreshOverlays();
|
||||
void on_WPDeleted(int wp_numberint, WayPointItem *);
|
||||
void on_WPInserted(int,WayPointItem*);
|
||||
void on_WPNumberChanged(int,int,WayPointItem*);
|
||||
void on_WPValuesChanged(WayPointItem*);
|
||||
private:
|
||||
Ui::pathPlanManager *ui;
|
||||
OPMapWidget * myMap;
|
||||
QList<WayPointItem*> * waypoints;
|
||||
};
|
||||
|
||||
#endif // PATHPLANMANAGER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user