diff --git a/App/GCS_zh_CN.qm b/App/GCS_zh_CN.qm
index 4507ccb..8ba1ba1 100644
Binary files a/App/GCS_zh_CN.qm and b/App/GCS_zh_CN.qm differ
diff --git a/App/GCS_zh_CN.ts b/App/GCS_zh_CN.ts
index 46ecca7..257f0ec 100644
--- a/App/GCS_zh_CN.ts
+++ b/App/GCS_zh_CN.ts
@@ -350,22 +350,12 @@
界面
-
- 无人机
-
-
-
-
- 航点
-
-
-
-
+
切换无人机
-
+
切换航点
@@ -422,87 +412,117 @@
指令 版本:
-
+
+ Group 1
+
+
+
+
+ Group 2
+
+
+
+
+ Group 3
+
+
+
+
+ Group 4
+
+
+
+
Selete Command File...
选择指令脚本...
-
+
command file (*.json)
指令脚本 (*.json)
-
+
.json
-
+
.qml
-
-
+
+
发送指令 %1 %2
-
+
无人机 %1 %2 %3 %4
-
+
set parameter
-
+
%1,%2 accepted and executed
%1,%2 发送成功
-
+
%1,%2 rejected
%1,%2 拒绝执行
-
+
%1,%2 permanently denied
%1,%2 永久拒绝
-
+
%1,%2 unsupported
%1,%2 不支持
-
+
%1,%2 failed
%1,%2 发送失败
-
+
%1,%2 being executed
%1,%2 正在执行
-
+
%1,%2 time out
%1,%2 发送超时
-
+
Please do not operate too fast, the last instruction has not been sent
请不要操作过快,上一个指令未发送完成
-
+
设置航点 %1
+
+
+ point:
+
+
+
+
+ click confirm to set uav %1 as current
+
+
%1 accepted and executed
%1 执行成功
@@ -528,7 +548,7 @@
%1 正在执行
-
+
click confirm to set Point %1 as current point
点击设置航点%1为当前航点
@@ -2122,36 +2142,36 @@
参数
-
-
+
+
Communication Lost
通讯丢失
-
-
+
+
Communication Regain
通讯已恢复
-
+
R:%1 / T:%2
收:%1/发:%2
-
-
-
+
+
+
未定位
-
+
%1D[%2颗]
%1D[%2颗]
-
+
fix[%1颗]
%1D Fix
差分[%1颗]
@@ -2169,256 +2189,256 @@
GPS错误
-
+
float[%1颗]
浮点[%1颗]
-
+
err[%1颗]
错误[%1颗]
-
+
ARM
解锁
-
+
DISARM
上锁
-
+
MANUAL
手动
-
+
ALTCTL
定高
-
+
POSCTL
定点
-
+
AUTO
自主
-
+
ACRO
-
+
OFFBOARD
-
+
STABILIZED
增稳
-
+
RATTITUDE
速率
-
+
STANDBY
待机
-
+
BIT
测试
-
+
AUTO_READY
就绪
-
+
AUTO_TAKEOFF
起飞
-
+
AUTO_LOITER
盘旋
-
+
AUTO_MISSION
任务
-
+
AUTO_RTL
返航
-
+
AUTO_LAND
着陆
-
+
AUTO_RTGS
RTGS
-
+
AUTO_FOLLOW_TARGET
目标跟随
-
+
开加力
-
+
半加力
-
+
全加力
-
+
关加力
-
+
伞舱开
-
+
伞舱关
-
+
INS解算正常
-
+
INS星数不足
-
+
INS内部错误
-
+
INS速度超限
-
+
SBG解算正常
-
+
SBG星数不足
-
+
SBG内部错误
-
+
SBG速度超限
-
+
安控区内
-
+
安控区外
-
+
mission group has changed, current group is %1
航线切换,当前航线为 %1
-
+
VERT_OFF
OFF
纵向制导关闭
-
+
VNAV2THT
消除纵向偏差
-
+
HDOT2THT
控制升降速率
-
+
GAMMA2THT
控制航迹角
-
+
AS2THT
俯仰控制速度
-
+
H2THT
控制绝对高度
-
+
AGL2THT
控制相对高度
-
+
LAT_OFF
横向制导关闭
-
+
LNAV2PHI
滚转消除侧偏
-
+
PSI2PHI
滚转控制航向
-
-
-
+
+
+
@@ -2427,156 +2447,156 @@
未定位
-
-
+
+
未初始化
-
-
+
+
垂直陀螺
-
-
+
+
AHRS
-
-
+
+
速度导航
-
-
+
+
位置导航
-
-
+
+
正常
-
-
-
+
+
-
+
+
无效
-
-
+
+
解算正常
-
-
+
+
卫星数不足
-
-
+
+
内部错误
-
-
+
+
速度超限
-
-
-
-
+
+
+
+
未知
-
-
+
+
多普勒
-
-
+
+
微分
-
-
-
- 单点
-
-
-
-
-
- 伪距差分
-
-
-
-
-
- SBAS广域差分
-
-
- 广域差分
+ 单点
- RTK_FLOAT
+ 伪距差分
- RTK_INT
+ SBAS广域差分
- PPP_FLOAT
+ 广域差分
- PPP_INT
+ RTK_FLOAT
+ RTK_INT
+
+
+
+
+
+ PPP_FLOAT
+
+
+
+
+
+ PPP_INT
+
+
+
+
+
FIXED
@@ -2585,17 +2605,17 @@
未支持
-
+
flight mode
飞行模式
-
+
连接内置惯导
-
+
连接SBG
@@ -2832,118 +2852,141 @@
起飞
-
+
number
航点
-
+
command
类型
-
+
par1
参数1
-
+
par2
参数2
-
+
par3
参数3
-
+
par4
参数4
-
-
+
+
lat
纬度
-
-
+
+
lng
经度
-
+
group
组别
-
+
+
+
inclusion
包含
-
+
par
参数
-
+
+ type
+ 类型
+
+
+
alt
海拔
-
-
+
+ Circle
+ 圆形
+
+
+
+
+ exclusion
+ 除外
+
+
+
+ Polygon
+ 多边形
+
+
+
+
航点
-
-
+
+
返航
-
-
+
+
降落
-
-
+
+
起飞
-
-
+
+
保持
-
-
+
+
表速
-
-
+
+
快升
-
-
+
+
开加力
-
-
+
+
关加力
@@ -5058,87 +5101,87 @@ p, li { white-space: pre-wrap; }
-
-
-
+
+
+
Relative
相对
-
-
-
+
+
+
Absolutely
绝对
-
+
param1
-
+
param2
-
+
param3
-
+
param4
-
+
param5
-
+
param6
-
+
param7
-
+
set
设置
-
+
Altitude
海拔
-
+
setLatitude
设置纬度
-
+
setLongitude
设置经度
-
-
+
+
plan file (*.plan)
任务文件 (*.plan)
-
+
click to clear all points
点击清除所有航点
-
+
Measuring
测量中
@@ -5194,7 +5237,7 @@ p, li { white-space: pre-wrap; }
-
+
Measure
测量
@@ -5208,8 +5251,8 @@ p, li { white-space: pre-wrap; }
组别
-
-
+
+
Selete Way Point File...
Select Loading File...
选择载入文件...
diff --git a/App/MenuBarUI/MenuBarUI.h b/App/MenuBarUI/MenuBarUI.h
index 0ce74de..a28df01 100644
--- a/App/MenuBarUI/MenuBarUI.h
+++ b/App/MenuBarUI/MenuBarUI.h
@@ -51,6 +51,9 @@ public slots:
void setTagetAirspeed(QVariant Value);
void setFlightTime(QTime Value);
+
+
+
signals:
void IndexChanged(int);
diff --git a/App/MissionUI/MissionUI.cpp b/App/MissionUI/MissionUI.cpp
index aa9f518..c79edf3 100644
--- a/App/MissionUI/MissionUI.cpp
+++ b/App/MissionUI/MissionUI.cpp
@@ -243,7 +243,7 @@ MissionUI::MissionUI(QWidget *parent) :
{
if(tablelist.key(table) == 1)//围栏
{
- table->setColumnCount(5); //设置列数为7
+ table->setColumnCount(6); //设置列数为7
table->setGeometry(QRect(10,455,740,95)); //设置tableWidget的大小
table->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选中模式为选中行
table->setSelectionMode ( QAbstractItemView::SingleSelection); //设置选择模式,选择单行
@@ -254,14 +254,15 @@ MissionUI::MissionUI(QWidget *parent) :
table->setFocusPolicy(Qt::StrongFocus);
table->setStyleSheet("QTableWidget::item:selected { background-color: rgb(85, 255, 127); color: rgb(255, 255, 255); } ");
- table->setColumnWidth(0,200); //设置第1列的列宽(group)
- table->setColumnWidth(1,200); //设置第2列的列宽(par1)
- table->setColumnWidth(2,150); //设置第3列的列宽(par2)
- table->setColumnWidth(3,150); //设置第4列的列宽(lat)
- table->setColumnWidth(4,150); //设置第5列的列宽(lng)
+ table->setColumnWidth(0,45); //设置第1列的列宽(group)
+ table->setColumnWidth(1,80); //设置第1列的列宽(type)
+ table->setColumnWidth(2,80); //设置第2列的列宽(par1)
+ table->setColumnWidth(3,80); //设置第3列的列宽(inclusion)
+ table->setColumnWidth(4,150); //设置第4列的列宽(lat)
+ table->setColumnWidth(5,150); //设置第5列的列宽(lng)
- table->setHorizontalHeaderLabels(QStringList() <setHorizontalHeaderLabels(QStringList() <
verticalHeader();
V_headerView->setHidden(true); //行名隐藏
@@ -344,6 +345,138 @@ void MissionUI::resizeEvent(QResizeEvent *event)
}
+void MissionUI::createFenceCircle(int group,qreal radius,bool inclusion,qreal lat,qreal lng)
+{
+ QTableWidget *tableWidget = tablelist.value(1);
+ if(!tableWidget)
+ {
+ qDebug() << "UNFIND TABLE";
+ return;
+ }
+
+ int idx = tableWidget->rowCount();
+
+ tableWidget->setRowCount(tableWidget->rowCount()+1); //设置行数+1
+
+ tableWidget->removeCellWidget(idx,0);
+ tableWidget->setItem(idx,0,new QTableWidgetItem(QString::number(group))); //第一列的内容设置为index
+
+ tableWidget->removeCellWidget(idx,1);
+ tableWidget->setItem(idx,1,new QTableWidgetItem(tr("Circle")));
+
+ tableWidget->removeCellWidget(idx,2);
+ tableWidget->setItem(idx,2,new QTableWidgetItem(QString::number(radius)));
+
+
+ QString inclusionName;
+ switch (inclusion) {
+ case 1:
+ inclusionName = tr("inclusion");
+ break;
+ case 0:
+ inclusionName = tr("exclusion");
+ break;
+ default:
+ break;
+ }
+
+ QTableWidgetItem *item3 = new QTableWidgetItem(inclusionName);
+ item3->setCheckState((inclusion)?(Qt::Checked):(Qt::Unchecked));
+
+ tableWidget->removeCellWidget(idx,3);
+ tableWidget->setItem(idx,3,item3);
+
+ tableWidget->removeCellWidget(idx,4);
+ tableWidget->setItem(idx,4,new QTableWidgetItem(QString::number(lat ,'f',7)));
+
+ tableWidget->removeCellWidget(idx,5);
+ tableWidget->setItem(idx,5,new QTableWidgetItem(QString::number(lng ,'f',7)));
+
+
+ for (int i = 0;irowCount();i++)
+ {
+ if(tableWidget->item(i,0)==NULL|| //判断指向该cell的指针是否为空
+ (tableWidget->item(i,0)&&
+ tableWidget->item(i,0)->text()==tr(""))) //判断该cell的text是否为空
+ {
+ tableWidget->removeRow(i);
+ }
+ }
+}
+
+void MissionUI::createFencePolygon(int group,qreal vertex, bool inclusion, QList latlng)
+{
+ QTableWidget *tableWidget = tablelist.value(1);
+ if(!tableWidget)
+ {
+ qDebug() << "UNFIND TABLE";
+ return;
+ }
+
+ int startIndex = tableWidget->rowCount();
+ for(QPointF p:latlng)
+ {
+ qreal lat = p.x();
+ qreal lng = p.y();
+
+ int idx = tableWidget->rowCount();
+ tableWidget->setRowCount(tableWidget->rowCount()+1); //设置行数+1
+
+ tableWidget->removeCellWidget(idx,0);
+ tableWidget->setItem(idx,0,new QTableWidgetItem(QString::number(group))); //第一列的内容设置为index
+
+ tableWidget->removeCellWidget(idx,1);
+ tableWidget->setItem(idx,1,new QTableWidgetItem(tr("Polygon")));
+
+ tableWidget->removeCellWidget(idx,2);
+ tableWidget->setItem(idx,2,new QTableWidgetItem(QString::number(vertex)));
+
+
+ QString inclusionName;
+ switch (inclusion) {
+ case 1:
+ inclusionName = tr("inclusion");
+ break;
+ case 0:
+ inclusionName = tr("exclusion");
+ break;
+ default:
+ break;
+ }
+
+ QTableWidgetItem *item3 = new QTableWidgetItem(inclusionName);
+ item3->setCheckState((inclusion)?(Qt::Checked):(Qt::Unchecked));
+
+ tableWidget->removeCellWidget(idx,3);
+ tableWidget->setItem(idx,3,item3);
+
+ tableWidget->removeCellWidget(idx,4);
+ tableWidget->setItem(idx,4,new QTableWidgetItem(QString::number(lat ,'f',7)));
+
+ tableWidget->removeCellWidget(idx,5);
+ tableWidget->setItem(idx,5,new QTableWidgetItem(QString::number(lng ,'f',7)));
+ }
+
+ int endIndex = tableWidget->rowCount();
+
+ tableWidget->setSpan(startIndex,0,endIndex - startIndex,1);
+ tableWidget->setSpan(startIndex,1,endIndex - startIndex,1);
+ tableWidget->setSpan(startIndex,2,endIndex - startIndex,1);
+ tableWidget->setSpan(startIndex,3,endIndex - startIndex,1);
+
+
+
+ for (int i = 0;irowCount();i++)
+ {
+ if(tableWidget->item(i,0)==NULL|| //判断指向该cell的指针是否为空
+ (tableWidget->item(i,0)&&
+ tableWidget->item(i,0)->text()==tr(""))) //判断该cell的text是否为空
+ {
+ tableWidget->removeRow(i);
+ }
+ }
+}
+
void MissionUI::pointCreate(float param1,float param2,float param3,float param4,
int32_t x,int32_t y,float z,
uint16_t seq,
@@ -580,6 +713,12 @@ void MissionUI::on_tabWidget_currentChanged(int index)
void MissionUI::itemSelectionChanged()
{
QTableWidget *widget = qobject_cast(sender());
+
+ if(widget == tablelist.value(1))
+ {
+ return;
+ }
+
int group = tablelist.key(widget);
int idx = widget->currentRow() + 1;
@@ -592,236 +731,544 @@ void MissionUI::itemSelectionChanged()
void MissionUI::itemClicked(QTableWidgetItem *item)
{
QTableWidget *widget = qobject_cast(sender());
+
int group = tablelist.key(widget);
int idx = widget->currentRow() + 1;
- emit waypointSelect(group,idx);//告诉底层要切换航点,切换航点后,会对表格进行设置,这个有问题,会导致表格重复刷新
+ int row=item->row();
+ int column = item->column();
+
+
+ if(widget == tablelist.value(1))
+ {
+ if(column == 3)
+ {
+ if(item->checkState() == Qt::Checked)//包含
+ {
+ QString inclusionName = tr("inclusion");
+ item->setText(inclusionName);
+ }
+ else//不包含
+ {
+ QString inclusionName = tr("exclusion");
+ item->setText(inclusionName);
+ }
+ }
+
+ int gidx = widget->item(row,0)->data(Qt::DisplayRole).toInt();//得到group
+ //找到开始的idx
+ int StartIdx = widget->item(row,0)->row();
+ for (int i = 0; i < widget->rowCount(); ++i) {
+ if(widget->item(i,0)->data(Qt::DisplayRole).toInt() == gidx)
+ {
+ StartIdx = i;
+ break;
+ }
+ }
+
+ int SpanCount = widget->rowSpan(row,0);
+
+ QString type = widget->item(StartIdx,1)->data(Qt::DisplayRole).toString();//得到type
+ qreal par = widget->item(StartIdx,2)->data(Qt::DisplayRole).toDouble();//得到par
+ bool inclusion = widget->item(StartIdx,3)->checkState()?(true):(false);
+
+ if(type == tr("Circle"))
+ {
+ qreal latitude = widget->item(row,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(row,5)->data(Qt::DisplayRole).toDouble();
+
+ emit setFenceCircle(gidx,par,inclusion,latitude,longitude);//修改圆形
+
+ }
+ else if(type == tr("Polygon"))
+ {
+ //从头获取所有点
+ QList latlng;
+ latlng.clear();
+
+ for(int i = StartIdx;i<(StartIdx + SpanCount);i++)
+ {
+ qreal latitude = widget->item(i,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(i,5)->data(Qt::DisplayRole).toDouble();
+
+ latlng.push_back(QPointF(latitude,longitude));
+ }
+
+ emit setFencePolygon(gidx,par,inclusion,latlng);
+
+ }
+ }
+ else
+ {
+ emit waypointSelect(group,idx);//告诉底层要切换航点,切换航点后,会对表格进行设置,这个有问题,会导致表格重复刷新
+ }
}
void MissionUI::itemDoubleClicked(QTableWidgetItem *item)
{
QTableWidget *widget = qobject_cast(sender());
+
int group = tablelist.key(widget);
int idx = widget->currentRow() + 1;
- //emit waypointSelect(group,idx);//切换过去
-
int row=item->row();
int column = item->column();
- if((column == 1)||(column == 2))//如果是第一个或者第二个,那么有操作
+
+ if(widget == tablelist.value(1))
{
- QVariant itemValue = item->data(Qt::DisplayRole);
-
- bool ok = false;
- qreal realValue = itemValue.toDouble(&ok);
-
- if(ok)//能够转成数字
+ if(column == 2)
{
- if(column == 2)
+ QString type = widget->item(row,1)->data(Qt::DisplayRole).toString();//得到type
+ if(type == tr("Circle"))
+ {
+ QLineEdit *line = new QLineEdit(widget);
+ line->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
+ line->setText(item->data(Qt::DisplayRole).toString());
+ widget->removeCellWidget(row,column);
+ widget->setCellWidget(row,column,line);
+
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ item->setText(str);
+ }
+
+ int gidx = widget->item(row,0)->data(Qt::DisplayRole).toInt();//得到group
+ //找到开始的idx
+ int StartIdx = widget->item(row,0)->row();
+ for (int i = 0; i < widget->rowCount(); ++i) {
+ if(widget->item(i,0)->data(Qt::DisplayRole).toInt() == gidx)
+ {
+ StartIdx = i;
+ break;
+ }
+ }
+
+ qreal par = widget->item(StartIdx,2)->data(Qt::DisplayRole).toDouble();//得到par
+ bool inclusion = widget->item(StartIdx,3)->checkState()?(true):(false);
+
+ qreal latitude = widget->item(row,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(row,5)->data(Qt::DisplayRole).toDouble();
+
+ emit setFenceCircle(gidx,par,inclusion,latitude,longitude);//修改圆形
+ }
+ });
+ }
+ }
+ else if(column == 3)
+ {
+ if(item->checkState() == Qt::Checked)//包含
+ {
+ QString inclusionName = tr("inclusion");
+ item->setText(inclusionName);
+ }
+ else//不包含
+ {
+ QString inclusionName = tr("exclusion");
+ item->setText(inclusionName);
+ }
+
+ int gidx = widget->item(row,0)->data(Qt::DisplayRole).toInt();//得到group
+ //找到开始的idx
+ int StartIdx = widget->item(row,0)->row();
+ for (int i = 0; i < widget->rowCount(); ++i) {
+ if(widget->item(i,0)->data(Qt::DisplayRole).toInt() == gidx)
+ {
+ StartIdx = i;
+ break;
+ }
+ }
+
+ int SpanCount = widget->rowSpan(row,0);
+
+ QString type = widget->item(StartIdx,1)->data(Qt::DisplayRole).toString();//得到type
+ qreal par = widget->item(StartIdx,2)->data(Qt::DisplayRole).toDouble();//得到par
+ bool inclusion = widget->item(StartIdx,3)->checkState()?(true):(false);
+
+ if(type == tr("Circle"))
+ {
+ qreal latitude = widget->item(row,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(row,5)->data(Qt::DisplayRole).toDouble();
+
+ emit setFenceCircle(gidx,par,inclusion,latitude,longitude);//修改圆形
+
+ }
+ else if(type == tr("Polygon"))
+ {
+ //从头获取所有点
+ QList latlng;
+ latlng.clear();
+
+ for(int i = StartIdx;i<(StartIdx + SpanCount);i++)
+ {
+ qreal latitude = widget->item(i,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(i,5)->data(Qt::DisplayRole).toDouble();
+
+ latlng.push_back(QPointF(latitude,longitude));
+ }
+
+ emit setFencePolygon(gidx,par,inclusion,latlng);
+ }
+
+ }
+ else if(column == 4)
+ {
+ QLineEdit *line = new QLineEdit(widget);
+ line->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
+ line->setText(item->data(Qt::DisplayRole).toString());
+ widget->removeCellWidget(row,column);
+ widget->setCellWidget(row,column,line);
+
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ item->setText(str);
+ }
+
+ int gidx = widget->item(row,0)->data(Qt::DisplayRole).toInt();//得到group
+ //找到开始的idx
+ int StartIdx = widget->item(row,0)->row();
+ for (int i = 0; i < widget->rowCount(); ++i) {
+ if(widget->item(i,0)->data(Qt::DisplayRole).toInt() == gidx)
+ {
+ StartIdx = i;
+ break;
+ }
+ }
+
+ int SpanCount = widget->rowSpan(row,0);
+
+ QString type = widget->item(StartIdx,1)->data(Qt::DisplayRole).toString();//得到type
+ qreal par = widget->item(StartIdx,2)->data(Qt::DisplayRole).toDouble();//得到par
+ bool inclusion = widget->item(StartIdx,3)->checkState()?(true):(false);
+
+ if(type == tr("Circle"))
+ {
+ qreal latitude = widget->item(row,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(row,5)->data(Qt::DisplayRole).toDouble();
+
+ emit setFenceCircle(gidx,par,inclusion,latitude,longitude);//修改圆形
+
+ }
+ else if(type == tr("Polygon"))
+ {
+ //从头获取所有点
+ QList latlng;
+ latlng.clear();
+
+ for(int i = StartIdx;i<(StartIdx + SpanCount);i++)
+ {
+ qreal latitude = widget->item(i,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(i,5)->data(Qt::DisplayRole).toDouble();
+
+ latlng.push_back(QPointF(latitude,longitude));
+ }
+
+ emit setFencePolygon(gidx,par,inclusion,latlng);
+ }
+ }
+ });
+ }
+ else if(column == 5)
+ {
+ QLineEdit *line = new QLineEdit(widget);
+ line->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
+ line->setText(item->data(Qt::DisplayRole).toString());
+ widget->removeCellWidget(row,column);
+ widget->setCellWidget(row,column,line);
+
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ item->setText(str);
+ }
+
+
+ int gidx = widget->item(row,0)->data(Qt::DisplayRole).toInt();//得到group
+ //找到开始的idx
+ int StartIdx = widget->item(row,0)->row();
+ for (int i = 0; i < widget->rowCount(); ++i) {
+ if(widget->item(i,0)->data(Qt::DisplayRole).toInt() == gidx)
+ {
+ StartIdx = i;
+ break;
+ }
+ }
+
+ int SpanCount = widget->rowSpan(row,0);
+
+ QString type = widget->item(StartIdx,1)->data(Qt::DisplayRole).toString();//得到type
+ qreal par = widget->item(StartIdx,2)->data(Qt::DisplayRole).toDouble();//得到par
+ bool inclusion = widget->item(StartIdx,3)->checkState()?(true):(false);
+
+ if(type == tr("Circle"))
+ {
+ qreal latitude = widget->item(row,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(row,5)->data(Qt::DisplayRole).toDouble();
+
+ emit setFenceCircle(gidx,par,inclusion,latitude,longitude);//修改圆形
+
+ }
+ else if(type == tr("Polygon"))
+ {
+ //从头获取所有点
+ QList latlng;
+ latlng.clear();
+
+ for(int i = StartIdx;i<(StartIdx + SpanCount);i++)
+ {
+ qreal latitude = widget->item(i,4)->data(Qt::DisplayRole).toDouble();
+ qreal longitude = widget->item(i,5)->data(Qt::DisplayRole).toDouble();
+
+ latlng.push_back(QPointF(latitude,longitude));
+ }
+
+ emit setFencePolygon(gidx,par,inclusion,latlng);
+ }
+
+ }
+ });
+ }
+ }
+ else
+ {
+ //emit waypointSelect(group,idx);//切换过去
+
+ if((column == 1)||(column == 2))//如果是第一个或者第二个,那么有操作
+ {
+ QVariant itemValue = item->data(Qt::DisplayRole);
+
+ bool ok = false;
+ qreal realValue = itemValue.toDouble(&ok);
+
+ if(ok)//能够转成数字
+ {
+ if(column == 2)
+ {
+ QLineEdit *line = new QLineEdit(widget);
+ line->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
+ line->setText(itemValue.toString());
+
+ widget->removeCellWidget(row,column);
+ widget->setCellWidget(row,column,line);
+
+ opwidget = widget;
+ opitem = item;
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ emit setParam1(str);//能够正常转换成数字再修改
+ }
+ }
+ });
+ }
+ }
+ else//不能转成数字
+ {
+ if(column == 1)
+ {
+ QComboBox *combox = new QComboBox(widget);
+ combox->addItem(tr("航点"),16);
+ combox->addItem(tr("返航"),20);
+ combox->addItem(tr("降落"),21);
+ combox->addItem(tr("起飞"),22);
+ combox->setCurrentIndex(combox->findText(itemValue.toString()));
+ combox->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
+
+ widget->removeCellWidget(row,column);
+ widget->setCellWidget(row,column,combox);
+
+ connect(combox,&QComboBox::currentTextChanged,[=]{
+ QString str = combox->currentText();
+ widget->removeCellWidget(row,column);
+ emit setCommand(str);//直接修改底层,让底层返回数据更新到界面
+ });
+
+ connect(combox,&QComboBox::editTextChanged,[=]{
+ QString str = combox->currentText();
+ widget->removeCellWidget(row,column);
+ emit setCommand(str);//直接修改底层,让底层返回数据更新到界面
+ });
+ }
+ else if(column == 2)
+ {
+ QComboBox *combox = new QComboBox(widget);
+ combox->addItem(tr("保持"),0);
+ combox->addItem(tr("表速"),-1);
+ combox->addItem(tr("快升"),-2);
+ combox->addItem(tr("开加力"),-3);
+ combox->addItem(tr("关加力"),-4);
+ combox->setCurrentIndex(combox->findText(itemValue.toString()));
+ combox->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
+
+ widget->removeCellWidget(row,column);
+ widget->setCellWidget(row,column,combox);
+
+ connect(combox,&QComboBox::currentTextChanged,[=]{
+ QString str = combox->currentText();
+ widget->removeCellWidget(row,column);
+ emit setParam1(str);
+ });
+ }
+ }
+
+ qDebug() << "clicked" << row << column << itemValue << ok;
+ }
+ else//后面的参数,应该都是数字
+ {
+ if(column == 0)//第一个不能编辑
+ {
+ return;
+ }
+
+ QVariant itemValue = item->data(Qt::DisplayRole);
+
+ bool ok = false;
+ qreal realValue = itemValue.toDouble(&ok);
+
+ if(ok)//能够转成数字
{
QLineEdit *line = new QLineEdit(widget);
line->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
line->setText(itemValue.toString());
-
widget->removeCellWidget(row,column);
widget->setCellWidget(row,column,line);
opwidget = widget;
opitem = item;
- connect(line,&QLineEdit::editingFinished,[=](){
- if(line)
- {
- QString str = line->text();
- bool ok = false;
- str.toDouble(&ok);
- if(ok)
+
+ if(column == 3)
+ {
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
{
- widget->removeCellWidget(row,column);
- emit setParam1(str);//能够正常转换成数字再修改
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ emit setParam2(str);//能够正常转换成数字再修改
+ }
}
- }
- });
+ });
+ }
+ else if(column == 4)
+ {
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ emit setParam3(str);//能够正常转换成数字再修改
+ }
+ }
+ });
+ }
+ else if(column == 5)
+ {
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ emit setParam4(str);//能够正常转换成数字再修改
+ }
+ }
+ });
+ }
+ else if(column == 6)
+ {
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ emit setParam5(str);//能够正常转换成数字再修改
+ }
+ }
+ });
+ }
+ else if(column == 7)
+ {
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ emit setParam6(str);//能够正常转换成数字再修改
+ }
+ }
+ });
+ }
+ else if(column == 8)
+ {
+ connect(line,&QLineEdit::editingFinished,[=](){
+ if(line)
+ {
+ QString str = line->text();
+ bool ok = false;
+ str.toDouble(&ok);
+ if(ok)
+ {
+ widget->removeCellWidget(row,column);
+ emit setParam7(str);//能够正常转换成数字再修改
+ }
+ }
+ });
+ }
}
- }
- else//不能转成数字
- {
- if(column == 1)
- {
- QComboBox *combox = new QComboBox(widget);
- combox->addItem(tr("航点"),16);
- combox->addItem(tr("返航"),20);
- combox->addItem(tr("降落"),21);
- combox->addItem(tr("起飞"),22);
- combox->setCurrentIndex(combox->findText(itemValue.toString()));
- combox->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
-
- widget->removeCellWidget(row,column);
- widget->setCellWidget(row,column,combox);
-
- connect(combox,&QComboBox::currentTextChanged,[=]{
- QString str = combox->currentText();
- widget->removeCellWidget(row,column);
- emit setCommand(str);//直接修改底层,让底层返回数据更新到界面
- });
-
- connect(combox,&QComboBox::editTextChanged,[=]{
- QString str = combox->currentText();
- widget->removeCellWidget(row,column);
- emit setCommand(str);//直接修改底层,让底层返回数据更新到界面
- });
- }
- else if(column == 2)
- {
- QComboBox *combox = new QComboBox(widget);
- combox->addItem(tr("保持"),0);
- combox->addItem(tr("表速"),-1);
- combox->addItem(tr("快升"),-2);
- combox->addItem(tr("开加力"),-3);
- combox->addItem(tr("关加力"),-4);
- combox->setCurrentIndex(combox->findText(itemValue.toString()));
- combox->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
-
- widget->removeCellWidget(row,column);
- widget->setCellWidget(row,column,combox);
-
- connect(combox,&QComboBox::currentTextChanged,[=]{
- QString str = combox->currentText();
- widget->removeCellWidget(row,column);
- emit setParam1(str);
- });
- }
- }
-
- qDebug() << "clicked" << row << column << itemValue << ok;
- }
- else//后面的参数,应该都是数字
- {
- if(column == 0)//第一个不能编辑
- {
- return;
- }
-
- QVariant itemValue = item->data(Qt::DisplayRole);
-
- bool ok = false;
- qreal realValue = itemValue.toDouble(&ok);
-
- if(ok)//能够转成数字
- {
- QLineEdit *line = new QLineEdit(widget);
- line->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
- line->setText(itemValue.toString());
- widget->removeCellWidget(row,column);
- widget->setCellWidget(row,column,line);
-
- opwidget = widget;
- opitem = item;
-
- if(column == 3)
+ else//不能转成数字
{
- connect(line,&QLineEdit::editingFinished,[=](){
- if(line)
- {
- QString str = line->text();
- bool ok = false;
- str.toDouble(&ok);
- if(ok)
- {
- widget->removeCellWidget(row,column);
- emit setParam2(str);//能够正常转换成数字再修改
- }
- }
- });
+ qDebug() << "input error";
}
- else if(column == 4)
- {
- connect(line,&QLineEdit::editingFinished,[=](){
- if(line)
- {
- QString str = line->text();
- bool ok = false;
- str.toDouble(&ok);
- if(ok)
- {
- widget->removeCellWidget(row,column);
- emit setParam3(str);//能够正常转换成数字再修改
- }
- }
- });
- }
- else if(column == 5)
- {
- connect(line,&QLineEdit::editingFinished,[=](){
- if(line)
- {
- QString str = line->text();
- bool ok = false;
- str.toDouble(&ok);
- if(ok)
- {
- widget->removeCellWidget(row,column);
- emit setParam4(str);//能够正常转换成数字再修改
- }
- }
- });
- }
- else if(column == 6)
- {
- connect(line,&QLineEdit::editingFinished,[=](){
- if(line)
- {
- QString str = line->text();
- bool ok = false;
- str.toDouble(&ok);
- if(ok)
- {
- widget->removeCellWidget(row,column);
- emit setParam5(str);//能够正常转换成数字再修改
- }
- }
- });
- }
- else if(column == 7)
- {
- connect(line,&QLineEdit::editingFinished,[=](){
- if(line)
- {
- QString str = line->text();
- bool ok = false;
- str.toDouble(&ok);
- if(ok)
- {
- widget->removeCellWidget(row,column);
- emit setParam6(str);//能够正常转换成数字再修改
- }
- }
- });
- }
- else if(column == 8)
- {
- connect(line,&QLineEdit::editingFinished,[=](){
- if(line)
- {
- QString str = line->text();
- bool ok = false;
- str.toDouble(&ok);
- if(ok)
- {
- widget->removeCellWidget(row,column);
- emit setParam7(str);//能够正常转换成数字再修改
- }
- }
- });
- }
- }
- else//不能转成数字
- {
- qDebug() << "input error";
}
}
}
+
+
diff --git a/App/MissionUI/MissionUI.h b/App/MissionUI/MissionUI.h
index 7a02435..0e4085a 100644
--- a/App/MissionUI/MissionUI.h
+++ b/App/MissionUI/MissionUI.h
@@ -45,6 +45,12 @@ public slots:
void settableGroup(int group);
+ void createFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng);
+ void createFencePolygon(int group,qreal vertex,bool inclusion,QList latlng);
+
+
+
+
protected slots:
void closeEvent(QCloseEvent *event);
void resizeEvent(QResizeEvent *event);
@@ -94,6 +100,13 @@ signals:
void getAllPoints(int group);//读取一下所有的航点
+ void setFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng);
+ void setFencePolygon(int group,qreal vertex,bool inclusion,QList latlng);
+
+
+
+
+
private:
Ui::MissionUI *ui;
diff --git a/App/MissionUI/propertyui.cpp b/App/MissionUI/propertyui.cpp
index 8fb352e..2ddf4a3 100644
--- a/App/MissionUI/propertyui.cpp
+++ b/App/MissionUI/propertyui.cpp
@@ -168,6 +168,20 @@ propertyui::propertyui(QWidget *parent) :
this,&propertyui::getAllPoints);
+ connect(this,&propertyui::createFenceCircle,
+ table,&MissionUI::createFenceCircle);
+
+ connect(this,&propertyui::createFencePolygon,
+ table,&MissionUI::createFencePolygon);
+
+ connect(table,&MissionUI::setFenceCircle,
+ this,&propertyui::setFenceCircle);
+
+ connect(table,&MissionUI::setFencePolygon,
+ this,&propertyui::setFencePolygon);
+
+
+
//初始化参数
setWayPointProperty(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3);
diff --git a/App/MissionUI/propertyui.h b/App/MissionUI/propertyui.h
index 30091c4..2b6ead5 100644
--- a/App/MissionUI/propertyui.h
+++ b/App/MissionUI/propertyui.h
@@ -263,6 +263,12 @@ Q_SIGNALS:
void ruler_clicked();
+ void createFenceCircle(int,qreal radius, bool inclusion, qreal lat, qreal lng);
+ void createFencePolygon(int,qreal vertex,bool inclusion,QList latlng);
+
+ void setFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng);
+ void setFencePolygon(int group,qreal vertex,bool inclusion,QList latlng);
+
private slots:
void GroupChanged(int value);
diff --git a/App/mainwindow.cpp b/App/mainwindow.cpp
index eb1b8f6..efdc478 100644
--- a/App/mainwindow.cpp
+++ b/App/mainwindow.cpp
@@ -426,6 +426,21 @@ MainWindow::MainWindow(QWidget *parent)
connect(map,SIGNAL(settableClicked()),
missionUI,SLOT(on_pushButton_Table_clicked()));
+
+ connect(map,SIGNAL(createFenceCircle(int,qreal,bool,qreal,qreal)),
+ missionUI,SIGNAL(createFenceCircle(int,qreal,bool,qreal,qreal)));
+
+ connect(map,SIGNAL(createFencePolygon(int,qreal,bool,QList)),
+ missionUI,SIGNAL(createFencePolygon(int,qreal,bool,QList)));
+
+
+ connect(missionUI,SIGNAL(setFenceCircle(int,qreal,bool,qreal,qreal)),
+ map,SLOT(setFenceCircle(int,qreal,bool,qreal,qreal)));
+
+ connect(missionUI,SIGNAL(setFencePolygon(int,qreal,bool,QList)),
+ map,SLOT(setFencePolygon(int,qreal,bool,QList)));
+
+
//dlink ----- map
connect(map,SIGNAL(signal_WPDownload(uint8_t,uint8_t,int)),
dlink->mavlinknode->Mission,SLOT(ReadCmd(uint8_t,uint8_t,int)),Qt::DirectConnection);
diff --git a/opmap/MAP_zh_CN.ts b/opmap/MAP_zh_CN.ts
index 6be83b8..c1f7090 100644
--- a/opmap/MAP_zh_CN.ts
+++ b/opmap/MAP_zh_CN.ts
@@ -83,27 +83,27 @@ Please first select the area of the map to rip with <CTRL>+Left mouse clic
-
+
开始上传航点,总数%1
-
+
上传失败%1
-
+
polygons
-
+
circles
-
+
recieve way point group:%1 seq:%2
收到航点:第%1组,第%2点
diff --git a/opmap/mapwidget/geoFencecircle.cpp b/opmap/mapwidget/geoFencecircle.cpp
index 07228ed..2ebc1b4 100644
--- a/opmap/mapwidget/geoFencecircle.cpp
+++ b/opmap/mapwidget/geoFencecircle.cpp
@@ -1,23 +1,27 @@
#include "geoFencecircle.h"
#include
namespace mapcontrol {
-geoFencecircle::geoFencecircle(int g, int count, int index, bool inclusion, geoFenceitem *center, double radius, QBrush color, MapGraphicItem *map, bool dashed, int width) :
+/*
+geoFencecircle::geoFencecircle(int group, bool inclusion, int version, geoFenceitem *center, double radius, QBrush color, MapGraphicItem *map, bool dashed, int width) :
QGraphicsEllipseItem(map),m_center(center), coord(center->coord), m_brush(color), m_map(map),dashed(dashed),lineWidth(width)
+*/
+
+geoFencecircle::geoFencecircle(int group, bool inclusion, int version, internals::PointLatLng const ¢er, double radius, QBrush color, MapGraphicItem *map, bool dashed, int width) :
+ QGraphicsEllipseItem(map),m_center(center), coord(center), m_brush(color), m_map(map),dashed(dashed),lineWidth(width)
+
{
this->setZValue(3);
+ m_version = version;
m_inclusion = inclusion;
m_radius = radius;
- m_group = g; //2
+ m_group = group; //2
m_latitude = coord.Lat();//5
m_longitide = coord.Lng();//6
-
- connect(center, SIGNAL(localPositionChanged(QPointF, geoFenceitem *)), this, SLOT(refreshLocations()));
- connect(center, SIGNAL(aboutToBeDeleted(geoFenceitem *)), this, SLOT(waypointdeleted()));
+ connect(map, SIGNAL(childRefreshPosition()), this, SLOT(refreshLocations()));
refreshLocations();
- connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
}
@@ -50,7 +54,7 @@ void geoFencecircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
}
- painter->translate(-line.length(), -line.length());
+ //painter->translate(-line.length(), -line.length());
if(m_inclusion)
@@ -62,24 +66,29 @@ void geoFencecircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
painter->setBrush(Qt::NoBrush);
}
+ painter->drawPoint(0, 0);
+ //painter->drawEllipse(QPointF(0,0),line.length(),line.length());
+ painter->drawEllipse(rectangle);
- painter->drawEllipse(this->rect());
}
void geoFencecircle::refreshLocations()
{
-
- //qDebug() << my_center->pos();
+ QPointF p(m_map->FromLatLngToLocal(this->coord).X(),
+ m_map->FromLatLngToLocal(this->coord).Y());
internals::PointLatLng C;
- C = m_map->FromLocalToLatLng(m_center->x(),m_center->y());
- C.SetLat(C.Lat() + m_radius/111133.3333f);
+ C = coord;
+ C.SetLat(coord.Lat() + m_radius/111133.3333f);
+ line = QLineF(p.x(),p.y(),p.x(),m_map->FromLatLngToLocal(C).Y());
+ rectangle.setRect(-line.length(),-line.length(), 2 * line.length(), 2 * line.length());
- line = QLineF(m_center->pos().x(),m_center->pos().y(),m_center->pos().x(),m_map->FromLatLngToLocal(C).Y());
- this->setRect(m_center->pos().x(), m_center->pos().y(), 2 * line.length(), 2 * line.length());
- this->update();
+ qDebug() << line << rectangle << C.Lat() << C.Lng() << m_radius;
+
+ setPos(p);
+ update();
}
void geoFencecircle::waypointdeleted()
diff --git a/opmap/mapwidget/geoFencecircle.h b/opmap/mapwidget/geoFencecircle.h
index 48fdfb1..d8faaae 100644
--- a/opmap/mapwidget/geoFencecircle.h
+++ b/opmap/mapwidget/geoFencecircle.h
@@ -21,15 +21,90 @@ class geoFencecircle : public QObject, public QGraphicsEllipseItem {
Q_OBJECT Q_INTERFACES(QGraphicsItem)
public:
enum { Type = UserType + 11 };
- geoFencecircle(int g, int count, int index, bool inclusion, geoFenceitem *center, double radius, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
-
+ //geoFencecircle(int group,bool inclusion, int version, geoFenceitem *center, double radius, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
+ geoFencecircle(int group,bool inclusion, int version, internals::PointLatLng const ¢er, double radius, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
int type() const;
internals::PointLatLng coord;
int number;
+
+
+ int Group(void)
+ {
+ return m_group;
+ }
+
+ void setGroup(int value)
+ {
+ m_group = value;
+ update();
+ }
+
+ bool Inclusion(void)
+ {
+ return m_inclusion;
+ }
+
+ void setInclusion(int value)
+ {
+ m_inclusion = value;
+ update();
+ }
+
+ qreal Radius(void)
+ {
+ return m_radius;
+ }
+
+ void setRadius(qreal value)
+ {
+ m_radius = value;
+ refreshLocations();
+ }
+
+ qreal Latitude(void)
+ {
+ return m_latitude;
+ }
+
+ void setLatitude(qreal value)
+ {
+ m_latitude = value;
+ coord.SetLat(m_latitude);
+ refreshLocations();
+ }
+ qreal Longitude(void)
+ {
+ return m_longitide;
+ }
+
+ void setLongitude(qreal value)
+ {
+ m_longitide = value;
+ coord.SetLng(m_longitide);
+ refreshLocations();
+ }
+
+ void setParameter(int group,qreal radius, bool inclusion, qreal lat, qreal lng)
+ {
+ m_group = group;
+ m_radius = radius;
+ m_inclusion = inclusion;
+
+ m_latitude = lat;
+ coord.SetLat(m_latitude);
+
+ m_longitide = lng;
+ coord.SetLng(m_longitide);
+
+ refreshLocations();
+ }
+
private:
QBrush m_brush;
MapGraphicItem *m_map;
+ int m_version = 0; //2
+
bool m_inclusion = true;
qreal m_radius = 0;//1
int m_group = 0; //2
@@ -38,12 +113,17 @@ private:
QLineF line;
- geoFenceitem *m_center;
+ internals::PointLatLng m_center;
bool dashed;
int lineWidth;
+ QRectF rectangle;
+
+
+
+
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
public slots:
diff --git a/opmap/mapwidget/geoFenceitem.cpp b/opmap/mapwidget/geoFenceitem.cpp
index 64d4377..78f0bc5 100644
--- a/opmap/mapwidget/geoFenceitem.cpp
+++ b/opmap/mapwidget/geoFenceitem.cpp
@@ -1,16 +1,20 @@
#include "geoFenceitem.h"
#include
+#include
+
+
namespace mapcontrol {
-geoFenceitem::geoFenceitem(int g, int count, int index, bool inclusion, internals::PointLatLng const & coord, QBrush color, MapGraphicItem *map, bool dashed, int width) :
- QGraphicsPolygonItem(map), number(index) , coord(coord), m_brush(color), m_map(map), dashed(dashed), lineWidth(width)
+geoFenceitem::geoFenceitem(int group, bool inclusion, int version, internals::PointLatLng const & coord, QBrush color, MapGraphicItem *map, bool dashed, int width) :
+ QGraphicsPolygonItem(map), number(0) , coord(coord), m_brush(color), m_map(map), dashed(dashed), lineWidth(width)
{
this->setZValue(3);
connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos()));
+ m_version = version;
m_inclusion = inclusion;
- m_Vertex = count;//1
- m_group = g; //2
+ //m_Vertex = count;//1
+ m_group = group; //2
m_latitude = coord.Lat();//5
m_longitide = coord.Lng();//6
@@ -47,26 +51,7 @@ void geoFenceitem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
}
painter->drawPoint(0, 0);
-
-/*
- QPolygonF polygon;
- for(internals::PointLatLng p:points)
- {
- QPointF pf;
- pf.setX(m_map->FromLatLngToLocal(p).X());
- pf.setY(m_map->FromLatLngToLocal(p).Y());
- polygon.push_back(pf);
- }
- */
-
-
-
painter->drawPolygon(polygon());
-
-
- qDebug() << polygon();
-
-
}
int geoFenceitem::type() const
@@ -74,6 +59,53 @@ int geoFenceitem::type() const
return Type;
}
+void geoFenceitem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+
+ }
+}
+
+void geoFenceitem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ isDragging = true;
+ }
+ QGraphicsItem::mousePressEvent(event);
+ update();
+}
+void geoFenceitem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ isDragging = false;
+ }
+ QGraphicsItem::mouseReleaseEvent(event);
+ update();
+}
+void geoFenceitem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (isDragging) {
+ //ElevationTrig();
+ emit localPositionChanged(this->pos(), this);
+ }
+ QGraphicsItem::mouseMoveEvent(event);
+ update();
+}
+
+
+void geoFenceitem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event)
+ update();
+}
+
+void geoFenceitem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event)
+ update();
+}
+
+
void geoFenceitem::setPosSLOT()
{
//qDebug() << "virtual set pos";
@@ -93,6 +125,7 @@ void geoFenceitem::setPosSLOT()
setPos(m_map->FromLatLngToLocal(this->coord).X(), m_map->FromLatLngToLocal(this->coord).Y());
emit localPositionChanged(this->pos(),this);
+ update();
}
void geoFenceitem::RefreshPos()
@@ -103,24 +136,8 @@ void geoFenceitem::RefreshPos()
void geoFenceitem::setPoints(QList p)
{
points = p;
-
- //QPolygonF polygon;
- /*
- m_polygon.clear();
- for(internals::PointLatLng LatLng:points)
- {
- QPointF pf;
- pf.setX(m_map->FromLatLngToLocal(LatLng).X());
- pf.setY(m_map->FromLatLngToLocal(LatLng).Y());
-
- m_polygon.append(pf);
- }
- setPolygon(m_polygon);
-
- qDebug() << m_polygon;
- */
-
- update();
+ m_Vertex = p.size();
+ RefreshPos();
}
diff --git a/opmap/mapwidget/geoFenceitem.h b/opmap/mapwidget/geoFenceitem.h
index 520e6b2..e1c46ef 100644
--- a/opmap/mapwidget/geoFenceitem.h
+++ b/opmap/mapwidget/geoFenceitem.h
@@ -20,7 +20,7 @@ class geoFenceitem : public QObject, public QGraphicsPolygonItem {
Q_OBJECT Q_INTERFACES(QGraphicsItem)
public:
enum { Type = UserType + 5 };
- geoFenceitem(int g,int count,int index, bool inclusion,internals::PointLatLng const & coord, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
+ geoFenceitem(int group,bool inclusion,int version,internals::PointLatLng const & coord, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget);
int type() const;
internals::PointLatLng coord;
@@ -31,11 +31,79 @@ public:
void setPoints(QList p);
+ int Group(void)
+ {
+ return m_group;
+ }
+
+ void setGroup(int value)
+ {
+ m_group = value;
+ RefreshPos();
+ }
+
+ bool Inclusion(void)
+ {
+ return m_inclusion;
+ }
+
+ void setInclusion(int value)
+ {
+ m_inclusion = value;
+ RefreshPos();
+ }
+
+ qreal Vertex(void)
+ {
+ return m_Vertex;
+ }
+
+ void setVertex(qreal value)
+ {
+ m_Vertex = value;
+ RefreshPos();
+ }
+
+ qreal Latitude(void)
+ {
+ return m_latitude;
+ }
+
+ void setLatitude(qreal value)
+ {
+ m_latitude = value;
+ coord.SetLat(m_latitude);
+ RefreshPos();
+ }
+ qreal Longitude(void)
+ {
+ return m_longitide;
+ }
+
+ void setLongitude(qreal value)
+ {
+ m_longitide = value;
+ coord.SetLng(m_longitide);
+ RefreshPos();
+ qDebug() << "set logitide";
+ }
+
+protected:
+
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
+ void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+
private:
QBrush m_brush;
MapGraphicItem *m_map;
+ int m_version = 0;//-1
+
bool m_inclusion = true;
qreal m_Vertex = 0;//1
int m_group = 0; //2
@@ -47,6 +115,8 @@ private:
QPolygonF m_polygon;
+ bool isDragging = false;
+
public slots:
void setPosSLOT();
diff --git a/opmap/mapwidget/opmapwidget.cpp b/opmap/mapwidget/opmapwidget.cpp
index 2d2f9b1..f3f4003 100644
--- a/opmap/mapwidget/opmapwidget.cpp
+++ b/opmap/mapwidget/opmapwidget.cpp
@@ -2029,6 +2029,58 @@ void OPMapWidget::WPFollowPrevious(bool flag,WayPointItem *w)
}
+void OPMapWidget::setFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng)
+{
+ //查找对应的组,进行设置
+
+ foreach(QGraphicsItem * i, map->childItems()) {
+ geoFencecircle *w = qgraphicsitem_cast(i);
+ if ((w)&&(w->Group() == group)) {
+
+ /*
+ w->setInclusion(inclusion);
+ w->setRadius(radius);
+ w->setLatitude(lat);
+ w->setLongitude(lng);
+ */
+
+ w->setParameter(group,radius,inclusion,lat,lng);
+
+ qDebug() << "set Circle value" << group << radius << inclusion << lat << lng;
+ }
+ }
+ qDebug() << "set Circle";
+}
+
+void OPMapWidget::setFencePolygon(int group,qreal vertex,bool inclusion,QList latlng)
+{
+ foreach(QGraphicsItem * i, map->childItems()) {
+ geoFenceitem *w = qgraphicsitem_cast(i);
+ if ((w)&&(w->Group() == group)) {
+
+ QList p;
+
+ for(QPointF pf:latlng)
+ {
+ internals::PointLatLng ll;
+
+ ll.SetLat(pf.x());
+ ll.SetLng(pf.y());
+
+ p.push_back(ll);
+ }
+
+ w->setInclusion(inclusion);
+ w->setVertex(vertex);
+ w->setPoints(p);
+ qDebug() << "set Polygon value";
+ }
+ }
+
+ qDebug() << "set Polygon";
+}
+
+
//先清除再读取
void OPMapWidget::WPLoad(QString path)//带文件目录参数
{
@@ -2055,6 +2107,7 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
QJsonObject json = doc.object();
//栅栏解码
+ int fenceCount = 0;
QJsonArray circlesArray = json.value("geoFence").toObject().value("circles").toArray();
for(QJsonValue item: circlesArray) {
@@ -2072,9 +2125,12 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
//生成一个⚪
- geoFenceitem *centeritem = new geoFenceitem(0,1,1, inclusion ,internals::PointLatLng(lat,lng),QColor("#FF8000"),map);
+ //geoFenceitem *centeritem = new geoFenceitem(fenceCount,inclusion,version,internals::PointLatLng(lat,lng),QColor("#FF8000"),map);
- geoFencecircle *c = new geoFencecircle(0,1,1,inclusion,centeritem,radius,QColor("#FF8000"),map);
+ geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,version,internals::PointLatLng(lat,lng),radius,QColor("#FF8000"),map);
+
+
+ emit createFenceCircle(fenceCount++,radius,inclusion,lat,lng);
}
@@ -2083,7 +2139,7 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
//每个item是一个组
QList points;
- QList polyitems;
+ QList latlng;
//获得边界
bool inclusion = item.toObject().value("inclusion").toBool();
QJsonArray polygon = item.toObject().value("polygon").toArray();
@@ -2099,12 +2155,12 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
//生成一个多边形
points.push_back(internals::PointLatLng(lat,lng));
- qDebug() << "polygon" << inclusion << version << lat << lng;
-
-
lat_sum += lat;
lng_sum += lng;
+
+ latlng.push_back(QPointF(lat,lng));
+
}
internals::PointLatLng center;
@@ -2112,51 +2168,11 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
center.SetLat(lat_sum/polygon.size());
center.SetLng(lng_sum/polygon.size());
- geoFenceitem *polyitem = new geoFenceitem(0,points.size(),0, inclusion ,center,QColor("#FF8000"),map);
+ geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,version,center,QColor("#FF8000"),map);
polyitem->setPoints(points);
-
- /*
-
- int count = 0;
- for(internals::PointLatLng p : points)
- {
- geoFenceitem *polyitem = new geoFenceitem(0,points.size(),count, inclusion ,p,QColor("#FF8000"),map);
- count ++;
- polyitems.push_back(polyitem);
-
- }
-
- geoFenceitem *last;
-
- for(geoFenceitem *p : polyitems)
- {
- if(p == polyitems.first())
- {
- last = p;
- }
- else
- {
- if(p == polyitems.last())
- {
- geoFenceitemline *polyline = new geoFenceitemline(last, polyitems.first(),map,QColor("#FF8000"));
- }
- else
- {
- geoFenceitemline *polyline = new geoFenceitemline(last, p,map,QColor("#FF8000"));
- last = p;
- }
- }
-
-
-
-
- }
- */
-
-
-
+ emit createFencePolygon(fenceCount++,points.size(),inclusion,latlng);
}
diff --git a/opmap/mapwidget/opmapwidget.h b/opmap/mapwidget/opmapwidget.h
index 8543b43..9e842df 100644
--- a/opmap/mapwidget/opmapwidget.h
+++ b/opmap/mapwidget/opmapwidget.h
@@ -646,6 +646,10 @@ signals:
+ void createFenceCircle(int group,qreal radius,bool inclusion,qreal lat,qreal lng);
+ void createFencePolygon(int group,qreal vertex,bool inclusion,QList latlng);
+
+
public slots:
void getAllPoints(int group);
@@ -727,6 +731,11 @@ public slots:
void OnSelectionChanged();
void WPShowTip(bool flag);
+
+
+ void setFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng);
+ void setFencePolygon(int group,qreal vertex,bool inclusion,QList latlng);
+
};
}
#endif // OPMAPWIDGET_H