修改航线从缓存读取,多任务模式
This commit is contained in:
@@ -347,6 +347,12 @@ void OPMapWidget::addUAV(int sysid,int compid)
|
||||
connect(uavItem,SIGNAL(selected(int,int)),
|
||||
this,SIGNAL(uav_selected(int,int)));
|
||||
|
||||
connect(uavItem,SIGNAL(vehicleChanged(int,int)),
|
||||
this,SLOT(checkoutVehicle(int,int)));
|
||||
|
||||
|
||||
|
||||
|
||||
uavItem->setOpacity(overlayOpacity);
|
||||
|
||||
//检测,如果只有一个飞机,那么就选中
|
||||
@@ -3178,6 +3184,278 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
|
||||
}
|
||||
|
||||
|
||||
void OPMapWidget::checkoutVehicle(int sys,int comp)
|
||||
{
|
||||
//检查并发送读取航线的信号
|
||||
|
||||
//删除一个组
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
|
||||
if (w) {
|
||||
emit WPDeleted(w->Number(), w);
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
//发送信号清除表格所有东西
|
||||
|
||||
emit clearTable();
|
||||
|
||||
//发送切换的信号,从缓存读取航线
|
||||
|
||||
emit getMissionFromVehicle(sys);
|
||||
|
||||
}
|
||||
|
||||
//这个有可能是其他线程运行,导致生成的航点不对,下载得到
|
||||
void OPMapWidget::vehicleChanged(float param1,float param2,float param3,float param4,
|
||||
int32_t x,int32_t y,float z,
|
||||
uint16_t seq,
|
||||
uint16_t group,
|
||||
uint16_t command,
|
||||
uint8_t target_system,
|
||||
uint8_t target_component,
|
||||
uint8_t frame,
|
||||
uint8_t current,
|
||||
uint8_t autocontinue,
|
||||
uint8_t mission_type)
|
||||
{
|
||||
|
||||
if((mission_type - 2) == -1)
|
||||
{
|
||||
qDebug() << command << seq << param1 << param2 << param3 << param4 << x << y;
|
||||
|
||||
if(command == MAV_CMD_NAV_FENCE_POLYGON_VERTEX_INCLUSION )
|
||||
{
|
||||
static int PolygonCount = 0;
|
||||
static QList<internals::PointLatLng> PolygonPoints;
|
||||
|
||||
PolygonCount ++;
|
||||
bool inclusion = true;
|
||||
|
||||
PolygonPoints.push_back(internals::PointLatLng(x * 10e-8,y * 10e-8));
|
||||
|
||||
if(PolygonCount >= param1)
|
||||
{
|
||||
|
||||
QList<QPointF> latlng;
|
||||
qreal lat_sum = 0;
|
||||
qreal lng_sum = 0;
|
||||
|
||||
for (internals::PointLatLng point: PolygonPoints) {
|
||||
qreal lat = point.Lat();
|
||||
qreal lng = point.Lng();
|
||||
|
||||
lat_sum += lat;
|
||||
lng_sum += lng;
|
||||
|
||||
latlng.push_back(QPointF(lat,lng));
|
||||
}
|
||||
|
||||
internals::PointLatLng center;
|
||||
|
||||
center.SetLat(lat_sum/latlng.size());
|
||||
center.SetLng(lng_sum/latlng.size());
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,0,center,QColor("#FF8000"),map);
|
||||
|
||||
polyitem->setPoints(PolygonPoints);
|
||||
|
||||
emit createFencePolygon(fenceCount++,PolygonPoints.size(),inclusion,latlng);
|
||||
|
||||
connect(polyitem,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)),
|
||||
this,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)));
|
||||
|
||||
PolygonCount = 0;
|
||||
PolygonPoints.clear();
|
||||
}
|
||||
}
|
||||
else if(command == MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION )
|
||||
{
|
||||
static int PolygonCount = 0;
|
||||
static QList<internals::PointLatLng> PolygonPoints;
|
||||
|
||||
PolygonCount ++;
|
||||
bool inclusion = false;
|
||||
|
||||
PolygonPoints.push_back(internals::PointLatLng(x * 10e-8,y * 10e-8));
|
||||
|
||||
if(PolygonCount >= param1)
|
||||
{
|
||||
|
||||
QList<QPointF> latlng;
|
||||
qreal lat_sum = 0;
|
||||
qreal lng_sum = 0;
|
||||
|
||||
for (internals::PointLatLng point: PolygonPoints) {
|
||||
qreal lat = point.Lat();
|
||||
qreal lng = point.Lng();
|
||||
|
||||
lat_sum += lat;
|
||||
lng_sum += lng;
|
||||
|
||||
latlng.push_back(QPointF(lat,lng));
|
||||
}
|
||||
|
||||
internals::PointLatLng center;
|
||||
|
||||
center.SetLat(lat_sum/latlng.size());
|
||||
center.SetLng(lng_sum/latlng.size());
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,0,center,QColor("#FF8000"),map);
|
||||
|
||||
polyitem->setPoints(PolygonPoints);
|
||||
|
||||
emit createFencePolygon(fenceCount++,PolygonPoints.size(),inclusion,latlng);
|
||||
|
||||
connect(polyitem,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)),
|
||||
this,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)));
|
||||
|
||||
PolygonCount = 0;
|
||||
PolygonPoints.clear();
|
||||
}
|
||||
}
|
||||
else if(command == MAV_CMD_NAV_FENCE_CIRCLE_INCLUSION )
|
||||
{
|
||||
bool inclusion = true;
|
||||
qreal radius = param1;
|
||||
|
||||
geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,0,internals::PointLatLng(x * 10e-8,y * 10e-8),radius,QColor("#FF8000"),map);
|
||||
emit createFenceCircle(fenceCount++,radius,inclusion,x * 10e-8,y * 10e-8);
|
||||
|
||||
connect(c,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)),
|
||||
this,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)));
|
||||
}
|
||||
else if(command == MAV_CMD_NAV_FENCE_CIRCLE_EXCLUSION )
|
||||
{
|
||||
bool inclusion = false;
|
||||
qreal radius = param1;
|
||||
|
||||
geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,0,internals::PointLatLng(x * 10e-8,y * 10e-8),radius,QColor("#FF8000"),map);
|
||||
emit createFenceCircle(fenceCount++,radius,inclusion,x * 10e-8,y * 10e-8);
|
||||
|
||||
connect(c,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)),
|
||||
this,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)));
|
||||
}
|
||||
else if(command == MAV_CMD_NAV_RALLY_POINT )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isExist = false;
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
if (w) {
|
||||
if(w->MissionType() == mission_type)//如果组别一样,那么就赋值
|
||||
{
|
||||
if(w->Number() == (seq+1))
|
||||
{
|
||||
|
||||
isExist = true;
|
||||
|
||||
internals::PointLatLng LatLng;
|
||||
|
||||
LatLng.SetLat(x * 10e-8);
|
||||
LatLng.SetLng(y * 10e-8);
|
||||
|
||||
|
||||
w->SetLat(LatLng.Lat());
|
||||
LatLng.SetLng(LatLng.Lng());
|
||||
w->SetNumber(seq+1);
|
||||
|
||||
emit setWPProperty(param1,param2,param3,param4,
|
||||
x,y,z,
|
||||
seq+1,
|
||||
group,
|
||||
command,
|
||||
target_system,
|
||||
target_component,
|
||||
frame,
|
||||
current,
|
||||
autocontinue,
|
||||
mission_type);
|
||||
|
||||
|
||||
w->emitWPProperty();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!isExist)
|
||||
{
|
||||
internals::PointLatLng LatLng;
|
||||
|
||||
LatLng.SetLat(x * 10e-8);
|
||||
LatLng.SetLng(y * 10e-8);
|
||||
|
||||
//获取当前组下面的seq最大值
|
||||
WayPointItem *Item = new WayPointItem(LatLng, z,seq+1,mission_type, map);
|
||||
|
||||
ConnectWP(Item);
|
||||
Item->setParentItem(map);
|
||||
Item->SetMissionType(mission_type);
|
||||
int position = Item->Number();
|
||||
emit WPCreated(position, Item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
|
||||
|
||||
emit setWPProperty(param1,param2,param3,param4,
|
||||
x,y,z,
|
||||
seq+1,
|
||||
group,
|
||||
command,
|
||||
target_system,
|
||||
target_component,
|
||||
frame,
|
||||
current,
|
||||
autocontinue,
|
||||
mission_type);
|
||||
|
||||
|
||||
Item->emitWPProperty();
|
||||
Item->setisShowTip(isShowTip);
|
||||
|
||||
//===========连线
|
||||
WayPointItem *w_last = WPFind(Item->MissionType(),Item->Number() - 1);
|
||||
|
||||
if(w_last)
|
||||
{
|
||||
WPLineCreate(w_last,Item,Qt::green,false,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void OPMapWidget::getMapTypes(void)
|
||||
{
|
||||
emit MapTypes(Helper::MapTypes());
|
||||
|
||||
@@ -675,6 +675,11 @@ signals:
|
||||
void FenceGroupChanged(int old,int cur);
|
||||
|
||||
|
||||
void getMissionFromVehicle(int sys);
|
||||
|
||||
void clearTable();
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
void getAllPoints(int group);
|
||||
@@ -713,6 +718,23 @@ public slots:
|
||||
uint8_t mission_type);
|
||||
|
||||
|
||||
void vehicleChanged(float param1,float param2,float param3,float param4,
|
||||
int32_t x,int32_t y,float z,
|
||||
uint16_t seq,
|
||||
uint16_t group,
|
||||
uint16_t command,
|
||||
uint8_t target_system,
|
||||
uint8_t target_component,
|
||||
uint8_t frame,
|
||||
uint8_t current,
|
||||
uint8_t autocontinue,
|
||||
uint8_t mission_type);
|
||||
|
||||
|
||||
void checkoutVehicle(int sys,int comp);
|
||||
|
||||
|
||||
|
||||
void WPLineDelete(WayPointItem *from, WayPointItem *to);
|
||||
WayPointLine *WPLineFind(WayPointItem *from, WayPointItem *to);
|
||||
|
||||
|
||||
+24
-19
@@ -49,7 +49,7 @@ UAVItem::UAVItem(MapGraphicItem *map, OPMapWidget *parent, QString uavPic ,uint8
|
||||
|
||||
localposition = map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||
this->setPos(localposition.X(), localposition.Y());
|
||||
this->setZValue(4);
|
||||
this->setZValue(7);
|
||||
trail = new QGraphicsItemGroup(this);
|
||||
trail->setParentItem(map);
|
||||
trailLine = new QGraphicsItemGroup(this);
|
||||
@@ -99,11 +99,11 @@ void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
this->setZValue(5);
|
||||
this->setZValue(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setZValue(4);
|
||||
this->setZValue(7);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,11 +200,11 @@ void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
painter->save();
|
||||
|
||||
painter->drawRect(boundingRect());
|
||||
|
||||
painter->restore();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -230,23 +230,28 @@ void UAVItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
|
||||
isSelected = true;
|
||||
//查找所有
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
UAVItem *uav = qgraphicsitem_cast<UAVItem *>(i);
|
||||
if (uav) {
|
||||
if(uav != this)
|
||||
{
|
||||
uav->setSelect(false);
|
||||
if(isSelected == false)
|
||||
{
|
||||
isSelected = true;
|
||||
//查找所有
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
UAVItem *uav = qgraphicsitem_cast<UAVItem *>(i);
|
||||
if (uav) {
|
||||
if(uav != this)
|
||||
{
|
||||
uav->setSelect(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "emit select" << sysid << compid;
|
||||
emit selected(sysid,compid);
|
||||
qDebug() << "emit select" << sysid << compid;
|
||||
emit selected(sysid,compid);
|
||||
|
||||
isShowTip = (isShowTip)?(false):(true);
|
||||
isShowTip = (isShowTip)?(false):(true);
|
||||
|
||||
update();
|
||||
emit vehicleChanged(sysid,compid);
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
//QGraphicsItem::mouseReleaseEvent(event);
|
||||
@@ -284,7 +289,7 @@ void UAVItem::setEdit(bool value)
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setZValue(4);
|
||||
this->setZValue(7);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -286,6 +286,8 @@ signals:
|
||||
|
||||
void selected(int sys,int comp);
|
||||
|
||||
void vehicleChanged(int sys,int comp);
|
||||
|
||||
void UAVReachedWayPoint(int const & waypointnumber, WayPointItem *waypoint);
|
||||
void UAVLeftSafetyBouble(internals::PointLatLng const & position);
|
||||
void setChildPosition();
|
||||
|
||||
Reference in New Issue
Block a user