表格完善,测量功能添加

This commit is contained in:
hm
2022-05-07 17:53:54 +08:00
parent b057ad1e57
commit 88a06f464e
10 changed files with 116 additions and 42 deletions
+40 -16
View File
@@ -17,11 +17,6 @@ MissionUI::MissionUI(QWidget *parent) :
this->setStyleSheet(stylesheet);
file.close();
//this->setFocus();
//this->setFocusPolicy(Qt::StrongFocus);
ui->pushButton_load->setFixedSize(80,40);
ui->pushButton_save->setFixedSize(80,40);
ui->pushButton_upload->setFixedSize(80,40);
@@ -67,11 +62,11 @@ MissionUI::MissionUI(QWidget *parent) :
table->setHorizontalHeaderLabels(QStringList() <<tr("number")<<tr("command")<<tr("par1")<<tr("par2")<<tr("par3")<<tr("par4")<<tr("lat")<<tr("lng")<<tr("alt"));
QHeaderView* V_headerView = table->verticalHeader();
V_headerView->setHidden(true); //行名隐藏
V_headerView->setHidden(true); //行名隐藏
QHeaderView* H_headerView = table->horizontalHeader();
H_headerView->setDefaultAlignment(Qt::AlignLeft); //表头信息显示居中靠左
H_headerView->setHighlightSections(false);//高亮选中内容的所在列标题
H_headerView->setDefaultAlignment(Qt::AlignLeft); //表头信息显示居中靠左
H_headerView->setHighlightSections(false); //高亮选中内容的所在列标题
H_headerView->setStretchLastSection(true);
@@ -247,6 +242,8 @@ void MissionUI::setCurrent(int group,int idx)
{
widget->selectRow(idx - 1);
}
//settableGroup(group);//切换会引起变化事件,导致重新刷新
}
void MissionUI::settableGroup(int group)
@@ -342,6 +339,35 @@ void MissionUI::on_pushButton_upload_clicked()
void MissionUI::on_pushButton_download_clicked()
{
QTableWidget *widget;
//根据tabwidget
int tab_idx =ui->tabWidget->currentIndex();
switch (tab_idx) {
case 0:
widget = tablelist.value(1);
break;
case 1:
widget = tablelist.value(3);
break;
case 2:
widget = tablelist.value(4);
break;
case 3:
widget = tablelist.value(5);
break;
case 4:
widget = tablelist.value(6);
break;
default:
break;
}
while (widget->rowCount() > 0) {
widget->removeRow(widget->currentRow());
}
emit WPDownload();
}
@@ -471,19 +497,11 @@ void MissionUI::on_pushButton_clean_clicked()
default:
break;
}
/*
int count = widget->rowCount();
for (int i = 0;i < count;i++) {
widget->removeRow(i);
}
*/
while (widget->rowCount() > 0) {
widget->removeRow(widget->currentRow());
}
emit WPDeleteAll();
}
@@ -577,6 +595,12 @@ void MissionUI::itemDoubleClicked(QTableWidgetItem *item)
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)
{
+14 -1
View File
@@ -2167,9 +2167,22 @@ void propertyui::on_pushButton_Group_clicked()
selector->show();
}
void propertyui::measureState(bool flag)
{
if(flag == true)
{
ui->pushButton_Ruler->setText("Measuring");
}
else
{
ui->pushButton_Ruler->setText("Measure");
}
}
void propertyui::on_pushButton_Ruler_clicked()
{
emit ruler_clicked();
}
void propertyui::on_pushButton_Table_clicked()
+4 -1
View File
@@ -219,7 +219,7 @@ public slots:
void measureState(bool flag);
@@ -260,6 +260,9 @@ Q_SIGNALS:
void getAllPoints(int group);
void ruler_clicked();
private slots:
void GroupChanged(int value);
+1 -1
View File
@@ -662,7 +662,7 @@
</size>
</property>
<property name="text">
<string>Ruler</string>
<string>Measure</string>
</property>
</widget>
</item>
+9 -2
View File
@@ -278,8 +278,6 @@ MainWindow::MainWindow(QWidget *parent)
connect(toolsui->index2,SIGNAL(setMultiple(double)),
dlink->mavlinknode->replay,SLOT(setMultiple(double)),Qt::DirectConnection);
connect(dlink->mavlinknode->replay,SIGNAL(currentPercentage(float)),
toolsui->index2,SLOT(setCurrentPercentage(float)));
@@ -416,6 +414,15 @@ MainWindow::MainWindow(QWidget *parent)
map,SLOT(getAllPoints(int)));
connect(map,SIGNAL(settableGroup(int)),
missionUI,SIGNAL(settableGroup(int)));
connect(missionUI,SIGNAL(ruler_clicked()),
map,SLOT(ruler_clicked()));
connect(map,SIGNAL(measureState(bool)),
missionUI,SLOT(measureState(bool)));
//dlink ----- map
connect(map,SIGNAL(signal_WPDownload(uint8_t,uint8_t,int)),
+14 -3
View File
@@ -1,5 +1,5 @@
#include "mavlinknode.h"
#include "QElapsedTimer"
/*
* mavlink 解析相关内容请参考如下
* https://mavlink.io/en/services/command.html
@@ -18,7 +18,7 @@ MavLinkNode::MavLinkNode(QObject *parent) : ThreadTemplet(parent)
CommucationOverTimer = 1000;
setRunFrq(10);//50
setRunFrq(100);//50
@@ -481,10 +481,18 @@ void MavLinkNode::process()//线程函数
uint8_t count = 0;
QByteArray datagram = nullptr;
bool isIdle = true;
QElapsedTimer time;
time.start();
while (running_flag)
{
time.restart();
count ++;
//QThread::msleep(1000/running_frq);
QThread::msleep(1000/running_frq);
//timer->start();
//解码从UDP来的
@@ -519,6 +527,9 @@ void MavLinkNode::process()//线程函数
{
// QThread::msleep(1000/running_frq);
}
int nsec = time.nsecsElapsed();
//qDebug() << "mavlinknode a loop using time:" << nsec << "ns";
}
}
+7 -1
View File
@@ -1,7 +1,7 @@
#include "dlink.h"
#include <string.h>
#include "QDateTime"
#include "QElapsedTimer"
DLink::DLink(QObject *parent) : QObject(parent)
{
@@ -428,6 +428,8 @@ void DLink::readPendingDatagramsSerialPort(void)
void DLink::readPendingDatagramsClient(void)
{
QElapsedTimer time;
time.start();
//轮番查询
if(Clientsock)
{
@@ -439,6 +441,10 @@ void DLink::readPendingDatagramsClient(void)
emit recieveMessage(SourceType::c_sock,datagram);
}
}
int milsec = time.elapsed();
//qDebug() << "a loop using time:" << milsec << "ms";
}
void DLink::processPendingMulticastDatagrams(void)
+1 -1
View File
@@ -76,7 +76,7 @@ void MeasureLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
}
else
{
myPen.setColor("#ffff00");
myPen.setColor("#FF00FF");
}
painter->setPen(myPen);
+22 -16
View File
@@ -125,11 +125,6 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
connect(waypointsetting,SIGNAL(WPLoad(QString)),
this,SLOT(WPLoad(QString)));
/*
connect(this,SIGNAL(allPoint(QMap<int,int>)),
waypointsetting,SLOT(setallPoint(QMap<int,int>)));
*/
connect(waypointsetting,SIGNAL(searchall()),
this,SLOT(WPsearchall()));
@@ -198,7 +193,12 @@ void OPMapWidget::ruler_clicked(void)
if(isMeasure)
{
isMeasure = false;
this->setCursor(Qt::ArrowCursor);
//this->setCursor(Qt::ArrowCursor);
if(measureline)
{
measureline->hide();
}
}
else
{
@@ -210,9 +210,11 @@ void OPMapWidget::ruler_clicked(void)
measureline->show();
}
QPixmap pix(":/markers/images/ruler.png");
this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
//QPixmap pix(":/markers/images/ruler.png");
//this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
}
emit measureState(isMeasure);
}
void OPMapWidget::table_clicked(void)
@@ -632,8 +634,8 @@ void OPMapWidget::mouseMoveEvent(QMouseEvent *event)
if(isMeasure)
{
QPixmap pix(":/markers/images/ruler.png");
this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
//QPixmap pix(":/markers/images/ruler.png");
//this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
}
@@ -709,8 +711,8 @@ void OPMapWidget::mousePressEvent(QMouseEvent *event)
if(isMeasure)
{
QPixmap pix(":/markers/images/ruler.png");
this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
//QPixmap pix(":/markers/images/ruler.png");
//this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
}
@@ -725,8 +727,8 @@ void OPMapWidget::mouseReleaseEvent(QMouseEvent *event)
if(isMeasure)
{
QPixmap pix(":/markers/images/ruler.png");
this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
//QPixmap pix(":/markers/images/ruler.png");
//this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
}
//qDebug() << "relea";
@@ -738,8 +740,8 @@ void OPMapWidget::mouseDoubleClickEvent(QMouseEvent *event)
if(isMeasure)
{
QPixmap pix(":/markers/images/ruler.png");
this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
//QPixmap pix(":/markers/images/ruler.png");
//this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
}
if(isMeasure)
@@ -2213,6 +2215,8 @@ void OPMapWidget::WPGroup(int value)
{
currentGroup = value;
qDebug() << "group checkout" << value;
//切换当前航线,其他都隐藏,或者高亮当前
@@ -2273,6 +2277,8 @@ void OPMapWidget::WPGroup(int value)
}
}
emit settableGroup(currentGroup);
update();
}
+4
View File
@@ -532,6 +532,7 @@ signals:
//map property
void MapTypes(QStringList list);
void settableGroup(int);
void TotalDistanceUpdate(double);
@@ -631,6 +632,9 @@ signals:
void setCurrent(int seq);
void measureState(bool);
public slots: